From 7f077afaac764a103deb5e5c4098131faac5e01c Mon Sep 17 00:00:00 2001 From: Paul Wolfenbarger Date: Tue, 18 Sep 2018 15:08:30 -0600 Subject: [PATCH 1/2] Removes stk_classic from the Trilinos repository This will close #3444 as stk_classic is not longer supported. --- packages/stk/stk_classic/CMakeLists.txt | 80 - packages/stk/stk_classic/README_stk_trilinos | 19 - .../stk/stk_classic/cmake/Dependencies.cmake | 8 - .../stk_classic/cmake/STKClassic_config.h.in | 11 - .../conversion_scripts/stk_to_stk_classic | 3 - .../conversion_scripts/stk_to_stk_classic.sed | 3 - packages/stk/stk_classic/doc/.gitignore | 2 - packages/stk/stk_classic/doc/Doxyfile | 4 - .../stk_classic/doc/Doxyfile.common.config | 1455 ---- packages/stk/stk_classic/doc/build_docs | 44 - .../stk/stk_classic/stk_adapt/CMakeLists.txt | 9 - .../stk_adapt/regression_tests/CMakeLists.txt | 17 - .../RegressionTestFileLoc.hpp | 8 - .../RegressionTestLocalRefiner.cpp | 992 --- .../regression_tests/RegressionTestMain.cpp | 29 - .../RegressionTestMeshColorer.cpp | 131 - .../RegressionTestNodeRegistry.cpp | 511 -- .../RegressionTestSTKMeshMemory.cpp | 166 - .../RegressionTestUniformRefiner.cpp | 3200 --------- .../stk_adapt/stk_adapt/Allocate.cpp | 94 - .../stk_adapt/stk_adapt/CMakeLists.txt | 60 - .../stk_adapt/stk_adapt/Colorer.cpp | 186 - .../stk_adapt/stk_adapt/Colorer.hpp | 105 - .../stk_adapt/stk_adapt/IAdapter.hpp | 96 - .../stk_adapt/stk_adapt/IEdgeAdapter.hpp | 198 - .../stk_adapt/IEdgeBasedAdapterPredicate.hpp | 45 - .../stk_adapt/stk_adapt/IElementAdapter.hpp | 127 - .../IElementBasedAdapterPredicate.hpp | 81 - .../stk_adapt/stk_adapt/NodeRegistry.cpp | 615 -- .../stk_adapt/stk_adapt/NodeRegistry.hpp | 2451 ------- .../stk_adapt/stk_adapt/NodeRegistryDef.hpp | 58 - .../Percept_MOAB_SimplexTemplateRefiner.cpp | 2193 ------ .../Percept_MOAB_SimplexTemplateRefiner.hpp | 136 - .../stk_adapt/PredicateBasedEdgeAdapter.hpp | 50 - .../PredicateBasedElementAdapter.hpp | 120 - .../stk_adapt/RefinementInfoByType.cpp | 120 - .../stk_adapt/RefinementInfoByType.hpp | 58 - .../stk_adapt/stk_adapt/Refiner.cpp | 3611 ---------- .../stk_adapt/stk_adapt/Refiner.hpp | 389 -- .../RefinerPattern_Line2_Line2_N.hpp | 179 - .../stk_adapt/RefinerPattern_Tet4_Tet4_N.hpp | 626 -- .../stk_adapt/RefinerPattern_Tri3_Tri3_2.hpp | 163 - .../stk_adapt/RefinerPattern_Tri3_Tri3_N.hpp | 426 -- .../stk_adapt/stk_adapt/RefinerUnrefine.cpp | 786 --- .../stk_adapt/stk_adapt/RefinerUtil.cpp | 357 - .../stk_adapt/stk_adapt/RefinerUtil.hpp | 49 - .../stk_adapt/SerializeNodeRegistry.hpp | 1667 ----- .../stk_adapt/stk_adapt/SubDimCell.hpp | 398 -- .../stk_adapt/URP_Heterogeneous_3D.hpp | 154 - .../stk_adapt/URP_Heterogeneous_Enrich_3D.hpp | 149 - .../URP_Heterogeneous_QuadraticRefine_3D.hpp | 134 - .../stk_adapt/stk_adapt/UniformRefiner.cpp | 24 - .../stk_adapt/stk_adapt/UniformRefiner.hpp | 25 - .../stk_adapt/UniformRefinerPattern.cpp | 579 -- .../stk_adapt/UniformRefinerPattern.hpp | 2969 -------- ...ormRefinerPattern_Beam2_Beam2_2_sierra.hpp | 52 - ...ormRefinerPattern_Beam2_Beam3_1_sierra.hpp | 123 - ...ormRefinerPattern_Beam3_Beam3_2_sierra.hpp | 50 - ...ormRefinerPattern_Hex20_Hex20_8_sierra.hpp | 93 - ...ormRefinerPattern_Hex27_Hex27_8_sierra.hpp | 91 - ...formRefinerPattern_Hex8_Hex20_1_sierra.hpp | 83 - ...formRefinerPattern_Hex8_Hex27_1_sierra.hpp | 85 - ...iformRefinerPattern_Hex8_Hex8_8_sierra.hpp | 82 - .../UniformRefinerPattern_Hex8_Tet4_24.hpp | 236 - .../UniformRefinerPattern_Hex8_Tet4_6_12.hpp | 379 -- ...ormRefinerPattern_Line2_Line2_2_sierra.hpp | 181 - ...ormRefinerPattern_Line2_Line3_1_sierra.hpp | 160 - ...ormRefinerPattern_Line3_Line3_2_sierra.hpp | 50 - ...rPattern_Pyramid13_Pyramid13_10_sierra.hpp | 105 - ...nerPattern_Pyramid5_Pyramid13_1_sierra.hpp | 89 - ...nerPattern_Pyramid5_Pyramid5_10_sierra.hpp | 287 - .../UniformRefinerPattern_Quad4_Quad4_4.hpp | 133 - ...ormRefinerPattern_Quad4_Quad4_4_sierra.hpp | 94 - ...ormRefinerPattern_Quad4_Quad8_1_sierra.hpp | 92 - ...ormRefinerPattern_Quad4_Quad9_1_sierra.hpp | 106 - .../UniformRefinerPattern_Quad4_Tri3_2.hpp | 133 - .../UniformRefinerPattern_Quad4_Tri3_4.hpp | 140 - .../UniformRefinerPattern_Quad4_Tri3_6.hpp | 183 - ...ormRefinerPattern_Quad8_Quad8_4_sierra.hpp | 94 - ...ormRefinerPattern_Quad9_Quad9_4_sierra.hpp | 100 - ...Pattern_ShellLine2_ShellLine2_2_sierra.hpp | 182 - ...Pattern_ShellLine2_ShellLine3_1_sierra.hpp | 69 - ...Pattern_ShellLine3_ShellLine3_2_sierra.hpp | 50 - ...Pattern_ShellQuad4_ShellQuad4_4_sierra.hpp | 121 - ...Pattern_ShellQuad4_ShellQuad8_1_sierra.hpp | 117 - ...Pattern_ShellQuad4_ShellQuad9_1_sierra.hpp | 120 - ...Pattern_ShellQuad8_ShellQuad8_4_sierra.hpp | 113 - ...erPattern_ShellTri3_ShellTri3_4_sierra.hpp | 110 - ...erPattern_ShellTri6_ShellTri6_4_sierra.hpp | 113 - ...ormRefinerPattern_Tet10_Tet10_8_sierra.hpp | 92 - ...formRefinerPattern_Tet4_Tet10_1_sierra.hpp | 84 - ...iformRefinerPattern_Tet4_Tet4_8_sierra.hpp | 92 - ...iformRefinerPattern_Tri3_Tri3_4_sierra.hpp | 99 - ...iformRefinerPattern_Tri3_Tri6_1_sierra.hpp | 94 - ...iformRefinerPattern_Tri6_Tri6_4_sierra.hpp | 100 - ...efinerPattern_Wedge15_Wedge15_8_sierra.hpp | 105 - ...efinerPattern_Wedge18_Wedge18_8_sierra.hpp | 104 - ...RefinerPattern_Wedge6_Wedge15_1_sierra.hpp | 89 - ...RefinerPattern_Wedge6_Wedge18_1_sierra.hpp | 88 - ...mRefinerPattern_Wedge6_Wedge6_8_sierra.hpp | 95 - .../stk_adapt/stk_adapt/main/AdaptMain.cpp | 1169 ---- .../stk_adapt/stk_adapt/main/CMakeLists.txt | 31 - .../stk_adapt/main/memory-multipliers.dat | 20 - .../stk_adapt/sierra_element/CMakeLists.txt | 38 - .../stk_adapt/sierra_element/CellTopology.cpp | 486 -- .../stk_adapt/sierra_element/CellTopology.hpp | 128 - .../GeneratedRefinementTable.hpp | 649 -- .../sierra_element/MeshObjTopology.hpp | 47 - .../stk_adapt/sierra_element/Readme.txt | 1 - .../sierra_element/RefinementKey.cpp | 99 - .../sierra_element/RefinementKey.hpp | 79 - .../sierra_element/RefinementTopology.cpp | 846 --- .../sierra_element/RefinementTopology.hpp | 223 - .../sierra_element/StdMeshObjTopologies.cpp | 2854 -------- .../sierra_element/StdMeshObjTopologies.hpp | 53 - .../sierra_element/stk_percept_code_types.hpp | 106 - packages/stk/stk_classic/stk_adapt/todo.txt | 1 - .../stk_adapt/unit_tests/CMakeLists.txt | 13 - .../stk_adapt/unit_tests/TestLocalRefiner.cpp | 166 - .../stk_adapt/unit_tests/TestLocalRefiner.hpp | 39 - .../unit_tests/TestLocalRefinerTet_N_1.hpp | 185 - .../unit_tests/TestLocalRefinerTet_N_2.hpp | 134 - .../unit_tests/TestLocalRefinerTet_N_2_1.hpp | 134 - .../unit_tests/TestLocalRefinerTet_N_3.hpp | 141 - .../unit_tests/TestLocalRefinerTet_N_3_1.cpp | 116 - .../unit_tests/TestLocalRefinerTet_N_3_1.hpp | 35 - .../unit_tests/TestLocalRefinerTet_N_4.hpp | 191 - .../unit_tests/TestLocalRefinerTri.cpp | 88 - .../unit_tests/TestLocalRefinerTri.hpp | 34 - .../unit_tests/TestLocalRefinerTri1.cpp | 95 - .../unit_tests/TestLocalRefinerTri1.hpp | 33 - .../unit_tests/TestLocalRefinerTri2.cpp | 111 - .../unit_tests/TestLocalRefinerTri2.hpp | 34 - .../unit_tests/TestLocalRefinerTri_N.cpp | 162 - .../unit_tests/TestLocalRefinerTri_N.hpp | 35 - .../unit_tests/TestLocalRefinerTri_N_1.cpp | 172 - .../unit_tests/TestLocalRefinerTri_N_1.hpp | 37 - .../unit_tests/TestLocalRefinerTri_N_2.cpp | 167 - .../unit_tests/TestLocalRefinerTri_N_2.hpp | 35 - .../unit_tests/TestLocalRefinerTri_N_3.hpp | 178 - ...calRefinerTri_N_3_EdgeBasedAnisotropic.hpp | 262 - .../TestLocalRefinerTri_N_3_IEdgeAdapter.hpp | 83 - ...estLocalRefinerTri_N_3_IElementAdapter.hpp | 104 - .../TestLocalRefinerTri_N_3_MeshSizeRatio.hpp | 173 - .../unit_tests/UnitTestLocalRefiner.cpp | 2008 ------ .../stk_adapt/unit_tests/UnitTestMain.cpp | 22 - .../unit_tests/UnitTestMeshColorer.cpp | 89 - .../unit_tests/UnitTestNodeRegistry.cpp | 730 -- .../unit_tests/UnitTestSubDimCell.cpp | 255 - .../stk_adapt/unit_tests/UnitTestSupport.cpp | 86 - .../stk_adapt/unit_tests/UnitTestSupport.hpp | 90 - .../unit_tests/UnitTestUniformRefiner.cpp | 3277 --------- .../generated_refinement_tables.hpp | 617 -- .../stk/stk_classic/stk_algsup/CMakeLists.txt | 5 - .../stk/stk_classic/stk_algsup/doc/Doxyfile | 33 - .../stk_classic/stk_algsup/doc/Doxyfile.input | 5 - .../stk_algsup/doc/Doxyfile.options | 81 - .../stk/stk_classic/stk_algsup/doc/index.dox | 73 - .../stk_algsup/AlgorithmRunSimple.hpp | 440 -- .../stk_algsup/stk_algsup/AlgorithmRunner.cpp | 106 - .../stk_algsup/stk_algsup/AlgorithmRunner.hpp | 368 - .../stk_algsup/AlgorithmRunnerTBB.cpp | 212 - .../stk_algsup/AlgorithmRunnerTPI.cpp | 147 - .../stk_algsup/stk_algsup/CMakeLists.txt | 25 - .../stk_algsup/stk_algsup/CudaCall.hpp | 32 - .../stk_algsup/stk_algsup/CudaDeviceMgr.cpp | 64 - .../stk_algsup/stk_algsup/CudaDeviceMgr.hpp | 37 - .../stk_algsup/stk_algsup/CudaMemoryMgr.cpp | 39 - .../stk_algsup/stk_algsup/CudaMemoryMgr.hpp | 188 - .../stk_algsup/unit_tests/CMakeLists.txt | 24 - .../stk_algsup/unit_tests/CudaTestMain.cu | 78 - .../stk_algsup/unit_tests/NoCudaTestMain.cpp | 15 - .../unit_tests/UnitTestAlgorithmRunner.cpp | 122 - .../stk_algsup/unit_tests/UnitTestCudaMgr.cpp | 42 - .../stk_algsup/unit_tests/UnitTestMain.cpp | 16 - .../unit_tests/UnitTest_helpers.cpp | 117 - .../unit_tests/UnitTest_helpers.hpp | 16 - .../stk_classic/stk_expreval/CMakeLists.txt | 6 - .../stk_expreval/stk_expreval/CMakeLists.txt | 49 - .../stk_expreval/stk_expreval/Constants.cpp | 22 - .../stk_expreval/stk_expreval/Constants.hpp | 41 - .../stk_expreval/stk_expreval/Evaluator.cpp | 947 --- .../stk_expreval/stk_expreval/Evaluator.hpp | 286 - .../stk_expreval/stk_expreval/ExprEvalFAD.cpp | 1253 ---- .../stk_expreval/stk_expreval/ExprEvalFAD.hpp | 754 --- .../stk_expreval/stk_expreval/Function.cpp | 504 -- .../stk_expreval/stk_expreval/Function.hpp | 131 - .../stk_expreval/stk_expreval/Lexer.cpp | 240 - .../stk_expreval/stk_expreval/Lexer.hpp | 135 - .../stk_expreval/stk_expreval/Variable.cpp | 15 - .../stk_expreval/stk_expreval/Variable.hpp | 443 -- .../stk_expreval/unit_tests/CMakeLists.txt | 21 - .../unit_tests/UnitTestEvaluator.cpp | 586 -- .../unit_tests/UnitTestEvaluatorFAD.cpp | 321 - .../stk_expreval/unit_tests/UnitTestMain.cpp | 18 - .../stk_expreval/use_cases/CMakeLists.txt | 27 - .../stk_expreval/use_cases/UseCaseMain.cpp | 16 - .../stk_integration_tests/CMakeLists.txt | 3 - .../stk_mesh/CMakeLists.txt | 23 - .../stk_mesh/IntegrationTestMain.cpp | 18 - .../stk/stk_classic/stk_io/CMakeLists.txt | 7 - packages/stk/stk_classic/stk_io/doc/Doxyfile | 1 - .../stk_io/doc/Doxyfile.common.config | 1 - .../stk/stk_classic/stk_io/doc/Doxyfile.input | 18 - packages/stk/stk_classic/stk_io/doc/index.dox | 26 - .../stk_classic/stk_io/stk_io/CMakeLists.txt | 57 - .../stk_classic/stk_io/stk_io/IossBridge.cpp | 1737 ----- .../stk_classic/stk_io/stk_io/IossBridge.hpp | 335 - .../stk_io/stk_io/MeshReadWriteUtils.cpp | 1080 --- .../stk_io/stk_io/MeshReadWriteUtils.hpp | 353 - .../stk_io/stk_io/util/CMakeLists.txt | 48 - .../stk_classic/stk_io/stk_io/util/Gears.cpp | 369 - .../stk_classic/stk_io/stk_io/util/Gears.hpp | 105 - .../stk_io/util/Gmesh_STKmesh_Fixture.cpp | 149 - .../stk_io/util/Gmesh_STKmesh_Fixture.hpp | 144 - .../stk_io/stk_io/util/IO_Fixture.cpp | 201 - .../stk_io/stk_io/util/IO_Fixture.hpp | 134 - .../stk_io/unit_tests/CMakeLists.txt | 30 - .../unit_tests/UnitTestGmeshFixture.cpp | 115 - .../stk_io/unit_tests/UnitTestIOFixture.cpp | 226 - .../stk_io/unit_tests/UnitTestMain.cpp | 16 - .../stk_io/unit_tests/UnitTestTopologyMap.cpp | 216 - .../stk/stk_classic/stk_linsys/CMakeLists.txt | 5 - .../stk/stk_classic/stk_linsys/doc/Doxyfile | 1 - .../stk_linsys/doc/Doxyfile.common.config | 1 - .../stk_classic/stk_linsys/doc/Doxyfile.input | 20 - .../stk/stk_classic/stk_linsys/doc/index.dox | 11 - .../stk_linsys/AggregateLinearSystem.cpp | 199 - .../stk_linsys/AggregateLinearSystem.hpp | 137 - .../stk_linsys/stk_linsys/CMakeLists.txt | 45 - .../stk_linsys/stk_linsys/DofMapper.cpp | 194 - .../stk_linsys/stk_linsys/DofMapper.hpp | 152 - .../stk_linsys/stk_linsys/FeiBaseIncludes.hpp | 22 - .../stk_linsys/stk_linsys/FieldIdMap.hpp | 25 - .../stk_linsys/stk_linsys/ImplDetails.cpp | 91 - .../stk_linsys/stk_linsys/ImplDetails.hpp | 85 - .../stk_linsys/stk_linsys/LinearSystem.cpp | 152 - .../stk_linsys/stk_linsys/LinearSystem.hpp | 110 - .../stk_linsys/LinearSystemInterface.hpp | 80 - .../stk_linsys/stk_linsys/Linsys.dox | 8 - .../stk_linsys/stk_linsys/LinsysFunctions.cpp | 325 - .../stk_linsys/stk_linsys/LinsysFunctions.hpp | 115 - .../stk_linsys/unit_tests/CMakeLists.txt | 31 - .../unit_tests/UnitTestDofMapper.cpp | 121 - .../stk_linsys/unit_tests/UnitTestImpl.cpp | 116 - .../unit_tests/UnitTestLinearSystem.cpp | 342 - .../unit_tests/UnitTestLinsysFunctions.cpp | 412 -- .../stk_linsys/unit_tests/UnitTestMain.cpp | 19 - .../unit_tests/UnitTest_helpers.cpp | 272 - .../unit_tests/UnitTest_helpers.hpp | 26 - .../stk/stk_classic/stk_mesh/CMakeLists.txt | 12 - .../stk/stk_classic/stk_mesh/doc/Doxyfile | 1 - .../stk_mesh/doc/Doxyfile.common.config | 1 - .../stk_classic/stk_mesh/doc/Doxyfile.input | 20 - .../stk/stk_classic/stk_mesh/doc/index.dox | 263 - .../stk_mesh/stk_mesh/CMakeLists.txt | 7 - .../stk_mesh/stk_mesh/base/Bucket.cpp | 289 - .../stk_mesh/stk_mesh/base/Bucket.hpp | 299 - .../stk_mesh/stk_mesh/base/BulkData.cpp | 836 --- .../stk_mesh/stk_mesh/base/BulkData.hpp | 725 -- .../stk_mesh/base/BulkDataEndSync.cpp | 1117 --- .../stk_mesh/base/BulkDataGhosting.cpp | 718 -- .../stk_mesh/stk_mesh/base/BulkDataOwner.cpp | 538 -- .../stk_mesh/base/BulkDataParallel.dox | 41 - .../stk_mesh/base/BulkDataParallelVerify.cpp | 548 -- .../stk_mesh/base/BulkDataRelation.cpp | 450 -- .../stk_mesh/base/BulkModification.cpp | 180 - .../stk_mesh/base/BulkModification.hpp | 36 - .../stk_mesh/stk_mesh/base/CMakeLists.txt | 60 - .../stk_mesh/stk_mesh/base/Comm.cpp | 69 - .../stk_mesh/stk_mesh/base/Comm.hpp | 42 - .../stk_mesh/stk_mesh/base/DataTraits.cpp | 456 -- .../stk_mesh/stk_mesh/base/DataTraits.hpp | 171 - .../stk_mesh/base/DataTraitsClass.hpp | 212 - .../stk_mesh/stk_mesh/base/DataTraitsEnum.hpp | 177 - .../stk_mesh/stk_mesh/base/DiagWriter.cpp | 161 - .../stk_mesh/stk_mesh/base/DiagWriter.hpp | 79 - .../stk_mesh/stk_mesh/base/DiagWriter_fwd.hpp | 28 - .../stk_mesh/stk_mesh/base/Entity.cpp | 281 - .../stk_mesh/stk_mesh/base/Entity.hpp | 589 -- .../stk_mesh/stk_mesh/base/EntityComm.cpp | 284 - .../stk_mesh/stk_mesh/base/EntityComm.hpp | 239 - .../stk_mesh/stk_mesh/base/EntityKey.cpp | 39 - .../stk_mesh/stk_mesh/base/EntityKey.hpp | 193 - .../stk_mesh/stk_mesh/base/Field.hpp | 142 - .../stk_mesh/stk_mesh/base/FieldBase.cpp | 57 - .../stk_mesh/stk_mesh/base/FieldBase.hpp | 200 - .../stk_mesh/stk_mesh/base/FieldData.cpp | 30 - .../stk_mesh/stk_mesh/base/FieldData.dox | 62 - .../stk_mesh/stk_mesh/base/FieldData.hpp | 321 - .../stk_mesh/stk_mesh/base/FieldParallel.cpp | 332 - .../stk_mesh/stk_mesh/base/FieldParallel.hpp | 197 - .../stk_mesh/stk_mesh/base/FieldRelation.hpp | 107 - .../stk_mesh/base/FieldRestriction.cpp | 45 - .../stk_mesh/base/FieldRestriction.hpp | 140 - .../stk_mesh/stk_mesh/base/FieldState.hpp | 56 - .../stk_mesh/stk_mesh/base/FieldTraits.hpp | 109 - .../stk_mesh/base/FindRestriction.hpp | 107 - .../stk_mesh/stk_mesh/base/GetBuckets.cpp | 113 - .../stk_mesh/stk_mesh/base/GetBuckets.hpp | 85 - .../stk_mesh/stk_mesh/base/GetEntities.cpp | 141 - .../stk_mesh/stk_mesh/base/GetEntities.hpp | 74 - .../stk_mesh/stk_mesh/base/Ghosting.cpp | 99 - .../stk_mesh/stk_mesh/base/Ghosting.hpp | 90 - .../stk_mesh/stk_mesh/base/Iterators.cpp | 91 - .../stk_mesh/stk_mesh/base/Iterators.hpp | 324 - .../stk_mesh/stk_mesh/base/MemoryUsage.cpp | 144 - .../stk_mesh/stk_mesh/base/MemoryUsage.hpp | 53 - .../stk_mesh/stk_mesh/base/Mesh.dox | 196 - .../stk_mesh/stk_mesh/base/MetaData.cpp | 538 -- .../stk_mesh/stk_mesh/base/MetaData.hpp | 1026 --- .../stk_mesh/stk_mesh/base/Part.cpp | 205 - .../stk_mesh/stk_mesh/base/Part.hpp | 249 - .../stk_mesh/stk_mesh/base/PartRelation.hpp | 71 - .../stk_mesh/stk_mesh/base/Property.cpp | 64 - .../stk_mesh/stk_mesh/base/Property.hpp | 74 - .../stk_mesh/stk_mesh/base/PropertyBase.hpp | 212 - .../stk_mesh/stk_mesh/base/Relation.cpp | 310 - .../stk_mesh/stk_mesh/base/Relation.dox | 128 - .../stk_mesh/stk_mesh/base/Relation.hpp | 387 -- .../stk_mesh/stk_mesh/base/Selector.cpp | 308 - .../stk_mesh/stk_mesh/base/Selector.hpp | 297 - .../stk_mesh/stk_mesh/base/SetOwners.hpp | 69 - .../stk_mesh/stk_mesh/base/Trace.cpp | 38 - .../stk_mesh/stk_mesh/base/Trace.hpp | 167 - .../stk_mesh/stk_mesh/base/Types.hpp | 170 - .../stk_mesh/stk_mesh/baseImpl/BucketImpl.cpp | 287 - .../stk_mesh/stk_mesh/baseImpl/BucketImpl.hpp | 170 - .../stk_mesh/baseImpl/BucketRepository.cpp | 580 -- .../stk_mesh/baseImpl/BucketRepository.hpp | 128 - .../stk_mesh/stk_mesh/baseImpl/EntityImpl.cpp | 266 - .../stk_mesh/stk_mesh/baseImpl/EntityImpl.hpp | 231 - .../stk_mesh/baseImpl/EntityRepository.cpp | 361 - .../stk_mesh/baseImpl/EntityRepository.hpp | 174 - .../stk_mesh/baseImpl/FieldBaseImpl.cpp | 498 -- .../stk_mesh/baseImpl/FieldBaseImpl.hpp | 174 - .../stk_mesh/baseImpl/FieldRepository.cpp | 225 - .../stk_mesh/baseImpl/FieldRepository.hpp | 113 - .../stk_mesh/stk_mesh/baseImpl/PartImpl.cpp | 106 - .../stk_mesh/stk_mesh/baseImpl/PartImpl.hpp | 150 - .../stk_mesh/baseImpl/PartRepository.cpp | 323 - .../stk_mesh/baseImpl/PartRepository.hpp | 89 - .../stk_mesh/stk_mesh/diag/EntityKey.hpp | 27 - .../stk_mesh/fem/BoundaryAnalysis.cpp | 224 - .../stk_mesh/fem/BoundaryAnalysis.hpp | 57 - .../stk_mesh/stk_mesh/fem/CMakeLists.txt | 52 - .../stk_mesh/stk_mesh/fem/CellTopology.hpp | 40 - .../stk_mesh/fem/CoordinateSystems.cpp | 405 -- .../stk_mesh/fem/CoordinateSystems.hpp | 317 - .../stk_mesh/fem/CreateAdjacentEntities.cpp | 494 -- .../stk_mesh/fem/CreateAdjacentEntities.hpp | 39 - .../stk_mesh/stk_mesh/fem/FEMHelpers.cpp | 446 -- .../stk_mesh/stk_mesh/fem/FEMHelpers.hpp | 242 - .../stk_mesh/stk_mesh/fem/FEMMetaData.cpp | 460 -- .../stk_mesh/stk_mesh/fem/FEMMetaData.hpp | 556 -- .../stk_mesh/stk_mesh/fem/SkinMesh.cpp | 519 -- .../stk_mesh/stk_mesh/fem/SkinMesh.hpp | 42 - .../stk_mesh/stk_mesh/fem/Stencils.cpp | 59 - .../stk_mesh/stk_mesh/fem/Stencils.hpp | 48 - .../stk_mesh/fem/TopologyDimensions.cpp | 38 - .../stk_mesh/fem/TopologyDimensions.hpp | 155 - .../stk_mesh/stk_mesh/fixtures/BoxFixture.cpp | 157 - .../stk_mesh/stk_mesh/fixtures/BoxFixture.hpp | 84 - .../stk_mesh/stk_mesh/fixtures/CMakeLists.txt | 57 - .../stk_mesh/stk_mesh/fixtures/Gear.cpp | 326 - .../stk_mesh/stk_mesh/fixtures/Gear.hpp | 164 - .../stk_mesh/fixtures/GearsFixture.cpp | 332 - .../stk_mesh/fixtures/GearsFixture.hpp | 119 - .../stk_mesh/fixtures/GridFixture.cpp | 115 - .../stk_mesh/fixtures/GridFixture.hpp | 50 - .../stk_mesh/stk_mesh/fixtures/HexFixture.cpp | 173 - .../stk_mesh/stk_mesh/fixtures/HexFixture.hpp | 123 - .../stk_mesh/fixtures/QuadFixture.cpp | 163 - .../stk_mesh/fixtures/QuadFixture.hpp | 118 - .../stk_mesh/stk_mesh/fixtures/README | 49 - .../stk_mesh/fixtures/RingFixture.cpp | 121 - .../stk_mesh/fixtures/RingFixture.hpp | 75 - .../stk_mesh/fixtures/SelectorFixture.cpp | 132 - .../stk_mesh/fixtures/SelectorFixture.hpp | 99 - .../stk_mesh/unit_tests/CMakeLists.txt | 24 - .../unit_tests/UnitTestBoundaryAnalysis.cpp | 271 - .../unit_tests/UnitTestBoxFixture.cpp | 209 - .../stk_mesh/unit_tests/UnitTestBucket.cpp | 450 -- .../stk_mesh/unit_tests/UnitTestBulkData.cpp | 1459 ---- .../unit_tests/UnitTestBulkDataAdapt.cpp | 232 - .../UnitTestBulkData_ChangeParts.cpp | 482 -- .../unit_tests/UnitTestBulkData_Destroy.cpp | 308 - .../unit_tests/UnitTestBulkData_new.cpp | 1112 --- .../unit_tests/UnitTestBulkModification.cpp | 371 - .../unit_tests/UnitTestChangeEntityId.cpp | 90 - .../stk_mesh/unit_tests/UnitTestCrackMesh.cpp | 158 - .../UnitTestCreateAdjacentEntities.cpp | 213 - .../unit_tests/UnitTestDataTraits.cpp | 581 -- .../unit_tests/UnitTestDeclareElement.cpp | 73 - .../stk_mesh/unit_tests/UnitTestEntity.cpp | 196 - .../unit_tests/UnitTestFEMMetaData.cpp | 585 -- .../stk_mesh/unit_tests/UnitTestField.cpp | 442 -- .../unit_tests/UnitTestFieldDataInitVal.cpp | 247 - .../stk_mesh/unit_tests/UnitTestFieldImpl.cpp | 484 -- .../unit_tests/UnitTestFieldRestriction.cpp | 183 - .../UnitTestGenerateNewEntities.cpp | 67 - .../unit_tests/UnitTestGetBuckets.cpp | 260 - .../unit_tests/UnitTestGridFixture.cpp | 100 - .../unit_tests/UnitTestHexFixture.cpp | 418 -- .../unit_tests/UnitTestInducedPart.cpp | 136 - .../stk_mesh/unit_tests/UnitTestMain.cpp | 18 - .../stk_mesh/unit_tests/UnitTestMetaData.cpp | 249 - .../UnitTestModificationEndWrapper.cpp | 22 - .../UnitTestModificationEndWrapper.hpp | 35 - .../stk_mesh/unit_tests/UnitTestPart.cpp | 388 -- .../unit_tests/UnitTestPartRepository.cpp | 186 - .../stk_mesh/unit_tests/UnitTestProperty.cpp | 127 - .../stk_mesh/unit_tests/UnitTestRelation.cpp | 448 -- .../unit_tests/UnitTestRingFixture.cpp | 242 - .../unit_tests/UnitTestRingFixture.hpp | 28 - .../stk_mesh/unit_tests/UnitTestSelector.cpp | 973 --- .../unit_tests/UnitTestSkinIrregular.cpp | 670 -- .../stk_mesh/unit_tests/UnitTestSkinning.cpp | 265 - .../stk_mesh/unit_tests/UnitTestTemplate.cpp | 24 - .../stk_mesh/unit_tests/UnitTestTopology.cpp | 375 -- .../stk_mesh/unit_tests/UnitTestTrace.cpp | 155 - .../unit_tests/UnitTestTransactionLog.cpp | 675 -- .../stk_mesh/use_cases/CMakeLists.txt | 30 - .../stk/stk_classic/stk_mesh/use_cases/README | 104 - .../stk_mesh/use_cases/UseCaseMain.cpp | 163 - .../stk_mesh/use_cases/UseCase_1.cpp | 46 - .../stk_mesh/use_cases/UseCase_1.hpp | 45 - .../stk_mesh/use_cases/UseCase_2.cpp | 608 -- .../stk_mesh/use_cases/UseCase_2.hpp | 108 - .../stk_mesh/use_cases/UseCase_3.cpp | 268 - .../stk_mesh/use_cases/UseCase_3.hpp | 75 - .../stk_mesh/use_cases/UseCase_4.cpp | 546 -- .../stk_mesh/use_cases/UseCase_4.hpp | 104 - .../use_cases/UseCase_ChangeOwner.cpp | 605 -- .../use_cases/UseCase_ChangeOwner.hpp | 58 - .../stk_mesh/use_cases/UseCase_Common.cpp | 142 - .../stk_mesh/use_cases/UseCase_Common.hpp | 58 - .../use_cases/UseCase_ElementDeath.hpp | 16 - .../use_cases/UseCase_ElementDeath_1.cpp | 374 - ...Case_ElementDeath_1_validation_helpers.cpp | 637 -- ...Case_ElementDeath_1_validation_helpers.hpp | 45 - .../stk_mesh/use_cases/UseCase_Skinning.cpp | 248 - .../stk_mesh/use_cases/UseCase_Skinning.hpp | 33 - .../stk_mesh/use_cases/UseCase_Skinning_1.cpp | 158 - .../use_cases/UseCase_Skinning_1b.cpp | 147 - .../stk_mesh/use_cases/UseCase_Skinning_2.cpp | 170 - .../stk_mesh/use_cases/centroid_algorithm.hpp | 212 - .../stk_classic/stk_percept/CMakeLists.txt | 10 - .../stk_classic/stk_percept/build/.gitignore | 1 - .../stk/stk_classic/stk_percept/build/README | 24 - .../stk_percept/build/build-pydoc.sh | 32 - .../stk_percept/build/install-pydoc.sh | 8 - .../build/sample-Trilinos-configure-script | 95 - .../stk/stk_classic/stk_percept/doc/Doxyfile | 39 - .../stk_percept/doc/Doxyfile.input | 12 - .../stk_percept/doc/Doxyfile.options | 96 - .../stk_percept/doc/PerceptMesh.html | 5999 ----------------- .../stk_classic/stk_percept/doc/dot/dg.dot | 15 - .../stk_classic/stk_percept/doc/dot/dot.old | 3 - .../stk_classic/stk_percept/doc/dot/hex.1.dot | 33 - .../stk_classic/stk_percept/doc/dot/hex.2.dot | 33 - .../stk_classic/stk_percept/doc/dot/hex.dot | 33 - .../stk_classic/stk_percept/doc/dot/hex.pdf | Bin 14575 -> 0 bytes .../stk/stk_classic/stk_percept/doc/dot/j.pdf | Bin 12788 -> 0 bytes .../stk_percept/doc/dot/quad.1.dot | 37 - .../stk_classic/stk_percept/doc/dot/quad.dot | 16 - .../stk_classic/stk_percept/doc/dot/quad.pdf | Bin 9664 -> 0 bytes .../stk_classic/stk_percept/doc/dot/run-quad | 2 - .../stk_classic/stk_percept/doc/dot/tet.dot | 23 - .../stk_classic/stk_percept/doc/dot/tet.pdf | Bin 11249 -> 0 bytes .../stk_classic/stk_percept/doc/dot/tri.dot | 19 - .../stk_classic/stk_percept/doc/dot/tri.pdf | Bin 9592 -> 0 bytes .../stk/stk_classic/stk_percept/doc/index.dox | 1 - .../stk_classic/stk_percept/dox/dot/run-it | 2 - .../regression_tests/RegressionTestMain.cpp | 29 - ...RegressionTestPerceptMeshFieldFunction.cpp | 312 - .../stk_percept/stk_percept/CMakeLists.txt | 72 - .../stk_percept/stk_percept/Edge.hpp | 39 - .../stk_percept/ExceptionWatch.hpp | 44 - .../stk_percept/GeometryVerifier.cpp | 511 -- .../stk_percept/GeometryVerifier.hpp | 45 - .../Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp | 157 - ...trepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp | 434 -- ...Intrepid_HGRAD_QUAD_C2_Serendipity_FEM.hpp | 124 - ...repid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp | 390 -- ...ntrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp | 137 - ...epid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp | 1230 ---- .../stk_percept/stk_percept/MeshUtil.cpp | 265 - .../stk_percept/stk_percept/MeshUtil.hpp | 61 - .../stk_percept/stk_percept/Name.hpp | 27 - .../stk_percept/stk_percept/NoMallocArray.hpp | 192 - .../stk_percept/stk_percept/Observable.hpp | 85 - .../stk_percept/stk_percept/OptionMask.hpp | 215 - .../stk_percept/stk_percept/ParallelUtil.hpp | 38 - .../stk_percept/ParallelUtilDef.hpp | 183 - .../stk_percept/stk_percept/Percept.hpp | 99 - .../stk_percept/PerceptBoostArray.hpp | 7 - .../stk_percept/stk_percept/PerceptMesh.cpp | 4471 ------------ .../stk_percept/stk_percept/PerceptMesh.hpp | 831 --- .../stk_percept/PerceptMeshReadWrite.hpp | 169 - .../stk_percept/stk_percept/ProgressMeter.cpp | 51 - .../stk_percept/stk_percept/ProgressMeter.hpp | 47 - .../stk_percept/RunEnvironment.cpp | 830 --- .../stk_percept/RunEnvironment.hpp | 192 - .../stk_percept/SameRankRelation.hpp | 40 - .../stk_percept/ShardsInterfaceTable.cpp | 101 - .../stk_percept/ShardsInterfaceTable.hpp | 116 - .../stk_percept/TopologyVerifier.cpp | 220 - .../stk_percept/TopologyVerifier.hpp | 41 - .../stk_percept/stk_percept/Util.cpp | 452 -- .../stk_percept/stk_percept/Util.hpp | 319 - .../stk_percept/fixtures/BeamFixture.cpp | 144 - .../stk_percept/fixtures/BeamFixture.hpp | 86 - .../stk_percept/fixtures/CMakeLists.txt | 39 - .../stk_percept/fixtures/Fixture.cpp | 19 - .../stk_percept/fixtures/Fixture.hpp | 72 - .../fixtures/HeterogeneousFixture.cpp | 372 - .../fixtures/HeterogeneousFixture.hpp | 94 - .../stk_percept/fixtures/PyramidFixture.cpp | 275 - .../stk_percept/fixtures/PyramidFixture.hpp | 87 - .../stk_percept/fixtures/QuadFixture.hpp | 473 -- .../stk_percept/fixtures/SingleTetFixture.cpp | 129 - .../stk_percept/fixtures/SingleTetFixture.hpp | 91 - .../stk_percept/fixtures/WedgeFixture.hpp | 219 - .../stk_percept/stk_percept/foo.cpp | 12 - .../stk_percept/function/BucketOp.hpp | 28 - .../stk_percept/function/CMakeLists.txt | 41 - .../function/CompositeFunction.hpp | 79 - .../stk_percept/function/ConstantFunction.hpp | 78 - .../stk_percept/function/ElementOp.hpp | 29 - .../stk_percept/function/FieldFunction.cpp | 293 - .../stk_percept/function/FieldFunction.hpp | 358 - .../stk_percept/function/Function.cpp | 245 - .../stk_percept/function/Function.hpp | 245 - .../stk_percept/function/FunctionOperator.cpp | 65 - .../stk_percept/function/FunctionOperator.hpp | 94 - .../stk_percept/function/MDArray.hpp | 149 - .../function/MultipleFieldFunction.hpp | 77 - .../stk_percept/function/PartOp.hpp | 29 - .../stk_percept/function/StringFunction.cpp | 533 -- .../stk_percept/function/StringFunction.hpp | 112 - .../stk_percept/function/StringFunction.i | 10 - .../stk_percept/function/StringFunction.py | 69 - .../function/StringFunction_wrap.cxx | 4760 ------------- .../function/internal/BuildBoundingBoxes.hpp | 150 - .../internal/BuildBoundingBoxesDef.hpp | 101 - .../function/internal/CMakeLists.txt | 40 - .../function/internal/ComputeBases.hpp | 125 - .../function/internal/ComputeFieldValues.hpp | 122 - .../function/internal/Dimensions.cpp | 21 - .../function/internal/Dimensions.hpp | 38 - .../internal/FunctionWithIntrepidRequest.hpp | 246 - .../function/internal/GenericFunction.cpp | 14 - .../function/internal/GenericFunction.hpp | 65 - .../function/internal/GenericFunction.i | 10 - .../function/internal/HasValue.hpp | 28 - .../function/internal/IntegratedOp.hpp | 530 -- .../function/internal/IsInElement.cpp | 123 - .../function/internal/IsInElement.hpp | 60 - .../function/internal/STKSearcher.hpp | 74 - .../function/internal/STKSearcherDef.hpp | 123 - .../function/internal/Searcher.hpp | 33 - .../function/internal/SimpleSearcher.cpp | 71 - .../function/internal/SimpleSearcher.hpp | 52 - .../stk_percept/function/internal/swig.make | 1 - .../stk_percept/function/jj.swig.make | 1 - .../stk_percept/math/CMakeLists.txt | 39 - .../stk_percept/stk_percept/math/Math.hpp | 135 - .../stk_percept/mesh/CMakeLists.txt | 3 - .../stk_percept/mesh/diff/MeshDifference.cpp | 87 - .../stk_percept/mesh/diff/MeshDifference.hpp | 37 - .../mesh/diff/MeshDifferenceMain.cpp | 18 - .../stk_percept/mesh/gen/CMakeLists.txt | 39 - .../stk_percept/mesh/gen/SweepMesher.cpp | 647 -- .../stk_percept/mesh/gen/SweepMesher.hpp | 600 -- .../stk_percept/mesh/gen/TransformPath.hpp | 122 - .../mesh/geometry/kernel/GeometryFactory.cpp | 47 - .../mesh/geometry/kernel/GeometryFactory.hpp | 25 - .../mesh/geometry/kernel/GeometryKernel.hpp | 34 - .../kernel/GeometryKernelOpenNURBS.cpp | 174 - .../kernel/GeometryKernelOpenNURBS.hpp | 33 - .../geometry/kernel/GeometryKernelStupid.hpp | 56 - .../mesh/geometry/kernel/MeshGeometry.cpp | 602 -- .../mesh/geometry/kernel/MeshGeometry.hpp | 107 - .../mod/mesquite-interface/JacobianUtil.cpp | 239 - .../mod/mesquite-interface/JacobianUtil.hpp | 57 - .../mesquite-interface/PMMLaplaceSmoother.hpp | 99 - .../PMMLaplaceSmoother1.cpp | 102 - .../PMMLaplaceSmoother1.hpp | 85 - .../mod/mesquite-interface/PMMMsqMatrix.hpp | 134 - .../PMMParallelReferenceMeshSmoother.cpp | 258 - .../PMMParallelReferenceMeshSmoother.hpp | 117 - .../PMMParallelReferenceMeshSmoother1.cpp | 1321 ---- .../PMMParallelReferenceMeshSmoother1.hpp | 67 - .../PMMParallelReferenceMeshSmoother2.cpp | 275 - .../PMMParallelReferenceMeshSmoother2.hpp | 50 - .../PMMParallelReferenceMeshSmoother3.cpp | 257 - .../PMMParallelReferenceMeshSmoother3.hpp | 49 - .../PMMParallelShapeImprover.cpp | 344 - .../PMMParallelShapeImprover.hpp | 140 - .../mesquite-interface/PMMShapeImprover.cpp | 323 - .../mesquite-interface/PMMShapeImprover.hpp | 136 - .../PMMShapeSizeOrientImprover.cpp | 118 - .../PMMShapeSizeOrientImprover.hpp | 100 - .../mesquite-interface/PMMSmootherMetric.hpp | 394 -- .../PerceptMesquiteMesh.cpp | 1379 ---- .../PerceptMesquiteMesh.hpp | 349 - .../PerceptMesquiteMeshDomain.cpp | 317 - .../PerceptMesquiteMeshDomain.hpp | 144 - .../mesquite-interface/SpacingFieldUtil.cpp | 142 - .../mesquite-interface/SpacingFieldUtil.hpp | 40 - .../stk_percept/norm/CMakeLists.txt | 39 - .../stk_percept/stk_percept/norm/H1Norm.hpp | 168 - .../stk_percept/norm/IntrepidManager.cpp | 693 -- .../stk_percept/norm/IntrepidManager.hpp | 660 -- .../stk_percept/stk_percept/norm/Norm.hpp | 325 - .../parse-sierra-log-timings-example.py | 220 - .../stk_percept/stk_percept/percept | 256 - .../stk_percept/percept.streaming.proto.1.py | 328 - .../stk_percept/percept.streaming.proto.2.py | 385 -- .../stk_percept/percept.streaming.proto.3.py | 356 - .../stk_percept/percept.streaming.proto.4.py | 387 -- .../stk_percept/percept.streaming.proto.py | 283 - .../stk_percept/stk_percept/pyencore.h | 2 - .../stk_percept/stk_percept/stk_mesh.hpp | 8 - .../stk_percept/util/CMakeLists.txt | 39 - .../stk_percept/util/GeneralFunction.hpp | 129 - .../stk_percept/verifier/mesh/Verifier.cpp | 105 - .../stk_percept/verifier/mesh/Verifier.hpp | 76 - .../stk_percept/verifier/mesh/main1.cpp | 35 - .../stk_percept/unit_tests/CMakeLists.txt | 25 - .../stk_percept/unit_tests/Documentation.hpp | 149 - .../stk_percept/unit_tests/Example2.py | 83 - .../unit_tests/FieldFunctionUnitTests.py | 356 - .../stk_percept/unit_tests/NormUnitTests.py | 266 - .../unit_tests/PerceptMeshUnitTests.py | 270 - .../unit_tests/StringFunctionUnitTests.py | 501 -- .../unit_tests/UniformRefinerUnitTests.py | 916 --- .../unit_tests/UnitTestFieldFunction.cpp | 673 -- .../unit_tests/UnitTestGeometryVerifier.cpp | 88 - .../stk_percept/unit_tests/UnitTestMain.cpp | 21 - .../stk_percept/unit_tests/UnitTestNorm.cpp | 1038 --- .../unit_tests/UnitTestPerceptMesh.cpp | 504 -- .../UnitTestPerceptMesquiteMesh.cpp | 1350 ---- .../stk_percept/unit_tests/UnitTestSearch.cpp | 108 - .../unit_tests/UnitTestStringFunction.cpp | 703 -- .../unit_tests/UnitTestTimeMaps.cpp | 256 - .../unit_tests/UnitTestTopoCheck.cpp | 761 --- .../unit_tests/UnitTestUtilities.cpp | 1043 --- .../stk_percept/unit_tests/UseCases.py | 94 - .../boost_python_getting_started1.cref | 34 - .../stk_percept/unit_tests/cube_hex8.e | Bin 3580 -> 0 bytes .../stk_percept/unit_tests/cube_hex8.e.out | Bin 4704 -> 0 bytes .../stk_percept/unit_tests/cube_hex8_8_out.e | Bin 7192 -> 0 bytes .../stk_percept/unit_tests/example.cpp | 33 - .../stk_percept/unit_tests/example.hpp | 39 - .../stk_percept/unit_tests/example.i | 10 - .../stk_percept/unit_tests/example.py | 118 - .../stk_percept/unit_tests/example_wrap.cpp | 4128 ------------ .../unit_tests/exodus_files/beam.e | Bin 2188 -> 0 bytes .../unit_tests/exodus_files/hex_fixture.e | Bin 7508 -> 0 bytes .../exodus_files/input_files_hex_fixture.e | Bin 7428 -> 0 bytes .../exodus_files/input_files_tet_fixture.e | Bin 56916 -> 0 bytes .../unit_tests/exodus_files/quad_fixture.e | Bin 9052 -> 0 bytes .../exodus_files/quad_fixture_no_sidesets.e | Bin 7888 -> 0 bytes .../exodus_files/quad_fixture_readwrite.e | Bin 9052 -> 0 bytes .../quad_fixture_with_coords_mag.e | Bin 10568 -> 0 bytes .../unit_tests/exodus_files/tet-mesh.e | Bin 2564 -> 0 bytes .../exodus_files/tet_from_hex_fixture_0.e | Bin 56872 -> 0 bytes .../stk_percept/unit_tests/mainsh.cpp | 453 -- .../unit_tests/pgi_compile/testpgi.cpp | 41 - .../unit_tests/pgi_compile/testpgi1.cpp | 75 - .../stk_percept/unit_tests/print_table.py | 69 - .../stk_percept/unit_tests/run-py-unit | 7 - .../stk_percept/unit_tests/runme_example.py | 51 - .../unit_tests/sun_compile/main-sun.cpp | 37 - .../unit_tests/transient_example/README | 9 - .../transient_example/code_verify.debug.py | 120 - .../transient_example/code_verify.py | 105 - .../unit_tests/transient_example/mms_user.C | 66 - .../transient_example/output1.gold.e | Bin 19748 -> 0 bytes .../transient_example/output2.gold.e | Bin 40884 -> 0 bytes .../transient_example/output3.gold.e | Bin 115700 -> 0 bytes .../transient_example/output4.gold.e | Bin 403572 -> 0 bytes .../stk_percept/unit_tests/unitTest1.py | 21 - .../stk_percept/unit_tests/unitTest2.py | 28 - .../stk_percept/unit_tests/unitTest_h1Norm.py | 22 - .../unit_tests/unitTest_h1Norm_1.py | 36 - .../stk_performance_tests/CMakeLists.txt | 3 - .../stk_mesh/CMakeLists.txt | 23 - .../stk_mesh/GearsSkinning.cpp | 561 -- .../stk_mesh/HeavyTest.cpp | 170 - .../stk_mesh/PerformanceTestLoopIteration.cpp | 148 - .../stk_mesh/PerformanceTestMain.cpp | 18 - .../stk_mesh/PerformanceTestSelector.cpp | 80 - .../stk_mesh/PerformanceTestSkinning.cpp | 462 -- .../stk_mesh/PerformanceTestTimingMaps.cpp | 334 - .../stk_classic/stk_rebalance/CMakeLists.txt | 12 - .../stk_classic/stk_rebalance/doc/Doxyfile | 1 - .../stk_rebalance/doc/Doxyfile.common.config | 1 - .../stk_rebalance/doc/Doxyfile.input | 22 - .../stk_classic/stk_rebalance/doc/index.dox | 45 - .../stk_rebalance/CMakeLists.txt | 49 - .../stk_rebalance/GeomDecomp.cpp | 141 - .../stk_rebalance/GeomDecomp.hpp | 146 - .../stk_rebalance/stk_rebalance/Partition.cpp | 24 - .../stk_rebalance/stk_rebalance/Partition.hpp | 160 - .../stk_rebalance/stk_rebalance/Rebalance.cpp | 204 - .../stk_rebalance/stk_rebalance/Rebalance.hpp | 73 - .../stk_rebalance/ZoltanPartition.cpp | 1036 --- .../stk_rebalance/ZoltanPartition.hpp | 342 - .../stk_rebalance_utils/CMakeLists.txt | 21 - .../stk_rebalance_utils/RebalanceUtils.cpp | 96 - .../stk_rebalance_utils/RebalanceUtils.hpp | 55 - .../stk_rebalance/unit_tests/CMakeLists.txt | 27 - .../stk_rebalance/unit_tests/UnitTestMain.cpp | 19 - .../unit_tests/UnitTestSimple.cpp | 383 -- .../unit_tests/UnitTestZoltanGraph.cpp | 200 - .../unit_tests/UnitTestZoltanSimple.cpp | 241 - .../stk_rebalance/use_cases/CMakeLists.txt | 24 - .../stk_rebalance/use_cases/UseCaseMain.cpp | 74 - .../use_cases/UseCase_Rebal_1.cpp | 128 - .../use_cases/UseCase_Rebal_1.hpp | 80 - .../use_cases/UseCase_Rebal_2.cpp | 253 - .../use_cases/UseCase_Rebal_2.hpp | 89 - .../use_cases/UseCase_Rebal_3.cpp | 188 - .../use_cases/UseCase_Rebal_3.hpp | 83 - .../use_cases/UseCase_Rebal_4.cpp | 407 -- .../use_cases/UseCase_Rebal_4.hpp | 74 - .../stk/stk_classic/stk_search/CMakeLists.txt | 5 - .../stk/stk_classic/stk_search/doc/Doxyfile | 1 - .../stk_search/doc/Doxyfile.common.config | 1 - .../stk/stk_classic/stk_search/doc/index.dox | 96 - .../stk_search/stk_search/BihTree.dox | 38 - .../stk_search/stk_search/BihTree.hpp | 495 -- .../stk_search/BihTreeParallelOps.hpp | 189 - .../stk_search/stk_search/BoundingBox.hpp | 314 - .../stk_search/BoundingBoxCompare.hpp | 149 - .../stk_search/stk_search/CMakeLists.txt | 65 - .../stk_search/stk_search/CoarseSearch.dox | 38 - .../stk_search/stk_search/CoarseSearch.hpp | 159 - .../stk_search/stk_search/IdentProc.hpp | 170 - .../stk_search/stk_search/OctTree.cpp | 291 - .../stk_search/stk_search/OctTree.dox | 38 - .../stk_search/stk_search/OctTree.hpp | 136 - .../stk_search/stk_search/OctTreeOps.cpp | 513 -- .../stk_search/stk_search/OctTreeOps.hpp | 1024 --- .../stk_search/stk_search/SearchTypes.hpp | 15 - .../stk_search/stk_search/diag/CMakeLists.txt | 38 - .../stk_search/stk_search/diag/IdentProc.hpp | 33 - .../stk_search/unit_tests/CMakeLists.txt | 33 - .../stk_search/unit_tests/UnitTestBihTree.cpp | 202 - .../unit_tests/UnitTestBoundingBox.cpp | 149 - .../unit_tests/UnitTestCoarseSearch.cpp | 57 - .../unit_tests/UnitTestIdentProc.cpp | 55 - .../stk_search/unit_tests/UnitTestMain.cpp | 18 - .../stk_search/unit_tests/UnitTestRange.cpp | 23 - .../unit_tests/UnitTestStkSearchFixture.cpp | 62 - .../unit_tests/UnitTestStkSearchFixture.hpp | 51 - .../stk_search/unit_tests/UnitTest_1.cpp | 80 - .../stk_search/unit_tests/UnitTest_4.cpp | 82 - .../stk_search_util/CMakeLists.txt | 3 - .../stk_search_util/CMakeLists.txt | 3 - .../stk_search_util/stk_mesh/CMakeLists.txt | 57 - .../stk_mesh/CreateBoundingBox.cpp | 345 - .../stk_mesh/CreateBoundingBox.hpp | 93 - .../stk_mesh/PrintBoundingBox.hpp | 166 - .../stk_mesh/PrintEntityProc.cpp | 184 - .../stk_mesh/PrintEntityProc.hpp | 89 - .../stk_classic/stk_transfer/CMakeLists.txt | 3 - .../stk_transfer/unit_tests/CMakeLists.txt | 24 - .../stk_transfer/unit_tests/UnitTestMain.cpp | 18 - .../stk_transfer/unit_tests/UnitTest_1.cpp | 43 - .../stk_classic/stk_usecases/CMakeLists.txt | 16 - .../stk_usecases/app/AppUseCase_14.cpp | 604 -- .../stk_usecases/app/AppUseCase_14.hpp | 72 - .../stk_usecases/app/CMakeLists.txt | 32 - .../stk_usecases/app/UseCase_10.hpp | 1691 ----- .../stk_usecases/app/UseCase_14_Common.cpp | 1758 ----- .../stk_usecases/app/UseCase_14_Common.hpp | 430 -- .../stk_usecases/app/UseCase_14_Fields.cpp | 331 - .../stk_usecases/app/UseCase_14_Fields.hpp | 90 - .../stk_usecases/app/UseCase_14a.cpp | 1223 ---- .../stk_usecases/app/UseCase_24.cpp | 462 -- .../stk_usecases/app/UseCase_7.cpp | 744 -- .../stk_usecases/app/UseCase_blas.cpp | 311 - .../stk_usecases/app/UseCase_blas_algs.hpp | 324 - .../stk_usecases/app/UseCase_driver.cpp | 225 - .../app/examples/example_driver.cpp | 110 - .../app/examples/example_io_1.cpp | 141 - .../app/examples/example_io_2.cpp | 723 -- .../app/examples/example_meshes.cpp | 267 - .../app/performance_algorithms.cpp | 495 -- .../app/performance_algorithms.hpp | 100 - .../stk_usecases/app/shared_fortran.F | 162 - .../stk_usecases/app/shared_fortran.hpp | 26 - .../stk_usecases/common/gnu_malloc_hooks.cpp | 171 - .../stk_usecases/common/gnu_malloc_hooks.hpp | 56 - .../stk_usecases/io/CMakeLists.txt | 23 - .../stk_usecases/io/io_example.cpp | 970 --- .../stk_usecases/io/io_example.dox | 804 --- .../stk_usecases/io/io_generated.cpp | 169 - .../stk_usecases/linsys/CMakeLists.txt | 33 - .../stk_usecases/linsys/LinsysUseCase_1.cpp | 438 -- .../stk_usecases/linsys/LinsysUseCase_2.cpp | 457 -- .../stk_usecases/linsys/LinsysUseCase_3.cpp | 478 -- .../stk_usecases/linsys/LinsysUseCase_4.cpp | 500 -- .../stk_usecases/linsys/LinsysUseCase_5.cpp | 557 -- .../stk_usecases/linsys/LinsysUseCase_7.cpp | 595 -- .../linsys/LinsysUseCase_driver.cpp | 228 - .../stk_usecases/mesh/CMakeLists.txt | 30 - .../stk_usecases/mesh/MeshUseCaseMain.cpp | 84 - .../stk_usecases/mesh/UseCase_13.cpp | 713 -- .../stk_usecases/mesh/UseCase_14.cpp | 1031 --- .../stk_usecases/mesh/UseCase_14.hpp | 1997 ------ .../stk_usecases/mesh/UseCase_23.cpp | 779 --- .../stk_usecases/mesh/UseCase_AD.cpp | 965 --- .../stk_usecases/mesh/UseCase_AD.hpp | 2086 ------ .../stk_usecases/mesh/centroid_algorithm.hpp | 183 - .../stk_usecases/search/SearchUseCaseMain.cpp | 130 - .../stk_usecases/search/SearchUseCase_1.cpp | 141 - .../stk_usecases/search/SearchUseCase_4.cpp | 133 - .../search/performance/Performance.hpp | 42 - .../search/performance/PerformanceMain.cpp | 141 - .../search/performance/Performance_1.cpp | 374 - .../stk_usecases/transfer/CMakeLists.txt | 34 - .../transfer/TransferUseCaseMain.cpp | 192 - .../transfer/UseCaseIsInElement.cpp | 77 - .../transfer/UseCaseIsInElement.hpp | 25 - .../stk_usecases/transfer/UseCase_0.cpp | 248 - .../stk_usecases/transfer/UseCase_1.cpp | 275 - .../stk_usecases/transfer/UseCase_2.cpp | 260 - .../stk_usecases/transfer/UseCase_3.cpp | 280 - .../stk_usecases/transfer/UseCase_4.cpp | 429 -- .../stk_usecases/util/CMakeLists.txt | 29 - .../stk_usecases/util/UseCaseMessage.cpp | 170 - .../stk_usecases/util/UseCaseTimer.cpp | 319 - .../stk_usecases/util/UtilUseCaseMain.cpp | 26 - .../stk/stk_classic/stk_util/CMakeLists.txt | 7 - .../stk/stk_classic/stk_util/doc/Doxyfile | 1 - .../stk_util/doc/Doxyfile.common.config | 1 - .../stk_classic/stk_util/doc/Doxyfile.input | 28 - .../stk/stk_classic/stk_util/doc/index.dox | 125 - .../stk_util/stk_util/CMakeLists.txt | 21 - .../stk_util/stk_util/diag/CMakeLists.txt | 86 - .../stk_util/stk_util/diag/Env.cpp | 1199 ---- .../stk_util/stk_util/diag/Env.hpp | 601 -- .../stk_util/stk_util/diag/FArray.cpp | 44 - .../stk_util/stk_util/diag/FArray.hpp | 1421 ---- .../stk_util/stk_util/diag/Mapv.cpp | 441 -- .../stk_util/stk_util/diag/Mapv.hpp | 739 -- .../stk_util/stk_util/diag/Option.cpp | 131 - .../stk_util/stk_util/diag/Option.hpp | 362 - .../stk_util/stk_util/diag/Platform.cpp | 765 --- .../stk_util/stk_util/diag/Platform.hpp | 300 - .../stk_util/stk_util/diag/PreParse.cpp | 141 - .../stk_util/stk_util/diag/PreParse.hpp | 82 - .../stk_util/stk_util/diag/PrintTable.cpp | 313 - .../stk_util/stk_util/diag/PrintTable.hpp | 421 -- .../stk_util/stk_util/diag/PrintTimer.cpp | 754 --- .../stk_util/stk_util/diag/PrintTimer.hpp | 29 - .../stk_util/stk_util/diag/Signal.cpp | 284 - .../stk_util/stk_util/diag/Signal.hpp | 102 - .../stk_util/stk_util/diag/SignalHandler.cpp | 217 - .../stk_util/stk_util/diag/SignalHandler.hpp | 98 - .../stk_util/stk_util/diag/SlibDiagWriter.cpp | 73 - .../stk_util/stk_util/diag/SlibDiagWriter.hpp | 48 - .../stk_util/stk_util/diag/String.cpp | 242 - .../stk_util/stk_util/diag/String.hpp | 819 --- .../stk_util/stk_util/diag/StringUtil.cpp | 347 - .../stk_util/stk_util/diag/StringUtil.hpp | 860 --- .../stk_util/stk_util/diag/Timer.cpp | 1206 ---- .../stk_util/stk_util/diag/Timer.dox | 140 - .../stk_util/stk_util/diag/Timer.hpp | 844 --- .../stk_util/diag/TimerMetricTraits.cpp | 156 - .../stk_util/diag/TimerMetricTraits.hpp | 130 - .../stk_util/stk_util/diag/Trace.cpp | 401 -- .../stk_util/stk_util/diag/Trace.hpp | 526 -- .../stk_util/stk_util/diag/UserPlugin.cpp | 250 - .../stk_util/stk_util/diag/UserPlugin.hpp | 685 -- .../stk_util/stk_util/diag/Writer.cpp | 356 - .../stk_util/stk_util/diag/Writer.dox | 442 -- .../stk_util/stk_util/diag/Writer.hpp | 813 --- .../stk_util/stk_util/diag/WriterExt.cpp | 110 - .../stk_util/stk_util/diag/WriterExt.hpp | 1164 ---- .../stk_util/stk_util/diag/WriterManip.cpp | 94 - .../stk_util/stk_util/diag/WriterManip.hpp | 177 - .../stk_util/stk_util/diag/WriterOStream.hpp | 48 - .../stk_util/stk_util/diag/WriterParser.cpp | 101 - .../stk_util/stk_util/diag/WriterParser.hpp | 76 - .../stk_util/stk_util/diag/WriterRegistry.cpp | 59 - .../stk_util/stk_util/diag/WriterRegistry.hpp | 90 - .../stk_util/stk_util/diag/Writer_fwd.hpp | 89 - .../stk_util/stk_util/environment/.gitignore | 3 - .../stk_util/environment/CMakeLists.txt | 83 - .../stk_util/stk_util/environment/CPUTime.cpp | 41 - .../stk_util/stk_util/environment/CPUTime.hpp | 24 - .../stk_util/environment/Demangle.cpp | 108 - .../stk_util/environment/Demangle.hpp | 37 - .../stk_util/environment/FormatMemorySize.cpp | 100 - .../stk_util/environment/FormatMemorySize.hpp | 23 - .../stk_util/environment/FormatTime.cpp | 64 - .../stk_util/environment/FormatTime.hpp | 31 - .../stk_util/environment/LogControl.cpp | 151 - .../stk_util/environment/LogControl.dox | 114 - .../stk_util/environment/LogControl.hpp | 263 - .../stk_util/environment/OutputLog.cpp | 700 -- .../stk_util/environment/OutputLog.dox | 442 -- .../stk_util/environment/OutputLog.hpp | 222 - .../stk_util/environment/ProductRegistry.cpp | 216 - .../stk_util/environment/ProductRegistry.hpp | 283 - .../stk_util/environment/ProgramOptions.cpp | 29 - .../stk_util/environment/ProgramOptions.dox | 87 - .../stk_util/environment/ProgramOptions.hpp | 48 - .../stk_util/environment/RegisterProduct.cpp | 35 - .../stk_util/environment/RegisterProduct.hpp | 11 - .../stk_util/environment/ReportHandler.cpp | 190 - .../stk_util/environment/ReportHandler.hpp | 291 - .../stk_util/environment/RuntimeDoomed.cpp | 122 - .../stk_util/environment/RuntimeDoomed.hpp | 406 -- .../stk_util/environment/RuntimeMessage.cpp | 489 -- .../stk_util/environment/RuntimeMessage.dox | 259 - .../stk_util/environment/RuntimeMessage.hpp | 308 - .../stk_util/environment/RuntimeWarning.cpp | 118 - .../stk_util/environment/RuntimeWarning.hpp | 390 -- .../stk_util/environment/WallTime.cpp | 41 - .../stk_util/environment/WallTime.hpp | 26 - .../stk_util/environment/product_registry.h | 66 - .../stk_util/environment/stk_version_gen.sh | 85 - .../generic_mesh/generic_mesh_functions.hpp | 271 - .../generic_mesh/generic_mesh_traits.hpp | 95 - .../stk_util/parallel/BroadcastArg.cpp | 88 - .../stk_util/parallel/BroadcastArg.hpp | 52 - .../stk_util/stk_util/parallel/CMakeLists.txt | 64 - .../stk_util/parallel/DistributedIndex.cpp | 1030 --- .../stk_util/parallel/DistributedIndex.hpp | 178 - .../stk_util/stk_util/parallel/Exception.cpp | 322 - .../stk_util/stk_util/parallel/Exception.hpp | 817 --- .../stk_util/parallel/ExceptionIos.hpp | 24 - .../stk_util/parallel/ExceptionReport.cpp | 174 - .../stk_util/parallel/ExceptionReport.hpp | 81 - .../stk_util/stk_util/parallel/MPI.cpp | 321 - .../stk_util/stk_util/parallel/MPI.hpp | 1033 --- .../stk_util/stk_util/parallel/Parallel.cpp | 65 - .../stk_util/stk_util/parallel/Parallel.hpp | 138 - .../stk_util/parallel/ParallelComm.cpp | 1040 --- .../stk_util/parallel/ParallelComm.hpp | 465 -- .../stk_util/parallel/ParallelIndex.cpp | 12 - .../stk_util/parallel/ParallelIndex.hpp | 305 - .../stk_util/parallel/ParallelInputStream.cpp | 155 - .../stk_util/parallel/ParallelInputStream.hpp | 28 - .../stk_util/parallel/ParallelReduce.cpp | 247 - .../stk_util/parallel/ParallelReduce.hpp | 232 - .../stk_util/parallel/mpi_filebuf.cpp | 475 -- .../stk_util/parallel/mpi_filebuf.hpp | 117 - .../stk_util/stk_util/parallel/mpih.hpp | 260 - .../stk_util/stk_util/stk_config.h | 26 - .../stk_util/unit_test_support/CMakeLists.txt | 53 - .../unit_test_support/GeneratedMesh.cpp | 1227 ---- .../unit_test_support/GeneratedMesh.hpp | 435 -- .../unit_test_support/stk_utest_macros.hpp | 201 - .../stk_util/use_cases/CMakeLists.txt | 52 - .../stk_util/use_cases/UseCaseEnvironment.cpp | 572 -- .../stk_util/use_cases/UseCaseEnvironment.hpp | 116 - .../stk_util/stk_util/util/Array.hpp | 673 -- .../stk_util/stk_util/util/Bootstrap.cpp | 41 - .../stk_util/stk_util/util/Bootstrap.dox | 62 - .../stk_util/stk_util/util/Bootstrap.hpp | 80 - .../stk_util/stk_util/util/CMakeLists.txt | 49 - .../stk_util/stk_util/util/CSet.cpp | 140 - .../stk_util/stk_util/util/CSet.hpp | 147 - .../stk_util/stk_util/util/Callback.hpp | 116 - .../stk_util/stk_util/util/FArrayPrint.hpp | 244 - .../stk_util/stk_util/util/FeatureTest.hpp | 185 - .../stk_util/stk_util/util/Foreach.hpp | 17 - .../stk_util/stk_util/util/Fortran.hpp | 22 - .../stk_util/stk_util/util/Identifier.cpp | 322 - .../stk_util/stk_util/util/Identifier.hpp | 258 - .../stk_util/util/IndentStreambuf.hpp | 388 -- .../stk_util/stk_util/util/IndexList.hpp | 104 - .../stk_util/stk_util/util/MallocUsed.h | 38 - .../stk_util/stk_util/util/Marshal.cpp | 431 -- .../stk_util/stk_util/util/Marshal.hpp | 324 - .../stk_util/stk_util/util/NamedPair.hpp | 61 - .../stk_util/stk_util/util/Null_Streambuf.cpp | 46 - .../stk_util/stk_util/util/Null_Streambuf.hpp | 45 - .../stk_util/stk_util/util/PairIter.hpp | 133 - .../stk_util/stk_util/util/Pool.cpp | 52 - .../stk_util/stk_util/util/Pool.hpp | 75 - .../stk_util/stk_util/util/RadixSort.hpp | 347 - .../stk_util/stk_util/util/Range.hpp | 66 - .../stk_util/stk_util/util/SameType.hpp | 33 - .../stk_util/stk_util/util/SimpleArrayOps.hpp | 381 -- .../stk_util/stk_util/util/StaticAssert.hpp | 35 - .../stk_util/stk_util/util/TeeStreambuf.hpp | 197 - .../stk_util/stk_util/util/TypeList.hpp | 1063 --- .../stk_util/stk_util/util/TypeListMap.hpp | 215 - .../stk_util/stk_util/util/TypeUtil.hpp | 95 - .../stk_util/stk_util/util/VecMap.hpp | 380 -- .../stk_util/stk_util/util/VecSet.hpp | 298 - .../stk_util/stk_util/util/ci_string.cpp | 83 - .../stk_util/stk_util/util/ci_string.hpp | 45 - .../stk_util/stk_util/util/ci_traits.cpp | 35 - .../stk_util/stk_util/util/ci_traits.hpp | 81 - .../stk_util/stk_util/util/config_google.h | 135 - .../stk_util/stk_util/util/dense_hash_map | 333 - .../stk_util/stk_util/util/densehashtable.h | 1268 ---- .../stk_util/stk_util/util/hashtable-common.h | 178 - .../util/libc_allocator_with_realloc.h | 121 - .../stk_util/util/nested_iterator.hpp | 271 - .../stk_util/stk_util/util/nested_range.hpp | 103 - .../util/random_access_iterator_wrapper.hpp | 60 - .../stk_util/stk_util/util/sparse_hash_map | 310 - .../stk_util/stk_util/util/sparseconfig.h | 49 - .../stk_util/stk_util/util/sparsehashtable.h | 1190 ---- .../stk_util/stk_util/util/sparsetable | 1598 ----- .../stk_util/util/string_case_compare.hpp | 138 - .../stk_util/stk_util/util/tokenize.cpp | 31 - .../stk_util/stk_util/util/tokenize.hpp | 20 - .../stk_util/util/type_traits_google.h | 336 - .../util/unused-maps/algorithm_eastl.h | 2964 -------- .../util/unused-maps/algorithm_rdestl.h | 273 - .../util/unused-maps/allocator_eastl.cpp | 87 - .../util/unused-maps/allocator_eastl.h | 326 - .../util/unused-maps/allocator_rdestl.h | 53 - .../util/unused-maps/assert_eastl.cpp | 121 - .../stk_util/util/unused-maps/config_eastl.h | 1191 ---- .../stk_util/util/unused-maps/eabase_eastl.h | 862 --- .../util/unused-maps/eacompiler_eastl.h | 476 -- .../util/unused-maps/eacompilertraits_eastl.h | 935 --- .../util/unused-maps/eaplatform_eastl.h | 541 -- .../util/unused-maps/fixed_allocator_eastl.h | 464 -- .../util/unused-maps/fixed_pool_eastl.cpp | 85 - .../util/unused-maps/fixed_pool_eastl.h | 1371 ---- .../util/unused-maps/functional_eastl.h | 929 --- .../util/unused-maps/functional_rdestl.h | 39 - .../util/unused-maps/generic_iterator_eastl.h | 226 - .../util/unused-maps/hash_map_eastl.h | 329 - .../util/unused-maps/hash_map_rdestl.h | 575 -- .../stk_util/util/unused-maps/hash_rdestl.h | 39 - .../util/unused-maps/hashtable_eastl.cpp | 209 - .../util/unused-maps/hashtable_eastl.h | 2251 ------- .../util/unused-maps/int_to_type_rdestl.h | 27 - .../util/unused-maps/iterator_eastl.h | 616 -- .../util/unused-maps/iterator_rdestl.h | 78 - .../stk_util/util/unused-maps/memory_eastl.h | 687 -- .../stk_util/util/unused-maps/pair_rdestl.h | 50 - .../stk_util/util/unused-maps/rdestl_common.h | 69 - .../util/unused-maps/red_black_tree_eastl.cpp | 511 -- .../util/unused-maps/red_black_tree_eastl.h | 1904 ------ .../util/unused-maps/string_eastl.cpp | 57 - .../stk_util/util/unused-maps/string_eastl.h | 3470 ---------- .../util/unused-maps/type_compound_eastl.h | 469 -- .../util/unused-maps/type_fundamental_eastl.h | 166 - .../util/unused-maps/type_pod_eastl.h | 284 - .../util/unused-maps/type_properties_eastl.h | 263 - .../util/unused-maps/type_traits_eastl.h | 337 - .../util/unused-maps/type_traits_rdestl.h | 96 - .../unused-maps/type_transformations_eastl.h | 223 - .../stk_util/util/unused-maps/utility_eastl.h | 297 - .../util/unused-maps/utility_rdestl.h | 193 - .../stk_util/stk_util/util/vectorization.hpp | 12 - .../stk_util/unit_tests/CMakeLists.txt | 33 - .../stk_util/unit_tests/UnitTestBoost.cpp | 92 - .../stk_util/unit_tests/UnitTestMain.cpp | 16 - .../stk_util/unit_tests/UnitTestParallel.cpp | 35 - .../stk_util/unit_tests/UnitTestRange.cpp | 47 - .../unit_tests/UnitTest_iterator_wrapper.cpp | 30 - .../unit_tests/diag/UnitTestTimer.cpp | 302 - .../unit_tests/diag/UnitTestWriter.cpp | 266 - .../environment/UnitTestCPUTime.cpp | 32 - .../environment/UnitTestDemangle.cpp | 120 - .../environment/UnitTestLogControl.cpp | 209 - .../environment/UnitTestOutputLog.cpp | 173 - .../environment/UnitTestReportHandler.cpp | 64 - .../environment/UnitTestThrowMacros.cpp | 219 - .../environment/UnitTestWallTime.cpp | 30 - .../unit_tests/parallel/CMakeLists.txt | 13 - .../parallel/UnitTestDistributedIndex.cpp | 618 -- .../parallel/UnitTestParallelMain.cpp | 19 - .../stk_util/unit_tests/util/UnitTestCSet.cpp | 138 - .../unit_tests/util/UnitTestFormatTime.cpp | 60 - .../unit_tests/util/UnitTestIdentifier.cpp | 125 - .../util/UnitTestIndentStreambuf.cpp | 465 -- .../unit_tests/util/UnitTestMallocUsed.cpp | 395 -- .../unit_tests/util/UnitTestMarshal.cpp | 220 - .../unit_tests/util/UnitTestPrintTable.cpp | 143 - .../unit_tests/util/UnitTestTeeStreambuf.cpp | 51 - .../util/UnitTest_filter_iterator.cpp | 53 - .../util/UnitTest_nested_iterator.cpp | 142 - .../unit_tests/util/UnitTest_nested_range.cpp | 105 - 1091 files changed, 287783 deletions(-) delete mode 100644 packages/stk/stk_classic/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/README_stk_trilinos delete mode 100644 packages/stk/stk_classic/cmake/Dependencies.cmake delete mode 100644 packages/stk/stk_classic/cmake/STKClassic_config.h.in delete mode 100755 packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic delete mode 100644 packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic.sed delete mode 100644 packages/stk/stk_classic/doc/.gitignore delete mode 100644 packages/stk/stk_classic/doc/Doxyfile delete mode 100644 packages/stk/stk_classic/doc/Doxyfile.common.config delete mode 100755 packages/stk/stk_classic/doc/build_docs delete mode 100644 packages/stk/stk_classic/stk_adapt/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestFileLoc.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestLocalRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMeshColorer.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestNodeRegistry.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestSTKMeshMemory.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestUniformRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Allocate.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/IAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeBasedAdapterPredicate.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/IElementAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/IElementBasedAdapterPredicate.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistryDef.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedEdgeAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedElementAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Line2_Line2_N.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tet4_Tet4_N.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_2.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_N.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUnrefine.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/SerializeNodeRegistry.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/SubDimCell.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_3D.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_Enrich_3D.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_QuadraticRefine_3D.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam3_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam3_Beam3_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex20_Hex20_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex27_Hex27_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex20_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex27_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex8_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_24.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_6_12.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line2_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line3_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line3_Line3_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_2.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_4.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_6.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet10_Tet10_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet10_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet4_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge15_Wedge15_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge18_Wedge18_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge15_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge18_1_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge6_8_sierra.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/main/AdaptMain.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/main/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/main/memory-multipliers.dat delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/GeneratedRefinementTable.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/MeshObjTopology.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/Readme.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementTopology.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementTopology.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/stk_percept_code_types.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/todo.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_1.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2_1.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_4.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_EdgeBasedAnisotropic.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IEdgeAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IElementAdapter.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_MeshSizeRatio.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestLocalRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMeshColorer.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestNodeRegistry.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSubDimCell.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.hpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestUniformRefiner.cpp delete mode 100644 packages/stk/stk_classic/stk_adapt/unit_tests/generated_refinement_tables.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_algsup/doc/Doxyfile delete mode 100644 packages/stk/stk_classic/stk_algsup/doc/Doxyfile.input delete mode 100755 packages/stk/stk_classic/stk_algsup/doc/Doxyfile.options delete mode 100644 packages/stk/stk_classic/stk_algsup/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunSimple.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTBB.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTPI.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CudaCall.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CudaDeviceMgr.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CudaDeviceMgr.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.hpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/CudaTestMain.cu delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/NoCudaTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestAlgorithmRunner.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestCudaMgr.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/UnitTest_helpers.cpp delete mode 100644 packages/stk/stk_classic/stk_algsup/unit_tests/UnitTest_helpers.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Constants.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Constants.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Function.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Function.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.hpp delete mode 100644 packages/stk/stk_classic/stk_expreval/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluator.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluatorFAD.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_expreval/use_cases/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_expreval/use_cases/UseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_integration_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_integration_tests/stk_mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_integration_tests/stk_mesh/IntegrationTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_io/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_io/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_io/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_io/doc/Doxyfile.input delete mode 100644 packages/stk/stk_classic/stk_io/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/IossBridge.cpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/IossBridge.hpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.cpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.hpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/Gears.cpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/Gears.hpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.cpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.hpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.cpp delete mode 100644 packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.hpp delete mode 100644 packages/stk/stk_classic/stk_io/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_io/unit_tests/UnitTestGmeshFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_io/unit_tests/UnitTestIOFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_io/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_io/unit_tests/UnitTestTopologyMap.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_linsys/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_linsys/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_linsys/doc/Doxyfile.input delete mode 100644 packages/stk/stk_classic/stk_linsys/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/FeiBaseIncludes.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/FieldIdMap.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystemInterface.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/Linsys.dox delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/LinsysFunctions.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/stk_linsys/LinsysFunctions.hpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestDofMapper.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinearSystem.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinsysFunctions.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.cpp delete mode 100644 packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_mesh/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_mesh/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_mesh/doc/Doxyfile.input delete mode 100644 packages/stk/stk_classic/stk_mesh/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataEndSync.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataGhosting.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataOwner.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallel.dox delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallelVerify.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataRelation.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsClass.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsEnum.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter_fwd.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Field.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.dox delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRelation.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldState.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldTraits.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/FindRestriction.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/MemoryUsage.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/MemoryUsage.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Mesh.dox delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/PartRelation.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/PropertyBase.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.dox delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Selector.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Selector.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/SetOwners.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/base/Types.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/diag/EntityKey.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CellTopology.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GearsFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GearsFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GridFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GridFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/README delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoundaryAnalysis.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoxFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBucket.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkDataAdapt.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_ChangeParts.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_Destroy.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_new.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkModification.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestChangeEntityId.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestCrackMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestCreateAdjacentEntities.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDataTraits.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDeclareElement.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestEntity.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFEMMetaData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestField.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldDataInitVal.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldImpl.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldRestriction.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGenerateNewEntities.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGetBuckets.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGridFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestHexFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestInducedPart.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMetaData.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPart.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPartRepository.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestProperty.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRelation.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSelector.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinIrregular.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinning.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTemplate.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTopology.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTrace.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTransactionLog.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/README delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_2.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_2.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1_validation_helpers.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1_validation_helpers.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.hpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1b.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_2.cpp delete mode 100644 packages/stk/stk_classic/stk_mesh/use_cases/centroid_algorithm.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/build/.gitignore delete mode 100644 packages/stk/stk_classic/stk_percept/build/README delete mode 100755 packages/stk/stk_classic/stk_percept/build/build-pydoc.sh delete mode 100755 packages/stk/stk_classic/stk_percept/build/install-pydoc.sh delete mode 100755 packages/stk/stk_classic/stk_percept/build/sample-Trilinos-configure-script delete mode 100644 packages/stk/stk_classic/stk_percept/doc/Doxyfile delete mode 100644 packages/stk/stk_classic/stk_percept/doc/Doxyfile.input delete mode 100755 packages/stk/stk_classic/stk_percept/doc/Doxyfile.options delete mode 100644 packages/stk/stk_classic/stk_percept/doc/PerceptMesh.html delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/dg.dot delete mode 100755 packages/stk/stk_classic/stk_percept/doc/dot/dot.old delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/hex.1.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/hex.2.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/hex.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/hex.pdf delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/j.pdf delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/quad.1.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/quad.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/quad.pdf delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/run-quad delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/tet.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/tet.pdf delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/tri.dot delete mode 100644 packages/stk/stk_classic/stk_percept/doc/dot/tri.pdf delete mode 100644 packages/stk/stk_classic/stk_percept/doc/index.dox delete mode 100755 packages/stk/stk_classic/stk_percept/dox/dot/run-it delete mode 100644 packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestPerceptMeshFieldFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Edge.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ExceptionWatch.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEM.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Name.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/NoMallocArray.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Observable.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/OptionMask.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtilDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Percept.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/PerceptBoostArray.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/PerceptMeshReadWrite.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/SameRankRelation.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Util.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/Util.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/QuadFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/fixtures/WedgeFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/foo.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/BucketOp.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/CompositeFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/ConstantFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/ElementOp.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/Function.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/Function.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/MDArray.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/MultipleFieldFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/PartOp.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.i delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.py delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction_wrap.cxx delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxes.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxesDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeBases.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeFieldValues.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/FunctionWithIntrepidRequest.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.i delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/HasValue.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IntegratedOp.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcher.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcherDef.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Searcher.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/internal/swig.make delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/function/jj.swig.make delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/math/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/math/Math.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifferenceMain.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/TransformPath.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernel.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelStupid.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMMsqMatrix.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMSmootherMetric.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/norm/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/norm/H1Norm.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/norm/IntrepidManager.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/norm/IntrepidManager.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/norm/Norm.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/parse-sierra-log-timings-example.py delete mode 100755 packages/stk/stk_classic/stk_percept/stk_percept/percept delete mode 100755 packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.1.py delete mode 100755 packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.2.py delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.3.py delete mode 100755 packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.4.py delete mode 100755 packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.py delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/pyencore.h delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/stk_mesh.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/util/GeneralFunction.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/main1.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/Documentation.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/Example2.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/FieldFunctionUnitTests.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/NormUnitTests.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/PerceptMeshUnitTests.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/StringFunctionUnitTests.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UniformRefinerUnitTests.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestFieldFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestGeometryVerifier.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestNorm.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesquiteMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestSearch.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestStringFunction.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestTimeMaps.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestTopoCheck.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UnitTestUtilities.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/UseCases.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/boost_python_getting_started1.cref delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/cube_hex8.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/cube_hex8.e.out delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/cube_hex8_8_out.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/example.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/example.hpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/example.i delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/example.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/example_wrap.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/beam.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/hex_fixture.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/input_files_hex_fixture.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/input_files_tet_fixture.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture_no_sidesets.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture_readwrite.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture_with_coords_mag.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/tet-mesh.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/tet_from_hex_fixture_0.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/mainsh.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi1.cpp delete mode 100755 packages/stk/stk_classic/stk_percept/unit_tests/print_table.py delete mode 100755 packages/stk/stk_classic/stk_percept/unit_tests/run-py-unit delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/runme_example.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/sun_compile/main-sun.cpp delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/README delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.debug.py delete mode 100755 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/mms_user.C delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output1.gold.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output2.gold.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output3.gold.e delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output4.gold.e delete mode 100755 packages/stk/stk_classic/stk_percept/unit_tests/unitTest1.py delete mode 100755 packages/stk/stk_classic/stk_percept/unit_tests/unitTest2.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/unitTest_h1Norm.py delete mode 100644 packages/stk/stk_classic/stk_percept/unit_tests/unitTest_h1Norm_1.py delete mode 100644 packages/stk/stk_classic/stk_performance_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/GearsSkinning.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/HeavyTest.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestLoopIteration.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestSelector.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestSkinning.cpp delete mode 100644 packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestTimingMaps.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_rebalance/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.input delete mode 100644 packages/stk/stk_classic/stk_rebalance/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestSimple.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanGraph.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanSimple.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_3.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_3.hpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_4.cpp delete mode 100644 packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_4.hpp delete mode 100644 packages/stk/stk_classic/stk_search/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_search/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_search/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_search/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/BihTree.dox delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/BihTree.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/BihTreeParallelOps.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/BoundingBox.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/BoundingBoxCompare.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.dox delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/IdentProc.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/OctTree.cpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/OctTree.dox delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/OctTree.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.cpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/SearchTypes.hpp delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/diag/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search/stk_search/diag/IdentProc.hpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestBihTree.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestBoundingBox.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestCoarseSearch.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestIdentProc.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestRange.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestStkSearchFixture.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTestStkSearchFixture.hpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTest_1.cpp delete mode 100644 packages/stk/stk_classic/stk_search/unit_tests/UnitTest_4.cpp delete mode 100644 packages/stk/stk_classic/stk_search_util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.cpp delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.hpp delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintBoundingBox.hpp delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintEntityProc.cpp delete mode 100644 packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintEntityProc.hpp delete mode 100644 packages/stk/stk_classic/stk_transfer/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_transfer/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_transfer/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_transfer/unit_tests/UnitTest_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_10.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_14_Common.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_14_Common.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_14a.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_24.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_7.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_blas.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_blas_algs.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/UseCase_driver.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/examples/example_driver.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/examples/example_io_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/examples/example_io_2.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/examples/example_meshes.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/performance_algorithms.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/performance_algorithms.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/app/shared_fortran.F delete mode 100644 packages/stk/stk_classic/stk_usecases/app/shared_fortran.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/common/gnu_malloc_hooks.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/common/gnu_malloc_hooks.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/io/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/io/io_example.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/io/io_example.dox delete mode 100644 packages/stk/stk_classic/stk_usecases/io/io_generated.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_2.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_3.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_4.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_5.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_7.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_driver.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/MeshUseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_13.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_14.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_14.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_23.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/mesh/centroid_algorithm.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/SearchUseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/SearchUseCase_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/SearchUseCase_4.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/performance/Performance.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/performance/PerformanceMain.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/search/performance/Performance_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/TransferUseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCaseIsInElement.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCaseIsInElement.hpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCase_0.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCase_1.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCase_2.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCase_3.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/transfer/UseCase_4.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_usecases/util/UseCaseMessage.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/util/UseCaseTimer.cpp delete mode 100644 packages/stk/stk_classic/stk_usecases/util/UtilUseCaseMain.cpp delete mode 100644 packages/stk/stk_classic/stk_util/CMakeLists.txt delete mode 120000 packages/stk/stk_classic/stk_util/doc/Doxyfile delete mode 120000 packages/stk/stk_classic/stk_util/doc/Doxyfile.common.config delete mode 100644 packages/stk/stk_classic/stk_util/doc/Doxyfile.input delete mode 100644 packages/stk/stk_classic/stk_util/doc/index.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Env.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Env.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/FArray.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/FArray.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Option.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Option.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Platform.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Platform.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Signal.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Signal.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/String.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/String.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Timer.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Timer.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Timer.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Trace.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Trace.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Writer.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Writer.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Writer.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterOStream.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/diag/Writer_fwd.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/.gitignore delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/environment/product_registry.h delete mode 100755 packages/stk/stk_classic/stk_util/stk_util/environment/stk_version_gen.sh delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_functions.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_traits.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/Exception.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/Exception.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionIos.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/parallel/mpih.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/stk_config.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/unit_test_support/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/unit_test_support/stk_utest_macros.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/use_cases/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Array.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.dox delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/CSet.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/CSet.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Callback.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/FArrayPrint.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/FeatureTest.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Foreach.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Fortran.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Identifier.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Identifier.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/IndentStreambuf.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/IndexList.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/MallocUsed.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Marshal.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Marshal.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/NamedPair.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/PairIter.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Pool.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Pool.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/RadixSort.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/Range.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/SameType.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/SimpleArrayOps.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/StaticAssert.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/TeeStreambuf.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/TypeList.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/TypeListMap.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/TypeUtil.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/VecMap.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/VecSet.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/ci_string.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/ci_string.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/config_google.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/dense_hash_map delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/densehashtable.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/hashtable-common.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/libc_allocator_with_realloc.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/nested_iterator.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/nested_range.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/random_access_iterator_wrapper.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/sparse_hash_map delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/sparseconfig.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/sparsehashtable.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/sparsetable delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/string_case_compare.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/tokenize.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/tokenize.hpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/type_traits_google.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/assert_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/config_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eabase_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompiler_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompilertraits_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eaplatform_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_allocator_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/generic_iterator_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/int_to_type_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/memory_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/pair_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/rdestl_common.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_compound_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_fundamental_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_pod_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_properties_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_transformations_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_eastl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_rdestl.h delete mode 100644 packages/stk/stk_classic/stk_util/stk_util/util/vectorization.hpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/UnitTestBoost.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/UnitTestMain.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/UnitTestParallel.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/UnitTestRange.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/UnitTest_iterator_wrapper.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestTimer.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestWriter.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestCPUTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestDemangle.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestLogControl.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestOutputLog.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestReportHandler.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestThrowMacros.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestWallTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/parallel/CMakeLists.txt delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestDistributedIndex.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestParallelMain.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestCSet.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestFormatTime.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIdentifier.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIndentStreambuf.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestMallocUsed.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestMarshal.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestPrintTable.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestTeeStreambuf.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_filter_iterator.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_nested_iterator.cpp delete mode 100644 packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_nested_range.cpp diff --git a/packages/stk/stk_classic/CMakeLists.txt b/packages/stk/stk_classic/CMakeLists.txt deleted file mode 100644 index 17ea7cb943ca..000000000000 --- a/packages/stk/stk_classic/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ - - -# -# A) Define the package -# - -# ENABLE_SHADOWING_WARNINGS not possible, because of TBB -TRIBITS_SUBPACKAGE(Classic) - -# -# B) Set up package-specific options -# - -TRIBITS_ADD_OPTION_AND_DEFINE( - ${PACKAGE_NAME}_Trilinos - HAVE_STK_Trilinos - "Building as a Trilinos package" - ON - ) - -## set fortran mangling options -# -#IF("${FC_FN_UNDERSCORE}" STREQUAL "NO_UNDER") -# SET(FORTRAN_NO_UNDERSCORE ON) -#ELSEIF("${FC_FN_UNDERSCORE}" STREQUAL "UNDER") -# SET(FORTRAN_ONE_UNDERSCORE ON) -#ELSEIF("${FC_FN_UNDERSCORE}" STREQUAL "SECOND_UNDER") -# SET(FORTRAN_TWO_UNDERSCORES ON) -#ELSE() -# MESSAGE("Could not determine the Fortran mangling defaulting to no underscore.") -# SET(FORTRAN_NO_UNDERSCORE ON) -#ENDIF() - -# -# C) Add the libraries, tests, and examples -# - -ADD_SUBDIRECTORY(stk_util) - -ADD_SUBDIRECTORY(stk_mesh) - -ADD_SUBDIRECTORY(stk_algsup) - -IF (${PACKAGE_NAME}_ENABLE_Sacado) - ADD_SUBDIRECTORY(stk_expreval) -ENDIF() - -IF( ${PACKAGE_NAME}_ENABLE_SEACASIoss ) - ADD_SUBDIRECTORY(stk_io) -ENDIF() - -IF( ${PACKAGE_NAME}_ENABLE_FEI AND ${PACKAGE_NAME}_ENABLE_AztecOO ) - ADD_SUBDIRECTORY(stk_linsys) -ENDIF() - -IF( ${PACKAGE_NAME}_ENABLE_Zoltan AND TPL_ENABLE_MPI ) - ADD_SUBDIRECTORY(stk_rebalance) -ENDIF() - -ADD_SUBDIRECTORY(stk_transfer) - -IF( ${PACKAGE_NAME}_ENABLE_ThreadPool ) - ADD_SUBDIRECTORY(stk_search) - ADD_SUBDIRECTORY(stk_search_util) -ENDIF() - -IF( ${PACKAGE_NAME}_ENABLE_IntrepidCore AND ${PACKAGE_NAME}_ENABLE_SEACASIoss AND ${PACKAGE_NAME}_ENABLE_ThreadPool ) - ADD_SUBDIRECTORY(stk_percept) - ADD_SUBDIRECTORY(stk_adapt) -ENDIF() - -IF ( ${PACKAGE_NAME}_ENABLE_BoostLib AND ${PACKAGE_NAME}_ENABLE_TESTS ) - ADD_SUBDIRECTORY(stk_usecases) -ENDIF() - -# -# D) Do standard postprocessing -# - -TRIBITS_SUBPACKAGE_POSTPROCESS() diff --git a/packages/stk/stk_classic/README_stk_trilinos b/packages/stk/stk_classic/README_stk_trilinos deleted file mode 100644 index 79d439b69bbd..000000000000 --- a/packages/stk/stk_classic/README_stk_trilinos +++ /dev/null @@ -1,19 +0,0 @@ - -The STK package in Trilinos is a work in progress. - -stk_mesh and stk_linsys are building, a portion of stk_util is building -(only the portion needed to build stk_mesh), and stk_mesh/unit_tests tests -are building and running. - -To enable the STK package in your cmake configure script, add these directives: - -D Trilinos_ENABLE_STK:BOOL=ON - -D TPL_ENABLE_Boost:BOOL=ON - -D TPL_ENABLE_MPI:BOOL=ON - -D Boost_INCLUDE_DIRS:PATH=/sierra/Dev/william/sierra_code/TPLs_src/boost/1.38.0 - -STK currently has a mandatory dependence on those TPLs (MPI and Boost). This will be -re-visited as time permits. - -Note that the Boost path above is specific to the engsci scico lan, and may be -volatile. You should provide your own boost path... - diff --git a/packages/stk/stk_classic/cmake/Dependencies.cmake b/packages/stk/stk_classic/cmake/Dependencies.cmake deleted file mode 100644 index 0c1650291bd6..000000000000 --- a/packages/stk/stk_classic/cmake/Dependencies.cmake +++ /dev/null @@ -1,8 +0,0 @@ -SET(LIB_REQUIRED_DEP_PACKAGES Shards Teuchos) -SET(LIB_OPTIONAL_DEP_PACKAGES SEACASIoss FEI AztecOO ThreadPool Zoltan Intrepid Sacado) -SET(TEST_REQUIRED_DEP_PACKAGES SEACASExodus) -SET(TEST_OPTIONAL_DEP_PACKAGES) -SET(LIB_REQUIRED_DEP_TPLS Boost BoostLib) -SET(LIB_OPTIONAL_DEP_TPLS OpenNURBS) -SET(TEST_REQUIRED_DEP_TPLS) -SET(TEST_OPTIONAL_DEP_TPLS gtest) diff --git a/packages/stk/stk_classic/cmake/STKClassic_config.h.in b/packages/stk/stk_classic/cmake/STKClassic_config.h.in deleted file mode 100644 index 9ba66f79dbb6..000000000000 --- a/packages/stk/stk_classic/cmake/STKClassic_config.h.in +++ /dev/null @@ -1,11 +0,0 @@ - -/* Define to indicate that STK is in Trilinos (rather than in Sierra) */ -#cmakedefine HAVE_STK_Trilinos - -#cmakedefine HAVE_MPI - -#cmakedefine FORTRAN_NO_UNDERSCORE - -#cmakedefine FORTRAN_ONE_UNDERSCORE - -#cmakedefine FORTRAN_TWO_UNDERSCORES diff --git a/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic b/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic deleted file mode 100755 index 845889fe6a39..000000000000 --- a/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic +++ /dev/null @@ -1,3 +0,0 @@ -base_dir=`dirname $0` - -find . -type f -exec sed -i -f $base_dir/stk_to_stk_classic.sed {} \; diff --git a/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic.sed b/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic.sed deleted file mode 100644 index 0b339ca8ddd4..000000000000 --- a/packages/stk/stk_classic/conversion_scripts/stk_to_stk_classic.sed +++ /dev/null @@ -1,3 +0,0 @@ -s/namespace stk\([^a-zA-Z0-9_-]\)/namespace stk_classic\1/g -s/namespace stk$/namespace stk_classic/g -s/stk\([ \t]*::\)/stk_classic\1/g diff --git a/packages/stk/stk_classic/doc/.gitignore b/packages/stk/stk_classic/doc/.gitignore deleted file mode 100644 index e237d1a6e7fd..000000000000 --- a/packages/stk/stk_classic/doc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/html/ -/tags diff --git a/packages/stk/stk_classic/doc/Doxyfile b/packages/stk/stk_classic/doc/Doxyfile deleted file mode 100644 index 68b45641129c..000000000000 --- a/packages/stk/stk_classic/doc/Doxyfile +++ /dev/null @@ -1,4 +0,0 @@ -@INCLUDE = Doxyfile.common.config -@INCLUDE = Doxyfile.input - -# Do not edit this file, put local configuration overrides in Doxyfile.input diff --git a/packages/stk/stk_classic/doc/Doxyfile.common.config b/packages/stk/stk_classic/doc/Doxyfile.common.config deleted file mode 100644 index 3133070f1a29..000000000000 --- a/packages/stk/stk_classic/doc/Doxyfile.common.config +++ /dev/null @@ -1,1455 +0,0 @@ -# This file contains every configuration parameter known to doxygen along -# with some documentation for the paramter. The settings in this file represent -# the default settings for STK products' doxygen. - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "Sierra Toolkit" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = "Version of the Day" - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -# We will default to current directory and allow this to be overridden with -# the STK_FORCE_DOX_OUTPUT_DIR environment variable -OUTPUT_DIRECTORY = $(STK_FORCE_DOX_OUTPUT_DIR) - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 2 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the -# files it parses. With this tag you can assign which parser to use -# for a given extension. Doxygen has a built-in mapping, but you can -# override or extend it using this tag. The format is ext=language, -# where ext is a file extension, and language is one of the parsers -# supported by doxygen: IDL, Java, Javascript, CSharp, C, C++, D, PHP, -# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f -# files as C (default is Fortran), use: inc=Fortran f=C. Note that for -# custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip -# sources only. Doxygen will parse them like normal C++ but will -# assume all classes use public instead of private inheritance when no -# explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to -# indicate getter and setter methods for a property. Setting this -# option to YES (the default) will make doxygen replace the get and -# set methods by a property in the documentation. This will only work -# if the methods are indeed getting or setting a simple type. If this -# is not the case, or you want to show the methods anyway, you should -# set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use -# to determine which symbols to keep in memory and which to flush to -# disk. When the cache is full, less often used symbols will be -# written to disk. For small to medium size projects (<1000 input -# files) the default value is probably good enough. For larger -# projects a too small cache size can cause doxygen to be busy -# swapping symbols to and from disk most of the time causing a -# significant performance penality. If the system has enough physical -# memory increasing the cache will improve the performance by keeping -# more symbols in memory. Note that the value works on a logarithmic -# scale so increasing the size by one will roughly double the memory -# usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = NO - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = YES - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple -# directories then setting the SHOW_DIRECTORIES tag to YES will show -# the directory hierarchy in the documentation. The default is NO. - -SHOW_DIRECTORIES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or -# script that doxygen should invoke to get the current version for -# each file (typically from the version control system). Doxygen will -# invoke the program by executing (via popen()) the command -# , where is the value of the -# FILE_VERSION_FILTER tag, and is the name of an input -# file provided by doxygen. Whatever the program writes to standard -# output is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./index.dox - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.vhd *.vhdl - -FILE_PATTERNS = *.dox *.cpp *.hpp *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that -# should excluded from the INPUT source files. This way you can easily -# exclude a subdirectory from a directory tree whose root is specified -# with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files -# will be generated. Documented entities will be cross-referenced with -# these sources. Note: To get rid of all source code in the generated -# output, make sure also VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 4 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each -# generated HTML page will contain the date and time when the page was -# generated. Setting this to NO can help when comparing the output of -# multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name -# of the feed. A documentation feed provides an umbrella under which -# multiple documentation sets from a single provider (such as a -# company or product suite) can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should -# uniquely identify the documentation publisher. This should be a -# reverse domain-name style string, -# e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [0,1..20]) -# that doxygen will group on one line in the generated HTML documentation. -# Note that a value of 0 will completely suppress the enum values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 1 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = YES - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANSPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to -# the HTML output directory using the MATHJAX_RELPATH option. The -# destination directory should contain the MathJax.js script. For -# instance, if the mathjax directory is located at the same level as -# the HTML output directory, then MATHJAX_RELPATH should be -# ../mathjax. The default value points to the mathjax.org site, so you -# can quickly see the result without installing MathJax, but it is -# strongly recommended to install a local copy of MathJax before -# deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -GENERATE_LATEX = NO - -# SKIPPED THE REST - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# SKIPPED - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# SKIPPED - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# SKIPPED - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# SKIPPED - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# SKIPPED - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED += DOXYGEN_COMPILE STK_HAS_MPI - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES -# then this tag can be used to specify a list of macro names that -# should be expanded. The macro definition that is found in the -# sources will be used. Use the PREDEFINED tag if you want to use a -# different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = ./tags - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = YES - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called FreeSans.ttf to the -# output directory and reference it in all dot files that doxygen -# generates. This font does not include all possible unicode -# characters however, so when you need these (or just want a -# differently looking font) you can specify the font name using -# DOT_FONTNAME. You need need to make sure dot is able to find the -# font, which can be done by putting it in a standard location or by -# setting the DOTFONTPATH environment variable or by setting -# DOT_FONTPATH to the directory containing the font. - -DOT_FONTNAME = FreeSans.ttf - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif. -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YE diff --git a/packages/stk/stk_classic/doc/build_docs b/packages/stk/stk_classic/doc/build_docs deleted file mode 100755 index 0e5032dca513..000000000000 --- a/packages/stk/stk_classic/doc/build_docs +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -rm -f Doxyfile.input -rm -f index.dox - -# Create Doxyfile.input - -echo "# DO NOT EDIT THIS FILE, IT IS GENERATED BY ./build_docs" >> Doxyfile.input -echo >> Doxyfile.input - -for i in ../stk_*/doc/Doxyfile.input; do - echo "@INCLUDE = $i" >> Doxyfile.input -done -echo >> Doxyfile.input - -echo "# OVERRIDES, CHANGE ./build_docs IF YOU NEED TO CHANGE THESE" >> Doxyfile.input -echo "# If there needs to be a different configuration when generating doxygen" >> Doxyfile.input -echo "# STK-wide via build_docs versus generating doxygen for individual STK" >> Doxyfile.input -echo "# products, express that here" >> Doxyfile.input - -# Create index.dox - -echo "/** \mainpage Sierra Toolkit" > index.dox -echo " *" >> index.dox - -echo " * @section stk_products The Sierra Toolkit contains the following products:" >> index.dox -echo " *" >> index.dox -for i in ../stk_*/doc/Doxyfile.input; do - gawk -- '/#BANNER/{print " * - "substr($0, 8)}' $i >> index.dox - echo " *" >> index.dox -done -echo " *" >> index.dox - -echo " * @section stk_howto How to..." >> index.dox -echo " *" >> index.dox -for i in ../stk_*/doc/Doxyfile.input; do - gawk -- '/#HOWTO/{print " * - "substr($0, 7)}' $i >> index.dox - echo " *" >> index.dox -done -echo " *" >> index.dox - -echo " */" >> index.dox - -doxygen diff --git a/packages/stk/stk_classic/stk_adapt/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/CMakeLists.txt deleted file mode 100644 index f94a3e8dca37..000000000000 --- a/packages/stk/stk_classic/stk_adapt/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ - -ADD_SUBDIRECTORY(stk_adapt) - -IF( TPL_ENABLE_Netcdf) - IF (NOT CMAKE_BUILD_TYPE STREQUAL DEBUG) - TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) -# TRIBITS_ADD_TEST_DIRECTORIES(regression_tests) - ENDIF() -ENDIF() diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/regression_tests/CMakeLists.txt deleted file mode 100644 index efd604a8521f..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ - -INCLUDE(TribitsAddExecutableAndTest) - -ASSERT_DEFINED(PACKAGE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR) - -FILE(GLOB SOURCES *.cpp) - - -# An input exodus file is required to run these regression tests. - -#TRIBITS_ADD_EXECUTABLE_AND_TEST( -# adapt_RegressionTest -# SOURCES ${SOURCES} -# COMM serial mpi -# STANDARD_PASS_OUTPUT -# ) - diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestFileLoc.hpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestFileLoc.hpp deleted file mode 100644 index cdf2aa547573..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestFileLoc.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#if 1 - const std::string path_sep = "._."; - const std::string input_files_loc="./input_files"+path_sep; - const std::string output_files_loc="./output_files"+path_sep; -#else - const std::string input_files_loc="./input_files/"; - const std::string output_files_loc="./output_files/"; -#endif diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestLocalRefiner.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestLocalRefiner.cpp deleted file mode 100644 index d5900f360402..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestLocalRefiner.cpp +++ /dev/null @@ -1,992 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace adapt - { - namespace regression_tests - { - -#if !defined(__IBMCPP__) - bool DO_TESTS=true; -#else - // maybe it takes too long on dawn so we turn off these long-running tests... - bool DO_TESTS=false; -#endif - - bool LARGE_TEST_ONLY=false; - -#include "RegressionTestFileLoc.hpp" - -// const std::string input_files_loc="./input_files/"; -// const std::string output_files_loc="./output_files/"; - - static std::string post_fix[9] = {"np0", "np1", "np2", "np3", "np4", "np5", "np6", "np7", "np8"}; - -#define EXTRA_PRINT 0 - - //============================================================================= - //============================================================================= - //============================================================================= - - - static void normalize(double input_normal[3], double normal[3]) - { - double sum = std::sqrt(input_normal[0]*input_normal[0]+ - input_normal[1]*input_normal[1]+ - input_normal[2]*input_normal[2]); - normal[0] = input_normal[0] / sum; - normal[1] = input_normal[1] / sum; - normal[2] = input_normal[2] / sum; - } - - static void normalize(double input_output_normal[3]) - { - normalize(input_output_normal, input_output_normal); - } - - static double distance(double c0[3], double c1[3]) - { - return std::sqrt((c0[0]-c1[0])*(c0[0]-c1[0]) + (c0[1]-c1[1])*(c0[1]-c1[1]) + (c0[2]-c1[2])*(c0[2]-c1[2]) ); - } - - static void difference(double v01[3], double c0[3], double c1[3]) - { - v01[0] = c0[0] - c1[0]; - v01[1] = c0[1] - c1[1]; - v01[2] = c0[2] - c1[2]; - } - static double dot(double c0[3], double c1[3]) - { - return c0[0]*c1[0] + c0[1]*c1[1] + c0[2]*c1[2]; - } - - static double plane_dot_product(double plane_point[3], double plane_normal[3], double point[3]) - { - double normal[3]={0,0,0}; - normalize(plane_normal, normal); - double dot = 0.0; - for (int i = 0; i < 3; i++) - { - dot += (point[i] - plane_point[i])*normal[i]; - } - return dot; - } - - -#if 0 - static void project_point_to_plane(double plane_point[3], double plane_normal[3], double point[3], double projected_point[3]) - { - double normal[3]={0,0,0}; - normalize(plane_normal, normal); - double dot = plane_dot_product(plane_point, plane_normal, point); - for (int i = 0; i < 3; i++) - { - projected_point[i] = plane_point[i] + (point[i] - dot*normal[i]); - } - } -#endif - - class SetRefineField : public percept::ElementOp - { - percept::PerceptMesh& m_eMesh; - public: - SetRefineField(percept::PerceptMesh& eMesh) : m_eMesh(eMesh) { - } - - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - double plane_point[3] = {2,0,0}; - double plane_normal[3] = {1, .5, -.5}; - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - double *f_data = PerceptMesh::field_data_entity(field, element); - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - bool found = false; - for (unsigned inode=0; inode < num_node-1; inode++) - { - mesh::Entity & node_i = * elem_nodes[ inode ].entity(); - double *coord_data_i = PerceptMesh::field_data(coordField, node_i); - - for (unsigned jnode=inode+1; jnode < num_node; jnode++) - { - mesh::Entity & node_j = * elem_nodes[ jnode ].entity(); - double *coord_data_j = PerceptMesh::field_data(coordField, node_j); - - double dot_0 = plane_dot_product(plane_point, plane_normal, coord_data_i); - double dot_1 = plane_dot_product(plane_point, plane_normal, coord_data_j); - - // if edge crosses the plane... - if (dot_0*dot_1 < 0) - { - found=true; - break; - } - } - } - if (found) - f_data[0] = 1.0; - else - f_data[0] = 0.0; - - return false; // don't terminate the loop - } - virtual void init_elementOp() {} - virtual void fini_elementOp() {} - }; - - class SetUnrefineField : public percept::ElementOp - { - percept::PerceptMesh& m_eMesh; - public: - SetUnrefineField(percept::PerceptMesh& eMesh) : m_eMesh(eMesh) {} - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - double *f_data = PerceptMesh::field_data_entity(field, element); - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - bool found = true; - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - double *coord_data = PerceptMesh::field_data(coordField, node); - - if (coord_data[0] < 0.0 || coord_data[1] < 0.0) // || coord_data[2] > 1.1) - { - found=false; - break; - } - } - if (found) - f_data[0] = -1.0; - else - f_data[0] = 0.0; - - return false; // don't terminate the loop - } - virtual void init_elementOp() {} - virtual void fini_elementOp() {} - }; - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_ElementBased) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - if (LARGE_TEST_ONLY || !DO_TESTS) return; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_local_refiner_break_tet_to_tet_2 - - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"cylinder_with_5_holes.e"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - SetRefineField set_ref_field(eMesh); - eMesh.elementOpLoop(set_ref_field, refine_field); - - SetUnrefineField set_unref_field(eMesh); - //eMesh.elementOpLoop(set_ref_field, refine_field); - - eMesh.save_as( output_files_loc+"local_tet_N_5_ElementBased_0_"+post_fix[p_size]+".e"); - - ElementRefinePredicate erp(0, refine_field, 0.0); - - PredicateBasedElementAdapter - breaker(erp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 3; ipass++) - { - eMesh.elementOpLoop(set_ref_field, refine_field); - - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tet_N_5_ElementBased_1_ipass_"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - breaker.deleteParentElements(); - eMesh.save_as(output_files_loc+"local_tet_N_5_ElementBased_1_"+post_fix[p_size]+".e"); - -#if 0 - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - eMesh.elementOpLoop(set_unref_field, refine_field); - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tet_N_5_ElementBased_1_unref_ipass_"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as( output_files_loc+"local_tet_N_5_ElementBased_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - struct MyEdgeBasedRefinePredicate : public IEdgeBasedAdapterPredicate { - - MyEdgeBasedRefinePredicate(stk_classic::mesh::Selector * selector=0, stk_classic::mesh::FieldBase *field=0, double tolerance=0.0) : - IEdgeBasedAdapterPredicate(selector, field, tolerance) {} - - /// Return DO_NOTHING, DO_REFINE, DO_UNREFINE or sum of these - int operator()(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) - { - int mark = 0; - if (0 == m_selector || (*m_selector)(element)) - { - double plane_point[3] = {2,0,0}; - double plane_normal[3] = {1, 0, 0}; - - double dot_0 = plane_dot_product(plane_point, plane_normal, coord0); - double dot_1 = plane_dot_product(plane_point, plane_normal, coord1); - - // if edge crosses the plane... - if (dot_0 * dot_1 < 0) - { - mark |= DO_REFINE; - } - - if (coord0[1] < 0 && coord1[1] < 0) - { - mark |= DO_UNREFINE; - } - } - - return mark; - } - }; - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_EdgeBased) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - if (LARGE_TEST_ONLY || !DO_TESTS) return; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_local_refiner_break_tet_to_tet_2 - - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"cylinder_with_5_holes.e"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - if (0) - { - SetRefineField set_ref_field(eMesh); - eMesh.elementOpLoop(set_ref_field, refine_field); - } - - eMesh.save_as( output_files_loc+"local_tet_N_5_EdgeBased_0_"+post_fix[p_size]+".e"); - - MyEdgeBasedRefinePredicate mrp(0, refine_field, 0.0); - - PredicateBasedEdgeAdapter - breaker(mrp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 5; ipass++) - { - //eMesh.elementOpLoop(set_ref_field, refine_field); - - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_1_ipass_"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //breaker.deleteParentElements(); - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_1_"+post_fix[p_size]+".e"); - -#if 1 - for (int iunref_pass=0; iunref_pass < 5; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_1_unref_ipass_"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as( output_files_loc+"local_tet_N_5_EdgeBased_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - struct PlaneShock - { - double plane_point_init[3]; // = {2 + shock_displacement,0,0}; - double plane_normal[3]; // = {1, 0, 0}; - double plane_point[3]; // = {2 + shock_displacement,0,0}; - - PlaneShock() - { - plane_point_init[0]=0; - plane_point_init[1]=0; - plane_point_init[2]=0; - plane_point[0]=0; - plane_point[1]=0; - plane_point[2]=0; - plane_normal[0]=1; - plane_normal[1]=0; - plane_normal[2]=0; - } - - void setCurrentPlanePoint(double shock_displacement) - { - normalize(plane_normal); - plane_point[0] = plane_point_init[0] + shock_displacement*plane_normal[0]; - plane_point[1] = plane_point_init[1] + shock_displacement*plane_normal[1]; - plane_point[2] = plane_point_init[2] + shock_displacement*plane_normal[2]; - } - - }; - - static double shock_width = 1./5.0; - - static double shock_function(double x) - { - // normalize by width - double width = shock_width; // 1./5.0; - x /= width; - return std::tanh(x); - } - - - static double shock_diff(stk_classic::mesh::FieldBase* nodal_refine_field, percept::PerceptMesh& eMesh, - stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, double *coord0, double *coord1, PlaneShock& shock, double shock_displacement) - { - shock.setCurrentPlanePoint(shock_displacement); - double *plane_point = shock.plane_point; - double *plane_normal = shock.plane_normal; - -#if 0 - double proj_pt_0[3]={0,0,0}; - double proj_pt_1[3]={0,0,0}; - project_point_to_plane(plane_point, plane_normal, coord0, proj_pt_0); - project_point_to_plane(plane_point, plane_normal, coord1, proj_pt_1); -#endif - - double dot_0 = plane_dot_product(plane_point, plane_normal, coord0); - double dot_1 = plane_dot_product(plane_point, plane_normal, coord1); - - double v01[3] = {0,0,0}; - difference(v01, coord1, coord0); - normalize(v01); - normalize(plane_normal); - double v01dotn = std::abs(dot(v01, plane_normal)); - - double d01p = std::abs(dot_0)+std::abs(dot_1); - dot_0 = shock_function(dot_0); - dot_1 = shock_function(dot_1); - - if (nodal_refine_field) - { - double *fd0 = eMesh.field_data(nodal_refine_field, node0); - double *fd1 = eMesh.field_data(nodal_refine_field, node1); - fd0[0] = dot_0; - fd1[0] = dot_1; - } - - double d01 = distance(coord0, coord1); - - return (1 + 0*d01 + 0*d01p + 0*v01dotn)*std::abs(dot_0 - dot_1); - } - - struct ShockBasedRefinePredicate : public IEdgeBasedAdapterPredicate { - - percept::PerceptMesh& m_eMesh; - stk_classic::mesh::FieldBase * m_nodal_refine_field; - PlaneShock m_shock; - double m_shock_displacement; - double m_shock_diff_criterion; - - ShockBasedRefinePredicate(stk_classic::mesh::FieldBase* nodal_refine_field, percept::PerceptMesh& eMesh, stk_classic::mesh::Selector* selector, stk_classic::mesh::FieldBase *field, double tolerance, - PlaneShock shock, double shock_displacement=0, double shock_diff_criterion=0.4) : - IEdgeBasedAdapterPredicate(selector, field, tolerance), m_eMesh(eMesh),m_nodal_refine_field(nodal_refine_field), m_shock(shock), m_shock_displacement(shock_displacement), - m_shock_diff_criterion(shock_diff_criterion) {} - - - /// Return DO_NOTHING, DO_REFINE, DO_UNREFINE or sum of these - int operator()(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) - { - int mark=0; - if (0 == m_selector || (*m_selector)(element)) - { - - // refine check - double d01 = shock_diff(m_nodal_refine_field, m_eMesh, node0, node1, coord0, coord1, m_shock, m_shock_displacement); - if ( d01 > m_shock_diff_criterion) // 0.05, 0.2 - { - mark |= DO_REFINE; - } - - // unrefine check - d01 = shock_diff(0, m_eMesh, node0, node1, coord0, coord1, m_shock, m_shock_displacement); - if ( d01 <= m_shock_diff_criterion/2.0 ) // 0.05, 0.2 - { - mark |= DO_UNREFINE; - } - - } - return mark; - } - - //double *fdata = stk_classic::mesh::field_data( *static_cast(m_field) , entity ); - //return m_selector(entity) && fdata[0] > 0; - }; - - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_EdgeBased_shock) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - if (LARGE_TEST_ONLY || !DO_TESTS) return; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_local_refiner_break_tet_to_tet_2 - - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"cylinder_with_5_holes.e"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* nodal_refine_field = eMesh.add_field("nodal_refine_field", eMesh.node_rank(), scalarDimension); - eMesh.commit(); - - if (0) - { - SetRefineField set_ref_field(eMesh); - eMesh.elementOpLoop(set_ref_field, refine_field); - } - - eMesh.save_as( output_files_loc+"local_tet_N_5_EdgeBased_shock_0_"+post_fix[p_size]+".e"); - - PlaneShock shock; - - ShockBasedRefinePredicate srp(nodal_refine_field, eMesh, 0, refine_field, 0.0, shock, 0.0); - - PredicateBasedEdgeAdapter - breaker(srp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - for (int ipass=0; ipass < 3; ipass++) - { - //eMesh.elementOpLoop(set_ref_field, refine_field); - - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_shock_1_ipass_"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - breaker.deleteParentElements(); - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_shock_1_"+post_fix[p_size]+".e"); - -#if 0 - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tet_N_5_EdgeBased_shock_1_unref_ipass_"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as( output_files_loc+"local_tet_N_5_EdgeBased_shock_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - - static void do_moving_shock_test(int num_time_steps, bool save_intermediate=false, bool delete_parents=false) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - shock_width = 1./5.0; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_local_refiner_break_tet_to_tet_2 - - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"cylinder_with_5_holes.e"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* nodal_refine_field = eMesh.add_field("nodal_refine_field", eMesh.node_rank(), scalarDimension); - eMesh.commit(); - - std::cout << "moving_shock initial number elements= " << eMesh.get_number_elements() << std::endl; - - eMesh.save_as( output_files_loc+"moving_shock_"+post_fix[p_size]+".e.0"); - - PlaneShock shock; - shock.plane_point_init[0] = 2.0; - shock.plane_point_init[1] = 0.0; - shock.plane_point_init[2] = 0.0; - shock.plane_normal[0] = 1; - shock.plane_normal[1] = 0; - shock.plane_normal[2] = 0; - - ShockBasedRefinePredicate srp(nodal_refine_field, eMesh, 0, refine_field, 0.0, shock, 0.0, 0.4); - - PredicateBasedEdgeAdapter - breaker(srp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - double delta_shock_displacement = 0.2; - double shock_displacement = -2.0; - int num_ref_passes = 2; - int num_unref_passes = 3; - - for (int istep = 0; istep < num_time_steps; istep++) - { - std::cout << "P[" << eMesh.get_rank() << "] istep= " << istep << std::endl; - - breaker.getRefinePredicate().m_shock_displacement = shock_displacement; - - for (int ipass=0; ipass < num_ref_passes; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - if (save_intermediate) - eMesh.save_as(output_files_loc+"tmp_moving_shock_ref_istep_ipass_"+toString(istep)+"_"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //breaker.getNodeRegistry().init_entity_repo(); - for (int iunref_pass=0; iunref_pass < num_unref_passes; iunref_pass++) - { - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << " unref list size= " << elements_to_unref.size() << std::endl; - breaker.unrefineTheseElements(elements_to_unref); - if (save_intermediate) - eMesh.save_as(output_files_loc+"tmp_moving_shock_unref_istep_ipass_"+toString(istep)+"_"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - } - - if (delete_parents && istep == num_time_steps-1) - { - breaker.deleteParentElements(); - } - if (istep == num_time_steps-1 || save_intermediate) - eMesh.save_as(output_files_loc+"moving_shock_"+post_fix[p_size]+".e."+toString(istep+1) ); - - shock_displacement += delta_shock_displacement; - - } - - eMesh.save_as(output_files_loc+"final_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - for (int iunref=0; iunref < 10; iunref++) - { - breaker.unrefineAll(); - } - breaker.deleteParentElements(); - std::cout << "moving_shock final number elements= " << eMesh.get_number_elements() << std::endl; - eMesh.save_as(output_files_loc+"final_unrefed_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - - // end_demo - } - - } - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_EdgeBased_moving_shock) - { - //if (1) return; - const bool do_full_demo = false; - if (LARGE_TEST_ONLY || !DO_TESTS) return; - if (do_full_demo) - { - int num_time_steps = 10; // 10 for stress testing - for (int istep=1; istep <= num_time_steps; istep++) - do_moving_shock_test(istep, false, true); - } - else - // normal regression testing - { - int num_time_steps = 3; // 10 for stress testing - bool save_intermediate=true; - do_moving_shock_test(num_time_steps, save_intermediate); - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - - static void do_moving_shock_test_cyl_sidesets(int num_time_steps, bool save_intermediate=false, bool delete_parents=false) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - shock_width = 1./25.0; - double shock_diff_criterion = 0.04; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size==1 || p_size == 3) - { - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"cylinder_tet4_0.e"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* nodal_refine_field = eMesh.add_field("nodal_refine_field", eMesh.node_rank(), scalarDimension); - eMesh.commit(); - - std::cout << "moving_shock initial number elements= " << eMesh.get_number_elements() << std::endl; - - eMesh.save_as( output_files_loc+"cyl_sidesets_moving_shock_"+post_fix[p_size]+".e.0"); - - PlaneShock shock; - shock.plane_point_init[0] = 0.0; - shock.plane_point_init[1] = 0.0; - shock.plane_point_init[2] = 0.0; - shock.plane_normal[0] = 1; - shock.plane_normal[1] = 0; - shock.plane_normal[2] = 0; - - ShockBasedRefinePredicate srp(nodal_refine_field, eMesh, 0, refine_field, 0.0, shock, 0.0, shock_diff_criterion); - - PredicateBasedEdgeAdapter - breaker(srp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - // x,y,z: [-.08,.08],[-.08,.08],[-.5,-.2] - double delta_shock_displacement = 0.2; - double shock_displacement = 0.0; - int num_ref_passes = 3; - int num_unref_passes = 3; - - for (int istep = 0; istep < num_time_steps; istep++) - { - std::cout << "P[" << eMesh.get_rank() << "] istep= " << istep << std::endl; - - breaker.getRefinePredicate().m_shock_displacement = shock_displacement; - - for (int ipass=0; ipass < num_ref_passes; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << " moving_shock number elements= " << eMesh.get_number_elements() << std::endl; - } - - //breaker.deleteParentElements(); - eMesh.save_as(output_files_loc+"tmp_cyl_sidesets_moving_shock_"+post_fix[p_size]+".e"); - //exit(123); - - //breaker.getNodeRegistry().init_entity_repo(); - for (int iunref_pass=0; iunref_pass < num_unref_passes; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - std::cout << "P[" << eMesh.get_rank() << "] done... iunref_pass= " << iunref_pass << " moving_shock number elements= " << eMesh.get_number_elements() << std::endl; - } - -// breaker.deleteParentElements(); - eMesh.save_as(output_files_loc+"tmp_cyl_sidesets_moving_shock_"+post_fix[p_size]+".e"); - //exit(123); - - if (delete_parents && istep == num_time_steps-1) - { - breaker.deleteParentElements(); - } - if (istep == num_time_steps-1 || save_intermediate) - eMesh.save_as(output_files_loc+"cyl_sidesets_moving_shock_"+post_fix[p_size]+".e."+toString(istep+1) ); - - shock_displacement += delta_shock_displacement; - - } - - eMesh.save_as(output_files_loc+"cyl_sidesets_final_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - for (int iunref=0; iunref < 10; iunref++) - { - breaker.unrefineAll(); - eMesh.save_as(output_files_loc+"cyl_sidesets_final_moving_shock_"+post_fix[p_size]+"_unrefAll_pass_"+toString(iunref)+".e."+toString(num_time_steps) ); - } - - if (0) - breaker.deleteParentElements(); - std::cout << "moving_shock final number elements= " << eMesh.get_number_elements() << std::endl; - eMesh.save_as(output_files_loc+"cyl_sidesets_final_unrefed_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - //exit(123); - - // end_demo - } - } - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_EdgeBased_moving_shock_cyl_sidesets) - { - const bool do_full_demo = false; - if (LARGE_TEST_ONLY || !DO_TESTS) return; - if (do_full_demo) - { - int num_time_steps = 10; // 10 for stress testing - for (int istep=1; istep <= num_time_steps; istep++) - do_moving_shock_test_cyl_sidesets(istep, false, true); - } - else - // normal regression testing - { - int num_time_steps = 1; // 10 for stress testing - do_moving_shock_test_cyl_sidesets(num_time_steps); - } - } - - - //============================================================================= - //============================================================================= - //============================================================================= - - - static void do_moving_shock_test_large_test(int num_time_steps, bool save_intermediate=false, bool delete_parents=false) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // shock_width = 1./50.; //1./25.0; - // shock_diff_criterion = 0.1; - shock_width = 1./500.; //1./25.0; - double shock_diff_criterion = 0.1; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size==1 || p_size == 2 || p_size == 8) - { - percept::PerceptMesh eMesh; - eMesh.open(input_files_loc+"large_testh1tet.g"); - - Local_Tet4_Tet4_N break_tet_to_tet_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* nodal_refine_field = eMesh.add_field("nodal_refine_field", eMesh.node_rank(), scalarDimension); - eMesh.commit(); - - //eMesh.delete_side_sets(); - - std::cout << "moving_shock initial number elements= " << eMesh.get_number_elements() << std::endl; - - eMesh.save_as( output_files_loc+"large_scale_moving_shock_"+post_fix[p_size]+".e.0"); - - stk_classic::mesh::Selector univ_selector(eMesh.get_fem_meta_data()->universal_part()); - - PlaneShock shock; - shock.plane_point_init[0] = 0.0; - shock.plane_point_init[1] = -0.07; - shock.plane_point_init[2] = -0.35; - shock.plane_normal[0] = 0; - shock.plane_normal[1] = .25/std::sqrt(.25*.25+1.); - shock.plane_normal[2] = 1./std::sqrt(.25*.25+1.); - - ShockBasedRefinePredicate srp(nodal_refine_field, eMesh, &univ_selector, refine_field, 0.0, shock, 0.0, shock_diff_criterion); - - PredicateBasedEdgeAdapter - breaker(srp, - eMesh, break_tet_to_tet_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - //breaker.setIgnoreSideSets(true); - - // x,y,z: [-.08,.08],[-.08,.08],[-.5,-.2] - double delta_shock_displacement = 0.2*0.08*(10./((double)num_time_steps)); - double shock_displacement = 0.0; - int num_ref_passes = 2; - int num_unref_passes = 3; - - for (int istep = 0; istep < num_time_steps; istep++) - { - std::cout << "P[" << eMesh.get_rank() << "] istep= " << istep << std::endl; - - breaker.getRefinePredicate().m_shock_displacement = shock_displacement; - - for (int ipass=0; ipass < num_ref_passes; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << " moving_shock number elements= " << eMesh.get_number_elements() << std::endl; - } - - eMesh.save_as(output_files_loc+"large_scale_moving_shock_"+post_fix[p_size]+"_ref.e"); - //exit(123); - - breaker.getNodeRegistry().init_entity_repo(); - for (int iunref_pass=0; iunref_pass < num_unref_passes; iunref_pass++) - { - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - breaker.unrefineTheseElements(elements_to_unref); - std::cout << "P[" << eMesh.get_rank() << "] done... iunref_pass= " << iunref_pass << " moving_shock number elements= " << eMesh.get_number_elements() << std::endl; - } - - if (delete_parents && istep == num_time_steps-1) - { - breaker.deleteParentElements(); - } - if (istep == num_time_steps-1 || save_intermediate) - eMesh.save_as(output_files_loc+"large_scale_moving_shock_"+post_fix[p_size]+".e."+toString(istep+1) ); - - shock_displacement += delta_shock_displacement; - - } - - eMesh.save_as(output_files_loc+"large_scale_final_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - for (int iunref=0; iunref < 10; iunref++) - { - breaker.unrefineAll(); - } - breaker.deleteParentElements(); - std::cout << "moving_shock final number elements= " << eMesh.get_number_elements() << std::endl; - eMesh.save_as(output_files_loc+"large_scale_final_unrefed_moving_shock_"+post_fix[p_size]+".e."+toString(num_time_steps) ); - - // end_demo - } - } - - STKUNIT_UNIT_TEST(regr_localRefiner, break_tet_to_tet_N_5_EdgeBased_moving_shock_large_test) - { - const bool do_full_demo = false; - if (!LARGE_TEST_ONLY || !DO_TESTS) return; - if (do_full_demo) - { - int num_time_steps = 10; // 10 for stress testing - for (int istep=1; istep <= num_time_steps; istep++) - do_moving_shock_test_large_test(istep, false, true); - } - else - // normal regression testing - { - int num_time_steps = 30; // 10 for stress testing - do_moving_shock_test_large_test(num_time_steps, true); - //int num_time_steps = 3; // 10 for stress testing - //do_moving_shock_test_large_test(num_time_steps); - } - } - - } - } -} diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMain.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMain.cpp deleted file mode 100644 index 63cada2acd51..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMain.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include -#include - -#include - -#if !PY_PERCEPT -STKUNIT_MAIN(argc, argv) -#else - int main() {return 0;} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMeshColorer.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMeshColorer.cpp deleted file mode 100644 index 729df177cebe..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestMeshColorer.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include - - -namespace stk_classic -{ - namespace adapt - { - namespace unit_tests - { - -#include "RegressionTestFileLoc.hpp" - - static stk_classic::diag::Writer & - dw() - { - //static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - int dw_enabled = 1; - static stk_classic::diag::Writer s_diagWriter(std::cout.rdbuf(), dw_enabled); - - s_diagWriter.setPrintMask(percept::LOG_NORM | percept::LOG_ALWAYS); - - return s_diagWriter; - } - -#define EXTRA_PRINT 0 - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(mesh_colorer, test1) - { - EXCEPTWATCH; - - dw().m(percept::LOG_MESH_COLORER) << "STKUNIT_UNIT_TEST::mesh_colorer::test1 " << stk_classic::diag::dendl; - - percept::PerceptMesh eMesh(3u); - if (eMesh.get_parallel_size() <= 3) - { - const size_t numxyz=3; - const size_t num_x = numxyz; - const size_t num_y = numxyz; - const size_t num_z = numxyz; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - eMesh.new_mesh(percept::GMeshSpec(config_mesh)); - int vectorDimension = 0; - stk_classic::mesh::FieldBase *element_color_field = eMesh.add_field("element_colors", eMesh.element_rank(), vectorDimension); - eMesh.commit(); - - std::vector mer; mer.push_back(eMesh.element_rank()); - Colorer meshColorer(mer); - unsigned elementType = 0u; - meshColorer.color(eMesh, &elementType, 0, element_color_field); - eMesh.save_as(output_files_loc+"cube_colored.e"); - //std::cout << "Mesh coloring info: " << meshColorer.getElementColors() << std::endl; - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(mesh_colorer, test_quad) - { - EXCEPTWATCH; - - dw().m(percept::LOG_MESH_COLORER) << "STKUNIT_UNIT_TEST::mesh_colorer::test_quad " << stk_classic::diag::dendl; - - percept::PerceptMesh eMesh(2u); - if (eMesh.get_parallel_size() == 1 || eMesh.get_parallel_size() == 3) - { - eMesh.open(input_files_loc+"break_test._.quad._.square._.square_quad4.e"); - int vectorDimension = 0; - stk_classic::mesh::FieldBase *element_color_field = eMesh.add_field("element_colors", eMesh.element_rank(), vectorDimension); - eMesh.commit(); - - std::vector mer; mer.push_back(eMesh.face_rank()); - Colorer meshColorer(mer); - unsigned elementType = 0u; - meshColorer.color(eMesh, &elementType, 0, element_color_field); - //std::cout << "Mesh coloring info: " << meshColorer.getElementColors() << std::endl; - eMesh.print_info(); - eMesh.dump(); - eMesh.save_as(output_files_loc+"square_quad4_colored.e"); - } - } - - } - } -} diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestNodeRegistry.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestNodeRegistry.cpp deleted file mode 100644 index 1a34e5f757bf..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestNodeRegistry.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -namespace stk_classic -{ - namespace adapt - { - namespace regression_tests - { - -#include "RegressionTestFileLoc.hpp" - - -#define EXTRA_PRINT 0 - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== -#if 1 - STKUNIT_UNIT_TEST(nodeRegistry_regr, test_parallel_0) - { - using namespace mesh; - using namespace fem; - - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_nodeRegistry_test_parallel_1 - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if ( p_size == 3) - { - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - //unsigned p_rank = mesh.parallel_rank(); - //unsigned p_size = mesh.parallel_size(); - const EntityRank elem_rank = meta_data.element_rank(); - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - stk_classic::mesh::Part * owned_part = & meta_data.locally_owned_part(); - stk_classic::mesh::Part * shared_part = & meta_data.globally_shared_part(); - stk_classic::mesh::PartVector owned_parts(1,owned_part); - stk_classic::mesh::PartVector shared_parts(1,shared_part); - - // Create nodes - Entity *node=0; - node = &mesh.declare_entity(0, - p_rank+1, - empty_parts); - - - Entity& elem = mesh.declare_entity(elem_rank, - p_rank+1, - empty_parts); - - - if (p_rank==0 || p_rank==2) - { - node = &mesh.declare_entity(0, - 2, - empty_parts); - mesh.declare_relation(elem, *node, 0); - } - else - { - mesh.declare_relation(elem, *node, 0); - } - - - - mesh.modification_end(); - } - - //exit(123); - } -#endif - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== -#if 1 - STKUNIT_UNIT_TEST(nodeRegistry_regr, test_parallel_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_nodeRegistry_test_parallel_1 - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test._.quad._.square._.square_quad4.e"); - eMesh.commit(); - - //eMesh.print_info("square_quad4 before dist"); - //eMesh.save_as("./cube_hex9-orig.e"); - - //unsigned p_size = eMesh.get_parallel_size(); - unsigned p_rank = eMesh.get_rank(); - Util::setRank(eMesh.get_rank()); - - if (p_size != 3) // FIXME - return; - - bool useGhosting = true; - NodeRegistry nodeRegistry(eMesh, useGhosting); - nodeRegistry.initialize(); - - if (p_size == 3) - { - //if (p_rank != 0) - { - // pick an element on the processor boundary - /* P[1] element_local = 1 Elem: 5 nodes: 9 11 12 10 - * P[1] element_ghost = 0 Elem: 11 nodes: 12 25 26 10 - * P[2] element_local = 1 Elem: 11 nodes: 12 25 26 10 - * P[2] element_ghost = 0 Elem: 5 nodes: 9 11 12 10 - */ - - // for proc 1 - unsigned elem_num_local = 11; // edge #3 - unsigned elem_num_ghost = 5; // edge #2 - unsigned elem_20 = 20; - - stk_classic::mesh::Entity* element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - if (p_rank == 2) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - } - if (p_rank == 0) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_20); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_20); - } - - dw() << "P["< needed_entity_ranks(1, needed_entity_rank); - - /* - * 1st of three steps to create and associate new nodes - register need for new nodes, then check if node is remote, then get - * from remote proc if necessary; finally, the local node database is ready to be queried - * - * The pattern is to begin the step, loop over all elements (including ghosts) and invoke the local operation - * The method doForAllSubEntities is a utility for performing the operation on all the sub entities. - * If more granularity is desired, the member functions can be invoked directly for a particular sub-entity. - */ - nodeRegistry.beginRegistration(); - if (p_rank) - { - nodeRegistry.doForAllSubEntities(&NodeRegistry::registerNeedNewNode, element_local, needed_entity_ranks); - nodeRegistry.doForAllSubEntities(&NodeRegistry::registerNeedNewNode, element_ghost, needed_entity_ranks); - } - nodeRegistry.endRegistration(); - - std::cout << "P["<get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[0]); - - //EXPECT_EQ(nodeIds_onSE.m_entity_id_vector[0], 42u); - EXPECT_EQ(nodeIds_onSE.m_entity_id_vector[0], 41u); - // should be the same node on each proc - std::cout << "P[" << p_rank << "] nodeId = " << nodeIds_onSE << " node= " << node << std::endl; - } - - // end_demo - - } - //std::cout << "P[" << p_rank << "] exiting " << std::endl; - //Util::pause(true); - //eMesh.save_as("./cube_hex9.e"); - if (0) - { - MPI_Barrier( MPI_COMM_WORLD ); - exit(1); - } - } - } - //exit(123); - - } -#endif - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== -#if 1 - STKUNIT_UNIT_TEST(nodeRegistry_regr, test_parallel_2) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_nodeRegistry_test_parallel_2 - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - std::cout << "nodeRegistry_regr.test_parallel_2: p_size = " << p_size << std::endl; - - if (p_size == 1 || p_size == 3) - { - - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test._.quad._.square._.square_quad4.e"); - - eMesh.commit(); - - //eMesh.print_info("square_quad4 before dist"); - //eMesh.save_as("./cube_hex9-orig.e"); - - //unsigned p_size = eMesh.get_parallel_size(); - unsigned p_rank = eMesh.get_rank(); - Util::setRank(eMesh.get_rank()); - - if (p_size != 3) // FIXME - return; - - bool useGhosting = true; - NodeRegistry nodeRegistry(eMesh, useGhosting); - nodeRegistry.initialize(); - - if (p_size == 3) - { - //if (p_rank != 0) - { - // pick an element on the processor boundary - /* P[1] element_local = 1 Elem: 5 nodes: 9 11 12 10 - * P[1] element_ghost = 0 Elem: 11 nodes: 12 25 26 10 - * P[2] element_local = 1 Elem: 11 nodes: 12 25 26 10 - * P[2] element_ghost = 0 Elem: 5 nodes: 9 11 12 10 - */ - - // for proc 1 - unsigned elem_num_local = 11; // edge #3 - unsigned elem_num_ghost = 5; // edge #2 - unsigned elem_20 = 20; - - unsigned elem_num_local_proc_0 = elem_20; - unsigned elem_num_local_proc_1 = elem_num_local; - unsigned elem_num_local_proc_2 = elem_num_ghost; - - stk_classic::mesh::Entity* element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_1); - stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_2); - if (p_rank == 2) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_2); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_1); - } - if (p_rank == 0) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_0); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local_proc_0); - } - - dw() << "P["< needed_entity_ranks(2); - needed_entity_ranks[0] = NeededEntityType(eMesh.edge_rank(), 1u); - needed_entity_ranks[1] = NeededEntityType(eMesh.element_rank(), 1u); - - /* - * 1st of three steps to create and associate new nodes - register need for new nodes, then check if node is remote, then get - * from remote proc if necessary; finally, the local node database is ready to be queried - * - * The pattern is to begin the step, loop over all elements (including ghosts) and invoke the local operation - * The method doForAllSubEntities is a utility for performing the operation on all the sub entities. - * If more granularity is desired, the member functions can be invoked directly for a particular sub-entity. - */ - nodeRegistry.beginRegistration(); - if (p_rank) - { - nodeRegistry.doForAllSubEntities(&NodeRegistry::registerNeedNewNode, element_local, needed_entity_ranks); - nodeRegistry.doForAllSubEntities(&NodeRegistry::registerNeedNewNode, element_ghost, needed_entity_ranks); - } - nodeRegistry.endRegistration(); - - std::cout << "P["<get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE[0]->identifier()); - - //EXPECT_EQ(nodeId, 42u); - // should be the same node on each proc - std::cout << "P[" << p_rank << "] nodeId = " << nodeIds_onSE << " node= " << node << std::endl; - } - - if (1) - { - if (p_rank) - { - NodeIdsOnSubDimEntityType& nodeIds_onSE_1 = *(nodeRegistry.getNewNodesOnSubDimEntity(element_local, needed_entity_ranks[1].first, 0u)); - if (!nodeIds_onSE_1[0]) - throw std::logic_error("nodeRegistry_regr.parallel_2 logic err2"); - - stk_classic::mesh::Entity* node_1 = eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE_1[0]->identifier()); - - std::cout << "P[" << p_rank << "] nodeId_1 = " << nodeIds_onSE_1 << " node_1= " << node_1 << std::endl; - - - unsigned expectedId= 37u; -#if NODE_REGISTRY_MAP_TYPE_BOOST -#endif -#if NODE_REGISTRY_MAP_TYPE_STD - expectedId= 38u; -#endif -#if NODE_REGISTRY_MAP_TYPE_GOOGLE - expectedId= 39u; -#endif -#if SDS_ENTITY_TYPE_ID - expectedId= 37u; -#else - expectedId= 37u; -#endif - - - unsigned expectedId_p2= 41u; -#if SDS_ENTITY_TYPE_ID - expectedId_p2= 41u; -#else - expectedId_p2= 41u; -#endif - - if (p_rank==1) std::cout << "P["<identifier(), expectedId); - if (p_rank==2) EXPECT_EQ(nodeIds_onSE_1[0]->identifier(), expectedId_p2); - } - - } - - // end_demo - } - //std::cout << "P[" << p_rank << "] exiting " << std::endl; - //Util::pause(true); - //eMesh.save_as("./cube_hex9.e"); - if (0) - { - MPI_Barrier( MPI_COMM_WORLD ); - exit(1); - } - } - } - } -#endif - - }// namespace unit_tests - }// namespace adapt -}// namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestSTKMeshMemory.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestSTKMeshMemory.cpp deleted file mode 100644 index ca1420f1e623..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestSTKMeshMemory.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include - - -namespace stk_classic -{ - namespace adapt - { - namespace regression_tests - { - - -#define DO_MEMORY_ACCOUNTING 1 - -typedef uint64_t MemorySizeType; - -struct MemoryInfo -{ - MemorySizeType m_malloc_used; - MemorySizeType m_malloc_footprint; - MemorySizeType m_malloc_max_footprint; - static const MemorySizeType MB = 1024*1024; - - MemoryInfo() { get_memory_usage(); } - - void get_memory_usage() - { -#if DO_MEMORY_ACCOUNTING -#if !defined(SIERRA_PTMALLOC3_ALLOCATOR) && !defined(SIERRA_PTMALLOC2_ALLOCATOR) - std::cout << "WARNING: ptmalloc2|3 not compiled in so malloc_used info unavailable. Recompile with e.g. 'bake allocator=ptmalloc2 (or 3)'. Printing zeros..." << std::endl; -#else - -#endif - m_malloc_used = malloc_used(); - m_malloc_footprint = malloc_footprint(); - m_malloc_max_footprint = malloc_max_footprint(); -#else - m_malloc_used = 0; - m_malloc_footprint = 0; - m_malloc_max_footprint = 0; -#endif - } - void set_state() { get_memory_usage(); } - void get_increment() { - MemoryInfo old_state = *this; - get_memory_usage(); - m_malloc_used -= old_state.m_malloc_used; - m_malloc_footprint -= old_state.m_malloc_footprint; - } - -}; - -inline double MegaByte(MemorySizeType x) { return ((double)x/1024.0/1024.0); } - -std::ostream& operator<<(std::ostream& os, const MemoryInfo& mem) -{ - char buf[1024]; - sprintf(buf, "\n%20s %20s %20s\n%20g %20g %20g\n", "used [MB]", "footprint [MB]", "max_footprint [MB]", - MegaByte(mem.m_malloc_used), MegaByte(mem.m_malloc_footprint), MegaByte(mem.m_malloc_max_footprint) ); - os << buf; - return os; -} - - -STKUNIT_UNIT_TEST(adapt, count_memory) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1) - { - const unsigned n = 20; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture > fixture( pm , nx , ny, false); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - //eMesh.print_info("quad mesh",2); - - //const size_t num_new_tris = 2000*2000; - const size_t num_new_tris = 20*20; - const size_t num_nodes_per_tri = 3; - const size_t num_new_nodes = num_new_tris*num_nodes_per_tri; - MemoryInfo mem_delta_node; - double time = -stk_classic::percept::Util::cpu_time(); - - std::vector new_nodes, new_elements; - - eMesh.get_bulk_data()->modification_begin(); - eMesh.createEntities(eMesh.node_rank(), num_new_nodes, new_nodes); - eMesh.get_bulk_data()->modification_end(); - - mem_delta_node.get_increment(); - double mem_per_node = double(mem_delta_node.m_malloc_used)/double(num_new_nodes); - std::cout << "\nstk_mesh count_memory mem_per_node = " << mem_per_node << "\n" << std::endl; - - MemoryInfo mem_delta_elem_0, mem_delta_elem_1; - - eMesh.get_bulk_data()->modification_begin(); - eMesh.createEntities(eMesh.element_rank(), num_new_tris, new_elements); - eMesh.get_bulk_data()->modification_end(); - - mem_delta_elem_0.get_increment(); - - eMesh.get_bulk_data()->modification_begin(); - size_t i_node=0; - for (size_t i=0; ideclare_relation(*new_elements[i],*new_nodes[i_node],ordinal); - ++ordinal; - ++i_node; - } - } - eMesh.get_bulk_data()->modification_end(); - - mem_delta_elem_1.get_increment(); - double mem_per_elem_0 = double(mem_delta_elem_0.m_malloc_used)/double(num_new_tris); - double mem_per_elem_1 = double(mem_delta_elem_1.m_malloc_used)/double(num_new_tris); - - time += stk_classic::percept::Util::cpu_time(); - - std::cout << "\nstk_mesh count_memory mem_per_elem (no connectivity) = " << mem_per_elem_0 << " with connectivity= " << mem_per_elem_1 << " cpu= " << time << std::endl; - - } -} - - - } - } -} diff --git a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestUniformRefiner.cpp b/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestUniformRefiner.cpp deleted file mode 100644 index 0b8c83298b0b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/regression_tests/RegressionTestUniformRefiner.cpp +++ /dev/null @@ -1,3200 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -// smoothing tests -#define StackTraceTmp StackTrace -#undef StackTrace -#include -#include -#include -#include -#include -#include -#include -#define StackTrace StackTraceTmp - -// this is for testing the local-refine refactoring -#define UNIFORM_REFINER UniformRefiner -//#define UNIFORM_REFINER TestLocalRefiner - -#define DO_SMOOTHING_TEST 0 - -namespace stk_classic -{ - namespace adapt - { - namespace regression_tests - { - -#include "RegressionTestFileLoc.hpp" - -#define EXTRA_PRINT 0 - - static std::string procs_string[9] = {"np0", "np1", "np2", "np3", "np4", "np5", "np6", "np7", "np8"}; - - static void output_draw(std::string filename, std::string toFile) - { - std::ofstream file(filename.c_str()); - file << toFile; - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - //========= AREA for tests in progress of being debugged - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, pyramid_mesh) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - bool do_sidesets = true; - - if (p_size <= 1) - { - // create the mesh - { - bool doCommit = false; - stk_classic::percept::PyramidFixture mesh(MPI_COMM_WORLD, doCommit, do_sidesets); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - em1.save_as(input_files_loc+"pyramid_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"pyramid_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"pyramid_0.e"); - - //URP_Heterogeneous_3D break_pattern(eMesh1); - Pyramid5_Pyramid5_10 break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(!do_sidesets); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"pyramid_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - -#if 0 - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad9_to_quad9_shell_1) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this case can't be load balanced (I presume there are too few elements) - - if (p_size <= 1) - { - // start_demo_break_quad4_to_quad9_to_quad9_shell - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"freshell_quad4.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - ShellQuad4_ShellQuad9_1 break_quad4_to_quad9_1(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad9_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh enriched"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad9_1.g"); - eMesh.save_as(input_files_loc+"freshell_quad9_quad9_0.g"); - - } - } -#endif - - - STKUNIT_UNIT_TEST(regr_uniformRefiner, beam_enrich) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // create the mesh - { - - stk_classic::percept::BeamFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_beam ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - em1.save_as(input_files_loc+"beam_enrich_0.e"); - - } - - // enrich - { - stk_classic::percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"beam_enrich_0.e"); - //URP_Heterogeneous_3D break_pattern(eMesh); - Beam2_Beam3_1 break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.save_as(output_files_loc+"beam_enrich_0.e"); - - eMesh.print_info("beam", 2); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"beam_enrich_1.e"); - - } - } - } - - STKUNIT_UNIT_TEST(regr_uniformRefiner, beam_refine) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // create the mesh - { - - stk_classic::percept::BeamFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_beam ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - em1.save_as(input_files_loc+"beam_0.e"); - - } - - // refine - { - stk_classic::percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"beam_0.e"); - //URP_Heterogeneous_3D break_pattern(eMesh); - Beam2_Beam2_2 break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.save_as(output_files_loc+"beam_0.e"); - - eMesh.print_info("beam", 2); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"beam_1.e"); - - } - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //===================== Table generation - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, generate_tables) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - Elem::StdMeshObjTopologies::bootstrap(); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1) - { - std::ofstream file("./generated_refinement_tables.hpp"); - - file << "#ifndef STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP" << std::endl; - file << "#define STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP" << std::endl; - - file << - "/** New ref topo info \n" - "* ------------------\n" - "*\n" - "* {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord}\n" - "*\n" - "* struct RefinementTopologyExtraEntry\n" - "* {\n" - "* unsigned ordinal_of_node; // ordinal of node in the total list of nodes - corresponds to the shards node ordinal\n" - "* unsigned rank_of_subcell; // rank of the subcell this node is associated with \n" - "* unsigned ordinal_of_subcell; // ordinal of the subcell in the shards numbering (e.g. edge # 3)\n" - "* unsigned ordinal_of_node_on_subcell; // ordinal of the node on the subcell (whcih node it is on a subcell that has multiple nodes)\n" - "* unsigned num_nodes_on_subcell; // how many nodes exist on the subcell \n" - "* double parametric_coordinates[3];\n" - "* };\n" - "* \n" - "* Bootstrapping this file: to create this file, run the regression test RegressionTestUniformRefiner.cpp :: generate_tables after putting in\n" - "* a dummy entry in ./sierra_element/GeneratedRefinementTable.hpp. The run will produce a local file, generated_refinement_tables.hpp \n" - "* which can be checked against the gold copy of GeneratedRefinementTable.hpp, then copied over it. Add a call below to generate the \n" - "* actual new table data. \n" - "*/\n\n" - << std::endl; - - // FIXME -#if !(defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND)) - - Line2_Line2_2 :: printRefinementTopoX_Table(file); - - Beam2_Beam2_2 :: printRefinementTopoX_Table(file); - - ShellLine2_ShellLine2_2 :: printRefinementTopoX_Table(file); - ShellLine3_ShellLine3_2 :: printRefinementTopoX_Table(file); - Quad4_Quad4_4 :: printRefinementTopoX_Table(file); - Tri3_Tri3_4 :: printRefinementTopoX_Table(file); - ShellTri3_ShellTri3_4 :: printRefinementTopoX_Table(file); - ShellTri6_ShellTri6_4 :: printRefinementTopoX_Table(file); - ShellQuad4_ShellQuad4_4 :: printRefinementTopoX_Table(file); - ShellQuad8_ShellQuad8_4 :: printRefinementTopoX_Table(file); - Tet4_Tet4_8 :: printRefinementTopoX_Table(file); - Hex8_Hex8_8 :: printRefinementTopoX_Table(file); - Wedge6_Wedge6_8 :: printRefinementTopoX_Table(file); - Wedge15_Wedge15_8 :: printRefinementTopoX_Table(file); - - //Pyramid5_Pyramid5_10 :: printRefinementTopoX_Table(file); - //Pyramid13_Pyramid13_10 :: printRefinementTopoX_Table(file); - - // Not supported by Sierra - // Wedge18_Wedge18_8 :: printRefinementTopoX_Table(file); - - Line3_Line3_2 :: printRefinementTopoX_Table(file); - Beam3_Beam3_2 :: printRefinementTopoX_Table(file); - - Tri6_Tri6_4 :: printRefinementTopoX_Table(file); - Quad8_Quad8_4 :: printRefinementTopoX_Table(file); - Quad9_Quad9_4 :: printRefinementTopoX_Table(file); - Hex27_Hex27_8 :: printRefinementTopoX_Table(file); - Hex20_Hex20_8 :: printRefinementTopoX_Table(file); - Tet10_Tet10_8 :: printRefinementTopoX_Table(file); - -#endif - file << "#endif" << std::endl; - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //===================== Shell elements testing - //====================================================================================================================== - //====================================================================================================================== - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad8_to_quad8_shell) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this case can't be load balanced (I presume there are too few elements) - - if (p_size <= 1) - { - // start_demo_break_quad4_to_quad8_to_quad8_shell - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"freshell_quad4.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - ShellQuad4_ShellQuad8_1 break_quad4_to_quad8_1(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad8_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad8_1, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh enriched"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad8_1.g"); - eMesh.save_as(input_files_loc+"freshell_quad8_quad8_0.g"); - - } - - if (1 && p_size <= 1) - { - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"freshell_quad8_quad8_0.g"); - - ShellQuad8_ShellQuad8_4 break_quad8_to_quad_8(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - //eMesh.print_info("quad mesh"); - //eMesh.save_as(output_files_loc+"freshell_quad4_quad8_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad8_to_quad_8, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh enriched and refined"); - eMesh.save_as(output_files_loc+"freshell_quad8_quad8_1.g"); - // end_demo - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - -#if 0 - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad9_to_quad9_shell) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this case can't be load balanced (I presume there are too few elements) - - if (p_size <= 1) - { - // start_demo_break_quad4_to_quad9_to_quad9_shell - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"freshell_quad4.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - ShellQuad4_ShellQuad9_1 break_quad4_to_quad9_1(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad9_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh enriched"); - eMesh.save_as(output_files_loc+"freshell_quad4_quad9_1.g"); - eMesh.save_as(input_files_loc+"freshell_quad9_quad9_0.g"); - - } - -#if 0 - if (1 && p_size <= 1) - { - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"freshell_quad9_quad9_0.g"); - - ShellQuad9_ShellQuad9_4 break_quad9_to_quad_9(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - //eMesh.print_info("quad mesh"); - //eMesh.save_as(output_files_loc+"freshell_quad4_quad9_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad9_to_quad_9, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh enriched and refined"); - eMesh.save_as(output_files_loc+"freshell_quad9_quad9_1.g"); - // end_demo - - } -#endif - } -#endif - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad_shell) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this case can't be load balanced (I presume there are too few elements) - - if (p_size <= 1) - { - // start_demo_break_quad_to_quad_shell - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"freshell_quad4.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - ShellQuad4_ShellQuad4_4 break_quad_to_quad_4(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - eMesh.save_as(output_files_loc+"freshell_quad4_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad shell mesh refined"); - eMesh.save_as(output_files_loc+"freshell_quad4_1.g"); - // end_demo - - } - } - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tri_to_tri_shell) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - // this case can't be load balanced (I presume there are too few elements) - - if (p_size <= 1) - { - // start_demo_break_tri_to_tri_shell - - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"freshell_tri3.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - - ShellTri3_ShellTri3_4 break_tri_to_tri_4(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("tri mesh"); - eMesh.save_as(output_files_loc+"freshell_tri3_0.g"); - - UNIFORM_REFINER breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri shell mesh refined"); - eMesh.save_as(output_files_loc+"freshell_tri3_1.g"); - // end_demo - - } - - } - - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, draw1) - { - //std::cout << Quad4_Quad4_4::draw() << std::endl; - std::string dir = "./"; - output_draw(dir+"quad4.dot", Quad4_Quad4_4::draw(true) ); - output_draw(dir+"tet4.dot", Tet4_Tet4_8::draw() ); - output_draw(dir+"hex8.dot", Hex8_Hex8_8::draw(true) ); - output_draw(dir+"hex27.dot", Hex27_Hex27_8::draw(true, true) ); - output_draw(dir+"hex20.dot", Hex20_Hex20_8::draw(true, true) ); - output_draw(dir+"wedge6.dot", Wedge6_Wedge6_8::draw() ); - - output_draw(dir+"quad9.dot", Quad9_Quad9_4::draw(true, true)); - } - - STKUNIT_UNIT_TEST(regr_uniformRefiner, draw) - { - //std::cout << Quad4_Quad4_4::draw() << std::endl; - std::string dir = "./"; - output_draw(dir+"quad4.dot", Quad4_Quad4_4::draw(true) ); - output_draw(dir+"tet4.dot", Tet4_Tet4_8::draw() ); - output_draw(dir+"hex8.dot", Hex8_Hex8_8::draw(true) ); - output_draw(dir+"wedge6.dot", Wedge6_Wedge6_8::draw() ); - - output_draw(dir+"quad9.dot", Quad9_Quad9_4::draw(true)); - - // refine -#if 0 - std::cout << Line2_Line2_2::draw() << std::endl; - std::cout << Tri3_Tri3_4::draw() << std::endl; - std::cout << Tet4_Tet4_8::draw() << std::endl; - std::cout << Hex8_Hex8_8::draw() << std::endl; -#endif - // enrich - // typedef UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > Quad4_Quad9_1; - // typedef UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > Quad4_Quad8_1; - // typedef UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > Tri3_Tri6_1; - // typedef UniformRefinerPattern, shards::Tetrahedron<10>, 1, SierraPort > Tet4_Tet10_1; - // typedef UniformRefinerPattern, shards::Hexahedron<27>, 1, SierraPort > Hex8_Hex27_1; - // typedef UniformRefinerPattern, shards::Hexahedron<20>, 1, SierraPort > Hex8_Hex20_1; - - // // convert - // typedef UniformRefinerPattern, shards::Triangle<3>, 6 > Quad4_Tri3_6; - // typedef UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > Quad4_Tri3_4; - // typedef UniformRefinerPattern, shards::Tetrahedron<4>, 24 > Hex8_Tet4_24; - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_tri_6) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_tri - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4.e"); - - typedef UniformRefinerPattern, shards::Triangle<3>, 6 > Quad4_Tri3_6; - - UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - //UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6; - UNIFORM_REFINER breaker(eMesh, break_quad_to_tri_6, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.save_as(output_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4_out.e"); - eMesh.save_as(output_files_loc+"square_quad4_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_tri_4) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - - // start_demo_uniformRefiner_break_quad_to_tri - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4.e"); - - UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > break_quad_to_tri_4(eMesh); - - int scalarDimension = 0; // a scalar - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - //UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6; - UNIFORM_REFINER breaker(eMesh, break_quad_to_tri_4, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - //eMesh.save_as(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4_out.e"); - eMesh.save_as(output_files_loc+"square_quad4_tri3_4_out.e"); - // end_demo - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_quad - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4 > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UNIFORM_REFINER breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"square_quad4_ref_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// uses the Sierra-ported tables from framework/{element,mesh_modification} - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad_sierra) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_quad - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UNIFORM_REFINER breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"square_quad4_ref_sierra_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// uses the Sierra-ported tables from framework/{element,mesh_modification} - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad_sierra_sidesets) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - //FIXME - if (0) - { - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"sidesets"+path_sep+"quad_sidesets.e"); - eMesh.commit(); - eMesh.print_info("quad mesh"); - } - - if (p_size == 1 || p_size == 2) - { - // start_demo_uniformRefiner_break_quad_to_quad - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"sidesets"+path_sep+"quad_sidesets.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UNIFORM_REFINER breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.print_info("after refinement break_quad_to_quad_sierra_sidesets"); - - eMesh.save_as(output_files_loc+"quad_sidesets_sierra_out.e"); - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - // FIXME - move and/or copy to unit tests - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_tet4_24_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_tet4_24_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - //unsigned p_rank = eMesh.get_rank(); - Util::setRank(eMesh.get_rank()); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - UniformRefinerPattern, shards::Tetrahedron<4>, 24 > break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_tet_24_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - //eMesh.save_as(input_files_loc+"break_test"+path_sep+"quad"+path_sep+"square"+path_sep+"square_quad4_out.e"); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_tet_24_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_tet4_6_12_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_tet4_6_12_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Tet4_6_12 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_tet_6_12_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.setRemoveOldElements(true); - //breaker.setIgnoreSideSets(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_tet_6_12_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_tet4_6_12_2) - { - - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_tet4_6_12_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"break_test"+path_sep+"hex"+path_sep+"cylinder"+path_sep+"cylinder_hex8.e"); - - Hex8_Tet4_6_12 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info("test",2); - eMesh.print_info(); - eMesh.save_as(output_files_loc+"cylinder_hex8_tet4_6_12_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_tet, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex8_tet4_6_12_1.e"); - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, quad4_quad4_4_test_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, true); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture"); - eMesh.save_as(output_files_loc+"quad_fixture.e"); - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad_sierra_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = true; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size == 1 || p_size == 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("quad mesh"); - - eMesh.save_as(output_files_loc+"quad_fixture_0.e"); - eMesh.close(); - - for (int iBreak = 0; iBreak < 2; iBreak++) - { - std::cout << "\n\n\n ================ tmp Refine Pass = " << iBreak << std::endl; - - percept::PerceptMesh eMesh1(2); - std::string fileName = std::string(input_files_loc+"quad_fixture_")+toString(iBreak)+std::string(".e"); - eMesh1.open(fileName); - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - - // if (iBreak != 0) - // proc_rank_field = eMesh1.get_field("proc_rank"); - - UNIFORM_REFINER breaker(eMesh1, break_quad_to_quad_4, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - std::string fileName1 = std::string(output_files_loc+"quad_fixture_")+toString(iBreak+1)+std::string(".e"); - //eMesh1.save_as(fileName+"_ref.e"); - //eMesh1.print_info("quad_fixture_1.e"); - - eMesh1.save_as(fileName1); - eMesh1.close(); - - if (0 && iBreak==0) - { - percept::PerceptMesh e1(2); - std::cout << "\n\n\n ================ tmp eMesh1.open_read_only(quad_fixture_1.e) \n\n\n " << std::endl; - e1.open_read_only(input_files_loc+"quad_fixture_1.e"); - e1.print_info("quad_fixture_1_read.e"); - e1.close(); - } - } - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad_to_quad_sierra_2) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("quad mesh"); - - eMesh.save_as(output_files_loc+"quad_fixture_mbreak_0.e"); - eMesh.close(); - - - percept::PerceptMesh eMesh1(2); - std::string fileName = std::string(input_files_loc+"quad_fixture_mbreak_0.e"); - eMesh1.open(fileName); - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - - UNIFORM_REFINER breaker(eMesh1, break_quad_to_quad_4, proc_rank_field); - - for (int iBreak = 0; iBreak < 2; iBreak++) - { - std::cout << "\n\n\n ================ tmp Refine Pass = " << iBreak << std::endl; - - breaker.doBreak(); - std::string fileName1 = std::string(output_files_loc+"quad_fixture_mbreak_")+toString(iBreak+1)+std::string(".e"); - eMesh1.save_as(fileName1); - } - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad9) - { - EXCEPTWATCH; - - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.save_as(output_files_loc+"quad_fixture_quad9_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - - breaker.doBreak(); - eMesh.save_as(output_files_loc+"quad_fixture_quad9_1.e"); - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad8) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad8_1 break_quad4_to_quad8_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.save_as(output_files_loc+"quad_fixture_quad8_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad8_1, proc_rank_field); - - breaker.doBreak(); - eMesh.save_as(output_files_loc+"quad_fixture_quad8_1.e"); - eMesh.save_as(input_files_loc+"quad_fixture_quad8_quad8_0.e"); - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad8_to_quad8) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture_quad8_quad8_0.e"); - - Quad8_Quad8_4 break_quad8_to_quad8_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_quad8_to_quad8_4, proc_rank_field); - breaker.setIgnoreSideSets(false); - - breaker.doBreak(); - eMesh.save_as(output_files_loc+"quad_fixture_quad8_quad8_1.e"); - - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad9_to_quad9_0) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = false; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 1) - { - { - const unsigned n = 1; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.save_as(output_files_loc+"quad_fixture_quad9_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - - breaker.doBreak(); - eMesh.save_as(input_files_loc+"quad_1x1_quad9_quad9_0.e"); - } - - { - percept::PerceptMesh em1(2); - em1.open(input_files_loc+"quad_1x1_quad9_quad9_0.e"); - Quad9_Quad9_4 break_q9_q9(em1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = em1.add_field("proc_rank", em1.element_rank(), scalarDimension); - - em1.commit(); - - //em1.save_as(output_files_loc+"quad_1x1_quad9_0.e"); - - UNIFORM_REFINER breaker(em1, break_q9_q9, proc_rank_field); - breaker.setIgnoreSideSets(!doGenSideSets); - - breaker.doBreak(); - em1.save_as(output_files_loc+"quad_1x1_quad9_quad9_1.e"); - - } - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_quad4_to_quad9_to_quad9) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = true; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - { - //FIXME const unsigned n = 12; - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.save_as(output_files_loc+"quad_fixture_quad9_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - std::cout << "break_quad4_to_quad9_1.fixSurfaceAndEdgeSetNamesMap().size()= " - << break_quad4_to_quad9_1.fixSurfaceAndEdgeSetNamesMap().size() << std::endl; - - breaker.doBreak(); - eMesh.save_as(input_files_loc+"quad_fixture_quad9_quad9_0.e"); - //eMesh.print_info("quad_fixture_quad9_quad9_0.e", 2); - } - - { - percept::PerceptMesh em1(2); - em1.open(input_files_loc+"quad_fixture_quad9_quad9_0.e"); - Quad9_Quad9_4 break_q9_q9(em1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = em1.add_field("proc_rank", em1.element_rank(), scalarDimension); - - em1.commit(); - - //em1.save_as(output_files_loc+"quad_fixture_quad9_0.e"); - - UNIFORM_REFINER breaker(em1, break_q9_q9, proc_rank_field); - breaker.setIgnoreSideSets(!doGenSideSets); - - breaker.doBreak(); - em1.save_as(output_files_loc+"quad_fixture_quad9_quad9_1.e"); - - } - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tri_to_tri_sierra_0) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture > fixture( pm , nx , ny, true); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, false); - - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("tri mesh"); - - eMesh.save_as(output_files_loc+"quad_fixture_tri3.e"); - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tri_to_tri_sierra_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri3_4 break_tri_to_tri_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("tri mesh", 5); - eMesh.print_info("tri mesh"); - eMesh.save_as(output_files_loc+"quad_fixture_tri3_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri mesh refined"); - eMesh.save_as(output_files_loc+"quad_fixture_tri3_1.e"); - - if (0) - { - percept::PerceptMesh e1(2); - e1.open_read_only(input_files_loc+"quad_fixture_tri3_1.e"); - e1.print_info("after read", 3); - } - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tri3_to_tri6_sierra) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri6_1 break_tri3_to_tri6(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("tri mesh", 5); - eMesh.print_info("tri mesh tri6"); - eMesh.save_as(output_files_loc+"quad_fixture_tri3_tri6_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_tri3_to_tri6, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri mesh enriched"); - eMesh.save_as(output_files_loc+"quad_fixture_tri3_tri6_1.e"); - eMesh.save_as(input_files_loc+"quad_fixture_tri6_tri6_0.e"); - - if (0) - { - percept::PerceptMesh e1(2); - e1.open_read_only(input_files_loc+"quad_fixture_tri3_1.e"); - e1.print_info("after read", 3); - } - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tri3_to_tri6_to_tri6_sierra) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_break_tri3_to_tri6_to_tri6_sierra - - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture_tri6_tri6_0.e"); - - Tri6_Tri6_4 break_tri6_to_tri6(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("tri mesh tri6"); - eMesh.save_as(output_files_loc+"quad_fixture_tri6_tri6_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_tri6_to_tri6, proc_rank_field); - breaker.doBreak(); - - eMesh.print_info("tri mesh refined"); - eMesh.save_as(output_files_loc+"quad_fixture_tri6_tri6_1.e"); - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tet4_tet4_0) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4 - percept::PerceptMesh eMesh(3u); - eMesh.open_read_only(input_files_loc+"break_test"+path_sep+"tet"+path_sep+"cylinder-from-hex"+path_sep+"cylinder_tet4.e"); - - eMesh.save_as(output_files_loc+"cylinder_tet4_0.e"); - // end_demo - - } - } - -#if 1 - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tet4_tet4_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"break_test"+path_sep+"tet"+path_sep+"cylinder-from-hex"+path_sep+"cylinder_tet4_0.e"); - - Tet4_Tet4_8 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UNIFORM_REFINER breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - eMesh.save_as(output_files_loc+"cylinder_tet4_1.e"); - - breaker.doBreak(); - eMesh.save_as(output_files_loc+"cylinder_tet4_2.e"); - // end_demo - - } - } -#endif - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tet4_tet10_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"break_test"+path_sep+"tet"+path_sep+"cylinder-from-hex"+path_sep+"cylinder_tet4_0.e"); - - Tet4_Tet10_1 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UNIFORM_REFINER breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - eMesh.save_as(output_files_loc+"cylinder_tet10_1.e"); - // end_demo - - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tet4_tet10_tet10_1) - { - // FIXME - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"break_test"+path_sep+"tet"+path_sep+"cylinder-from-hex"+path_sep+"cylinder_tet4_0.e"); - - Tet4_Tet10_1 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UNIFORM_REFINER breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - eMesh.save_as(input_files_loc+"cylinder_tet10_1.e"); - eMesh.print_info("cylinder_tet10_1"); - // end_demo - - } - - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"cylinder_tet10_1.e"); - - Tet10_Tet10_8 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info("tet mesh"); - - UNIFORM_REFINER breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - //breaker.doBreak(); - - unsigned numRefines = 1; - for (unsigned iBreak = 0; iBreak < numRefines; iBreak++) - { - breaker.doBreak(); - } - - eMesh.save_as(output_files_loc+"cylinder_tet10_tet10_"+toString(numRefines)+"_"+procs_string[p_size]+".e"); - // end_demo - - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex8_8_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex8_8_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex8_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_hex_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex_hex_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex8_8_2) - { - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex8_8_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"break_test"+path_sep+"hex"+path_sep+"cylinder"+path_sep+"cylinder_hex8.e"); - - Hex8_Hex8_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(output_files_loc+"cylinder_hex8_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex8_1.e"); - - breaker.doBreak(); - eMesh.save_as(output_files_loc+"cylinder_hex8_2.e"); - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex27_1_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex27_1_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex8_hex27_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex8_hex27_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex27_1_2) - { - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex27_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"break_test"+path_sep+"hex"+path_sep+"cylinder"+path_sep+"cylinder_hex8.e"); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(output_files_loc+"cylinder_hex27_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex27_1.e"); - - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex20_1_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex20_1_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex20_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex8_hex20_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex8_hex20_cube1x1x")+toString(p_size)+std::string(".e")); - eMesh.save_as(std::string(input_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex20_1_2) - { - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex20_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"break_test"+path_sep+"hex"+path_sep+"cylinder"+path_sep+"cylinder_hex8.e"); - - Hex8_Hex20_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(output_files_loc+"cylinder_hex20_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex20_1.e"); - eMesh.save_as(input_files_loc+"cylinder_hex20_hex20_0.e"); - - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex20_hex20_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex20_hex20_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - if (p_size <= 3) - { - eMesh.open(std::string(input_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - Hex20_Hex20_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_1.e")); - } - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex20_hex20_1_2) - { - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex20_hex20_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"cylinder_hex20_hex20_0.e"); - - Hex20_Hex20_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.save_as(output_files_loc+"cylinder_hex20_hex20_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex20_hex20_1.e"); - - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex27_hex27_0) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex27_hex27_0 - - int scalarDimension = 0; // a scalar - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(input_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_0.e")); - } - - - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - eMesh.open(std::string(input_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_0.e")); - - Hex27_Hex27_8 break_hex_to_hex(eMesh); - - //stk_classic::mesh::FieldBase* proc_rank_field = eMesh.get_field("proc_rank"); - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info(); - //eMesh.save_as(std::string(output_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - // FIXME - breaker.setIgnoreSideSets(true); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(std::string(output_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_1.e")); - } - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, hex8_hex27_hex27_1) - { - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex27_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"break_test"+path_sep+"hex"+path_sep+"cylinder"+path_sep+"cylinder_hex8.e"); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(output_files_loc+"cylinder_hex8_hex27_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(input_files_loc+"cylinder_hex8_hex27_1.e"); - } - - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"cylinder_hex8_hex27_1.e"); - - Hex27_Hex27_8 break_hex_to_hex(eMesh); - - //stk_classic::mesh::FieldBase* proc_rank_field = eMesh.get_field("proc_rank"); - int scalarDimension = 0; - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_hex_to_hex, proc_rank_field); - //FIXME breaker.setIgnoreSideSets(false); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"cylinder_hex8_hex27_hex27_1.e"); - - } - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, wedge6_2) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_regr_uniformRefiner_wedge6_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("swept-wedge_0.e") ); - - eMesh.open("swept-wedge_0.e"); - - Wedge6_Wedge6_8 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"swept-wedge_1.e"); - - } - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, wedge6_enrich_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_regr_uniformRefiner_wedge6_enrich_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("swept-wedge_enrich_0.e") ); - - eMesh.open("swept-wedge_enrich_0.e"); - - Wedge6_Wedge15_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"swept-wedge_enrich_1.e"); - eMesh.save_as(input_files_loc+"swept-wedge_enrich_refine_0.e"); - - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, wedge6_enrich_refine) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_regr_uniformRefiner_wedge6_enrich_refine - - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - - if (p_size == 1) - { - PerceptMesh eMesh(3u); - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 2, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("tmp-swept-wedge_enrich_0.e") ); - - eMesh.open("tmp-swept-wedge_enrich_0.e"); - - Wedge6_Wedge15_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - eMesh.save_as(input_files_loc+"swept-wedge_enrich_refine_0.e"); - } - - percept::PerceptMesh eMesh(3u); - - if (p_size == 1) - { - eMesh.open(input_files_loc+"swept-wedge_enrich_refine_0.e"); - - Wedge15_Wedge15_8 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"swept-wedge_enrich_refine_1.e"); - - } - // end_demo - - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, heterogeneous_mesh) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::HeterogeneousFixture mesh(MPI_COMM_WORLD, false); - - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("heterogeneous", 4); - - em1.save_as(input_files_loc+"heterogeneous_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"heterogeneous_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_0.e"); - - URP_Heterogeneous_3D break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"heterogeneous_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, heterogeneous_mesh_sidesets) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::HeterogeneousFixture mesh(MPI_COMM_WORLD, false, true); - - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("heterogeneous", 4); - - em1.save_as(input_files_loc+"heterogeneous_sideset_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"heterogeneous_sideset_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_sideset_0.e"); - - URP_Heterogeneous_3D break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"heterogeneous_sideset_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, pyramid_mesh_enrich) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh_enrich - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::PyramidFixture mesh(MPI_COMM_WORLD, false); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("hetero_enrich", 4); - - em1.save_as(input_files_loc+"pyramid_enrich_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"pyramid_enrich_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // enrich the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"pyramid_enrich_0.e"); - //eMesh1.print_info("hetero_enrich_2", 4); - - URP_Heterogeneous_Enrich_3D break_pattern(eMesh1); - //int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = 0; //eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - //eMesh1.print_info("hetero_enrich_2", 4); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"pyramid_enrich_1.e"); - eMesh1.save_as(input_files_loc+"pyramid_quadratic_refine_0.e"); - eMesh1.close(); - } - } - // end_demo - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - -#if 0 - STKUNIT_UNIT_TEST(regr_uniformRefiner, beam_refine) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // create the mesh - { - - stk_classic::percept::BeamFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_beam ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - em1.save_as(input_files_loc+"beam_0.e"); - - } - - // refine - { - stk_classic::percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"beam_0.e"); - //URP_Heterogeneous_3D break_pattern(eMesh); - Beam2_Beam2_2 break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.save_as(output_files_loc+"beam_0.e"); - - eMesh.print_info("beam", 2); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"beam_1.e"); - - } - } - } - -#endif - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== -#if 1 - - STKUNIT_UNIT_TEST(regr_uniformRefiner, biplane_refine) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this case can't be load balanced? - - if (p_size <= 1) - { - // start_demo_biplane_refine - std::string input_mesh = input_files_loc+"salinas"+path_sep+"biplane.e"; - - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - URP_Heterogeneous_3D break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("biplane", 2); - eMesh.save_as(output_files_loc+"biplane_0.e"); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(false); - breaker.doBreak(); - - //eMesh.print_info("biplane", 2); - eMesh.save_as(output_files_loc+"biplane_1.e"); - - } - } - -#endif - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_tet_shell3_tet) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - std::cout << "p_size= " << p_size << std::endl; - // this case can't be load balanced (I presume there are too few elements) - if (p_size <= 1) - { - // start_demo_break_tet_shell3_tet - - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"tet_shell3_tet.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - URP_Heterogeneous_3D break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - unsigned numRefines = 2; - for (unsigned iBreak = 0; iBreak < numRefines; iBreak++) - { - breaker.doBreak(); - } - - eMesh.save_as(output_files_loc+"tet_shell3_tet_"+toString(numRefines)+".g"); - eMesh.close(); - - // end_demo - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, break_hex_shell4_hex) - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - // this case can't be load balanced (I presume there are too few elements) - //if (p_size <= 3) - if (p_size == 1) - { - // start_demo_break_hex_shell4_hex - std::string input_mesh = input_files_loc+"shell-tests"+path_sep+"hex_shell4_hex.g"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - percept::PerceptMesh eMesh(3u); - eMesh.open(input_mesh); - - URP_Heterogeneous_3D break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - eMesh.save_as(output_files_loc+"hex_shell4_hex_1.g"); - eMesh.close(); - - // end_demo - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, heterogeneous_mesh_enrich) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh_enrich - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::HeterogeneousFixture mesh(MPI_COMM_WORLD, false); - - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("hetero_enrich", 4); - - - em1.save_as(input_files_loc+"heterogeneous_enrich_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"heterogeneous_enrich_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // enrich the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_enrich_0.e"); - //eMesh1.print_info("hetero_enrich_2", 4); - - URP_Heterogeneous_Enrich_3D break_pattern(eMesh1); - //int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = 0; //eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - //eMesh1.print_info("hetero_enrich_2", 4); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"heterogeneous_enrich_1.e"); - eMesh1.save_as(input_files_loc+"heterogeneous_quadratic_refine_0.e"); - eMesh1.close(); - } - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, heterogeneous_quadratic_refine) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_quadratic_refine - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_quadratic_refine_0.e"); - - URP_Heterogeneous_QuadraticRefine_3D break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UNIFORM_REFINER breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh1.save_as(output_files_loc+"heterogeneous_quadratic_refine_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - //here - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - STKUNIT_UNIT_TEST(regr_uniformRefiner, wedge6_wedge18_enrich) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_regr_uniformRefiner_wedge6_wedge18_enrich - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - - //unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - mesh::BulkData *bulk = - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("")); - //std::string("swept-wedge6_18_enrich_0.e") ); - - percept::PerceptMesh eMesh(wedgeFixture.getMetaData(), bulk, false); - //percept::PerceptMesh eMesh; - //eMesh.open("swept-wedge6_18_enrich_0.e"); - - Wedge6_Wedge18_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info(); - - wedgeFixture.createBulkAfterMetaCommit(MPI_COMM_WORLD); - - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - //eMesh.save_as(output_files_loc+"swept-wedge6_18_enrich_0.e"); - //eMesh.save_as(input_files_loc+"swept-wedge6_18_enrich_refine_0.e"); - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - -#if 0 - - STKUNIT_UNIT_TEST(regr_uniformRefiner, wedge6_18_enrich_refine) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_regr_uniformRefiner_wedge6_18_enrich_refine - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - eMesh.open(input_files_loc+"swept-wedge_enrich_refine_0.e"); - - Wedge15_Wedge15_8 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UNIFORM_REFINER breaker(eMesh, break_wedge, proc_rank_field); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - eMesh.save_as(output_files_loc+"swept-wedge_enrich_refine_1.e"); - } - // end_demo - } -#endif - - //============================================================================= - //============================================================================= - //============================================================================= -#if DO_SMOOTHING_TEST - - // A cube with an indented bump on the bottom, new parallel smoother, convert to tet - - STKUNIT_UNIT_TEST(regr_perceptMesquite, tet_4) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 2) - { - unsigned n = 12; - std::cout << "P["< & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - // cluster the mesh towards the bump - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - data[2] = data[2]*data[2]; - } - } - } - eMesh.save_as(input_files_loc+"tet_4_smooth.0.e"); - - // save state of original mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_NM1"), eMesh.get_coordinates_field()); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - double ix = data[0]; - double iy = data[1]; - data[2] = (ix)*(1.0-ix)*(iy)*(1.0-iy)*2.0*4.; - } - } - } - // save state of projected mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_N"), eMesh.get_coordinates_field()); - - eMesh.save_as(input_files_loc+"tet_4_smooth.0_perturbed.e"); - - std::cout << "tmp srk doing Shape smoothing for tet_4 case..." << std::endl; - - //bool do_jacobi = true; - Mesquite::MsqDebug::disable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - - int msq_debug = 0; // 1,2,3 for more debug info - bool always_smooth = true; - int innerIter = 1001; - - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - stk_classic::percept::PMMParallelShapeImprover pmmpsi(innerIter, 1.e-4, 1); - pmmpsi.run(pmm, 0, always_smooth, msq_debug); - } - - eMesh.save_as(output_files_loc+"tet_4_si_smooth.1.e"); - - } - - } -#endif - - - }// namespace regression_tests - }// namespace adapt -}// namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Allocate.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Allocate.cpp deleted file mode 100644 index 93f7c002c29a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Allocate.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Allocate.cpp - * - * Created on: Jan 22, 2011 - * Author: kdcopps - */ - -// this is here only to avoid a warning on Mac builds - it was complaining about no symbols existing in this file - -namespace stk_classic { - namespace adapt { - void dummyAllocateMethodForMacBuildWarning() - { - } - } -} - -#ifdef STK_ADAPT_REPLACE_NEW_DELETE - -#ifdef STK_HAVE_TBB -#include - -#pragma GCC visibility push(hidden) - -extern "C++" -{ - void* operator new(std::size_t) throw (std::bad_alloc); - void* operator new[](std::size_t) throw (std::bad_alloc); - void* operator new(std::size_t, const std::nothrow_t&) throw(); - void* operator new[](std::size_t, const std::nothrow_t&) throw(); - void operator delete(void*) throw(); - void operator delete[](void*) throw(); - void operator delete(void*, const std::nothrow_t&) throw(); - void operator delete[](void*, const std::nothrow_t&) throw(); -} // extern "C++" - -#pragma GCC visibility pop - - -// See Intel Threading Building Blocks, James Reinders (2007). -// chapter 11.11.1. Replacing new and delete -// -// No retry loop because we assume that scalable_malloc does -// all it takes to allocate the memory, so calling it repeatedly -// will not improve the situation at all -// -// No use of std::new_handler because it cannot be done in portable -// and thread-safe way (see sidebar) -// -// We throw std::bad_alloc() when scalable_malloc returns NULL -//(we return NULL if it is a no-throw implementation) - - -void* operator new (size_t size) throw (std::bad_alloc) { - if (size == 0) size = 1; - if (void* ptr = scalable_malloc (size)) - return ptr; - throw std::bad_alloc (); -} - -void* operator new[] (size_t size) throw (std::bad_alloc) { - return operator new (size); -} - -void* operator new (size_t size, const std::nothrow_t&) throw () { - if (size == 0) size = 1; - if (void* ptr = scalable_malloc (size)) - return ptr; - return NULL; -} - -void* operator new[] (size_t size, const std::nothrow_t&) throw () { - return operator new (size, std::nothrow); -} - -void operator delete (void* ptr) throw () { - if (ptr != 0) scalable_free (ptr); -} - -void operator delete[] (void* ptr) throw () { - operator delete (ptr); -} - -void operator delete (void* ptr, const std::nothrow_t&) throw () { - if (ptr != 0) scalable_free (ptr); -} - -void operator delete[] (void* ptr, const std::nothrow_t&) throw () { - operator delete (ptr, std::nothrow); -} - -#endif // STK_HAVE_TBB - -#endif // STK_ADAPT_REPLACE_NEW_DELETE diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/stk_adapt/CMakeLists.txt deleted file mode 100644 index 695b21d4bb9d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ - -INCLUDE(TribitsLibraryMacros) - -ADD_SUBDIRECTORY(sierra_element) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(HEADERS "") -SET(SOURCES "") - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -#SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/main) -#APPEND_GLOB(HEADERS ${DIR}/*.hpp) -#APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -#IF( TPL_ENABLE_OpenNURBS) -IF( STK_ADAPT_HAS_GEOMETRY ) - SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/geometry) - APPEND_GLOB(HEADERS ${DIR}/*.hpp) - APPEND_GLOB(SOURCES ${DIR}/*.cpp) -ENDIF() - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/sierra_element) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -# Must glob the binary dir last to get all of the auto-generated headers -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_SET(HEADERS ${DIR}/${PACKAGE_NAME}_config.h ) - -#SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk_util/stk_util/unit_test_support/) -#APPEND_GLOB(HEADERS ${DIR}/*.hpp) -#APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) - -TRIBITS_ADD_LIBRARY( - stkclassic_adapt - HEADERS ${HEADERS} - DEPLIBS stkclassic_percept - SOURCES ${SOURCES} -) - -INSTALL(FILES ${HEADERS} DESTINATION -${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_adapt/) - -ADD_SUBDIRECTORY(main) - -#INCLUDE(TribitsAddExecutableAndTest) - -#TRIBITS_ADD_EXECUTABLE( -# adapt -# COMM serial mpi -# SOURCES ${SOURCES} -# DIRECTORY . -#) diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.cpp deleted file mode 100644 index 8d2020c2284b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include - -#include - - - -namespace stk_classic { - namespace adapt { - - using namespace std; - - template bool contains(STD_Set& set, Key key) { return set.find(key) != set.end(); } - - Colorer::Colorer(std::vector< ColorerSetType >& element_colors, std::vector ranks ) : m_element_colors(element_colors), m_entityRanks(), - m_noColoring(true) - { - if (ranks.size()) - { - m_entityRanks = ranks; - } - else - { - throw std::runtime_error("Colorer:: you must pass in non-zero length ranks"); - } - } - - Colorer::Colorer(std::vector ranks ) : m_element_colors(m_element_colors_internal), m_entityRanks(), m_noColoring(true) - { - if (ranks.size()) - { - m_entityRanks = ranks; - } - else - { - throw std::runtime_error("Colorer:: you must pass in non-zero length ranks"); - } - } - - void Colorer::setNoColoring(bool no_coloring) { m_noColoring = no_coloring; } - bool Colorer::getNoColoring() { return m_noColoring; } - - std::vector< ColorerSetType >& Colorer:: - getElementColors() { return m_element_colors; } - - void Colorer:: - color(percept::PerceptMesh& eMesh, unsigned * elementType, stk_classic::mesh::PartVector* fromParts, stk_classic::mesh::FieldBase *element_color_field) - { - const unsigned MAX_COLORS=1000; - vector< ColorerNodeSetType > node_colors(MAX_COLORS+1); - ColorerElementSetType all_elements; - - mesh::Selector selector(eMesh.get_fem_meta_data()->universal_part()); - if (fromParts) - { - if (0) - { - std::cout << "tmp Colorer::color fromParts= " << *fromParts << std::endl; - std::cout << "tmp Colorer::color elementType= " << *elementType << std::endl; - for (unsigned i_part = 0; i_part < fromParts->size(); i_part++) - { - std::cout << "tmp Colorer::color i_part = " << i_part << " fromParts= " << (*fromParts)[i_part]->name() << std::endl; - } - } - - selector = mesh::selectUnion(*fromParts); - } - - stk_classic::mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - unsigned ncolor = 0; - int nelem = 0; - unsigned num_max_colors = MAX_COLORS; - if (m_noColoring) - num_max_colors = 1; - - m_element_colors = vector< ColorerSetType > (num_max_colors+1); - - for (unsigned icolor = 0; icolor < num_max_colors; icolor++) - { - int num_colored_this_pass = 0; - for (unsigned irank = 0; irank < m_entityRanks.size(); irank++) - { - const vector & buckets = bulkData.buckets( m_entityRanks[irank] ); - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - bool doThisBucket = true; - const CellTopologyData * const bucket_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - shards::CellTopology topo(bucket_cell_topo_data); - if (elementType && (topo.getKey() != *elementType)) - { - doThisBucket = false; - } - - if (0 && doThisBucket) - { - std::cout << "tmp color = " << icolor << " bucket topo name= " << topo.getName() << " key= " << topo.getKey() - << " elementType= " << (elementType? *elementType : 0) << " doThisBucket= " << doThisBucket << std::endl; - } - - if (doThisBucket) - { - const unsigned num_elements_in_bucket = bucket.size(); - nelem += num_elements_in_bucket; - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - if (0) - std::cout << "tmp color = " << icolor << " bucket topo name= " << topo.getName() << " key= " << topo.getKey() - << " elementId = " << element.identifier() << " element = " << element << std::endl; - - stk_classic::mesh::EntityId elem_id = element.identifier(); - - if (!m_noColoring && contains(all_elements, elem_id)) - continue; - - bool none_in_this_color = true; - static std::vector node_ids(100); - unsigned num_node = 0; - - if (!m_noColoring) - { - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - num_node = elem_nodes.size(); - node_ids.reserve(num_node); - for (unsigned inode=0; inode < num_node; inode++) - { - stk_classic::mesh::Entity & node = *elem_nodes[ inode ].entity(); - stk_classic::mesh::EntityId nid = node.identifier(); - node_ids[inode] = nid; - if (contains(node_colors[icolor], nid)) - { - none_in_this_color = false; - break; - } - } - } - if (none_in_this_color) - { - ++num_colored_this_pass; - if (element_color_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(element_color_field) , element ); - fdata[0] = double(icolor); - } -#if STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR - m_element_colors[icolor].push_back(&element); -#else - m_element_colors[icolor].insert(&element); -#endif - if (!m_noColoring) - { - all_elements.insert(elem_id); - for (unsigned inode=0; inode < num_node; inode++) - { - node_colors[icolor].insert(node_ids[inode]); - } - } - } - } // elements in bucket - } // doThisBucket - } // selection - } // buckets - } // irank - if (0 == num_colored_this_pass) - { - break; - } - ++ncolor; - if (ncolor == num_max_colors-1) - { - throw std::runtime_error("broken algorithm in mesh colorer"); - } - } // icolor - - //std::cout << "tmp ncolor = " << ncolor << " nelem= " << nelem << std::endl; - - m_element_colors.resize(ncolor); - } - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.hpp deleted file mode 100644 index 71181546c360..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Colorer.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef stk_adapt_Colorer_hpp -#define stk_adapt_Colorer_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#define STK_ADAPT_COLORER_STORED_ENTITYID 0 - -#define STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR 1 - -/// define only one of these to be 1 -#define STK_ADAPT_COLORER_SET_TYPE_BOOST 1 -#define STK_ADAPT_COLORER_SET_TYPE_TR1 0 -#define STK_ADAPT_COLORER_SET_TYPE_STD 0 - - -#if STK_ADAPT_COLORER_SET_TYPE_BOOST -#include -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_STD -#include -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_TR1 -#include -#endif - -namespace stk_classic { - namespace adapt { - -#if STK_ADAPT_COLORER_STORED_ENTITYID - typedef mesh::EntityId ColorerStoredEntity; -#else - typedef mesh::Entity *ColorerStoredEntity; -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR - typedef std::vector ColorerSetType; -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_BOOST -# if !STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR - typedef boost::unordered_set ColorerSetType; -# endif - typedef boost::unordered_set ColorerNodeSetType; - typedef boost::unordered_set ColorerElementSetType; -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_TR1 -# if !STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR - typedef tr1::unordered_set ColorerSetType; -# endif - typedef tr1::unordered_set ColorerNodeSetType; - typedef tr1::unordered_set ColorerElementSetType; -#endif - -#if STK_ADAPT_COLORER_SET_TYPE_STD -# if !STK_ADAPT_COLORER_SET_TYPE_USE_VECTOR - typedef std::set ColorerSetType; -# endif - typedef std::set ColorerNodeSetType; - typedef std::set ColorerElementSetType; -#endif - - - class Colorer - { - public: - - Colorer(std::vector< ColorerSetType >& element_colors, std::vector ranks); - Colorer(std::vector ranks ); - void color(percept::PerceptMesh& eMesh, unsigned *elementType = 0, mesh::PartVector* fromParts = 0, mesh::FieldBase *element_color_field=0); - - /// Set to true to avoid the coloring step and just return elements in a single color - void setNoColoring(bool no_coloring); - bool getNoColoring(); - - std::vector< ColorerSetType >& getElementColors(); - - private: - std::vector< ColorerSetType >& m_element_colors; - std::vector< ColorerSetType > m_element_colors_internal; - std::vector m_entityRanks; - bool m_noColoring; - }; - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/IAdapter.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/IAdapter.hpp deleted file mode 100644 index 8c1a40ed8155..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/IAdapter.hpp +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef stk_adapt_IAdapter_hpp -#define stk_adapt_IAdapter_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * An IAdapter is an abstract base class that provides all functionality of a Refiner but requires sub-classes to - * overload the refineMethodApply() and buildUnrefineList() methods. The refineMethodApply() method is used by the driving code during - * refinement/parallel communication, while the buildUnrefineList() supplies the driving code with a list of - * candidate elements that are requested to be unrefined. Generally, a user will not overload IAdapter directly, - * but instead will use one of its pre-existing subclasses (see below). - * - * There are two flavors of derived classes that can be used to develop your own adapter: - * a) overload "mark" method on abstract base class IEdgeAdapter or IElementAdapter - * b) or use the predicate-based approach where you supply simple structs with an operator() that supplies - * information on whether an edge or element is to be refined/unrefined (classes named *Predicate*.*pp ) - * - * Details on the two flavors of adapters: - * - * a) - * IEdgeAdapter is a base class for your class that provide a mark(edge_info) method. - * IElementAdapter allows overloading mark(element_info) method. - * In either case, the mark methods tell the driving code to refine any (or all edges) of the mesh, unrefine an - * element (note that all "siblings" of the element must be marked before the collection is deleted and the parent - * is reinstated to replace the children), or refine an element by subsequently marking all its edges. - * - * @see IEdgeAdapter, IElementAdapter, - * unit_tests/TestLocalRefinerTri_N_3_IEdgeAdapter, - * unit_tests/TestLocalRefinerTri_N_3_IElementAdapter, - * and these tests in unit_tests/UnitTestLocalRefiner: - * STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_1_IEdgeAdapter) - * STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_1_IElementAdapter) - * - * b) - * Predicate based adapters are similar to Edge/IElementAdapter but are constructed with user-supplied structs that must - * provide an operator() that takes edge- or element-based info, respectively, depending on the sub-flavor. - * - * PredicateBasedIElementAdapter takes two structs defining a refine and unrefine operation on an element. - * PredicateBasedEdgeAdapter takes structs defining a refine operation on an edge, and unrefine on element. - * - * The structs are required to satisfy signatures of ElementRefinePredicate (for element-based ops) and - * IEdgeBasedAdapterPredicate respectively. - * - * @see ElementRefinePredicate, IEdgeBasedAdapterPredicate, PredicateBasedEdgeAdapter, PredicateBasedIElementAdapter - * and this tests in unit_tests/UnitTestLocalRefiner.cpp: - * STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_5_ElementBased) - * - * and the various tests in regression_tests/RegressionTestUniformRefiner.cpp. - * - * - * - */ - - /// Note: these can be bitwise or'ed to say this element can be refined or unrefined which is useful during testing - /// (for example, during refinement we may want to refine a region, then immediately unrefine, so elements - /// could have both refine and unrefine marks). - /// It can also be used as an error check that enforces that both options can't be set at the same time. - - enum AdaptInstruction { - DO_NOTHING = 0, - DO_REFINE = 1 << 0, - DO_UNREFINE = 1 << 1 - }; - - class IAdapter : public Refiner - { - public: - - - virtual ElementUnrefineCollection buildUnrefineList() = 0; - - protected: - IAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks) = 0; - - - }; - - IAdapter::IAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeAdapter.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeAdapter.hpp deleted file mode 100644 index f42ab988216a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeAdapter.hpp +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef stk_adapt_IEdgeAdapter_hpp -#define stk_adapt_IEdgeAdapter_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * An IEdgeAdapter is an abstract base class for derived classes that are required to overload the mark method, - * which provides info such as the element the edge belongs to, which edge ordinal it is, the nodes of the edge - * and the edge coordinates. - */ - class IEdgeAdapter : public IAdapter - { - public: - IEdgeAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - /// can be overriden - virtual ElementUnrefineCollection buildUnrefineList(); - - protected: - - /// Client supplies these methods - given an element, which edge, and the nodes on the edge, return instruction on what to do to the edge, - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - - virtual int mark(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) = 0; - - /// This convenience method calls mark and if all edges are marked for unrefine, it returns -1 to unrefine the element. - /// This method can be overriden to allow for an "element-based" determination that doesn't need to visit edges. - virtual int markUnrefine(const stk_classic::mesh::Entity& element); - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - IEdgeAdapter::IEdgeAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - IAdapter(eMesh, bp, proc_rank_field) - { - } - - void IEdgeAdapter:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - throw std::runtime_error("IEdgeAdapter::apply can't use IEdgeAdapter for RefinerPatterns that require face nodes"); - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - throw std::runtime_error("IEdgeAdapter::apply can't use IEdgeAdapter for RefinerPatterns that require volume nodes"); - } - - // see how many edges are already marked - int num_marked=0; - std::vector edge_marks(numSubDimNeededEntities,0); - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) - { - edge_marks[iSubDimOrd] = 1; - ++num_marked; - } - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - - int markInfo = mark(element, iSubDimOrd, node0, node1, coord0, coord1, &edge_marks); - - bool needNodes = (DO_REFINE & markInfo); - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, needNodes); - } - } - - } // iSubDimOrd - } // ineed_ent - } - - int IEdgeAdapter::markUnrefine(const stk_classic::mesh::Entity& element) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - unsigned numSubDimNeededEntities = 0; - numSubDimNeededEntities = cell_topo_data->edge_count; - - bool unrefAllEdges = true; - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - int markInfo = mark(element, iSubDimOrd, node0, node1, coord0, coord1, 0); - bool do_unref = markInfo & DO_UNREFINE; - if (!do_unref) - { - unrefAllEdges = false; - break; - } - } - if (unrefAllEdges) - return -1; - else - return 0; - } - - ElementUnrefineCollection IEdgeAdapter::buildUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false)) - { - int markInfo = markUnrefine(element); - if (markInfo & DO_UNREFINE) - { - elements_to_unref.insert(&element); - //std::cout << "tmp unref element id= " << element.identifier() << std::endl; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeBasedAdapterPredicate.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeBasedAdapterPredicate.hpp deleted file mode 100644 index 46c22f83f29b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/IEdgeBasedAdapterPredicate.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef stk_adapt_IEdgeBasedAdapterPredicate_hpp -#define stk_adapt_IEdgeBasedAdapterPredicate_hpp - -#include -#include - -#include - -namespace stk_classic { - namespace adapt { - - /** Signatures for predicate objects that can be used to select entities (elements, edges, faces,...) for - * refinement or unrefinement. The class must supply an operator() that takes an entity and decides - * on whether it should be refined, or unrefined, or ignored. - * - * The Selector pattern as shown below is useful for selecting only entities that belong to particular - * mesh Parts, for example, or any other definition of Selector. - * - * We follow the unary_function pattern to enable the structs to be used in STL algorithms that know about - * unary_functions. - * - * The following are a couple of examples of what refine and unrefine predicates might look like. - * - * Following these examples we show the prototype for the operations that are performed on these predicates. - */ - - // Example - struct IEdgeBasedAdapterPredicate { - stk_classic::mesh::Selector * m_selector; - stk_classic::mesh::FieldBase *m_field; - double m_tolerance; - protected: - IEdgeBasedAdapterPredicate(stk_classic::mesh::Selector * selector = 0, stk_classic::mesh::FieldBase *field = 0, double tolerance=0.0) : - m_selector(selector), m_field(field), m_tolerance(tolerance) {} - - /// for a Refine predicate, Return true for refine, false for ignore - /// for an Unrefine predicate, return true for unrefine, false for ignore - bool operator()(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks); - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementAdapter.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementAdapter.hpp deleted file mode 100644 index 4d70e3b46fa5..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementAdapter.hpp +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef stk_adapt_IElementAdapter_hpp -#define stk_adapt_IElementAdapter_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * An IElementAdapter is an abstract base class for derived classes that are required to overload the mark method, - * which supplies the derived class with the element to be marked for refine, unrefine, or both (@see IAdapter::AdaptInstruction) - */ - class IElementAdapter : public IAdapter - { - public: - IElementAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - virtual ElementUnrefineCollection buildUnrefineList() ; - - protected: - - /// Client supplies this method - given an element return instruction on what to do to the element: - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - virtual int mark(const stk_classic::mesh::Entity& element) = 0; - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - IElementAdapter::IElementAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - IAdapter(eMesh, bp, proc_rank_field) - { - } - - void IElementAdapter:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - int markInfo = mark(element); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - bool needNodes = ( markInfo & DO_REFINE); - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, needNodes); - } // iSubDimOrd - } - } // ineed_ent - } - - - ElementUnrefineCollection IElementAdapter::buildUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false)) - { - int markInfo = mark(element); - if (markInfo & DO_UNREFINE) - { - elements_to_unref.insert(&element); - } - } - } - } - } - - return elements_to_unref; - } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementBasedAdapterPredicate.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementBasedAdapterPredicate.hpp deleted file mode 100644 index e41e461c414d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/IElementBasedAdapterPredicate.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef stk_adapt_IElementBasedAdapterPredicate_hpp -#define stk_adapt_IElementBasedAdapterPredicate_hpp - -#include -#include - -#include - -namespace stk_classic { - namespace adapt { - - /** Signatures for predicate objects that can be used to select entities (elements, edges, faces,...) for - * refinement or unrefinement. The class must supply an operator() that takes an entity and decides - * on whether it should be refined, or unrefined, or ignored. - * - * The Selector pattern as shown below is useful for selecting only entities that belong to particular - * mesh Parts, for example, or any other definition of Selector. - * - * We follow the unary_function pattern to enable the structs to be used in STL algorithms that know about - * unary_functions. - * - * The following are a couple of examples of what refine and unrefine predicates might look like. - * - * Following these examples we show the prototype for the operations that are performed on these predicates. - */ - - // Example - struct IElementBasedAdapterPredicate : public std::unary_function { - stk_classic::mesh::Selector * m_selector; - stk_classic::mesh::FieldBase *m_field; - double m_tolerance; - protected: - IElementBasedAdapterPredicate(stk_classic::mesh::Selector * selector=0, stk_classic::mesh::FieldBase *field=0, double tolerance=0.0) : - m_selector(selector), m_field(field), m_tolerance(tolerance) {} - }; - - // Can be instantiated by the user, or used to define your own - struct ElementRefinePredicate : public IElementBasedAdapterPredicate { - - ElementRefinePredicate(stk_classic::mesh::Selector* selector=0, stk_classic::mesh::FieldBase *field=0, double tolerance=0.0) : - IElementBasedAdapterPredicate(selector, field, tolerance) {} - - /// Return true for refine, false for ignore - int operator()(const stk_classic::mesh::Entity& entity) { - double *fdata = 0; - if (m_field) - fdata = stk_classic::mesh::field_data( *static_cast(m_field) , entity ); - bool selected = (m_selector==0 || (*m_selector)(entity)); - bool ref_field_criterion = (fdata && fdata[0] > 0); - bool unref_field_criterion = (fdata && fdata[0] < 0); - int mark = 0; - if (selected && ref_field_criterion) mark |= DO_REFINE; - if (selected && unref_field_criterion) mark |= DO_UNREFINE; - return mark; - } - }; - - /** Example of how the above is used (pseudo-code): - * - * class PredicateAdapter : public Refiner { - * void visit_for_refine_and_unrefin(std::unary_function& user_predicate_refine) - * { - * foreach (Entity entity in list) - * { - * if (user_predicate_refine(entity) & DO_REFINE) { do_refine_operation(entity); } - * } - * foreach (Entity entity in list) - * { - * if (user_predicate_unrefine(entity) & DO_UNREFINE) { do_unrefine_operation(entity); } - * } - * } - * }; - */ - - //get_selected_entities(Selector, rank, EntityVec vec); - - - //filter_iterator( Predicate&, vec.begin()); - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.cpp deleted file mode 100644 index f7f0c0ba6592..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.cpp +++ /dev/null @@ -1,615 +0,0 @@ -#include - -#if 0 && NODE_REGISTRY_MAP_TYPE_TEUCHOS_HASHTABLE -namespace Teuchos -{ - //template int hashCode(const T& x); - - template <> int hashCode(const SDCell_HashTable_Key& x) - { - return (int)x.getHash(); - } - -} -#endif - -namespace stk_classic { - namespace adapt { - -#if !NODE_REGISTRY_MAP_ACCESSORS_INLINED - SubDimCellData& NodeRegistry::getFromMap(SubDimCell_EntityId& subDimEntity) - { - //ftest(subDimEntity); - return m_cell_2_data_map[subDimEntity]; - } - void NodeRegistry::putInMap(SubDimCell_EntityId& subDimEntity, SubDimCellData& data) - { - //m_cell_2_data_map.insert(std::subDimEntity, data); - //SubDimCellData& dataInMap = m_cell_2_data_map[subDimEntity]; - //dataInMap = data; - //ftest(subDimEntity); - m_cell_2_data_map[subDimEntity] = data; - } -#endif - - /// fill - /// @param subDimEntity with the stk_classic::mesh::EntityId's of - /// the ordinal @param iSubDimOrd sub-dimensional entity of - /// @param element of rank - /// @param needed_entity_rank - /// - void NodeRegistry:: - noInline_getSubDimEntity(SubDimCell_SDSEntityType& subDimEntity, const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - subDimEntity.clear(); - // in the case of elements, we don't share any nodes so we just make a map of element id to node - if (needed_entity_rank == m_eMesh.element_rank()) - { - subDimEntity.insert( const_cast(&element) ); - //!!subDimEntity.insert(element.identifier()); - return; - } - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - //CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - const unsigned * inodes = 0; - unsigned nSubDimNodes = 0; - static const unsigned edge_nodes_2[2] = {0,1}; - static const unsigned face_nodes_3[3] = {0,1,2}; - static const unsigned face_nodes_4[4] = {0,1,2,3}; - - // special case for faces in 3D - if (needed_entity_rank == m_eMesh.face_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - if (nSubDimNodes ==3 ) - inodes = face_nodes_3; - else - inodes = face_nodes_4; - - } - // special case for edges in 2D - else if (needed_entity_rank == m_eMesh.edge_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - if (nSubDimNodes == 2 ) - { - inodes = edge_nodes_2; - } - else - { - throw std::runtime_error("NodeRegistry bad for edges"); - } - } - else if (needed_entity_rank == m_eMesh.edge_rank()) - { - inodes = cell_topo_data->edge[iSubDimOrd].node; - nSubDimNodes = 2; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - nSubDimNodes = cell_topo_data->side[iSubDimOrd].topology->vertex_count; - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - inodes = cell_topo_data->side[iSubDimOrd].node; - } - - //subDimEntity.reserve(nSubDimNodes); - for (unsigned jnode = 0; jnode < nSubDimNodes; jnode++) - { - subDimEntity.insert( elem_nodes[inodes[jnode]].entity() ); - //!!subDimEntity.insert(elem_nodes[inodes[jnode]].entity()->identifier()); - } - - } - - static double spacing_edge(unsigned iv0, unsigned iv1, unsigned nsz, unsigned nsp, double lspc[8][3], double den_xyz[3], double *coord[8]) - { - unsigned iv[2]={iv0,iv1}; - double alp[2]={0.0,0.0}; - double alp1[2]={0.0,0.0}; - for (unsigned ipts=0; ipts < nsz; ipts++) - { - unsigned jpts = iv[ipts]; - double len = 0.0; - alp[ipts]=0.0; - - for (unsigned isp = 0; isp < nsp; isp++) - { - alp[ipts] += (coord[iv[1]][isp] - coord[iv[0]][isp])*lspc[jpts][isp]; - len += (coord[iv[1]][isp] - coord[iv[0]][isp])*(coord[iv[1]][isp] - coord[iv[0]][isp]); - } - alp[ipts] = std::fabs(alp[ipts])/std::sqrt(len); - } - const double fac=3.0, facden = 4.0; - for (unsigned ipts=0; ipts < nsz; ipts++) - { - double lsum=0.0; - double lsum1=0.0; - for (unsigned jpts=0; jpts < nsz; jpts++) - { - lsum1 += (jpts==ipts?0:alp[jpts]); - lsum += alp[jpts]; - } - alp1[ipts] = (alp[ipts] + lsum1*fac)/(facden*lsum); - } - double sum=0.0; - for (unsigned ipts=0; ipts < nsz; ipts++) - { - sum += alp1[ipts]; - } - for (unsigned ipts=0; ipts < nsz; ipts++) - { - alp1[ipts] /= sum; - } - return 1.0-alp1[0]; - //return alp1[0]; - } - - static void normalize_spacing_0(unsigned nsz, unsigned nsp, double spc[8][3], double den_xyz[3]) - { - //double m_min_spacing_factor = 0.5; - double m_min_spacing_factor = 0.0; - for (unsigned isp = 0; isp < nsp; isp++) - { - double den = 0.0; - unsigned ipts=0; - for (ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] = 1.0/spc[ipts][isp]; - den += spc[ipts][isp]; - } - for (ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] /= den; - } - // now it's a fraction [0,1], check if it's too big - for (ipts=0; ipts < nsz; ipts++) - { - if ( spc[ipts][isp] > 1.0 - m_min_spacing_factor) - { - spc[ipts][isp] = 1.0 - m_min_spacing_factor; - for (unsigned jpts=0; jpts < nsz; jpts++) - { - if (ipts != jpts) - spc[ipts][isp] = m_min_spacing_factor/((double)(nsz-1)); - } - - break; - } - } - // now renormalize it - den = 0.0; - for (ipts=0; ipts < nsz; ipts++) - { - den += spc[ipts][isp]; - } - for (ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] /= den; - } - - } - } - - static void normalize_spacing(unsigned nsz, unsigned nsp, double spc[8][3], double den_xyz[3], double *coord[8]) - { - double fac = 0.0, facden=0.0; - switch(nsz) { - case 2: - fac = 3.0; facden=4.0; - break; - case 4: - fac = 41./3./7.; facden=16./7.; // heuristic - break; - case 8: - fac = 411./259.; facden=64./37.; // heuristic - break; - default: - normalize_spacing_0(nsz,nsp,spc,den_xyz); - return; - } - - //facden = 1+(double(nsz)-1)*fac; - double lspc[8][3]; - for (unsigned isp = 0; isp < nsp; isp++) - { - for (unsigned ipts=0; ipts < nsz; ipts++) - { - lspc[ipts][isp] = spc[ipts][isp]; - } - } - - for (unsigned isp = 0; isp < nsp; isp++) - { - if (nsz == 4) - { - double alp01 = spacing_edge(0, 1, 2, nsp, lspc, den_xyz, coord); - double alp32 = spacing_edge(3, 2, 2, nsp, lspc, den_xyz, coord); - double x = 0.5*(alp01+alp32); - double alp12 = spacing_edge(1, 2, 2, nsp, lspc, den_xyz, coord); - double alp03 = spacing_edge(0, 3, 2, nsp, lspc, den_xyz, coord); - double y = 0.5*(alp12+alp03); - if (isp == 0) - { - spc[0][0] = (1-x)*(1-y); - spc[1][0] = x*(1-y); - spc[2][0] = x*y; - spc[3][0] = (1-x)*y; - } - else - { - for (unsigned ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] = spc[ipts][0]; - } - } - } - else if (nsz == 8) - { - double alp01 = spacing_edge(0, 1, 2, nsp, lspc, den_xyz, coord); - double alp32 = spacing_edge(3, 2, 2, nsp, lspc, den_xyz, coord); - double alp45 = spacing_edge(4, 5, 2, nsp, lspc, den_xyz, coord); - double alp76 = spacing_edge(7, 6, 2, nsp, lspc, den_xyz, coord); - double x = 0.25*(alp01+alp32+alp45+alp76); - double alp12 = spacing_edge(1, 2, 2, nsp, lspc, den_xyz, coord); - double alp03 = spacing_edge(0, 3, 2, nsp, lspc, den_xyz, coord); - double alp56 = spacing_edge(5, 6, 2, nsp, lspc, den_xyz, coord); - double alp47 = spacing_edge(4, 7, 2, nsp, lspc, den_xyz, coord); - double y = 0.25*(alp12+alp03+alp56+alp47); - double alp04 = spacing_edge(0, 4, 2, nsp, lspc, den_xyz, coord); - double alp15 = spacing_edge(1, 5, 2, nsp, lspc, den_xyz, coord); - double alp26 = spacing_edge(2, 6, 2, nsp, lspc, den_xyz, coord); - double alp37 = spacing_edge(3, 7, 2, nsp, lspc, den_xyz, coord); - double z = 0.25*(alp04+alp15+alp26+alp37); - if (isp == 0) - { - spc[0][0] = (1-x)*(1-y)*(1-z); - spc[1][0] = x*(1-y)*(1-z); - spc[2][0] = x*y*(1-z); - spc[3][0] = (1-x)*y*(1-z); - spc[4][0] = (1-x)*(1-y)*z; - spc[5][0] = x*(1-y)*z; - spc[6][0] = x*y*z; - spc[7][0] = (1-x)*y*z; - } - else - { - for (unsigned ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] = spc[ipts][0]; - } - } - } - else - { - for (unsigned ipts=0; ipts < nsz; ipts++) - { - double lsum=0.0; - double lsum1=0.0; - for (unsigned jpts=0; jpts < nsz; jpts++) - { - lsum1 += (jpts==ipts?0:lspc[jpts][isp]); - lsum += lspc[jpts][isp]; - } - spc[ipts][isp] = (lspc[ipts][isp] + lsum1*fac)/(facden*lsum); - } - } - double sum=0.0; - for (unsigned ipts=0; ipts < nsz; ipts++) - { - sum += spc[ipts][isp]; - } - for (unsigned ipts=0; ipts < nsz; ipts++) - { - spc[ipts][isp] /= sum; - if (0 && nsz == 8 && isp == 1) - std::cout << "spc[" << ipts << "]= " << spc[ipts][isp] << std::endl; - } - } - } - - /// makes coordinates of this new node be the centroid of its sub entity - this version does it for all new nodes - void NodeRegistry::makeCentroid(stk_classic::mesh::FieldBase *field) - { - EXCEPTWATCH; - //unsigned *null_u = 0; - stk_classic::mesh::FieldBase *spacing_field = m_eMesh.get_field("ref_spacing_field"); - - int spatialDim = m_eMesh.get_spatial_dim(); - int fieldDim = spatialDim; - stk_classic::mesh::EntityRank field_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - { - EXCEPTWATCH; - unsigned nfr = field->restrictions().size(); - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //mesh::Part& frpart = metaData.get_part(fr.ordinal()); - field_rank = fr.entity_rank(); - fieldDim = fr.dimension() ; - } - } - // FIXME for interpolation of element fields - if (field_rank != stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - if (field_rank == m_eMesh.element_rank()) - { - - } - return; - } - - SubDimCellToDataMap::iterator iter; - - for (iter = m_cell_2_data_map.begin(); iter != m_cell_2_data_map.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - //unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - unsigned char owning_elementSubDimOrd = nodeId_elementOwnderId.get(); - VERIFY_OP_ON(owning_elementSubDimOrd, >, 0, "hmm 2"); - --owning_elementSubDimOrd ; - - static const SubDimCellData empty_SubDimCellData; - - bool is_empty = (nodeId_elementOwnderId == empty_SubDimCellData); - - if (s_allow_empty_sub_dims && is_empty) - { - return; - } - - if (is_empty) - { - throw std::runtime_error("makeCentroid(field) empty cell found"); - } - - if (nodeIds_onSE.size() != 1) - { - continue; - } - - stk_classic::mesh::EntityRank needed_entity_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - // SPECIAL CASE - // SPECIAL CASE - // SPECIAL CASE - if (subDimEntity.size() == 1) - { - needed_entity_rank = m_eMesh.element_rank(); - } - - if (nodeIds_onSE[0] == 0) - { - continue; - } - - stk_classic::mesh::Entity * c_node = nodeIds_onSE[0]; - - if (!c_node) - { - throw std::runtime_error("makeCentroid(field): bad node found 0.0"); - } - - std::vector c_p(fieldDim,0); - bool doPrint = false; - std::vector nodes(8,(stk_classic::mesh::Entity *)0); - unsigned nsz = 0; - bool do_spacing=false; - - if (needed_entity_rank == m_eMesh.element_rank()) - { - EXCEPTWATCH; - stk_classic::mesh::Entity *element_p = 0; - { - SDSEntityType elementId = *subDimEntity.begin(); - //!!element_p = get_entity_element(*m_eMesh.get_bulk_data(), m_eMesh.element_rank(), elementId); - element_p = elementId; - if (!element_p) - { - throw std::runtime_error("makeCentroid(field): bad elem found 2"); - } - } - - stk_classic::mesh::Entity& element = *element_p; - bool element_is_ghost = m_eMesh.isGhostElement(element); - if (element_is_ghost) - { - //std::cout << "tmp found ghost" << std::endl; - } - else - { - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - unsigned npts = elem_nodes.size(); - nsz = npts; - nodes.resize(nsz, (stk_classic::mesh::Entity *)0); - c_p.resize(fieldDim,0); - //if (npts == 2) doPrint=true; - //double dnpts = elem_nodes.size(); - for (unsigned ipts = 0; ipts < npts; ipts++) - { - stk_classic::mesh::Entity * node = elem_nodes[ipts].entity(); - if (!node) - { - throw std::runtime_error("makeCentroid(field): bad node found 1.0"); - } - nodes[ipts] = node; - } - } - } - else - { - nsz = subDimEntity.size(); - nodes.resize(nsz, (stk_classic::mesh::Entity *)0); - c_p.resize(fieldDim,0); - - if (do_spacing && nsz == 4 && spatialDim == 3) - { - //exit(1); - //element_side_nodes( const stk_classic::mesh::Entity & elem , int local_side_id, stk_classic::mesh::EntityRank side_entity_rank, std::vector& side_node_entities ) - stk_classic::mesh::Entity *owning_element = m_eMesh.get_bulk_data()->get_entity(m_eMesh.element_rank(), owning_elementId); - VERIFY_OP_ON(owning_element, !=, 0, "hmmm"); - std::vector side_node_entities; - PerceptMesh::element_side_nodes(*owning_element, owning_elementSubDimOrd, m_eMesh.face_rank(), side_node_entities); - VERIFY_OP_ON(side_node_entities.size(), ==, 4, "hmmm 3"); - for (unsigned ipts=0; ipts < side_node_entities.size(); ipts++) - { - nodes[ipts] = side_node_entities[ipts]; - } - } - else - { - unsigned ipts=0; - for (SubDimCell_SDSEntityType::const_iterator ids = subDimEntity.begin(); ids != subDimEntity.end(); ++ids, ++ipts) - { - SDSEntityType nodeId = *ids; - stk_classic::mesh::Entity * node = nodeId; - nodes[ipts]=node; - } - } - } - - { - //if ( (spacing_field && (spacing_field != field) && subDimEntity.size() == 2)) - // FIXME for quadratic elements - if (do_spacing && (nsz <= 8 && spacing_field && (spacing_field != field) ) ) - { - EXCEPTWATCH; - unsigned ipts=0; - - double * coord[8] = {0,0,0,0,0,0,0,0}; - double * field_data[8] = {0,0,0,0,0,0,0,0}; - double * spacing[8] = {0,0,0,0,0,0,0,0}; - - for (ipts=0; ipts < nsz; ipts++) - { - coord[ipts] = m_eMesh.field_data_inlined(m_eMesh.get_coordinates_field(), *nodes[ipts]); - field_data[ipts] = m_eMesh.field_data_inlined(field, *nodes[ipts]); - spacing[ipts] = m_eMesh.field_data_inlined(spacing_field, *nodes[ipts]); - } - - double spc[8][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; - double den = 0.0; - double den_xyz[3] = {0,0,0}; - if (nsz == 2) - { - den = 0.0; - for (ipts=0; ipts < nsz; ipts++) - { - double len = 0.0; - for (int isp = 0; isp < spatialDim; isp++) - { - spc[ipts][0] += (coord[1][isp] - coord[0][isp])*spacing[ipts][isp]; - len += (coord[1][isp] - coord[0][isp])*(coord[1][isp] - coord[0][isp]); - } - spc[ipts][0] = std::fabs(spc[ipts][0])/std::sqrt(len); - } - for (ipts=0; ipts < nsz; ipts++) - { - for (int isp = 1; isp < spatialDim; isp++) - { - spc[ipts][isp] = spc[ipts][0]; - } - } - } - else - { - for (ipts=0; ipts < nsz; ipts++) - { - for (int isp = 0; isp < spatialDim; isp++) - { - spc[ipts][isp] = spacing[ipts][isp]; - } - } - } - normalize_spacing(nsz, spatialDim, spc, den_xyz, coord); - if (0 && nsz==2 && (coord[1][0] < 1.e-3 && coord[0][0] < 1.e-3)) - for (ipts=0; ipts < nsz; ipts++) - for (int isp = 0; isp < spatialDim; isp++) - { - std::cout << "y = " << coord[ipts][1] << " new spc[" << ipts << "]= " << spc[ipts][1] << std::endl; - } - - - for (ipts=0; ipts < nsz; ipts++) - { - if (field_data[ipts]) - { - for (int isp = 0; isp < fieldDim; isp++) - { - c_p[isp] += field_data[ipts][isp]*spc[ipts][isp]; - } - } - } - - } - else - { - EXCEPTWATCH; - double dnpts = nsz; - unsigned ipts=0; - for (ipts=0; ipts < nsz; ipts++) - { - stk_classic::mesh::Entity * node = nodes[ipts]; - if (!node) - { - throw std::runtime_error("makeCentroid(field): bad node found 2.0"); - } - //double * coord = m_eMesh.field_data(field, *node, null_u); - double * field_data = m_eMesh.field_data_inlined(field, *node); - - if (doPrint && field_data) - { - //const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - //CellTopology cell_topo(cell_topo_data); - - std::cout << "tmp NodeRegistry::makeCentroid(field) npts= " << subDimEntity.size() << " ipts= " << ipts - << " field_data= " << field_data[0] << " " << field_data[1] << " " << field_data[2] << std::endl; - } - - if (field_data) - { - for (int isp = 0; isp < fieldDim; isp++) - { - c_p[isp] += field_data[isp]/dnpts; - } - } - } - } - } - - // set coords - { - EXCEPTWATCH; - - //double * c_coord = m_eMesh.field_data(field, *c_node, null_u); - double * c_coord = m_eMesh.field_data_inlined(field, *c_node); - - if (c_coord) - { - for (int isp = 0; isp < fieldDim; isp++) - { - c_coord[isp] = c_p[isp]; - } - - if (doPrint) - std::cout << "tmp NodeRegistry::makeCentroid(field) c_coord= " << c_coord[0] << " " << c_coord[1] << " " << c_coord[2] << std::endl; - - - } - } - } - } // makeCentroid(stk_classic::mesh::FieldBase *) - - - } -} diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.hpp deleted file mode 100644 index 58332e4a2bb9..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistry.hpp +++ /dev/null @@ -1,2451 +0,0 @@ -/** - 1. class/struct for the data type stored on a sub-dim entity (value) - 2. key (subDimEntity) gives value& - 2a. getDefaultValueFromKeyIfKeyNotPresent - 2b. value * isKeyInMap(key) [returns 0 if not present] - 2c. insert (key,value) pair, with overwrite - 2d. for a given key, reset the data (value type) to "empty" - - is_value_null, is_value_cleared, is_value_null_or_cleared - insert(key,value) - getValueWithDefaultIfNotPresent(key) - - Paradigm: avoid determining if it's null - just ask for is_value_null_or_cleared, if it is, - then getValueWithDefaultIfNotPresent(key), else - - Or, always do is_value_null, then insertAndReturnDefaultValue(), else getValue(). This is needed - for performance since we don't want to always construct a default value, as the operator[] does. - - - - - 3. we treat key,value as value-types, but we need to be aware of performance - and pass/return references as needed - 4. notify delete a node: find subDimEntity containing the node and remove from the value - 5. notify delete an element: if an element is about to be deleted from stk_mesh, notify - the DB so the appropriate owning element flags can be reset - 6. - */ - -#ifndef stk_adapt_NodeRegistry_hpp -#define stk_adapt_NodeRegistry_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -/// define only one of these to be 1 -/// current best setting is NODE_REGISTRY_MAP_TYPE_BOOST = 1 -#define NODE_REGISTRY_MAP_TYPE_BOOST 1 -#define NODE_REGISTRY_MAP_TYPE_TR1 0 -#define NODE_REGISTRY_MAP_TYPE_STD 0 -#define NODE_REGISTRY_MAP_TYPE_GOOGLE 0 - -// next two are deprecated -#define NODE_REGISTRY_MAP_TYPE_PERCEPT_HASHTABLE 0 -#define NODE_REGISTRY_MAP_TYPE_TEUCHOS_HASHTABLE 0 - -/// current best is STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO 1, DO_REHASH 1 -#define STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO 0 -#define STK_ADAPT_NODEREGISTRY_DO_REHASH 1 - -#if NODE_REGISTRY_MAP_TYPE_BOOST -#include -#endif - -#if NODE_REGISTRY_MAP_TYPE_STD -#include -#endif - -#if NODE_REGISTRY_MAP_TYPE_TR1 -#include -#endif - - -#include - -#if NODE_REGISTRY_MAP_TYPE_GOOGLE -#include -#include -#endif - -// set to maximum number of procs -#define PSEUDO_ELEMENT_MAGIC_NUMBER 1000000 -// set to skip over the FAMILY_TREE_RANK (which is 1 + element rank) -#define PSEUDO_ELEMENT_RANK_SHIFT 2 - - -namespace stk_classic { - namespace adapt { - - using namespace stk_classic::percept; - using std::vector; - using std::map; - using std::set; - - // FIXME - static bool s_allow_empty_sub_dims = true; // for uniform refine, this should be false for testing - - typedef std::pair NeededEntityType; - - // using tuple here instead of pair to allow for future expansion - - // pair of node id and the owning element for a node on a sub-dimensional entity (like a face or edge) - enum SubDimCellDataEnum { - SDC_DATA_GLOBAL_NODE_IDS, - SDC_DATA_OWNING_ELEMENT_KEY, - SDC_DATA_OWNING_ELEMENT_ORDINAL // the ordinal of the face/edge owning this sub-dim entity - }; - - typedef stk_classic::mesh::Entity* NodeIdsOnSubDimEntityTypeQuantum; - - /// data on a sub-dim entity (global node ids on the entity, the owning element's id) - struct NodeIdsOnSubDimEntityType : public std::vector - { - typedef std::vector base_type; - typedef std::vector entity_id_vector_type; - entity_id_vector_type m_entity_id_vector; - unsigned m_mark; - - NodeIdsOnSubDimEntityType(unsigned sz=1, NodeIdsOnSubDimEntityTypeQuantum allValues=0) : base_type(sz,allValues), - m_entity_id_vector(sz,0u), - m_mark(0u) {} - - void resize(size_t sz) - { - m_entity_id_vector.resize(sz); - base_type::resize(sz); - } - - void pack(CommBuffer& buff) - { - buff.pack< unsigned > ( this->size() ); - m_entity_id_vector.resize( this->size() ); - for (unsigned ii = 0; ii < this->size(); ii++) - { - if (!(*this)[ii]) - throw std::logic_error("logic err in NodeIdsOnSubDimEntityType::pack"); - stk_classic::mesh::EntityId id = ((*this)[ii])->identifier(); - m_entity_id_vector[ii] = id; - buff.pack( id ); - } - } - void unpack(PerceptMesh& eMesh, CommBuffer& buff) - { - unsigned sz; - buff.unpack< unsigned > ( sz ); - this->resize( sz ); - m_entity_id_vector.resize( sz ); - for (unsigned ii = 0; ii < this->size(); ii++) - { - stk_classic::mesh::EntityId id=0; - buff.unpack( id ); - m_entity_id_vector[ii] = id; - } - } - }; - - inline std::ostream &operator<<(std::ostream& out, const boost::array& arr) - { - out << arr[0]; - return out; - } - - - typedef boost::tuple SubDimCellData; - -#define SDS_ENTITY_TYPE_ID 0 -#if SDS_ENTITY_TYPE_ID - typedef stk_classic::mesh::EntityId SDSEntityType; - - struct CompareSDSEntityType { - bool operator() (SDSEntityType i, SDSEntityType j) { return (i < j) ; } - }; - -#else - typedef stk_classic::mesh::Entity * SDSEntityType; - - struct CompareSDSEntityType { - bool operator() (SDSEntityType i, SDSEntityType j) { return (i->identifier() < j->identifier());} - }; - - template<> - inline int SubDimCell >::hashCode() -#if 1 - { - typedef stk_classic::percept::NoMallocArray base_type; - - std::size_t sum = 0; - - for ( base_type::iterator i = this->begin(); i != this->end(); i++) - { - sum += static_cast((*i)->identifier()); - } - return sum; - } -#endif - -#endif - - typedef SubDimCell SubDimCell_SDSEntityType; - - inline std::ostream& operator<<(std::ostream& out, SubDimCellData& val) - { - out << "SDC:: node ids= " << val.get() - << " owning element rank= " << stk_classic::mesh::entity_rank(val.get()) - << " owning element id= " << stk_classic::mesh::entity_id(val.get()) - << " owning element subDim-ord= " << val.get(); - return out; - } - - } -} - -namespace stk_classic { - namespace adapt { - - typedef stk_classic::mesh::Entity *EntityPtr; - - /// map of the node ids on a sub-dim entity to the data on the sub-dim entity - -#if NODE_REGISTRY_MAP_TYPE_BOOST -# ifdef STK_HAVE_TBB - - typedef tbb::scalable_allocator > RegistryAllocator; - typedef boost::unordered_map, my_fast_equal_to, RegistryAllocator > SubDimCellToDataMap; - -# else - - typedef boost::unordered_map, my_fast_equal_to > SubDimCellToDataMap; - typedef boost::unordered_map EntityRepo; - - typedef boost::tuple ElementSideTuple; - - struct my_tuple_hash : public std::unary_function< ElementSideTuple, std::size_t> - { - inline std::size_t - operator()(const ElementSideTuple& x) const - { - return std::size_t(x.get<0>())+std::size_t(x.get<1>())+std::size_t(x.get<2>()); - } - }; - - typedef boost::unordered_map ElementSideMap; - -# endif -#endif - -#if NODE_REGISTRY_MAP_TYPE_GOOGLE - - // typedef google::sparse_hash_map google_sparse_map_type; - // google_sparse_map_type google_sparse_map1(init_capacity); - // google_sparse_map1.set_empty_key(2*N); - -# ifdef STK_HAVE_TBB - - typedef tbb::scalable_allocator > RegistryAllocator; - typedef google::sparse_hash_map, my_equal_to, RegistryAllocator > SubDimCellToDataMap; - typedef google::sparse_hash_map EntityRepo; - -# else - - typedef google::sparse_hash_map, my_equal_to > SubDimCellToDataMap; - typedef boost::unordered_map EntityRepo; - -# endif -#endif - -#if NODE_REGISTRY_MAP_TYPE_TR1 - typedef tr1::unordered_map, my_equal_to > SubDimCellToDataMap; - typedef tr1::unordered_map EntityRepo; -#endif - -#if NODE_REGISTRY_MAP_TYPE_STD - -# if STK_ADAPT_SUBDIMCELL_USES_STL_SET - typedef map SubDimCellToDataMap; -# endif - -# if STK_ADAPT_SUBDIMCELL_USES_STL_VECTOR - typedef map > SubDimCellToDataMap; -# endif - -# if STK_ADAPT_SUBDIMCELL_USES_NO_MALLOC_ARRAY - typedef map > SubDimCellToDataMap; -# endif - - typedef map EntityRepo; -#endif - - // Rank of sub-dim cells needing new nodes, which sub-dim entity, one non-owning element identifier, nodeId_elementOwnderId.first - // FIXME - consider using bitfields to pack first two entries into a short - does this save anything on buffer size? - enum CommDataTypeEnum { - CDT_NEEDED_ENTITY_RANK, - CDT_SUB_DIM_ENTITY_ORDINAL, - CDT_NON_OWNING_ELEMENT_KEY - //,NEW_NODE_IDS - }; - enum - { - NEW_NODE_IDS - }; - typedef boost::tuple CommDataType; - - enum { - MODE_SERIAL, - MODE_BUFFER_SIZING, - MODE_BUFFERS_ALLOCD, - MODE_SEND_DONE - // after unpack, reset to MODE_SERIAL, i.e. it's cyclical - }; - - enum NodeRegistryState { - NRS_NONE, - NRS_START_REGISTER_NODE, - NRS_END_REGISTER_NODE, - NRS_START_CHECK_FOR_REMOTE, - NRS_END_CHECK_FOR_REMOTE, - NRS_START_PARALLEL_OPS, - NRS_START_GET_FROM_REMOTE, - NRS_END_GET_FROM_REMOTE, - NRS_END_PARALLEL_OPS - }; - - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - class NodeRegistry - { - static const unsigned NR_MARK_NONE = 1u; - static const unsigned NR_MARK = 2u; - - public: - // FIXME use unordered_set - typedef std::set SetOfEntities; - - //======================================================================================================================== - // high-level interface - //NodeRegistry(percept::PerceptMesh& eMesh) : m_eMesh(eMesh), m_comm_all(eMesh.get_bulk_data()->parallel()), m_gee_cnt(0), m_gen_cnt(0), - //m_entity_repo(stk_classic::mesh::stk_classic::percept::EntityRankEnd) - - NodeRegistry(percept::PerceptMesh& eMesh, bool useCustomGhosting = false) : m_eMesh(eMesh), - //m_comm_all(0), - m_comm_all( new stk_classic::CommAll(eMesh.get_bulk_data()->parallel()) ), - //m_comm_all(eMesh.get_bulk_data()->parallel()), - // why does this cause failures? - //m_cell_2_data_map(eMesh.get_number_elements()*8u), - m_useCustomGhosting(useCustomGhosting), - m_gee_cnt(0), m_gen_cnt(0), - m_entity_repo(stk_classic::percept::EntityRankEnd), - m_debug(false), - m_state(NRS_NONE) - { -#if !PERCEPT_USE_PSEUDO_ELEMENTS - m_useCustomGhosting = true; -#endif - //m_comm_all( new stk_classic::CommAll(eMesh.get_bulk_data()->parallel()) ), - -#if NODE_REGISTRY_MAP_TYPE_GOOGLE - //SubDimCell_SDSEntityType empty_key; - //empty_key.insert( std::numeric_limits::max() ); - //m_cell_2_data_map.set_empty_key(empty_key); - - SubDimCell_SDSEntityType deleted_key; - deleted_key.insert( std::numeric_limits::max() - 1u ); - m_cell_2_data_map.set_deleted_key(deleted_key); -#endif - } - - ~NodeRegistry() { - if (m_comm_all) - delete m_comm_all; - } - - void init_comm_all() - { - //std::cout << "tmp &m_eMesh = " << &m_eMesh << std::endl; - if (m_comm_all) - delete m_comm_all; - m_comm_all = new stk_classic::CommAll(m_eMesh.get_bulk_data()->parallel()); - } - - void init_entity_repo() - { - for (unsigned i = 0; i < stk_classic::percept::EntityRankEnd; i++) m_entity_repo[i].clear(); - } - - void clear_dangling_nodes(SetOfEntities* nodes_to_be_deleted) - { - const bool debug = false; - if (debug) std::cout << "tmp srk NodeRegistry::clear_dangling_nodes start" << std::endl; - double cpu_0 = stk_classic::cpu_time(); - - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = getMap(); - - std::vector to_erase; - int num_delete=0; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - VERIFY_OP_ON(nodeIds_onSE.size(), ==, nodeIds_onSE.m_entity_id_vector.size(), "NodeRegistry::clear_dangling_nodes id vector/size mismatch"); - unsigned nnodes = nodeIds_onSE.size(); - NodeIdsOnSubDimEntityType node_to_keep(0); - //std::vector node_to_keep; - std::vector node_id_to_keep(0); - for (unsigned inode=0; inode < nnodes; inode++) - { - if (!nodeIds_onSE[inode]) continue; - stk_classic::mesh::EntityId id = nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::EntityId id_check = nodeIds_onSE[inode]->identifier(); - VERIFY_OP_ON(id_check, ==, id, "NodeRegistry::clear_dangling_nodes id"); - - //if ( stk_classic::mesh::EntityLogDeleted == nodeIds_onSE[inode]->log_query() ) - if (nodes_to_be_deleted && nodes_to_be_deleted->find(nodeIds_onSE[inode]) != nodes_to_be_deleted->end()) - { - ++num_delete; - } - else if (!nodes_to_be_deleted && stk_classic::mesh::EntityLogDeleted == nodeIds_onSE[inode]->log_query() ) - { - ++num_delete; - } - else - { - node_to_keep.push_back(nodeIds_onSE[inode]); - node_id_to_keep.push_back(id); - } - } - nodeIds_onSE = node_to_keep; - nodeIds_onSE.m_entity_id_vector = node_id_to_keep; - if (nodeIds_onSE.size() != nodeIds_onSE.m_entity_id_vector.size()) - { - std::cout << "NodeRegistry::clear_dangling_nodes id vector/size mismatch 1 size= " << nodeIds_onSE.size() << " id.size= " << nodeIds_onSE.m_entity_id_vector.size() << std::endl; - } - VERIFY_OP_ON(nodeIds_onSE.size(), ==, nodeIds_onSE.m_entity_id_vector.size(), "NodeRegistry::clear_dangling_nodes id vector/size mismatch 1"); - - if (nodeIds_onSE.size() == 0) - to_erase.push_back(iter->first); - - } - if (debug) std::cout << "tmp srk NodeRegistry::clear_dangling_nodes num_delete= " << num_delete << std::endl; - if (to_erase.size()) - { - if (debug) std::cout << "tmp srk NodeRegistry::clear_dangling_nodes nodeIds_onSE.size() != node_to_keep.size()), to_erase= " << to_erase.size() << std::endl; - for (unsigned i=0; i < to_erase.size(); i++) - { - map.erase(to_erase[i]); - } - } - - // check - if (1) - { - for (iter = map.begin(); iter != map.end(); ++iter) - { - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - VERIFY_OP_ON(nodeIds_onSE.size(), ==, nodeIds_onSE.m_entity_id_vector.size(), "NodeRegistry::clear_dangling_nodes id vector/size mismatch after erase"); - } - } - double cpu_1 = stk_classic::cpu_time(); - if (debug) std::cout << "tmp srk NodeRegistry::clear_dangling_nodes end, time= " << (cpu_1-cpu_0) << std::endl; - } - - void initialize() - { - //std::cout << "tmp &m_eMesh = " << &m_eMesh << std::endl; - //delete m_comm_all; - //m_comm_all = new stk_classic::CommAll(m_eMesh.get_bulk_data()->parallel()); - m_cell_2_data_map.clear(); - init_entity_repo(); - } - - void //NodeRegistry:: - beginRegistration() - { - m_nodes_to_ghost.resize(0); - m_pseudo_entities.clear(); - m_state = NRS_START_REGISTER_NODE; - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::beginRegistration" << std::endl; - } - - void //NodeRegistry:: - endRegistration() - { - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endRegistration start" << std::endl; - - //putInESMap(); - - removeUnmarkedSubDimEntities(); - - m_eMesh.get_bulk_data()->modification_begin(); - this->createNewNodesInParallel(); - m_nodes_to_ghost.resize(0); - -#if STK_ADAPT_NODEREGISTRY_DO_REHASH - m_cell_2_data_map.rehash(m_cell_2_data_map.size()); -#endif - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endRegistration end" << std::endl; - - m_state = NRS_END_REGISTER_NODE; - - } - - void //NodeRegistry:: - beginLocalMeshMods() - { - } - - void //NodeRegistry:: - endLocalMeshMods() - { - } - - void //NodeRegistry:: - beginCheckForRemote() - { - m_state = NRS_START_CHECK_FOR_REMOTE; - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::beginCheckForRemote " << std::endl; - } - - void //NodeRegistry:: - endCheckForRemote() - { - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endCheckForRemote start " << std::endl; - stk_classic::ParallelMachine pm = m_eMesh.get_bulk_data()->parallel(); - int failed = 0; - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - - this->allocateBuffers(); - -#if STK_ADAPT_NODEREGISTRY_DO_REHASH - m_cell_2_data_map.rehash(m_cell_2_data_map.size()); -#endif - - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endCheckForRemote end " << std::endl; - - m_state = NRS_END_CHECK_FOR_REMOTE; - - } - - void //NodeRegistry:: - beginGetFromRemote() - { - m_state = NRS_START_GET_FROM_REMOTE; - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::beginGetFromRemote " << std::endl; - - } - void //NodeRegistry:: - endGetFromRemote() - { - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endGetFromRemote start " << std::endl; - stk_classic::ParallelMachine pm = m_eMesh.get_bulk_data()->parallel(); - int failed = 0; - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - - this->communicate(); - - failed = 0; - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - - if (m_useCustomGhosting) - { - //std::cout << "m_useCustomGhosting= " << m_useCustomGhosting << std::endl; - stk_classic::mesh::Ghosting & ghosting = m_eMesh.get_bulk_data()->create_ghosting( std::string("new_nodes") ); - - vector receive; - - ghosting.receive_list( receive ); - //if (receive.size()) std::cout << "NodeRegistry::endGetFromRemote receive.size() = " << receive.size() << std::endl; - - m_eMesh.get_bulk_data()->change_ghosting( ghosting, m_nodes_to_ghost, receive); - - } - - failed = 0; - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - -#if PERCEPT_USE_PSEUDO_ELEMENTS - if (!m_useCustomGhosting) setAllReceivedNodeData(); -#endif - - m_eMesh.get_bulk_data()->modification_end(); - - if (m_useCustomGhosting) setAllReceivedNodeData(); - - if (0 && !m_useCustomGhosting) - { - m_eMesh.get_bulk_data()->modification_begin(); - removePseudoEntities(); - m_eMesh.get_bulk_data()->modification_end(); - } - - if (m_debug) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp NodeRegistry::endGetFromRemote end " << std::endl; - - m_state = NRS_END_GET_FROM_REMOTE; - } - - void removePseudoEntities() - { - - for (SetOfEntities::iterator it = m_pseudo_entities.begin(); it != m_pseudo_entities.end(); ++it) - { - stk_classic::mesh::Entity *pseudo_elem = *it; - bool did_destroy = m_eMesh.get_bulk_data()->destroy_entity(pseudo_elem); - VERIFY_OP_ON(did_destroy, ==, true, "NodeRegistry::removePseudoEntities couldn't destroy"); - } - } - - void setAllReceivedNodeData() - { - EXCEPTWATCH; - //m_eMesh.get_bulk_data()->modification_begin(); - SubDimCellToDataMap::iterator iter; - stk_classic::mesh::PartVector empty_parts; - - for (iter = m_cell_2_data_map.begin(); iter != m_cell_2_data_map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - - if (nodeIds_onSE.m_entity_id_vector.size() != nodeIds_onSE.size()) - { - std::cout << " nodeIds_onSE.m_entity_id_vector.size() = " << nodeIds_onSE.m_entity_id_vector.size() - << " nodeIds_onSE.size() = " << nodeIds_onSE.size() << std::endl; - - throw std::logic_error("NodeRegistry:: setAllReceivedNodeData logic err #0"); - } - - for (unsigned ii = 0; ii < nodeIds_onSE.size(); ii++) - { - if (!nodeIds_onSE.m_entity_id_vector[ii]) - { - nodeIds_onSE[ii] = 0; - } - else - { - stk_classic::mesh::Entity *node = get_entity_node_I(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[ii]); // FIXME - if (!node) - { - if (m_useCustomGhosting) - { - throw std::logic_error("NodeRegistry:: setAllReceivedNodeData logic err #3"); - } - else - { - //std::cout << "tmp P[" << m_eMesh.get_rank() << "] NodeRegistry::setAllReceivedNodeData id= " << nodeIds_onSE.m_entity_id_vector[ii] << std::endl; - node = & m_eMesh.get_bulk_data()->declare_entity(m_eMesh.node_rank(), nodeIds_onSE.m_entity_id_vector[ii], empty_parts); -#if PERCEPT_USE_PSEUDO_ELEMENTS - stk_classic::mesh::Entity *elem = & m_eMesh.get_bulk_data()->declare_entity(m_eMesh.element_rank()+PSEUDO_ELEMENT_RANK_SHIFT, - nodeIds_onSE.m_entity_id_vector[ii]*PSEUDO_ELEMENT_MAGIC_NUMBER+m_eMesh.get_rank(), - empty_parts); - m_pseudo_entities.insert(elem); - m_eMesh.get_bulk_data()->declare_relation(*elem, *node, 0); -#endif - if (!node) throw std::logic_error("NodeRegistry:: setAllReceivedNodeData logic err #3.1"); - } - } - nodeIds_onSE[ii] = node; - } - } - } - //m_eMesh.get_bulk_data()->modification_end(); - } - - /// when a sub-dim entity is visited during node registration but is flagged as not being marked, and thus not requiring - /// any new nodes, we flag it with NR_MARK_NONE, then remove it here - void removeUnmarkedSubDimEntities() - { - EXCEPTWATCH; - SubDimCellToDataMap::iterator iter; - - for (iter = m_cell_2_data_map.begin(); iter != m_cell_2_data_map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - if (nodeIds_onSE.size()) - { - unsigned mark = nodeIds_onSE.m_mark; - unsigned is_marked = mark & NR_MARK; - unsigned is_not_marked = mark & NR_MARK_NONE; -#if 0 - if (!(is_marked || is_not_marked)) - { - std::cout << "is_not_marked = " << is_not_marked << " is_marked= " << is_marked << std::endl; - throw std::logic_error("removeUnmarkedSubDimEntities::err1"); - } -#endif - //nodeIds_onSE.m_mark = 0u; - if (!is_marked && is_not_marked) - { - //std::cout << "tmp SRK FOUND NR_MARK " << NR_MARK << " " << NR_MARK_NONE << std::endl; - nodeIds_onSE.resize(0); - } - } - } - } - - bool is_empty( const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd); - - /// Register the need for a new node on the sub-dimensional entity @param subDimEntity on element @param element. - /// If the element is a ghost element, the entity is still registered: the locality/ownership of the new entity - /// can be determined by the locality of the element (ghost or not). - bool registerNeedNewNode(const stk_classic::mesh::Entity& element, NeededEntityType& needed_entity_rank, unsigned iSubDimOrd, bool needNodes) - { - static SubDimCell_SDSEntityType subDimEntity; - getSubDimEntity(subDimEntity, element, needed_entity_rank.first, iSubDimOrd); - - static SubDimCellData new_SubDimCellData; - static SubDimCellData empty_SubDimCellData; - - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - bool is_not_empty_but_data_cleared = (!is_empty && nodeId_elementOwnderId.get().size() == 0); - - // if empty or if my id is the smallest, make this element the owner - bool should_put_in = - (element.identifier() < stk_classic::mesh::entity_id(nodeId_elementOwnderId.get())) - || (element.entity_rank() > stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get())); - -#define DEBUG_NR_UNREF 0 - if (DEBUG_NR_UNREF) - { - std::cout << "registerNeedNewNode:: is_empty= " << is_empty << " should_put_in= " << should_put_in << " needed_entity_rank= " - << needed_entity_rank.first << " subDimEntity= "; - - for (unsigned k=0; k < subDimEntity.size(); k++) - { - std::cout << " " << subDimEntity[k]->identifier() << " "; - } -#if 0 - for (unsigned k=0; k < subDimEntity.size(); k++) - { - std::cout << " " << (stk_classic::mesh::EntityId) subDimEntity[k] << " "; - } -#endif - std::cout << std::endl; - } - - if (!is_empty) - { - unsigned& mark = nodeId_elementOwnderId.get().m_mark; - if (needNodes) - mark |= NR_MARK; - else - mark |= NR_MARK_NONE; - } - - - /// once it's in, the assertion should be: - /// owning_elementId < non_owning_elementId && owning_elementRank >= non_owning_elementRank - /// - if (is_empty || is_not_empty_but_data_cleared || should_put_in) - { - // new SubDimCellData SDC_DATA_OWNING_ELEMENT_KEY - // CHECK - - unsigned numNewNodes = needed_entity_rank.second; - - NodeIdsOnSubDimEntityType nid_new(numNewNodes, 0u); - if (needNodes) - nid_new.m_mark |= NR_MARK; - else - nid_new.m_mark |= NR_MARK_NONE; - - // create SubDimCellData for the map rhs - // add one to iSubDimOrd for error checks later - SubDimCellData data(nid_new, stk_classic::mesh::EntityKey(element.entity_rank(), element.identifier()), iSubDimOrd+1 ); - putInMap(subDimEntity, data); - - if (0 && DEBUG_NR_UNREF) - { - std::cout << "registerNeedNewNode:: is_empty= " << is_empty << " should_put_in= " << should_put_in << " subDimEntity= "; - for (unsigned k=0; k < subDimEntity.size(); k++) - { - std::cout << " " << subDimEntity[k]->identifier() << " "; - } -#if 0 - for (unsigned k=0; k < subDimEntity.size(); k++) - { - std::cout << " " << (stk_classic::mesh::EntityId) subDimEntity[k] << " "; - } -#endif - std::cout << std::endl; - } - - // new_SubDimCellData.get<0>().init(needed_entity_rank.second, 0u); - // new_SubDimCellData.get<1>() = newEntityKey; - //m_cell_2_data_map.insert(std::pair(subDimEntity, new_SubDimCellData) ); - //m_cell_2_data_map.insert(std::pair(subDimEntity, data) ); - - return true; - } - return false; - } - - /// check the newly registered node from the registry, which does one of three things, depending on what mode we are in: - /// 1. counts buffer in prep for sending (just does a pack) - /// 2. packs the buffer (after buffers are alloc'd) - /// 3. returns the new node after all communications are done - bool checkForRemote(const stk_classic::mesh::Entity& element, NeededEntityType& needed_entity_rank, unsigned iSubDimOrd, bool needNodes_notUsed) - { - EXCEPTWATCH; - static SubDimCellData empty_SubDimCellData; - static CommDataType buffer_entry; - - bool isGhost = m_eMesh.isGhostElement(element); - - if (!isGhost) return true; - - static SubDimCell_SDSEntityType subDimEntity; - getSubDimEntity(subDimEntity, element, needed_entity_rank.first, iSubDimOrd); - - stk_classic::CommAll& comm_all = *m_comm_all; - unsigned proc_size = comm_all.parallel_size(); - unsigned proc_rank = comm_all.parallel_rank(); - unsigned owner_proc_rank = element.owner_rank(); - - - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - - if (is_empty) - { - std::cout << "element= " << element - << " needed_entity_rank= " << needed_entity_rank.first<< " " << needed_entity_rank.second << std::endl; - std::cout << "subDimEntity= " << subDimEntity << std::endl; - std::cout << "nodeId_elementOwnderId= " << nodeId_elementOwnderId << std::endl; - std::cout << "empty_SubDimCellData= " << empty_SubDimCellData << std::endl; - throw std::logic_error("NodeRegistry::checkForRemote no data (is_empty=true) - logic error."); - return false; - } - else - { - - unsigned owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nidsz = nodeIds_onSE.size(); - - // error check - bool isNotOK = (element.identifier() < owning_elementId) && (element.entity_rank() > owning_elementRank) ; - - if ( isNotOK ) - { - std::cout << "P[" << proc_rank << "] elem id = " << element.identifier() - << " nodeId_elementOwnderId.get() = " - << owning_elementId - << std::endl; - throw std::logic_error("NodeRegistry::checkForRemote logic: owning element info is wrong"); - } - - unsigned erank = m_eMesh.element_rank(); - erank = owning_elementRank; - //VERIFY_OP(erank, <=, owning_elementRank , "erank..."); - stk_classic::mesh::Entity * owning_element = get_entity_element(*m_eMesh.get_bulk_data(), erank, owning_elementId); - - if (!owning_element) - throw std::logic_error("NodeRegistry::checkForRemote logic: owning_element is null"); - - bool owning_element_is_ghost = m_eMesh.isGhostElement(*owning_element); - - // if this element is a ghost, and the owning element of the node is not a ghost, send info - // to ghost element's owner proc - if (!owning_element_is_ghost && isGhost) - { - buffer_entry = CommDataType( - needed_entity_rank.first, - iSubDimOrd, - element.key() - ); - - if (nodeIds_onSE.m_entity_id_vector.size() != nodeIds_onSE.size()) - { - throw std::logic_error("NodeRegistry::checkForRemote logic err #0.1"); - } - - for (unsigned iid = 0; iid < nidsz; iid++) - { - if (nodeIds_onSE[iid] == 0) - { - throw std::logic_error("logic: hmmm #5.0"); - } - - if (!nodeIds_onSE.m_entity_id_vector[iid]) - { - throw std::logic_error("NodeRegistry::checkForRemote logic err #0.2"); - } - - //stk_classic::mesh::Entity * new_node = get_entity_node_Ia(*m_eMesh.get_bulk_data(), Node, nodeIds_onSE, iid); - stk_classic::mesh::Entity * new_node = nodeIds_onSE[iid]; - - if (0) - { - stk_classic::mesh::Entity * new_node_1 = get_entity_node_I(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[iid]); - if (new_node != new_node_1) - { - throw std::logic_error("NodeRegistry::checkForRemote logic err #0.3"); - } - } - - if (!new_node) - { - throw std::logic_error("NodeRegistry::checkForRemote logic: new_node is null"); - } - - m_nodes_to_ghost.push_back( stk_classic::mesh::EntityProc(new_node, owner_proc_rank) ); - } - - if (isParallelRun(proc_size)) - { - //std::cout << "P[" << proc_rank << "] : pack " << buffer_entry << " owner_proc_rank= " << owner_proc_rank << std::endl; - m_comm_all->send_buffer( owner_proc_rank ).pack< CommDataType > (buffer_entry); - NodeIdsOnSubDimEntityType& nids = nodeId_elementOwnderId.get(); - nids.pack(m_comm_all->send_buffer( owner_proc_rank )); - } - else - { - // FIXME createNodeAndConnect(buffer_entry); - } - } - } - return true; // FIXME - } - - bool getFromRemote(const stk_classic::mesh::Entity& element, NeededEntityType& needed_entity_rank, unsigned iSubDimOrd, bool needNodes_notUsed) - { - return checkForRemote(element, needed_entity_rank, iSubDimOrd, needNodes_notUsed); - } - - -#define LOCAL_INLINE inline - - LOCAL_INLINE stk_classic::mesh::Entity* get_entity_using_find(stk_classic::mesh::EntityRank& rank, const stk_classic::mesh::EntityId& id) const - { - const EntityRepo::const_iterator i = m_entity_repo[rank].find( id ); - return i != m_entity_repo[rank].end() ? i->second : NULL ; - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - -#if STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO - stk_classic::mesh::Entity* entity = get_entity_using_find(rank, id); - if (entity) - return entity; - else - { - entity = bulk.get_entity(rank, id); - m_entity_repo[rank][id] = entity; - return entity; - } -#else - return bulk.get_entity(rank, id); -#endif - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_I(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - -#if STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO - stk_classic::mesh::Entity* entity = get_entity_using_find(rank, id); - if (entity) - return entity; - else - { - entity = bulk.get_entity(rank, id); - m_entity_repo[rank][id] = entity; - return entity; - } -#else - return bulk.get_entity(rank, id); -#endif - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_Ia(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - -#if STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO - stk_classic::mesh::Entity* entity = get_entity_using_find(rank, id); - if (entity) - return entity; - else - { - entity = bulk.get_entity(rank, id); - m_entity_repo[rank][id] = entity; - return entity; - } -#else - return bulk.get_entity(rank, id); -#endif - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_Ib(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { -#if STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO - stk_classic::mesh::Entity* entity = get_entity_using_find(rank, id); - if (entity) - return entity; - else - { - entity = bulk.get_entity(rank, id); - m_entity_repo[rank][id] = entity; - return entity; - } -#else - return bulk.get_entity(rank, id); -#endif - } - - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_element(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - //m_gee_cnt++; - return get_entity(bulk, rank, id); - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_node_I(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - //m_gen_cnt++; - return get_entity_I(bulk, rank, id); - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_node_Ia(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, NodeIdsOnSubDimEntityType& nodeIds_onSE, unsigned index) - { - //m_gen_cnt++; - //stk_classic::mesh::Entity * entity = get_entity(bulk, rank, nodeIds_onSE.m_entity_id_vector[index]); - stk_classic::mesh::Entity * entity = nodeIds_onSE[index]; - return entity; - } - - LOCAL_INLINE stk_classic::mesh::Entity *get_entity_node_Ib(stk_classic::mesh::BulkData& bulk, stk_classic::mesh::EntityRank rank, stk_classic::mesh::EntityId id) - { - //m_gen_cnt++; - return get_entity_Ib(bulk, rank, id); - } - - NodeIdsOnSubDimEntityType* getNewNodesOnSubDimEntity(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank& needed_entity_rank, unsigned iSubDimOrd); - - /// makes coordinates of this new node be the centroid of its sub entity - void makeCentroidCoords(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - makeCentroidField(element, needed_entity_rank, iSubDimOrd, m_eMesh.get_coordinates_field()); - } - - void makeCentroidField(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd, stk_classic::mesh::FieldBase *field) - { - //EXCEPTWATCH; - - int spatialDim = m_eMesh.get_spatial_dim(); - stk_classic::mesh::EntityRank field_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - { - unsigned nfr = field->restrictions().size(); - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //mesh::Part& frpart = metaData.get_part(fr.ordinal()); - field_rank = fr.entity_rank(); - spatialDim = fr.dimension() ; - } - } - - if (field_rank != stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - return; - } - - unsigned *null_u = 0; - static SubDimCell_SDSEntityType subDimEntity; - //subDimEntity.clear(); - getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - static SubDimCellData empty_SubDimCellData; - - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - - if (s_allow_empty_sub_dims && is_empty) - { - return; - } - if (is_empty) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - shards::CellTopology cell_topo(cell_topo_data); - - std::cout << "NodeRegistry::makeCentroidField: no node found, cell_topo = " << cell_topo.getName() - << "\n subDimEntity= " << subDimEntity - << "\n element= " << element - << "\n element.entity_rank() = " << element.entity_rank() - << "\n needed_entity_rank= " << needed_entity_rank - << "\n iSubDimOrd= " << iSubDimOrd << std::endl; - throw std::runtime_error("makeCentroidField: no node found"); - } - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - if (nodeIds_onSE.size() != 1) - throw std::runtime_error("makeCentroidField not ready for multiple nodes"); - //stk_classic::mesh::Entity * c_node = m_eMesh.get_bulk_data()->get_entity(Node, nodeIds_onSE[0]); - //stk_classic::mesh::Entity * c_node = get_entity_node(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE[0]); - //stk_classic::mesh::Entity * c_node = get_entity_node_Ia(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE, 0u); - stk_classic::mesh::Entity * c_node = nodeIds_onSE[0]; - - - if (!c_node) - { - throw std::runtime_error("makeCentroidField: bad node found 0"); - } - - //std::vector c_p(spatialDim, 0.0); - double c_p[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - - bool doPrint = false; - - if (needed_entity_rank == m_eMesh.element_rank()) - { - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - unsigned npts = elem_nodes.size(); - //if (npts == 2) doPrint=true; - double dnpts = elem_nodes.size(); - for (unsigned ipts = 0; ipts < npts; ipts++) - { - //stk_classic::mesh::EntityId nodeId = elem_nodes[ipts]; - stk_classic::mesh::Entity * node = elem_nodes[ipts].entity(); //m_eMesh.get_bulk_data()->get_entity(Node, nodeId); - if (!node) - { - throw std::runtime_error("makeCentroidField: bad node found 1"); - } - //double * const coord = stk_classic::mesh::field_data( *field , *node ); - double * coord = m_eMesh.field_data(field, *node, null_u); - - if (doPrint && coord) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - shards::CellTopology cell_topo(cell_topo_data); - - std::cout << "tmp NodeRegistry::makeCentroidField cell_topo = " << cell_topo.getName() << " ipts= " << ipts - << " coord= " << coord[0] << " " << coord[1] << " " << coord[2] << std::endl; - } - - if (coord) - { - for (int isp = 0; isp < spatialDim; isp++) - { - c_p[isp] += coord[isp]/dnpts; - } - } - } - - } - else - { - double dnpts = subDimEntity.size(); - for (SubDimCell_SDSEntityType::iterator ids = subDimEntity.begin(); ids != subDimEntity.end(); ids++) - { - SDSEntityType nodeId = *ids; - - //stk_classic::mesh::Entity * node = m_eMesh.get_bulk_data()->get_entity(Node, nodeId); - //!!stk_classic::mesh::Entity * node = get_entity_node_II(*m_eMesh.get_bulk_data(),Node, nodeId); - stk_classic::mesh::Entity * node = nodeId; - if (!node) - { - throw std::runtime_error("makeCentroidField: bad node found 2"); - } - //double * const coord = stk_classic::mesh::field_data( *field, *node ); - double * coord = m_eMesh.field_data(field, *node, null_u); - if (coord) - { - for (int isp = 0; isp < spatialDim; isp++) - { - c_p[isp] += coord[isp]/dnpts; - } - } - } - } - //double * c_coord = stk_classic::mesh::field_data( *field , *c_node ); - double * c_coord = m_eMesh.field_data(field, *c_node, null_u); - if (c_coord) - { - //std::string coord_str; - for (int isp = 0; isp < spatialDim; isp++) - { - c_coord[isp] = c_p[isp]; - //if (doPrint) - // coord_str += toString(c_coord[isp])+ " "; - } - if (doPrint) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - shards::CellTopology cell_topo(cell_topo_data); - - std::cout << "tmp NodeRegistry::makeCentroidField cell_topo = " << cell_topo.getName() - << "\n subDimEntity= " << subDimEntity - << "\n element= " << element - << "\n element.entity_rank() = " << element.entity_rank() - << "\n needed_entity_rank= " << needed_entity_rank - << "\n iSubDimOrd= " << iSubDimOrd << std::endl; - //std::cout << "P[" << m_eMesh.get_rank() << "] needed_entity_rank= " << needed_entity_rank << " coord= " << coord_str << std::endl; - } - } - - } - - void makeCentroid(stk_classic::mesh::FieldBase *field); - - /// do interpolation for all fields - void interpolateFields(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - const stk_classic::mesh::FieldVector & fields = m_eMesh.get_fem_meta_data()->get_fields(); - unsigned nfields = fields.size(); - //std::cout << "P[" << p_rank << "] info> Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - //std::cout << "P[" << m_eMesh.get_rank() << "] field = " << field->name() << std::endl; - makeCentroidField(element, needed_entity_rank, iSubDimOrd, field); - } - } - - /// do interpolation for all fields - void interpolateFields() - { - const stk_classic::mesh::FieldVector & fields = m_eMesh.get_fem_meta_data()->get_fields(); - unsigned nfields = fields.size(); - //std::cout << "P[" << p_rank << "] info> Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - //std::cout << "P[" << m_eMesh.get_rank() << "] field = " << field->name() << std::endl; - makeCentroid(field); - } - } - - - /// check for adding new nodes to existing parts based on sub-entity part ownership - - void addToExistingParts(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - const std::vector< stk_classic::mesh::Part * > & parts = m_eMesh.get_fem_meta_data()->get_parts(); - - unsigned nparts = parts.size(); - - //CHECK - static SubDimCell_SDSEntityType subDimEntity; - //subDimEntity.clear(); - getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - static SubDimCellData empty_SubDimCellData; - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - - if (s_allow_empty_sub_dims && is_empty) - { - return; - } - - if (is_empty) - { - throw std::runtime_error("addToExistingParts: no node found"); - } - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nidsz = nodeIds_onSE.size(); - - for (unsigned i_nid = 0; i_nid < nidsz; i_nid++) - { - //stk_classic::mesh::Entity * c_node = get_entity_node(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE[i_nid]); - //stk_classic::mesh::Entity * c_node = get_entity_node_Ia(*m_eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE, i_nid); - stk_classic::mesh::Entity * c_node = nodeIds_onSE[i_nid]; - - if (!c_node) - { - std::cout << "addToExistingParts: " << nodeIds_onSE[i_nid] << " i_nid= " << i_nid << " nidsz= " << nidsz - << " needed_entity_rank= " << needed_entity_rank << " iSubDimOrd= " << iSubDimOrd << std::endl; - throw std::runtime_error("addToExistingParts: bad node found 0.1"); - } - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - stk_classic::mesh::Selector selector(part); - - //std::cout << "P[" << m_eMesh.get_rank() << "] NodeRegistry::addToExistingParts Part[" << ipart << "]= " << part.name() << std::endl; - //std::string part_name = part.name(); - - // FIXME - is there a better way to determine if a part is one of the "standard" parts? - if (stk_classic::mesh::is_auto_declared_part(part)) //part_name[0] == '{') // is_auto_declared_part - continue; - - //std::cout << "P[" << p_rank << "] info> Part[" << ipart << "]= " << part.name() - // << " topology = " << (topology?shards::CellTopology(topology).getName():"null") - // << std::endl; - - - bool found = true; - if (needed_entity_rank == m_eMesh.element_rank()) - { - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - unsigned npts = elem_nodes.size(); - for (unsigned ipts = 0; ipts < npts; ipts++) - { - stk_classic::mesh::Entity * node = elem_nodes[ipts].entity(); - if (!node) - { - throw std::runtime_error("addToExistingParts: bad node found 1.1"); - } - if (!selector(*node)) - { - found = false; - break; - } - - } - } - else - { - //double dnpts = subDimEntity.size(); - for (SubDimCell_SDSEntityType::iterator ids = subDimEntity.begin(); ids != subDimEntity.end(); ++ids) - { - SDSEntityType nodeId = *ids; - //!!Entity * node = get_entity_node_II(*m_eMesh.get_bulk_data(),Node, nodeId); - stk_classic::mesh::Entity * node = nodeId; - if (!node) - { - throw std::runtime_error("addToExistingParts: bad node found 2.1"); - } - if (!selector(*node)) - { - found = false; - break; - } - } - } - if (found) - { - // add to part - std::vector add_parts(1, &part); - std::vector remove_parts; - const CellTopologyData *const topology = stk_classic::percept::PerceptMesh::get_cell_topology(part); - const unsigned part_rank = part.primary_entity_rank(); - - //if (!topology) - if (part_rank == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - m_eMesh.get_bulk_data()->change_entity_parts( *c_node, add_parts, remove_parts ); - if (0) - { - std::cout << "P[" << m_eMesh.get_rank() << "] adding node " << c_node->identifier() << " to Part[" << ipart << "]= " << part.name() - << " topology = " << (topology ? shards::CellTopology(topology).getName() : "null") - << std::endl; - } - } - - } - } - } - } - - /// Check for adding new nodes to existing parts based on sub-entity part ownership. - /// This version does it in bulk and thus avoids repeats on shared sub-dim entities. - - void addToExistingPartsNew() - { - static std::vector add_parts(1, static_cast(0)); - static std::vector remove_parts; - - //std::cout << "tmp addToExistingPartsNew... " << std::endl; - const std::vector< stk_classic::mesh::Part * > & parts = m_eMesh.get_fem_meta_data()->get_parts(); - - unsigned nparts = parts.size(); - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - - //std::cout << "P[" << m_eMesh.get_rank() << "] NodeRegistry::addToExistingParts Part[" << ipart << "]= " << part.name() << std::endl; - //std::string part_name = part.name(); - - // FIXME - is there a better way to determine if a part is one of the "standard" parts? - if (stk_classic::mesh::is_auto_declared_part(part)) //part_name[0] == '{') // is_auto_declared_part - continue; - - const CellTopologyData *const topology = stk_classic::percept::PerceptMesh::get_cell_topology(part); - const unsigned part_rank = part.primary_entity_rank(); - - if (part_rank == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - stk_classic::mesh::Selector selector(part); - - //std::cout << "P[" << m_eMesh.get_rank() << "] NodeRegistry::addToExistingPartsNew rank=Node = Part[" << ipart << "]= " << part.name() << std::endl; - add_parts[0] = ∂ - - SubDimCellToDataMap::iterator iter; - //std::cout << "tmp m_cell_2_data_map.size() = " << m_cell_2_data_map.size() << std::endl; - for (iter = m_cell_2_data_map.begin(); iter != m_cell_2_data_map.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - //std::cout << "P[" << p_rank << "] info> Part[" << ipart << "]= " << part.name() - // << " topology = " << (topology?shards::CellTopology(topology).getName():"null") - // << std::endl; - - bool found = true; - stk_classic::mesh::EntityRank needed_entity_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - // - // SPECIAL CASE - // SPECIAL CASE - // SPECIAL CASE - // - if( subDimEntity.size() == 1) - { - needed_entity_rank = m_eMesh.element_rank(); - } - - if (needed_entity_rank == m_eMesh.element_rank()) - { - stk_classic::mesh::Entity *element_p = 0; - { - SDSEntityType elementId = *subDimEntity.begin(); - element_p = elementId; - if (!element_p) - { - throw std::runtime_error("addToExistingPartsNew: bad elem found 2"); - } - } - - stk_classic::mesh::Entity& element = *element_p; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - unsigned npts = elem_nodes.size(); - for (unsigned ipts = 0; ipts < npts; ipts++) - { - stk_classic::mesh::Entity * node = elem_nodes[ipts].entity(); - if (!selector(*node)) - { - found = false; - break; - } - } - } - else - { - for (SubDimCell_SDSEntityType::const_iterator ids = subDimEntity.begin(); ids != subDimEntity.end(); ++ids) - { - SDSEntityType nodeId = *ids; - stk_classic::mesh::Entity * node = nodeId; - if (!selector(*node)) - { - found = false; - break; - } - } - } - if (found) - { - // add to part - - unsigned nidsz = nodeIds_onSE.size(); - - for (unsigned i_nid = 0; i_nid < nidsz; i_nid++) - { - stk_classic::mesh::Entity * c_node = nodeIds_onSE[i_nid]; - - if (!c_node) - { - // note, this is ok - a null node here can come from a ghost element - if (1) - { - continue; - } - else - { - std::cout << "addToExistingPartsNew: " << nodeIds_onSE[i_nid] << " i_nid= " << i_nid << " nidsz= " << nidsz - << std::endl; - throw std::runtime_error("addToExistingParts: bad node found 0.3"); - } - } - - // only try to add to part if I am the owner - if (c_node->owner_rank() == m_eMesh.get_parallel_rank()) - m_eMesh.get_bulk_data()->change_entity_parts( *c_node, add_parts, remove_parts ); - - if (0) - { - std::cout << "P[" << m_eMesh.get_rank() << "] adding node " << c_node->identifier() << " to Part[" << ipart << "]= " << part.name() - << " topology = " << (topology ? shards::CellTopology(topology).getName() : "null") - << std::endl; - } - } - - } - } - } - } - //std::cout << "tmp addToExistingPartsNew...done " << std::endl; - } - - SubDimCellData& getNewNodeAndOwningElement(SubDimCell_SDSEntityType& subDimEntity) - { - return m_cell_2_data_map[subDimEntity]; - } - - -#define NODE_REGISTRY_MAP_ACCESSORS_INLINED 1 - - SubDimCellData * getFromMapPtr(const SubDimCell_SDSEntityType& subDimEntity) const -#if NODE_REGISTRY_MAP_ACCESSORS_INLINED - { - const SubDimCellToDataMap::const_iterator i = m_cell_2_data_map.find( subDimEntity ); - return i != m_cell_2_data_map.end() ? (const_cast(&(i->second))) : 0 ; - } -#else - ; -#endif - - SubDimCellData& getFromMap(const SubDimCell_SDSEntityType& subDimEntity) const -#if NODE_REGISTRY_MAP_ACCESSORS_INLINED - { - const SubDimCellToDataMap::const_iterator i = m_cell_2_data_map.find( subDimEntity ); - return * (const_cast(&(i->second))); - } -#else - ; -#endif - void putInMap(SubDimCell_SDSEntityType& subDimEntity, SubDimCellData& data) -#if NODE_REGISTRY_MAP_ACCESSORS_INLINED - { - m_cell_2_data_map[subDimEntity] = data; - } -#else - ; -#endif - - /// @param needNodes should be true in general; it's used by registerNeedNewNode to generate actual data or not on the subDimEntity - /// For local refinement, subDimEntity's needs are not always known uniquely by the pair {elementId, iSubDimOrd}; for example, in - /// an element-based marking scheme, the shared face between two elements may be viewed differently. So, we need the ability to - /// override the default behavior of always creating new nodes on the subDimEntity, but still allow the entity to be created in - /// the NodeRegistry databse. - - typedef bool (NodeRegistry::*ElementFunctionPrototype)( const stk_classic::mesh::Entity& element, NeededEntityType& needed_entity_rank, unsigned iSubDimOrd, bool needNodes); - - /// this is a helper method that loops over all sub-dimensional entities whose rank matches on of those in @param needed_entity_ranks - /// and registers that sub-dimensional entity as needing a new node. - /// @param isGhost should be true if this element is a ghost, in which case this will call the appropriate method to set up for - // communications - - void //NodeRegistry:: - doForAllSubEntities(ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - shards::CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - (this ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } // iSubDimOrd - } // ineed_ent - } - - void //NodeRegistry:: - noInline_getSubDimEntity(SubDimCell_SDSEntityType& subDimEntity, const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd); - - /// fill - /// @param subDimEntity with the stk_classic::mesh::EntityId's of - /// the ordinal @param iSubDimOrd sub-dimensional entity of - /// @param element of rank - /// @param needed_entity_rank - /// - void //NodeRegistry:: - getSubDimEntity(SubDimCell_SDSEntityType& subDimEntity, const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - subDimEntity.clear(); - // in the case of elements, we don't share any nodes so we just make a map of element id to node - if (needed_entity_rank == m_eMesh.element_rank()) - { - subDimEntity.insert( const_cast(&element) ); - //!!subDimEntity.insert(element.identifier()); - return; - } - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - //CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - const unsigned * inodes = 0; - unsigned nSubDimNodes = 0; - static const unsigned edge_nodes_2[2] = {0,1}; - static const unsigned face_nodes_3[3] = {0,1,2}; - static const unsigned face_nodes_4[4] = {0,1,2,3}; - - // special case for faces in 3D - if (needed_entity_rank == m_eMesh.face_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - if (nSubDimNodes ==3 ) - inodes = face_nodes_3; - else - inodes = face_nodes_4; - - } - // special case for edges in 2D - else if (needed_entity_rank == m_eMesh.edge_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - if (nSubDimNodes == 2 ) - { - inodes = edge_nodes_2; - } - else - { - throw std::runtime_error("NodeRegistry bad for edges"); - } - } - else if (needed_entity_rank == m_eMesh.edge_rank()) - { - inodes = cell_topo_data->edge[iSubDimOrd].node; - nSubDimNodes = 2; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - nSubDimNodes = cell_topo_data->side[iSubDimOrd].topology->vertex_count; - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - inodes = cell_topo_data->side[iSubDimOrd].node; - } - - //subDimEntity.reserve(nSubDimNodes); - for (unsigned jnode = 0; jnode < nSubDimNodes; jnode++) - { - subDimEntity.insert( elem_nodes[inodes[jnode]].entity() ); - //!!subDimEntity.insert(elem_nodes[inodes[jnode]].entity()->identifier()); - } - - } - - - // FIXME - unsigned total_size() { - //throw std::runtime_error("not ready"); - //return m_cell_2_data_map.size(); - unsigned sz=0; - - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - SubDimCellData& data = (*cell_iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = data.get(); - - sz += nodeIds_onSE.size(); - } - return sz; - } - - unsigned local_size() - { - unsigned sz=0; - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - SubDimCellData& data = (*cell_iter).second; - - stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(data.get()); - - NodeIdsOnSubDimEntityType& nodeIds_onSE = data.get(); - if (nodeIds_onSE.size()) - { - //! - unsigned erank = m_eMesh.element_rank(); - erank = stk_classic::mesh::entity_rank(data.get()); - stk_classic::mesh::Entity * owning_element = get_entity_element(*m_eMesh.get_bulk_data(), erank, owning_elementId); - //! - - if (!owning_element) - { - std::cout << "tmp owning_element = null, owning_elementId= " << owning_elementId - //<< " nodeIds_onSE= " << nodeIds_onSE - << std::endl; - throw std::logic_error("logic: hmmm #5.2"); - } - if (!m_eMesh.isGhostElement(*owning_element)) - { - //sz += 1; - sz += nodeIds_onSE.size(); - } - } - } - return sz; - } - - //======================================================================================================================== - // low-level interface - // FIXME - bool isParallelRun(unsigned size) { return true; } - - void checkDB(std::string msg="") - { - if (0) - { - unsigned sz=0; - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - SubDimCellData& data = (*cell_iter).second; - stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(data.get()); - NodeIdsOnSubDimEntityType& nodeIds_onSE = data.get(); - - stk_classic::mesh::Entity * owning_element = m_eMesh.get_bulk_data()->get_entity(m_eMesh.element_rank(), owning_elementId); - if (!owning_element) - throw std::logic_error("logic: hmmm #5.3"); - bool isGhost = m_eMesh.isGhostElement(*owning_element); - if (!m_eMesh.isGhostElement(*owning_element)) - { - ++sz; - } - if (!isGhost) - std::cout << "P[" << m_eMesh.get_rank() << "] owning_elementId = " << owning_elementId << " isGhostElement = " << isGhost - << " nodeId = " << nodeIds_onSE << std::endl; - } - } - if (1) - { - std::cout << "NodeRegistry::checkDB start msg= " << msg << std::endl; - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& subDimCellData = (*cell_iter).second; - //stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(subDimCellData.get()); - //stk_classic::mesh::EntityRank owning_element_rank = stk_classic::mesh::entity_rank(subDimCellData.get()); - NodeIdsOnSubDimEntityType& nodeIds_onSE = subDimCellData.get(); - - for (unsigned i=0; i < nodeIds_onSE.size(); i++) - { - stk_classic::mesh::Entity *node = nodeIds_onSE[i]; - stk_classic::mesh::EntityId nodeId = nodeIds_onSE.m_entity_id_vector[i]; - VERIFY_OP_ON(node, !=, 0, "checkDB #11.1"); - VERIFY_OP_ON(nodeId, !=, 0, "checkDB #11.1.1"); - VERIFY_OP_ON(node->identifier(), ==, nodeId, "checkDB #11.2"); - stk_classic::mesh::Entity *node_0 = m_eMesh.get_bulk_data()->get_entity(0, nodeId); - - VERIFY_OP_ON(node, ==, node_0, "checkDB #11.3"); - VERIFY_OP_ON(node_0->identifier(), ==, nodeId, "checkDB #11.4"); - } - } - std::cout << "NodeRegistry::checkDB end msg= " << msg << std::endl; - } - - if (0) - { - std::cout << "NodeRegistry::checkDB start 1 msg= " << msg << std::endl; - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& subDimCellData = (*cell_iter).second; - stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(subDimCellData.get()); - stk_classic::mesh::EntityRank owning_element_rank = stk_classic::mesh::entity_rank(subDimCellData.get()); - NodeIdsOnSubDimEntityType& nodeIds_onSE = subDimCellData.get(); - - if (owning_elementId == 0) continue; - stk_classic::mesh::Entity * owning_element = m_eMesh.get_bulk_data()->get_entity(owning_element_rank, owning_elementId); - if (!owning_element) - throw std::logic_error("logic: checkDB hmmm #11.0"); - //bool isGhost = m_eMesh.isGhostElement(*owning_element); - if (!m_eMesh.isGhostElement(*owning_element)) - { - for (unsigned i=0; i < nodeIds_onSE.size(); i++) - { - stk_classic::mesh::Entity *node = nodeIds_onSE[i]; - stk_classic::mesh::EntityId nodeId = nodeIds_onSE.m_entity_id_vector[i]; - VERIFY_OP_ON(node, !=, 0, "checkDB #11.1"); - VERIFY_OP_ON(nodeId, !=, 0, "checkDB #11.1.1"); - VERIFY_OP_ON(node->identifier(), ==, nodeId, "checkDB #11.2"); - stk_classic::mesh::Entity *node_0 = m_eMesh.get_bulk_data()->get_entity(0, nodeId); - - VERIFY_OP_ON(node, ==, node_0, "checkDB #11.3"); - VERIFY_OP_ON(node_0->identifier(), ==, nodeId, "checkDB #11.4"); - unsigned owner_rank = node->owner_rank(); - VERIFY_OP_ON(owner_rank, ==, owning_element->owner_rank(), "checkDB #11.6"); - } - } - } - std::cout << "NodeRegistry::checkDB end 1 msg= " << msg << std::endl; - - } - - } - - /// allocate the send/recv buffers for all-to-all communication - bool allocateBuffers() - { - stk_classic::CommAll& comm_all = *m_comm_all; - unsigned proc_size = comm_all.parallel_size(); - unsigned proc_rank = comm_all.parallel_rank(); - - // FIXME - add some error checking - -#if 0 - if (!isParallelRun(proc_size)) - { - return false; - } -#endif - - bool local = true; // FIXME - unsigned num_msg_bounds = proc_size < 4 ? proc_size : proc_size/4 ; - bool global = comm_all.allocate_buffers(num_msg_bounds , false, local ); - if ( not global ) - { - std::cout << "P[" << proc_rank << "] : not global" << std::endl; - return false; - } - return true; - } - - void communicate() - { - stk_classic::CommAll& comm_all = *m_comm_all; - //unsigned proc_size = comm_all.parallel_size(); - //unsigned proc_rank = comm_all.parallel_rank(); - -#if 0 - for (unsigned i_proc_rank = 0; i_proc_rank < proc_size; i_proc_rank++) - { - std::cout << "P[" << proc_rank << "] : i_proc_rank = " << i_proc_rank << " send buf size = " - << m_comm_all->send_buffer( i_proc_rank ).size() << " num in buf= " - << m_comm_all->send_buffer( i_proc_rank ).size() / sizeof(CommDataType) << std::endl; - } -#endif - comm_all.communicate(); - - stk_classic::ParallelMachine pm = m_eMesh.get_bulk_data()->parallel(); - int failed = 0; - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - - unpack(); - - } - - void - unpack() - { - stk_classic::CommAll& comm_all = *m_comm_all; - - int failed = 0; - std::string msg; - - stk_classic::ParallelMachine pm = m_eMesh.get_bulk_data()->parallel(); - unsigned proc_size = m_eMesh.get_bulk_data()->parallel_size(); - unsigned proc_rank = comm_all.parallel_rank(); - - vector nodes_to_ghost; - - CommDataType buffer_entry; - NodeIdsOnSubDimEntityType nodeIds_onSE; - try - { - for(unsigned from_proc = 0; from_proc < proc_size; ++from_proc ) - { - stk_classic::CommBuffer & recv_buffer = comm_all.recv_buffer( from_proc ); - - //unsigned num_in_buffer = recv_buffer.size() / sizeof(CommDataType); - //std::cout << "for proc= " << from_proc << " recv_buffer.size()= " << recv_buffer.size() << " num_in_buffer = " << num_in_buffer << std::endl; - - while ( recv_buffer.remaining() ) - { - // - // this->unpack( this->container(), p, recv_buffer ); - // - // Rank of sub-dim cells needing new nodes, which sub-dim entity, one non-owning element identifier, nodeId_elementOwnderId.first - // typedef boost::tuple::tuple CommDataType; - - - recv_buffer.unpack< CommDataType >( buffer_entry ); - nodeIds_onSE.unpack(m_eMesh, recv_buffer); - //recv_buffer.unpack< NodeIdsOnSubDimEntityType > (nodeIds_onSE); - - - //std::cout << "P[" << proc_rank << "] unpack for buffer from proc= " << from_proc << " " << buffer_entry << std::endl; - createNodeAndConnect(buffer_entry, nodeIds_onSE, from_proc, nodes_to_ghost); - } - } - } - catch ( std::exception &x ) - { - failed = 1; - msg = std::string("unpack error: ")+x.what(); - } - - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &failed ) ); - if ( failed ) - { - throw std::runtime_error( msg+" from unpack error, rank = "+toString(proc_rank) ); - } - - if (nodes_to_ghost.size()) - { - stk_classic::mesh::Ghosting & ghosting = m_eMesh.get_bulk_data()->create_ghosting( std::string("new_nodes") ); - - vector receive; - ghosting.receive_list( receive ); - //if (receive.size()) std::cout << "NodeRegistry::endGetFromRemote receive.size() = " << receive.size() << std::endl; - m_eMesh.get_bulk_data()->change_ghosting( ghosting, nodes_to_ghost, receive); - } - - }// unpack - - - /// after registering all needed nodes, this method is used to request new nodes on this processor - void createNewNodesInParallel() - { - static int num_times_called = 0; - ++num_times_called; - - stk_classic::mesh::Part* new_nodes_part = m_eMesh.get_non_const_part("refine_new_nodes_part"); - if (new_nodes_part) - { - // first remove any existing nodes - //unsigned proc_rank = m_eMesh.get_rank(); - //std::cout << "P[" << proc_rank << "] remove existing nodes... " << std::endl; - std::vector remove_parts(1, new_nodes_part); - std::vector add_parts; - std::vector node_vec; - - stk_classic::mesh::Selector removePartSelector(*new_nodes_part & m_eMesh.get_fem_meta_data()->locally_owned_part() ); - const std::vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - if (removePartSelector(bucket)) - { - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& node = bucket[ientity]; - node_vec.push_back(&node); - } - } - } - for (unsigned ii=0; ii < node_vec.size(); ii++) - { - m_eMesh.get_bulk_data()->change_entity_parts( *node_vec[ii], add_parts, remove_parts ); - } - - //std::cout << "P[" << proc_rank << "] remove existing nodes...done " << std::endl; - } - - unsigned num_nodes_needed = local_size(); - - // FIXME - // assert( bulk data is in modifiable mode) - // create new entities on this proc - vector new_nodes; - - if (m_useCustomGhosting) - m_eMesh.createEntities( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, num_nodes_needed, new_nodes); - - std::vector ids(num_nodes_needed); - - if (!m_useCustomGhosting) - { -#define NR_GEN_OWN_IDS 0 -#if NR_GEN_OWN_IDS - new_nodes.resize(num_nodes_needed); -#else - m_eMesh.createEntities( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, num_nodes_needed, new_nodes); -#endif - - // bogus, but just for testing - we delete the just-created entities and re-declare them without ownership info - // so that modification_end takes care of assigning ownership - stk_classic::mesh::PartVector empty_parts; - for (unsigned i=0; i < num_nodes_needed; i++) - { -#if NR_GEN_OWN_IDS - ids[i] = (num_times_called*100000) + i + (num_times_called*100000)*1000*m_eMesh.get_parallel_rank(); -#else - ids[i] = new_nodes[i]->identifier(); - bool did_destroy = m_eMesh.get_bulk_data()->destroy_entity(new_nodes[i]); - VERIFY_OP_ON(did_destroy, ==, true, "createNewNodesInParallel couldn't destroy"); -#endif - new_nodes[i] = & m_eMesh.get_bulk_data()->declare_entity(m_eMesh.node_rank(), ids[i], empty_parts); -#if PERCEPT_USE_PSEUDO_ELEMENTS - unsigned proc_rank = m_eMesh.get_rank(); - stk_classic::mesh::Entity *elem = & m_eMesh.get_bulk_data()->declare_entity(m_eMesh.element_rank()+PSEUDO_ELEMENT_RANK_SHIFT, ids[i]*PSEUDO_ELEMENT_MAGIC_NUMBER+proc_rank, empty_parts); - m_pseudo_entities.insert(elem); - m_eMesh.get_bulk_data()->declare_relation(*elem, *new_nodes[i], 0); -#endif - } - } - - if (new_nodes_part) - { - //unsigned proc_rank = m_eMesh.get_rank(); - //std::cout << "P[" << proc_rank << "] add new nodes... " << std::endl; - stk_classic::mesh::Selector selector(m_eMesh.get_fem_meta_data()->locally_owned_part() ); - std::vector add_parts(1, new_nodes_part); - std::vector remove_parts; - for (unsigned ind = 0; ind < new_nodes.size(); ind++) - { - - m_eMesh.get_bulk_data()->change_entity_parts( *new_nodes[ind], add_parts, remove_parts ); - } - //std::cout << "P[" << proc_rank << "] add new nodes...done " << std::endl; - } - - // set map values to new node id's - unsigned inode=0; - - for (SubDimCellToDataMap::iterator cell_iter = m_cell_2_data_map.begin(); cell_iter != m_cell_2_data_map.end(); ++cell_iter) - { - SubDimCellData& data = (*cell_iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = data.get(); - if (!nodeIds_onSE.size()) - continue; - - stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(data.get()); - - if (!owning_elementId) - { - throw std::logic_error("logic: hmmm #5.4.0"); - } - - //! - unsigned erank = m_eMesh.element_rank(); - erank = stk_classic::mesh::entity_rank(data.get()); - stk_classic::mesh::Entity * owning_element = get_entity_element(*m_eMesh.get_bulk_data(), erank, owning_elementId); - //! - - if (!owning_element) - { - throw std::logic_error("logic: hmmm #5.4"); - } - if (!m_eMesh.isGhostElement(*owning_element)) - { - if (nodeIds_onSE.m_entity_id_vector.size() != nodeIds_onSE.size()) - { - throw std::logic_error("NodeRegistry:: createNewNodesInParallel logic err #0.0"); - } - - for (unsigned ii = 0; ii < nodeIds_onSE.size(); ii++) - { - //nodeIds_onSE[ii] = new_nodes[inode]->identifier(); - - VERIFY_OP(inode, < , num_nodes_needed, "UniformRefiner::doBreak() too many nodes"); - if ( DEBUG_NR_UNREF) - { - std::cout << "tmp createNewNodesInParallel: old node id= " << (nodeIds_onSE[ii] ? toString(nodeIds_onSE[ii]->identifier()) : std::string("null")) << std::endl; - std::cout << "tmp createNewNodesInParallel: new node="; - m_eMesh.print_entity(std::cout, *new_nodes[inode]); - } - - // if already exists from a previous iteration/call to doBreak, don't reset it and just use the old node - if (nodeIds_onSE[ii]) - { - if (DEBUG_NR_UNREF) - { - std::cout << "tmp createNewNodesInParallel: old node id is no-null, re-using it= " << (nodeIds_onSE[ii] ? toString(nodeIds_onSE[ii]->identifier()) : std::string("null")) << std::endl; - std::cout << "tmp createNewNodesInParallel: new node="; - m_eMesh.print_entity(std::cout, *new_nodes[inode]); - } - } - else - { - nodeIds_onSE[ii] = new_nodes[inode]; - nodeIds_onSE.m_entity_id_vector[ii] = new_nodes[inode]->identifier(); - } - - //nodeIds_onSE.m_entity_vector[ii] = new_nodes[inode]; - inode++; - } - //data.get()[0] = new_nodes[inode]->identifier(); - } - } - } - - - /// unpacks the incoming information in @param buffer_entry and adds that information to my local node registry - /// (i.e. the map of sub-dimensional entity to global node id is updated) - void - createNodeAndConnect(CommDataType& buffer_entry, NodeIdsOnSubDimEntityType& nodeIds_onSE, unsigned from_proc, vector& nodes_to_ghost) - { - //stk_classic::mesh::EntityId& non_owning_elementId = buffer_entry.get(); - - stk_classic::mesh::EntityRank& needed_entity_rank = buffer_entry.get(); - unsigned iSubDimOrd = buffer_entry.get(); - stk_classic::mesh::EntityKey& non_owning_elementKey = buffer_entry.get(); - stk_classic::mesh::EntityId non_owning_elementId = stk_classic::mesh::entity_id(non_owning_elementKey); - stk_classic::mesh::EntityRank non_owning_elementRank = stk_classic::mesh::entity_rank(non_owning_elementKey); - - // create a new relation here? no, we are going to delete this element, so we just register that the new node is attached to - //stk_classic::mesh::Entity * element = m_eMesh.get_bulk_data()->get_entity(m_eMesh.element_rank(), non_owning_elementId); - - //! - unsigned erank = m_eMesh.element_rank(); - erank = non_owning_elementRank; - stk_classic::mesh::Entity * element = get_entity_element(*m_eMesh.get_bulk_data(), erank, non_owning_elementId); - //! - - for (unsigned iid = 0; iid < nodeIds_onSE.size(); iid++) - { - //stk_classic::mesh::Entity * node = get_entity_node_I(*m_eMesh.get_bulk_data(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE[iid]); - //nodeIds_onSE.m_entity_vector[iid] = node; - //stk_classic::mesh::Entity * node = get_entity_node_Ia(*m_eMesh.get_bulk_data(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE, iid); - stk_classic::mesh::Entity * node = nodeIds_onSE[iid]; - - // has to be null, right? - if (node) - { - throw std::logic_error("logic: node should be null in createNodeAndConnect"); - } - } - if (!element) - { - throw std::logic_error("logic: element shouldn't be null in createNodeAndConnect"); - } - - static SubDimCell_SDSEntityType subDimEntity; - getSubDimEntity(subDimEntity, *element, needed_entity_rank, iSubDimOrd); - SubDimCellData& subDimCellData = getNewNodeAndOwningElement(subDimEntity); - // assert it is empty? - - subDimCellData.get() = nodeIds_onSE; - -#ifndef NDEBUG - stk_classic::mesh::EntityId owning_element_id = stk_classic::mesh::entity_id(subDimCellData.get()); - stk_classic::mesh::EntityRank owning_element_rank = stk_classic::mesh::entity_rank(subDimCellData.get()); - //VERIFY_OP(owning_element_id, !=, non_owning_elementId, "createNodeAndConnect:: bad elem ids"); - //VERIFY_OP(owning_element_id, < , non_owning_elementId, "createNodeAndConnect:: bad elem ids 2"); - - // owning_elementId < non_owning_elementId && owning_elementRank >= non_owning_elementRank - if (owning_element_rank >= non_owning_elementRank) - { - VERIFY_OP(owning_element_id, !=, non_owning_elementId, "createNodeAndConnect:: bad elem ids"); - VERIFY_OP(owning_element_id, < , non_owning_elementId, "createNodeAndConnect:: bad elem ids 2"); - } -#endif - - } - - public: - SubDimCellToDataMap& getMap() { return m_cell_2_data_map; } - PerceptMesh& getMesh() { return m_eMesh; } - bool getUseCustomGhosting() { return m_useCustomGhosting; } - - // remove any sub-dim entities from the map that have a node in deleted_nodes - void cleanDeletedNodes(std::set& deleted_nodes, bool debug=false) - { - std::set deleted_nodes_copy = deleted_nodes; - - if (DEBUG_NR_UNREF) - std::cout << "tmp cleanDeletedNodes deleted_nodes size: " << deleted_nodes_copy.size() << std::endl; - - SubDimCellToDataMap::iterator iter; - std::vector to_delete; - - SubDimCellToDataMap& map = m_cell_2_data_map; - if (DEBUG_NR_UNREF) - std::cout << "tmp cleanDeletedNodes map size: " << map.size() << std::endl; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - - unsigned jj = 0; - bool found = false; - for (unsigned ii = 0; ii < nodeIds_onSE.size(); ii++) - { - if (deleted_nodes.find(nodeIds_onSE[ii]) != deleted_nodes.end()) - { - found = true; - jj = ii; - deleted_nodes_copy.erase(nodeIds_onSE[ii]); - break; - } - } - if (found) - { - if (DEBUG_NR_UNREF) - { - std::cout << "tmp cleanDeletedNodes:: removing node id= " << nodeIds_onSE[jj]->identifier() << std::endl; - std::cout << "Node: "; - m_eMesh.print_entity(std::cout, *nodeIds_onSE[jj]); - } - if (!debug) - { - //unsigned owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - //unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - //nodeId_elementOwnderId.get() = stk_classic::mesh::EntityKey(0u, 0u); - //nodeIds_onSE.resize(0); - to_delete.push_back(iter); - } - } - } - - //std::cout << "tmp cleanDeletedNodes to_delete.size()= " << to_delete.size() << " map.size()= " << map.size() << std::endl; - for (unsigned itd=0; itd < to_delete.size(); itd++) - { - map.erase(to_delete[itd]); - } - - if (DEBUG_NR_UNREF && deleted_nodes_copy.size()) - { - std::cout << "tmp cleanDeletedNodes some deleted nodes not found, size()=: " << deleted_nodes_copy.size() << " nodes= " << std::endl; - std::set::iterator it; - for (it = deleted_nodes_copy.begin(); it != deleted_nodes_copy.end(); ++it) - { - stk_classic::mesh::Entity *node = *it; - std::cout << "Node: "; - m_eMesh.print_entity(std::cout, *node); - } - - } - } - - // further cleanup of the NodeRegistry db - some elements get deleted on some procs but the ghost elements - // are still in the db - the easiest way to detect this is as used here: during modification_begin(), - // cleanup of cached transactions are performed, then we find these by seeing if our element id's are - // no longer in the stk_mesh db. - - void clear_element_owner_data_phase_2() - { - m_eMesh.get_bulk_data()->modification_begin(); - - SubDimCellToDataMap::iterator iter; - - SubDimCellToDataMap& map = m_cell_2_data_map; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - unsigned owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - - if (owning_elementId) - { - //stk_classic::mesh::Entity * owning_element = get_entity_element(*m_eMesh.get_bulk_data(), owning_elementRank, owning_elementId); - stk_classic::mesh::Entity * owning_element = m_eMesh.get_bulk_data()->get_entity(owning_elementRank, owning_elementId); - -#if 0 - if (owning_element != owning_element_1) - { - - std::cout << "P[" << m_eMesh.get_rank() << "] NR::clear_2 error # 1= " << owning_element << " " << owning_element_1 << std::endl; - throw std::logic_error("NodeRegistry:: clear_element_owner_data_phase_2 error # 1"); - } -#endif - - if (!owning_element) - { - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - nodeIds_onSE.resize(0); - - nodeId_elementOwnderId.get() = stk_classic::mesh::EntityKey(owning_elementRank, 0u); - - } - } - } - m_eMesh.get_bulk_data()->modification_end(); - - } - - // remove/zero any data that points to a deleted element - // called by Refiner with "children_to_be_removed_with_ghosts" - void clear_element_owner_data( std::set& elems_to_be_deleted) - { - SubDimCellToDataMap::iterator iter; - - SubDimCellToDataMap& map = m_cell_2_data_map; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - unsigned owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - - if (owning_elementId) - { - stk_classic::mesh::Entity * owning_element = get_entity_element(*m_eMesh.get_bulk_data(), owning_elementRank, owning_elementId); - stk_classic::mesh::Entity * owning_element_1 = m_eMesh.get_bulk_data()->get_entity(owning_elementRank, owning_elementId); - - if (owning_element != owning_element_1) - { - std::cout << "P[" << m_eMesh.get_rank() << "] NR::clear_1 error # 1= " << owning_element << " " << owning_element_1 << std::endl; - throw std::logic_error("NodeRegistry:: clear_element_owner_data_phase_1 error # 1"); - } - - if (owning_element) - { - - bool isGhost = m_eMesh.isGhostElement(*owning_element); - - bool in_deleted_list = elems_to_be_deleted.find(owning_element) != elems_to_be_deleted.end(); - - if (in_deleted_list) - { - - if (0) - std::cout << "clear_element_owner_data: owning_elementId = " << owning_elementId - << " isGhost= " << isGhost << std::endl; - - // FIXME - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - nodeIds_onSE.resize(0); - // FIXME - nodeId_elementOwnderId.get() = stk_classic::mesh::EntityKey(owning_elementRank, 0u); - } - } - } - } - } - - void dumpDB(std::string msg="") - { - if (!DEBUG_NR_UNREF) return; - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = m_cell_2_data_map; - std::cout << msg << " tmp dumpDB map size: " << map.size() << std::endl; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - - for (unsigned ii = 0; ii < nodeIds_onSE.size(); ii++) - { - std::cout << "tmp ddb:: node id= " << nodeIds_onSE[ii]->identifier() << std::endl; - std::cout << "subDimEntity= "; - for (unsigned k=0; k < subDimEntity.size(); k++) - { - std::cout << " " << subDimEntity[k]->identifier() << " "; - } - std::cout << "Node: "; - m_eMesh.print_entity(std::cout, *nodeIds_onSE[ii]); - } - } - } - - // estimate of memory used by this object - unsigned get_memory_usage() - { - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = m_cell_2_data_map; - - unsigned mem=0; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - mem += sizeof(SDSEntityType)*subDimEntity.size(); - mem += sizeof(stk_classic::mesh::EntityKey); - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - - unsigned mem1 = (sizeof(NodeIdsOnSubDimEntityTypeQuantum)+ - sizeof(stk_classic::mesh::EntityId))*nodeIds_onSE.size() +sizeof(unsigned); - - mem += mem1; - } - return mem; - } - - - private: - percept::PerceptMesh& m_eMesh; - stk_classic::CommAll * m_comm_all; - SubDimCellToDataMap m_cell_2_data_map; - - vector m_nodes_to_ghost; - SetOfEntities m_pseudo_entities; - bool m_useCustomGhosting; - - public: - int m_gee_cnt; - int m_gen_cnt; - //const CellTopologyData * const m_cell_topo_data; - std::vector m_entity_repo; - - bool m_debug; - - NodeRegistryState m_state; - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistryDef.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistryDef.hpp deleted file mode 100644 index 8a45ae5de8ae..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/NodeRegistryDef.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef stk_adapt_NodeRegistryDef_hpp -#define stk_adapt_NodeRegistryDef_hpp - -#include - -namespace stk_classic { - namespace adapt { - - NodeIdsOnSubDimEntityType* NodeRegistry::getNewNodesOnSubDimEntity(const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank& needed_entity_rank, - unsigned iSubDimOrd) - { - EXCEPTWATCH; - static SubDimCell_SDSEntityType subDimEntity; - getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - static SubDimCellData empty_SubDimCellData; - - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - - if (is_empty) - { - if (0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - CellTopology cell_topo(cell_topo_data); - - std::cout << "NodeRegistry::getNewNodesOnSubDimEntity: no node found, cell_topo = " << cell_topo.getName() - << "\n subDimEntity= " << subDimEntity - << "\n element= " << element - << "\n element.entity_rank() = " << element.entity_rank() - << "\n needed_entity_rank= " << needed_entity_rank - << "\n iSubDimOrd= " << iSubDimOrd << std::endl; - throw std::runtime_error("NodeRegistry::getNewNodesOnSubDimEntity: no node found"); - - } - return 0; - } - NodeIdsOnSubDimEntityType& nodeId = nodeId_elementOwnderId.get(); - return &nodeId; - } - - bool NodeRegistry::is_empty( const stk_classic::mesh::Entity& element, stk_classic::mesh::EntityRank needed_entity_rank, unsigned iSubDimOrd) - { - static SubDimCell_SDSEntityType subDimEntity; - getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - static SubDimCellData empty_SubDimCellData; - - SubDimCellData* nodeId_elementOwnderId_ptr = getFromMapPtr(subDimEntity); - //SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - return is_empty; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.cpp deleted file mode 100644 index 67cc88e8196a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.cpp +++ /dev/null @@ -1,2193 +0,0 @@ - -//p #include "EdgeSizeEvaluator.hpp" -//p #include "RefinerTagManager.hpp" - -//p #include "moab/Interface.hpp" - -#include -#include -#include -#include - -#include - -#include - -// Static arrays holding parametric coordinates of element vertices -#if 0 -static double MBVertexParametric[] = { 0., 0., 0. }; -static double MBEdgeParametric[] = { 0., 0., 0., 1., 0., 0. }; -static double MBTriParametric[] = { 0., 0., 0., 1., 0., 0., 0., 1., 0. }; -static double MBTetParametric[] = { 0., 0., 0., 1., 0., 0., 0., 1., 0., 0., 0., 1. }; -#endif - -#ifdef MB_DEBUG_TESSELLATOR -# define MB_TESSELLATOR_INCR_CASE_COUNT(cs) this->case_counts[cs]++ -# define MB_TESSELLATOR_INCR_SUBCASE_COUNT(cs,sc) this->subcase_counts[cs][sc]++ -#else // MB_DEBUG_TESSELLATOR -# define MB_TESSELLATOR_INCR_CASE_COUNT(cs) -# define MB_TESSELLATOR_INCR_SUBCASE_COUNT(cs,sc) -#endif // MB_DEBUG_TESSELLATOR - -#define PERCEPT_DEBUG 0 - -namespace moab { - - static void error(int i) - { - std::string ii = "Percept_MOAB_SimplexTemplateRefiner:: err # "+ boost::lexical_cast(i); - throw std::logic_error("test"); - } - - //p this is from some comments below, and coded in tet_edges. It's only used for disambiguation of same-length edges. - //p * Edge 0-1, Edge 1-2, Edge 2-0, Edge 0-3, Edge 1-3, Edge 2-3, - int tet_edges[6][2] = {{0,1}, {1,2}, {2,0}, {0,3}, {1,3}, {2,3}}; - - double compute_edge_length_squared(double *c0, double *c1) - { - return - (c0[0]-c1[0])*(c0[0]-c1[0])+ - (c0[1]-c1[1])*(c0[1]-c1[1])+ - (c0[2]-c1[2])*(c0[2]-c1[2]); - } - - /**\brief Refine a tetrahedron. - - */ - bool SimplexTemplateRefiner::refine_3_simplex(std::vector& new_tets, - unsigned edge_marks[6], - int max_depth, - double* v0, void* t0, EntityHandle h0, - double* v1, void* t1, EntityHandle h1, - double* v2, void* t2, EntityHandle h2, - double* v3, void* t3, EntityHandle h3 ) - { // refine_3_simplex - int edge_code = 0; - - double s_midpt0c[3]={0,0,0}; - double s_midpt1c[3]={0,0,0}; - double s_midpt2c[3]={0,0,0}; - double s_midpt3c[3]={0,0,0}; - double s_midpt4c[3]={0,0,0}; - double s_midpt5c[3]={0,0,0}; - - double* midpt0c=0; - double* midpt1c=0; - double* midpt2c=0; - double* midpt3c=0; - double* midpt4c=0; - double* midpt5c=0; - - void* midpt0t=0; - void* midpt1t=0; - void* midpt2t=0; - void* midpt3t=0; - void* midpt4t=0; - void* midpt5t=0; - - EntityHandle midpt0h=0; - EntityHandle midpt1h=0; - EntityHandle midpt2h=0; - EntityHandle midpt3h=0; - EntityHandle midpt4h=0; - EntityHandle midpt5h=0; - - if ( max_depth-- > 0 ) - { - midpt0c = &s_midpt0c[0]; - midpt1c = &s_midpt1c[0]; - midpt2c = &s_midpt2c[0]; - midpt3c = &s_midpt3c[0]; - midpt4c = &s_midpt4c[0]; - midpt5c = &s_midpt5c[0]; - - midpt0t = this->heap_tag_storage(); - midpt1t = this->heap_tag_storage(); - midpt2t = this->heap_tag_storage(); - midpt3t = this->heap_tag_storage(); - midpt4t = this->heap_tag_storage(); - midpt5t = this->heap_tag_storage(); - - //pfor ( int i = 0; i < 6; ++ i ) - for ( int i = 0; i < 3; ++ i ) - { - midpt0c[i] = ( v0[i] + v1[i] ) * .5; - midpt1c[i] = ( v1[i] + v2[i] ) * .5; - midpt2c[i] = ( v2[i] + v0[i] ) * .5; - midpt3c[i] = ( v0[i] + v3[i] ) * .5; - midpt4c[i] = ( v1[i] + v3[i] ) * .5; - midpt5c[i] = ( v2[i] + v3[i] ) * .5; - } - - /*p - (*this->tag_assigner)( v0, t0, h0, midpt0c, midpt0t, v1, t1, h1 ); - (*this->tag_assigner)( v1, t1, h1, midpt1c, midpt1t, v2, t2, h2 ); - (*this->tag_assigner)( v2, t2, h2, midpt2c, midpt2t, v0, t0, h0 ); - (*this->tag_assigner)( v0, t0, h0, midpt3c, midpt3t, v3, t3, h3 ); - (*this->tag_assigner)( v1, t1, h1, midpt4c, midpt4t, v3, t3, h3 ); - (*this->tag_assigner)( v2, t2, h2, midpt5c, midpt5t, v3, t3, h3 ); - */ - - for (int ie=0; ie < 6; ie++) - { - if (edge_marks[ie]) edge_code |= (1 << ie); - } - } - - //p perform edge length calculations in a consistent way (see below, we do it on permuted values) - //double edge_length2[6]; - //for ( int ei = 0; ei < 6; ++ ei ) - // edge_length2[ei] = 0.; - - - if (PERCEPT_DEBUG) - std::cout << "tmp PM edge_code= " << edge_code << std::endl; - - if ( ! edge_code ) - { - // No edges to subdivide - - return false; - } - - double facept0c[3]={0,0,0}; - double facept1c[3]={0,0,0}; - double facept2c[3]={0,0,0}; - double facept3c[3]={0,0,0}; - -// facept0c = this->heap_coord_storage(); -// facept1c = this->heap_coord_storage(); -// facept2c = this->heap_coord_storage(); -// facept3c = this->heap_coord_storage(); - - double* vertex_coords[14] = { - v0, v1, v2, v3, - midpt0c, midpt1c, midpt2c, - midpt3c, midpt4c, midpt5c, - facept0c, facept1c, facept2c, facept3c - }; - - void* facept0t = this->heap_tag_storage(); - void* facept1t = this->heap_tag_storage(); - void* facept2t = this->heap_tag_storage(); - void* facept3t = this->heap_tag_storage(); - - void* vertex_tags[14] = { - t0, t1, t2, t3, - midpt0t, midpt1t, midpt2t, - midpt3t, midpt4t, midpt5t, - facept0t, facept1t, facept2t, facept3t - }; - (void)vertex_tags; - - EntityHandle vertex_hash[14] = { - h0, h1, h2, h3, - midpt0h, midpt1h, midpt2h, - midpt3h, midpt4h, midpt5h, - 0, 0, 0, 0 - }; - - // Generate tetrahedra that are compatible except when edge - // lengths are equal on indeterminately subdivided faces. - double* permuted_coords[14]; -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - void* permuted_tags[14]; -#endif - EntityHandle permuted_hash[14]; - int permuted_local_ids[14]; // this is just a copy of permutations_from_index, for readability - double permlen[6]; // permuted edge lengths - int C = SimplexTemplateRefiner::template_index[edge_code][0]; - int P = SimplexTemplateRefiner::template_index[edge_code][1]; - - if (PERCEPT_DEBUG) - std::cout << "tmp PM C,P= " << C << " " << P << std::endl; - - // 1. Permute the tetrahedron into our canonical configuration - for ( int i = 0; i < 14; ++ i ) - { - permuted_local_ids[i] = SimplexTemplateRefiner::permutations_from_index[P][i]; - permuted_coords[i] = vertex_coords[SimplexTemplateRefiner::permutations_from_index[P][i]]; -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - permuted_tags[i] = vertex_tags[SimplexTemplateRefiner::permutations_from_index[P][i]]; -#endif - permuted_hash[i] = vertex_hash[SimplexTemplateRefiner::permutations_from_index[P][i]]; - } - - /*p - for ( int i = 4 ; i < 10; ++ i ) - { - // permute edge lengths too - permlen[i-4] = edge_length2[SimplexTemplateRefiner::permutations_from_index[P][i] - 4]; - } - */ - for (int i = 0; i < 6; i++) - { - - double *c0 = permuted_coords[tet_edges[i][0]]; - double *c1 = permuted_coords[tet_edges[i][1]]; - //bool reverse=false; - if (permuted_hash[tet_edges[i][0]] > permuted_hash[tet_edges[i][1]]) - { - c0 = permuted_coords[tet_edges[i][1]]; - c1 = permuted_coords[tet_edges[i][0]]; - //reverse=true; - } - permlen[i] = compute_edge_length_squared(c0, c1); - } - - int comparison_bits; - int comparison_bits_save; - std::stack output_tets; - std::stack output_perm; - std::stack output_sign; - - // cout << "Case " << C << " Permutation " << P << endl; - // 2. Generate tetrahedra based on the configuration. - // Note that case 0 is handled above (edgeCode == 0). - - switch ( C ) - { - case 1: // Ruprecht-Müller Case 1 - MB_TESSELLATOR_INCR_CASE_COUNT(0); - output_tets.push( SimplexTemplateRefiner::templates + 0 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(0,0); - break; - case 2: // Ruprecht-Müller Case 2a - comparison_bits = - ( permlen[0] <= permlen[1] ? 1 : 0 ) | ( permlen[0] >= permlen[1] ? 2 : 0 ) | - 0; - - // a tie-breaker for a pair of edges that have the same length - add all the vertex handles - // and choose one case or the other depending on if the sum is odd or even - -#if 0 - -#define VH(iedge) (permuted_hash[tet_edges[iedge][0]] + permuted_hash[tet_edges[iedge][1]]) -#define CMP_VH(ie,je) ((VH(ie)+VH(je)) % 2 == 0) - -#else - -#define V0(iedge) permuted_hash[tet_edges[iedge][0]] -#define V1(iedge) permuted_hash[tet_edges[iedge][1]] - -#define VH(iedge) (V0(iedge) + V1(iedge)) - //#define CMP_VH(ie,je) ( VH(ie) == VH(je) ? ( std::min(V0(ie),V1(ie)) < std::min(V0(je),V1(je)) ) : ((VH(ie)+VH(je)) % 2 == 0) ) -#define CMP_VH(ie,je) ( ( std::min(V0(ie),V1(ie)) == std::min(V0(je),V1(je)) ) ? (VH(ie) < VH(je)) : ( std::min(V0(ie),V1(ie)) < std::min(V0(je),V1(je)) ) ) - -#endif - - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[0][i] + permuted_coords[2][i] ) * .375 + permuted_coords[1][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[2], permuted_tags[1], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[0], permuted_hash[2], permuted_hash[1], permuted_coords[10], permuted_tags[10] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(0,1)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - } - - MB_TESSELLATOR_INCR_CASE_COUNT(1); - output_tets.push( SimplexTemplateRefiner::templates + 9 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(1,0); - switch ( comparison_bits ) - { - case 2: // 0>1 - output_tets.push( SimplexTemplateRefiner::templates + 14 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(1,1); - break; - case 1: // 1>0 - output_tets.push( SimplexTemplateRefiner::templates + 14 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[13] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(1,2); - break; - case 3: // 0=1 - error(1); - output_tets.push( SimplexTemplateRefiner::templates + 23 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(1,3); - break; - } - break; - case 3: // Ruprecht-Müller Case 2b - MB_TESSELLATOR_INCR_CASE_COUNT(2); - output_tets.push( SimplexTemplateRefiner::templates + 40 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(2,0); - break; - case 4: // Ruprecht-Müller Case 3a - //0<3<2<0 ? - - comparison_bits = - ( permlen[0] <= permlen[3] ? 1 : 0 ) | ( permlen[0] >= permlen[3] ? 2 : 0 ) | - ( permlen[2] <= permlen[3] ? 4 : 0 ) | ( permlen[2] >= permlen[3] ? 8 : 0 ) | - ( permlen[0] <= permlen[2] ? 16 : 0 ) | ( permlen[0] >= permlen[2] ? 32 : 0 ) | - 0; - comparison_bits_save = comparison_bits; - if ( ( comparison_bits_save & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[1][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[3], permuted_tags[0], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[1], permuted_hash[3], permuted_hash[0], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(0,3)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - } - if ( ( comparison_bits_save & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[13][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[0], permuted_tags[13] ); - permuted_hash[13] = (*this->output_functor)( - permuted_hash[2], permuted_hash[3], permuted_hash[0], permuted_coords[13], permuted_tags[13] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(2,3)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - } - if ( ( comparison_bits_save & 48 ) == 48 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[0], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[1], permuted_hash[2], permuted_hash[0], permuted_coords[10] , permuted_tags[10] ); -#else - comparison_bits -= 48 ; - if (CMP_VH(0,2)) - comparison_bits |= 16; - else - comparison_bits |= 32; -#endif - } - - MB_TESSELLATOR_INCR_CASE_COUNT(3); - output_tets.push( SimplexTemplateRefiner::templates + 57 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,0); - - // here - switch ( comparison_bits ) - { - case 42: // 0>2>3<0 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,1); - break; - case 25: // 2>3>0<2 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[11] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,2); - break; - case 37: // 3>0>2<3 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[3] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,3); - break; - case 21: // 3>2>0<3 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[22] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,4); - break; - case 26: // 2>0>3<2 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[12] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,5); - break; - case 38: // 0>3>2<0 - output_tets.push( SimplexTemplateRefiner::templates + 62 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,6); - break; - case 58: // 0=2>3<0 - error(2); - output_tets.push( SimplexTemplateRefiner::templates + 75 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,7); - break; - case 29: // 2=3>0<2 - error(3); - output_tets.push( SimplexTemplateRefiner::templates + 75 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[11] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,8); - break; - case 39: // 0=3>2<0 - error(4); - output_tets.push( SimplexTemplateRefiner::templates + 75 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[3] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,9); - break; - case 53: // 3>0=2<3 - error(5); - output_tets.push( SimplexTemplateRefiner::templates + 96 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,10); - break; - case 46: // 0>2=3<0 - error(6); - output_tets.push( SimplexTemplateRefiner::templates + 96 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[11] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,11); - break; - case 27: // 2>0=3<2 - error(7); - output_tets.push( SimplexTemplateRefiner::templates + 96 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[3] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,12); - break; - case 63: // 0=2=3=0 - error(8); - output_tets.push( SimplexTemplateRefiner::templates + 117 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(3,13); - break; - } - - break; - case 5: // Ruprecht-Müller Case 3b - MB_TESSELLATOR_INCR_CASE_COUNT(4); - output_tets.push( SimplexTemplateRefiner::templates + 162 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(4,0); - break; - case 6: // Ruprecht-Müller Case 3c - comparison_bits = - ( permlen[0] <= permlen[1] ? 1 : 0 ) | ( permlen[0] >= permlen[1] ? 2 : 0 ) | - ( permlen[0] <= permlen[3] ? 4 : 0 ) | ( permlen[0] >= permlen[3] ? 8 : 0 ) | - 0; - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[0][i] + permuted_coords[2][i] ) * .375 + permuted_coords[1][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[2], permuted_tags[1], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[0], permuted_hash[2], permuted_hash[1], permuted_coords[10], permuted_tags[10] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(0,1)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - - } - if ( ( comparison_bits & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[1][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[3], permuted_tags[0], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[1], permuted_hash[3], permuted_hash[0], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(0,3)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - - } - MB_TESSELLATOR_INCR_CASE_COUNT(5); - switch ( comparison_bits ) - { - case 10: // 0>1,0>3 - output_tets.push( SimplexTemplateRefiner::templates + 179 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,0); - break; - case 5: // 1>0,3>0 - output_tets.push( SimplexTemplateRefiner::templates + 200 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,1); - break; - case 6: // 0>1,3>0 - output_tets.push( SimplexTemplateRefiner::templates + 221 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,2); - break; - case 9: // 1>0,0>3 - output_tets.push( SimplexTemplateRefiner::templates + 242 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,3); - break; - case 11: // 0=1,0>3 - error(9); - output_tets.push( SimplexTemplateRefiner::templates + 263 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,4); - break; - case 14: // 0=3,0>1 - error(10); - output_tets.push( SimplexTemplateRefiner::templates + 263 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,5); - break; - case 7: // 3>0,0=1 - error(11); - output_tets.push( SimplexTemplateRefiner::templates + 292 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,6); - break; - case 13: // 1>0,0=3 - error(12); - output_tets.push( SimplexTemplateRefiner::templates + 292 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,7); - break; - case 15: // 0=1,0=3 - error(13); - output_tets.push( SimplexTemplateRefiner::templates + 321 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(5,8); - break; - } - break; - case 7: // Ruprecht-Müller Case 3d - comparison_bits = - ( permlen[0] <= permlen[2] ? 1 : 0 ) | ( permlen[0] >= permlen[2] ? 2 : 0 ) | - ( permlen[0] <= permlen[4] ? 4 : 0 ) | ( permlen[0] >= permlen[4] ? 8 : 0 ) | - 0; - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[0], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[1], permuted_hash[2], permuted_hash[0], permuted_coords[10], permuted_tags[10] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(0,2)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - } - if ( ( comparison_bits & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[3][i] ) * .375 + permuted_coords[1][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[3], permuted_tags[1], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[0], permuted_hash[3], permuted_hash[1], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(0,4)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - } - MB_TESSELLATOR_INCR_CASE_COUNT(6); - switch ( comparison_bits ) - { - case 10: // 0>4,0>2 - output_tets.push( SimplexTemplateRefiner::templates + 362 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,0); - break; - case 5: // 4>0,2>0 - output_tets.push( SimplexTemplateRefiner::templates + 383 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,1); - break; - case 9: // 0>4,2>0 - output_tets.push( SimplexTemplateRefiner::templates + 404 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,2); - break; - case 6: // 4>0,0>2 - output_tets.push( SimplexTemplateRefiner::templates + 425 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,3); - break; - case 14: // 0=4,0>2 - error(14); - output_tets.push( SimplexTemplateRefiner::templates + 446 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,4); - break; - case 11: // 0=2,0>4 - error(15); - output_tets.push( SimplexTemplateRefiner::templates + 446 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,5); - break; - case 13: // 2>0,0=4 - error(16); - output_tets.push( SimplexTemplateRefiner::templates + 475 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,6); - break; - case 7: // 4>0,0=2 - error(17); - output_tets.push( SimplexTemplateRefiner::templates + 475 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,7); - break; - case 15: // 0=4,0=2 - error(18); - output_tets.push( SimplexTemplateRefiner::templates + 504 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(6,8); - break; - } - break; - case 8: // Ruprecht-Müller Case 4a - comparison_bits = - ( permlen[4] <= permlen[5] ? 1 : 0 ) | ( permlen[4] >= permlen[5] ? 2 : 0 ) | - ( permlen[3] <= permlen[4] ? 4 : 0 ) | ( permlen[3] >= permlen[4] ? 8 : 0 ) | - 0; - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[12][i] = ( permuted_coords[1][i] + permuted_coords[2][i] ) * .375 + permuted_coords[3][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[2], permuted_tags[3], permuted_tags[12] ); - permuted_hash[12] = (*this->output_functor)( - permuted_hash[1], permuted_hash[2], permuted_hash[3], permuted_coords[12], permuted_tags[12] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(4,5)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - - } - if ( ( comparison_bits & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(3,4)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - } - MB_TESSELLATOR_INCR_CASE_COUNT(7); - output_tets.push( SimplexTemplateRefiner::templates + 545 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,0); - switch ( comparison_bits ) - { - case 5: // 5>4>3 - output_tets.push( SimplexTemplateRefiner::templates + 554 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,1); - break; - case 10: // 3>4>5 - output_tets.push( SimplexTemplateRefiner::templates + 554 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[13] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,2); - break; - case 6: // 3<4>5 - output_tets.push( SimplexTemplateRefiner::templates + 571 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,3); - break; - case 9: // 3>4<5 - output_tets.push( SimplexTemplateRefiner::templates + 588 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,4); - break; - case 14: // 3=4>5 - error(19); - output_tets.push( SimplexTemplateRefiner::templates + 605 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,5); - break; - case 7: // 4=5,4>3 - error(20); - output_tets.push( SimplexTemplateRefiner::templates + 605 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[13] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,6); - break; - case 13: // 5>4,3=4 - error(21); - output_tets.push( SimplexTemplateRefiner::templates + 630 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,7); - break; - case 11: // 3>4=5 - error(22); - output_tets.push( SimplexTemplateRefiner::templates + 630 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[13] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,8); - break; - case 15: // 3=4=5 - error(23); - output_tets.push( SimplexTemplateRefiner::templates + 655 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(7,9); - break; - } - break; - case 9: // Ruprecht-Müller Case 4b - comparison_bits = - ( permlen[1] <= permlen[2] ? 1 : 0 ) | ( permlen[1] >= permlen[2] ? 2 : 0 ) | - ( permlen[2] <= permlen[3] ? 4 : 0 ) | ( permlen[2] >= permlen[3] ? 8 : 0 ) | - ( permlen[3] <= permlen[4] ? 16 : 0 ) | ( permlen[3] >= permlen[4] ? 32 : 0 ) | - ( permlen[1] <= permlen[4] ? 64 : 0 ) | ( permlen[1] >= permlen[4] ? 128 : 0 ) | - 0; - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[0][i] ) * .375 + permuted_coords[2][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[0], permuted_tags[2], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[1], permuted_hash[0], permuted_hash[2], permuted_coords[10], permuted_tags[10] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(1,2)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - - } - if ( ( comparison_bits & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[13][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[0][i] * .25; - } - (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[0], permuted_tags[13] ); - permuted_hash[13] = (*this->output_functor)( - permuted_hash[2], permuted_hash[3], permuted_hash[0], permuted_coords[13], permuted_tags[13] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(2,3)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - } - if ( ( comparison_bits & 48 ) == 48 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 48 ; - if (CMP_VH(3,4)) - comparison_bits |= 16; - else - comparison_bits |= 32; -#endif - } - if ( ( comparison_bits & 192 ) == 192 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[12][i] = ( permuted_coords[2][i] + permuted_coords[3][i] ) * .375 + permuted_coords[1][i] * .25; - } - (*this->tag_assigner)( permuted_tags[2], permuted_tags[3], permuted_tags[1], permuted_tags[12] ); - permuted_hash[12] = (*this->output_functor)( - permuted_hash[2], permuted_hash[3], permuted_hash[1], permuted_coords[12], permuted_tags[12] ); -#else - comparison_bits -= 192 ; - if (CMP_VH(1,4)) - comparison_bits |= 64; - else - comparison_bits |= 128; -#endif - } - MB_TESSELLATOR_INCR_CASE_COUNT(8); - switch ( comparison_bits ) - { - case 85: // 2>1,3>2,4>3,4>1 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,0); - break; - case 102: // 1>2,3>2,3>4,4>1 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,1); - break; - case 170: // 1>2,2>3,3>4,1>4 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,2); - break; - case 153: // 2>1,2>3,4>3,1>4 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,3); - break; - case 90: // 1>2,2>3,4>3,4>1 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[9] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,4); - break; - case 105: // 2>1,2>3,3>4,4>1 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[7] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,5); - break; - case 165: // 2>1,3>2,3>4,1>4 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[19] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,6); - break; - case 150: // 1>2,3>2,4>3,1>4 - output_tets.push( SimplexTemplateRefiner::templates + 688 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[23] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,7); - break; - case 101: // 2>1,3>2,3>4,4>1 - { - int alternates[] = { 713, 738, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 0, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,8); - break; - case 86: // 1>2,3>2,4>3,4>1 - { - int alternates[] = {713, 738, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 14, -1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,9); - break; - case 154: // 1>2,2>3,4>3,1>4 - { - int alternates[] = {713, 738, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 5, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,10); - break; - case 169: // 2>1,2>3,3>4,1>4 - { - int alternates[] = {713, 738, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 15, -1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,11); - break; - case 89: // 2>1,2>3,4>3,4>1 - output_tets.push( SimplexTemplateRefiner::templates + 763 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,12); - break; - case 166: // 1>2,3>2,3>4,1>4 - output_tets.push( SimplexTemplateRefiner::templates + 763 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,13); - break; - case 103: // 1=2,3>2,3>4,4>1 - error(24); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,14); - break; - case 87: // 1=2,3>2,4>3,4>1 - error(25); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,15); - break; - case 185: // 2>1,2>3,3=4,1>4 - error(26); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,16); - break; - case 186: // 1>2,2>3,3=4,1>4 - error(27); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,17); - break; - case 158: // 1>2,2=3,4>3,1>4 - error(28); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[9] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,18); - break; - case 229: // 2>1,3>2,3>4,1=4 - error(29); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[7] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,19); - break; - case 233: // 2>1,2>3,3>4,1=4 - error(30); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[19] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,20); - break; - case 94: // 1>2,2=3,4>3,4>1 - error(31); - output_tets.push( SimplexTemplateRefiner::templates + 788 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[23] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,21); - break; - case 155: // 1=2,2>3,4>3,1>4 - error(32); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,22); - break; - case 171: // 1=2,2>3,3>4,1>4 - error(33); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,23); - break; - case 118: // 1>2,3>2,3=4,4>1 - error(34); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,24); - break; - case 117: // 2>1,3>2,3=4,4>1 - error(35); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,25); - break; - case 109: // 2>1,2=3,3>4,4>1 - error(36); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[9] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,26); - break; - case 218: // 1>2,2>3,4>3,1=4 - error(37); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[7] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,27); - break; - case 214: // 1>2,3>2,4>3,1=4 - error(38); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[19] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,28); - break; - case 173: // 2>1,2=3,3>4,1>4 - error(39); - output_tets.push( SimplexTemplateRefiner::templates + 825 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[23] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,29); - break; - case 91: // 1=2,2>3,4>3,4>1 - error(40); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,30); - break; - case 167: // 1=2,3>2,3>4,1>4 - error(41); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,31); - break; - case 182: // 1>2,3>2,3=4,1>4 - error(42); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,32); - break; - case 121: // 2>1,2>3,3=4,4>1 - error(43); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,33); - break; - case 93: // 2>1,2=3,4>3,4>1 - error(44); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[9] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,34); - break; - case 217: // 2>1,2>3,4>3,1=4 - error(45); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[7] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,35); - break; - case 230: // 1>2,3>2,3>4,1=4 - error(46); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[19] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,36); - break; - case 174: // 1>2,2=3,3>4,1>4 - error(47); - output_tets.push( SimplexTemplateRefiner::templates + 862 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[23] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,37); - break; - case 119: // 1=2,3>2,3=4,4>1 - error(48); - output_tets.push( SimplexTemplateRefiner::templates + 899 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,38); - break; - case 187: // 1=2>3=4,1>4 - error(49); - output_tets.push( SimplexTemplateRefiner::templates + 899 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,39); - break; - case 222: // 1>2,2=3,4>3,1=4 - error(50); - output_tets.push( SimplexTemplateRefiner::templates + 899 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[9] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,40); - break; - case 237: // 2>1,2=3,3>4,1=4 - error(51); - output_tets.push( SimplexTemplateRefiner::templates + 899 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[7] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,41); - break; - case 95: // 4>1=2=3,4>3 - error(52); - output_tets.push( SimplexTemplateRefiner::templates + 944 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,42); - break; - case 231: // 1=2,3>2,3>4,1=4 - error(53); - output_tets.push( SimplexTemplateRefiner::templates + 944 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,43); - break; - case 190: // 1>2=3=4,1>4 - error(54); - output_tets.push( SimplexTemplateRefiner::templates + 944 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,44); - break; - case 249: // 2>1,2>3,3=4,1=4 - error(55); - output_tets.push( SimplexTemplateRefiner::templates + 944 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,45); - break; - case 175: // 1=2=3>4,1>4 - error(56); - output_tets.push( SimplexTemplateRefiner::templates + 993 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,46); - break; - case 219: // 1=2>3,4>3,1=4 - error(57); - output_tets.push( SimplexTemplateRefiner::templates + 993 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,47); - break; - case 125: // 2>1,2=3=4>1 - error(58); - output_tets.push( SimplexTemplateRefiner::templates + 993 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,48); - break; - case 246: // 1>2,3>2,3=4=1 - error(59); - output_tets.push( SimplexTemplateRefiner::templates + 993 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,49); - break; - case 255: // 1=2=3=4=1 - error(60); - output_tets.push( SimplexTemplateRefiner::templates + 1042 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(8,50); - break; - } - break; - case 10: // Ruprecht-Müller Case 5 - comparison_bits = - ( permlen[1] <= permlen[2] ? 1 : 0 ) | ( permlen[1] >= permlen[2] ? 2 : 0 ) | - ( permlen[3] <= permlen[4] ? 4 : 0 ) | ( permlen[3] >= permlen[4] ? 8 : 0 ) | - 0; - if ( ( comparison_bits & 3 ) == 3 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[10][i] = ( permuted_coords[1][i] + permuted_coords[0][i] ) * .375 + permuted_coords[2][i] * .25; - } - (*this->tag_assigner)( permuted_tags[1], permuted_tags[0], permuted_tags[2], permuted_tags[10] ); - permuted_hash[10] = (*this->output_functor)( - permuted_hash[1], permuted_hash[0], permuted_hash[2], permuted_coords[10], permuted_tags[10] ); -#else - comparison_bits -= 3 ; - if (CMP_VH(1,2)) - comparison_bits |= 1; - else - comparison_bits |= 2; -#endif - } - if ( ( comparison_bits & 12 ) == 12 ) - { -#if PERCEPT_MOAB_ALLOW_FACE_DISAMB - // Compute face point and tag - for ( int i = 0; i < 6; ++ i ) - { - permuted_coords[11][i] = ( permuted_coords[0][i] + permuted_coords[1][i] ) * .375 + permuted_coords[3][i] * .25; - } - (*this->tag_assigner)( permuted_tags[0], permuted_tags[1], permuted_tags[3], permuted_tags[11] ); - permuted_hash[11] = (*this->output_functor)( - permuted_hash[0], permuted_hash[1], permuted_hash[3], permuted_coords[11], permuted_tags[11] ); -#else - comparison_bits -= 12 ; - if (CMP_VH(3,4)) - comparison_bits |= 4; - else - comparison_bits |= 8; -#endif - } - MB_TESSELLATOR_INCR_CASE_COUNT(9); - output_tets.push( SimplexTemplateRefiner::templates + 1107 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,0); - switch ( comparison_bits ) - { - case 10: // 1>2,3>4 - output_tets.push( SimplexTemplateRefiner::templates + 1116 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,1); - break; - case 5: // 2>1,4>3 - output_tets.push( SimplexTemplateRefiner::templates + 1116 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,2); - break; - case 6: // 1>2,4>3 - { - int alternates[] = { 1137, 1158, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 0, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,3); - break; - case 9: // 2>1,3>4 - { - int alternates[] = {1137, 1158, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 14, -1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,4); - break; - case 11: // 1=2,3>4 - error(61); - { - int alternates[] = { 1179, 1212, 1245, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 0, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,5); - break; - case 7: // 1=2,4>3 - error(62); - { - int alternates[] = {1179, 1212, 1245, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 14, -1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[14] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,6); - break; - case 14: // 3=4,1>2 - error(63); - { - int alternates[] = {1179, 1212, 1245, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 5, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[5] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,7); - break; - case 13: // 3=4,2>1 - error(64); - { - int alternates[] = {1179, 1212, 1245, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 15, -1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[15] ); - output_sign.push( -1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,8); - break; - case 15: // 1=2,3=4 - error(65); - output_tets.push( SimplexTemplateRefiner::templates + 1278 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(9,9); - break; - } - break; - case 11: // Ruprecht-Müller Case 6 - MB_TESSELLATOR_INCR_CASE_COUNT(10); - output_tets.push( SimplexTemplateRefiner::templates + 1319 ); - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(10,0); - { - int alternates[] = { 1336, 1353, 1370, -1 }; - output_tets.push( SimplexTemplateRefiner::templates + this->best_tets( alternates, permuted_coords, 0, 1 ) ); - } - output_perm.push( SimplexTemplateRefiner::permutations_from_index[0] ); - output_sign.push( 1 ); - MB_TESSELLATOR_INCR_SUBCASE_COUNT(10,1); - break; - } - - int* tets; - int ntets; - int* perm; - int sgn; -#ifdef MB_DEBUG_TESSELLATOR - if ( output_tets.empty() ) - { - cout << "Argh! Case " << C << " Perm " << P << " has no output!" << endl; - } -#endif // MB_DEBUG_TESSELLATOR - while ( ! output_tets.empty() ) - { - tets = output_tets.top(); - ntets = *tets; - tets++; - perm = output_perm.top(); - sgn = output_sign.top(); - - output_tets.pop(); - output_perm.pop(); - output_sign.pop(); - - if (PERCEPT_DEBUG) - std::cout << "tmp PM case= " << C << " edge_code= " << edge_code << " ntets= " << ntets << std::endl; - int t; - if ( sgn > 0 ) - { - for ( t = 0; t < ntets; ++t ) - { -#if 0 - this->refine_3_simplex( max_depth, - permuted_coords[perm[tets[0]]], permuted_tags[perm[tets[0]]], permuted_hash[perm[tets[0]]], - permuted_coords[perm[tets[1]]], permuted_tags[perm[tets[1]]], permuted_hash[perm[tets[1]]], - permuted_coords[perm[tets[2]]], permuted_tags[perm[tets[2]]], permuted_hash[perm[tets[2]]], - permuted_coords[perm[tets[3]]], permuted_tags[perm[tets[3]]], permuted_hash[perm[tets[3]]] - ); -#endif - TetTupleInt nt = TetTupleInt(permuted_local_ids[perm[tets[0]]], - permuted_local_ids[perm[tets[1]]], - permuted_local_ids[perm[tets[2]]], - permuted_local_ids[perm[tets[3]]]); - - new_tets.push_back(nt); - - if (PERCEPT_DEBUG) - std::cout << "tmp PM new tet= " << nt << std::endl; - - tets += 4; - } - } - else - { - // we have an inverted tet... reverse the first 2 vertices - // so the orientation is positive. - for ( t = 0; t < ntets; ++t ) - { -#if 0 - this->refine_3_simplex( max_depth, - permuted_coords[perm[tets[1]]], permuted_tags[perm[tets[1]]], permuted_hash[perm[tets[1]]], - permuted_coords[perm[tets[0]]], permuted_tags[perm[tets[0]]], permuted_hash[perm[tets[0]]], - permuted_coords[perm[tets[2]]], permuted_tags[perm[tets[2]]], permuted_hash[perm[tets[2]]], - permuted_coords[perm[tets[3]]], permuted_tags[perm[tets[3]]], permuted_hash[perm[tets[3]]] - ); -#endif - TetTupleInt nt = TetTupleInt(permuted_local_ids[perm[tets[1]]], - permuted_local_ids[perm[tets[0]]], - permuted_local_ids[perm[tets[2]]], - permuted_local_ids[perm[tets[3]]]); - - new_tets.push_back(nt); - - - if (PERCEPT_DEBUG) - std::cout << "tmp PM new tet= " << nt << std::endl; - - tets += 4; - } - } - } - - return true; - } - - /* - * The array below is indexed by the edge code for a tetrahedron. - * Looking up a row with a tet's edge code will return C and P. - * C is a configuration number and P is a permutation index. - * - * C is based on the case number from Ruprecht and - * Müller's (1998) paper on adaptive tetrahedra. (The case - * numbers are shown to the left of the row in the column - * labeled case. The only difference is that we introduce - * a case 3d which is part of case 3c in the paper.) - * - * P is an index into the permutations_from_index array below, - * and is used to transform the current tetrahedron into - * the canonical configuration associated with C. - * - * The 6-digit binary number to the left (which is shown in - * the horribly UNconventional LSB->MSB order) is the edge - * code for the row. The 6 digits correspond to the 6 edges - * of the tetrahedron; a '0' implies no subdivision while - * a '1' implies subdivision should occur. The ordering of - * the bits is - * - * Edge 0-1, Edge 1-2, Edge 2-0, Edge 0-3, Edge 1-3, Edge 2-3, - * - * where the numbers are vertices of the tetrahedron 0-1-2-3. - * Note that Tet 0-1-2-3 must be positive (i.e., the plane - * specified by Triangle 0-1-2 must have a normal pointing - * towards vertex 3, and Triangle 0-1-2's normal must be - * calculated using the cross-product (Edge 0-1) x (Edge 0-2)). - * - * =========== - * References: - * (Ruprect and Müller, 1998) A Scheme for Edge-based Adaptive - * Tetrahedron Subdivision, Mathematical Visualization (eds. - * Hege and Polthier), pp. 61--70. Springer-Verlag. 1998. - */ - int SimplexTemplateRefiner::template_index[64][2] = - { - /* code case C P */ - /* 000000 0 0 */ { 0, 0 }, - /* 100000 1 1 */ { 1, 0 }, - /* 010000 2 1 */ { 1, 1 }, - /* 110000 3 2a */ { 2, 0 }, - /* 001000 4 1 */ { 1, 2 }, - /* 101000 5 2a */ { 2, 2 }, - /* 011000 6 2a */ { 2, 1 }, - /* 111000 7 3b */ { 5, 11 }, - /* 000100 8 1 */ { 1, 10 }, - /* 100100 9 2a */ { 2, 5 }, - /* 010100 10 2b */ { 3, 1 }, - /* 110100 11 3c */ { 6, 0 }, - /* 001100 12 2a */ { 2, 10 }, - /* 101100 13 3a */ { 4, 0 }, - /* 011100 14 3d */ { 7, 2 }, - /* 111100 15 4a */ { 8, 6 }, - /* 000010 16 1 */ { 1, 6 }, - /* 100010 17 2a */ { 2, 4 }, - /* 010010 18 2a */ { 2, 8 }, - /* 110010 19 3a */ { 4, 1 }, - /* 001010 20 2b */ { 3, 2 }, - /* 101010 21 3d */ { 7, 0 }, - /* 011010 22 3c */ { 6, 1 }, - /* 111010 23 4a */ { 8, 9 }, - /* 000110 24 2a */ { 2, 3 }, - /* 100110 25 3b */ { 5, 0 }, - /* 010110 26 3d */ { 7, 4 }, - /* 110110 27 4a */ { 8, 11 }, - /* 001110 28 3c */ { 6, 10 }, - /* 101110 29 4a */ { 8, 7 }, - /* 011110 30 4b */ { 9, 0 }, - /* 111110 31 5 */ { 10, 7 }, - /* 000001 32 1 */ { 1, 7 }, - /* 100001 33 2b */ { 3, 0 }, - /* 010001 34 2a */ { 2, 7 }, - /* 110001 35 3d */ { 7, 1 }, - /* 001001 36 2a */ { 2, 11 }, - /* 101001 37 3c */ { 6, 2 }, - /* 011001 38 3a */ { 4, 2 }, - /* 111001 39 4a */ { 8, 3 }, - /* 000101 40 2a */ { 2, 9 }, - /* 100101 41 3d */ { 7, 10 }, - /* 010101 42 3c */ { 6, 7 }, - /* 110101 43 4b */ { 9, 2 }, - /* 001101 44 3b */ { 5, 7 }, - /* 101101 45 4a */ { 8, 8 }, - /* 011101 46 4a */ { 8, 4 }, - /* 111101 47 5 */ { 10, 6 }, - /* 000011 48 2a */ { 2, 6 }, - /* 100011 49 3c */ { 6, 4 }, - /* 010011 50 3b */ { 5, 1 }, - /* 110011 51 4a */ { 8, 10 }, - /* 001011 52 3d */ { 7, 7 }, - /* 101011 53 4b */ { 9, 1 }, - /* 011011 54 4a */ { 8, 5 }, - /* 111011 55 5 */ { 10, 10 }, - /* 000111 56 3a */ { 4, 10 }, - /* 100111 57 4a */ { 8, 1 }, - /* 010111 58 4a */ { 8, 2 }, - /* 110111 59 5 */ { 10, 2 }, - /* 001111 60 4a */ { 8, 0 }, - /* 101111 61 5 */ { 10, 1 }, - /* 011111 62 5 */ { 10, 0 }, - /* 111111 63 6 */ { 11, 0 }, - }; - - - /* Does this mean anything? If so, then you are either - * superstitious or much more clever than I (or both?). - */ - /* permutation index, P: 0 1 2 3 4 5 6 7 8 9 10 11 */ - /* number of references: 12 9 9 3 4 2 5 6 2 3 7 2 */ - - - /* - * The array below is a list of all the _positive_ - * permutations of Tetrahedron 0-1-2-3. Given a - * permutation index, it returns a row of 14 values: - * these are the vertex numbers of the permuted - * tetrahedron. The first 4 values are the permuted - * corner indices, the next 6 values are the - * permuted edge midpoint indices, and the final - * entries reference mid-face points inserted - * to maintain a compatible tetrahedralization. - * - * There are 24 entries, 6 for each of the 4 faces of - * the tetrahedron. - */ - int SimplexTemplateRefiner::permutations_from_index[24][14] = - { - /* corners midpoints face points */ - /* POSITIVE ARRANGEMENTS */ - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, /* Face 0-1-2 */ - { 1, 2, 0, 3, 5, 6, 4, 8, 9, 7, 10, 12, 13, 11 }, - { 2, 0, 1, 3, 6, 4, 5, 9, 7, 8, 10, 13, 11, 12 }, - - { 0, 3, 1, 2, 7, 8, 4, 6, 9, 5, 11, 13, 12, 10 }, /* Face 0-3-1 */ - { 3, 1, 0, 2, 8, 4, 7, 9, 5, 6, 11, 12, 10, 13 }, - { 1, 0, 3, 2, 4, 7, 8, 5, 6, 9, 11, 10, 13, 12 }, - - { 1, 3, 2, 0, 8, 9, 5, 4, 7, 6, 12, 11, 13, 10 }, /* Face 1-3-2 */ - { 3, 2, 1, 0, 9, 5, 8, 7, 6, 4, 12, 13, 10, 11 }, - { 2, 1, 3, 0, 5, 8, 9, 6, 4, 7, 12, 10, 11, 13 }, - - { 2, 3, 0, 1, 9, 7, 6, 5, 8, 4, 13, 12, 11, 10 }, /* Face 2-3-0 */ - { 3, 0, 2, 1, 7, 6, 9, 8, 4, 5, 13, 11, 10, 12 }, - { 0, 2, 3, 1, 6, 9, 7, 4, 5, 8, 13, 10, 12, 11 }, - - /* NEGATIVE ARRANGEMENTS */ - { 0, 2, 1, 3, 6, 5, 4, 7, 9, 8, 10, 13, 12, 11 }, /* Face 0-1-2 */ - { 2, 1, 0, 3, 5, 4, 6, 9, 8, 7, 10, 12, 11, 13 }, - { 1, 0, 2, 3, 4, 6, 5, 8, 7, 9, 10, 11, 13, 12 }, - - { 0, 1, 3, 2, 4, 8, 7, 6, 5, 9, 11, 10, 12, 13 }, /* Face 0-3-1 */ - { 1, 3, 0, 2, 8, 7, 4, 5, 9, 6, 11, 12, 13, 10 }, - { 3, 0, 1, 2, 7, 4, 8, 9, 6, 5, 11, 13, 10, 12 }, - - { 1, 2, 3, 0, 5, 9, 8, 4, 6, 7, 12, 10, 13, 11 }, /* Face 1-3-2 */ - { 2, 3, 1, 0, 9, 8, 5, 6, 7, 4, 12, 13, 11, 10 }, - { 3, 1, 2, 0, 8, 5, 9, 7, 4, 6, 12, 11, 10, 13 }, - - { 2, 0, 3, 1, 6, 7, 9, 5, 4, 8, 13, 10, 11, 12 }, /* Face 2-3-0 */ - { 0, 3, 2, 1, 7, 9, 6, 4, 8, 5, 13, 11, 12, 10 }, - { 3, 2, 0, 1, 9, 6, 7, 8, 5, 4, 13, 12, 10, 11 } - }; - - /* - * Below is a list of output tetrahedra. The array is - * generated by TessellatorGenerator.py - * which also generates the code that references it. - * Each set of tetrahedra begins with a single integer - * that is the number of tetrahedra for that particular - * case. It is followed by 5 integers for each output - * tetrahedron; the first four numbers on each row are - * indices of the output tetrahedron. The final number - * is a bit vector specifying which edges of the - * tetrahedron are internal to the parent tetrahedron - * being decomposed. - * - * Multiple lists of output tetrahedra may be - * combined to create the tessellation of a single - * input tetrahedron. - */ - - int SimplexTemplateRefiner::templates[] = - { - // case 1_0 - 2, - 0, 4, 2, 3, - 4, 1, 2, 3, - - // case 2a_0 - 1, - 3, 4, 5, 1, - - // case 2a, 0>1 - 2, - 0, 4, 2, 3, - 4, 5, 2, 3, - - // case 2a, 0=1 - 4, - 10, 3, 0, 4, - 10, 3, 4, 5, - 10, 3, 5, 2, - 10, 3, 2, 0, - - // case 2b_0 - 4, - 0, 4, 9, 3, - 4, 1, 9, 3, - 0, 4, 2, 9, - 4, 1, 2, 9, - - // case 3a_0 - 1, - 4, 7, 6, 0, - - // case 3a, 0>2>3<0 - 3, - 1, 3, 2, 4, - 4, 6, 3, 2, - 4, 6, 7, 3, - - // case 3a, 0=2>3<0 - 5, - 4, 6, 7, 3, - 10, 1, 2, 3, - 10, 2, 6, 3, - 10, 6, 4, 3, - 10, 4, 1, 3, - - // case 3a, 3>0=2<3 - 5, - 1, 3, 2, 7, - 10, 1, 2, 7, - 10, 2, 6, 7, - 10, 6, 4, 7, - 10, 4, 1, 7, - - // case 3a, 0=2=3=0 - 11, - 2, 6, 10, 13, - 3, 7, 13, 11, - 4, 1, 10, 11, - 11, 6, 10, 4, - 11, 6, 13, 10, - 11, 6, 7, 13, - 11, 6, 4, 7, - 2, 10, 11, 13, - 1, 10, 11, 2, - 2, 11, 3, 13, - 3, 2, 1, 11, - - // case 3b_0 - 4, - 0, 7, 4, 2, - 4, 7, 8, 2, - 4, 8, 1, 2, - 7, 3, 8, 2, - - // case 3c, 0>1,0>3 - 5, - 4, 2, 7, 5, - 4, 2, 0, 7, - 4, 3, 1, 5, - 4, 3, 5, 7, - 3, 5, 7, 2, - - // case 3c, 1>0,3>0 - 5, - 0, 5, 2, 7, - 0, 5, 7, 4, - 7, 1, 4, 5, - 7, 1, 5, 3, - 3, 5, 7, 2, - - // case 3c, 0>1,3>0 - 5, - 4, 2, 7, 5, - 4, 2, 0, 7, - 7, 1, 4, 5, - 7, 1, 5, 3, - 3, 5, 7, 2, - - // case 3c, 1>0,0>3 - 5, - 0, 5, 2, 7, - 0, 5, 7, 4, - 4, 3, 1, 5, - 4, 3, 5, 7, - 3, 5, 7, 2, - - // case 3c, 0=1,0>3 - 7, - 4, 1, 5, 3, - 10, 0, 4, 7, - 10, 2, 0, 7, - 10, 7, 4, 3, - 10, 2, 7, 3, - 10, 5, 2, 3, - 10, 4, 5, 3, - - // case 3c, 3>0,0=1 - 7, - 7, 1, 5, 3, - 7, 5, 2, 3, - 10, 0, 4, 7, - 10, 2, 0, 7, - 10, 5, 2, 7, - 10, 4, 5, 7, - 1, 5, 4, 7, - - // case 3c, 0=1,0=3 - 10, - 4, 1, 5, 11, - 11, 1, 5, 3, - 10, 0, 4, 7, - 10, 2, 0, 7, - 10, 5, 2, 3, - 10, 2, 7, 3, - 10, 7, 4, 11, - 10, 7, 11, 3, - 10, 4, 5, 11, - 10, 11, 5, 3, - - // case 3d, 0>4,0>2 - 5, - 4, 3, 6, 0, - 4, 3, 8, 6, - 4, 2, 8, 1, - 4, 2, 6, 8, - 2, 3, 6, 8, - - // case 3d, 4>0,2>0 - 5, - 8, 0, 6, 4, - 8, 0, 3, 6, - 6, 1, 8, 4, - 6, 1, 2, 8, - 2, 3, 6, 8, - - // case 3d, 0>4,2>0 - 5, - 4, 3, 6, 0, - 4, 3, 8, 6, - 6, 1, 8, 4, - 6, 1, 2, 8, - 2, 3, 6, 8, - - // case 3d, 4>0,0>2 - 5, - 8, 0, 6, 4, - 8, 0, 3, 6, - 4, 2, 8, 1, - 4, 2, 6, 8, - 2, 3, 6, 8, - - // case 3d, 0=4,0>2 - 7, - 4, 1, 2, 8, - 11, 4, 0, 6, - 11, 0, 3, 6, - 11, 2, 4, 6, - 11, 3, 2, 6, - 11, 3, 8, 2, - 11, 8, 4, 2, - - // case 3d, 2>0,0=4 - 7, - 6, 2, 8, 1, - 6, 8, 2, 3, - 11, 4, 0, 6, - 11, 0, 3, 6, - 8, 11, 3, 6, - 8, 4, 11, 6, - 1, 6, 4, 8, - - // case 3d, 0=4,0=2 - 10, - 4, 1, 10, 8, - 10, 2, 8, 1, - 11, 4, 0, 6, - 11, 0, 3, 6, - 11, 3, 8, 2, - 11, 3, 2, 6, - 11, 10, 4, 6, - 11, 10, 6, 2, - 8, 4, 11, 10, - 11, 10, 2, 8, - - // case 4a_0 - 2, - 7, 8, 9, 3, - 7, 9, 8, 6, - - // case 4a, 5>4>3 - 4, - 8, 0, 6, 1, - 8, 0, 7, 6, - 9, 1, 6, 2, - 9, 1, 8, 6, - - // case 4a, 3<4>5 - 4, - 8, 0, 6, 1, - 8, 0, 7, 6, - 8, 2, 6, 9, - 8, 2, 1, 6, - - // case 4a, 3>4<5 - 4, - 6, 9, 8, 1, - 6, 9, 1, 2, - 6, 7, 0, 1, - 6, 7, 1, 8, - - // case 4a, 3=4>5 - 6, - 6, 7, 0, 11, - 6, 0, 1, 11, - 6, 7, 11, 8, - 6, 11, 1, 8, - 1, 2, 6, 8, - 2, 6, 8, 9, - - // case 4a, 5>4,3=4 - 6, - 6, 7, 0, 11, - 6, 0, 1, 11, - 6, 7, 11, 8, - 6, 11, 1, 8, - 1, 2, 6, 9, - 1, 6, 8, 9, - - // case 4a, 3=4=5 - 8, - 6, 7, 0, 11, - 6, 0, 1, 11, - 6, 7, 11, 8, - 6, 11, 1, 8, - 6, 1, 2, 12, - 6, 2, 9, 12, - 6, 9, 8, 12, - 6, 8, 1, 12, - - // case 4b, 2>1,3>2,4>3,4>1 - 6, - 6, 8, 1, 5, - 6, 8, 0, 1, - 6, 8, 7, 0, - 6, 8, 2, 7, - 7, 8, 2, 3, - 6, 8, 5, 2, - - // case 4b, 2>1,3>2,3>4,4>1 - 6, - 6, 8, 1, 5, - 6, 8, 7, 1, - 6, 7, 0, 1, - 8, 7, 3, 2, - 6, 8, 5, 2, - 6, 8, 2, 7, - - // case 4b, 2>1,3>2,3>4,4>1, a - 6, - 7, 8, 1, 5, - 6, 5, 7, 1, - 6, 7, 0, 1, - 8, 7, 3, 2, - 7, 8, 5, 2, - 6, 5, 2, 7, - - // case 4b, 2>1,2>3,4>3,4>1 - 6, - 6, 8, 5, 2, - 6, 8, 2, 3, - 6, 8, 3, 7, - 6, 8, 7, 0, - 6, 8, 0, 1, - 6, 8, 1, 5, - - // case 4b, 1=2,3>2,3>4,4>1 - 9, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 7, - 10, 7, 1, 8, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 2, 7, 8, - 6, 5, 2, 8, - 7, 8, 2, 3, - - // case 4b, 1=2,2>3,4>3,1>4 - 9, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 8, - 10, 7, 0, 8, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 3, 7, 8, - 6, 5, 3, 8, - 6, 5, 2, 3, - - // case 4b, 1=2,2>3,4>3,4>1 - 9, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 8, - 10, 7, 0, 8, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 3, 7, 8, - 6, 5, 2, 8, - 6, 2, 3, 8, - - // case 4b, 1=2,3>2,3=4,4>1 - 11, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 11, - 10, 11, 1, 8, - 10, 0, 11, 7, - 10, 7, 11, 8, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 2, 7, 8, - 6, 5, 2, 8, - 7, 8, 2, 3, - - // case 4b, 4>1=2=3,4>3 - 12, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 8, - 10, 7, 0, 8, - 13, 6, 2, 5, - 13, 3, 7, 8, - 13, 2, 3, 8, - 13, 2, 8, 5, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 13, 7, 8, - 6, 5, 13, 8, - - // case 4b, 1=2=3>4,1>4 - 12, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 7, - 10, 7, 1, 8, - 13, 6, 2, 5, - 13, 3, 7, 8, - 13, 2, 3, 5, - 13, 3, 8, 5, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 13, 7, 8, - 6, 5, 13, 8, - - // case 4b, 1=2=3=4=1 - 16, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 11, - 10, 11, 1, 8, - 10, 0, 11, 7, - 10, 7, 11, 8, - 13, 6, 2, 5, - 13, 3, 7, 8, - 13, 2, 3, 12, - 13, 2, 12, 5, - 13, 12, 3, 8, - 13, 12, 5, 8, - 6, 7, 10, 8, - 6, 10, 5, 8, - 6, 5, 13, 8, - 6, 13, 7, 8, - - // case 5_0 - 2, - 7, 8, 9, 3, - 6, 5, 2, 9, - - // case 5, 1>2,3>4 - 5, - 5, 7, 1, 8, - 5, 7, 0, 1, - 5, 7, 6, 0, - 5, 7, 9, 6, - 5, 7, 8, 9, - - // case 5, 1>2,4>3 - 5, - 0, 5, 6, 7, - 0, 5, 7, 8, - 0, 5, 8, 1, - 5, 7, 9, 6, - 5, 7, 8, 9, - - // case 5, 1>2,4>3, a - 5, - 0, 5, 6, 8, - 0, 6, 7, 8, - 0, 5, 8, 1, - 5, 8, 9, 6, - 6, 7, 8, 9, - - // case 5, 1=2,3>4 - 8, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 7, - 10, 7, 1, 8, - 10, 8, 5, 9, - 10, 6, 7, 9, - 10, 7, 8, 9, - 10, 5, 6, 9, - - // case 5, 1=2,3>4, a - 8, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 7, - 10, 7, 1, 8, - 7, 8, 5, 9, - 10, 6, 7, 5, - 10, 7, 8, 5, - 5, 9, 6, 7, - - // case 5, 1=2,3>4, b - 8, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 7, - 10, 7, 1, 8, - 6, 8, 5, 9, - 10, 6, 7, 8, - 10, 6, 8, 5, - 8, 9, 6, 7, - - // case 5, 1=2,3=4 - 10, - 10, 6, 0, 7, - 10, 1, 5, 8, - 10, 0, 1, 11, - 10, 11, 1, 8, - 10, 0, 11, 7, - 10, 7, 11, 8, - 10, 8, 5, 9, - 10, 6, 7, 9, - 10, 7, 8, 9, - 10, 5, 6, 9, - - // case 6_0 - 4, - 7, 8, 9, 3, - 6, 5, 2, 9, - 4, 1, 5, 8, - 0, 4, 6, 7, - - // case 6_1 - 4, - 6, 4, 5, 8, - 6, 5, 9, 8, - 6, 9, 7, 8, - 6, 7, 4, 8, - - // case 6_1, a - 4, - 5, 8, 9, 7, - 5, 9, 6, 7, - 5, 6, 4, 7, - 5, 4, 8, 7, - - // case 6_1, b - 4, - 4, 5, 6, 9, - 4, 6, 7, 9, - 4, 7, 8, 9, - 4, 8, 5, 9, - - }; - -} // namespace moab - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.hpp deleted file mode 100644 index 2785c3bdf9d9..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Percept_MOAB_SimplexTemplateRefiner.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/** This class comes from MOAB, modified for STK Percept/Adapt - * - * MOAB 4.1.0RC1 - * Released June 1, 2011 - * - * http://trac.mcs.anl.gov/projects/ITAPS/wiki/MOAB - * - * Modifications center around exposing only the refine_3_simplex method as a static - * method, and changing the algorithm to avoid introducing face nodes to disambiguate - * cases with equal edge lengths. Also, memory management and output functors removed - * to just triangulate a given tet with given edge marks with one level of subdivision. - * - * Changes are mostly identify with comments starting with "p". - * - */ - -/* - * MOAB, a Mesh-Oriented datABase, is a software component for creating, - * storing and accessing finite element mesh data. - * - * Copyright 2007 Sandia Corporation. Under the terms of Contract - * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government - * retains certain rights in this software. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - */ - -/**\class moab::SimplexTemplateRefiner - * - * This is a concrete subclass of EntityRefiner that implements - * refinement using templates applied to simplices. - * Entities that are not simplices are divided into tetrahedra, - * triangles, or lines before being processed. - * Points are passed through unchanged. - * - * \author David Thompson - * \author Philippe Pebay - * - * \date 24 December 2007 - */ -#ifndef MB_SIMPLEX_TEMPLATE_REFINER_HPP -#define MB_SIMPLEX_TEMPLATE_REFINER_HPP - -#include -#include - -#include -#include - - -//p #include "EntityRefiner.hpp" -//p #include "SimplexTemplateTagAssigner.hpp" - -//p #include "moab/Types.hpp" // for MB_DLL_EXPORT - -namespace moab { - - typedef boost::tuple TetTupleInt; - //p - typedef int EntityHandle; - - - //p class RefinerTagManager; - - //p class MB_DLL_EXPORT SimplexTemplateRefiner : public EntityRefiner - - class SimplexTemplateRefiner - { - public: - SimplexTemplateRefiner() {} - virtual ~SimplexTemplateRefiner() {} - - /*p - virtual bool refine_entity( EntityType etyp, EntityHandle entity ); - virtual unsigned long get_heap_size_bound( int max_recursions ) const { return 48 * 4 * ( 1 << max_recursions ) + 8; } - - virtual bool set_tag_assigner( SimplexTemplateTagAssigner* ta ); - SimplexTemplateTagAssigner* get_tag_assigner() const { return this->tag_assigner; } - - virtual bool prepare( RefinerTagManager* tmgr, EntityRefinerOutputFunctor* ofunc ); - */ - - public: - /*p - SimplexTemplateTagAssigner* tag_assigner; - RefinerTagManager* tag_manager; - std::vector corner_coords; - std::vector corner_tags; - std::vector corner_handles; - bool input_is_output; - - */ - - static int template_index[64][2]; - static int permutations_from_index[24][14]; - static int templates[]; - - /*p - void refine_0_simplex( const double* v0, const void* t0, EntityHandle h0 ); - bool refine_1_simplex( int max_depth, - const double* v0, const void* t0, EntityHandle h0, - const double* v1, const void* t1, EntityHandle h1 ); - bool refine_2_simplex( int max_depth, int move, - const double* v0, const void* t0, EntityHandle h0, - const double* v1, const void* t1, EntityHandle h1, - const double* v2, const void* t2, EntityHandle h2 ); - */ - bool refine_3_simplex(std::vector& new_tets, - unsigned edge_marks[6], - int max_depth, - double* v0, void* t0, EntityHandle h0, - double* v1, void* t1, EntityHandle h1, - double* v2, void* t2, EntityHandle h2, - double* v3, void* t3, EntityHandle h3 ); - - double *heap_coord_storage() { - //return new double[3]; - return 0; - } - void *heap_tag_storage() { return 0; } - - int best_tets( int* alternates, double*[14], int, int ) { return alternates[0]; } - /*p - void assign_parametric_coordinates( int num_nodes, const double* src, double* tgt ); - static bool compare_Hopf_cross_string_dist( const double* v00, const double* v01, const double* v10, const double* v11 ); - */ - }; - -} // namespace moab - -#endif // MB_SIMPLEX_TEMPLATE_REFINER_HPP - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedEdgeAdapter.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedEdgeAdapter.hpp deleted file mode 100644 index 451ab0df782d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedEdgeAdapter.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef stk_adapt_PredicateBasedEdgeAdapter_hpp -#define stk_adapt_PredicateBasedEdgeAdapter_hpp - -#include - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * Predicate-based marker - * - * The functor @class RefinePredicate should supply an operator() that returns an entry from AdaptInstruction, - * either to do nothing, refine, unrefine, or both refine & unrefine (useful for unit testing, etc.) - */ - - template - class PredicateBasedEdgeAdapter : public IEdgeAdapter - { - RefinePredicate& m_predicate_refine; - - public: - - PredicateBasedEdgeAdapter(RefinePredicate& predicate_refine, - percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0) : - IEdgeAdapter(eMesh, bp, proc_rank_field), m_predicate_refine(predicate_refine) - { - } - - RefinePredicate& getRefinePredicate() { return m_predicate_refine; } - - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - virtual int mark(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) - { - int mark = m_predicate_refine(element, which_edge, node0, node1, coord0, coord1, existing_edge_marks); - return mark; - } - - - }; - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedElementAdapter.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedElementAdapter.hpp deleted file mode 100644 index 7fa469b199c6..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/PredicateBasedElementAdapter.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef stk_adapt_PredicateBasedElementAdapter_hpp -#define stk_adapt_PredicateBasedElementAdapter_hpp - -#include - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * Predicate-based marker - * - * The functor @class RefinePredicate should supply an operator() that returns an entry from AdaptInstruction, - * either to do nothing, refine, unrefine, or both refine & unrefine (useful for unit testing, etc.) - */ - typedef std::unary_function AdapterPredicateFunctor; - - template - class PredicateBasedElementAdapter : public IAdapter - { - RefinePredicate& m_predicate_refine; - - public: - - PredicateBasedElementAdapter(RefinePredicate& predicate_refine, - percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0) : - IAdapter(eMesh, bp, proc_rank_field), m_predicate_refine(predicate_refine) - { - } - - virtual ElementUnrefineCollection buildUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false)) - { - - if (m_predicate_refine(element) & DO_UNREFINE) - elements_to_unref.insert(&element); - } - } - } - } - - return elements_to_unref; - } - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - bool markInfo = (m_predicate_refine(element) & DO_REFINE); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, markInfo); - } - } - } - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.cpp deleted file mode 100644 index 4c94ede14dc5..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.cpp +++ /dev/null @@ -1,120 +0,0 @@ - -#include -#include -#include - -namespace stk_classic { - namespace adapt { - - /** Estimate number of elements for each topology based on old/new saved in m_numOrigElems, m_numNewElems. - * Saves estimates in m_numOrigElemsLast, m_numNewElemsLast corresponding to iRefinePass. - * iRefinePass is used to predict number of new elements in query_only mode of UniformRefiner. - * Pass in 0 for iRefinePass unless you are using UniformRefiner in query_only mode, in which case - * pass in the current refinement pass - */ - void RefinementInfoByType::estimateNew(std::vector< RefinementInfoByType >& refinementInfoByType, int iRefinePass) - { - for (unsigned irank = 0; irank < refinementInfoByType.size(); irank++) - { - RefinementInfoCount numOrig = refinementInfoByType[irank].m_numOrigElems; - RefinementInfoCount numNew = refinementInfoByType[irank].m_numNewElems; - refinementInfoByType[irank].m_numOrigElemsLast = numOrig; - refinementInfoByType[irank].m_numNewElemsLast = numNew; - if (numOrig) - { - double refFactor = ((double)numNew)/((double)numOrig); - double refFactorNew = std::pow(refFactor, ((double)(iRefinePass+1) )); - double refFactorOld = std::pow(refFactor, ((double)(iRefinePass) )); - numNew = (RefinementInfoCount)((double)numOrig * refFactorNew); - numOrig = (RefinementInfoCount)((double)numOrig * refFactorOld); - refinementInfoByType[irank].m_numOrigElemsLast = numOrig; - refinementInfoByType[irank].m_numNewElemsLast = numNew; - } - } - } - - /** iRefinePass is used to predict number of new elements in query_only mode of UniformRefiner. - * Pass in 0 for iRefinePass unless you are using UniformRefiner in query_only mode, in which case - * pass in the current refinement pass - */ - void RefinementInfoByType::printTable(std::ostream& os, std::vector< RefinementInfoByType >& refinementInfoByType, int iRefinePass, bool printAll) - { - if (refinementInfoByType.size() == 0) return; - - RefinementInfoCount numOrigTot = 0; - RefinementInfoCount numNewTot = 0; - estimateNew(refinementInfoByType, iRefinePass); - for (unsigned irank = 0; irank < refinementInfoByType.size(); irank++) - { - RefinementInfoCount numOrigLast = refinementInfoByType[irank].m_numOrigElemsLast; - RefinementInfoCount numNewLast = refinementInfoByType[irank].m_numNewElemsLast; - numOrigTot += numOrigLast; - numNewTot += numNewLast; - } - - RefinementInfoCount numOrigNodes = refinementInfoByType[0].m_numOrigNodes; - RefinementInfoCount numNewNodes = refinementInfoByType[0].m_numNewNodes; - - //os << "Refinement Info> total original elements = " << numOrigTot << "\n"; - //os << "Refinement Info> total new elements = " << numNewTot << "\n"; - - stk_classic::PrintTable table; - table.setTitle("Refinement Info\n"); - //table.setAutoEndCol(false); - - table << "|" << " " << "|" << justify(PrintTable::Cell::CENTER) - << "Original" << stk_classic::end_col << " " << "|" << "New " << stk_classic::end_col << " " << "|" << stk_classic::end_header; - // << stk_classic::span << "Original" << "|" << stk_classic::span << "New " << "|" << stk_classic::end_header; - table << justify(PrintTable::Cell::LEFT) ; - table << "|" << "Element Topology Type" << "|" << "Elements" << stk_classic::end_col << "Nodes" << "|" << "Elements" << stk_classic::end_col << "Nodes" << "|" << stk_classic::end_header; - - for (unsigned irank = 0; irank < refinementInfoByType.size(); irank++) - { - if (!printAll && refinementInfoByType[irank].m_numOrigElems == 0) - continue; - - RefinementInfoCount numOrig = refinementInfoByType[irank].m_numOrigElemsLast; - RefinementInfoCount numNew = refinementInfoByType[irank].m_numNewElemsLast; - - table << "|" << refinementInfoByType[irank].m_topology.getName() << "|" - << numOrig << stk_classic::end_col << " " << "|" - << numNew << stk_classic::end_col << " " << "|" - // << numOrig << stk_classic::end_col << numOrigNodes << "|" - // << numNew << stk_classic::end_col << numNewNodes << "|" - << stk_classic::end_row; - } - - table << "|" << "Totals" << "|" - << numOrigTot << stk_classic::end_col << numOrigNodes << "|" - << numNewTot << stk_classic::end_col << numNewNodes << "|" - << stk_classic::end_row; - -#if 0 - table << "|" << "Node Totals" << "|" - << numOrigNodes << "|" - << numNewNodes << "|" - << stk_classic::end_row; -#endif - - os << "\n" << table; - } - - void RefinementInfoByType::countCurrentNodes(stk_classic::percept::PerceptMesh& eMesh, std::vector< RefinementInfoByType >& refinementInfoByType) - { - mesh::Selector selector(eMesh.get_fem_meta_data()->locally_owned_part()); - std::vector count ; - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - unsigned nnodes = count[0]; - - stk_classic::ParallelMachine pm = eMesh.get_bulk_data()->parallel(); - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &nnodes ) ); - - for (unsigned i = 0; i < refinementInfoByType.size(); i++) - { - refinementInfoByType[i].m_numNewNodes = nnodes; - } - } - - } -} diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.hpp deleted file mode 100644 index 271f2bba24bc..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinementInfoByType.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef stk_adapt_RefinementInfoByType_hpp -#define stk_adapt_RefinementInfoByType_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - - - -namespace stk_classic { - namespace adapt { - - struct RefinementInfoByType - { - RefinementInfoByType() : - m_numOrigElems(0), - m_numNewElems(0), - m_numOrigNodes(0), - m_numNewNodes(0), - - m_numOrigElemsLast(0), - m_numNewElemsLast(0), - m_rank(0) - {} - - typedef uint64_t RefinementInfoCount ; - //typedef unsigned RefinementInfoCount ; - - RefinementInfoCount m_numOrigElems; - RefinementInfoCount m_numNewElems; - shards::CellTopology m_topology; - RefinementInfoCount m_numOrigNodes; - RefinementInfoCount m_numNewNodes; - - RefinementInfoCount m_numOrigElemsLast; - RefinementInfoCount m_numNewElemsLast; - unsigned m_rank; - - static void estimateNew(std::vector< RefinementInfoByType >& refinementInfoByType, int iRefinePass); - static void printTable(std::ostream& os, std::vector< RefinementInfoByType >& refinementInfoByType, int iRefinePass, bool printAll = false); - static void countCurrentNodes(stk_classic::percept::PerceptMesh& eMesh, std::vector< RefinementInfoByType >& refinementInfoByType); - - }; - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.cpp deleted file mode 100644 index 92ab8a9a410f..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.cpp +++ /dev/null @@ -1,3611 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include - -#include - -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -#if defined ( STK_PERCEPT_HAS_MESQUITE ) -#define StackTraceTmp StackTrace -#undef StackTrace -#include -#include -#include -#include -#include -#include -#include -#define StackTrace StackTraceTmp - -#endif - -namespace stk_classic { - - namespace adapt { - using namespace std; - using namespace percept; - - Refiner::Refiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - m_eMesh(eMesh), m_breakPattern(), - m_nodeRegistry(0), - m_proc_rank_field(proc_rank_field), m_doRemove(true), m_ranks(), m_ignoreSideSets(false), - m_geomFile(""), m_geomSnap(false), - m_doQueryOnly(false), - m_progress_meter_frequency(20), - m_doProgress(true && (0 == eMesh.get_rank()) ), - m_alwaysInitNodeRegistry(true), - m_doSmoothGeometry(true) - { - bp.setSubPatterns(m_breakPattern, eMesh); - m_nodeRegistry = new NodeRegistry (m_eMesh); - m_nodeRegistry->initialize(); - m_nodeRegistry->init_comm_all(); - m_allocated = false; - } - - //NLM new constructor for Python users - //takes in a Pattern refine_type to determine which UniformRefinerPatternBase will be used - - Refiner::Refiner(percept::PerceptMesh& eMesh, Pattern refine_type, stk_classic::mesh::FieldBase *proc_rank_field) : - m_eMesh(eMesh), m_breakPattern(), - m_nodeRegistry(0), - m_proc_rank_field(proc_rank_field), m_doRemove(true), m_ranks(), m_ignoreSideSets(false), - m_geomFile(""), m_geomSnap(false), - m_doQueryOnly(false), - m_progress_meter_frequency(20), - m_doProgress(true && (0 == eMesh.get_rank()) ), - m_alwaysInitNodeRegistry(true), - m_doSmoothGeometry(true) - { - m_nodeRegistry = new NodeRegistry (m_eMesh); - m_nodeRegistry->initialize(); - m_nodeRegistry->init_comm_all(); - m_allocated = true; - UniformRefinerPatternBase* bp; - switch(refine_type) - { - case LINE2_LINE2_2: - bp = (UniformRefinerPatternBase*) new Line2_Line2_2(eMesh); - break; - case BEAM2_BEAM2_2: - bp = (UniformRefinerPatternBase*) new Beam2_Beam2_2(eMesh); - break; - case SHELLLINE2_SHELLLINE2_2: - bp = (UniformRefinerPatternBase*) new ShellLine2_ShellLine2_2(eMesh); - break; - case SHELLLINE3_SHELLLINE3_2: - bp = (UniformRefinerPatternBase*) new ShellLine3_ShellLine3_2(eMesh); - break; - case QUAD4_QUAD4_4_OLD: - bp = (UniformRefinerPatternBase*) new Quad4_Quad4_4_Old(eMesh); - break; - case QUAD4_QUAD4_4: - bp = (UniformRefinerPatternBase*) new Quad4_Quad4_4(eMesh); - break; - case QUAD4_QUAD4_4_SIERRA: - bp = (UniformRefinerPatternBase*) new Quad4_Quad4_4_Sierra(eMesh); - break; - case TRI3_TRI3_4: - bp = (UniformRefinerPatternBase*) new Tri3_Tri3_4(eMesh); - break; - case SHELLTRI3_SHELLTRI3_4: - bp = (UniformRefinerPatternBase*) new ShellTri3_ShellTri3_4(eMesh); - break; - case SHELLTRI6_SHELLTRI6_4: - bp = (UniformRefinerPatternBase*) new ShellTri6_ShellTri6_4(eMesh); - break; - case SHELLQUAD4_SHELLQUAD4_4: - bp = (UniformRefinerPatternBase*) new ShellQuad4_ShellQuad4_4(eMesh); - break; - case SHELLQUAD8_SHELLQUAD8_4: - bp = (UniformRefinerPatternBase*) new ShellQuad8_ShellQuad8_4(eMesh); - break; - case TET4_TET4_8: - bp = (UniformRefinerPatternBase*) new Tet4_Tet4_8(eMesh); - break; - case HEX8_HEX8_8: - bp = (UniformRefinerPatternBase*) new Hex8_Hex8_8(eMesh); - break; - case WEDGE6_WEDGE6_8: - bp = (UniformRefinerPatternBase*) new Wedge6_Wedge6_8(eMesh); - break; - case PYRAMID5_PYRAMID5_10: - bp = (UniformRefinerPatternBase*) new Pyramid5_Pyramid5_10(eMesh); - break; - case LINE3_LINE3_2: - bp = (UniformRefinerPatternBase*) new Line3_Line3_2(eMesh); - break; - case BEAM3_BEAM3_2: - bp = (UniformRefinerPatternBase*) new Beam3_Beam3_2(eMesh); - break; - case TRI6_TRI6_4: - bp = (UniformRefinerPatternBase*) new Tri6_Tri6_4(eMesh); - break; - case QUAD9_QUAD9_4: - bp = (UniformRefinerPatternBase*) new Quad9_Quad9_4(eMesh); - break; - case QUAD8_QUAD8_4: - bp = (UniformRefinerPatternBase*) new Quad8_Quad8_4(eMesh); - break; - case HEX27_HEX27_8: - bp = (UniformRefinerPatternBase*) new Hex27_Hex27_8(eMesh); - break; - case HEX20_HEX20_8: - bp = (UniformRefinerPatternBase*) new Hex20_Hex20_8(eMesh); - break; - case TET10_TET10_8: - bp = (UniformRefinerPatternBase*) new Tet10_Tet10_8(eMesh); - break; - case WEDGE15_WEDGE15_8: - bp = (UniformRefinerPatternBase*) new Wedge15_Wedge15_8(eMesh); - break; - case WEDGE18_WEDGE18_8: - bp = (UniformRefinerPatternBase*) new Wedge18_Wedge18_8(eMesh); - break; - case PYRAMID13_PYRAMID13_10: - bp = (UniformRefinerPatternBase*) new Pyramid13_Pyramid13_10(eMesh); - break; - case QUAD4_QUAD9_1: - bp = (UniformRefinerPatternBase*) new Quad4_Quad9_1(eMesh); - break; - case QUAD4_QUAD8_1: - bp = (UniformRefinerPatternBase*) new Quad4_Quad8_1(eMesh); - break; - case BEAM2_BEAM3_1: - bp = (UniformRefinerPatternBase*) new Beam2_Beam3_1(eMesh); - break; - case SHELLQUAD4_SHELLQUAD8_1: - bp = (UniformRefinerPatternBase*) new ShellQuad4_ShellQuad8_1(eMesh); - break; - case TRI3_TRI6_1: - bp = (UniformRefinerPatternBase*) new Tri3_Tri6_1(eMesh); - break; - case TET4_TET10_1: - bp = (UniformRefinerPatternBase*) new Tet4_Tet10_1(eMesh); - break; - case HEX8_HEX27_1: - bp = (UniformRefinerPatternBase*) new Hex8_Hex27_1(eMesh); - break; - case HEX8_HEX20_1: - bp = (UniformRefinerPatternBase*) new Hex8_Hex20_1(eMesh); - break; - case WEDGE6_WEDGE15_1: - bp = (UniformRefinerPatternBase*) new Wedge6_Wedge15_1(eMesh); - break; - case WEDGE6_WEDGE18_1: - bp = (UniformRefinerPatternBase*) new Wedge6_Wedge18_1(eMesh); - break; - case PYRAMID5_PYRAMID13_1: - bp = (UniformRefinerPatternBase*) new Pyramid5_Pyramid13_1(eMesh); - break; - case QUAD4_TRI3_2: - bp = (UniformRefinerPatternBase*) new Quad4_Tri3_2(eMesh); - break; - case QUAD4_TRI3_4: - bp = (UniformRefinerPatternBase*) new Quad4_Tri3_4(eMesh); - break; - case QUAD4_TRI3_6: - bp = (UniformRefinerPatternBase*) new Quad4_Tri3_6(eMesh); - break; - case HEX8_TET4_24: - bp = (UniformRefinerPatternBase*) new Hex8_Tet4_24(eMesh); - break; - case HEX8_TET4_6_12: - bp = (UniformRefinerPatternBase*) new Hex8_Tet4_6_12(eMesh); - break; - default: - throw std::runtime_error("Refiner::Refiner Unrecognized refinement pattern"); - break; - } - - bp->setSubPatterns(m_breakPattern, eMesh); - - m_proc_rank_field = proc_rank_field; - } - - Refiner::~Refiner() - { - if (m_nodeRegistry) - delete m_nodeRegistry; - if (m_allocated) - { - //for (unsigned int i = 0; i < m_breakPattern.size(); i++) - // SRK only delete the first one - others are handled by the parent 0'th break pattern - for (unsigned int i = 0; i < 1; i++) - { - delete m_breakPattern[i]; - } - } - } - -#define EXTRA_PRINT_UR_GETBLOCKS 0 - - void Refiner:: - setGeometryFile(std::string file_name) { m_geomFile = file_name; - m_geomSnap = true; } - - - void Refiner:: - setRemoveOldElements(bool do_remove) { m_doRemove = do_remove; } - - bool Refiner:: - getRemoveOldElements() { return m_doRemove; } - - void Refiner:: - setDoProgressMeter(bool do_progress) { m_doProgress = do_progress; } - - bool Refiner:: - getDoProgressMeter() { return m_doProgress; } - - void Refiner:: - setIgnoreSideSets(bool ignore_ss) - { - m_ignoreSideSets= ignore_ss; - } - - bool Refiner:: - getIgnoreSideSets() - { - return m_ignoreSideSets; - } - - void Refiner:: - removeFromOldPart(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern) - { - EXCEPTWATCH; - - std::string oldPartName = breakPattern->getOldElementsPartName()+toString(rank); - mesh::Part *oldPart = m_eMesh.get_fem_meta_data()->get_part(oldPartName); - //std::cout << "tmp removeFromOldPart:: oldPartName= " << oldPartName << std::endl; - if (!oldPart) - { - std::cout << "oldPartName= " << oldPartName << std::endl; - throw std::runtime_error("oldpart is null"); - } - - mesh::PartVector remove_parts(1, oldPart); - mesh::PartVector add_parts; - mesh::Selector on_locally_owned_part = ( m_eMesh.get_fem_meta_data()->locally_owned_part() ); - - std::vector elems; - const vector & buckets = m_eMesh.get_bulk_data()->buckets( rank ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) // && fromPartsSelector(**k) ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - elems.push_back(&element); - } - } - } - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - //std::cout << "tmp removeFromOldPart:: element = " << *elems[ielem] << std::endl; - m_eMesh.get_bulk_data()->change_entity_parts( *elems[ielem], add_parts, remove_parts ); - } - } - - void Refiner:: - addOldElementsToPart(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern, unsigned *elementType) - { - EXCEPTWATCH; - //m_eMesh.get_bulk_data()->modification_begin(); - std::string oldPartName = breakPattern->getOldElementsPartName()+toString(rank); - mesh::Part *oldPart = m_eMesh.get_fem_meta_data()->get_part(oldPartName); - -#define DEBUG_REMOVE_OLD_PARTS 0 - - if (DEBUG_REMOVE_OLD_PARTS) std::cout << "tmp addOldElementsToPart:: oldPartName= " << oldPartName << std::endl; - - if (!oldPart) - { - std::cout << "oldPartName= " << oldPartName << std::endl; - throw std::runtime_error("oldpart is null"); - } - - mesh::PartVector add_parts(1, oldPart); - mesh::PartVector remove_parts; - mesh::Selector on_locally_owned_part = ( m_eMesh.get_fem_meta_data()->locally_owned_part() ); - - // The list of Parts that this break pattern will refine. Only remove elements belonging to these parts. - mesh::Selector fromPartsSelector = mesh::selectUnion( breakPattern->getFromParts() ); - - std::vector elems; - const vector & buckets = m_eMesh.get_bulk_data()->buckets( rank ); - - unsigned nele=0; - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k) && fromPartsSelector(**k) ) - { - stk_classic::mesh::Bucket & bucket = **k ; - const CellTopologyData * const bucket_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - shards::CellTopology topo(bucket_cell_topo_data); - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - EXCEPTWATCH; - stk_classic::mesh::Entity& element = bucket[i_element]; - if (&element == 0) - { - std::cout << "element = 0" << std::endl; - throw std::runtime_error("element = 0"); - //exit(1); - } - - if (elementType && (topo.getKey() != *elementType)) - { - } - else - { - elems.push_back(&element); - ++nele; - if (DEBUG_REMOVE_OLD_PARTS) std::cout << "tmp adding to oldParts = " << element << std::endl; - } - } - } - } - - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - if (DEBUG_REMOVE_OLD_PARTS) std::cout << "tmp addOldElementsToPart element = " << *elems[ielem] << std::endl; - m_eMesh.get_bulk_data()->change_entity_parts( *elems[ielem], add_parts, remove_parts ); - } - - //m_eMesh.get_bulk_data()->modification_end(); - } - - void Refiner:: - trace_print(std::string msg) - { - size_t heap_in_Mb = 0; - size_t memory_in_Mb = 0; - double cpu = 0.0; - - if (TRACE_STAGE_PRINT) - { - memory_in_Mb = Util::memory(heap_in_Mb); - memory_in_Mb = memory_in_Mb / (1024*1024); - heap_in_Mb = heap_in_Mb / (1024*1024); - } - - cpu = Util::cpu_time(); - std::cout - << msg - << " cpu_time= " << cpu/(60.) << " [min] " - << " mem= " << memory_in_Mb << " [Mb] " - //<< " heap= " << heap_in_Mb << " [Mb] " - << std::endl; - - } - - - struct myVec - { - double *data; - int len; - int res; - }; - - static void doPrintSizes() - { - if (0) - { - std::cout - << "sizeof(myVec) = " << sizeof(myVec) << " " - << "sizeof(Relation) = " << sizeof(stk_classic::mesh::Relation) << " " - << "sizeof(Entity) = " << sizeof(stk_classic::mesh::Entity) << " " - << "sizeof(EntityImpl) = " << sizeof(stk_classic::mesh::impl::EntityImpl) << " " - << "\nsizeof(EntityKey) = " << sizeof(stk_classic::mesh::EntityKey) << " " - << "\nsizeof(RelationVector) = " << sizeof(stk_classic::mesh::RelationVector) << " " - << "\nsizeof(EntityCommInfoVector) = " << sizeof(stk_classic::mesh::EntityCommInfoVector) << " " - << "\nsizeof(Bucket *) = " << sizeof(stk_classic::mesh::Bucket *) << " " - << "\nsizeof(unsigned) = " << sizeof(unsigned) << " " - << "\nsizeof(size_t) = " << sizeof(size_t) << " " - << "\nsizeof(EntityModificationLog) = " << sizeof(stk_classic::mesh::EntityModificationLog) << std::endl; - - } - } - - void Refiner:: - checkBreakPatternValidityAndBuildRanks(std::vector& ranks) - { - ranks.resize(0); - - m_eMesh.get_bulk_data()->modification_begin(); - for (unsigned ibp = 0; ibp < m_breakPattern.size(); ibp++) - { - if (m_breakPattern[ibp]) - { - stk_classic::mesh::EntityRank irank = m_breakPattern[ibp]->getPrimaryEntityRank(); - stk_classic::mesh::EntityRank irank_prev = stk_classic::percept::EntityRankEnd; - if (ibp > 0) irank_prev = m_breakPattern[ibp-1]->getPrimaryEntityRank(); - if (irank > irank_prev) - { - throw std::logic_error("m_breakPattern: must be in decreasing order of rank"); - } - ranks.push_back(irank); - if (m_doRemove) - { - unsigned elementType = m_breakPattern[ibp]->getFromTypeKey(); - addOldElementsToPart(irank, m_breakPattern[ibp], &elementType); - } - } - else - { - std::cout << "ibp = " << ibp << std::endl; - throw std::logic_error("m_breakPattern is null"); - } - } - m_eMesh.get_bulk_data()->modification_end(); - - } - - void Refiner:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - shards::CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } // iSubDimOrd - } // ineed_ent - } - - void Refiner:: - doBreak() - { - EXCEPTWATCH; - - /**/ TRACE_PRINT( "Refiner:doBreak start..."); - - m_nodeRegistry->dumpDB("start of doBreak"); - - if (0) doPrintSizes(); - - CommDataType buffer_entry; - - stk_classic::mesh::BulkData& bulkData = *m_eMesh.get_bulk_data(); - static SubDimCellData empty_SubDimCellData; - - // color elements -#if 0 - struct EntityExcluder - { - virtual bool exclude(stk_classic::mesh::Entity& element) = 0; - }; -#endif - - std::vector& ranks = m_ranks; - // check logic of break pattern setup and also build ranks used vector - checkBreakPatternValidityAndBuildRanks(ranks); - - /////////////////////////////////////////////////////////// - ///// Get info on refinements that will be done - /////////////////////////////////////////////////////////// - if (1) - { - - unsigned num_orig_nodes=0; - { - std::vector count1 ; - - stk_classic::mesh::count_entities(stk_classic::mesh::Selector(m_eMesh.get_fem_meta_data()->universal_part()) , *m_eMesh.get_bulk_data(), count1 ); - if (count1.size() < 3) - { - throw std::logic_error("logic error in Refiner m_refinementInfoByType"); - } - num_orig_nodes = count1[0]; - } - - m_refinementInfoByType.resize(ranks.size()); - - stk_classic::mesh::PartVector fromPartsAll; - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - stk_classic::mesh::PartVector * fromParts = &(m_breakPattern[irank]->getFromParts()); - if (fromParts) - { - for (unsigned ipart = 0; ipart < fromParts->size(); ipart++) - { - fromPartsAll.push_back((*fromParts)[ipart]); - } - } - } - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - EXCEPTWATCH; - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - shards::CellTopology cell_topo(m_breakPattern[irank]->getFromTopology()); - - mesh::Selector selector(m_eMesh.get_fem_meta_data()->locally_owned_part()); - if (fromPartsAll.size()) - { - selector = mesh::Selector(); - for (unsigned ipart = 0; ipart < fromPartsAll.size(); ipart++) - { - mesh::Part *part = fromPartsAll[ipart]; - const CellTopologyData * part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*part); - if (part_cell_topo_data) - { - shards::CellTopology part_cell_topo(part_cell_topo_data); - if (part_cell_topo.getKey() == elementType) - { - selector = selector | *part; - } - } - } - selector = selector & (mesh::Selector(m_eMesh.get_fem_meta_data()->locally_owned_part())); - } - std::vector count ; - stk_classic::mesh::count_entities( selector, *m_eMesh.get_bulk_data(), count ); - if (count.size() < 3) - { - throw std::logic_error("logic error in Refiner m_refinementInfoByType"); - } - unsigned n_ele = count[ ranks[irank] ]; - - m_refinementInfoByType[irank].m_rank = ranks[irank]; - m_refinementInfoByType[irank].m_numOrigElems = n_ele; - - m_refinementInfoByType[irank].m_numNewElems = n_ele * m_breakPattern[irank]->getNumNewElemPerElem(); - m_refinementInfoByType[irank].m_topology = cell_topo; - m_refinementInfoByType[irank].m_numOrigNodes = num_orig_nodes; - m_refinementInfoByType[irank].m_numNewNodes = 0; // can't predict this - } - - // sum info from all procs - { - stk_classic::ParallelMachine pm = m_eMesh.get_bulk_data()->parallel(); - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &m_refinementInfoByType[irank].m_numOrigElems ) ); - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &m_refinementInfoByType[irank].m_numNewElems ) ); - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &m_refinementInfoByType[irank].m_numOrigNodes ) ); - } - } - - } - - if (m_doQueryOnly) - { - return; - } - - // do elements first, then any faces or edge elements - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // do the top level, all elements of this rank operation - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned num_elem_not_ghost_0 = 0; - - /////////////////////////////////////////////////////////// - ///// Do the mesh coloring step for each type of element - /////////////////////////////////////////////////////////// - - vector< vector< ColorerSetType > > elementColorsByType = vector < vector< ColorerSetType > > (ranks.size()); - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - EXCEPTWATCH; - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - shards::CellTopology cell_topo(m_breakPattern[irank]->getFromTopology()); - - if (TRACE_STAGE_PRINT) std::cout << "tmp Refiner:: irank = " << irank << " ranks[irank] = " << ranks[irank] - << " elementType= " << elementType - << " cell_topo= " << cell_topo.getName() - << std::endl; - - std::vector ranks_one(1, ranks[irank]); - - // this gives a list of colored elements for this element type only - stk_classic::mesh::PartVector * fromParts = 0; - fromParts = &(m_breakPattern[irank]->getFromParts()); - - //!FIXME add part info - Colorer meshColorerThisTypeOnly(elementColorsByType[irank], ranks_one); TRACE_PRINT("Refiner: Color mesh (all top level rank elements)... "); - meshColorerThisTypeOnly.color(m_eMesh, &elementType, fromParts); TRACE_PRINT("Refiner: Color mesh (all top level rank elements)...done "); - - if (0 && elementColorsByType[irank].size() == 0) - { - std::cout << "WARNING: no elements found of this type: " << cell_topo.getName() << " key= " << elementType << std::endl; - } - } - - // FIXME warn if a topology shows up without a break pattern - - /////////////////////////////////////////////////////////// - ///// // start top-level ranks - /////////////////////////////////////////////////////////// - - { // start top-level ranks - - - /////////////////////////////////////////////////////////// - ///// // node registration step - /////////////////////////////////////////////////////////// - - { // node registration step - EXCEPTWATCH; - - /**/ TRACE_PRINT("Refiner: beginRegistration (top-level rank)... "); - m_nodeRegistry->dumpDB("before init"); - if (m_alwaysInitNodeRegistry) - { - m_nodeRegistry->initialize(); - } - else - { - //m_nodeRegistry->clear_element_owner_data(); - m_nodeRegistry->init_entity_repo(); - } - - m_nodeRegistry->init_comm_all(); - - m_eMesh.adapt_parent_to_child_relations().clear(); - - // register non-ghosted elements needs for new nodes, parallel create new nodes - m_nodeRegistry->beginRegistration(); - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - { - EXCEPTWATCH; - - vector< ColorerSetType >& elementColors = elementColorsByType[irank]; - - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - - bool count_only = false; - bool doAllElements = true; - - unsigned num_elem_not_ghost_0_incr = doForAllElements(irank, "Register New Nodes", - ranks[irank], &NodeRegistry::registerNeedNewNode, elementColors, elementType, needed_entity_ranks, - count_only, doAllElements); - - num_elem_not_ghost_0 += num_elem_not_ghost_0_incr; - - if (0) std::cout << "tmp irank= " << irank << " ranks[irank]= " << ranks[irank] << " nodeRegistry size= " << m_nodeRegistry->getMap().size() << std::endl; - - } - } - - m_nodeRegistry->endRegistration(); /**/ TRACE_PRINT("Refiner: endRegistration (top-level rank)... "); - } - m_nodeRegistry->dumpDB("after registration"); - -#define CHECK_DEBUG 0 - if (CHECK_DEBUG) - { - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - m_nodeRegistry->checkDB("after registerNeedNewNode"); - check_db("after registerNeedNewNode"); - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - } - - /////////////////////////////////////////////////////////// - ///// Check for remote - /////////////////////////////////////////////////////////// - - { // beginCheckForRemote() - EXCEPTWATCH; - - /**/ TRACE_PRINT("Refiner: beginCheckForRemote (top-level rank)... "); - - // now register ghosted elements needs for new nodes (this does a pack operation) - m_nodeRegistry->beginCheckForRemote(); - unsigned num_elem = 0; - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - //if (ranks[irank] >= m_eMesh.face_rank()) - { - EXCEPTWATCH; - vector< ColorerSetType >& elementColors = elementColorsByType[irank]; - - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - - bool count_only = false; - bool doAllElements = false; // only do ghost elements - num_elem = doForAllElements(irank, "Check For Comm", ranks[irank], &NodeRegistry::checkForRemote, elementColors, elementType, needed_entity_ranks, count_only, doAllElements); - } - } - m_nodeRegistry->endCheckForRemote(); /**/ TRACE_PRINT("Refiner: endCheckForRemote (top-level rank)... "); - - if (1 && CHECK_DEBUG) - { - std::cout << "num_elem= " << num_elem << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - m_nodeRegistry->checkDB("after checkForRemote"); - check_db("after checkForRemote"); - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - } - - } - - /////////////////////////////////////////////////////////// - ///// Get from remote - /////////////////////////////////////////////////////////// - /// communicate all-to-all the new node creation information which also updates the node registry so it can - /// be queried locally now for any ghost or non-ghost element - - { // get from remote - - EXCEPTWATCH; - - /**/ TRACE_PRINT("Refiner: beginGetFromRemote (top-level rank)... "); - m_nodeRegistry->beginGetFromRemote(); - unsigned num_elem = 0; - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - { - EXCEPTWATCH; - - vector< ColorerSetType >& elementColors = elementColorsByType[irank]; - - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - - bool count_only = false; - bool doAllElements = false; // ghost elements only - num_elem = doForAllElements(irank, "Get From Remote", ranks[irank], &NodeRegistry::getFromRemote, elementColors, elementType, needed_entity_ranks, count_only, doAllElements); - } - } - - m_nodeRegistry->endGetFromRemote(); /**/ TRACE_PRINT("Refiner: endGetFromRemote (top-level rank)... "); - m_nodeRegistry->dumpDB("after endGetFromRemote"); - - //stk_classic::diag::printTimersTable(std::cout, perceptTimer(), stk_classic::diag::METRICS_ALL, false); - - if (CHECK_DEBUG) - { - std::cout << "num_elem= " << num_elem << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - m_nodeRegistry->checkDB("end getFromRemote"); - check_db("end getFromRemote"); - MPI_Barrier( MPI_COMM_WORLD ); - - std::cout << "P["<< m_eMesh.get_rank() - <<"] ========================================================================================================================" << std::endl; - } - } // get from remote - } // start top-level ranks - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // for each element type, in top-down rank order, do the rest of the refinement operations - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bulkData.modification_begin(); - - if (CHECK_DEBUG) - { - m_nodeRegistry->checkDB("after mod begin() after end getFromRemote"); - } - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - EXCEPTWATCH; - - unsigned elementType = m_breakPattern[irank]->getFromTypeKey(); - if (TRACE_STAGE_PRINT) - std::cout << "tmp Refiner:: irank = " << irank - << " ranks[irank] = " << ranks[irank] << " elementType= " << elementType << std::endl; - - std::vector ranks_one(1, ranks[irank]); - - vector< ColorerSetType >& elementColors = elementColorsByType[irank]; - - // loop over elements, build faces, edges in threaded mode (guaranteed no mem conflicts) - // (note: invoke UniformRefinerPattern: what entities are needed) - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - vector new_elements; - - //bulkData.modification_begin(); - - { - EXCEPTWATCH; - - // count num new elements needed on this proc (served by UniformRefinerPattern) - bool count_only = true; - bool doAllElements = true; - /**/ TRACE_PRINT("Refiner: registerNeedNewNode count_only(true) ranks[irank]==ranks[0]... "); - unsigned num_elem_not_ghost = doForAllElements(irank, "Register New Nodes", ranks[irank], &NodeRegistry::registerNeedNewNode, elementColors, elementType, needed_entity_ranks, count_only, doAllElements); - /**/ TRACE_PRINT("Refiner: registerNeedNewNode count_only(true) ranks[irank]==ranks[0]... done "); - - unsigned num_elem_needed = num_elem_not_ghost * m_breakPattern[irank]->getNumNewElemPerElem(); - - // FIXME TMP - if (CHECK_DEBUG) - { - unsigned nele_col=0; - for (unsigned icolor = 0; icolor < elementColors.size(); icolor++) - { - nele_col += elementColors[icolor].size(); - } - std::cout << "tmp Refiner::doBreak: irank= " << irank << " ranks[irank]= " << ranks[irank] << " bp= [" - << m_breakPattern[irank]->getFromTopoPartName() << " ==> " - << m_breakPattern[irank]->getToTopoPartName() << "] num_elem_needed= " << num_elem_needed - << " num_elem_not_ghost= " << num_elem_not_ghost - << " nelementColors= " << nele_col << " elementColors.size()= " << elementColors.size() - << std::endl; - } - - if (0 && num_elem_not_ghost != num_elem_not_ghost_0) - { - std::cout << "num_elem_not_ghost_0 = " << num_elem_not_ghost_0 << " num_elem_not_ghost= " << num_elem_not_ghost << std::endl; - throw std::runtime_error("num_elem_not_ghost_0 != num_elem_not_ghost"); - } - - // create new entities on this proc - m_nodeRegistry->beginLocalMeshMods(); - new_elements.resize(0); /**/ TRACE_PRINT("Refiner: createEntities... ranks[irank]==ranks[0] "); - m_eMesh.createEntities( ranks[irank], num_elem_needed, new_elements); /**/ TRACE_PRINT("Refiner: createEntities... ranks[irank]==ranks[0] done "); - m_nodeRegistry->endLocalMeshMods(); - - } - m_nodeRegistry->dumpDB("after endLocalMeshMods"); - if (CHECK_DEBUG) - { - m_nodeRegistry->checkDB("after endLocalMeshMods"); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Global element ops: here's where we e.g. connect the new elements by declaring new relations - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /**/ TRACE_PRINT("Refiner: createElementsAndNodesAndConnectLocal... "); - /**/ TRACE_CPU_TIME_AND_MEM_0(CONNECT_LOCAL); - - createElementsAndNodesAndConnectLocal(irank, ranks[irank], m_breakPattern[irank], elementColors, needed_entity_ranks, new_elements); - - /**/ TRACE_CPU_TIME_AND_MEM_1(CONNECT_LOCAL); - /**/ TRACE_PRINT("Refiner: createElementsAndNodesAndConnectLocal...done "); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Global node loop operations: this is where we perform ops like adding new nodes to the right parts, interpolating fields, etc. - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if (TRACE_STAGE_PRINT && !m_eMesh.get_rank()) { - Util::trace_cpu_time_and_mem_print(CONNECT_LOCAL, "CONNECT_LOCAL"); - Util::trace_cpu_time_and_mem_print(CONNECT_LOCAL_createNewNeededNodes, "CONNECT_LOCAL_createNewNeededNodes"); - Util::trace_cpu_time_and_mem_print(CONNECT_LOCAL_createNewElements, "CONNECT_LOCAL_createNewElements"); - Util::trace_cpu_time_and_mem_print(CONNECT_LOCAL_URP_createOrGetNode, "CONNECT_LOCAL_URP_createOrGetNode"); - Util::trace_cpu_time_and_mem_print(CONNECT_LOCAL_URP_declare_relation, "CONNECT_LOCAL_URP_declare_relation"); - } - - } // irank - - /**/ TRACE_PRINT("Refiner: addToExistingParts [etc.]... "); -#if !STK_ADAPT_URP_LOCAL_NODE_COMPS - if (1) - { - EXCEPTWATCH; - // only need to do this once: the map is fully built and we loop over the map's faces/edges, which are fixed after the getFromRemote step - - m_nodeRegistry->addToExistingPartsNew(); - //std::cout << "tmp makeCentroid... " << std::endl; - m_nodeRegistry->makeCentroid(m_eMesh.get_coordinates_field()); - //std::cout << "tmp makeCentroid...done " << std::endl; - //std::cout << "tmp interpolateFields... " << std::endl; - m_nodeRegistry->interpolateFields(); - //std::cout << "tmp interpolateFields...done " << std::endl; - } - //std::cout << "tmp dump_elements 1" << std::endl; - // m_eMesh.dump_elements(); -#endif - /**/ TRACE_PRINT("Refiner: addToExistingParts [etc.] ...done "); - - /***********************/ TRACE_PRINT("Refiner: fixElementSides1 "); - fixElementSides1(); - m_eMesh.adapt_parent_to_child_relations().clear(); - /***********************/ TRACE_PRINT("Refiner: fixElementSides1...done "); - - //std::cout << "tmp dump_elements 2" << std::endl; - //m_eMesh.dump_elements(); - -#if CHECK_DEBUG - std::cout << "m_doRemove= " << m_doRemove << std::endl; - check_db("b4 remove"); -#endif - - if (m_doRemove) - { - EXCEPTWATCH; - - //bulkData.modification_begin(); - - /***********************/ TRACE_PRINT("Refiner: fixElementSides1 "); - // fixElementSides1(); - // m_eMesh.adapt_parent_to_child_relations().clear(); - /***********************/ TRACE_PRINT("Refiner: fixElementSides1...done "); - - for (unsigned irank = 0; irank < ranks.size(); irank++) - { - -#if PERCEPT_USE_FAMILY_TREE - if (irank == 0) - removeFamilyTrees(); -#endif - removeOldElements(irank, ranks[irank], m_breakPattern[irank]); - renameNewParts(ranks[irank], m_breakPattern[irank]); - fixSurfaceAndEdgeSetNames(ranks[irank], m_breakPattern[irank]); - } - } - - // remove any elements that are empty (these can exist when doing local refinement) - removeEmptyElements(); - - // remove nodes not referred to by elements - removeDanglingNodes(); - - // remove pseudo elements - //m_nodeRegistry->removePseudoEntities(); - - set_active_part(); - - /**/ TRACE_PRINT("Refiner: modification_end...start... "); - bulkData.modification_end(); - // force a flush of all pending deletes, etc - bulkData.modification_begin(); - bulkData.modification_end(); - /**/ TRACE_PRINT("Refiner: modification_end...done "); - - // remove pseudo elements - if (0) - { - bulkData.modification_begin(); - // FIXME - remove only those that are not shared? - //removeNodesWithOnlyPseudoNodeRelations(); - m_nodeRegistry->removePseudoEntities(); - bulkData.modification_end(); - } - - //std::cout << "tmp dump_elements 3" << std::endl; - //m_eMesh.dump_elements(); - - snapAndSmooth(m_geomSnap, m_geomFile); - - /**/ TRACE_PRINT( "Refiner:doBreak ... done"); - - //std::cout << "tmp m_nodeRegistry.m_gee_cnt= " << m_nodeRegistry->m_gee_cnt << std::endl; - //std::cout << "tmp m_nodeRegistry.m_gen_cnt= " << m_nodeRegistry->m_gen_cnt << std::endl; - RefinementInfoByType::countCurrentNodes(m_eMesh, getRefinementInfoByType()); - - getNodeRegistry().init_entity_repo(); - //getNodeRegistry().clear_dangling_elements(); - - m_nodeRegistry->dumpDB("after doBreak"); -#if CHECK_DEBUG - //check_db("after doBreak"); - m_nodeRegistry->checkDB("after doBreak"); -#endif - - } // doBreak - - // FIXME - temp until we figure out what to do with parent/child, persistence, etc. - // FIXME - just deletes elements, not family trees for now - - /// Delete all elements that aren't child elements - void Refiner::deleteParentElements() - { - //check_sidesets_2(" deleteParentElements:: start"); - //check_sidesets(" deleteParentElements:: start"); - //check_sidesets_1(" deleteParentElements:: start"); - - std::vector ranks_to_be_deleted; - ranks_to_be_deleted.push_back(m_eMesh.element_rank()); - ranks_to_be_deleted.push_back(m_eMesh.side_rank()); - - //std::cout << "tmp srk ranks_to_be_deleted= " << ranks_to_be_deleted << std::endl; - - elements_to_be_destroyed_type parents; - for (unsigned irank=0; irank < ranks_to_be_deleted.size(); irank++) - { - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( ranks_to_be_deleted[irank] ); - int npar=0; - int nchild=0; - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - // only do "old" elements - //if (!oldPartSelector(bucket)) - // continue; - - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - if (!m_eMesh.isParentElement(element, false)) - //if (!m_eMesh.hasFamilyTree(element) || m_eMesh.isChildElement(element, true)) - //if (!m_eMesh.hasFamilyTree(element) || m_eMesh.isChildElementLeaf(element, true)) - { - // it has no family tree, so it's a leaf, or it has no children - ++nchild; - } - else - { - ++npar; -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - parents.push_back(&element); -#else - parents.insert(&element); -#endif - } - } - } - //std::cout << "tmp removeElements(parents) irank, size= " << ranks_to_be_deleted[irank] << " " << npar << " nchild= " << nchild << std::endl; - - } - - m_eMesh.get_bulk_data()->modification_begin(); - //SidePartMap side_part_map; - //get_side_part_relations(false, side_part_map); -#if PERCEPT_USE_FAMILY_TREE - removeFamilyTrees(); -#endif - //std::cout << "tmp removeElements(parents) size= " << parents.size() << std::endl; - removeElements(parents); - //fix_side_sets_3(false, side_part_map); - fix_side_sets_2(); - - m_eMesh.get_bulk_data()->modification_end(); - - //check_sidesets_2(" deleteParentElements:: end"); - //check_sidesets(" deleteParentElements:: end"); - //check_sidesets_1(" deleteParentElements:: end"); - - } - - void Refiner::removeEmptyElements() - { - - elements_to_be_destroyed_type list; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - if (0 == element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK).size()) - { -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - list.push_back(&element); -#else - list.insert(&element); -#endif - } - } - } - - //m_eMesh.get_bulk_data()->modification_begin(); - //std::cout << "tmp removeElements(parents) " << std::endl; - removeElements(list); - //m_eMesh.get_bulk_data()->modification_end(); - - } - - void Refiner::removeDanglingNodes() - { - SetOfEntities node_list; - SetOfEntities pseudos; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.node_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_nodes_in_bucket; iElement++) - { - stk_classic::mesh::Entity& node = bucket[iElement]; - if (0 == node.relations().size()) - { - node_list.insert(&node); - } - else if (1 == node.relations().size() && node.relations()[0].entity()->entity_rank() == m_eMesh.element_rank() + PSEUDO_ELEMENT_RANK_SHIFT) - { - pseudos.insert( node.relations()[0].entity() ); - node_list.insert(&node); - } - } - } - - //if (1 && node_list.size()) std::cout << "P[" << m_eMesh.get_rank() << "] tmp number of dangling nodes = " << node_list.size() << " and pseudos= " << pseudos.size() << std::endl; - //!srk - getNodeRegistry().clear_dangling_nodes(&node_list); - - if (1) - { - for (SetOfEntities::iterator itbd = pseudos.begin(); itbd != pseudos.end(); ++itbd) - { - stk_classic::mesh::Entity *pseudo_p = *itbd; - - if ( ! m_eMesh.get_bulk_data()->destroy_entity( pseudo_p ) ) - { - throw std::logic_error("Refiner::removeDanglingNodes couldn't remove pseudo"); - - } - } - } - - for (SetOfEntities::iterator itbd = node_list.begin(); itbd != node_list.end(); ++itbd) - { - stk_classic::mesh::Entity *node_p = *itbd; - - if ( ! m_eMesh.get_bulk_data()->destroy_entity( node_p ) ) - { - throw std::logic_error("Refiner::removeDanglingNodes couldn't remove node"); - - } - } - - // check for any null entities - //std::cout << "check for any null entities..." << std::endl; - const vector & elem_buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = elem_buckets.begin() ; k != elem_buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_nodes_in_bucket; iElement++) - { - stk_classic::mesh::Entity& elem = bucket[iElement]; - const stk_classic::mesh::PairIterRelation& rels = elem.relations(m_eMesh.node_rank()); - for (unsigned j=0; j < rels.size(); j++) - { - if (rels[j].entity() == 0) throw std::runtime_error("bad node in an element"); - } - } - } - - - } - -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#if 0 - static stk_classic::mesh::Selector getNodeWasSnappedSelector(MeshGeometry& mesh_geometry) - { - stk_classic::mesh::Selector selector; - const std::vector& geomEvaluators = mesh_geometry.getGeomEvaluators(); - - for (unsigned s=0; s < geomEvaluators.size(); s++) - { - selector |= geomEvaluators[s]->mMesh; - } - return selector; - } -#endif -#endif - - void Refiner::snapAndSmooth(bool geomSnap, std::string geomFile) - { - std::cout << " geomFile= " << geomFile << " geomSnap= " << geomSnap << std::endl; -#if defined( STK_PERCEPT_HAS_GEOMETRY ) - if (geomFile == "") return; - std::cout << " 2 geomFile= " << geomFile << " geomSnap= " << geomSnap << std::endl; - - //SMOOTHING_OPTIONS option = SNAP_PLUS_SMOOTH; - SMOOTHING_OPTIONS option = USE_LINE_SEARCH_WITH_MULTIPLE_STATES; - - GeometryKernelOpenNURBS gk; - // set to 0.0 for no checks, > 0.0 for a fixed check delta, < 0.0 (e.g. -0.5) to check against local edge length average times this |value| - double doCheckMovement = 0.0; - //double doCheckMovement = -1.0; - - // anything exceeding a value > 0.0 will be printed - double doCheckCPUTime = 0.0; - //double doCheckCPUTime = 0.1; - - MeshGeometry mesh_geometry(&gk, doCheckMovement, doCheckCPUTime); - GeometryFactory factory(&gk, &mesh_geometry); - factory.read_file(geomFile, &m_eMesh); - - switch(option) { - case SNAP_PLUS_SMOOTH: - { - mesh_geometry.snap_points_to_geometry(&m_eMesh); - if (doCheckMovement != 0.0) - mesh_geometry.print_node_movement_summary(); - -#if defined (STK_PERCEPT_HAS_MESQUITE) - if (m_doSmoothGeometry) - { - smoothGeometry(mesh_geometry,option); - mesh_geometry.snap_points_to_geometry(&m_eMesh); - } -#endif - } - break; - case USE_LINE_SEARCH_WITH_MULTIPLE_STATES: - { - //VERIFY_OP_ON(m_eMesh.get_coordinates_field()->number_of_states(), ==, 3, "Must use PerceptMesh::set_num_coordinate_field_states(3) to use new smoothing."); - stk_classic::mesh::FieldBase *nm1_field = m_eMesh.get_field("coordinates_NM1"); - -#ifdef STK_PERCEPT_HAS_MESQUITE - if (m_doSmoothGeometry && nm1_field) - { - // make a copy of current non-snapped state (dst,src) - m_eMesh.copy_field(m_eMesh.get_field("coordinates_NM1"), m_eMesh.get_coordinates_field() ); - } -#endif - - // do the snap - if (geomSnap) - mesh_geometry.snap_points_to_geometry(&m_eMesh); - if (doCheckMovement != 0.0) - mesh_geometry.print_node_movement_summary(); - -#ifdef STK_PERCEPT_HAS_MESQUITE - if (m_doSmoothGeometry && nm1_field) - { - // make a copy of current snapped state - m_eMesh.copy_field(m_eMesh.get_field("coordinates_N"), m_eMesh.get_coordinates_field() ); - - // reset current state to non-snapped state - m_eMesh.copy_field(m_eMesh.get_coordinates_field(), m_eMesh.get_field("coordinates_NM1") ); - - smoothGeometry(mesh_geometry,option); - //mesh_geometry.snap_points_to_geometry(&m_eMesh); - } -#endif - - } - break; - } - -#endif - } - -#if defined( STK_PERCEPT_HAS_MESQUITE ) && defined(STK_PERCEPT_HAS_GEOMETRY) - void Refiner::smoothGeometry(MeshGeometry& mesh_geometry, SMOOTHING_OPTIONS option) - { - bool do_mesquite_smoothing = true; - if (do_mesquite_smoothing) - { - int msq_debug = 2; // 1,2,3 for more debug info - bool always_smooth = true; - bool do_laplace = false; - bool do_jacobi = true; - - PerceptMesquiteMeshDomain pmd(&m_eMesh, &mesh_geometry); - - switch(option) { - case SNAP_PLUS_SMOOTH: - { -#define ALWAYS_PMM_PARALLEL 1 -#if ALWAYS_PMM_PARALLEL - PerceptMesquiteMesh pmm0(&m_eMesh, &pmd); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - Mesquite::MsqError err; - //pmm.helper.set_communication_model(Mesquite::ParallelHelperImpl::Blocking, err); -#else - PerceptMesquiteMesh pmm(&m_eMesh, &pmd); -#endif - if (do_laplace) - { - PMMLaplaceSmoother1 ls; - if (do_jacobi) ls.get_smoother().do_jacobi_optimization(); - ls.run(pmm, pmd, always_smooth, msq_debug); - } - else - { - //PMMShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - PMMShapeImprover si(100, 1.e-8, 20); - //PMMShapeImprover si(5, 1.e-8, 20); - //const double max_vertex_movement_term_crit=10; - //PMMShapeSizeOrientImprover si(10); - si.run(pmm, pmd, always_smooth, msq_debug); - } - } - break; - case USE_LINE_SEARCH_WITH_MULTIPLE_STATES: - { -#if 1 - // geometry used for classification of fixed/non-fixed nodes - PerceptMesquiteMesh pmm(&m_eMesh, &pmd); - - //PMMShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - - percept::PMMParallelShapeImprover pmmpsi(1001, 1.e-4, 1); - //pmmpsi.run(pmm, &pmd, always_smooth, msq_debug); - pmmpsi.run(pmm, &pmd, always_smooth, msq_debug); - - -#endif - } - break; - } - return; - } - } -#endif - - unsigned Refiner:: - doForAllElements(unsigned irank, std::string function_info, - stk_classic::mesh::EntityRank rank, NodeRegistry::ElementFunctionPrototype function, - vector< ColorerSetType >& elementColors, unsigned elementType, - vector& needed_entity_ranks, - bool only_count, bool doAllElements) - //bool only_count=false, bool doAllElements=true) - { - EXCEPTWATCH; - unsigned num_elem = 0; - - int progress_meter_num_total = 0; - if (m_doProgress) - { - m_doProgress = false; - progress_meter_num_total = doForAllElements(irank, function_info, rank, function, elementColors, elementType, needed_entity_ranks, true, doAllElements); - m_doProgress = true; - std::ostringstream oss; oss << function_info <<" [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::INIT, 0.0, oss.str()); - notifyObservers(&pd); - } - int progress_meter_when_to_post = progress_meter_num_total / m_progress_meter_frequency; - if (0 == progress_meter_when_to_post) - progress_meter_when_to_post = 1; - double d_progress_meter_num_total = progress_meter_num_total; - - for (unsigned icolor = 0; icolor < elementColors.size(); icolor++) - { - if (elementColors[icolor].size() == 0) - { - std::cout << "tmp doForAllElements elementColors size = 0!!!" << std::endl; - continue; - } - - //stk_classic::mesh::Entity* first_element_p = *(elementColors[icolor].begin()); - //const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*first_element_p); - - // do in threaded mode FIXME - for (ColorerSetType::iterator iele = elementColors[icolor].begin(); - iele != elementColors[icolor].end(); - iele++) - { - const stk_classic::mesh::Entity * element_p = *iele; - const stk_classic::mesh::Entity& element = * element_p; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error if isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - bool elementIsGhost = m_eMesh.isGhostElement(element); - if (!elementIsGhost) - ++num_elem; - - if (!only_count && (doAllElements || elementIsGhost)) - { - refineMethodApply(function, element, needed_entity_ranks); - } - - if (m_doProgress && (num_elem % progress_meter_when_to_post == 0) ) - { - double progress_meter_percent = 100.0*((double)num_elem)/std::max(d_progress_meter_num_total,1.0); - std::ostringstream oss; oss << function_info << " [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::RUNNING, progress_meter_percent, oss.str()); - notifyObservers(&pd); - if (0) std::cout << "progress_meter_percent = " << progress_meter_percent << std::endl; - } - - } // elements in this color - } // icolor - - if (m_doProgress) - { - std::ostringstream oss; oss << function_info << " [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::FINI, 0.0, oss.str()); - notifyObservers(&pd); - } - - return num_elem; - } - - void Refiner:: - createElementsAndNodesAndConnectLocal(unsigned irank, stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase *breakPattern, - vector< ColorerSetType >& elementColors, vector& needed_entity_ranks, - vector& new_elements_pool) - { - EXCEPTWATCH; - static NewSubEntityNodesType s_new_sub_entity_nodes(stk_classic::percept::EntityRankEnd); - - NewSubEntityNodesType& new_sub_entity_nodes = s_new_sub_entity_nodes; - - vector::iterator element_pool_it = new_elements_pool.begin(); - - int jele = 0; - int numPrints = 20; - - // create new elements and connect them up - - for (unsigned icolor = 0; icolor < elementColors.size(); icolor++) - { - jele += elementColors[icolor].size(); - } - - int nele = jele; - jele = 0; - int printEvery = nele/numPrints; - if (printEvery == 0) printEvery = 1; - if (0) - { - std::cout << "Refiner::createElementsAndNodesAndConnectLocal: rank= " << rank - << " elementColors.size() = " << elementColors.size() << " num elements = " << nele - << " printEvery= " << printEvery - << std::endl; - } - if (m_doProgress) - { - std::ostringstream oss; oss << "Create Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::INIT, 0.0, oss.str()); - notifyObservers(&pd); - } - - for (unsigned icolor = 0; icolor < elementColors.size(); icolor++) - { - TRACE_PRINT( "Refiner:createElementsAndNodesAndConnectLocal color= " + percept::toString(icolor) + " [ " + - (percept::toString (((double)icolor)/((double)elementColors.size())*100 )).substr(0,4) + " %] "); - - if (elementColors[icolor].size() == 0) - { - std::cout << "tmp elementColors size = 0!!!" << std::endl; - continue; - } - - stk_classic::mesh::Entity* first_element_p = *(elementColors[icolor].begin()); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*first_element_p); - shards::CellTopology cell_topo(cell_topo_data); - - for (ColorerSetType::iterator iele = elementColors[icolor].begin(); iele != elementColors[icolor].end(); iele++) - { - - stk_classic::mesh::Entity* element_p = *iele; - if (!element_p) - { - throw std::runtime_error("Refiner::createElementsAndNodesAndConnectLocal"); - } - - if (0 && (jele % printEvery == 0)) - { - std::cout << "Refiner::createElementsAndNodesAndConnectLocal: element # = " << jele << " [" - << (((double)jele)/((double)nele)*100.0) << " %]" << std::endl; - } - if (m_doProgress && (jele % printEvery == 0)) - { - std::ostringstream oss; oss << "Create Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::RUNNING, 100.0*((double)jele)/((double)std::max(nele,1)), oss.str()); - notifyObservers(&pd); - } - - stk_classic::mesh::Entity& element = * element_p; - - if (m_proc_rank_field && rank == m_eMesh.element_rank()) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(m_proc_rank_field) , element ); - fdata[0] = double(element.owner_rank()); - //if (1 || element.owner_rank() == 3) - // std::cout << "tmp element.owner_rank() = " << element.owner_rank() << std::endl; - } - // FIXME - - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error if isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - if (0) - { - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size() == 1) - { - std::cout << "tmp isParent = " << isParent << " isChild = " << m_eMesh.isChildElement(element) << " element_to_family_tree_relations.size() = " << element_to_family_tree_relations.size() << std::endl; - } - } - - if (isParent) - continue; - - - if (!m_eMesh.isGhostElement(element)) - { - //std::cout << "P["<< m_eMesh.get_rank() << "] element.owner_rank() = " << element.owner_rank() << std::endl; - /**/ TRACE_CPU_TIME_AND_MEM_0(CONNECT_LOCAL_createNewNeededNodes); - - if (createNewNeededNodeIds(cell_topo_data, element, needed_entity_ranks, new_sub_entity_nodes)) - { - std::cout << "typeid= " << typeid(*breakPattern).name() << std::endl; - throw std::logic_error("needed_entity_ranks[ineed_ent].second"); - } - - /**/ TRACE_CPU_TIME_AND_MEM_1(CONNECT_LOCAL_createNewNeededNodes); - - /**/ TRACE_CPU_TIME_AND_MEM_0(CONNECT_LOCAL_createNewElements); - - breakPattern->createNewElements(m_eMesh, *m_nodeRegistry, element, new_sub_entity_nodes, element_pool_it, m_proc_rank_field); - - /**/ TRACE_CPU_TIME_AND_MEM_1(CONNECT_LOCAL_createNewElements); - } - - ++jele; - } - } - - if (m_doProgress) - { - std::ostringstream oss; oss << "Create Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::FINI, 0.0, oss.str()); - notifyObservers(&pd); - } - - } - - /// create a list of nodes from the new nodes that can be easily deciphered by the UniformRefinerPattern - /// Returns the 3D array new_sub_entity_nodes[entity_rank][ordinal_of_sub_dim_entity][ordinal_of_node_on_sub_dim_entity] - - bool Refiner:: - createNewNeededNodeIds(const CellTopologyData * const cell_topo_data, - const stk_classic::mesh::Entity& element, vector& needed_entity_ranks, NewSubEntityNodesType& new_sub_entity_nodes) - { - EXCEPTWATCH; - - NodeRegistry& nodeRegistry = *m_nodeRegistry; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - // CHECK - cache this - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - - // special case of face in 3d or edge in 2d - if (needed_entity_ranks[ineed_ent].first == element.entity_rank()) - { - numSubDimNeededEntities = 1; - } - else if (needed_entity_ranks[ineed_ent].first == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_ranks[ineed_ent].first == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_ranks[ineed_ent].first == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - if (needed_entity_ranks[ineed_ent].first >= new_sub_entity_nodes.size()) - { - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #1"); - } - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first].resize(numSubDimNeededEntities); - - if (0) - { - std::cout << "P[" << m_eMesh.get_rank() << "] needed_entity_ranks[ineed_ent]= " << needed_entity_ranks[ineed_ent].first - << " , " << needed_entity_ranks[ineed_ent].second << " numSubDimNeededEntities= " << numSubDimNeededEntities - << std::endl; - } - - // ensure nodes don't get inadvertently reused - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first][iSubDimOrd].resize(0); - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - // CHECK - NodeIdsOnSubDimEntityType* nodeIds_onSE_ptr = nodeRegistry.getNewNodesOnSubDimEntity(element, needed_entity_ranks[ineed_ent].first, iSubDimOrd); - if (nodeIds_onSE_ptr == 0) - { - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first][iSubDimOrd].resize(0); - continue; - } - NodeIdsOnSubDimEntityType& nodeIds_onSE = *nodeIds_onSE_ptr; - - if (nodeIds_onSE.size() == 0) - { - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first][iSubDimOrd].resize(0); - continue; - } - - if (!nodeIds_onSE[0]) { - - if (nodeIds_onSE.m_entity_id_vector[0] == 0) - { - // for debugging cases that may have inconsistent edge marking schemes -#define DEBUG_ALLOW_0_ENTITY_ID_VECTOR 0 - if (DEBUG_ALLOW_0_ENTITY_ID_VECTOR) - { - continue; - } - else - { - std::cout << "P[" << m_eMesh.get_rank() << "] nodeId ## = 0 << " - << " nodeIds_onSE.m_entity_id_vector[0] = " << nodeIds_onSE.m_entity_id_vector[0] - << " element= " << element - << " needed_entity_ranks= " << needed_entity_ranks[ineed_ent].first - << " iSubDimOrd = " << iSubDimOrd - << std::endl; - std::cout << " element= "; - m_eMesh.print_entity(std::cout, element, 0); - - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #5.0, nodeIds_onSE.m_entity_id_vector[i_new_node] == 0"); - } - } - - stk_classic::mesh::Entity * node1 = m_eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[0]); - nodeIds_onSE[0] = node1; - - if (!node1) - { - if (!m_nodeRegistry->getUseCustomGhosting()) - { - static stk_classic::mesh::PartVector empty_parts; - node1 = & m_eMesh.get_bulk_data()->declare_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[0], empty_parts); - } - - if (!node1) - { - std::cout << "P[" << m_eMesh.get_rank() << "] nodeId ## = 0 << " - << " nodeIds_onSE.m_entity_id_vector[0] = " << nodeIds_onSE.m_entity_id_vector[0] << " node1= " << node1 - << " element= " << element - << " needed_entity_ranks= " << needed_entity_ranks[ineed_ent].first - << " iSubDimOrd = " << iSubDimOrd - << std::endl; - throw std::logic_error("Refiner::createNewNeededNodeIds logic error #0"); - } - } - - } - - unsigned num_new_nodes_needed = needed_entity_ranks[ineed_ent].second; - if (0) - { - const CellTopologyData * const cell_topo_data_0 = stk_classic::percept::PerceptMesh::get_cell_topology(element); - shards::CellTopology cell_topo_0(cell_topo_data_0); - - std::cout << "tmp 43 cell_topo= " << cell_topo_0.getName() << " ineed_ent= " << ineed_ent << " needed_entity_ranks[ineed_ent].first/second = " - << needed_entity_ranks[ineed_ent].first << " " - << needed_entity_ranks[ineed_ent].second - << std::endl; - } - - if (num_new_nodes_needed < 1) - { - //std::cout << "needed_entity_ranks[ineed_ent].second = " << num_new_nodes_needed << std::endl; - //throw std::logic_error("needed_entity_ranks[ineed_ent].second"); - return true; - } - - if (iSubDimOrd >= new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first].size()) - { - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #2"); - } - //std::cout << "tmp elementid, iSubDimOrd, num_new_nodes_needed = " << element.identifier() << " " << iSubDimOrd << " " << num_new_nodes_needed << std::endl; - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first][iSubDimOrd].resize(num_new_nodes_needed); - if (num_new_nodes_needed > nodeIds_onSE.size()) - { - std::cout << "Refiner::createNewNeededNodeIds logic err #3: num_new_nodes_needed= " << num_new_nodes_needed - << " nodeIds_onSE.size() = " << nodeIds_onSE.size() << std::endl; - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #3"); - } - - for (unsigned i_new_node = 0; i_new_node < num_new_nodes_needed; i_new_node++) - { - if (!nodeIds_onSE[i_new_node]) - { - if (nodeIds_onSE.m_entity_id_vector[i_new_node] == 0) - { - if (DEBUG_ALLOW_0_ENTITY_ID_VECTOR) - { - continue; - } - else - { - std::cout << "P[" << m_eMesh.get_rank() << "] nodeId ## = 0 << " - << " nodeIds_onSE.m_entity_id_vector[0] = " << nodeIds_onSE.m_entity_id_vector[0] - << " element= " << element - << " needed_entity_ranks= " << needed_entity_ranks[ineed_ent].first - << " iSubDimOrd = " << iSubDimOrd - << std::endl; - std::cout << " element= "; - m_eMesh.print_entity(std::cout, element, 0); - - } - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #5.1, nodeIds_onSE.m_entity_id_vector[i_new_node] == 0"); - } - stk_classic::mesh::Entity * node1 = m_eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[i_new_node]); - - if (!node1) - { - if (!m_nodeRegistry->getUseCustomGhosting()) - { - static stk_classic::mesh::PartVector empty_parts; - node1 = & m_eMesh.get_bulk_data()->declare_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[i_new_node], empty_parts); - } - if (!node1) - { - throw std::logic_error("Refiner::createNewNeededNodeIds logic err #4"); - } - } - nodeIds_onSE[i_new_node] = node1; - VERIFY_OP_ON(node1->identifier(), ==, nodeIds_onSE.m_entity_id_vector[i_new_node], "Refiner::createNewNeededNodeIds logic err #4.1"); - } - new_sub_entity_nodes[needed_entity_ranks[ineed_ent].first][iSubDimOrd][i_new_node] = nodeIds_onSE[i_new_node]->identifier(); - -#ifndef NDEBUG - stk_classic::mesh::Entity * node2 = m_eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE[i_new_node]->identifier() ); - if (!node2) - { - std::cout << "P[" << m_eMesh.get_rank() << "] element is ghost = " << m_eMesh.isGhostElement(element) - << " needed_entity_ranks= " << needed_entity_ranks[ineed_ent].first << " iSubDimOrd= " << iSubDimOrd - << " i_new_node= " << i_new_node - << " id= " << nodeIds_onSE[i_new_node]->identifier() - << " entity_vec_id= " << nodeIds_onSE.m_entity_id_vector[i_new_node] - << std::endl; - - VERIFY_OP_ON(node2, !=, 0, "Refiner::createNewNeededNodeIds logic err #6 - node2 is null"); - } -#endif - - } - } - } - return false; - } - - - /** Creates a map of element sides to their higher-dimensional base elements - */ - -#define EXTRA_PRINT_UR_BESDB 0 - - void Refiner:: - buildElementSideDB(SubDimCellToDataMap& cell_2_data_map) - { - - } - - - /** @deprecated */ - void Refiner:: - fixElementSides() - { - } - - void Refiner:: - fixElementSides1() - { - EXCEPTWATCH; - if (getIgnoreSideSets()) return; - - if (m_eMesh.get_spatial_dim() == 3) - { - fixElementSides1(m_eMesh.face_rank()); - } - // FIXME - else if (m_eMesh.get_spatial_dim() == 2) - { - fixElementSides1(m_eMesh.edge_rank()); - } - } - - - -#if PERCEPT_USE_FAMILY_TREE == 0 - static const SameRankRelationValue * getChildVectorPtr( SameRankRelation& repo , stk_classic::mesh::Entity *parent) - { - SameRankRelation::const_iterator i = repo.find( parent ); - if (i != repo.end()) - return &i->second; - else - return 0; - } -#endif - - /** Sets orientations and associativity of elements to sub-dimensional faces/edges after refinement. - */ -#define EXTRA_PRINT_UR_FES 0 - -#if PERCEPT_USE_FAMILY_TREE == 0 - void Refiner:: - fixElementSides1(stk_classic::mesh::EntityRank side_rank) - { - EXCEPTWATCH; - - bool notFound = true; - for (unsigned ibp = 0; ibp < m_breakPattern.size(); ibp++) - { - // only check the side elements - if (m_breakPattern[ibp]->getPrimaryEntityRank() == side_rank) - { - notFound = false; - } - } - if (notFound) - { - std::cout << "Refiner::fixElementSides1: missing sub-dim break pattern - logic error\n" - " ---- for this refinement pattern to be able to handle sidesets and edgesets you must provide the sub-dim break pattern\n" - " ---- or you must set the setIgnoreSideSets() flag " << std::endl; - throw std::logic_error("Refiner::fixElementSides1: missing sub-dim break pattern - logic error"); - return; - } - - SameRankRelation& parent_child = m_eMesh.adapt_parent_to_child_relations(); - - //std::cout << "tmp parent_child.size() = " << parent_child.size() << std::endl; - - SameRankRelation::iterator pc_it; - for (pc_it = parent_child.begin(); pc_it != parent_child.end(); pc_it++) - { - const SameRankRelationKey& parent = pc_it->first; - SameRankRelationValue& child_vector = pc_it->second; - - if (0 == &parent) - { - throw std::logic_error("Refiner::fixElementSides1 parent is null"); - } - - if (0 == parent) - { - throw std::logic_error("Refiner::fixElementSides1 parent is null"); - } - - const CellTopologyData *parent_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*parent); - if (0 == parent_topo_data) - { - throw std::logic_error("Refiner::fixElementSides1 parent_topo_data is null"); - } - - shards::CellTopology parent_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*parent)); - //unsigned parent_nsides = (unsigned)parent_topo.getSideCount(); - - for (unsigned i_child = 0; i_child < child_vector.size(); i_child++) - { - stk_classic::mesh::Entity *child = child_vector[i_child]; - //mesh::PairIterRelation child_sides = child->relations(side_rank); - if (!child) - { - std::cout << "fixElementSides1: child == null, i_child= " << i_child << " nchild= " << child_vector.size() << std::endl; - throw std::runtime_error("fixElementSides1: child == null"); - } - - shards::CellTopology child_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*child)); - unsigned child_nsides = (unsigned)child_topo.getSideCount(); - - // if parent has any side relations, check if any of the sides' children match the parent's children's faces - mesh::PairIterRelation parent_sides = parent->relations(side_rank); - mesh::PairIterRelation side_to_parent = parent->relations(m_eMesh.element_rank()); - - //std::cout << "tmp here 1 child_nsides= " << child_nsides - // << " parent_sides.size()=" << parent_sides.size() << " side_to_parent.size() = " << side_to_parent.size() << std::endl; - - for (unsigned i_parent_side = 0; i_parent_side < parent_sides.size(); i_parent_side++) - { - stk_classic::mesh::Entity *parent_side = parent_sides[i_parent_side].entity(); - //unsigned local_parent_side_id = parent_sides[i_parent_side].identifier(); - - if (!parent_side) - { - throw std::logic_error("parent_side is null"); - } - SameRankRelation& repo = m_eMesh.adapt_parent_to_child_relations(); - //SameRankRelationValue& parent_side_children = m_eMesh.adapt_parent_to_child_relations()[parent_side]; - const SameRankRelationValue* parent_side_children_ptr = getChildVectorPtr(repo, parent_side); - if (!parent_side_children_ptr) - continue; - - //const SameRankRelationValue& parent_side_children = getChildVector(repo, parent_side); - const SameRankRelationValue& parent_side_children = *parent_side_children_ptr; - - //std::cout << "tmp here 2 parent_side_children.size() = " << parent_side_children.size() - // << std::endl; - - for (unsigned i_parent_side_child = 0; i_parent_side_child < parent_side_children.size(); i_parent_side_child++) - { - stk_classic::mesh::Entity *parent_side_child = parent_side_children[i_parent_side_child]; - - //std::cout << "tmp here 3 parent_side_child = " << *parent_side_child - // << std::endl; - - int permIndex = -1; - int permPolarity = 1; - - // use of i_parent_side here implies that the children's sides match up with the parents, this could be untrue - - // then will require a search through all child faces - // NOTE: have to search over child faces due to different topology cases - if parent & child have same topology, - // we can save a few ops here TODO FIXME - unsigned k_child_side = 0; - -#if 0 - // FIXME - why is this #if'd out? - boolean sameTopology = false; // FIXME - get this from the break pattern - if (sameTopology) - { - PerceptMesh::element_side_permutation(*child, *parent_side_child, k_child_side, permIndex, permPolarity); - } -#endif - - if (permIndex < 0) - { - // try search - for (unsigned j_child_side = 0; j_child_side < child_nsides; j_child_side++) - { - PerceptMesh::element_side_permutation(*child, *parent_side_child, j_child_side, permIndex, permPolarity); - if (0) - std::cout << "tmp j_child_side = " << j_child_side << " permIndex= " << permIndex - << " child= " << *child - << " parent_side_child= " << *parent_side_child - << std::endl; - - if (permIndex >= 0) - { - k_child_side = j_child_side; - break; - } - } - } - - if (permIndex >= 0) - { - if (0) - std::cout << "tmp decl rel permIndex= " << permIndex - << " child= " << *child - << " parent_side_child= " << *parent_side_child - << std::endl; - m_eMesh.get_bulk_data()->declare_relation(*child, *parent_side_child, k_child_side); - PerceptMesh::element_side_permutation(*child, *parent_side_child, k_child_side, permIndex, permPolarity); - } - else - { - // error condition? - //throw std::runtime_error("fixElementSides1: couldn't find a matching face"); - } - } - } - } - } - } - -#elif PERCEPT_USE_FAMILY_TREE == 1 - - - void Refiner:: - check_sidesets(std::string msg) - { - EXCEPTWATCH; - - std::cout << "tmp check_sidesets start..." << std::endl; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - if (side.relations(node_rank).size() == 0) - continue; - if (!m_eMesh.hasFamilyTree(side) || m_eMesh.isChildElement(side, true)) - { - bool found = false; - const vector & element_buckets = m_eMesh.get_bulk_data()->buckets( element_rank ); - for ( vector::const_iterator it_element_bucket = element_buckets.begin() ; - it_element_bucket != element_buckets.end() ; ++it_element_bucket ) - { - stk_classic::mesh::Bucket & element_bucket = **it_element_bucket ; - const unsigned num_elements_in_element_bucket = element_bucket.size(); - for (unsigned i_element = 0; i_element < num_elements_in_element_bucket; i_element++) - { - stk_classic::mesh::Entity& element = element_bucket[i_element]; - if (element.relations(node_rank).size() == 0) - continue; - - shards::CellTopology element_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - unsigned element_nsides = (unsigned)element_topo.getSideCount(); - - for (unsigned j_element_side = 0; j_element_side < element_nsides; j_element_side++) - { - int permIndex = -1; - int permPolarity = 1; - PerceptMesh::element_side_permutation(element, side, j_element_side, permIndex, permPolarity); - if (permIndex >= 0) - { - found = true; - break; - } - } - } - } // elements... - if (!found) - { - std::cout << "ERROR: side = " << side << std::cout; - throw std::logic_error("check_sidesets error"); - } - } - } - } - std::cout << "tmp check_sidesets ...end" << std::endl; - } - - // check for two sides sharing all nodes - void Refiner:: - check_sidesets_1(std::string msg) - { - EXCEPTWATCH; - - std::cout << "P["<< m_eMesh.get_rank() << "] tmp check_sidesets_1 start... " << msg << std::endl; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - - typedef std::set SetOfEntities; - SetOfEntities side_set; - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - - if (m_eMesh.isGhostElement(side)) - continue; - - if (side.relations(node_rank).size() == 0) - continue; - - if (m_eMesh.check_entity_duplicate(side)) - { - throw std::logic_error("found two sides with same nodes"); - } - } - } - std::cout << "P["<< m_eMesh.get_rank() << "] tmp check_sidesets_1 ... end " << msg << std::endl; - } - - // fast check if side elems have relations to elements and vice versa - void Refiner:: - check_sidesets_2(std::string msg) - { - EXCEPTWATCH; - - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - std::cout << "tmp check_sidesets_2 start... " << msg << " side_rank= " << side_rank << " element_rank= " << element_rank << std::endl; - - typedef std::set SetOfEntities; - SetOfEntities side_set; - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - if (m_eMesh.isGhostElement(side)) - continue; - - if (side.relations(node_rank).size() == 0) - { - continue; - } - - if (side.relations(element_rank).size() > 1) - { - throw std::logic_error("check_sidesets_2: too many side relations"); - } - - if (side.relations(element_rank).size() < 1) - { - throw std::logic_error("check_sidesets_2: too few side relations"); - } - - //if (!m_eMesh.isLeafElement(side)) - // continue; - - bool found = false; - - stk_classic::mesh::PairIterRelation side_nodes = side.relations(node_rank); - - for (unsigned isnode=0; isnode < side_nodes.size(); isnode++) - { - stk_classic::mesh::PairIterRelation node_elements = side_nodes[isnode].entity()->relations(element_rank); - for (unsigned ienode=0; ienode < node_elements.size(); ienode++) - { - stk_classic::mesh::Entity& element = *node_elements[ienode].entity(); - - if (element.relations(node_rank).size() == 0) - continue; - if (m_eMesh.isGhostElement(element)) - continue; - - // FIXME - //if (m_eMesh.isLeafElement(element)) - { - shards::CellTopology element_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - unsigned element_nsides = (unsigned)element_topo.getSideCount(); - - for (unsigned j_element_side = 0; j_element_side < element_nsides; j_element_side++) - { - int permIndex = -1; - int permPolarity = 1; - PerceptMesh::element_side_permutation(element, side, j_element_side, permIndex, permPolarity); - if (permIndex >= 0) - { - found = true; - //std::cout << "found side element needing fixing, id= " << side.identifier() - // << " ele id= " << element.identifier() << std::endl; - //m_eMesh.get_bulk_data()->declare_relation(element, side, j_element_side); - } - if (found) break; - } - if (found) break; - } - if (found) break; - } - if (found) break; - } - - if (!found) - { - std::cout << "ERROR: side = " << side << std::cout; - throw std::logic_error("check_sidesets_2 error"); - } - } - } - std::cout << "tmp check_sidesets_2 ...end" << std::endl; - } - - // find remaining missing relations - void Refiner:: - fix_side_sets_1() - { - EXCEPTWATCH; - - //std::cout << "tmp fix_side_sets_1 start..." << std::endl; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - SetOfEntities side_set_with_empty_relations; - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - - if (side.relations(node_rank).size() == 0) - continue; - - //if (!m_eMesh.hasFamilyTree(side) || m_eMesh.isChildElement(side, true)) - { - if (side.relations(element_rank).size() > 1) - { - throw std::logic_error("fix_side_sets_1: too many side relations"); - } - - // already found - if (side.relations(element_rank).size()) - continue; - - side_set_with_empty_relations.insert(&side); - } - } - } - - for (SetOfEntities::iterator side_iter = side_set_with_empty_relations.begin(); side_iter != side_set_with_empty_relations.end(); ++side_iter) - { - stk_classic::mesh::Entity& side = **side_iter; - - if (side.relations(node_rank).size() == 0) - continue; - - if (side.relations(element_rank).size() > 1) - { - throw std::logic_error("fix_side_sets_1: too many side relations"); - } - - // already found - if (side.relations(element_rank).size()) - continue; - - bool found = false; - const vector & element_buckets = m_eMesh.get_bulk_data()->buckets( element_rank ); - for ( vector::const_iterator it_element_bucket = element_buckets.begin() ; - it_element_bucket != element_buckets.end() ; ++it_element_bucket ) - { - stk_classic::mesh::Bucket & element_bucket = **it_element_bucket ; - const unsigned num_elements_in_element_bucket = element_bucket.size(); - for (unsigned i_element = 0; i_element < num_elements_in_element_bucket; i_element++) - { - stk_classic::mesh::Entity& element = element_bucket[i_element]; - if (element.relations(node_rank).size() == 0) - continue; - - if (!m_eMesh.hasFamilyTree(element) || m_eMesh.isChildElement(element, true)) - { - shards::CellTopology element_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - unsigned element_nsides = (unsigned)element_topo.getSideCount(); - - for (unsigned j_element_side = 0; j_element_side < element_nsides; j_element_side++) - { - int permIndex = -1; - int permPolarity = 1; - PerceptMesh::element_side_permutation(element, side, j_element_side, permIndex, permPolarity); - if (permIndex >= 0) - { - found = true; - if (1) - { - std::cout << "found side element needing fixing, id= " << side.identifier() << std::endl; - std::cout << "found side element needing fixing, ele id= " << element.identifier() << std::endl; - //exit(123); - throw std::logic_error("fix_side_sets_2 error 1"); - } - - - mesh::PairIterRelation rels = element.relations(side_rank); - - //std::cout << "found 1 side element needing fixing, id= " << side.identifier() << std::endl; - - bool found_existing_rel = false; - for (unsigned irels=0; irels < rels.size(); irels++) - { - if (rels[irels].entity() == &side) - { - //std::cout << "found 2 side element needing fixing, id= " << side.identifier() << std::endl; - found_existing_rel = true; - break; - } - } - if (found_existing_rel) - { - throw std::logic_error("found_existing_rel where none expected"); - } - else - { - //std::cout << "found 3 side element needing fixing, id= " << side.identifier() << std::endl; - m_eMesh.get_bulk_data()->declare_relation(element, side, j_element_side); - //std::cout << "found 4 side element needing fixing, id= " << side.identifier() << std::endl; - } - - break; - } - if (found) break; - } - if (found) break; - } - if (found) break; - } - if (found) break; - } // element buckets... - - if (!found) - { - std::cout << "ERROR: side = " << side << std::cout; - throw std::logic_error("fix_side_sets_1 error"); - } - } - //std::cout << "tmp fix_side_sets_1 ...end" << std::endl; - } - - // determine side part to elem part relations - void Refiner:: - get_side_part_relations(bool checkParentChild, SidePartMap& side_part_map) - { - EXCEPTWATCH; - std::cout << "get_side_part_relations start...\n"; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank edge_rank = m_eMesh.edge_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - int spatialDim = m_eMesh.get_spatial_dim(); - - unsigned side_rank_iter_begin = side_rank; - unsigned side_rank_iter_end = side_rank; - if (spatialDim == 3) - { - side_rank_iter_begin = edge_rank; - } - - // get super-relations (side_part.name() --> elem_part.name()) - for (unsigned side_rank_iter = side_rank_iter_begin; side_rank_iter <= side_rank_iter_end; side_rank_iter++) - { - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank_iter ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - stk_classic::mesh::PartVector side_parts; - side_bucket.supersets(side_parts); - if (0) - for (unsigned isp=0; isp < side_parts.size(); isp++) - { - std::cout << "side_part= " << side_parts[isp]->name() << std::endl; - } - - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - - if (m_eMesh.isGhostElement(side)) - continue; - - if (side.relations(node_rank).size() == 0) - continue; - - if (side.relations(element_rank).size() > 1) - { - std::cout << "get_side_part_relations: too many side relations" << std::endl; - throw std::logic_error("get_side_part_relations: too many side relations"); - } - - bool isLeafElement = !checkParentChild || m_eMesh.isLeafElement(side); - if (isLeafElement) - { - stk_classic::mesh::PairIterRelation side_to_elem_rels = side.relations(element_rank); - for (unsigned irel = 0; irel < side_to_elem_rels.size(); irel++) - { - stk_classic::mesh::Entity& elem = *side_to_elem_rels[irel].entity(); - stk_classic::mesh::PartVector elem_parts; - elem.bucket().supersets(elem_parts); - for (unsigned isp=0; isp < side_parts.size(); isp++) - { - if ( stk_classic::mesh::is_auto_declared_part(*side_parts[isp]) ) - continue; - const CellTopologyData *const topology = stk_classic::percept::PerceptMesh::get_cell_topology(*side_parts[isp]); - if (!topology) - continue; - - for (unsigned iep=0; iep < elem_parts.size(); iep++) - { - if ( stk_classic::mesh::is_auto_declared_part(*elem_parts[iep]) ) - continue; - - //if (elem_parts[iep]->name().find(UniformRefinerPatternBase::getOldElementsPartName()) != std::string::npos) - // continue; - - const STK_Adapt_Auto_Part *auto_part = elem_parts[iep]->attribute(); - if (elem_parts[iep]->name().find(UniformRefinerPatternBase::getOldElementsPartName()) != std::string::npos) - { - if (!auto_part) throw std::runtime_error("Refiner::get_side_part_relations: bad old part attribute for auto"); - } - - if (auto_part) - { - continue; - } - - if (elem_parts[iep] != side_parts[isp]) - { - SidePartMap::iterator found = side_part_map.find(side_parts[isp]->name()); - if (found != side_part_map.end()) - { - if (found->second != elem_parts[iep]->name()) - { - std::cout << "side_part = " << side_parts[isp]->name() - << " elem_part = " << elem_parts[iep]->name() - << " found_elem_part = " << found->second - << std::endl; - throw std::runtime_error("Refiner::get_side_part_relations: too many side_part to elem_part relations"); - } - } - side_part_map[side_parts[isp]->name()] = elem_parts[iep]->name(); - } - } - } - } - } - } - } - } - - if (1) - { - SidePartMap::iterator iter; - for (iter = side_part_map.begin(); iter != side_part_map.end(); iter++) - { - std::cout << "Refiner::get_side_part_relations: side_part = " << iter->first << " elem_part= " << iter->second << std::endl; - } - //exit(1); - } - std::cout << "get_side_part_relations ... done\n"; - } - - // fast reconnector - checks for which super-connections are valid (from the original mesh, look - // at which side-part touches which element-part, save the info), and reconnects found side/elem matches. - void Refiner:: - fix_side_sets_3(bool checkParentChild, SidePartMap& side_part_map) - { - EXCEPTWATCH; - - std::cout << "tmp fix_side_sets_3 start... checkParentChild= " << checkParentChild << std::endl; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank edge_rank = m_eMesh.edge_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - int spatialDim = m_eMesh.get_spatial_dim(); - - //const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - //const vector & family_tree_buckets = m_eMesh.get_bulk_data()->buckets( FAMILY_TREE_RANK ); - //bool have_family_tree = family_tree_buckets.size() > 0; - - //std::cout << "tmp fix_side_sets_3 side_rank= " << side_rank << " element_rank= " << element_rank << std::endl; - - // loop over all sides that are leaves (not parent or have no family tree), - // loop over their nodes and their associated elements, - // connect element and side if they share a face - - unsigned side_rank_iter_begin = side_rank; - unsigned side_rank_iter_end = side_rank; - if (spatialDim == 3) - { - side_rank_iter_begin = edge_rank; - } - - for (unsigned side_rank_iter = side_rank_iter_begin; side_rank_iter <= side_rank_iter_end; side_rank_iter++) - { - SetOfEntities side_set; - int connections=0; - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank_iter ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - - if (m_eMesh.isGhostElement(side)) - continue; - - if (side.relations(node_rank).size() == 0) - continue; - - if (side.relations(element_rank).size() > 1) - { - std::cout << "fix_side_sets_3: too many side relations" << std::endl; - throw std::logic_error("fix_side_sets_3: too many side relations"); - } - - bool isLeafElement = !checkParentChild || m_eMesh.isLeafElement(side); - if (!isLeafElement) - continue; - - side_set.insert(&side); - } - } - - for (SetOfEntities::iterator it_side=side_set.begin(); it_side != side_set.end(); ++it_side) - { - stk_classic::mesh::Entity& side = **it_side; - - bool found = false; - - stk_classic::mesh::PairIterRelation side_nodes = side.relations(node_rank); - - for (unsigned isnode=0; isnode < side_nodes.size(); isnode++) - { - stk_classic::mesh::PairIterRelation node_elements = side_nodes[isnode].entity()->relations(element_rank); - for (unsigned ienode=0; ienode < node_elements.size(); ienode++) - { - stk_classic::mesh::Entity& element = *node_elements[ienode].entity(); - - if (element.relations(node_rank).size() == 0) - continue; - if (m_eMesh.isGhostElement(element)) - continue; - - // FIXME - bool isLeafElement = !checkParentChild || m_eMesh.isLeafElement(element); - if (isLeafElement) - { - if (connectSides(&element, &side, &side_part_map)) - { - ++connections; - found = true; - } - } - if (found) break; - } - if (found) break; - } - - if (!found) - { - std::cout << "ERROR: side = " << side << std::endl; - throw std::logic_error("fix_side_sets_3 error 2"); - } - } - std::cout << "Refiner::fix_side_sets_3 number of connections for side_rank= " << side_rank_iter << " = " << connections << std::endl; - - } - - std::cout << "tmp fix_side_sets_3 ...end" << std::endl; - } - - // fast check if side elems have relations to elements and vice versa - void Refiner:: - fix_side_sets_2() - { - EXCEPTWATCH; - - //std::cout << "tmp fix_side_sets_2 start... " << std::endl; - - stk_classic::mesh::EntityRank node_rank = m_eMesh.node_rank(); - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - stk_classic::mesh::EntityRank element_rank = m_eMesh.element_rank(); - - int spatialDim = m_eMesh.get_spatial_dim(); - - //std::cout << "tmp fix_side_sets_2 side_rank= " << side_rank << " element_rank= " << element_rank << std::endl; - - // loop over all sides that are leaves (not parent or have no family tree), - // loop over their nodes and their associated elements, - // connect element and side if they share a face - - unsigned side_rank_iter_begin = side_rank; - unsigned side_rank_iter_end = side_rank; - if (spatialDim == 3) - { - side_rank_iter_begin = m_eMesh.edge_rank(); - } - for (unsigned side_rank_iter = side_rank_iter_begin; side_rank_iter <= side_rank_iter_end; side_rank_iter++) - { - SetOfEntities side_set; - - const vector & side_buckets = m_eMesh.get_bulk_data()->buckets( side_rank_iter ); - for ( vector::const_iterator it_side_bucket = side_buckets.begin() ; it_side_bucket != side_buckets.end() ; ++it_side_bucket ) - { - stk_classic::mesh::Bucket & side_bucket = **it_side_bucket ; - const unsigned num_elements_in_side_bucket = side_bucket.size(); - for (unsigned i_side = 0; i_side < num_elements_in_side_bucket; i_side++) - { - stk_classic::mesh::Entity& side = side_bucket[i_side]; - - if (m_eMesh.isGhostElement(side)) - continue; - - if (side.relations(node_rank).size() == 0) - continue; - - if (side.relations(element_rank).size() > 1) - { - std::cout << "fix_side_sets_2: too many side relations" << std::endl; - throw std::logic_error("fix_side_sets_2: too many side relations"); - } - // if we already have a connection, skip this side - if (side.relations(element_rank).size() == 1) - continue; - - if (!m_eMesh.isLeafElement(side)) - continue; - - side_set.insert(&side); - } - } - - for (SetOfEntities::iterator it_side=side_set.begin(); it_side != side_set.end(); ++it_side) - { - stk_classic::mesh::Entity& side = **it_side; - - bool found = false; - - stk_classic::mesh::PairIterRelation side_nodes = side.relations(node_rank); - - for (unsigned isnode=0; isnode < side_nodes.size(); isnode++) - { - stk_classic::mesh::PairIterRelation node_elements = side_nodes[isnode].entity()->relations(element_rank); - for (unsigned ienode=0; ienode < node_elements.size(); ienode++) - { - stk_classic::mesh::Entity& element = *node_elements[ienode].entity(); - - if (element.relations(node_rank).size() == 0) - continue; - if (m_eMesh.isGhostElement(element)) - continue; - - // FIXME - if (m_eMesh.isLeafElement(element)) - { - if (connectSides(&element, &side)) - found = true; - } - if (found) break; - } - if (found) break; - } - - if (!found) - { - std::cout << "ERROR: side = " << side << std::endl; - throw std::logic_error("fix_side_sets_2 error 2"); - } - } - } - - //std::cout << "tmp fix_side_sets_2 ...end" << std::endl; - } - - void Refiner:: - fixElementSides1(stk_classic::mesh::EntityRank side_rank) - { - EXCEPTWATCH; - - // FIXME - cleanup, remove all old code - - //std::cout << "fixElementSides1 " << std::endl; - // we don't check parent child here so we can pick up the original elements - // FIXME - should we have option of checking parent, child, parent|child, etc? - //SidePartMap side_part_map; - //get_side_part_relations(false, side_part_map); - //fix_side_sets_3(true, side_part_map); - fix_side_sets_2(); - - } - - // if the element (element) has a side that matches the given side (side_elem), connect them but first delete old connections - bool Refiner::connectSides(stk_classic::mesh::Entity *element, stk_classic::mesh::Entity *side_elem, SidePartMap *side_part_map) - { - EXCEPTWATCH; - shards::CellTopology element_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*element)); - unsigned element_nsides = (unsigned)element_topo.getSideCount(); - - // check validity of connection - if (side_part_map) - { - bool valid = false; - stk_classic::mesh::PartVector side_parts, elem_parts; - element->bucket().supersets(elem_parts); - side_elem->bucket().supersets(side_parts); - for (unsigned isp = 0; isp < side_parts.size(); isp++) - { - if ( stk_classic::mesh::is_auto_declared_part(*side_parts[isp]) ) - continue; - const CellTopologyData *const topology = stk_classic::percept::PerceptMesh::get_cell_topology(*side_parts[isp]); - if (!topology) - continue; - - SidePartMap::iterator found = side_part_map->find(side_parts[isp]->name()); - if (found == side_part_map->end()) - { - //std::cout << "side_part = " << side_parts[isp]->name() << std::endl; - //throw std::runtime_error("Refiner::connectSides: couldn't find side map part"); - continue; - } - std::string& elem_part_name = found->second; - for (unsigned iep = 0; iep < elem_parts.size(); iep++) - { - if ( stk_classic::mesh::is_auto_declared_part(*elem_parts[iep]) ) - continue; - if (elem_parts[iep]->name() == elem_part_name) - //if (elem_parts[iep] == found->second) - { - valid = true; - break; - } - } - } - if (!valid) return false; - } - - // special case for shells - int topoDim = UniformRefinerPatternBase::getTopoDim(element_topo); - - bool isShell = false; - if (topoDim < (int)element->entity_rank()) - { - isShell = true; - } - int spatialDim = m_eMesh.get_spatial_dim(); - if (spatialDim == 3 && isShell && side_elem->entity_rank() == m_eMesh.edge_rank()) - { - element_nsides = (unsigned) element_topo.getEdgeCount(); - } - - int permIndex = -1; - int permPolarity = 1; - - unsigned k_element_side = 0; - - // try search - for (unsigned j_element_side = 0; j_element_side < element_nsides; j_element_side++) - { - PerceptMesh::element_side_permutation(*element, *side_elem, j_element_side, permIndex, permPolarity); - if (permIndex >= 0) - { - k_element_side = j_element_side; - break; - } - } - - if (permIndex >= 0) - { - mesh::PairIterRelation rels = side_elem->relations(m_eMesh.element_rank()); - - if (rels.size() > 1) - { - throw std::logic_error("rels.size() > 1"); - } - - if (rels.size()) - { - stk_classic::mesh::Entity *to_rel = rels[0].entity(); - stk_classic::mesh::RelationIdentifier to_id = rels[0].identifier(); - bool del = m_eMesh.get_bulk_data()->destroy_relation( *to_rel, *side_elem, to_id); - if (!del) - throw std::logic_error("connectSides:: destroy_relation failed"); - } - - // special case for shells - if (isShell) - { - // FIXME for 2D - if (side_elem->entity_rank() == m_eMesh.face_rank()) - { - stk_classic::mesh::PairIterRelation elem_sides = element->relations(side_elem->entity_rank()); - unsigned elem_sides_size= elem_sides.size(); - //std::cout << "tmp srk found shell, elem_sides_size= " << elem_sides_size << std::endl; - if (elem_sides_size == 1) - { - stk_classic::mesh::RelationIdentifier rel_id = elem_sides[0].identifier(); - if (rel_id > 1) - throw std::logic_error("connectSides:: logic 1"); - k_element_side = (rel_id == 0 ? 1 : 0); - //std::cout << "tmp srk k_element_side= " << k_element_side << " rel_id= " << rel_id << std::endl; - } - } - } - - m_eMesh.get_bulk_data()->declare_relation(*element, *side_elem, k_element_side); - return true; - } - else - { - // error condition? - //throw std::runtime_error("fixElementSides2: couldn't find a matching face"); - return false; - } - } - - - void Refiner:: - fixElementSides2() - { - EXCEPTWATCH; - //std::cout << "fixElementSides2 start... " << std::endl; - - stk_classic::mesh::EntityRank side_rank = m_eMesh.side_rank(); - - bool notFound = true; - for (unsigned ibp = 0; ibp < m_breakPattern.size(); ibp++) - { - // only check the side elements - if (m_breakPattern[ibp]->getPrimaryEntityRank() == side_rank) - { - notFound = false; - } - } - if (notFound) - { - std::cout << "Refiner::fixElementSides2: missing sub-dim break pattern - logic error\n" - " ---- for this refinement pattern to be able to handle sidesets and edgesets you must provide the sub-dim break pattern\n" - " ---- or you must set the setIgnoreSideSets() flag " << std::endl; - throw std::logic_error("Refiner::fixElementSides2: missing sub-dim break pattern - logic error"); - return; - } - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - if (m_eMesh.hasFamilyTree(element) && m_eMesh.isParentElementLeaf(element) && !m_eMesh.isGhostElement(element)) - { - stk_classic::mesh::Entity* parent = &element; - - fixSides(parent); - } - } - } - - //std::cout << "fixElementSides2 ...end " << std::endl; - - fix_side_sets_1(); - - } - - void Refiner::fixSides(stk_classic::mesh::Entity *parent) - { - - std::vector children; - VERIFY_OP_ON(m_eMesh.hasFamilyTree(*parent), == , true, "error 101"); - m_eMesh.getChildren(*parent, children); - - // if parent has any side relations, check if any of the sides' children match the parent's children's faces - mesh::PairIterRelation parent_sides = parent->relations(m_eMesh.side_rank()); - - for (unsigned i_parent_side = 0; i_parent_side < parent_sides.size(); i_parent_side++) - { - stk_classic::mesh::Entity *parent_side = parent_sides[i_parent_side].entity(); - - //VERIFY_OP_ON(parent_side->entity_rank(), ==, side_rank, "side ranks mismatch"); - - // parent_side has no children - if (m_eMesh.isLeafElement(*parent_side)) - { - // find a child of parent to hook to the parent_side, enforce it must find one, replace old ones - for (unsigned i_child = 0; i_child < children.size(); i_child++) - { - stk_classic::mesh::Entity *child = children[i_child]; - - connectSides(child, parent_side); - } - } - else - { - std::vector parent_side_children; - m_eMesh.getChildren(*parent_side, parent_side_children); - - for (unsigned i_parent_side_child = 0; i_parent_side_child < parent_side_children.size(); i_parent_side_child++) - { - // the child of the parent's side - stk_classic::mesh::Entity *parent_side_child = parent_side_children[i_parent_side_child]; - - // loop over each child associated with parent - for (unsigned i_child = 0; i_child < children.size(); i_child++) - { - stk_classic::mesh::Entity *child = children[i_child]; - - connectSides(child, parent_side_child); - } - } - } - } - } - - -#endif - - void Refiner:: - fixElementSides(stk_classic::mesh::EntityRank side_rank) - { - - } - -#undef EXTRA_PRINT_UR_FES - - /** Sets orientations and associativity of elements to sub-dimensional faces/edges after refinement. - */ - void Refiner:: - checkFixElementSides(stk_classic::mesh::EntityRank side_rank, stk_classic::mesh::EntityRank elem_rank) - { - } - - void Refiner::removeFamilyTrees() - { - EXCEPTWATCH; - - elements_to_be_destroyed_type elements_to_be_destroyed; - - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - const vector & buckets = m_eMesh.get_bulk_data()->buckets( FAMILY_TREE_RANK ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - stk_classic::mesh::Entity* element_p = &element; - -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - elements_to_be_destroyed.push_back(element_p); -#else - elements_to_be_destroyed.insert(element_p); -#endif - } - } - } - //std::cout << "tmp P[" << m_eMesh.get_rank() << "] removing family_trees, size() = " << elements_to_be_destroyed.size() << std::endl; - removeElements(elements_to_be_destroyed); - } - - void Refiner:: - removeOldElements(unsigned irank, stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern) - { - EXCEPTWATCH; - - const mesh::Part *oldPart = m_eMesh.getPart(breakPattern->getOldElementsPartName()+toString(rank)); - - if (1 && oldPart) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*oldPart); - std::string ct_name = (cell_topo_data ? cell_topo_data->name : ""); - //std::cout << "tmp removeOldElements::name= " << oldPart->name() << " for rank= " << rank << " topology= " << ct_name << std::endl; - } - - if (!oldPart) - { - std::cout << "name= " << breakPattern->getOldElementsPartName()+toString(rank) << std::endl; - throw std::runtime_error("oldPart is null"); - } - - mesh::Selector removePartSelector (*oldPart); - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( rank ); - - elements_to_be_destroyed_type elements_to_be_destroyed; - -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - unsigned nel = 0u; - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - nel += num_elements_in_bucket; - } - } - elements_to_be_destroyed.reserve(nel); -#endif - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - if (0) - { - std::string str; - stk_classic::mesh::PartVector pv; - bucket.supersets(pv); - for (unsigned ip = 0; ip < pv.size(); ip++) - { - str += " "+pv[ip]->name(); - } - std::cout << "P[" << m_eMesh.get_rank() << "] removing elements in bucket of parts: " << str << std::endl; - } - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - stk_classic::mesh::Entity* element_p = &element; - - if (!m_eMesh.isGhostElement(element)) - { -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - elements_to_be_destroyed.push_back(element_p); -#else - elements_to_be_destroyed.insert(element_p); -#endif - //std::cout << "tmp removing elem = " << *element_p << " "; - //m_eMesh.print_entity(std::cout, *element_p); - } - } - } - } - removeElements(elements_to_be_destroyed, irank); - - } - - void Refiner::removeElements(elements_to_be_destroyed_type& elements_to_be_destroyed, unsigned irank) - { - elements_to_be_destroyed_type elements_to_be_destroyed_pass2; - - if (m_doProgress) - { - std::ostringstream oss; oss << "Delete Original Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::INIT, 0.0, oss.str()); - notifyObservers(&pd); - } - unsigned num_elem = 0; - int progress_meter_num_total = elements_to_be_destroyed.size(); - int progress_meter_when_to_post = progress_meter_num_total / m_progress_meter_frequency; - if (0 == progress_meter_when_to_post) - progress_meter_when_to_post = 1; - double d_progress_meter_num_total = progress_meter_num_total; - - for (elements_to_be_destroyed_type::iterator itbd = elements_to_be_destroyed.begin(); itbd != elements_to_be_destroyed.end(); ++itbd) - { - stk_classic::mesh::Entity *element_p = *itbd; - - if (m_doProgress && (num_elem % progress_meter_when_to_post == 0) ) - { - double progress_meter_percent = 100.0*((double)num_elem)/std::max(d_progress_meter_num_total,1.0); - std::ostringstream oss; oss << "Delete Original Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::RUNNING, progress_meter_percent, oss.str()); - notifyObservers(&pd); - } - - ++num_elem; - - if (0) - { - std::cout << "tmp removeElements removing element_p = " << element_p << std::endl; - if (element_p) std::cout << "tmp removeElements removing id= " << element_p->identifier() << std::endl; - } - - if ( ! m_eMesh.get_bulk_data()->destroy_entity( element_p ) ) - { -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - elements_to_be_destroyed_pass2.push_back(element_p); -#else - elements_to_be_destroyed_pass2.insert(element_p); -#endif - //throw std::logic_error("Refiner::removeElements couldn't remove element"); - - } - } - - if (m_doProgress) - { - std::ostringstream oss; oss << "Delete Original Elements pass [" << 100.0*((double)irank)/((double)m_ranks.size()) << " %]"; - ProgressMeterData pd(ProgressMeterData::FINI, 0.0, oss.str()); - notifyObservers(&pd); - } - - //std::cout << "tmp Refiner::removeElements pass2 size = " << elements_to_be_destroyed_pass2.size() << std::endl; - for (elements_to_be_destroyed_type::iterator itbd = elements_to_be_destroyed_pass2.begin(); - itbd != elements_to_be_destroyed_pass2.end(); ++itbd) - { - stk_classic::mesh::Entity *element_p = *itbd; - if ( ! m_eMesh.get_bulk_data()->destroy_entity( element_p ) ) - { - shards::CellTopology cell_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*element_p)); - std::cout << "tmp Refiner::removeElements couldn't remove element in pass2,...\n tmp destroy_entity returned false: cell= " << cell_topo.getName() << std::endl; - const mesh::PairIterRelation elem_relations = element_p->relations(element_p->entity_rank()+1); - std::cout << "tmp elem_relations.size() = " << elem_relations.size() << std::endl; - - throw std::logic_error("Refiner::removeElements couldn't remove element, destroy_entity returned false."); - } - } - } - - /// fix names of surfaces (changing for example surface_hex8_quad4 to surface_tet4_tri3) - void Refiner:: - fixSurfaceAndEdgeSetNames(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern) - { - EXCEPTWATCH; - stk_classic::mesh::PartVector toParts = breakPattern->getToParts(); - - //std::cout << "toParts.size()= " << toParts.size() << " typeid= " << typeid(*breakPattern).name() << std::endl; - - for (unsigned i_part = 0; i_part < toParts.size(); i_part++) - { - //const std::string & partName = toParts[i_part]->name(); - std::string * toPartName_p = const_cast (&toParts[i_part]->name()); - - std::string toPartName = toParts[i_part]->name(); - if ( toPartName.find("surface_", 0) == std::string::npos) - { - if (0) std::cout << "tmp fixSurfaceAndEdgeSetNames:: skipping toPartName= " << toPartName << " typeid= " << typeid(*breakPattern).name() << std::endl; - continue; - } - - std::string newToPartName = toPartName; - - StringStringMap::iterator map_it; - StringStringMap str_map = breakPattern->fixSurfaceAndEdgeSetNamesMap(); - if (0) std::cout << "tmp fixSurfaceAndEdgeSetNamesMap:: str_map.size()= " << str_map.size() - //<< " " << breakPattern->getFromTopoPartName() << "__" << breakPattern->getToTopoPartName() - << " typeid= " << typeid(*breakPattern).name() - << std::endl; - - for (map_it = str_map.begin(); map_it != str_map.end(); map_it++) - { - std::string from_str = map_it->first; - std::string to_str = map_it->second; - Util::replace(newToPartName, from_str, to_str); - if (0) - std::cout << "tmp fixSurfaceAndEdgeSetNamesMap: old= " << toPartName << " new= " << newToPartName << std::endl; - } - - *toPartName_p = newToPartName; - - if (0) - std::cout << "tmp fixSurfaceAndEdgeSetNamesMap:: P[" << m_eMesh.get_rank() << "] new part name= " << toParts[i_part]->name() - << " old part name = " << toPartName - << std::endl; - } - } - - // FIXME this is a hack to rename parts - /// Renames as follows: - /// originalPartName -> originalPartName_uo_1000 The original part holds the elements to be converted, and is renamed to be the "old" part - /// originalPartName_urpconv -> originalPartName The new part has the same name as the original part with urpconv appended, which - /// is then changed back to the original part name - /// fromPartName -> fromPartName+"_uo_1000" - /// toPartName_urpconv -> toPartName - /// - /// So, after the renaming, the original part name holds the new elements, and the original elements are - /// in the part with the original name appended with _uo_1000. These parts are ignored on subsequent input. - /// -#define DEBUG_RENAME_NEW_PARTS 0 - void Refiner:: - renameNewParts(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern) - { - EXCEPTWATCH; - - stk_classic::mesh::PartVector toParts = breakPattern->getToParts(); - stk_classic::mesh::PartVector fromParts = breakPattern->getFromParts(); - - if (DEBUG_RENAME_NEW_PARTS) - { - for (unsigned i_part = 0; i_part < toParts.size(); i_part++) - { - std::cout << "tmp toParts[i_part]->name() = " << toParts[i_part]->name() << std::endl; - } - for (unsigned i_part = 0; i_part < fromParts.size(); i_part++) - { - std::cout << " fromParts[i_part]->name() = " << fromParts[i_part]->name() << std::endl; - } - } - - if (fromParts.size() == toParts.size()) - { - for (unsigned i_part = 0; i_part < toParts.size(); i_part++) - { - if (DEBUG_RENAME_NEW_PARTS) std::cout << "tmp before: fromPartName= " << fromParts[i_part]->name() - << " toPartName= " << toParts[i_part]->name() << std::endl; - - std::string * toPartName_p = const_cast (&toParts[i_part]->name()); - std::string toPartName = toParts[i_part]->name(); - if (toParts[i_part]->name() == fromParts[i_part]->name()) - { - continue; - } - std::string fromPartName = toPartName; - int len = fromPartName.length(); - int clen = breakPattern->getAppendConvertString().length(); - fromPartName.erase(len - clen, clen); - //mesh::Part *fromPart = m_eMesh.get_non_const_part(fromPartName); - mesh::Part *fromPart = fromParts[i_part]; - VERIFY_OP_ON(fromPart, !=, 0, std::string("Refiner::renameNewParts null fromPart found, fromPart= ")+fromPartName); - std::string * fromPartName_p = const_cast (&fromPart->name()); - *toPartName_p = fromPartName; - *fromPartName_p = fromPartName + breakPattern->getAppendOriginalString(); - - if (DEBUG_RENAME_NEW_PARTS) { - std::cout << "tmp after: fromPartName= " << fromParts[i_part]->name() << " toPartName= " << toParts[i_part]->name() << std::endl; - std::cout << "tmp P[" << m_eMesh.get_rank() << "] fromPartName: " << fromPartName << " part= " << toParts[i_part]->name() - << " old part name = " << fromPart->name() - << std::endl; - } - } - } - else - { - for (unsigned i_part = 0; i_part < fromParts.size(); i_part++) - { - if (DEBUG_RENAME_NEW_PARTS) std::cout << "tmp before: fromPartName= " << fromParts[i_part]->name() << std::endl; - std::string * fromPartName_p = const_cast (&fromParts[i_part]->name()); - *fromPartName_p = fromParts[i_part]->name() + breakPattern->getAppendOriginalString(); - if (DEBUG_RENAME_NEW_PARTS) { - std::cout << "tmp after: fromPartName= " << fromParts[i_part]->name() << std::endl; - } - } - - for (unsigned i_part = 0; i_part < toParts.size(); i_part++) - { - if (DEBUG_RENAME_NEW_PARTS) std::cout << "tmp before: toPartName= " << toParts[i_part]->name() << std::endl; - - std::string * toPartName_p = const_cast (&toParts[i_part]->name()); - std::string toPartName = toParts[i_part]->name(); - if (toPartName.find(breakPattern->getAppendConvertString()) == std::string::npos) - continue; - int len = toPartName.length(); - int clen = breakPattern->getAppendConvertString().length(); - toPartName.erase(len - clen, clen); - *toPartName_p = toPartName; - - if (DEBUG_RENAME_NEW_PARTS) { - std::cout << "tmp after: toPartName= " << toParts[i_part]->name() << std::endl; - } - } - } - } - - - std::vector< RefinementInfoByType >& - Refiner:: - getRefinementInfoByType() - { - return m_refinementInfoByType; - } - - void - Refiner:: - setQueryPassOnly(bool doQueryOnly) - { - m_doQueryOnly = doQueryOnly; - } - - - void Refiner::set_active_part() - { - // deal with parts - stk_classic::mesh::Part* child_elements_part = m_eMesh.get_non_const_part("refine_active_elements_part"); - stk_classic::mesh::Part* parent_elements_part = m_eMesh.get_non_const_part("refine_inactive_elements_part"); - if (child_elements_part && parent_elements_part) - { - //m_eMesh.get_bulk_data()->modification_begin(); - std::vector child_parts(1, child_elements_part); - std::vector parent_parts(1, parent_elements_part); - //mesh::Selector in_child_part(*child_elements_part); - mesh::Selector on_locally_owned_part = ( m_eMesh.get_fem_meta_data()->locally_owned_part() ); - - std::vector child_entities; - std::vector parent_entities; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - if (on_locally_owned_part(bucket)) - { - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - if (m_eMesh.hasFamilyTree(element) && m_eMesh.isParentElement(element, true)) - { - //if (in_child_part(element)) - { - parent_entities.push_back(&element); - } - } - else - { - //if (!in_child_part(element)) - { - child_entities.push_back(&element); - } - } - } - - } - } - - //std::cout << "tmp Refiner::set_active_part: child_entities= " << child_entities.size() << " parent_entities= " << parent_entities.size() << std::endl; - for (unsigned iv=0; iv < child_entities.size(); iv++) - { - m_eMesh.get_bulk_data()->change_entity_parts( *child_entities[iv], child_parts, parent_parts ); - } - for (unsigned iv=0; iv < parent_entities.size(); iv++) - { - m_eMesh.get_bulk_data()->change_entity_parts( *parent_entities[iv], parent_parts, child_parts ); - } - - /* for future - if (!m_doIOSaveInactiveElements) - { - m_eMesh.set_io_omitted_parts(parent_parts); - } - */ - //m_eMesh.get_bulk_data()->modification_end(); - } - - } - - // ======================================================================================================================== - // ======================================================================================================================== - // ======================================================================================================================== - - - void Refiner::check_db(std::string msg) - { - std::cout << "P[" << m_eMesh.get_rank() << "] tmp check_db msg= " << msg << std::endl; - check_db_entities_exist(msg); - check_db_ownership_consistency(msg); - std::cout << "P[" << m_eMesh.get_rank() << "] tmp check_db done msg= " << msg << std::endl; - //check_db_hanging_nodes(); - } - - - void Refiner::check_db_entities_exist(std::string msg) - { - std::vector ranks_to_check; - ranks_to_check.push_back(m_eMesh.node_rank()); - ranks_to_check.push_back(m_eMesh.element_rank()); - for (unsigned irank=0; irank < ranks_to_check.size(); irank++) - { - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( ranks_to_check[irank] ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - stk_classic::mesh::Entity *element_1 = m_eMesh.get_bulk_data()->get_entity(ranks_to_check[irank], element.identifier()); - if (&element != element_1 || element.identifier() != element_1->identifier()) - { - std::cout << "msg= " << msg << " error element, element_1, ids= " - << &element << " " << element_1 << " " << element.identifier() << " " << element_1->identifier() << std::endl; - throw std::logic_error("check_db_entities_exist:: error #1"); - } - - } - } - } - } - - void Refiner::check_db_ownership_consistency(std::string msg) - { - SubDimCellToDataMap& cell_2_data_map = m_nodeRegistry->getMap(); - - for (SubDimCellToDataMap::iterator cell_iter = cell_2_data_map.begin(); cell_iter != cell_2_data_map.end(); ++cell_iter) - { - SubDimCellData& nodeId_elementOwnderId = (*cell_iter).second; - stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(nodeId_elementOwnderId.get()); - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned owning_elementRank = stk_classic::mesh::entity_rank(nodeId_elementOwnderId.get()); - - if (nodeIds_onSE.size()) - { - - if (!owning_elementId) - throw std::logic_error("check_db_ownership_consistency:: error #1 msg= "+msg); - - stk_classic::mesh::Entity * owning_element = m_eMesh.get_bulk_data()->get_entity(owning_elementRank, owning_elementId); - - if (!owning_element) - { - std::cout << "P[" << m_eMesh.get_rank() << "] " - << " error check_db_ownership_consistency: msg= " << msg << " owning_elementId= " << owning_elementId << std::endl; - throw std::logic_error("check_db_ownership_consistency:: error #2, msg= "+msg); - } - - if (stk_classic::mesh::EntityLogDeleted == owning_element->log_query() ) - { - std::cout << "P[" << m_eMesh.get_rank() << "] " - << " error check_db_ownership_consistency: EntityLogDeleted, msg= " << msg << " owning_elementId= " << owning_elementId << std::endl; - throw std::logic_error("check_db_ownership_consistency:: error #2.0, msg= "+msg); - } - - - if (owning_element->identifier() != owning_elementId) - { - std::cout << "msg= " << msg << " check_db_ownership_consistency error element, element_1, ids= " - << owning_elementId << " " << owning_element->identifier() << std::endl; - throw std::logic_error("check_db_ownership_consistency:: error #1.1, msg= "+msg); - } - - if (!m_eMesh.isGhostElement(*owning_element)) - { - - for (unsigned inode = 0; inode < nodeIds_onSE.size(); inode++) - { - stk_classic::mesh::Entity *node = nodeIds_onSE[inode]; - if (!node) - throw std::logic_error("check_db_ownership_consistency:: error #3, msg= "+msg); - - stk_classic::mesh::Entity * node1 = m_eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE.m_entity_id_vector[inode]); - if (!node1) - throw std::logic_error("check_db_ownership_consistency:: error #3a, msg= "+msg); - - stk_classic::mesh::Entity * node2 = m_eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, node->identifier() ); - if (!node2) - throw std::logic_error("check_db_ownership_consistency:: error #3b, msg= "+msg); - if (node != node2) - throw std::logic_error("check_db_ownership_consistency:: error #3c, msg= "+msg); - - } - } - } - } - } - - void Refiner::check_db_hanging_nodes() - { - std::set node_set; - - // check for hanging nodes - ensure all parents have their sub-entities in the DB - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - if (m_eMesh.hasFamilyTree(element) && m_eMesh.isParentElement(element, false)) - { - for (unsigned irank=0; irank < m_ranks.size(); irank++) - { - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - shards::CellTopology cell_topo(cell_topo_data); - unsigned elementType = cell_topo.getKey(); - unsigned bpElementType = m_breakPattern[irank]->getFromTypeKey(); - if (elementType == bpElementType) - { - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - static SubDimCellData empty_SubDimCellData; - SubDimCell_SDSEntityType subDimEntity; - m_nodeRegistry->getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - - SubDimCellData* nodeId_elementOwnderId_ptr = m_nodeRegistry->getFromMapPtr(subDimEntity); - SubDimCellData& nodeId_elementOwnderId = (nodeId_elementOwnderId_ptr ? *nodeId_elementOwnderId_ptr : empty_SubDimCellData); - bool is_empty = nodeId_elementOwnderId_ptr == 0; - if (!is_empty) - { - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - if (nodeIds_onSE.size() == 0) - { - if (1) std::cout << "error check_db_hanging_nodes irank = " << irank << " ranks[irank] = " << m_ranks[irank] - << " elementType= " << elementType - << " cell_topo= " << cell_topo.getName() - << std::endl; - - throw std::logic_error("check_db_hanging_nodes:: error #1"); - } - } - - /*if (nodeIds_onSE.size() != 0) - { - //std::cout << "tmp" << std::endl; - - } - */ - - } - } - } - } - } - } - } - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.hpp deleted file mode 100644 index 8b06bf488b52..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/Refiner.hpp +++ /dev/null @@ -1,389 +0,0 @@ -#ifndef stk_adapt_Refiner_hpp -#define stk_adapt_Refiner_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#endif - -#define UNIFORM_REF_REMOVE_OLD_STD_SET 1 -#define UNIFORM_REF_REMOVE_OLD_STD_VECTOR 0 -#define UNIFORM_REF_REMOVE_OLD_BOOST_SET 0 - -#if UNIFORM_REF_REMOVE_OLD_BOOST_SET -#include -#endif - - -namespace stk_classic { - namespace adapt { - - typedef std::set ElementUnrefineCollection; - //typedef std::map SidePartMap; - typedef std::map SidePartMap; - - using std::vector; - using std::map; - using std::set; - - -#if UNIFORM_REF_REMOVE_OLD_STD_SET - typedef std::set elements_to_be_destroyed_type; -#endif -#if UNIFORM_REF_REMOVE_OLD_STD_VECTOR - typedef std::vector elements_to_be_destroyed_type; -#endif -#if UNIFORM_REF_REMOVE_OLD_BOOST_SET - typedef boost::unordered_set elements_to_be_destroyed_type; -#endif - - - /// e.g. UniformRefiner, shards::Tet<4> > - //template -#if 0 - class ParallelMeshModAlgorithm - { - public: - virtual void planActions()=0; - virtual void performActions()=0; - protected: - void helperFunction1(); - void helperFunction2(); - //... - }; -#endif - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - //template - class Refiner -#ifndef SWIG //NLM - : public stk_classic::percept::Observable -#endif - { - public: - Refiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - Refiner(percept::PerceptMesh& eMesh, Pattern refine_type, stk_classic::mesh::FieldBase *proc_rank_field=0); - //Refiner(percept::PerceptMesh& eMesh, std::vector& bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - virtual ~Refiner(); - - void - doBreak(); - - void - setRemoveOldElements(bool do_remove); - bool - getRemoveOldElements(); - - /* for future - void - setIOSaveInactiveElements(bool do_save) { m_doIOSaveInactiveElements = do_save; } - bool - getIOSaveInactiveElements() { return m_doIOSaveInactiveElements; } - */ - - void - setGeometryFile(std::string file_name); - - void - setSmoothGeometry(bool do_smooth) { m_doSmoothGeometry = do_smooth; } - bool - getSmoothGeometry() { return m_doSmoothGeometry; } - - void - setRemoveGeometryBlocks(bool do_remove) { m_removeGeometryBlocks = do_remove; } - bool - getRemoveGeometryBlocks() { return m_removeGeometryBlocks; } - - void - setIgnoreSideSets(bool ignore_sidesets) ; - - bool - getIgnoreSideSets(); - - std::vector< RefinementInfoByType >& - getRefinementInfoByType(); - - void - setQueryPassOnly(bool doQueryOnly); - - void - setDoProgressMeter(bool do_progress); - bool - getDoProgressMeter(); - - - // ================================ unrefine - - typedef std::set NodeSetType; - typedef std::set SetOfEntities; - - - void - unrefineTheseElements(ElementUnrefineCollection& elements_to_unref); - - void - unrefineAll(); - - void - setAlwaysInitializeNodeRegistry(bool do_init) { m_alwaysInitNodeRegistry = do_init; } - - bool - getAlwaysInitializeNodeRegistry() { return m_alwaysInitNodeRegistry; } - -#if defined( STK_PERCEPT_HAS_MESQUITE ) && defined(STK_PERCEPT_HAS_GEOMETRY) - - enum SMOOTHING_OPTIONS { - // snaps and discards original coord field, tries to smooth - SNAP_PLUS_SMOOTH, - // keeps original and snapped states; does line search between; tries to keep always-valid mesh - USE_LINE_SEARCH_WITH_MULTIPLE_STATES - //,END_OPTIONS - }; - - void smoothGeometry(MeshGeometry& mesh_geometry, SMOOTHING_OPTIONS option); -#endif - - void snapAndSmooth(bool geomSnap, std::string geomFile); - - void deleteParentElements(); - - void check_db(std::string msg="") ; - - void check_sidesets(std::string msg=""); - void check_sidesets_1(std::string msg); - void check_sidesets_2(std::string msg); - void fix_side_sets_1(); - void fix_side_sets_2(); - void fix_side_sets_3(bool checkParentChild, SidePartMap& side_part_map); - - /// determine side part to elem part relations - void get_side_part_relations(bool checkParentChild, SidePartMap& side_part_map); - - bool connectSides(stk_classic::mesh::Entity *element, stk_classic::mesh::Entity *side_elem, SidePartMap* side_part_map=0); - void fixElementSides2(); - void fixSides(stk_classic::mesh::Entity *parent); - - NodeRegistry& getNodeRegistry() { return *m_nodeRegistry; } - percept::PerceptMesh& getMesh() { return m_eMesh; } - protected: - - //============= unrefine - void - filterUnrefSet(ElementUnrefineCollection& elements_to_unref); - - void - getKeptNodes(NodeSetType& kept_nodes, ElementUnrefineCollection& elements_to_unref); - - void - getDeletedNodes(NodeSetType& deleted_nodes, const NodeSetType& kept_nodes, ElementUnrefineCollection& elements_to_unref); - - - void - removeDeletedNodes(NodeSetType& deleted_nodes); - - void getChildrenToBeRemoved(ElementUnrefineCollection& elements_to_unref, - SetOfEntities& children_to_be_removed, SetOfEntities& children_to_be_removed_with_ghosts, - SetOfEntities& copied_children_to_be_removed, - SetOfEntities& family_trees_to_be_removed, - SetOfEntities& parent_elements); - - void removeFamilyTrees(SetOfEntities& family_trees_to_be_removed); - - - void getSideElemsToBeRemoved(SetOfEntities& children_to_be_removed, SetOfEntities& side_elem_set_to_be_removed, SetOfEntities& family_trees_to_be_removed, SetOfEntities& parent_side_elements); - - void removeChildElements(SetOfEntities& children_to_be_removed); - - void removeSideElements(SetOfEntities& side_elem_set_to_be_removed, SetOfEntities& elements_to_be_deleted); - - void remesh(SetOfEntities& parent_elements); - //============= unrefine end - - void check_db_ownership_consistency(std::string msg=""); - void check_db_hanging_nodes(); - void check_db_entities_exist(std::string msg=""); - - /** Overrides start =======> - */ - - /** Overrides - * m_nodeRegistry data member. The same loop should be executed every time this method is called (i.e. the same elements should be visited). Also, there - * is policy associated with the @param only_count and @param doAllElements inputs. If doAllElements==true, then ghost elements should not be skipped. - * If only_count==true, then *do not* call the supplied @param function, rather just count the number of elements to be visited and return that number. - * @return Always return the number of elements visited (modulo the doAllElements parameter). - * - * Note: client code can just use the supplied implementation in this base class - it is not necessary to override - * - * @see UniformRefiner implementation of this method for an example. - */ - - virtual unsigned - doForAllElements(unsigned irank, std::string function_info, - stk_classic::mesh::EntityRank rank, NodeRegistry::ElementFunctionPrototype function, - vector< ColorerSetType >& elementColors, unsigned elementType, - vector& needed_entity_ranks, - bool only_count=false, bool doAllElements=true) ; - - /** Create a list of nodes from the new nodes that can be easily deciphered by the UniformRefinerPattern. - * - * This is a helper function that gets all the nodes ready for use in creating new elements. For each rank of those needed by - * the algorithm (supplied information from the break pattern), it fills the 3D array new_sub_entity_nodes with the new nodes. - * - * Returns the 3D array new_sub_entity_nodes[entity_rank_of_entity_or_sub_dim_entity][ordinal_of_sub_dim_entity][ordinal_of_node_on_sub_dim_entity] - * - */ - virtual bool - createNewNeededNodeIds(const CellTopologyData * const cell_topo_data, - const stk_classic::mesh::Entity& element, vector& needed_entity_ranks, NewSubEntityNodesType& nodes) ; - - /** Method that actually creates new elements by first calling createNewNeededNodeIds then calls the break pattern's createNewElements method. - * - * A sample implementation is shown in @see UniformRefiner - */ - virtual void - createElementsAndNodesAndConnectLocal(unsigned irank, stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern, - vector< ColorerSetType >& elementColors, vector& needed_entity_ranks, - vector& new_elements_pool) ; - - /** This is a helper method that loops over all sub-dimensional entities whose rank matches on of those in @param needed_entity_ranks - * and registers that sub-dimensional entity as needing a new node, or whatever other function NodeRegistry requires (getFromRemote(), etc) - * Override it to only apply the @param function to the desired sub-entities (e.g. for non-uniform/local refinement) - * - * It is a copy of NodeRegistry's doForAllSubEntities method. Provided here so it can be overridden. - * - * Note: this is the minimal function that needs to be overridden to get different marking/refining behavior - */ - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - /// =========> Overrides end - - - - void - removeFamilyTrees(); - - void - removeOldElements(unsigned irank, stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern ); - - void - removeElements( elements_to_be_destroyed_type& elements_to_be_destroyed, unsigned irank=0); - - void - removeEmptyElements(); - - // empty nodes (nodes not referred to by any elements) are possibly created during refine, this method removes them - void - removeDanglingNodes(); - - void - addOldElementsToPart(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern, unsigned *elementType = 0u); - - void - removeFromOldPart(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern); - - void - renameNewParts(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern); - - void - fixSurfaceAndEdgeSetNames(stk_classic::mesh::EntityRank rank, UniformRefinerPatternBase* breakPattern); - - void - fixElementSides(); - - void - fixElementSides1(); - - void - fixElementSides(stk_classic::mesh::EntityRank side_rank); - - void - fixElementSides1(stk_classic::mesh::EntityRank side_rank); - - void - checkFixElementSides(stk_classic::mesh::EntityRank side_rank, stk_classic::mesh::EntityRank elem_rank); - - void - buildElementSideDB(SubDimCellToDataMap& cell_2_data_map); - - void - trace_print(std::string msg); - - void - checkBreakPatternValidityAndBuildRanks(std::vector& ranks); - - void - set_active_part(); - - - protected: - percept::PerceptMesh& m_eMesh; - - //UniformRefinerPatternBase & m_breakPattern; - std::vector m_breakPattern; - - NodeRegistry* m_nodeRegistry; - stk_classic::mesh::FieldBase *m_proc_rank_field; - bool m_doRemove; - - // for future: - // bool m_doIOSaveInactiveElements; // default false - - std::vector m_ranks; - bool m_ignoreSideSets; - std::string m_geomFile; - bool m_geomSnap; - - std::vector< RefinementInfoByType > m_refinementInfoByType; - bool m_doQueryOnly; - - int m_progress_meter_frequency; - bool m_doProgress; - - bool m_alwaysInitNodeRegistry; - bool m_doSmoothGeometry; - bool m_allocated; - - bool m_removeGeometryBlocks; - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Line2_Line2_N.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Line2_Line2_N.hpp deleted file mode 100644 index cd51decd9add..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Line2_Line2_N.hpp +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef stk_adapt_RefinerPattern_Line2_Line2_N_sierra_hpp -#define stk_adapt_RefinerPattern_Line2_Line2_N_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class RefinerPattern, shards::Line<2>, -1 > : public URP, shards::Line<2> > - { - public: - - RefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Line<2> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple line_tuple_type; - static vector elems(2); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - - unsigned num_nodes_on_edge = new_sub_entity_nodes[m_eMesh.edge_rank()][0].size(); - if (!num_nodes_on_edge) - return; - - double coord_x[3]; - for (int iedge = 0; iedge < 1; iedge++) - { - //double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - //double * mp = midPoint(FACE_COORD(iedge,0), FACE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - double * mp = midPoint(VERT_COORD(0), VERT_COORD(1), eMesh.get_spatial_dim(), coord_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 " << std::endl; - } - - eMesh.createOrGetNode(EDGE_N(iedge), mp); - } - - // FIXME - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_primaryEntityRank, 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), m_primaryEntityRank, 0u); - - nodeRegistry.interpolateFields(*const_cast(&element), m_primaryEntityRank, 0u); - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - -#ifndef NDEBUG - unsigned num_child = ref_topo.num_child(); - VERIFY_OP(num_child, == , 2, "createNewElements num_child problem"); - bool homogeneous_child = ref_topo.homogeneous_child(); - VERIFY_OP(homogeneous_child, ==, true, "createNewElements homogeneous_child"); -#endif - - // new_sub_entity_nodes[i][j] - //const UInt * const * child_nodes() const { - //const UInt * child_node_0 = ref_topo.child_node(0); - - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - RefTopoX& l2 = Elem::StdMeshObjTopologies::RefinementTopologyExtra< FromTopology > ::refinement_topology; - -#define CENTROID_N NN(m_primaryEntityRank,0) - - for (unsigned iChild = 0; iChild < 2; iChild++) - { - unsigned EN[2]; - for (unsigned jNode = 0; jNode < 2; jNode++) - { - unsigned childNodeIdx = ref_topo.child_node(iChild)[jNode]; -#ifndef NDEBUG - unsigned childNodeIdxCheck = l2[childNodeIdx].ordinal_of_node; - VERIFY_OP(childNodeIdx, ==, childNodeIdxCheck, "childNodeIdxCheck"); -#endif - unsigned inode=0; - - if (l2[childNodeIdx].rank_of_subcell == 0) - inode = VERT_N(l2[childNodeIdx].ordinal_of_subcell); - else if (l2[childNodeIdx].rank_of_subcell == 1) - inode = EDGE_N(l2[childNodeIdx].ordinal_of_subcell); - - // else if (l2[childNodeIdx].rank_of_subcell == 2) - // inode = CENTROID_N; - - EN[jNode] = inode; - } - elems[iChild] = line_tuple_type(EN[0], EN[1]); - } - -#undef CENTROID_N - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - -#if 0 - if (proc_rank_field && proc_rank_field->rank() == m_eMesh.edge_rank()) //&& m_eMesh.get_spatial_dim()==1) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } -#endif - stk_classic::mesh::FieldBase * proc_rank_field_edge = m_eMesh.get_field("proc_rank_edge"); - if (proc_rank_field_edge) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field_edge) , newElement ); - fdata[0] = double(newElement.owner_rank()); - //fdata[0] = 1234.56; - if (0) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp set proc_rank_field_edge to value = " << newElement.owner_rank() - << " for side element = " << newElement.identifier() - << std::endl; - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 " << std::endl; - exit(1); - } - - } - - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tet4_Tet4_N.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tet4_Tet4_N.hpp deleted file mode 100644 index a2cc3f6efe9a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tet4_Tet4_N.hpp +++ /dev/null @@ -1,626 +0,0 @@ -#ifndef stk_adapt_RefinerPattern_Tet4_Tet4_N_sierra_hpp -#define stk_adapt_RefinerPattern_Tet4_Tet4_N_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - -#include - -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" - -/** NOTE: A lot of the following code is unfinished (greedy triangulation scheme). - * The call to triangulate_tet_generic has been replaced with a call to the - * MOAB SimplexTemplateRefiner as modified for Percept/Adapt. - * - * We are leaving this unfinished code in place until the MOAB testing is verified. - */ - -#define PERCEPT_USE_MOAB_REFINER 1 - -namespace stk_classic { - namespace adapt { - - /*---------------------------------------------------------------------*/ - /** From Shards_BasicTopologies.hpp - * - * typedef MakeTypeList< IndexList< 0 , 1 , 4 > , - * IndexList< 1 , 2 , 5 > , - * IndexList< 2 , 0 , 6 > , - * IndexList< 0 , 3 , 7 > , - * IndexList< 1 , 3 , 8 > , - * IndexList< 2 , 3 , 9 > >::type - * TetrahedronEdgeNodeMap ; - * - * typedef MakeTypeList< IndexList< 0 , 1 , 3 , 4 , 8 , 7 > , - * IndexList< 1 , 2 , 3 , 5 , 9 , 8 > , - * IndexList< 0 , 3 , 2 , 7 , 9 , 6 > , - * IndexList< 0 , 2 , 1 , 6 , 5 , 4 > >::type - * TetrahedronSideNodeMap ; - * - * - */ - - /*---------------------------------------------------------------------*/ - /** - * PARENT 4-Node Tetrahedron Object Nodes - * 3 - * o - * /|\ - * / | \ (PARENT) 4-Node Tetrahedron Object - * / | \ Edge Node Map: - * / | \ 0 1 2 3 4 5 - * / | \ { {0, 1}, {1, 2}, {2, 0}, {0, 3}, {1, 3}, {2, 3} }; - * 0 o-----|-----o 2 - * \ | / - * \ | / Face Node Map: - * \ | / - * \ | / { {0, 1, 3}, {1, 2, 3}, {0, 3, 2}, {0, 2, 1} } - * \|/ - * o - * 1 - * - * 3 - * o - * /|\ - * / | \ - * 7 * | * 9 - * / | \ - * / 6| \ - * 0 o----*|-----o 2 - * \ *8 / - * \ | / - * 4 * | * 5 - * \ | / - * \|/ - * o - * 1 - */ - /*---------------------------------------------------------------------*/ - /** Edge (j) of face (i) maps to edge (k) of tet: ==> tet_face_edge_map[4][3] == tet_face_edge_map[i][j] - * - * face 0 {0, 1, 3}: {0, 4, 3} - * face 1 {1, 2, 3}: {1, 5, 4} - * face 2 {0, 3, 2}: {3, 5, 2} - * face 3 {0, 2, 1}: {2, 1, 0} - */ - - static unsigned tbl_tet_face_edge_map[4][3] = { {0, 4, 3}, {1, 5, 4}, {3, 5, 2}, {2, 1, 0} }; - static unsigned tbl_tet_face_nodes[4][3] = { {0, 1, 3}, {1, 2, 3}, {0, 3, 2}, {0, 2, 1} }; - static unsigned tbl_tet_edge_nodes[6][2] = { {0, 1}, {1, 2}, {2, 0}, {0, 3}, {1, 3}, {2, 3} }; - - typedef boost::tuple TetTupleTypeLocal; - typedef boost::tuple TetTupleType; - - /// general refinement pattern - - // the "-1" here signifies the number of elements created is not fixed, depends on the marking pattern - template <> - class RefinerPattern, shards::Tetrahedron<4>, -1 > : public URP,shards::Tetrahedron<4> > - { - - RefinerPattern, shards::Triangle<3>, -1 > * m_face_breaker; - - public: - - RefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<4> >(eMesh), - m_face_breaker(0) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - m_face_breaker = new RefinerPattern, shards::Triangle<3>, -1 > (eMesh, block_names) ; - - } - - ~RefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - bp[0] = this; - bp[1] = m_face_breaker; - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { -#if 0 - // FIXME - tmp, for now to create a centroid node which we delete later - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 1u; - needed_entities[1].first = m_eMesh.element_rank(); - needed_entities[1].second = 1u; -#else - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 1u; -#endif - - } - - // FIXME - for now, create more than we need (to fix this right we need a change to the Refiner.cpp interface) - virtual unsigned getNumNewElemPerElem() { return 8; } - - static stk_classic::mesh::Entity* get_new_node(percept::PerceptMesh& eMesh) - { - //stk_classic::mesh::PartVector empty ; - std::vector requested_entities; - eMesh.createEntities(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, 1, requested_entities); - return requested_entities[0]; - } - - // rotate in place so that the minimum node index is first - static void normalize(tri_tuple_type_local& face) - { - //tri_tuple_type_local new_face; - int nodes[3] = {face.get<0>(), face.get<1>(), face.get<2>() }; - int min_node_val = 1000; - int min_node_index = -1; - for (int i = 0; i < 3; i++) - { - if (nodes[i] < min_node_val) - { - min_node_val = nodes[i]; - min_node_index = i; - } - } - face.get<0>() = nodes[min_node_index]; - face.get<1>() = nodes[(min_node_index+1) % 3]; - face.get<2>() = nodes[(min_node_index+2) % 3]; - } - - - static bool is_valid_tet(std::vector& three_faces, TetTupleTypeLocal& valid_tet) - { - bool is_valid = false; - std::set node_set; - for (unsigned i=0; i < 3; i++) - { - node_set.insert(three_faces[i].get<0>()); - node_set.insert(three_faces[i].get<1>()); - node_set.insert(three_faces[i].get<2>()); - } - if (node_set.size() == 4) - { - is_valid = true; - valid_tet.get<0>() = three_faces[0].get<0>(); - valid_tet.get<1>() = three_faces[0].get<1>(); - valid_tet.get<2>() = three_faces[0].get<2>(); - node_set.erase(three_faces[0].get<0>()); - node_set.erase(three_faces[0].get<1>()); - node_set.erase(three_faces[0].get<2>()); - valid_tet.get<3>() = *node_set.begin(); - - // check_volume(valid_tet,... - } - return is_valid; - } - - - static bool check_tet(std::vector& three_faces, TetTupleTypeLocal& valid_tet) - { - // FIXME - return false; - } - - static bool add_face(std::set& tet_faces_local_set, std::vector& tet_faces_local, std::vector& tets) - { - unsigned nface=tet_faces_local.size(); - if (nface < 3) - { - throw std::logic_error("RefinerPattern_Tet4_Tet4_N::add_face: found nface < 3"); - } - std::vector three_faces(3); - for (unsigned i = 0; i < nface-2; i++) - { - // - // double best_quality = 1e30; ... FIXME - // - for (unsigned j = i+1; j < nface-1; j++) - { - for (unsigned k = j+1; k < nface; k++) - { - three_faces[0] = tet_faces_local[i]; - three_faces[1] = tet_faces_local[j]; - three_faces[2] = tet_faces_local[k]; - TetTupleTypeLocal valid_tet; - bool is_valid_tet = check_tet(three_faces, valid_tet); - if (is_valid_tet) - { - tets.push_back(valid_tet); - unsigned nodes[4] = {valid_tet.get<0>(), valid_tet.get<1>(), valid_tet.get<2>(), valid_tet.get<3>() }; - for (int iface = 0; iface < 4; iface++) - { - tri_tuple_type_local tet_face(nodes[tbl_tet_face_nodes[iface][0]], - nodes[tbl_tet_face_nodes[iface][1]], - nodes[tbl_tet_face_nodes[iface][2]] ); - normalize(tet_face); - tet_faces_local_set.insert(tet_face); - } - for (int iface = 0; iface < 3; iface++) - { - tet_faces_local_set.erase(three_faces[iface]); - } - tet_faces_local = std::vector(tet_faces_local_set.begin(), tet_faces_local_set.end()); - return true; - } - } - } - } - return false; - } - - static void triangulate_tet_generic(std::vector& tet_faces, double * centroid_coord, double *node_coords[10], std::vector& tets) - { -#if PERCEPT_USE_MOAB_REFINER - -#else - // algorithm is a greedy triangulation scheme: - // 1. form triples of external faces (initialize tet_faces_local from @param tet_faces) - // 2. if a triple forms a valid tet (i.e. it has positive volume and shares exactly 4 nodes): - // a. output it into @param tets - // b. remove its faces from tet_faces_local, add any face not originally tet_faces_local to tet_faces_local to - // maintain tet_faces_local as the list of external faces - // - // Note: forming triples is brute-force below, but could easily be optimized by using a node-neighbors map - tets.resize(0); - TetTupleTypeLocal valid_tet(0,0,0,0); - - std::set tet_faces_local_set(tet_faces.begin(), tet_faces.end()); - std::vector tet_faces_local = tet_faces; - - int iloop=0; - while (tet_faces_local_set.size()) - { - add_face(tet_faces_local_set, tet_faces_local, tets); - ++iloop; - if (iloop > 1000) - throw std::logic_error("RefinerPattern_Tet4_Tet4_N::add_face: iloop"); - } -#endif - } - - - /** - * - * Convention: input is the element's nodes and the marks on the 6 edges. Output is an array - * of "elements" defined as local id's of nodes forming those elements, where {0,1,2,3} represent - * the original vertices and {4,..,9} are the edges: - * - * - * 3 - * o - * /|\ - * / | \ - * 7 * | * 9 - * / | \ - * / 6| \ - * 0 o----*|-----o 2 - * \ *8 / - * \ | / - * 4 * | * 5 - * \ | / - * \|/ - * o - * 1 - */ - - - -#define TET_VERT_N(i) (i) -#define TET_EDGE_N(i) ((i)+4) - - static void triangulate_tet(PerceptMesh& eMesh, stk_classic::mesh::Entity *tet_elem_nodes[4], unsigned edge_marks[6], - std::vector& tets) - { - - const CellTopologyData * const cell_topo_data = shards::getCellTopologyData< shards::Tetrahedron<4> >(); - - shards::CellTopology cell_topo(cell_topo_data); - //VectorFieldType* coordField = eMesh.get_coordinates_field(); - - unsigned num_edges_marked=0; - for (int iedge = 0; iedge < 6; iedge++) - { - unsigned num_nodes_on_edge = edge_marks[iedge]; - if (num_nodes_on_edge) - { - ++num_edges_marked; - } - } - - if (0) - std::cout << "tmp RefinerPattern_Tet4_Tet4_N::num_edges_marked= " << num_edges_marked << std::endl; - - // uniform refinement - if (num_edges_marked == 6) - { - tets.resize(8); - - // FIXME - use MOAB - - // FIXME - use StdMeshObjTopologies directly - //stk_classic::adapt::Elem::MeshObjTopology mesh_obj_topo; - //const RefinementTopology *ref_topo = mesh_obj_topo.getRefinementTopology(Elem::CellTopology(cell_topo)); - - /** - * - * CHILD 4-Node Tetrahedron 3D Object Node Maps: - * | - * | static const UInt child_0[] = { 0, 4, 6, 7 }; // srkenno 091410 fixed (used to be {0, 4, 8, 7} ) - * | static const UInt child_1[] = { 4, 1, 5, 8 }; - * | static const UInt child_2[] = { 6, 5, 2, 9 }; - * | static const UInt child_3[] = { 7, 8, 9, 3 }; - * | static const UInt child_4[] = { 8, 7, 6, 4 }; - * | static const UInt child_5[] = { 6, 9, 8, 5 }; - * | static const UInt child_6[] = { 9, 8, 7, 6 }; - * | static const UInt child_7[] = { 5, 6, 4, 8 }; - * | - */ - - tets[0] = TetTupleTypeLocal( 0, 4, 6, 7 ); - tets[1] = TetTupleTypeLocal( 4, 1, 5, 8 ); - tets[2] = TetTupleTypeLocal( 6, 5, 2, 9 ); - tets[3] = TetTupleTypeLocal( 7, 8, 9, 3 ); - tets[4] = TetTupleTypeLocal( 8, 7, 6, 4 ); - tets[5] = TetTupleTypeLocal( 6, 9, 8, 5 ); - tets[6] = TetTupleTypeLocal( 9, 8, 7, 6 ); - tets[7] = TetTupleTypeLocal( 5, 6, 4, 8 ); - } - else if (num_edges_marked == 0) - { - return; - } - // general case - else - { - if (PERCEPT_USE_MOAB_REFINER) - { - double * node_coords[4]; - for (int inode=0; inode < 4; inode++) - { - node_coords[inode] = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *tet_elem_nodes[inode] ); - if (0) std::cout << "tmp RP node_coords= " - << node_coords[inode][0] << " " - << node_coords[inode][1] << " " - << node_coords[inode][2] << std::endl; - } - - std::vector new_tets; - moab::SimplexTemplateRefiner str; - str.refine_3_simplex(new_tets, edge_marks, 1, - node_coords[0], 0, tet_elem_nodes[0]->identifier(), - node_coords[1], 0, tet_elem_nodes[1]->identifier(), - node_coords[2], 0, tet_elem_nodes[2]->identifier(), - node_coords[3], 0, tet_elem_nodes[3]->identifier() ); - - if (0) - { - for (int inode=0; inode < 4; inode++) - { - node_coords[inode] = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *tet_elem_nodes[inode] ); - std::cout << "tmp RefPatt::createNewElements node_coords after= " - << node_coords[inode][0] << " " - << node_coords[inode][1] << " " - << node_coords[inode][2] << std::endl; - } - } - - tets.resize(new_tets.size()); - for (unsigned i = 0; i < new_tets.size(); i++) - { - tets[i] = TetTupleTypeLocal((unsigned)new_tets[i].get<0>(), - (unsigned)new_tets[i].get<1>(), - (unsigned)new_tets[i].get<2>(), - (unsigned)new_tets[i].get<3>() ); - if (0) - std::cout << "tmp RefPatt::createNewElements new tet= " << tets[i] << std::endl; - - } - return; - } - - - tets.resize(0); - std::vector tet_faces; - - // algorithm: triangulate each face, create tets from centroid, collapse shortest edge - static stk_classic::mesh::Entity *centroid_node = 0; - static stk_classic::mesh::Entity *temp_edge_nodes[6] = {0,0,0,0,0,0}; - if (!centroid_node) - { - centroid_node = get_new_node(eMesh); - if (!centroid_node) - throw std::logic_error("RefinerPattern_Tet4_Tet4_N::triangulate_tet: centroid_node is null"); - for (int i = 0; i < 6; i++) - temp_edge_nodes[i] = get_new_node(eMesh); - } - - - for (int iface = 0; iface < 4; iface++) - { - unsigned tri_face_edge_marks[3] = {0,0,0}; - for (int iedge = 0; iedge < 3; iedge++) - { - tri_face_edge_marks[iedge] = edge_marks[tbl_tet_face_edge_map[iface][iedge]]; - } - - stk_classic::mesh::Entity *tri_elem_nodes_local[3] = {0,0,0}; - for (int inode=0; inode < 3; inode++) - { - tri_elem_nodes_local[inode] = tet_elem_nodes[tbl_tet_face_nodes[iface][inode]]; - } - - std::vector tri_face_elems_local; - RefinerPattern, shards::Triangle<3>, -1 >::triangulate_face(eMesh, tri_elem_nodes_local, tri_face_edge_marks, tri_face_elems_local); - - - // triangulate_face returns tri_face_elems_local, a vector of 3-tuples with local face/edge numbers: - // {0,1,2} for the vertices, and {3,4,5} for the edges - // These need to be converted to the parent tet's vertices {0-3}, and edges {4-9}, done by TET_TRI_CV_EV - -#define TET_TRI_CV_EV(iface,i) ( i < 3 ? tbl_tet_face_nodes[iface][i] : tbl_tet_face_edge_map[iface][i-3] ) - - for (unsigned itri = 0; itri < tri_face_elems_local.size(); itri++) - { - normalize(tri_face_elems_local[itri]); - - // FIXME - do we need to reverse two nodes for positive volumes since faces have right-hand-rule pointing outward? - // The current scheme gives all outward-pointing faces, so when tets are created, there should be a reversal, or - // we could do it here. - tri_tuple_type_local tet_face(TET_TRI_CV_EV(iface, tri_face_elems_local[itri].get<0>()), - TET_TRI_CV_EV(iface, tri_face_elems_local[itri].get<1>()), - TET_TRI_CV_EV(iface, tri_face_elems_local[itri].get<2>()) ); - normalize(tet_face); - tet_faces.push_back(tet_face); - } - } - -#define TET_CENTROID_NODE (4+6) - - // compute centroid and temp_edge_nodes - double * node_coords[10]; // all node coords in order, vertices {0-3}, edges {4-9} - double * centroid_coord = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *centroid_node); - for (int dim=0; dim < 3; dim++) centroid_coord[dim] = 0.0; - for (int inode=0; inode < 4; inode++) - { - double * coord = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *tet_elem_nodes[inode] ); - for (int dim=0; dim < 3; dim++) centroid_coord[dim] += coord[dim]/4.; - node_coords[inode] = coord; - } - int jnode = 4; - for (int iedge=0; iedge < 6; iedge++) - { - double * coord0 = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *tet_elem_nodes[tbl_tet_edge_nodes[iedge][0]] ); - double * coord1 = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *tet_elem_nodes[tbl_tet_edge_nodes[iedge][1]] ); - double * temp_node_coord = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *temp_edge_nodes[iedge] ); - node_coords[jnode++] = temp_node_coord; - for (int dim=0; dim < 3; dim++) temp_node_coord[dim] = 0.5*(coord0[dim] + coord1[dim]); - } - - triangulate_tet_generic(tet_faces, centroid_coord, node_coords, tets); - } - } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, std::vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - static std::vector elems(8); - static std::vector elems_local(8); - unsigned num_new_elems=0; - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - //VectorFieldType* coordField = eMesh.get_coordinates_field(); - - std::vector add_parts; - std::vector remove_parts; - add_parts = m_toParts; - - unsigned edge_marks[6] = {0,0,0,0,0,0}; - unsigned num_edges_marked=0; - for (int iedge = 0; iedge < 6; iedge++) - { - unsigned num_nodes_on_edge = new_sub_entity_nodes[m_eMesh.edge_rank()][iedge].size(); - if (num_nodes_on_edge) - { - edge_marks[iedge] = 1; - ++num_edges_marked; - } - } - if (num_edges_marked == 0) - return; - - stk_classic::mesh::Entity *elem_nodes_local[4] = {0,0,0,0}; - for (int inode=0; inode < 4; inode++) - { - elem_nodes_local[inode] = elem_nodes[inode].entity(); - } - triangulate_tet(eMesh, elem_nodes_local, edge_marks, elems_local); - - //#define TET_CV_EV(i) ( i < 4 ? VERT_N(i) : (i < TET_CENTROID_NODE ? EDGE_N(i-4) : -1) ) -#define TET_CV_EV(i) ( i < 4 ? VERT_N(i) : EDGE_N(i-4) ) - - num_new_elems = elems_local.size(); - elems.resize(num_new_elems); - for (unsigned ielem=0; ielem < num_new_elems; ielem++) - { - elems[ielem] = TetTupleType( TET_CV_EV(elems_local[ielem].get<0>() ), - TET_CV_EV(elems_local[ielem].get<1>() ), - TET_CV_EV(elems_local[ielem].get<2>() ), - TET_CV_EV(elems_local[ielem].get<3>() ) ); - if (0) - std::cout << "tmp RefPatt::createNewElements new tet= " << elems[ielem] << std::endl; - - } - - //std::cout << "tmp RefinerPattern_Tet4_Tet4_N::num_edges_marked= " << num_edges_marked << std::endl; - - //nodeRegistry.makeCentroidCoords(*const_cast(&element), m_eMesh.element_rank(), 0u); - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << "] nid = 0 << " << std::endl; - //exit(1); - } - } - - // 4 nodes of the new tets - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<3>()), 3); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - interpolateElementFields(eMesh, element, newElement); - - if (0) - { - std::cout << "tmp RefPatt::createNewElements element.identifier()= " << element.identifier() - << " newElement= " << newElement.identifier() << std::endl; - - } - - element_pool++; - - } - - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_2.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_2.hpp deleted file mode 100644 index 39f70165824a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_2.hpp +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef stk_adapt_RefinerPattern_Tri3_Tri3_2_sierra_hpp -#define stk_adapt_RefinerPattern_Tri3_Tri3_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" - -namespace stk_classic { - namespace adapt { - - /// this is for testing only - or could be unsed in future for a bisection-based refinement scheme - - template <> - class RefinerPattern, shards::Triangle<3>, 2 > : public URP,shards::Triangle<3> > - { - - UniformRefinerPattern, shards::Line<2>, 2, SierraPort > * m_edge_breaker; - - public: - - RefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Triangle<3> >(eMesh), - m_edge_breaker(0) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - if (m_eMesh.get_spatial_dim() == 2) - { - m_edge_breaker = new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ; - } - - } - - ~RefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; - if (m_eMesh.get_spatial_dim() == 2) - { - bp[1] = m_edge_breaker; - } - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 1u; - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tri_tuple_type; - static vector elems(2); - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - add_parts = m_toParts; - - - unsigned num_edges_marked=0; - for (int iedge = 0; iedge < 3; iedge++) - { - unsigned num_nodes_on_edge = new_sub_entity_nodes[m_eMesh.edge_rank()][iedge].size(); - if (num_nodes_on_edge) - { - ++num_edges_marked; - } - } - if (num_edges_marked > 1) - { - throw std::runtime_error("RefinerPattern_Tri3_Tri3_2 can only refine element with one marked edge"); - } - if (num_edges_marked == 0) - return; - - double tmp_x[3]; - for (int iedge = 0; iedge < 3; iedge++) - { - double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), tmp_x); - - unsigned num_nodes_on_edge = new_sub_entity_nodes[m_eMesh.edge_rank()][iedge].size(); - if (num_nodes_on_edge) - { - eMesh.createOrGetNode(EDGE_N(iedge), mp); - elems[0] = tri_tuple_type(VERT_N(iedge), EDGE_N(iedge), VERT_N((iedge+2)%3) ); - elems[1] = tri_tuple_type(EDGE_N(iedge), VERT_N((iedge+1)%3), VERT_N((iedge+2)%3) ); - } - } - - //nodeRegistry.makeCentroidCoords(*const_cast(&element), m_eMesh.element_rank(), 0u); - - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - //std::cout << "tmp newElement id = " << newElement.identifier() << std::endl; - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } - - eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << "] nid = 0 << " << std::endl; - //exit(1); - } - } - - // 3 nodes of the new tris - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_N.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_N.hpp deleted file mode 100644 index 2271f9569f05..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerPattern_Tri3_Tri3_N.hpp +++ /dev/null @@ -1,426 +0,0 @@ -#ifndef stk_adapt_RefinerPattern_Tri3_Tri3_N_sierra_hpp -#define stk_adapt_RefinerPattern_Tri3_Tri3_N_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -//#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" -#include "RefinerPattern_Line2_Line2_N.hpp" - -namespace stk_classic { - namespace adapt { - - typedef boost::tuple tri_tuple_type_local; - typedef boost::tuple tri_tuple_type; - - /// general refinement pattern - - // the "-1" here signifies the number of elements created is not fixed, depends on the marking pattern - template <> - class RefinerPattern, shards::Triangle<3>, -1 > : public URP,shards::Triangle<3> > - { - - RefinerPattern, shards::Line<2>, -1 > * m_edge_breaker; - - public: - - RefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Triangle<3> >(eMesh), - m_edge_breaker(0) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - if (m_eMesh.get_spatial_dim() == 2) - { - m_edge_breaker = new RefinerPattern, shards::Line<2>, -1 > (eMesh, block_names) ; - } - - } - - ~RefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; - if (m_eMesh.get_spatial_dim() == 2) - { - bp[1] = m_edge_breaker; - } - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 1u; - } - - // FIXME - for now, create more than we need (to fix this right we need a change to the Refiner.cpp interface) - virtual unsigned getNumNewElemPerElem() { return 4; } - - /** - * - * Convention: input is the element's nodes and the marks on the edges. Output is an array - * of "elements" defined as local id's of nodes forming those elements, where {0,1,2} represent - * the original vertices and {3,4,5} are the edges: - * - * 2 - * o - * / \ - * / \ - * / \ - * 5 * * 4 - * / \ - * / \ - * / \ - * o-------*-------o - * 0 3 1 - */ - - // Note: this will form the basis of triangulating faces in 3D, so it is generalized to a - // generic method. - // Note: code below doesn't orient the face except for a rotation - we need a polarity flip check as - // well for the general, 3D face case - // - -#define T_VERT_N(i) (i) -#define T_EDGE_N(i) ((i)+3) - - static void triangulate_face(PerceptMesh& eMesh, stk_classic::mesh::Entity *elem_nodes[3], unsigned edge_marks[3], - vector& elems) - { - elems.resize(0); - - const CellTopologyData * const cell_topo_data = shards::getCellTopologyData< shards::Triangle<3> >(); - - shards::CellTopology cell_topo(cell_topo_data); - //const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); /NLM - VectorFieldType* coordField = eMesh.get_coordinates_field(); - - unsigned num_edges_marked=0; - for (int iedge = 0; iedge < 3; iedge++) - { - unsigned num_nodes_on_edge = edge_marks[iedge]; - if (num_nodes_on_edge) - { - ++num_edges_marked; - } - } - - //std::cout << "tmp RefinerPattern_Tri3_Tri3_N::num_edges_marked= " << num_edges_marked << std::endl; - - if (num_edges_marked == 3) - { - elems.resize(4); - - elems[0] = tri_tuple_type( T_VERT_N(0), T_EDGE_N(0), T_EDGE_N(2) ); - elems[1] = tri_tuple_type( T_VERT_N(1), T_EDGE_N(1), T_EDGE_N(0) ); - elems[2] = tri_tuple_type( T_VERT_N(2), T_EDGE_N(2), T_EDGE_N(1) ); - elems[3] = tri_tuple_type( T_EDGE_N(0), T_EDGE_N(1), T_EDGE_N(2) ); - } - else if (num_edges_marked == 2) - { - /** - * - * case 1: jedge == max length edge - * - * i2 - * o - * /|\ - * / | \ - * / | \ - * / | * jedgep - * / | / \ - * / | / \ - * / |/ \ - * o-------*-------o - * i0 jedge i1 - * - * - * case 2: jedge+1 == max length edge - * - * i2 - * o - * / \ - * / \ - * / \ - * / _.* jedgep - * / _.* / \ - * / _.* / \ - * /.* / \ - * o-------*-------o - * i0 jedge i1 - * - */ - - elems.resize(3); - - // find first of two marked edges in sequence (get in "standard" orientation), and longest marked edge - int jedge = -1; - int jedge_max_edge = -1; - double max_edge_length = -1.0; - unsigned id_diff_0 = 0u; - unsigned id_diff_1 = 0u; - for (int iedge = 0; iedge < 3; iedge++) - { - - unsigned num_nodes_on_edge = edge_marks[iedge]; - unsigned num_nodes_on_edge_p = edge_marks[(iedge+1)%3]; - if (num_nodes_on_edge && num_nodes_on_edge_p) - { - jedge = iedge; - } - - if (num_nodes_on_edge) - { - stk_classic::mesh::Entity * node_0 = elem_nodes[cell_topo_data->edge[iedge].node[0]]; - stk_classic::mesh::Entity * node_1 = elem_nodes[cell_topo_data->edge[iedge].node[1]]; - - //bool reverse = false; - // ensure edge_len is computed identically, independent of edge orientation - if (node_0->identifier() > node_1->identifier()) - { - //reverse = true; - stk_classic::mesh::Entity *node_temp = node_0; - node_0 = node_1; - node_1 = node_temp; - } - - double * const coord_0 = stk_classic::mesh::field_data( *coordField , *node_0 ); - double * const coord_1 = stk_classic::mesh::field_data( *coordField , *node_1 ); - double edge_len_squared = 0.0; - - edge_len_squared = - (coord_0[0] - coord_1[0])*(coord_0[0] - coord_1[0])+ - (coord_0[1] - coord_1[1])*(coord_0[1] - coord_1[1])+ - (eMesh.get_spatial_dim() == 2 ? 0 : - (coord_0[2] - coord_1[2])*(coord_0[2] - coord_1[2]) ); - - if (edge_len_squared > max_edge_length) - { - id_diff_0 = node_0->identifier(); - id_diff_1 = node_1->identifier(); - max_edge_length = edge_len_squared; - jedge_max_edge = iedge; - } - // intentional floating-point comparison (tie-break) - else if (edge_len_squared == max_edge_length) - { - unsigned loc_id_diff_0 = node_0->identifier(); - unsigned loc_id_diff_1 = node_1->identifier(); - bool lexical_less = false; - if (loc_id_diff_0 < id_diff_0) - { - lexical_less = true; - } - else if (loc_id_diff_0 == id_diff_0 && loc_id_diff_1 < id_diff_1) - { - lexical_less = true; - } - if (!lexical_less) - { - max_edge_length = edge_len_squared; - jedge_max_edge = iedge; - } - } - } - } - - if (jedge < 0 || jedge_max_edge < 0) - { - std::cout << "jedge = " << jedge << " jedge_max_edge = " << jedge_max_edge << std::endl; - throw std::runtime_error("RefinerPattern_Tri3_Tri3_N jedge < 0"); - } - - //stk_classic::mesh::Entity & node0 = *elem_nodes[iii].entity(); - int i0 = cell_topo_data->edge[jedge].node[0]; - if (i0 != jedge) - { - std::cout << "i0 = " << i0 << " jedge= " << jedge << std::endl; - throw std::runtime_error("RefinerPattern_Tri3_Tri3_N i0 != jedge"); - } - - int i1 = (i0+1)%3; - int i2 = (i0+2)%3; - int jedgep = (jedge+1)%3; - if (jedge_max_edge == jedge) - { - elems[0] = tri_tuple_type( T_VERT_N(i0), T_EDGE_N(jedge), T_VERT_N(i2) ); - elems[1] = tri_tuple_type( T_EDGE_N(jedge), T_EDGE_N( jedgep ), T_VERT_N(i2) ); - elems[2] = tri_tuple_type( T_EDGE_N(jedge), T_VERT_N(i1), T_EDGE_N( jedgep ) ); - } - else - { - elems[0] = tri_tuple_type( T_VERT_N(i0), T_EDGE_N(jedge), T_EDGE_N( jedgep ) ); - elems[1] = tri_tuple_type( T_VERT_N(i0), T_EDGE_N( jedgep ), T_VERT_N(i2) ); - elems[2] = tri_tuple_type( T_EDGE_N(jedge), T_VERT_N(i1), T_EDGE_N( jedgep ) ); - } - } - else if (num_edges_marked == 1) - { - elems.resize(2); - for (int iedge = 0; iedge < 3; iedge++) - { - unsigned num_nodes_on_edge = edge_marks[iedge]; - if (num_nodes_on_edge) - { - elems[0] = tri_tuple_type(T_VERT_N(iedge), T_EDGE_N(iedge), T_VERT_N((iedge+2)%3) ); - elems[1] = tri_tuple_type(T_EDGE_N(iedge), T_VERT_N((iedge+1)%3), T_VERT_N((iedge+2)%3) ); - break; - } - } - } - else if (num_edges_marked == 0) - { -#if 0 - // this allows each level to be at the same hierarchical level by having a single parent to single child - elems.resize(1); - elems[0] = tri_tuple_type(T_VERT_N(0), T_VERT_N(1), T_VERT_N(2) ); -#else - if (elems.size() != 0) - { - std::cout << "tmp num_edges_marked= 0 " << elems.size() << std::endl; - throw std::logic_error("hmmmmmmmmmmm"); - } - - return; -#endif - } - - } - - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - if (0 && eMesh.check_entity_duplicate(element)) - { - throw std::logic_error("RefinerPattern_Tri3_Tri3_N::createNewElements bad duplicate element of PARENT!"); - } - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tri_tuple_type; - typedef boost::tuple tri_tuple_type_int; - static vector elems(4); - static vector elems_local(4); - unsigned num_new_elems=0; - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - //VectorFieldType* coordField = eMesh.get_coordinates_field(); - - std::vector add_parts; - std::vector remove_parts; - add_parts = m_toParts; - - unsigned edge_marks[3] = {0,0,0}; - unsigned num_edges_marked=0; - for (int iedge = 0; iedge < 3; iedge++) - { - unsigned num_nodes_on_edge = new_sub_entity_nodes[m_eMesh.edge_rank()][iedge].size(); - if (num_nodes_on_edge) - { - edge_marks[iedge] = 1; - ++num_edges_marked; - } - } - if (num_edges_marked == 0) - return; - - stk_classic::mesh::Entity *elem_nodes_local[3] = {0,0,0}; - for (int inode=0; inode < 3; inode++) - { - elem_nodes_local[inode] = elem_nodes[inode].entity(); - } - triangulate_face(eMesh, elem_nodes_local, edge_marks, elems_local); - -#define CV_EV(i) ( i < 3 ? VERT_N(i) : EDGE_N(i-3) ) - - num_new_elems = elems_local.size(); - elems.resize(num_new_elems); - for (unsigned ielem=0; ielem < num_new_elems; ielem++) - { - elems[ielem] = tri_tuple_type( CV_EV(elems_local[ielem].get<0>() ), CV_EV(elems_local[ielem].get<1>() ), CV_EV(elems_local[ielem].get<2>() ) ); - } - - //std::cout << "tmp RefinerPattern_Tri3_Tri3_N::num_edges_marked= " << num_edges_marked << std::endl; - - //nodeRegistry.makeCentroidCoords(*const_cast(&element), m_eMesh.element_rank(), 0u); - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - if (fdata) - fdata[0] = double(newElement.owner_rank()); - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << "] nid = 0 << " << std::endl; - //exit(1); - } - } - - // 3 nodes of the new tris - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - interpolateElementFields(eMesh, element, newElement); - - // FIXME tmp - could be slow - - if (0 && eMesh.check_entity_duplicate(newElement)) - { - if (eMesh.check_entity_duplicate(element)) - { - std::cout << "RefinerPattern_Tri3_Tri3_N::createNewElements bad duplicate element of PARENT 2!" << std::endl; - } - std::cout << "RefinerPattern_Tri3_Tri3_N bad duplicate element= " << element << " newElement= " << newElement << " elems.size() = " << elems.size() << std::endl; - std::cout << "===> newElement.ischild, is parent = " << eMesh.isChildElement(newElement) << " " << eMesh.isParentElement(newElement) << std::endl; - throw std::logic_error("RefinerPattern_Tri3_Tri3_N::createNewElements bad duplicate element"); - } - - element_pool++; - - } - - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUnrefine.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUnrefine.cpp deleted file mode 100644 index 82790b9dfe3c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUnrefine.cpp +++ /dev/null @@ -1,786 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include - - -namespace stk_classic { - namespace adapt { - using namespace std; - using namespace percept; - - // ==================================================================================================== - // ==================================================================================================== - // ==================================================================================================== - - // get set of children with no nieces that are to be removed; put their parents in a list; - // put the children's family trees in a list to be removed - void Refiner::getChildrenToBeRemoved(ElementUnrefineCollection& elements_to_unref, - SetOfEntities& children_to_be_removed, SetOfEntities& children_to_be_removed_with_ghosts, - SetOfEntities& copied_children_to_be_removed_NOT_USED, - SetOfEntities& family_trees_to_be_removed, - SetOfEntities& parent_elements) - { - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - - unsigned nchild_removed = 0; - - for (ElementUnrefineCollection::iterator u_iter = elements_to_unref.begin(); - u_iter != elements_to_unref.end(); ++u_iter) - { - stk_classic::mesh::Entity * element_p = *u_iter; - bool isGhostElement = m_eMesh.isGhostElement(*element_p); - bool isChild = m_eMesh.isChildElement(*element_p); - - if (!isChild) - { - throw std::logic_error(" found parent where child expected"); - continue; - } - - stk_classic::mesh::PairIterRelation child_to_family_tree_relations = element_p->relations(FAMILY_TREE_RANK); - - // look for level 0 only - these are children with no children - unsigned child_ft_level_0 = m_eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, *element_p); - - stk_classic::mesh::Entity *family_tree = child_to_family_tree_relations[child_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(m_eMesh.element_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error("Refiner::unrefineTheseElements family_tree_relations.size() == 0"); - } - - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - if (!parent) - { - throw std::logic_error("Refiner::unrefineTheseElements parent == null"); - } - parent_elements.insert(parent); - - family_trees_to_be_removed.insert(family_tree); - - ++nchild_removed; - - if (!isGhostElement) - { - children_to_be_removed.insert( element_p ); - } - children_to_be_removed_with_ghosts.insert( element_p ); - - } -#if DEBUG_UNREF - std::cout << "tmp nchild_removed=: " << nchild_removed << std::endl; -#endif - -#if DEBUG_UNREF_1 - std::cout << "tmp children_to_be_removed size = " << children_to_be_removed.size() << std::endl; - std::cout << "tmp nchild_removed=: " << nchild_removed << std::endl; -#endif - - - } - - void Refiner::removeFamilyTrees(SetOfEntities& family_trees_to_be_removed) - { - for(SetOfEntities::iterator family_tree_it = family_trees_to_be_removed.begin(); - family_tree_it != family_trees_to_be_removed.end(); ++family_tree_it) - { - stk_classic::mesh::Entity *family_tree = *family_tree_it; - if ( ! m_eMesh.get_bulk_data()->destroy_entity( family_tree ) ) - { - throw std::logic_error("Refiner::unrefineTheseElements couldn't remove element, destroy_entity returned false for family_tree."); - } - } - } - - void Refiner::removeDeletedNodes(NodeSetType& deleted_nodes) - { - //std::cout << "P["<< m_eMesh.get_rank() << "] removeDeletedNodes deleted_nodes.size()= " << deleted_nodes.size() << std::endl; - for(SetOfEntities::iterator node_it = deleted_nodes.begin(); - node_it != deleted_nodes.end(); ++node_it) - { - stk_classic::mesh::Entity *node = *node_it; - if ( ! m_eMesh.get_bulk_data()->destroy_entity( node ) ) - { - //throw std::logic_error("Refiner::unrefineTheseElements couldn't remove node, destroy_entity returned false for node."); - } - } - } - - - void Refiner::getSideElemsToBeRemoved(SetOfEntities& children_to_be_removed, SetOfEntities& side_elem_set_to_be_removed, SetOfEntities& family_trees_to_be_removed, SetOfEntities& parent_side_elements) - { - if (getIgnoreSideSets()) return; - - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - for(SetOfEntities::iterator child_it = children_to_be_removed.begin(); - child_it != children_to_be_removed.end(); ++child_it) - { - stk_classic::mesh::Entity *child = *child_it; - - if (m_eMesh.hasFamilyTree(*child) && !m_eMesh.isChildWithoutNieces(*child)) - throw std::logic_error("error 34"); - - // add sideset elements to list to be removed (and their family tree info) - mesh::PairIterRelation side_relations = child->relations(m_eMesh.side_rank()); - for (unsigned jside = 0; jside < side_relations.size(); jside++) - { - stk_classic::mesh::Entity * side_element = side_relations[jside].entity(); - // FIXME err check - if (m_eMesh.hasFamilyTree(*side_element) && !m_eMesh.isChildWithoutNieces(*side_element)) - { - throw std::logic_error("error 35"); - } - //if (m_eMesh.hasFamilyTree(*side_element) && m_eMesh.isChildWithoutNieces(*side_element, false)) - if (m_eMesh.hasFamilyTree(*side_element)) - { - unsigned side_elem_child_ft_level_0 = m_eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, *side_element); - - mesh::PairIterRelation side_element_to_family_tree_relations = side_element->relations(FAMILY_TREE_RANK); - stk_classic::mesh::Entity *family_tree = side_element_to_family_tree_relations[side_elem_child_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(side_element->entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error("Refiner::unrefineTheseElements family_tree_relations.size() == 0 [1]"); - } - - for (unsigned ichild=1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *side_elem_sibling = family_tree_relations[ichild].entity(); - - //std::cout << "tmp unref side element id= " << side_element->identifier() << std::endl; - side_elem_set_to_be_removed.insert(side_elem_sibling); - } - - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - parent_side_elements.insert(parent); - family_trees_to_be_removed.insert(family_tree); - } - } - } - } - - - - void Refiner::removeChildElements(SetOfEntities& children_to_be_removed) - { - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - for(SetOfEntities::iterator child_it = children_to_be_removed.begin(); - child_it != children_to_be_removed.end(); ++child_it) - { - stk_classic::mesh::Entity *child = *child_it; - - if (m_eMesh.isGhostElement(*child)) - { - throw std::logic_error("Refiner::removeChildElements couldn't remove element, Ghost is true."); - } - if ( ! m_eMesh.get_bulk_data()->destroy_entity( child ) ) - { - CellTopology cell_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*child)); - - //const mesh::PairIterRelation elem_relations = child->relations(child->entity_rank()+1); - const mesh::PairIterRelation child_to_ft_relations = child->relations(FAMILY_TREE_RANK); -#if DEBUG_UNREF - std::cout << "tmp Refiner::unrefineTheseElements couldn't remove element cell= " << cell_topo.getName() << std::endl; - std::cout << "tmp child_to_ft_relations.size() = " << child_to_ft_relations.size() << std::endl; - //std::cout << "tmp ft_id loc, outerloop= " << child_to_family_tree_relations[0].entity()->identifier() << " " << family_tree_id << std::endl; - - m_eMesh.print_entity(std::cout, *child); -#endif - - throw std::logic_error("Refiner::unrefineTheseElements couldn't remove element, destroy_entity returned false."); - } - } - } - - void Refiner::removeSideElements(SetOfEntities& side_elem_set_to_be_removed, SetOfEntities& elements_to_be_deleted) - { - for(SetOfEntities::iterator side_elem_it = side_elem_set_to_be_removed.begin(); - side_elem_it != side_elem_set_to_be_removed.end(); ++side_elem_it) - { - stk_classic::mesh::Entity *side_elem = *side_elem_it; - bool del = m_eMesh.get_bulk_data()->destroy_entity( side_elem ); - if ( ! del ) - { - std::cout << "Refiner::unrefineTheseElements couldn't remove side element, destroy_entity returned false." << *side_elem << std::endl; - del = m_eMesh.get_bulk_data()->destroy_entity( side_elem ); - if (1) - { - stk_classic::mesh::PairIterRelation rels = side_elem->relations(m_eMesh.element_rank()); - for (unsigned irels=0; irels < rels.size(); irels++) - { - bool in_del = (elements_to_be_deleted.find(rels[irels].entity()) != elements_to_be_deleted.end()); - std::cout << "Refiner::unrefineTheseElements found element: in del list= " << in_del << std::endl; - } - } - throw std::logic_error("Refiner::unrefineTheseElements couldn't remove side element, destroy_entity returned false."); - } - } - } - - - // for the given set of parent elements, remesh the interior after the children have been removed and any deleted nodes have been removed from the NodeRegistry - void Refiner::remesh(SetOfEntities& parent_elements) - { - // - // FIXME refactor to a generic function operating on a collection of elements; incorporate with the doBreak() calls above - // - // remesh - -#if DEBUG_UNREF - std::cout << "tmp remesh:: parent_elements.size() [elements to be remeshed] = " << parent_elements.size() << std::endl; -#endif - - // FIXME for performance - //static NewSubEntityNodesType s_new_sub_entity_nodes(stk_classic::percept::EntityRankEnd); - NewSubEntityNodesType s_new_sub_entity_nodes(stk_classic::percept::EntityRankEnd); - - NewSubEntityNodesType& new_sub_entity_nodes = s_new_sub_entity_nodes; - - for (unsigned irank=0; irank < m_ranks.size(); irank++) - { - unsigned num_new_elem_during_remesh = 0; - vector needed_entity_ranks; - m_breakPattern[irank]->fillNeededEntities(needed_entity_ranks); - - vector new_elements; - - // count num new elements needed on this proc (served by UniformRefinerPattern) - unsigned num_elem_not_ghost = 0u; - - for (ElementUnrefineCollection::iterator p_iter = parent_elements.begin(); - p_iter != parent_elements.end(); ++p_iter) - { - stk_classic::mesh::Entity *parent = *p_iter; - - stk_classic::mesh::Entity& element = *parent; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - CellTopology cell_topo(cell_topo_data); - unsigned elementType = cell_topo.getKey(); - unsigned bpElementType = m_breakPattern[irank]->getFromTypeKey(); - if (elementType == bpElementType) - { - if (!m_eMesh.isGhostElement(element)) - { - ++num_elem_not_ghost; - } - } - } - - unsigned num_elem_needed = num_elem_not_ghost * m_breakPattern[irank]->getNumNewElemPerElem(); - - //std::cout << "tmp remesh::rank[" << irank << "] = " << m_ranks[irank] << " , num_elem_needed= " << num_elem_needed << std::endl; - -#if DEBUG_UNREF - std::cout << "tmp remesh::rank[irank], num_elem_needed= " << m_ranks[irank] << " " << num_elem_needed << std::endl; -#endif - - // create new entities on this proc - new_elements.resize(0); - m_eMesh.createEntities( m_ranks[irank], num_elem_needed, new_elements); - vector::iterator element_pool_it = new_elements.begin(); - - // FIXME - we could directly call this with a refactor to change elementColors passed in here as a generic collection + checking for element Type - // - //createElementsAndNodesAndConnectLocal(m_ranks[irank], m_breakPattern[irank], elementColors, needed_entity_ranks, new_elements); - - for (ElementUnrefineCollection::iterator p_iter = parent_elements.begin(); - p_iter != parent_elements.end(); ++p_iter) - { - stk_classic::mesh::Entity *parent_p = *p_iter; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*parent_p); - CellTopology cell_topo(cell_topo_data); - unsigned elementType = cell_topo.getKey(); - unsigned bpElementType = m_breakPattern[irank]->getFromTypeKey(); - if (elementType == bpElementType) - { - stk_classic::mesh::Entity& parent = *parent_p; - - if (!m_eMesh.isGhostElement(parent)) - { -#if DEBUG_UNREF - //std::cout << "P["<< m_eMesh.get_rank() << "] parent.owner_rank() = " << parent.owner_rank() << std::endl; - std::cout << "tmp Parent to be remeshed = "; - m_eMesh.print_entity(std::cout, parent); -#endif - if (createNewNeededNodeIds(cell_topo_data, parent, needed_entity_ranks, new_sub_entity_nodes)) - { - //std::cout << "typeid= " << typeid(*breakPattern).name() << std::endl; - throw std::logic_error("unrefineTheseElements:: createNewNeededNodeIds failed"); - } - - vector::iterator element_pool_it_b4 = element_pool_it; - m_breakPattern[irank]->createNewElements(m_eMesh, *m_nodeRegistry, parent, new_sub_entity_nodes, element_pool_it, m_proc_rank_field); - vector::iterator element_pool_it_af = element_pool_it; - num_new_elem_during_remesh += (element_pool_it_af - element_pool_it_b4); - } - } - } -#if DEBUG_UNREF - std::cout << "tmp remesh:: nchild elements during remesh for rank[irank] = " << m_ranks[irank] << " " << num_new_elem_during_remesh << std::endl; -#endif - - } // irank - - } - - - void - Refiner:: - unrefineAll() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error in isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && (m_eMesh.hasFamilyTree(element) && m_eMesh.isChildWithoutNieces(element, false) ) ) - { - bool elementIsGhost = m_eMesh.isGhostElement(element); - - if (!elementIsGhost) - { - elements_to_unref.insert(&element); - } - } - } - } - } - unrefineTheseElements(elements_to_unref); - } - -#define DEBUG_UNREF 0 -#define DEBUG_UNREF_1 0 - - void Refiner:: - filterUnrefSet(ElementUnrefineCollection& elements_to_unref) - { - int print_filter_info = DEBUG_UNREF_1; - if (print_filter_info) std::cout << "P["<< m_eMesh.get_rank() << "] filterUnrefSet: initial set size = " << elements_to_unref.size() << std::endl; - - const unsigned FAMILY_TREE_RANK = m_eMesh.element_rank() + 1u; - ElementUnrefineCollection elements_to_unref_copy; - - typedef std::set SetOfEntities; - - int num_is_parent = 0; - int num_elem_nodes_0 = 0; - int num_has_nieces = 0; - - for (ElementUnrefineCollection::iterator u_iter = elements_to_unref.begin(); - u_iter != elements_to_unref.end(); ++u_iter) - { - stk_classic::mesh::Entity& element = **u_iter; - - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - { - ++num_is_parent; - continue; - } - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - int elem_nodes_size = elem_nodes.size(); - bool has_no_nieces = m_eMesh.hasFamilyTree(element) && m_eMesh.isChildWithoutNieces(element, false); - - if (!elem_nodes_size) num_elem_nodes_0++; - if (!has_no_nieces) num_has_nieces++; - if (elem_nodes_size && has_no_nieces) - { - stk_classic::mesh::PairIterRelation child_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - - // look for level 0 only - these are children with no children - unsigned child_ft_level_0 = m_eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - - stk_classic::mesh::Entity *family_tree = child_to_family_tree_relations[child_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(m_eMesh.element_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error("Refiner::filterUnrefSet family_tree_relations.size() == 0"); - } - - SetOfEntities side_elem_set; - - bool all_siblings_in_unref_set = true; - bool all_side_sets_ok = true; - - for (unsigned ichild=1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - if (m_eMesh.isParentElement(*child)) - { - throw std::logic_error("Refiner::filterUnrefSet isParentElement not expected"); - } - bool in_unref_set = elements_to_unref.find(child) != elements_to_unref.end(); - if (!in_unref_set) - { - all_siblings_in_unref_set = false; - break; - } - - { - mesh::PairIterRelation side_relations = child->relations(m_eMesh.side_rank()); - for (unsigned jside = 0; jside < side_relations.size(); jside++) - { - stk_classic::mesh::Entity * side_element = side_relations[jside].entity(); - side_elem_set.insert(side_element); - - if (0) - { - stk_classic::mesh::PairIterRelation side_elem_to_family_tree_relations = side_element->relations(FAMILY_TREE_RANK); - stk_classic::mesh::Entity *side_elem_family_tree_0 = side_elem_to_family_tree_relations[0].entity(); - std::cout << "side_elem_family_tree_0= " << side_elem_family_tree_0 << std::endl; - } - - // FIXME if (!m_eMesh.hasFamilyTree(*side_element) || !m_eMesh.isChildWithoutNieces(*side_element)) - if (m_eMesh.hasFamilyTree(*side_element) && !m_eMesh.isChildWithoutNieces(*side_element)) - { - //std::cout << "error 35" << std::endl; - all_side_sets_ok=false; - break; - } - } - } - } - - if (all_side_sets_ok) - { - for (unsigned ichild=1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - - { - mesh::PairIterRelation side_relations = child->relations(m_eMesh.side_rank()); - for (unsigned jside = 0; jside < side_relations.size(); jside++) - { - stk_classic::mesh::Entity * side_element = side_relations[jside].entity(); - //side_elem_set.insert(side_element); - - if (!m_eMesh.hasFamilyTree(*side_element)) continue; - - stk_classic::mesh::PairIterRelation side_elem_to_family_tree_relations = side_element->relations(FAMILY_TREE_RANK); - - // look for level 0 only - these are children with no children - unsigned side_elem_ft_level_0 = m_eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, *side_element); - - stk_classic::mesh::Entity *side_elem_family_tree = side_elem_to_family_tree_relations[side_elem_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation side_elem_family_tree_relations = side_elem_family_tree->relations(m_eMesh.side_rank()); - for (unsigned ise_child=1; ise_child < side_elem_family_tree_relations.size(); ise_child++) - { - stk_classic::mesh::Entity *se_sibling = side_elem_family_tree_relations[ise_child].entity(); - bool in_set = (side_elem_set.find(se_sibling) != side_elem_set.end()); - if (!in_set) - { - all_side_sets_ok = false; - break; - } - } - } - } - } - } - - if (all_siblings_in_unref_set && all_side_sets_ok) - { - for (unsigned ichild=1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - elements_to_unref_copy.insert(child); - } - } - } - } - if (print_filter_info) std::cout << "tmp filterUnrefSet::elements_to_unref.size = " << elements_to_unref.size() - << " filtered size= " << elements_to_unref_copy.size() - << " num_has_nieces= " << num_has_nieces - << " num_elem_nodes_0= " << num_elem_nodes_0 - << " num_is_parent= " << num_is_parent - << std::endl; - elements_to_unref = elements_to_unref_copy; - } - - void Refiner:: - getKeptNodes(NodeSetType& kept_nodes, ElementUnrefineCollection& elements_to_unref) - { - bool doTest=true; - - // mark kept nodes - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //if (m_eMesh.isLeafElement(element) && !m_eMesh.isGhostElement(element)) - if (!doTest || (elem_nodes.size() && m_eMesh.isLeafElement(element)) ) - { - bool in_unref_set = elements_to_unref.find( &element ) != elements_to_unref.end(); - //bool isGhostElement = m_eMesh.isGhostElement(element); - //if (!in_unref_set && !isGhostElement) - if (!in_unref_set) - { - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - kept_nodes.insert(node); -#if DEBUG_UNREF - std::cout << "tmp kept node: " << *node << " "; - m_eMesh.print_entity(std::cout, *node); -#endif - - } - } - } - } - } - } - - - } - - void Refiner:: - getDeletedNodes(NodeSetType& deleted_nodes, const NodeSetType& kept_nodes, ElementUnrefineCollection& elements_to_unref) - { - // mark deleted nodes (nodes in list of elements_to_unref - for (ElementUnrefineCollection::iterator u_iter = elements_to_unref.begin(); - u_iter != elements_to_unref.end(); ++u_iter) - { - stk_classic::mesh::Entity * element = *u_iter; - - - if (!m_eMesh.isGhostElement(*element)) - //if (m_eMesh.isChildElement(*element) && !m_eMesh.isGhostElement(*element)) - { - const mesh::PairIterRelation elem_nodes = element->relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - bool in_kept_nodes_set = kept_nodes.find( node ) != kept_nodes.end(); - if (!in_kept_nodes_set) - { - deleted_nodes.insert(node); -#if DEBUG_UNREF - std::cout << "tmp deleted node: " << *node << " "; - m_eMesh.print_entity(std::cout, *node); -#endif - } - } - } - } - if (DEBUG_UNREF_1) std::cout << "tmp kept_nodes size= " << kept_nodes.size() << " deleted_nodes size= " << deleted_nodes.size() << std::endl; - - } - - void - Refiner:: - unrefineTheseElements(ElementUnrefineCollection& elements_to_unref) - { - if (m_alwaysInitNodeRegistry) - { - throw std::logic_error("Refiner::unrefineTheseElements: to use urefinement, you must have setAlwaysInitializeNodeRegistry(false)"); - } - - //m_nodeRegistry->checkDB("unrefine start"); - - m_eMesh.get_bulk_data()->modification_begin(); - - //check_sidesets_2(" unrefineTheseElements:: start"); - - // mark nodes - // set<> kept_nodes - // set<> deleted_nodes - - /* Algorithm Option 1: - (requires parallel comm) - 1. reset/initialize node registry - 2. loop over elements; - verify has no children - get the parent; - - 2. loop over elements; - verify has no children - get the parent; - loop over parent sub-dim entities; - for - */ - - /* Option 2,3: purely local - - 0. keep NodeRegistry DB always (could be compressed later with a single int holding element id + subDim +iord) - 1. mark all nodes belonging to non-deleted leaf elements as KEPT - 2. foreach elements_to_unref; - verify has no children - get the parent; - mark nodes of deleted elements as DELETED (but if KEPT is set, then don't delete) - 3. foreach elements_to_unref - a. delete parent's children (once only of course) - b. delete any DELETED nodes (if not done automagically by stk_mesh in step 3a) - c. for sanity, delete DELETED nodes from NodeRegistry DB - - [option 2]: - 4. re-refine using currently marked edges using templates - - [option 3]: - 4. re-refine using currently marked edges using a local triangulation of each parent and its marked edges - [option 1]: use a local Delaunay method - [option 2]: project to a master element, use some form of template approach - - 5. rebuild when there's a load-balance? - [option 1]: build a surrogate DB in stk_mesh using face/edge and attributes - [option 2]: use existing db, add parallel comm - - */ - - //std::cout << "tmp elements_to_unref.size() = " << elements_to_unref.size() << std::endl; - - - NodeSetType kept_nodes; - NodeSetType deleted_nodes; - - // filter unref set - filterUnrefSet(elements_to_unref); - - // get kept nodes - getKeptNodes(kept_nodes, elements_to_unref); - - // get deleted nodes - getDeletedNodes(deleted_nodes, kept_nodes, elements_to_unref); - - // nothing to be done - if (0 && deleted_nodes.size() == 0) - { - m_eMesh.get_bulk_data()->modification_end(); - std::cout << "Refiner::unrefineTheseElements: deleted_nodes size is 0, nothing to be done, early return." << std::endl; - return; - } - - // remove deleted nodes and their associated sub-dim entities from NodeRegistry's db - m_nodeRegistry->cleanDeletedNodes(deleted_nodes); - - // remove elements to be unrefined - ElementUnrefineCollection copied_children_to_be_removed = elements_to_unref; - -#if DEBUG_UNREF || DEBUG_UNREF_1 - std::cout << "tmp copied_children_to_be_removed.size() [= num elements to be urefined that are children and !ghosts]= " << copied_children_to_be_removed.size() << std::endl; -#endif - - typedef std::set SetOfEntities; - - SetOfEntities family_trees_to_be_removed; - SetOfEntities children_to_be_removed; - SetOfEntities children_to_be_removed_with_ghosts; - SetOfEntities parent_elements; - - // set to hold sideset elements to be removed - SetOfEntities side_elem_set_to_be_removed; - SetOfEntities side_elem_family_trees_to_be_removed; - SetOfEntities parent_side_elements; - - // find all elements to be removed from the filtered list and build additional list with ghost elements - getChildrenToBeRemoved(elements_to_unref, - children_to_be_removed, children_to_be_removed_with_ghosts, copied_children_to_be_removed, - family_trees_to_be_removed, - parent_elements); - - // NodeRegistry must be kept in sync - m_nodeRegistry->clear_element_owner_data(children_to_be_removed_with_ghosts); - - // get the corresponding side elements from the children->side relations - getSideElemsToBeRemoved(children_to_be_removed, side_elem_set_to_be_removed, side_elem_family_trees_to_be_removed, - parent_side_elements); - - // first have to delete the family tree (higher ranks have to be deleted first) - removeFamilyTrees(family_trees_to_be_removed); - - // remove children - removeChildElements(children_to_be_removed); - - // for sideset elements, remove their family trees first - removeFamilyTrees(side_elem_family_trees_to_be_removed); - - // remove sideset elements - removeSideElements(side_elem_set_to_be_removed, children_to_be_removed); - - // remesh the holes left by removing child elems - remesh(parent_elements); - remesh(parent_side_elements); - -#if CHECK_DEBUG - check_db("after unrefineTheseElements, b4 mod end"); -#endif - - // remove any elements that are empty (these can exist when doing local refinement) - removeEmptyElements(); - - removeDeletedNodes(deleted_nodes); - - set_active_part(); - - fixElementSides1(); - - //if (1) std::cout << "P["<< m_eMesh.get_rank() << "] unrefineTheseElements modification_end start..." << std::endl; - m_eMesh.get_bulk_data()->modification_end(); - //if (1) std::cout << "P["<< m_eMesh.get_rank() << "] unrefineTheseElements modification_end ...end" << std::endl; - - -#if CHECK_DEBUG - check_db("before clear_element_owner_data_phase_2"); -#endif - //m_nodeRegistry->checkDB("before clear_element_owner_data_phase_2"); - - m_nodeRegistry->clear_element_owner_data_phase_2(); - - //m_nodeRegistry->checkDB("after clear_element_owner_data_phase_2"); - - //check_sidesets_2(" unrefineTheseElements:: end"); - - -#if CHECK_DEBUG - check_db("after unrefineTheseElements"); -#endif - - } - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.cpp deleted file mode 100644 index a41d35658641..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.cpp +++ /dev/null @@ -1,357 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -namespace stk_classic { -namespace adapt { - -using namespace std; -using namespace percept; - -#define EXTRA_PRINT_UR_GETBLOCKS 0 - -// FIXME move this to a utils class -BlockNamesType RefinerUtil::getBlockNames(std::string& block_name, unsigned proc_rank, percept::PerceptMesh& eMesh) -{ - BlockNamesType blocks(stk_classic::percept::EntityRankEnd+1u); - if (block_name.length() == 0) - return blocks; - - if (block_name.substr(0, 5) == "file:") - { - if (1) throw std::runtime_error("file: option Not implemented"); - std::string fileName = block_name.substr(5, block_name.length()-5); - std::ifstream file(fileName.c_str()); - while(!file.eof()) - { - std::string block; - file >> block; - if (block[0] != '#') - { - if (block.substr(0,6) == "block_") - blocks[eMesh.element_rank()].push_back(block); - else if (block.substr(0,8) == "surface_") - blocks[eMesh.face_rank()].push_back(block); - } - - } - } - else - { - std::string names = block_name; - - // pre-process to look for ".." range indicator - - std::string new_names = names; - new_names = ""; - while(1) - { - if (!names.length()) - break; - size_t ipos = names.find(','); - bool last_one = (ipos == std::string::npos); - - { - std::string n1 = (last_one ? names : names.substr(0, ipos) ); - bool inc = true; - //bool exc = false; - if ('-' == n1[0]) - { - //exc = true; - inc = false; - } - else if ('+' == n1[0]) - { - } - else - { - n1 = "+" + n1; - } - std::string plus_or_minus = (inc?"+":"-"); - std::string n2 = n1.substr(1, n1.length()-1); - std::string id_string_start = ""; - std::string id_string_end = ""; - // leave open the possibility for other identifiers for range - std::string dotdot = ".."; - int dotdot_len = dotdot.length(); - size_t pos_dotdot = n1.find(dotdot); - if (pos_dotdot != std::string::npos) - { - if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp with .., n1= " << n1 << " n2= " << n2 << std::endl; - - if (n1.length() > 6 && n1.substr(1,6) == "block_") - { - // +block_123..block_125 - // 0123456789^1234567890 - id_string_start = n1.substr(7, pos_dotdot-7); - id_string_end = n1.substr(pos_dotdot+dotdot_len+6, n1.length()-(pos_dotdot+dotdot_len+6)); - } - else if (n1.length() > 8 && n1.substr(1,8) == "surface_") - { - // error - } - else - { - // +12..45 - // 012^456 - //std::cout << "tmp pos_dotdot= " << pos_dotdot << std::endl; - - id_string_start = n1.substr(1, pos_dotdot-1); - id_string_end = n1.substr(pos_dotdot+dotdot_len+0, n1.length()-(pos_dotdot+dotdot_len+0)); - } - - int id_start = 0; - int id_end = 0; - try { - id_start = boost::lexical_cast(id_string_start); - id_end = boost::lexical_cast(id_string_end); - } - catch (std::exception& X) - { - std::cout << "RefinerUtil::getBlockNames: exception: " << X.what() << std::endl; - std::cout << "RefinerUtil::getBlockNames: invalid range syntax in block_name: with .., id_string_start= " - << id_string_start << " id_string_end= " << id_string_end << std::endl; - throw std::runtime_error("invalid input syntax"); - } - catch ( const std::exception * X ) - { - std::cout << "RefinerUtil::getBlockNames: exception: " << X->what() << std::endl; - std::cout << "RefinerUtil::getBlockNames: invalid range syntax in block_name: with .., id_string_start= " - << id_string_start << " id_string_end= " << id_string_end << std::endl; - throw std::runtime_error("invalid input syntax"); - } - catch( ... ) - { - throw std::runtime_error("invalid input syntax"); - } - if (EXTRA_PRINT_UR_GETBLOCKS) - { - std::cout << "tmp with .., id_string_start= " << id_string_start << " id_string_end= " << id_string_end << std::endl; - std::cout << "tmp with .., id_start= " << id_start << " id_end= " << id_end << std::endl; - } - - for (int id=id_start; id <= id_end; id++) - { - new_names += plus_or_minus+boost::lexical_cast(id)+(id == id_end ? "" : ","); - } - if (!last_one) - new_names += ","; - if (EXTRA_PRINT_UR_GETBLOCKS) - std::cout << "tmp new_names with .. = " << new_names << std::endl; - } - else - { - new_names += n1 + (last_one? "":","); - if (EXTRA_PRINT_UR_GETBLOCKS) - std::cout << "tmp new_names without .. = " << new_names << std::endl; - } - if (last_one) - { - break; - } - else - { - names = names.substr(ipos+1, names.length()-(ipos+1)); - } - } - } - if (EXTRA_PRINT_UR_GETBLOCKS) - std::cout << "tmp new_names after .. (range) processing = " << new_names << std::endl; - - names = new_names; - std::string names_save = names; - - // post process to remove +name if -name exists - new_names = ""; - while(1) - { - if (!names.length()) - break; - size_t ipos = names.find(','); - bool last_one = (ipos == std::string::npos); - - std::string n1 = (last_one ? names : names.substr(0, ipos) ); - - bool inc = true; - //bool exc = false; - if ('-' == n1[0]) - { - //exc = true; - inc = false; - } - else if ('+' == n1[0]) - { - } - else - { - //error - } - std::string n2 = n1.substr(1, n1.length()-1); - - if (inc) - { - size_t jpos = names_save.find("-"+n2); - if (jpos != std::string::npos) - { - // don't add it - } - else - { - new_names += n1 + (last_one? "":","); - } - } - else - { - new_names += n1 + (last_one? "":","); - } - - if (last_one) - { - break; - } - else - { - names = names.substr(ipos+1, names.length()-(ipos+1)); - } - } - - - if (EXTRA_PRINT_UR_GETBLOCKS) - std::cout << "tmp new_names after post-proc to remove +name if -name exists= " << new_names << std::endl; - if (new_names.length() && !proc_rank) - { - std::cout << "RefinerUtil:: --block_name option after processing for removing -name= " << new_names << std::endl; - } - - // final step - names = new_names; - while(1) - { - if (!names.length()) - break; - size_t ipos = names.find(','); - bool last_one = (ipos == std::string::npos); - - { - std::string n1 = (last_one ? names : names.substr(0, ipos) ); - - bool inc = true; - //bool exc = false; - if ('-' == n1[0]) - { - //exc = true; - inc = false; - } - else if ('+' == n1[0]) - { - } - else - { - n1 = "+" + n1; - } - std::string n2 = n1.substr(1, n1.length()-1); - - //std::cout << "n1= " << n1 << " n2= " << n2 << std::endl; - if (n1.length() > 6 && n1.substr(1,6) == "block_") - blocks[eMesh.element_rank()].push_back(n1); - else if (n1.length() > 8 && n1.substr(1,8) == "surface_") - blocks[eMesh.face_rank()].push_back(n1); - else - { - std::string pm = (inc?"+":"-"); - blocks[eMesh.element_rank()].push_back(pm+"block_"+n2); - } - if (last_one) - { - break; - } - else - { - names = names.substr(ipos+1, names.length()-(ipos+1)); - } - } - } - if (EXTRA_PRINT_UR_GETBLOCKS) - std::cout << "tmp RefinerUtil::getBlockNames: blocks = " << blocks << std::endl; - } - - return blocks; -} - -// FIXME move this to a utils class -/** - * This method looks for surfaces that share nodes with the blocks specified in @param blocks and if it finds - * any surfaces (sidesets), they are added to the blocks so they get refined properly. - * TODO: If a surface is shared by more than one block, an error is thrown. - */ - -BlockNamesType RefinerUtil::correctBlockNamesForPartPartConsistency(percept::PerceptMesh& eMesh, BlockNamesType& blocks) -{ - if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "RefinerUtil::correctBlockNamesForPartPartConsistency..." << std::endl; - - if (blocks[eMesh.element_rank()].size() == 0) - return blocks; - - stk_classic::mesh::EntityRank subDimRank = (eMesh.get_spatial_dim() == 3 ? eMesh.face_rank() : eMesh.edge_rank()); - - mesh::PartVector all_parts = eMesh.get_fem_meta_data()->get_parts(); - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - mesh::Part * part = *i_part ; - - for (mesh::PartVector::iterator i_surfacePart = all_parts.begin(); i_surfacePart != all_parts.end(); ++i_surfacePart) - { - mesh::Part * surfacePart = *i_surfacePart ; - if ( stk_classic::mesh::is_auto_declared_part(*surfacePart) ) - continue; - - const CellTopologyData * part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*surfacePart); - CellTopology surf_topo(part_cell_topo_data); - //if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp srk surfacePart= " << surfacePart->name() << " topo= " << (part_cell_topo_data?surf_topo.getName() : "NULL") << std::endl; - - if (part_cell_topo_data && part->primary_entity_rank() == eMesh.element_rank() && surfacePart->primary_entity_rank() == subDimRank) - { - std::string partNamePlus = "+" + part->name(); - std::vector::iterator partInBlocks = std::find(blocks[eMesh.element_rank()].begin(), blocks[eMesh.element_rank()].end(), partNamePlus); - // if this part is not in the blocks list, skip it - if (partInBlocks == blocks[eMesh.element_rank()].end()) - { - //if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp srk skipping part= " << partNamePlus << std::endl; - continue; - } - std::string surfacePartNamePlus = "+" + surfacePart->name(); - std::vector::iterator surfacePartInBlocks = std::find(blocks[subDimRank].begin(), blocks[subDimRank].end(), surfacePartNamePlus); - // if this surface is already in the list, skip it - if (surfacePartInBlocks != blocks[subDimRank].end()) - { - //if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp srk skipping surf= " << surfacePartNamePlus << std::endl; - continue; - } - bool isBoundarySurface= eMesh.isBoundarySurface(*part, *surfacePart); - - if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp srk isBoundarySurface for part/surf= " << part->name() << " / " << surfacePart->name() << " = " << isBoundarySurface << std::endl; - if (isBoundarySurface) - { - if (EXTRA_PRINT_UR_GETBLOCKS) std::cout << "tmp part [" << part->name() << "] shares sideset [" << surfacePart->name() << "]" << std::endl; - blocks[subDimRank].push_back(std::string("+"+surfacePart->name())); - } - else - { - //std::cout << "tmp part [" << part->name() << "] doesn't shares sideset [" << surfacePart->name() << "]" << std::endl; - } - } - } - } - if (0) std::cout << "tmp RefinerUtil::correctBlockNamesForPartPartConsistency: blocks = " << blocks << std::endl; - return blocks; -} - -} -} diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.hpp deleted file mode 100644 index efd55e7e3843..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/RefinerUtil.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef stk_adapt_RefinerUtil_hpp -#define stk_adapt_RefinerUtil_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include - - -namespace stk_classic { -namespace adapt { - -class RefinerUtil -{ -public: - - static BlockNamesType - getBlockNames(std::string& block_name, unsigned proc_rank, percept::PerceptMesh& eMesh); - - - static BlockNamesType - correctBlockNamesForPartPartConsistency(percept::PerceptMesh& eMesh, BlockNamesType& blocks); -}; - -} -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/SerializeNodeRegistry.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/SerializeNodeRegistry.hpp deleted file mode 100644 index 1fa5c43fe686..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/SerializeNodeRegistry.hpp +++ /dev/null @@ -1,1667 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#define DEBUG_YAML 0 - -#define STK_ADAPT_USE_YAML_CPP 1 -#define STK_ADAPT_HAVE_YAML_CPP (STK_ADAPT_USE_YAML_CPP && STK_BUILT_IN_SIERRA) -#if STK_ADAPT_HAVE_YAML_CPP -#include - -#define YAML_CHECK(emitter) do { if (1 && !emitter.good()) { std::cout << "Emitter error: " << __FILE__ << ":" << __LINE__ << " emitter.good()= " \ - << emitter.good() << " Error Message: " << emitter.GetLastError() << std::endl; return;} } while(0) - -#define YAML_ERRCHECK YAML_CHECK(emitter) - -#endif - - -namespace stk_classic { - - namespace adapt { - - -#if STK_ADAPT_HAVE_YAML_CPP - - /** in the following, we are looking at one partition, m_iM, of M-partitioned mesh - * - */ - - class SerializeNodeRegistry { - - public: - typedef std::vector IdVector; - - // PartMap maps a part name to data about the part: its primary entity rank, topology name, subset parts - typedef std::string TopologyName; - typedef std::string PartName; - typedef std::vector PartSubsets; - typedef boost::tuple PartMapData; - typedef std::map PartMap; - - typedef stk_classic::mesh::EntityId NodeMapKey; - typedef int ProcRank; - typedef std::vector SharedProcs; - typedef SharedProcs NodeMapValue; - typedef boost::unordered_map NodeMap; - - private: - PerceptMesh& m_eMesh; - NodeRegistry* m_nodeRegistry; - std::string m_input_mesh_name; - std::string m_output_mesh_name; - std::string m_filePrefix; - // iM, M = pseudo processor (reads file.e.M.iM) - // iP, P = worker, nworker - int m_M, m_iM, m_W, m_iW; - // for W==1, [start,end] = [0,M-1] - // W==2, iW==0, [M_0,M_1] = [0,M/2-1] , - // iW==1, = [M/2,M-1] - // etc.. - int m_M_0, m_M_1; - const std::vector & m_entity_rank_names; - IdVector m_id_max; - std::string m_globalIdFile; - std::string m_localNodeRegistryFile; - std::string m_globalNodeRegistryFile; - std::string m_globalPartsFile; - const unsigned FAMILY_TREE_RANK; - static const bool m_debug = false; - int m_spatialDim; - PartMap *m_partMap; - NodeMap *m_nodeMap; - std::string m_geomFile; - - public: - enum { MaxPass = 3 }; - - SerializeNodeRegistry(PerceptMesh& eMesh, NodeRegistry* nodeRegistry, std::string input_mesh_name, std::string output_mesh_name, - int M, int iM, int W=1, int iW=0, int M_0=-1, int M_1=-1) : - m_eMesh(eMesh), m_nodeRegistry(nodeRegistry), m_input_mesh_name(input_mesh_name), m_output_mesh_name(output_mesh_name), m_filePrefix(input_mesh_name), - m_M(M), m_iM(iM), m_W(W), m_iW(iW), m_M_0(M_0 >= 0 ? M_0 : 0), m_M_1(M_1 >= 0 ? M_1 : M-1), - m_entity_rank_names(eMesh.get_fem_meta_data()->entity_rank_names()), - m_id_max(m_entity_rank_names.size(), 0u), FAMILY_TREE_RANK(eMesh.element_rank() + 1u), - m_partMap(0), m_nodeMap(0), m_geomFile("") - { - size_t pos = m_filePrefix.find("."); - if (pos != std::string::npos) - m_filePrefix = m_filePrefix.substr(0, pos); - m_globalIdFile = "global_id_data.yaml.W."+toString(m_W)+"."+toString(m_iW); - m_localNodeRegistryFile = std::string("local_nodeRegistry.yaml.")+toString(m_M)+"."+toString(m_iM)+"."+toString(m_W)+"."+toString(m_iW); - m_globalNodeRegistryFile = std::string("global_nodeRegistry.yaml.W."+toString(m_W)+"."+toString(m_iW)); - m_globalPartsFile = "global_parts.yaml.W."+toString(m_W)+"."+toString(m_iW); - m_spatialDim = eMesh.get_spatial_dim(); - } - - ~SerializeNodeRegistry() { - if (m_partMap) delete m_partMap; - if (m_nodeMap) delete m_nodeMap; - } - - void set_geometry_file(std::string geomFile) { m_geomFile = geomFile; } - - void pass(int streaming_pass) - { - std::cout << "\n\nM[" << m_iM << ", " << m_M << "] W[" << m_iW << ", " << m_W << "] ------ SerializeNodeRegistry ----- pass number " << streaming_pass << "\n\n" << std::endl; - - switch(streaming_pass) - { - case -1: passM1(); return; - case 0: pass0(); return; - case 1: pass1(); return; - case 2: pass2(); return; - case 3: pass3(); return; - default: - throw std::logic_error("SerializeNodeRegistry::pass unknown pass"); - } - } - - void pass_init(int streaming_pass) - { - std::cout << "\n\nM[" << m_iM << ", " << m_M << "] W[" << m_iW << ", " << m_W << "] ------ SerializeNodeRegistry ----- init pass number " << streaming_pass << "\n\n" << std::endl; - - switch(streaming_pass) - { - case -1: passM1_init(); return; - case 0: pass0_init(); return; - // case 1: pass1_init(); return; - // case 2: pass2_init(); return; - // case 3: pass3_init(); return; - // default: - // throw std::logic_error("SerializeNodeRegistry::pass unknown pass"); - } - } - - void pass_final(int streaming_pass) - { - std::cout << "\n\nM[" << m_iM << ", " << m_M << "] W[" << m_iW << ", " << m_W << "] ------ SerializeNodeRegistry ----- final pass number " << streaming_pass << "\n\n" << std::endl; - - switch(streaming_pass) - { - case -1: passM1_final(); return; - case 0: pass0_final(); return; -// case 1: pass1_final(); return; - case 2: pass2_final(); return; -// case 3: pass3_final(); return; -// default: -// throw std::logic_error("SerializeNodeRegistry::pass unknown pass"); - } - } - - //fem::CellTopology get_cell_topology( const Part & part) const; - - /** - * passM1: open unrefined mesh, get Part (exodus block) information, put to global yaml file - * (m_iM = 0...m_M) - */ - // part primary_entity_rank, topology name - void writeGlobalPartsFile() - { - m_globalPartsFile = "global_parts.yaml.W."+toString(m_W)+"."+toString(m_iW); - writeGlobalPartsFile(m_globalPartsFile, *m_partMap); - } - - void writeGlobalPartsFile(std::string fileName, PartMap& partMap) - { - std::fstream file; - file.open(fileName.c_str(), std::ios_base::out | std::ios_base::trunc); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::writeGlobalPartsFile couldn't open file ")+fileName); - } - YAML::Emitter out; - out << YAML::BeginMap; YAML_CHECK(out); - PartMap::iterator iter; - for (iter = partMap.begin(); iter != partMap.end(); ++iter) - { - out << YAML::Key << iter->first; YAML_CHECK(out); - out << YAML::Value; YAML_CHECK(out); - out << YAML::Flow; YAML_CHECK(out); - out << YAML::BeginSeq; YAML_CHECK(out); - out << iter->second.get<0>(); - out << iter->second.get<1>(); - { - out << YAML::Flow; YAML_CHECK(out); - out << YAML::BeginSeq; YAML_CHECK(out); - PartSubsets subsets = iter->second.get<2>(); - for (unsigned isub=0; isub < subsets.size(); isub++) - { - out << subsets[isub]; - } - out << YAML::EndSeq; YAML_CHECK(out); - } - out << YAML::EndSeq; YAML_CHECK(out); - } - out << YAML::EndMap; YAML_CHECK(out); - file << out.c_str(); - file.close(); - } - - void declareGlobalParts() - { - if (!m_partMap) readGlobalPartsFile(); - PartMap::iterator iter; - for (iter = m_partMap->begin(); iter != m_partMap->end(); ++iter) - { - PartName part_name = iter->first; - stk_classic::mesh::EntityRank part_rank = iter->second.get<0>(); - TopologyName topo_name = iter->second.get<1>(); - const stk_classic::mesh::Part* c_part = m_eMesh.get_fem_meta_data()->get_part(part_name); - stk_classic::mesh::Part *part = const_cast(c_part); - if (!part) - { - part = &m_eMesh.get_fem_meta_data()->declare_part(part_name, part_rank); - stk_classic::io::put_io_part_attribute(*part); - stk_classic::mesh::fem::CellTopology topo = m_eMesh.get_fem_meta_data()->get_cell_topology(topo_name); - if (!topo.getCellTopologyData()) - { - std::cout << "bad cell topo SerializeNodeRegistry::declareGlobalParts topo_name= " << topo_name << std::endl; - throw std::runtime_error("bad cell topo SerializeNodeRegistry::declareGlobalParts"); - } - stk_classic::mesh::fem::set_cell_topology(*part, topo); - } - } - // once parts are declared, declare part subsets - for (iter = m_partMap->begin(); iter != m_partMap->end(); ++iter) - { - PartName part_name = iter->first; - const stk_classic::mesh::Part* c_part = m_eMesh.get_fem_meta_data()->get_part(part_name); - stk_classic::mesh::Part *part = const_cast(c_part); - if (!part) - { - throw std::runtime_error(std::string("no part found SerializeNodeRegistry::declareGlobalParts: part= ")+part_name); - } - PartSubsets subsets = iter->second.get<2>(); - for (unsigned isub=0; isub < subsets.size(); isub++) - { - const stk_classic::mesh::Part* c_subset = m_eMesh.get_fem_meta_data()->get_part(subsets[isub]); - stk_classic::mesh::Part *subset = const_cast(c_subset); - - if (!subset) - { - throw std::runtime_error(std::string("no subset part found SerializeNodeRegistry::declareGlobalParts: subset part= ")+subsets[isub]); - } - m_eMesh.get_fem_meta_data()->declare_part_subset(*part, *subset); - } - } - } - - // part primary_entity_rank, topology name - void readGlobalPartsFile() - { - if (m_partMap) delete m_partMap; - m_partMap = new PartMap; - - readGlobalPartsFile(m_globalPartsFile, *m_partMap); - } - - // merge parts if already there - void readGlobalPartsFile(std::string fileName, PartMap& partMap) - { - std::fstream file; - file.open(fileName.c_str(), std::ios_base::in); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::readGlobalPartsFile couldn't open file ")+fileName); - } - - YAML::Parser parser(file); - YAML::Node doc; - - try { - while(parser.GetNextDocument(doc)) { - //std::cout << "\n readGlobalPartsFile doc.Type() = " << doc.Type() << " doc.Tag()= " << doc.Tag() << " doc.size= " << doc.size() << std::endl; - if (doc.Type() == YAML::NodeType::Map) - { - for(YAML::Iterator iter=doc.begin();iter!=doc.end();++iter) - { - const YAML::Node& key = iter.first(); - PartName part_name; - key >> part_name; - - const YAML::Node& valSeq = iter.second(); - stk_classic::mesh::EntityRank rank; - TopologyName topo_name; - YAML::Iterator itv=valSeq.begin(); - *itv >> rank; - ++itv; - *itv >> topo_name; - ++itv; - const YAML::Node& subsetSeq = *itv; - YAML::Iterator iss; - PartSubsets subsets; - for (iss = subsetSeq.begin(); iss != subsetSeq.end(); ++iss) - { - PartName subset_name; - *iss >> subset_name; - subsets.push_back(subset_name); - } - PartMapData pmd(rank, topo_name, subsets); - if (0) - { - partMap[part_name] = pmd; - } - else - { - PartMapData& pmd_existing = partMap[part_name]; - pmd_existing.get<0>() = rank; - pmd_existing.get<1>() = topo_name; - PartSubsets& subsets_existing = pmd_existing.get<2>(); - //std::cout << "pmd read= " << pmd << std::endl; - //std::cout << "pmd existing= " << pmd_existing << std::endl; - for (unsigned isub=0; isub < subsets.size(); isub++) - { - if (std::find(subsets_existing.begin(), subsets_existing.end(), subsets[isub]) == subsets_existing.end()) - { - subsets_existing.push_back(subsets[isub]); - } - } - } - } - } - else - { - throw std::runtime_error("bad global_parts file"); - } - } - } - catch(YAML::ParserException& e) { - std::cout << e.what() << "\n"; - throw std::runtime_error( e.what()); - } - file.close(); - } - - /** - * loop over all files (m_iM...) - * loop over all my nodes - * add my proc rank to map value - * - * cull node map (only nodes that are shared remain) - * - * write nodeMap to file by procId: shared node with proc (map > ) - * loop over nodes, procs sharing node, NodeMapVector[procs][node] = owner - * - * put NodeMapVector[proc] out in separate file - * - * NodeMap read back in gives shared nodes mapped to owner - so, if not in map, not shared - */ - - void writeNodeMap(std::string fileName, int jM, bool is_local) - { - std::fstream file; - file.open(fileName.c_str(), std::ios_base::out | std::ios_base::trunc); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::writeNodeMap couldn't open file ")+fileName); - } - YAML::Emitter out; - out << YAML::BeginMap; YAML_CHECK(out); - NodeMap::iterator iter; - for (iter = m_nodeMap->begin(); iter != m_nodeMap->end(); ++iter) - { - NodeMapValue& procs = iter->second; - bool include_entry = true; - if (is_local) - { - if (procs.size() <= 1) throw std::logic_error("SerializeNodeRegistry::writeNodeMap procs.size is <=1"); - NodeMapValue::iterator find_my_proc = std::find(procs.begin(), procs.end(), jM); - include_entry = include_entry && (find_my_proc != procs.end()); // shared by me - } - if (include_entry) - { - if (procs[0] == jM) // I own it - { - } - - out << YAML::Key << iter->first; YAML_CHECK(out); - out << YAML::Value; YAML_CHECK(out); - // not strictly necessary, but we'll leave it as a sequence to be consistent with NodeMap type - out << YAML::Flow; YAML_CHECK(out); - out << YAML::BeginSeq; YAML_CHECK(out); - if (is_local) - { - // put out only the owner of the node - out << procs[0]; YAML_CHECK(out); - } - else - { - // put out all procs shared by this node - for (unsigned ii = 0; ii < procs.size(); ii++) - { - out << procs[ii]; YAML_CHECK(out); - } - } - out << YAML::EndSeq; YAML_CHECK(out); - } - } - out << YAML::EndMap; YAML_CHECK(out); - file << out.c_str(); - file.close(); - } - - /** - * file with all node/proc pairs to determine shared/non-shared nodes and ownership - */ - void createLocalNodeMapFiles(int iW) - { - VERIFY_OP_ON(m_nodeMap, !=, 0, "SerializeNodeRegistry::createLocalNodeMapFiles m_nodeMap is null"); - - for (int jM = m_M_0; jM <= m_M_1; jM++) - { - std::string localNodeMapFile = std::string("local_nodeMap.yaml")+"."+toString(m_M)+"."+toString(jM)+"."+toString(m_W)+"."+toString(iW); - - writeNodeMap(localNodeMapFile, jM, true); - } - } - - /// Remove nodes that are only touched by one processor, and are thus not shared - void cullNodeMap() - { - NodeMap::iterator iter; - std::vector non_shared; - for (iter = m_nodeMap->begin(); iter != m_nodeMap->end(); ++iter) - { - const NodeMapValue& procs = iter->second; - if (procs.size() == 1) - { - non_shared.push_back(iter->first); - } - } - for (unsigned i = 0; i < non_shared.size(); i++) - { - m_nodeMap->erase(non_shared[i]); - } - } - - // node, proc owner - void readNodeMap(std::string fileName, NodeMap& nodeMap, bool is_local) - { - std::fstream file; - file.open(fileName.c_str(), std::ios_base::in); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::readNodeMap couldn't open file ")+fileName); - } - - YAML::Parser parser(file); - YAML::Node doc; - - try { - while(parser.GetNextDocument(doc)) { - std::cout << "tmp srk readNodeMap= " << fileName - << " doc.Type() = " << doc.Type() << " doc.Tag()= " << doc.Tag() << " doc.size= " << doc.size() << std::endl; - if (doc.Type() == YAML::NodeType::Map) - { - for(YAML::Iterator iter=doc.begin();iter!=doc.end();++iter) - { - const YAML::Node& key = iter.first(); - stk_classic::mesh::EntityId id; - key >> id; - NodeMapValue procs; - const YAML::Node& val = iter.second(); - val >> procs; - //std::cout << "readNodeMap id= " << id << " procs= " << procs << std::endl; - if (is_local && procs.size() != 1) - throw std::logic_error(std::string("SerializeNodeRegistry::readNodeMap procs.size is != 1, = ")+toString(procs.size())); - NodeMapValue& procs_existing = nodeMap[id]; - for (unsigned ip=0; ip < procs.size(); ip++) - { - if (std::find(procs_existing.begin(), procs_existing.end(), procs[ip]) == procs_existing.end()) - { - procs_existing.push_back(procs[ip]); - } - } - std::sort(procs_existing.begin(), procs_existing.end()); - //std::cout << "id, procs= " << id << " " << procs_existing << std::endl; - //nodeMap[id] = procs; - } - } - else - { - throw std::runtime_error("bad nodeMap file"); - } - } - } - catch(YAML::ParserException& e) { - std::cout << e.what() << "\n"; - throw std::runtime_error( e.what()); - } - file.close(); - } - - void readLocalNodeMapFile(NodeMap& nodeMap) - { - std::string localNodeMapFile = std::string("local_nodeMap.yaml")+"."+toString(m_M)+"."+toString(m_iM)+"."+toString(m_W)+"."+toString(m_iW); - readNodeMap(localNodeMapFile, nodeMap, true); - } - - // creates m_partMap if null, reads in global part map from file - void getGlobalPartMap() - { - readGlobalPartsFile(); - } - - void setGlobalPartMap() - { - writeGlobalPartsFile(); - } - - void initializeGlobalPartMap() - { - if (m_partMap) delete m_partMap; - m_partMap = new PartMap; - setGlobalPartMap(); - } - - void getGlobalNodeMap() - { - std::cout << "tmp srk SerializeNodeRegistry::getGlobalNodeMap, m_nodeMap= " << m_nodeMap << std::endl; - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - std::string globalNodeMapFile = std::string("global_nodeMap.yaml")+".W."+toString(m_W)+"."+toString(m_iW); - readNodeMap(globalNodeMapFile, *m_nodeMap, false); - } - - void setGlobalNodeMap() - { - std::cout << "tmp srk SerializeNodeRegistry::setGlobalNodeMap\n"; - std::string globalNodeMapFile = std::string("global_nodeMap.yaml")+".W."+toString(m_W)+"."+toString(m_iW); - writeNodeMap(globalNodeMapFile, 0, false); - } - - void initializeGlobalNodeMap() - { - std::cout << "tmp srk SerializeNodeRegistry::initializeGlobalNodeMap\n"; - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - setGlobalNodeMap(); - } - - - void passM1_mergeGlobalParts() - { - const stk_classic::mesh::PartVector& parts = m_eMesh.get_fem_meta_data()->get_parts(); - for (unsigned ipart=0; ipart < parts.size(); ipart++) - { - //const Part& part = *parts[ipart]; - stk_classic::mesh::Part& part = *parts[ipart]; - if (stk_classic::mesh::is_auto_declared_part(part)) - { - continue; - } - - // only io parts allowed - if (!stk_classic::io::is_part_io_part(part)) - { - if (m_debug) std::cout << "part without io attr= " << part.name() << std::endl; - continue; - } - - stk_classic::mesh::fem::CellTopology topo = m_eMesh.get_fem_meta_data()->get_cell_topology(part); - TopologyName topo_name = "null"; - if (topo.getCellTopologyData()) topo_name = topo.getName(); - //std::cout << "part, topo= " << part.name() << " " << topo_name << std::endl; - const stk_classic::mesh::PartVector& part_subsets = part.subsets(); - PartSubsets subsets(part_subsets.size()); - for (unsigned isub=0; isub < subsets.size(); isub++) - { - subsets[isub] = part_subsets[isub]->name(); - } - PartMapData pmd(part.primary_entity_rank(), topo_name, subsets); - PartMap::iterator inMap = m_partMap->find(part.name()); - // if not yet in the map, or if already in map, choose to overwrite if this is the one with subset info - if (inMap == m_partMap->end()) - { - if (m_debug) std::cout << "mergeGlobalParts:: not yet in map, part = " << part.name() << " data= " << pmd << std::endl; - (*m_partMap)[part.name()] = pmd; - } - else - { - PartSubsets& inMapSubsets = inMap->second.get<2>(); - if (m_debug) std::cout << "mergeGlobalParts:: in map, before, part = " << part.name() << " data= " << pmd << std::endl; - for (unsigned isub=0; isub < subsets.size(); isub++) - { - PartSubsets::iterator iv = find(inMapSubsets.begin(), inMapSubsets.end(), subsets[isub]); - if (iv == inMapSubsets.end()) - { - inMapSubsets.push_back(subsets[isub]); - } - } - if (m_debug) std::cout << "mergeGlobalParts:: in map, after, part = " << part.name() << " data= " << pmd << std::endl; - } - } - // init/fini - if (m_W == 1 && m_iM == m_M_1) - { - writeGlobalPartsFile(); - } - } - - // open each global nodes file and add to the global node map - void createGlobalNodeMap() - { - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - for (m_iM = m_M_0; m_iM <= m_M_1; m_iM++) - { - readLocalNodeMapFile(*m_nodeMap); - } - } - - void passM1_createLocalNodeMap() - { - const std::vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entities_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_entities_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - stk_classic::mesh::EntityId id = entity.identifier(); - NodeMapValue& procs = (*m_nodeMap)[id]; - if (procs.size() == 0) - { - procs.push_back(m_iM); - } - else - { - NodeMapValue::iterator it = std::find(procs.begin(), procs.end(), m_iM); - if (it == procs.end()) - { - procs.push_back(m_iM); - std::sort(procs.begin(), procs.end()); - } - } - } - } - } - // init/fini - if (m_W == 1 && m_iM == m_M_1) - { - cullNodeMap(); - createLocalNodeMapFiles(m_iW); - } - } - - static void getStreamingPiece(int M, int W, int iW, int& M_0, int& M_1) - { - VERIFY_OP_ON(W, >, 0, "AdaptMain::getStreamingPiece #0"); - VERIFY_OP_ON(M, >, 0, "AdaptMain::getStreamingPiece #1"); - VERIFY_OP_ON(M % W, ==, 0, "AdaptMain::getStreamingPiece: streaming_size M must be divisible by number of workers W."); - int len = M / W; - M_0 = iW*len; - M_1 = (iW+1)*len - 1; // we use these as start/end, as in for(int iM = M_0; iM <= M_1; iM++) - } - - void pass0_init() - { - std::cout << "pass0_init\n"; - // create initial file, write 0's in it for m_id_max (it should be initialized to 0, but just to be sure, we reset it here) - for (unsigned irank=0; irank < m_id_max.size(); irank++) - m_id_max[irank]=0u; - for (int jW = 0; jW < m_W; jW++) - { - std::string globalIdFile = "global_id_data.yaml.W."+toString(m_W)+"."+toString(jW); - std::cout << "pass0_init globalIdFile= " << globalIdFile << std::endl; - setCurrentGlobalMaxId(globalIdFile, m_id_max); - } - } - - void pass0_final() - { - std::cout << "pass0_final, m_id_max= " << m_id_max << std::endl; - for (unsigned irank=0; irank < m_id_max.size(); irank++) - { - m_id_max[irank]=0u; - } - - // first, get the max of all - IdVector id_max_local_0(m_id_max.size(), 0u); - // now get how many each iW used - IdVector id_used(m_id_max.size(), 0u); - std::vector num_id_used(m_W); - for (int jW = 0; jW < m_W; jW++) - { - std::string globalIdFile = "global_id_data.yaml.W."+toString(m_W)+"."+toString(jW); - getCurrentGlobalMaxId(globalIdFile, id_max_local_0, true); - getCurrentGlobalMaxId(globalIdFile, id_used, false); - num_id_used[jW] = id_used; - std::cout << "pass0_final: num_id_used = " << num_id_used[jW] << std::endl; - } - - std::vector id_max_new(m_W); - id_max_new[0] = id_max_local_0; - std::cout << "pass0_final: id_max_new[0] = " << id_max_new[0] << std::endl; - for (int jW = 1; jW < m_W; jW++) - { - id_max_new[jW].resize(m_id_max.size()); - for (unsigned irank=0; irank < id_max_local_0.size(); irank++) - { - id_max_new[jW][irank] = id_max_new[jW-1][irank] + (num_id_used[jW-1][irank] + 1); - } - std::cout << "pass0_final: id_max_new[jW] = " << id_max_new[jW] << std::endl; - } - - for (int jW = 0; jW < m_W; jW++) - { - std::string globalIdFileWrite = "global_id_data.yaml.W."+toString(m_W)+"."+toString(jW); - setCurrentGlobalMaxId(globalIdFileWrite, id_max_new[jW]); - } - // for (int jW = 0; jW < m_W; jW++) - // { - // setCurrentGlobalMaxId(globalIdFile, m_id_max); - // } - //printCurrentGlobalMaxId("pass0"); - } - - void passM1_init() - { - // init/fini - VERIFY_OP_ON(m_iW, ==, -1, "passM1_init #0"); - for (m_iW = 0; m_iW < m_W; ++m_iW) - { - initializeGlobalPartMap(); - initializeGlobalNodeMap(); - } - m_iW = -1; - } - - void passM1_final() - { - PartMap partMap; - for (int jW = 0; jW < m_W; jW++) - { - std::string globalPartMapFile = std::string("global_parts.yaml")+".W."+toString(m_W)+"."+toString(jW); - // does a merge... - readGlobalPartsFile(globalPartMapFile, partMap); - } - for (int jW = 0; jW < m_W; jW++) - { - std::string globalPartMapFile = std::string("global_parts.yaml")+".W."+toString(m_W)+"."+toString(jW); - //std::string globalPartMapFile = std::string("global_parts.yaml")+".W."+toString(m_W)+"."+toString(m_W); - writeGlobalPartsFile(globalPartMapFile, partMap); - } - - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - for (int jW = 0; jW < m_W; jW++) - { - std::string globalNodeMapFile = std::string("global_nodeMap.yaml")+".W."+toString(m_W)+"."+toString(jW); - readNodeMap(globalNodeMapFile, *m_nodeMap, false); - } - cullNodeMap(); - std::cout << "m_nodeMap->size() = " << m_nodeMap->size() << " m_W= " << m_W << std::endl; - for (int jW = 0; jW < m_W; jW++) - { - SerializeNodeRegistry::getStreamingPiece(m_M, m_W, jW, m_M_0, m_M_1); - createLocalNodeMapFiles(jW); - } - } - - void passM1() - { - for (int m_iM = m_M_0; m_iM <= m_M_1; m_iM++) - { - //input_mesh = input_mesh_save+"."+toString(M)+"."+toString(m_iM); - std::string input_mesh = Ioss::Utils::decode_filename(m_input_mesh_name, m_iM, m_M); - PerceptMesh eMesh(m_spatialDim); - eMesh.open_read_only(input_mesh); - NodeRegistry *some_nr = 0; - SerializeNodeRegistry snr(eMesh, some_nr, m_input_mesh_name, m_output_mesh_name, m_M, m_iM, m_W, m_iW, m_M_0, m_M_1); - - // init/fini - if (m_W == 1 && m_iM == m_M_0) - { - snr.initializeGlobalPartMap(); - snr.initializeGlobalNodeMap(); - } - - snr.getGlobalPartMap(); - snr.passM1_mergeGlobalParts(); - snr.setGlobalPartMap(); - - snr.getGlobalNodeMap(); - snr.passM1_createLocalNodeMap(); - snr.setGlobalNodeMap(); - - } - } - - /** - * pass0: open unrefined mesh, refine it, find max id - * (m_iM = 0...M) - * 1. if m_iM==0, setCurrentGlobalMaxId to [0,0,0,0] - * 2. getCurrentGlobalMaxId() - * 3. find new max id from current mesh - * 4. setCurrentGlobalMaxId() - */ - void pass0() - { - // init/fini - if (m_W == 1 && m_iM == m_M_0 ) - { - // create initial file, write 0's in it for m_id_max (it should be initialized to 0, but just to be sure, we reset it here) - for (unsigned irank=0; irank < m_id_max.size(); irank++) - m_id_max[irank]=0u; - setCurrentGlobalMaxId(); - } - - getCurrentGlobalMaxId(); - findCurrentMaxId(m_eMesh); - setCurrentGlobalMaxId(); - printCurrentGlobalMaxId("pass0"); - } - - void printCurrentGlobalMaxId(std::string msg="") - { - //if (m_debug) - std::cout << "M[" << m_iM << ", " << m_M << "] W[" << m_iW << ", " << m_W << "] SerializeNodeRegistry::printCurrentGlobalMaxId: = " << m_id_max << " for: " << msg << std::endl; - } - - /** - * pass1: refine mesh, write local NodeRegistry, set new max id from refined mesh - assumes parent elements exist - * - * (m_iM = 0...M) - * 1. open file.e.M.m_iM, refine mesh - * 2. - * 3. getCurrentGlobalMaxId() - * 4. resetNewElementIds() (resets new element ids by looking at child elements only) - * 5. write NodeRegistry in name.yaml.M.m_iM - * 6. setCurrentGlobalMaxId() - * 7. save refined mesh - */ - void pass1() - { - NodeRegistry& nodeRegistry = *m_nodeRegistry; - getCurrentGlobalMaxId(); - resetNewElementIds(m_eMesh, nodeRegistry); - resetNewNodeIds(nodeRegistry); - setCurrentGlobalMaxId(); - printCurrentGlobalMaxId("pass1"); - - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - readLocalNodeMapFile(*m_nodeMap); - writeNodeRegistry(nodeRegistry, m_localNodeRegistryFile); - } - - /** - * pass2 - create global NodeRegistry from each local one by "last one wins" - * (single call, no loop over m_iM) - * 1. create new (global) NodeRegistry - * 2. getCurrentGlobalMaxId - * 3. loop m_iM - * a. read NodeRegistry from name.yaml.M.m_iM -> input values into new NodeRegistry - * 4. for each key/value pair, increment idserver, save new id in value - * 5. write new global NodeRegistry - * - */ - void pass2() - { - if (m_iM != m_M_0) throw std::logic_error("SerializeNodeRegistry::pass2 logic error"); - if (m_W > 1) return; // done in pass2_final - - getCurrentGlobalMaxId(); - printCurrentGlobalMaxId("pass2 initial"); - - PerceptMesh eMeshNew(m_spatialDim); - eMeshNew.openEmpty(); - NodeRegistry globalNR(eMeshNew); - - PerceptMesh eMeshLocal(m_spatialDim); - eMeshLocal.openEmpty(); - - for (m_iM = m_M_0; m_iM <= m_M_1; m_iM++) - { - NodeRegistry newLocalNR(eMeshLocal); - m_localNodeRegistryFile = std::string("local_nodeRegistry.yaml.")+toString(m_M)+"."+toString(m_iM)+"."+toString(m_W)+"."+toString(m_iW); - readNodeRegistry(newLocalNR, m_localNodeRegistryFile); - addLocalNodeRegistryToGlobal(newLocalNR, globalNR); - } - - createGlobalNodeMap(); - - writeNodeRegistry(globalNR, m_globalNodeRegistryFile); - setCurrentGlobalMaxId(); - printCurrentGlobalMaxId("pass2 done"); - } - - void pass2_final() - { -// getCurrentGlobalMaxId(); -// printCurrentGlobalMaxId("pass2 initial"); - - PerceptMesh eMeshNew(m_spatialDim); - eMeshNew.openEmpty(); - NodeRegistry globalNR(eMeshNew); - - PerceptMesh eMeshLocal(m_spatialDim); - eMeshLocal.openEmpty(); - - if (m_nodeMap) delete m_nodeMap; - m_nodeMap = new NodeMap; - - int iWSave = m_iW; - for (int jW = 0; jW < m_W; jW++) - { - SerializeNodeRegistry::getStreamingPiece(m_M, m_W, jW, m_M_0, m_M_1); - m_iW = jW; - - for (m_iM = m_M_0; m_iM <= m_M_1; m_iM++) - { - NodeRegistry newLocalNR(eMeshLocal); - std::string localNodeRegistryFile = std::string("local_nodeRegistry.yaml.")+toString(m_M)+"."+toString(m_iM)+"."+toString(m_W)+"."+toString(jW); - readNodeRegistry(newLocalNR, localNodeRegistryFile); - addLocalNodeRegistryToGlobal(newLocalNR, globalNR); - - // replacement for: createGlobalNodeMap(); - readLocalNodeMapFile(*m_nodeMap); - } - } - m_iW = iWSave; - - for (int jW = 0; jW < m_W; jW++) - { - std::string globalNodeRegistryFile = "global_nodeRegistry.yaml.W."+toString(m_W)+"."+toString(jW); - writeNodeRegistry(globalNR, globalNodeRegistryFile); - } - //setCurrentGlobalMaxId(); - //printCurrentGlobalMaxId("pass2 done"); - } - - /** - * pass 3: - * 1. read global NodeRegistry - * 2. read each refined file-ref.M.m_iM - * 3. lookup edge/face/elem in global NodeRegistry, reset id to that found in NR - * 4. write refined file-ref-id.M.m_iM - */ - private: - void pass3() - { - PerceptMesh eMeshGlobal(m_spatialDim); - eMeshGlobal.openEmpty(); - // here we use the same eMesh to use the same BulkData - this could be changed if we didn't use pointers - // but always used id's in the maps' keys - //PerceptMesh eMeshLocal(m_spatialDim); - //eMeshLocal.openEmpty(); - NodeRegistry globalNR(eMeshGlobal); - //NodeRegistry localNR(eMeshLocal); - NodeRegistry localNR(eMeshGlobal); - readNodeRegistry(localNR, m_localNodeRegistryFile); - readNodeRegistry(globalNR, m_globalNodeRegistryFile); - lookupAndSetNewNodeIds(localNR, globalNR); - } - - public: - // single call instead of multiple loops on iM from caller - sets global parts, sets new node Ids from global nodeRegistry - void pass3_new() - { - for (int jM = m_M_0; jM <= m_M_1; jM++) - { - std::string input_mesh_new = m_output_mesh_name+"-pass1"; - input_mesh_new = Ioss::Utils::decode_filename(input_mesh_new, jM, m_M); - std::string output_mesh_new = Ioss::Utils::decode_filename(m_output_mesh_name, jM, m_M); - PerceptMesh eMesh(0); - eMesh.open(input_mesh_new); - m_spatialDim = eMesh.get_spatial_dim(); - eMesh.setStreamingSize(m_M); - NodeRegistry *some_nr0 = 0; - SerializeNodeRegistry snr0(eMesh, some_nr0, m_input_mesh_name, m_output_mesh_name, m_M, jM, m_W, m_iW, m_M_0, m_M_1); - snr0.getGlobalPartMap(); - snr0.declareGlobalParts(); - eMesh.commit(); - - NodeRegistry *some_nr = 0; - SerializeNodeRegistry snr(eMesh, some_nr, m_input_mesh_name, m_output_mesh_name, m_M, jM, m_W, m_iW, m_M_0, m_M_1); - snr.pass(3); - std::cout << "tmp srk debug SerializeNodeRegistry: " << PERCEPT_OUT(m_M) << PERCEPT_OUT(jM) << PERCEPT_OUT(m_W) << PERCEPT_OUT(m_iW) << PERCEPT_OUT(m_M_0) << PERCEPT_OUT(m_M_1) << " output_mesh_new= " << output_mesh_new << std::endl; - if (m_geomFile != "") - eMesh.remove_geometry_blocks_on_output(m_geomFile); - eMesh.save_as(output_mesh_new); - } - } - - // for each subDimEntity in local NodeRegistry, find it in the global NodeRegistry and reset ID's to the global values - void lookupAndSetNewNodeIds(NodeRegistry& localNR, NodeRegistry& globalNR) - { - m_eMesh.get_bulk_data()->modification_begin(); - SubDimCellToDataMap& localMap = localNR.getMap(); - //SubDimCellToDataMap& globalMap = globalNR.getMap(); - //std::cout << " tmp SerializeNodeRegistry::lookupAndSetNewNodeIds localMap size: " << localMap.size() << std::endl; - - SubDimCellToDataMap::iterator iter; - for (iter = localMap.begin(); iter != localMap.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = iter->first; - SubDimCellData& nodeId_elementOwnderId = iter->second; - - // special case for "interior" subDimEntity's which are centroid nodes for quad or hex elements - - // by definition they aren't shared - if (subDimEntity.size() == 1) - continue; - - // lookup from global... - SubDimCellData* global_nodeId_elementOwnderId_ptr = globalNR.getFromMapPtr(subDimEntity); - if (!global_nodeId_elementOwnderId_ptr) - { - std::cout << "M[" << m_iM << "] SerializeNodeRegistry::lookupAndSetNewNodeIds couldn't find subDimEntity= " << subDimEntity; - for (unsigned kk=0; kk < subDimEntity.size(); kk++) - { - std::cout << " [" << subDimEntity[kk]->identifier() << "] "; - } - std::cout << std::endl; - } - else - { - } - VERIFY_OP_ON(global_nodeId_elementOwnderId_ptr, !=, 0, "SerializeNodeRegistry::lookupAndSetNewNodeIds couldn't find subDimEntity"); - - NodeIdsOnSubDimEntityType& global_nodeIds_onSE = global_nodeId_elementOwnderId_ptr->get(); - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned global_nnodes = global_nodeIds_onSE.size(); - unsigned nnodes = nodeIds_onSE.size(); - VERIFY_OP_ON(global_nnodes, ==, nnodes, "SerializeNodeRegistry::lookupAndSetNewNodeIds: mismatch in nnodes"); - - for (unsigned inode=0; inode < nnodes; inode++) - { - stk_classic::mesh::EntityId id_new = global_nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::EntityId id_old = nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::Entity* tmp_global_node = globalNR.getMesh().get_bulk_data()->get_entity(0, id_new); - stk_classic::mesh::Entity* local_node_to_change = m_eMesh.get_bulk_data()->get_entity(0, id_old); - if (m_debug) std::cout << "m_iM= " << m_iM << " id_new= " << id_new << " id_old= " << id_old << std::endl; - VERIFY_OP_ON(local_node_to_change, !=, 0, "SerializeNodeRegistry::lookupAndSetNewNodeIds null local_node_to_change"); - VERIFY_OP_ON(tmp_global_node, !=, 0, "SerializeNodeRegistry::lookupAndSetNewNodeIds null tmp_global_node"); - VERIFY_OP_ON(tmp_global_node, ==, global_nodeIds_onSE[inode], "SerializeNodeRegistry::lookupAndSetNewNodeIds new node mistmatch"); - if (id_new != id_old) - { - if (m_debug) std::cout << "DIFF m_iM= " << m_iM << " id_new= " << id_new << " id_old= " << id_old << std::endl; - stk_classic::mesh::Entity* local_node_new_id_check = m_eMesh.get_bulk_data()->get_entity(0, id_new); - if (!local_node_new_id_check) - { - m_eMesh.get_bulk_data()->change_entity_id(id_new, *local_node_to_change); - } - } - } - } - m_eMesh.get_bulk_data()->modification_end(); - } - - void writeNodeRegistry(NodeRegistry& nodeRegistry, std::string filename) - { - YAML::Emitter yaml; - if (m_debug) std::cout << "\nnodeRegistry.serialize_write(yaml) to file= " << filename << std::endl; - // old way was to not use the node map to filter and so we wrote the whole interior and boundary map - const bool do_filter_for_shared_nodes = true; - if (do_filter_for_shared_nodes) - serialize_write(nodeRegistry, yaml, m_nodeMap); - else - serialize_write(nodeRegistry, yaml, 0); - if (!yaml.good()) - { - std::cout << "Emitter error: " << yaml.good() << " " < } - // value.serialized = { {new_nid0, new_nid1,...}:vector, {elem_own[rank, ele_id]:EntityKey} } - - for (iter = localMap.begin(); iter != localMap.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - if (m_debug) - { - std::cout << "SerializeNodeRegistry::processNodeRegistry inserting localMap entry = " << subDimEntity ; - for (unsigned kk=0; kk < subDimEntity.size(); kk++) - { - std::cout << " [" << subDimEntity[kk]->identifier() << "] "; - } - std::cout << " data= " << nodeId_elementOwnderId << " nid=" << nodeId_elementOwnderId.get().m_entity_id_vector[0] << std::endl; - } - /// clone subDimEntity... - globalMap[subDimEntity] = nodeId_elementOwnderId; - } - if (m_debug) std::cout << "SerializeNodeRegistry::processNodeRegistry globalMap size= " << globalMap.size() << std::endl; - } - - ///Note: we read and write to a file instead of storing in memory to allow stk_adapt_exe to be called on a - // single piece of the partition - useful for testing and for potentially parallelizing the global outer loop - void getCurrentGlobalMaxId() - { - getCurrentGlobalMaxId(m_globalIdFile, m_id_max, false); - } - - void getCurrentGlobalMaxId(std::string fileName, IdVector& id_max, bool merge=false) - { - // get max node, element id, dump to global file, if global file exists, read from it, use those as start values - std::fstream file; - file.open(fileName.c_str(), std::ios_base::in); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::getCurrentGlobalMaxId couldn't open file ")+fileName); - } - - YAML::Parser parser(file); - YAML::Node doc; - stk_classic::mesh::EntityId id_max_local; - try { - while(parser.GetNextDocument(doc)) { - if (m_debug) std::cout << "\n read doc.Type() = " << doc.Type() << " doc.Tag()= " << doc.Tag() << " doc.size= " << doc.size() << std::endl; - if (doc.Type() == YAML::NodeType::Map) - { - for (unsigned irank=0; irank < m_id_max.size(); irank++) - { - doc[m_entity_rank_names[irank]] >> id_max_local; - if (merge) - { - id_max[irank] = std::max(id_max_local, id_max[irank]); - } - else - { - id_max[irank] = id_max_local; - } - } - } - else - { - throw std::runtime_error("bad streaming-refine-global-data file"); - } - } - } - catch(YAML::ParserException& e) { - std::cout << e.what() << "\n"; - throw std::runtime_error( e.what()); - } - file.close(); - } - - void setCurrentGlobalMaxId() - { - setCurrentGlobalMaxId(m_globalIdFile, m_id_max); - } - - void setCurrentGlobalMaxId(std::string fileName, IdVector& id_max) - { - std::fstream file; - file.open(fileName.c_str(), std::ios_base::out | std::ios_base::trunc); - if (!file.is_open()) - { - throw std::runtime_error(std::string("SerializeNodeRegistry::setCurrentGlobalMaxId couldn't open file ")+fileName); - } - - YAML::Emitter out; - out << YAML::BeginMap; - for (unsigned irank=0; irank < id_max.size(); irank++) - { - out << YAML::Key << m_entity_rank_names[irank] << YAML::Value << id_max[irank]; - } - out << YAML::EndMap; - file << out.c_str(); - file.close(); - } - - void findCurrentMaxId(PerceptMesh& eMesh) - { - for (unsigned irank=0; irank < m_id_max.size(); irank++) - { - // bucket loop - const std::vector & buckets = eMesh.get_bulk_data()->buckets( irank ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entities_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_entities_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - stk_classic::mesh::EntityId id = entity.identifier(); - m_id_max[irank] = std::max(m_id_max[irank], id); - } - } - } - } - } - - // use id_max values as a simple id server to reset new element ids - void resetNewElementIds(PerceptMesh& eMesh, NodeRegistry& nodeRegistry) - { - - typedef std::pair EntityPair; - for (unsigned irank=1; irank < m_id_max.size(); irank++) - { - if (irank == FAMILY_TREE_RANK) continue; - // bucket loop - const std::vector & buckets = eMesh.get_bulk_data()->buckets( irank ); - std::vector id_change; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entities_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_entities_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - //! FIXME - //if (eMesh.hasFamilyTree(entity) && eMesh.isChildElement(entity)) - { - stk_classic::mesh::EntityId id = m_id_max[irank] + 1; - m_id_max[irank] = id; - - stk_classic::mesh::EntityId id_old = entity.identifier(); - id_change.push_back(EntityPair(id_old, id)); - } - } - } - } - - eMesh.get_bulk_data()->modification_begin(); - - for (unsigned ii=0; ii< id_change.size(); ii++) - { - stk_classic::mesh::Entity *entity = eMesh.get_bulk_data()->get_entity(irank, id_change[ii].first); - VERIFY_OP_ON(entity, !=, 0, "SerializeNodeRegistry::resetNewElementIds"); - VERIFY_OP_ON(entity->identifier(), ==, id_change[ii].first, "SerializeNodeRegistry::resetNewElementIds bad00"); - stk_classic::mesh::EntityId id_new = id_change[ii].second; - //stk_classic::mesh::EntityId id_old = entity->identifier(); - eMesh.get_bulk_data()->change_entity_id(id_new, *entity); - } - } - } - - void checkNR(NodeRegistry& nodeRegistry, std::string msg="") - { - nodeRegistry.getMesh().get_bulk_data()->modification_begin(); - - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = nodeRegistry.getMap(); - std::cout << " tmp SerializeNodeRegistry::checkNR msg= " << msg << " map size: " << map.size() << std::endl; - - if (1) - { - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nnodes = nodeIds_onSE.size(); - for (unsigned inode=0; inode < nnodes; inode++) - { - VERIFY_OP_ON(nodeIds_onSE[inode], !=, 0, "SerializeNodeRegistry::checkNR node is null 0"); - stk_classic::mesh::EntityId id_old = nodeIds_onSE.m_entity_id_vector[inode]; - VERIFY_OP_ON(id_old, !=, 0, "SerializeNodeRegistry::checkNR node id is 0"); - stk_classic::mesh::EntityId id_old_check = nodeIds_onSE[inode]->identifier(); - if (nodeIds_onSE[inode]->entity_rank() != 0) - std::cout << "SerializeNodeRegistry checkNR 1" << nodeIds_onSE[inode]->identifier() << " " << msg << std::endl; - - VERIFY_OP_ON(nodeIds_onSE[inode]->entity_rank(), ==, 0, "SerializeNodeRegistry checkNR 1"); - if (id_old_check != id_old) - std::cout << "SerializeNodeRegistry checkNR 2" << nodeIds_onSE[inode]->identifier() << " " << msg << std::endl; - - VERIFY_OP_ON(id_old_check, ==, id_old, "SerializeNodeRegistry::checkNR id_old"); - - stk_classic::mesh::Entity *node = nodeRegistry.getMesh().get_bulk_data()->get_entity(0, id_old); - VERIFY_OP_ON(node, !=, 0, "SerializeNodeRegistry::checkNR node is null"); - VERIFY_OP_ON(node, ==, nodeIds_onSE[inode], "SerializeNodeRegistry::checkNR node is not same"); - } - } - } - std::cout << " tmp SerializeNodeRegistry::checkNR done msg= " << msg << " map size: " << map.size() << std::endl; - nodeRegistry.getMesh().get_bulk_data()->modification_end(); - } - - void fixNR(NodeRegistry& nodeRegistry, std::string msg="") - { - nodeRegistry.getMesh().get_bulk_data()->modification_begin(); - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = nodeRegistry.getMap(); - std::cout << " tmp SerializeNodeRegistry::fixNR msg= " << msg << " map size: " << map.size() << std::endl; - - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nnodes = nodeIds_onSE.size(); - for (unsigned inode=0; inode < nnodes; inode++) - { - stk_classic::mesh::EntityId id = nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::Entity *node = nodeRegistry.getMesh().get_bulk_data()->get_entity(0, id); - VERIFY_OP_ON(node, !=, 0, "SerializeNodeRegistry::fixNR node is null "+toString(id)); - nodeIds_onSE[inode] = node; - } - } - nodeRegistry.getMesh().get_bulk_data()->modification_end(); - std::cout << " tmp SerializeNodeRegistry::fixNR done msg= " << msg << " map size: " << map.size() << std::endl; - } - - /// Using the current global max id, in a simple id-server manner, generate new id's and assign to - /// the shared nodes. - void resetNewNodeIds(NodeRegistry& nodeRegistry) - { - nodeRegistry.getMesh().get_bulk_data()->modification_begin(); - - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = nodeRegistry.getMap(); - std::cout << " tmp SerializeNodeRegistry::resetNewNodeIds map size: " << map.size() << std::endl; - - if (1) - { - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nnodes = nodeIds_onSE.size(); - for (unsigned inode=0; inode < nnodes; inode++) - { - stk_classic::mesh::EntityId id_old = nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::EntityId id_old_check = nodeIds_onSE[inode]->identifier(); - VERIFY_OP_ON(id_old_check, ==, id_old, "SerializeNodeRegistry::resetNewNodeIds id_old"); - } - } - } - // key.serialized = { nodeid_0,... : set } - // value.serialized = { {new_nid0, new_nid1,...}:vector, {elem_own[rank, ele_id]:EntityKey} } - - for (iter = map.begin(); iter != map.end(); ++iter) - { - //const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - unsigned nnodes = nodeIds_onSE.size(); - for (unsigned inode=0; inode < nnodes; inode++) - { - stk_classic::mesh::EntityId id_old = nodeIds_onSE.m_entity_id_vector[inode]; - stk_classic::mesh::EntityId id_old_check = nodeIds_onSE[inode]->identifier(); - VERIFY_OP_ON(id_old_check, ==, id_old, "SerializeNodeRegistry::resetNewNodeIds id_old"); - - stk_classic::mesh::EntityId id_new = m_id_max[0]+1; - m_id_max[0] = id_new; - nodeIds_onSE.m_entity_id_vector[inode] = id_new; - - nodeRegistry.getMesh().get_bulk_data()->change_entity_id(id_new, *nodeIds_onSE[inode]); - - stk_classic::mesh::EntityId id_new_check = nodeIds_onSE[inode]->identifier(); - VERIFY_OP_ON(id_new_check, ==, id_new, "SerializeNodeRegistry::resetNewNodeIds id_new"); - id_new = nodeIds_onSE.m_entity_id_vector[inode]; - - VERIFY_OP_ON(id_new_check, ==, id_new, "SerializeNodeRegistry::resetNewNodeIds id_new 2"); - } - } - nodeRegistry.getMesh().get_bulk_data()->modification_end(); - } - - - static void serialize_write(NodeRegistry& nodeRegistry, YAML::Emitter& emitter, NodeMap *nodeMapFilter = 0, std::string msg="") - { - SubDimCellToDataMap::iterator iter; - SubDimCellToDataMap& map = nodeRegistry.getMap(); - //std::cout << msg << " tmp serialize_write map size: " << map.size() << std::endl; - - if (0) emitter << YAML::Anchor("NodeRegistry::map"); YAML_ERRCHECK; - //emitter << YAML::Flow; YAML_ERRCHECK; - emitter << YAML::BeginMap; YAML_ERRCHECK; - - // key.serialized = { nodeid_0,... : set } - // value.serialized = { {new_nid0, new_nid1,...}:vector, {elem_own[rank, ele_id]:EntityKey} } - - int jj=0; - for (iter = map.begin(); iter != map.end(); ++iter) - { - const SubDimCell_SDSEntityType& subDimEntity = (*iter).first; - SubDimCellData& nodeId_elementOwnderId = (*iter).second; - - // check if all nodes are on the boundary (defined by shared nodes in the NodeMap) - if (nodeMapFilter) - { - // special case for "interior" subDimEntity's which are centroid nodes for quad or hex elements - - // by definition they aren't shared - if (subDimEntity.size() == 1) - continue; - - bool notFound = false; - for (unsigned k=0; k < subDimEntity.size(); k++) - { - //std::cout << " " << subDimEntity[k]->identifier() << " "; - NodeMap::iterator filter_iter = nodeMapFilter->find(subDimEntity[k]->identifier()); - if (filter_iter == nodeMapFilter->end()) - { - notFound = true; - break; - } - } - if (notFound) - continue; - } - - //emitter << YAML::Key << subDimEntity; - emitter << YAML::Key; YAML_ERRCHECK; - emitter << YAML::Flow; YAML_ERRCHECK; - emitter << YAML::BeginSeq; YAML_ERRCHECK; - if (0) emitter << YAML::Anchor(std::string("seq")+boost::lexical_cast(jj++)); YAML_ERRCHECK; - for (unsigned k=0; k < subDimEntity.size(); k++) - { - //std::cout << " " << subDimEntity[k]->identifier() << " "; - emitter << subDimEntity[k]->identifier(); YAML_ERRCHECK; - } - emitter << YAML::EndSeq; YAML_ERRCHECK; - - NodeIdsOnSubDimEntityType& nodeIds_onSE = nodeId_elementOwnderId.get(); - stk_classic::mesh::EntityKey& value_entity_key = nodeId_elementOwnderId.get(); - - //emitter << YAML::Scalar << nodeIds_onSE.size() - emitter << YAML::Value; YAML_ERRCHECK; - emitter << YAML::Flow; YAML_ERRCHECK; - emitter << YAML::BeginSeq; YAML_ERRCHECK; - emitter << stk_classic::mesh::entity_rank(value_entity_key); - emitter << stk_classic::mesh::entity_id(value_entity_key); - for (unsigned ii = 0; ii < nodeIds_onSE.size(); ii++) - { - //emitter << (int)nodeIds_onSE[ii]->identifier(); YAML_ERRCHECK; - stk_classic::mesh::EntityId id = nodeIds_onSE.m_entity_id_vector[ii]; - stk_classic::mesh::EntityId id_check = nodeIds_onSE[ii]->identifier(); - VERIFY_OP_ON(id_check, ==, id, "SerializeNodeRegistry::serialize_write id"); - - emitter << (int)nodeIds_onSE.m_entity_id_vector[ii]; YAML_ERRCHECK; - } - emitter << YAML::EndSeq; YAML_ERRCHECK; - } - - emitter << YAML::EndMap; YAML_ERRCHECK; - - } - - static void serialize_read(NodeRegistry& nodeRegistry, std::ifstream& file_in, std::string msg="", bool force_have_node=false) - { - PerceptMesh& eMesh = nodeRegistry.getMesh(); - eMesh.get_bulk_data()->modification_begin(); - - YAML::Parser parser(file_in); - YAML::Node doc; - if (DEBUG_YAML) - std::cout - << "\n serialize_read..." - << " YAML::NodeType::Null= " << YAML::NodeType::Null - << " YAML::NodeType::Scalar= " << YAML::NodeType::Scalar - << " YAML::NodeType::Sequence= " << YAML::NodeType::Sequence - << " YAML::NodeType::Map= " << YAML::NodeType::Map - << std::endl; - - SubDimCellToDataMap& map = nodeRegistry.getMap(); - //std::cout << msg << " tmp serialize_read map size: " << map.size() << std::endl; - - try { - while(parser.GetNextDocument(doc)) { - if (DEBUG_YAML) std::cout << "s_r doc.Type() = " << doc.Type() << " doc.Tag()= " << doc.Tag() << " doc.size= " << doc.size() << std::endl; - if (doc.Type() == YAML::NodeType::Map) - { - for(YAML::Iterator it=doc.begin();it!=doc.end();++it) { - typedef stk_classic::mesh::EntityId SDSEntityType_ID; - //typedef stk_classic::mesh::Entity * SDSEntityType; - SDSEntityType_ID key_quantum; - //typedef SubDimCell SubDimCell_SDSEntityType; - SubDimCell_SDSEntityType key; // subDimEntity = (*iter).first; - - //struct NodeIdsOnSubDimEntityType : public std::vector - // { - // typedef IdVector entity_id_vector_type; - - stk_classic::mesh::EntityId value_tuple_0_quantum; - NodeIdsOnSubDimEntityType value_tuple_0; - //stk_classic::mesh::EntityKey::raw_key_type value_tuple_1; - - //typedef boost::tuple SubDimCellData; - SubDimCellData value; // nodeId_elementOwnderId = (*iter).second; - NodeIdsOnSubDimEntityType& nodeIds_onSE = value.get(); - nodeIds_onSE.resize(0); - stk_classic::mesh::EntityKey& value_entity_key = value.get(); - // value = { {new_node0, new_node1,...}:[vector,vector], {elem_own[rank, ele_id]:EntityKey} } - // key = { nodePtr_0,... : set } - // value.serialized = { {new_nid0, new_nid1,...}:vector, {elem_own[rank, ele_id]:EntityKey} } - // key.serialized = { nodeid_0,... : set } - - - //if (DEBUG_YAML) std::cout << "it.first().Type() = " << it.first().Type() << " it.first().Tag()= " << it.first().Tag() << std::endl; - //if (DEBUG_YAML) std::cout << "it.second().Type() = " << it.second().Type() << " it.second().Tag()= " << it.second().Tag() << std::endl; - const YAML::Node& keySeq = it.first(); - for(YAML::Iterator itk=keySeq.begin();itk!=keySeq.end();++itk) { - *itk >> key_quantum; - if (DEBUG_YAML) std::cout << "s_r key_quantum= " << key_quantum << std::endl; - SDSEntityType node = eMesh.get_bulk_data()->get_entity(0, key_quantum); - //key.insert(const_cast(&element) ); - if (!node) - { - if (force_have_node) - throw std::runtime_error("NodeRegistry::serialize_read: null node returned from get_entity"); - else - { - stk_classic::mesh::PartVector parts(1, &eMesh.get_fem_meta_data()->universal_part()); - node = &eMesh.get_bulk_data()->declare_entity(0, static_cast(key_quantum), parts); - } - } - - key.insert( node ); - - } - - int iseq=0; - const YAML::Node& valSeq = it.second(); - stk_classic::mesh::EntityRank rank; - stk_classic::mesh::EntityKey::raw_key_type id; - for(YAML::Iterator itv=valSeq.begin();itv!=valSeq.end();++itv,++iseq) { - if (iseq == 0) - { - *itv >> rank; - } - else if (iseq == 1) - { - *itv >> id; - stk_classic::mesh::EntityKey entityKey(rank,id); - if (DEBUG_YAML) std::cout << "s_r value_tuple_1= " << rank << " " << id << std::endl; - value_entity_key = stk_classic::mesh::EntityKey(rank,id); - if (DEBUG_YAML) std::cout << "s_r owning element rank= " << stk_classic::mesh::entity_rank(value.get()) - << " owning element id= " << stk_classic::mesh::entity_id(value.get()) - << std::endl; - } - else - { - *itv >> value_tuple_0_quantum; - - //stk_classic::mesh::EntityId owning_elementId = stk_classic::mesh::entity_id(data.get()); - nodeIds_onSE.m_entity_id_vector.push_back(value_tuple_0_quantum); - stk_classic::mesh::Entity *entity = eMesh.get_bulk_data()->get_entity(0, value_tuple_0_quantum); - if (!entity) - { - if (force_have_node) - throw std::runtime_error("NodeRegistry::serialize_read: null node returned from get_entity 2"); - else - { - stk_classic::mesh::PartVector parts(1, &eMesh.get_fem_meta_data()->universal_part()); - entity = &eMesh.get_bulk_data()->declare_entity(0, static_cast(value_tuple_0_quantum), - parts); - } - } - - nodeIds_onSE.push_back(entity); - - int sz = nodeIds_onSE.size(); - int sz1 = nodeIds_onSE.m_entity_id_vector.size(); - VERIFY_OP_ON(sz, ==, sz1, "SerializeNodeRegistry::serialize_read sz"); - stk_classic::mesh::EntityId id = nodeIds_onSE.m_entity_id_vector[sz-1]; - stk_classic::mesh::EntityId id_check = nodeIds_onSE[sz-1]->identifier(); - VERIFY_OP_ON(id_check, ==, id, "SerializeNodeRegistry::serialize_read id"); - - if (DEBUG_YAML) std::cout << "s_r value_tuple_0_quantum= " << value_tuple_0_quantum << " entity= " << entity - << " len0= " << nodeIds_onSE.size() << " len1= " << nodeIds_onSE.m_entity_id_vector.size() << std::endl; - } - } - - map[key] = value; - } - } - } - } - catch(YAML::ParserException& e) { - std::cout << e.what() << "\n"; - throw std::runtime_error(std::string("yaml parsing error: ")+e.what()); - } - - eMesh.get_bulk_data()->modification_end(); - } - - - }; - -#else - class SerializeNodeRegistry { - public: - SerializeNodeRegistry(PerceptMesh& eMesh, NodeRegistry* nodeRegistry, std::string input_mesh_name, std::string output_mesh_name, - int M, int iM, int W=1, int iW=0, int M_0=-1, int M_1=-1) {} - }; -#endif - - } -} diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/SubDimCell.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/SubDimCell.hpp deleted file mode 100644 index 0aee54b00a17..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/SubDimCell.hpp +++ /dev/null @@ -1,398 +0,0 @@ -#ifndef stk_adapt_SubDimCell_hpp -#define stk_adapt_SubDimCell_hpp - -#include -#include - - -#define STK_ADAPT_SUBDIMCELL_USES_STL_SET 0 -#define STK_ADAPT_SUBDIMCELL_USES_STL_VECTOR 0 -#define STK_ADAPT_SUBDIMCELL_USES_NO_MALLOC_ARRAY 1 - -#if STK_ADAPT_SUBDIMCELL_USES_NO_MALLOC_ARRAY -#include -#endif - -#if STK_ADAPT_SUBDIMCELL_USES_BOOST_ARRAY -#include -#endif - -#include -#include -#include - -#ifdef STK_HAVE_TBB -#include -#endif - - -namespace stk_classic { - namespace adapt { - - - template - struct SubDimCellCompare - { - bool operator() (T i, T j) { return (i < j) ; } - }; - - // only set one of these - -#if STK_ADAPT_SUBDIMCELL_USES_STL_SET - -# ifdef STK_HAVE_TBB - typedef std::set, tbb::scalable_allocator > SubDimCellBaseClass; -# else - typedef std::set SubDimCellBaseClass; -# endif - - /// this class represents the set of node id's defining a sub-dimensional entity of an element (like a face or edge) - template > - class SubDimCell : public SubDimCellBaseClass - { - std::size_t m_hash; - public: - //set m_ids; - SubDimCell() : SubDimCellBaseClass(), m_hash(0u) {} - SubDimCell(unsigned num_ids, Ids *ids) : SubDimCellBaseClass(ids, ids+num_ids), m_hash(0u) - { - } - inline unsigned getHash() const - { - return m_hash; - } - inline void setHash(std::size_t hash) - { - m_hash = hash; - } - void clear() - { - m_hash = 0u; - SubDimCellBaseClass::clear(); - } - }; -#endif - -#if STK_ADAPT_SUBDIMCELL_USES_STL_VECTOR - - //typedef array SubDimCell; - - /// We assume we don't have any sub-dimensional entities with more than 4 nodes - template > - class SubDimCell : public std::vector //: public my_array //: public boost::array - { - public: - //typedef boost::array base_type; - typedef std::vector base_type; - - SubDimCell(unsigned n=4) : base_type() { base_type::reserve(n); } - void insert(T val) - { - bool found = false; - for (unsigned i = 0; i < base_type::size(); i++) - { - if (val == (*this)[i]) - { - found = true; - break; - } - } - if (!found) - { - base_type::push_back(val); - std::sort( base_type::begin(), base_type::end(), CompareClass() ); - - } - } - - }; -#endif - -#if STK_ADAPT_SUBDIMCELL_USES_NO_MALLOC_ARRAY - - //typedef array SubDimCell; - - /// We assume we don't have any sub-dimensional entities with more than 4 nodes - template > - class SubDimCell : public stk_classic::percept::NoMallocArray - { - std::size_t m_hash; - - public: - typedef stk_classic::percept::NoMallocArray base_type; - typedef std::size_t size_type; - - typedef SubDimCell VAL; - - //repo always init to 0 size: SubDimCell(unsigned n=4) : base_type(n), m_hash(0u) {} - SubDimCell() : base_type(), m_hash(0u) {} - SubDimCell(unsigned n) : base_type(), m_hash(0u) {} - - - // behaves like std::set - void insert(T val) - { - bool found = false; - for (size_type i = 0; i < base_type::size(); i++) - { - if (val == (*this)[i]) - { - found = true; - break; - } - } - if (!found) - { - //if (size() > max_size() ) throw std::runtime_error("SubDimCell out of range"); - base_type::insert(val); - std::sort( base_type::begin(), base_type::end(), CompareClass() ); - - } - m_hash = hashCode(); - } - - int hashCode(); - - inline unsigned getHash() const - { - return m_hash; - } - inline void setHash(std::size_t hash) - { - m_hash = hash; - } - void clear() - { - m_hash = 0u; - base_type::clear(); - } - - inline - bool operator==(const VAL& rhs) const - { - if (base_type::size() != rhs.size()) - return false; - //return true; - for (size_type i = 0; i < base_type::size(); i++) - { - if ((*this)[i] != rhs[i]) - return false; - } - return true; - } - - bool operator<(const VAL& rhs) const - { - if (base_type::size() < rhs.size()) - return true; - else if (base_type::size() > rhs.size()) - return false; - else - { - for (size_type i = 0; i < base_type::size(); i++) - { - if ((*this)[i] < rhs[i]) - return true; - } - } - return false; - } - - }; - - template - inline int SubDimCell::hashCode() - { - typedef stk_classic::percept::NoMallocArray base_type; - - std::size_t sum = 0; - - for (typename base_type::iterator i = this->begin(); i != this->end(); i++) - { - //sum += static_cast(const_cast(*i)); - //sum += static_cast((*i)->identifier()); - sum += (size_t)(*i); - } - return sum; - } - - - -#endif - -#if 1 - -#define DATA -#define GET(x,i) x[i] - - template - struct SubDimCell_compare - { - bool operator() (const SubDimCell& lhs, const SubDimCell& rhs) const - { - if (lhs.size() < rhs.size()) return true; - if (lhs.size() > rhs.size()) return false; - for (unsigned i = 0; i < lhs.size(); i++) - { - if (GET(lhs,i) < GET(rhs,i)) return true; - if (GET(lhs,i) > GET(rhs,i)) return false; - } - return false; - } - }; - - template - struct my_hash : public std::unary_function< SubDimCell, std::size_t> - { - typedef SubDimCell _Tp ; - - inline std::size_t - operator()(const _Tp& x) const - { - if (x.getHash()) - { - return x.getHash(); - } - std::size_t sum = 0; - typename _Tp::const_iterator i = x.begin(); - - for (i = x.begin(); i != x.end(); i++) - { - sum += static_cast(*i); - } - - (const_cast<_Tp *>(&x))->setHash(sum); - - return sum; - } - - }; - - template - struct my_fast_hash : public std::unary_function< SubDimCell, std::size_t> - { - typedef SubDimCell _Tp ; - - inline std::size_t - operator()(const _Tp& x) const - { - return x.getHash(); - } - - }; - - template - struct my_equal_to : public std::binary_function, - SubDimCell, bool> - { - typedef SubDimCell _Tp ; - bool - operator()(const _Tp& x, const _Tp& y) const - { - if (x.size() != y.size()) return false; - //for (unsigned i = 0; i < x.size(); i++) - typename _Tp::const_iterator ix = x.begin(); - typename _Tp::const_iterator iy = y.begin(); - //for (unsigned i = 0; i < x.size(); i++) - for (ix = x.begin(), iy = y.begin(); ix != x.end(); ix++, iy++) - { - //if (GET(x,i) != GET(y,i)) return false; - if (*ix != *iy) return false; - } - return true; - } - }; - - template - struct my_fast_equal_to : public std::binary_function, - SubDimCell, bool> - { - typedef SubDimCell _Tp ; - inline bool - operator()(const _Tp& x, const _Tp& y) const - { -#if 0 - return x == y; -#else - if (x.getHash() != y.getHash()) return false; - if (x.size() != y.size()) return false; - typename _Tp::const_iterator ix = x.begin(); - typename _Tp::const_iterator iy = y.begin(); - //for (ix = x.begin(), iy = y.begin(); ix != x.end(); ix++, iy++) - for (; ix != x.end(); ix++, iy++) - { - if (*ix != *iy) return false; - } - return true; -#endif - } - }; - - template - struct my_hash_old : public std::unary_function< SubDimCell , std::size_t> - { - typedef SubDimCell _Tp ; - - inline std::size_t - operator()(const _Tp& x) const - { - std::size_t sum = 0; - for (unsigned i = 0; i < x.size(); i++) - { - sum += static_cast(GET(x,i)); - } - return sum; - } - }; - - template - struct my_equal_to_old : public std::binary_function< SubDimCell, SubDimCell, bool> - { - typedef SubDimCell _Tp ; - bool - operator()(const _Tp& x, const _Tp& y) const - { - if (x.size() != y.size()) return false; - for (unsigned i = 0; i < x.size(); i++) - { - if (GET(x,i) != GET(y,i)) return false; - } - return true; - } - }; - - - template - std::ostream& operator<<(std::ostream& out, const SubDimCell& c) - { - out << "SubDimCell size= " << c.size() << " vals= {"; - //for (unsigned i = 0; i < c.size(); i++) - typename SubDimCell::const_iterator i = c.begin(); - //for (unsigned i = 0; i < x.size(); i++) - for (i = c.begin(); i != c.end(); i++) - { - - out << *i << " "; - //out << c[i] << " "; - } - out << "}"; - return out; - } - -// template -// std::ostringstream& operator<< (std::ostringstream& out, SubDimCell& c) -// { -// out << t; -// return out; -// } - -#undef DATA -#undef GET - -#endif - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_3D.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_3D.hpp deleted file mode 100644 index 24e27f5267b8..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_3D.hpp +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef stk_adapt_URP_Heterogeneous_3D_hpp -#define stk_adapt_URP_Heterogeneous_3D_hpp - - -#include -#include - -#include - -namespace stk_classic { - namespace adapt { - - class URP_Heterogeneous_3D : public UniformRefinerPatternBase - { - - std::vector m_bp; - - protected: - - percept::PerceptMesh& m_eMesh; - - public: - - URP_Heterogeneous_3D(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : m_eMesh(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - //!setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - // list all types of known break patterns to be used here - m_bp.resize(0); - - int spatialDim = eMesh.get_spatial_dim(); - - // refine - - // put them in reverse topological rank order - - if (spatialDim == 3) - { - m_bp.push_back(new UniformRefinerPattern, shards::Tetrahedron<4>, 8, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Hexahedron<8>, 8, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Wedge<6>, 8, SierraPort > (eMesh, block_names)); - - m_bp.push_back(new UniformRefinerPattern, shards::Pyramid<5>, 10, SierraPort > (eMesh, block_names)); - - m_bp.push_back(new UniformRefinerPattern, shards::Hexahedron<27>, 8, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Hexahedron<20>, 8, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Tetrahedron<10>, 8, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Wedge<15>, 8, SierraPort > (eMesh, block_names)); - - - m_bp.push_back(new UniformRefinerPattern, shards::ShellQuadrilateral<4>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back(new UniformRefinerPattern, shards::ShellTriangle<3>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back(new UniformRefinerPattern, shards::ShellTriangle<6>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back(new UniformRefinerPattern, shards::ShellQuadrilateral<8>, 4, SierraPort > (eMesh, block_names)); - - // tmp FIXME -#define ENABLE_DEBUG_BEAM_ELEMENTS_IN_2D 1 -#if !ENABLE_DEBUG_BEAM_ELEMENTS_IN_2D - m_bp.push_back(new UniformRefinerPattern, shards::Beam<2>, 2, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Beam<3>, 2, SierraPort > (eMesh, block_names)); -#endif - } - -#if ENABLE_DEBUG_BEAM_ELEMENTS_IN_2D - m_bp.push_back(new UniformRefinerPattern, shards::Beam<2>, 2, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Beam<3>, 2, SierraPort > (eMesh, block_names)); -#endif - - m_bp.push_back(new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back(new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back(new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > (eMesh, block_names)); - - m_bp.push_back(new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Line<3>, 2, SierraPort > (eMesh, block_names)); - -#if 0 - m_bp.push_back(new UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > (eMesh, block_names)); - -#endif - - } - - ~URP_Heterogeneous_3D() - { - for (unsigned ibp=0; ibp < m_bp.size(); ibp++) - { - if (m_bp[ibp]) delete m_bp[ibp]; - } - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - - bp = m_bp; - } - - virtual void doBreak() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::doBreak()"); - - } - virtual unsigned getFromTypeKey() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getFromTypeKey()"); - - } - - virtual std::string getFromTopoPartName() { - shards::CellTopology cell_topo(getFromTopology()); - return cell_topo.getName(); - } - virtual std::string getToTopoPartName() { - shards::CellTopology cell_topo(getToTopology()); - return cell_topo.getName(); - } - - virtual const CellTopologyData * getFromTopology() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getFromTopology()"); - } - - virtual const CellTopologyData * getToTopology() { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getToTopology()"); - } - - void fillNeededEntities(std::vector& needed_entities) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::fillNeededEntities()"); - } - - virtual unsigned getNumNewElemPerElem() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getNumNewElemPerElem()"); - return 8; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::createNewElements()"); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_Enrich_3D.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_Enrich_3D.hpp deleted file mode 100644 index cea3fbefafb0..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_Enrich_3D.hpp +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef stk_adapt_URP_Heterogeneous_Enrich_3D_hpp -#define stk_adapt_URP_Heterogeneous_Enrich_3D_hpp - - -#include -#include - -#include - - -#define FACE_BREAKER_HETERO_ENRICH_3D 1 - -#if FACE_BREAKER_HETERO_ENRICH_3D -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - class URP_Heterogeneous_Enrich_3D : public UniformRefinerPatternBase - { - - std::vector m_bp; - -#if FACE_BREAKER_HETERO_ENRICH_3D - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; -#endif - - protected: - - percept::PerceptMesh& m_eMesh; - - public: - - URP_Heterogeneous_Enrich_3D(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : m_eMesh(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - Elem::StdMeshObjTopologies::bootstrap(); - - // list all types of known break patterns to be used here - m_bp.resize(0); - - int spatialDim = eMesh.get_spatial_dim(); - - // refine - - // put them in reverse topological rank order - - if (spatialDim != 3) - { - throw std::runtime_error("URP_Heterogeneous_Enrich_3D is only for 3D meshes"); - } - -// // refine -// m_bp.push_back( new UniformRefinerPattern, shards::Hexahedron<8>, 8, SierraPort > (eMesh, block_names) ); -// m_bp.push_back( new UniformRefinerPattern, shards::Wedge<6>, 8, SierraPort > (eMesh, block_names) ); -// m_bp.push_back( new UniformRefinerPattern, shards::Tetrahedron<4>, 8, SierraPort > (eMesh, block_names) ); - - - // enrich - m_bp.push_back ( new UniformRefinerPattern< shards::Wedge<6>, shards::Wedge<15>, 1, SierraPort > (eMesh, block_names) ); - m_bp.push_back ( new UniformRefinerPattern, shards::Tetrahedron<10>, 1, SierraPort > (eMesh, block_names) ); - m_bp.push_back ( new UniformRefinerPattern, shards::Hexahedron<27>, 1, SierraPort > (eMesh, block_names) ); - m_bp.push_back ( new UniformRefinerPattern< shards::Pyramid<5>, shards::Pyramid<13>, 1, SierraPort > (eMesh, block_names) ); - - //m_bp.push_back( new UniformRefinerPattern, shards::ShellQuadrilateral<9>, 1, SierraPort > (eMesh, block_names) ); - //m_bp.push_back( new UniformRefinerPattern, shards::ShellTriangle<3>, 4, SierraPort > (eMesh, block_names) ); - - -#if FACE_BREAKER_HETERO_ENRICH_3D - - m_bp.push_back( new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back( new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names) ); - -#endif - - } - - ~URP_Heterogeneous_Enrich_3D() - { - for (unsigned ibp=0; ibp < m_bp.size(); ibp++) - { - if (m_bp[ibp]) delete m_bp[ibp]; - } - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - - bp = m_bp; - - } - - virtual std::string getFromTopoPartName() { - shards::CellTopology cell_topo(getFromTopology()); - return cell_topo.getName(); - } - virtual std::string getToTopoPartName() { - shards::CellTopology cell_topo(getToTopology()); - return cell_topo.getName(); - } - - virtual void doBreak() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::doBreak()"); - - } - virtual unsigned getFromTypeKey() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::getFromTypeKey()"); - - } - - virtual const CellTopologyData * getFromTopology() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::getFromTopology()"); - } - virtual const CellTopologyData * getToTopology() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getToTopology()"); - } - - - void fillNeededEntities(std::vector& needed_entities) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::fillNeededEntities()"); - } - - virtual unsigned getNumNewElemPerElem() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::getNumNewElemPerElem()"); - return 8; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_Enrich_3D::createNewElements()"); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_QuadraticRefine_3D.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_QuadraticRefine_3D.hpp deleted file mode 100644 index 6d0c1f0ce558..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/URP_Heterogeneous_QuadraticRefine_3D.hpp +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef stk_adapt_URP_Heterogeneous_QuadraticRefine_3D_hpp -#define stk_adapt_URP_Heterogeneous_QuadraticRefine_3D_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_HETERO_QUADRATIC_REFINE_3D 0 -#if FACE_BREAKER_HETERO_QUADRATIC_REFINE_3D -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - class URP_Heterogeneous_QuadraticRefine_3D : public UniformRefinerPatternBase - { - - std::vector m_bp; - -#if FACE_BREAKER_HETERO_QUADRATIC_REFINE_3D - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; -#endif - - protected: - - percept::PerceptMesh& m_eMesh; - - public: - - URP_Heterogeneous_QuadraticRefine_3D(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : m_eMesh(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - Elem::StdMeshObjTopologies::bootstrap(); - - // list all types of known break patterns to be used here - m_bp.resize(0); - - // refine - m_bp.push_back( new UniformRefinerPattern, shards::Hexahedron<27>, 8, SierraPort > (eMesh, block_names) ); - m_bp.push_back( new UniformRefinerPattern, shards::Wedge<15>, 8, SierraPort > (eMesh, block_names) ); - m_bp.push_back( new UniformRefinerPattern, shards::Tetrahedron<10>, 8, SierraPort > (eMesh, block_names) ); - - // FIXME - //m_bp.push_back( new UniformRefinerPattern, shards::ShellQuadrilateral<9>, 4, SierraPort > (eMesh, block_names) ); - //m_bp.push_back( new UniformRefinerPattern, shards::ShellTriangle<6>, 4, SierraPort > (eMesh, block_names) ); - - // enrich -// m_bp.push_back ( new UniformRefinerPattern< shards::Wedge<6>, shards::Wedge<15>, 1, SierraPort > (eMesh, block_names) ); -// m_bp.push_back ( new UniformRefinerPattern, shards::Tetrahedron<10>, 1, SierraPort > (eMesh, block_names) ); -// m_bp.push_back ( new UniformRefinerPattern, shards::Hexahedron<27>, 1, SierraPort > (eMesh, block_names) ); - -#if FACE_BREAKER_HETERO_QUADRATIC_REFINE_3D - - m_bp.push_back( new UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > (eMesh, block_names) ); - m_bp.push_back( new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names) ); - -#endif - - } - - ~URP_Heterogeneous_QuadraticRefine_3D() - { - for (unsigned ibp=0; ibp < m_bp.size(); ibp++) - { - if (m_bp[ibp]) delete m_bp[ibp]; - } - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - - bp = m_bp; - - } - - virtual std::string getFromTopoPartName() { - shards::CellTopology cell_topo(getFromTopology()); - return cell_topo.getName(); - } - virtual std::string getToTopoPartName() { - shards::CellTopology cell_topo(getToTopology()); - return cell_topo.getName(); - } - - virtual void doBreak() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::doBreak()"); - - } - virtual unsigned getFromTypeKey() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::getFromTypeKey()"); - - } - - virtual const CellTopologyData * getFromTopology() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::getFromTopology()"); - } - virtual const CellTopologyData * getToTopology() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_3D::getToTopology()"); - } - - - void fillNeededEntities(std::vector& needed_entities) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::fillNeededEntities()"); - } - - virtual unsigned getNumNewElemPerElem() - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::getNumNewElemPerElem()"); - return 8; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - throw std::runtime_error("shouldn't call URP_Heterogeneous_QuadraticRefine_3D::createNewElements()"); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.cpp deleted file mode 100644 index 1248aef13de0..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - - -namespace stk_classic { - namespace adapt { - - - UniformRefiner::UniformRefiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.hpp deleted file mode 100644 index 927b102669f7..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefiner.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef stk_adapt_UniformRefiner_hpp -#define stk_adapt_UniformRefiner_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - //template - class UniformRefiner : public Refiner - { - public: - UniformRefiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - protected: - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.cpp deleted file mode 100644 index b098415003e2..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.cpp +++ /dev/null @@ -1,579 +0,0 @@ - -#include -#include - -namespace stk_classic { - namespace adapt { - - STK_Adapt_Auto_Part stk_adapt_auto_part; - - const std::string UniformRefinerPatternBase::m_oldElementsPartName = "urp_oldElements"; - - std::string UniformRefinerPatternBase::s_convert_options = "Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4"; - std::string UniformRefinerPatternBase::s_refine_options = "DEFAULT, Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Pyramid5_Pyramid5_10, " - " Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge15_Wedge15_8, Pyramid13_Pyramid13_10, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4"; - std::string UniformRefinerPatternBase::s_enrich_options = "DEFAULT, Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, " - " Wedge6_Wedge15_1, Wedge6_Wedge18_1, Pyramid5_Pyramid13_1"; - - -#if 0 - Teuchos::RCP UniformRefinerPatternBase:: - findDefaultConvert(percept::PerceptMesh& eMesh, BlockNamesType& block_names) - { - Teuchos::RCP pattern; - - - //else if (convert == "Quad4_Tri3_6") pattern = Teuchos::rcp(new Quad4_Tri3_6(eMesh, block_names)); - pattern = Teuchos::rcp(new Quad4_Tri3_4(eMesh, block_names)); - else if (convert == "Hex8_Tet4_24") pattern = Teuchos::rcp(new Hex8_Tet4_24(eMesh, block_names)); - else if (convert == "Hex8_Tet4_6") pattern = Teuchos::rcp(new Hex8_Tet4_6_12(eMesh, block_names)); - - } -#endif - - Teuchos::RCP UniformRefinerPatternBase:: - createPattern(std::string refine, std::string enrich, std::string convert, percept::PerceptMesh& eMesh, BlockNamesType& block_names) - { - Teuchos::RCP pattern; - - // refine - if (refine == "DEFAULT") pattern = Teuchos::rcp(new URP_Heterogeneous_3D(eMesh, block_names)); - else if (refine == "Quad4_Quad4_4") pattern = Teuchos::rcp(new Quad4_Quad4_4_Sierra(eMesh, block_names)); - else if (refine == "Tri3_Tri3_4") pattern = Teuchos::rcp(new Tri3_Tri3_4(eMesh, block_names)); - else if (refine == "Tet4_Tet4_8") pattern = Teuchos::rcp(new Tet4_Tet4_8(eMesh, block_names)); - else if (refine == "Hex8_Hex8_8") pattern = Teuchos::rcp(new Hex8_Hex8_8(eMesh, block_names)); - else if (refine == "Wedge6_Wedge6_8") pattern = Teuchos::rcp(new Wedge6_Wedge6_8(eMesh, block_names)); - else if (refine == "Pyramid5_Pyramid5_10") pattern = Teuchos::rcp(new Pyramid5_Pyramid5_10(eMesh, block_names)); - - // shells - else if (refine == "ShellTri3_ShellTri3_4") pattern = Teuchos::rcp(new ShellTri3_ShellTri3_4(eMesh, block_names)); - else if (refine == "ShellQuad4_ShellQuad4_4") pattern = Teuchos::rcp(new ShellQuad4_ShellQuad4_4(eMesh, block_names)); - - else if (refine == "Tri6_Tri6_4") pattern = Teuchos::rcp(new Tri6_Tri6_4(eMesh, block_names)); - else if (refine == "Quad9_Quad9_4") pattern = Teuchos::rcp(new Quad9_Quad9_4(eMesh, block_names)); - else if (refine == "Hex27_Hex27_8") pattern = Teuchos::rcp(new Hex27_Hex27_8(eMesh, block_names)); - else if (refine == "Tet10_Tet10_8") pattern = Teuchos::rcp(new Tet10_Tet10_8(eMesh, block_names)); - else if (refine == "Wedge15_Wedge15_8") pattern = Teuchos::rcp(new Wedge15_Wedge15_8(eMesh, block_names)); - //else if (refine == "Wedge18_Wedge18_8") pattern = Teuchos::rcp(new Wedge18_Wedge18_8(eMesh, block_names)); - else if (refine == "Pyramid13_Pyramid13_10") pattern = Teuchos::rcp(new Pyramid13_Pyramid13_10(eMesh, block_names)); - - // enrich - else if (enrich == "DEFAULT") pattern = Teuchos::rcp(new URP_Heterogeneous_Enrich_3D(eMesh, block_names)); - else if (enrich == "Quad4_Quad8_1") pattern = Teuchos::rcp(new Quad4_Quad8_1(eMesh, block_names)); - else if (enrich == "Quad4_Quad9_1") pattern = Teuchos::rcp(new Quad4_Quad9_1(eMesh, block_names)); - else if (enrich == "Tri3_Tri6_1") pattern = Teuchos::rcp(new Tri3_Tri6_1(eMesh, block_names)); - else if (enrich == "Tet4_Tet10_1") pattern = Teuchos::rcp(new Tet4_Tet10_1(eMesh, block_names)); - else if (enrich == "Hex8_Hex20_1") pattern = Teuchos::rcp(new Hex8_Hex20_1(eMesh, block_names)); - else if (enrich == "Hex8_Hex27_1") pattern = Teuchos::rcp(new Hex8_Hex27_1(eMesh, block_names)); - else if (enrich == "Wedge6_Wedge15_1") pattern = Teuchos::rcp(new Wedge6_Wedge15_1(eMesh, block_names)); - else if (enrich == "Wedge6_Wedge18_1") pattern = Teuchos::rcp(new Wedge6_Wedge18_1(eMesh, block_names)); - else if (enrich == "Pyramid5_Pyramid13_1") pattern = Teuchos::rcp(new Pyramid5_Pyramid13_1(eMesh, block_names)); - - // convert - //else if (convert == "DEFAULT") pattern = findDefaultConvert(eMesh, block_names); - else if (convert == "Quad4_Tri3_2") pattern = Teuchos::rcp(new Quad4_Tri3_2(eMesh, block_names)); - else if (convert == "Quad4_Tri3_6") pattern = Teuchos::rcp(new Quad4_Tri3_6(eMesh, block_names)); - else if (convert == "Quad4_Tri3_4") pattern = Teuchos::rcp(new Quad4_Tri3_4(eMesh, block_names)); - else if (convert == "Hex8_Tet4_24") pattern = Teuchos::rcp(new Hex8_Tet4_24(eMesh, block_names)); - else if (convert == "Hex8_Tet4_6") pattern = Teuchos::rcp(new Hex8_Tet4_6_12(eMesh, block_names)); - else - { - throw std::invalid_argument( (std::string("UniformRefinerPatternBase::createPattern unknown string: refine= ")+refine+" enrich= "+enrich+ - " convert= " + convert).c_str() ); - } - - return pattern; - } - - - /* - static const SameRankRelationValue * getChildVectorPtr( SameRankRelation& repo , Entity *parent) - { - SameRankRelation::const_iterator i = repo.find( parent ); - if (i != repo.end()) - return &i->second; - else - return 0; - } - */ - -#if PERCEPT_USE_FAMILY_TREE == 0 - /// if numChild is passed in as non-null, use that value, else use getNumNewElemPerElem() as size of child vector - void UniformRefinerPatternBase::set_parent_child_relations(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& parent_elem, stk_classic::mesh::Entity& newElement, - unsigned ordinal, unsigned *numChild) - { -#if NEW_FIX_ELEMENT_SIDES - VERIFY_OP(ordinal, < , getNumNewElemPerElem(), "logic error in set_parent_child_relations"); - VERIFY_OP(&parent_elem, != , 0, "set_parent_child_relations: parent_elem is null"); - VERIFY_OP(&newElement, != , 0, "set_parent_child_relations: newElement is null"); - - if (0 == &parent_elem) - { - throw std::logic_error("UniformRefinerPatternBase::set_parent_child_relations parent_elem is null"); - } - - PerceptEntityVector& entity_vector = eMesh.adapt_parent_to_child_relations()[&parent_elem]; - - //entity_vector.reserve(getNumNewElemPerElem()); -#if 0 - unsigned nchild = getNumNewElemPerElem(); - if (numChild) nchild = *numChild; - if (entity_vector.size() != nchild) - { - entity_vector.resize(nchild); - } -#else - if (ordinal + 1 > entity_vector.size()) - { - entity_vector.resize(ordinal+1); - } -#endif - entity_vector[ordinal] = &newElement; - - if (0) std::cout << "tmp here 12 ordinal= " << ordinal << " [ " << getNumNewElemPerElem() << "] newElement_ptr= "<< &newElement<< std::endl; -#endif - } - -#elif PERCEPT_USE_FAMILY_TREE == 1 - /// if numChild is passed in as non-null, use that value, else use getNumNewElemPerElem() as size of child vector - void UniformRefinerPatternBase::set_parent_child_relations(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& parent_elem, stk_classic::mesh::Entity& newElement, - unsigned ordinal, unsigned *numChild) - { -#if NEW_FIX_ELEMENT_SIDES - - //VERIFY_OP(ordinal, < , getNumNewElemPerElem(), "logic error in set_parent_child_relations"); - VERIFY_OP(&parent_elem, != , 0, "set_parent_child_relations: parent_elem is null"); - VERIFY_OP(&newElement, != , 0, "set_parent_child_relations: newElement is null"); - - if (0 == &parent_elem) - { - throw std::logic_error("UniformRefinerPatternBase::set_parent_child_relations parent_elem is null"); - } - - const unsigned FAMILY_TREE_RANK = eMesh.element_rank() + 1u; - stk_classic::mesh::Entity* family_tree = 0; - mesh::PairIterRelation parent_to_family_tree_relations = parent_elem.relations(FAMILY_TREE_RANK); -#define DEBUG_MULTI_LEVEL 0 -#if DEBUG_MULTI_LEVEL - int parent_to_family_tree_relations_size_0 = parent_to_family_tree_relations.size(); - if (parent_to_family_tree_relations.size() == 1) - { - std::cout << " parent_to_family_tree_relations.size()==1 && eMesh.isChildElement(parent_elem) = " << eMesh.isChildElement(parent_elem) - << " parent_elem= " << parent_elem - << std::endl; - } -#endif - // if this is the first time the parent_elem has been visited, or if the parent_elem is the child of another parent, - // (at level 0 only, which is what isChildElement checks), then we need to add a new family tree - - if (parent_to_family_tree_relations.size() == 0 || (parent_to_family_tree_relations.size() == 1 && eMesh.isChildElement(parent_elem) ) ) - { - stk_classic::mesh::PartVector add(1, &eMesh.get_fem_meta_data()->universal_part()); - - // explanation: we want to avoid the above use of BulkData::generate_new_entities due to the parallel comm required, so we - // use the parent_id for the familty_tree_id. - // there are two types of family tree uses, one for - // the first level of parent/child (FAMILY_TREE_LEVEL_0) and one that holds a child that now is a parent (FAMILY_TREE_LEVEL_1) - // - // Since we know that the parent_id is unique across processors, we can use it for the family tree - // and guarantee uniqueness of family tree id's across processors. - stk_classic::mesh::EntityId parent_id = parent_elem.identifier(); - stk_classic::mesh::EntityId family_tree_id = parent_id; - - // FIXME - if (parent_elem.entity_rank() != eMesh.element_rank()) - { - stk_classic::mesh::EntityId FT_SHIFT_SIDE = 100000000000ull; - if (family_tree_id > FT_SHIFT_SIDE) - throw std::logic_error("FT_SHIFT_SIDE error in set_parent_child_relations"); - family_tree_id += FT_SHIFT_SIDE; - //std::cout << "tmp family_tree_id = " << family_tree_id << " parent_id= " << parent_id << std::endl; - } - -#if DEBUG_MULTI_LEVEL - if (parent_to_family_tree_relations.size() == 1) - { - std::cout << "tmp family_tree_id = " << family_tree_id << " parent_id= " << parent_id << std::endl; - } -#endif - //unsgined FT_SHIFT = 100000000u; - unsigned FT_SHIFT = 0u; - family_tree_id += FT_SHIFT; - - family_tree = & eMesh.get_bulk_data()->declare_entity(FAMILY_TREE_RANK, family_tree_id, add); - - // make the parent be the first relation; children are at the end - // from->to -#if DEBUG_MULTI_LEVEL - std::cout << "tmp super->parent " << family_tree->identifier() << " -> " << parent_elem.identifier() << " " << parent_elem << std::endl; -#endif - eMesh.get_bulk_data()->declare_relation(*family_tree, parent_elem, FAMILY_TREE_PARENT); - //eMesh.get_bulk_data()->declare_relation( parent_elem, *family_tree, ptft_size-1); - parent_to_family_tree_relations = parent_elem.relations(FAMILY_TREE_RANK); - -#if DEBUG_MULTI_LEVEL - unsigned ptft_size = parent_to_family_tree_relations.size(); - VERIFY_OP_ON(family_tree, !=, 0,"err1"); - if (1) - { - std::cout - << "ptft_size= " << ptft_size << " family_tree= " << family_tree - << " family_tree_id= " << family_tree->identifier() << std::endl; - for (unsigned k = 0; k < ptft_size; k++) - { - stk_classic::mesh::Entity * ft = parent_to_family_tree_relations[k].entity(); - std::cout << "ft= " << ft << " ft_id= " << ft->identifier() << std::endl; - } - } - VERIFY_OP_ON(family_tree, ==, parent_to_family_tree_relations[FAMILY_TREE_LEVEL_0].entity(),"err2"); -#endif - } - -#if DEBUG_MULTI_LEVEL - int parent_to_family_tree_relations_size_1 = parent_to_family_tree_relations.size(); -#endif - - if (parent_to_family_tree_relations.size() == 1) - { - //VERIFY_OP_ON(family_tree, !=, 0,"err1"); - //VERIFY_OP_ON(family_tree, ==, parent_to_family_tree_relations[FAMILY_TREE_LEVEL_0].entity(),"err2"); - - unsigned parent_elem_ft_level_0 = eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, parent_elem); - //family_tree = parent_to_family_tree_relations[FAMILY_TREE_LEVEL_0].entity(); - family_tree = parent_to_family_tree_relations[parent_elem_ft_level_0].entity(); - } - else if (parent_to_family_tree_relations.size() == 2) - { - //VERIFY_OP_ON(family_tree, !=, 0,"err1"); - //VERIFY_OP_ON(family_tree, ==, parent_to_family_tree_relations[FAMILY_TREE_LEVEL_1].entity(),"err2"); - //family_tree = parent_to_family_tree_relations[FAMILY_TREE_LEVEL_1].entity(); - - // EXPLANATION: stk_mesh inserts back-relations in front of existing relations (it uses the std::vector::insert method) - // FIXME - need a unit test to check if this ever breaks in the future (i.e. going to boost::mesh) - //family_tree = parent_to_family_tree_relations[FAMILY_TREE_LEVEL_0].entity(); - - unsigned parent_elem_ft_level_1 = eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_1, parent_elem); - family_tree = parent_to_family_tree_relations[parent_elem_ft_level_1].entity(); - - } - else - { - throw std::logic_error("UniformRefinerPatternBase::set_parent_child_relations no family_tree"); - } - - //entity_vector.reserve(getNumNewElemPerElem()); - // - //unsigned nchild = getNumNewElemPerElem(); - //if (numChild) nchild = *numChild; - -#if DEBUG_MULTI_LEVEL - std::cout << "tmp parent_to_family_tree_relations_size_0 = " << parent_to_family_tree_relations_size_0 << " parent_to_family_tree_relations_size_1= " << parent_to_family_tree_relations_size_1 << std::endl; - std::cout << "tmp super->child " << family_tree->identifier() << " -> " << newElement.identifier() << " [" << (ordinal+1) << "]" << newElement << std::endl; -#endif - - // error check - if (1) - { - mesh::PairIterRelation family_tree_relations = family_tree->relations(parent_elem.entity_rank()); - for (unsigned i = 1; i < family_tree_relations.size(); i++) - { - if (family_tree_relations[i].identifier() == (ordinal + 1)) - { - std::cout << "UniformRefinerPatternBase::set_parent_child_relations trying to refine a parent element again, or error in ordinal [" - << ordinal << "]" << " family_tree_relations.size= " << family_tree_relations.size() << std::endl; - throw std::logic_error("UniformRefinerPatternBase::set_parent_child_relations trying to refine a parent element again, or error in ordinal"); - } - } - } - - eMesh.get_bulk_data()->declare_relation(*family_tree, newElement, ordinal + 1); // the + 1 here is to give space for the parent - - // add all the nodes for ghosting purposes - /** Explanation: child elements can be created in the aura that have nodes in the aura but aren't shared - * which doesn't bring over parent/child relations to the other processors. The code below adds relations - * to all nodes of the parent elements thus providing necessary links that the closure code can follow to - * gather parent/child relations and send to sharing procs. - */ - bool workaround_shared_node_issue = true; - if (workaround_shared_node_issue) - { - - mesh::PairIterRelation parent_elem_nodes = parent_elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned i = 0; i < parent_elem_nodes.size(); i++) - { - if (!stk_classic::mesh::in_shared(*parent_elem_nodes[i].entity())) continue; - - bool found = false; - mesh::PairIterRelation ft_nodes = family_tree->relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned j = 0; j < ft_nodes.size(); j++) - { - if (ft_nodes[j].entity() == parent_elem_nodes[i].entity()) - { - found = true; - break; - } - } - if (!found) - { - eMesh.get_bulk_data()->declare_relation(*family_tree, *parent_elem_nodes[i].entity(), ft_nodes.size()); - } - } - - stk_classic::mesh::PairIterRelation child_elem_nodes = newElement.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - if (child_elem_nodes.size() == 0) - { - throw std::runtime_error("child_elem has no nodes"); - } - for (unsigned i = 0; i < child_elem_nodes.size(); i++) - { - if (!stk_classic::mesh::in_shared(*child_elem_nodes[i].entity())) continue; - - bool found = false; - mesh::PairIterRelation ft_nodes = family_tree->relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned j = 0; j < ft_nodes.size(); j++) - { - if (ft_nodes[j].entity() == child_elem_nodes[i].entity()) - { - found = true; - break; - } - } - if (!found) - { - eMesh.get_bulk_data()->declare_relation(*family_tree, *child_elem_nodes[i].entity(), ft_nodes.size()); - } - } - - // check for second level and subsequent refinement - if (parent_to_family_tree_relations.size() == 2) - { - unsigned parent_elem_ft_level_0 = eMesh.getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, parent_elem); - stk_classic::mesh::Entity* family_tree_level_0 = parent_to_family_tree_relations[parent_elem_ft_level_0].entity(); - - stk_classic::mesh::PairIterRelation ft_level_0_nodes = family_tree_level_0->relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned i = 0; i < ft_level_0_nodes.size(); i++) - { - if (!stk_classic::mesh::in_shared(*ft_level_0_nodes[i].entity())) continue; - - bool found = false; - mesh::PairIterRelation ft_nodes = family_tree->relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned j = 0; j < ft_nodes.size(); j++) - { - if (ft_nodes[j].entity() == ft_level_0_nodes[i].entity()) - { - found = true; - break; - } - } - if (!found) - { - eMesh.get_bulk_data()->declare_relation(*family_tree, *ft_level_0_nodes[i].entity(), ft_nodes.size()); - } - } - } - - } - - - if (0) std::cout << "tmp here 12 ordinal= " << ordinal << " [ " << getNumNewElemPerElem() << "] newElement_ptr= "<< &newElement<< std::endl; - bool foundSide = findSideRelations(eMesh, &parent_elem, &newElement); - if (!foundSide) { - //throw std::runtime_error("UniformRefinerPatternBase:: set_parent_child_relations couldn't set child side to elem relations"); - } -#endif - } -#endif - - void UniformRefinerPatternBase::interpolateElementFields(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& old_owning_elem, stk_classic::mesh::Entity& newElement) - { - // FIXME -// if (old_owning_elem.entity_rank() != eMesh.element_rank()) -// { -// return; -// } - const stk_classic::mesh::FieldVector & fields = eMesh.get_fem_meta_data()->get_fields(); - unsigned nfields = fields.size(); - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - int field_dimension = -1; - - stk_classic::mesh::EntityRank field_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - { - unsigned nfr = field->restrictions().size(); - //if (Util::getFlag(1234)) std::cout << "tmp number of field restrictions= " << nfr << " for field= " << field->name() << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //mesh::Part& frpart = metaData.get_part(fr.ordinal()); - - field_rank = fr.entity_rank(); - int rank = field->rank(); - if(rank == 0) - field_dimension = fr.dimension() ; - else - field_dimension = fr.stride(rank - 1); - - //if (Util::getFlag(1234)) std::cout << "tmp field_rank= " << field_rank << " field_dimension= " << field_dimension << std::endl; - } - } - if (field_rank == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - continue; - } - if (field_rank == old_owning_elem.entity_rank()) - { - unsigned stride_old=0, stride_new=0; - double *fdata_old = PerceptMesh::field_data_entity(field, old_owning_elem, &stride_old); - if (!fdata_old) - continue; - if ((int)stride_old != field_dimension) - { - VERIFY_OP_ON((int)stride_old, ==, field_dimension, "interpolateElementFields err1"); - throw std::runtime_error("interpolateElementFields err1"); - } - double *fdata_new = PerceptMesh::field_data_entity(field, newElement, &stride_new); - if (!fdata_new) - continue; - if ((int)stride_new != field_dimension || stride_new != stride_old) - { - VERIFY_OP_ON((int)stride_new, ==, field_dimension, "interpolateElementFields err2"); - VERIFY_OP_ON(stride_new, ==, stride_old, "interpolateElementFields err3"); - throw std::runtime_error("interpolateElementFields err2"); - } - for (unsigned i = 0; i < stride_old; i++) - { - fdata_new[i] = fdata_old[i]; - } - } - - } - } - - bool UniformRefinerPatternBase::findSideRelations(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity* parent, stk_classic::mesh::Entity* child) - { - VERIFY_OP_ON(parent->entity_rank(), ==, child->entity_rank(), "UniformRefinerPatternBase::findSideRelations: bad ranks"); - if (parent->entity_rank() == eMesh.element_rank()) - return true; - - for (unsigned higher_order_rank = parent->entity_rank()+1u; higher_order_rank <= eMesh.element_rank(); higher_order_rank++) - { - stk_classic::mesh::PairIterRelation parent_to_elem_rels = parent->relations(higher_order_rank); - VERIFY_OP_ON(parent_to_elem_rels.size(), <=, 1, "UniformRefinerPatternBase::findSideRelations bad number of side to elem relations"); - if (parent_to_elem_rels.size() == 0) - { - // nothing to do - return true; - } - - for (unsigned i_parent_to_elem=0; i_parent_to_elem < parent_to_elem_rels.size(); i_parent_to_elem++) - { - stk_classic::mesh::Entity *parents_volume_element = parent_to_elem_rels[i_parent_to_elem].entity(); - - std::vector parents_volume_elements_children; - VERIFY_OP_ON(eMesh.hasFamilyTree(*parents_volume_element), == , true, "UniformRefinerPatternBase::findSideRelations parent's volume element has no children."); - //if (! eMesh.hasFamilyTree(*parents_volume_element) ) return true; - eMesh.getChildren(*parents_volume_element, parents_volume_elements_children); - for (unsigned i_vol_child=0; i_vol_child < parents_volume_elements_children.size(); i_vol_child++) - { - stk_classic::mesh::Entity* parents_volume_elements_child = parents_volume_elements_children[i_vol_child]; - - VERIFY_OP_ON(parents_volume_elements_child->entity_rank(), ==, higher_order_rank, "UniformRefinerPatternBase::findSideRelations: bad ranks 2"); - if (connectSides(eMesh, parents_volume_elements_child, child)) - return true; - } - } - } - return false; - } - - // if the element (element) has a side that matches the given side (side_elem), connect them but first delete old connections - bool UniformRefinerPatternBase::connectSides(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity *element, stk_classic::mesh::Entity *side_elem) - { - EXCEPTWATCH; - shards::CellTopology element_topo(stk_classic::percept::PerceptMesh::get_cell_topology(*element)); - unsigned element_nsides = (unsigned)element_topo.getSideCount(); - - // special case for shells - int topoDim = UniformRefinerPatternBase::getTopoDim(element_topo); - - bool isShell = false; - if (topoDim < (int)element->entity_rank()) - { - isShell = true; - } - int spatialDim = eMesh.get_spatial_dim(); - if (spatialDim == 3 && isShell && side_elem->entity_rank() == eMesh.edge_rank()) - { - element_nsides = (unsigned) element_topo.getEdgeCount(); - } - - int permIndex = -1; - int permPolarity = 1; - - unsigned k_element_side = 0; - - // try search - for (unsigned j_element_side = 0; j_element_side < element_nsides; j_element_side++) - { - PerceptMesh::element_side_permutation(*element, *side_elem, j_element_side, permIndex, permPolarity); - if (permIndex >= 0) - { - k_element_side = j_element_side; - break; - } - } - - if (permIndex >= 0) - { - mesh::PairIterRelation rels = side_elem->relations(eMesh.element_rank()); - - if (rels.size() > 1) - { - throw std::logic_error("rels.size() > 1"); - } - - if (rels.size()) - { - stk_classic::mesh::Entity *to_rel = rels[0].entity(); - stk_classic::mesh::RelationIdentifier to_id = rels[0].identifier(); - bool del = eMesh.get_bulk_data()->destroy_relation( *to_rel, *side_elem, to_id); - if (!del) - throw std::logic_error("connectSides:: destroy_relation failed"); - } - - // special case for shells - if (0 && isShell) - { - // FIXME for 2D - if (side_elem->entity_rank() == eMesh.face_rank()) - { - stk_classic::mesh::PairIterRelation elem_sides = element->relations(side_elem->entity_rank()); - unsigned elem_sides_size= elem_sides.size(); - //std::cout << "tmp srk found shell, elem_sides_size= " << elem_sides_size << std::endl; - if (elem_sides_size == 1) - { - stk_classic::mesh::RelationIdentifier rel_id = elem_sides[0].identifier(); - if (rel_id > 1) - throw std::logic_error("connectSides:: logic 1"); - k_element_side = (rel_id == 0 ? 1 : 0); - //std::cout << "tmp srk k_element_side= " << k_element_side << " rel_id= " << rel_id << std::endl; - } - } - } - - eMesh.get_bulk_data()->declare_relation(*element, *side_elem, k_element_side); - return true; - } - else - { - // error condition? - //throw std::runtime_error("connectSides: couldn't find a matching face"); - return false; - } - } - - - } -} - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.hpp deleted file mode 100644 index 8e59b2a34d10..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern.hpp +++ /dev/null @@ -1,2969 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_hpp -#define stk_adapt_UniformRefinerPattern_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Teuchos_RCP.hpp" - -#include -#include -#include -#include - - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - - -#include -#include - -// more efficient fixElementSides implementation using parent/child relations -#define NEW_FIX_ELEMENT_SIDES 1 - -// set to 0 for doing global (and thus more efficient) computation of node coords and adding to parts -#define STK_ADAPT_URP_LOCAL_NODE_COMPS 0 - -// set to 1 to turn on some print tracing and cpu/mem tracing -#define FORCE_TRACE_PRINT_ONLY 0 -#define TRACE_STAGE_PRINT_ON 0 -#define TRACE_STAGE_PRINT (TRACE_STAGE_PRINT_ON && (m_eMesh.get_rank()==0)) - -#if TRACE_STAGE_PRINT_ON -# define TRACE_PRINT(a) do { trace_print(a); } while(0) -# define TRACE_CPU_TIME_AND_MEM_0(a) do { Util::trace_cpu_time_and_mem_0(a); } while(0) -# define TRACE_CPU_TIME_AND_MEM_1(a) do { Util::trace_cpu_time_and_mem_1(a); } while(0) -#else -# if FORCE_TRACE_PRINT_ONLY -# define TRACE_PRINT(a) do { trace_print(a); } while(0) -# else -# define TRACE_PRINT(a) do {} while(0) -# endif -# define TRACE_CPU_TIME_AND_MEM_0(a) do { } while(0) -# define TRACE_CPU_TIME_AND_MEM_1(a) do { } while(0) -#endif - - - -namespace stk_classic { - namespace adapt { - - using std::vector; - //using namespace stk_classic::percept; - - using shards::CellTopology; - - typedef std::vector > BlockNamesType; - typedef std::map StringStringMap; - - typedef vector > > NewSubEntityNodesType; - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - - typedef Elem::StdMeshObjTopologies::RefinementTopologyExtraEntry *RefTopoX_arr; - - // useful tools -#define NODE_COORD(node) stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node ) -#define VERT_COORD(ivert) NODE_COORD(*elem_nodes[ivert].entity()) -#define EDGE_COORD(iedge,inode) NODE_COORD(*elem_nodes[cell_topo_data->edge[iedge].node[inode]].entity()) -#define FACE_COORD(iface,inode) NODE_COORD(*elem_nodes[cell_topo_data->side[iface].node[inode]].entity()) - - /// 2D array new_sub_entity_nodes[entity_rank][ordinal_of_node_on_sub_dim_entity] - -#define VERT_N(i) elem_nodes[i].entity()->identifier() - -// #define VERT_N(i) elem_nodes[i].entity()->identifier() -// #define EDGE_N(i) new_sub_entity_nodes[m_eMesh.edge_rank()][i][0] -// #define FACE_N(i) new_sub_entity_nodes[m_eMesh.face_rank()][i][0] -// #define NN(i_entity_rank, j_ordinal_on_subDim_entity) new_sub_entity_nodes[i_entity_rank][j_ordinal_on_subDim_entity][0] - - -#define DEBUG_URP_HPP 0 - -#if defined(NDEBUG) || !DEBUG_URP_HPP - -# define NN(i_entity_rank, j_ordinal_on_subDim_entity) new_sub_entity_nodes[i_entity_rank][j_ordinal_on_subDim_entity][0] - -#else - -# define NN(i_entity_rank, j_ordinal_on_subDim_entity) \ - ( ((unsigned)i_entity_rank < new_sub_entity_nodes.size() && (unsigned)j_ordinal_on_subDim_entity < new_sub_entity_nodes[i_entity_rank].size() \ - && new_sub_entity_nodes[i_entity_rank][j_ordinal_on_subDim_entity].size() ) ? new_sub_entity_nodes[i_entity_rank][j_ordinal_on_subDim_entity][0] : 0u ) - -#endif - -#define EDGE_N(i) NN(m_eMesh.edge_rank(), i) -#define FACE_N(i) NN(m_eMesh.face_rank(), i) - -#define EDGE_N_Q(iedge, inode_on_edge) new_sub_entity_nodes[m_eMesh.edge_rank()][iedge][inode_on_edge] -#define FACE_N_Q(iface, inode_on_face) new_sub_entity_nodes[m_eMesh.face_rank()][iface][inode_on_face] -#define NN_Q(i_entity_rank, j_ordinal_of_entity, k_ordinal_of_node_on_entity) \ - new_sub_entity_nodes[i_entity_rank][j_ordinal_of_entity][k_ordinal_of_node_on_entity] - -#define NN_Q_P(i_entity_rank, j_ordinal_of_entity, k_ordinal_of_node_on_entity, perm) \ - new_sub_entity_nodes[i_entity_rank][j_ordinal_of_entity][perm[k_ordinal_of_node_on_entity]] - - struct SierraPort {}; - - /// signifies a part that has been defined automatically during adaptivity - struct STK_Adapt_Auto_Part {}; - extern STK_Adapt_Auto_Part stk_adapt_auto_part; - - - /// The base class for all refinement patterns - /// ------------------------------------------------------------------------------------------------------------------------ - //template< typename ToTopology > - class UniformRefinerPatternBase - { - protected: - - enum - { - /* - base_topo_key_hex27 = shards::Hexahedron<27>::key, - base_topo_key_hex20 = shards::Hexahedron<20>::key, - base_topo_key_quad8 = shards::Quadrilateral<8>::key, - base_topo_key_shellquad8 = shards::ShellQuadrilateral<8>::key, - base_topo_key_shellquad9 = shards::ShellQuadrilateral<9>::key, - base_topo_key_quad9 = shards::Quadrilateral<9>::key, - base_topo_key_wedge15 = shards::Wedge<15>::key, - */ - - base_s_beam_2_key = shards::Beam<2>::key, - base_s_beam_3_key = shards::Beam<3>::key, - - base_s_shell_line_2_key = shards::ShellLine<2>::key, - base_s_shell_line_3_key = shards::ShellLine<3>::key, - base_s_shell_tri_3_key = shards::ShellTriangle<3>::key, - base_s_shell_tri_6_key = shards::ShellTriangle<6>::key, - base_s_shell_quad_4_key = shards::ShellQuadrilateral<4>::key, - base_s_shell_quad_8_key = shards::ShellQuadrilateral<8>::key, - base_s_shell_quad_9_key = shards::ShellQuadrilateral<9>::key - - }; - - stk_classic::mesh::PartVector m_fromParts; - stk_classic::mesh::PartVector m_toParts; - const std::string m_appendConvertString; //="_urpconv_" - const std::string m_appendOriginalString; //="_urporig_100000" - static const std::string m_oldElementsPartName; - stk_classic::mesh::EntityRank m_primaryEntityRank; - public: - //typedef ToTopology TTopo; - - UniformRefinerPatternBase() : m_appendConvertString("_urpconv"), - m_appendOriginalString(percept::PerceptMesh::s_omit_part+"_1000"), // _100000 - //m_oldElementsPartName("urp_oldElements"), - m_primaryEntityRank(stk_classic::mesh::fem::FEMMetaData::INVALID_RANK) - { - Elem::StdMeshObjTopologies::bootstrap(); - - } - virtual ~UniformRefinerPatternBase() {} - - virtual void doBreak()=0; - - virtual unsigned getFromTypeKey()=0; - virtual const CellTopologyData * getFromTopology()=0; - virtual const CellTopologyData * getToTopology()=0; - - stk_classic::mesh::EntityRank getPrimaryEntityRank() { return m_primaryEntityRank; } - /// must be provided by derived classes - /// ------------------------------------------------------------------------------------------------------------------------ - - /// supplies the ranks of the sub entities needed during refinement (eg. m_eMesh.face_rank(), m_eMesh.edge_rank(),..) - /// 10/02/10 and the number of nodes needed for each sub entity - virtual void fillNeededEntities(std::vector& needed_entities)=0; - - /// - virtual void setNeededParts(percept::PerceptMesh& eMesh, BlockNamesType block_names_ranks, - bool sameTopology=true) { - throw std::runtime_error("not implemented"); - } - - /// supply the number of new elements per element during refinement - virtual unsigned getNumNewElemPerElem()=0; - - /// given the node database (NodeRegistry), and the newly created nodes, and an iterator for the elements in the element pool, - /// create all new sub-elements of the refined element - virtual void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0)=0; - - /// if numChild is passed in as non-null, use that value, else use getNumNewElemPerElem() as size of child vector - void set_parent_child_relations(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& old_owning_elem, stk_classic::mesh::Entity& newElement, unsigned ordinal, unsigned *numChild=0); - - void interpolateElementFields(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& old_owning_elem, stk_classic::mesh::Entity& newElement); - - /// given a new element (child) that is a child of an original element (parent), look at parent's side to elem - /// relations and from the children of the element, choose an element to connect the new side to (using connectSides) - bool findSideRelations(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity *parent, stk_classic::mesh::Entity *child); - bool connectSides(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity *element, stk_classic::mesh::Entity *side_elem); - - /// optionally overridden (must be overridden if sidesets are to work properly) to provide info on which sub pattern - /// should be used to refine side sets (and edge sets) - virtual void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - /// default is only this pattern - bp = std::vector(1u, 0); - bp[0] = this; - } - - /// for i/o to work properly, supply string replacements such as for hex-->tet breaking, you would supply "quad"-->"tri" etc. string maps - virtual StringStringMap fixSurfaceAndEdgeSetNamesMap() - { - // provide a null implementation - StringStringMap map; - return map; - } - - /// provided by this class - /// ------------------------------------------------------------------------------------------------------------------------ - - virtual std::string getFromTopoPartName() =0; - virtual std::string getToTopoPartName() =0; - virtual std::string getName() { return std::string(); } - - stk_classic::mesh::PartVector& getToParts() { return m_toParts; } - stk_classic::mesh::PartVector& getFromParts() { return m_fromParts; } - const std::string& getAppendConvertString() { return m_appendConvertString; } - const std::string& getAppendOriginalString() { return m_appendOriginalString; } - static const std::string& getOldElementsPartName() { return m_oldElementsPartName; } - - /// utilities - /// --------- - - /// sets the needed number of nodes on each sub-entity to 1 - this is just a helper - in general, edges and faces have 1 new node - /// for linear elements, and multiple new nodes in the case of quadratic elements - void setToOne(std::vector& needed_entities) - { - for (unsigned i = 0; i < needed_entities.size(); i++) - { - needed_entities[i].second = 1u; - } - } - double * midPoint(const double *p1, const double *p2, int spatialDim, double *x) - { - x[0] = 0.5*(p1[0]+p2[0]); - x[1] = 0.5*(p1[1]+p2[1]); - if (spatialDim == 3) - x[2] = 0.5*(p1[2]+p2[2]); - return x; - } - - double * getCentroid( double* pts[], int len, int spatialDim, double *x) - { - double dlen = double(len); - for (int jsp = 0; jsp < spatialDim; jsp++) - { - x[jsp] = 0.0; - } - for (int ipt = 0; ipt < len; ipt++) - { - for (int jsp = 0; jsp < spatialDim; jsp++) - { - x[jsp] += pts[ipt][jsp] / dlen; - } - } - return x; - } - - static int getTopoDim(shards::CellTopology& cell_topo) - { - int topoDim = cell_topo.getDimension(); - unsigned cell_topo_key = cell_topo.getKey(); - - switch (cell_topo_key) - { - case base_s_shell_line_2_key: - case base_s_shell_line_3_key: - case base_s_beam_2_key: - case base_s_beam_3_key: - topoDim = 1; - break; - - case base_s_shell_tri_3_key: - case base_s_shell_tri_6_key: - case base_s_shell_quad_4_key: - case base_s_shell_quad_9_key: - case base_s_shell_quad_8_key: - topoDim = 2; - break; - } - - return topoDim; - } - - static Teuchos::RCP - createPattern(std::string refine, std::string enrich, std::string convert, percept::PerceptMesh& eMesh, BlockNamesType& block_names); - - static std::string s_convert_options; - static std::string s_refine_options; - static std::string s_enrich_options; - - - - }; - /// Utility intermediate base class providing more support for standard refinement operations - /// ------------------------------------------------------------------------------------------------------------------------ - - template< typename FTopo, typename TTopo > - class URP1 - { - public: - typedef FTopo FromTopology ; - typedef TTopo ToTopology ; - }; - - template - class URP : public UniformRefinerPatternBase, public URP1 - { - public: - - enum - { - fromTopoKey = FromTopology::key, - toTopoKey = ToTopology::key, - topo_key_hex27 = shards::Hexahedron<27>::key, - topo_key_hex20 = shards::Hexahedron<20>::key, - topo_key_quad8 = shards::Quadrilateral<8>::key, - topo_key_shellquad8 = shards::ShellQuadrilateral<8>::key, - topo_key_shellquad9 = shards::ShellQuadrilateral<9>::key, - topo_key_quad9 = shards::Quadrilateral<9>::key, - topo_key_wedge15 = shards::Wedge<15>::key, - topo_key_pyramid13 = shards::Pyramid<13>::key, - topo_key_pyramid5 = shards::Pyramid<5>::key, - topo_key_tet4 = shards::Tetrahedron<4>::key, - - s_shell_line_2_key = shards::ShellLine<2>::key, - s_shell_line_3_key = shards::ShellLine<3>::key, - s_shell_tri_3_key = shards::ShellTriangle<3>::key, - s_shell_tri_6_key = shards::ShellTriangle<6>::key, - s_shell_quad_4_key = shards::ShellQuadrilateral<4>::key, - s_shell_quad_8_key = shards::ShellQuadrilateral<8>::key, - s_shell_quad_9_key = shards::ShellQuadrilateral<9>::key, - - // Cast the keys to int to avoid warning messages about comparisons - // between incompatible enums. - centroid_node = ((int)toTopoKey == (int)topo_key_quad9 ? 8 : - ((int)toTopoKey == (int)topo_key_hex27 ? 20 : 0) - ) - }; - - // return the type of element this pattern can refine - virtual unsigned getFromTypeKey() { return fromTopoKey; } - virtual const CellTopologyData * getFromTopology() { return shards::getCellTopologyData< FromTopology >(); } - virtual const CellTopologyData * getToTopology() { return shards::getCellTopologyData< ToTopology >(); } - - virtual std::string getFromTopoPartName() { - shards::CellTopology cell_topo(getFromTopology()); - return cell_topo.getName(); - } - virtual std::string getToTopoPartName() { - shards::CellTopology cell_topo(getToTopology()); - return cell_topo.getName(); - } - - virtual std::string getName() { return std::string("UniformRefinerPattern_")+getFromTopoPartName()+"_"+getToTopoPartName(); } - - // draw - /// draw a picture of the element's topology and its refinement pattern (using the "dot" program from AT&T's graphviz program) - static std::string draw(bool showRefined = false, bool showEdgeNodes = false) - { - Elem::StdMeshObjTopologies::bootstrap(); - -#define EXPRINT 0 - - const CellTopologyData * const cell_topo_data = shards::getCellTopologyData(); - shards::CellTopology cell_topo(cell_topo_data); - - std::ostringstream graph_str; - - unsigned n_vert = FromTopology::vertex_count; - unsigned n_node = FromTopology::node_count; - unsigned n_edge = cell_topo.getEdgeCount(); - unsigned n_face = cell_topo.getFaceCount(); - unsigned n_side = cell_topo.getSideCount(); - - graph_str << - "graph " << cell_topo.getName() << " {\n" - << "# name= " << cell_topo.getName() << "\n" - << "# n_vert = " << n_vert << "\n" - << "# n_node = " << n_node << "\n" - << "# n_edge = " << n_edge << "\n" - << "# n_face = " << n_face << "\n" - << "# n_side = " << n_side << "\n" - << - " ratio=1;\n" - " layout=nop;\n" - " size=\"4,4\";\n" - " bb=\"-50,-50,150,150\";\n" - " node [color=Green, fontcolor=Blue, font=Courier, width=0.125, height=0.125, shape=circle, fontsize=6, fixedsize=true, penwidth=0.2]; \n" - //" edge [style=dashed]; \n" - " edge [penwidth=0.1]; \n" - ; - - - //" node [color=Green, fontcolor=Blue, font=Courier, width=\"0.1\", height=\"0.1\", shape=none];\n" ; - - std::vector needed_entities; - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); - if (!ref_topo_p) - throw std::runtime_error("draw:: error, no refinement topology found"); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - - unsigned num_child = ref_topo.num_child(); - unsigned num_child_nodes = ref_topo.num_child_nodes(); - bool homogeneous_child = ref_topo.homogeneous_child(); - - //bool edge_exists[num_child_nodes][num_child_nodes]; - bool edge_exists[128][128]; - - - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - RefTopoX& ref_topo_x = Elem::StdMeshObjTopologies::RefinementTopologyExtra< FromTopology > ::refinement_topology; - - if (0) std::cout << num_child << " " << homogeneous_child << " " << n_vert; - - //if (n_face == 0) n_face = 1; // 2D face has one "face" - if (0) - std::cout << "tmp n_face= " << n_face << " n_side= " << n_side << std::endl; - - - Math::MyVector delta; - double len_max = 0.0; - for (unsigned i_edge = 0; i_edge < n_edge; i_edge++) - { - Math::MyVector pc0( ref_topo_x[ cell_topo_data->edge[i_edge].node[0] ].parametric_coordinates ); - Math::MyVector pc1( ref_topo_x[ cell_topo_data->edge[i_edge].node[1] ].parametric_coordinates ); - pc0 -= pc1; - double len = norm_2(pc0); - len_max = std::max(len_max, len); - } - - double scv = 80.0; - Math::Matrix scm = Math::scalingMatrix(scv / len_max); - Math::Matrix rm = scm; - - Math::MyVector centroid; - for (unsigned i_node = 0; i_node < n_node; i_node++) - { - Math::MyVector pc( ref_topo_x[i_node].parametric_coordinates ); - centroid += pc/(double(n_node)); - } - if (0) std::cout << "len_max= " << len_max << " centroid= " << centroid << std::endl; - - if (cell_topo.getDimension() == 3) - { - - // good one - Math::Matrix rmx = Math::rotationMatrix(0, -60.0); - Math::Matrix rmy = Math::rotationMatrix(1, 0.0); - Math::Matrix rmz = Math::rotationMatrix(2, -30.0); - - //rm = ublas::prod(rmy, rmz); - rm = ublas::prod(rmx, rmz); - rm = ublas::prod(rmy, rm); - rm = ublas::prod(scm, rm); - } - - if (0) - std::cout << rm; - for (unsigned i_node = 0; i_node < n_node; i_node++) - { - double *pc = ref_topo_x[i_node].parametric_coordinates; - Math::MyVector v(pc); - v -= centroid; - v = ublas::prod(rm, v); - - v(0) += scv/2.; - v(1) += scv/2.; - v(2) += scv/2.; - - graph_str << " " << i_node << " [ pos=\"" << v(0) << "," << v(1) << "\"];\n"; - } - - // draw edges - if (!showRefined) - //if (showEdges) - for (unsigned i_edge = 0; i_edge < n_edge; i_edge++) - { - unsigned nn = cell_topo_data->edge[i_edge].topology->vertex_count; - if (showEdgeNodes) - nn = cell_topo_data->edge[i_edge].topology->node_count; - for (unsigned j_node = 0; j_node < nn - 1; j_node++) - { - graph_str << " " - << cell_topo_data->edge[i_edge].node[j_node] << " -- " - << cell_topo_data->edge[i_edge].node[(j_node + 1) % nn] << " ; \n" ; - } - } - - bool ft = (fromTopoKey == toTopoKey); - - if (showRefined && ft) - { - // draw edges - for (unsigned i=0; i < num_child_nodes; i++) - for (unsigned j = 0; j < num_child_nodes; j++) - { - edge_exists[i][j]=false; - } - for (unsigned iChild = 0; iChild < num_child; iChild++) - { - // draw nodes - unsigned nvn = (showEdgeNodes? FromTopology::node_count : FromTopology::vertex_count); - for (unsigned jNode = 0; jNode < nvn; jNode++) - { - unsigned childNodeIdx = ref_topo.child_node(iChild)[jNode]; -#ifndef NDEBUG - unsigned childNodeIdxCheck = ref_topo_x[childNodeIdx].ordinal_of_node; - VERIFY_OP(childNodeIdx, ==, childNodeIdxCheck, "childNodeIdxCheck"); -#endif - - double *pc = ref_topo_x[childNodeIdx].parametric_coordinates; - Math::MyVector v(pc); - v -= centroid; - v = ublas::prod(rm, v); - - v(0) += scv/2.; - v(1) += scv/2.; - v(2) += scv/2.; - - //graph_str << " " << i_node << " [ pos=\"" << pc[0] << "," << pc[1] << "\"];\n"; - std::string color="green"; - //if (childNodeIdx >= FromTopology::node_count) - if (childNodeIdx >= FromTopology::vertex_count) - color = "red"; - graph_str << " " << childNodeIdx << " [color=" << color << ", pos=\"" << v(0) << "," << v(1) << "\"];\n"; - - } - - for (unsigned i_edge = 0; i_edge < n_edge; i_edge++) - { - //unsigned nn = cell_topo_data->edge[i_edge].topology->vertex_count; - //unsigned nn = cell_topo_data->edge[i_edge].topology->node_count; - - unsigned nn = cell_topo_data->edge[i_edge].topology->vertex_count; - if (showEdgeNodes) - nn = cell_topo_data->edge[i_edge].topology->node_count; - - for (unsigned j_node = 0; j_node < nn - 1; j_node++) - { - unsigned j0 = ref_topo.child_node(iChild)[ cell_topo_data->edge[i_edge].node[j_node] ]; - unsigned j1 = ref_topo.child_node(iChild)[ cell_topo_data->edge[i_edge].node[(j_node + 1) % nn] ]; - unsigned j00 = std::min(j0,j1); - unsigned j10 = std::max(j0,j1); - if (!edge_exists[j00][j10]) - graph_str << " " << std::min(j0,j1) << " -- " << std::max(j0,j1) << " ; \n" ; - edge_exists[j00][j10]=true; - } - } - - } - } - - graph_str << "}\n"; - - return std::string(graph_str.str()); - - } - - protected: - percept::PerceptMesh& m_eMesh; - URP(percept::PerceptMesh& eMesh) : m_eMesh(eMesh) {} - - typedef ToTopology TTopo; - typedef boost::array refined_element_type; - - - void interpolateLine3(percept::PerceptMesh& eMesh, stk_classic::mesh::FieldBase* field, - MDArray& output_pts, stk_classic::mesh::Entity& element, MDArray& input_param_coords, double time_val=0.0) - { - int fieldStride = output_pts.dimension(1); - unsigned *null_u = 0; - - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(mesh::fem::FEMMetaData::NODE_RANK); - double xi = input_param_coords(0, 0); - - // FIXME assumes {-1,0,1} element parametric coords - //double basis_val[3] = { (xi)*(xi - 1.0)/2.0, (1.0-xi)*(1.0+xi) , (xi)*(1.0+xi)/2.0 }; - - double basis_val[3] = { (xi)*(xi - 1.0)/2.0, (xi)*(1.0+xi)/2.0, (1.0-xi)*(1.0+xi) }; - - for (int i_stride=0; i_stride < fieldStride; i_stride++) - { - output_pts(0, i_stride) = 0.0; - } - for (unsigned i_node = 0; i_node < elem_nodes.size(); i_node++) - { - stk_classic::mesh::Entity *node = elem_nodes[i_node].entity(); - double *f_data = eMesh.field_data(field, *node, null_u); - for (int i_stride=0; i_stride < fieldStride; i_stride++) - { - output_pts(0, i_stride) += f_data[i_stride]*basis_val[i_node]; - } - } - } - - void interpolateIntrepid(percept::PerceptMesh& eMesh, stk_classic::mesh::FieldBase* field, shards::CellTopology& cell_topo, - MDArray& output_pts, stk_classic::mesh::Entity& element, MDArray& input_param_coords, double time_val=0.0) - { - int fieldStride = output_pts.dimension(1); - unsigned *null_u = 0; - - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(mesh::fem::FEMMetaData::NODE_RANK); - MDArray basis_val(elem_nodes.size(), 1); - //std::cout << "tmp fieldStride= " << fieldStride << " elem_nodes.size()= " << elem_nodes.size() << std::endl; - - PerceptMesh::BasisTypeRCP basis = eMesh.getBasis(cell_topo); - basis->getValues(basis_val, input_param_coords, Intrepid::OPERATOR_VALUE); - if (0) - std::cout << "\n tmp input_param_coords= " - << input_param_coords(0,0) << " " - << input_param_coords(0,1) << " " - << input_param_coords(0,2) << " " << std::endl; - - for (int i_stride=0; i_stride < fieldStride; i_stride++) - { - output_pts(0, i_stride) = 0.0; - } - for (unsigned i_node = 0; i_node < elem_nodes.size(); i_node++) - { - //std::cout << "tmp basis_val[" << i_node <<"]= " << basis_val(i_node,0) << std::endl; - stk_classic::mesh::Entity *node = elem_nodes[i_node].entity(); - double *f_data = eMesh.field_data(field, *node, null_u); - for (int i_stride=0; i_stride < fieldStride; i_stride++) - { - output_pts(0, i_stride) += f_data[i_stride]*basis_val(i_node, 0); - } - } - } - - /// helpers for interpolating fields, coordinates - /// ------------------------------------------------------------------------------------------------------------------------ -#define EXTRA_PRINT_URP_IF 0 - - - /// This version uses Intrepid for interpolation - void interpolateFields(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element, stk_classic::mesh::Entity& newElement, const unsigned *child_nodes, - RefTopoX_arr ref_topo_x, stk_classic::mesh::FieldBase *field) - { - EXCEPTWATCH; - - unsigned *null_u = 0; - - shards::CellTopology cell_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - - // FIXME - need topo dimensions here - int topoDim = getTopoDim(cell_topo); - - - int fieldStride = 0; - stk_classic::mesh::EntityRank fr_type = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - - //std::cout << "tmp cell_topo= " << cell_topo.getName() << " topoDim= " << topoDim << std::endl; - - if (EXTRA_PRINT_URP_IF) std::cout << "tmp field = " << field->name() << " topoDim= " << topoDim << std::endl; - - { - unsigned nfr = field->restrictions().size(); - if (EXTRA_PRINT_URP_IF && nfr != 1 ) std::cout << "tmp P[" << 0 << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - fr_type = fr.entity_rank(); - fieldStride = fr.dimension() ; - stk_classic::mesh::Part& frpart = eMesh.get_fem_meta_data()->get_part(fr.part_ordinal()); - if (EXTRA_PRINT_URP_IF && nfr != 1 ) std::cout << "tmp P[" << 0 << "] info> number of field restrictions= " << nfr << " fr_type= " << fr_type - << " fieldStride = " << fieldStride << " frpart= " << frpart.name() - << std::endl; - } - { - const stk_classic::mesh::FieldBase::Restriction & r = - field->restriction(fr_type, stk_classic::mesh::fem::FEMMetaData::get(*field).universal_part()); - fieldStride = r.dimension(); - if (EXTRA_PRINT_URP_IF) std::cout << "tmp stride = " << r.dimension() << " fieldStride= " << fieldStride - << " fr_type= " << fr_type << std::endl; - } - } - // FIXME - if (!fieldStride || fr_type != stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - return; - - //FieldFunction field_func("tmp", field, eMesh, topoDim, fieldStride); - FieldFunction field_func("tmp", field, eMesh, topoDim, fieldStride); - - MDArray input_pts(1, topoDim); - MDArray input_param_coords(1, topoDim); - MDArray output_pts(1, fieldStride); - - if (EXTRA_PRINT_URP_IF) std::cout << "tmp field = " << field->name() << " topoDim= " << topoDim << " fieldStride= " << fieldStride << std::endl; - - if (1) - { - static bool entered = false; - - if (!entered && (toTopoKey == topo_key_quad8 || toTopoKey == topo_key_hex20 || toTopoKey == topo_key_shellquad8)) - { - entered = true; - - std::cout << "tmp testing basis functions " << std::endl; - std::cout << "tmp toTopoKey: " << toTopoKey << " topo_key_quad8 = " << topo_key_quad8 << " cell_topo= " << cell_topo.getName() << std::endl; - std::cout << "tmp toTopoKey: " << toTopoKey << " topo_key_shellquad8 = " << topo_key_shellquad8 << " cell_topo= " << cell_topo.getName() << std::endl; - std::cout << "tmp toTopoKey: " << toTopoKey << " topo_key_hex20 = " << topo_key_hex20 << " cell_topo= " << cell_topo.getName() << std::endl; - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(mesh::fem::FEMMetaData::NODE_RANK); - - - PerceptMesh::BasisTypeRCP basis = eMesh.getBasis(cell_topo); - MDArray output_tmp(elem_nodes.size(), 1); - MDArray input_param_coords_tmp(1, topoDim); - - for (unsigned i_node = 0; i_node < elem_nodes.size(); i_node++) - { - double *param_coord = ref_topo_x[i_node].parametric_coordinates; - for (int ip=0; ip < topoDim; ip++) - { - input_param_coords_tmp(0, ip) = param_coord[ip]; - } - - basis->getValues(output_tmp, input_param_coords_tmp, Intrepid::OPERATOR_VALUE); - bool found = false; - for (unsigned ii=0; ii < elem_nodes.size(); ii++) - { - if (fabs(output_tmp(ii, 0)-((ii == i_node)? 1.0 : 0.0)) > 1.e-6) - { - found = true; - std::cout << "tmp i_node= " << i_node << " elem_nodes.size()= " << elem_nodes.size() << std::endl; - std::cout << "fabs(output_tmp(ii, 0)-1.0) > 1.e-6),... output_tmp(ii,0)= " << output_tmp(ii,0) << std::endl; - std::cout << "ii = " << ii << " i_node= " << i_node << std::endl; - std::cout << "input_param_coords= " - << input_param_coords << " " << std::endl; - std::cout << "output_tmp= " << output_tmp << std::endl; - } - } - if (found) throw std::runtime_error("error in Intrepid"); - } - } - } - - stk_classic::mesh::PairIterRelation new_elem_nodes = newElement.relations(mesh::fem::FEMMetaData::NODE_RANK); - for (unsigned i_new_node = 0; i_new_node < new_elem_nodes.size(); i_new_node++) - { - unsigned childNodeIdx = child_nodes[i_new_node]; - if (EXTRA_PRINT_URP_IF) std::cout << "tmp childNodeIdx, i_new_node= " << childNodeIdx << " " << i_new_node << std::endl; - double *param_coord = ref_topo_x[childNodeIdx].parametric_coordinates; - if (EXTRA_PRINT_URP_IF) std::cout << "tmp childNodeIdx, i_new_node= " << childNodeIdx << " " << i_new_node - << " param_coord= " << param_coord[0] << " " << param_coord[1] << std::endl; - for (int ip=0; ip < topoDim; ip++) - { - input_param_coords(0, ip) = param_coord[ip]; - } - if (EXTRA_PRINT_URP_IF) std::cout << "tmp input_param_coords= " << input_param_coords << " cell_topo= " << cell_topo << std::endl; - - - double time_val=0.0; - - /// unfortunately, Intrepid doesn't support a quadratic Line<3> element - - if (toTopoKey == topo_key_wedge15 || toTopoKey == topo_key_quad8 || toTopoKey == topo_key_shellquad8 || toTopoKey == topo_key_hex20 || toTopoKey == topo_key_pyramid13) - { - //std::cout << "tmp here 1 i_new_node= " << i_new_node << " base element= " << std::endl; - if ( EXTRA_PRINT_URP_IF) eMesh.print_entity(std::cout, element, eMesh.get_coordinates_field() ); - - interpolateIntrepid(eMesh, field, cell_topo, output_pts, element, input_param_coords, time_val); - if (0) - { - std::cout << "tmp input_param_coords= " - << input_param_coords(0,0) << " " - << input_param_coords(0,1) << " " - << (topoDim == 3 ? input_param_coords(0,2) : 0.0 ) << " " - ; - std::cout << "output_pts= " - << output_pts(0,0) << " " - << output_pts(0,1) << " " - << (topoDim == 3 ? output_pts(0,2) : 0.0 ) << " " - << std::endl; - } - } - else - { - if (cell_topo.getDimension() == 1 && cell_topo.getNodeCount() == 3) // Line<3> element - { - interpolateLine3(eMesh, field, output_pts, element, input_param_coords, time_val); - } - else - { - field_func(input_pts, output_pts, element, input_param_coords, time_val); - } - } - - stk_classic::mesh::Entity *new_node = new_elem_nodes[i_new_node].entity(); - - { - double *f_data_new = eMesh.field_data(field, *new_node, null_u); - for (int ifd=0; ifd < fieldStride; ifd++) - { - f_data_new[ifd] = output_pts(0, ifd); - } - } - } - if ( EXTRA_PRINT_URP_IF) - { - std::cout << "tmp newElement: " << std::endl; - eMesh.print_entity(std::cout, newElement, eMesh.get_coordinates_field() ); - } - } - - /// do interpolation for all fields - /// This version uses Intrepid - void interpolateFields(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element, stk_classic::mesh::Entity& newElement, const unsigned *child_nodes, - RefTopoX_arr ref_topo_x) - { - const stk_classic::mesh::FieldVector & fields = eMesh.get_fem_meta_data()->get_fields(); - unsigned nfields = fields.size(); - //std::cout << "P[" << p_rank << "] info> Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - //std::cout << "P[" << eMesh.get_rank() << "] field = " << field->name() << std::endl; - - interpolateFields(eMesh, element, newElement, child_nodes, ref_topo_x, field); - } - } - - - stk_classic::mesh::Entity& createOrGetNode(NodeRegistry& nodeRegistry, PerceptMesh& eMesh, stk_classic::mesh::EntityId eid) - { -#if STK_ADAPT_NODEREGISTRY_USE_ENTITY_REPO - stk_classic::mesh::Entity *node_p = nodeRegistry.get_entity_node_Ib(*eMesh.get_bulk_data(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, eid); - if (node_p) - return *node_p; - else - return eMesh.createOrGetNode(eid); -#else - return eMesh.createOrGetNode(eid); -#endif - } - - enum { NumNewElements_Enrich = 1 }; - - void - genericEnrich_createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - std::vector needed_entities; - fillNeededEntities(needed_entities); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - typedef boost::array quadratic_type; - - static vector elems(NumNewElements_Enrich); - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - unsigned n_edges = cell_topo_data->edge_count; - - unsigned n_faces = cell_topo.getFaceCount(); - if (n_faces == 0) n_faces = 1; // 2D face has one "face" - unsigned n_sides = cell_topo.getSideCount(); - if (0) - std::cout << "tmp n_faces= " << n_faces << " n_sides= " << n_sides << std::endl; - - add_parts = m_toParts; - -#if STK_ADAPT_URP_LOCAL_NODE_COMPS - for (unsigned i_need = 0; i_need < needed_entities.size(); i_need++) - { - unsigned nSubDimEntities = 1; - if (needed_entities[i_need].first == m_eMesh.edge_rank()) - { - nSubDimEntities = cell_topo_data->edge_count; - } - else if (needed_entities[i_need].first == m_eMesh.face_rank()) - { - nSubDimEntities = cell_topo_data->side_count; - } - - for (unsigned iSubDim = 0; iSubDim < nSubDimEntities; iSubDim++) - { - nodeRegistry.makeCentroidCoords(*const_cast(&element), needed_entities[i_need].first, iSubDim); - nodeRegistry.addToExistingParts(*const_cast(&element), needed_entities[i_need].first, iSubDim); - nodeRegistry.interpolateFields(*const_cast(&element), needed_entities[i_need].first, iSubDim); - } - } -#endif - - const CellTopologyData * const cell_topo_data_toTopo = shards::getCellTopologyData< ToTopology >(); - shards::CellTopology cellTopo(cell_topo_data_toTopo); - -#define CENTROID_N NN(m_primaryEntityRank,0) - - quadratic_type& EN = elems[0]; - - for (unsigned ind = 0; ind < FromTopology::vertex_count; ind++) - { - EN[ind] = VERT_N(ind); - } - - for (unsigned i_need = 0; i_need < needed_entities.size(); i_need++) - { - if (needed_entities[i_need].first == m_eMesh.edge_rank()) - { - for (unsigned i_edge = 0; i_edge < n_edges; i_edge++) - { - unsigned edge_ord = cell_topo_data_toTopo->edge[i_edge].node[2]; - unsigned inode = EDGE_N(i_edge); - EN[edge_ord] = inode; - } - } - else if (needed_entities[i_need].first == m_eMesh.face_rank()) - { - for (unsigned i_face = 0; i_face < n_faces; i_face++) - { - // FIXME assumes face is quadrilateral - shards::CellTopology face_topo = cell_topo.getDimension()==2 ? cell_topo : shards::CellTopology(cell_topo.getCellTopologyData( 2, i_face)); - if (0) - std::cout << "tmp P[" << eMesh.get_rank() << "] inode = " << FACE_N(i_face) << " for i_face = " << i_face - << " face_topo.getNodeCount()= " << face_topo.getNodeCount() - << std::endl; - if (face_topo.getNodeCount() == 4 || toTopoKey == topo_key_quad9) - { - unsigned face_ord = 0; - if (toTopoKey == topo_key_quad9) - { - face_ord = 8; - } - else - { - face_ord = cell_topo_data_toTopo->side[i_face].node[8]; - } - - unsigned inode = FACE_N(i_face); - - //std::cout << "tmp P[" << eMesh.get_rank() << "] inode = " << inode << " for i_face = " << i_face << " face_ord= " << face_ord << std::endl; - - if (!inode) - { - std::cout << "P[" << eMesh.get_rank() << "] inode = 0 for i_face = " << i_face << " face_ord= " << face_ord << std::endl; - //throw std::logic_error("UniformRefinerPatternBase::genericEnrich_createNewElements bad entity id = 0 "); - } - - EN[face_ord] = inode; - } - } - } - else if (needed_entities[i_need].first == m_eMesh.element_rank()) - { - EN[ centroid_node ] = CENTROID_N; - } - } - -#undef CENTROID_N - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - // FIXME - if (m_primaryEntityRank == m_eMesh.element_rank() && proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - for (int inode=0; inode < ToTopology::node_count; inode++) - { - stk_classic::mesh::EntityId eid = elems[ielem][inode]; - if (!eid) - { - std::cout << "P[" << eMesh.get_rank() << "] eid = 0 for inode = " << inode << std::endl; - throw std::logic_error("UniformRefinerPatternBase::genericEnrich_createNewElements bad entity id = 0 "); - } - //stk_classic::mesh::Entity& node = eMesh.createOrGetNode(eid); - stk_classic::mesh::Entity& node = createOrGetNode(nodeRegistry, eMesh, eid); - eMesh.get_bulk_data()->declare_relation(newElement, node, inode); - } - - if (0 && EXTRA_PRINT_URP_IF) - { - std::cout << "tmp newElement: " << std::endl; - eMesh.print_entity(std::cout, newElement, eMesh.get_coordinates_field() ); - } - - set_parent_child_relations(eMesh, element, newElement, ielem); - - interpolateElementFields(eMesh, element, newElement); - - element_pool++; - - } - - } - - /*------------------------------------------------------------------------*/ - /* comments from Shards_CellTopology.hpp with locally added comments - * \brief Find the permutation from the expected nodes to the actual nodes, - * - * Find permutation 'p' such that: - * actual_node[j] == expected_node[ top.permutation[p].node[j] ] - * for all vertices. - * - * So, actual_node[j] is the sub-dim cell; expected_node is the parent cell->subcell[dim][Ord].node[ perm[p][j] ] - * - * Get sub-dim cell's nodes from NodeRegistry (actual_node array); or just sort them into a set - * Get parent element's sub-dim cell nodes from element->subcell[dim][ord].node - * Get permutation using shards::findPermutation(cell_topo, parent->subcell[dim][ord].node, subdim_cell_sorted_nodes) - * - * - * Then ParentCell.node(K) == SubCell.node(I) where: - * - SubCellTopology == ParentCellTopology->subcell[dim][Ord].topology - * - K = ParentCellTopology->subcell[dim][Ord].node[IP] - * - IP = SubCellTopology->permutation[P].node[I] - * - I = SubCellTopology->permutation_inverse[P].node[IP] - - */ - - int getPermutation(int num_verts, stk_classic::mesh::Entity& element, shards::CellTopology& cell_topo, unsigned rank_of_subcell, unsigned ordinal_of_subcell) - { - if (rank_of_subcell == 0 || rank_of_subcell == 3) return 0; - - //! We choose to define the "global baseline" as an imaginary face that has its nodes sorted on their identifiers. - //! The main part of this is to find the minimum node index. - //! Once sorted, the node id's go into the vector_sdcell_global_baseline array. - - static std::vector vector_sdcell_global_baseline(4); - static std::vector subCell_from_element(4); - - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(mesh::fem::FEMMetaData::NODE_RANK); - - const unsigned * inodes = cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].node; - int num_subcell_verts = cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].topology->vertex_count; - - // tmp - //vector_sdcell_global_baseline.resize(num_subcell_verts); - //subCell_from_element.resize(num_subcell_verts); - // tmp end - - unsigned minNodeId = 0; - for (int iv = 0; iv < num_subcell_verts; iv++) - { - unsigned nid = elem_nodes[inodes[iv]].entity()->identifier(); - if (iv == 0) - minNodeId = nid; - else - minNodeId = std::min(minNodeId, nid); - subCell_from_element[iv] = nid; - } - - int perm = -1; - - /// for tri or quad faces we search for the min node, then look at its two neighbors along edges - /// - if the first edge is the next node in line (in terms of its id) we use the ordering as 0,1,2,3 - /// else it is flipped and we reverse the ordering - /// - once the ordering is determined, the actual permutation can be deduced from shards - /// - - { - // quad or tri - if (0 && num_subcell_verts==3) - { - std::cout << "tmp b4 element 1= " << element << " cell_topo= " << cell_topo.getName() - << " rank_of_subcell= " << rank_of_subcell << std::endl; - std::cout << "tmp b4 vector_sdcell_global_baseline= " << vector_sdcell_global_baseline << std::endl; - std::cout << "tmp b4 subCell_from_element = " << subCell_from_element << std::endl; - } - - //! extract the minimal node index - //set_sdcell_global_baseline_iter = set_sdcell_global_baseline.begin(); - unsigned i0 = minNodeId; - - //! find the rotation to get to the minimal node - int j0 = -1; - for (int iv = 0; iv < num_subcell_verts; iv++) - { - if (i0 == subCell_from_element[iv]) - { - j0 = iv; - break; - } - } - - if (j0 < 0) throw std::logic_error("j0 < 0 "); - - int j1 = (j0 + 1) % num_subcell_verts; - int j2 = (j0 + (num_subcell_verts-1)) % num_subcell_verts; // adds 3 for quads, or 2 for tris to pickup the neigh node - - //! see if we need to reverse the order to make it match up; save the newly oriented nodes in vector_sdcell_global_baseline - if (subCell_from_element[j1] < subCell_from_element[j2]) - { - for (int iv = 0; iv < num_subcell_verts; iv++) - { - vector_sdcell_global_baseline[iv] = subCell_from_element[(j0 + iv) % num_subcell_verts]; - } - } - else - { - for (int iv = 0; iv < num_subcell_verts; iv++) - { - vector_sdcell_global_baseline[(num_subcell_verts - iv) % num_subcell_verts] = - subCell_from_element[(j0 + iv) % num_subcell_verts]; - } - } - - //! now we have a set of nodes in the right order, use Shards to get the actual permutation - perm = shards::findPermutation(cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].topology, - &vector_sdcell_global_baseline[0], &subCell_from_element[0]); - - //std::cout << "tmp perm = " << perm << std::endl; - - if ( perm < 0) - { - std::cout << "tmp aft element 1= " << element << " cell_topo= " << cell_topo.getName() << " rank_of_subcell= " << rank_of_subcell << std::endl; - std::cout << "tmp aft vector_sdcell_global_baseline= " << vector_sdcell_global_baseline << std::endl; - std::cout << "tmp aft subCell_from_element = " << subCell_from_element << std::endl; - throw std::logic_error("getPermutation: perm < 0"); - } - - if (0 && num_subcell_verts==3) - { - const unsigned *perm_array = cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].topology->permutation[perm].node; - for (int iv = 0; iv < num_subcell_verts; iv++) - { - std::cout << "tmp perm_array[" << iv << "]= " << perm_array[iv] << std::endl; - } - } - - } - - if (perm < 0) - { - std::cout << "tmp element 1= " << element << " cell_topo= " << cell_topo.getName() << " rank_of_subcell= " << rank_of_subcell << std::endl; - std::cout << "tmp vector_sdcell_global_baseline= " << vector_sdcell_global_baseline << std::endl; - std::cout << "tmp subCell_from_element = " << subCell_from_element << std::endl; - throw std::logic_error("getPermutation 2: perm < 0"); - } - - return perm; - } - - //static std::vector s_needed_entities; - //static vector s_elems; - //static std::vector s_add_parts; - //static std::vector s_remove_parts; - - void - genericRefine_createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - EXCEPTWATCH; - static std::vector needed_entities; - fillNeededEntities(needed_entities); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - static vector elems; - elems.resize(getNumNewElemPerElem()); - - shards::CellTopology cell_topo(cell_topo_data); - bool isLinearElement = Util::isLinearElement(cell_topo); - - // SPECIAL CASE ALERT FIXME - //if (toTopoKey == topo_key_wedge15) - // isLinearElement = true; - //std::cout << "tmp cell_topo= " << cell_topo.getName() << " isLinearElement= " << isLinearElement << std::endl; - - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - int topoDim = cell_topo.getDimension(); - //unsigned cell_topo_key = fromTopoKey; - //getTopoDim(topoDim, cell_topo_key); - unsigned cellDimension = (unsigned)topoDim; - - // FIXME - if (0) - { - int nface = new_sub_entity_nodes[2].size(); - std::cout << "tmp nface= " << nface << " cellDimension= " << cellDimension << std::endl; - for (int iface = 0; iface < nface; iface++) - { - std::cout << "tmp iface= " << iface << " vec= " << new_sub_entity_nodes[2][iface] << std::endl; - } - } - - unsigned n_edges = cell_topo_data->edge_count; - if (n_edges == 0) n_edges = 1; // 1D edge has one "edge" - unsigned n_faces = cell_topo.getFaceCount(); - if (n_faces == 0) n_faces = 1; // 2D face has one "face" - unsigned n_sides = cell_topo.getSideCount(); - if (0) std::cout << "tmp n_edges= " << n_edges << " n_faces= " << n_faces << " n_sides= " << n_sides << std::endl; - - for (unsigned i_need = 0; i_need < needed_entities.size(); i_need++) - { - unsigned nSubDimEntities = 0; - if (needed_entities[i_need].first == m_eMesh.edge_rank()) - { - nSubDimEntities = cell_topo_data->edge_count; - } - else if (needed_entities[i_need].first == m_eMesh.face_rank()) - { - nSubDimEntities = cell_topo_data->side_count; - } - else if (needed_entities[i_need].first == m_eMesh.element_rank()) - { - nSubDimEntities = 1; - } - - - // FIXME - assumes first node on each sub-dim entity is the "linear" one - for (unsigned iSubDim = 0; iSubDim < nSubDimEntities; iSubDim++) - { - //! -#if STK_ADAPT_URP_LOCAL_NODE_COMPS - nodeRegistry.addToExistingParts(*const_cast(&element), needed_entities[i_need].first, iSubDim); - if (isLinearElement) - { - nodeRegistry.interpolateFields(*const_cast(&element), needed_entities[i_need].first, iSubDim); - } -#endif - - } - } - - const CellTopologyData * const cell_topo_data_toTopo = shards::getCellTopologyData< ToTopology >(); - shards::CellTopology cellTopo(cell_topo_data_toTopo); - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); // CHECK - if (!ref_topo_p) - throw std::runtime_error("genericRefine_createNewElements:: error, no refinement topology found"); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - - unsigned num_child = ref_topo.num_child(); - unsigned iChildStart = 0; - //unsigned iChildEnd = num_child-1; - // SPECIAL CASE ALERT - if (fromTopoKey == topo_key_pyramid5) - { - num_child = getNumNewElemPerElem(); - if (toTopoKey == topo_key_tet4) - { - iChildStart = 6; - //iChildEnd = 9; - } - } - else - { - VERIFY_OP(num_child, == , getNumNewElemPerElem(), "genericRefine_createNewElements num_child problem"); - } - - // FIXME check if this is a wedge - //bool homogeneous_child = ref_topo.homogeneous_child(); - //VERIFY_OP(homogeneous_child, ==, true, "genericRefine_createNewElements homogeneous_child"); - - RefTopoX& ref_topo_x = Elem::StdMeshObjTopologies::RefinementTopologyExtra< FromTopology > ::refinement_topology; - - for (unsigned iChild = 0; iChild < num_child; iChild++) - { - int iChildRefTopo = iChild + iChildStart; - - refined_element_type& EN = elems[iChild]; - for (unsigned jNode = 0; jNode < ToTopology::node_count; jNode++) - { - unsigned childNodeIdx = ref_topo.child_node(iChildRefTopo)[jNode]; - -#ifndef NDEBUG - unsigned childNodeIdxCheck = ref_topo_x[childNodeIdx].ordinal_of_node; - VERIFY_OP(childNodeIdx, ==, childNodeIdxCheck, "childNodeIdxCheck"); -#endif - - unsigned inode=0; - unsigned rank_of_subcell = ref_topo_x[childNodeIdx].rank_of_subcell; - unsigned ordinal_of_subcell = ref_topo_x[childNodeIdx].ordinal_of_subcell; - unsigned ordinal_of_node_on_subcell = ref_topo_x[childNodeIdx].ordinal_of_node_on_subcell; - unsigned num_nodes_on_subcell = ref_topo_x[childNodeIdx].num_nodes_on_subcell; - - bool usePerm = true; - - // only need permuation for quadratic elements - if (num_nodes_on_subcell == 1) - usePerm = false; - - const unsigned * perm_array = 0; - if (usePerm) - { - int perm_ord = getPermutation(FromTopology::vertex_count, element, cell_topo, rank_of_subcell, ordinal_of_subcell); - - if (perm_ord < 0) - throw std::logic_error("permutation < 0 "); - //std::cout << "tmp 0 " << perm_ord << " rank_of_subcell= " << rank_of_subcell << " ordinal_of_subcell= " << ordinal_of_subcell << std::endl; - //std::cout << "tmp 0 " << cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].topology << std::endl; - if (1 <= rank_of_subcell && rank_of_subcell <= 2) - { - perm_array = cell_topo.getCellTopologyData()->subcell[rank_of_subcell][ordinal_of_subcell].topology->permutation[perm_ord].node; - } - - } - - if (0) - { - std::cout << "tmp 2 cell_topo = " << cell_topo.getName() << " isLinearElement= " << isLinearElement << std::endl; - std::cout << "tmp m_primaryEntityRank = " << m_primaryEntityRank << std::endl; - std::cout << "tmp rank_of_subcell = " << rank_of_subcell << std::endl; - std::cout << "tmp ordinal_of_subcell = " << ordinal_of_subcell << std::endl; - std::cout << "tmp ordinal_of_node_on_subcell = " << ordinal_of_node_on_subcell << std::endl; - std::cout << "tmp num_nodes_on_subcell = " << num_nodes_on_subcell << std::endl; - std::cout << "tmp new_sub_entity_nodes.size() = " << new_sub_entity_nodes.size() << std::endl; - std::cout << "tmp new_sub_entity_nodes[Face].size() = " << new_sub_entity_nodes[m_eMesh.face_rank()].size() << std::endl; - if (new_sub_entity_nodes[m_eMesh.face_rank()].size()) - { - std::cout << "tmp new_sub_entity_nodes[Face][ordinal_of_subcell].size() = " - << new_sub_entity_nodes[m_eMesh.face_rank()][ordinal_of_subcell].size() << std::endl; - } - - //std::cout << "tmp new_sub_entity_nodes = \n" << new_sub_entity_nodes << std::endl; - } - - - // FIXME these ranks are hardcoded because there is a basic assumption in the table generation code that - // assumes these ranks are used - switch (rank_of_subcell) - { - case 0: - inode = VERT_N(ordinal_of_subcell); - break; - - case 1: - if (usePerm) // FIXME - if (num_nodes_on_subcell > 1) - inode = NN_Q_P(m_eMesh.edge_rank(), ordinal_of_subcell, ordinal_of_node_on_subcell, perm_array); - else - inode = NN_Q(m_eMesh.edge_rank(), ordinal_of_subcell, ordinal_of_node_on_subcell); - else - inode = EDGE_N_Q(ordinal_of_subcell, ordinal_of_node_on_subcell); - - break; - - case 2: - if (cellDimension == 2) - { - VERIFY_OP(ordinal_of_subcell, == , 0, "createNewElements: ordinal_of_subcell"); - - if (usePerm) - { - if (num_nodes_on_subcell > 1) - { - inode = NN_Q_P(m_primaryEntityRank, ordinal_of_subcell, ordinal_of_node_on_subcell, perm_array); - } - else - { - inode = NN_Q(m_primaryEntityRank, ordinal_of_subcell, ordinal_of_node_on_subcell); - } - } - else - { - inode = NN_Q(m_primaryEntityRank, ordinal_of_subcell, ordinal_of_node_on_subcell); - } - } - else - { - if (usePerm) - { - if (num_nodes_on_subcell > 1) - { - if (0) - { - std::cout << "tmp cell_topo = " << cell_topo.getName() << " isLinearElement= " << isLinearElement << std::endl; - std::cout << "tmp rank_of_subcell = " << rank_of_subcell << std::endl; - std::cout << "tmp ordinal_of_subcell = " << ordinal_of_subcell << std::endl; - std::cout << "tmp ordinal_of_node_on_subcell = " << ordinal_of_node_on_subcell << std::endl; - std::cout << "tmp num_nodes_on_subcell = " << num_nodes_on_subcell << std::endl; - - for (unsigned ii=0; ii < num_nodes_on_subcell; ii++) - { - std::cout << "tmp pa[ii]= " << perm_array[ii] << std::endl; - } - - std::cout << "tmp new_sub_entity_nodes.size() = " << new_sub_entity_nodes.size() << std::endl; - std::cout << "tmp new_sub_entity_nodes[Face].size() = " << new_sub_entity_nodes[m_eMesh.face_rank()].size() << std::endl; - if (new_sub_entity_nodes[m_eMesh.face_rank()].size()) - { - std::cout << "tmp new_sub_entity_nodes[Face][ordinal_of_subcell].size() = " - << new_sub_entity_nodes[m_eMesh.face_rank()][ordinal_of_subcell].size() << std::endl; - } - - std::cout << "tmp new_sub_entity_nodes[Face][ordinal_of_subcell] = \n" - << new_sub_entity_nodes[m_eMesh.face_rank()][ordinal_of_subcell] << std::endl; - - std::cout << "tmp new_sub_entity_nodes = \n" - << new_sub_entity_nodes << std::endl; - - std::cout << "tmp pa = " << (usePerm ? perm_array[ordinal_of_node_on_subcell] : ordinal_of_node_on_subcell) << std::endl; - - } - inode = NN_Q_P(m_eMesh.face_rank(), ordinal_of_subcell, ordinal_of_node_on_subcell, perm_array); - } - else - { - if (0) - { - std::cout << "tmp 1 cell_topo = " << cell_topo.getName() << " isLinearElement= " << isLinearElement << std::endl; - std::cout << "tmp m_primaryEntityRank = " << m_primaryEntityRank << std::endl; - std::cout << "tmp rank_of_subcell = " << rank_of_subcell << std::endl; - std::cout << "tmp ordinal_of_subcell = " << ordinal_of_subcell << std::endl; - std::cout << "tmp ordinal_of_node_on_subcell = " << ordinal_of_node_on_subcell << std::endl; - std::cout << "tmp num_nodes_on_subcell = " << num_nodes_on_subcell << std::endl; - std::cout << "tmp new_sub_entity_nodes.size() = " << new_sub_entity_nodes.size() << std::endl; - std::cout << "tmp new_sub_entity_nodes[Face].size() = " << new_sub_entity_nodes[m_eMesh.face_rank()].size() << std::endl; - if (new_sub_entity_nodes[m_eMesh.face_rank()].size()) - { - std::cout << "tmp new_sub_entity_nodes[Face][ordinal_of_subcell].size() = " - << new_sub_entity_nodes[m_eMesh.face_rank()][ordinal_of_subcell].size() << std::endl; - } - - std::cout << "tmp new_sub_entity_nodes = \n" << new_sub_entity_nodes << std::endl; - } - - inode = NN_Q(m_eMesh.face_rank(), ordinal_of_subcell, ordinal_of_node_on_subcell); - } - } - else - { - inode = NN_Q(m_eMesh.face_rank(), ordinal_of_subcell, ordinal_of_node_on_subcell); - } - - } - break; - case 3: - inode = NN_Q(m_primaryEntityRank, ordinal_of_subcell, ordinal_of_node_on_subcell); - break; - default: - throw std::logic_error("UniformRefinerPattern logic error"); - } - - if (0) std::cout << "tmp 2.1 " << inode << " " << jNode - << " usePerm = " << usePerm - << " childNodeIdx= " << childNodeIdx - << " rank_of_subcell= " << rank_of_subcell - << " ordinal_of_subcell = " << ordinal_of_subcell - << " ordinal_of_node_on_subcell = " << ordinal_of_node_on_subcell - << " num_nodes_on_subcell = " << num_nodes_on_subcell - << std::endl; - EN[jNode] = inode; - } - } - - - for (unsigned iChild = 0; iChild < num_child; iChild++) - { - int iChildRefTopo = iChild + iChildStart; - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (m_primaryEntityRank == m_eMesh.element_rank() && proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - for (int inode=0; inode < ToTopology::node_count; inode++) - { - stk_classic::mesh::EntityId eid = elems[iChild][inode]; - if (!eid) - { - std::cout << "P[" << eMesh.get_rank() << "] eid = 0 for inode = " << inode << " iChild = " << iChild << std::endl; - std::cout << "elems[iChild] = " ; - for (int in=0; in < ToTopology::node_count; in++) - { - std::cout << "in= " << in << " elems[iChild][in]= " << elems[iChild][in] << std::endl; - } - throw std::logic_error("UniformRefinerPatternBase::genericRefine_createNewElements bad entity id = 0 "); - } - - /**/ TRACE_CPU_TIME_AND_MEM_0(CONNECT_LOCAL_URP_createOrGetNode); - stk_classic::mesh::Entity& node = createOrGetNode(nodeRegistry, eMesh, eid); - /**/ TRACE_CPU_TIME_AND_MEM_1(CONNECT_LOCAL_URP_createOrGetNode); - - /**/ TRACE_CPU_TIME_AND_MEM_0(CONNECT_LOCAL_URP_declare_relation); - eMesh.get_bulk_data()->declare_relation(newElement, node, inode); - //register_relation(newElement, node, inode); - /**/ TRACE_CPU_TIME_AND_MEM_1(CONNECT_LOCAL_URP_declare_relation); - } - - if (!isLinearElement) - { - interpolateFields(eMesh, element, newElement, ref_topo.child_node(iChildRefTopo), &ref_topo_x[0], eMesh.get_coordinates_field() ); - interpolateFields(eMesh, element, newElement, ref_topo.child_node(iChildRefTopo), &ref_topo_x[0]); - //std::cout << "tmp found !isLinearElement... " << std::endl; - //exit(1); - } - - set_parent_child_relations(eMesh, element, newElement, iChildRefTopo); - - interpolateElementFields(eMesh, element, newElement); - - element_pool++; - } - } - - /// utility methods for converting Sierra tables to new format (which groups DOF's on sub-entities) - static bool on_parent_vertex(unsigned childNodeIdx) - { - return (childNodeIdx < FromTopology::vertex_count); - } - - static bool on_parent_edge(unsigned childNodeIdx, const Elem::RefinementTopology& ref_topo) - { - unsigned num_child_nodes = ref_topo.num_child_nodes(); - - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - unsigned n_edges = cell_topo.getEdgeCount(); - - for (unsigned i_edge = 0; i_edge < n_edges; i_edge++) - { - const UInt *edge_nodes = ref_topo.edge_node(i_edge); - - unsigned i_ord = 0; - for (unsigned i_edge_n = 0; edge_nodes[i_edge_n] != END_UINT_ARRAY; i_edge_n++) - { - unsigned j_e_node = edge_nodes[i_edge_n]; - if (childNodeIdx == j_e_node) - { - return true; - } - if (j_e_node < num_child_nodes) - ++i_ord; - } - } - return false; - } - - - static bool on_parent_face(unsigned childNodeIdx, const Elem::RefinementTopology& ref_topo) - { - unsigned num_child_nodes = ref_topo.num_child_nodes(); - - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - if (cell_topo.getDimension() == 2) - { - return true; // by definition - } - - unsigned n_faces = cell_topo.getFaceCount(); - if (n_faces == 0) n_faces = 1; // 2D face has one "face" - - for (unsigned i_face = 0; i_face < n_faces; i_face++) - { - const UInt *face_nodes = ref_topo.face_node(i_face); - - unsigned i_ord = 0; - for (unsigned i_face_n = 0; face_nodes[i_face_n] != END_UINT_ARRAY; i_face_n++) - { - unsigned j_e_node = face_nodes[i_face_n]; - if (childNodeIdx == j_e_node) - { - return true; - } - if (j_e_node < num_child_nodes) - ++i_ord; - } - } - return false; - } - - static bool on_parent_edge_interior(unsigned childNodeIdx, const Elem::RefinementTopology& ref_topo, unsigned& i_edge, unsigned& i_ord, unsigned& n_ord) - { - if (on_parent_vertex(childNodeIdx)) - return false; - - unsigned num_child_nodes = ref_topo.num_child_nodes(); - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - unsigned n_edges = cell_topo.getEdgeCount(); - if (n_edges == 0) n_edges = 1; - - for ( i_edge = 0; i_edge < n_edges; i_edge++) - { - const UInt *edge_nodes = ref_topo.edge_node(i_edge); - - n_ord = 0; - int n_edge_n = 0; - for (unsigned i_edge_n = 0; edge_nodes[i_edge_n] != END_UINT_ARRAY; i_edge_n++) - { - if (on_parent_vertex(edge_nodes[i_edge_n])) - continue; - if (edge_nodes[i_edge_n] < num_child_nodes) - ++n_ord; - ++n_edge_n; - } - - i_ord = 0; - for (unsigned i_edge_n = 0; edge_nodes[i_edge_n] != END_UINT_ARRAY; i_edge_n++) - // go in reverse to put mid node at the end - //for (int i_edge_n = n_edge_n-1; i_edge_n >= 0; i_edge_n--) - { - if (on_parent_vertex(edge_nodes[i_edge_n])) - continue; - unsigned j_e_node = edge_nodes[i_edge_n]; - if (childNodeIdx == j_e_node) - { - if (i_ord == 0) - i_ord = n_ord-1; - else - --i_ord; - - return true; - } - if (j_e_node < num_child_nodes) - ++i_ord; - } - } - return false; - } - - /** SPECIAL CASE ALERT (see below for triangle faces) - * - * To prepare for future truly hierarchical elements, we want to number the nodes on the interior of each face - * in a manner that mimics the parent element. For example, nodes {8, 17-20, and 21-24} below are not numbered - * consistent with the parent quadratic element. The consistent numbering would be {21-24, 17-20, 8} to correspond - * with parent's {0-8} numbering: - * - * After refinement: - * - * 3 14 6 13 2 CHILD 9-Node Quadrilateral Object Nodes - * o----*----o----*----o (new nodes = *) - * | | | - * | 24 | 23 | - * 15* * *19 * *12 - * | | | - * | 8| 18 | - * 7 o----*----o----*----o 5 - * | 20 | | - * | | | - * 16* * 17* * *11 - * | 21 | 22 | - * | | | - * o----*----o----*----o - * 0 9 4 10 1 - * - * - * After refinement: - * - * 3 14 6 13 2 CHILD 8-Node Quadrilateral Object Nodes - * o----*----o----*----o (new nodes = *) - * | | | - * | | | - * 15* *19 *12 This case is so similar to the full quadratic case we just re-use the node numbering and - * | | | go ahead and generate 9 nodes per face, which is 4 more than we need, but we drop them later. - * | 8| 18 | - * 7 o----*----o----*----o 5 - * | 20 | | - * | | | - * 16* 17* *11 - * | | | - * | | | - * o----*----o----*----o - * 0 9 4 10 1 - * - * The way this meshes with hierarchical elements is to imagine the face being - * part of a p-element with local polynomial degree 4x3 (p=4 in local-x of the face, p=3 in local-y). In that - * case, we can think of the nodes laid out in a rectangular pattern as: - * - * o---o---o - * | | | - * o---o---o - * - * or in the parent's hierarchical element (e.g. node 5 is the hiearchical edge-bubble DOF), and numbered - * in a lexicographical (x-first, then y) ordering: - * - * 3 6 2 - * o-------o-------o - * | | - * | 11 12 13 | - * | o--o--o | - * 7 o | | | o 5 - * | o--o--o | - * | 8 9 10 | - * | | - * o-------o-------o - * 0 4 1 - * - * - * Of course, this is only symbolic of the hiearchical DOF's at the center of the face, shown as Lagrange-type DOF's for - * exposition only. In reality, we denote just with a + at the center: - * - * 6 - * 3 _ 2 - * o---------------o - * | | - * | | - * | 8 | - * 7 || + || 5 - * | | - * | | - * | | - * o---------------o - * 0 - 1 - * 4 - * - * So, we renumber the nodes on the face interior as: {21-24, 17-20, 8} - this is used below to choose face DOF ordinals - * in building the tables in printRefinementTopoX_Table - * - */ - static unsigned renumber_quad_face_interior_nodes(unsigned original_node) - { - static int face_interior_inverse_map[] = { -1, /* 0 */ - -1, -2, -3, -4, -5, -6, -7, - 8, /* 8 */ - -9, -10, - -11, -12, -13, -14, -15, -16, - 4, 5, 6, 7, // -17, -18, -19, -20 - 0, 1, 2, 3 }; //-21, -22, -23, -24}; - - /* - static int face_interior_map[] = {21, 22, 23, 24, - 17, 18, 19, 20, - 8 }; - */ - if (original_node >= 25) throw std::logic_error("renumber_quad_face_interior_nodes 1"); - int val = face_interior_inverse_map[original_node]; - if (val < 0) throw std::logic_error("renumber_quad_face_interior_nodes 2"); - return (unsigned)val; - } - - // not used (yet) - static unsigned renumber_quad_face_interior_nodes_quad8(unsigned original_node) - { - // FIXME - if (1) return renumber_quad_face_interior_nodes(original_node); - - static int face_interior_inverse_map[] = { -1, /* 0 */ - -1, -2, -3, -4, -5, -6, -7, - 4, /* 8 */ - -9, -10, - -11, -12, -13, -14, -15, -16, - 0, 1, 2, 3 // -17, -18, -19, -20 - }; - - /* - static int face_interior_map[] = {21, 22, 23, 24, - 17, 18, 19, 20, - 8 }; - */ - if (original_node >= 21) throw std::logic_error("renumber_quad_face_interior_nodes_quad8 1"); - int val = face_interior_inverse_map[original_node]; - if (val < 0) throw std::logic_error("renumber_quad_face_interior_nodes_quad8 2"); - return (unsigned)val; - } - - /*--------------------------------------------------------------------*/ - /** - * 2 PARENT 6-Node Triangle Object Nodes - * o - * / \ - * / \ (PARENT) 6-Node Triangle Object Edge Node Map: - * / \ - * 5 o o 4 { {0, 1, 3}, {1, 2, 4}, {2, 0, 5} }; - * / \ - * / \ - * / \ - * o-------o-------o - * 0 3 1 - * - * After refinement: - * - * 2 CHILD 6-Node Triangle Object Nodes - * o (new nodes = *) - * / \ - * 10 * * 9 - * / 14 \ - * 5 o---*---o 4 - * / \ / \ - * 11 * 12* *13 * 8 - * / \ / \ - * o---*---o---*---o - * 0 6 3 7 1 - * - * | CHILD 6-Node Triangle Object Node Maps: - * | - * | static const UInt child_0[] = { 0, 3, 5, 6, 12, 11 }; - * | static const UInt child_1[] = { 3, 1, 4, 7, 8, 13 }; - * | static const UInt child_2[] = { 5, 4, 2, 14, 9, 10 }; - * | static const UInt child_3[] = { 4, 5, 3, 14, 12, 13 }; - * | - * - * Refined 6-Node Triangle Object PERMUTATION Node Maps: - * - * Rotation Polarity - * 0 1 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; - * 0 0 { 0, 2, 1, 5, 4, 3, 11, 10, 9, 8, 7, 6, 12, 14, 13 }; - * 1 1 { 2, 0, 1, 5, 3, 4, 10, 11, 6, 7, 8, 9, 14, 12, 13 }; - * 1 0 { 2, 1, 0, 4, 3, 5, 9, 8, 7, 6, 11, 10, 14, 13, 12 }; - * 2 1 { 1, 2, 0, 4, 5, 3, 8, 9, 10, 11, 6, 7, 13, 14, 12 }; - * 2 0 { 1, 0, 2, 3, 5, 4, 7, 6, 11, 10, 9, 8 13, 12, 14 }; - * - **/ - - static bool on_parent_face_interior(unsigned childNodeIdx, const Elem::RefinementTopology& ref_topo, unsigned& i_face, unsigned& i_ord, unsigned& n_ord) - { - if (on_parent_edge(childNodeIdx, ref_topo)) - return false; - - static bool doRenumber = true; - - unsigned num_child_nodes = ref_topo.num_child_nodes(); - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - - int topoDim = getTopoDim(cell_topo); - //unsigned cell_topo_key = fromTopoKey; - - - if (topoDim == 2) - { - i_face = 0; - n_ord = 0; - int n_face_n = 0; - for (unsigned i_face_n = 0; i_face_n < num_child_nodes; i_face_n++) - { - if (on_parent_edge(i_face_n, ref_topo)) - continue; - ++n_ord; - ++n_face_n; - } - - if (fromTopoKey == topo_key_quad8 || fromTopoKey == topo_key_shellquad8) - { - n_ord = 9; - std::cout << "n_ord = " << n_ord << " for cell_topo= " << cell_topo.getName() << std::endl; - } - - i_ord = 0; - for (unsigned i_face_n = 0; i_face_n < num_child_nodes; i_face_n++) - { - if (on_parent_edge(i_face_n, ref_topo)) - continue; - if (i_face_n == childNodeIdx) - { - if (fromTopoKey == topo_key_quad9 || fromTopoKey == topo_key_quad8 || fromTopoKey == topo_key_shellquad8) - { - if (doRenumber) - { - i_ord = renumber_quad_face_interior_nodes(i_face_n); - } - } - return true; - } - ++i_ord; - } - return false; - } // cell dim == 2 - - unsigned n_faces = cell_topo.getFaceCount(); - - for ( i_face = 0; i_face < n_faces; i_face++) - { - const UInt *face_nodes = ref_topo.face_node(i_face); - - n_ord = 0; - int n_face_n = 0; - for (unsigned i_face_n = 0; face_nodes[i_face_n] != END_UINT_ARRAY; i_face_n++) - { - if (on_parent_edge(face_nodes[i_face_n], ref_topo)) - continue; - if (face_nodes[i_face_n] < num_child_nodes) - ++n_ord; - ++n_face_n; - } - - if (1 && fromTopoKey == topo_key_hex20) - { - n_ord = 9; - } - - i_ord = 0; - unsigned fnl=0; - for (unsigned i_face_n = 0; face_nodes[i_face_n] != END_UINT_ARRAY; i_face_n++) - { - ++fnl; - } - for (unsigned i_face_n = 0; face_nodes[i_face_n] != END_UINT_ARRAY; i_face_n++) - { - if (on_parent_edge(face_nodes[i_face_n], ref_topo)) - continue; - unsigned j_e_node = face_nodes[i_face_n]; - if (childNodeIdx == j_e_node) - { - if (fromTopoKey == topo_key_hex27) - { - if (doRenumber) - { - i_ord = renumber_quad_face_interior_nodes(i_face_n); - } - } - if (fromTopoKey == topo_key_hex20) - { - if (doRenumber) - { - i_ord = renumber_quad_face_interior_nodes_quad8(i_face_n); - //std::cout << "tmp childNodeIdx= " << childNodeIdx << " i_ord= " << i_ord << " i_face_n= " << i_face_n << " fnl= " << fnl << std::endl; - } - } - - return true; - } - if (j_e_node < num_child_nodes) - ++i_ord; - } - } - - return false; - } - - static bool on_parent_volume_interior(unsigned childNodeIdx, const Elem::RefinementTopology& ref_topo, unsigned& i_volume, unsigned& i_ord, unsigned& n_ord) - { - if (on_parent_face(childNodeIdx, ref_topo)) - return false; - - unsigned num_child_nodes = ref_topo.num_child_nodes(); - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - - i_volume = 0; - - n_ord = 0; - for (unsigned i_volume_n = 0; i_volume_n < num_child_nodes; i_volume_n++) - { - if (on_parent_face(i_volume_n, ref_topo)) - continue; - - ++n_ord; - } - - i_ord = 0; - for (unsigned i_volume_n = 0; i_volume_n < num_child_nodes; i_volume_n++) - { - if (on_parent_face(i_volume_n, ref_topo)) - continue; - - if (childNodeIdx == i_volume_n) - { - return true; - } - ++i_ord; - } - - return false; - } - - - /// utility to help convert Sierra tables - this method takes the index of the child node and finds it and adds - /// the associated info to the ref_topo_x tables containing the new/additional refinement table information - static void findRefinedCellTopoInfo(unsigned childNodeIdx, - const Elem::RefinementTopology& ref_topo, - RefTopoX_arr ref_topo_x, // assumed good for the vertices - unsigned& rank_of_subcell, - unsigned& ordinal_of_subcell, - unsigned& ordinal_of_node_on_subcell, - unsigned& num_node_on_subcell) - { - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - - //bool found = false; - bool on_parent_edge = false; - bool on_parent_face = false; - bool on_parent_volume = false; - if (on_parent_vertex(childNodeIdx)) - { - rank_of_subcell = 0; - ordinal_of_subcell = childNodeIdx; - ordinal_of_node_on_subcell = 0; - num_node_on_subcell = 1; - return; - } - - - - if ( (on_parent_edge = on_parent_edge_interior(childNodeIdx, ref_topo, ordinal_of_subcell, ordinal_of_node_on_subcell, num_node_on_subcell))) - { - rank_of_subcell = 1; - // SPECIAL CASE - if (cell_topo.getKey() == base_s_beam_2_key || - cell_topo.getKey() == base_s_beam_3_key) - { - //rank_of_subcell = 3; // wrong - see UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp and ...Beam3... - rank_of_subcell = 1; // wrong - see UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp and ...Beam3... - } - return; - } - - if ( (on_parent_face = on_parent_face_interior(childNodeIdx, ref_topo, ordinal_of_subcell, ordinal_of_node_on_subcell, num_node_on_subcell))) - { - rank_of_subcell = 2; - return; - } - - // FIXME - if (cell_topo.getDimension() == 2) - { - } - - if ( (on_parent_volume = on_parent_volume_interior(childNodeIdx, ref_topo, ordinal_of_subcell, ordinal_of_node_on_subcell, num_node_on_subcell))) - { - rank_of_subcell = 3; - return; - } - throw std::logic_error("findRefinedCellTopoInfo:: hmmmm"); - } - - static void findRefinedCellParamCoords(const Elem::RefinementTopology& ref_topo, - RefTopoX_arr ref_topo_x) - { - shards::CellTopology parent_cell_topo ( shards::getCellTopologyData< FromTopology >() ); - - unsigned num_child = ref_topo.num_child(); - - for (unsigned i_child = 0; i_child < num_child; i_child++) - { - shards::CellTopology cell_topo = ref_topo.child_cell_topology(i_child); - - const unsigned *child_nodes = ref_topo.child_node(i_child); - - unsigned n_edges = cell_topo.getEdgeCount(); - if (n_edges == 0) n_edges = 1; // 1D edge has one "edge" - unsigned n_faces = cell_topo.getFaceCount(); - if (parent_cell_topo.getDimension() > 1 && n_faces == 0) n_faces = 1; // 2D face has one "face" - - for (unsigned i_edge = 0; i_edge < n_edges; i_edge++) - { - // FIXME for 2d - shards::CellTopology edge_topo = parent_cell_topo.getDimension()==1? parent_cell_topo : shards::CellTopology(cell_topo.getCellTopologyData( 1, i_edge)); - - if (edge_topo.getNodeCount() == 3) - { - unsigned i0 = 0; - unsigned i1 = 0; - unsigned i2 = 0; - - if (parent_cell_topo.getDimension() == 1) - { - i0 = child_nodes[0]; - i1 = child_nodes[1]; - i2 = child_nodes[2]; - } - else - { - i0 = child_nodes[cell_topo.getCellTopologyData()->edge[i_edge].node[0]]; - i1 = child_nodes[cell_topo.getCellTopologyData()->edge[i_edge].node[1]]; - i2 = child_nodes[cell_topo.getCellTopologyData()->edge[i_edge].node[2]]; - } - - double *param_coord = ref_topo_x[i2].parametric_coordinates; - param_coord[0] = (ref_topo_x[i0].parametric_coordinates[0]+ref_topo_x[i1].parametric_coordinates[0])/2.; - param_coord[1] = (ref_topo_x[i0].parametric_coordinates[1]+ref_topo_x[i1].parametric_coordinates[1])/2.; - param_coord[2] = (ref_topo_x[i0].parametric_coordinates[2]+ref_topo_x[i1].parametric_coordinates[2])/2.; - - if (0) - std::cout<<"param_coord in findRefinedCellParamCoords edge= " << i2 << " " - << param_coord[0] << " " - << param_coord[1] << " " - << param_coord[2] << std::endl; - } - } - - for (unsigned i_face = 0; i_face < n_faces; i_face++) - { - // FIXME for 2d - shards::CellTopology face_topo = cell_topo.getDimension()==2 ? cell_topo : shards::CellTopology(cell_topo.getCellTopologyData( 2, i_face)); - - // skip triangle faces - if (face_topo.getVertexCount() == 3) - continue; - - // NOTE: if this is a serendipity 8-node face, it has no interior node - only 9-noded quad faces have an interior node - if (face_topo.getNodeCount() == 9) - { - unsigned i0 = cell_topo.getDimension()==2 ? 8 : cell_topo.getCellTopologyData()->side[i_face].node[8]; - i0 = child_nodes[i0]; - - double *param_coord = ref_topo_x[i0].parametric_coordinates; - param_coord[0] = 0.0; - param_coord[1] = 0.0; - param_coord[2] = 0.0; - for (unsigned i_face_n=0; i_face_n < 4; i_face_n++) - { - unsigned i1 = cell_topo.getDimension()==2 ? i_face_n : cell_topo.getCellTopologyData()->side[i_face].node[i_face_n]; - i1 = child_nodes[i1]; - param_coord[0] += ref_topo_x[i1].parametric_coordinates[0]/4.; - param_coord[1] += ref_topo_x[i1].parametric_coordinates[1]/4.; - param_coord[2] += ref_topo_x[i1].parametric_coordinates[2]/4.; - } - if (0) - std::cout<<"param_coord in findRefinedCellParamCoords face= " << i0 << " " - << param_coord[0] << " " - << param_coord[1] << " " - << param_coord[2] << std::endl; - - } - } - - if (cell_topo.getDimension() == 3 && toTopoKey == topo_key_hex27) - { - unsigned i0 = child_nodes[centroid_node]; // Has to be a Hex27 to have an interior node - double *param_coord = ref_topo_x[i0].parametric_coordinates; - - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] = 0.0; - } - for (unsigned k_node = 0; k_node < 8; k_node++) - { - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] += ref_topo_x[k_node].parametric_coordinates[ix]/8.0; - } - } - if (0) - std::cout<<"param_coord in findRefinedCellParamCoords vol= " - << param_coord[0] << " " - << param_coord[1] << " " - << param_coord[2] << std::endl; - - } - } - } - - - /// continuing in the convert tables theme, this helps to find the new nodes' parametric coordinates - static void findRefinedCellParamCoordsLinear(const Elem::RefinementTopology& ref_topo, - RefTopoX_arr ref_topo_x // assumed good for the vertices - ) - { - double param_coord[3]; - shards::CellTopology cell_topo ( shards::getCellTopologyData< FromTopology >() ); - - unsigned num_child_nodes = ref_topo.num_child_nodes(); - for (unsigned childNodeIdx = 0; childNodeIdx < num_child_nodes; childNodeIdx++) - { - bool found = false; - //bool on_edge = false; - bool on_vertex = false; - if (childNodeIdx < FromTopology::vertex_count) - { - param_coord[0] = ref_topo_x[childNodeIdx].parametric_coordinates[0]; - param_coord[1] = ref_topo_x[childNodeIdx].parametric_coordinates[1]; - param_coord[2] = ref_topo_x[childNodeIdx].parametric_coordinates[2]; - found = true; - on_vertex = true; - } - - if (!on_vertex) - { - unsigned n_edges = cell_topo.getEdgeCount(); - if (n_edges == 0) n_edges = 1; // 1D face has one "edge" - unsigned n_faces = cell_topo.getFaceCount(); - if (cell_topo.getDimension() > 1 && n_faces == 0) n_faces = 1; // 2D face has one "face" - //unsigned n_sides = cell_topo.getSideCount(); - - // check for shell line elements - int topoDim = getTopoDim(cell_topo); - if (topoDim == 1) n_faces = 0; - - for (unsigned i_edge = 0; i_edge < n_edges; i_edge++) - { - const UInt *edge_nodes = ref_topo.edge_node(i_edge); - - if (childNodeIdx == edge_nodes[2]) // FIXME - { - //on_edge = true; - found = true; - param_coord[0] = (ref_topo_x[edge_nodes[0]].parametric_coordinates[0]+ref_topo_x[edge_nodes[1]].parametric_coordinates[0])/2.; - param_coord[1] = (ref_topo_x[edge_nodes[0]].parametric_coordinates[1]+ref_topo_x[edge_nodes[1]].parametric_coordinates[1])/2.; - param_coord[2] = (ref_topo_x[edge_nodes[0]].parametric_coordinates[2]+ref_topo_x[edge_nodes[1]].parametric_coordinates[2])/2.; - break; - } - } - - if (!found) - { - for (unsigned i_face = 0; i_face < n_faces; i_face++) - { - - // FIXME for 2d - shards::CellTopology face_topo = cell_topo.getDimension()==2 ? cell_topo : shards::CellTopology(cell_topo.getCellTopologyData( 2, i_face)); - - // skip triangle faces - if (face_topo.getVertexCount() == 3) - continue; - - const UInt *face_nodes = ref_topo.face_node(i_face); - - unsigned j_node_end = 0; -#if 0 - bool lfnd = false; - for (unsigned j_node = 0; j_node < 9; j_node++) - { - if (face_nodes[j_node] == END_UINT_ARRAY) - { - lfnd = true; - j_node_end = j_node; - break; - } - } - if (!lfnd) - { - throw std::logic_error("findRefinedCellParamCoordsLinear logic err # 0"); - } -#endif - j_node_end = 9; //!# - - for (unsigned j_node = 0; j_node < j_node_end; j_node++) // FIXME - { - if (cell_topo.getDimension() != 2 && face_nodes[j_node] == END_UINT_ARRAY) - { - throw std::logic_error("findRefinedCellParamCoordsLinear logic err # 1"); - } - unsigned fn = cell_topo.getDimension()==2 ? j_node : face_nodes[j_node]; - - if (childNodeIdx == fn) - { - found = true; - - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] = 0.0; - } - - for (unsigned k_node = 0; k_node < 4; k_node++) - { - if (cell_topo.getDimension() != 2 && face_nodes[k_node] == END_UINT_ARRAY) - { - throw std::logic_error("findRefinedCellParamCoordsLinear logic err # 2"); - } - unsigned fnk = cell_topo.getDimension()==2 ? k_node : face_nodes[k_node]; - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] += ref_topo_x[fnk].parametric_coordinates[ix]/4.0; - } - } - - break; - } - } - } - } - } - - if (!found) - { - found = true; - - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] = 0.0; - } - unsigned nvert = FromTopology::vertex_count; - double dnvert = (double)nvert; - for (unsigned k_node = 0; k_node < nvert; k_node++) - { - for (unsigned ix=0; ix < 3; ix++) - { - param_coord[ix] += ref_topo_x[k_node].parametric_coordinates[ix]/dnvert; - } - } - } - - for (unsigned ix=0; ix < 3; ix++) - { - ref_topo_x[childNodeIdx].parametric_coordinates[ix] = param_coord[ix]; - } - if (0) - std::cout<<"tmp param_coord in findRefinedCellParamCoordsLinear= " << childNodeIdx << " " - << param_coord[0] << " " - << param_coord[1] << " " - << param_coord[2] << std::endl; - } - - } - - public: - - /// this is called one time (during code development) to generate and print a table of the extra refinement info - -#define DEBUG_PRINT_REF_TOPO_X 0 - static void - printRefinementTopoX_Table(std::ostream& out = std::cout ) - { - const CellTopologyData * const cell_topo_data = shards::getCellTopologyData< ToTopology >(); - - shards::CellTopology cell_topo(cell_topo_data); - - if (DEBUG_PRINT_REF_TOPO_X) - { - std::cout << "toTopoKey: " << toTopoKey << " topo_key_quad8 = " << topo_key_quad8 << " cell_topo= " << cell_topo.getName() << std::endl; - std::cout << "toTopoKey: " << toTopoKey << " topo_key_shellquad8 = " << topo_key_shellquad8 << " cell_topo= " << cell_topo.getName() << std::endl; - } - - unsigned n_edges = cell_topo_data->edge_count; - unsigned n_faces = cell_topo.getFaceCount(); - if (n_faces == 0) n_faces = 1; // 2D face has one "face" - unsigned n_sides = cell_topo.getSideCount(); - if (DEBUG_PRINT_REF_TOPO_X) std::cout << "tmp n_edges= " << n_edges << " n_faces= " << n_faces << " n_sides= " << n_sides << std::endl; - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); - if (!ref_topo_p) - throw std::runtime_error("printRefinementTopoX_Table:: error, no refinement topology found"); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - - unsigned num_child = ref_topo.num_child(); - unsigned num_child_nodes = ref_topo.num_child_nodes(); - - if (DEBUG_PRINT_REF_TOPO_X) std::cout << "tmp num_child_nodes= " << num_child_nodes << " num_child= " << num_child << std::endl; - - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - - RefTopoX_arr ref_topo_x = new Elem::StdMeshObjTopologies::RefinementTopologyExtraEntry[num_child_nodes]; - - std::string ct_name = cell_topo.getName(); - Util::replace(ct_name, "_", "<"); - - bool useIntrepid = true; - if (useIntrepid) - { - for (unsigned iNode = 0; iNode < FromTopology::node_count; iNode++) - { - const double * param_coord = Intrepid::CellTools::getReferenceNode(cell_topo, iNode); - ref_topo_x[iNode].parametric_coordinates[0] = param_coord[0]; - ref_topo_x[iNode].parametric_coordinates[1] = param_coord[1]; - ref_topo_x[iNode].parametric_coordinates[2] = param_coord[2]; - if (0) std::cout<<"tmp param_coord= " - << param_coord[0] << " " - << param_coord[1] << " " - << param_coord[2] << std::endl; - } - } - - findRefinedCellParamCoordsLinear(ref_topo, ref_topo_x); - findRefinedCellParamCoords(ref_topo, ref_topo_x); - - out << "\n template<> RefTopoX RefinementTopologyExtra< shards:: " << ct_name << "> > :: refinement_topology = {" << std::endl; - for (unsigned childNodeIdx = 0; childNodeIdx < num_child_nodes; childNodeIdx++) - { - //* {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - - unsigned rank_of_subcell = 0; - unsigned ordinal_of_subcell = 0; - unsigned ordinal_of_node_on_subcell = 0; - unsigned num_node_on_subcell = 0; - - findRefinedCellTopoInfo(childNodeIdx, ref_topo, &ref_topo_x[0], rank_of_subcell, - ordinal_of_subcell, ordinal_of_node_on_subcell, num_node_on_subcell); - - double *param_coord = ref_topo_x[childNodeIdx].parametric_coordinates; - out << "{\t" << childNodeIdx << ",\t" << rank_of_subcell << ",\t" << ordinal_of_subcell << ",\t" - << ordinal_of_node_on_subcell << ",\t" << num_node_on_subcell - << ",\t{" << param_coord[0] << ",\t" << param_coord[1] << ",\t" << param_coord[2] << "} }" - << (childNodeIdx==(num_child_nodes-1)? " " : ",") << std::endl; - } - out << "\n};" << std::endl; - delete[] ref_topo_x; - } - - private: - - void fixSubsets(percept::PerceptMesh& eMesh, bool sameTopology) - { - if (sameTopology) - return; - - for (unsigned i_fromPart = 0; i_fromPart < m_fromParts.size(); i_fromPart++) - { - stk_classic::mesh::Part& fromPart = *m_fromParts[i_fromPart]; - - stk_classic::mesh::EntityRank switch_fromPart_primary_entity_rank = fromPart.primary_entity_rank(); - - //case - if(switch_fromPart_primary_entity_rank == eMesh.edge_rank() || - switch_fromPart_primary_entity_rank == eMesh.face_rank() ) - { - stk_classic::mesh::Part& toPart = *m_toParts[i_fromPart]; - - const stk_classic::mesh::PartVector from_subsets = fromPart.subsets(); - for (unsigned i_from_subset = 0; i_from_subset < from_subsets.size(); i_from_subset++) - { - stk_classic::mesh::Part& from_subset = *from_subsets[i_from_subset]; - const CellTopologyData * from_subset_part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(from_subset); - const CellTopologyData * to_subset_part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(toPart); - if (!from_subset_part_cell_topo_data || !to_subset_part_cell_topo_data) - continue; - std::string to_subset_name = from_subset.name() + "#" + to_subset_part_cell_topo_data->name + "#" + getAppendConvertString(); - - stk_classic::mesh::Part* to_subset_p = eMesh.get_fem_meta_data()->get_part(to_subset_name); - VERIFY_OP_ON(to_subset_p, !=, 0, std::string("fixSubsets couldn't find part error, part= ")+to_subset_name); - stk_classic::mesh::Part& to_subset = *to_subset_p; - - eMesh.get_fem_meta_data()->declare_part_subset(toPart, to_subset); - - //std::cout << "fixSubsets:: declare_part_subset toPart = " << toPart.name() << " to_subset= " << to_subset.name() << std::endl; - } - } - } - } - - public: - virtual ~URP() {} - - - const CellTopologyData * get_effective_topo(mesh::Part& part) - { - const CellTopologyData * part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(part); - - // check subsets - if (!part_cell_topo_data) - { - const stk_classic::mesh::PartVector subsets = part.subsets(); - for (unsigned i_subset = 0; i_subset < subsets.size(); i_subset++) - { - stk_classic::mesh::Part& subset = *subsets[i_subset]; - part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(subset); - if (part_cell_topo_data) - return part_cell_topo_data; - } - } - return part_cell_topo_data; - } - -#define DEBUG_SET_NEEDED_PARTS 0 - - void setNeededParts(percept::PerceptMesh& eMesh, BlockNamesType block_names_ranks, - bool sameTopology=true) - { - EXCEPTWATCH; - - // a part to hold new nodes - if (1) // FIXME - this is causing an exception in parallel runs, why? - { - stk_classic::mesh::Part* new_nodes_part = eMesh.get_non_const_part("refine_new_nodes_part"); - if (!new_nodes_part) - { - stk_classic::mesh::Part& part = eMesh.get_fem_meta_data()->declare_part("refine_new_nodes_part", mesh::fem::FEMMetaData::NODE_RANK); - mesh::MetaData & meta = mesh::MetaData::get(part); - meta.declare_attribute_no_delete(part, &stk_adapt_auto_part); - } - } - - // a part to hold active elements (i.e. leaf elements), and parent (non-active) elements - if (1) - { - stk_classic::mesh::Part* active_elements_part = eMesh.get_non_const_part("refine_active_elements_part"); - if (!active_elements_part) - { - stk_classic::mesh::Part& part = eMesh.get_fem_meta_data()->declare_part("refine_active_elements_part", eMesh.element_rank()); - mesh::MetaData & meta = mesh::MetaData::get(part); - meta.declare_attribute_no_delete(part, &stk_adapt_auto_part); - } - stk_classic::mesh::Part* inactive_elements_part = eMesh.get_non_const_part("refine_inactive_elements_part"); - if (!inactive_elements_part) - { - stk_classic::mesh::Part& part = eMesh.get_fem_meta_data()->declare_part("refine_inactive_elements_part", eMesh.element_rank()); - mesh::MetaData & meta = mesh::MetaData::get(part); - meta.declare_attribute_no_delete(part, &stk_adapt_auto_part); - } - } - - if (block_names_ranks.size() == 0) - { - block_names_ranks.resize(stk_classic::percept::EntityRankEnd); - } - - m_fromParts.resize(0); - m_toParts.resize(0); - - if (DEBUG_SET_NEEDED_PARTS) - { - stk_classic::mesh::PartVector all_parts = eMesh.get_fem_meta_data()->get_parts(); - std::cout << "\n\n====>\ntmp 0 setNeededParts: for From= " << getFromTopoPartName() << " To= " << getToTopoPartName(); - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - stk_classic::mesh::Part * part = *i_part ; - if ( stk_classic::mesh::is_auto_declared_part(*part) ) - continue; - std::cout << ", " << part->name(); - } - std::cout << std::endl; - } - - for (unsigned irank = 0; irank < stk_classic::percept::EntityRankEnd; irank++) - { - if (m_primaryEntityRank != irank) - continue; - - std::vector& block_names_include = block_names_ranks[irank]; - - stk_classic::mesh::PartVector all_parts = eMesh.get_fem_meta_data()->get_parts(); - bool found_include_only_block = false; - for (unsigned ib = 0; ib < block_names_include.size(); ib++) - { - bool foundPart = false; - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - stk_classic::mesh::Part * part = *i_part ; - - std::string bname = block_names_include[ib]; - if ('+' == bname[0]) - found_include_only_block = true; - bname = bname.substr(1, bname.length()-1); - if (part->name() == bname) - { - foundPart = true; - break; - } - } - if (!foundPart) - { - std::string msg = "UniformRefinerPattern::setNeededParts unknown block name: " + block_names_include[ib]; - throw std::runtime_error(msg.c_str()); - } - } - - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - stk_classic::mesh::Part * part = *i_part ; - - //if (part->name()[0] == '{' "{") // is_auto_declared_part, ie. UNIVERSAL universal_part - if ( stk_classic::mesh::is_auto_declared_part(*part) ) - continue; - - bool doThisPart = (block_names_ranks[m_eMesh.element_rank()].size() == 0); - - if (!doThisPart) - { - // we found one block with a "+", so this means include only the actual specified list of blocks, except for those excluded with "-" - if (found_include_only_block) - { - doThisPart = false; - for (unsigned ib = 0; ib < block_names_include.size(); ib++) - { - std::string bname = block_names_include[ib]; - if ('+' == bname[0]) - { - bname = bname.substr(1, bname.length()-1); - if (part->name() == bname) - { - doThisPart = true; - break; - } - } - } - } - else - // do them all, except for excludes - { - doThisPart = true; - } - - // check for excludes - if (doThisPart) - { - for (unsigned ib = 0; ib < block_names_include.size(); ib++) - { - std::string bname = block_names_include[ib]; - if ('-' == bname[0]) - { - bname = bname.substr(1, bname.length()-1); - if (part->name() == bname) - { - doThisPart = false; - break; - } - } - } - } - } - bool isOldElementsPart = ( (part->name()).find(UniformRefinerPatternBase::m_oldElementsPartName) != std::string::npos); - doThisPart = doThisPart && ( part->primary_entity_rank() == m_primaryEntityRank ); - doThisPart = doThisPart && !isOldElementsPart; - - bool isConvertedPart = ( (part->name()).find(getAppendConvertString()) != std::string::npos); - doThisPart = doThisPart && !isConvertedPart; - - if (!isOldElementsPart) - { - const CellTopologyData * part_cell_topo_data = get_effective_topo(*part); - - if (!part_cell_topo_data) - { - //std::cout << "cell topo is null for part = " << part->name() << std::endl; - //throw std::runtime_error("cell topo is null"); - doThisPart = false; - } - else - { - shards::CellTopology topo(part_cell_topo_data); - unsigned my_cellTopoKey = getFromTypeKey(); - doThisPart = doThisPart && (topo.getKey() == my_cellTopoKey); - - if (DEBUG_SET_NEEDED_PARTS) - std::cout << "tmp setNeededParts:: " - << "\n part name= " << part->name() - << "\n doThisPart= " << doThisPart - << "\n part->primary_entity_rank() = " << part->primary_entity_rank() - << "\n my_cellTopoKey= " << my_cellTopoKey - << "\n topo.getKey() = " << topo.getKey() - << "\n topo.getName() = " << topo.getName() - << std::endl; - } - } - - if (doThisPart) - { - stk_classic::mesh::EntityRank switch_part_primary_entity_rank = part->primary_entity_rank() ; - - if (switch_part_primary_entity_rank == eMesh.edge_rank() || - switch_part_primary_entity_rank == eMesh.element_rank() || - switch_part_primary_entity_rank == eMesh.face_rank()) - { - stk_classic::mesh::Part * block_to=0; - if (sameTopology) - { - block_to = part; - } - else - { - std::string newPartName = part->name() + "#" + getToTopoPartName() + "#" + getAppendConvertString(); - block_to = &eMesh.get_fem_meta_data()->declare_part(newPartName, part->primary_entity_rank()); - if (DEBUG_SET_NEEDED_PARTS) std::cout << "tmp setNeededParts:: declare_part name= " << newPartName - << " with topo= " << getToTopoPartName() << std::endl; - stk_classic::mesh::fem::set_cell_topology< ToTopology >( *block_to ); - stk_classic::io::put_io_part_attribute(*block_to); - } - - - if (!((part->name()).find(UniformRefinerPatternBase::getOldElementsPartName()) != std::string::npos)) - { - if (DEBUG_SET_NEEDED_PARTS) std::cout << "tmp setNeededParts:: fromPart = " << part->name() << " toPart = " << block_to->name() << std::endl; - m_fromParts.push_back(part); - m_toParts.push_back(block_to); - } - } - } - } - } - fixSubsets(eMesh, sameTopology); - - { - stk_classic::mesh::PartVector all_parts = eMesh.get_fem_meta_data()->get_parts(); - std::string oldPartName = UniformRefinerPatternBase::getOldElementsPartName() + toString(m_primaryEntityRank); - bool foundOldPart = false; - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - stk_classic::mesh::Part * part = *i_part ; - if (oldPartName == part->name()) - { - foundOldPart = true; - break; - } - } - - if (!foundOldPart) - { - if (DEBUG_SET_NEEDED_PARTS) std::cout << "tmp setNeededParts:: declare_part for oldPartName = " - << oldPartName << " rank= " << m_primaryEntityRank << std::endl; - stk_classic::mesh::Part& part = eMesh.get_fem_meta_data()->declare_part(oldPartName, m_primaryEntityRank); - mesh::MetaData & meta = mesh::MetaData::get(part); - meta.declare_attribute_no_delete(part, &stk_adapt_auto_part); - } - } - } - -#define DEBUG_CHANGE_ENTITY_PARTS 0 - - void change_entity_parts(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& old_owning_elem, stk_classic::mesh::Entity& newElement) - { - static std::vector add_parts(1); - static std::vector remove_parts; - - bool found = false; - for (unsigned i_part = 0; i_part < m_fromParts.size(); i_part++) - { - if (old_owning_elem.bucket().member(*m_fromParts[i_part])) - { - add_parts[0] = m_toParts[i_part]; - if (DEBUG_CHANGE_ENTITY_PARTS) - { - std::cout << "tmp changing newElement " << newElement.identifier() - << " rank= " << newElement.entity_rank() - << " from part= " << m_fromParts[i_part]->name() - << " to part= " << m_toParts[i_part]->name() - << " for old elem= " << old_owning_elem.identifier() - << " rank= " << old_owning_elem.entity_rank() - << std::endl; - } - eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - found = true; - } - } - if (!found) - { - std::cout << "URP::change_entity_parts couldn't find part, listing parts: " << std::endl; - std::cout << "m_fromParts= " << m_fromParts << std::endl; - for (unsigned i_part = 0; i_part < m_fromParts.size(); i_part++) - { - std::cout << "i_part = " << i_part << " m_fromParts= " << m_fromParts[i_part]->name() << std::endl; - } - //bool found_in_another_part = false; - - stk_classic::mesh::PartVector all_parts = eMesh.get_fem_meta_data()->get_parts(); - for (mesh::PartVector::iterator i_part = all_parts.begin(); i_part != all_parts.end(); ++i_part) - { - stk_classic::mesh::Part * part = *i_part ; - - if (old_owning_elem.bucket().member(*part)) - { - std::cout << "found_in_another_part part name= " << part->name() << std::endl; - //found_in_another_part = true; - } - } - - throw std::runtime_error("URP::change_entity_parts couldn't find part"); - } - } - }; - - template - class UniformRefinerPattern : public URP //, public URP1 - { - public: - }; - - // FIXME - temporary for testing only - we need a RefinerPattern with UniformRefinerPattern as a sub-class - // (i.e. rename UniformRefinerPattern to RefinerPattern, create new UniformRefinerPattern as sub-class of RefinerPattern, specialize) - template - class RefinerPattern : public URP //, public URP1 - { - public: - }; - - - } -} - - - -// all the patterns - -// homogeneous refine -#include "UniformRefinerPattern_Quad4_Quad4_4.hpp" -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" -#include "UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp" -#include "UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp" -#include "UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" -#include "UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra.hpp" -#include "UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra.hpp" -#include "UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra.hpp" -#include "UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra.hpp" - - -#include "UniformRefinerPattern_Tet4_Tet4_8_sierra.hpp" -#include "UniformRefinerPattern_Hex8_Hex8_8_sierra.hpp" -#include "UniformRefinerPattern_Wedge6_Wedge6_8_sierra.hpp" -#include "UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra.hpp" - - -#include "UniformRefinerPattern_Line3_Line3_2_sierra.hpp" -#include "UniformRefinerPattern_Beam3_Beam3_2_sierra.hpp" -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#include "UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp" -#include "UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp" -#include "UniformRefinerPattern_Hex27_Hex27_8_sierra.hpp" -#include "UniformRefinerPattern_Hex20_Hex20_8_sierra.hpp" -#include "UniformRefinerPattern_Tet10_Tet10_8_sierra.hpp" -#include "UniformRefinerPattern_Wedge15_Wedge15_8_sierra.hpp" -#include "UniformRefinerPattern_Wedge18_Wedge18_8_sierra.hpp" -#include "UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra.hpp" - -#include "URP_Heterogeneous_3D.hpp" -#include "URP_Heterogeneous_QuadraticRefine_3D.hpp" - -// enrich - -#include "UniformRefinerPattern_Line2_Line3_1_sierra.hpp" -#include "UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp" -#include "UniformRefinerPattern_Beam2_Beam3_1_sierra.hpp" - -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp" -#include "UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra.hpp" -#include "UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp" -#include "UniformRefinerPattern_Tet4_Tet10_1_sierra.hpp" -#include "UniformRefinerPattern_Hex8_Hex27_1_sierra.hpp" -#include "UniformRefinerPattern_Hex8_Hex20_1_sierra.hpp" -#include "UniformRefinerPattern_Wedge6_Wedge15_1_sierra.hpp" -#include "UniformRefinerPattern_Wedge6_Wedge18_1_sierra.hpp" -#include "UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra.hpp" - -#include "URP_Heterogeneous_Enrich_3D.hpp" - -// convert topology -#include "UniformRefinerPattern_Quad4_Tri3_6.hpp" -#include "UniformRefinerPattern_Quad4_Tri3_4.hpp" -#include "UniformRefinerPattern_Quad4_Tri3_2.hpp" -#include "UniformRefinerPattern_Hex8_Tet4_24.hpp" -#include "UniformRefinerPattern_Hex8_Tet4_6_12.hpp" - -// local refinement - for testing only right now -#include "RefinerPattern_Tri3_Tri3_2.hpp" -#include "RefinerPattern_Tri3_Tri3_N.hpp" -#include "RefinerPattern_Tet4_Tet4_N.hpp" - - -namespace stk_classic { - namespace adapt { - - // refine - typedef UniformRefinerPattern, shards::Line<2>, 2, SierraPort > Line2_Line2_2; - typedef UniformRefinerPattern, shards::Beam<2>, 2, SierraPort > Beam2_Beam2_2; - typedef UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > ShellLine2_ShellLine2_2; - typedef UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > ShellLine3_ShellLine3_2; - typedef UniformRefinerPattern, shards::Quadrilateral<4>, 4 > Quad4_Quad4_4_Old; - typedef UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > Quad4_Quad4_4; - - typedef UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > Quad4_Quad4_4_Sierra; - typedef UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > Tri3_Tri3_4; - typedef UniformRefinerPattern, shards::ShellTriangle<3>, 4, SierraPort > ShellTri3_ShellTri3_4; - typedef UniformRefinerPattern, shards::ShellTriangle<6>, 4, SierraPort > ShellTri6_ShellTri6_4; - typedef UniformRefinerPattern, shards::ShellQuadrilateral<4>, 4, SierraPort > ShellQuad4_ShellQuad4_4; - typedef UniformRefinerPattern, shards::ShellQuadrilateral<8>, 4, SierraPort > ShellQuad8_ShellQuad8_4; - - typedef UniformRefinerPattern, shards::Tetrahedron<4>, 8, SierraPort > Tet4_Tet4_8; - typedef UniformRefinerPattern, shards::Hexahedron<8>, 8, SierraPort > Hex8_Hex8_8; - typedef UniformRefinerPattern, shards::Wedge<6>, 8, SierraPort > Wedge6_Wedge6_8; - typedef UniformRefinerPattern, shards::Pyramid<5>, 10, SierraPort > Pyramid5_Pyramid5_10; - - typedef UniformRefinerPattern, shards::Line<3>, 2, SierraPort > Line3_Line3_2; - typedef UniformRefinerPattern, shards::Beam<3>, 2, SierraPort > Beam3_Beam3_2; - typedef UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > Tri6_Tri6_4; - typedef UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > Quad9_Quad9_4; - typedef UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > Quad8_Quad8_4; - typedef UniformRefinerPattern, shards::Hexahedron<27>, 8, SierraPort > Hex27_Hex27_8; - typedef UniformRefinerPattern, shards::Hexahedron<20>, 8, SierraPort > Hex20_Hex20_8; - typedef UniformRefinerPattern, shards::Tetrahedron<10>, 8, SierraPort > Tet10_Tet10_8; - typedef UniformRefinerPattern, shards::Wedge<15>, 8, SierraPort > Wedge15_Wedge15_8; - typedef UniformRefinerPattern, shards::Wedge<18>, 8, SierraPort > Wedge18_Wedge18_8; - typedef UniformRefinerPattern, shards::Pyramid<13>, 10, SierraPort > Pyramid13_Pyramid13_10; - - // enrich - typedef UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > Quad4_Quad9_1; - typedef UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > Quad4_Quad8_1; - typedef UniformRefinerPattern, shards::Beam<3>, 1, SierraPort > Beam2_Beam3_1; - - typedef UniformRefinerPattern, shards::ShellQuadrilateral<8>, 1, SierraPort > ShellQuad4_ShellQuad8_1; - typedef UniformRefinerPattern, shards::ShellQuadrilateral<9>, 1, SierraPort > ShellQuad4_ShellQuad9_1; - typedef UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > Tri3_Tri6_1; - typedef UniformRefinerPattern, shards::Tetrahedron<10>, 1, SierraPort > Tet4_Tet10_1; - typedef UniformRefinerPattern, shards::Hexahedron<27>, 1, SierraPort > Hex8_Hex27_1; - typedef UniformRefinerPattern, shards::Hexahedron<20>, 1, SierraPort > Hex8_Hex20_1; - typedef UniformRefinerPattern, shards::Wedge<15>, 1, SierraPort > Wedge6_Wedge15_1; - typedef UniformRefinerPattern, shards::Wedge<18>, 1, SierraPort > Wedge6_Wedge18_1; - typedef UniformRefinerPattern, shards::Pyramid<13>, 1, SierraPort > Pyramid5_Pyramid13_1; - - // convert - typedef UniformRefinerPattern, shards::Triangle<3>, 2 > Quad4_Tri3_2; - typedef UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > Quad4_Tri3_4; - typedef UniformRefinerPattern, shards::Triangle<3>, 6 > Quad4_Tri3_6; - typedef UniformRefinerPattern, shards::Tetrahedron<4>, 24 > Hex8_Tet4_24; - typedef UniformRefinerPattern, shards::Tetrahedron<4>, 6 > Hex8_Tet4_6_12; - - // local refinement - for testing only right now - - typedef RefinerPattern, shards::Triangle<3>, 2 > Local_Tri3_Tri3_2; - typedef RefinerPattern, shards::Triangle<3>, -1 > Local_Tri3_Tri3_N; - -//DPM adding enum for use in initializing empty UniformRefiner objects -enum Pattern - { - LINE2_LINE2_2, - BEAM2_BEAM2_2, - SHELLLINE2_SHELLLINE2_2, - SHELLLINE3_SHELLLINE3_2, - QUAD4_QUAD4_4_OLD, - QUAD4_QUAD4_4, - QUAD4_QUAD4_4_SIERRA, - TRI3_TRI3_4, - SHELLTRI3_SHELLTRI3_4, - SHELLTRI6_SHELLTRI6_4, - SHELLQUAD4_SHELLQUAD4_4, - SHELLQUAD8_SHELLQUAD8_4, - TET4_TET4_8, - HEX8_HEX8_8, - WEDGE6_WEDGE6_8, - PYRAMID5_PYRAMID5_10, - LINE3_LINE3_2, - BEAM3_BEAM3_2, - TRI6_TRI6_4, - QUAD9_QUAD9_4, - QUAD8_QUAD8_4, - HEX27_HEX27_8, - HEX20_HEX20_8, - TET10_TET10_8, - WEDGE15_WEDGE15_8, - WEDGE18_WEDGE18_8, - PYRAMID13_PYRAMID13_10, - QUAD4_QUAD9_1, - QUAD4_QUAD8_1, - BEAM2_BEAM3_1, - SHELLQUAD4_SHELLQUAD8_1, - TRI3_TRI6_1, - TET4_TET10_1, - HEX8_HEX27_1, - HEX8_HEX20_1, - WEDGE6_WEDGE15_1, - WEDGE6_WEDGE18_1, - PYRAMID5_PYRAMID13_1, - QUAD4_TRI3_2, - QUAD4_TRI3_4, - QUAD4_TRI3_6, - HEX8_TET4_24, - HEX8_TET4_6_12 - }; - typedef RefinerPattern, shards::Tetrahedron<4>, -1 > Local_Tet4_Tet4_N; - - } -} - - - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp deleted file mode 100644 index f1652d73edd2..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam2_2_sierra.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Beam2_Beam2_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Beam2_Beam2_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Beam<2>, 2, SierraPort > : public URP, shards::Beam<2> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Beam<2> >(eMesh) - { - // m_primaryEntityRank = m_eMesh.edge_rank(); - // if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam3_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam3_1_sierra.hpp deleted file mode 100644 index 35277e626b86..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam2_Beam3_1_sierra.hpp +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Beam2_Beam3_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Beam2_Beam3_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Beam<2>, shards::Beam<3>, 1, SierraPort > : public URP , shards::Beam<3> > - { - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Beam<3> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - bp[0] = this; - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.element_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::array quadratic_type; - static vector elems(1); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - nodeRegistry.addToExistingParts(*const_cast(&element), m_primaryEntityRank, 0u); - -#define CENTROID_N NN(m_primaryEntityRank,0) - - { - quadratic_type& EN = elems[0]; - - for (unsigned ind = 0; ind < 2; ind++) - { - unsigned inode = VERT_N(ind); - EN[ind] = inode; - } - - EN[2] = CENTROID_N; - } - -#undef CENTROID_N - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - // FIXME - if (0 && proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem][0]) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 " << std::endl; - exit(1); - } - - } - for (int inode=0; inode < 3; inode++) - { - stk_classic::mesh::EntityId eid = elems[ielem][inode]; - stk_classic::mesh::Entity& node = eMesh.createOrGetNode(eid); - eMesh.get_bulk_data()->declare_relation(newElement, node, inode); - } - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam3_Beam3_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam3_Beam3_2_sierra.hpp deleted file mode 100644 index fe3c3c154cdc..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Beam3_Beam3_2_sierra.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Beam3_Beam3_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Beam3_Beam3_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Beam<3>, 2, SierraPort > : public URP, shards::Beam<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Beam<3> >(eMesh) - { - // m_primaryEntityRank = m_eMesh.edge_rank(); - // if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 3u; - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex20_Hex20_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex20_Hex20_8_sierra.hpp deleted file mode 100644 index 80759abf30a9..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex20_Hex20_8_sierra.hpp +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex20_Hex20_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Hex20_Hex20_8_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define FACE_BREAKER_H20_H20 1 -#if FACE_BREAKER_H20_H20 -#include "UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Hexahedron<20>, 8, SierraPort > : public URP, shards::Hexahedron<20> > - { - - //Teuchos::RCP< UniformRefinerPattern, shards::Line<2>, 2, SierraPort > > m_face_breaker; - //UniformRefinerPatternBase * m_face_breaker; -#if FACE_BREAKER_H20_H20 - UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Hexahedron<20> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_H20_H20 - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > (eMesh, block_names); - -#endif - - } - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if FACE_BREAKER_H20_H20 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - bp[0] = this; -#if FACE_BREAKER_H20_H20 - bp[1] = m_face_breaker; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); -// needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 5u); -// needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 7u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 9u); - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 27u); - //setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - //typedef boost::array refined_element_type; - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex27_Hex27_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex27_Hex27_8_sierra.hpp deleted file mode 100644 index 59f2c2871092..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex27_Hex27_8_sierra.hpp +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex27_Hex27_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Hex27_Hex27_8_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define FACE_BREAKER_H27_H27 1 -#if FACE_BREAKER_H27_H27 -#include "UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Hexahedron<27>, 8, SierraPort > : public URP, shards::Hexahedron<27> > - { - - //Teuchos::RCP< UniformRefinerPattern, shards::Line<2>, 2, SierraPort > > m_face_breaker; - //UniformRefinerPatternBase * m_face_breaker; -#if FACE_BREAKER_H27_H27 - UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Hexahedron<27> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_H27_H27 - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > (eMesh, block_names); - -#endif - - } - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if FACE_BREAKER_H27_H27 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - bp[0] = this; -#if FACE_BREAKER_H27_H27 - bp[1] = m_face_breaker; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 9u); - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 27u); - //setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - //typedef boost::array refined_element_type; - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex20_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex20_1_sierra.hpp deleted file mode 100644 index 859106621a6e..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex20_1_sierra.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex8_Hex20_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Hex8_Hex20_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_HEX8_HEX20_1 1 -#if FACE_BREAKER_HEX8_HEX20_1 -#include "UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Hexahedron<8>, shards::Hexahedron<20>, 1, SierraPort > : public URP , shards::Hexahedron<20> > - { - -#if FACE_BREAKER_HEX8_HEX20_1 - UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > * m_subDim_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Hexahedron<20> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_HEX8_HEX20_1 - m_subDim_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - bp[0] = this; -#if FACE_BREAKER_HEX8_HEX20_1 - bp[1] = m_subDim_breaker; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex27_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex27_1_sierra.hpp deleted file mode 100644 index ee72762d543c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex27_1_sierra.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex8_Hex27_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Hex8_Hex27_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_HEX8_HEX27_1 1 -#if FACE_BREAKER_HEX8_HEX27_1 -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Hexahedron<8>, shards::Hexahedron<27>, 1, SierraPort > : public URP , shards::Hexahedron<27> > - { - -#if FACE_BREAKER_HEX8_HEX27_1 - UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > * m_subDim_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Hexahedron<27> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_HEX8_HEX27_1 - m_subDim_breaker = new UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - } - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - bp[0] = this; -#if FACE_BREAKER_HEX8_HEX27_1 - bp[1] = m_subDim_breaker; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - needed_entities[2].first = m_eMesh.element_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex8_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex8_8_sierra.hpp deleted file mode 100644 index 241a80fc7d74..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Hex8_8_sierra.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex8_Hex8_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Hex8_Hex8_8_sierra_hpp - -#include -#include - -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" - -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Hexahedron<8>, 8, SierraPort > : public URP,shards::Hexahedron<8> > - { - -#define FACE_BREAKER_H8_H8_8 1 -#if FACE_BREAKER_H8_H8_8 - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Hexahedron<8> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_H8_H8_8 - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - bp[0] = this; -#if FACE_BREAKER_H8_H8_8 - bp[1] = m_face_breaker; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - needed_entities[2].first = m_eMesh.element_rank(); - setToOne(needed_entities); - - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_24.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_24.hpp deleted file mode 100644 index 7de789f4a853..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_24.hpp +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex8_Tet4_24_hpp -#define stk_adapt_UniformRefinerPattern_Hex8_Tet4_24_hpp - -#include "UniformRefinerPattern.hpp" -#include "UniformRefinerPattern_Quad4_Tri3_4.hpp" - -namespace stk_classic { - namespace adapt { - - /** From Shards_BasicTopologies.hpp - * - * \brief Topological traits: Dimension = 3, Sides = 6, Edges = 12, - * Vertices = 8, and Nodes = 8, 20, or 27. - * - *
                                                                        
-     *   Linear 8-Node Hexahedron node locations.                                    
-     *                                                                               
-     *          7                    6                                               
-     *           o------------------o                                                
-     *          /|                 /|                                                
-     *         / |                / |                                                
-     *        /  |               /  |                                                
-     *       /   |              /   |                                                
-     *      /    |             /    |                                                
-     *     /     |            /     |                                                
-     *  4 /      |         5 /      |                                                
-     *   o------------------o       |                                                
-     *   |       |          |       |                                                
-     *   |     3 o----------|-------o 2                                              
-     *   |      /           |      /                                                 
-     *   |     /            |     /                                                  
-     *   |    /             |    /                                                   
-     *   |   /              |   /                                                    
-     *   |  /               |  /                                                     
-     *   | /                | /                                                      
-     *   |/                 |/                                                       
-     *   o------------------o                                                        
-     *  0                    1                                                       
-     *                                                                               
-     *                                                                               
-     *   face numbering for symmetric hex to tet break pattern                      |   typedef                                                                  
-     *                                                                              |     MakeTypeList< IndexList< 0 , 1 ,   8 > ,                               
-     *           7                                                                  |                   IndexList< 1 , 2 ,   9 > ,                               
-     *            o------------------o 6                                            |                   IndexList< 2 , 3 ,  10 > ,                               
-     *           /|                 /|                                              |                   IndexList< 3 , 0 ,  11 > ,                               
-     *          / |                / |                                              |                   IndexList< 4 , 5 ,  16 > ,                               
-     *         /  |   13          /  |                                              |                   IndexList< 5 , 6 ,  17 > ,                               
-     *        /   |    o         /   |                                              |                   IndexList< 6 , 7 ,  18 > ,                               
-     *       /    |       o10   /    |     Node #14 is at centroid of element       |                   IndexList< 7 , 4 ,  19 > ,                               
-     *      /     |            /     |                                              |                   IndexList< 0 , 4 ,  12 > ,                               
-     *   4 /      |         5 /      |     "2D surface" containing nodes            |                   IndexList< 1 , 5 ,  13 > ,                               
-     *    o------------------o    9  |      0,1,5,4 has node 25 at center....       |                   IndexList< 2 , 6 ,  14 > ,                               
-     *    | 11o   | 3        |   o   |                                              |                   IndexList< 3 , 7 ,  15 > >::type                         
-     *    |       o----------|-------o 2                                            |     HexahedronEdgeNodeMap ;                                                
-     *    |      /           |      /                                               |                                                                            
-     *    |     /   8        |     /                                                |   typedef                                                                  
-     *    |    /    o        |    /                                                 |     MakeTypeList< IndexList< 0, 1, 5, 4,   8, 13, 16, 12,   25 > ,         
-     *    |   /        o12   |   /                                                  |                   IndexList< 1, 2, 6, 5,   9, 14, 17, 13,   24 > ,         
-     *    |  /               |  /                                                   |                   IndexList< 2, 3, 7, 6,  10, 15, 18, 14,   26 > ,         
-     *    | /                | /                                                    |                   IndexList< 0, 4, 7, 3,  12, 19, 15, 11,   23 > ,         
-     *    |/                 |/                                                     |                   IndexList< 0, 3, 2, 1,  11, 10,  9,  8,   21 > ,         
-     *    o------------------o                                                      |                   IndexList< 4, 5, 6, 7,  16, 17, 18, 19,   22 > >::type   
-     *   0                    1                                                     |     HexahedronFaceNodeMap ;                                                
-     *                                                                              |
-     * 
| - * - * - */ - - - template <> - class UniformRefinerPattern, shards::Tetrahedron<4>, 24 > : public URP, shards::Tetrahedron<4> > - { - private: - UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > *m_face_breaker; - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<4> >(eMesh) - { - EXCEPTWATCH; - - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - -#define USE_FACE_BREAKER 1 -#if USE_FACE_BREAKER - m_face_breaker = new UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > (eMesh, block_names); -#endif - } - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - - virtual void doBreak() {} - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.face_rank(); - needed_entities[1].first = m_eMesh.element_rank(); - setToOne(needed_entities); - - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - bp[0] = this; - -#if USE_FACE_BREAKER - bp.push_back( m_face_breaker); -#endif - } - - virtual unsigned getNumNewElemPerElem() { return 24u; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - EXCEPTWATCH; - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tet_tuple_type; - static vector elems(24); - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - - // FIXME - maybe the computation of node coorinates should go in the calling code? - double tmp_x[3]; - for (unsigned i_face = 0; i_face < 6; i_face++) - { - double * pts[4] = {FACE_COORD(i_face, 0), FACE_COORD(i_face, 1), FACE_COORD(i_face, 2), FACE_COORD(i_face, 3)}; - - double * mp = getCentroid(pts, 4, eMesh.get_spatial_dim(), tmp_x); - -#if 0 - std::cout << "pts = \n" - - << pts[0][0] << " " << pts[0][1] << " " << pts[0][2] << " \n" - << pts[1][0] << " " << pts[1][1] << " " << pts[1][2] << " \n" - << pts[2][0] << " " << pts[2][1] << " " << pts[2][2] << " \n" - << pts[3][0] << " " << pts[3][1] << " " << pts[3][2] << " \n" - << " centroid = " - << mp[0] << " " << mp[1] << " " << mp[2] << std::endl; -#endif - - //stk_classic::mesh::Entity& new_node =eMesh.createOrGetNode(FACE_N(i_face), mp); - - eMesh.createOrGetNode(FACE_N(i_face), mp); - nodeRegistry.addToExistingParts(*const_cast(&element), m_eMesh.face_rank(), i_face); - nodeRegistry.interpolateFields(*const_cast(&element), m_eMesh.face_rank(), i_face); - - } - - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_eMesh.element_rank(), 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), m_eMesh.element_rank(), 0u); - nodeRegistry.interpolateFields(*const_cast(&element), m_eMesh.element_rank(), 0u); - - - //#define C 14 - -// new_sub_entity_nodes[i][j] -#define CENTROID_N NN(m_eMesh.element_rank(), 0) - - unsigned iele = 0; - for (unsigned i_face = 0; i_face < 6; i_face++) - { - for (unsigned i_tri_on_face = 0; i_tri_on_face < 4; i_tri_on_face++) - { - unsigned itf = cell_topo_data->side[i_face].node[ i_tri_on_face ]; - unsigned itfp = cell_topo_data->side[i_face].node[ (i_tri_on_face + 1) % 4]; - if ( itf > 7) - { - throw std::logic_error("UniformRefinerPattern_Hex8_Tet4_20 logic err"); - } - - elems[iele++] = tet_tuple_type(CENTROID_N, VERT_N(itf), VERT_N(itfp), FACE_N(i_face)); - } - } - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(1); - } - } - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<3>()), 3); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_6_12.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_6_12.hpp deleted file mode 100644 index 80a252ed7e8b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Hex8_Tet4_6_12.hpp +++ /dev/null @@ -1,379 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Hex8_Tet4_6_12_hpp -#define stk_adapt_UniformRefinerPattern_Hex8_Tet4_6_12_hpp - -#include "UniformRefinerPattern.hpp" -#include "UniformRefinerPattern_Quad4_Tri3_2.hpp" - -namespace stk_classic { - namespace adapt { - - /** From Shards_BasicTopologies.hpp - * - * \brief Topological traits: Dimension = 3, Sides = 6, Edges = 12, - * Vertices = 8, and Nodes = 8, 20, or 27. - * - *
                                                                        
-     *   Linear 8-Node Hexahedron node locations.                                    
-     *                                                                               
-     *          7                    6                                               
-     *           o------------------o                                                
-     *          /|                 /|                                                
-     *         / |                / |                                                
-     *        /  |               /  |                                                
-     *       /   |              /   |                                                
-     *      /    |             /    |                                                
-     *     /     |            /     |                                                
-     *  4 /      |         5 /      |                                                
-     *   o------------------o       |                                                
-     *   |       |          |       |                                                
-     *   |     3 o----------|-------o 2                                              
-     *   |      /           |      /                                                 
-     *   |     /            |     /                                                  
-     *   |    /             |    /                                                   
-     *   |   /              |   /                                                    
-     *   |  /               |  /                                                     
-     *   | /                | /                                                      
-     *   |/                 |/                                                       
-     *   o------------------o                                                        
-     *  0                    1                                                       
-     *                                                                               
-     *                                                                               
-     *   face numbering for symmetric hex to tet break pattern                      |   typedef                                                                  
-     *                                                                              |     MakeTypeList< IndexList< 0 , 1 ,   8 > ,                               
-     *           7                                                                  |                   IndexList< 1 , 2 ,   9 > ,                               
-     *            o------------------o 6                                            |                   IndexList< 2 , 3 ,  10 > ,                               
-     *           /|                 /|                                              |                   IndexList< 3 , 0 ,  11 > ,                               
-     *          / |                / |                                              |                   IndexList< 4 , 5 ,  16 > ,                               
-     *         /  |   13          /  |                                              |                   IndexList< 5 , 6 ,  17 > ,                               
-     *        /   |    o         /   |                                              |                   IndexList< 6 , 7 ,  18 > ,                               
-     *       /    |       o10   /    |     Node #14 is at centroid of element       |                   IndexList< 7 , 4 ,  19 > ,                               
-     *      /     |            /     |                                              |                   IndexList< 0 , 4 ,  12 > ,                               
-     *   4 /      |         5 /      |     "2D surface" containing nodes            |                   IndexList< 1 , 5 ,  13 > ,                               
-     *    o------------------o    9  |      0,1,5,4 has node 25 at center....       |                   IndexList< 2 , 6 ,  14 > ,                               
-     *    | 11o   | 3        |   o   |                                              |                   IndexList< 3 , 7 ,  15 > >::type                         
-     *    |       o----------|-------o 2                                            |     HexahedronEdgeNodeMap ;                                                
-     *    |      /           |      /                                               |                                                                            
-     *    |     /   8        |     /                                                |   typedef                                                                  
-     *    |    /    o        |    /                                                 |     MakeTypeList< IndexList< 0, 1, 5, 4,   8, 13, 16, 12,   25 > ,         
-     *    |   /        o12   |   /                                                  |                   IndexList< 1, 2, 6, 5,   9, 14, 17, 13,   24 > ,         
-     *    |  /               |  /                                                   |                   IndexList< 2, 3, 7, 6,  10, 15, 18, 14,   26 > ,         
-     *    | /                | /                                                    |                   IndexList< 0, 4, 7, 3,  12, 19, 15, 11,   23 > ,         
-     *    |/                 |/                                                     |                   IndexList< 0, 3, 2, 1,  11, 10,  9,  8,   21 > ,         
-     *    o------------------o                                                      |                   IndexList< 4, 5, 6, 7,  16, 17, 18, 19,   22 > >::type   
-     *   0                    1                                                     |     HexahedronFaceNodeMap ;                                                
-     *                                                                              |
-     * 
| - * - * - */ - - - template <> - class UniformRefinerPattern, shards::Tetrahedron<4>, 6 > : public URP, shards::Tetrahedron<4> > - { - private: -#define USE_FACE_BREAKER_H8_T4_6 1 -#if USE_FACE_BREAKER_H8_T4_6 - UniformRefinerPattern, shards::Triangle<3>, 2 > *m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<4> >(eMesh) - { - EXCEPTWATCH; - - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - -#if USE_FACE_BREAKER_H8_T4_6 - m_face_breaker = new UniformRefinerPattern, shards::Triangle<3>, 2 > (eMesh, block_names); -#endif - } - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - - virtual void doBreak() {} - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.element_rank(); - setToOne(needed_entities); - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - bp[0] = this; - -#if USE_FACE_BREAKER_H8_T4_6 - if (1) - { - // UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > *face_breaker = - // new UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > (eMesh); - bp[1] = m_face_breaker; - } -#endif - } - - /// NOTE: we create additional un-used elements if the Hex8 can be broken into 6 tets - virtual unsigned getNumNewElemPerElem() { return 12u; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - EXCEPTWATCH; - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tet_tuple_type; - vector new_elements(6); - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - // for cases that have a single center node, we just compute the new node's quantities here instead of globally - //stk_classic::mesh::Entity * node = get_bulk_data()->get_entity( Node, node_id ); - -#define CENTROID_N NN(m_eMesh.element_rank(), 0) - -#if STK_ADAPT_URP_LOCAL_NODE_COMPS - nodeRegistry.makeCentroidCoords(*const_cast(&element), Element, 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), Element, 0u); - nodeRegistry.interpolateFields(*const_cast(&element), Element, 0u); -#endif - - // following code is from SweepMesher::breakElement, modified here for stk_mesh - // from here------------------------------------------->>>>>> - { - static unsigned loc_trifaces[6][2][3]; // iQuadFace, kTriOnQuadFace, jTriNodeIndex - static unsigned loc_qfaces[6][4]; // iHexFaceOrd, iFaceNodeOrd - - static unsigned element_globalIds[8] = {0,0,0,0, 0,0,0,0}; - //static std::vector element_globalIds(8); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - //std::cout << "tmp hex elem= " << element << std::endl; - for (int inode=0; inode < 8; inode++) - { - stk_classic::mesh::Entity & node = * elem_nodes[inode].entity(); - element_globalIds[inode] = node.identifier(); - } - - // build quad face break patterns - use simple min node index as first node - const CellTopologyData *hex_topo = shards::getCellTopologyData >(); - - // node valences - unsigned valences[8]={0,0,0,0,0,0,0,0}; - for (unsigned iHexFaceOrd = 0; iHexFaceOrd < 6; iHexFaceOrd++) - { - const CellTopologyData_Subcell& face = hex_topo->side[iHexFaceOrd]; - unsigned iqf = face.node[0]; - unsigned globalIqf = element_globalIds[iqf]; - unsigned minVal = globalIqf; - unsigned indxMinVal = 0; - for (unsigned iFaceNodeOrd=1; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - iqf = face.node[iFaceNodeOrd]; - globalIqf = element_globalIds[iqf]; - if (globalIqf < minVal) - { - minVal = globalIqf; - indxMinVal = iFaceNodeOrd; - } - } - // permute to make min node index come first - for (unsigned iFaceNodeOrd=0; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - unsigned jFaceNodeOrd = (iFaceNodeOrd + indxMinVal) % 4; - //qfaces[iHexFaceOrd][iFaceNodeOrd] = element_globalIds[face.node[jFaceNodeOrd]]; - loc_qfaces[iHexFaceOrd][iFaceNodeOrd] = face.node[jFaceNodeOrd]; - } - if (0) - std::cout << "tmp hex face[" << iHexFaceOrd << "] = " - << element_globalIds[loc_qfaces[iHexFaceOrd][0]] << " " - << element_globalIds[loc_qfaces[iHexFaceOrd][1]] << " " - << element_globalIds[loc_qfaces[iHexFaceOrd][2]] << " " - << element_globalIds[loc_qfaces[iHexFaceOrd][3]] << std::endl; - - // each quad face is now broken into tri faces as {0,1,2}, {0,2,3} - loc_trifaces[iHexFaceOrd][0][0] = loc_qfaces[iHexFaceOrd][0]; - loc_trifaces[iHexFaceOrd][0][1] = loc_qfaces[iHexFaceOrd][1]; - loc_trifaces[iHexFaceOrd][0][2] = loc_qfaces[iHexFaceOrd][2]; - loc_trifaces[iHexFaceOrd][1][0] = loc_qfaces[iHexFaceOrd][0]; - loc_trifaces[iHexFaceOrd][1][1] = loc_qfaces[iHexFaceOrd][2]; - loc_trifaces[iHexFaceOrd][1][2] = loc_qfaces[iHexFaceOrd][3]; - - valences[loc_trifaces[iHexFaceOrd][0][0]]++; - valences[loc_trifaces[iHexFaceOrd][0][1]]++; - valences[loc_trifaces[iHexFaceOrd][0][2]]++; - valences[loc_trifaces[iHexFaceOrd][1][0]]++; - valences[loc_trifaces[iHexFaceOrd][1][1]]++; - valences[loc_trifaces[iHexFaceOrd][1][2]]++; - } - - // find max valence - unsigned vmaxIndx = 0; - unsigned vmax = valences[0]; - for (unsigned iv = 1; iv < 8; iv++) - { - if (valences[iv] > vmax) - { - vmax = valences[iv]; - vmaxIndx = iv; - } - } - - if (vmax != 6) - { - /// Rare case - create tets by joining centroid to each face - for now, just throw an exception to see how often this - /// case occurs - FIXME - take this exception out later - if (1) - { - std::ostringstream msg; - msg << "shouldn't ever get this exception - please inform srkenno@sandia.gov\n"; - throw std::runtime_error( msg.str() ); - } - new_elements.resize(12); - - // boost::array centroid = {{0,0,0}}; - // for (unsigned iv = 0; iv < 8; iv++) - // { - // centroid[0] += m_node_coords[element_globalIds[iv]][0]/8.0; - // centroid[1] += m_node_coords[element_globalIds[iv]][1]/8.0; - // centroid[2] += m_node_coords[element_globalIds[iv]][2]/8.0; - // } - // m_node_coords.push_back(centroid); - - // unsigned newNodeIndex = m_node_coords.size() - 1; - - int iele=0; - for (unsigned iQuadFace = 0; iQuadFace < 6; iQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - // m_elems[shards_Tetrahedron_4].push_back(newNodeIndex); - // for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - // { - // m_elems[shards_Tetrahedron_4].push_back(element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - // } - - new_elements[iele++] = tet_tuple_type(CENTROID_N, - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][0]], - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][1]], - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][2]]); - - } - } - } - else - { - /// normal case - connect max valence node to other faces without that node (should be 6 tets always) - /// Note: there is a 5-tet configuration that exists for some face diagonal configurations - FIXME - could add this case later - /// The 5-tet case consists of an interior tet with no boundary faces, and 4 corner tets; the boundary faces have - /// to each have alternating diagonals along the 3 axis directions for this configuration to exist - unsigned count=0; - for (unsigned iQuadFace = 0; iQuadFace < 6; iQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - bool isEqual = false; - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - if (vmaxIndx == loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]) - { - isEqual = true; - break; - } - } - if (not isEqual) - { - // m_elems[shards_Tetrahedron_4].push_back(element_globalIds[vmaxIndx]); - // for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - // { - // m_elems[shards_Tetrahedron_4].push_back(element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - // } - new_elements[count] = tet_tuple_type(element_globalIds[vmaxIndx], - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][0]], - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][1]], - element_globalIds[loc_trifaces[iQuadFace][kTriOnQuadFace][2]]); - - ++count; - - } - } - } - assert(count == 6); - - } - } - // to here <<<<<< ----------------------- - - for (unsigned ielem=0; ielem < new_elements.size(); ielem++) - { - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - unsigned nchild = new_elements.size(); - - { - if (!new_elements[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(123); - } - } - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(new_elements[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(new_elements[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(new_elements[ielem].get<2>()), 2); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(new_elements[ielem].get<3>()), 3); - - set_parent_child_relations(eMesh, element, newElement, ielem, &nchild); - - element_pool++; - } - - if (1 && new_elements.size() == 6) - { - for (unsigned ielem=0; ielem < 6; ielem++) - { - // destroy un-needed elems - // elems_to_destroy.push_back(*element_pool); ++element_pool; - eMesh.get_bulk_data()->destroy_entity(*element_pool); - ++element_pool; - } - //nodes_to_destroy.push_back(CENTROID_N) - stk_classic::mesh::Entity * node = eMesh.get_bulk_data()->get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, CENTROID_N); - if (!node) - { - throw std::logic_error("UniformRefinerPattern_Hex8_Tet4_6_12:: node is null"); - } - else - { - eMesh.get_bulk_data()->destroy_entity(node); - } - } - } - - }; -#undef CENTROID_N - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line2_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line2_2_sierra.hpp deleted file mode 100644 index 01d9076484dc..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line2_2_sierra.hpp +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Line2_Line2_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Line2_Line2_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Line<2>, 2, SierraPort > : public URP, shards::Line<2> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Line<2> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple line_tuple_type; - static vector elems(2); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - - double coord_x[3]; - for (int iedge = 0; iedge < 1; iedge++) - { - //double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - //double * mp = midPoint(FACE_COORD(iedge,0), FACE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - double * mp = midPoint(VERT_COORD(0), VERT_COORD(1), eMesh.get_spatial_dim(), coord_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 " << std::endl; - } - - eMesh.createOrGetNode(EDGE_N(iedge), mp); - } - - // FIXME - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_primaryEntityRank, 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), m_primaryEntityRank, 0u); - - nodeRegistry.interpolateFields(*const_cast(&element), m_primaryEntityRank, 0u); - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - -#ifndef NDEBUG - unsigned num_child = ref_topo.num_child(); - VERIFY_OP(num_child, == , 2, "createNewElements num_child problem"); - bool homogeneous_child = ref_topo.homogeneous_child(); - VERIFY_OP(homogeneous_child, ==, true, "createNewElements homogeneous_child"); -#endif - - // new_sub_entity_nodes[i][j] - //const UInt * const * child_nodes() const { - //const UInt * child_node_0 = ref_topo.child_node(0); - - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - RefTopoX& l2 = Elem::StdMeshObjTopologies::RefinementTopologyExtra< FromTopology > ::refinement_topology; - -#define CENTROID_N NN(m_primaryEntityRank,0) - - for (unsigned iChild = 0; iChild < 2; iChild++) - { - unsigned EN[2]; - for (unsigned jNode = 0; jNode < 2; jNode++) - { - unsigned childNodeIdx = ref_topo.child_node(iChild)[jNode]; -#ifndef NDEBUG - unsigned childNodeIdxCheck = l2[childNodeIdx].ordinal_of_node; - VERIFY_OP(childNodeIdx, ==, childNodeIdxCheck, "childNodeIdxCheck"); -#endif - unsigned inode=0; - - if (l2[childNodeIdx].rank_of_subcell == 0) - inode = VERT_N(l2[childNodeIdx].ordinal_of_subcell); - else if (l2[childNodeIdx].rank_of_subcell == 1) - inode = EDGE_N(l2[childNodeIdx].ordinal_of_subcell); - - // else if (l2[childNodeIdx].rank_of_subcell == 2) - // inode = CENTROID_N; - - EN[jNode] = inode; - } - elems[iChild] = line_tuple_type(EN[0], EN[1]); - } - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - -#if 0 - if (proc_rank_field && proc_rank_field->rank() == m_eMesh.edge_rank()) //&& m_eMesh.get_spatial_dim()==1) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } -#endif - stk_classic::mesh::FieldBase * proc_rank_field_edge = m_eMesh.get_field("proc_rank_edge"); - if (proc_rank_field_edge) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field_edge) , newElement ); - fdata[0] = double(newElement.owner_rank()); - //fdata[0] = 1234.56; - if (0) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp set proc_rank_field_edge to value = " << newElement.owner_rank() - << " for side element = " << newElement.identifier() - << std::endl; - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 " << std::endl; - exit(1); - } - - } - - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line3_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line3_1_sierra.hpp deleted file mode 100644 index d824df5044b3..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line2_Line3_1_sierra.hpp +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Line2_Line3_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Line2_Line3_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Line<2>, shards::Line<3>, 1, SierraPort > : public URP , shards::Line<3> > - { - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Line<3> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - - if (eMesh.get_spatial_dim() == 1) - { - bp[0] = this; - } - else - { - } - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - //needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].first = (m_eMesh.get_spatial_dim() == 1 ? m_eMesh.element_rank() : m_eMesh.edge_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::array quadratic_type; - static vector elems(1); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - -#if 0 - double coord_x[3]; - for (int iedge = 0; iedge < 1; iedge++) - { - double * mp = midPoint(VERT_COORD(0), VERT_COORD(1), eMesh.get_spatial_dim(), coord_x); - //double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 " << std::endl; - } - eMesh.createOrGetNode(EDGE_N(iedge), mp); - } - // FIXME - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_primaryEntityRank, 0u); - nodeRegistry.interpolateFields(*const_cast(&element), m_primaryEntityRank, 0u); -#endif - nodeRegistry.addToExistingParts(*const_cast(&element), m_primaryEntityRank, 0u); - -#define CENTROID_N NN(m_primaryEntityRank,0) - - - { - quadratic_type& EN = elems[0]; - - for (unsigned ind = 0; ind < 2; ind++) - { - unsigned inode = VERT_N(ind); - EN[ind] = inode; - } - - EN[2] = CENTROID_N; - } - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - // FIXME - if (0 && proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - - { - if (!elems[ielem][0]) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 " << std::endl; - exit(1); - } - - } - for (int inode=0; inode < 3; inode++) - { - stk_classic::mesh::EntityId eid = elems[ielem][inode]; - stk_classic::mesh::Entity& node = eMesh.createOrGetNode(eid); - eMesh.get_bulk_data()->declare_relation(newElement, node, inode); - } - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line3_Line3_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line3_Line3_2_sierra.hpp deleted file mode 100644 index c4c3b775aa4c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Line3_Line3_2_sierra.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Line3_Line3_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Line3_Line3_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Line<3>, 2, SierraPort > : public URP, shards::Line<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Line<3> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 3u; - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra.hpp deleted file mode 100644 index 9d4a944e7336..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Pyramid13_Pyramid13_10_sierra_hpp - -#include -#include - -#define FACE_BREAKER_P13_P13_10 0 -#if FACE_BREAKER_P13_P13_10 -#include "UniformRefinerPattern_Quad10_Quad10_4_sierra.hpp" -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#endif - -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Pyramid<13>, 10, SierraPort > : public URP,shards::Pyramid<13> > - { - -#if FACE_BREAKER_P13_P13_10 - UniformRefinerPattern, shards::Quadrilateral<10>, 4, SierraPort > * m_face_breaker; - UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > * m_face_breaker_tri; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Pyramid<13> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_P13_P13_10 - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<10>, 4, SierraPort > (eMesh, block_names) ; - m_face_breaker_tri = new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names); -#endif - - } - - ~UniformRefinerPattern() - { -#if FACE_BREAKER_P13_P13_10 - if (m_face_breaker) delete m_face_breaker; - if (m_face_breaker_tri) delete m_face_breaker_tri; -#endif - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - -#if FACE_BREAKER_P13_P13_10 - bp = std::vector(3u, 0); - bp[0] = this; - bp[1] = m_face_breaker; - bp[2] = m_face_breaker_tri; -#else - bp = std::vector(1u, 0); - bp[0] = this; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - // FIXME need to take into account the mixed topology nature of the faces - - needed_entities.resize(3); - - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 9u); // cheating here - we re-use the full quadratic face - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 3u); - - } - - virtual unsigned getNumNewElemPerElem() { return 10; } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { -#if 0 - static bool s_not_printed = true; - - if (s_not_printed) - { - s_not_printed = false; - printRefinementTopoX_Table(); - } -#endif - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra.hpp deleted file mode 100644 index c6cff177891d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Pyramid5_Pyramid13_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_P5_P13_1 1 -#if FACE_BREAKER_P5_P13_1 -#include "UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Pyramid<5>, shards::Pyramid<13>, 1, SierraPort > : public URP , shards::Pyramid<13> > - { - -#if FACE_BREAKER_P5_P13_1 - UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > * m_subDim_breaker; - UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > * m_subDim_breaker_quad; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Pyramid<13> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if FACE_BREAKER_P5_P13_1 - - m_subDim_breaker = new UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > (eMesh, block_names) ; - m_subDim_breaker_quad = new UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > (eMesh, block_names); -#endif - - } - - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - if (m_subDim_breaker_quad) delete m_subDim_breaker_quad; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(3u, 0); - - bp[0] = this; -#if FACE_BREAKER_P5_P13_1 - bp[1] = m_subDim_breaker; - bp[2] = m_subDim_breaker_quad; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra.hpp deleted file mode 100644 index ab4c5de046c7..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra.hpp +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Pyramid5_Pyramid5_10_sierra_hpp - -#include -#include - -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" - -#include - -namespace stk_classic { - namespace adapt { - -#define DEBUG_Pyramid5_Pyramid5_10 0 - - // Some explanation: Pyramid refinement pattern creates a heterogeneous mesh, so we create two - // sub-patterns to deal with the two different resulting topologies (pyramid and tet). A third - // (parent) pattern is created to refer to the two sub-patterns, akin to URP_Heterogeneous_3D. - - //================================================================================================================================================================ - template <> - class UniformRefinerPattern, shards::Pyramid<5>, 6, SierraPort > : public URP, shards::Pyramid<5> > - { - - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Pyramid<5> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - ~UniformRefinerPattern() - { - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - - bp[0] = this; - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 6; } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - //================================================================================================================================================================ - template <> - class UniformRefinerPattern, shards::Tetrahedron<4>, 4, SierraPort > : public URP, shards::Tetrahedron<4> > - { - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<4> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - Elem::StdMeshObjTopologies::bootstrap(); - - } - - ~UniformRefinerPattern() - { - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - - bp[0] = this; - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - //================================================================================================================================================================ - template <> - //class UniformRefinerPattern, shards::Pyramid<5>, 6, SierraPort > : public URP, shards::Pyramid<5> > - class UniformRefinerPattern, shards::Pyramid<5>, 10, SierraPort > : public UniformRefinerPatternBase - { - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; - UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > * m_face_breaker_tri; - - std::vector m_bp; - protected: - - percept::PerceptMesh& m_eMesh; - - public: - - static void printParts(UniformRefinerPatternBase *bp) - { - for (unsigned ii=0; ii < bp->getFromParts().size(); ii++) - { - std::cout << "tmp Pyramid5_Pyramid5_10 ii, fromParts= " << ii << " " << bp->getFromParts()[ii]->name() << std::endl; - } - for (unsigned ii=0; ii < bp->getToParts().size(); ii++) - { - std::cout << "tmp Pyramid5_Pyramid5_10 ii, toParts= " << ii << " " << bp->getToParts()[ii]->name() << std::endl; - } - } - - //UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Pyramid<5> >(eMesh), m_eMesh(eMesh) - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : m_eMesh(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - Elem::StdMeshObjTopologies::bootstrap(); - - // list all types of known break patterns to be used here - m_bp.resize(0); - - m_bp.push_back(new UniformRefinerPattern, shards::Pyramid<5>, 6, SierraPort > (eMesh, block_names)); - m_bp.push_back(new UniformRefinerPattern, shards::Tetrahedron<4>, 4, SierraPort > (eMesh, block_names)); - - bool sameTopology = false; - //setNeededParts(eMesh, block_names, sameTopology); - m_bp[0]->setNeededParts(eMesh, block_names, sameTopology); // force a new part for pyramids - if (DEBUG_Pyramid5_Pyramid5_10) - { - std::cout << "tmp Pyramid5_Pyramid5_10 printParts m_bp[0]= " ; printParts(m_bp[0]); - } - m_bp[1]->setNeededParts(eMesh, block_names, sameTopology); - if (DEBUG_Pyramid5_Pyramid5_10) - { - std::cout << "tmp Pyramid5_Pyramid5_10 printParts m_bp[1]= " ; printParts(m_bp[1]); - } - - for (int ibp=0; ibp < 2; ibp++) - { - stk_classic::mesh::PartVector& fromParts = m_bp[ibp]->getFromParts(); - for (unsigned ii=0; ii < fromParts.size(); ii++) - { - if (std::find(getFromParts().begin(), getFromParts().end(), fromParts[ii]) == getFromParts().end()) - { - getFromParts().push_back(fromParts[ii]); - } - } - stk_classic::mesh::PartVector& toParts = m_bp[ibp]->getToParts(); - for (unsigned ii=0; ii < toParts.size(); ii++) - { - if (std::find(getToParts().begin(), getToParts().end(), toParts[ii]) == getToParts().end()) - { - getToParts().push_back(toParts[ii]); - } - } - } - if (DEBUG_Pyramid5_Pyramid5_10) - { - std::cout << "tmp Pyramid5_Pyramid5_10 printParts this= " ; - printParts(this); - } - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ; - m_face_breaker_tri = new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names); - } - - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - if (m_face_breaker_tri) delete m_face_breaker_tri; - for (unsigned ibp=0; ibp < m_bp.size(); ibp++) - { - if (m_bp[ibp]) delete m_bp[ibp]; - } - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - - bp.resize(3u); - bp[0] = this; - bp[1] = m_face_breaker; - bp[2] = m_face_breaker_tri; - } - - virtual void doBreak() - { - throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::doBreak()"); - } - virtual unsigned getFromTypeKey() - { - //throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::getFromTypeKey()"); - return shards::Pyramid<5>::key; - } - - virtual std::string getFromTopoPartName() { - shards::CellTopology cell_topo(getFromTopology()); - return cell_topo.getName(); - } - virtual std::string getToTopoPartName() { - shards::CellTopology cell_topo(getToTopology()); - return cell_topo.getName(); - } - - virtual const CellTopologyData * getFromTopology() { return shards::getCellTopologyData< shards::Pyramid<5> >(); } - virtual const CellTopologyData * getToTopology() { return shards::getCellTopologyData< shards::Pyramid<5> >(); } - -// virtual const CellTopologyData * getFromTopology() -// { -// throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::getFromTopology()"); -// } - -// virtual const CellTopologyData * getToTopology() { -// throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::getToTopology()"); -// } - - void fillNeededEntities(std::vector& needed_entities) - { - //throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::fillNeededEntities()"); - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() - { - //throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::getNumNewElemPerElem()"); - return 10; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - //throw std::runtime_error("shouldn't call URP_Pyramid5_Pyramid5::createNewElements()"); - - // pyramids - m_bp[0]->createNewElements(eMesh, nodeRegistry, element, new_sub_entity_nodes, element_pool, proc_rank_field); - // tets - m_bp[1]->createNewElements(eMesh, nodeRegistry, element, new_sub_entity_nodes, element_pool, proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4.hpp deleted file mode 100644 index 17f5c254a43c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4.hpp +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Quad4_4_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Quad4_4_hpp - - -//#include "UniformRefinerPattern.hpp" - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Quadrilateral<4>, 4 > : public URP,shards::Quadrilateral<4> > - { - public: - -// UniformRefinerPattern(percept::PerceptMesh& eMesh, std::string fromTopoPartName="block_1", std::string toTopoPartName="block_quad_4") -// { -// setNeededParts(eMesh, fromTopoPartName, toTopoPartName); -// } - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Quadrilateral<4> >(eMesh) - { - m_primaryEntityRank = eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); // edges have 2 nodes - needed_entities[1].first = m_eMesh.element_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple quad_tuple_type; - static vector elems(4); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //stk_classic::mesh::Part & active = mesh->ActivePart(); - //stk_classic::mesh::Part & quad4 = mesh->QuadPart(); - - std::vector add_parts; - std::vector remove_parts; - - //add_parts.push_back( &active ); - //FIXME - //add_parts.push_back( const_cast( eMesh.getPart(m_toTopoPartName) )); - add_parts = m_toParts; - - double tmp_x[3]; - for (int iedge = 0; iedge < 4; iedge++) - { - double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), tmp_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 << " << std::endl; - } - eMesh.createOrGetNode(EDGE_N(iedge), mp); - - } - - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_eMesh.element_rank(), 0u); - - -// new_sub_entity_nodes[i][j] -#define CENTROID_N NN(m_primaryEntityRank,0) - - elems[0] = quad_tuple_type(VERT_N(0), EDGE_N(0), CENTROID_N, EDGE_N(3)); - elems[1] = quad_tuple_type(VERT_N(1), EDGE_N(1), CENTROID_N, EDGE_N(0)); - elems[2] = quad_tuple_type(VERT_N(2), EDGE_N(2), CENTROID_N, EDGE_N(1)); - elems[3] = quad_tuple_type(VERT_N(3), EDGE_N(3), CENTROID_N, EDGE_N(2)); - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } - - eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(1); - } - - } - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<3>()), 3); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp deleted file mode 100644 index f3e46413f1ba..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Quad4_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Quad4_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > : public URP,shards::Quadrilateral<4> > - { - - //Teuchos::RCP< UniformRefinerPattern, shards::Line<2>, 2, SierraPort > > m_edge_breaker; - //UniformRefinerPatternBase * m_edge_breaker; -#define EDGE_BREAKER_Q4_Q4_4_S 1 -#if EDGE_BREAKER_Q4_Q4_4_S - UniformRefinerPattern, shards::Line<2>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Quadrilateral<4> >(eMesh) - { - m_primaryEntityRank = eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_Q4_Q4_4_S - if (m_eMesh.get_spatial_dim() == 2) - m_edge_breaker = new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ; - else - m_edge_breaker = 0; -#endif - - } - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q4_Q4_4_S - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - // FIXME - // std::cout << "ERROR" ; - // exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp deleted file mode 100644 index d968eb301a23..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Quad8_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Quad8_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - -#define EDGE_BREAKER_Q4_Q8_1 1 -#if EDGE_BREAKER_Q4_Q8_1 -#include "UniformRefinerPattern_Line2_Line3_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Quadrilateral<4>, shards::Quadrilateral<8>, 1, SierraPort > : public URP , shards::Quadrilateral<8> > - { - -#if EDGE_BREAKER_Q4_Q8_1 - UniformRefinerPattern, shards::Line<3>, 1, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Quadrilateral<8> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if EDGE_BREAKER_Q4_Q8_1 - - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q4_Q8_1 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - } - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp deleted file mode 100644 index 69f6df1aac56..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Quad9_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Quad9_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - -#define EDGE_BREAKER_Q4_Q9_1 1 -#if EDGE_BREAKER_Q4_Q9_1 -#include "UniformRefinerPattern_Line2_Line3_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Quadrilateral<4>, shards::Quadrilateral<9>, 1, SierraPort > : public URP , shards::Quadrilateral<9> > - { - -#if EDGE_BREAKER_Q4_Q9_1 - UniformRefinerPattern, shards::Line<3>, 1, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Quadrilateral<9> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if EDGE_BREAKER_Q4_Q9_1 - - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q4_Q9_1 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - } - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - virtual StringStringMap fixSurfaceAndEdgeSetNamesMap() - { - StringStringMap str_map; - //str_map["hex8"] = "tet4"; - str_map["quad4"] = "quad9"; - return str_map; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_2.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_2.hpp deleted file mode 100644 index 69e1b68f8d31..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_2.hpp +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Tri3_2_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Tri3_2_hpp - - -//#include "UniformRefinerPattern.hpp" - -namespace stk_classic { - namespace adapt { - - //struct Specialization {}; - - template <> - class UniformRefinerPattern, shards::Triangle<3>, 2 > : public URP , shards::Triangle<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Triangle<3> >(eMesh) - { - EXCEPTWATCH; - m_primaryEntityRank = eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - - } - - virtual void doBreak() {} - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(0); - //needed_entities[0] = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - virtual StringStringMap fixSurfaceAndEdgeSetNamesMap() - { - StringStringMap str_map; - str_map["hex8"] = "tet4"; - str_map["quad4"] = "tri3"; - return str_map; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tri_tuple_type; - static vector elems(2); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //std::cout << "tmp quad elem= " << element << std::endl; - - //stk_classic::mesh::Part & active = mesh->ActivePart(); - //stk_classic::mesh::Part & quad4 = mesh->QuadPart(); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - - //std::cout << "P["<< m_eMesh.get_rank() << "] add_parts = " << add_parts << std::endl; - - //stk_classic::mesh::EntityRank my_rank = m_primaryEntityRank; - - //nodeRegistry.makeCentroid(*const_cast(&element), my_rank, 0u); - //nodeRegistry.addToExistingParts(*const_cast(&element), my_rank, 0u); - //nodeRegistry.interpolateFields(*const_cast(&element), my_rank, 0u); - - { - unsigned globalIqf = VERT_N(0); - unsigned minVal = globalIqf; - unsigned indxMinVal = 0; - for (unsigned iFaceNodeOrd=1; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - globalIqf = VERT_N(iFaceNodeOrd); - if (globalIqf < minVal) - { - minVal = globalIqf; - indxMinVal = iFaceNodeOrd; - } - } - - unsigned istart = indxMinVal; - elems[0] = tri_tuple_type(VERT_N((0 + istart) % 4), VERT_N((1 + istart) % 4), VERT_N((2 + istart) % 4)); - elems[1] = tri_tuple_type(VERT_N((0 + istart) % 4), VERT_N((2 + istart) % 4), VERT_N((3 + istart) % 4)); - } - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field && element.entity_rank() == m_eMesh.element_rank()) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(1); - } - - } - - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_4.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_4.hpp deleted file mode 100644 index c87c3290f649..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_4.hpp +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Tri3_4_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Tri3_4_hpp - - -//#include "UniformRefinerPattern.hpp" - -namespace stk_classic { - namespace adapt { - - struct Specialization {}; - - template <> - class UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > : public URP , shards::Triangle<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Triangle<3> >(eMesh) - { - EXCEPTWATCH; - m_primaryEntityRank = eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - - } - - virtual void doBreak() {} - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - virtual StringStringMap fixSurfaceAndEdgeSetNamesMap() - { - StringStringMap str_map; - str_map["hex8"] = "tet4"; - str_map["quad4"] = "tri3"; - return str_map; - } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tri_tuple_type; - static vector elems(4); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //stk_classic::mesh::Part & active = mesh->ActivePart(); - //stk_classic::mesh::Part & quad4 = mesh->QuadPart(); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - - //std::cout << "P["<< m_eMesh.get_rank() << "] add_parts = " << add_parts << std::endl; - - stk_classic::mesh::EntityRank my_rank = m_primaryEntityRank; - - nodeRegistry.makeCentroidCoords(*const_cast(&element), my_rank, 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), my_rank, 0u); - nodeRegistry.interpolateFields(*const_cast(&element), my_rank, 0u); - -#define CENTROID_N NN(m_primaryEntityRank, 0) - - elems[0] = tri_tuple_type(VERT_N(0), VERT_N(1), CENTROID_N); - elems[1] = tri_tuple_type(VERT_N(1), VERT_N(2), CENTROID_N); - elems[2] = tri_tuple_type(VERT_N(2), VERT_N(3), CENTROID_N); - elems[3] = tri_tuple_type(VERT_N(3), VERT_N(0), CENTROID_N); - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - - /** - \node[above] at (p4.side 1){2}; - \node[left] at (p4.side 2){3}; - \node[below] at (p4.side 3){0}; - \node[right] at (p4.side 4){1}; - */ - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - - //std::cout << "P["<< m_eMesh.get_rank() << "] urp tmp 3 " << proc_rank_field << std::endl; - if (proc_rank_field && element.entity_rank() == m_eMesh.element_rank()) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - fdata[0] = double(newElement.owner_rank()); - } - - //std::cout << "P["<< m_eMesh.get_rank() << "] urp tmp 4 " << std::endl; - change_entity_parts(eMesh, element, newElement); - - //std::cout << "P["<< m_eMesh.get_rank() << "] urp tmp 5 " << std::endl; - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(1); - } - - } - //std::cout << "P["<< m_eMesh.get_rank() << "] urp tmp 6 " << std::endl; - - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - - //std::cout << "P["<< m_eMesh.get_rank() << "] urp tmp 7 " << std::endl; - set_parent_child_relations(eMesh, element, newElement, ielem); - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_6.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_6.hpp deleted file mode 100644 index db09e48b4c95..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad4_Tri3_6.hpp +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad4_Tri3_6_hpp -#define stk_adapt_UniformRefinerPattern_Quad4_Tri3_6_hpp - -#include -#include - -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" - -//#include "UniformRefinerPattern.hpp" - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Triangle<3>, 6 > : public URP , shards::Triangle<3> > - { -#define EDGE_BREAKER_Q4_T3_6_S 1 -#if EDGE_BREAKER_Q4_T3_6_S - UniformRefinerPattern, shards::Line<2>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Triangle<3> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_Q4_T3_6_S - if (m_eMesh.get_spatial_dim() == 2) - m_edge_breaker = new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ; - else - m_edge_breaker = 0; -#endif - - } - - ~UniformRefinerPattern() - { -#if EDGE_BREAKER_Q4_T3_6_S - if (m_edge_breaker) delete m_edge_breaker; -#endif - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q4_T3_6_S - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - // FIXME - // std::cout << "ERROR" ; - // exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); // edges have 2 nodes - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 6; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple tri_tuple_type; - static vector elems(6); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //stk_classic::mesh::Part & active = mesh->ActivePart(); - //stk_classic::mesh::Part & quad4 = mesh->QuadPart(); - - std::vector add_parts; - std::vector remove_parts; - - //add_parts.push_back( &active ); - //FIXME - //add_parts.push_back( const_cast( eMesh.getPart(m_toTopoPartName) )); - add_parts = m_toParts; - - /** - \node[above] at (p4.side 1){2}; - \node[left] at (p4.side 2){3}; - \node[below] at (p4.side 3){0}; - \node[right] at (p4.side 4){1}; - */ - - - - double tmp_x[3]; - for (int iedge = 0; iedge < 4; iedge++) - { - double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), tmp_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 << " << std::endl; - } - eMesh.createOrGetNode(EDGE_N(iedge), mp); - - } - - - elems[0] = tri_tuple_type(VERT_N(0), EDGE_N(0), EDGE_N(3)); - elems[1] = tri_tuple_type(VERT_N(1), EDGE_N(1), EDGE_N(0)); - elems[2] = tri_tuple_type(EDGE_N(0), EDGE_N(1), EDGE_N(3)); - - elems[3] = tri_tuple_type(VERT_N(2), EDGE_N(2), EDGE_N(1)); - elems[4] = tri_tuple_type(VERT_N(3), EDGE_N(3), EDGE_N(2)); - elems[5] = tri_tuple_type(EDGE_N(2), EDGE_N(3), EDGE_N(1)); - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - //stk_classic::mesh::Entity& newElement = eMesh.get_bulk_data()->declare_entity(Element, *element_id_pool, eMesh.getPart(interface_table::shards_Triangle_3) ); - - stk_classic::mesh::Entity& newElement = *(*element_pool); - - if (proc_rank_field) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 << " << std::endl; - exit(1); - } - - } - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<2>()), 2); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp deleted file mode 100644 index 587f83c5e555..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad8_Quad8_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Quad8_Quad8_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define EDGE_BREAKER_Q8_Q8 1 -#if EDGE_BREAKER_Q8_Q8 -#include "UniformRefinerPattern_Line3_Line3_2_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > : public URP,shards::Quadrilateral<8> > - { -#if EDGE_BREAKER_Q8_Q8 - UniformRefinerPattern, shards::Line<3>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::Quadrilateral<8> >(eMesh) - { - m_primaryEntityRank = eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_Q8_Q8 - if (m_eMesh.get_spatial_dim() == 2) - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 2, SierraPort > (eMesh, block_names) ; - else - m_edge_breaker = 0; -#endif - - } - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_BREAKER_Q8_Q8 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q8_Q8 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - } - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - //needed_entities[1] = NeededEntityType( (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()), 5u); - needed_entities[1] = NeededEntityType( (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()), 9u); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp deleted file mode 100644 index 1de19afa7319..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Quad9_Quad9_4_sierra.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Quad9_Quad9_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Quad9_Quad9_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define EDGE_BREAKER_Q9_Q9 1 -#if EDGE_BREAKER_Q9_Q9 -#include "UniformRefinerPattern_Line3_Line3_2_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Quadrilateral<9>, 4, SierraPort > : public URP,shards::Quadrilateral<9> > - { - - //Teuchos::RCP< UniformRefinerPattern, shards::Line<2>, 2, SierraPort > > m_edge_breaker; - //UniformRefinerPatternBase * m_edge_breaker; -#if EDGE_BREAKER_Q9_Q9 - UniformRefinerPattern, shards::Line<3>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Quadrilateral<9> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_Q9_Q9 - if (m_eMesh.get_spatial_dim() == 2) - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 2, SierraPort > (eMesh, block_names) ; - else - m_edge_breaker = 0; -#endif - - } - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_BREAKER_Q9_Q9 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_Q9_Q9 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - // FIXME - // std::cout << "ERROR" ; - // exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType( (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()), 9u); - //setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp deleted file mode 100644 index e2f06916702c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > : public URP, shards::ShellLine<2> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::ShellLine<2> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - typedef boost::tuple line_tuple_type; - static vector elems(2); - - CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - std::vector add_parts; - std::vector remove_parts; - - add_parts = m_toParts; - - double coord_x[3]; - for (int iedge = 0; iedge < 1; iedge++) - { - //double * mp = midPoint(EDGE_COORD(iedge,0), EDGE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - //double * mp = midPoint(FACE_COORD(iedge,0), FACE_COORD(iedge,1), eMesh.get_spatial_dim(), coord_x); - double * mp = midPoint(VERT_COORD(0), VERT_COORD(1), eMesh.get_spatial_dim(), coord_x); - - if (!EDGE_N(iedge)) - { - std::cout << "P[" << eMesh.get_rank() << " nid ## = 0 " << std::endl; - } - - eMesh.createOrGetNode(EDGE_N(iedge), mp); - } - - // FIXME - nodeRegistry.makeCentroidCoords(*const_cast(&element), m_primaryEntityRank, 0u); - nodeRegistry.addToExistingParts(*const_cast(&element), m_primaryEntityRank, 0u); - - nodeRegistry.interpolateFields(*const_cast(&element), m_primaryEntityRank, 0u); - - Elem::CellTopology elem_celltopo = Elem::getCellTopology< FromTopology >(); - const Elem::RefinementTopology* ref_topo_p = Elem::getRefinementTopology(elem_celltopo); - const Elem::RefinementTopology& ref_topo = *ref_topo_p; - -#ifndef NDEBUG - unsigned num_child = ref_topo.num_child(); - VERIFY_OP(num_child, == , 2, "createNewElements num_child problem"); - bool homogeneous_child = ref_topo.homogeneous_child(); - VERIFY_OP(homogeneous_child, ==, true, "createNewElements homogeneous_child"); -#endif - - // new_sub_entity_nodes[i][j] - //const UInt * const * child_nodes() const { - //const UInt * child_node_0 = ref_topo.child_node(0); - - typedef Elem::StdMeshObjTopologies::RefTopoX RefTopoX; - RefTopoX& l2 = Elem::StdMeshObjTopologies::RefinementTopologyExtra< FromTopology > ::refinement_topology; - -#define CENTROID_N NN(m_primaryEntityRank,0) - - for (unsigned iChild = 0; iChild < 2; iChild++) - { - unsigned EN[2]; - for (unsigned jNode = 0; jNode < 2; jNode++) - { - unsigned childNodeIdx = ref_topo.child_node(iChild)[jNode]; -#ifndef NDEBUG - unsigned childNodeIdxCheck = l2[childNodeIdx].ordinal_of_node; - VERIFY_OP(childNodeIdx, ==, childNodeIdxCheck, "childNodeIdxCheck"); -#endif - unsigned inode=0; - - if (l2[childNodeIdx].rank_of_subcell == 0) - inode = VERT_N(l2[childNodeIdx].ordinal_of_subcell); - else if (l2[childNodeIdx].rank_of_subcell == 1) - inode = EDGE_N(l2[childNodeIdx].ordinal_of_subcell); - - // else if (l2[childNodeIdx].rank_of_subcell == 2) - // inode = CENTROID_N; - - EN[jNode] = inode; - } - elems[iChild] = line_tuple_type(EN[0], EN[1]); - } - -#undef CENTROID_N - - // write a diagram of the refinement pattern as a vtk file, or a latex/tikz/pgf file -#define WRITE_DIAGRAM 0 -#if WRITE_DIAGRAM - -#endif - - for (unsigned ielem=0; ielem < elems.size(); ielem++) - { - stk_classic::mesh::Entity& newElement = *(*element_pool); - -#if 0 - if (proc_rank_field && proc_rank_field->rank() == m_eMesh.edge_rank()) //&& m_eMesh.get_spatial_dim()==1) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field) , newElement ); - //fdata[0] = double(m_eMesh.get_rank()); - fdata[0] = double(newElement.owner_rank()); - } -#endif - stk_classic::mesh::FieldBase * proc_rank_field_edge = m_eMesh.get_field("proc_rank_edge"); - if (proc_rank_field_edge) - { - double *fdata = stk_classic::mesh::field_data( *static_cast(proc_rank_field_edge) , newElement ); - fdata[0] = double(newElement.owner_rank()); - //fdata[0] = 1234.56; - if (0) - std::cout << "P[" << m_eMesh.get_rank() << "] tmp set proc_rank_field_edge to value = " << newElement.owner_rank() - << " for side element = " << newElement.identifier() - << std::endl; - } - - //eMesh.get_bulk_data()->change_entity_parts( newElement, add_parts, remove_parts ); - - change_entity_parts(eMesh, element, newElement); - - { - if (!elems[ielem].get<0>()) - { - std::cout << "P[" << eMesh.get_rank() << " nid = 0 " << std::endl; - exit(1); - } - - } - - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<0>()), 0); - eMesh.get_bulk_data()->declare_relation(newElement, eMesh.createOrGetNode(elems[ielem].get<1>()), 1); - - set_parent_child_relations(eMesh, element, newElement, ielem); - - - element_pool++; - - } - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp deleted file mode 100644 index 02395014915e..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellLine<3>, 1, SierraPort > : public URP, shards::ShellLine<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::ShellLine<3> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); // different topologies - Elem::StdMeshObjTopologies::bootstrap(); - } - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(1u, 0); - - if (eMesh.get_spatial_dim() == 1) - { - bp[0] = this; - } - else - { - } - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - //needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].first = (m_eMesh.get_spatial_dim() == 1 ? m_eMesh.element_rank() : m_eMesh.edge_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp deleted file mode 100644 index f630512bf095..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > : public URP, shards::ShellLine<3> > - { - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::ShellLine<3> >(eMesh) - { - m_primaryEntityRank = m_eMesh.edge_rank(); - if (m_eMesh.get_spatial_dim() == 1) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 3u; - } - - virtual unsigned getNumNewElemPerElem() { return 2; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra.hpp deleted file mode 100644 index 1203c6348610..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra.hpp +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad4_4_sierra_hpp - - -#include -#include - -#define EDGE_QU4_QU4_4_BREAKER 1 -#if EDGE_QU4_QU4_4_BREAKER -#include "UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellQuadrilateral<4>, 4, SierraPort > : - public URP,shards::ShellQuadrilateral<4> > - { - - -#if EDGE_QU4_QU4_4_BREAKER - UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::ShellQuadrilateral<4> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_QU4_QU4_4_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ; - } -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_QU4_QU4_4_BREAKER - bp = std::vector(3u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 3) - { - bp[0] = this; -#if EDGE_QU4_QU4_4_BREAKER - bp[1] = m_face_breaker; - bp[2] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell quad class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { -// needed_entities.resize(1); -// needed_entities[0].first = m_eMesh.edge_rank(); - - if (m_eMesh.get_spatial_dim() == 2) - { - throw std::runtime_error("ERROR in shell quad class fillNeededEntities"); - } - - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra.hpp deleted file mode 100644 index b3ee0081fbfe..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad8_1_sierra_hpp - - -#include -#include - -#define EDGE_QU4_QU8_1_BREAKER 1 -#if EDGE_QU4_QU8_1_BREAKER -#include "UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad8_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellQuadrilateral<8>, 1, SierraPort > : - public URP,shards::ShellQuadrilateral<8> > - { - - -#if EDGE_QU4_QU8_1_BREAKER - UniformRefinerPattern, shards::ShellLine<3>, 1, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::ShellQuadrilateral<8> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); // different topologies - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_QU4_QU8_1_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<3>, 1, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 1, SierraPort > (eMesh, block_names) ; - } -#endif - - } - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_QU4_QU8_1_BREAKER - bp = std::vector(3u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 3) - { - bp[0] = this; -#if EDGE_QU4_QU8_1_BREAKER - bp[1] = m_face_breaker; - bp[2] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell quad class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - if (m_eMesh.get_spatial_dim() == 2) - { - throw std::runtime_error("ERROR in shell quad class fillNeededEntities"); - } - - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - //needed_entities[1].first = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra.hpp deleted file mode 100644 index 243fb46b14d9..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellQuad4_ShellQuad9_1_sierra_hpp - - -#include -#include - -#define EDGE_QU4_QU9_1_BREAKER 1 -#if EDGE_QU4_QU9_1_BREAKER -#include "UniformRefinerPattern_ShellLine2_ShellLine3_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellQuadrilateral<9>, 1, SierraPort > : - public URP,shards::ShellQuadrilateral<9> > - { - - -#if EDGE_QU4_QU9_1_BREAKER - UniformRefinerPattern, shards::ShellLine<3>, 1, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::ShellQuadrilateral<9> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); // different topologies - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_QU4_QU9_1_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<3>, 1, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > (eMesh, block_names) ; - } -#endif - - } - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_QU4_QU9_1_BREAKER - bp = std::vector(3u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 3) - { - bp[0] = this; -#if EDGE_QU4_QU9_1_BREAKER - bp[1] = m_face_breaker; - bp[2] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell quad class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - if (m_eMesh.get_spatial_dim() == 2) - { - throw std::runtime_error("ERROR in shell quad class fillNeededEntities"); - } - - needed_entities.resize(2); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[0].second = 1u; - // FIXME - this is a problem with the definition of what a needed entity rank is, and what an stk_classic::mesh::Entity rank is - needed_entities[1].first = m_eMesh.face_rank(); // FIXME m_eMesh.element_rank(); - //needed_entities[1].first = m_eMesh.element_rank(); - needed_entities[1].second = 1u; - - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra.hpp deleted file mode 100644 index 547223991671..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellQuad8_ShellQuad8_4_sierra_hpp - - -#include -#include - -#define EDGE_QU8_QU8_4_BREAKER 1 -#if EDGE_QU8_QU8_4_BREAKER - -#include "UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp" -#include "UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellQuadrilateral<8>, 4, SierraPort > : - public URP,shards::ShellQuadrilateral<8> > - { - - -#if EDGE_QU8_QU8_4_BREAKER - UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::ShellQuadrilateral<8> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_QU8_QU8_4_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > (eMesh, block_names) ; - } -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp.resize(0); - - if (eMesh.get_spatial_dim() == 3) - { - bp.push_back(this); -#if EDGE_QU8_QU8_4_BREAKER - bp.push_back( m_face_breaker); - bp.push_back( m_edge_breaker); -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell quad class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - if (m_eMesh.get_spatial_dim() == 2) - { - throw std::runtime_error("ERROR in shell quad class fillNeededEntities"); - } - - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank() , 9u); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra.hpp deleted file mode 100644 index eda957ba0a75..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra.hpp +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellTri3_ShellTri3_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define EDGE_ST3_ST3_4_BREAKER 1 -#if EDGE_ST3_ST3_4_BREAKER -#include "UniformRefinerPattern_ShellLine2_ShellLine2_2_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellTriangle<3>, 4, SierraPort > : public URP,shards::ShellTriangle<3> > - { - - -#if EDGE_ST3_ST3_4_BREAKER - UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::ShellTriangle<3> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_ST3_ST3_4_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<2>, 2, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names) ; - } -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if EDGE_ST3_ST3_4_BREAKER - bp = std::vector(3u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 3) - { - bp[0] = this; -#if EDGE_ST3_ST3_4_BREAKER - bp[1] = m_face_breaker; - bp[2] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell tri class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra.hpp deleted file mode 100644 index c3a8e06672fc..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_ShellTri6_ShellTri6_4_sierra_hpp - - -#include -#include - -#define EDGE_TR6_TR6_4_BREAKER 1 -#if EDGE_TR6_TR6_4_BREAKER - -#include "UniformRefinerPattern_ShellLine3_ShellLine3_2_sierra.hpp" -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::ShellTriangle<6>, 4, SierraPort > : - public URP,shards::ShellTriangle<6> > - { - - -#if EDGE_TR6_TR6_4_BREAKER - UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > * m_edge_breaker; - UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : - URP, shards::ShellTriangle<6> >(eMesh) - { - - if (m_eMesh.get_spatial_dim() != 3) - { - throw std::runtime_error("can't refine shell elements in 2D"); - } - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_TR6_TR6_4_BREAKER - - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 3) - { - m_edge_breaker = new UniformRefinerPattern, shards::ShellLine<3>, 2, SierraPort > (eMesh, block_names) ; - m_face_breaker = new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names) ; - } -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp.resize(0); - - if (eMesh.get_spatial_dim() == 3) - { - bp.push_back(this); -#if EDGE_TR6_TR6_4_BREAKER - bp.push_back( m_face_breaker); - bp.push_back( m_edge_breaker); -#endif - } - else if (eMesh.get_spatial_dim() != 3) - { - // FIXME - std::cout << "ERROR" ; - throw std::runtime_error("ERROR in shell quad class"); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - if (m_eMesh.get_spatial_dim() == 2) - { - throw std::runtime_error("ERROR in shell quad class fillNeededEntities"); - } - - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank() , 6u); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet10_Tet10_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet10_Tet10_8_sierra.hpp deleted file mode 100644 index 8b128d7947eb..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet10_Tet10_8_sierra.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tet10_Tet10_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tet10_Tet10_8_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define FACE_BREAKER_T10_T10 1 -#if FACE_BREAKER_T10_T10 -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Tetrahedron<10>, 8, SierraPort > : public URP, shards::Tetrahedron<10> > - { - - //Teuchos::RCP< UniformRefinerPattern, shards::Line<2>, 2, SierraPort > > m_face_breaker; - //UniformRefinerPatternBase * m_face_breaker; -#if FACE_BREAKER_T10_T10 - UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<10> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_T10_T10 - - m_face_breaker = new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names); - -#endif - - } - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; -#if FACE_BREAKER_T10_T10 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - bp[0] = this; -#if FACE_BREAKER_T10_T10 - bp[1] = m_face_breaker; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - // 4 vertices - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); // 18 - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 3u); // 12 - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 1u); // 1 - //setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - //typedef boost::array refined_element_type; - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet10_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet10_1_sierra.hpp deleted file mode 100644 index 1c2a246045aa..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet10_1_sierra.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tet4_Tet10_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tet4_Tet10_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_TET4_TET10_1 1 -#if FACE_BREAKER_TET4_TET10_1 -#include "UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Tetrahedron<4>, shards::Tetrahedron<10>, 1, SierraPort > : public URP , shards::Tetrahedron<10> > - { - -#if FACE_BREAKER_TET4_TET10_1 - UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > * m_subDim_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Tetrahedron<10> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if FACE_BREAKER_TET4_TET10_1 - - m_subDim_breaker = new UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - bp[0] = this; -#if FACE_BREAKER_TET4_TET10_1 - bp[1] = m_subDim_breaker; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet4_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet4_8_sierra.hpp deleted file mode 100644 index 4a3857cb8531..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tet4_Tet4_8_sierra.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tet4_Tet4_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tet4_Tet4_8_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define USE_FACE_BREAKER_T4_T4_8 1 -#if USE_FACE_BREAKER_T4_T4_8 -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Tetrahedron<4>, 8, SierraPort > : public URP, shards::Tetrahedron<4> > - { - -#if USE_FACE_BREAKER_T4_T4_8 - // FIXME - UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > * m_face_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Tetrahedron<4> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if USE_FACE_BREAKER_T4_T4_8 - - //m_face_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - m_face_breaker = new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 3) - { - bp[0] = this; -#if USE_FACE_BREAKER_T4_T4_8 - bp[1] = m_face_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 2) - { - // FIXME - std::cout << "ERROR" ; - exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp deleted file mode 100644 index 99a6c0ea1a7e..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tri3_Tri3_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tri3_Tri3_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > : public URP,shards::Triangle<3> > - { - -#define EDGE_BREAKER_T3_T3_4_S 1 -#if EDGE_BREAKER_T3_T3_4_S - UniformRefinerPattern, shards::Line<2>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Triangle<3> >(eMesh), - m_edge_breaker (0) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_T3_T3_4_S - //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); - if (m_eMesh.get_spatial_dim() == 2) - { - m_edge_breaker = new UniformRefinerPattern, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ; - } -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_T3_T3_4_S - if (m_eMesh.get_spatial_dim() == 2) - { - bp[1] = m_edge_breaker; - } -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - // FIXME -// std::cout << "ERROR" ; -// exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - //needed_entities[1] = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp deleted file mode 100644 index 53bb98472062..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tri3_Tri6_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tri3_Tri6_1_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#include - -#define EDGE_BREAKER_T3_T6_1 1 -#if EDGE_BREAKER_T3_T6_1 -#include "UniformRefinerPattern_Line2_Line3_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Triangle<3>, shards::Triangle<6>, 1, SierraPort > : public URP , shards::Triangle<6> > - { - -#if EDGE_BREAKER_T3_T6_1 - UniformRefinerPattern, shards::Line<3>, 1, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Triangle<6> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if EDGE_BREAKER_T3_T6_1 - - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 1, SierraPort > (eMesh, block_names) ; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(2u, 0); - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_T3_T6_1 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - } - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - //needed_entities[1] = (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp deleted file mode 100644 index cc2ef29922e3..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Tri6_Tri6_4_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Tri6_Tri6_4_sierra_hpp - - -//#include "UniformRefinerPattern.hpp" -#include -#include - -#define EDGE_BREAKER_T6_T6 1 -#if EDGE_BREAKER_T6_T6 -#include "UniformRefinerPattern_Line3_Line3_2_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > : public URP,shards::Triangle<6> > - { - -#if EDGE_BREAKER_T6_T6 - UniformRefinerPattern, shards::Line<3>, 2, SierraPort > * m_edge_breaker; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Triangle<6> >(eMesh) - { - m_primaryEntityRank = m_eMesh.face_rank(); - if (m_eMesh.get_spatial_dim() == 2) - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if EDGE_BREAKER_T6_T6 - if (m_eMesh.get_spatial_dim() == 2) - m_edge_breaker = new UniformRefinerPattern, shards::Line<3>, 2, SierraPort > (eMesh, block_names) ; - else - m_edge_breaker = 0; -#endif - - } - - ~UniformRefinerPattern() - { - if (m_edge_breaker) delete m_edge_breaker; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - -#if EDGE_BREAKER_T6_T6 - bp = std::vector(2u, 0); -#else - bp = std::vector(1u, 0); -#endif - - if (eMesh.get_spatial_dim() == 2) - { - bp[0] = this; -#if EDGE_BREAKER_T6_T6 - bp[1] = m_edge_breaker; -#endif - } - else if (eMesh.get_spatial_dim() == 3) - { - // FIXME - // std::cout << "ERROR" ; - // exit(1); - } - - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType( (m_eMesh.get_spatial_dim() == 2 ? m_eMesh.element_rank() : m_eMesh.face_rank()), 3u); - //setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 4; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge15_Wedge15_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge15_Wedge15_8_sierra.hpp deleted file mode 100644 index cbc93612a774..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge15_Wedge15_8_sierra.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Wedge15_Wedge15_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Wedge15_Wedge15_8_sierra_hpp - -#include -#include - -#define FACE_BREAKER_W15_W15_8 0 -#if FACE_BREAKER_W15_W15_8 -#include "UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp" -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#endif - -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Wedge<15>, 8, SierraPort > : public URP,shards::Wedge<15> > - { - -#if FACE_BREAKER_W15_W15_8 - UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > * m_face_breaker; - UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > * m_face_breaker_tri; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Wedge<15> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_W15_W15_8 - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > (eMesh, block_names) ; - m_face_breaker_tri = new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names); -#endif - - } - - ~UniformRefinerPattern() - { -#if FACE_BREAKER_W15_W15_8 - if (m_face_breaker) delete m_face_breaker; - if (m_face_breaker_tri) delete m_face_breaker_tri; -#endif - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - -#if FACE_BREAKER_W15_W15_8 - bp = std::vector(3u, 0); - bp[0] = this; - bp[1] = m_face_breaker; - bp[2] = m_face_breaker_tri; -#else - bp = std::vector(1u, 0); - bp[0] = this; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - // FIXME need to take into account the mixed topology nature of the faces - - needed_entities.resize(3); - - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 9u); // cheating here - we re-use the full quadratic face - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 3u); - - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { -#if 0 - static bool s_not_printed = true; - - if (s_not_printed) - { - s_not_printed = false; - printRefinementTopoX_Table(); - } -#endif - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge18_Wedge18_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge18_Wedge18_8_sierra.hpp deleted file mode 100644 index 51e375495b6b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge18_Wedge18_8_sierra.hpp +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Wedge18_Wedge18_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Wedge18_Wedge18_8_sierra_hpp - -#include -#include - -#define FACE_BREAKER_W18_W18_8 0 -#if FACE_BREAKER_W18_W18_8 -#include "UniformRefinerPattern_Quad8_Quad8_4_sierra.hpp" -#include "UniformRefinerPattern_Tri6_Tri6_4_sierra.hpp" -#endif - -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Wedge<18>, 8, SierraPort > : public URP,shards::Wedge<18> > - { - -#if FACE_BREAKER_W18_W18_8 - UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > * m_face_breaker; - UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > * m_face_breaker_tri; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Wedge<18> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_W18_W18_8 - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<8>, 4, SierraPort > (eMesh, block_names) ; - m_face_breaker_tri = new UniformRefinerPattern, shards::Triangle<6>, 4, SierraPort > (eMesh, block_names); -#endif - - } - ~UniformRefinerPattern() - { -#if FACE_BREAKER_W18_W18_8 - if (m_face_breaker) delete m_face_breaker; - if (m_face_breaker_tri) delete m_face_breaker_tri; -#endif - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - -#if FACE_BREAKER_W18_W18_8 - bp = std::vector(3u, 0); - bp[0] = this; - bp[1] = m_face_breaker; - bp[2] = m_face_breaker_tri; -#else - bp = std::vector(1u, 0); - bp[0] = this; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - // FIXME need to take into account the mixed topology nature of the faces - needed_entities.resize(3); - - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 3u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 9u); - needed_entities[2] = NeededEntityType(m_eMesh.element_rank(), 18u); - - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { -#if 0 - static bool s_not_printed = true; - - if (s_not_printed) - { - s_not_printed = false; - printRefinementTopoX_Table(); - } -#endif - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge15_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge15_1_sierra.hpp deleted file mode 100644 index 9bfa0943b1ad..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge15_1_sierra.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Wedge6_Wedge15_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Wedge6_Wedge15_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_W6_W15_1 1 -#if FACE_BREAKER_W6_W15_1 -#include "UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Wedge<6>, shards::Wedge<15>, 1, SierraPort > : public URP , shards::Wedge<15> > - { - -#if FACE_BREAKER_W6_W15_1 - UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > * m_subDim_breaker; - UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > * m_subDim_breaker_quad; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Wedge<15> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if FACE_BREAKER_W6_W15_1 - - m_subDim_breaker = new UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > (eMesh, block_names) ; - m_subDim_breaker_quad = new UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > (eMesh, block_names); -#endif - - } - - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - if (m_subDim_breaker_quad) delete m_subDim_breaker_quad; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(3u, 0); - - bp[0] = this; -#if FACE_BREAKER_W6_W15_1 - bp[1] = m_subDim_breaker; - bp[2] = m_subDim_breaker_quad; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(1); - needed_entities[0].first = m_eMesh.edge_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge18_1_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge18_1_sierra.hpp deleted file mode 100644 index f7bc97efe555..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge18_1_sierra.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Wedge6_Wedge18_1_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Wedge6_Wedge18_1_sierra_hpp - - -#include -#include - -#include - -#define FACE_BREAKER_W6_W18_1 1 -#if FACE_BREAKER_W6_W18_1 -#include "UniformRefinerPattern_Tri3_Tri6_1_sierra.hpp" -#include "UniformRefinerPattern_Quad4_Quad9_1_sierra.hpp" -#endif - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern< shards::Wedge<6>, shards::Wedge<18>, 1, SierraPort > : public URP , shards::Wedge<18> > - { - -#if FACE_BREAKER_W6_W18_1 - UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > * m_subDim_breaker; - UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > * m_subDim_breaker_quad; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP , shards::Wedge<18> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, false); - Elem::StdMeshObjTopologies::bootstrap(); -#if FACE_BREAKER_W6_W18_1 - - m_subDim_breaker = new UniformRefinerPattern, shards::Triangle<6>, 1, SierraPort > (eMesh, block_names) ; - m_subDim_breaker_quad = new UniformRefinerPattern, shards::Quadrilateral<9>, 1, SierraPort > (eMesh, block_names); -#endif - - } - ~UniformRefinerPattern() - { - if (m_subDim_breaker) delete m_subDim_breaker; - if (m_subDim_breaker_quad) delete m_subDim_breaker_quad; - } - - - virtual void doBreak() {} - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(3u, 0); - - bp[0] = this; -#if FACE_BREAKER_W6_W18_1 - bp[1] = m_subDim_breaker; - bp[2] = m_subDim_breaker_quad; -#endif - - } - - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(2); - needed_entities[0] = NeededEntityType(m_eMesh.edge_rank(), 1u); - needed_entities[1] = NeededEntityType(m_eMesh.face_rank(), 1u); - } - - virtual unsigned getNumNewElemPerElem() { return 1; } - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { - genericEnrich_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } // namespace adapt -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge6_8_sierra.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge6_8_sierra.hpp deleted file mode 100644 index 8b693fad63ae..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/UniformRefinerPattern_Wedge6_Wedge6_8_sierra.hpp +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef stk_adapt_UniformRefinerPattern_Wedge6_Wedge6_8_sierra_hpp -#define stk_adapt_UniformRefinerPattern_Wedge6_Wedge6_8_sierra_hpp - -#include -#include - -#include "UniformRefinerPattern_Quad4_Quad4_4_sierra.hpp" -#include "UniformRefinerPattern_Tri3_Tri3_4_sierra.hpp" - -#include - -namespace stk_classic { - namespace adapt { - - template <> - class UniformRefinerPattern, shards::Wedge<6>, 8, SierraPort > : public URP,shards::Wedge<6> > - { - -#define FACE_BREAKER_W6_W6_8 1 -#if FACE_BREAKER_W6_W6_8 - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > * m_face_breaker; - UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > * m_face_breaker_tri; -#endif - - public: - - UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP, shards::Wedge<6> >(eMesh) - { - m_primaryEntityRank = eMesh.element_rank(); - - setNeededParts(eMesh, block_names, true); - Elem::StdMeshObjTopologies::bootstrap(); - -#if FACE_BREAKER_W6_W6_8 - - m_face_breaker = new UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > (eMesh, block_names) ; - m_face_breaker_tri = new UniformRefinerPattern, shards::Triangle<3>, 4, SierraPort > (eMesh, block_names); -#endif - - } - - ~UniformRefinerPattern() - { - if (m_face_breaker) delete m_face_breaker; - if (m_face_breaker_tri) delete m_face_breaker_tri; - } - - void setSubPatterns( std::vector& bp, percept::PerceptMesh& eMesh ) - { - EXCEPTWATCH; - bp = std::vector(3u, 0); - - bp[0] = this; -#if FACE_BREAKER_W6_W6_8 - bp[1] = m_face_breaker; - bp[2] = m_face_breaker_tri; -#endif - } - - virtual void doBreak() {} - void fillNeededEntities(std::vector& needed_entities) - { - needed_entities.resize(3); - needed_entities[0].first = m_eMesh.edge_rank(); - needed_entities[1].first = m_eMesh.face_rank(); - setToOne(needed_entities); - } - - virtual unsigned getNumNewElemPerElem() { return 8; } - - - void - createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, - stk_classic::mesh::Entity& element, NewSubEntityNodesType& new_sub_entity_nodes, vector::iterator& element_pool, - stk_classic::mesh::FieldBase *proc_rank_field=0) - { -#if 0 - static bool s_not_printed = true; - - if (s_not_printed) - { - s_not_printed = false; - printRefinementTopoX_Table(); - } -#endif - genericRefine_createNewElements(eMesh, nodeRegistry, - element, new_sub_entity_nodes, element_pool, - proc_rank_field); - } - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/AdaptMain.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/main/AdaptMain.cpp deleted file mode 100644 index 1c492ba67c6c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/AdaptMain.cpp +++ /dev/null @@ -1,1169 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#define ALLOW_MEM_TEST 1 - -extern double s_timers[10]; // = {0,0,0,0,0,0,0,0,0,0}; - - -namespace stk_classic { - - namespace adapt { - - static int s_spatialDim=0; - - typedef uint64_t MemorySizeType; - - BOOST_STATIC_ASSERT(sizeof(uint64_t) == sizeof(size_t)); - - static double MegaByte(MemorySizeType x) { return ((double)x/1024.0/1024.0); } - - - - struct MemoryMultipliers - { - MemorySizeType num_hex8; - MemorySizeType num_tet4; - MemorySizeType num_nodes; - - typedef MemorySizeType MemMultType; - MemMultType mult_hex8; - MemMultType mult_tet4; - MemMultType mult_nodes; - - MemoryMultipliers(MemMultType mult_hex8=1490, MemMultType mult_tet4=702, MemMultType mult_nodes=0): - num_hex8(0ul), - num_tet4(0ul), - num_nodes(0ul), - mult_hex8(mult_hex8), - mult_tet4(mult_tet4), - mult_nodes(mult_nodes) - { - } - - void read_simple(std::string file_name) - { - std::ifstream file(file_name.c_str()); - if (file.good()) - file >> mult_hex8 >> mult_tet4 >> mult_nodes; - //std::string line1; - //file >> line1; - //std::cout << "mult_hex8= " << mult_hex8 << " mult_tet4= " << mult_tet4 << " mult_nodes=" << mult_nodes << std::endl; - } - - MemorySizeType estimate_memory() - { - return mult_nodes*num_nodes + mult_hex8*num_hex8 + mult_tet4*num_tet4; - } - - MemorySizeType estimate_memory(std::vector& refInfo) - { - num_hex8=0ul; - num_tet4=0ul; - num_nodes=0ul; - - for (unsigned i = 0; i < refInfo.size(); i++) - { - num_nodes= refInfo[0].m_numNewNodes; - //std::cout << "irank, rank, m_numNewNodes, m_numNewElems= " << i << " " << refInfo[i].m_rank << " " << refInfo[i].m_numNewNodes - //<< " " << refInfo[i].m_numNewElemsLast - //<< std::endl; - - // if (refInfo[i].m_rank == 0) - // { - // num_nodes += refInfo[i].m_numNewNodes; - // } - // else - { - switch(refInfo[i].m_topology.getKey()) - { - case shards::Hexahedron<8>::key: - num_hex8 += refInfo[i].m_numNewElemsLast; - break; - case shards::Tetrahedron<4>::key: - num_tet4 += refInfo[i].m_numNewElemsLast; - break; - default: - break; - } - } - } - - return estimate_memory(); - } - - static void process_estimate(MemorySizeType tot_mem, PerceptMesh& eMesh, std::vector& refInfo, std::string memory_multipliers_file, std::string input_file) - { - //const stk_classic::ParallelMachine& comm = eMesh.get_bulk_data()->parallel(); - - // this is a data gather pass - if (tot_mem) - { - /* - mesh::Selector sel_locally_owned(eMesh.get_fem_meta_data()->locally_owned_part()); - mesh::Selector sel_globally_shared(eMesh.get_fem_meta_data()->globally_shared_part()); - mesh::Selector sel_universal(eMesh.get_fem_meta_data()->universal_part()); - - std::vector count ; - stk_classic::mesh::count_entities( sel_universal, *eMesh.get_bulk_data(), count ); - - unsigned nnodes = count[0]; - - stk_classic::ParallelMachine pm = eMesh.get_bulk_data()->parallel(); - stk_classic::all_reduce( pm, stk_classic::ReduceSum<1>( &nnodes ) ); - */ - MemoryMultipliers memMults; - // FIXME, here's where we would read in some values for memMults from memory_multipliers_file - if (memory_multipliers_file.size()) - memMults.read_simple(memory_multipliers_file); - RefinementInfoByType::countCurrentNodes(eMesh, refInfo); - MemorySizeType estMem = memMults.estimate_memory(refInfo); - //std::cout << "tmp srk tot_mem = " << MegaByte(tot_mem) << " estMem= " << MegaByte(estMem) << std::endl; - if (eMesh.get_rank() == 0) - { - std::cout << "MemEst: num_nodes= " << memMults.num_nodes << " num_tet4= " << memMults.num_tet4 << " num_hex8= " << memMults.num_hex8 << " memory[MB]= " << MegaByte(tot_mem) - << " estMem[MB]= " << MegaByte(estMem) - << " mult_hex8= " << memMults.mult_hex8 << " mult_tet4= " << memMults.mult_tet4 << " mult_nodes=" << memMults.mult_nodes << std::endl; - - std::cout << "(*MemEstMM: " << input_file << " *) ,{" << memMults.num_nodes << ", " << memMults.num_tet4 << "," << memMults.num_hex8 << "," << MegaByte(tot_mem) - << ", " << MegaByte(estMem) << "}" << std::endl; - } - - } - else - { - // this is an estimate multipliers pass (computes memory using current multipliers) - MemoryMultipliers memMults; - // FIXME, here's where we would read in some values for memMults from memory_multipliers_file - if (memory_multipliers_file.size()) - memMults.read_simple(memory_multipliers_file); - RefinementInfoByType::countCurrentNodes(eMesh, refInfo); - MemorySizeType estMem = memMults.estimate_memory(refInfo); - //std::cout << "tmp srk tot_mem = " << MegaByte(tot_mem) << " estMem= " << MegaByte(estMem) << std::endl; - if (eMesh.get_rank() == 0) - { - std::cout << "MemEst: num_nodes= " << memMults.num_nodes << " num_tet4= " << memMults.num_tet4 << " num_hex8= " << memMults.num_hex8 << " memory[MB]= " << MegaByte(tot_mem) - << " estMem[MB]= " << MegaByte(estMem) - << " mult_hex8= " << memMults.mult_hex8 << " mult_tet4= " << memMults.mult_tet4 << " mult_nodes=" << memMults.mult_nodes << std::endl; - - std::cout << "(*MemEstMM: " << input_file << " *) ,{" << memMults.num_nodes << ", " << memMults.num_tet4 << "," << memMults.num_hex8 << "," << MegaByte(tot_mem) - << ", " << MegaByte(estMem) << "}" << std::endl; - } - - } - } - }; - - - static MemorySizeType memory_dump(int dump_level, const stk_classic::ParallelMachine& comm, stk_classic::mesh::BulkData& bulkData, NodeRegistry* node_reg, std::string msg) - { - MemorySizeType returned_total_memory; - MemorySizeType malloc_used_0 = malloc_used(); - MemorySizeType malloc_footprint_0 = malloc_footprint(); - MemorySizeType malloc_max_footprint_0 = malloc_max_footprint(); - MemorySizeType MB = 1024*1024; - - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &malloc_used_0 ) ); - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &malloc_footprint_0 ) ); - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &malloc_max_footprint_0 ) ); - - stk_classic::mesh::MemoryUsage mem_usage; - stk_classic::mesh::compute_memory_usage(bulkData, mem_usage); - - MemorySizeType node_reg_mem = 0; - if (node_reg) - node_reg_mem = node_reg->get_memory_usage(); - MemorySizeType node_reg_mem_sum = node_reg_mem; - MemorySizeType node_reg_mem_max = node_reg_mem; - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &node_reg_mem_sum ) ); - stk_classic::all_reduce( comm, stk_classic::ReduceMax<1>( &node_reg_mem_max ) ); - - MemorySizeType mem_total_bytes_sum = mem_usage.total_bytes; - MemorySizeType mem_total_bytes_max = mem_usage.total_bytes; - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &mem_total_bytes_sum ) ); - stk_classic::all_reduce( comm, stk_classic::ReduceMax<1>( &mem_total_bytes_max ) ); - if (bulkData.parallel_rank() == 0) - { -#if !defined(SIERRA_PTMALLOC3_ALLOCATOR) && !defined(SIERRA_PTMALLOC2_ALLOCATOR) - std::cout << "WARNING: ptmalloc2|3 not compiled in so malloc_used info unavailable. Recompile with e.g. 'bake allocator=ptmalloc2 (or 3)'. Printing zeros..." << std::endl; - - // intelcray - -#else - -#endif - - if (dump_level > 1) - - { - std::cout << "P[" << bulkData.parallel_rank() << "] AdaptMain::memory_dump stk_mesh counted memory usage at stage [" << msg << "] " - " parallel sum, max memory [MB]= " << ((double)mem_total_bytes_sum)/MB << " , " << ((double)mem_total_bytes_max)/MB << std::endl; - if (dump_level > 2) - stk_classic::mesh::print_memory_usage(mem_usage, std::cout); - - std::cout << "P[" << bulkData.parallel_rank() << "] AdaptMain::memory_dump malloc_used total (sum all proc) at stage [" << msg << "] = " - << " malloc_used malloc_footprint malloc_max_footprint [MB]= " << ((double)malloc_used_0)/MB - << " , " << ((double)malloc_footprint_0)/MB - << " , " << ((double)malloc_max_footprint_0)/MB - << std::endl; - } - - { - std::cout << "AdaptMain::memory_dump summary for " << msg << " : stk_mesh [sum], NodeRegistry [sum], ptmalloc[sum] [MB] " - << ((double)mem_total_bytes_sum)/MB << " , " - << ((double)node_reg_mem_sum)/MB << " , " - << ((double)malloc_used_0)/MB - << std::endl; - } - - } - if (malloc_used_0) - returned_total_memory = malloc_used_0; - else - returned_total_memory = mem_total_bytes_sum+node_reg_mem_sum; - - return returned_total_memory; - } - - //extern void test_memory(int, int); - void test_memory(percept::PerceptMesh& eMesh, MemorySizeType n_elements, MemorySizeType n_nodes) - { - vector new_elements; - vector new_nodes; - - eMesh.get_bulk_data()->modification_begin(); - - std::cout << "creating " << n_elements << " elements..." <(100ul), n_elements); - MemorySizeType print_mod = n_elements/num_prints; - MemorySizeType i_node = 0; - int n_node_per_element = 8; - for (MemorySizeType i_element = 0; i_element < n_elements; i_element++) - { - if (!i_element || (i_element % print_mod == 0)) - { - std::cout << "declare_relation for i_element = " << i_element << " [" << n_elements << "] = " << ((double)i_element)/((double)n_elements)*100 << "%" - << std::endl; - } - stk_classic::mesh::Entity& element = *new_elements[i_element]; - - for (int j_node = 0; j_node < n_node_per_element; j_node++) - { - stk_classic::mesh::Entity& node = *new_nodes[i_node]; - - eMesh.get_bulk_data()->declare_relation(element, node, j_node); - - i_node++; - if (i_node >= n_nodes-1) - i_node = 0; - } - } - - std::cout << " doing modification_end ... " << std::endl; - eMesh.get_bulk_data()->modification_end(); - std::cout << " done modification_end ... " << std::endl; - - - } - - static void checkInput(std::string option, std::string value, std::string allowed_values, RunEnvironment& run_environment) - { - //if (value.length() == 0) return; - std::vector vals = Util::split(allowed_values, ", "); - for (unsigned i = 0; i < vals.size(); i++) - { - if (vals[i] == value) - return; - } - std::ostringstream oss; - oss << "AdaptMain::checkInput bad option for " << option << " (= " << value << ") \n allowed values = " << allowed_values; - //throw std::runtime_error(oss.str()); - { - std::cout << oss.str() << std::endl; - run_environment.printHelp(); - exit(1); - } - - } - - static void print_simple_usage(int argc, char **argv) - { - std::cout << "AdaptMain::print_simple_usage number of arguments = " << argc << std::endl; - for (int i = 0; i < argc; i++) - { - std::cout << "AdaptMain::print_simple_usage arg[" << i << "]= " << argv[i] << std::endl; - } - std::cout << "usage: exe_name [convert|enrich|refine] input_file_name [output_file_name] [number_refines]" << std::endl; - } - - int adapt_main(int argc, char **argv) ; - int adapt_main_full_options(int argc, char **argv) ; - - // FIXME - static int check_for_simple_options(int argc, char **argv) - { - int simple = 0; - for (int i = 1; i < argc; i++) - { - if (std::string(argv[i]) == "refine" || std::string(argv[i]) == "enrich" || std::string(argv[i]) == "convert") - return i; - } - return simple; - } - - static bool debug = false; - int adapt_main_simple_options(int argc_in, char **argv_in) - { - - // format: exe_name [convert|enrich|refine] input_file_name - int simple_options_index = check_for_simple_options(argc_in, argv_in); - - // if (!simple_options_index) - // { - // print_simple_usage(); - // return 1; - // } - - int argc = argc_in; - if (argc != 2 + simple_options_index && argc != 3 + simple_options_index && argc != 4 + simple_options_index ) - { - print_simple_usage(argc_in, argv_in); - return 1; - } - - std::vector argv(argc); - for (int i = 0; i < argc; i++) - { - argv[i] = (const char *)argv_in[i]; - } - if (debug) - std::cout << "argc = " << argc << " argv= \n" << argv << std::endl; - - std::string exe_name = argv[0]; - std::string option = argv[0+simple_options_index]; - if (option != "refine" && option != "enrich" && option != "convert") - { - print_simple_usage(argc_in, argv_in); - return 1; - } - std::string input_mesh = argv[1+simple_options_index]; - std::string number_refines = (argc == 3+simple_options_index? argv[2+simple_options_index] : "1"); - int nref=0; - - bool isInt = false; - try { - nref = boost::lexical_cast(number_refines); - (void)nref; - isInt = true; - } - catch( ... ) - { - } - - std::string output_mesh = input_mesh; - std::string extension = input_mesh.substr(input_mesh.length()-2,input_mesh.length()); - if (debug) std::cout << " extension= " << extension << std::endl; - std::string new_ext = ""; - new_ext += "_"; - if (option == "refine") - new_ext += "refined_"+number_refines+extension; - else - new_ext += option+"ed_"+extension; - - if (!isInt && (argc == 3+simple_options_index)) - { - output_mesh = number_refines; - number_refines = (argc == 4+simple_options_index? argv[3+simple_options_index] : "1"); - //std::cout << "tmp output_mesh= " << output_mesh << std::endl; - //std::cout << "tmp number_refines= " << number_refines << std::endl; - } - else - { - Util::replace(output_mesh, extension, new_ext); - } - if (debug) std::cout << " output_mesh= " << output_mesh << std::endl; - - std::vector argv_new; - for (int i = 0; i < simple_options_index; i++) - argv_new.push_back(argv[i]); - argv_new.push_back("--input_mesh="+input_mesh); - argv_new.push_back("--output_mesh="+output_mesh); - if (option == "refine") - argv_new.push_back("--refine=DEFAULT"); - else if (option == "enrich") - argv_new.push_back("--enrich=DEFAULT"); - else - argv_new.push_back("--convert=Hex8_Tet4_24"); - argv_new.push_back("--load_balance=1"); - argv_new.push_back("--remove_original_elements=1"); - argv_new.push_back("--number_refines="+number_refines); - - if ( debug) std::cout << "new argv = \n" << argv_new << std::endl; - int argc_new = argv_new.size(); - char **argv_new_cstr = new char*[argc_new]; - for (int i = 0; i < argc_new; i++) - { - argv_new_cstr[i] = (char *)argv_new[i].c_str(); - } - int ret_val = adapt_main_full_options(argc_new, argv_new_cstr); - delete[] argv_new_cstr; - return ret_val; - } - - static void dump_args(int argc, char **argv) - { - std::cout << "argc = " << argc << std::endl; - for (int i = 0; i < argc; i++) - { - std::cout << "argv[" << i << "]= " << argv[i] << std::endl; - } - } - - int adapt_main(int argc, char **argv) - { - if (debug) - dump_args(argc, argv); - // allow positional arguments, etc. - if (check_for_simple_options(argc, argv)) - return adapt_main_simple_options(argc, argv); - else - return adapt_main_full_options(argc, argv); - } - - int adapt_main_full_options(int argc, char **argv) - { - EXCEPTWATCH; - bool debug_re = false; - - RunEnvironment run_environment(&argc, &argv, debug_re); - unsigned p_rank = stk_classic::parallel_machine_rank(run_environment.m_comm); - unsigned p_size = stk_classic::parallel_machine_size(run_environment.m_comm); - - - std::string options_description_desc = "stk_adapt options"; - - // NOTE: Options --directory --output-log --runtest are handled/defined in RunEnvironment - std::string input_mesh=""; - std::string input_geometry=""; - std::string output_mesh=""; - std::string block_name_inc = ""; - std::string block_name_exc = ""; - std::string convert=""; - std::string refine=""; - //std::string refine=""; - std::string enrich=""; - bool doRefineMesh = true; - int load_balance = 1; - std::string convert_Hex8_Tet4_24 = "Hex8_Tet4_24"; - int print_info=0; - int remove_original_elements = 1; - int number_refines = 1; - int proc_rank_field = 0; - int query_only = 0; - int progress_meter = 0; - int smooth_geometry = 0; - int refine_to_spacing = 0; - //double min_spacing_factor = 0.25; // range [0,0.5] - int remove_geometry_blocks = 0; - int sync_io_regions = 1; - int delete_parents = 1; - int print_memory_usage = 0; - // a list of comma-separated names like Entity, Relation, Field, etc. - std::string memory_multipliers_file=""; - int estimate_memory_usage=0; - int streaming_size=0; - int streaming_rank=0; - int streaming_pass_start= -2; // FIXME - change to not start from -1 below - int streaming_pass_end= -2; - //std::string streaming_instruction=""; - int streaming_W = 0; - int streaming_iW = 0; - - // Hex8_Tet4_24 (default), Quad4_Quad4_4, Qu - std::string block_name_desc = - "block name(s) to convert: there are 4 options\n" - " (1) empty string or option not specified: convert all blocks in the input mesh file\n" - " (2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names\n" - " from the given file\n" - " (3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional\n" - " (4) a single input block name (e.g. block_3) to be converted \n" - " (5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory\n" - " (6) block_1..block_10 include the range of blocks #1 to #10 \n" - " (7) any combination of [+] and - options and range (..) option can be specified \n" - "Note: wherever you specify block_# this can be replaced with just the #, e.g. \"1,2,4,5\" "; - - std::string convert_options = UniformRefinerPatternBase::s_convert_options; - std::string refine_options = UniformRefinerPatternBase::s_refine_options; - std::string enrich_options = UniformRefinerPatternBase::s_enrich_options; - - std::string def1= Util::split(convert_options, ", ")[0] ; - if (0) std::cout << def1 << "tmp split = " << Util::split(convert_options, ", ") << std::endl; - int test_memory_elements = 0; - int test_memory_nodes = 0; - - //convert_options = "DEFAULT or one of "+convert_options; - //refine_options = "DEFAULT or one of "+refine_options; - //enrich_options = "DEFAULT or one of "+enrich_options; - - // : if not specified, use input mesh name appended with _{converted,refined_#refines,enriched}"); - - std::string block_name_desc_inc = "which blocks to include, specified as: "+block_name_desc; - std::string block_name_desc_exc = "which blocks to exclude, specified as: "+block_name_desc; - - int help = 0; - - run_environment.clp.setOption("help" , &help , "print this usage message"); - run_environment.clp.setOption("convert" , &convert , convert_options.c_str()); - run_environment.clp.setOption("refine" , &refine , refine_options.c_str()); - run_environment.clp.setOption("enrich" , &enrich , enrich_options.c_str()); - run_environment.clp.setOption("input_mesh" , &input_mesh , "input mesh name"); - run_environment.clp.setOption("output_mesh" , &output_mesh , "output mesh name"); - - run_environment.clp.setOption("query_only" , &query_only , "query only, no refinement done"); - run_environment.clp.setOption("progress_meter" , &progress_meter , "progress meter on or off"); - run_environment.clp.setOption("smooth_geometry" , &smooth_geometry , "smooth geometry - moves nodes after geometry projection to try to avoid bad meshes"); - run_environment.clp.setOption("remove_geometry_blocks" , &remove_geometry_blocks , "remove geometry blocks from output Exodus file after refinement/geometry projection"); - run_environment.clp.setOption("sync_io_regions" , &sync_io_regions , "synchronize input/output region's Exodus id's"); - run_environment.clp.setOption("delete_parents" , &delete_parents , "DEBUG: delete parents from a nested, multi-refine mesh - used for debugging"); - - run_environment.clp.setOption("number_refines" , &number_refines , "number of refinement passes"); - run_environment.clp.setOption("block_name" , &block_name_inc , block_name_desc_inc.c_str()); - //run_environment.clp.setOption("exclude" , &block_name_exc , block_name_desc_exc.c_str()); - run_environment.clp.setOption("print_info" , &print_info , ">= 0 (higher values print more info)"); - run_environment.clp.setOption("load_balance" , &load_balance , " load balance (slice/spread) input mesh file"); - - run_environment.clp.setOption("memory_multipliers_file" , &memory_multipliers_file , - " filename with 3 space-separated entries, with estimate for bytes-per-hex8 tet4 and nodes, e.g. 300 280 200"); - //" filename with a comma-separated string of class names and memory multipliers, one per line, \n eg Node,80\nField,10\nHexahedron<8>,90"); - run_environment.clp.setOption("estimate_memory_usage" , &estimate_memory_usage , - " if query_only=1, use multipliers from memory_multipliers_file to estimate memory to be used in refinements.\n If query_only=0, gather memory data and write to the file."); - -#if ALLOW_MEM_TEST - run_environment.clp.setOption("test_memory_elements" , &test_memory_elements , " give a number of elements"); - run_environment.clp.setOption("test_memory_nodes" , &test_memory_nodes , " give a number of nodes"); -#endif - run_environment.clp.setOption("proc_rank_field" , &proc_rank_field , " add an element field to show processor rank"); - run_environment.clp.setOption("remove_original_elements" , &remove_original_elements , " remove original (converted) elements (default=true)"); - run_environment.clp.setOption("input_geometry" , &input_geometry , "input geometry name"); - run_environment.clp.setOption("streaming_size" , &streaming_size , - "INTERNAL use only by python script streaming refinement interface:\n" - " run in streaming mode - this number specifies how many virtual procs the mesh is split into\n" - " i.e. we expect to see files like file.e.N.iN where N = streaming_size iN=0..N"); - run_environment.clp.setOption("streaming_rank" , &streaming_rank , - "INTERNAL use only by python script streaming refinement interface:\n" - " run in streaming mode - this number specifies which virtual proc this is."); - run_environment.clp.setOption("streaming_pass_start" , &streaming_pass_start , - "INTERNAL use only by python script streaming refinement interface:\n"); - run_environment.clp.setOption("streaming_pass_end" , &streaming_pass_end , - "INTERNAL use only by python script streaming refinement interface:\n"); - run_environment.clp.setOption("streaming_W" , &streaming_W , - "INTERNAL use only by python script streaming refinement interface:\n"); - run_environment.clp.setOption("streaming_iW" , &streaming_iW , - "INTERNAL use only by python script streaming refinement interface:\n"); - run_environment.clp.setOption("print_memory_usage" , &print_memory_usage , "print memory usage"); - - int err_clp = run_environment.processCommandLine(); - if (err_clp) return err_clp; - - int result = 0; - unsigned failed_proc_rank = 0u; - - double t0 = 0.0; - double t1 = 0.0; - double cpu0 = 0.0; - double cpu1 = 0.0; - - if (convert.length()) - checkInput("convert", convert, convert_options, run_environment); - - if (enrich.length()) - checkInput("enrich", enrich, enrich_options, run_environment); - - if (refine.length()) - checkInput("refine", refine, refine_options, run_environment); - - if (print_info) - { - doRefineMesh = false; - } - - if (help - || input_mesh.length() == 0 - || output_mesh.length() == 0 - || (convert.length() == 0 && refine.length()==0 && enrich.length()==0) - //|| not (convert == "Hex8_Tet4_24" || convert == "Quad4_Quad4_4" || convert == "Quad4_Tri3_6") - ) - { - run_environment.printHelp(); - return 1; - } - -#if defined( STK_HAS_MPI ) - MPI_Barrier( MPI_COMM_WORLD ); -#endif - - std::string input_mesh_save = input_mesh; - std::string output_mesh_save = output_mesh; - - // streaming - int m_M = 1; - int m_W = 1; - int m_iW = 0; - int m_M_0 = 0; - int m_M_1 = 0; -#if STK_ADAPT_HAVE_YAML_CPP - if (streaming_size) - { - m_M = streaming_size; - m_W = streaming_W ? streaming_W : 1; - m_iW = streaming_W ? streaming_iW : 0; - SerializeNodeRegistry::getStreamingPiece(m_M, m_W, m_iW, m_M_0, m_M_1); - } - //std::cout << "tmp srk AdaptMain: " << PERCEPT_OUT(streaming_size) << PERCEPT_OUT(streaming_W) << PERCEPT_OUT(streaming_iW) << PERCEPT_OUT(m_M) << PERCEPT_OUT(m_W) << PERCEPT_OUT(m_iW) << PERCEPT_OUT(m_M_0) << PERCEPT_OUT(m_M_1) << std::endl; -#endif - - // FIXME - starting from -1 pass is bogus -#if STK_ADAPT_HAVE_YAML_CPP - int remove_original_elements_save = remove_original_elements; - int delete_parents_save = delete_parents; - - if ((streaming_pass_start == -2 && streaming_pass_end != -2) || - (streaming_pass_start != -2 && streaming_pass_end == -2)) - { - throw std::runtime_error("must specify both streaming_pass_start and streaming_pass_end"); - } - - if (streaming_pass_start != -2 && (streaming_pass_start < -1 || streaming_pass_start > SerializeNodeRegistry::MaxPass)) - { - throw std::runtime_error("streaming_pass_start bad value"); - } - if (streaming_pass_end != -2 && (streaming_pass_end < -1 || streaming_pass_end > SerializeNodeRegistry::MaxPass)) - { - throw std::runtime_error("streaming_pass_end bad value"); - } - if (streaming_pass_end != -2 && (streaming_pass_end < streaming_pass_start)) - { - throw std::runtime_error("streaming_pass_start > streaming_pass_end"); - } - - if (streaming_pass_end != -2) - { - std::cout << "\n\nWARNING: running passes from command line: streaming_pass_start,end= [" << streaming_pass_start << ", " << streaming_pass_end << "]\n\n"; - } - - // allow for driving this from a script - if (streaming_pass_start == -2 && streaming_pass_end == -2) - { - streaming_pass_start = streaming_size ? -1 : 0; - streaming_pass_end = streaming_size ? SerializeNodeRegistry::MaxPass : 0; - } -#else - streaming_pass_start = 0; - streaming_pass_end = 0; -#endif - - bool do_normal_pass = true; - if (m_W > 1 && (m_iW == -1 || m_iW == m_W)) - { - do_normal_pass = false; - } - - if (streaming_size && s_spatialDim == 0) - { - PerceptMesh eMesh(0); - std::string mesh_name = Ioss::Utils::decode_filename(input_mesh_save, 0, m_M); - eMesh.open(mesh_name); - if (smooth_geometry == 1) eMesh.add_coordinate_state_fields(); - if (refine_to_spacing == 1) eMesh.add_spacing_fields(); - s_spatialDim = eMesh.get_spatial_dim(); - VERIFY_OP_ON(s_spatialDim, >=, 2, "AdaptMain bad spatial_dim"); - } - - for (int i_pass=streaming_pass_start; i_pass <= streaming_pass_end; i_pass++) - { - -#if STK_ADAPT_HAVE_YAML_CPP - if (streaming_size) - { - - // init pass - if (m_W > 1 && m_iW == -1) - { - PerceptMesh eMesh(3); - eMesh.openEmpty(); - SerializeNodeRegistry snr(eMesh, 0, input_mesh, output_mesh, m_M, m_M_0, m_W, m_iW, m_M_0, m_M_1); - snr.pass_init(i_pass); - VERIFY_OP_ON(streaming_pass_start, ==, streaming_pass_end, "must have one pass at a time with W > 1"); - continue; - } - - remove_original_elements = 0; - delete_parents = 0; - if (i_pass == 1) - { - remove_original_elements = remove_original_elements_save; - delete_parents = delete_parents_save; - } - } - //std::cout << "tmp srk i_pass= " << i_pass << " delete_parents= " << delete_parents << " remove_original_elements= " << remove_original_elements << std::endl; -#endif - - if (do_normal_pass) - { - if (streaming_size) - { - // special cases - - // read all files, get global parts and node info - if (i_pass == -1) - { -#if STK_ADAPT_HAVE_YAML_CPP - PerceptMesh eMesh(s_spatialDim); - eMesh.openEmpty(); - SerializeNodeRegistry snr(eMesh, 0, input_mesh, output_mesh, m_M, 0, m_W, m_iW, m_M_0, m_M_1); - snr.pass(i_pass); -#else - throw std::runtime_error("must have YAML for streaming refine"); -#endif - continue; - } - - if (i_pass == 2) - { -#if STK_ADAPT_HAVE_YAML_CPP - if (m_W == 1) - { - // no exodus files i/o - PerceptMesh eMesh(s_spatialDim); - eMesh.openEmpty(); - SerializeNodeRegistry snr(eMesh, 0, input_mesh, output_mesh, m_M, 0, m_W, m_iW, m_M_0, m_M_1); - snr.pass(i_pass); - } - -#else - throw std::runtime_error("must have YAML for streaming refine"); -#endif - continue; - } - } - - for (int m_iM = m_M_0; m_iM <= m_M_1; m_iM++) - { - if (streaming_size) - { - input_mesh = Ioss::Utils::decode_filename(input_mesh_save, m_iM, m_M); - output_mesh = Ioss::Utils::decode_filename(output_mesh_save, m_iM, m_M); - - if (i_pass == 1) - { - output_mesh = output_mesh_save+"-pass1"; - output_mesh = Ioss::Utils::decode_filename(output_mesh, m_iM, m_M); - } - } - - try { - - if (load_balance) - { - if (streaming_size) throw std::runtime_error("can't load balance and stream"); - RunEnvironment::doLoadBalance(run_environment.m_comm, input_mesh); - } - - percept::PerceptMesh eMesh(0); // FIXME - //percept::PerceptMesh eMesh; // FIXME - - if (streaming_size) - { - // special cases - if (i_pass == 3) - { -#if STK_ADAPT_HAVE_YAML_CPP - // fini - //if ((m_W > 1 && m_iW == m_W) || (m_W == 1 && m_iM == m_M_1)) - if (m_iM == m_M_1) - { - NodeRegistry *some_nr = 0; - PerceptMesh eMeshEmpty(0); - eMeshEmpty.openEmpty(); - SerializeNodeRegistry snr(eMeshEmpty, some_nr, input_mesh_save, output_mesh_save, m_M, 0, m_W, m_iW, m_M_0, m_M_1); - if (remove_geometry_blocks) snr.set_geometry_file(input_geometry); - snr.pass3_new(); - } -#else - throw std::runtime_error("must have YAML for streaming refine"); -#endif - continue; - } - } - - // ============== START ================================================================== - - if (do_normal_pass) - { - eMesh.open(input_mesh); - if (smooth_geometry == 1) eMesh.add_coordinate_state_fields(); - if (refine_to_spacing == 1) eMesh.add_spacing_fields(); - if (!sync_io_regions) eMesh.set_sync_io_regions(false); - if (!s_spatialDim) s_spatialDim = eMesh.get_spatial_dim(); - - Util::setRank(eMesh.get_rank()); - - Teuchos::RCP pattern; - - if (doRefineMesh) - { - // FIXME move this next block of code to a method on UniformRefiner - BlockNamesType block_names(stk_classic::percept::EntityRankEnd+1u); - if (block_name_inc.length()) - { - block_names = RefinerUtil::getBlockNames(block_name_inc, eMesh.get_rank(), eMesh); - if (1) - { - eMesh.commit(); - block_names = RefinerUtil::correctBlockNamesForPartPartConsistency(eMesh, block_names); - - eMesh.close(); - eMesh.open(input_mesh); - if (smooth_geometry == 1) eMesh.add_coordinate_state_fields(); - if (refine_to_spacing == 1) eMesh.add_spacing_fields(); - } - } - - pattern = UniformRefinerPatternBase::createPattern(refine, enrich, convert, eMesh, block_names); - - if (0) - { - run_environment.printHelp(); - exit(1); - } - } - - if (0) - { - std::cout << "tmp convert = " << convert << std::endl; - std::cout << "tmp refine = " << refine << std::endl; - std::cout << "tmp enrich = " << enrich << std::endl; - } - - int scalarDimension = 0; // a scalar - - stk_classic::mesh::FieldBase* proc_rank_field_ptr = 0; - if (proc_rank_field) - { - proc_rank_field_ptr = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - } - -#if STK_ADAPT_HAVE_YAML_CPP - // FIXME - this is this needed? see above - // add global parts not found in this file - if (streaming_size) - { - NodeRegistry *some_nr = 0; - SerializeNodeRegistry snr(eMesh, some_nr, input_mesh, output_mesh, m_M, m_iM, m_W, m_iW, m_M_0, m_M_1); - snr.declareGlobalParts(); - } -#endif - eMesh.commit(); - - if (print_memory_usage) - memory_dump(print_memory_usage, run_environment.m_comm, *eMesh.get_bulk_data(), 0, "after file open"); - - if (test_memory_nodes && test_memory_elements) - { - std::cout << "test_memory_elements and nodes are nonzero, will not refine exodus files." << std::endl; - - test_memory(eMesh, test_memory_elements, test_memory_nodes); - - if (print_memory_usage) - memory_dump(print_memory_usage, run_environment.m_comm, *eMesh.get_bulk_data(), 0, "after test memory"); - - if (estimate_memory_usage && !query_only) - { - MemorySizeType tot_mem = memory_dump(false, run_environment.m_comm, *eMesh.get_bulk_data(), 0, "after test memory"); - - //std::cout << "MemEst: num_nodes= " << test_memory_nodes << " num_tet4=0 hum_hex8= " << test_memory_elements << " memory= " << MegaByte(tot_mem) << std::endl; - //MemoryMultipliers::process_estimate(tot_mem, eMesh, breaker.getRefinementInfoByType(), memory_multipliers_file); - MemoryMultipliers memMults; - if (memory_multipliers_file.size()) - memMults.read_simple(memory_multipliers_file); - memMults.num_hex8=test_memory_elements; - memMults.num_nodes=test_memory_nodes; - MemorySizeType estMem = memMults.estimate_memory(); - // std::cout << "MemEst: num_nodes= " << memMults.num_nodes << " num_tet4= " << memMults.num_tet4 << " num_hex8= " << memMults.num_hex8 << " memory= " << MegaByte(tot_mem) - // << " estMem= " << MegaByte(estMem) << std::endl; - std::cout << "MemEst: num_nodes= " << memMults.num_nodes << " num_tet4= " << memMults.num_tet4 << " num_hex8= " << memMults.num_hex8 << " memory[MB]= " << MegaByte(tot_mem) - << " estMem[MB]= " << MegaByte(estMem) - << " mult_hex8= " << memMults.mult_hex8 << " mult_tet4= " << memMults.mult_tet4 << " mult_nodes=" << memMults.mult_nodes << std::endl; - std::cout << "(*MemEstMM: " << input_mesh << " *) ,{" << memMults.num_nodes << ", " << memMults.num_tet4 << "," << memMults.num_hex8 << "," << MegaByte(tot_mem) - << ", " << MegaByte(estMem) << "}" << std::endl; - - } - if (estimate_memory_usage && query_only) - { - //MemoryMultipliers::process_estimate(0, eMesh, breaker.getRefinementInfoByType(), memory_multipliers_file, input_mesh); - } - - return 0; - } - - // FIXME - if (0) - { - eMesh.save_as("outtmp.e"); - exit(1); - } - - if (print_info) - { - eMesh.print_info("convert", print_info); - } - - // FIXME - if (0) - { - eMesh.print_info("before convert", 2); - exit(1); - } - - if (doRefineMesh) - { - t0 = stk_classic::wall_time(); - cpu0 = stk_classic::cpu_time(); - - UniformRefiner breaker(eMesh, *pattern, proc_rank_field_ptr); - - ProgressMeter pm(breaker); - //pm.setActive(true); - - //std::cout << "P[" << p_rank << ", " << p_size << "] input_geometry = " << input_geometry << std::endl; - - if (input_geometry != "") - { - breaker.setGeometryFile(input_geometry); - breaker.setSmoothGeometry(smooth_geometry == 1); - //breaker.setRemoveGeometryBlocks(remove_geometry_blocks == 1); - } - breaker.setRemoveOldElements(remove_original_elements); - breaker.setQueryPassOnly(query_only == 1); - breaker.setDoProgressMeter(progress_meter == 1 && 0 == p_rank); - //breaker.setIgnoreSideSets(true); - - - for (int iBreak = 0; iBreak < number_refines; iBreak++) - { - if (!eMesh.get_rank()) - { - std::cout << "Refinement pass # " << (iBreak+1) << " start..." << std::endl; - } - //breaker.setPassNumber(iBreak); - breaker.doBreak(); - //RefinementInfoByType::countCurrentNodes(eMesh, breaker.getRefinementInfoByType()); - if (!eMesh.get_rank()) - { - std::cout << std::endl; - int ib = iBreak; - if (!query_only) ib = 0; - RefinementInfoByType::printTable(std::cout, breaker.getRefinementInfoByType(), ib , true); - std::cout << std::endl; - } - if (print_memory_usage) - { - memory_dump(print_memory_usage, run_environment.m_comm, *eMesh.get_bulk_data(), &breaker.getNodeRegistry(), - std::string("after refine pass: ")+toString(iBreak)); - } - - if (estimate_memory_usage && !query_only) - { - MemorySizeType tot_mem = memory_dump(false, run_environment.m_comm, *eMesh.get_bulk_data(), &breaker.getNodeRegistry(), - std::string("after refine pass: ")+toString(iBreak)); - std::cout << "P[" << p_rank << "] tmp srk tot_mem= " << MegaByte(tot_mem) << std::endl; - MemoryMultipliers::process_estimate(tot_mem, eMesh, breaker.getRefinementInfoByType(), memory_multipliers_file, input_mesh); - } - if (estimate_memory_usage && query_only) - { - RefinementInfoByType::estimateNew(breaker.getRefinementInfoByType(), iBreak); - MemoryMultipliers::process_estimate(0, eMesh, breaker.getRefinementInfoByType(), memory_multipliers_file, input_mesh); - } - - } // iBreak - - if (number_refines == 0 && input_geometry != "" && smooth_geometry == 1) - { - breaker.setSmoothGeometry(true); - breaker.snapAndSmooth(false, input_geometry); - } - - - if (streaming_size) - { -#if STK_ADAPT_HAVE_YAML_CPP - { - SerializeNodeRegistry snr(eMesh, &breaker.getNodeRegistry(), input_mesh, output_mesh, m_M, m_iM, m_W, m_iW, m_M_0, m_M_1); - snr.pass(i_pass); - } - - if (i_pass == 0) - { - NodeRegistry *some_nr = 0; - SerializeNodeRegistry snr(eMesh, some_nr, input_mesh, output_mesh, m_M, m_iM, m_W, m_iW, m_M_0, m_M_1); - snr.getGlobalPartMap(); - snr.passM1_mergeGlobalParts(); - snr.setGlobalPartMap(); - } -#else - throw std::runtime_error("must have YAML for streaming refine"); -#endif - } - - if (delete_parents) - breaker.deleteParentElements(); - - t1 = stk_classic::wall_time(); - cpu1 = stk_classic::cpu_time(); - - stk_classic::percept::pout() << "P[" << p_rank << "] AdaptMain:: saving mesh... \n"; - std::cout << "P[" << p_rank << "] AdaptMain:: saving mesh... " << std::endl; - if (streaming_size) eMesh.setStreamingSize(m_M); - if (remove_geometry_blocks) eMesh.remove_geometry_blocks_on_output(input_geometry); - eMesh.save_as(output_mesh); - stk_classic::percept::pout() << "P[" << p_rank << "] AdaptMain:: ... mesh saved\n"; - std::cout << "P[" << p_rank << "] AdaptMain:: mesh saved" << std::endl; - - if (print_memory_usage) - memory_dump(print_memory_usage, run_environment.m_comm, *eMesh.get_bulk_data(), &breaker.getNodeRegistry(), "after final save mesh"); - - } // doRefineMesh - } // do_normal_pass - -#if 0 - for (int itime=0; itime < 10; itime++) - { - std::cout << "tmp timer[" << itime << "]= " << s_timers[itime] << " " << s_timers[itime]/s_timers[3]*100 << " %" << std::endl; - } -#endif - - } - catch ( const std::exception * X ) { - std::cout << "AdaptMain:: unexpected exception POINTER: " << X->what() << std::endl; - failed_proc_rank = p_rank+1u; - } - catch ( const std::exception & X ) { - std::cout << "AdaptMain:: unexpected exception: " << X.what() << std::endl; - failed_proc_rank = p_rank+1u; - } - catch( ... ) { - std::cout << "AdaptMain:: ... exception" << std::endl; - failed_proc_rank = p_rank+1u; - } - - stk_classic::all_reduce( run_environment.m_comm, stk_classic::ReduceSum<1>( &failed_proc_rank ) ); - if (failed_proc_rank) - { - stk_classic::percept::pout() << "P[" << p_rank << "] exception found on processor " << (failed_proc_rank-1) << "\n"; - exit(1); - } - - stk_classic::percept::pout() << "P[" << p_rank << ", " << p_size << "] wall clock time on processor [" << p_rank << ", " << p_size << "]= " << (t1-t0) << " (sec) " - << " cpu time= " << (cpu1 - cpu0) << " (sec)\n"; - std::cout << "P[" << p_rank << ", " << p_size << "] wall clock time on processor [" << p_rank << ", " << p_size << "]= " << (t1-t0) << " (sec) " - << " cpu time= " << (cpu1 - cpu0) << " (sec) " << std::endl; - - double cpuMax = (cpu1-cpu0); - double wallMax = (t1-t0); - double cpuSum = (cpu1-cpu0); - - stk_classic::all_reduce( run_environment.m_comm, stk_classic::ReduceSum<1>( &cpuSum ) ); - stk_classic::all_reduce( run_environment.m_comm, stk_classic::ReduceMax<1>( &cpuMax ) ); - stk_classic::all_reduce( run_environment.m_comm, stk_classic::ReduceMax<1>( &wallMax ) ); - - if (0 == p_rank) - { - stk_classic::percept::pout() << "P[" << p_rank << ", " << p_size << "] max wall clock time = " << wallMax << " (sec)\n"; - stk_classic::percept::pout() << "P[" << p_rank << ", " << p_size << "] max cpu clock time = " << cpuMax << " (sec)\n"; - stk_classic::percept::pout() << "P[" << p_rank << ", " << p_size << "] sum cpu clock time = " << cpuSum << " (sec)\n"; - std::cout << "P[" << p_rank << ", " << p_size << "] max wall clock time = " << wallMax << " (sec)" << std::endl; - std::cout << "P[" << p_rank << ", " << p_size << "] max cpu clock time = " << cpuMax << " (sec)" << std::endl; - std::cout << "P[" << p_rank << ", " << p_size << "] sum cpu clock time = " << cpuSum << " (sec)" << std::endl; - } - } // m_iM - - } // do_normal_pass - -#if STK_ADAPT_HAVE_YAML_CPP - // fini pass - if (m_W > 1 && m_iW == m_W) - { - VERIFY_OP_ON(s_spatialDim, >=, 2, "AdaptMain bad spatial_dim"); - PerceptMesh eMesh(s_spatialDim); - eMesh.openEmpty(); - SerializeNodeRegistry snr(eMesh, 0, input_mesh, output_mesh, m_M, 0, m_W, m_iW, m_M_0, m_M_1); - snr.pass_final(i_pass); - } -#endif - - } // i_pass - - return result; - } - - } -} - -//#include "pyencore.h" -//#if !PY_PERCEPT -int main(int argc, char **argv) { - - int res=0; - res = stk_classic::adapt::adapt_main(argc, argv); - stk_classic::adapt::ParallelMachineFinalize pm(true); - return res; -} -//#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/stk_adapt/main/CMakeLists.txt deleted file mode 100644 index 7477af22615d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ - -INCLUDE(TribitsLibraryMacros) - -#SET(HEADERS "") -#SET(SOURCES "") - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - - -#SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk_util/stk_util/unit_test_support/) -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk_percept/) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) - - -INCLUDE(TribitsAddExecutableAndTest) - -INCLUDE_DIRECTORIES( .. ) - -IF( ${PACKAGE_NAME}_ENABLE_BoostLib ) - TRIBITS_ADD_EXECUTABLE( - adapt_exe_1 - HEADERS ${HEADERS} - SOURCES AdaptMain.cpp - COMM serial mpi - ) -ENDIF() diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/memory-multipliers.dat b/packages/stk/stk_classic/stk_adapt/stk_adapt/main/memory-multipliers.dat deleted file mode 100644 index 617a8d483230..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/main/memory-multipliers.dat +++ /dev/null @@ -1,20 +0,0 @@ -343 300 328 -# mult_hex8 mult_tet4 mult_nodes (just an example for now, this format will change) - - - -# name= bytes per entity -Node= 100 -ParallelSize= 1 -NodesPerProcessor= 0 -Field= 10 -Part= 10 -Relation= 1 -Hexahedron<8>= 80 -Tetrahedron<4>= 60 - - - -Id=run on 3/6/11,Node=100000,Hexahedron<8>=100000,Field=10,NodesPerProcessor=10000,Memory=10000000 -Id=run on 3/8/11,Node=200000,Hexahedron<8>=100000,Field=10,NodesPerProcessor=10000,Memory=10000000 -Id=run on 3/9/11,Node=300000,Hexahedron<8>=100000,Field=10,NodesPerProcessor=10000,Memory=10000000 diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CMakeLists.txt deleted file mode 100644 index db930be2d249..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_adapt/sierra_element/) - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.cpp deleted file mode 100644 index d2c423105ac1..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* shards : Shared Discretization Tools */ -/* Copyright (2008, 2011) Sandia Corporation */ -/* */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* */ -/* This library is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as */ -/* published by the Free Software Foundation; either version 2.1 of the */ -/* License, or (at your option) any later version. */ -/* */ -/* This library is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ -/* Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public */ -/* License along with this library; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ -/* USA */ -/* Questions? Contact Pavel Bochev (pbboche@sandia.gov) */ -/* H. Carter Edwards (hcedwar@sandia.gov) */ -/* Denis Ridzal (dridzal@sandia.gov). */ -/*------------------------------------------------------------------------*/ - -//#define HAVE_SHARDS_DEBUG - -#include -#include -#include - -#include - -//#include -//#include - -//#include -#include - -using namespace shards; - -namespace stk_classic { namespace adapt { - namespace Elem { - - namespace { - - //srk typedef std::map > CellTopologyNameMap; - typedef std::map CellTopologyNameMap; - typedef std::map CellTopologyIdMap; - typedef std::map IdCellTopologyMap; - - CellTopologyNameMap & - get_cell_topology_name_map() - { - static CellTopologyNameMap s_cellTopologyMap; - - if (s_cellTopologyMap.empty()) { - s_cellTopologyMap[getCellTopology().getName()] = getCellTopology(); - s_cellTopologyMap[getCellTopology().getName()] = getCellTopology(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - // s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - s_cellTopologyMap[getCellTopology >().getName()] = getCellTopology >(); - } - - return s_cellTopologyMap; - } - - - CellTopologyIdMap & - get_cell_topology_id_map() - { - static CellTopologyIdMap s_cellTopologyMap; - - if (s_cellTopologyMap.empty()) { - s_cellTopologyMap[NODE_0] = getCellTopology(); - s_cellTopologyMap[PARTICLE_1] = getCellTopology(); - s_cellTopologyMap[EDGE_2] = getCellTopology >(); - s_cellTopologyMap[EDGE_3] = getCellTopology >(); - s_cellTopologyMap[SHELL_LINE_2] = getCellTopology >(); - s_cellTopologyMap[SHELL_LINE_3] = getCellTopology >(); - s_cellTopologyMap[ROD_2] = getCellTopology >(); - s_cellTopologyMap[ROD_3] = getCellTopology >(); - s_cellTopologyMap[FACE_TRI_3] = getCellTopology >(); - s_cellTopologyMap[FACE_TRI_4] = getCellTopology >(); - s_cellTopologyMap[FACE_TRI_6] = getCellTopology >(); - s_cellTopologyMap[SHELL_TRI_3] = getCellTopology >(); - // s_cellTopologyMap[SHELL_TRI_4] = getCellTopology >(); - s_cellTopologyMap[SHELL_TRI_6] = getCellTopology >(); - s_cellTopologyMap[FACE_QUAD_4] = getCellTopology >(); - s_cellTopologyMap[FACE_QUAD_8] = getCellTopology >(); - s_cellTopologyMap[FACE_QUAD_9] = getCellTopology >(); - s_cellTopologyMap[SHELL_QUAD_4] = getCellTopology >(); - s_cellTopologyMap[SHELL_QUAD_8] = getCellTopology >(); - s_cellTopologyMap[SHELL_QUAD_9] = getCellTopology >(); - s_cellTopologyMap[SOLID_TET_4] = getCellTopology >(); - s_cellTopologyMap[SOLID_TET_8] = getCellTopology >(); - s_cellTopologyMap[SOLID_TET_10] = getCellTopology >(); - s_cellTopologyMap[SOLID_HEX_8] = getCellTopology >(); - s_cellTopologyMap[SOLID_HEX_20] = getCellTopology >(); - s_cellTopologyMap[SOLID_HEX_27] = getCellTopology >(); - s_cellTopologyMap[SOLID_PYRAMID_5] = getCellTopology >(); - s_cellTopologyMap[SOLID_PYRAMID_13] = getCellTopology >(); - s_cellTopologyMap[SOLID_PYRAMID_14] = getCellTopology >(); - s_cellTopologyMap[SOLID_WEDGE_6] = getCellTopology >(); - s_cellTopologyMap[SOLID_WEDGE_15] = getCellTopology >(); - s_cellTopologyMap[SOLID_WEDGE_18] = getCellTopology >(); - s_cellTopologyMap[FACE_PENT_5] = getCellTopology >(); - s_cellTopologyMap[FACE_HEX_6] = getCellTopology >(); - } - - return s_cellTopologyMap; - } - - - IdCellTopologyMap & - get_id_cell_topology_map() - { - static IdCellTopologyMap s_cellTopologyMap; - - if (s_cellTopologyMap.empty()) { - s_cellTopologyMap[getCellTopology()] = NODE_0; - s_cellTopologyMap[getCellTopology()] = PARTICLE_1; - s_cellTopologyMap[getCellTopology >()] = EDGE_2; - s_cellTopologyMap[getCellTopology >()] = EDGE_3; - s_cellTopologyMap[getCellTopology >()] = SHELL_LINE_2; - s_cellTopologyMap[getCellTopology >()] = SHELL_LINE_3; - s_cellTopologyMap[getCellTopology >()] = ROD_2; - s_cellTopologyMap[getCellTopology >()] = ROD_3; - s_cellTopologyMap[getCellTopology >()] = FACE_TRI_3; - s_cellTopologyMap[getCellTopology >()] = FACE_TRI_4; - s_cellTopologyMap[getCellTopology >()] = FACE_TRI_6; - s_cellTopologyMap[getCellTopology >()] = SHELL_TRI_3; - // s_cellTopologyMap[getCellTopology >()] = SHELL_TRI_4; - s_cellTopologyMap[getCellTopology >()] = SHELL_TRI_6; - s_cellTopologyMap[getCellTopology >()] = FACE_QUAD_4; - s_cellTopologyMap[getCellTopology >()] = FACE_QUAD_8; - s_cellTopologyMap[getCellTopology >()] = FACE_QUAD_9; - s_cellTopologyMap[getCellTopology >()] = SHELL_QUAD_4; - s_cellTopologyMap[getCellTopology >()] = SHELL_QUAD_8; - s_cellTopologyMap[getCellTopology >()] = SHELL_QUAD_9; - s_cellTopologyMap[getCellTopology >()] = SOLID_TET_4; - s_cellTopologyMap[getCellTopology >()] = SOLID_TET_8; - s_cellTopologyMap[getCellTopology >()] = SOLID_TET_10; - s_cellTopologyMap[getCellTopology >()] = SOLID_HEX_8; - s_cellTopologyMap[getCellTopology >()] = SOLID_HEX_20; - s_cellTopologyMap[getCellTopology >()] = SOLID_HEX_27; - s_cellTopologyMap[getCellTopology >()] = SOLID_PYRAMID_5; - s_cellTopologyMap[getCellTopology >()] = SOLID_PYRAMID_13; - s_cellTopologyMap[getCellTopology >()] = SOLID_PYRAMID_14; - s_cellTopologyMap[getCellTopology >()] = SOLID_WEDGE_6; - s_cellTopologyMap[getCellTopology >()] = SOLID_WEDGE_15; - s_cellTopologyMap[getCellTopology >()] = SOLID_WEDGE_18; - s_cellTopologyMap[getCellTopology >()] = FACE_PENT_5; - s_cellTopologyMap[getCellTopology >()] = FACE_HEX_6; - } - - return s_cellTopologyMap; - } - - } // namespace - - - CellTopology - getBasicCellTopology( - const char * name) - { - CellTopologyNameMap &cell_topology_map = get_cell_topology_name_map(); - - CellTopologyNameMap::const_iterator it = cell_topology_map.find(name); - - if (it == cell_topology_map.end()) - { - //throw RuntimeError() << "Cell topology " << name << " is not defined"; - std::ostringstream msg; - msg << "Cell topology " << name << " is not defined"; - throw std::runtime_error(msg.str()); - } - - return (*it).second; - } - - - CellTopology - getBasicCellTopology( - TopologyId id) - { - if (id == INVALID) - return CellTopology(); - - CellTopologyIdMap &cell_topology_map = get_cell_topology_id_map(); - - CellTopologyIdMap::const_iterator it = cell_topology_map.find(id); - - if (it == cell_topology_map.end()) - { - //throw RuntimeError() << "Cell topology " << id << " is not defined"; - std::ostringstream msg; - msg << "Cell topology " << id << " is not defined"; - throw std::runtime_error(msg.str()); - } - - return (*it).second; - } - - - TopologyId - getCellTopologyId( - const CellTopology & cell_topology) - { - if (cell_topology.getCellTopologyData() == 0) - return INVALID; - - IdCellTopologyMap &cell_topology_map = get_id_cell_topology_map(); - - IdCellTopologyMap::const_iterator it = cell_topology_map.find(cell_topology); - - if (it == cell_topology_map.end()) - { - //throw RuntimeError() << "Cell topology " << cell_topology.getName() << " is not defined"; - std::ostringstream msg; - msg << "Cell topology " << cell_topology.getName() << " is not defined"; - throw std::runtime_error(msg.str()); - - } - - return (*it).second; - } - - - Elem::CellTopology - edgeCellTopology( - const Elem::CellTopology & cell_topology, - UInt ordinal) - { - if (ordinal >= cell_topology.getEdgeCount()) - return NULL; - - return cell_topology.getCellTopologyData(1, ordinal); - } - - - Elem::CellTopology - faceCellTopology( - const Elem::CellTopology & cell_topology, - UInt ordinal) - { - if (ordinal >= cell_topology.getFaceCount()) - return NULL; - - return cell_topology.getCellTopologyData(2, ordinal); - } - - - /** Query 2D edge or 3D face topologies. */ - Elem::CellTopology - sideCellTopology( - const Elem::CellTopology & cell_topology, - UInt ordinal) - { - return cell_topology.getDimension() == 3 ? faceCellTopology(cell_topology, ordinal) : edgeCellTopology(cell_topology, ordinal); - } - - - bool isElement(const Elem::CellTopology &cell_topology, unsigned spatial_dimension) { - bool is_element = isShellElement(cell_topology) - || isRodElement(cell_topology) || isParticleElement(cell_topology) - || cell_topology.getDimension() == spatial_dimension; // isSolidElement(cell_topology, spatial_dimension); - - return is_element; - } - - - bool isSolidElement(const Elem::CellTopology &cell_topology, unsigned spatial_dimension) { - bool is_solid = cell_topology.getDimension() == spatial_dimension - && !isShellElement(cell_topology) && !isRodElement(cell_topology) && !isParticleElement(cell_topology); - - return is_solid; - } - - - bool isShellElement(const Elem::CellTopology &cell_topology) { - return cell_topology.getSideCount() == 2; - } - - - bool isRodElement(const Elem::CellTopology &cell_topology) { - bool is_rod = cell_topology.getDimension() == 2 - && cell_topology.getSideCount() == 1; - - return is_rod; - } - - - bool isParticleElement(const Elem::CellTopology &cell_topology) { - bool is_particle = cell_topology.getDimension() == 1 - && cell_topology.getNodeCount() == 1; - - return is_particle; - } - - - const unsigned * - getNodesOfEdge( - const Elem::CellTopology & cell_topology, - unsigned edge) - { - if (edge >= cell_topology.getEdgeCount()) - return NULL; - - // Get the topology to test the bounds of subcell_dim and subcell_ord. - cell_topology.getCellTopologyData(1, edge); - return cell_topology.getCellTopologyData()->subcell[1][edge].node; - } - - - const unsigned * - getNodesOfFace( - const Elem::CellTopology & cell_topology, - unsigned face) - { - if (face >= cell_topology.getFaceCount()) - return NULL; - - // Get the topology to test the bounds of subcell_dim and subcell_ord. - cell_topology.getCellTopologyData(2, face); - return cell_topology.getCellTopologyData()->subcell[2][face].node; - } - - - const unsigned * - getNodesOfSide( - const Elem::CellTopology & cell_topology, - unsigned side) - { - return cell_topology.getDimension() == 3 ? getNodesOfFace(cell_topology, side) : getNodesOfEdge(cell_topology, side); - } - - - int - getEdgeNode( - const Elem::CellTopology & cell_topology, - unsigned edge, - unsigned node_of_edge) - { - return cell_topology.getNodeMap(1, edge, node_of_edge); - } - - - int - getFaceNode( - const Elem::CellTopology & cell_topology, - unsigned face, - unsigned node_of_face) - { - return cell_topology.getNodeMap(2, face, node_of_face); - } - - - int - getSideNode( - const Elem::CellTopology & cell_topology, - unsigned side, - unsigned node_of_side) - { - return cell_topology.getDimension() == 3 ? getFaceNode(cell_topology, side, node_of_side) : getEdgeNode(cell_topology, side, node_of_side); - } - - - int - getFaceEdge( - const Elem::CellTopology & cell_topology, - unsigned face, - unsigned edge_of_face) - { - return ::mapCellFaceEdge(cell_topology.getBaseCellTopologyData(), face, edge_of_face); - } - - - Elem::CellTopology - nodeCellTopology( - const Elem::CellTopology & cell_topology, - UInt ordinal) - { - return (ordinal < cell_topology.getNodeCount()) ? cell_topology.getCellTopologyData(0, ordinal) : NULL; - } - - - bool - isCellTopologySubsetOf( - const Elem::CellTopology & cell_topology, - const Elem::CellTopology & richer) - { - bool result = false; - UInt i, j; - - if (0 < cell_topology.getVertexCount()) { - result = - cell_topology.getDimension() == richer.getDimension() && - cell_topology.getVertexCount() == richer.getVertexCount() && - cell_topology.getEdgeCount() == richer.getEdgeCount() && - cell_topology.getFaceCount() == richer.getFaceCount() && - cell_topology.getNodeCount() <= richer.getNodeCount(); - - for (i = 0; result && i < cell_topology.getEdgeCount(); ++i) { - result = isCellTopologySubsetOf(edgeCellTopology(cell_topology, i), edgeCellTopology(richer, i)); - - for (j = 0; result && j < edgeCellTopology(cell_topology, i).getNodeCount(); ++j) - result = getEdgeNode(cell_topology, i, j) == getEdgeNode(richer, i, j); - } - - for (i = 0; i < cell_topology.getFaceCount() && result; ++i) { - result = isCellTopologySubsetOf(faceCellTopology(cell_topology, i), faceCellTopology(richer, i)); - - for (j = 0; result && j < faceCellTopology(cell_topology, i).getNodeCount(); ++j) - result = getFaceNode(cell_topology, i, j) == getFaceNode(richer, i, j); - } - } - - return result; - } - - - unsigned - getParametricDimension( - const Elem::CellTopology & cell_topology) - { - unsigned parametric_dimension = cell_topology.getDimension(); - if (isShellElement(cell_topology) || isRodElement(cell_topology) || isParticleElement(cell_topology)) - --parametric_dimension; - - return parametric_dimension; - } - - int - findReversePermutation( - const CellTopologyData & top, - int permutation_ord) - { - const int nv = top.vertex_count ; - const int np = top.permutation_count ; - const unsigned * const perm_node = top.permutation[permutation_ord].node ; - int p = 0 ; - for ( ; p < np ; ++p ) { - const unsigned * const reverse_perm_node = top.permutation[p].node ; - int j = 0 ; - for ( ; j < nv && reverse_perm_node[j] == perm_node[nv - 1 - j] ; ++j ) - ; - if ( nv == j ) - break ; - } - return p ; - } - - } // namespace Elem -} // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.hpp deleted file mode 100644 index f3d4a6bc78f2..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/CellTopology.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef stk_adapt_sierra_element_CellTopology_hpp -#define stk_adapt_sierra_element_CellTopology_hpp - -//#include - -#include - -#include - -namespace stk_classic { - namespace adapt { - namespace Elem { - - enum TopologyId { - INVALID = 0, - NODE_0, - - EDGE_2, - EDGE_3, - - FACE_TRI_3, - FACE_TRI_4, - FACE_TRI_6, - FACE_QUAD_4, - FACE_QUAD_5, - FACE_QUAD_8, - FACE_QUAD_9, - - PARTICLE_1, - ROD_2, - ROD_3, - SHELL_LINE_2, - SHELL_LINE_3, - SHELL_TRI_3, - // SHELL_TRI_4, - SHELL_TRI_6, - SHELL_QUAD_4, - SHELL_QUAD_9, - - SOLID_HEX_8, - SOLID_HEX_20, - SOLID_HEX_27, - SOLID_TET_4, - SOLID_TET_8, - SOLID_TET_10, - SOLID_WEDGE_6, - SOLID_WEDGE_15, - SOLID_PYRAMID_5, - SOLID_PYRAMID_13, - - SHELL_QUAD_8, - SOLID_WEDGE_18, - SOLID_PYRAMID_14, - - FACE_PENT_5, - FACE_HEX_6 - }; - - //using namespace shards; - - typedef shards::CellTopology CellTopology; - - template - CellTopology getCellTopology() { - return CellTopology(shards::getCellTopologyData()); - } - - TopologyId getCellTopologyId(const CellTopology &cell_topology); - - CellTopology getBasicCellTopology(TopologyId id); - CellTopology getBasicCellTopology(const char *name); - - CellTopology nodeCellTopology(const CellTopology &cell_topology, UInt ordinal); - CellTopology edgeCellTopology(const CellTopology &cell_topology, UInt ordinal); - CellTopology faceCellTopology(const CellTopology &cell_topology, UInt ordinal); - CellTopology sideCellTopology(const CellTopology &cell_topology, UInt ordinal); - - bool isElement(const CellTopology &cell_topology, unsigned spatial_dimension); - bool isSolidElement(const CellTopology &cell_topology, unsigned spatial_dimension); - bool isShellElement(const CellTopology &cell_topology); - bool isRodElement(const CellTopology &cell_topology); - bool isParticleElement(const CellTopology &cell_topology); - - int getEdgeNode(const CellTopology &cell_topology, unsigned edge, unsigned node_of_edge); - int getFaceNode(const CellTopology &cell_topology, unsigned face, unsigned node_of_face); - int getSideNode(const CellTopology &cell_topology, unsigned side, unsigned node_of_side); - int getFaceEdge(const CellTopology &cell_topology, unsigned face, unsigned edge_of_face); - - const unsigned *getNodesOfEdge(const CellTopology &cell_topology, unsigned edge); - const unsigned *getNodesOfFace(const CellTopology &cell_topology, unsigned face); - const unsigned *getNodesOfSide(const CellTopology &cell_topology, unsigned side); - - bool isCellTopologySubsetOf(const CellTopology &cell_topology, const CellTopology &richer); - - unsigned getParametricDimension(const CellTopology &cell_topology) ; - - int findReversePermutation(const CellTopologyData &top, int permutation_ord); - - } // namespace Elem - } // namespace adapt -} // namespace stk_classic - -// namespace shards { - -// inline bool operator<(const CellTopology &c1, const CellTopology &c2) { -// return c1.getTopology() < c2.getTopology(); -// } - -// inline bool operator==(const CellTopology &c1, const CellTopology &c2) { -// return c1.getTopology() == c2.getTopology(); -// } - -// inline bool operator!=(const CellTopology &c1, const CellTopology &c2) { -// return !(c1 == c2); -// } - -// } // namespace shards - -#endif // stk_adapt_sierra_element_CellTopology_hpp - diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/GeneratedRefinementTable.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/GeneratedRefinementTable.hpp deleted file mode 100644 index 0b6dffc53e83..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/GeneratedRefinementTable.hpp +++ /dev/null @@ -1,649 +0,0 @@ -#ifndef STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP -#define STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP -/** New ref topo info - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - * - * struct RefinementTopologyExtraEntry - * { - * unsigned ordinal_of_node; // ordinal of node in the total list of nodes - corresponds to the shards node ordinal - * unsigned rank_of_subcell; // rank of the subcell this node is associated with - * unsigned ordinal_of_subcell; // ordinal of the subcell in the shards numbering (e.g. edge # 3) - * unsigned ordinal_of_node_on_subcell; // ordinal of the node on the subcell (whcih node it is on a subcell that has multiple nodes) - * unsigned num_nodes_on_subcell; // how many nodes exist on the subcell - * double parametric_coordinates[3]; - * }; - * - * Bootstrapping this file: to create this file, run the regression test RegressionTestUniformRefiner.cpp :: generate_tables after putting in - * a dummy entry in ./sierra_element/GeneratedRefinementTable.hpp. The run will produce a local file, generated_refinement_tables.hpp - * which can be checked against the gold copy of GeneratedRefinementTable.hpp, then copied over it. Add a call below to generate the - * actual new table data. - */ - - -template<> RefTopoX RefinementTopologyExtra< shards:: Line<2> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 0, 1, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Beam<2> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 0, 1, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellLine<2> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 0, 1, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellLine<3> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 2, 3, {0, 0, 0} }, - { 3, 1, 0, 0, 3, {-0.5, 0, 0} }, - { 4, 1, 0, 1, 3, {0.5, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<4> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 0, 1, {0, -1, 0} }, - { 5, 1, 1, 0, 1, {1, 0, 0} }, - { 6, 1, 2, 0, 1, {0, 1, 0} }, - { 7, 1, 3, 0, 1, {-1, 0, 0} }, - { 8, 2, 0, 0, 1, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Triangle<3> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 1, 0, 0, 1, {0.5, 0, 0} }, - { 4, 1, 1, 0, 1, {0.5, 0.5, 0} }, - { 5, 1, 2, 0, 1, {0, 0.5, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellTriangle<3> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 1, 0, 0, 1, {0.5, 0, 0} }, - { 4, 1, 1, 0, 1, {0.5, 0.5, 0} }, - { 5, 1, 2, 0, 1, {0, 0.5, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellTriangle<6> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 1, 0, 2, 3, {0.5, 0, 0} }, - { 4, 1, 1, 2, 3, {0.5, 0.5, 0} }, - { 5, 1, 2, 2, 3, {0, 0.5, 0} }, - { 6, 1, 0, 0, 3, {0.25, 0, 0} }, - { 7, 1, 0, 1, 3, {0.75, 0, 0} }, - { 8, 1, 1, 0, 3, {0.75, 0.25, 0} }, - { 9, 1, 1, 1, 3, {0.25, 0.75, 0} }, - { 10, 1, 2, 0, 3, {0, 0.75, 0} }, - { 11, 1, 2, 1, 3, {0, 0.25, 0} }, - { 12, 2, 0, 0, 3, {0.25, 0.25, 0} }, - { 13, 2, 0, 1, 3, {0.5, 0.25, 0} }, - { 14, 2, 0, 2, 3, {0.25, 0.5, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellQuadrilateral<4> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 0, 1, {0, -1, 0} }, - { 5, 1, 1, 0, 1, {1, 0, 0} }, - { 6, 1, 2, 0, 1, {0, 1, 0} }, - { 7, 1, 3, 0, 1, {-1, 0, 0} }, - { 8, 2, 0, 0, 1, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: ShellQuadrilateral<8> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 2, 3, {0, -1, 0} }, - { 5, 1, 1, 2, 3, {1, 0, 0} }, - { 6, 1, 2, 2, 3, {0, 1, 0} }, - { 7, 1, 3, 2, 3, {-1, 0, 0} }, - { 8, 2, 0, 8, 9, {0, 0, 0} }, - { 9, 1, 0, 0, 3, {-0.5, -1, 0} }, - { 10, 1, 0, 1, 3, {0.5, -1, 0} }, - { 11, 1, 1, 0, 3, {1, -0.5, 0} }, - { 12, 1, 1, 1, 3, {1, 0.5, 0} }, - { 13, 1, 2, 0, 3, {0.5, 1, 0} }, - { 14, 1, 2, 1, 3, {-0.5, 1, 0} }, - { 15, 1, 3, 0, 3, {-1, 0.5, 0} }, - { 16, 1, 3, 1, 3, {-1, -0.5, 0} }, - { 17, 2, 0, 4, 9, {0, -0.5, 0} }, - { 18, 2, 0, 5, 9, {0.5, 0, 0} }, - { 19, 2, 0, 6, 9, {0, 0.5, 0} }, - { 20, 2, 0, 7, 9, {-0.5, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Tetrahedron<4> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 0, 3, 0, 1, {0, 0, 1} }, - { 4, 1, 0, 0, 1, {0.5, 0, 0} }, - { 5, 1, 1, 0, 1, {0.5, 0.5, 0} }, - { 6, 1, 2, 0, 1, {0, 0.5, 0} }, - { 7, 1, 3, 0, 1, {0, 0, 0.5} }, - { 8, 1, 4, 0, 1, {0.5, 0, 0.5} }, - { 9, 1, 5, 0, 1, {0, 0.5, 0.5} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<8> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, -1} }, - { 1, 0, 1, 0, 1, {1, -1, -1} }, - { 2, 0, 2, 0, 1, {1, 1, -1} }, - { 3, 0, 3, 0, 1, {-1, 1, -1} }, - { 4, 0, 4, 0, 1, {-1, -1, 1} }, - { 5, 0, 5, 0, 1, {1, -1, 1} }, - { 6, 0, 6, 0, 1, {1, 1, 1} }, - { 7, 0, 7, 0, 1, {-1, 1, 1} }, - { 8, 1, 0, 0, 1, {0, -1, -1} }, - { 9, 1, 1, 0, 1, {1, 0, -1} }, - { 10, 1, 2, 0, 1, {0, 1, -1} }, - { 11, 1, 3, 0, 1, {-1, 0, -1} }, - { 12, 1, 8, 0, 1, {-1, -1, 0} }, - { 13, 1, 9, 0, 1, {1, -1, 0} }, - { 14, 1, 10, 0, 1, {1, 1, 0} }, - { 15, 1, 11, 0, 1, {-1, 1, 0} }, - { 16, 1, 4, 0, 1, {0, -1, 1} }, - { 17, 1, 5, 0, 1, {1, 0, 1} }, - { 18, 1, 6, 0, 1, {0, 1, 1} }, - { 19, 1, 7, 0, 1, {-1, 0, 1} }, - { 20, 3, 0, 0, 1, {0, 0, 0} }, - { 21, 2, 4, 0, 1, {0, 0, -1} }, - { 22, 2, 5, 0, 1, {0, 0, 1} }, - { 23, 2, 3, 0, 1, {-1, 0, 0} }, - { 24, 2, 1, 0, 1, {1, 0, 0} }, - { 25, 2, 0, 0, 1, {0, -1, 0} }, - { 26, 2, 2, 0, 1, {0, 1, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<6> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, -1} }, - { 1, 0, 1, 0, 1, {1, 0, -1} }, - { 2, 0, 2, 0, 1, {0, 1, -1} }, - { 3, 0, 3, 0, 1, {0, 0, 1} }, - { 4, 0, 4, 0, 1, {1, 0, 1} }, - { 5, 0, 5, 0, 1, {0, 1, 1} }, - { 6, 1, 0, 0, 1, {0.5, 0, -1} }, - { 7, 1, 1, 0, 1, {0.5, 0.5, -1} }, - { 8, 1, 2, 0, 1, {0, 0.5, -1} }, - { 9, 1, 6, 0, 1, {0, 0, 0} }, - { 10, 1, 7, 0, 1, {1, 0, 0} }, - { 11, 1, 8, 0, 1, {0, 1, 0} }, - { 12, 1, 3, 0, 1, {0.5, 0, 1} }, - { 13, 1, 4, 0, 1, {0.5, 0.5, 1} }, - { 14, 1, 5, 0, 1, {0, 0.5, 1} }, - { 15, 2, 0, 0, 1, {0.5, 0, 0} }, - { 16, 2, 1, 0, 1, {0.5, 0.5, 0} }, - { 17, 2, 2, 0, 1, {0, 0.5, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<18> > :: refinement_topology = { - { 0, 0, 0, 0, 0, {0, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<15> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, -1} }, - { 1, 0, 1, 0, 1, {1, 0, -1} }, - { 2, 0, 2, 0, 1, {0, 1, -1} }, - { 3, 0, 3, 0, 1, {0, 0, 1} }, - { 4, 0, 4, 0, 1, {1, 0, 1} }, - { 5, 0, 5, 0, 1, {0, 1, 1} }, - { 6, 1, 0, 2, 3, {0.5, 0, -1} }, - { 7, 1, 1, 2, 3, {0.5, 0.5, -1} }, - { 8, 1, 2, 2, 3, {0, 0.5, -1} }, - { 9, 1, 6, 2, 3, {0, 0, 0} }, - { 10, 1, 7, 2, 3, {1, 0, 0} }, - { 11, 1, 8, 2, 3, {0, 1, 0} }, - { 12, 1, 3, 2, 3, {0.5, 0, 1} }, - { 13, 1, 4, 2, 3, {0.5, 0.5, 1} }, - { 14, 1, 5, 2, 3, {0, 0.5, 1} }, - { 15, 2, 0, 0, 5, {0.5, 0, 0} }, - { 16, 2, 1, 0, 5, {0.5, 0.5, 0} }, - { 17, 2, 2, 0, 5, {0, 0.5, 0} }, - { 18, 1, 0, 0, 3, {0.25, 0, -1} }, - { 19, 1, 0, 1, 3, {0.75, 0, -1} }, - { 20, 1, 1, 0, 3, {0.75, 0.25, -1} }, - { 21, 1, 1, 1, 3, {0.25, 0.75, -1} }, - { 22, 1, 2, 0, 3, {0, 0.75, -1} }, - { 23, 1, 2, 1, 3, {0, 0.25, -1} }, - { 24, 2, 0, 4, 5, {0.25, 0, 0} }, - { 25, 2, 0, 2, 5, {0.75, 0, 0} }, - { 26, 2, 1, 4, 5, {0.75, 0.25, 0} }, - { 27, 2, 1, 2, 5, {0.25, 0.75, 0} }, - { 28, 2, 2, 3, 5, {0, 0.75, 0} }, - { 29, 2, 2, 1, 5, {0, 0.25, 0} }, - { 30, 1, 3, 0, 3, {0.25, 0, 1} }, - { 31, 1, 3, 1, 3, {0.75, 0, 1} }, - { 32, 1, 4, 0, 3, {0.75, 0.25, 1} }, - { 33, 1, 4, 1, 3, {0.25, 0.75, 1} }, - { 34, 1, 5, 0, 3, {0, 0.75, 1} }, - { 35, 1, 5, 1, 3, {0, 0.25, 1} }, - { 36, 2, 3, 1, 3, {0.25, 0.5, -1} }, - { 37, 2, 3, 0, 3, {0.25, 0.25, -1} }, - { 38, 2, 3, 2, 3, {0.5, 0.25, -1} }, - { 39, 3, 0, 0, 3, {0.25, 0.5, 0} }, - { 40, 3, 0, 1, 3, {0.25, 0.25, 0} }, - { 41, 3, 0, 2, 3, {0.5, 0.25, 0} }, - { 42, 2, 4, 2, 3, {0.25, 0.5, 1} }, - { 43, 2, 4, 0, 3, {0.25, 0.25, 1} }, - { 44, 2, 4, 1, 3, {0.5, 0.25, 1} }, - { 45, 1, 6, 0, 3, {0, 0, -0.5} }, - { 46, 2, 0, 1, 5, {0.5, 0, -0.5} }, - { 47, 1, 7, 0, 3, {1, 0, -0.5} }, - { 48, 2, 1, 1, 5, {0.5, 0.5, -0.5} }, - { 49, 1, 8, 0, 3, {0, 1, -0.5} }, - { 50, 2, 2, 4, 5, {0, 0.5, -0.5} }, - { 51, 1, 6, 1, 3, {0, 0, 0.5} }, - { 52, 2, 0, 3, 5, {0.5, 0, 0.5} }, - { 53, 1, 7, 1, 3, {1, 0, 0.5} }, - { 54, 2, 1, 3, 5, {0.5, 0.5, 0.5} }, - { 55, 1, 8, 1, 3, {0, 1, 0.5} }, - { 56, 2, 2, 2, 5, {0, 0.5, 0.5} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Pyramid<5> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 0, 4, 0, 1, {0, 0, 1} }, - { 5, 1, 0, 0, 1, {0, -1, 0} }, - { 6, 1, 1, 0, 1, {1, 0, 0} }, - { 7, 1, 2, 0, 1, {0, 1, 0} }, - { 8, 1, 3, 0, 1, {-1, 0, 0} }, - { 9, 1, 4, 0, 1, {-0.5, -0.5, 0.5} }, - { 10, 1, 5, 0, 1, {0.5, -0.5, 0.5} }, - { 11, 1, 6, 0, 1, {0.5, 0.5, 0.5} }, - { 12, 1, 7, 0, 1, {-0.5, 0.5, 0.5} }, - { 13, 2, 4, 0, 1, {0, 0, 0} } -}; - -// FIXME: note from -//Note 13 Node Pyramid Refinement not yet complete. - -template<> RefTopoX RefinementTopologyExtra< shards:: Pyramid<13> > :: refinement_topology = { - // bogus, just to avoid a compile error - { 0, 0, 0, 0, 1, {-1, 0, 0} } - -}; - - -template<> RefTopoX RefinementTopologyExtra< shards:: Line<3> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 2, 3, {0, 0, 0} }, - { 3, 1, 0, 0, 3, {-0.5, 0, 0} }, - { 4, 1, 0, 1, 3, {0.5, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Beam<3> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 1, 0, 2, 3, {0, 0, 0} }, - { 3, 1, 0, 0, 3, {-0.5, 0, 0} }, - { 4, 1, 0, 1, 3, {0.5, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Triangle<6> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 1, 0, 2, 3, {0.5, 0, 0} }, - { 4, 1, 1, 2, 3, {0.5, 0.5, 0} }, - { 5, 1, 2, 2, 3, {0, 0.5, 0} }, - { 6, 1, 0, 0, 3, {0.25, 0, 0} }, - { 7, 1, 0, 1, 3, {0.75, 0, 0} }, - { 8, 1, 1, 0, 3, {0.75, 0.25, 0} }, - { 9, 1, 1, 1, 3, {0.25, 0.75, 0} }, - { 10, 1, 2, 0, 3, {0, 0.75, 0} }, - { 11, 1, 2, 1, 3, {0, 0.25, 0} }, - { 12, 2, 0, 0, 3, {0.25, 0.25, 0} }, - { 13, 2, 0, 1, 3, {0.5, 0.25, 0} }, - { 14, 2, 0, 2, 3, {0.25, 0.5, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<8> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 2, 3, {0, -1, 0} }, - { 5, 1, 1, 2, 3, {1, 0, 0} }, - { 6, 1, 2, 2, 3, {0, 1, 0} }, - { 7, 1, 3, 2, 3, {-1, 0, 0} }, - { 8, 2, 0, 8, 9, {0, 0, 0} }, - { 9, 1, 0, 0, 3, {-0.5, -1, 0} }, - { 10, 1, 0, 1, 3, {0.5, -1, 0} }, - { 11, 1, 1, 0, 3, {1, -0.5, 0} }, - { 12, 1, 1, 1, 3, {1, 0.5, 0} }, - { 13, 1, 2, 0, 3, {0.5, 1, 0} }, - { 14, 1, 2, 1, 3, {-0.5, 1, 0} }, - { 15, 1, 3, 0, 3, {-1, 0.5, 0} }, - { 16, 1, 3, 1, 3, {-1, -0.5, 0} }, - { 17, 2, 0, 4, 9, {0, -0.5, 0} }, - { 18, 2, 0, 5, 9, {0.5, 0, 0} }, - { 19, 2, 0, 6, 9, {0, 0.5, 0} }, - { 20, 2, 0, 7, 9, {-0.5, 0, 0} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<9> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 2, 3, {0, -1, 0} }, - { 5, 1, 1, 2, 3, {1, 0, 0} }, - { 6, 1, 2, 2, 3, {0, 1, 0} }, - { 7, 1, 3, 2, 3, {-1, 0, 0} }, - { 8, 2, 0, 8, 9, {0, 0, 0} }, - { 9, 1, 0, 0, 3, {-0.5, -1, 0} }, - { 10, 1, 0, 1, 3, {0.5, -1, 0} }, - { 11, 1, 1, 0, 3, {1, -0.5, 0} }, - { 12, 1, 1, 1, 3, {1, 0.5, 0} }, - { 13, 1, 2, 0, 3, {0.5, 1, 0} }, - { 14, 1, 2, 1, 3, {-0.5, 1, 0} }, - { 15, 1, 3, 0, 3, {-1, 0.5, 0} }, - { 16, 1, 3, 1, 3, {-1, -0.5, 0} }, - { 17, 2, 0, 4, 9, {0, -0.5, 0} }, - { 18, 2, 0, 5, 9, {0.5, 0, 0} }, - { 19, 2, 0, 6, 9, {0, 0.5, 0} }, - { 20, 2, 0, 7, 9, {-0.5, 0, 0} }, - { 21, 2, 0, 0, 9, {-0.5, -0.5, 0} }, - { 22, 2, 0, 1, 9, {0.5, -0.5, 0} }, - { 23, 2, 0, 2, 9, {0.5, 0.5, 0} }, - { 24, 2, 0, 3, 9, {-0.5, 0.5, 0} } - -}; - - -template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<27> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, -1} }, - { 1, 0, 1, 0, 1, {1, -1, -1} }, - { 2, 0, 2, 0, 1, {1, 1, -1} }, - { 3, 0, 3, 0, 1, {-1, 1, -1} }, - { 4, 0, 4, 0, 1, {-1, -1, 1} }, - { 5, 0, 5, 0, 1, {1, -1, 1} }, - { 6, 0, 6, 0, 1, {1, 1, 1} }, - { 7, 0, 7, 0, 1, {-1, 1, 1} }, - { 8, 1, 0, 2, 3, {0, -1, -1} }, - { 9, 1, 1, 2, 3, {1, 0, -1} }, - { 10, 1, 2, 2, 3, {0, 1, -1} }, - { 11, 1, 3, 2, 3, {-1, 0, -1} }, - { 12, 1, 8, 2, 3, {-1, -1, 0} }, - { 13, 1, 9, 2, 3, {1, -1, 0} }, - { 14, 1, 10, 2, 3, {1, 1, 0} }, - { 15, 1, 11, 2, 3, {-1, 1, 0} }, - { 16, 1, 4, 2, 3, {0, -1, 1} }, - { 17, 1, 5, 2, 3, {1, 0, 1} }, - { 18, 1, 6, 2, 3, {0, 1, 1} }, - { 19, 1, 7, 2, 3, {-1, 0, 1} }, - { 20, 3, 0, 0, 27, {0, 0, 0} }, - { 21, 2, 4, 8, 9, {0, 0, -1} }, - { 22, 2, 5, 8, 9, {0, 0, 1} }, - { 23, 2, 3, 8, 9, {-1, 0, 0} }, - { 24, 2, 1, 8, 9, {1, 0, 0} }, - { 25, 2, 0, 8, 9, {0, -1, 0} }, - { 26, 2, 2, 8, 9, {0, 1, 0} }, - { 27, 1, 0, 0, 3, {-0.5, -1, -1} }, - { 28, 1, 0, 1, 3, {0.5, -1, -1} }, - { 29, 1, 1, 0, 3, {1, -0.5, -1} }, - { 30, 1, 1, 1, 3, {1, 0.5, -1} }, - { 31, 1, 2, 0, 3, {0.5, 1, -1} }, - { 32, 1, 2, 1, 3, {-0.5, 1, -1} }, - { 33, 1, 3, 0, 3, {-1, 0.5, -1} }, - { 34, 1, 3, 1, 3, {-1, -0.5, -1} }, - { 35, 1, 8, 0, 3, {-1, -1, -0.5} }, - { 36, 1, 9, 0, 3, {1, -1, -0.5} }, - { 37, 1, 10, 0, 3, {1, 1, -0.5} }, - { 38, 1, 11, 0, 3, {-1, 1, -0.5} }, - { 39, 1, 8, 1, 3, {-1, -1, 0.5} }, - { 40, 1, 9, 1, 3, {1, -1, 0.5} }, - { 41, 1, 10, 1, 3, {1, 1, 0.5} }, - { 42, 1, 11, 1, 3, {-1, 1, 0.5} }, - { 43, 1, 4, 0, 3, {-0.5, -1, 1} }, - { 44, 1, 4, 1, 3, {0.5, -1, 1} }, - { 45, 1, 5, 0, 3, {1, -0.5, 1} }, - { 46, 1, 5, 1, 3, {1, 0.5, 1} }, - { 47, 1, 6, 0, 3, {0.5, 1, 1} }, - { 48, 1, 6, 1, 3, {-0.5, 1, 1} }, - { 49, 1, 7, 0, 3, {-1, 0.5, 1} }, - { 50, 1, 7, 1, 3, {-1, -0.5, 1} }, - { 51, 2, 0, 7, 9, {-0.5, -1, 0} }, - { 52, 2, 0, 5, 9, {0.5, -1, 0} }, - { 53, 2, 1, 7, 9, {1, -0.5, 0} }, - { 54, 2, 1, 5, 9, {1, 0.5, 0} }, - { 55, 2, 2, 7, 9, {0.5, 1, 0} }, - { 56, 2, 2, 5, 9, {-0.5, 1, 0} }, - { 57, 2, 3, 6, 9, {-1, 0.5, 0} }, - { 58, 2, 3, 4, 9, {-1, -0.5, 0} }, - { 59, 2, 0, 4, 9, {0, -1, -0.5} }, - { 60, 2, 4, 7, 9, {0, -0.5, -1} }, - { 61, 2, 4, 5, 9, {0, 0.5, -1} }, - { 62, 2, 2, 4, 9, {0, 1, -0.5} }, - { 63, 2, 2, 6, 9, {0, 1, 0.5} }, - { 64, 2, 5, 6, 9, {0, 0.5, 1} }, - { 65, 2, 5, 4, 9, {0, -0.5, 1} }, - { 66, 2, 0, 6, 9, {0, -1, 0.5} }, - { 67, 2, 4, 4, 9, {-0.5, 0, -1} }, - { 68, 2, 4, 6, 9, {0.5, 0, -1} }, - { 69, 2, 1, 4, 9, {1, 0, -0.5} }, - { 70, 2, 1, 6, 9, {1, 0, 0.5} }, - { 71, 2, 5, 5, 9, {0.5, 0, 1} }, - { 72, 2, 5, 7, 9, {-0.5, 0, 1} }, - { 73, 2, 3, 5, 9, {-1, 0, 0.5} }, - { 74, 2, 3, 7, 9, {-1, 0, -0.5} }, - { 75, 3, 0, 1, 27, {0, -0.5, 0} }, - { 76, 3, 0, 2, 27, {0, 0.5, 0} }, - { 77, 3, 0, 3, 27, {-0.5, 0, 0} }, - { 78, 3, 0, 4, 27, {0.5, 0, 0} }, - { 79, 3, 0, 5, 27, {0, 0, -0.5} }, - { 80, 3, 0, 6, 27, {0, 0, 0.5} }, - { 81, 3, 0, 7, 27, {0, 0, 0} }, - { 82, 3, 0, 8, 27, {0, 0, 0} }, - { 83, 3, 0, 9, 27, {0, 0, 0} }, - { 84, 3, 0, 10, 27, {0, 0, 0} }, - { 85, 3, 0, 11, 27, {0, 0, 0} }, - { 86, 3, 0, 12, 27, {0, 0, 0} }, - { 87, 3, 0, 13, 27, {0, 0, 0} }, - { 88, 3, 0, 14, 27, {0, 0, 0} }, - { 89, 2, 4, 0, 9, {-0.5, -0.5, -1} }, - { 90, 2, 4, 1, 9, {-0.5, 0.5, -1} }, - { 91, 2, 4, 2, 9, {0.5, 0.5, -1} }, - { 92, 2, 4, 3, 9, {0.5, -0.5, -1} }, - { 93, 2, 5, 0, 9, {-0.5, -0.5, 1} }, - { 94, 2, 5, 1, 9, {0.5, -0.5, 1} }, - { 95, 2, 5, 2, 9, {0.5, 0.5, 1} }, - { 96, 2, 5, 3, 9, {-0.5, 0.5, 1} }, - { 97, 2, 3, 0, 9, {-1, -0.5, -0.5} }, - { 98, 2, 3, 1, 9, {-1, -0.5, 0.5} }, - { 99, 2, 3, 2, 9, {-1, 0.5, 0.5} }, - { 100, 2, 3, 3, 9, {-1, 0.5, -0.5} }, - { 101, 2, 1, 0, 9, {1, -0.5, -0.5} }, - { 102, 2, 1, 1, 9, {1, 0.5, -0.5} }, - { 103, 2, 1, 2, 9, {1, 0.5, 0.5} }, - { 104, 2, 1, 3, 9, {1, -0.5, 0.5} }, - { 105, 2, 0, 0, 9, {-0.5, -1, -0.5} }, - { 106, 2, 0, 1, 9, {0.5, -1, -0.5} }, - { 107, 2, 0, 2, 9, {0.5, -1, 0.5} }, - { 108, 2, 0, 3, 9, {-0.5, -1, 0.5} }, - { 109, 2, 2, 0, 9, {0.5, 1, -0.5} }, - { 110, 2, 2, 1, 9, {-0.5, 1, -0.5} }, - { 111, 2, 2, 2, 9, {-0.5, 1, 0.5} }, - { 112, 2, 2, 3, 9, {0.5, 1, 0.5} }, - { 113, 3, 0, 15, 27, {0, -0.5, -0.5} }, - { 114, 3, 0, 16, 27, {0, 0.5, -0.5} }, - { 115, 3, 0, 17, 27, {0, 0.5, 0.5} }, - { 116, 3, 0, 18, 27, {0, -0.5, 0.5} }, - { 117, 3, 0, 19, 27, {-0.5, -0.5, 0} }, - { 118, 3, 0, 20, 27, {0.5, -0.5, 0} }, - { 119, 3, 0, 21, 27, {0.5, 0.5, 0} }, - { 120, 3, 0, 22, 27, {-0.5, 0.5, 0} }, - { 121, 3, 0, 23, 27, {-0.5, 0, -0.5} }, - { 122, 3, 0, 24, 27, {0.5, 0, -0.5} }, - { 123, 3, 0, 25, 27, {0.5, 0, 0.5} }, - { 124, 3, 0, 26, 27, {-0.5, 0, 0.5} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<20> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, -1} }, - { 1, 0, 1, 0, 1, {1, -1, -1} }, - { 2, 0, 2, 0, 1, {1, 1, -1} }, - { 3, 0, 3, 0, 1, {-1, 1, -1} }, - { 4, 0, 4, 0, 1, {-1, -1, 1} }, - { 5, 0, 5, 0, 1, {1, -1, 1} }, - { 6, 0, 6, 0, 1, {1, 1, 1} }, - { 7, 0, 7, 0, 1, {-1, 1, 1} }, - { 8, 1, 0, 2, 3, {0, -1, -1} }, - { 9, 1, 1, 2, 3, {1, 0, -1} }, - { 10, 1, 2, 2, 3, {0, 1, -1} }, - { 11, 1, 3, 2, 3, {-1, 0, -1} }, - { 12, 1, 8, 2, 3, {-1, -1, 0} }, - { 13, 1, 9, 2, 3, {1, -1, 0} }, - { 14, 1, 10, 2, 3, {1, 1, 0} }, - { 15, 1, 11, 2, 3, {-1, 1, 0} }, - { 16, 1, 4, 2, 3, {0, -1, 1} }, - { 17, 1, 5, 2, 3, {1, 0, 1} }, - { 18, 1, 6, 2, 3, {0, 1, 1} }, - { 19, 1, 7, 2, 3, {-1, 0, 1} }, - { 20, 3, 0, 0, 7, {0, 0, 0} }, - { 21, 2, 4, 8, 9, {0, 0, -1} }, - { 22, 2, 5, 8, 9, {0, 0, 1} }, - { 23, 2, 3, 8, 9, {-1, 0, 0} }, - { 24, 2, 1, 8, 9, {1, 0, 0} }, - { 25, 2, 0, 8, 9, {0, -1, 0} }, - { 26, 2, 2, 8, 9, {0, 1, 0} }, - { 27, 1, 0, 0, 3, {-0.5, -1, -1} }, - { 28, 1, 0, 1, 3, {0.5, -1, -1} }, - { 29, 1, 1, 0, 3, {1, -0.5, -1} }, - { 30, 1, 1, 1, 3, {1, 0.5, -1} }, - { 31, 1, 2, 0, 3, {0.5, 1, -1} }, - { 32, 1, 2, 1, 3, {-0.5, 1, -1} }, - { 33, 1, 3, 0, 3, {-1, 0.5, -1} }, - { 34, 1, 3, 1, 3, {-1, -0.5, -1} }, - { 35, 1, 8, 0, 3, {-1, -1, -0.5} }, - { 36, 1, 9, 0, 3, {1, -1, -0.5} }, - { 37, 1, 10, 0, 3, {1, 1, -0.5} }, - { 38, 1, 11, 0, 3, {-1, 1, -0.5} }, - { 39, 1, 8, 1, 3, {-1, -1, 0.5} }, - { 40, 1, 9, 1, 3, {1, -1, 0.5} }, - { 41, 1, 10, 1, 3, {1, 1, 0.5} }, - { 42, 1, 11, 1, 3, {-1, 1, 0.5} }, - { 43, 1, 4, 0, 3, {-0.5, -1, 1} }, - { 44, 1, 4, 1, 3, {0.5, -1, 1} }, - { 45, 1, 5, 0, 3, {1, -0.5, 1} }, - { 46, 1, 5, 1, 3, {1, 0.5, 1} }, - { 47, 1, 6, 0, 3, {0.5, 1, 1} }, - { 48, 1, 6, 1, 3, {-0.5, 1, 1} }, - { 49, 1, 7, 0, 3, {-1, 0.5, 1} }, - { 50, 1, 7, 1, 3, {-1, -0.5, 1} }, - { 51, 2, 0, 7, 9, {-0.5, -1, 0} }, - { 52, 2, 0, 5, 9, {0.5, -1, 0} }, - { 53, 2, 1, 7, 9, {1, -0.5, 0} }, - { 54, 2, 1, 5, 9, {1, 0.5, 0} }, - { 55, 2, 2, 7, 9, {0.5, 1, 0} }, - { 56, 2, 2, 5, 9, {-0.5, 1, 0} }, - { 57, 2, 3, 6, 9, {-1, 0.5, 0} }, - { 58, 2, 3, 4, 9, {-1, -0.5, 0} }, - { 59, 2, 0, 4, 9, {0, -1, -0.5} }, - { 60, 2, 4, 7, 9, {0, -0.5, -1} }, - { 61, 2, 4, 5, 9, {0, 0.5, -1} }, - { 62, 2, 2, 4, 9, {0, 1, -0.5} }, - { 63, 2, 2, 6, 9, {0, 1, 0.5} }, - { 64, 2, 5, 6, 9, {0, 0.5, 1} }, - { 65, 2, 5, 4, 9, {0, -0.5, 1} }, - { 66, 2, 0, 6, 9, {0, -1, 0.5} }, - { 67, 2, 4, 4, 9, {-0.5, 0, -1} }, - { 68, 2, 4, 6, 9, {0.5, 0, -1} }, - { 69, 2, 1, 4, 9, {1, 0, -0.5} }, - { 70, 2, 1, 6, 9, {1, 0, 0.5} }, - { 71, 2, 5, 5, 9, {0.5, 0, 1} }, - { 72, 2, 5, 7, 9, {-0.5, 0, 1} }, - { 73, 2, 3, 5, 9, {-1, 0, 0.5} }, - { 74, 2, 3, 7, 9, {-1, 0, -0.5} }, - { 75, 3, 0, 1, 7, {0, -0.5, 0} }, - { 76, 3, 0, 2, 7, {0, 0.5, 0} }, - { 77, 3, 0, 3, 7, {-0.5, 0, 0} }, - { 78, 3, 0, 4, 7, {0.5, 0, 0} }, - { 79, 3, 0, 5, 7, {0, 0, -0.5} }, - { 80, 3, 0, 6, 7, {0, 0, 0.5} } - -}; - -template<> RefTopoX RefinementTopologyExtra< shards:: Tetrahedron<10> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 0, 3, 0, 1, {0, 0, 1} }, - { 4, 1, 0, 2, 3, {0.5, 0, 0} }, - { 5, 1, 1, 2, 3, {0.5, 0.5, 0} }, - { 6, 1, 2, 2, 3, {0, 0.5, 0} }, - { 7, 1, 3, 2, 3, {0, 0, 0.5} }, - { 8, 1, 4, 2, 3, {0.5, 0, 0.5} }, - { 9, 1, 5, 2, 3, {0, 0.5, 0.5} }, - { 10, 1, 0, 0, 3, {0.25, 0, 0} }, - { 11, 1, 0, 1, 3, {0.75, 0, 0} }, - { 12, 1, 1, 0, 3, {0.75, 0.25, 0} }, - { 13, 1, 1, 1, 3, {0.25, 0.75, 0} }, - { 14, 1, 2, 0, 3, {0, 0.75, 0} }, - { 15, 1, 2, 1, 3, {0, 0.25, 0} }, - { 16, 1, 3, 0, 3, {0, 0, 0.25} }, - { 17, 1, 4, 0, 3, {0.75, 0, 0.25} }, - { 18, 1, 5, 0, 3, {0, 0.75, 0.25} }, - { 19, 1, 3, 1, 3, {0, 0, 0.75} }, - { 20, 1, 4, 1, 3, {0.25, 0, 0.75} }, - { 21, 1, 5, 1, 3, {0, 0.25, 0.75} }, - { 22, 3, 0, 0, 1, {0.25, 0.25, 0.25} }, - { 23, 2, 0, 2, 3, {0.25, 0, 0.5} }, - { 24, 2, 3, 1, 3, {0.25, 0.5, 0} }, - { 25, 2, 2, 0, 3, {0, 0.25, 0.25} }, - { 26, 2, 1, 0, 3, {0.5, 0.25, 0.25} }, - { 27, 2, 0, 0, 3, {0.25, 0, 0.25} }, - { 28, 2, 1, 1, 3, {0.25, 0.5, 0.25} }, - { 29, 2, 2, 1, 3, {0, 0.25, 0.5} }, - { 30, 2, 3, 2, 3, {0.5, 0.25, 0} }, - { 31, 2, 3, 0, 3, {0.25, 0.25, 0} }, - { 32, 2, 1, 2, 3, {0.25, 0.25, 0.5} }, - { 33, 2, 2, 2, 3, {0, 0.5, 0.25} }, - { 34, 2, 0, 1, 3, {0.5, 0, 0.25} } - -}; -#endif diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/MeshObjTopology.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/MeshObjTopology.hpp deleted file mode 100644 index 6e026f8b945b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/MeshObjTopology.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/**-------------------------------------------------------------------* - * Copyright 1999 - 2009 Sandia Corporation. * - * Under the terms of Contract DE-AC04-94AL85000, there is a * - * non-exclusive license for use of this work by or on behalf * - * of the U.S. Government. Export of this program may require * - * a license from the United States Government. * - *--------------------------------------------------------------------*/ - -#ifndef stk_adapt_sierra_element_MeshObjTopology_hpp -#define stk_adapt_sierra_element_MeshObjTopology_hpp - -#include - -namespace stk_classic { - namespace adapt { - namespace Elem { - - class MeshObjTopology - { - public: - MeshObjTopology( - const CellTopologyData * cell_topology_data) - : m_cellTopology(cell_topology_data) - {} - - public: - ~MeshObjTopology() - {} - - Elem::CellTopology getCellTopology() const { - return m_cellTopology; - } - - protected: - Elem::CellTopology m_cellTopology; - - private: - MeshObjTopology(); - MeshObjTopology(const MeshObjTopology &); - MeshObjTopology & operator = (const MeshObjTopology &); - }; - - } // namespace Elem - } // namespace adapt -} // namespace stk_classic - -#endif // stk_adapt_sierra_element_MeshObjTopology_hpp diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/Readme.txt b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/Readme.txt deleted file mode 100644 index 6ed04141e686..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/Readme.txt +++ /dev/null @@ -1 +0,0 @@ -These files are a port of souce code from framework/src/{element,mesh_modification} to STK. diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.cpp deleted file mode 100644 index c40001318a30..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 - 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2003 Sandia Corporation, Albuquerque, NM. - -#include - -#include - -namespace stk_classic { namespace adapt { -namespace Elem { - -/* - Derek Gaston: I've pretty much disabled this class so it always returns 0x0. - This is because I've removed heterogeneous refinement from the framework. - Hopefully this class will get completely removed one day... -*/ - -RefinementKey::RefinementKey() -{ - //Default constructor will assign 0x0 to value_ - //This will correspond to normal homogeneous refinement patterns - value_=0x0; -} -RefinementKey::RefinementKey(UInt valueArgue) -{ - //constructor where value is known -// value_=valueArgue; - value_=0x0; - -} - -RefinementKey::~RefinementKey() -{ -//Destructor -//Do Nothing -} - -UInt Elem::RefinementKey::value() -{ - return value_; -} - -void Elem::RefinementKey::assign_value(UInt valueArgue) -{ - //Assigns value_ based on a given id # - //Usefull when changing value to default during unrefinement - //as well as when assigning the unrefinement template id # - -// value_ = valueArgue; - -} - -void Elem::RefinementKey::assign_value(std::vector & edge_order) -{ - //Assigns value_ based on a given edge order cut vector - //Used durring heterogeneous marker resolution - -/* value_ = 0x0; - - for (UInt position = 0; position < edge_order.size(); ++position) { - value_ |= (edge_order[position]+1)<<(position*4); - } -*/ -} - -std::vector Elem::RefinementKey::ordered_cut_edges( UInt numEdges ) const -{ - //Given the number of edges of a mesh object populates a vector - //of edges to be refined in the correct order based on value_ - - std::vector edge_order; - edge_order.clear(); - - for (UInt iedge = 0; iedge>(iedge*4) & 0xF; - if(edge != 0x0) edge_order.push_back(edge-1); - } - return edge_order; - -} - - -bool Elem::RefinementKey::full_refinement( UInt numEdges ) -{ - //if number of edges on refinement key equal numEdges than full refinement - std::vector edgeOrder = ordered_cut_edges(numEdges); - UInt edgeOrderSize = edgeOrder.size(); - return edgeOrderSize == numEdges; -} - -} // namespace Elem -} // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.hpp deleted file mode 100644 index dcbc83beb5b0..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementKey.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/**-------------------------------------------------------------------* - * Copyright 2003 - 2009 Sandia Corporation. * - * Under the terms of Contract DE-AC04-94AL85000, there is a * - * non-exclusive license for use of this work by or on behalf * - * of the U.S. Government. Export of this program may require * - * a license from the United States Government. * - *--------------------------------------------------------------------*/ -/** - * @file - * @specifications for heterogeneous key id to give refinement topologies - * @author Warren B. Tauber - * - * @par Description: - * - * In order to support removal of hanging nodes elements can be refined - * according to topologies that do not refine every edge and or face. To - * account for the different possibilities a key id is given to each mesh - * object. This key id will contain the edges to be cut information . - * Given the key id number member functions of this class will be able to - * give a vector of ordered edges to be cut. Also the reverse will be - * available as well. These functions will be different for each base - * topology class. - * - * value_ will be such that for 2d solid triangular elements - * a value of 0x021 would be edge 0 cut first then edge 1 - * a value 0f 0x321 would be edge 0 then edge 1 then edge 2 - * value of digits in key_id corresponds to (edge# +1 ) in left to right - * ordering - */ - -/*--------------------------------------------------------------------*/ - -#ifndef stk_adapt_sierra_element_Elem_RefinementKey_hpp -#define stk_adapt_sierra_element_Elem_RefinementKey_hpp - -#include -#include - -namespace stk_classic { namespace adapt { - namespace Elem { - - class RefinementKey { - private: - /** Unsigned integer that will store the correct template **/ - UInt value_; - - public: - - /** Default Constructer that assigns the value_ to 0x0 **/ - RefinementKey(); - - /** Constructer where value is known **/ - explicit RefinementKey(UInt valueArg); - - /** Destructor **/ - ~RefinementKey(); - - /** Returns the value_ **/ - UInt value(); - - /** Assigns value_**/ - void assign_value(UInt valueArg) ; - - /** function that assigns the value_ based on edges to be cut **/ - void assign_value( std::vector & edge_order ) ; - - /** function that returns ordered edges to be cut **/ - /** for this method need the objTopologyes number of edges **/ - std::vector ordered_cut_edges( UInt numEdges ) const ; - - /** Function returns boolean for full refinement **/ - bool full_refinement( UInt numEdges ); - }; - - } // namespace Elem -} // namespace adapt -} // namespace stk_classic - -#endif // stk_adapt_sierra_element_Elem_RefinementKey_hpp diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementTopology.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementTopology.cpp deleted file mode 100644 index c096098eada8..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/RefinementTopology.cpp +++ /dev/null @@ -1,846 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 1999 - 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -/* Copyright 1999-2002 Sandia Corporation, Albuquerque, NM. */ - - -#include -#include -#include - -#include - -//#include - -#include -#include -//#include -#include - -#include - -namespace stk_classic { - - using namespace percept; - - namespace adapt { - namespace Elem { - - namespace { - - typedef std::map CellTopologyRefinementMap; - - CellTopologyRefinementMap & - get_cell_topology_refinement_map() - { - /* %TRACE[SPEC]% */ /* %TRACE% */ - static CellTopologyRefinementMap s_cellTopologyRefinementMap; - - return s_cellTopologyRefinementMap; - } - - } // namespace < - - - const RefinementTopology * - getRefinementTopology( - const Elem::CellTopology & cell_topology) - { - return get_cell_topology_refinement_map()[cell_topology]; - } - - - const UInt * - getRefinementEdgeNode( - const Elem::CellTopology & cell_topology, - UInt edge) - { - return get_cell_topology_refinement_map()[cell_topology]->edge_node(edge); - } - - - const UInt * - getRefinementFaceNode( - const Elem::CellTopology & cell_topology, - UInt face) - { - return get_cell_topology_refinement_map()[cell_topology]->face_node(face); - } - - - const UInt * - getRefinementEdgePermutation( - const Elem::CellTopology & cell_topology, - UInt permutation_ordinal) - { - return get_cell_topology_refinement_map()[cell_topology] ? get_cell_topology_refinement_map()[cell_topology]->edge_permutation(permutation_ordinal) : 0; - } - - - RefinementTopology::RefinementTopology( - MeshObjTopology * mesh_obj_topology, - UInt num_child, - const MeshObjTopology * const * child_topology, - UInt num_child_nodes, - const UInt * const * child_nodes, - const UInt num_edges, - const UInt * const * edge_node, - const UInt num_faces, - const UInt * const * face_node, - UInt num_orientations, - const UInt * const * perm_node, - const UInt * const * perm_edge, - bool homogeneous_child) - : m_cellTopology(mesh_obj_topology->getCellTopology()), - m_numChild(num_child), - m_childCellTopology(0), - m_numChildNodes(num_child_nodes), - m_childNode(child_nodes), - m_numEdges(num_edges), - m_edgeNode(edge_node), - m_numFaces(num_faces), - m_faceNode(face_node), - m_numOrientations(num_orientations), - m_nodePermutation(perm_node), - m_edgePermutation(perm_edge), - m_homogeneousChild(homogeneous_child) - { - // mesh_obj_topology->set_refinement_topology(this); - - m_childCellTopology = new CellTopology[num_child]; - for (size_t i = 0; i < num_child; ++i) - m_childCellTopology[i] = child_topology[i]->getCellTopology(); - - get_cell_topology_refinement_map()[mesh_obj_topology->getCellTopology()] = this; - } - - RefinementTopology::~RefinementTopology() - { - delete[] m_childCellTopology; - } - - - const UInt * - RefinementTopology::node_permutation( - UInt permutation_ordinal) const - { - return permutation_ordinal < m_numOrientations ? m_nodePermutation[permutation_ordinal] : NULL; - } - - - const UInt * - RefinementTopology::edge_permutation( - UInt permutation_ordinal) const - { - return permutation_ordinal < m_numOrientations ? m_edgePermutation[permutation_ordinal] : NULL; - } - - - /*--------------------------------------------------------------------*/ - /*----MeshObjRefinementTopology----------------------------------*/ - /*--------------------------------------------------------------------*/ - MeshObjRefinementTopology::MeshObjRefinementTopology() - : m_numChild(0), - m_numChildNodes(0), - m_childCellTopology(0), - m_childNode(0), - m_homogeneous(true), - m_fullRefinement(false) - {} - - - MeshObjRefinementTopology::~MeshObjRefinementTopology() - { - //Destructor - //if homogeneous do not delete data as they refer to static variables - //if not homogeneous release refinement pattern data - - if(!m_homogeneous){ - - //Delete 2 dimensional array of childNode - for(UInt i = 0; igetCellTopology() : CellTopology(); - return (child < m_numChild) ? m_childCellTopology[child] : CellTopology(); - } - - - const UInt * - MeshObjRefinementTopology::child_node( - UInt child) const - { - return (child < m_numChild) ? m_childNode[child] : NULL; - } - - bool - MeshObjRefinementTopology::homogeneous_refinement() const - { - return m_homogeneous; - } - - - bool - MeshObjRefinementTopology::full_refinement() const - { - return m_fullRefinement; - } - - - std::pair - MeshObjRefinementTopology::child_face( - const UInt face_ordinal, - const UInt face_child_ordinal, - const CellTopology & objTop, - const RefinementKey & objDesiredKey) const - { - std::pair result(0,0); - - bool flag = (face_ordinal < objTop.getFaceCount()) && - (face_child_ordinal < getRefinementTopology(faceCellTopology(objTop, face_ordinal))->num_child()); - - if (flag) { - - // Match nodes of - // face_topology(face_ordinal)->child_nodes(face_child_node)[*] - // to - // child_topology(face_child.first)->face_nodes(face_child.second)[*] - - - - const CellTopology faceTop = Elem::faceCellTopology(objTop, face_ordinal); - - const UInt * const faceN = getRefinementTopology(objTop)->face_node(face_ordinal); - - //const UInt * const faceChildN = faceTop.child_node(face_child_ordinal); - - //faceChildN needs to be replaced with faceDesiredTop.child_node - //Need face desired key - - std::vector sideEdgePattern; - sideEdgePattern.clear(); - std::vector objEdgePattern = objDesiredKey.ordered_cut_edges(objTop.getEdgeCount()); - for(UInt jEdge = 0; jEdgequery_refinement_topology(faceDesiredKey,faceDesiredTop)) { - //throw RuntimeError() << "Failed query of face refinement topology." - // << std::endl << StackTrace; - THROW( "Failed query of face refinement topology."); - } - - const UInt * const faceChildN = faceDesiredTop.child_node(face_child_ordinal); - - const CellTopology faceChildTop = getRefinementTopology(faceTop)->child_cell_topology(face_child_ordinal); - - flag = false; - std::pair cf; - - for (cf.first = 0; cf.first < num_child(); ++cf.first) { - const UInt * const childN = child_node( cf.first); - const CellTopology childTop = child_cell_topology(cf.first); - - for (cf.second = 0; cf.second < childTop.getFaceCount(); ++cf.second) { - if (Elem::faceCellTopology(childTop, cf.second) == faceChildTop) { - - const UInt * const childFaceN = getRefinementTopology(childTop)->face_node(cf.second); - - UInt i = 0; - - for (; i < faceChildTop.getNodeCount() && - faceN[ faceChildN[i] ] == childN[ childFaceN[i] ]; ++i); - - if (i == faceChildTop.getNodeCount()) { - VERIFY_TRUE_ON(! flag); - flag = true; - result.first = cf.first; - result.second = cf.second; - } - } - } - } - } - - if (! flag) - { - // throw RuntimeError() << "MeshObjRefinementTopology[" << objTop.getName() << "]::child_face(" - // << face_ordinal << "," << face_child_ordinal - // << ") could not find a match." << std::endl << StackTrace; - THROW("MeshObjRefinementTopology[" << objTop.getName() << "]::child_face(" - << face_ordinal << "," << face_child_ordinal - << ") could not find a match." ); - - } - - return result; - } - - - std::pair - MeshObjRefinementTopology::child_edge( - const UInt edge_ordinal, - const UInt edge_child_ordinal, - const CellTopology & objTop) const - { - std::pair result(0,0); - - bool flag = (edge_ordinal < objTop.getEdgeCount()) && - (edge_child_ordinal < getRefinementTopology(edgeCellTopology(objTop, edge_ordinal))->num_child()); - - if (flag) { - - // Match nodes of - // edge_topology(edge_ordinal)->child_nodes(edge_child_node)[*] - // to - // child_topology(edge_child.first)->edge_nodes(edge_child.second)[*] - - const CellTopology edgeTop = edgeCellTopology(objTop, edge_ordinal); - - const UInt * const edgeN = getRefinementTopology(objTop)->edge_node(edge_ordinal); - const UInt * const edgeChildN = getRefinementTopology(edgeTop)->child_node(edge_child_ordinal); - - const CellTopology edgeChildTop = getRefinementTopology(edgeTop)->child_cell_topology(edge_child_ordinal); - - flag = false; - std::pair ce; - for (ce.first = 0; ce.first < num_child(); ++ce.first) { - - const UInt * const childN = child_node( ce.first); - const CellTopology childTop = child_cell_topology(ce.first); - - for (ce.second = 0; ce.second < childTop.getEdgeCount(); ++ce.second) { - - if (Elem::edgeCellTopology(childTop, ce.second) == edgeChildTop) { - - const UInt * const childEdgeN = getRefinementTopology(childTop)->edge_node(ce.second); - UInt i = 0; - - for (; i < edgeChildTop.getNodeCount() && - edgeN[ edgeChildN[i] ] == childN[ childEdgeN[i] ]; ++i); - - - if (i == edgeChildTop.getNodeCount()) { - flag = true; - result.first = ce.first; - result.second = ce.second; - - } - } - } - } - } - - if (! flag) - { - // throw RuntimeError() << "MeshObjRefinementTopology[" << objTop.getName() << "]::child_edge(" - // << edge_ordinal << "," << edge_child_ordinal - // << ") could not find a match." << std::endl << StackTrace; - THROW("MeshObjRefinementTopology[" << objTop.getName() << "]::child_edge(" - << edge_ordinal << "," << edge_child_ordinal - << ") could not find a match." ); - } - - return result; - } - - - std::pair - RefinementTopology::child_face( - const UInt face_ordinal, - const UInt face_child_ordinal) const - { - std::pair result(0,0); - - bool flag = (face_ordinal < m_cellTopology.getFaceCount()) && - (face_child_ordinal < getRefinementTopology(faceCellTopology(m_cellTopology, face_ordinal))->num_child()); - - if (flag) { - - // Match nodes of - // face_topology(face_ordinal)->child_nodes(face_child_node)[*] - // to - // child_topology(face_child.first)->face_nodes(face_child.second)[*] - - const CellTopology & faceTop = faceCellTopology(m_cellTopology, face_ordinal); - - const UInt * const faceN = face_node(face_ordinal); - - const UInt * const faceChildN = Elem::getRefinementTopology(faceTop)->child_node(face_child_ordinal); - - const CellTopology faceChildTop = getRefinementTopology(faceTop)->child_cell_topology(face_child_ordinal); - - flag = false; - std::pair cf; - - for (cf.first = 0; cf.first < num_child(); ++cf.first) { - - const UInt * const childN = child_node( cf.first); - const CellTopology childTop = child_cell_topology(cf.first); - - for (cf.second = 0; cf.second < childTop.getFaceCount(); ++cf.second) { - - if (faceCellTopology(childTop, cf.second) == faceChildTop) { - - const UInt * const childFaceN = Elem::getRefinementTopology(childTop)->face_node(cf.second); - - UInt i = 0; - - for (; i < faceChildTop.getNodeCount() && - faceN[ faceChildN[i] ] == childN[ childFaceN[i] ]; ++i); - - if (i == faceChildTop.getNodeCount()) { - VERIFY_TRUE(! flag); - flag = true; - result.first = cf.first; - result.second = cf.second; - } - } - } - } - } - - if (! flag) { - // throw RuntimeError() << "CellTopology[" << m_cellTopology.getName() << "]::child_face(" - // << face_ordinal << "," << face_child_ordinal - // << ") could not find a match." << std::endl << StackTrace; - THROW( "CellTopology[" << m_cellTopology.getName() << "]::child_face(" - << face_ordinal << "," << face_child_ordinal - << ") could not find a match." ); - } - - return result; - } - - - std::pair - RefinementTopology::child_edge( - const UInt edge_ordinal, - const UInt edge_child_ordinal) const - { - std::pair result(0,0); - - bool flag = (edge_ordinal < m_cellTopology.getEdgeCount()) && - (edge_child_ordinal < getRefinementTopology(edgeCellTopology(m_cellTopology, edge_ordinal))->num_child()); - - if (flag) { - - // Match nodes of - // edge_topology(edge_ordinal)->child_nodes(edge_child_node)[*] - // to - // child_topology(edge_child.first)->edge_nodes(edge_child.second)[*] - - const CellTopology & edgeTop = edgeCellTopology(m_cellTopology, edge_ordinal); - - const UInt * const edgeN = edge_node(edge_ordinal); - const UInt * const edgeChildN = getRefinementTopology(edgeTop)->child_node(edge_child_ordinal); - - const CellTopology edgeChildTop = getRefinementTopology(edgeTop)->child_cell_topology(edge_child_ordinal); - - flag = false; - std::pair ce; - - for (ce.first = 0; ce.first < num_child(); ++ce.first) { - - const UInt * const childN = child_node( ce.first); - const CellTopology childTop = child_cell_topology(ce.first); - - for (ce.second = 0; ce.second < childTop.getEdgeCount(); ++ce.second) { - - if (edgeCellTopology(childTop, ce.second) == edgeChildTop) { - - const UInt * const childEdgeN = getRefinementTopology(childTop)->edge_node(ce.second); - - UInt i = 0; - - for (; i < edgeChildTop.getNodeCount() && - edgeN[ edgeChildN[i] ] == childN[ childEdgeN[i] ]; ++i); - - if (i == edgeChildTop.getNodeCount()) { - VERIFY_TRUE(! flag); - flag = true; - result.first = ce.first; - result.second = ce.second; - } - } - } - } - } - - if (! flag) { - // throw RuntimeError() << "CellTopology[" << m_cellTopology.getName() << "]::child_edge(" - // << edge_ordinal << "," << edge_child_ordinal - // << ") could not find a match." << std::endl << StackTrace; - THROW("CellTopology[" << m_cellTopology.getName() << "]::child_edge(" - << edge_ordinal << "," << edge_child_ordinal - << ") could not find a match." ); - } - - return result; - } - - - bool - RefinementTopology::query_refinement_topology( - RefinementKey & objKey, - MeshObjRefinementTopology & objRefTop) const - { - // check if partial refinement key defined - if (0x0 != objKey.value()) { - // check if tri or tet element - if (this == getRefinementTopology(getCellTopology >())) { - return refine_rivara_tri(objKey, objRefTop); - } - else if (this == getRefinementTopology(getCellTopology >())) { - return refine_rivara_tet(objKey, objRefTop); - } - } - else { - //Return normal homogeneous patterns due to default value of 0x0 - //or the fact that obj topology name is currently not supported for partial refinement - //Need to return differnet pattens for all normal homogeneous objects - //these refinement patterns will not be dynamically created but will - //point to or be equal to the current static objects; - objRefTop.m_homogeneous = true; - objRefTop.m_fullRefinement = true; - objRefTop.m_numChild = num_child(); - objRefTop.m_numChildNodes= num_child_nodes(); - objRefTop.m_childCellTopology = child_cell_topology(); - objRefTop.m_childNode = (UInt * *) child_nodes(); - return true; - } - return false; - } - - - // Performs logic for bisection of triangle based on refinement key - // Bisections are performed in order of largest to smallest edge to be refined - bool - RefinementTopology::refine_rivara_tri( - RefinementKey & objKey, - MeshObjRefinementTopology & objRefTop) const - { - //partial refinement key defined so create pattern - - //refTop is not based on standard homogeneous patterns - objRefTop.m_homogeneous = false; - - UInt objNumNodes = m_cellTopology.getNodeCount(); - - //Vector of edges and order in which to be refined - std::vector edgePattern = objKey.ordered_cut_edges(m_cellTopology.getEdgeCount()); - - UInt num_edges_cut = edgePattern.size(); - - //number of child equals num_edges_cut +1 - objRefTop.m_numChild =num_edges_cut+1; - - //number of child nodes = m_cellTopology.getNodeCount() + num_edges_cut for 2D triangle - objRefTop.m_numChildNodes = objNumNodes+num_edges_cut; - - //Determine childNode for different templates based on largest edge bisection - UInt longEdge = edgePattern[0]; - - //For first bisection pNode is new child node need to find the node - //that is the opposite vertex of pNode - UInt node0 = edge_node(longEdge)[0]; - UInt node1 = edge_node(longEdge)[1]; - UInt pNode = edge_node(longEdge)[2]; - UInt oppVertex = objNumNodes; - for (UInt iNode = 0; iNode < objNumNodes; ++iNode) { - if(iNode != node0 && iNode != node1) oppVertex = iNode; - } - VERIFY_TRUE(oppVertex != m_cellTopology.getNodeCount()); - - //Define a vector of of vectors that hold child node maps - //Store all possible child node maps to be genereated - //First Bisection gives 2 child elements - //Then each of those elements gives possibly 2 more child - - std::vector > childNodeVec(6, std::vector(3)); - - //An array that tells wether a given possible child node map is active - bool childActive[6]={false,false,false,false,false,false}; - - //First Bisection - - childNodeVec[0][node0]=node0; - childNodeVec[0][node1]=pNode; - childNodeVec[0][oppVertex]=oppVertex; - - childNodeVec[1][node0]=pNode; - childNodeVec[1][node1]=node1; - childNodeVec[1][oppVertex]=oppVertex; - - childActive[0]=true; - childActive[1]=true; - - UInt iChildFilled = 2; - - //Now determine further bisection if needed - //If one of the elements formed in first bisection is refined than - //They will no longer be active - - for (UInt iEdge=1;iEdge edgePattern = objKey.ordered_cut_edges(objNumEdges); - - objRefTop.m_numChild = 1; - objRefTop.m_numChildNodes = objNumNodes; - UInt longEdge = edgePattern[0]; - UInt node0 = edge_node(longEdge)[0]; - UInt node1 = edge_node(longEdge)[1]; - UInt pNode = edge_node(longEdge)[2]; - - UInt oppEdge = objNumEdges; - for(UInt i=0;i > childNodeVec(14, std::vector(4)); - - bool childActive[14]={false,false,false,false,false,false, - false,false,false,false,false,false,false,false}; - - //First Bisection - objRefTop.m_numChild = objRefTop.m_numChild+1; - objRefTop.m_numChildNodes = objRefTop.m_numChildNodes +1; - - childNodeVec[0][node0]=node0; - childNodeVec[0][node1]=pNode; - childNodeVec[0][oppEdgeNode0]=oppEdgeNode0; - childNodeVec[0][oppEdgeNode1]=oppEdgeNode1; - - childNodeVec[1][node0]=pNode; - childNodeVec[1][node1]=node1; - childNodeVec[1][oppEdgeNode0]=oppEdgeNode0; - childNodeVec[1][oppEdgeNode1]=oppEdgeNode1; - - childActive[0]=true; - childActive[1]=true; - - UInt iChildFilled = 2; - - //After first bisection iterate over edges to be refined - for(UInt iEdge=1;iEdge - -#include - -#include -#include - -namespace stk_classic { namespace adapt { - namespace Elem { - - class MeshObjTopology; - class RefinementKey; - class MeshObjRefinementTopology; - - class RefinementTopology - { - public: - RefinementTopology(MeshObjTopology *mesh_obj_topology, - UInt num_child, const MeshObjTopology * const *child_topology, - UInt num_child_nodes, const UInt * const *child_nodes, - const UInt num_edges, const UInt * const *edge_node, - const UInt num_faces, const UInt * const *face_node, - UInt num_orientations, const UInt * const *perm_node, const UInt * const *perm_edge, - bool homogeneous_child); - - RefinementTopology(const CellTopology &mesh_obj_topology, - UInt num_child, const MeshObjTopology * const *child_topology, - UInt num_child_nodes, const UInt * const *child_nodes, - const UInt num_edges, const UInt * const *edge_node, - const UInt num_faces, const UInt * const *face_node, - UInt num_orientations, const UInt * const *perm_node, const UInt * const *perm_edge, - bool homogeneous_child); - - ~RefinementTopology(); - - private: - RefinementTopology(const RefinementTopology &); - RefinementTopology &operator=(const RefinementTopology &); - - public: - /** Number of refinement child topologies. */ - UInt num_child() const { - return m_numChild; - } - - /** Query if the refined mesh object topologies are homogeneous. */ - bool homogeneous_child() const { - return m_homogeneousChild; - } - - const CellTopology *child_cell_topology() const { - return m_childCellTopology; - } - - CellTopology child_cell_topology(UInt ordinal) const { - return (ordinal < m_numChild) ? m_childCellTopology[ordinal] : CellTopology(); - } - - /** Total number of unique nodes of the connected child objects. - * Nodes that are shared by child objects are only counted once. - * Every node of the parent is also one of the child nodes. - */ - UInt num_child_nodes() const { - return m_numChildNodes; - } - - const UInt * const * child_nodes() const { - return m_childNode; - } - - /** Map ordinals of child object topology nodes to child nodes. - * Array dimension is [ child_topology(child)->num_nodes() ] - * @pre child < num_child() - * @pre node_of_child < child_topology(child)->num_nodes() - * @post 0 <= child_node(child)[i] < num_child_nodes - */ - const UInt * child_node(UInt child) const { - return (child < m_numChild) ? m_childNode[child] : NULL; - } - - const UInt *edge_node(UInt edge) const { - if (edge >= m_numEdges) - return NULL; - - return m_edgeNode[edge]; - } - - const UInt *face_node(UInt face) const { - if (face >= m_numFaces) - return NULL; - - return m_faceNode[face]; - } - - const UInt *node_permutation(UInt orientation) const; - - /** Permutation vector from the expected orientation - * to the input permutation. - */ - const UInt *edge_permutation(UInt orientation) const; - - bool query_refinement_topology(RefinementKey &object_key, MeshObjRefinementTopology & refTop) const; - - bool refine_rivara_tri(RefinementKey &, MeshObjRefinementTopology & refTop) const; - bool refine_rivara_tet(RefinementKey &, MeshObjRefinementTopology & refTop) const; - - /*------------------------------------------------------------------*/ - /** Mapping of parent->face->child to parent->child->face - * @pre face_ordinal < num_faces() - * @pre face_child_ordinal < face_topology(face_ordinal)->num_child() - * @return (child_ordinal, child_face_ordinal) - */ - std::pair child_face(const UInt face_ordinal , - const UInt face_child_ordinal) const; - - /** Mapping of parent->edge->child to parent->child->edge - * @pre edge_ordinal < getEdgeCount() - * @pre edge_child_ordinal < edge_topology(edge_ordinal)->num_child() - * @return (child_ordinal, child_edge_ordinal) - */ - std::pair child_edge(const UInt edge_ordinal , - const UInt edge_child_ordinal) const; - - private: - CellTopology m_cellTopology; - UInt m_numChild; - CellTopology * m_childCellTopology; - UInt m_numChildNodes; - const UInt * const * m_childNode; - const UInt m_numEdges; - const UInt * const * m_edgeNode; ///< Node ordinals map to edges - ///< m_edgeNode[ m_numEdges ][ num-nodes-of-edge ] - - const UInt m_numFaces; - const UInt * const * m_faceNode; ///< Mapping of node ordinals to faces - ///< m_faceNode[ m_numFaces ][ num-nodes-of-face ] - - UInt m_numOrientations; - const UInt * const * m_nodePermutation; - const UInt * const * m_edgePermutation; - - bool m_homogeneousChild; - }; - - - /** - * Class to hold refinement information for partial and heterogeneous - */ - class MeshObjRefinementTopology - { - public: - MeshObjRefinementTopology(); - ~MeshObjRefinementTopology(); - - UInt num_child() const; - - UInt num_child_nodes() const ; - - CellTopology child_cell_topology(UInt child) const ; - - const UInt * child_node(UInt child) const ; - - bool homogeneous_refinement() const; - - bool full_refinement() const; - /*------------------------------------------------------------------*/ - /** Mapping of parent->face->child to parent->child->face - * @pre face_ordinal < num_faces() - * @pre face_child_ordinal < face_topology(face_ordinal)->num_child() - * @arg objTop need to have objects regular topology as well - * @return (child_ordinal, child_face_ordinal) - */ - std::pair child_face(const UInt face_ordinal , - const UInt face_child_ordinal, - const Elem::CellTopology & objTop , - const RefinementKey &objDesiredKey) const ; - - /** Mapping of parent->edge->child to parent->child->edge - * @pre edge_ordinal < getEdgeCount() - * @pre edge_child_ordinal < edge_topology(edge_ordinal)->num_child() - * @arg objTop need to have objects regular topology as well - * @return (child_ordinal, child_edge_ordinal) - */ - std::pair child_edge(const UInt edge_ordinal , - const UInt edge_child_ordinal, - const Elem::CellTopology & objTop) const; - - - public: // private: - UInt m_numChild; - UInt m_numChildNodes; - const CellTopology * m_childCellTopology; - UInt * * m_childNode; - bool m_homogeneous; /*whether refinement is self simmilar*/ - bool m_fullRefinement; /*whether all edges are to be refined or not*/ - - private: - MeshObjRefinementTopology(const MeshObjRefinementTopology&); - MeshObjRefinementTopology&operator=(const MeshObjRefinementTopology&); - }; - - - const RefinementTopology *getRefinementTopology(const Elem::CellTopology &cell_topology); - const UInt *getRefinementEdgeNode(const Elem::CellTopology &cell_topology, UInt edge); - const UInt *getRefinementFaceNode(const Elem::CellTopology &cell_topology, UInt face); - const UInt *getRefinementEdgePermutation(const Elem::CellTopology &cell_topology, UInt permutation_ordinal); - - } // namespace Elem -} // namespace adapt -} // namespace stk_classic - -#endif // stk_adapt_sierra_element_RefinementTopology_hpp diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.cpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.cpp deleted file mode 100644 index 3b7ea0e77853..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.cpp +++ /dev/null @@ -1,2854 +0,0 @@ -// FIXME - cleanup all the comments with New ref info -/*--------------------------------------------------------------------*/ -/* Copyright 1997 - 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -/** - * NOTE: the text of the RefTopoX tables herein are generated from stk_adapt/UniformRefinerPattern::printRefinementTopoX_Table - * This need only be done once at code development time, or if Intrepid changes their definitions of parametric coordinates. - * Note: these tables could be generated each time the code is run by using a 'bootstrap' method and by changing the types - * of RefTopoX to be a pointer to an array of RefinementTopologyExtra entries that can be allocated and filled on the fly - * in the bootstrap process. However, we liked the idea of being able to view the tables, that's why they are generated - * and pasted in below. - */ - -#include - -#include - -#include -#include -#include - -#include - -#include - - -//using sierra::Diag::Tracespec; -//#define RuntimeError() std::runtime_exception - -namespace stk_classic { - - using namespace percept; - - namespace adapt { - namespace Elem { - - namespace StdMeshObjTopologies { - - enum { NOT_ELEMENT = 0 , PARTICLE = 1, ROD = 2, SHELL = 3 }; - - enum { EUA = END_UINT_ARRAY }; - typedef const Elem::MeshObjTopology * const_top_ptr ; - - static const_top_ptr node(); - static const_top_ptr point(); - static const_top_ptr line( UInt eclass, UInt nnode); - static const_top_ptr tri( UInt eclass, UInt nnode); - static const_top_ptr tri4( UInt eclass); - static const_top_ptr quad( UInt eclass, UInt nnode); - static const_top_ptr tet( UInt nnode); - static const_top_ptr hex( UInt nnode); - static const_top_ptr wedge( UInt nnode); - static const_top_ptr pyramid( UInt nnode); - - // Node topologies - const MeshObjTopology * Node_0(); - - // Edge topologies - const MeshObjTopology * Edge_2(); // Linear 3D edge - const MeshObjTopology * Edge_3(); // Quadratic 3D edge - - // Triangular face topology, has three edges - const MeshObjTopology * Face_Tri_3(); // Triangle face 3N - const MeshObjTopology * Face_Tri_4(); // Triangle face 4N - const MeshObjTopology * Face_Tri_6(); // Triangle face 6N - - // Quadrilateral face topology, has four edges - const MeshObjTopology * Face_Quad_4(); // Quad face 4N - const MeshObjTopology * Face_Quad_8(); // Quad face 8N - const MeshObjTopology * Face_Quad_9(); // Quad face 9N - - // 3D Particle Element topologies - const MeshObjTopology * Particle_1(); - - // 3D Rod Element topology, has ZERO faces and ONE edge - const MeshObjTopology * Rod_2(); - const MeshObjTopology * Rod_3(); - - // 2D Shell Element topology, has TWO edges - const MeshObjTopology * Shell_Line_2(); - const MeshObjTopology * Shell_Line_3(); - - // 3D Triangular Shell Element topology, has TWO faces and THREE edges - const MeshObjTopology * Shell_Tri_3(); - const MeshObjTopology * Shell_Tri_6(); - - // 3D Quadrilateral Shell Element topology, has TWO faces and FOUR edges - const MeshObjTopology * Shell_Quad_4(); - const MeshObjTopology * Shell_Quad_9(); - - // 3D Tetrahedral Solid Element topology, has FOUR faces, 6 EDGES - const MeshObjTopology * Solid_Tet_4(); // 4-Nodes - const MeshObjTopology * Solid_Tet_8(); // 8-Nodes - const MeshObjTopology * Solid_Tet_10(); // 10-Nodes - - // 3D Wedge Solid Element topology, has FIVE faces and NINE edges - const MeshObjTopology * Solid_Wedge_6(); // 6-Nodes - const MeshObjTopology * Solid_Wedge_15(); // 15-Nodes - - // 3D Hexahedral Solid Element topology, has SIX faces and TWELVE edges - const MeshObjTopology * Solid_Hex_8(); // 8-Nodes - const MeshObjTopology * Solid_Hex_20(); // 20-Nodes - const MeshObjTopology * Solid_Hex_27(); // 27-Nodes - - // 3D Pyramid Solid Element topology, has FIVE faces and EIGHT edges - const MeshObjTopology * Solid_Pyramid_5(); // 5-Nodes - const MeshObjTopology * Solid_Pyramid_13(); // 13-Nodes - - const MeshObjTopology * - node() - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology node3D(shards::getCellTopologyData()); - - { - static const_top_ptr node3D_child[] = { & node3D }; - - static UInt child_node[] = { 0 , EUA}; - static UInt * child_node_table[] = { child_node }; - - static RefinementTopology node3D_refinement(&node3D, 1, node3D_child, 1, child_node_table, 0, NULL, 0, NULL, 0, NULL, NULL, false); - } - - return &node3D; - } - - - const MeshObjTopology * - point() - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology part3D(shards::getCellTopologyData()); - - { - static const_top_ptr part3D_child[] = { & part3D }; - - static UInt child_node[] = { 0 , EUA}; - static UInt * child_node_table[] = { child_node }; - - static RefinementTopology part3D_refinement(&part3D, 1, part3D_child, 1, child_node_table, 0, NULL, 0, NULL, 0, NULL, NULL, false); - // static RefinementTopology part3D_refinement(shards::getCellTopologyData(), 1, part3D_child, 1, child_node_table, 0, NULL, 0, NULL, 0, NULL, NULL, false); - } - - return &part3D; - } - - - /*--------------------------------------------------------------------*/ - /** - * 0 1 PARENT Linear Edge Element Nodes (SPACE_DIM = 1!) - * o---------------o - * - * - * After refinement: - * - * - * 0 2 1 CHILD Linear Edge Element Nodes (new nodes = *) - * o-------*-------o - * - * | CHILD Linear Edge Node Maps (global node numbers!) - * 0 1 | - * o-------o | - * E#1 | Element (or edge) 0: childNodeMap[0] = { 0, 2 }; - * | - * 0 1 | - * o-------o | - * E#2 | Element (or edge) 1: childNodeMap[1] = { 2, 1 }; - * - * - * Refined Linear Edge (or Linear Bar element) PERMUTATION Node Maps: - * - * Polarity = 1 { 0, 1; 2 } - * Polarity = 0 { 1, 0; 2 } - * - **/ - - /*--------------------------------------------------------------------*/ - /** - * 0 2 1 PARENT 3-Node Line Object Nodes - * o-------o-------o - * - * - * After refinement: - * - * - * 0 3 2 4 1 CHILD Objects (new nodes = *) - * o---*---o---*---o - * - * - * | CHILD Line Node Maps (global node numbers!) - * 0 2 1 | - * o---o---o | - * E#1 | Object (or line) 0: childNodeMap[0] = { 0, 2, 3 }; - * | - * 0 2 1 | - * o---o---o | - * E#2 | Object (or line) 1: childNodeMap[1] = { 2, 1, 4 }; - * - * - * Refined 3-Node Line Object PERMUTATION Node Maps: - * - * Polarity = 1 { 0, 1, 2; 3, 4 } - * Polarity = 0 { 1, 0, 2; 4, 3 } - * - **/ - - /* New ref topo info Line2 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ - -#include "GeneratedRefinementTable.hpp" - - /*--------------------------------------------------------------------*/ - // Line topologies with 2 or 3 nodes - // eclass == NOT_ELEMENT = > edge - // eclass == ROD - // eclass == SHELL - const MeshObjTopology * - line( - UInt eclass, - UInt nnode) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology edge_2(shards::getCellTopologyData >()); - static MeshObjTopology edge_3(shards::getCellTopologyData >()); - - static MeshObjTopology rod_2(shards::getCellTopologyData >()); - static MeshObjTopology rod_3(shards::getCellTopologyData >()); - - static MeshObjTopology shell_2(shards::getCellTopologyData >()); - static MeshObjTopology shell_3(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Initialize num-child and child-topology - static const_top_ptr edge_2_child[] = { &edge_2 , &edge_2 }; - static const_top_ptr edge_3_child[] = { &edge_3 , &edge_3 }; - - static const_top_ptr rod_2_child[] = { &rod_2 , &rod_2 }; - static const_top_ptr rod_3_child[] = { &rod_3 , &rod_3 }; - - static const_top_ptr shell_2_child[] = { &shell_2 , &shell_2 }; - static const_top_ptr shell_3_child[] = { &shell_3 , &shell_3 }; - - static const UInt child_0[] = { 0 , 2 , 3 , EUA}; - static const UInt child_1[] = { 2 , 1 , 4 , EUA}; - static const UInt * child_node_table[] = { child_0 , child_1 }; - - // Initialize edge permutations - static const UInt perm_P1[] = { 0, 1, 2, 3, 4 , EUA}; // Vertices + children - static const UInt perm_P0[] = { 1, 0, 2, 4, 3 , EUA}; // Vertices + children - static const UInt * perm_table[2] = { NULL , NULL }; // Polarity only - - if ( perm_table[0] == NULL ) { - perm_table[ 0 ] = perm_P1 ; - perm_table[ 1 ] = perm_P0 ; - } - - // Initialize rod-edge and shell-edge - - static const UInt edge_0[] = { 0 , 1 , 2 , 3 , 4 , EUA}; - static const UInt edge_1[] = { 1 , 0 , 2 , 4 , 3 , EUA}; - static const UInt * edge_table[] = { edge_0 , edge_1 }; - -// static RefinementTopology edge_2_refinement(&edge_2, 2, edge_2_child, 3, child_node_table, 0, NULL, 0, NULL, 2, perm_table, NULL, true); -// static RefinementTopology edge_3_refinement(&edge_3, 2, edge_3_child, 5, child_node_table, 0, NULL, 0, NULL, 2, perm_table, NULL, true); - - static RefinementTopology edge_2_refinement(&edge_2, 2, edge_2_child, 3, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - static RefinementTopology edge_3_refinement(&edge_3, 2, edge_3_child, 5, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - - static RefinementTopology rod_2_refinement(&rod_2, 2, rod_2_child, 3, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - static RefinementTopology rod_3_refinement(&rod_3, 2, rod_3_child, 5, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - - static RefinementTopology shell_2_refinement(&shell_2, 2, shell_2_child, 3, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - static RefinementTopology shell_3_refinement(&shell_3, 2, shell_3_child, 5, child_node_table, 2, edge_table, 0, NULL, 2, perm_table, NULL, true); - } - } - - MeshObjTopology * top = NULL ; - - switch( ( eclass << 8 ) | ( nnode << 4 ) ) { - case 0x0020 : top = & edge_2 ; break ; - case 0x0030 : top = & edge_3 ; break ; - case 0x0220 : top = & rod_2 ; break ; - case 0x0230 : top = & rod_3 ; break ; - case 0x0320 : top = & shell_2 ; break ; - case 0x0330 : top = & shell_3 ; break ; - default : - //throw RuntimeError() << "Invalid eclass and nnode specified" << std::endl;// << StackTrace; - throw std::runtime_error( "Invalid eclass and nnode specified") ; // << std::endl;// << StackTrace; - } - - return top ; - } - - - /*--------------------------------------------------------------------*/ - /** - * 3 2 PARENT Linear 4-Node Quadrilateral Element Nodes - * o---------------o (SPACE_DIM = 2!) - * | | - * | | - * | | - * | | - * | | (PARENT) Linear 4-Node Quadrilateral - * | | Element Edge Node Map: - * | | - * | | { {0, 1}, {1, 2}, {2, 3} {3, 0} }; - * | | - * o---------------o - * 0 1 - * - * After refinement: - * - * 3 6 2 CHILD Linear 4-Node Quadrilateral Element Nodes - * o-------*-------o (SPACE_DIM = 2!) (new nodes = *) - * | | | - * | | | - * | | | - * | 8| | - * 7*-------*-------*5 - * | | | - * | | | - * | | | - * | | | - * o-------*-------o - * 0 4 1 | CHILD Linear 4-Node Quadrilateral Element Node Maps: - * | - * | - * | Element 0: childNodeMap[0] = { 0, 4, 8, 7 } - * | Element 1: childNodeMap[1] = { 4, 1, 5, 8 } - * | Element 2: childNodeMap[2] = { 8, 5, 2, 6 } - * | Element 3: childNodeMap[3] = { 7, 8, 6, 3 } - * | - * - * New ref topo info Quad4 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - * { - * {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - * {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - * {2, 0, 2, 0, 1, {1.0, 1.0, 0.0} }, - * {3, 0, 3, 0, 1, {0.0, 1.0, 0.0} }, - * {4, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - * {5, 1, 1, 0, 1, {1.0, 0.5, 0.0} }, - * {6, 1, 2, 0, 1, {0.5, 1.0, 0.0} }, - * {7, 1, 3, 0, 1, {0.0, 0.5, 0.0} }, - * {8, 2, 0, 0, 1, {0.5, 0.5, 0.0} } - * } - * - * Refined Linear 4-Node Quadrilateral Element PERMUTATION Node Maps: - * - * Rotation Polarity - * 0 1 { 0, 1, 2, 3; 4, 5, 6, 7, 8 } - * 0 0 { 0, 3, 2, 1; 7, 6, 5, 4, 8 } - * 1 1 { 3, 0, 1, 2; 7, 4, 5, 6, 8 } - * 1 0 { 3, 2, 1, 0; 6, 5, 4, 7, 8 } - * 2 1 { 2, 3, 0, 1; 6, 7, 4, 5, 8 } - * 2 0 { 2, 1, 0, 3; 5, 4, 7, 6, 8 } - * 3 1 { 1, 2, 3, 0; 5, 6, 7, 4, 8 } - * 3 0 { 1, 0, 3, 2; 4, 7, 6, 5, 8 } - * - */ - /*--------------------------------------------------------------------*/ - /** - * 3 6 2 PARENT 9-Node Quadrilateral Object Nodes - * o-------o-------o - * | | - * | | - * | 8 | - * 7 o o o 5 (PARENT) 9-Node Quadrilateral Object's - * | | Edge Node Map: - * | | - * | | { {0, 1, 4}, {1, 2, 5}, {2, 3, 6} {3, 0, 7} }; - * o-------o-------o - * 0 4 1 - * - * - * After refinement: - * - * 3 14 6 13 2 CHILD 9-Node Quadrilateral Object Nodes - * o----*----o----*----o (new nodes = *) - * | | | - * | 24 | 23 | - * 15* * *19 * *12 - * | | | - * | 8| 18 | - * 7 o----*----o----*----o 5 - * | 20 | | - * | | | - * 16* * 17* * *11 - * | 21 | 22 | - * | | | - * o----*----o----*----o - * 0 9 4 10 1 - * - * CHILD 9-Node Quadrilateral Object Node Maps: - * | - * | - * | Object 0: childNodeMap[0] = { 0, 4, 8, 7, 9, 17, 20, 16; 21 } - * | Object 1: childNodeMap[1] = { 4, 1, 5, 8, 10, 11, 18, 17; 22 } - * | Object 2: childNodeMap[2] = { 8, 5, 2, 6, 18, 12, 13, 19; 23 } - * | Object 3: childNodeMap[3] = { 7, 8, 6, 3, 20, 19, 14, 15; 24 } - * | - * New ref topo info Quad9 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - * { - * {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - * {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - * {2, 0, 2, 0, 1, {1.0, 1.0, 0.0} }, - * {3, 0, 3, 0, 1, {0.0, 1.0, 0.0} }, - * {4, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - * {5, 1, 1, 0, 1, {1.0, 0.5, 0.0} }, - * {6, 1, 2, 0, 1, {0.5, 1.0, 0.0} }, - * {7, 1, 3, 0, 1, {0.0, 0.5, 0.0} }, - * {8, 2, 0, 8, 9, {0.5, 0.5, 0.0} }, - * - * {9, 1, 0, 1, 3, {0.25, 0.00, 0.00} }, - * {10, 1, 0, 2, 3, {0.75, 0.00, 0.00} }, - * {11, 1, 1, 1, 3, {1.00, 0.25, 0.00} }, - * {12, 1, 1, 2, 3, {1.00, 0.75, 0.00} }, - * {13, 1, 2, 1, 3, {0.75, 1.00, 0.00} }, - * {14, 1, 2, 2, 3, {0.25, 1.00, 0.00} }, - * {15, 1, 3, 1, 3, {0.00, 0.75, 0.00} }, - * {16, 1, 3, 2, 3, {0.00, 0.25, 0.00} } - - * {17, 2, 0, 4, 9, {0.50, 0.25, 0.00} }, - * {18, 2, 0, 5, 9, {0.75, 0.50, 0.00} }, - * {19, 2, 0, 6, 9, {0.50, 0.75, 0.00} }, - * {20, 2, 0, 7, 9, {0.25, 0.50, 0.00} }, - * - * {21, 2, 0, 0, 9, {0.25, 0.25, 0.00} }, - * {22, 2, 0, 1, 9, {0.75, 0.25, 0.00} }, - * {23, 2, 0, 2, 9, {0.75, 0.75, 0.00} }, - * {24, 2, 0, 3, 9, {0.25, 0.75, 0.00} }, - * - * - * - * } - * - * Refined 9-Node Quadrilateral Object PERMUTATION Node Maps: - * - * Rotation Polarity - * 0 1 { 0, 1, 2, 3, 4, 5, 6, 7; 8, 9, 10, 11, 12, 13, 14, 15, 16, - * 17, 18, 19, 20, 21, 22, 23, 24 } - * 0 0 { 0, 3, 2, 1, 7, 6, 5, 4; 8, 16, 15, 14, 13, 12, 11, 10, 9, - * 20, 19, 18, 17, 21, 24, 23, 22 } - * 1 1 { 3, 0, 1, 2, 7, 4, 5, 6; 8, 15, 16, 9, 10, 11, 12, 13, 14, - * 20, 17, 18, 19, 24, 21, 22, 23 } - * 1 0 { 3, 2, 1, 0, 6, 5, 4, 7; 8, 14, 13, 12, 11, 10, 9, 16, 15, - * 19, 18, 17, 20, 24, 23, 22, 21 } - * 1 1 { 1, 2, 3, 0, 5, 6, 7, 4; 8, 11, 12, 13, 14, 15, 16, 9, 10, - * 18, 19, 20, 17, 22, 23, 24, 21 } - * 1 0 { 1, 0, 3, 2, 4, 7, 6, 5; 8, 10, 9, 16, 15, 14, 13, 12, 11, - * 17, 20, 19, 18, 22, 21, 24, 23 } - * 3 1 { 2, 3, 0, 1, 6, 7, 4, 5; 8, 13, 14, 15, 16, 9, 10, 11, 12, - * 19, 20, 17, 18, 23, 24, 21, 22 } - * 3 0 { 2, 1, 0, 3, 5, 4, 7, 6; 8, 12, 11, 10, 9, 16, 15, 14, 13, - * 18, 17, 20, 19, 23, 22, 21, 24 } - * - **/ - /*--------------------------------------------------------------------*/ - // Quadrilateral with 4, 8, or 9 nodes. Face, shell, or 2D solid. - // eclass == NOT_ELEMENT = > face in 3D - // eclass == SHELL = > element in 3D - // eclass == SOLID = > element in 2D - - const MeshObjTopology * - quad(UInt eclass, UInt nnode) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology face_4(shards::getCellTopologyData >()); - static MeshObjTopology face_8(shards::getCellTopologyData >()); - static MeshObjTopology face_9(shards::getCellTopologyData >()); - - static MeshObjTopology shell_4(shards::getCellTopologyData >()); - static MeshObjTopology shell_8(shards::getCellTopologyData >()); - static MeshObjTopology shell_9(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Child topologies and child nodes - - static const_top_ptr - face_4_child[] = { &face_4, &face_4, &face_4, &face_4 }; - static const_top_ptr - face_8_child[] = { &face_8, &face_8, &face_8, &face_8 }; - static const_top_ptr - face_9_child[] = { &face_9, &face_9, &face_9, &face_9 }; - - static const_top_ptr - shell_4_child[] = {&shell_4, &shell_4, &shell_4, &shell_4}; - static const_top_ptr - shell_8_child[] = {&shell_8, &shell_8, &shell_8, &shell_8}; - static const_top_ptr - shell_9_child[] = {&shell_9, &shell_9, &shell_9, &shell_9}; - - static const UInt child_0[] = { 0, 4, 8, 7, 9, 17, 20, 16, 21 , EUA}; - static const UInt child_1[] = { 4, 1, 5, 8, 10, 11, 18, 17, 22 , EUA}; - static const UInt child_2[] = { 8, 5, 2, 6, 18, 12, 13, 19, 23 , EUA}; - static const UInt child_3[] = { 7, 8, 6, 3, 20, 19, 14, 15, 24 , EUA}; - - static const UInt * child_node_table[] = {child_0, child_1, child_2, child_3}; - - // Face permutations - // Permutation tables including children [ 2 * number_of_vertices ] - // Five groups of nodes: - // a) vertices - // b) outer edge mid-points + centroid - // c) outer edge quarter points - // d) inner edge mid-points - // e) child centroid - - static const UInt perm_P1_R0[] = { 0, 1, 2, 3, - 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, - 21, 22, 23, 24 , EUA}; - - static const UInt perm_P1_R1[] = { 3, 0, 1, 2, - 7, 4, 5, 6, 8, - 15, 16, 9, 10, 11, 12, 13, 14, - 20, 17, 18, 19, - 24, 21, 22, 23 , EUA}; - - static const UInt perm_P1_R2[] = { 2, 3, 0, 1, - 6, 7, 4, 5, 8, - 13, 14, 15, 16, 9, 10, 11, 12, - 19, 20, 17, 18, - 23, 24, 21, 22 , EUA}; - - static const UInt perm_P1_R3[] = { 1, 2, 3, 0, - 5, 6, 7, 4, 8, - 11, 12, 13, 14, 15, 16, 9, 10, - 18, 19, 20, 17, - 22, 23, 24, 21 , EUA}; - - static const UInt perm_P0_R0[] = { 0, 3, 2, 1, - 7, 6, 5, 4, 8, - 16, 15, 14, 13, 12, 11, 10, 9, - 20, 19, 18, 17, - 21, 24, 23, 22 , EUA}; - - static const UInt perm_P0_R1[] = { 3, 2, 1, 0, - 6, 5, 4, 7, 8, - 14, 13, 12, 11, 10, 9, 16, 15, - 19, 18, 17, 20, - 24, 23, 22, 21 , EUA}; - - static const UInt perm_P0_R2[] = { 2, 1, 0, 3, - 5, 4, 7, 6, 8, - 12, 11, 10, 9, 16, 15, 14, 13, - 18, 17, 20, 19, - 23, 22, 21, 24 , EUA}; - - static const UInt perm_P0_R3[] = { 1, 0, 3, 2, - 4, 7, 6, 5, 8, - 10, 9, 16, 15, 14, 13, 12, 11, - 17, 20, 19, 18, - 22, 21, 24, 23 , EUA}; - - - static const UInt * perm_table[] = { NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL }; - - perm_table[ 0 ] = perm_P1_R0 ; - perm_table[ 1 ] = perm_P1_R1 ; - perm_table[ 2 ] = perm_P1_R2 ; - perm_table[ 3 ] = perm_P1_R3 ; - perm_table[ 4 ] = perm_P0_R0 ; - perm_table[ 5 ] = perm_P0_R1 ; - perm_table[ 6 ] = perm_P0_R2 ; - perm_table[ 7 ] = perm_P0_R3 ; - - // Face edge permutations - // Permutation tables [ 2 * number_of_vertices ] - - static const UInt edge_perm_P1_R0[] = { 0, 1, 2, 3 , EUA}; - static const UInt edge_perm_P1_R1[] = { 3, 0, 1, 2 , EUA}; - static const UInt edge_perm_P1_R2[] = { 2, 3, 0, 1 , EUA}; - static const UInt edge_perm_P1_R3[] = { 1, 2, 3, 0 , EUA}; - static const UInt edge_perm_P0_R0[] = { 3, 2, 1, 0 , EUA}; - static const UInt edge_perm_P0_R1[] = { 2, 1, 0, 3 , EUA}; - static const UInt edge_perm_P0_R2[] = { 1, 0, 3, 2 , EUA}; - static const UInt edge_perm_P0_R3[] = { 0, 3, 2, 1 , EUA}; - - static const UInt * edge_perm_table[] = { NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL }; - - edge_perm_table[ 0 ] = edge_perm_P1_R0 ; - edge_perm_table[ 1 ] = edge_perm_P1_R1 ; - edge_perm_table[ 2 ] = edge_perm_P1_R2 ; - edge_perm_table[ 3 ] = edge_perm_P1_R3 ; - edge_perm_table[ 4 ] = edge_perm_P0_R0 ; - edge_perm_table[ 5 ] = edge_perm_P0_R1 ; - edge_perm_table[ 6 ] = edge_perm_P0_R2 ; - edge_perm_table[ 7 ] = edge_perm_P0_R3 ; - - // Edge topology and node tables including edges' child-nodes - static const UInt edge_0[] = { 0, 1, 4, 9, 10 , EUA}; - static const UInt edge_1[] = { 1, 2, 5, 11, 12 , EUA}; - static const UInt edge_2[] = { 2, 3, 6, 13, 14 , EUA}; - static const UInt edge_3[] = { 3, 0, 7, 15, 16 , EUA}; - static const UInt * edge_table[] = { edge_0 , edge_1 , edge_2 , edge_3 }; - - // 3D Shell has two faces - - static const UInt face_0[] = { 0, 1, 2, 3, - 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, - 21, 22, 23, 24 , EUA}; - - static const UInt face_1[] = { 0, 3, 2, 1, - 7, 6, 5, 4, 8, - 16, 15, 14, 13, 12, 11, 10, 9, - 20, 19, 18, 17, - 21, 24, 23, 22 , EUA}; - - static const UInt * face_table[] = { face_0 , face_1 }; - - static RefinementTopology face_4_refinement(&face_4, 4, face_4_child, 9, child_node_table, 4, edge_table, 0, NULL, 8, perm_table, edge_perm_table, true); - static RefinementTopology face_8_refinement(&face_8, 4, face_8_child, 21, child_node_table, 4, edge_table, 0, NULL, 8, perm_table, edge_perm_table, true); - static RefinementTopology face_9_refinement(&face_9, 4, face_9_child, 25, child_node_table, 4, edge_table, 0, NULL, 8, perm_table, edge_perm_table, true); - - static RefinementTopology shell_4_refinement(&shell_4, 4, shell_4_child, 9, child_node_table, 4, edge_table, 2, face_table, 0, NULL, NULL, true); - static RefinementTopology shell_8_refinement(&shell_8, 4, shell_8_child, 21, child_node_table, 4, edge_table, 2, face_table, 0, NULL, NULL, true); - static RefinementTopology shell_9_refinement(&shell_9, 4, shell_9_child, 25, child_node_table, 4, edge_table, 2, face_table, 0, NULL, NULL, true); - } - } - - //-------------------------------------------------------------------- - - MeshObjTopology * top = NULL ; - - switch( ( eclass << 8 ) | ( nnode << 4 ) ) { - case 0x0040 : top = &face_4 ; break ; - case 0x0080 : top = &face_8 ; break ; - case 0x0090 : top = &face_9 ; break ; - case 0x0340 : top = &shell_4 ; break ; - case 0x0380 : top = &shell_8 ; break ; - case 0x0390 : top = &shell_9 ; break ; - default: - //throw RuntimeError() << "Invalid eclass and nnode specified" << std::endl;// << StackTrace; - throw std::runtime_error( "Invalid eclass and nnode specified") ; // << std::endl;// << StackTrace; - } - - return top ; - } - - /* New ref topo info Quad4 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ -#if 0 - template<> - RefTopoX - RefinementTopologyExtra< shards::Quadrilateral<4> >::refinement_topology = - { - {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - {2, 0, 2, 0, 1, {1.0, 1.0, 0.0} }, - {3, 0, 3, 0, 1, {0.0, 1.0, 0.0} }, - {4, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - {5, 1, 1, 0, 1, {1.0, 0.5, 0.0} }, - {6, 1, 2, 0, 1, {0.5, 1.0, 0.0} }, - {7, 1, 3, 0, 1, {0.0, 0.5, 0.0} }, - {8, 2, 0, 0, 1, {0.5, 0.5, 0.0} } - }; -#endif - /* New ref topo info Quad9 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ - -#if 0 - template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<9> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {-1, -1, 0} }, - { 1, 0, 1, 0, 1, {1, -1, 0} }, - { 2, 0, 2, 0, 1, {1, 1, 0} }, - { 3, 0, 3, 0, 1, {-1, 1, 0} }, - { 4, 1, 0, 0, 3, {0, -1, 0} }, - { 5, 1, 1, 0, 3, {1, 0, 0} }, - { 6, 1, 2, 0, 3, {0, 1, 0} }, - { 7, 1, 3, 0, 3, {-1, 0, 0} }, - { 8, 2, 0, 0, 9, {0, 0, 0} }, - { 9, 1, 0, 1, 3, {-0.5, -1, 0} }, - { 10, 1, 0, 2, 3, {0.5, -1, 0} }, - { 11, 1, 1, 1, 3, {1, -0.5, 0} }, - { 12, 1, 1, 2, 3, {1, 0.5, 0} }, - { 13, 1, 2, 1, 3, {0.5, 1, 0} }, - { 14, 1, 2, 2, 3, {-0.5, 1, 0} }, - { 15, 1, 3, 1, 3, {-1, 0.5, 0} }, - { 16, 1, 3, 2, 3, {-1, -0.5, 0} }, - { 17, 2, 0, 1, 9, {0, -0.5, 0} }, - { 18, 2, 0, 2, 9, {0.5, 0, 0} }, - { 19, 2, 0, 3, 9, {0, 0.5, 0} }, - { 20, 2, 0, 4, 9, {-0.5, 0, 0} }, - { 21, 2, 0, 5, 9, {-0.5, -0.5, 0} }, - { 22, 2, 0, 6, 9, {0.5, -0.5, 0} }, - { 23, 2, 0, 7, 9, {0.5, 0.5, 0} }, - { 24, 2, 0, 8, 9, {-0.5, 0.5, 0} } - - }; -#endif - - /*--------------------------------------------------------------------*/ - /** - * 2 PARENT Linear 3-Node Triangle Element Nodes - * o (SPACE_DIM = 2!) - * / \ - * / \ (PARENT) Linear 3-Node Triangle Edge Node Map: - * / \ - * / \ { {0, 1}, {1, 2}, {2, 0} }; - * / \ - * / \ - * / \ - * o---------------o - * 0 1 - * - * After refinement: - * - * 2 CHILD Linear 3-Node Triangle Element Nodes - * o (new nodes = *) - * / \ - * / \ - * / \ - * 5 *-------* 4 - * / \ / \ - * / \ / \ - * / \ / \ - * o-------*-------o - * 0 3 1 - * - * | CHILD Linear 3-Node Triangle Element Node Maps: - * | - * | - * | static const UInt child_0[] = { 0, 3, 5 }; - * | static const UInt child_1[] = { 3, 1, 4 }; - * | static const UInt child_2[] = { 5, 4, 2 }; - * | static const UInt child_3[] = { 4, 5, 3 }; - * | - */ - - /* New ref topo info Tri3 - * ------------------ - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ -#if 0 - template<> - RefTopoX - RefinementTopologyExtra< shards::Triangle<3> >::refinement_topology = - { - {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - {2, 0, 2, 0, 1, {0.0, 1.0, 0.0} }, - - {3, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - {4, 1, 1, 0, 1, {0.5, 0.5, 0.0} }, - {5, 1, 2, 0, 1, {0.0, 0.5, 0.0} }, - - }; -#endif - - /* Refined Linear 3-Node Triangle Element PERMUTATION Node Maps: - * - * Rotation Polarity - * 0 1 { 0, 1, 2; 3, 4, 5 } - * 0 0 { 0, 2, 1; 5, 4, 3 } - * 1 1 { 2, 0, 1; 5, 3, 4 } - * 1 0 { 2, 1, 0; 4, 3, 5 } - * 2 1 { 1, 2, 0; 4, 5, 3 } - * 2 0 { 1, 0, 2; 3, 5, 4 } - * - */ - - /*--------------------------------------------------------------------*/ - /** - * 2 PARENT 6-Node Triangle Object Nodes - * o - * / \ - * / \ (PARENT) 6-Node Triangle Object Edge Node Map: - * / \ - * 5 o o 4 { {0, 1, 3}, {1, 2, 4}, {2, 0, 5} }; - * / \ - * / \ - * / \ - * o-------o-------o - * 0 3 1 - * - * After refinement: - * - * 2 CHILD 6-Node Triangle Object Nodes - * o (new nodes = *) - * / \ - * 10 * * 9 - * / 14 \ - * 5 o---*---o 4 - * / \ / \ - * 11 * 12* *13 * 8 - * / \ / \ - * o---*---o---*---o - * 0 6 3 7 1 - * - * | CHILD 6-Node Triangle Object Node Maps: - * | - * | static const UInt child_0[] = { 0, 3, 5, 6, 12, 11 }; - * | static const UInt child_1[] = { 3, 1, 4, 7, 8, 13 }; - * | static const UInt child_2[] = { 5, 4, 2, 14, 9, 10 }; - * | static const UInt child_3[] = { 4, 5, 3, 14, 12, 13 }; - * | - * - * Refined 6-Node Triangle Object PERMUTATION Node Maps: - * - * Rotation Polarity - * 0 1 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; - * 0 0 { 0, 2, 1, 5, 4, 3, 11, 10, 9, 8, 7, 6, 12, 14, 13 }; - * 1 1 { 2, 0, 1, 5, 3, 4, 10, 11, 6, 7, 8, 9, 14, 12, 13 }; - * 1 0 { 2, 1, 0, 4, 3, 5, 9, 8, 7, 6, 11, 10, 14, 13, 12 }; - * 2 1 { 1, 2, 0, 4, 5, 3, 8, 9, 10, 11, 6, 7, 13, 14, 12 }; - * 2 0 { 1, 0, 2, 3, 5, 4, 7, 6, 11, 10, 9, 8 13, 12, 14 }; - * - **/ - - /*--------------------------------------------------------------------*/ - // Triangle with 3 or 6 nodes. Face, shell, or 2D solid. - // eclass == NOT_ELEMENT = > sdim == 3 && mdim == 2 - // eclass == SOLID = > sdim == 2 && mdim == 2 - // eclass == SHELL = > sdim == 3 && mdim == 3 - const MeshObjTopology * - tri(UInt eclass, UInt nnode) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology face_3(shards::getCellTopologyData >()); - static MeshObjTopology face_6(shards::getCellTopologyData >()); - static MeshObjTopology shell_3(shards::getCellTopologyData >()); - static MeshObjTopology shell_6(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Child topologies and child nodes - - static const_top_ptr - face_3_child[] = { &face_3, &face_3, &face_3, &face_3 }; - static const_top_ptr - face_6_child[] = { &face_6, &face_6, &face_6, &face_6 }; - - static const_top_ptr - shell_3_child[] = {&shell_3, &shell_3, &shell_3, &shell_3}; - static const_top_ptr - shell_6_child[] = {&shell_6, &shell_6, &shell_6, &shell_6}; - - static const UInt child_0[] = { 0, 3, 5, 6, 12, 11 , EUA}; - static const UInt child_1[] = { 3, 1, 4, 7, 8, 13 , EUA}; - static const UInt child_2[] = { 5, 4, 2, 14, 9, 10 , EUA}; - static const UInt child_3[] = { 4, 5, 3, 14, 12, 13 , EUA}; - - static const UInt * child_node_table[4] = - { child_0, child_1, child_2, child_3 }; - - - // Permutation tables including children [ 2 * number_of_vertices ] - - static const UInt perm_P1_R0[] = { 0, 1, 2, - 3, 4, 5, - 6, 7, 8, 9, 10, 11, - 12, 13, 14 , EUA}; - - static const UInt perm_P1_R1[] = { 2, 0, 1, - 5, 3, 4, - 10, 11, 6, 7, 8, 9, - 14, 12, 13 , EUA}; - - static const UInt perm_P1_R2[] = { 1, 2, 0, - 4, 5, 3, - 8, 9, 10, 11, 6, 7, - 13, 14, 12 , EUA}; - static const UInt perm_P0_R0[] = { 0, 2, 1, - 5, 4, 3, - 11, 10, 9, 8, 7, 6, - 12, 14, 13 , EUA}; - - static const UInt perm_P0_R1[] = { 2, 1, 0, - 4, 3, 5, - 9, 8, 7, 6, 11, 10, - 14, 13, 12 , EUA}; - - static const UInt perm_P0_R2[] = { 1, 0, 2, - 3, 5, 4, - 7, 6, 11, 10, 9, 8, - 13, 12, 14 , EUA}; - - - static const UInt * perm_table[] = { NULL, NULL, NULL, NULL, NULL, NULL }; - - perm_table[ 0 ] = perm_P1_R0 ; - perm_table[ 1 ] = perm_P1_R1 ; - perm_table[ 2 ] = perm_P1_R2 ; - perm_table[ 3 ] = perm_P0_R0 ; - perm_table[ 4 ] = perm_P0_R1 ; - perm_table[ 5 ] = perm_P0_R2 ; - - // Edge permutation tables [ 2 * number_of_vertices ] - - static const UInt edge_perm_P1_R0[] = { 0, 1, 2 , EUA}; - static const UInt edge_perm_P1_R1[] = { 2, 0, 1 , EUA}; - static const UInt edge_perm_P1_R2[] = { 1, 2, 0 , EUA}; - static const UInt edge_perm_P0_R0[] = { 2, 1, 0 , EUA}; - static const UInt edge_perm_P0_R1[] = { 1, 0, 2 , EUA}; - static const UInt edge_perm_P0_R2[] = { 0, 2, 1 , EUA}; - - static const UInt * edge_perm_table[] = { NULL, NULL, NULL, NULL, NULL, NULL }; - - edge_perm_table[ 0 ] = edge_perm_P1_R0 ; - edge_perm_table[ 1 ] = edge_perm_P1_R1 ; - edge_perm_table[ 2 ] = edge_perm_P1_R2 ; - edge_perm_table[ 3 ] = edge_perm_P0_R0 ; - edge_perm_table[ 4 ] = edge_perm_P0_R1 ; - edge_perm_table[ 5 ] = edge_perm_P0_R2 ; - - // Edge topology and node tables including edges' child-nodes - static const UInt edge_0[] = { 0, 1, 3, 6, 7 , EUA}; - static const UInt edge_1[] = { 1, 2, 4, 8, 9 , EUA}; - static const UInt edge_2[] = { 2, 0, 5, 10, 11 , EUA}; - static const UInt * edge_table[3] = { edge_0 , edge_1 , edge_2 }; - - // 3D shells have two faces - static const UInt face_0[] = { 0, 1, 2, - 3, 4, 5, - 6, 7, 8, 9, 10, 11, - 12, 13, 14 , EUA}; - - static const UInt face_1[] = { 0, 2, 1, - 5, 4, 3, - 11, 10, 9, 8, 7, 6, - 12, 14, 13, EUA}; - - static const UInt * face_table[] = { face_0 , face_1 }; - - static RefinementTopology face_3_refinement(&face_3, 4, face_3_child, 6, child_node_table, 3, edge_table, 0, NULL, 6, perm_table, edge_perm_table, true); - static RefinementTopology face_6_refinement(&face_6, 4, face_6_child, 15, child_node_table, 3, edge_table, 0, NULL, 6, perm_table, edge_perm_table, true); - static RefinementTopology shell_3_refinement(&shell_3, 4, shell_3_child, 6, child_node_table, 3, edge_table, 2, face_table, 0, NULL, NULL, true); - static RefinementTopology shell_6_refinement(&shell_6, 4, shell_6_child, 15, child_node_table, 3, edge_table, 2, face_table, 0, NULL, NULL, true); - } - } - - MeshObjTopology * top = NULL ; - - switch( ( eclass << 8 ) | ( nnode << 4 ) ) { - case 0x0030 : top = &face_3 ; break ; - case 0x0060 : top = &face_6 ; break ; - case 0x0330 : top = &shell_3 ; break ; - case 0x0360 : top = &shell_6 ; break ; - case 0x0430 : top = &face_3 ; break ; - case 0x0460 : top = &face_6 ; break ; - default: - //throw RuntimeError() << "Invalid eclass and nnode specified" << std::endl ;// << StackTrace; - throw std::runtime_error( "Invalid eclass and nnode specified") ; // << std::endl ;// << StackTrace; - } - - return top ; - } - - - /*-------------------------------------------------------------------*/ - /** - * 2 PARENT 4-Node Triangle Object Nodes - * o - * / \ - * / \ (PARENT) 4-Node Triangle Object Edge Node Map: - * / \ - * / \ { {0, 1}, {1, 2}, {2, 0} }; - * / o \ - * / 3 \ - * / \ - * o---------------o - * 0 1 - * - * - * After refinement: - * - * 2 CHILD 4-Node Triangle Object Nodes - * o (new nodes = *) - * / \ - * / 9 \ - * / * \ - * 6 *-------* 5 - * / \ o / \ - * / 7 \ 3 / 8 \ - * / * \ / * \ - * o-------*-------o - * 0 4 1 - * - * | CHILD 4-Node Triangle Object Node Maps: - * | - * | static const UInt child_0[] = { 0, 4, 6, 7 }; - * | static const UInt child_1[] = { 4, 1, 5, 8 }; - * | static const UInt child_2[] = { 6, 5, 2, 9 }; - * | static const UInt child_3[] = { 5, 6, 4, 3 }; - * | - * - * 4-Node Triangle Object PERMUTATION Node Maps: - * - * Original Parent 4-Node Triangle Object: - * Rotation Polarity - * 0 1 { 0, 1, 2, 3 } - * 0 0 { 0, 2, 1, 3 } - * 1 1 { 2, 0, 1, 3 } - * 1 0 { 2, 1, 0, 3 } - * 2 1 { 1, 2, 0, 3 } - * 2 0 { 1, 0, 2, 3 } - * - * After Refinement and using child node numbering: - * Rotation Polarity - * - * 0 1 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - * 0 0 { 0, 2, 1, 3, 6, 5, 4, 7, 9, 8 }; - * 1 1 { 2, 0, 1, 3, 6, 4, 5, 9, 7, 8 }; - * 1 0 { 2, 1, 0, 3, 6, 5, 4, 9, 8, 7 }; - * 2 1 { 1, 2, 0, 3, 5, 6, 4, 8, 9, 7 }; - * 2 0 { 1, 0, 2, 3, 4, 6, 5, 8, 7, 9 }; - * - */ - - /*-------------------------------------------------------------------*/ - // Triangle with 4 nodes. Face, or 2D solid. - // eclass == NOT_ELEMENT - // eclass == SOLID - const MeshObjTopology * - tri4( UInt /* eclass */) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology face_4(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Child topologies and child nodes - - static const_top_ptr face_4_child[] = - { &face_4 , &face_4 , &face_4 , &face_4 }; - - static const UInt child_0[] = { 0, 4, 6, 7 , EUA}; - static const UInt child_1[] = { 4, 1, 5, 8 , EUA}; - static const UInt child_2[] = { 6, 5, 2, 9 , EUA}; - static const UInt child_3[] = { 5, 6, 4, 3 , EUA}; - - static const UInt * child_node_table[] = {child_0, child_1, child_2, child_3}; - - // Permutation tables including children [ 2 * number_of_vertices ] - - static const UInt perm_P1_R0[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , EUA}; - static const UInt perm_P1_R1[] = { 2, 0, 1, 3, 6, 4, 5, 9, 7, 8 , EUA}; - static const UInt perm_P1_R2[] = { 1, 2, 0, 3, 5, 6, 4, 8, 9, 7 , EUA}; - static const UInt perm_P0_R0[] = { 0, 2, 1, 3, 6, 5, 4, 7, 9, 8 , EUA}; - static const UInt perm_P0_R1[] = { 2, 1, 0, 3, 5, 4, 6, 9, 8, 7 , EUA}; - static const UInt perm_P0_R2[] = { 1, 0, 2, 3, 4, 6, 5, 8, 7, 9 , EUA}; - - static const UInt * perm_table[] = { NULL, NULL, NULL, NULL, NULL, NULL }; - - perm_table[ 0 ] = perm_P1_R0 ; - perm_table[ 1 ] = perm_P1_R1 ; - perm_table[ 2 ] = perm_P1_R2 ; - perm_table[ 3 ] = perm_P0_R0 ; - perm_table[ 4 ] = perm_P0_R1 ; - perm_table[ 5 ] = perm_P0_R2 ; - - // Edge permutation tables [ 2 * number_of_vertices ] - - static const UInt edge_perm_P1_R0[] = { 0, 1, 2 , EUA}; - static const UInt edge_perm_P1_R1[] = { 2, 0, 1 , EUA}; - static const UInt edge_perm_P1_R2[] = { 1, 2, 0 , EUA}; - static const UInt edge_perm_P0_R0[] = { 2, 1, 0 , EUA}; - static const UInt edge_perm_P0_R1[] = { 1, 0, 2 , EUA}; - static const UInt edge_perm_P0_R2[] = { 0, 2, 1 , EUA}; - - static const UInt * edge_perm_table[] = { NULL, NULL, NULL, NULL, NULL, NULL }; - - edge_perm_table[ 0 ] = edge_perm_P1_R0 ; - edge_perm_table[ 1 ] = edge_perm_P1_R1 ; - edge_perm_table[ 2 ] = edge_perm_P1_R2 ; - edge_perm_table[ 3 ] = edge_perm_P0_R0 ; - edge_perm_table[ 4 ] = edge_perm_P0_R1 ; - edge_perm_table[ 5 ] = edge_perm_P0_R2 ; - - // Edge topology and node tables including edges' child-nodes - - static const UInt edge_0[] = { 0, 1, 4 , EUA}; - static const UInt edge_1[] = { 1, 2, 5 , EUA}; - static const UInt edge_2[] = { 2, 0, 6 , EUA}; - static const UInt * edge_table[] = { edge_0 , edge_1 , edge_2 }; - - static RefinementTopology face_4_refinement(&face_4, 4, face_4_child, 10, child_node_table, 3, edge_table, 0, NULL, 6, perm_table, edge_perm_table, false); - } - } - - MeshObjTopology * const top = &face_4 ; - - return top ; - } - - /*--------------------------------------------------------------------*/ - /** - * PARENT Linear 8-Node Hexahedron Nodes - * 7 6 (SPACE_DIM = 3!) - * o------------------o - * /| /| - * / | / | - * / | / | - * / | / | - * / | / | - * / | / | - * 4 / | 5 / | - * o------------------o | - * | | | | - * | 3 o----------|-------o 2 - * | / | / - * | / | / - * | / | / - * | / | / - * | / | / - * | / | / - * |/ |/ - * o------------------o - * 0 1 - * - * (PARENT) Linear 8-Node Hexahedron - * 3D Element Edge Node Map: - * - * { {0, 1}, {1, 2}, {2, 3}, {3, 0}, - * {4, 5}, {5, 6}, {6, 7}, {7, 4}, - * {0, 4}, {1, 5}, {2, 6}, {3, 7} }; - * - * 3D Element Face Node Map: - * - * { {0, 1, 5, 4}, {1, 2, 6, 5}, { 2, 3, 7, 6}, { 0, 4, 7, 3}, { 0, 3, 2, 1}, { 4, 5, 6, 7} }; - * Shards face list info: - * - * typedef - * MakeTypeList< IndexList< 0, 1, 5, 4, 8, 13, 16, 12, 25 > , - * IndexList< 1, 2, 6, 5, 9, 14, 17, 13, 24 > , - * IndexList< 2, 3, 7, 6, 10, 15, 18, 14, 26 > , - * IndexList< 0, 4, 7, 3, 12, 19, 15, 11, 23 > , - * IndexList< 0, 3, 2, 1, 11, 10, 9, 8, 21 > , - * IndexList< 4, 5, 6, 7, 16, 17, 18, 19, 22 > >::type - * HexahedronFaceNodeMap ; - * - * - * After refinement (new nodes = *): - * - * - * 7 18 6 - * o---------*--------o - * /| /| /| - * / | / | / | - * 19 / | 22/ | / | - * *---------*--------*17 | - * /| 15*----/|---*---/|---*14 - * / | /| / | /|26/ | /| | (PARENT) Linear 8-Node Hexahedron - * 4 / | / |16/ | / | / | / | | 3D Element Edge Node to mid-edge quadratic node map - * o---------*--20----o5 |/ | | - * | 23*---|-|---*- 10|---*24 | | { 8, 9, 10, 11, - * | /| 3o-|--/|---*|--/|---o 2 | 16, 17, 18, 19, - * | / | / | / | / | / | / | 12, 13, 14, 15 } - * |/ | / 25|/ | / |/ | / | - * 12*---------*--------*13 |/ | Face to mid-face quadratic node map - * | 11*-----|---*----|---* 9 | { 25, 24, 26, 23, 21, 22 } - * | / | /21 | / | 0, 1, 2, 3, 4, 5 - * | / | / | / - * |/ |/ |/ - * o---------*--------o - * 0 8 1 - * - * - * CHILD Linear 8-Node Hexahedron 3D Element Node Maps: - * | - * | static const UInt child_0[] = { 0, 8, 21, 11, 12, 25, 20, 23 }; - * | static const UInt child_1[] = { 8, 1, 9, 21, 25, 13, 24, 20 }; - * | static const UInt child_2[] = { 21, 9, 2, 10, 20, 24, 14, 26 }; - * | static const UInt child_3[] = { 11, 21, 10, 3, 23, 20, 26, 15 }; - * | static const UInt child_4[] = { 12, 25, 20, 23, 4, 16, 22, 19 }; - * | static const UInt child_5[] = { 25, 13, 24, 20, 16, 5, 17, 22 }; - * | static const UInt child_6[] = { 20, 24, 14, 26, 22, 17, 6, 18 }; - * | static const UInt child_7[] = { 23, 20, 26, 15, 19, 22, 18, 7 }; - * | - * - */ - - /* New ref topo info Hex8 - * ---------------------- - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ -#if 0 - template<> - RefTopoX - RefinementTopologyExtra< shards::Hexahedron<8> >::refinement_topology = - { - {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - {2, 0, 2, 0, 1, {1.0, 1.0, 0.0} }, - {3, 0, 3, 0, 1, {0.0, 1.0, 0.0} }, - {4, 0, 4, 0, 1, {0.0, 0.0, 1.0} }, - {5, 0, 5, 0, 1, {1.0, 0.0, 1.0} }, - {6, 0, 6, 0, 1, {1.0, 1.0, 1.0} }, - {7, 0, 7, 0, 1, {0.0, 1.0, 1.0} }, - - {8, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - {9, 1, 1, 0, 1, {1.0, 0.5, 0.0} }, - {10, 1, 2, 0, 1, {0.5, 1.0, 0.0} }, - {11, 1, 3, 0, 1, {0.0, 0.5, 0.0} }, - - {12, 1, 8, 0, 1, {0.0, 0.0, 0.5} }, - {13, 1, 9, 0, 1, {1.0, 0.0, 0.5} }, - {14, 1, 10, 0, 1, {1.0, 1.0, 0.5} }, - {15, 1, 11, 0, 1, {0.0, 1.0, 0.5} }, - - {16, 1, 4, 0, 1, {0.5, 0.0, 1.0} }, - {17, 1, 5, 0, 1, {1.0, 0.5, 1.0} }, - {18, 1, 6, 0, 1, {0.5, 1.0, 1.0} }, - {19, 1, 7, 0, 1, {0.0, 0.5, 1.0} }, - - {20, 3, 0, 0, 1, {0.5, 0.5, 0.5} }, - - {21, 2, 4, 0, 1, {0.5, 0.5, 0.0} }, - {22, 2, 5, 0, 1, {0.5, 0.5, 1.0} }, - {23, 2, 3, 0, 1, {0.0, 0.5, 0.5} }, - {24, 2, 1, 0, 1, {1.0, 0.5, 0.5} }, - {25, 2, 0, 0, 1, {0.5, 0.0, 0.5} }, - {26, 2, 2, 0, 1, {0.5, 1.0, 0.5} } - - }; -#endif - -#if 0 - template<> - RefTopoX - RefinementTopologyExtra< shards::Hexahedron<27> >::refinement_topology = - { - {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} } - }; -#endif - - /*--------------------------------------------------------------------------*/ - /** - * PARENT Quadratic 20-Node Hexahedron Nodes - * 7 18 6 (SPACE_DIM = 3!) - * o--------o---------o - * /| /| - * / | / | - * / | / | - * 19o | 17o | - * / 15o / o14 - * / | / | - * 4 / | 16 / | - * o---------o--------o 5 | - * | | 10 | | - * | 3 o-------o--|-------o 2 - * | / | / - * | / | / - * 12o / o13 / - * | o11 | o9 - * | / | / - * | / | / - * |/ |/ - * o---------o--------o - * 0 8 1 - * - * PARENT Quadratic 20-Node Hexahedron 3D Element Edge Node Map: - * - * | - * | static const UInt edge_0[] = { 0, 1, 8 }; - * | static const UInt edge_1[] = { 1, 2, 9 }; - * | static const UInt edge_2[] = { 2, 3, 10 }; - * | static const UInt edge_3[] = { 3, 0, 11 }; - * | static const UInt edge_4[] = { 4, 5, 16 }; - * | static const UInt edge_5[] = { 5, 6, 17 }; - * | static const UInt edge_6[] = { 6, 7, 18 }; - * | static const UInt edge_7[] = { 7, 4, 19 }; - * | static const UInt edge_8[] = { 0, 4, 12 }; - * | static const UInt edge_9[] = { 1, 5, 13 }; - * | static const UInt edge_10[] = { 2, 6, 14 }; - * | static const UInt edge_11[] = { 3, 7, 15 }; - * | - * - * CHILD Quadratic 20-Node Hexahedron 3D Element Node Maps: - * | - * | // Child node tables use Two groups of nodes: - * | // a) vertices - * | // b) outer edge mid-points - * | - * | static const UInt child_0[] = { 0, 8, 21, 11, 12, 25, 20, 23, - * | 27, 60, 67, 34, 35, 59, 79, 74, 51, 75, 77, 58 }; - * | - * | static const UInt child_1[] = { 8, 1, 9, 21, 25, 13, 24, 20, - * | 28, 29, 68, 60, 59, 36, 69, 79, 52, 53, 78, 75 }; - * | - * | static const UInt child_2[] = { 21, 9, 2, 10, 20, 24, 14, 26, - * | 68, 30, 31, 61, 79, 69, 37, 62, 78, 54, 55, 76 }; - * | - * | static const UInt child_3[] = { 11, 21, 10, 3, 23, 20, 26, 15, - * | 67, 61, 32, 33, 74, 79, 62, 38, 77, 76, 56, 57 }; - * | - * | static const UInt child_4[] = { 12, 25, 20, 23, 4, 16, 22, 19, - * | 51, 75, 77, 58, 39, 66, 80, 73, 43, 65, 72, 50 }; - * | - * | static const UInt child_5[] = { 25, 13, 24, 20, 16, 5, 17, 22, - * | 52, 53, 78, 75, 66, 40, 70, 80, 44, 45, 71, 65 }; - * | - * | static const UInt child_6[] = { 20, 24, 14, 26, 22, 17, 6, 18, - * | 78, 54, 55, 76, 80, 70, 41, 63, 71, 46, 47, 64 }; - * | - * | static const UInt child_7[] = { 23, 20, 26, 15, 19, 22, 18, 7, - * | 77, 76, 56, 57, 73, 80, 63, 42, 72, 64, 48, 49 }; - * | - * - */ - - /*--------------------------------------------------------------------------*/ - /** - * PARENT Quadratic 27-Node Hexahedron Nodes - * 7 18 6 (SPACE_DIM = 3!) - * o--------o---------o - * /| /| - * / | / | - * / | / | - * 19o | 17o | - * / 15o / o14 - * / | / | - * 4 / | 16 / | - * o---------o--------o 5 | - * | | 10 | | - * | 3 o-------o--|-------o 2 - * | / | / - * | / | / - * 12o / o13 / - * | o11 | o9 - * | / | / - * | / | / - * |/ |/ - * o---------o--------o - * 0 8 1 - * - * - * x--------x---------x - * /| /| - * / | / | - * / | 22 / | - * x | o x | - * / x o26 / x (Node #20 is at centroid of element) - * / | / | - * / | / | "2D surface" containing nodes 0, 8, 1, 13, 5, 16, 4, 12 has - * x---------x--------x | node 25 at center.... - * | 23o | | o24 | - * | x-------x--|-------x - * | / | / - * | / 25 | / - * x / o x / - * | x o21 | x - * | / | / - * | / | / - * |/ |/ - * x---------x--------x - * - * - * PARENT Quadratic 27-Node Hexahedron 3D Element Edge Node Map: - * - * | - * | static const UInt edge_0[] = { 0, 1, 8 }; - * | static const UInt edge_1[] = { 1, 2, 9 }; - * | static const UInt edge_2[] = { 2, 3, 10 }; - * | static const UInt edge_3[] = { 3, 0, 11 }; - * | static const UInt edge_4[] = { 4, 5, 16 }; - * | static const UInt edge_5[] = { 5, 6, 17 }; - * | static const UInt edge_6[] = { 6, 7, 18 }; - * | static const UInt edge_7[] = { 7, 4, 19 }; - * | static const UInt edge_8[] = { 0, 4, 12 }; - * | static const UInt edge_9[] = { 1, 5, 13 }; - * | static const UInt edge_10[] = { 2, 6, 14 }; - * | static const UInt edge_11[] = { 3, 7, 15 }; - * | - * - * Refined 27-Node Hexahedron Edge node tables: - * | - * | static const UInt edge_0[] = { 0, 1, 8, 27, 28 }; - * | static const UInt edge_1[] = { 1, 2, 9, 29, 30 }; - * | static const UInt edge_2[] = { 2, 3, 10, 31, 32 }; - * | static const UInt edge_3[] = { 3, 0, 11, 33, 34 }; - * | static const UInt edge_4[] = { 4, 5, 16, 43, 44 }; - * | static const UInt edge_5[] = { 5, 6, 17, 45, 46 }; - * | static const UInt edge_6[] = { 6, 7, 18, 47, 48 }; - * | static const UInt edge_7[] = { 7, 4, 19, 49, 50 }; - * | static const UInt edge_8[] = { 0, 4, 12, 35, 39 }; - * | static const UInt edge_9[] = { 1, 5, 13, 36, 40 }; - * | static const UInt edge_10[] = { 2, 6, 14, 37, 41 }; - * | static const UInt edge_11[] = { 3, 7, 15, 38, 42 }; - * | - * - * CHILD 27-Node Hexahedron 3D Element Node Maps: - * | - * | // Child node tables use Four groups of nodes: - * | // a) vertices - * | // b) outer edge mid-points - * | // c) centroid - * | // d) mid-face points - * | - * | static const UInt child_0[] = { 0, 8, 21, 11, 12, 25, 20, 23, - * | 27, 60, 67, 34, 35, 59, 79, 74, 51, 75, 77, 58, - * | 81, 89, 117, 97, 113, 105, 121 }; - * | - * | static const UInt child_1[] = { 8, 1, 9, 21, 25, 13, 24, 20, - * | 28, 29, 68, 60, 59, 36, 69, 79, 52, 53, 78, 75, - * | 82, 92, 118, 113, 101, 106, 122 }; - * | - * | static const UInt child_2[] = { 21, 9, 2, 10, 20, 24, 14, 26, - * | 68, 30, 31, 61, 79, 69, 37, 62, 78, 54, 55, 76, - * | 83, 91, 119, 114, 102, 122, 109 }; - * | - * | static const UInt child_3[] = { 11, 21, 10, 3, 23, 20, 26, 15, - * | 67, 61, 32, 33, 74, 79, 62, 38, 77, 76, 56, 57, - * | 84, 90, 120, 100, 114, 121, 110 }; - * | - * | static const UInt child_4[] = { 12, 25, 20, 23, 4, 16, 22, 19, - * | 51, 75, 77, 58, 39, 66, 80, 73, 43, 65, 72, 50, - * | 85, 117, 93, 98, 116, 108, 124 }; - * | - * | static const UInt child_5[] = { 25, 13, 24, 20, 16, 5, 17, 22, - * | 52, 53, 78, 75, 66, 40, 70, 80, 44, 45, 71, 65, - * | 86, 118, 94, 116, 104, 107, 123 }; - * | - * | static const UInt child_6[] = { 20, 24, 14, 26, 22, 17, 6, 18, - * | 78, 54, 55, 76, 80, 70, 41, 63, 71, 46, 47, 64, - * | 87, 119, 95, 115, 103, 123, 112 }; - * | - * | static const UInt child_7[] = { 23, 20, 26, 15, 19, 22, 18, 7, - * | 77, 76, 56, 57, 73, 80, 63, 42, 72, 64, 48, 49, - * | 88, 120, 96, 99, 115, 124, 111 }; - * | - * | - * | Refined Hexagonal Element "Exterior" Faces - * | (Local Face node numbering for 'Hierarchical/Consistent' Hex objects) - * | - * | 3 14 6 13 2 - * | o----*----o----*----o - * | | | | - * | | 24 | 23 | - * | 15* * *19 * *12 - * | | | | - * | | 8| 18 | - * | 7 o----*----o----*----o 5 - * | | 20 | | - * | | | | - * | 16* * 17* * *11 - * | | 21 | 22 | - * | | | | - * | o----*----o----*----o - * | 0 9 4 10 1 - * | - * | - * | Hexagonal object face topology child-nodes: - * | - * | // Face node tables use Six groups of nodes: - * | // a) vertices (Local nodes: 0-1-2-3 ) - * | // b) edge mid-points (Local nodes: 4-5-6-7 ) - * | // c) centroid (Local node : 8 ) - * | // d) edge quater points (Local nodes: 9-10-11-12-13-14-15-16) - * | // e) interior edge mid-points (Local nodes: 17-18-19-20 ) - * | // f) mid-quadrant points (Local nodes: 21-22-23-24 ) - * | - * | static const UInt face_0[] = { 0, 1, 5, 4, 8, 13, 16, 12, 25, - * | 27, 28, 36, 40, 44, 43, 39, 35, - * | 59, 52, 66, 51, 105, 106, 107, 108 }; - * | - * | static const UInt face_1[] = { 1, 2, 6, 5, 9, 14, 17, 13, 24, - * | 29, 30, 37, 41, 46, 45, 40, 36, - * | 69, 54, 70, 53, 101, 102, 103, 104 }; - * | - * | static const UInt face_2[] = { 2, 3, 7, 6, 10, 15, 18, 14, 26, - * | 31, 32, 38, 42, 48, 47, 41, 37, - * | 62, 56, 63, 55, 109, 110, 111, 112 }; - * | - * | static const UInt face_3[] = { 0, 4, 7, 3, 12, 19, 15, 11, 23, - * | 35, 39, 50, 49, 42, 38, 33, 34, - * | 58, 73, 57, 74 97, 98, 99, 100 }; - * | - * | static const UInt face_4[] = { 0, 3, 2, 1, 11, 10, 9, 8 21, - * | 34, 33, 32, 31, 30, 29, 28, 27, - * | 67, 61, 68, 60, 89, 90, 91, 92 }; - * | - * | static const UInt face_5[] = { 4, 5, 6, 7, 16, 17, 18, 19, 22, - * | 43, 44, 45, 46, 47, 48, 49, 50, - * | 65, 71, 64, 72, 93, 94, 95, 96 }; - * - */ - - /*--------------------------------------------------------------------*/ - // Hexahedrons 8, 20, or 27 nodes (3D solid). - const MeshObjTopology * hex( UInt nnode) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology hex8(shards::getCellTopologyData >()); - static MeshObjTopology hex20(shards::getCellTopologyData >()); - static MeshObjTopology hex27(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Child topology and nodes - - static const_top_ptr hex8_child[] = - { &hex8 , &hex8 , &hex8 , &hex8 , &hex8 , &hex8 , &hex8 , &hex8 }; - - static const_top_ptr hex20_child[] = - { &hex20, &hex20, &hex20, &hex20, &hex20, &hex20, &hex20, &hex20 }; - - static const_top_ptr hex27_child[] = - { &hex27, &hex27, &hex27, &hex27, &hex27, &hex27, &hex27, &hex27 }; - - // Child node tables use Four groups of nodes: - // a) vertices - // b) outer edge mid-points - // c) centroid - // d) mid-face points - - static const UInt child_0[] = { 0, 8, 21, 11, 12, 25, 20, 23, - 27, 60, 67, 34, 35, 59, 79, 74, 51, 75, 77, 58, - 81, 89, 117, 97, 113, 105, 121 , EUA}; - - static const UInt child_1[] = { 8, 1, 9, 21, 25, 13, 24, 20, - 28, 29, 68, 60, 59, 36, 69, 79, 52, 53, 78, 75, - 82, 92, 118, 113, 101, 106, 122 , EUA}; - - static const UInt child_2[] = { 21, 9, 2, 10, 20, 24, 14, 26, - 68, 30, 31, 61, 79, 69, 37, 62, 78, 54, 55, 76, - 83, 91, 119, 114, 102, 122, 109 , EUA}; - - static const UInt child_3[] = { 11, 21, 10, 3, 23, 20, 26, 15, - 67, 61, 32, 33, 74, 79, 62, 38, 77, 76, 56, 57, - 84, 90, 120, 100, 114, 121, 110 , EUA}; - - static const UInt child_4[] = { 12, 25, 20, 23, 4, 16, 22, 19, - 51, 75, 77, 58, 39, 66, 80, 73, 43, 65, 72, 50, - 85, 117, 93, 98, 116, 108, 124 , EUA}; - - static const UInt child_5[] = { 25, 13, 24, 20, 16, 5, 17, 22, - 52, 53, 78, 75, 66, 40, 70, 80, 44, 45, 71, 65, - 86, 118, 94, 116, 104, 107, 123 , EUA}; - - static const UInt child_6[] = { 20, 24, 14, 26, 22, 17, 6, 18, - 78, 54, 55, 76, 80, 70, 41, 63, 71, 46, 47, 64, - 87, 119, 95, 115, 103, 123, 112 , EUA}; - - static const UInt child_7[] = { 23, 20, 26, 15, 19, 22, 18, 7, - 77, 76, 56, 57, 73, 80, 63, 42, 72, 64, 48, 49, - 88, 120, 96, 99, 115, 124, 111 , EUA}; - - static const UInt * child_node_table[] = - { child_0 , child_1 , child_2 , child_3 , - child_4 , child_5 , child_6 , child_7 }; - - // for hex20 elements: - static const UInt hex20_child_0[] = { 0, 8, 21, 11, 12, 25, 20, 23, - 27, 60, 67, 34, 35, 59, 79, 74, 51, 75, 77, 58 , EUA }; - - static const UInt hex20_child_1[] = { 8, 1, 9, 21, 25, 13, 24, 20, - 28, 29, 68, 60, 59, 36, 69, 79, 52, 53, 78, 75 , EUA }; - - static const UInt hex20_child_2[] = { 21, 9, 2, 10, 20, 24, 14, 26, - 68, 30, 31, 61, 79, 69, 37, 62, 78, 54, 55, 76 , EUA }; - - static const UInt hex20_child_3[] = { 11, 21, 10, 3, 23, 20, 26, 15, - 67, 61, 32, 33, 74, 79, 62, 38, 77, 76, 56, 57 , EUA }; - - static const UInt hex20_child_4[] = { 12, 25, 20, 23, 4, 16, 22, 19, - 51, 75, 77, 58, 39, 66, 80, 73, 43, 65, 72, 50 , EUA }; - - static const UInt hex20_child_5[] = { 25, 13, 24, 20, 16, 5, 17, 22, - 52, 53, 78, 75, 66, 40, 70, 80, 44, 45, 71, 65 , EUA }; - - static const UInt hex20_child_6[] = { 20, 24, 14, 26, 22, 17, 6, 18, - 78, 54, 55, 76, 80, 70, 41, 63, 71, 46, 47, 64 , EUA }; - - static const UInt hex20_child_7[] = { 23, 20, 26, 15, 19, 22, 18, 7, - 77, 76, 56, 57, 73, 80, 63, 42, 72, 64, 48, 49 , EUA }; - - - static const UInt * hex20_child_node_table[] = - { hex20_child_0 , hex20_child_1 , hex20_child_2 , hex20_child_3 , - hex20_child_4 , hex20_child_5 , hex20_child_6 , hex20_child_7 }; - - - - // Edge topology and node tables including edges' child-nodes - - static const UInt edge_0[] = { 0, 1, 8, 27, 28 , EUA}; - static const UInt edge_1[] = { 1, 2, 9, 29, 30 , EUA}; - static const UInt edge_2[] = { 2, 3, 10, 31, 32 , EUA}; - static const UInt edge_3[] = { 3, 0, 11, 33, 34 , EUA}; - static const UInt edge_4[] = { 4, 5, 16, 43, 44 , EUA}; - static const UInt edge_5[] = { 5, 6, 17, 45, 46 , EUA}; - static const UInt edge_6[] = { 6, 7, 18, 47, 48 , EUA}; - static const UInt edge_7[] = { 7, 4, 19, 49, 50 , EUA}; - static const UInt edge_8[] = { 0, 4, 12, 35, 39 , EUA}; - static const UInt edge_9[] = { 1, 5, 13, 36, 40 , EUA}; - static const UInt edge_10[] = { 2, 6, 14, 37, 41 , EUA}; - static const UInt edge_11[] = { 3, 7, 15, 38, 42 , EUA}; - - static const UInt * edge_table[] = - { edge_0 , edge_1 , edge_2 , edge_3 , edge_4 , edge_5 , - edge_6 , edge_7 , edge_8 , edge_9 , edge_10 , edge_11 }; - - // Face topology and edge tables including faces' child-nodes - - // Each face will have at 25 nodes to cover all cases of refined - // Hexahedron faces: Quad_4_3D, Quad_8_3D, or Quad_9_3D. - // Face node tables use Six groups of nodes: - // a) vertices (Local nodes: 0-1-2-3 ) - // b) edge mid-points (Local nodes: 4-5-6-7 ) - // c) centroid (Local node : 8 ) - // d) edge quater points (Local nodes: 9-10-11-12-13-14-15-16) - // e) interior edge mid-points (Local nodes: 17-18-19-20 ) - // f) mid-quadrant points (Local nodes: 21-22-23-24 ) - - static const UInt face_0[] = { 0, 1, 5, 4, 8, 13, 16, 12, 25, - 27, 28, 36, 40, 44, 43, 39, 35, - 59, 52, 66, 51, 105, 106, 107, 108 , EUA}; - - static const UInt face_1[] = { 1, 2, 6, 5, 9, 14, 17, 13, 24, - 29, 30, 37, 41, 46, 45, 40, 36, - 69, 54, 70, 53, 101, 102, 103, 104 , EUA}; - - static const UInt face_2[] = { 2, 3, 7, 6, 10, 15, 18, 14, 26, - 31, 32, 38, 42, 48, 47, 41, 37, - 62, 56, 63, 55, 109, 110, 111, 112 , EUA}; - - static const UInt face_3[] = { 0, 4, 7, 3, 12, 19, 15, 11, 23, - 35, 39, 50, 49, 42, 38, 33, 34, - 58, 73, 57, 74, 97, 98, 99, 100 , EUA}; - - static const UInt face_4[] = { 0, 3, 2, 1, 11, 10, 9, 8, 21, - 34, 33, 32, 31, 30, 29, 28, 27, - 67, 61, 68, 60, 89, 90, 91, 92 , EUA}; - - static const UInt face_5[] = { 4, 5, 6, 7, 16, 17, 18, 19, 22, - 43, 44, 45, 46, 47, 48, 49, 50, - 65, 71, 64, 72, 93, 94, 95, 96 , EUA}; - - static const UInt * face_table[] = - { face_0 , face_1 , face_2 , face_3 , face_4 , face_5 }; - - - // for hex20 elements - static const UInt hex20_face_0[] = { 0, 1, 5, 4, 8, 13, 16, 12, 25, - 27, 28, 36, 40, 44, 43, 39, 35, - 59, 52, 66, 51, EUA}; - - static const UInt hex20_face_1[] = { 1, 2, 6, 5, 9, 14, 17, 13, 24, - 29, 30, 37, 41, 46, 45, 40, 36, - 69, 54, 70, 53, EUA}; - - static const UInt hex20_face_2[] = { 2, 3, 7, 6, 10, 15, 18, 14, 26, - 31, 32, 38, 42, 48, 47, 41, 37, - 62, 56, 63, 55, EUA}; - - static const UInt hex20_face_3[] = { 0, 4, 7, 3, 12, 19, 15, 11, 23, - 35, 39, 50, 49, 42, 38, 33, 34, - 58, 73, 57, 74, EUA}; - - static const UInt hex20_face_4[] = { 0, 3, 2, 1, 11, 10, 9, 8, 21, - 34, 33, 32, 31, 30, 29, 28, 27, - 67, 61, 68, 60, EUA}; - - static const UInt hex20_face_5[] = { 4, 5, 6, 7, 16, 17, 18, 19, 22, - 43, 44, 45, 46, 47, 48, 49, 50, - 65, 71, 64, 72, EUA}; - - static const UInt * hex20_face_table[] = - { hex20_face_0 , hex20_face_1 , hex20_face_2 , hex20_face_3 , hex20_face_4 , hex20_face_5 }; - - - static RefinementTopology hex8_refinement(&hex8, 8, hex8_child, 27, child_node_table, 12, edge_table, 6, face_table, 0, NULL, NULL, true); - static RefinementTopology hex20_refinement(&hex20, 8, hex20_child, 81, hex20_child_node_table, 12, edge_table, 6, hex20_face_table, 0, NULL, NULL, true); - static RefinementTopology hex27_refinement(&hex27, 8, hex27_child, 125, child_node_table, 12, edge_table, 6, face_table, 0, NULL, NULL, true); - } - } - - MeshObjTopology * top = NULL ; - - switch( nnode ) { - case 8 : top = & hex8 ; break ; - case 20 : top = & hex20 ; break ; - case 27 : top = & hex27 ; break ; - default : - //throw RuntimeError() << "Invalid nnode specified" << std::endl ;// << StackTrace; - throw std::runtime_error( "Invalid nnode specified") ; // << std::endl ;// << StackTrace; - } - - return top ; - } - - - /*---------------------------------------------------------------------*/ - /** - * PARENT 4-Node Tetrahedron Object Nodes - * 3 - * o - * /|\ - * / | \ (PARENT) 4-Node Tetrahedron Object - * / | \ Edge Node Map: - * / | \ - * / | \ { {0, 1}, {1, 2}, {2, 0}, {0, 3}, {1, 3}, {2, 3} }; - * 0 o-----|-----o 2 - * \ | / - * \ | / - * \ | / - * \ | / - * \|/ - * o - * 1 - * - * After refinement (new nodes = *): - * - * 3 - * o - * /|\ - * / | \ - * 7 * | * 9 - * / | \ - * / 6| \ - * 0 o----*|-----o 2 - * \ *8 / - * \ | / - * 4 * | * 5 - * \ | / - * \|/ - * o - * 1 - * - * CHILD 4-Node Tetrahedron 3D Object Node Maps: - * | - * | static const UInt child_0[] = { 0, 4, 6, 7 }; // srkenno 091410 fixed (used to be {0, 4, 8, 7} ) - * | static const UInt child_1[] = { 4, 1, 5, 8 }; - * | static const UInt child_2[] = { 6, 5, 2, 9 }; - * | static const UInt child_3[] = { 7, 8, 9, 3 }; - * | static const UInt child_4[] = { 8, 7, 6, 4 }; - * | static const UInt child_5[] = { 6, 9, 8, 5 }; - * | static const UInt child_6[] = { 9, 8, 7, 6 }; - * | static const UInt child_7[] = { 5, 6, 4, 8 }; - * | - * - **/ - - /* New ref topo info Tet4 - * ---------------------- - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ -#if 0 - template<> - RefTopoX - RefinementTopologyExtra< shards::Tetrahedron<4> >::refinement_topology = - { - {0, 0, 0, 0, 1, {0.0, 0.0, 0.0} }, - {1, 0, 1, 0, 1, {1.0, 0.0, 0.0} }, - {2, 0, 2, 0, 1, {0.0, 1.0, 0.0} }, - {3, 0, 3, 0, 1, {0.0, 0.0, 1.0} }, - {4, 1, 0, 0, 1, {0.5, 0.0, 0.0} }, - {5, 1, 1, 0, 1, {0.5, 0.5, 0.0} }, - {6, 1, 2, 0, 1, {0.0, 0.5, 0.0} }, - {7, 1, 3, 0, 1, {0.0, 0.0, 0.5} }, - {8, 1, 4, 0, 1, {0.5, 0.0, 0.5} }, - {9, 1, 5, 0, 1, {0.0, 0.5, 0.5} } - }; - -#endif - - /*--------------------------------------------------------------------------*/ - /** - * PARENT 10-Node Tetrahedron Object Nodes - * 3 - * o - * /|\ - * / | \ - * 7 o | o 9 (PARENT) 10-Node Tetrahedron Object - * / | \ Edge Node Map: - * / 6| \ - * 0 o----o|-----o 2 { {0, 1, 4}, {1, 2, 5}, {2, 0, 6}, - * \ o8 / {0, 3, 7}, {1, 3, 8}, {2, 3, 9} }; - * \ | / - * 4 o | o 5 - * \ | / - * \|/ - * o - * 1 - * - * After refinement (new nodes = *): - * - * 3 - * o - * /|\ - * * | * - * / | \ - * 7 o | o 9 - * / * \ - * * | * - * / 6| \ - * 0 o---*--o|--*----o 2 - * \ o8 / - * * | * - * \ | / - * 4 o | o 5 - * \ * / - * * | * - * \|/ - * o - * 1 - * - * | // Child edge node tables - * | - * | static const UInt edge_0[] = { 0, 1, 4, 10, 11 }; - * | static const UInt edge_1[] = { 1, 2, 5, 12, 13 }; - * | static const UInt edge_2[] = { 2, 0, 6, 14, 15 }; - * | static const UInt edge_3[] = { 0, 3, 7, 16, 19 }; - * | static const UInt edge_4[] = { 1, 3, 8, 17, 20 }; - * | static const UInt edge_5[] = { 2, 3, 9, 18, 21 }; - * | - * | // Child face node (cfn) tables: - * | // Local Face (LF) LF0 uses [0:5], LF1 uses [6:11], LF2 uses [12:17], LF3 uses [18:23] - * | - * | static const UInt cfn_0[] = {0, 4, 7, 10, 27, 16, 4, 6, 7, 31, 25, 27, 0, 7, 6, 16, 25, 15, 0, 6, 4, 15, 31, 10 }; - * | static const UInt cfn_1[] = {4, 1, 8, 11, 17, 34, 1, 5, 8, 12, 26, 17, 4, 8, 5, 34, 26, 20, 4, 5, 1, 30, 12, 11 }; - * | static const UInt cfn_2[] = {6, 5, 9, 24, 28, 33, 5, 2, 9, 13, 18, 28, 6, 9, 2, 33, 18, 14, 6, 2, 5, 14, 13, 24 }; - * | static const UInt cfn_3[] = {7, 8, 3, 23, 20, 19, 8, 9, 3, 32, 21, 20, 7, 3, 9, 19, 21, 29, 7, 9, 8, 29, 32, 33 }; - * | static const UInt cfn_4[] = {8, 7, 4, 23, 27, 34, 7, 6, 4, 25, 31, 27, 8, 4, 6, 34, 31, 22, 8, 6, 7, 22, 25, 23 }; - * | static const UInt cfn_5[] = {6, 9, 5, 33, 28, 24, 9, 8, 5, 32, 26, 28, 6, 5, 8, 24, 26, 22, 6, 8, 9, 22, 32, 33 }; - * | static const UInt cfn_6[] = {9, 8, 6, 32, 22, 33, 8, 7, 6, 23, 25, 22, 9, 6, 7, 33, 25, 29, 9, 7, 8, 29, 23, 32 }; - * | static const UInt cfn_7[] = {5, 6, 8, 24, 22, 26, 6, 4, 8, 31, 34, 22, 5, 8, 4, 26, 34, 30, 5, 4, 6, 30, 31, 24 }; - * | - * - * - * - * Face #0: Face #1: Face #2: - * - * 3 3 3 - * o o o - * / \ / \ / \ - * 19* *20 20* *21 21* *19 - * / 23 \ / 32 \ / 29 \ < - * 7 o---*---o 8 8 o---*---o 9 9 o---*---o 7 \ - * / \ / \ / \ / \ / \ / \ \ - * 16* 27* *34 *17 17* 26* *28 *18 18* 33* *25 *16 | - * / \ / \ / \ / \ / \ / \ | - * o---*---o---*---o o---*---o---*---o o---*---o---*---o # - * 0 10 4 11 1 1 12 5 13 2 2 14 6 15 0 - * # # - * \ \ - * \ \ - * --> --> - * - * Face #3: - * - * 1 - * o - * / \ - * 11* *12 - * / 30 \ - * 4 o---*---o 5 - * / \ / \ - * 10* 31* *24 *13 - * / \ / \ - * o---*---o---*---o - * 0 15 6 14 2 - * # - * \ - * \ - * --> - * - * Various Interior Faces of Children: - * - * 7 9 7 25 6 8 26 5 - * o o o---*---o o---*---o - * / \ / \ \ / \ / - * 23* *25 32* *33 27* *31 34* *30 - * / 22 \ / 22 \ \ / \ / - * 8o---*---o10 8o---*---o6 o o - * \ / \ / 4 4 - * 26* *24 34* *31 - * \ / \ / - * o o - * 5 4 - * - * 9 9 - * o o - * / \ / \ - * 33* *28 29* *32 - * / \ / \ - * o---*---o o---*---o - * 6 24 5 7 23 8 - * - * - * Edge node tables for refined 10-Node Tetrahedrons: - * | - * | static const UInt edge_0[] = { 0, 1, 4, 10, 11 }; - * | static const UInt edge_1[] = { 1, 2, 5, 12, 13 }; - * | static const UInt edge_2[] = { 2, 0, 6, 14, 15 }; - * | static const UInt edge_3[] = { 0, 3, 7, 16, 19 }; - * | static const UInt edge_4[] = { 1, 3, 8, 17, 20 }; - * | static const UInt edge_5[] = { 2, 3, 9, 18, 21 }; - * | - * - * Face node tables for refined 10-Node Tetrahedrons: - * | - * | static const UInt face_0[] = { 0, 1, 3, 4, 8, 7, 10, 11, 17, 20, 19, 16, 27, 34, 23 }; - * | static const UInt face_1[] = { 1, 2, 3, 5, 9, 8, 12, 13, 18, 21, 20, 17, 26, 28, 32 }; - * | static const UInt face_2[] = { 0, 3, 2, 7, 9, 6, 16, 19, 21, 18, 14, 15, 25, 29, 33 }; - * | static const UInt face_3[] = { 0, 2, 1, 6, 5, 4, 15, 14, 13, 12, 11, 10, 31, 24, 30 }; - * | - * - * CHILD 10-Node Tetrahedron Object Node Maps: - * - * | - * | static const UInt child_0[] = { 0, 4, 8, 7, 10, 31, 15, 16, 27, 25 }; - * | static const UInt child_1[] = { 4, 1, 5, 8, 11, 12, 30, 34, 17, 26 }; - * | static const UInt child_2[] = { 6, 5, 2, 9, 24, 13, 14, 33, 28, 18 }; - * | static const UInt child_3[] = { 7, 8, 9, 3, 23, 32, 29, 19, 20, 21 }; - * | static const UInt child_4[] = { 8, 7, 6, 4, 23, 25, 22, 34, 27, 31 }; - * | static const UInt child_5[] = { 6, 9, 8, 5, 33, 32, 22, 24, 28, 26 }; - * | static const UInt child_6[] = { 9, 8, 7, 6, 32, 23, 29, 33, 22, 25 }; - * | static const UInt child_7[] = { 5, 6, 4, 8, 24, 31, 30, 26, 22, 34 }; - * | - * - * - **/ - - /*--------------------------------------------------------------------------*/ - /** - * PARENT Semi-Linear 8-Node Tetrahedron Nodes - * 3 (SPACE_DIM = 3!) - * o - * /|\ - * / | \ - * / | \ "Front faces" - * / | \ Node 4 on 2D surface containing nodes 0, 1, 3 - * / | \ Node 5 on 2D surface containing nodes 1, 2, 3 - * 0 o-----|-----o 2 - * \ 4 | + / (PARENT) Semi-Linear 8-Node Tetrahedron - * \ + | 5 / 3D Element Edge Node Map: - * \ | / - * \ | / { {0, 1}, {1, 2}, {2, 0}, {0, 3}, {1, 3}, {2, 3} } - * \|/ - * o - * 1 - * - * - * 3 - * o - * /|\ "Back faces (note mid-face-node does not follow face ordering!)" - * / | \ Node 7 on 2D surface containing nodes 0, 3, 2 - * / | \ Node 6 on 2D surface containing nodes 0, 2, 1 - * / |+ \ - * / |7 \ - * 0 o-----|-----o 2 - * \ 6| / - * \ +| / - * \ | / - * \ | / - * \|/ - * o - * 1 - * - * After refinement (new nodes = *): - * - * 3 - * o - * /|\ - * / | \ - * 11* | *13 - * / | \ - * / 10| \ - * 0 o----*|-----o 2 - * \ *12 / - * \ | / - * 8 * | * 9 - * \ | / - * \|/ - * o - * 1 - * - * | // Child edge node tables - * | - * | static const UInt edge_0[] = { 0, 1, 8 }; - * | static const UInt edge_1[] = { 1, 2, 9 }; - * | static const UInt edge_2[] = { 2, 0, 10 }; - * | static const UInt edge_3[] = { 0, 3, 11 }; - * | static const UInt edge_4[] = { 1, 3, 12 }; - * | static const UInt edge_5[] = { 2, 3, 13 }; - * | - * - * | - * | // Child face node (cfn) tables: - * | // Local Face (LF) - * | LF0 uses [0:3], LF1 uses [4:7], LF2 uses [8:11], LF3 uses [12:15] - * | - * | static const UInt cfn_0[] = - * | { 0, 8, 11, 14, 8, 10, 11, 30, 0, 11, 10, 17, 0, 10, 8, 16 }; - * | static const UInt cfn_1[] = - * | { 8, 1, 12, 18, 1, 9, 12, 15, 8, 12, 9, 31, 8, 9, 1, 24 }; - * | static const UInt cfn_2[] = - * | { 10, 9, 13, 32, 9, 2, 13, 19, 10, 13, 2, 25, 10, 2, 9, 20 }; - * | static const UInt cfn_3[] = - * | { 11, 12, 3, 22, 12, 13, 3, 23, 11, 3, 13, 21, 11, 13, 12, 33 }; - * | static const UInt cfn_4[] = - * | { 12, 11, 8, 4, 11, 10, 8, 30, 12, 8, 10, 29, 12, 10, 11, 26 }; - * | static const UInt cfn_5[] = - * | { 10, 13, 9, 32, 13, 12, 9, 5, 10, 9, 12, 27, 10, 12, 13, 28 }; - * | static const UInt cfn_6[] = - * | { 13, 12, 10, 28, 12, 11, 10, 26, 13, 10, 11, 7, 13, 11, 12, 33 }; - * | static const UInt cfn_7[] = - * | { 9, 10, 12, 27, 10, 8, 12, 29, 9, 12, 8, 31, 9, 8, 10, 6 }; - * | - * - * - * Face #0: Face #1: Face #2: - * - * 3 3 3 - * o o o - * / \ / \ / \ - * / 16\ / 19\ / 24\ - * / * \ / * \ / * \ < - * 11*-------*12 12*-------*13 13*-------*11 \ - * / \ o / \ / \ o / \ / \ o / \ \ - * /14 \ 4 /15 \ /17 \ 5 /18 \ /25 \ 7 / 23\ | - * / * \ / * \ / * \ / * \ / * \ / * \ | - * o-------*-------o o-------*-------o o-------*-------o # - * 0 8 1 1 9 2 2 10 0 - * # # - * \ \ - * \ \ - * --> --> - * - * Face #3: - * - * 1 - * o - * / \ - * /22 \ - * / * \ - * 8*-------*9 - * / \ o / \ - * /20 \ 6 / 21\ - * / * \ / * \ - * o-------*-------o - * 0 10 2 - * # - * \ - * \ - * --> - * - * Various Interior Faces of Children: - * - * 11 13 11 10 12 9 - * * * *-------* *-------* - * / \ / \ \ * / \ * / - * /26 \ /28 \ \30 / \31 / - * / * \ / * \ \ / \ / - * 12*-------*10 10*-------*12 * * - * \ * / \ * / 8 8 - * \27 / \29 / - * \ / \ / - * * * - * 9 8 - * - * 13 13 - * * * - * / \ / \ - * /32 \ /33 \ - * / * \ / * \ - * *-------* *-------* - * 10 9 11 12 - * - * | // tet8 face node tables - * | - * | static const UInt t8_face_0[] = { 0, 1, 3, 4, 8, 12, 11, 14, 15, 16 }; - * | static const UInt t8_face_1[] = { 1, 2, 3, 5, 9, 13, 12, 17, 18, 19 }; - * | static const UInt t8_face_2[] = { 0, 3, 2, 7, 11, 13, 10, 23, 24, 25 }; - * | static const UInt t8_face_3[] = { 0, 2, 1, 6, 10, 9, 8, 20, 21, 22 }; - * | - * - * CHILD 8-Node Tetrahedron Object Node Maps: - * - * | - * | static const UInt child_0[] = { 0, 8, 10, 11, 14, 30, 23, 20 }; - * | static const UInt child_1[] = { 8, 1, 9, 12, 15, 17, 31, 22 }; - * | static const UInt child_2[] = { 10, 9, 2, 13, 32, 18, 25, 21 }; - * | static const UInt child_3[] = { 11, 12, 13, 3, 16, 19, 24, 33 }; - * | static const UInt child_4[] = { 12, 11, 10, 8, 4, 30, 29, 26 }; - * | static const UInt child_5[] = { 10, 13, 12, 9, 32, 5, 27, 28 }; - * | static const UInt child_6[] = { 13, 12, 11, 10, 28, 26, 7, 33 }; - * | static const UInt child_7[] = { 9, 10, 8, 12, 27, 29, 31, 6 }; - * | - * - **/ - - /*--------------------------------------------------------------------*/ - // Tetrahedron with 4, 8, or 10 Nodes. Object is a 3D solid. - const MeshObjTopology * tet( UInt nnode ) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology tet4(shards::getCellTopologyData >()); - static MeshObjTopology tet8(shards::getCellTopologyData >()); - static MeshObjTopology tet10(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Tet4 and Tet10 Child and child node specifications - - static const_top_ptr tet4_child[] = - { &tet4 , &tet4 , &tet4 , &tet4 , &tet4 , &tet4 , &tet4 , &tet4 }; - - static const_top_ptr tet10_child[] = - { &tet10, &tet10, &tet10, &tet10, &tet10, &tet10, &tet10, &tet10 }; - - static const UInt tet4_child_0[] = { 0, 4, 6, 7, 10, 31, 15, 16, 27, 25 , EUA}; - static const UInt tet4_child_1[] = { 4, 1, 5, 8, 11, 12, 30, 34, 17, 26 , EUA}; - static const UInt tet4_child_2[] = { 6, 5, 2, 9, 24, 13, 14, 33, 28, 18 , EUA}; - static const UInt tet4_child_3[] = { 7, 8, 9, 3, 23, 32, 29, 19, 20, 21 , EUA}; - static const UInt tet4_child_4[] = { 8, 7, 6, 4, 23, 25, 22, 34, 27, 31 , EUA}; - static const UInt tet4_child_5[] = { 6, 9, 8, 5, 33, 32, 22, 24, 28, 26 , EUA}; - static const UInt tet4_child_6[] = { 9, 8, 7, 6, 32, 23, 29, 33, 22, 25 , EUA}; - static const UInt tet4_child_7[] = { 5, 6, 4, 8, 24, 31, 30, 26, 22, 34 , EUA}; - static const UInt * tet4_child_node_table[] = - { tet4_child_0 , tet4_child_1 , tet4_child_2 , tet4_child_3 , - tet4_child_4 , tet4_child_5 , tet4_child_6 , tet4_child_7 }; - - - - // Tet8 Child and child node specifications - - static const_top_ptr tet8_child[] = - { &tet8 , &tet8 , &tet8 , &tet8 , &tet8 , &tet8 , &tet8 , &tet8 }; - - static const UInt tet8_child_0[] = { 0, 8, 10, 11, 14, 30, 20, 23 , EUA}; - static const UInt tet8_child_1[] = { 8, 1, 9, 12, 15, 17, 22, 31 , EUA}; - static const UInt tet8_child_2[] = { 10, 9, 2, 13, 32, 18, 21, 25 , EUA}; - static const UInt tet8_child_3[] = { 11, 12, 13, 3, 16, 19, 33, 24 , EUA}; - static const UInt tet8_child_4[] = { 12, 11, 10, 8, 4, 30, 26, 29 , EUA}; - static const UInt tet8_child_5[] = { 10, 13, 12, 9, 32, 5, 28, 27 , EUA}; - static const UInt tet8_child_6[] = { 13, 12, 11, 10, 28, 26, 33, 7 , EUA}; - static const UInt tet8_child_7[] = { 9, 10, 8, 12, 27, 29, 6, 31 , EUA}; - static const UInt * tet8_child_node_table[] = - { tet8_child_0 , tet8_child_1 , tet8_child_2 , tet8_child_3 , - tet8_child_4 , tet8_child_5 , tet8_child_6 , tet8_child_7 }; - - // Edge topology and node tables including edges' child-nodes - - // Edge child nodes for both Tet4 and Tet10 edges - - static const UInt edge_0[] = { 0, 1, 4, 10, 11 , EUA}; - static const UInt edge_1[] = { 1, 2, 5, 12, 13 , EUA}; - static const UInt edge_2[] = { 2, 0, 6, 14, 15 , EUA}; - static const UInt edge_3[] = { 0, 3, 7, 16, 19 , EUA}; - static const UInt edge_4[] = { 1, 3, 8, 17, 20 , EUA}; - static const UInt edge_5[] = { 2, 3, 9, 18, 21 , EUA}; - static const UInt * tet4_edge_table[] = - { edge_0 , edge_1 , edge_2 , edge_3 , edge_4 , edge_5 }; - - // Edge child nodes for Tet8 edges - - static const UInt tet8_edge_0[] = { 0, 1, 8 , EUA}; - static const UInt tet8_edge_1[] = { 1, 2, 9 , EUA}; - static const UInt tet8_edge_2[] = { 2, 0, 10 , EUA}; - static const UInt tet8_edge_3[] = { 0, 3, 11 , EUA}; - static const UInt tet8_edge_4[] = { 1, 3, 12 , EUA}; - static const UInt tet8_edge_5[] = { 2, 3, 13 , EUA}; - - static const UInt * tet8_edge_table[] = - { tet8_edge_0, tet8_edge_1, tet8_edge_2, tet8_edge_3, tet8_edge_4, tet8_edge_5 }; - - // Face topology, nodes, and edge tables - - // Face node tables use Four groups of nodes: - // a) vertices - // b) outer edge mid-points - // c) outer edge quarter points - // d) inner edge mid-points - - static const UInt tet4_face_0[] = { 0, 1, 3, - 4, 8, 7, - 10, 11, 17, 20, 19, 16, - 27, 34, 23 , EUA}; - - static const UInt tet4_face_1[] = { 1, 2, 3, - 5, 9, 8, - 12, 13, 18, 21, 20, 17, - 26, 28, 32 , EUA}; - - static const UInt tet4_face_2[] = { 0, 3, 2, - 7, 9, 6, - 16, 19, 21, 18, 14, 15, - 25, 29, 33 , EUA}; - - static const UInt tet4_face_3[] = { 0, 2, 1, - 6, 5, 4, - 15, 14, 13, 12, 11, 10, - 31, 24, 30 , EUA}; - - static const UInt * tet4_face_table[4] = { tet4_face_0, tet4_face_1, tet4_face_2, tet4_face_3 }; - - // tet8 face node tables - - static const UInt tet8_face_0[] = { 0, 1, 3, 4, 8, 12, 11, 14, 15, 16 , EUA}; - static const UInt tet8_face_1[] = { 1, 2, 3, 5, 9, 13, 12, 17, 18, 19 , EUA}; - static const UInt tet8_face_2[] = { 0, 3, 2, 7, 11, 13, 10, 23, 24, 25 , EUA}; - static const UInt tet8_face_3[] = { 0, 2, 1, 6, 10, 9, 8, 20, 21, 22 , EUA}; - static const UInt * tet8_face_table[4] = - { tet8_face_0, tet8_face_1, tet8_face_2, tet8_face_3 }; - - static RefinementTopology tet4_refinement(&tet4, 8, tet4_child, 10, tet4_child_node_table, 6, tet4_edge_table, 4, tet4_face_table, 0, NULL, NULL, true); - static RefinementTopology tet10_refinement(&tet10, 8, tet10_child, 35, tet4_child_node_table, 6, tet4_edge_table, 4, tet4_face_table, 0, NULL, NULL, true); - static RefinementTopology tet8_refinement(&tet8, 8, tet8_child, 34, tet8_child_node_table, 6, tet8_edge_table, 4, tet8_face_table, 0, NULL, NULL, true); - } - } - - MeshObjTopology * top = NULL ; - - switch( nnode ) { - case 4 : top = &tet4 ; break ; - case 8 : top = &tet8 ; break ; - case 10 : top = &tet10 ; break ; - default: - //throw RuntimeError() << "Invalid nnode specified" << std::endl ;// << StackTrace; - throw std::runtime_error( "Invalid nnode specified") ; // << std::endl ;// << StackTrace; - } - - return top ; - } - - - - /*--------------------------------------------------------------------*/ - /** - * Wedge Element with 6 Nodes - * Pentahedral Element with 6 Nodes - * 3-Sided Prism Element with 6 Nodes - * - * PARENT Linear 6-Node Wedge Nodes - * 5 (SPACE_DIM = 3!) - * . o - * . / \ - * . / \ Face_Quad_4_3D() 0-1-4-3 - * . / \ Face_Quad_4_3D() 1-4-5-2 - * . / \ Face_Quad_4_3D() 0-2-5-3 - * 2 . o---------o 4 Face_Tri_3_3D() 0-1-2 - * o . 3 . Face_Tri_3_3D() 3-4-5 - * /.\ . - * /. \ . - * /. \ . - * /. \ . - * o---------o - * 0 1 - * - * - * CHILD Wedge6 node tables; - * | - * | static const UInt child_0[] = { 0, 6, 8, 9, 15, 17 }; - * | static const UInt child_1[] = { 6, 1, 7, 15, 10, 16 }; - * | static const UInt child_2[] = { 8, 7, 2, 17, 16, 11 }; - * | static const UInt child_3[] = { 7, 8, 6, 16, 17, 15 }; - * | static const UInt child_4[] = { 9, 15, 17, 3, 12, 14 }; - * | static const UInt child_5[] = { 15, 10, 16, 12, 4, 13 }; - * | static const UInt child_6[] = { 17, 16, 11, 14, 13, 5 }; - * | static const UInt child_7[] = { 16, 17, 15, 13, 14, 12 }; - * - * Refined Wedge6 Edge node tables: - * | - * | static const UInt edge_0[] = { 0, 1, 6 }; - * | static const UInt edge_1[] = { 1, 2, 7 }; - * | static const UInt edge_2[] = { 2, 0, 8 }; - * | static const UInt edge_3[] = { 3, 4, 12 }; - * | static const UInt edge_4[] = { 4, 5, 13 }; - * | static const UInt edge_5[] = { 5, 3, 14 }; - * | static const UInt edge_6[] = { 0, 3, 9 }; - * | static const UInt edge_7[] = { 1, 4, 10 }; - * | static const UInt edge_8[] = { 2, 5, 11 }; - * - * Refined Wedge6 Face node tables: - * | - * | static const UInt face_0[] = { 0, 1, 4, 3, 6, 10, 12, 9, 15 }; - * | static const UInt face_1[] = { 1, 2, 5, 4, 7, 11, 13, 10, 16 }; - * | static const UInt face_2[] = { 0, 3, 5, 2, 9, 14, 11, 8, 17 }; - * | static const UInt face_3[] = { 0, 2, 1, 8, 7, 6, -1, -1, -1}; - * | static const UInt face_4[] = { 3, 4, 5, 12, 13, 14, -1, -1, -1}; - * - */ - - /* New ref topo info Wedge6 - * ---------------------- - * - * {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} - */ -#if 0 - template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<6> > :: refinement_topology = { - { 0, 0, 0, 0, 1, {0, 0, 0} }, - { 1, 0, 1, 0, 1, {1, 0, 0} }, - { 2, 0, 2, 0, 1, {0, 1, 0} }, - { 3, 0, 3, 0, 1, {0, 0, 1} }, - { 4, 0, 4, 0, 1, {1, 0, 1} }, - { 5, 0, 5, 0, 1, {0, 1, 1} }, - { 6, 1, 0, 0, 1, {0.5, 0, 0} }, - { 7, 1, 1, 0, 1, {0.5, 0.5, 0} }, - { 8, 1, 2, 0, 1, {0, 0.5, 0} }, - { 9, 1, 6, 0, 1, {0, 0, 0.5} }, - { 10, 1, 7, 0, 1, {1, 0, 0.5} }, - { 11, 1, 8, 0, 1, {0, 1, 0.5} }, - { 12, 1, 3, 0, 1, {0.5, 0, 1} }, - { 13, 1, 4, 0, 1, {0.5, 0.5, 1} }, - { 14, 1, 5, 0, 1, {0, 0.5, 1} }, - { 15, 2, 0, 0, 1, {0.5, 0, 0.5} }, - { 16, 2, 1, 0, 1, {0.5, 0.5, 0.5} }, - { 17, 2, 2, 0, 1, {0, 0.5, 0.5} } - - }; -#endif - - /*--------------------------------------------------------------------*/ - /** - * Wedge Element with 15 Nodes - * Pentahedral Element with 15 Nodes - * 3-Sided Prism Element with 15 Nodes - * - * PARENT Quadratic 15-Node Wedge Nodes - * (SPACE_DIM = 3!) - * - * 5 - * o - * / \ - * 14 / \ - * o o 13 - * / \ - * 3 / \ - * o-----o-----o - * 12 4 - * 11 - * o Face_Quad_8_3D() 0-6-1-10-4-12-3-9 - * . . Face_Quad_8_3D() 1-10-4-13-5-11-2-7 - * . . Face_Quad_8_3D() 0-8-2-11-5-14-3-9 - * . . Face_Tri_6_3D() 0-6-1-7-2-8 - * . . Face_Tri_6_3D() 3-12-4-13-5-14 - * . . - * 9 o...........o 10 - * - * 2 - * o - * / \ - * / \ - * 8 o o 7 - * / \ - * / \ - * o-----o-----o - * 0 6 1 - * - * - * | - * | After Refinement: - * | - * - * Face #0 Face #1 Face #2 - * - * 3 30 12 31 4 4 32 13 33 5 5 34 14 35 3 - * o----*----o----*----o o----*----o----*----o o----*----o----*----o - * | | | | | | | | | - * | | | | | | | | | - * 51* *52 *53 53* *54 *55 55* *56 *51 - * | | | | | | | | | - * | 15| 25 | | 16| 27 | | 17| 29 | - * 9 o----*----o----*----o 10 10 o----*----o----*----o 11 11 o----*----o----*----o 9 - * | 24 | | | 26 | | | 28 | | - * | | | | | | | | | - * 45* 46* *47 47* 48* 49* 49* 50* *45 ^ - * | | | | | | | | | | - * | | | | | | | | | | - * o----*----o----*----o o----*----o----*----o o----*----o----*----o # - * 0 18 6 19 1 1 20 7 21 2 2 22 8 23 0 - * # # - * \ \ - * \ \ - * --> --> - * - * - * Face #4 Face #5 - * - * 2 21 7 20 1 5 33 13 32 4 - * o-----*-----o-----*-----o o-----*-----o-----*-----o - * \ / \ / \ / \ / - * \ / \ / \ / \ / - * 22* 36* *38 *19 34* 42* *44 *31 - * \ / \ / \ / \ / - * \ / 37 \ / \ / 43 \ / - * 8 o-----*-----o 6 14 o-----*-----o 12 - * \ / \ / - * \ / \ / - * ^ 23* *18 35* *30 ^ - * \ \ / \ / / - * \ \ / \ / / - * # o o # - * 0 3 - * - * - * - * CHILD Wedge15 node tables: - * | - * | static const UInt child_0[] = { 0, 6, 8, 9, 15, 17, 18, 37, 28, 45, 46, 50, 24, 40, 29 }; - * | static const UInt child_1[] = { 6, 1, 7, 15, 10, 16, 19, 20, 38, 46, 47, 48, 25, 26, 41 }; - * | static const UInt child_2[] = { 8, 7, 2, 17, 16, 11, 36, 21, 22, 50, 48, 49, 39, 27, 28 }; - * | static const UInt child_3[] = { 9, 15, 17, 3, 12, 14, 24, 40, 29, 51, 52, 56, 30, 43, 35 }; - * | static const UInt child_4[] = { 15, 10, 16, 12, 4, 13, 25, 26, 41, 52, 53, 54, 31, 32, 44 }; - * | static const UInt child_5[] = { 17, 16, 11, 14, 13, 5, 39, 27, 28, 56, 54, 55, 42, 33, 34 }; - * | static const UInt child_6[] = { 7, 8, 6, 16, 17, 15, 36, 37, 38, 48, 50, 46, 39, 40, 41 }; - * | static const UInt child_7[] = { 16, 17, 15, 13, 14, 12, 39, 40, 41, 54, 56, 52, 42, 43, 44 }; - * | - * - * Refined Wedge15 Edge node tables: - * | - * | static const UInt edge_0[] = { 0, 1, 6, 18, 19 }; - * | static const UInt edge_1[] = { 1, 2, 7, 20, 21 }; - * | static const UInt edge_2[] = { 2, 0, 8, 22, 23 }; - * | static const UInt edge_3[] = { 3, 4, 12, 30, 31 }; - * | static const UInt edge_4[] = { 4, 5, 13, 32, 33 }; - * | static const UInt edge_5[] = { 5, 3, 14, 34, 35 }; - * | static const UInt edge_6[] = { 0, 3, 9, 45, 51 }; - * | static const UInt edge_7[] = { 1, 4, 10, 47, 53 }; - * | static const UInt edge_8[] = { 2, 5, 11, 49, 55 }; - * - * Refined Wedge15 Face node tables: - * | - * | static const UInt face_0[] = {0, 1, 4, 3, 6, 10, 12, 9, 15, 18, 19, 47, 53, 31, 30, 51, 45, 46, 25, 52, 24}; - * | static const UInt face_1[] = {1, 2, 5, 4, 7, 11, 13, 10, 16, 20, 21, 49, 55, 33, 32, 53, 47, 48, 27, 54, 26}; - * | static const UInt face_2[] = {0, 3, 5, 2, 9, 14, 11, 8, 17, 45, 51, 35, 34, 55, 49, 22, 23, 29, 56, 28, 50}; - * | static const UInt face_3[] = {0, 2, 1, 8, 7, 6, 23, 22, 21, 20, 19, 18, 37, 36, 38 }; - * | static const UInt face_4[] = {3, 4, 5, 12, 13, 14, 30, 31, 32, 33, 34, 35, 43, 44, 42 }; - * | - * - **/ - - /*--------------------------------------------------------------------*/ - // Pentahedrons with 6 or 15 nodes (3D solid). - // Wedges with 6 or 15 nodes (3D solid). - // eclass == SOLID = > sdim == 3 && mdim == 3 - const MeshObjTopology * wedge( UInt nnode ) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology wedge6(shards::getCellTopologyData >()); - static MeshObjTopology wedge15(shards::getCellTopologyData >()); - static MeshObjTopology wedge18(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Children and child nodes - static const_top_ptr wedge6_child[] = - {&wedge6, &wedge6, &wedge6, &wedge6, - &wedge6, &wedge6, &wedge6, &wedge6 }; - - static const_top_ptr wedge15_child[] = - {&wedge15, &wedge15, &wedge15, &wedge15, - &wedge15, &wedge15, &wedge15, &wedge15}; - - static const UInt child_0[] = - { 0, 6, 8, 9, 15, 17, 18, 37, 23, 45, 46, 50, 24, 40, 29 , EUA}; - static const UInt child_1[] = - { 6, 1, 7, 15, 10, 16, 19, 20, 38, 46, 47, 48, 25, 26, 41 , EUA}; - static const UInt child_2[] = - { 8, 7, 2, 17, 16, 11, 36, 21, 22, 50, 48, 49, 39, 27, 28 , EUA}; - static const UInt child_3[] = - { 9, 15, 17, 3, 12, 14, 24, 40, 29, 51, 52, 56, 30, 43, 35 , EUA}; - static const UInt child_4[] = - { 15, 10, 16, 12, 4, 13, 25, 26, 41, 52, 53, 54, 31, 32, 44 , EUA}; - static const UInt child_5[] = - { 17, 16, 11, 14, 13, 5, 39, 27, 28, 56, 54, 55, 42, 33, 34 , EUA}; - static const UInt child_6[] = - { 7, 8, 6, 16, 17, 15, 36, 37, 38, 48, 50, 46, 39, 40, 41 , EUA}; - static const UInt child_7[] = - { 16, 17, 15, 13, 14, 12, 39, 40, 41, 54, 56, 52, 42, 43, 44 , EUA}; - static const UInt * child_node_table[] = - { child_0 , child_1 , child_2 , child_3 , - child_4 , child_5 , child_6 , child_7 }; - - - - // Edge topology and node tables including edges' child-nodes - - static const UInt edge_0[] = { 0, 1, 6, 18, 19 , EUA}; - static const UInt edge_1[] = { 1, 2, 7, 20, 21 , EUA}; - static const UInt edge_2[] = { 2, 0, 8, 22, 23 , EUA}; - static const UInt edge_3[] = { 3, 4, 12, 30, 31 , EUA}; - static const UInt edge_4[] = { 4, 5, 13, 32, 33 , EUA}; - static const UInt edge_5[] = { 5, 3, 14, 34, 35 , EUA}; - static const UInt edge_6[] = { 0, 3, 9, 45, 51 , EUA}; - static const UInt edge_7[] = { 1, 4, 10, 47, 53 , EUA}; - static const UInt edge_8[] = { 2, 5, 11, 49, 55 , EUA}; - static const UInt * edge_table[] = - { edge_0 , edge_1 , edge_2 , - edge_3 , edge_4 , edge_5 , - edge_6 , edge_7 , edge_8 }; - - // Face topology, nodes tables, and edge tables - - static const UInt face_0[] = {0, 1, 4, 3, 6, 10, 12, 9, 15, 18, 19, 47, 53, 31, 30, 51, 45, 46, 25, 52, 24, EUA}; - static const UInt face_1[] = {1, 2, 5, 4, 7, 11, 13, 10, 16, 20, 21, 49, 55, 33, 32, 53, 47, 48, 27, 54, 26, EUA}; - static const UInt face_2[] = {0, 3, 5, 2, 9, 14, 11, 8, 17, 45, 51, 35, 34, 55, 49, 22, 23, 29, 56, 28, 50, EUA}; - static const UInt face_3[] = {0, 2, 1, 8, 7, 6, 23, 22, 21, 20, 19, 18, 37, 36, 38 , EUA}; - static const UInt face_4[] = {3, 4, 5, 12, 13, 14, 30, 31, 32, 33, 34, 35, 43, 44, 42 , EUA}; - - static const UInt * face_table[] = - { face_0 , face_1 , face_2 , face_3 , face_4 }; - - static RefinementTopology wedge6_refinement(&wedge6, 8, wedge6_child, 18, child_node_table, 9, edge_table, 5, face_table, 0, NULL, NULL, false); - static RefinementTopology wedge15_refinement(&wedge15, 8, wedge15_child, 57, child_node_table, 9, edge_table, 5, face_table, 0, NULL, NULL, false); - } - } - - VERIFY_TRUE( nnode == 6 || nnode == 15 ); - - MeshObjTopology * const top = nnode == 6 ? &wedge6 : &wedge15 ; - - return top ; - } - - - // Pyramids with 5 or 13 nodes (3D solid). - // eclass == SOLID = > sdim == 3 && mdim == 3 - const MeshObjTopology * - pyramid( - UInt nnode ) - { - /* %TRACE[NONE]% */ /* %TRACE% */ - static MeshObjTopology pyramid5(shards::getCellTopologyData >()); - static MeshObjTopology pyramid13(shards::getCellTopologyData >()); - - static bool first = true ; - - if ( first ) { - - first = false ; - - { // Children and child nodes - - static const_top_ptr tet4 = StdMeshObjTopologies::Solid_Tet_4(); - - //Note 13 Node Pyramid Refinement not yet complete. - static const_top_ptr pyramid5_child[] = - {&pyramid5, &pyramid5, &pyramid5, &pyramid5, &pyramid5, - &pyramid5, tet4, tet4, tet4, tet4}; - - static const_top_ptr pyramid13_child[] = - {&pyramid13, &pyramid13, &pyramid13, &pyramid13, - &pyramid13, &pyramid13, &pyramid13, &pyramid13, - &pyramid13, &pyramid13, &pyramid13, &pyramid13 }; - - static const UInt child_0[] = { 0, 5, 13, 8, 9 , EUA}; - static const UInt child_1[] = { 5, 1, 6, 13, 10 , EUA}; - static const UInt child_2[] = { 13, 6, 2, 7, 11 , EUA}; - static const UInt child_3[] = { 8, 13, 7, 3, 12 , EUA}; - static const UInt child_4[] = { 9, 12, 11, 10, 13 , EUA}; - static const UInt child_5[] = { 9, 10, 11, 12, 4 , EUA}; - static const UInt child_6[] = { 13, 10, 9, 5 , EUA}; - static const UInt child_7[] = { 13, 11, 10, 6 , EUA}; - static const UInt child_8[] = { 13, 12, 11, 7 , EUA}; - static const UInt child_9[] = { 13, 9, 12, 8 , EUA}; - - static const UInt * child_node_table[] = - { child_0 , child_1 , child_2, child_3 , child_4 , - child_5, child_6, child_7, child_8, child_9 }; - - // Edge topology and node tables including edges' child-nodes - - /* TODO: Update the 99's with the child nodes for the 13 node pyramid */ - static const UInt edge_0[] = { 0, 1, 5 , 99, 99 , EUA}; - static const UInt edge_1[] = { 1, 2, 6 , 99, 99 , EUA}; - static const UInt edge_2[] = { 2, 3, 7 , 99, 99 , EUA}; - static const UInt edge_3[] = { 3, 0, 8 , 99, 99 , EUA}; - static const UInt edge_4[] = { 0, 4, 9 , 99, 99 , EUA}; - static const UInt edge_5[] = { 1, 4, 10 , 99, 99 , EUA}; - static const UInt edge_6[] = { 2, 4, 11 , 99, 99 , EUA}; - static const UInt edge_7[] = { 3, 4, 12 , 99, 99 , EUA}; - static const UInt * edge_table[] = - { edge_0 , edge_1 , edge_2 , edge_3 , - edge_4 , edge_5 , edge_6 , edge_7 }; - - // Face topology, nodes tables, and edge tables - - static const UInt face_0[] = { 0, 1, 4, 5, 10, 9 , EUA}; - static const UInt face_1[] = { 1, 2, 4, 6, 11, 10 , EUA}; - static const UInt face_2[] = { 2, 3, 4, 7, 12, 11 , EUA}; - static const UInt face_3[] = { 3, 0, 4, 8, 9, 12 , EUA}; - static const UInt face_4[] = { 0, 3, 2, 1, 8, 7, 6, 5, 13 , EUA}; - - static const UInt * face_table[] = - { face_0 , face_1 , face_2 , face_3 , face_4 }; - - static RefinementTopology pyramid5_refinement(&pyramid5, 10, pyramid5_child, 14, child_node_table, 8, edge_table, 5, face_table, 0, NULL, NULL, false); - static RefinementTopology pyramid13_refinement(&pyramid13, 0, pyramid13_child, 0, child_node_table, 8, edge_table, 5, face_table, 0, NULL, NULL, false); - } - } - - VERIFY_TRUE( nnode == 5 || nnode == 13 ); - - MeshObjTopology * const top = nnode == 5 ? &pyramid5 : &pyramid13 ; - - return top ; - } - - const MeshObjTopology * Node_0() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Node_0()"); /* %TRACE% */ - return node(); - } - - const MeshObjTopology * Particle_1() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Particle_1()"); /* %TRACE% */ - return point(); - } - - /*--------------------------------------------------------------------*/ - /* Line topologies (edges, rods, 2D shell) */ - const MeshObjTopology * Edge_2() { - // // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Edge_2()"); /* %TRACE% */ - return line(NOT_ELEMENT, 2); - } - - const MeshObjTopology * Edge_3() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Edge_3()"); /* %TRACE% */ - return line(NOT_ELEMENT, 3); - } - - const MeshObjTopology * Rod_2() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Rod_2()"); /* %TRACE% */ - return line(ROD, 2); - } - - const MeshObjTopology * Rod_3() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Rod_3()"); /* %TRACE% */ - return line(ROD, 3); - } - - const MeshObjTopology * Shell_Line_2() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Line_2()"); /* %TRACE% */ - return line(SHELL, 2); - } - - const MeshObjTopology * Shell_Line_3() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Line_3()"); /* %TRACE% */ - return line(SHELL, 3); - } - - const MeshObjTopology * Face_Tri_3() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Tri_3()"); /* %TRACE% */ - return tri(NOT_ELEMENT, 3); - } - - const MeshObjTopology * Face_Tri_6() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Tri_6()"); /* %TRACE% */ - return tri(NOT_ELEMENT, 6); - } - - const MeshObjTopology * Face_Tri_4() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Tri_4()"); /* %TRACE% */ - return tri4(NOT_ELEMENT); - } - - const MeshObjTopology * Shell_Tri_3() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Tri_3()"); /* %TRACE% */ - return tri(SHELL, 3); - } - - const MeshObjTopology * Shell_Tri_6() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Tri_6()"); /* %TRACE% */ - return tri(SHELL, 6); - } - - - /*--------------------------------------------------------------------*/ - /* Quadrilaterals with 4, 8, or 9 nodes */ - const MeshObjTopology * Face_Quad_4() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Quad_4()"); /* %TRACE% */ - return quad(NOT_ELEMENT, 4); - } - - const MeshObjTopology * Face_Quad_8() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Quad_8()"); /* %TRACE% */ - return quad(NOT_ELEMENT, 8); - } - - const MeshObjTopology * Face_Quad_9() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Face_Quad_9()"); /* %TRACE% */ - return quad(NOT_ELEMENT, 9); - } - - const MeshObjTopology * Shell_Quad_4() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Quad_4()"); /* %TRACE% */ - return quad(SHELL, 4); - } - - const MeshObjTopology * Shell_Quad_9() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Shell_Quad_9()"); /* %TRACE% */ - return quad(SHELL, 9); - } - - /*--------------------------------------------------------------------*/ - /* Hexahedrons with 8, 20, or 27 nodes */ - const MeshObjTopology * Solid_Hex_8() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Hex_8()"); /* %TRACE% */ - return hex(8); - } - - const MeshObjTopology * Solid_Hex_20() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Hex_20()"); /* %TRACE% */ - return hex(20); - } - - const MeshObjTopology * Solid_Hex_27() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Hex_27()"); /* %TRACE% */ - return hex(27); - } - - /*--------------------------------------------------------------------*/ - /* Tetrahedrons with 4, 8, or 10 nodes */ - const MeshObjTopology * Solid_Tet_4() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Tet_4()"); /* %TRACE% */ - return tet(4); - } - - const MeshObjTopology * Solid_Tet_8() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Tet_8()"); /* %TRACE% */ - return tet(8); - } - - const MeshObjTopology * Solid_Tet_10() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Tet_10()"); /* %TRACE% */ - return tet(10); - } - - /*--------------------------------------------------------------------*/ - /* Pentahedrons (a.k.a. "wedges") with 6 or 15 nodes */ - const MeshObjTopology * Solid_Wedge_6() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Wedge_6()"); /* %TRACE% */ - return wedge(6); - } - - const MeshObjTopology * Solid_Wedge_15() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Wedge_15()"); /* %TRACE% */ - return wedge(15); - } - - /*--------------------------------------------------------------------*/ - /* Pyramids with 5 or 13 nodes */ - const MeshObjTopology * Solid_Pyramid_5() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Pyramid_5()"); /* %TRACE% */ - return pyramid(5); - } - - const MeshObjTopology * Solid_Pyramid_13() { - // /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Solid_Pyramid_13()"); /* %TRACE% */ - return pyramid(13); - } - - void - bootstrap() - { - /* %TRACE[ON]% */ /* %TRACE% */ - static bool first_call = true ; - - if ( first_call ) { // Construct topologies - first_call = false ; - - // Nodes - node(); - - // Edges - line(NOT_ELEMENT, 3); - - // Faces - tri( NOT_ELEMENT, 3); - tri4(NOT_ELEMENT); - tri( NOT_ELEMENT, 6); - quad(NOT_ELEMENT, 4); - quad(NOT_ELEMENT, 8); - quad(NOT_ELEMENT, 9); - - // Elements - point(); - line(ROD, 2); - line(ROD, 3); - line(SHELL, 2); - line(SHELL, 3); - tri( SHELL, 3); - tri( SHELL, 6); - tri4(SHELL); - quad(SHELL, 4); - quad(SHELL, 9); - - hex( 8); - hex(20); - hex(27); - tet( 4); - tet( 8); - tet(10); - wedge( 6); - wedge(15); - pyramid( 5); - pyramid(13); - } - } - - } // namespace StdMeshObjTopologies -} // namespace Elem -} // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.hpp deleted file mode 100644 index 09b7cc0edb50..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/StdMeshObjTopologies.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 1997 - 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef stk_adapt_sierra_element_StdMeshObjTopologies_hpp -#define stk_adapt_sierra_element_StdMeshObjTopologies_hpp - -namespace stk_classic { - namespace adapt { - enum { END_UINT_ARRAY = 99999 }; - - namespace Elem { - - namespace StdMeshObjTopologies { - - struct RefinementTopologyExtraEntry - { - unsigned ordinal_of_node; // ordinal of node in the total list of nodes - corresponds to the shards node ordinal - unsigned rank_of_subcell; // rank of the subcell this node is associated with - unsigned ordinal_of_subcell; // ordinal of the subcell in the shards numbering (e.g. edge # 3) - unsigned ordinal_of_node_on_subcell; // ordinal of the node on the subcell (whcih node it is on a subcell that has multiple nodes) - unsigned num_nodes_on_subcell; // how many nodes exist on the subcell - double parametric_coordinates[3]; - }; - - typedef RefinementTopologyExtraEntry RefTopoX[]; - - template - class RefTopoX1 - { - public: - typedef RefinementTopologyExtraEntry RefTopoX2[]; - }; - - template - class RefinementTopologyExtra - { - public: - static RefTopoX refinement_topology; - }; - - void bootstrap(); - - } // namespace StdMeshObjTopologies - } // namespace Elem - } // namespace adapt -} // namespace stk_classic - -#endif // stk_adapt_sierra_element_StdMeshObjTopologies_hpp diff --git a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/stk_percept_code_types.hpp b/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/stk_percept_code_types.hpp deleted file mode 100644 index c74c78d5f11c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/stk_adapt/sierra_element/stk_percept_code_types.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2000 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 1996 Sandia Corporation, Albuquerque, NM. - -#ifndef stk_percept_code_types_hpp -#define stk_percept_code_types_hpp - -#include -#include - -#define THROW(message) do { \ - std::ostringstream msg; \ - msg << message; \ - throw std::runtime_error(msg.str()); \ - } while (0) - - - -// If one of these two macros is not defined, default the precision to double -#if !defined FOUR_BYTE_REAL && !defined EIGHT_BYTE_REAL -#define EIGHT_BYTE_REAL -#endif - -#if !defined FOUR_BYTE_LONG && !defined EIGHT_BYTE_LONG -#define FOUR_BYTE_LONG -#endif - -/* typedefs to allow easy modification of word size for a particular - * application or computer */ - -#include - -typedef void Void; - -typedef int Int; -typedef unsigned int UInt; -#define Int_MAX INT_MAX -#define Int_MIN INT_MIN -#define UInt_MAX UINT_MAX - -#ifdef FOUR_BYTE_LONG - -typedef long Long; -typedef unsigned long ULong; -#define Long_MAX LONG_MAX -#define Long_MIN LONG_MIN -#define ULong_MAX ULONG_MAX - -#elif defined EIGHT_BYTE_LONG - -typedef long long Long; -typedef unsigned long long ULong; -#define Long_MAX LLONG_MAX -#define Long_MIN LLONG_MIN -#define ULong_MAX ULLONG_MAX - -#endif - -#include - -#ifdef FOUR_BYTE_REAL - -typedef float Real; -#define Real_MAX FLT_MAX -#define Real_MIN FLT_MIN -#define Real_DIG FLT_DIG -#define Real_EPSILON FLT_EPSILON - -#define REAL_MAX FLT_MAX -#define REAL_MIN FLT_MIN -#define REAL_DIG FLT_DIG -#define REAL_EPSILON FLT_EPSILON - -#elif defined EIGHT_BYTE_REAL - -typedef double Real; -#define Real_MAX DBL_MAX -#define Real_MIN DBL_MIN -#define Real_DIG DBL_DIG -#define Real_EPSILON DBL_EPSILON - -#define REAL_MAX DBL_MAX -#define REAL_MIN DBL_MIN -#define REAL_DIG DBL_DIG -#define REAL_EPSILON DBL_EPSILON - -#endif - -#include - -//typedef std::complex Complex; - -/* using C++ */ -#ifdef __cplusplus - -#else - -#endif // __cplusplus - -#endif // stk_percept_code_types_hpp diff --git a/packages/stk/stk_classic/stk_adapt/todo.txt b/packages/stk/stk_classic/stk_adapt/todo.txt deleted file mode 100644 index 12bfd3df3d7b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/todo.txt +++ /dev/null @@ -1 +0,0 @@ -1. Intrepid - ask for Line<3> support diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_adapt/unit_tests/CMakeLists.txt deleted file mode 100644 index db49a21f8f8a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - -INCLUDE(TribitsAddExecutableAndTest) - -ASSERT_DEFINED(PACKAGE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR) - -FILE(GLOB SOURCES *.cpp) - -#TRIBITS_ADD_EXECUTABLE_AND_TEST( -# adapt_UnitTest -# SOURCES ${SOURCES} -# COMM serial -# STANDARD_PASS_OUTPUT -# ) diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.cpp deleted file mode 100644 index dc280a98a4b1..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - TestLocalRefiner::TestLocalRefiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - // test uniform refinement using bulk data and buckets directly (not using the element color vectors) - unsigned TestLocalRefiner:: - doForAllElements(stk_classic::mesh::EntityRank rank, NodeRegistry::ElementFunctionPrototype function, - vector< ColorerSetType >& elementColors, unsigned elementType, - vector& needed_entity_ranks, - bool only_count, bool doAllElements) - //bool only_count=false, bool doAllElements=true) - { - EXCEPTWATCH; - unsigned num_elem = 0; - - int progress_meter_num_total = 0; - if (m_doProgress) - { - m_doProgress = false; - progress_meter_num_total = doForAllElements(rank, function, elementColors, elementType, needed_entity_ranks, true, doAllElements); - m_doProgress = true; - ProgressMeterData pd(ProgressMeterData::INIT, 0.0, "NodeRegistry passes"); - notifyObservers(&pd); - } - int progress_meter_when_to_post = progress_meter_num_total / m_progress_meter_frequency; - if (0 == progress_meter_when_to_post) - progress_meter_when_to_post = 1; - double d_progress_meter_num_total = progress_meter_num_total; - - percept::PerceptMesh& eMesh = m_eMesh; - -#if 0 - stk_classic::mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - const std::vector< stk_classic::mesh::Part * > & parts = metaData.get_parts(); - unsigned nparts = parts.size(); - if (1) std::cout << "Number of parts = " << nparts << std::endl; - VectorFieldType* coordField = eMesh.get_coordinates_field(); -#endif - stk_classic::mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - - const std::vector & buckets = bulkData.buckets( rank ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (in_surface_selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - // in case the cell topology is needed - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - shards::CellTopology cell_topo(cell_topo_data); - - if (cell_topo.getKey() != elementType) - continue; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - const stk_classic::mesh::Entity& element = bucket[iElement]; - - //const stk_classic::mesh::PairIterRelation& elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - //const stk_classic::mesh::Entity& element = * element_p; - - bool elementIsGhost = m_eMesh.isGhostElement(element); - if (!elementIsGhost) - ++num_elem; - - if (!only_count && (doAllElements || elementIsGhost)) - { - refineMethodApply(function, element, needed_entity_ranks); - } - - if (m_doProgress && (num_elem % progress_meter_when_to_post == 0) ) - { - double progress_meter_percent = 100.0*((double)num_elem)/d_progress_meter_num_total; - ProgressMeterData pd(ProgressMeterData::RUNNING, progress_meter_percent, "NodeRegistry passes"); - notifyObservers(&pd); - } - } - - } - } - - if (m_doProgress) - { - ProgressMeterData pd(ProgressMeterData::FINI, 0.0, "NodeRegistry passes"); - notifyObservers(&pd); - } - - return num_elem; - } - - void TestLocalRefiner:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } // iSubDimOrd - } // ineed_ent - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.hpp deleted file mode 100644 index 031bfbc918c5..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefiner.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef stk_adapt_TestLocalRefiner_hpp -#define stk_adapt_TestLocalRefiner_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that does uniform refinement but uses non-uniform methods - */ - class TestLocalRefiner : public Refiner - { - public: - TestLocalRefiner(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - protected: - virtual unsigned - doForAllElements(stk_classic::mesh::EntityRank rank, NodeRegistry::ElementFunctionPrototype function, - vector< ColorerSetType >& elementColors, unsigned elementType, - vector& needed_entity_ranks, - bool only_count=false, bool doAllElements=true); - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_1.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_1.hpp deleted file mode 100644 index af2f9b2515a4..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_1.hpp +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_1_hpp -#define stk_adapt_TestLocalRefinerTet_N_1_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3 - */ - class TestLocalRefinerTet_N_1 : public Refiner - { - public: - TestLocalRefinerTet_N_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - // ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_1::TestLocalRefinerTet_N_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - void TestLocalRefinerTet_N_1:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { -#if 0 - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - -#endif - // mark all edges - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } - - } // iSubDimOrd - } // ineed_ent - } - -#if 0 - ElementUnrefineCollection TestLocalRefinerTet_N_1::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false)) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - //if (coord[0] > 2.1 || coord[1] > 2.1) - if (coord[0] > 1.0001 || coord[1] > 1.0001) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp unref element id= " << element.identifier() << std::endl; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } -#endif - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2.hpp deleted file mode 100644 index 6c5656cd0de4..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2.hpp +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_2_hpp -#define stk_adapt_TestLocalRefinerTet_N_2_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3 - */ - class TestLocalRefinerTet_N_2 : public Refiner - { - public: - TestLocalRefinerTet_N_2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0, unsigned mark_first_n_edges=1); - - // ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - unsigned m_mark_first_n_edges; - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_2::TestLocalRefinerTet_N_2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field, unsigned mark_first_n_edges) : - Refiner(eMesh, bp, proc_rank_field), m_mark_first_n_edges(mark_first_n_edges) - { - } - - - void TestLocalRefinerTet_N_2:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { -#if 0 - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - -#endif - // mark first m_mark_first_n_edges edges - //std::cout << "element.identifier() = " << element.identifier() << std::endl; - - if (iSubDimOrd < m_mark_first_n_edges && element.identifier() == 1) - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } - - } // iSubDimOrd - } // ineed_ent - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2_1.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2_1.hpp deleted file mode 100644 index 2bb39b03efac..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_2_1.hpp +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_2_1_hpp -#define stk_adapt_TestLocalRefinerTet_N_2_1_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3 - */ - class TestLocalRefinerTet_N_2_1 : public Refiner - { - public: - TestLocalRefinerTet_N_2_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0, unsigned edge_mark_bitcode=1); - - // ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - unsigned m_edge_mark_bitcode; - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_2_1::TestLocalRefinerTet_N_2_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field, unsigned edge_mark_bitcode) : - Refiner(eMesh, bp, proc_rank_field), m_edge_mark_bitcode(edge_mark_bitcode) - { - } - - - void TestLocalRefinerTet_N_2_1:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { -#if 0 - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - -#endif - // mark first m_edge_mark_bitcode edges - std::cout << "tmp TestLocalRefinerTet_N_2_1 element.identifier() = " << element.identifier() - << " m_edge_mark_bitcode= " << m_edge_mark_bitcode << std::endl; - - if ( ((1 << iSubDimOrd) & m_edge_mark_bitcode) && element.identifier() == 1) - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - - } - - } // iSubDimOrd - } // ineed_ent - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3.hpp deleted file mode 100644 index 76a5b62d190f..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3.hpp +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_3_hpp -#define stk_adapt_TestLocalRefinerTet_N_3_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3 - */ - class TestLocalRefinerTet_N_3 : public Refiner - { - public: - TestLocalRefinerTet_N_3(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - // ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_3::TestLocalRefinerTet_N_3(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - void TestLocalRefinerTet_N_3:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { -#if 0 - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - -#endif - // mark first m_edge_mark_bitcode edges - unsigned edge_mark_bitcode = (element.identifier() - 1); - - if ( ((1 << iSubDimOrd) & edge_mark_bitcode ) ) - { - //if (edge_mark_bitcode == 4) - if (0) - { - std::cout << "tmp TestLocalRefinerTet_N_3 element.identifier() = " << element.identifier() - << " edge_mark_bitcode = " << edge_mark_bitcode << " iSubDimOrd= " << iSubDimOrd << std::endl; - } - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - - } - - } // iSubDimOrd - } // ineed_ent - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.cpp deleted file mode 100644 index 712e6649488a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.cpp +++ /dev/null @@ -1,116 +0,0 @@ - -#include - -namespace stk_classic { - namespace adapt { - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3_1 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_3_1::TestLocalRefinerTet_N_3_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field, unsigned edge_mark_bitcode) : - Refiner(eMesh, bp, proc_rank_field), m_edge_mark_bitcode(edge_mark_bitcode) - { - } - - - void TestLocalRefinerTet_N_3_1:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { -#if 0 - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - -#endif - // mark only the first element - - - if ( ((1 << iSubDimOrd) & m_edge_mark_bitcode ) && 1 == element.identifier() ) - { - if (1) - { - std::cout << "tmp TestLocalRefinerTet_N_3_1 element.identifier() = " << element.identifier() - << " edge_mark_bitcode = " << m_edge_mark_bitcode << " iSubDimOrd= " << iSubDimOrd << std::endl; - } - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - - } - - } // iSubDimOrd - } // ineed_ent - } - - - - } -} - diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.hpp deleted file mode 100644 index 0dfdb00c474e..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_3_1.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_3_1_hpp -#define stk_adapt_TestLocalRefinerTet_N_3_1_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3_1 - */ - class TestLocalRefinerTet_N_3_1 : public Refiner - { - public: - TestLocalRefinerTet_N_3_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0, unsigned edge_mark_bitcode=1); - - // ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - unsigned m_edge_mark_bitcode; - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_4.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_4.hpp deleted file mode 100644 index f01abae04ab3..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTet_N_4.hpp +++ /dev/null @@ -1,191 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTet_N_4_hpp -#define stk_adapt_TestLocalRefinerTet_N_4_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_4 - */ - class TestLocalRefinerTet_N_4 : public Refiner - { - public: - TestLocalRefinerTet_N_4(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0, unsigned edge_mark_bitcode=1); - - ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - unsigned m_edge_mark_bitcode; - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_4 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTet_N_4::TestLocalRefinerTet_N_4(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field, unsigned edge_mark_bitcode) : - Refiner(eMesh, bp, proc_rank_field), m_edge_mark_bitcode(edge_mark_bitcode) - { - } - - - void TestLocalRefinerTet_N_4:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical plane position - const double vx = 0.21; - - // horizontal plane position - const double vy = 1.21; - - // in plane position - const double vz = 1.21; - - // choose to refine or not - bool do_refine = false; - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) -#if 1 - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - || - ( std::fabs(coord0[2]-coord1[2]) > 1.e-3 && - ( (coord0[2] < vz && vz < coord1[2]) || (coord1[2] < vz && vz < coord0[2]) ) - ) -#endif - ) - { - do_refine = true; - } - - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, do_refine); - } - - } // iSubDimOrd - } // ineed_ent - } - - ElementUnrefineCollection TestLocalRefinerTet_N_4::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false) ) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - if (coord[0] > 2.1 || coord[1] > 2.1 || coord[2] > 2.1) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp element id= " << element.identifier() << " "; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.cpp deleted file mode 100644 index e4808657fde3..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - TestLocalRefinerTri::TestLocalRefinerTri(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - void TestLocalRefinerTri:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - if (coord0[0] < 0.49 && coord1[0] < 0.49) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - - } // iSubDimOrd - } // ineed_ent - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.hpp deleted file mode 100644 index 2155120fbf29..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_hpp -#define stk_adapt_TestLocalRefinerTri_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that does uniform refinement but uses non-uniform methods - */ - class TestLocalRefinerTri : public Refiner - { - public: - TestLocalRefinerTri(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - protected: - - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.cpp deleted file mode 100644 index db2dda5688ba..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - TestLocalRefinerTri1::TestLocalRefinerTri1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - void TestLocalRefinerTri1:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - // VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - unsigned which_edge_marked = 0u; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) - { - ++num_marked; - which_edge_marked = iSubDimOrd; - } - } - } - std::cout << "tmp num_marked= " << num_marked << " which_edge_marked= " << which_edge_marked << std::endl; - - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - // arbitrarily mark the first edge if no edges are marked - if (num_marked <= 1) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], which_edge_marked, true ); - } - - } - - } // ineed_ent - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.hpp deleted file mode 100644 index dc4590e6f54a..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri1.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri1_hpp -#define stk_adapt_TestLocalRefinerTri1_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that does uniform refinement but uses non-uniform methods - */ - class TestLocalRefinerTri1 : public Refiner - { - public: - TestLocalRefinerTri1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.cpp deleted file mode 100644 index 6aba7167a9eb..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - TestLocalRefinerTri2::TestLocalRefinerTri2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field, bool diagonals) : - Refiner(eMesh, bp, proc_rank_field), m_diagonals(diagonals) - { - } - - void TestLocalRefinerTri2:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // only refine diagonals of the split quads - if (m_diagonals) - { - if ( std::abs(coord0[0]-coord1[0]) > 1.e-3 && std::abs(coord0[1]-coord1[1]) > 1.e-3 ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - else - { - if ( std::abs(coord0[0]-coord1[0]) < 1.e-3 && std::abs(coord0[1]-coord1[1]) > 1.e-3 ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - } - - } // iSubDimOrd - } // ineed_ent - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.hpp deleted file mode 100644 index d5c780e0f02b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri2.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri2_hpp -#define stk_adapt_TestLocalRefinerTri2_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that does uniform refinement but uses non-uniform methods - */ - class TestLocalRefinerTri2 : public Refiner - { - bool m_diagonals; - public: - TestLocalRefinerTri2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0, bool diagonals=true); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.cpp deleted file mode 100644 index 3abd0d6c6cf4..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N::TestLocalRefinerTri_N(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - void TestLocalRefinerTri_N:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - //double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - //double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // choose to refine or not - //if (0 || (node0.identifier() < node1.identifier() || (node0.identifier() % 2 == 0))) - if (node0.identifier() + node1.identifier() < 40) - { - int delta = (int)node0.identifier() - (int)node1.identifier(); - if (delta < 0) delta = -delta; - if ( delta > 4 && (node0.identifier() + node1.identifier() < 30)) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - if ( (node0.identifier() + node1.identifier() > 20)) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - } - - } // iSubDimOrd - } // ineed_ent - } - - ElementUnrefineCollection TestLocalRefinerTri_N::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - bool elementIsGhost = m_eMesh.isGhostElement(element); - if (elementIsGhost) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildElement(element)) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - if (coord[0] > 2.1 || coord[1] > 2.1) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp element id= " << element.identifier() << " "; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.hpp deleted file mode 100644 index d9a4a35e2eea..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_hpp -#define stk_adapt_TestLocalRefinerTri_N_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N - */ - class TestLocalRefinerTri_N : public Refiner - { - public: - TestLocalRefinerTri_N(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.cpp deleted file mode 100644 index 04fa1f9d6793..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include - -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - - -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_1 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N_1::TestLocalRefinerTri_N_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - static std::vector get_random_sequence(int min, int max, int num) - { - srand(1234); - - std::vector seq(num); - for (int i = 0; i < num; i++) - { - seq[i] = (int)((double)min + ((double)(max - min)) * (double)rand()/((double)RAND_MAX)); - } - return seq; - } - - void TestLocalRefinerTri_N_1:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - static std::vector random_sequence = get_random_sequence(1, 50, 50); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - //VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - //double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - //double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // choose to refine or not - if (random_sequence[ node0.identifier() + node1.identifier() ] < node0.identifier() + node1.identifier()) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - - } // iSubDimOrd - } // ineed_ent - } - - ElementUnrefineCollection TestLocalRefinerTri_N_1::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; -#if 0 - // add ghost elements here, but skip them in Refiner::unrefineTheseElements - bool elementIsGhost = m_eMesh.isGhostElement(element); - if (elementIsGhost) - continue; -#endif - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildElement(element, false)) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - if (coord[0] > 2.1 || coord[1] > 2.1) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp element id= " << element.identifier() << " "; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.hpp deleted file mode 100644 index c4402ad00c78..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_1.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_1_hpp -#define stk_adapt_TestLocalRefinerTri_N_1_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_1 - */ - class TestLocalRefinerTri_N_1 : public Refiner - { - public: - TestLocalRefinerTri_N_1(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - // not needed - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.cpp deleted file mode 100644 index cc0b2b63327d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include - -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -//#define STK_PERCEPT_HAS_GEOMETRY -#undef STK_PERCEPT_HAS_GEOMETRY -#if defined( STK_PERCEPT_HAS_GEOMETRY ) -#include -#include -#include -#endif - -// FIXME -// #include -// #include -// FIXME - -namespace stk_classic { - namespace adapt { - - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_2 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N_2::TestLocalRefinerTri_N_2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - void TestLocalRefinerTri_N_2:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // choose to refine or not - if ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - - } // iSubDimOrd - } // ineed_ent - } - - ElementUnrefineCollection TestLocalRefinerTri_N_2::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false) ) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - if (coord[0] > 2.1 || coord[1] > 2.1) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp element id= " << element.identifier() << " "; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } // namespace adapt -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.hpp deleted file mode 100644 index c8f3ace87866..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_2.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_2_hpp -#define stk_adapt_TestLocalRefinerTri_N_2_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_2 - */ - class TestLocalRefinerTri_N_2 : public Refiner - { - public: - TestLocalRefinerTri_N_2(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3.hpp deleted file mode 100644 index 3eb9e81b73b6..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3.hpp +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_3_hpp -#define stk_adapt_TestLocalRefinerTri_N_3_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation that marks some edges randomly to test RefinerPattern_Tri3_Tri3_N_3 - */ - class TestLocalRefinerTri_N_3 : public Refiner - { - public: - TestLocalRefinerTri_N_3(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - ElementUnrefineCollection buildTestUnrefineList(); - - protected: - - virtual void - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, - vector& needed_entity_ranks); - - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3 in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N_3::TestLocalRefinerTri_N_3(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - Refiner(eMesh, bp, proc_rank_field) - { - } - - - void TestLocalRefinerTri_N_3:: - refineMethodApply(NodeRegistry::ElementFunctionPrototype function, const stk_classic::mesh::Entity& element, vector& needed_entity_ranks) - { - //static int n_seq = 400; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - CellTopology cell_topo(cell_topo_data); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - for (unsigned ineed_ent=0; ineed_ent < needed_entity_ranks.size(); ineed_ent++) - { - unsigned numSubDimNeededEntities = 0; - stk_classic::mesh::EntityRank needed_entity_rank = needed_entity_ranks[ineed_ent].first; - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - numSubDimNeededEntities = cell_topo_data->edge_count; - } - else if (needed_entity_rank == m_eMesh.face_rank()) - { - numSubDimNeededEntities = cell_topo_data->side_count; - } - else if (needed_entity_rank == m_eMesh.element_rank()) - { - numSubDimNeededEntities = 1; - } - - // see how many edges are already marked - int num_marked=0; - if (needed_entity_rank == m_eMesh.edge_rank()) - { - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - if (!is_empty) ++num_marked; - } - } - - for (unsigned iSubDimOrd = 0; iSubDimOrd < numSubDimNeededEntities; iSubDimOrd++) - { - /// note: at this level of granularity we can do single edge refinement, hanging nodes, etc. - //SubDimCell_SDSEntityType subDimEntity; - //getSubDimEntity(subDimEntity, element, needed_entity_rank, iSubDimOrd); - //bool is_empty = m_nodeRegistry->is_empty( element, needed_entity_rank, iSubDimOrd); - //if(1||!is_empty) - - if (needed_entity_rank == m_eMesh.edge_rank()) - { - stk_classic::mesh::Entity & node0 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[0]].entity(); - stk_classic::mesh::Entity & node1 = *elem_nodes[cell_topo_data->edge[iSubDimOrd].node[1]].entity(); - double * const coord0 = stk_classic::mesh::field_data( *coordField , node0 ); - double * const coord1 = stk_classic::mesh::field_data( *coordField , node1 ); - - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - (m_nodeRegistry ->* function)(element, needed_entity_ranks[ineed_ent], iSubDimOrd, true); - } - } - - } // iSubDimOrd - } // ineed_ent - } - - ElementUnrefineCollection TestLocalRefinerTri_N_3::buildTestUnrefineList() - { - ElementUnrefineCollection elements_to_unref; - - const vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - - // FIXME - // skip elements that are already a parent (if there's no family tree yet, it's not a parent, so avoid throwing an error is isParentElement) - const bool check_for_family_tree = false; - bool isParent = m_eMesh.isParentElement(element, check_for_family_tree); - - if (isParent) - continue; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - if (elem_nodes.size() && m_eMesh.isChildWithoutNieces(element, false)) - { - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - //if (coord[0] > 2.1 || coord[1] > 2.1) - if (coord[0] > 1.0001 || coord[1] > 1.0001) - { - found = false; - break; - } - } - if (found) - { - elements_to_unref.insert(&element); - //std::cout << "tmp unref element id= " << element.identifier() << std::endl; - //m_eMesh.print_entity(std::cout, element); - } - } - } - } - } - - return elements_to_unref; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_EdgeBasedAnisotropic.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_EdgeBasedAnisotropic.hpp deleted file mode 100644 index ced988c9d048..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_EdgeBasedAnisotropic.hpp +++ /dev/null @@ -1,262 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_3_EdgeBasedAnisotropic_hpp -#define stk_adapt_TestLocalRefinerTri_N_3_EdgeBasedAnisotropic_hpp - -#include - -#include - -namespace stk_classic { - namespace adapt { - - void exact_hessian(const int id, const double *xyz, double *hess, const int spatial_dim) - { - switch (id) - { - case 0: - { - // simple poly with max Hess at x=1 - const double x = xyz[0]; - hess[0] = 200*x*x; - hess[1] = 0; - hess[2] = 0; - hess[3] = 0; - } - break; - case 1: - { - // simple poly with max Hess at y=1 - const double y = xyz[1]; - hess[0] = 0; - hess[1] = 0; - hess[2] = 0; - hess[3] = 200*y*y; - } - break; - case 2: - { - // fully 2d case - const double x = xyz[0]; - const double y = xyz[1]; - hess[0] = 200*x*x; - hess[1] = 0; - hess[2] = 0; - hess[3] = 200*y*y; - } - break; - case 3: - { - // full tensor 2d case - // f = 100*(y-x+1)*(y-x-1) = 100*y*y+100*y*y+(-200)*x*y + linear terms - hess[0] = 200; - hess[1] = -200; - hess[2] = -200; - hess[3] = 200; - } - break; - default: - { - std::ostringstream msg; - msg << " exact_hessian unknown id = " << id << "\n"; - throw new std::runtime_error(msg.str()); - } - } - } - - void interp_nodal_hessian( - const int hess_id, - PerceptMesh& eMesh, - VectorFieldType* nodal_hessian_field) - { - const int spatial_dim = eMesh.get_spatial_dim(); - - stk_classic::mesh::Selector selector = - eMesh.get_fem_meta_data()->locally_owned_part() | - eMesh.get_fem_meta_data()->globally_shared_part(); - - std::vector buckets; - stk_classic::mesh::get_buckets( selector, eMesh.get_bulk_data()->buckets( eMesh.node_rank() ), buckets ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) { - - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i = 0; i < num_nodes_in_bucket; i++) { - - stk_classic::mesh::Entity& node = bucket[i]; - - const double *coords = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node); - double *hess = stk_classic::mesh::field_data( *nodal_hessian_field , node); - - exact_hessian(hess_id, coords, hess, spatial_dim); - } - } - } - - /** - * A test implementation as a use case for EdgeBasedAnisotropic - */ - class TestLocalRefinerTri_N_3_EdgeBasedAnisotropic : public IEdgeAdapter - { - public: - TestLocalRefinerTri_N_3_EdgeBasedAnisotropic( - percept::PerceptMesh& eMesh, - UniformRefinerPatternBase & bp, - VectorFieldType * nodal_hessian_field, - stk_classic::mesh::FieldBase *proc_rank_field=0); - - protected: - - /// Client supplies these methods - given an element, which edge, and the nodes on the edge, return instruction on what to do to the edge, - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - virtual int mark( - const stk_classic::mesh::Entity& element, - unsigned which_edge, - stk_classic::mesh::Entity & node0, - stk_classic::mesh::Entity & node1, - double *coord0, - double *coord1, - std::vector* existing_edge_marks) ; - - VectorFieldType * m_nodal_hessian_field; - - const double m_upper_bound, m_lower_bound; - const double length_min, length_max; - }; - - TestLocalRefinerTri_N_3_EdgeBasedAnisotropic::TestLocalRefinerTri_N_3_EdgeBasedAnisotropic( - percept::PerceptMesh& eMesh, - UniformRefinerPatternBase & bp, - VectorFieldType * nodal_hessian_field, - stk_classic::mesh::FieldBase *proc_rank_field) - : - IEdgeAdapter(eMesh, bp, proc_rank_field), - m_nodal_hessian_field(nodal_hessian_field), - m_upper_bound(sqrt(2.0)), - m_lower_bound(1./sqrt(2.0)), - length_min(0.01), - // for coarsen only => use length_max longer than any edge length - length_max(2.0*sqrt(2.0)) // diagonal of 2x2 square - {} - - int - TestLocalRefinerTri_N_3_EdgeBasedAnisotropic::mark( - const stk_classic::mesh::Entity& element, - unsigned which_edge, - stk_classic::mesh::Entity & node0, - stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, - std::vector* existing_edge_marks) - { - int mark=0; - - const int spatial_dim = m_eMesh.get_spatial_dim(); - - std::vector hessian(spatial_dim*spatial_dim, 0.0); - - // Hessian from midpoint interp of nodal Hessian field - const double *hess0 = stk_classic::mesh::field_data( *m_nodal_hessian_field , node0); - const double *hess1 = stk_classic::mesh::field_data( *m_nodal_hessian_field , node1); - for (int d=0; d edge_vec(spatial_dim, 0.0); - double length = 0; - for (int d=0; d lambda(spatial_dim, 0.0); - for (int d=0; d 1/length_max < inv_h_opt < 1/length_min - // TEST for refinement only replace length_max with local_length - //inv_h_opt = std::min(std::max(inv_h_opt, 1./length_max), 1./length_min); - inv_h_opt = std::min(std::max(inv_h_opt, 1./local_length), 1./length_min); - - const double metric = 1. / (local_length * inv_h_opt); - */ - - // Test 2.2: mark if local_metric > 0 - /* - const double metric = (local_metric > 0) ? 2*m_Rup : 0.5*m_Rup; - */ - - double seminorm = 0; - for (int d1=0; d1 Rup - if (metric > m_upper_bound) { - mark |= DO_REFINE; - } -// else if (metric < m_lower_bound) { -// mark |= DO_UNREFINE; -// } -// else { -// mark |= DO_NOTHING; -// } - - return mark; - } - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IEdgeAdapter.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IEdgeAdapter.hpp deleted file mode 100644 index fe1157b24e8b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IEdgeAdapter.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_3_IEdgeAdapter_hpp -#define stk_adapt_TestLocalRefinerTri_N_3_IEdgeAdapter_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation as a use case for IEdgeAdapter - */ - class TestLocalRefinerTri_N_3_IEdgeAdapter : public IEdgeAdapter - { - public: - TestLocalRefinerTri_N_3_IEdgeAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - //virtual ElementUnrefineCollection buildUnrefList(); - - protected: - - /// Client supplies these methods - given an element, which edge, and the nodes on the edge, return instruction on what to do to the edge, - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - virtual int mark(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) ; - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3_IEdgeAdapter in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N_3_IEdgeAdapter::TestLocalRefinerTri_N_3_IEdgeAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - IEdgeAdapter(eMesh, bp, proc_rank_field) - { - } - - - int TestLocalRefinerTri_N_3_IEdgeAdapter:: - mark(const stk_classic::mesh::Entity& element, unsigned which_edge, stk_classic::mesh::Entity & node0, stk_classic::mesh::Entity & node1, - double *coord0, double *coord1, std::vector* existing_edge_marks) - { - int mark=0; - - // refine test - { - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - mark |= DO_REFINE; - } - } - - // choose to unrefine or not - { - if (coord0[0] > 1.0001 || coord0[1] > 1.0001 || coord1[0] > 1.0001 || coord1[1] > 1.0001) - { - } - else - mark |= DO_UNREFINE; - } - - return mark; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IElementAdapter.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IElementAdapter.hpp deleted file mode 100644 index 0281e226f535..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_IElementAdapter.hpp +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_3_IElementAdapter_hpp -#define stk_adapt_TestLocalRefinerTri_N_3_IElementAdapter_hpp - -#include - -namespace stk_classic { - namespace adapt { - - //======================================================================================================================== - //======================================================================================================================== - //======================================================================================================================== - /** - * A test implementation as a use case for IElementAdapter - */ - class TestLocalRefinerTri_N_3_IElementAdapter : public IElementAdapter - { - public: - TestLocalRefinerTri_N_3_IElementAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field=0); - - //virtual ElementUnrefineCollection buildUnrefList(); - - protected: - - /// Client supplies these methods - given an element, which edge, and the nodes on the edge, return instruction on what to do to the edge, - /// DO_NOTHING (nothing), DO_REFINE (refine), DO_UNREFINE - virtual int mark(const stk_classic::mesh::Entity& element); - - }; - - // This is a very specialized test that is used in unit testing only (see unit_localRefiner/break_tri_to_tri_N_3_IElementAdapter in UnitTestLocalRefiner.cpp) - - TestLocalRefinerTri_N_3_IElementAdapter::TestLocalRefinerTri_N_3_IElementAdapter(percept::PerceptMesh& eMesh, UniformRefinerPatternBase & bp, stk_classic::mesh::FieldBase *proc_rank_field) : - IElementAdapter(eMesh, bp, proc_rank_field) - { - } - - - int TestLocalRefinerTri_N_3_IElementAdapter:: - mark(const stk_classic::mesh::Entity& element) - { - int mark=0; - - // refine test - { - // vertical line position - const double vx = 0.21; - - // horizontal line position - const double vy = 1.21; - - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - stk_classic::mesh::Entity *node1 = elem_nodes[(inode + 1) % 3].entity(); - double *coord0 = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - double *coord1 = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node1 ); - - // choose to refine or not - if ( - ( std::fabs(coord0[0]-coord1[0]) > 1.e-3 && - ( (coord0[0] < vx && vx < coord1[0]) || (coord1[0] < vx && vx < coord0[0]) ) - ) - || - ( std::fabs(coord0[1]-coord1[1]) > 1.e-3 && - ( (coord0[1] < vy && vy < coord1[1]) || (coord1[1] < vy && vy < coord0[1]) ) - ) - ) - { - mark |= DO_REFINE; - break; - } - } - } - - // unrefine test - { - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - bool found = true; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coord = stk_classic::mesh::field_data( *m_eMesh.get_coordinates_field(), *node ); - //if (coord[0] > 2.1 || coord[1] > 2.1) - if (coord[0] > 1.0001 || coord[1] > 1.0001) - { - found = false; - break; - } - } - - if (found) - { - mark |= DO_UNREFINE; - } - } - return mark; - } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_MeshSizeRatio.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_MeshSizeRatio.hpp deleted file mode 100644 index 8f3365d940a0..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/TestLocalRefinerTri_N_3_MeshSizeRatio.hpp +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef stk_adapt_TestLocalRefinerTri_N_3_MeshSizeRatio_hpp -#define stk_adapt_TestLocalRefinerTri_N_3_MeshSizeRatio_hpp - -#include - -#include - -namespace stk_classic { - namespace adapt { - - void exact_nodal_solution(const double *xyz, double *field, const int spatial_dim) - { - // 1d case for now - const double xdiff = xyz[0] - 0.5329; - const double lambda = 0.5; - const double amp = 1e-2; - const double twopi = 8.0*atan(1.0); - - if (xdiff > 0.0 && xdiff < 0.5) - field[0] = 1.0 + amp*(1.0-cos(twopi*xdiff/lambda)); - else - field[0] = 0.0; - } - - double triangle_area(const std::vector & nodal_coords) - { - double x[3] = {nodal_coords[0], nodal_coords[2], nodal_coords[4]}; - double y[3] = {nodal_coords[1], nodal_coords[3], nodal_coords[5]}; - - return 0.5*fabs( (x[0]-x[2])*(y[1]-y[0]) - (x[0]-x[1])*(y[2]-y[0]) ); - } - - void compute_elem_mesh_size_ratio( - PerceptMesh& eMesh, - ScalarFieldType* elem_ratio_field, - const double &global_error_tol) - { - const int spatial_dim = eMesh.get_spatial_dim(); - double local_error_tol = global_error_tol; - - static bool first_run = true; - - stk_classic::mesh::Part * activeElementsPart = eMesh.get_non_const_part("refine_active_elements_part"); - - stk_classic::mesh::Selector selector = first_run ? - eMesh.get_fem_meta_data()->locally_owned_part() : - ( eMesh.get_fem_meta_data()->locally_owned_part() & (*activeElementsPart) ); - - first_run = false; - - std::vector count ; - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - const double num_elems = (double) count[eMesh.element_rank()]; - local_error_tol /= sqrt(num_elems); - - std::vector buckets; - stk_classic::mesh::get_buckets( selector, eMesh.get_bulk_data()->buckets( eMesh.element_rank() ), buckets ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) { - - stk_classic::mesh::Bucket & bucket = **k ; - - shards::CellTopology ct = stk_classic::mesh::fem::get_cell_topology(bucket); - const int Nnpe = ct.getNodeCount(); - - std::vector nodal_interp(Nnpe); - std::vector nodal_coords(Nnpe*spatial_dim); - - const unsigned num_elems_in_bucket = bucket.size(); - for (unsigned i = 0; i < num_elems_in_bucket; i++) { - - stk_classic::mesh::Entity& element = bucket[i]; - - // gather nodal coords and compute centroid - std::vector centroid(spatial_dim, 0.0); - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for (unsigned inode=0; inode < elem_nodes.size(); inode++) { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *coords = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node); - - for (int d=0; d Rup - const double & ratio = *( stk_classic::mesh::field_data( *m_elem_ratio_field , element) ); - - if (ratio > m_Rup) - mark |= DO_REFINE; - - return mark; - } - } -} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestLocalRefiner.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestLocalRefiner.cpp deleted file mode 100644 index d029576e2985..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestLocalRefiner.cpp +++ /dev/null @@ -1,2008 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - - -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { - namespace adapt { - namespace unit_tests { - - static int print_infoLevel = 0; - static std::string post_fix[4] = {"np0", "np1", "np2", "np3"}; - - /// configuration: you can choose where to put the generated Exodus files (see variables input_files_loc, output_files_loc) - /// The following defines where to put the input and output files created by this set of functions - -#if 1 - const std::string input_files_loc="./input_files_"; - const std::string output_files_loc="./output_files_"; -#else - const std::string input_files_loc="./input_files/"; - const std::string output_files_loc="./output_files/"; -#endif - -#define EXTRA_PRINT 0 - - /// This function either writes the given mesh to a file in Exodus format (option 0) - /// or, under option 1, checks if the file already exists, and if so, treats that - /// file as the "gold" copy and does a regression difference check. - - static void save_or_diff(PerceptMesh& eMesh, std::string filename, int option = 0) - { - return UnitTestSupport::save_or_diff(eMesh, filename, option); - } - - static double tet_volume(SingleTetFixture::Point *node_coord_data, SingleTetFixture::TetIds& tetra_node_ids, unsigned node_id_offset=0) - { - double mat[3][3]; - for (int inode=0; inode < 3; inode++) - { - for (int ipt=0; ipt < 3; ipt++) - { - mat[inode][ipt] = node_coord_data[tetra_node_ids[inode+1]-node_id_offset][ipt] - node_coord_data[tetra_node_ids[0]-node_id_offset][ipt]; - } - } - double vol = (mat[0][0]*(mat[1][1]*mat[2][2]-mat[1][2]*mat[2][1]) - -mat[0][1]*(mat[1][0]*mat[2][2] - mat[1][2]*mat[2][0]) - +mat[0][2]*(mat[1][0]*mat[2][1] - mat[1][1]*mat[2][0]) - ) / 6.0; - return vol; - } - - static double totalVolume(PerceptMesh& eMesh) - { - double totVol=0.0; - - SingleTetFixture::Point node_coord_data[4] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; - static SingleTetFixture::TetIds tetra_node_ids[] = { {0, 1, 2, 3} }; - - const vector & buckets = eMesh.get_bulk_data()->buckets( eMesh.element_rank() ); - - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *fdata = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node); - node_coord_data[inode][0] = fdata[0]; - node_coord_data[inode][1] = fdata[1]; - node_coord_data[inode][2] = fdata[2]; - } - double vol = tet_volume(node_coord_data, tetra_node_ids[0]); - if (vol < 0) - { - std::cout << "ERROR neg vol = " << vol << std::endl; - } - totVol += vol; - } - } - return totVol; - } - - - static void fixture_setup_NxNxN_box_hex_and_tet_mesh() - { - EXCEPTWATCH; - static int entered=0; - if (!entered) - entered = 1; - else - return; - - MPI_Barrier( MPI_COMM_WORLD ); - - int N=4; - - // start_demo_uniformRefiner_hex8_build - { - percept::PerceptMesh eMesh(3u); - - //unsigned p_size = eMesh.get_parallel_size(); - - // generate a N x N x N mesh - std::string gmesh_spec = - toString(N)+"x"+ - toString(N)+"x"+ - toString(N)+ - std::string("|bbox:0,0,0,")+ - toString(N)+","+ - toString(N)+","+ - toString(N); - - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - eMesh.commit(); - - eMesh.save_as(input_files_loc+"hex_fixture_NxNxN.e"); - - // end_demo - } - - // start_demo_uniformRefiner_hex8_build_1 - { - percept::PerceptMesh eMesh(3u); - - //unsigned p_size = eMesh.get_parallel_size(); - eMesh.open(input_files_loc+"hex_fixture_NxNxN.e"); - - Hex8_Tet4_24 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"tet_fixture_NxNxN.e"); - - - if (0) - { - PerceptMesh em1; - em1.open_read_only(input_files_loc+"tet_fixture_NxNxN_tmp.e"); - em1.save_as(input_files_loc+"tet_fixture_NxNxN.e"); - em1.print_info("srk tmp tet_fixture_NxNxN.e after reopen", 2); - } - // end_demo - } - } - - - //============================================================================= - //============================================================================= - //============================================================================= - /// check triangulate_tet - - STKUNIT_UNIT_TEST(unit_localRefiner, triangulate_tet) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - { - // create the mesh - - stk_classic::percept::SingleTetFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh eMesh(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - eMesh.save_as(input_files_loc+"local_tet_0.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - unsigned edge_mark_bitcode = 4u; - TestLocalRefinerTet_N_2_1 breaker(eMesh, break_tet, 0, edge_mark_bitcode); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_1_bitcode_4.e"); - } - - { - { - - // create the mesh - unsigned npts=4; - unsigned ntets=1; - static SingleTetFixture::Point node_coord_data[ ] = { - { 10 , 2 , 0 } , { 11 , 2 , 0 } , { 10 , 3 , 0 } , { 10 , 2 , 1 } }; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static SingleTetFixture::TetIds tetra_node_ids[] = { - { 1, 2, 3, 4} }; - - stk_classic::percept::SingleTetFixture mesh(pm, false, npts, node_coord_data, ntets, tetra_node_ids); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - mesh.m_metaData.commit(); - mesh.populate(); - - std::cout << "here" << std::endl; - bool isCommitted = true; - percept::PerceptMesh eMesh(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - eMesh.save_as(input_files_loc+"local_tet_41.e"); - } - - { - for (unsigned edge_mark_bitcode = 12u; edge_mark_bitcode <= 14u; edge_mark_bitcode++) - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_41.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - double totalVol0 = totalVolume(eMesh); - std::cout << "tmp edge_mark_bitcode= " << edge_mark_bitcode << " totalVol0 = " << totalVol0 << std::endl; - - TestLocalRefinerTet_N_2_1 breaker(eMesh, break_tet, 0, edge_mark_bitcode); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - double totalVol1 = totalVolume(eMesh); - std::cout << "tmp edge_mark_bitcode= " << edge_mark_bitcode << " totalVol1 = " << totalVol1 << std::endl; - - eMesh.save_as(output_files_loc+"local_tet_N_2_1_bitcode_"+toString((int)edge_mark_bitcode)+".e" ); - } - } - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_1 breaker(eMesh, break_tet, 0); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_1_1.e"); - } - - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_1.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 2); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_2.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 3); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_3.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 4); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_4.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 5); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_5.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_0.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 6); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2_6.e"); - } - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - /// check triangulate_tet - two tets sharing a face - - STKUNIT_UNIT_TEST(unit_localRefiner, triangulate_tet_2) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - { - - // create the mesh - unsigned npts=5; - unsigned ntets=2; - static SingleTetFixture::Point node_coord_data[ ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 1 }, {1, 1, 1} }; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static SingleTetFixture::TetIds tetra_node_ids[] = { - { 1, 2, 3, 4}, {2, 3, 4, 5} }; - - stk_classic::percept::SingleTetFixture mesh(pm, false, npts, node_coord_data, ntets, tetra_node_ids); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - mesh.m_metaData.commit(); - mesh.populate(); - - std::cout << "here" << std::endl; - bool isCommitted = true; - percept::PerceptMesh eMesh(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - eMesh.save_as(input_files_loc+"local_tet_2.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_2.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_2 breaker(eMesh, break_tet, 0, 1); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"local_tet_N_2tet_1.e"); - } - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - - /// check triangulate_tet - two tets sharing a face, random coords - - // Pathscale is the only platform that doesn't pass this test -#ifndef __PATHSCALE__ - STKUNIT_UNIT_TEST(unit_localRefiner, triangulate_tet_2_rand) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - srandom(1234); - int ncases = 100; - int icase = 0; - for (int jcase = 0; jcase < ncases; jcase++) - { - - // create the mesh - unsigned npts=5; - unsigned ntets=2; - SingleTetFixture::Point node_coord_data[] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 1 }, {1, 1, 1} }; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static SingleTetFixture::TetIds tetra_node_ids[] = { - { 1, 2, 3, 4}, {2, 3, 4, 5} }; - - for (unsigned ipts = 0; ipts < npts; ipts++) - { - for (int ii=0; ii < 3; ii++) node_coord_data[ipts][ii] = ((double)random())/((double)RAND_MAX); - } - - double vol0 = tet_volume(node_coord_data, tetra_node_ids[0], 1); - double vol1 = tet_volume(node_coord_data, tetra_node_ids[1], 1); - std::cout << "tmp vol0 = " << vol0 << " vol1 = " << vol1 << std::endl; - if (vol0 < 0.0 || vol1 < 0.0) - continue; - - { - stk_classic::percept::SingleTetFixture mesh(pm, false, npts, node_coord_data, ntets, tetra_node_ids); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - mesh.m_metaData.commit(); - mesh.populate(); - - - - bool isCommitted = true; - percept::PerceptMesh eMesh(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - - eMesh.save_as(input_files_loc+"local_tet_2_rand.e."+toString(icase)); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_2_rand.e."+toString(icase)); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - double totalVol0 = totalVolume(eMesh); - std::cout << "tmp totalVol0 = " << totalVol0 << std::endl; - - int edge_mark_bitcode = 0; - edge_mark_bitcode = (int)(63.*((double)random())/((double)RAND_MAX)); - std::cout << "tmp edge_mark_bitcode= " << edge_mark_bitcode << std::endl; - if (edge_mark_bitcode <= 0) edge_mark_bitcode = 1; - if (edge_mark_bitcode >= 63) edge_mark_bitcode = 63; - - TestLocalRefinerTet_N_3_1 breaker(eMesh, break_tet, 0, edge_mark_bitcode); - // we do this (for now) since old elements that aren't refined are being removed (FIXME in Refiner.cpp) - breaker.setRemoveOldElements(false); - breaker.doBreak(); - breaker.deleteParentElements(); - - double totalVol1 = totalVolume(eMesh); - std::cout << "tmp edge_mark_bitcode= " << edge_mark_bitcode << " totalVol1 = " << totalVol1 << std::endl; - - if (std::abs(totalVol0 - totalVol1) > 1.e-6) - { - eMesh.save_as( output_files_loc+"local_tet_2_rand_error."+toString(icase)+".e" ); - throw std::runtime_error("triangulate_tet_2_rand:: error, volumes don't match"); - } - save_or_diff(eMesh, output_files_loc+"local_tet_2_rand.e."+toString(icase) ); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_2_rand.e."+toString(icase)); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - //eMesh.print_info("srk tmp SingleTetFixture 2a", 2); - - int edge_mark_bitcode = 0; - edge_mark_bitcode = (int)(63.*((double)random())/((double)RAND_MAX)); - if (edge_mark_bitcode <= 0) edge_mark_bitcode = 1; - if (edge_mark_bitcode >= 63) edge_mark_bitcode = 63; - - TestLocalRefinerTet_N_3_1 breaker(eMesh, break_tet, 0, edge_mark_bitcode); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - - //eMesh.print_info("srk tmp SingleTetFixture 3", 2); - -#if 1 - MeshUtil::m_debug = true; - bool isConsistent = percept::MeshUtil::facesConsistent(eMesh); - MeshUtil::m_debug = false; - if (!isConsistent) - { - std::cout << "tmp error isConsistent= " << isConsistent << std::endl; - eMesh.save_as( output_files_loc+"local_tet_2_rand_error.e."+toString(icase) ); - } - STKUNIT_EXPECT_TRUE(isConsistent); -#endif - } - - ++icase; - } - } - } -#endif - - //============================================================================= - //============================================================================= - //============================================================================= - /// check triangulate_tet - all 64 cases for a single tet - - STKUNIT_UNIT_TEST(unit_localRefiner, triangulate_tet_64) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - { - - // create the mesh - static SingleTetFixture::Point node_coord_data[ ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 1 } }; - - SingleTetFixture::Point pts[64*4]; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static SingleTetFixture::TetIds tets[64]; - - unsigned ntets = 0; - unsigned npts = 0; - unsigned edge_mark_bitcode = 0u; - unsigned ipts = 0; - int is = 0; - int ie = 7; - int js = 0; - int je = 7; -#if 0 - is = 0; - ie = 2; - js = 2; - je = 6; -#endif - for (int j = js; j <= je; j++) - { - for (int i = is; i <= ie; i++) - { - //std::cout << "\ntmp i = " << i << " j= " << j << "\n--------------------------------\n" << std::endl; - - for (int k = 0; k < 4; k++) - { - //pts[ipts][0] = node_coord_data[k][0] + i * 2; - //pts[ipts][1] = node_coord_data[k][1] + j * 2; - pts[ipts][0] = node_coord_data[k][0] + i * 1.25; - pts[ipts][1] = node_coord_data[k][1] + j * 1.25; - pts[ipts][2] = node_coord_data[k][2]; - ++npts; - ++ipts; - } - - tets[edge_mark_bitcode][0] = edge_mark_bitcode*4 + 1; - tets[edge_mark_bitcode][1] = edge_mark_bitcode*4 + 2; - tets[edge_mark_bitcode][2] = edge_mark_bitcode*4 + 3; - tets[edge_mark_bitcode][3] = edge_mark_bitcode*4 + 4; - - ++edge_mark_bitcode; - ++ntets; - } - } - - stk_classic::percept::SingleTetFixture mesh(pm, false, npts, pts, ntets, tets); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh eMesh(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - if (0) - { - percept::GeometryVerifier gv(true); - std::cout << "tmp GeometryVerifier= " << eMesh.get_bulk_data() << std::endl; - bool igb = gv.isGeometryBad(*eMesh.get_bulk_data(), true); - std::cout << "tmp isGeometryBad= " << igb << std::endl; - } - - double totalVol0 = totalVolume(eMesh); - std::cout << "tmp 64 totalVol0 = " << totalVol0 << std::endl; - - eMesh.save_as(input_files_loc+"local_tet_64.e"); - } - - { - PerceptMesh eMesh; - eMesh.open(input_files_loc+"local_tet_64.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - eMesh.commit(); - - TestLocalRefinerTet_N_3 breaker(eMesh, break_tet, 0); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - //breaker.deleteParentElements(); - - if (0) - { - percept::GeometryVerifier gv(true); - std::cout << "tmp GeometryVerifier= " << eMesh.get_bulk_data() << std::endl; - bool igb = gv.isGeometryBad(*eMesh.get_bulk_data(), true); - std::cout << "tmp isGeometryBad= " << igb << std::endl; - } - - double totalVol1 = totalVolume(eMesh); - std::cout << "tmp 64 totalVol1 = " << totalVol1 << std::endl; - - save_or_diff(eMesh, output_files_loc+"local_tet_N_3_64tet_1.e"); - } - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - /// check triangulate_tet - - STKUNIT_UNIT_TEST(unit_localRefiner, triangulate_tet_planes) - { - EXCEPTWATCH; - fixture_setup_NxNxN_box_hex_and_tet_mesh(); - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 3) - { - - { - PerceptMesh eMesh; - - eMesh.open(input_files_loc+"tet_fixture_NxNxN.e"); - Local_Tet4_Tet4_N break_tet(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - TestLocalRefinerTet_N_4 breaker(eMesh, break_tet, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - int nref = 3; - int nunref = 5; - for (int ipass = 0; ipass < nref; ipass++) - { - breaker.doBreak(); - eMesh.save_as( output_files_loc+"local_tet_N_4_planes_iref_"+toString(ipass)+".e"); - } - - //save_or_diff(eMesh, output_files_loc+"local_tet_N_4_planes.e"); - eMesh.save_as( output_files_loc+"local_tet_N_4_planes.e"); - - for (int iunref_pass=0; iunref_pass < nunref; ++iunref_pass) - { - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - } - - //save_or_diff(eMesh, output_files_loc+"local_tet_N_4_planes_unref.e"); - eMesh.save_as( output_files_loc+"local_tet_N_4_planes_unref.e"); - - breaker.deleteParentElements(); - eMesh.save_as( output_files_loc+"local_tet_N_4_planes_unref_noParentElements.e"); - - } - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Create a triangle mesh using the QuadFixture with the option of breaking the quads into triangles - /// Refine the triangle mesh, write the results. - - /// Refine a triangle mesh - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri) - { - //fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_local_refiner_break_tri_to_tri - - const unsigned n = 1; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_2 break_tri_to_tri_2(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("local tri mesh", print_infoLevel); - //save_or_diff(eMesh, output_files_loc+"local_tri_0.e"); - - TestLocalRefinerTri breaker(eMesh, break_tri_to_tri_2, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.print_info("local tri mesh refined", print_infoLevel); - //save_or_diff(eMesh, output_files_loc+"local_tri_1.e"); - - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Refine a triangle mesh by trying to mark only one edge per triangle, in a random-ish way - - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_1) - { - //fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_local_refiner_break_tri_to_tri_1 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_2 break_tri_to_tri_2(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("local tri mesh", print_infoLevel); - save_or_diff(eMesh, output_files_loc+"local_tri_1_0.e"); - - bool diagonals=true; - TestLocalRefinerTri2 breaker(eMesh, break_tri_to_tri_2, proc_rank_field, diagonals); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.print_info("local tri mesh refined", print_infoLevel); - save_or_diff(eMesh, output_files_loc+"local_tri_1_1.e"); - - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Refine a triangle mesh by trying to mark only one edge per triangle, in a random-ish way - - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_2) - { - //fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_2 break_tri_to_tri_2(eMesh); - //Local_Tri3_Tri3_N break_tri_to_tri_2(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("local tri mesh", print_infoLevel); - save_or_diff(eMesh, output_files_loc+"local_tri_2_0.e"); - - bool diagonals=false; - TestLocalRefinerTri2 breaker(eMesh, break_tri_to_tri_2, proc_rank_field, diagonals); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.print_info("local tri mesh refined", print_infoLevel); - save_or_diff(eMesh, output_files_loc+"local_tri_2_1.e"); - - // end_demo - } - - } - - - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_1 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_1_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_1 breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - breaker.doBreak(); - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_1_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); - - //breaker.unrefineAll(); - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_1_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_1_1_unref_"+post_fix[p_size]+".e"); - - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_2) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_2_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_2 breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_2_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_2_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - //breaker.unrefineAll(); - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_2_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_2_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_3 breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_1_unref_ipass"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - //breaker.unrefineAll(); - } - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_3_1_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_2) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_3 breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 8; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - for (int iunref_pass=0; iunref_pass < 7; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_1_unref_ipass"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - //breaker.unrefineAll(); - } - - - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_3_2_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_1_unref_"+post_fix[p_size]+".e"); - - if (1) - { - for (int ipass=8; ipass < 16; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //eMesh.dump_elements_compact(); - - // FIXME FIXME FIXME - breaker.deleteParentElements(); - - //eMesh.print_info("local tri mesh refined", 2); - - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_16_"+post_fix[p_size]+".e"); - } - - -#endif - // end_demo - } - - } - - -#if 0 - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_3_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_3 breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_2_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - for (int iunref_pass=0; iunref_pass < 2; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - //breaker.unrefineAll(); - } - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_3_2_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_2_unref_"+post_fix[p_size]+".e"); - exit(123); -#endif - // end_demo - } - - } -#endif - -#if 0 - //============================================================================= - //============================================================================= - //============================================================================= - - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_local_refiner_break_tri_to_tri_1 - - const unsigned n = 4; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("local tri mesh", print_infoLevel); - save_or_diff(eMesh, output_files_loc+"local_tri_N_0.e"); - - TestLocalRefinerTri_N breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - breaker.doBreak(); - - eMesh.print_info("local tri mesh refined", print_infoLevel); - //eMesh.dump_elements(); - save_or_diff(eMesh, output_files_loc+"local_tri_N_1.e"); - - //breaker.unrefineAll(); - ElementUnrefineCollection elements_to_unref = breaker.buildTestUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_1_unref.e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_1_unref.e"); - - // end_demo - } - - } -#endif - - - - //============================================================================= - //============================================================================= - //============================================================================= - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_1_IEdgeAdapter) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IEdgeAdapter_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_3_IEdgeAdapter breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_unref_ipass"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - //breaker.unrefineAll(); - } - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IEdgeAdapter_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - -#if 1 - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_3_1_IElementAdapter) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IElementAdapter_0_"+post_fix[p_size]+".e"); - - TestLocalRefinerTri_N_3_IElementAdapter breaker(eMesh, break_tri_to_tri_N, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IElementAdapter_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - //eMesh.dump_elements_compact(); - - //eMesh.print_info("local tri mesh refined", 2); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IElementAdapter_1_"+post_fix[p_size]+".e"); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IElementAdapter_1_"+post_fix[p_size]+".e"); - - //MPI_Barrier( MPI_COMM_WORLD ); -#if 1 - - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tri_N_3_1_IElementAdapter_1_unref_ipass"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - //breaker.unrefineAll(); - } - - // FIXME - eMesh.save_as( output_files_loc+"local_tri_N_3_1_IElementAdapter_1_unref_"+post_fix[p_size]+".e"); - //save_or_diff(eMesh, output_files_loc+"local_tri_N_3_1_IElementAdapter_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } -#endif - - //============================================================================= - //============================================================================= - //============================================================================= - -#if 1 - class SetRefineField : public percept::ElementOp - { - percept::PerceptMesh& m_eMesh; - public: - SetRefineField(percept::PerceptMesh& eMesh) : m_eMesh(eMesh) {} - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - double *f_data = PerceptMesh::field_data_entity(field, element); - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - bool found = true; - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - double *coord_data = PerceptMesh::field_data(coordField, node); - - //std::cout << "tmp coord_data= " << coord_data[0] << std::endl; - - if (coord_data[0] > 1.1) - { - found=false; - break; - } - } - if (found) - f_data[0] = 1.0; - else - f_data[0] = 0.0; - - return false; // don't terminate the loop - } - virtual void init_elementOp() {} - virtual void fini_elementOp() {} - }; - - class SetUnrefineField : public percept::ElementOp - { - percept::PerceptMesh& m_eMesh; - public: - SetUnrefineField(percept::PerceptMesh& eMesh) : m_eMesh(eMesh) {} - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - double *f_data = PerceptMesh::field_data_entity(field, element); - VectorFieldType* coordField = m_eMesh.get_coordinates_field(); - - bool found = true; - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - double *coord_data = PerceptMesh::field_data(coordField, node); - - //std::cout << "tmp coord_data= " << coord_data[0] << std::endl; - - if (coord_data[0] > 1.1 || coord_data[1] > 1.1) - { - found=false; - break; - } - } - if (found) - f_data[0] = -1.0; - else - f_data[0] = 0.0; - - return false; // don't terminate the loop - } - virtual void init_elementOp() {} - virtual void fini_elementOp() {} - }; - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_5_ElementBased) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_local_refiner_break_tri_to_tri_2 - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - stk_classic::mesh::FieldBase* refine_field = eMesh.add_field("refine_field", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - fixture.generate_mesh(); - - SetRefineField set_ref_field(eMesh); - eMesh.elementOpLoop(set_ref_field, refine_field); - - save_or_diff(eMesh, output_files_loc+"local_tri_N_5_ElementBased_0_"+post_fix[p_size]+".e"); - - stk_classic::mesh::Selector univ_selector(eMesh.get_fem_meta_data()->universal_part()); - - ElementRefinePredicate erp(&univ_selector, refine_field, 0.0); - PredicateBasedElementAdapter - breaker(erp, - eMesh, break_tri_to_tri_N, proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - for (int ipass=0; ipass < 4; ipass++) - { - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tri_N_5_ElementBased_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as(output_files_loc+"local_tri_N_5_ElementBased_1_"+post_fix[p_size]+".e"); - //breaker.deleteParentElements(); - //eMesh.save_as(output_files_loc+"local_tri_N_5_ElementBased_1_"+post_fix[p_size]+"_no_parent_elems.e"); - -#if 1 - for (int iunref_pass=0; iunref_pass < 4; iunref_pass++) - { - std::cout << "P[" << eMesh.get_rank() << "] iunref_pass= " << iunref_pass << std::endl; - ElementUnrefineCollection elements_to_unref = breaker.buildUnrefineList(); - breaker.unrefineTheseElements(elements_to_unref); - eMesh.save_as(output_files_loc+"local_tri_N_5_ElementBased_1_unref_ipass"+toString(iunref_pass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as( output_files_loc+"local_tri_N_5_ElementBased_1_unref_"+post_fix[p_size]+".e"); -#endif - // end_demo - } - - } -#endif - - //============================================================================= - //============================================================================= - //============================================================================= - - - - static void set_node_coords(percept::PerceptMesh& eMesh, mesh::PairIterRelation& elem_nodes, double tri_coords[3][3]) - { - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - double *fdata = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node ); - for (int dim=0; dim < eMesh.get_spatial_dim(); dim++) - { - fdata[dim] = tri_coords[inode][dim]; - } - } - } - - std::vector convert_tuple(tri_tuple_type_local& tuple) - { - std::vector cv(3); - cv[0] = tuple.get<0>(); - cv[1] = tuple.get<1>(); - cv[2] = tuple.get<2>(); - return cv; - } - - static bool in_set(tri_tuple_type_local& expected, vector& base, bool reverse=false) - { - std::vector cv_expected = convert_tuple(expected); - - for (unsigned ie = 0; ie < base.size(); ie++) - { - std::vector cv_base = convert_tuple(base[ie]); - for (int i = 0; i < 3; i++) - { - bool found = true; - if (reverse) - { - int k=0; - for (int j = 2; j >= 0; --j) - { - if (cv_expected[k++] != cv_base[(i+j)%3]) - { - found = false; - break; - } - } - } - else - { - for (int j = 0; j < 3; j++) - { - if (cv_expected[j] != cv_base[(i+j)%3]) - { - found = false; - break; - } - } - } - - if (found) - { - return true; - } - } - } - return false; - } - - // bcarnes: unit test for initial adaptive refinement - element based - // use ratio of current to optimal mesh ratio to guide refinement - // no coarsening - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_MeshSizeRatio) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 1) { - - const double global_error_tol = 0.001; - - const unsigned n = 2; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - int scalarDimension = 0; - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // field for elem mesh size ratio (non-dimensional) - ScalarFieldType * elem_ratio_field = - (ScalarFieldType *) eMesh.add_field("elem_ratio", eMesh.element_rank(), scalarDimension); - assert(elem_ratio_field); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("local tri mesh",2); - save_or_diff(eMesh, output_files_loc+"local_tri_N_MeshSizeRatio_0_"+post_fix[p_size]+".e"); - - // main class used to drive the test - TestLocalRefinerTri_N_3_MeshSizeRatio breaker ( - eMesh, - break_tri_to_tri_N, - elem_ratio_field, - proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - const int max_iter = 5; - for (int ipass=0; ipass < max_iter; ipass++) { - - // compute exact elem interp error and then elem mesh size ratio (elem loop) - compute_elem_mesh_size_ratio(eMesh, elem_ratio_field, global_error_tol); - - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tri_N_MeshSizeRatio_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as(output_files_loc+"local_tri_N_MeshSizeRatio_1_"+post_fix[p_size]+".e"); - } - } - - // bcarnes: unit test for initial adaptive refinement - edge based - // use ratio of current to optimal mesh ratio to guide refinement - // no coarsening - - STKUNIT_UNIT_TEST(unit_localRefiner, break_tri_to_tri_N_EdgeBasedAnisotropic) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 1) { - - const unsigned n = 1; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Local_Tri3_Tri3_N break_tri_to_tri_N(eMesh); - const int scalarDimension = 0; - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // field for nodal Hessian field - const int spatial_dim = eMesh.get_spatial_dim(); - const int tensorDimension = spatial_dim*spatial_dim; //(spatial_dim==2) ? 3 : 6; - VectorFieldType * nodal_hessian_field = - (VectorFieldType *) eMesh.add_field("nodal_hessian", eMesh.node_rank(), tensorDimension); - assert(nodal_hessian_field); - - eMesh.commit(); - - fixture.generate_mesh(); - - //save_or_diff(eMesh, output_files_loc+"local_tri_N_EdgeBasedAnisotropic_0_"+post_fix[p_size]+".e"); - - // main class used to drive the test - TestLocalRefinerTri_N_3_EdgeBasedAnisotropic breaker ( - eMesh, - break_tri_to_tri_N, - nodal_hessian_field, - proc_rank_field); - - breaker.setRemoveOldElements(false); - breaker.setAlwaysInitializeNodeRegistry(false); - - const int max_iter = 4; - for (int ipass=0; ipass < max_iter; ipass++) { - - // compute nodal Hessian from analytic function for testing - const int hess_id = 3; - interp_nodal_hessian(hess_id, eMesh, nodal_hessian_field); - - std::cout << "P[" << eMesh.get_rank() << "] ipass= " << ipass << std::endl; - breaker.doBreak(); - std::cout << "P[" << eMesh.get_rank() << "] done... ipass= " << ipass << std::endl; - eMesh.save_as(output_files_loc+"local_tri_N_EdgeBasedAnisotropic_1_ipass"+toString(ipass)+"_"+post_fix[p_size]+".e"); - } - - eMesh.save_as(output_files_loc+"local_tri_N_EdgeBasedAnisotropic_1_"+post_fix[p_size]+".e"); - } - } - - /// Create a single triangle mesh and mark the edges, call RefinerPattern_Tri3_Tri3_N::triangulate_face - /// and check properties of the result - reverse the triangle polarity and check for consistency - - STKUNIT_UNIT_TEST(unit_localRefiner, check_triangulate_face) - { - //fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 1) - { - - const unsigned n = 1; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture ( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - eMesh.commit(); - - fixture.generate_mesh(); - - // delete the first element - eMesh.get_bulk_data()->modification_begin(); - stk_classic::mesh::Entity* element_0 = &( (**(eMesh.get_bulk_data()->buckets(eMesh.element_rank()).begin()))[0]); - if ( ! eMesh.get_bulk_data()->destroy_entity( element_0 ) ) - { - throw std::logic_error("failed in deleting element"); - } - eMesh.get_bulk_data()->modification_end(); - - // single element left - //stk_classic::mesh::Entity& element = (**(eMesh.get_bulk_data()->buckets(eMesh.element_rank()).begin()))[0]; - - eMesh.save_as(output_files_loc+"tri_face_0.e"); - - // single element left - stk_classic::mesh::Entity& element = (**(eMesh.get_bulk_data()->buckets(eMesh.element_rank()).begin()))[0]; - std::cout << "element = " << element << std::endl; - - mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - - stk_classic::mesh::Entity *elem_nodes_vector[3]; - for (unsigned inode=0; inode < elem_nodes.size(); inode++) - { - stk_classic::mesh::Entity *node = elem_nodes[inode].entity(); - elem_nodes_vector[inode] = node; - } - vector elems_local; - - // test 1 - { - unsigned edge_marks[3] = {1,1,0}; - double tri_coords[3][3] = {{0,0,0}, {1,0,0}, {0,1,0}}; - set_node_coords(eMesh, elem_nodes, tri_coords); - Local_Tri3_Tri3_N::triangulate_face(eMesh, elem_nodes_vector, edge_marks, elems_local); - - // expected: - vector elems_local_expected(3); - elems_local_expected[0] = tri_tuple_type_local(0,3,4); - elems_local_expected[1] = tri_tuple_type_local(3,1,4); - elems_local_expected[2] = tri_tuple_type_local(0,4,2); - - std::cout << "test1: elems_local_expected= " << elems_local_expected << std::endl; - std::cout << "test1: elems_local= " << elems_local << std::endl; - - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[0], elems_local)); - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[1], elems_local)); - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[2], elems_local)); - - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[0], elems_local, true)); - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[1], elems_local, true)); - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[2], elems_local, true)); - } - - // test2: same as test 1 but mirror image (emulating a face shared between two tets) - { - stk_classic::mesh::Entity* node1 = elem_nodes_vector[1]; - elem_nodes_vector[1] = elem_nodes_vector[2]; - elem_nodes_vector[2] = node1; - - unsigned edge_marks[3] = {0,1,1}; - Local_Tri3_Tri3_N::triangulate_face(eMesh, elem_nodes_vector, edge_marks, elems_local); - - // expected: - vector elems_local_expected(3); - elems_local_expected[0] = tri_tuple_type_local(0,1,4); - elems_local_expected[1] = tri_tuple_type_local(0,4,5); - elems_local_expected[2] = tri_tuple_type_local(2,5,4); - - std::cout << "test2: elems_local_expected= " << elems_local_expected << std::endl; - std::cout << "test2: elems_local= " << elems_local << std::endl; - - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[0], elems_local)); - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[1], elems_local)); - STKUNIT_EXPECT_TRUE(in_set(elems_local_expected[2], elems_local)); - - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[0], elems_local, true)); - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[1], elems_local, true)); - STKUNIT_EXPECT_TRUE(!in_set(elems_local_expected[2], elems_local, true)); - } - - - - // end_demo - } - - } - - - - } // namespace unit_tests - } // namespace adapt -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 53a5447cf12d..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include - -#if !PY_PERCEPT -STKUNIT_MAIN(argc, argv) -#else - int main() {return 0;} -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMeshColorer.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMeshColorer.cpp deleted file mode 100644 index 8ba7424ae8a6..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestMeshColorer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace adapt { -namespace unit_tests { - -static int dw_enabled = 1; -static stk_classic::diag::Writer s_diagWriter(std::cout.rdbuf(), dw_enabled); - -static stk_classic::diag::Writer & -dw() -{ - //static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - - s_diagWriter.setPrintMask(percept::LOG_NORM+percept::LOG_ALWAYS); - - return s_diagWriter; -} -//static stk_classic::diag::Writer &s_dw_tmp = dw(); - -#define EXTRA_PRINT 0 - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(mesh_colorer, test1) -{ - dw().m(percept::LOG_MESH_COLORER) << "TEST::mesh_colorer::test1 " << stk_classic::diag::dendl; - - const size_t numxyz=3; - const size_t num_x = numxyz; - const size_t num_y = numxyz; - const size_t num_z = numxyz; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - percept::PerceptMesh eMesh(3u); - eMesh.new_mesh(percept::GMeshSpec(config_mesh)); - int vectorDimension = 0; - mesh::FieldBase *element_color_field = eMesh.add_field("element_colors", eMesh.element_rank(), vectorDimension); - eMesh.commit(); - - std::vector mer; mer.push_back(eMesh.element_rank()); - Colorer meshColorer(mer); - unsigned elementType = 0u; - meshColorer.color(eMesh, &elementType, 0, element_color_field); - //eMesh.save_as("./cube_colored.e"); - - //std::cout << "Mesh coloring info: " << meshColorer.getElementColors() << std::endl; - -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestNodeRegistry.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestNodeRegistry.cpp deleted file mode 100644 index 57c1afe4a68c..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestNodeRegistry.cpp +++ /dev/null @@ -1,730 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace adapt { -namespace unit_tests { - -#define EXTRA_PRINT 0 - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(nodeRegistry, createAddNodes_serial_and_1st_parallel) -{ - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - percept::PerceptMesh eMesh(3u); - eMesh.new_mesh(percept::GMeshSpec("3x3x12|bbox:0,0,0,1,1,1")); // create a 3x3x12 hex mesh in the unit cube - //int scalarDimension = 0; // a scalar - //int vectorDimension = 3; - eMesh.commit(); - eMesh.print_info(); - - unsigned p_size = eMesh.get_bulk_data()->parallel_size(); - unsigned p_rank = eMesh.get_bulk_data()->parallel_rank(); - - std::cout << "TEST::nodeRegistry::createAddNodes_serial: p_size = "<< p_size << " rank= " << p_rank << std::endl; - if (p_size >= 1) // FIXME - return; - - if (p_size >= 3) - return; - - //stk_classic::CommAll comm_all(eMesh.get_bulk_data()->parallel()); - NodeRegistry nodeRegistry(eMesh); - nodeRegistry.initialize(); - - if (p_size == 2) return; // FIXME - if (p_size == 2) - { - unsigned elem_num=(12/p_size)*3*3; - - const stk_classic::mesh::Entity* element_1_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num); - dw() << "P["<get_entity(eMesh.element_rank(), elem_num); - std::cout << "P["<get_entity(eMesh.element_rank(), elem_num_local); - const stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - - if (p_rank == 1) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - } - - dw() << "P["<get_entity(eMesh.element_rank(), elem_num_local); - stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - if (p_rank == 1) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - } - - dw() << "P["<declare_part("block_hex_20", eMesh.element_rank()); - /// set cell topology for the part block_hex_20 - mesh::fem::set_cell_topology< shards::Hexahedron<20> >( block_hex_20 ); - stk_classic::io::put_io_part_attribute(block_hex_20); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as("./cube1x1x2_hex-20-orig.e"); - - mesh::Part* block_hex_8 = const_cast(eMesh.getPart("block_1")); - - NodeRegistry nodeRegistry(eMesh); - nodeRegistry.initialize(); - - if (p_size <= 2) - { - // pick an element on the processor boundary - unsigned elem_num_local = 1; - unsigned elem_num_ghost = 2; - if (p_size == 1) - elem_num_ghost = 1; - - stk_classic::mesh::Entity* element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - if (p_rank == 1) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - } - - dw() << "P["<modification_begin(); - - //getCellTopologyData< shards::Node >() - const CellTopologyData *const cell_topo_data =stk_classic::percept::PerceptMesh::get_cell_topology(block_hex_20); - CellTopology cell_topo(cell_topo_data); - - for (unsigned isd = 0; isd < 12; isd++) - { - nodeRegistry.makeCentroidCoords(element_local, needed_entity_rank.first, isd); - NodeIdsOnSubDimEntityType& nodeIds_onSE_0_loc = *( nodeRegistry.getNewNodesOnSubDimEntity(element_local, needed_entity_rank.first, isd)); - - stk_classic::mesh::Entity* node = eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE_0_loc[0]->identifier()); - - unsigned edge_ord = 8u + isd; - //unsigned n_edge_ord = cell_topo_data->edge[isd].topology->node_count; - //std::cout << "n_edge_ord = " << n_edge_ord << std::endl; - edge_ord = cell_topo_data->edge[isd].node[2]; - eMesh.get_bulk_data()->declare_relation(element_local, *node, edge_ord); - } - - std::vector add_parts(1, &block_hex_20); - std::vector remove_parts(1, block_hex_8); - eMesh.get_bulk_data()->change_entity_parts( element_local, add_parts, remove_parts ); - - eMesh.get_bulk_data()->modification_end(); - eMesh.print_info("After quadratic"); - - eMesh.save_as("./cube1x1x2_hex-20.e"); - //exit(1); - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -#ifdef STK_BUILT_IN_SIERRA - -STKUNIT_UNIT_TEST(nodeRegistry, test_serial_hex8_tet4_24_1) -{ - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_nodeRegistry_test_serial_hex8_tet4_24_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - unsigned p_rank = eMesh.get_rank(); - Util::setRank(eMesh.get_rank()); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,1"); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - // prepare for breaking into tet elements - mesh::Part& block_tet_4 = eMesh.get_fem_meta_data()->declare_part("block_tet_4", eMesh.element_rank()); - /// set cell topology for the part block_tet_4 - mesh::fem::set_cell_topology< shards::Tetrahedron<4> >( block_tet_4 ); - stk_classic::io::put_io_part_attribute(block_tet_4); - - eMesh.commit(); - eMesh.print_info(); - eMesh.save_as(std::string("./")+std::string("cube1x1x")+toString(p_size)+std::string("-orig.e")); - - //mesh::Part* block_hex_8 = const_cast(eMesh.getPart("block_1")); - - NodeRegistry nodeRegistry(eMesh); - nodeRegistry.initialize(); - - if (p_size <= 2) - { - // pick an element on the processor boundary - unsigned elem_num_local = 1; - unsigned elem_num_ghost = 2; - if (p_size == 1) - elem_num_ghost = 1; - - stk_classic::mesh::Entity* element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - stk_classic::mesh::Entity* element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - if (p_rank == 1) - { - element_local_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_ghost); - element_ghost_p = eMesh.get_bulk_data()->get_entity(eMesh.element_rank(), elem_num_local); - } - - dw() << "P["<, int, my_hash, my_equal_to > map_; - - SubDimCell empty_key; - empty_key.insert( std::numeric_limits::max() ); - map_.set_empty_key(empty_key); - - SubDimCell deleted_key; - deleted_key.insert( std::numeric_limits::max()-1 ); - map_.set_deleted_key(deleted_key); - - SubDimCell set1; - SubDimCell set2; - SubDimCell set3; - - set1.insert(1); set1.insert(2); set1.insert(3); - set2.insert(3); set2.insert(1); set2.insert(2); - set3.insert(4); set3.insert(1); set3.insert(2); - typedef pair::iterator, bool> result_type; - - std::ostringstream strs1; - strs1 << set1; - - map_[set1] = 1; - map_[set2] = 2; - map_[set3] = 3; - - cout << "map_[set1]= " << map_[set1] << endl; - cout << "map_[set2]= " << map_[set2] << endl; - cout << "map_[set3]= " << map_[set3] << endl; - - STKUNIT_EXPECT_EQ(map_[set1], map_[set2]); - STKUNIT_EXPECT_TRUE(set1 == set2); - - cout << "set1 = " << endl; - for (SubDimCell::iterator si1 = set1.begin(); si1 != set1.end(); si1++) - { - cout << *si1 << " "; - } - cout << endl; - cout << "set2 = " << endl; - for (SubDimCell::iterator si2 = set2.begin(); si2 != set2.end(); si2++) - { - cout << *si2 << " "; - } - cout << endl; - cout << "set3 = " << endl; - for (SubDimCell::iterator si3 = set3.begin(); si3 != set3.end(); si3++) - { - cout << *si3 << " "; - } - cout << endl; - - //#define QUOTE(expr) #expr - struct less > less_set; - OUT(less_set(set1,set2)); - OUT(less_set(set2,set1)); - OUT(less_set(set1,set3)); - OUT(less_set(set3,set1)); - - copy(set1.begin(), set1.end(), ostream_iterator(cout, " ")); - cout << endl; - //cout << set1 << endl; - cout << set1 << endl; - vector aaa1(3); - aaa1[0] = 0; - aaa1[1] = 1; - aaa1[2] = 2; - cout << aaa1 << endl; - //aaa(cout, aaa1); - //cout << map_ << endl; - - map_.clear(); -} -#endif - -//============================================================================= -//============================================================================= -//============================================================================= - - -STKUNIT_UNIT_TEST(SubDimCell, test1) -{ - map, int> map_; - map, int, less >::iterator map_it; - SubDimCell set1; - SubDimCell set2; - SubDimCell set3; - - set1.insert(1); set1.insert(2); set1.insert(3); - set2.insert(3); set2.insert(1); set2.insert(2); - set3.insert(4); set3.insert(1); set3.insert(2); - typedef pair::iterator, bool> result_type; - - - std::cout << "tmp srk set1= " << set1[0] << " " << set1[1] << " " << set1[2] << std::endl; - - std::ostringstream strs1; - strs1 << set1; - - map_[set1] = 1; - map_[set2] = 2; - map_[set3] = 3; - - cout << "map_[set1]= " << map_[set1] << endl; - cout << "map_[set2]= " << map_[set2] << endl; - cout << "map_[set3]= " << map_[set3] << endl; - - STKUNIT_EXPECT_EQ(map_[set1], map_[set2]); - STKUNIT_EXPECT_TRUE(set1 == set2); - - cout << "set1 = " << endl; - for (SubDimCell::iterator si1 = set1.begin(); si1 != set1.end(); si1++) - { - cout << *si1 << " "; - } - cout << endl; - cout << "set2 = " << endl; - for (SubDimCell::iterator si2 = set2.begin(); si2 != set2.end(); si2++) - { - cout << *si2 << " "; - } - cout << endl; - cout << "set3 = " << endl; - for (SubDimCell::iterator si3 = set3.begin(); si3 != set3.end(); si3++) - { - cout << *si3 << " "; - } - cout << endl; - - //#define QUOTE(expr) #expr - struct less > less_set; - OUT(less_set(set1,set2)); - OUT(less_set(set2,set1)); - OUT(less_set(set1,set3)); - OUT(less_set(set3,set1)); - - copy(set1.begin(), set1.end(), ostream_iterator(cout, " ")); - cout << endl; - //cout << set1 << endl; - cout << set1 << endl; - vector aaa1(3); - aaa1[0] = 0; - aaa1[1] = 1; - aaa1[2] = 2; - cout << aaa1 << endl; - //aaa(cout, aaa1); - //cout << map_ << endl; -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(SubDimCell, test2) -{ -#if 0 - map, int> map_; - map, int, less >::iterator map_it; - SubDimCell set1; - SubDimCell set2; - SubDimCell set3; - set1.insert(1); set1.insert(2); set1.insert(3); - set2.insert(3); set2.insert(1); set2.insert(2); - set3.insert(4); set3.insert(1); set3.insert(2); - typedef pair::iterator, bool> result_type; - - map_[set1] = 1; - map_[set2] = 2; - map_[set3] = 3; - - cout << "map_[set1]= " << map_[set1] << endl; - cout << "map_[set2]= " << map_[set2] << endl; - cout << "map_[set3]= " << map_[set3] << endl; - - STKUNIT_EXPECT_EQ(map_[set1], map_[set2]); - STKUNIT_EXPECT_TRUE(set1 == set2); - - cout << "set1 = " << endl; - for (SubDimCell::iterator si1 = set1.begin(); si1 != set1.end(); si1++) - { - cout << *si1 << " "; - } - cout << endl; - cout << "set2 = " << endl; - for (SubDimCell::iterator si2 = set2.begin(); si2 != set2.end(); si2++) - { - cout << *si2 << " "; - } - cout << endl; - cout << "set3 = " << endl; - for (SubDimCell::iterator si3 = set3.begin(); si3 != set3.end(); si3++) - { - cout << *si3 << " "; - } - cout << endl; - - //#define QUOTE(expr) #expr - - struct less > less_set; - OUT(less_set(set1,set2)); - OUT(less_set(set2,set1)); - OUT(less_set(set1,set3)); - OUT(less_set(set3,set1)); - - copy(set1.begin(), set1.end(), ostream_iterator(cout, " ")); - cout << endl; - //cout << set1 << endl; - cout << set1 << endl; - vector aaa1(3); - aaa1[0] = 0; - aaa1[1] = 1; - aaa1[2] = 2; - cout << aaa1 << endl; - //aaa(cout, aaa1); - //cout << map_ << endl; -#endif -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.cpp deleted file mode 100644 index 8df2ab55f531..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include - -namespace stk_classic { - namespace adapt { - namespace unit_tests { - - /// CONFIGURATIONS - /// you can choose to use regression testing or not (see always_do_regression_tests) - - - void UnitTestSupport::save_or_diff(PerceptMesh& eMesh, std::string filename, int option ) - { - if (always_do_regression_tests || option == 1) - { - unsigned p_size = eMesh.get_parallel_size(); - unsigned p_rank = eMesh.get_parallel_rank(); - std::string par_filename = filename; - if (p_size > 1) - { - par_filename = filename+"."+toString(p_size)+"."+toString(p_rank); - } - if (Util::file_exists(par_filename)) - { - int spatialDim = eMesh.get_spatial_dim(); - - PerceptMesh eMesh1(spatialDim); - eMesh.save_as("./tmp.e"); - eMesh1.open_read_only("./tmp.e"); - - PerceptMesh eMesh_gold(spatialDim); - eMesh_gold.open_read_only(filename); - //eMesh_gold.print_info("gold copy: "+filename, 2); - //eMesh1.print_info("compare to: "+filename, 2); - { - std::string diff_msg = "gold file diff report: "+filename+" \n"; - bool print_during_diff = false; - bool diff = PerceptMesh::mesh_difference(eMesh1, eMesh_gold, diff_msg, print_during_diff); - if (diff) - { - //std::cout << "tmp writing and reading to cleanup parts" << std::endl; - - // write out and read back in to cleanup old parts - eMesh1.save_as("./tmp.e"); - PerceptMesh eMesh2(spatialDim); - eMesh2.open_read_only("./tmp.e"); - //std::cout << "tmp done writing and reading to cleanup parts" << std::endl; - bool diff_2 = PerceptMesh::mesh_difference(eMesh2, eMesh_gold, diff_msg, print_during_diff); - //std::cout << "tmp diff_2= " << diff_2 << std::endl; - diff = diff_2; - if (diff_2) - { - //bool diff_3 = - PerceptMesh::mesh_difference(eMesh2, eMesh_gold, diff_msg, true); - } - } - - STKUNIT_EXPECT_TRUE(!diff); - } - } - else - { - eMesh.save_as(filename); - } - } - else - { - eMesh.save_as(filename); - } - } - - - - - bool UnitTestSupport::always_do_regression_tests = true; - - - } - } -} diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.hpp deleted file mode 100644 index 70d08714ce7b..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestSupport.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef stk_adapt_unit_tests_UnitTestSupport_hpp -#define stk_adapt_unit_tests_UnitTestSupport_hpp - -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { - namespace adapt { - namespace unit_tests { - - - class UnitTestSupport - { - public: - /// The following defines where to put the input and output files created by this set of functions - static const std::string input_files_loc; - static const std::string output_files_loc; - - static bool always_do_regression_tests; - - /// This function either writes the given mesh to a file in Exodus format (option 0) - /// or, under option 1, checks if the file already exists, and if so, treats that - /// file as the "gold" copy and does a regression difference check. - /// Overriden by always_do_regression_tests - if "true", then option 1 is always done. - - static void save_or_diff(PerceptMesh& eMesh, std::string filename, int option = 0); - - - - }; - } - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestUniformRefiner.cpp b/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestUniformRefiner.cpp deleted file mode 100644 index 1d832d6ef5d2..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/UnitTestUniformRefiner.cpp +++ /dev/null @@ -1,3277 +0,0 @@ - -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#if defined ( STK_PERCEPT_HAS_MESQUITE ) - -#define StackTraceTmp StackTrace -#undef StackTrace -#include -#define StackTrace StackTraceTmp -#endif - -#include -#include - -#include - -#include - - -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { - namespace adapt { - namespace unit_tests { - -#define DO_TESTS 0 -#if DO_TESTS - static int print_infoLevel = 0; - - /// configuration: you can choose where to put the generated Exodus files (see variables input_files_loc, output_files_loc) - /// The following defines where to put the input and output files created by this set of functions - -#if 1 - const std::string input_files_loc="./input_files_"; - const std::string output_files_loc="./output_files_"; -#else - const std::string input_files_loc="./input_files/"; - const std::string output_files_loc="./output_files/"; -#endif - -#define EXTRA_PRINT 0 - - /// This function either writes the given mesh to a file in Exodus format (option 0) - /// or, under option 1, checks if the file already exists, and if so, treats that - /// file as the "gold" copy and does a regression difference check. - - - static void save_or_diff(PerceptMesh& eMesh, std::string filename, int option = 0) - { - return UnitTestSupport::save_or_diff(eMesh, filename, option); - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Creates meshes for use in later tests - /// 1. Create hex mesh from a fixture and write it in Exodus format for use later. - /// 2. Read the hex mesh and convert it to tet elements using stk_adapt/UniformRefiner, write it in Exodus format - - //STKUNIT_UNIT_TEST(unit_uniformRefiner, build_meshes) - static void fixture_setup_0() - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - // start_demo_uniformRefiner_hex8_build - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - // generate a 4x4x(4*p_size) mesh - std::string gmesh_spec = std::string("4x4x")+toString(4*p_size)+std::string("|bbox:0,0,0,1,1,1"); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - eMesh.commit(); - save_or_diff(eMesh, input_files_loc+"hex_fixture.e"); - - // end_demo - } - - // start_demo_uniformRefiner_hex8_build_1 - { - percept::PerceptMesh eMesh(3u); - - //unsigned p_size = eMesh.get_parallel_size(); - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Tet4_24 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"tet_fixture.e"); - save_or_diff(eMesh, input_files_loc+"tet_from_hex_fixture.e"); - // end_demo - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Creates meshes for use in later tests - quad meshes with and without sidesets - - //STKUNIT_UNIT_TEST(unit_uniformRefiner, quad4_quad4_4_test_1) - static void fixture_setup_1() - { - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, true); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture", print_infoLevel); - save_or_diff(eMesh, input_files_loc+"quad_fixture.e"); - } - - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, false); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture no sidesets", print_infoLevel); - save_or_diff(eMesh, input_files_loc+"quad_fixture_no_sidesets.e"); - } - } - - static void fixture_setup() - { - //std::cout << "tmp fixture_setup" << std::endl; - static bool is_setup = false; - if (is_setup) return; - fixture_setup_0(); - fixture_setup_1(); - is_setup = true; - } - - //===================================================================================================================================================================================================== - //===================================================================================================================================================================================================== - //===================================================================================================================================================================================================== - -#define REPRO_ERROR_7539 0 - -#if REPRO_ERROR_7539 - STKUNIT_UNIT_TEST(unit1_uniformRefiner, stk_fixture) - { - typedef stk_classic::mesh::Field ProcIdFieldType; - - using Teuchos::RCP; - using Teuchos::rcp; - using Teuchos::rcpFromRef; - - int numprocs = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - int rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - std::cout << "Running numprocs = " << numprocs << " rank = " << rank << std::endl; - - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,3,3,3); - ProcIdFieldType & processorIdField = hf.m_fem_meta.declare_field("PROC_ID"); - stk_classic::mesh::put_field( processorIdField , 3, hf.m_fem_meta.universal_part()); - - stk_classic::percept::PerceptMesh eMesh(&hf.m_fem_meta,&hf.m_bulk_data,false); - stk_classic::adapt::Hex8_Hex8_8 break_quad(eMesh); - - hf.m_fem_meta.commit(); - hf.generate_mesh(); - - const std::vector & buckets = hf.m_bulk_data.buckets(3); - for(std::size_t i=0;i ProcIdFieldType; - - using Teuchos::RCP; - using Teuchos::rcp; - using Teuchos::rcpFromRef; - - int numprocs = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - int rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - std::cout << "Running numprocs = " << numprocs << " rank = " << rank << std::endl; - - // local scope to make sure we don't re-use hf - { - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,3,3,3); - ProcIdFieldType & processorIdField = hf.m_fem_meta.declare_field("PROC_ID"); - stk_classic::mesh::put_field( processorIdField , 3, hf.m_fem_meta.universal_part()); - - // to get any output we must tell I/O about this part - stk_classic::io::put_io_part_attribute( hf.m_hex_part); - - hf.m_fem_meta.commit(); - hf.generate_mesh(); - - const std::vector & buckets = hf.m_bulk_data.buckets(3); - for(std::size_t i=0;i fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad4_4 break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - if (0) - { - percept::GeometryVerifier gv(true); - std::cout << "tmp GeometryVerifier= " << eMesh.get_bulk_data() << std::endl; - bool igb = gv.isGeometryBad(*eMesh.get_bulk_data(), true); - std::cout << "tmp isGeometryBad= " << igb << std::endl; - } - - fixture.generate_mesh(); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - //MPI_Barrier( MPI_COMM_WORLD ); - - //eMesh.dump_elements_compact(); - - //MPI_Barrier( MPI_COMM_WORLD ); - //exit(123); - - - // end_demo - } - - } - - /// Refine a triangle mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri_to_tri_sierra_1_test) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 2) - { - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = false; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri3_4 break_tri_to_tri_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - UniformRefiner breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.doBreak(); - //eMesh.dump_elements_compact(); - - //MPI_Barrier( MPI_COMM_WORLD ); - //exit(123); - - - // end_demo - } - - } - -#endif - - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Refine quad elements - /// uses the Sierra-ported tables from framework/{element,mesh_modification} - STKUNIT_UNIT_TEST(unit_uniformRefiner, break_quad_to_quad_sierra) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, true); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, false); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh); - // FIXME - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("quad mesh"); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - //!!eMesh, "./square_quad4_ref_sierra_out.e"); - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Refine quad elements with beam elements for the "side sets" - STKUNIT_UNIT_TEST(unit_uniformRefiner, break_quad_to_quad_sierra_1) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool debug_geom_side_sets_as_blocks = true; - percept::QuadFixture fixture( pm , nx , ny, true, debug_geom_side_sets_as_blocks); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, false); - - //UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_pattern(eMesh); - URP_Heterogeneous_3D break_pattern(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("quad mesh"); - eMesh.save_as("./quad_mesh_count_0.e"); - { - std::vector count ; - stk_classic::mesh::Selector selector(eMesh.get_fem_meta_data()->universal_part()); - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - std::cout << "{ Node = " << count[ 0 ] ; - std::cout << " Edge = " << count[ 1 ] ; - std::cout << " Face = " << count[ 2 ] ; - std::cout << " Elem = " << count[ 3 ] ; - std::cout << " }" << std::endl ; - } - - UniformRefiner breaker(eMesh, break_pattern, proc_rank_field); - breaker.setRemoveOldElements(true); - breaker.doBreak(); - - eMesh.save_as("./quad_mesh_count_1.e"); - - { - std::vector count ; - stk_classic::mesh::Selector selector(eMesh.get_fem_meta_data()->universal_part()); - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - std::cout << "{ Node = " << count[ 0 ] ; - std::cout << " Edge = " << count[ 1 ] ; - std::cout << " Face = " << count[ 2 ] ; - std::cout << " Elem = " << count[ 3 ] ; - std::cout << " }" << std::endl ; - } - //exit(123); - - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Create a triangle mesh using the QuadFixture with the option of breaking the quads into triangles - /// Refine the triangle mesh, write the results. - - STKUNIT_UNIT_TEST(unit_uniformRefiner, break_tri_to_tri_sierra) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture > fixture( pm , nx , ny, true); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, false); - - // UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_tri_to_tri_4(eMesh); - // // FIXME - // int scalarDimension = 0; // a scalar - // FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("tri mesh"); - - // UniformRefiner breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - // breaker.doBreak(); - - save_or_diff(eMesh, input_files_loc+"quad_fixture_tri3.e"); - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Refine a hex8 mesh - STKUNIT_UNIT_TEST(unit_uniformRefiner, hex8_hex8_8_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex8_8_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - // generate a 4x4x(4*p_size) mesh - std::string gmesh_spec = std::string("4x4x")+toString(4*p_size)+std::string("|bbox:0,0,0,1,1,1"); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - //eMesh.commit(); - //eMesh.reopen(); - - Hex8_Hex8_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - // end_demo - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Create and write a wedge mesh using the WedgeFixture - - STKUNIT_UNIT_TEST(unit_uniformRefiner, wedge6_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_wedge6_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) // this fixture only works in serial mode - { - percept::WedgeFixture wedgeFixture; - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string(input_files_loc+"swept-wedge_0.e") ); - } - } - - - //============================================================================================================================================================= - //============================================================================================================================================================= - //============================================================================================================================================================= - - /// Create a Beam mesh and enrich it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, beam_enrich) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // create the mesh - { - - stk_classic::percept::BeamFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_beam ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - save_or_diff(em1, input_files_loc+"beam_enrich_0.e"); - - } - - // enrich - { - stk_classic::percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"beam_enrich_0.e"); - //URP_Heterogeneous_3D break_pattern(eMesh); - Beam2_Beam3_1 break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - save_or_diff(eMesh, output_files_loc+"beam_enrich_0.e"); - - eMesh.print_info("beam", print_infoLevel); - - UniformRefiner breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"beam_enrich_1.e"); - - } - } - } - //============================================================================= - //============================================================================= - //============================================================================= - - /// Create a beam mesh and refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, beam_refine) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // create the mesh - { - - stk_classic::percept::BeamFixture mesh(pm, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_beam ); - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - save_or_diff(em1, input_files_loc+"beam_0.e"); - - } - - // refine - { - stk_classic::percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"beam_0.e"); - //URP_Heterogeneous_3D break_pattern(eMesh); - Beam2_Beam2_2 break_pattern(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - save_or_diff(eMesh, output_files_loc+"beam_0.e"); - - eMesh.print_info("beam", print_infoLevel); - - UniformRefiner breaker(eMesh, break_pattern, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"beam_1.e"); - - } - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //===================== Table generation - //====================================================================================================================== - - /// This code generates C++ tables used by stk_adapt - tables contain node numbering, parametric coordinates consistent - /// with Intrepid, and related information needed by UniformRefiner. The generated code should be compared with - /// and merged into as appropriate if there is a change - /// in the tables in that package, or an additional element type is added. - /** This comment is from the generated code and tells how to bootstrap this process. - * Bootstrapping this file: to create this file, run the regression test RegressionTestUniformRefiner.cpp :: generate_tables after putting in - * a dummy entry in ./sierra_element/GeneratedRefinementTable.hpp. The run will produce a local file, generated_refinement_tables.hpp - * which can be checked against the gold copy of GeneratedRefinementTable.hpp, then copied over it. Add a call below to generate the - * actual new table data. - */ - - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, generate_tables) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - Elem::StdMeshObjTopologies::bootstrap(); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1) - { - std::ofstream file("./generated_refinement_tables.hpp"); - - file << "#ifndef STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP" << std::endl; - file << "#define STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP" << std::endl; - - file << - "/** New ref topo info \n" - "* ------------------\n" - "*\n" - "* {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord}\n" - "*\n" - "* struct RefinementTopologyExtraEntry\n" - "* {\n" - "* unsigned ordinal_of_node; // ordinal of node in the total list of nodes - corresponds to the shards node ordinal\n" - "* unsigned rank_of_subcell; // rank of the subcell this node is associated with \n" - "* unsigned ordinal_of_subcell; // ordinal of the subcell in the shards numbering (e.g. edge # 3)\n" - "* unsigned ordinal_of_node_on_subcell; // ordinal of the node on the subcell (whcih node it is on a subcell that has multiple nodes)\n" - "* unsigned num_nodes_on_subcell; // how many nodes exist on the subcell \n" - "* double parametric_coordinates[3];\n" - "* };\n" - "* \n" - "* Bootstrapping this file: to create this file, run the regression test RegressionTestUniformRefiner.cpp :: generate_tables after putting in\n" - "* a dummy entry in ./sierra_element/GeneratedRefinementTable.hpp. The run will produce a local file, generated_refinement_tables.hpp \n" - "* which can be checked against the gold copy of GeneratedRefinementTable.hpp, then copied over it. Add a call below to generate the \n" - "* actual new table data. \n" - "*/\n\n" - << std::endl; - - // FIXME -#if !(defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND)) - - Line2_Line2_2 :: printRefinementTopoX_Table(file); - - Beam2_Beam2_2 :: printRefinementTopoX_Table(file); - - ShellLine2_ShellLine2_2 :: printRefinementTopoX_Table(file); - ShellLine3_ShellLine3_2 :: printRefinementTopoX_Table(file); - Quad4_Quad4_4 :: printRefinementTopoX_Table(file); - Tri3_Tri3_4 :: printRefinementTopoX_Table(file); - ShellTri3_ShellTri3_4 :: printRefinementTopoX_Table(file); - ShellTri6_ShellTri6_4 :: printRefinementTopoX_Table(file); - ShellQuad4_ShellQuad4_4 :: printRefinementTopoX_Table(file); - ShellQuad8_ShellQuad8_4 :: printRefinementTopoX_Table(file); - Tet4_Tet4_8 :: printRefinementTopoX_Table(file); - Hex8_Hex8_8 :: printRefinementTopoX_Table(file); - Wedge6_Wedge6_8 :: printRefinementTopoX_Table(file); - Wedge15_Wedge15_8 :: printRefinementTopoX_Table(file); - - // Not supported by Sierra - // Wedge18_Wedge18_8 :: printRefinementTopoX_Table(file); - - Line3_Line3_2 :: printRefinementTopoX_Table(file); - Beam3_Beam3_2 :: printRefinementTopoX_Table(file); - - Tri6_Tri6_4 :: printRefinementTopoX_Table(file); - Quad8_Quad8_4 :: printRefinementTopoX_Table(file); - Quad9_Quad9_4 :: printRefinementTopoX_Table(file); - Hex27_Hex27_8 :: printRefinementTopoX_Table(file); - Hex20_Hex20_8 :: printRefinementTopoX_Table(file); - Tet10_Tet10_8 :: printRefinementTopoX_Table(file); -#endif - file << "#endif" << std::endl; - } - - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Code to generate Dot/Graphviz files representing the topology of element refinement based on the internal tables - - static void output_draw(std::string filename, std::string toFile) - { - std::ofstream file(filename.c_str()); - file << toFile; - } - - STKUNIT_UNIT_TEST(unit_uniformRefiner, draw1) - { - fixture_setup(); - //std::cout << Quad4_Quad4_4::draw() << std::endl; - std::string dir = "./"; - output_draw(dir+"quad4.dot", Quad4_Quad4_4::draw(true) ); - output_draw(dir+"tet4.dot", Tet4_Tet4_8::draw() ); - output_draw(dir+"hex8.dot", Hex8_Hex8_8::draw(true) ); - output_draw(dir+"hex27.dot", Hex27_Hex27_8::draw(true, true) ); - output_draw(dir+"hex20.dot", Hex20_Hex20_8::draw(true, true) ); - output_draw(dir+"wedge6.dot", Wedge6_Wedge6_8::draw() ); - - output_draw(dir+"quad9.dot", Quad9_Quad9_4::draw(true, true)); - } - - STKUNIT_UNIT_TEST(unit_uniformRefiner, draw) - { - fixture_setup(); - //std::cout << Quad4_Quad4_4::draw() << std::endl; - std::string dir = "./"; - output_draw(dir+"quad4.dot", Quad4_Quad4_4::draw(true) ); - output_draw(dir+"tet4.dot", Tet4_Tet4_8::draw() ); - output_draw(dir+"hex8.dot", Hex8_Hex8_8::draw(true) ); - output_draw(dir+"wedge6.dot", Wedge6_Wedge6_8::draw() ); - - output_draw(dir+"quad9.dot", Quad9_Quad9_4::draw(true)); - - // refine -#if 0 - std::cout << Line2_Line2_2::draw() << std::endl; - std::cout << Tri3_Tri3_4::draw() << std::endl; - std::cout << Tet4_Tet4_8::draw() << std::endl; - std::cout << Hex8_Hex8_8::draw() << std::endl; -#endif - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Convert a quad mesh to triangles with 6 triangles per quad - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_tri_6) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_tri_6 - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture.e"); - - typedef UniformRefinerPattern, shards::Triangle<3>, 6 > Quad4_Tri3_6; - - UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - //UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6; - UniformRefiner breaker(eMesh, break_quad_to_tri_6, proc_rank_field); - //breaker.setIgnoreSideSets(true); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"square_quad4_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Convert a quad mesh to triangles with 4 triangles per quad - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_tri_4) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - - // start_demo_uniformRefiner_break_quad_to_tri_4 - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture.e"); - - UniformRefinerPattern, shards::Triangle<3>, 4, Specialization > break_quad_to_tri_4(eMesh); - - int scalarDimension = 0; // a scalar - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - //UniformRefinerPattern, shards::Triangle<3>, 6 > break_quad_to_tri_6; - UniformRefiner breaker(eMesh, break_quad_to_tri_4, proc_rank_field); - breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"square_quad4_tri3_4_out.e"); - // end_demo - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh using the "standalone" refinement pattern: - /// UniformRefinerPattern, shards::Quadrilateral<4>, 4 > - /// This pattern is an example (like the convert-type patterns) showing how to write a new pattern with no dependencies - // on other (say tabular) data/info. - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_quad - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture_no_sidesets.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4 > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"square_quad4_ref_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh - /// uses the Sierra-ported tables from framework/{element,mesh_modification} - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad_sierra) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_quad_to_quad_sierra - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"square_quad4_ref_sierra_out.e"); - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh with sidesets - /// uses the Sierra-ported tables from framework/{element,mesh_modification} - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad_sierra_sidesets) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - if (p_size == 1 || p_size == 2) - { - // start_demo_uniformRefiner_break_quad_to_quad_sierra_sidesets - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture.e"); - - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("quad mesh"); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - - eMesh.print_info("after refinement break_quad_to_quad_sierra_sidesets"); - - save_or_diff(eMesh, output_files_loc+"quad_sidesets_sierra_out.e"); - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Convert a hex mesh to tets using 24 tets per hex - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_tet4_24_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_tet4_24_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - //unsigned p_rank = eMesh.get_rank(); - Util::setRank(eMesh.get_rank()); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - UniformRefinerPattern, shards::Tetrahedron<4>, 24 > break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_tet_24_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_tet_24_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Convert a hex mesh using 6 tets per hex - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_tet4_6_12_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_tet4_6_12_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Tet4_6_12 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_tet_6_12_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_tet, proc_rank_field); - breaker.setRemoveOldElements(true); - //breaker.setIgnoreSideSets(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_tet_6_12_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Convert a hex mesh using 6 tets per hex - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_tet4_6_12_2) - { - fixture_setup(); - - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_tet4_6_12_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Tet4_6_12 break_hex_to_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info("test",2); - eMesh.print_info(); - save_or_diff(eMesh, output_files_loc+"hex8_tet4_6_12_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_tet, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex8_tet4_6_12_1.e"); - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, quad4_quad4_4_test_1) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, true); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_test_1.e"); - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh; test the multiple refinement feature - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad_sierra_1) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = true; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("quad mesh"); - - save_or_diff(eMesh, output_files_loc+"quad_fixture_0.e"); - save_or_diff(eMesh, input_files_loc+"quad_fixture_0.e"); - eMesh.close(); - - for (int iBreak = 0; iBreak < 2; iBreak++) - { - std::cout << "\n\n\n ================ tmp Refine Pass = " << iBreak << std::endl; - - percept::PerceptMesh eMesh1(2); - std::string fileName = std::string(input_files_loc+"quad_fixture_")+toString(iBreak)+std::string(".e"); - eMesh1.open(fileName); - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - - // if (iBreak != 0) - // proc_rank_field = eMesh1.get_field("proc_rank"); - - UniformRefiner breaker(eMesh1, break_quad_to_quad_4, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.doBreak(); - std::string fileName1 = std::string(output_files_loc+"quad_fixture_")+toString( iBreak + 1 )+std::string(".e"); - std::string fileName2 = std::string(input_files_loc+"quad_fixture_")+toString( iBreak + 1 )+std::string(".e"); - - //eMesh1.print_info("quad_fixture_1.e"); - - save_or_diff(eMesh1, fileName2); - save_or_diff(eMesh1, fileName1); - eMesh1.close(); - - if (0 && iBreak==0) - { - percept::PerceptMesh e1(2); - std::cout << "\n\n\n ================ tmp eMesh1.open_read_only(quad_fixture_1.e) \n\n\n " << std::endl; - e1.open_read_only(input_files_loc+"quad_fixture_1.e"); - e1.print_info("quad_fixture_1_read.e"); - e1.close(); - } - } - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad mesh; test the multiple refinement feature - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad_sierra_2) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("quad mesh"); - - save_or_diff(eMesh, output_files_loc+"quad_fixture_mbreak_0.e"); - save_or_diff(eMesh, input_files_loc+"quad_fixture_mbreak_0.e"); - eMesh.close(); - - - percept::PerceptMesh eMesh1(2); - std::string fileName = std::string(input_files_loc+"quad_fixture_mbreak_0.e"); - eMesh1.open(fileName); - UniformRefinerPattern, shards::Quadrilateral<4>, 4, SierraPort > break_quad_to_quad_4(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - - UniformRefiner breaker(eMesh1, break_quad_to_quad_4, proc_rank_field); - - for (int iBreak = 0; iBreak < 2; iBreak++) - { - std::cout << "\n\n\n ================ tmp Refine Pass = " << iBreak << std::endl; - - breaker.doBreak(); - std::string fileName1 = std::string(output_files_loc+"quad_fixture_mbreak_")+toString(iBreak+1)+std::string(".e"); - save_or_diff(eMesh1, fileName1); - } - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a quad mesh (convert linear Quad4 elements to quadratic Quad9) - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad4_to_quad9) - { - fixture_setup(); - EXCEPTWATCH; - - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad9_0.e"); - - UniformRefiner breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad9_1.e"); - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a quad mesh (convert linear Quad4 elements to serendepity Quad8) - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad4_to_quad8) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - const unsigned nx = n , ny = n; - - bool doGenSideSets = true; - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad8_1 break_quad4_to_quad8_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad8_0.e"); - - UniformRefiner breaker(eMesh, break_quad4_to_quad8_1, proc_rank_field); - - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad8_1.e"); - save_or_diff(eMesh, input_files_loc+"quad_fixture_quad8_quad8_0.e"); - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quad8/serendepity mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad8_to_quad8) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture_quad8_quad8_0.e"); - - Quad8_Quad8_4 break_quad8_to_quad8_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_quad8_to_quad8_4, proc_rank_field); - breaker.setIgnoreSideSets(false); - - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad8_quad8_1.e"); - - } - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a quad4 mesh to quad9 then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad4_to_quad9_to_quad9_0) - { - fixture_setup(); - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = false; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 1) - { - { - const unsigned n = 1; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - - UniformRefiner breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"quad_1x1_quad9_quad9_0.e"); - } - - { - percept::PerceptMesh em1(2); - em1.open(input_files_loc+"quad_1x1_quad9_quad9_0.e"); - Quad9_Quad9_4 break_q9_q9(em1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = em1.add_field("proc_rank", em1.element_rank(), scalarDimension); - - em1.commit(); - - - UniformRefiner breaker(em1, break_q9_q9, proc_rank_field); - breaker.setIgnoreSideSets(!doGenSideSets); - - breaker.doBreak(); - save_or_diff(em1, output_files_loc+"quad_1x1_quad9_quad9_1.e"); - - } - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a quad4 mesh to quad9 then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad4_to_quad9_to_quad9) - { - fixture_setup(); - EXCEPTWATCH; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - bool doGenSideSets = true; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 3) - { - { - //FIXME const unsigned n = 12; - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, doGenSideSets); - - // Adopt the meta/bulk data - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad9_1 break_quad4_to_quad9_1(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - fixture.generate_mesh(); - - - UniformRefiner breaker(eMesh, break_quad4_to_quad9_1, proc_rank_field); - std::cout << "break_quad4_to_quad9_1.fixSurfaceAndEdgeSetNamesMap().size()= " - << break_quad4_to_quad9_1.fixSurfaceAndEdgeSetNamesMap().size() << std::endl; - - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"quad_fixture_quad9_quad9_0.e"); - //eMesh.print_info("quad_fixture_quad9_quad9_0.e", 2); - } - - { - percept::PerceptMesh em1(2); - em1.open(input_files_loc+"quad_fixture_quad9_quad9_0.e"); - Quad9_Quad9_4 break_q9_q9(em1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = em1.add_field("proc_rank", em1.element_rank(), scalarDimension); - - em1.commit(); - - - UniformRefiner breaker(em1, break_q9_q9, proc_rank_field); - breaker.setIgnoreSideSets(!doGenSideSets); - - breaker.doBreak(); - save_or_diff(em1, output_files_loc+"quad_fixture_quad9_quad9_1.e"); - - } - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a triangle mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri_to_tri_sierra_0) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture > fixture( pm , nx , ny, true); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, false); - - eMesh.commit(); - - fixture.generate_mesh(); - - eMesh.print_info("tri mesh"); - - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3.e"); - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a triangle mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri_to_tri_sierra_1) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri3_4 break_tri_to_tri_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("tri mesh", 5); - eMesh.print_info("tri mesh"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_0.e"); - - UniformRefiner breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri mesh refined"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_1.e"); - - if (0) - { - percept::PerceptMesh e1(2); - e1.open_read_only(input_files_loc+"quad_fixture_tri3_1.e"); - e1.print_info("after read", 3); - } - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - -#if defined ( STK_PERCEPT_HAS_MESQUITE ) - - /// Refine a triangle mesh with spacing - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_quad_to_quad_sierra_spc) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture fixture( pm , nx , ny, createEdgeSets); - fixture.set_bounding_box(0,1,0,1); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Quad4_Quad4_4 break_quad_to_quad_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - eMesh.add_spacing_fields(); - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - const std::vector & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& node = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node ); - double iy = data[1]; // /double(nele); - iy = iy*iy; - data[1] = iy; // *double(nele); - } - } - } - SpacingFieldUtil sfu(eMesh); - sfu.compute_spacing_field(); - - //eMesh.print_info("quad mesh", 5); - eMesh.print_info("quad mesh"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad3_spc_0.e"); - - UniformRefiner breaker(eMesh, break_quad_to_quad_4, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("quad mesh refined", 5); - eMesh.print_info("quad mesh refined"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_quad3_spc_1.e"); - - // end_demo - } -#if 0 - Math::Matrix rmx = Math::rotationMatrix(0, 30); - Math::Matrix rmy = Math::rotationMatrix(1, -45); - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm; - rm = rmy * rmz; - rm = rmx * rm; - eMesh.transform_mesh(rm); -#endif - } - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a triangle mesh with spacing - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri_to_tri_sierra_spc) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - fixture.set_bounding_box(0,1,0,1); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri3_4 break_tri_to_tri_4(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - eMesh.add_spacing_fields(); - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - const std::vector & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& node = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node ); - double iy = data[1]; // /double(nele); - iy = iy*iy; - data[1] = iy; // *double(nele); - } - } - } - SpacingFieldUtil sfu(eMesh); - sfu.compute_spacing_field(); - - //eMesh.print_info("tri mesh", 5); - eMesh.print_info("tri mesh"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_spc_0.e"); - - UniformRefiner breaker(eMesh, break_tri_to_tri_4, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri mesh refined"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_spc_1.e"); - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - // A cube with an indented bump on the bottom - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex_4) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - unsigned n = 12; - std::string gmesh_spec = toString(n)+"x"+toString(n)+"x"+toString(n)+std::string("|bbox:0,0,0,1,1,1|sideset:xXyYzZ"); - PerceptMesh eMesh(3); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - Hex8_Hex8_8 break_hex_to_hex(eMesh); - eMesh.add_spacing_fields(); - eMesh.commit(); - - const std::vector & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - // cluster the mesh towards the bump - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - data[2] = data[2]*data[2]; - } - } - } - SpacingFieldUtil sfu(eMesh); - sfu.compute_spacing_field(); - - save_or_diff(eMesh, output_files_loc+"hex_4_spc.0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, 0); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex_4_spc.1.e"); - - } - } - -#endif - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a triangle mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri3_to_tri6_sierra) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool createEdgeSets = true; - percept::QuadFixture > fixture( pm , nx , ny, createEdgeSets); - - bool isCommitted = false; - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data, isCommitted); - - Tri3_Tri6_1 break_tri3_to_tri6(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - - // std::cout << "proc_rank_field rank= " << proc_rank_field->rank() << std::endl; - // std::cout << "proc_rank_field_edge rank= " << proc_rank_field_edge->rank() << std::endl; - - //fixture.meta_data.commit(); - eMesh.commit(); - - fixture.generate_mesh(); - - //eMesh.print_info("tri mesh", 5); - eMesh.print_info("tri mesh tri6"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_tri6_0.e"); - - UniformRefiner breaker(eMesh, break_tri3_to_tri6, proc_rank_field); - breaker.doBreak(); - - //eMesh.print_info("tri mesh refined", 5); - eMesh.print_info("tri mesh enriched"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri3_tri6_1.e"); - save_or_diff(eMesh, input_files_loc+"quad_fixture_tri6_tri6_0.e"); - - if (0) - { - percept::PerceptMesh e1(2); - e1.open_read_only(input_files_loc+"quad_fixture_tri3_1.e"); - e1.print_info("after read", 3); - } - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a triangle mesh then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tri3_to_tri6_to_tri6_sierra) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size <= 3) - { - // start_demo_break_tri3_to_tri6_to_tri6_sierra - - percept::PerceptMesh eMesh(2u); - eMesh.open(input_files_loc+"quad_fixture_tri6_tri6_0.e"); - - Tri6_Tri6_4 break_tri6_to_tri6(eMesh); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - //stk_classic::mesh::FieldBase* proc_rank_field_edge = - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension); - eMesh.commit(); - - eMesh.print_info("tri mesh tri6"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri6_tri6_0.e"); - - UniformRefiner breaker(eMesh, break_tri6_to_tri6, proc_rank_field); - breaker.doBreak(); - - eMesh.print_info("tri mesh refined"); - save_or_diff(eMesh, output_files_loc+"quad_fixture_tri6_tri6_1.e"); - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a linear tet mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tet4_tet4_0) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_0 - percept::PerceptMesh eMesh(3u); - eMesh.open_read_only(input_files_loc+"tet_from_hex_fixture.e"); - save_or_diff(eMesh, input_files_loc+"tet_from_hex_fixture_0.e"); - // end_demo - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a linear tet mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tet4_tet4_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet4_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"tet_from_hex_fixture_0.e"); - - Tet4_Tet4_8 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UniformRefiner breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"tet4_refined_1.e"); - - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"tet4_refined_2.e"); - // end_demo - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear tet mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tet4_tet10_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet10_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"tet_from_hex_fixture_0.e"); - - Tet4_Tet10_1 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UniformRefiner breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"tet10_1.e"); - // end_demo - - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear tet mesh then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, break_tet4_tet10_tet10_1) - { - fixture_setup(); - // FIXME - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet10_tet10_1 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"tet_from_hex_fixture_0.e"); - - Tet4_Tet10_1 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info("tet mesh"); - - UniformRefiner breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"tet10_1.e"); - eMesh.print_info("tet10_1"); - // end_demo - - } - - if (p_size == 1 || p_size == 3) - { - // start_demo_uniformRefiner_break_tet4_tet10_tet10_2 - percept::PerceptMesh eMesh(3u); - eMesh.open(input_files_loc+"tet10_1.e"); - - Tet10_Tet10_8 break_tet_tet(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info("tet mesh"); - - UniformRefiner breaker(eMesh, break_tet_tet, proc_rank_field); - //breaker.setRemoveOldElements(false); - //breaker.setIgnoreSideSets(true); - //breaker.doBreak(); - - unsigned numRefines = 1; - for (unsigned iBreak = 0; iBreak < numRefines; iBreak++) - { - breaker.doBreak(); - } - - save_or_diff(eMesh, output_files_loc+"tet10_tet10_"+toString(numRefines)+".e"); - // end_demo - - - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a linear hex mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex8_8_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex8_8_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex8_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - // int vectorDimension = 3; - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - // eMesh.add_field("velocity", mesh::Node, vectorDimension); - // eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_hex_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex_hex_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a linear hex mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex8_8_2) - { - fixture_setup(); - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex8_8_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Hex8_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, output_files_loc+"hex8_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex8_1.e"); - - breaker.doBreak(); - save_or_diff(eMesh, output_files_loc+"hex8_2.e"); - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear hex mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex27_1_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex27_1_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex8_hex27_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex8_hex27_cube1x1x")+toString(p_size)+std::string(".e")); - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear hex mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex27_1_2) - { - fixture_setup(); - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex27_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, output_files_loc+"hex27_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex27_1.e"); - - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear hex mesh to serendepity hex20 elements - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex20_1_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex8_hex20_1_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex20_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex8_hex20_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex8_hex20_cube1x1x")+toString(p_size)+std::string(".e")); - save_or_diff(eMesh, std::string(input_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear hex mesh to serendepity hex20 elements - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex20_1_2) - { - fixture_setup(); - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex20_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Hex20_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, output_files_loc+"hex20_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex20_1.e"); - save_or_diff(eMesh, input_files_loc+"hex20_hex20_0.e"); - - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a serendepity hex20 mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex20_hex20_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex20_hex20_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - if (p_size <= 3) - { - eMesh.open(std::string(input_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - Hex20_Hex20_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_0.e")); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex20_hex20_cube1x1x")+toString(p_size)+std::string("_1.e")); - } - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a serendepity hex20 mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex20_hex20_1_2) - { - fixture_setup(); - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex20_hex20_1_2 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex20_hex20_0.e"); - - Hex20_Hex20_8 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - save_or_diff(eMesh, output_files_loc+"hex20_hex20_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - //breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex20_hex20_1.e"); - - - // end_demo - } - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quadratic hex27 mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex27_hex27_0) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_uniformRefiner_hex27_hex27_0 - - int scalarDimension = 0; // a scalar - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - std::string gmesh_spec = std::string("1x1x")+toString(p_size)+std::string("|bbox:0,0,0,1,1,"+toString(p_size) ); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("-orig.e")); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(input_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_0.e")); - } - - - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - eMesh.open(std::string(input_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_0.e")); - - Hex27_Hex27_8 break_hex_to_hex(eMesh); - - //stk_classic::mesh::FieldBase* proc_rank_field = eMesh.get_field("proc_rank"); - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info(); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - // FIXME - breaker.setIgnoreSideSets(true); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, std::string(output_files_loc+"")+std::string("hex27_hex27_cube1x1x")+toString(p_size)+std::string("_1.e")); - } - - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a quadratic hex27 mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, hex8_hex27_hex27_1) - { - fixture_setup(); - EXCEPTWATCH; - - // start_demo_uniformRefiner_hex8_hex27_hex27_1 - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - if (p_size == 1 || p_size == 3) - { - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex_fixture.e"); - - Hex8_Hex27_1 break_hex_to_hex(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - eMesh.print_info(); - save_or_diff(eMesh, output_files_loc+"hex8_hex27_0.e"); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, input_files_loc+"hex8_hex27_1.e"); - } - - { - percept::PerceptMesh eMesh(3u); - - eMesh.open(input_files_loc+"hex8_hex27_1.e"); - - Hex27_Hex27_8 break_hex_to_hex(eMesh); - - //stk_classic::mesh::FieldBase* proc_rank_field = eMesh.get_field("proc_rank"); - int scalarDimension = 0; - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_hex_to_hex, proc_rank_field); - //FIXME breaker.setIgnoreSideSets(false); - breaker.setRemoveOldElements(true); - - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"hex8_hex27_hex27_1.e"); - - } - - // end_demo - } - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine a linear wedge mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, wedge6_2) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_unit1_uniformRefiner_wedge6_2 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string(input_files_loc+"swept-wedge_0.e") ); - - eMesh.open(input_files_loc+"swept-wedge_0.e"); - - Wedge6_Wedge6_8 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"swept-wedge_1.e"); - - } - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear wedge mesh to serendepity Wedge15 - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, wedge6_enrich_1) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_unit1_uniformRefiner_wedge6_enrich_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string(input_files_loc+"swept-wedge_enrich_0.e") ); - - eMesh.open(input_files_loc+"swept-wedge_enrich_0.e"); - - Wedge6_Wedge15_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"swept-wedge_enrich_1.e"); - save_or_diff(eMesh, input_files_loc+"swept-wedge_enrich_refine_0.e"); - - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a linear wedge mesh to serendepity Wedge15 then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, wedge6_enrich_refine) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_unit1_uniformRefiner_wedge6_enrich_refine - - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - - if (p_size == 1) - { - PerceptMesh eMesh(3u); - percept::WedgeFixture wedgeFixture; - - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 2, 2, - 0, 1, - 0, 1, - 0, 1, - std::string(input_files_loc+"tmp-swept-wedge_enrich_0.e") ); - - eMesh.open(input_files_loc+"tmp-swept-wedge_enrich_0.e"); - - Wedge6_Wedge15_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh.commit(); - UniformRefiner breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - save_or_diff(eMesh, input_files_loc+"swept-wedge_2_enrich_refine_0.e"); - } - - percept::PerceptMesh eMesh(3u); - - if (p_size == 1) - { - eMesh.open(input_files_loc+"swept-wedge_2_enrich_refine_0.e"); - - Wedge15_Wedge15_8 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - UniformRefiner breaker(eMesh, break_wedge, proc_rank_field); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh, output_files_loc+"swept-wedge_2_enrich_refine_1.e"); - - } - // end_demo - - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Generate a heterogeneous mesh (tet, hex, wedge elements) then refine it - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, heterogeneous_mesh) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::HeterogeneousFixture mesh(MPI_COMM_WORLD, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_hex ); - stk_classic::io::put_io_part_attribute( mesh.m_block_wedge ); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - stk_classic::io::put_io_part_attribute( mesh.m_block_pyramid ); - stk_classic::io::put_io_part_attribute( mesh.m_block_quad_shell ); - stk_classic::io::put_io_part_attribute( mesh.m_block_tri_shell ); -#endif - - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("heterogeneous", 4); - - save_or_diff(em1, input_files_loc+"heterogeneous_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"heterogeneous_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_0.e"); - - URP_Heterogeneous_3D break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UniformRefiner breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - RefinementInfoByType::printTable(std::cout, breaker.getRefinementInfoByType(), 0, true ); - RefinementInfoByType::printTable(std::cout, breaker.getRefinementInfoByType(), 0, false ); - - save_or_diff(eMesh1, output_files_loc+"heterogeneous_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a heterogeneous mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, heterogeneous_mesh_enrich) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_mesh_enrich - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD); - - if (p_size <= 1) - { - // create the mesh - { - stk_classic::percept::HeterogeneousFixture mesh(MPI_COMM_WORLD, false); - stk_classic::io::put_io_part_attribute( mesh.m_block_hex ); - stk_classic::io::put_io_part_attribute( mesh.m_block_wedge ); - stk_classic::io::put_io_part_attribute( mesh.m_block_tet ); - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - stk_classic::io::put_io_part_attribute( mesh.m_block_pyramid ); - stk_classic::io::put_io_part_attribute( mesh.m_block_quad_shell ); - stk_classic::io::put_io_part_attribute( mesh.m_block_tri_shell ); -#endif - - mesh.m_metaData.commit(); - mesh.populate(); - - bool isCommitted = true; - percept::PerceptMesh em1(&mesh.m_metaData, &mesh.m_bulkData, isCommitted); - - //em1.print_info("hetero_enrich", 4); - - - save_or_diff(em1, input_files_loc+"heterogeneous_enrich_0.e"); - em1.close(); - } - - std::string input_mesh = input_files_loc+"heterogeneous_enrich_0.e"; - if (p_size > 1) - { - RunEnvironment::doLoadBalance(pm, input_mesh); - } - - // enrich the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_enrich_0.e"); - //eMesh1.print_info("hetero_enrich_2", 4); - - URP_Heterogeneous_Enrich_3D break_pattern(eMesh1); - //int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = 0; //eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - eMesh1.commit(); - //eMesh1.print_info("hetero_enrich_2", 4); - - UniformRefiner breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh1, output_files_loc+"heterogeneous_enrich_1.e"); - save_or_diff(eMesh1, input_files_loc+"heterogeneous_quadratic_refine_0.e"); - eMesh1.close(); - } - } - // end_demo - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Refine the enriched heterogeneous mesh - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, heterogeneous_quadratic_refine) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // start_demo_heterogeneous_quadratic_refine - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - if (p_size <= 1) - { - // refine the mesh - if (1) - { - percept::PerceptMesh eMesh1(3); - - eMesh1.open(input_files_loc+"heterogeneous_quadratic_refine_0.e"); - - URP_Heterogeneous_QuadraticRefine_3D break_pattern(eMesh1); - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh1.add_field("proc_rank", eMesh1.element_rank(), scalarDimension); - eMesh1.commit(); - - UniformRefiner breaker(eMesh1, break_pattern, proc_rank_field); - - //breaker.setRemoveOldElements(false); - breaker.setIgnoreSideSets(true); - breaker.doBreak(); - - save_or_diff(eMesh1, output_files_loc+"heterogeneous_quadratic_refine_1.e"); - eMesh1.close(); - } - } - // end_demo - } - - //here - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - - /// Enrich a wedge6 mesh to wedge18 - - STKUNIT_UNIT_TEST(unit1_uniformRefiner, wedge6_wedge18_enrich) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_unit1_uniformRefiner_wedge6_wedge18_enrich - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(pm); - - - //unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - // void createMesh(stk_classic::ParallelMachine parallel_machine, - // unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - // double xmin, double xmax, - // double ymin, double ymax, - // double zmin, double zmax, - // std::string output_filename - // ) - percept::WedgeFixture wedgeFixture; - - mesh::BulkData *bulk = - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("")); - //std::string("swept-wedge6_18_enrich_0.e") ); - - percept::PerceptMesh eMesh(wedgeFixture.getMetaData(), bulk, false); - //percept::PerceptMesh eMesh; - //eMesh.open("swept-wedge6_18_enrich_0.e"); - - Wedge6_Wedge18_1 break_wedge(eMesh); - - int scalarDimension = 0; // a scalar - stk_classic::mesh::FieldBase* proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - //eMesh.print_info(); - - wedgeFixture.createBulkAfterMetaCommit(MPI_COMM_WORLD); - - UniformRefiner breaker(eMesh, break_wedge, proc_rank_field); - breaker.doBreak(); - - } - // end_demo - } - - -#endif - - } // namespace unit_tests - } // namespace adapt -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_adapt/unit_tests/generated_refinement_tables.hpp b/packages/stk/stk_classic/stk_adapt/unit_tests/generated_refinement_tables.hpp deleted file mode 100644 index f1241e8630b1..000000000000 --- a/packages/stk/stk_classic/stk_adapt/unit_tests/generated_refinement_tables.hpp +++ /dev/null @@ -1,617 +0,0 @@ -#ifndef STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP -#define STK_ADAPT_GENERATED_REFINEMENT_TABLES_HPP -/** New ref topo info -* ------------------ -* -* {Ord, Rnk-assoc, Ord-rnk-assoc, Ord-node-on-subcell, num-rnk-assoc, param-coord} -* -* struct RefinementTopologyExtraEntry -* { -* unsigned ordinal_of_node; // ordinal of node in the total list of nodes - corresponds to the shards node ordinal -* unsigned rank_of_subcell; // rank of the subcell this node is associated with -* unsigned ordinal_of_subcell; // ordinal of the subcell in the shards numbering (e.g. edge # 3) -* unsigned ordinal_of_node_on_subcell; // ordinal of the node on the subcell (whcih node it is on a subcell that has multiple nodes) -* unsigned num_nodes_on_subcell; // how many nodes exist on the subcell -* double parametric_coordinates[3]; -* }; -* -* Bootstrapping this file: to create this file, run the regression test RegressionTestUniformRefiner.cpp :: generate_tables after putting in -* a dummy entry in ./sierra_element/GeneratedRefinementTable.hpp. The run will produce a local file, generated_refinement_tables.hpp -* which can be checked against the gold copy of GeneratedRefinementTable.hpp, then copied over it. Add a call below to generate the -* actual new table data. -*/ - - - - template<> RefTopoX RefinementTopologyExtra< shards:: Line<2> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 1, 0, 0, 1, {0, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Beam<2> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 3, 0, 0, 1, {0, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellLine<2> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 1, 0, 0, 1, {0, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellLine<3> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 1, 0, 2, 3, {0, 0, 0} }, -{ 3, 1, 0, 0, 3, {-0.5, 0, 0} }, -{ 4, 1, 0, 1, 3, {0.5, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<4> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, 0} }, -{ 1, 0, 1, 0, 1, {1, -1, 0} }, -{ 2, 0, 2, 0, 1, {1, 1, 0} }, -{ 3, 0, 3, 0, 1, {-1, 1, 0} }, -{ 4, 1, 0, 0, 1, {0, -1, 0} }, -{ 5, 1, 1, 0, 1, {1, 0, 0} }, -{ 6, 1, 2, 0, 1, {0, 1, 0} }, -{ 7, 1, 3, 0, 1, {-1, 0, 0} }, -{ 8, 2, 0, 0, 1, {0, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Triangle<3> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 1, 0, 0, 1, {0.5, 0, 0} }, -{ 4, 1, 1, 0, 1, {0.5, 0.5, 0} }, -{ 5, 1, 2, 0, 1, {0, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellTriangle<3> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 1, 0, 0, 1, {0.5, 0, 0} }, -{ 4, 1, 1, 0, 1, {0.5, 0.5, 0} }, -{ 5, 1, 2, 0, 1, {0, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellTriangle<6> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 1, 0, 2, 3, {0.5, 0, 0} }, -{ 4, 1, 1, 2, 3, {0.5, 0.5, 0} }, -{ 5, 1, 2, 2, 3, {0, 0.5, 0} }, -{ 6, 1, 0, 0, 3, {0.25, 0, 0} }, -{ 7, 1, 0, 1, 3, {0.75, 0, 0} }, -{ 8, 1, 1, 0, 3, {0.75, 0.25, 0} }, -{ 9, 1, 1, 1, 3, {0.25, 0.75, 0} }, -{ 10, 1, 2, 0, 3, {0, 0.75, 0} }, -{ 11, 1, 2, 1, 3, {0, 0.25, 0} }, -{ 12, 2, 0, 0, 3, {0.25, 0.25, 0} }, -{ 13, 2, 0, 1, 3, {0.5, 0.25, 0} }, -{ 14, 2, 0, 2, 3, {0.25, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellQuadrilateral<4> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, 0} }, -{ 1, 0, 1, 0, 1, {1, -1, 0} }, -{ 2, 0, 2, 0, 1, {1, 1, 0} }, -{ 3, 0, 3, 0, 1, {-1, 1, 0} }, -{ 4, 1, 0, 0, 1, {0, -1, 0} }, -{ 5, 1, 1, 0, 1, {1, 0, 0} }, -{ 6, 1, 2, 0, 1, {0, 1, 0} }, -{ 7, 1, 3, 0, 1, {-1, 0, 0} }, -{ 8, 2, 0, 0, 1, {0, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: ShellQuadrilateral<8> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, 0} }, -{ 1, 0, 1, 0, 1, {1, -1, 0} }, -{ 2, 0, 2, 0, 1, {1, 1, 0} }, -{ 3, 0, 3, 0, 1, {-1, 1, 0} }, -{ 4, 1, 0, 2, 3, {0, -1, 0} }, -{ 5, 1, 1, 2, 3, {1, 0, 0} }, -{ 6, 1, 2, 2, 3, {0, 1, 0} }, -{ 7, 1, 3, 2, 3, {-1, 0, 0} }, -{ 8, 2, 0, 8, 9, {0, 0, 0} }, -{ 9, 1, 0, 0, 3, {-0.5, -1, 0} }, -{ 10, 1, 0, 1, 3, {0.5, -1, 0} }, -{ 11, 1, 1, 0, 3, {1, -0.5, 0} }, -{ 12, 1, 1, 1, 3, {1, 0.5, 0} }, -{ 13, 1, 2, 0, 3, {0.5, 1, 0} }, -{ 14, 1, 2, 1, 3, {-0.5, 1, 0} }, -{ 15, 1, 3, 0, 3, {-1, 0.5, 0} }, -{ 16, 1, 3, 1, 3, {-1, -0.5, 0} }, -{ 17, 2, 0, 4, 9, {0, -0.5, 0} }, -{ 18, 2, 0, 5, 9, {0.5, 0, 0} }, -{ 19, 2, 0, 6, 9, {0, 0.5, 0} }, -{ 20, 2, 0, 7, 9, {-0.5, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Tetrahedron<4> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 0, 3, 0, 1, {0, 0, 1} }, -{ 4, 1, 0, 0, 1, {0.5, 0, 0} }, -{ 5, 1, 1, 0, 1, {0.5, 0.5, 0} }, -{ 6, 1, 2, 0, 1, {0, 0.5, 0} }, -{ 7, 1, 3, 0, 1, {0, 0, 0.5} }, -{ 8, 1, 4, 0, 1, {0.5, 0, 0.5} }, -{ 9, 1, 5, 0, 1, {0, 0.5, 0.5} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<8> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, -1} }, -{ 1, 0, 1, 0, 1, {1, -1, -1} }, -{ 2, 0, 2, 0, 1, {1, 1, -1} }, -{ 3, 0, 3, 0, 1, {-1, 1, -1} }, -{ 4, 0, 4, 0, 1, {-1, -1, 1} }, -{ 5, 0, 5, 0, 1, {1, -1, 1} }, -{ 6, 0, 6, 0, 1, {1, 1, 1} }, -{ 7, 0, 7, 0, 1, {-1, 1, 1} }, -{ 8, 1, 0, 0, 1, {0, -1, -1} }, -{ 9, 1, 1, 0, 1, {1, 0, -1} }, -{ 10, 1, 2, 0, 1, {0, 1, -1} }, -{ 11, 1, 3, 0, 1, {-1, 0, -1} }, -{ 12, 1, 8, 0, 1, {-1, -1, 0} }, -{ 13, 1, 9, 0, 1, {1, -1, 0} }, -{ 14, 1, 10, 0, 1, {1, 1, 0} }, -{ 15, 1, 11, 0, 1, {-1, 1, 0} }, -{ 16, 1, 4, 0, 1, {0, -1, 1} }, -{ 17, 1, 5, 0, 1, {1, 0, 1} }, -{ 18, 1, 6, 0, 1, {0, 1, 1} }, -{ 19, 1, 7, 0, 1, {-1, 0, 1} }, -{ 20, 3, 0, 0, 1, {0, 0, 0} }, -{ 21, 2, 4, 0, 1, {0, 0, -1} }, -{ 22, 2, 5, 0, 1, {0, 0, 1} }, -{ 23, 2, 3, 0, 1, {-1, 0, 0} }, -{ 24, 2, 1, 0, 1, {1, 0, 0} }, -{ 25, 2, 0, 0, 1, {0, -1, 0} }, -{ 26, 2, 2, 0, 1, {0, 1, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<6> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, -1} }, -{ 1, 0, 1, 0, 1, {1, 0, -1} }, -{ 2, 0, 2, 0, 1, {0, 1, -1} }, -{ 3, 0, 3, 0, 1, {0, 0, 1} }, -{ 4, 0, 4, 0, 1, {1, 0, 1} }, -{ 5, 0, 5, 0, 1, {0, 1, 1} }, -{ 6, 1, 0, 0, 1, {0.5, 0, -1} }, -{ 7, 1, 1, 0, 1, {0.5, 0.5, -1} }, -{ 8, 1, 2, 0, 1, {0, 0.5, -1} }, -{ 9, 1, 6, 0, 1, {0, 0, 0} }, -{ 10, 1, 7, 0, 1, {1, 0, 0} }, -{ 11, 1, 8, 0, 1, {0, 1, 0} }, -{ 12, 1, 3, 0, 1, {0.5, 0, 1} }, -{ 13, 1, 4, 0, 1, {0.5, 0.5, 1} }, -{ 14, 1, 5, 0, 1, {0, 0.5, 1} }, -{ 15, 2, 0, 0, 1, {0.5, 0, 0} }, -{ 16, 2, 1, 0, 1, {0.5, 0.5, 0} }, -{ 17, 2, 2, 0, 1, {0, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Wedge<15> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, -1} }, -{ 1, 0, 1, 0, 1, {1, 0, -1} }, -{ 2, 0, 2, 0, 1, {0, 1, -1} }, -{ 3, 0, 3, 0, 1, {0, 0, 1} }, -{ 4, 0, 4, 0, 1, {1, 0, 1} }, -{ 5, 0, 5, 0, 1, {0, 1, 1} }, -{ 6, 1, 0, 2, 3, {0.5, 0, -1} }, -{ 7, 1, 1, 2, 3, {0.5, 0.5, -1} }, -{ 8, 1, 2, 2, 3, {0, 0.5, -1} }, -{ 9, 1, 6, 2, 3, {0, 0, 0} }, -{ 10, 1, 7, 2, 3, {1, 0, 0} }, -{ 11, 1, 8, 2, 3, {0, 1, 0} }, -{ 12, 1, 3, 2, 3, {0.5, 0, 1} }, -{ 13, 1, 4, 2, 3, {0.5, 0.5, 1} }, -{ 14, 1, 5, 2, 3, {0, 0.5, 1} }, -{ 15, 2, 0, 0, 5, {0.5, 0, 0} }, -{ 16, 2, 1, 0, 5, {0.5, 0.5, 0} }, -{ 17, 2, 2, 0, 5, {0, 0.5, 0} }, -{ 18, 1, 0, 0, 3, {0.25, 0, -1} }, -{ 19, 1, 0, 1, 3, {0.75, 0, -1} }, -{ 20, 1, 1, 0, 3, {0.75, 0.25, -1} }, -{ 21, 1, 1, 1, 3, {0.25, 0.75, -1} }, -{ 22, 1, 2, 0, 3, {0, 0.75, -1} }, -{ 23, 1, 2, 1, 3, {0, 0.25, -1} }, -{ 24, 2, 0, 4, 5, {0.25, 0, 0} }, -{ 25, 2, 0, 2, 5, {0.75, 0, 0} }, -{ 26, 2, 1, 4, 5, {0.75, 0.25, 0} }, -{ 27, 2, 1, 2, 5, {0.25, 0.75, 0} }, -{ 28, 2, 2, 3, 5, {0, 0.75, 0} }, -{ 29, 2, 2, 1, 5, {0, 0.25, 0} }, -{ 30, 1, 3, 0, 3, {0.25, 0, 1} }, -{ 31, 1, 3, 1, 3, {0.75, 0, 1} }, -{ 32, 1, 4, 0, 3, {0.75, 0.25, 1} }, -{ 33, 1, 4, 1, 3, {0.25, 0.75, 1} }, -{ 34, 1, 5, 0, 3, {0, 0.75, 1} }, -{ 35, 1, 5, 1, 3, {0, 0.25, 1} }, -{ 36, 2, 3, 1, 3, {0.25, 0.5, -1} }, -{ 37, 2, 3, 0, 3, {0.25, 0.25, -1} }, -{ 38, 2, 3, 2, 3, {0.5, 0.25, -1} }, -{ 39, 3, 0, 0, 3, {0.25, 0.5, 0} }, -{ 40, 3, 0, 1, 3, {0.25, 0.25, 0} }, -{ 41, 3, 0, 2, 3, {0.5, 0.25, 0} }, -{ 42, 2, 4, 2, 3, {0.25, 0.5, 1} }, -{ 43, 2, 4, 0, 3, {0.25, 0.25, 1} }, -{ 44, 2, 4, 1, 3, {0.5, 0.25, 1} }, -{ 45, 1, 6, 0, 3, {0, 0, -0.5} }, -{ 46, 2, 0, 1, 5, {0.5, 0, -0.5} }, -{ 47, 1, 7, 0, 3, {1, 0, -0.5} }, -{ 48, 2, 1, 1, 5, {0.5, 0.5, -0.5} }, -{ 49, 1, 8, 0, 3, {0, 1, -0.5} }, -{ 50, 2, 2, 4, 5, {0, 0.5, -0.5} }, -{ 51, 1, 6, 1, 3, {0, 0, 0.5} }, -{ 52, 2, 0, 3, 5, {0.5, 0, 0.5} }, -{ 53, 1, 7, 1, 3, {1, 0, 0.5} }, -{ 54, 2, 1, 3, 5, {0.5, 0.5, 0.5} }, -{ 55, 1, 8, 1, 3, {0, 1, 0.5} }, -{ 56, 2, 2, 2, 5, {0, 0.5, 0.5} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Line<3> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 1, 0, 2, 3, {0, 0, 0} }, -{ 3, 1, 0, 0, 3, {-0.5, 0, 0} }, -{ 4, 1, 0, 1, 3, {0.5, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Beam<3> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 3, 0, 2, 3, {0, 0, 0} }, -{ 3, 3, 0, 0, 3, {-0.5, 0, 0} }, -{ 4, 3, 0, 1, 3, {0.5, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Triangle<6> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 1, 0, 2, 3, {0.5, 0, 0} }, -{ 4, 1, 1, 2, 3, {0.5, 0.5, 0} }, -{ 5, 1, 2, 2, 3, {0, 0.5, 0} }, -{ 6, 1, 0, 0, 3, {0.25, 0, 0} }, -{ 7, 1, 0, 1, 3, {0.75, 0, 0} }, -{ 8, 1, 1, 0, 3, {0.75, 0.25, 0} }, -{ 9, 1, 1, 1, 3, {0.25, 0.75, 0} }, -{ 10, 1, 2, 0, 3, {0, 0.75, 0} }, -{ 11, 1, 2, 1, 3, {0, 0.25, 0} }, -{ 12, 2, 0, 0, 3, {0.25, 0.25, 0} }, -{ 13, 2, 0, 1, 3, {0.5, 0.25, 0} }, -{ 14, 2, 0, 2, 3, {0.25, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<8> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, 0} }, -{ 1, 0, 1, 0, 1, {1, -1, 0} }, -{ 2, 0, 2, 0, 1, {1, 1, 0} }, -{ 3, 0, 3, 0, 1, {-1, 1, 0} }, -{ 4, 1, 0, 2, 3, {0, -1, 0} }, -{ 5, 1, 1, 2, 3, {1, 0, 0} }, -{ 6, 1, 2, 2, 3, {0, 1, 0} }, -{ 7, 1, 3, 2, 3, {-1, 0, 0} }, -{ 8, 2, 0, 8, 9, {0, 0, 0} }, -{ 9, 1, 0, 0, 3, {-0.5, -1, 0} }, -{ 10, 1, 0, 1, 3, {0.5, -1, 0} }, -{ 11, 1, 1, 0, 3, {1, -0.5, 0} }, -{ 12, 1, 1, 1, 3, {1, 0.5, 0} }, -{ 13, 1, 2, 0, 3, {0.5, 1, 0} }, -{ 14, 1, 2, 1, 3, {-0.5, 1, 0} }, -{ 15, 1, 3, 0, 3, {-1, 0.5, 0} }, -{ 16, 1, 3, 1, 3, {-1, -0.5, 0} }, -{ 17, 2, 0, 4, 9, {0, -0.5, 0} }, -{ 18, 2, 0, 5, 9, {0.5, 0, 0} }, -{ 19, 2, 0, 6, 9, {0, 0.5, 0} }, -{ 20, 2, 0, 7, 9, {-0.5, 0, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Quadrilateral<9> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, 0} }, -{ 1, 0, 1, 0, 1, {1, -1, 0} }, -{ 2, 0, 2, 0, 1, {1, 1, 0} }, -{ 3, 0, 3, 0, 1, {-1, 1, 0} }, -{ 4, 1, 0, 2, 3, {0, -1, 0} }, -{ 5, 1, 1, 2, 3, {1, 0, 0} }, -{ 6, 1, 2, 2, 3, {0, 1, 0} }, -{ 7, 1, 3, 2, 3, {-1, 0, 0} }, -{ 8, 2, 0, 8, 9, {0, 0, 0} }, -{ 9, 1, 0, 0, 3, {-0.5, -1, 0} }, -{ 10, 1, 0, 1, 3, {0.5, -1, 0} }, -{ 11, 1, 1, 0, 3, {1, -0.5, 0} }, -{ 12, 1, 1, 1, 3, {1, 0.5, 0} }, -{ 13, 1, 2, 0, 3, {0.5, 1, 0} }, -{ 14, 1, 2, 1, 3, {-0.5, 1, 0} }, -{ 15, 1, 3, 0, 3, {-1, 0.5, 0} }, -{ 16, 1, 3, 1, 3, {-1, -0.5, 0} }, -{ 17, 2, 0, 4, 9, {0, -0.5, 0} }, -{ 18, 2, 0, 5, 9, {0.5, 0, 0} }, -{ 19, 2, 0, 6, 9, {0, 0.5, 0} }, -{ 20, 2, 0, 7, 9, {-0.5, 0, 0} }, -{ 21, 2, 0, 0, 9, {-0.5, -0.5, 0} }, -{ 22, 2, 0, 1, 9, {0.5, -0.5, 0} }, -{ 23, 2, 0, 2, 9, {0.5, 0.5, 0} }, -{ 24, 2, 0, 3, 9, {-0.5, 0.5, 0} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<27> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, -1} }, -{ 1, 0, 1, 0, 1, {1, -1, -1} }, -{ 2, 0, 2, 0, 1, {1, 1, -1} }, -{ 3, 0, 3, 0, 1, {-1, 1, -1} }, -{ 4, 0, 4, 0, 1, {-1, -1, 1} }, -{ 5, 0, 5, 0, 1, {1, -1, 1} }, -{ 6, 0, 6, 0, 1, {1, 1, 1} }, -{ 7, 0, 7, 0, 1, {-1, 1, 1} }, -{ 8, 1, 0, 2, 3, {0, -1, -1} }, -{ 9, 1, 1, 2, 3, {1, 0, -1} }, -{ 10, 1, 2, 2, 3, {0, 1, -1} }, -{ 11, 1, 3, 2, 3, {-1, 0, -1} }, -{ 12, 1, 8, 2, 3, {-1, -1, 0} }, -{ 13, 1, 9, 2, 3, {1, -1, 0} }, -{ 14, 1, 10, 2, 3, {1, 1, 0} }, -{ 15, 1, 11, 2, 3, {-1, 1, 0} }, -{ 16, 1, 4, 2, 3, {0, -1, 1} }, -{ 17, 1, 5, 2, 3, {1, 0, 1} }, -{ 18, 1, 6, 2, 3, {0, 1, 1} }, -{ 19, 1, 7, 2, 3, {-1, 0, 1} }, -{ 20, 3, 0, 0, 27, {0, 0, 0} }, -{ 21, 2, 4, 8, 9, {0, 0, -1} }, -{ 22, 2, 5, 8, 9, {0, 0, 1} }, -{ 23, 2, 3, 8, 9, {-1, 0, 0} }, -{ 24, 2, 1, 8, 9, {1, 0, 0} }, -{ 25, 2, 0, 8, 9, {0, -1, 0} }, -{ 26, 2, 2, 8, 9, {0, 1, 0} }, -{ 27, 1, 0, 0, 3, {-0.5, -1, -1} }, -{ 28, 1, 0, 1, 3, {0.5, -1, -1} }, -{ 29, 1, 1, 0, 3, {1, -0.5, -1} }, -{ 30, 1, 1, 1, 3, {1, 0.5, -1} }, -{ 31, 1, 2, 0, 3, {0.5, 1, -1} }, -{ 32, 1, 2, 1, 3, {-0.5, 1, -1} }, -{ 33, 1, 3, 0, 3, {-1, 0.5, -1} }, -{ 34, 1, 3, 1, 3, {-1, -0.5, -1} }, -{ 35, 1, 8, 0, 3, {-1, -1, -0.5} }, -{ 36, 1, 9, 0, 3, {1, -1, -0.5} }, -{ 37, 1, 10, 0, 3, {1, 1, -0.5} }, -{ 38, 1, 11, 0, 3, {-1, 1, -0.5} }, -{ 39, 1, 8, 1, 3, {-1, -1, 0.5} }, -{ 40, 1, 9, 1, 3, {1, -1, 0.5} }, -{ 41, 1, 10, 1, 3, {1, 1, 0.5} }, -{ 42, 1, 11, 1, 3, {-1, 1, 0.5} }, -{ 43, 1, 4, 0, 3, {-0.5, -1, 1} }, -{ 44, 1, 4, 1, 3, {0.5, -1, 1} }, -{ 45, 1, 5, 0, 3, {1, -0.5, 1} }, -{ 46, 1, 5, 1, 3, {1, 0.5, 1} }, -{ 47, 1, 6, 0, 3, {0.5, 1, 1} }, -{ 48, 1, 6, 1, 3, {-0.5, 1, 1} }, -{ 49, 1, 7, 0, 3, {-1, 0.5, 1} }, -{ 50, 1, 7, 1, 3, {-1, -0.5, 1} }, -{ 51, 2, 0, 7, 9, {-0.5, -1, 0} }, -{ 52, 2, 0, 5, 9, {0.5, -1, 0} }, -{ 53, 2, 1, 7, 9, {1, -0.5, 0} }, -{ 54, 2, 1, 5, 9, {1, 0.5, 0} }, -{ 55, 2, 2, 7, 9, {0.5, 1, 0} }, -{ 56, 2, 2, 5, 9, {-0.5, 1, 0} }, -{ 57, 2, 3, 6, 9, {-1, 0.5, 0} }, -{ 58, 2, 3, 4, 9, {-1, -0.5, 0} }, -{ 59, 2, 0, 4, 9, {0, -1, -0.5} }, -{ 60, 2, 4, 7, 9, {0, -0.5, -1} }, -{ 61, 2, 4, 5, 9, {0, 0.5, -1} }, -{ 62, 2, 2, 4, 9, {0, 1, -0.5} }, -{ 63, 2, 2, 6, 9, {0, 1, 0.5} }, -{ 64, 2, 5, 6, 9, {0, 0.5, 1} }, -{ 65, 2, 5, 4, 9, {0, -0.5, 1} }, -{ 66, 2, 0, 6, 9, {0, -1, 0.5} }, -{ 67, 2, 4, 4, 9, {-0.5, 0, -1} }, -{ 68, 2, 4, 6, 9, {0.5, 0, -1} }, -{ 69, 2, 1, 4, 9, {1, 0, -0.5} }, -{ 70, 2, 1, 6, 9, {1, 0, 0.5} }, -{ 71, 2, 5, 5, 9, {0.5, 0, 1} }, -{ 72, 2, 5, 7, 9, {-0.5, 0, 1} }, -{ 73, 2, 3, 5, 9, {-1, 0, 0.5} }, -{ 74, 2, 3, 7, 9, {-1, 0, -0.5} }, -{ 75, 3, 0, 1, 27, {0, -0.5, 0} }, -{ 76, 3, 0, 2, 27, {0, 0.5, 0} }, -{ 77, 3, 0, 3, 27, {-0.5, 0, 0} }, -{ 78, 3, 0, 4, 27, {0.5, 0, 0} }, -{ 79, 3, 0, 5, 27, {0, 0, -0.5} }, -{ 80, 3, 0, 6, 27, {0, 0, 0.5} }, -{ 81, 3, 0, 7, 27, {0, 0, 0} }, -{ 82, 3, 0, 8, 27, {0, 0, 0} }, -{ 83, 3, 0, 9, 27, {0, 0, 0} }, -{ 84, 3, 0, 10, 27, {0, 0, 0} }, -{ 85, 3, 0, 11, 27, {0, 0, 0} }, -{ 86, 3, 0, 12, 27, {0, 0, 0} }, -{ 87, 3, 0, 13, 27, {0, 0, 0} }, -{ 88, 3, 0, 14, 27, {0, 0, 0} }, -{ 89, 2, 4, 0, 9, {-0.5, -0.5, -1} }, -{ 90, 2, 4, 1, 9, {-0.5, 0.5, -1} }, -{ 91, 2, 4, 2, 9, {0.5, 0.5, -1} }, -{ 92, 2, 4, 3, 9, {0.5, -0.5, -1} }, -{ 93, 2, 5, 0, 9, {-0.5, -0.5, 1} }, -{ 94, 2, 5, 1, 9, {0.5, -0.5, 1} }, -{ 95, 2, 5, 2, 9, {0.5, 0.5, 1} }, -{ 96, 2, 5, 3, 9, {-0.5, 0.5, 1} }, -{ 97, 2, 3, 0, 9, {-1, -0.5, -0.5} }, -{ 98, 2, 3, 1, 9, {-1, -0.5, 0.5} }, -{ 99, 2, 3, 2, 9, {-1, 0.5, 0.5} }, -{ 100, 2, 3, 3, 9, {-1, 0.5, -0.5} }, -{ 101, 2, 1, 0, 9, {1, -0.5, -0.5} }, -{ 102, 2, 1, 1, 9, {1, 0.5, -0.5} }, -{ 103, 2, 1, 2, 9, {1, 0.5, 0.5} }, -{ 104, 2, 1, 3, 9, {1, -0.5, 0.5} }, -{ 105, 2, 0, 0, 9, {-0.5, -1, -0.5} }, -{ 106, 2, 0, 1, 9, {0.5, -1, -0.5} }, -{ 107, 2, 0, 2, 9, {0.5, -1, 0.5} }, -{ 108, 2, 0, 3, 9, {-0.5, -1, 0.5} }, -{ 109, 2, 2, 0, 9, {0.5, 1, -0.5} }, -{ 110, 2, 2, 1, 9, {-0.5, 1, -0.5} }, -{ 111, 2, 2, 2, 9, {-0.5, 1, 0.5} }, -{ 112, 2, 2, 3, 9, {0.5, 1, 0.5} }, -{ 113, 3, 0, 15, 27, {0, -0.5, -0.5} }, -{ 114, 3, 0, 16, 27, {0, 0.5, -0.5} }, -{ 115, 3, 0, 17, 27, {0, 0.5, 0.5} }, -{ 116, 3, 0, 18, 27, {0, -0.5, 0.5} }, -{ 117, 3, 0, 19, 27, {-0.5, -0.5, 0} }, -{ 118, 3, 0, 20, 27, {0.5, -0.5, 0} }, -{ 119, 3, 0, 21, 27, {0.5, 0.5, 0} }, -{ 120, 3, 0, 22, 27, {-0.5, 0.5, 0} }, -{ 121, 3, 0, 23, 27, {-0.5, 0, -0.5} }, -{ 122, 3, 0, 24, 27, {0.5, 0, -0.5} }, -{ 123, 3, 0, 25, 27, {0.5, 0, 0.5} }, -{ 124, 3, 0, 26, 27, {-0.5, 0, 0.5} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Hexahedron<20> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {-1, -1, -1} }, -{ 1, 0, 1, 0, 1, {1, -1, -1} }, -{ 2, 0, 2, 0, 1, {1, 1, -1} }, -{ 3, 0, 3, 0, 1, {-1, 1, -1} }, -{ 4, 0, 4, 0, 1, {-1, -1, 1} }, -{ 5, 0, 5, 0, 1, {1, -1, 1} }, -{ 6, 0, 6, 0, 1, {1, 1, 1} }, -{ 7, 0, 7, 0, 1, {-1, 1, 1} }, -{ 8, 1, 0, 2, 3, {0, -1, -1} }, -{ 9, 1, 1, 2, 3, {1, 0, -1} }, -{ 10, 1, 2, 2, 3, {0, 1, -1} }, -{ 11, 1, 3, 2, 3, {-1, 0, -1} }, -{ 12, 1, 8, 2, 3, {-1, -1, 0} }, -{ 13, 1, 9, 2, 3, {1, -1, 0} }, -{ 14, 1, 10, 2, 3, {1, 1, 0} }, -{ 15, 1, 11, 2, 3, {-1, 1, 0} }, -{ 16, 1, 4, 2, 3, {0, -1, 1} }, -{ 17, 1, 5, 2, 3, {1, 0, 1} }, -{ 18, 1, 6, 2, 3, {0, 1, 1} }, -{ 19, 1, 7, 2, 3, {-1, 0, 1} }, -{ 20, 3, 0, 0, 7, {0, 0, 0} }, -{ 21, 2, 4, 8, 9, {0, 0, -1} }, -{ 22, 2, 5, 8, 9, {0, 0, 1} }, -{ 23, 2, 3, 8, 9, {-1, 0, 0} }, -{ 24, 2, 1, 8, 9, {1, 0, 0} }, -{ 25, 2, 0, 8, 9, {0, -1, 0} }, -{ 26, 2, 2, 8, 9, {0, 1, 0} }, -{ 27, 1, 0, 0, 3, {-0.5, -1, -1} }, -{ 28, 1, 0, 1, 3, {0.5, -1, -1} }, -{ 29, 1, 1, 0, 3, {1, -0.5, -1} }, -{ 30, 1, 1, 1, 3, {1, 0.5, -1} }, -{ 31, 1, 2, 0, 3, {0.5, 1, -1} }, -{ 32, 1, 2, 1, 3, {-0.5, 1, -1} }, -{ 33, 1, 3, 0, 3, {-1, 0.5, -1} }, -{ 34, 1, 3, 1, 3, {-1, -0.5, -1} }, -{ 35, 1, 8, 0, 3, {-1, -1, -0.5} }, -{ 36, 1, 9, 0, 3, {1, -1, -0.5} }, -{ 37, 1, 10, 0, 3, {1, 1, -0.5} }, -{ 38, 1, 11, 0, 3, {-1, 1, -0.5} }, -{ 39, 1, 8, 1, 3, {-1, -1, 0.5} }, -{ 40, 1, 9, 1, 3, {1, -1, 0.5} }, -{ 41, 1, 10, 1, 3, {1, 1, 0.5} }, -{ 42, 1, 11, 1, 3, {-1, 1, 0.5} }, -{ 43, 1, 4, 0, 3, {-0.5, -1, 1} }, -{ 44, 1, 4, 1, 3, {0.5, -1, 1} }, -{ 45, 1, 5, 0, 3, {1, -0.5, 1} }, -{ 46, 1, 5, 1, 3, {1, 0.5, 1} }, -{ 47, 1, 6, 0, 3, {0.5, 1, 1} }, -{ 48, 1, 6, 1, 3, {-0.5, 1, 1} }, -{ 49, 1, 7, 0, 3, {-1, 0.5, 1} }, -{ 50, 1, 7, 1, 3, {-1, -0.5, 1} }, -{ 51, 2, 0, 7, 9, {-0.5, -1, 0} }, -{ 52, 2, 0, 5, 9, {0.5, -1, 0} }, -{ 53, 2, 1, 7, 9, {1, -0.5, 0} }, -{ 54, 2, 1, 5, 9, {1, 0.5, 0} }, -{ 55, 2, 2, 7, 9, {0.5, 1, 0} }, -{ 56, 2, 2, 5, 9, {-0.5, 1, 0} }, -{ 57, 2, 3, 6, 9, {-1, 0.5, 0} }, -{ 58, 2, 3, 4, 9, {-1, -0.5, 0} }, -{ 59, 2, 0, 4, 9, {0, -1, -0.5} }, -{ 60, 2, 4, 7, 9, {0, -0.5, -1} }, -{ 61, 2, 4, 5, 9, {0, 0.5, -1} }, -{ 62, 2, 2, 4, 9, {0, 1, -0.5} }, -{ 63, 2, 2, 6, 9, {0, 1, 0.5} }, -{ 64, 2, 5, 6, 9, {0, 0.5, 1} }, -{ 65, 2, 5, 4, 9, {0, -0.5, 1} }, -{ 66, 2, 0, 6, 9, {0, -1, 0.5} }, -{ 67, 2, 4, 4, 9, {-0.5, 0, -1} }, -{ 68, 2, 4, 6, 9, {0.5, 0, -1} }, -{ 69, 2, 1, 4, 9, {1, 0, -0.5} }, -{ 70, 2, 1, 6, 9, {1, 0, 0.5} }, -{ 71, 2, 5, 5, 9, {0.5, 0, 1} }, -{ 72, 2, 5, 7, 9, {-0.5, 0, 1} }, -{ 73, 2, 3, 5, 9, {-1, 0, 0.5} }, -{ 74, 2, 3, 7, 9, {-1, 0, -0.5} }, -{ 75, 3, 0, 1, 7, {0, -0.5, 0} }, -{ 76, 3, 0, 2, 7, {0, 0.5, 0} }, -{ 77, 3, 0, 3, 7, {-0.5, 0, 0} }, -{ 78, 3, 0, 4, 7, {0.5, 0, 0} }, -{ 79, 3, 0, 5, 7, {0, 0, -0.5} }, -{ 80, 3, 0, 6, 7, {0, 0, 0.5} } - -}; - - template<> RefTopoX RefinementTopologyExtra< shards:: Tetrahedron<10> > :: refinement_topology = { -{ 0, 0, 0, 0, 1, {0, 0, 0} }, -{ 1, 0, 1, 0, 1, {1, 0, 0} }, -{ 2, 0, 2, 0, 1, {0, 1, 0} }, -{ 3, 0, 3, 0, 1, {0, 0, 1} }, -{ 4, 1, 0, 2, 3, {0.5, 0, 0} }, -{ 5, 1, 1, 2, 3, {0.5, 0.5, 0} }, -{ 6, 1, 2, 2, 3, {0, 0.5, 0} }, -{ 7, 1, 3, 2, 3, {0, 0, 0.5} }, -{ 8, 1, 4, 2, 3, {0.5, 0, 0.5} }, -{ 9, 1, 5, 2, 3, {0, 0.5, 0.5} }, -{ 10, 1, 0, 0, 3, {0.25, 0, 0} }, -{ 11, 1, 0, 1, 3, {0.75, 0, 0} }, -{ 12, 1, 1, 0, 3, {0.75, 0.25, 0} }, -{ 13, 1, 1, 1, 3, {0.25, 0.75, 0} }, -{ 14, 1, 2, 0, 3, {0, 0.75, 0} }, -{ 15, 1, 2, 1, 3, {0, 0.25, 0} }, -{ 16, 1, 3, 0, 3, {0, 0, 0.25} }, -{ 17, 1, 4, 0, 3, {0.75, 0, 0.25} }, -{ 18, 1, 5, 0, 3, {0, 0.75, 0.25} }, -{ 19, 1, 3, 1, 3, {0, 0, 0.75} }, -{ 20, 1, 4, 1, 3, {0.25, 0, 0.75} }, -{ 21, 1, 5, 1, 3, {0, 0.25, 0.75} }, -{ 22, 3, 0, 0, 1, {0.25, 0.25, 0.25} }, -{ 23, 2, 0, 2, 3, {0.25, 0, 0.5} }, -{ 24, 2, 3, 1, 3, {0.25, 0.5, 0} }, -{ 25, 2, 2, 0, 3, {0, 0.25, 0.25} }, -{ 26, 2, 1, 0, 3, {0.5, 0.25, 0.25} }, -{ 27, 2, 0, 0, 3, {0.25, 0, 0.25} }, -{ 28, 2, 1, 1, 3, {0.25, 0.5, 0.25} }, -{ 29, 2, 2, 1, 3, {0, 0.25, 0.5} }, -{ 30, 2, 3, 2, 3, {0.5, 0.25, 0} }, -{ 31, 2, 3, 0, 3, {0.25, 0.25, 0} }, -{ 32, 2, 1, 2, 3, {0.25, 0.25, 0.5} }, -{ 33, 2, 2, 2, 3, {0, 0.5, 0.25} }, -{ 34, 2, 0, 1, 3, {0.5, 0, 0.25} } - -}; -#endif diff --git a/packages/stk/stk_classic/stk_algsup/CMakeLists.txt b/packages/stk/stk_classic/stk_algsup/CMakeLists.txt deleted file mode 100644 index 846ae14ab7a3..000000000000 --- a/packages/stk/stk_classic/stk_algsup/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -ADD_SUBDIRECTORY(stk_algsup) - -TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - diff --git a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile b/packages/stk/stk_classic/stk_algsup/doc/Doxyfile deleted file mode 100644 index 1ab92af52e16..000000000000 --- a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile +++ /dev/null @@ -1,33 +0,0 @@ -@INCLUDE = Doxyfile.options - -# -# Package options -# -PROJECT_NAME = "Sierra Toolkit Algorithm Support" -OUTPUT_DIRECTORY = ../.. - -# -# What and how documentation is extracted -# -@INCLUDE = Doxyfile.input - -FILE_PATTERNS = *.dox *.hpp *.h - -IMAGE_PATH = -# EXAMPLE_PATH = ../example -EXCLUDE = -EXAMPLE_PATTERNS = -INPUT_FILTER = -ALPHABETICAL_INDEX = YES -IGNORE_PREFIX = -RECURSIVE = YES -# -# Links to other packages -# -ALLEXTERNALS = YES -EXTERNAL_GROUPS = YES - -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 - -GENERATE_TAGFILE = ./tags diff --git a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.input b/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.input deleted file mode 100644 index 675e175533f2..000000000000 --- a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.input +++ /dev/null @@ -1,5 +0,0 @@ -#BANNER @copydoc stk_algsup_banner -#HOWTO @copydoc stk_algsup_howto - -INPUT += ../stk_algsup/doc/index.dox \ - ../stk_algsup/stk_algsup diff --git a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.options b/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.options deleted file mode 100755 index 91cfa7f49a28..000000000000 --- a/packages/stk/stk_classic/stk_algsup/doc/Doxyfile.options +++ /dev/null @@ -1,81 +0,0 @@ -# -# Package options -# -OUTPUT_LANGUAGE = English -PROJECT_NUMBER = "Version of the Day" -# -# What and how documentation is extracted -# -SUBGROUPING = YES -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -DETAILS_AT_TOP = YES -#DETAILS_AT_TOP = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -SHOW_DIRECTORIES = YES -INTERNAL_DOCS = NO -CLASS_DIAGRAMS = YES -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = YES -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = NO -TAB_SIZE = 2 -ENABLED_SECTIONS = -ENUM_VALUES_PER_LINE = 4 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = "$file:$line: $text" -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 4 -# -# What diagrams are created -# -CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -#UML_LOOK = YES -TEMPLATE_RELATIONS = YES -#TEMPLATE_RELATIONS = NO -#MAX_DOT_GRAPH_WIDTH = 500 -HIDE_UNDOC_RELATIONS = YES -# -# Preprocessing -# -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_FILE_PATTERNS = -PREDEFINED += DOXYGEN_COMPILE STK_HAS_MPI -# -# What kind of documentation is generated -# -GENERATE_HTMLHELP = NO -DISABLE_INDEX = NO -GENERATE_LATEX = NO -GENERATE_RTF = NO -GENERATE_MAN = NO -GENERATE_XML = NO -SEARCHENGINE = YES diff --git a/packages/stk/stk_classic/stk_algsup/doc/index.dox b/packages/stk/stk_classic/stk_algsup/doc/index.dox deleted file mode 100644 index 36616af33f6b..000000000000 --- a/packages/stk/stk_classic/stk_algsup/doc/index.dox +++ /dev/null @@ -1,73 +0,0 @@ -/** - * \page stk_algsup_banner Sierra Toolkit Algorithm Support - * - * \ref stk_algsup_module "Sierra Toolkit Algorithm Support" - * - * The Sierra Toolkit Algorithm Support product provides... - * - * \addtogroup stk_algsup_module Sierra Toolkit Algorithm Support Product - * - * The Sierra Toolkit Algorithm Support product provides... - * - * \code - * #include - * #include - * \endcode - * - * where directory is one of the following: - * - *
    - *
  • \ref stk_algsup_diagnostics_module "diag" - * - * functions and classes that support diagnostic output - * - *
- * - * Algorithm Support How To ... - * - * \copydoc stk_algsup_howto - * - * \page stk_algsup_howto Algorithm Support How To ... - * - * Sierra Tookit Algorithm Support - * - * - Thread Support - * - \ref stk_algsup_thread_howto_create "Create Thread Algorithms"
- * - CUDA Support - * - \ref stk_algsup_cuda_howto_create "Create Cuda Algorithms"
- * - * \defgroup stk_algsup_module_detail Sierra Toolkit Algorithm Support - * @{ - * - * \defgroup stk_algsup_module Coarse Algorithm Support - * - * The coarse algorithm support module... - * - * blah blah lah - * - * @{ - * \defgroup stk_algsup_detail Command Line Options - * \defgroup - * @} - * - * \defgroup stk_algsup_diagnostics_module Algorithm Support Diagnostics - * @{ - * \defgroup stk_algsup_diag_detail Diagnostics available for algorithm support - * \defgroup - * @} - * - * \defgroup stk_algsup_thread_module Thread - * @{ - * \defgroup stk_algsup_thread_detail Thread - * \defgroup - * @} - * - * \defgroup stk_algsup_cuda_module Cuda - * @{ - * \defgroup stk_algsup_cuda_detail Cuda - * \defgroup - * @} - * - * @} - */ - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunSimple.hpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunSimple.hpp deleted file mode 100644 index dc6a22e5f8b5..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunSimple.hpp +++ /dev/null @@ -1,440 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_algsup_AlgorithmRunSimple_hpp -#define stk_algsup_AlgorithmRunSimple_hpp - -#include - -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -/** \ingroup stk_mesh_module - * \brief Field with defined data type and multi-dimensions (if any) - * \todo REFACTOR This convenience class is not appropriately named. - */ -template< class F, class R > -class GatherField - : public Field::data_type *, R> -{ -#ifndef DOXYGEN_COMPILE - - public: - typedef Field::data_type *, R> PtrField; - - typedef F RelatedField; - typedef R Relation; - - private: - - ~GatherField(); - GatherField(); - GatherField( const GatherField & ); - GatherField & operator = ( const GatherField & ); - -#endif /* DOXYGEN_COMPILE */ -}; -} // namespace mesh - -struct AlgField -{ - virtual ~AlgField() - {} - - virtual void set(const stk_classic::mesh::Bucket &bucket) = 0; -}; - - -typedef std::vector AlgFieldVector; - - -class Algorithm -{ -public: - Algorithm(stk_classic::mesh::MetaData &meta_data) - : m_metaData(meta_data) - {} - - virtual ~Algorithm() - {} - - void add_field(AlgField *field) { - m_fieldVector.push_back(field); - } - - virtual void apply( const AlgorithmWork & ) = 0 ; - -// static void number_cruncher(.....); - - -// void run(const stk_classic::mesh::Bucket& bucket, int begin, int end ) { -// run(bucket, begin, end); -// } - -public: - const stk_classic::mesh::MetaData & m_metaData; - -private: - AlgFieldVector m_fieldVector; -}; - - -template -struct AlgFieldPtr : public AlgField -{ - typedef typename stk_classic::mesh::FieldTraits::data_type Scalar; - - AlgFieldPtr(Algorithm *algorithm, const char *name) - : m_field(*algorithm->m_metaData.get_field(name)) - { - algorithm->add_field(this); - } - - AlgFieldPtr(Algorithm *algorithm, const char *name, stk_classic::mesh::FieldState field_state) - : m_field(algorithm->m_metaData.get_field(name)->field_of_state(field_state)) - { - algorithm->add_field(this); - } - - AlgFieldPtr(Algorithm *algorithm, T &field) - : m_field(field) - { - algorithm->add_field(this); - } - - AlgFieldPtr(Algorithm *algorithm, T &field, stk_classic::mesh::FieldState field_state) - : m_field(field.field_of_state(field_state)) - { - algorithm->add_field(this); - } - - virtual ~AlgFieldPtr() - {} - - virtual void set(const stk_classic::mesh::Bucket &bucket) { - m_ptr = stk_classic::mesh::field_data(m_field, bucket.begin()); - } - - T & m_field; - Scalar * m_ptr; -}; - - -template< class ArrayType > -struct ToArrayVector -{}; - - -template< typename Scalar , shards::ArrayOrder Order , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7> -struct ToArrayVector< shards::Array > -{ - typedef shards::ArrayVector ArrayVectorType; -}; - - -template -struct DimTagInfo; - - -template <> -struct DimTagInfo -{ - static unsigned value(const stk_classic::mesh::Bucket &bucket) { - return 3; - } -}; - - -template <> -struct DimTagInfo -{ - static unsigned value(const stk_classic::mesh::Bucket &bucket) { - return 0; - } -}; - - -template -class AlgFieldGather; - - -template< typename Scalar , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7, class Relation> -struct AlgFieldGather< stk_classic::mesh::GatherField , Relation> > : public AlgField -{ - typedef stk_classic::mesh::Field T; - typedef typename stk_classic::mesh::GatherField, Relation>::PtrField PtrField; - typedef typename ToArrayVector, Relation>::type, stk_classic::mesh::EntityDimension >::type>::ArrayVectorType ScratchArray; - - AlgFieldGather(Algorithm *algorithm, const char *name) - : m_field(*algorithm->m_metaData.get_field(name)), - m_array() - { - algorithm->add_field(this); - } - - AlgFieldGather(Algorithm *algorithm, const char *name, stk_classic::mesh::FieldState field_state) - : m_field(algorithm->m_metaData.get_field(name)->field_of_state(field_state)), - m_array() - { - algorithm->add_field(this); - } - -// AlgFieldGather(Algorithm *algorithm, T &field) -// : m_field(field), -// m_array() -// { -// algorithm->add_field(this); -// } - -// AlgFieldGather(Algorithm *algorithm, T &field, stk_classic::mesh::FieldState field_state) -// : m_field(field.field_of_state(field_state)), -// m_array() -// { -// algorithm->add_field(this); -// } - - virtual ~AlgFieldGather() - {} - - virtual void set(const stk_classic::mesh::Bucket &bucket) { - m_begin = stk_classic::mesh::field_data(m_field, bucket.begin()); - m_end = stk_classic::mesh::field_data(m_field, bucket.end()); - - unsigned dims[8]; - dims[0] = DimTagInfo::value(bucket); - dims[1] = DimTagInfo::value(bucket); - dims[2] = DimTagInfo::value(bucket); - dims[3] = DimTagInfo::value(bucket); - dims[4] = DimTagInfo::value(bucket); - dims[5] = DimTagInfo::value(bucket); - dims[6] = DimTagInfo::value(bucket); - dims[7] = 0; - - stk_classic::mesh::BucketArray gather_array(m_field, bucket); - - dims[stk_classic::mesh::FieldTraits::Rank] = gather_array.dimension(0); - dims[stk_classic::mesh::FieldTraits::Rank + 1] = gather_array.dimension(1); - - m_array.resize(&dims[0]); - m_size = 1; - for (int i = 0; i < ScratchArray::Rank - 2; ++i) - m_size *= m_array.dimension(i); - - m_ptr = m_array.contiguous_data(); - } - - void fill(const Scalar &value) { - Scalar *d = m_ptr; - for (Scalar **p = m_begin; p != m_end; ++p) - for (Scalar *q = *p; q != *p + m_size; ++q) - *d++ = value; - } - - void gather() { - Scalar *d = m_ptr; - for (Scalar **p = m_begin; p != m_end; ++p) - for (Scalar *q = *p; q != *p + m_size; ++q) - *d++ = *q; - } - - void scatter() - { - Scalar *d = m_ptr; - for (Scalar **p = m_begin; p != m_end; ++p) - for (Scalar *q = *p; q != *p + m_size; ++q) - *q = *d++; - } - - void assemble() - { - Scalar *d = m_ptr; - for (Scalar **p = m_begin; p != m_end; ++p) - for (Scalar *q = *p; q != *p + m_size; ++q) - *q += *d++; - } - - PtrField & m_field; - Scalar ** m_begin; - Scalar ** m_end; - Scalar * m_ptr; - unsigned m_size; - ScratchArray m_array; -}; - - -template -class AlgFieldX; - - -template< typename Scalar , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7, class Relation> -struct AlgFieldX< stk_classic::mesh::GatherField , Relation> > : public AlgField -{ - typedef stk_classic::mesh::Field T; - typedef typename stk_classic::mesh::GatherField, Relation>::PtrField PtrField; - typedef typename shards::ArrayAppend< typename shards::ArrayAppend< shards::Array, Relation>::type, stk_classic::mesh::EntityDimension >::type Array; - - AlgFieldX(Algorithm *algorithm, const char *name) - : m_field(*algorithm->m_metaData.get_field(name)), - m_begin(0), - m_end(0), - m_ptr(0) - { - algorithm->add_field(this); - } - - AlgFieldX(Algorithm *algorithm, const char *name, stk_classic::mesh::FieldState field_state) - : m_field(algorithm->m_metaData.get_field(name)->field_of_state(field_state)), - m_begin(0), - m_end(0), - m_ptr(0) - { - algorithm->add_field(this); - } - -// AlgFieldX(Algorithm *algorithm, T &field) -// : m_field(field), -// m_array() -// { -// algorithm->add_field(this); -// } - -// AlgFieldX(Algorithm *algorithm, T &field, stk_classic::mesh::FieldState field_state) -// : m_field(field.field_of_state(field_state)), -// m_array() -// { -// algorithm->add_field(this); -// } - - virtual ~AlgFieldX() - {} - - virtual void set(const stk_classic::mesh::Bucket &bucket) { - m_begin = stk_classic::mesh::field_data(m_field, bucket.begin()); - m_end = stk_classic::mesh::field_data(m_field, bucket.end()); - m_ptr = m_begin; - } - -// PtrField::Array get(unsigned i) -// { -// return PtrField::Array(m_begi -// void fill(const T::Array &value) { -// std::fill(m_ptr, m_ptr + m_array.size(), value); -// } - - PtrField & m_field; - Scalar ** m_begin; - Scalar ** m_end; - Scalar ** m_ptr; -}; - - -template -struct AlgFieldArray : public AlgField, public stk_classic::mesh::BucketArray -{ - typedef stk_classic::mesh::BucketArray Array; - - AlgFieldArray(Algorithm *algorithm, const char *name) - : m_field(*algorithm->m_metaData.get_field(name)) - { - algorithm->add_field(this); - } - - AlgFieldArray(Algorithm *algorithm, const char *name, stk_classic::mesh::FieldState field_state) - : m_field(algorithm->m_metaData.get_field(name)->field_of_state(field_state)) - { - algorithm->add_field(this); - } - - AlgFieldArray(Algorithm *algorithm, T &field) - : m_field(field) - { - algorithm->add_field(this); - } - - AlgFieldArray(Algorithm *algorithm, T &field, stk_classic::mesh::FieldState field_state) - : m_field(field.field_of_state(field_state)) - { - algorithm->add_field(this); - } - - virtual void set(const stk_classic::mesh::Bucket &bucket) { - Array::setup(m_field, bucket); - } - - T & m_field; -}; - - -template -class FillFieldAlgorithm; - -template< typename Scalar , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7> -class FillFieldAlgorithm< stk_classic::mesh::Field > -{ -public: - typedef stk_classic::mesh::Field Field; - typedef shards::ArrayVector FillArray; - - FillFieldAlgorithm(Field &field, const FillArray &fill_value) - : m_field(field), - m_fillValue(), - m_value(0) - { - std::vector dims; - fill_value.dimensions(dims); - - m_fillValue.resize(&dims[0]); - std::copy(fill_value.contiguous_data(), fill_value.contiguous_data() + fill_value.size(), m_fillValue.contiguous_data()); - } - - FillFieldAlgorithm(Field &field, const Scalar &value) - : m_field(field), - m_fillValue(), - m_value(value) - {} - - enum { chunk_size = 0 }; ///< Don't slice the buckets - - void apply( const stk_classic::AlgorithmWork & work ) - { - //const stk_classic::mesh::Bucket& bucket = work.bucket ; - if (m_fillValue.size()) { - Scalar *begin_p = stk_classic::mesh::field_data(m_field, work.bucket_slice_begin); - Scalar *end_p = stk_classic::mesh::field_data(m_field, work.bucket_slice_end); - for (Scalar *p = begin_p; p != end_p; p += m_fillValue.size()) - std::copy(m_fillValue.contiguous_data(), m_fillValue.contiguous_data() + m_fillValue.size(), p); - } - else { - Scalar *begin_p = stk_classic::mesh::field_data(m_field, work.bucket_slice_begin); - Scalar *end_p = stk_classic::mesh::field_data(m_field, work.bucket_slice_end); - std::fill(begin_p, end_p, m_value); - } - } - -private: - Field & m_field; - FillArray m_fillValue; - Scalar m_value; -}; - -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.cpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.cpp deleted file mode 100644 index 9c2252c972f3..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include -#include - -namespace stk_classic { - -//---------------------------------------------------------------------- - -AlgorithmInterface::~AlgorithmInterface(){} - -//---------------------------------------------------------------------- - -void AlgorithmInterface::apply_one( - const mesh::Selector & selector , - const mesh::PartVector & union_part_vector , - const mesh::Bucket & bucket , - void * reduce ) const -{ - mesh::PartVector parts ; - - const bool run_it = selector( bucket ); - get_involved_parts( union_part_vector, bucket, parts ); - - if ( run_it ) { - if ( 0 < m_maximum_entity_count ) { - for ( mesh::Bucket::iterator j = bucket.begin(); j != bucket.end() ; ) { - mesh::Bucket::iterator e = j ; - if ( static_cast( bucket.end() - e ) < static_cast(m_maximum_entity_count) ) { - e = bucket.end(); - } - else { - e += m_maximum_entity_count ; - } - apply( j , e , parts , reduce ); - j = e ; - } - } - else { - apply( bucket.begin() , bucket.end() , parts , reduce ); - } - } -} - -//void AlgorithmInterface::apply_one( -// const mesh::Selector & selector , -// const mesh::Bucket & bucket , -// void * reduce ) const -//{ -// const mesh::PartVector empty_union_part_vector; -// apply_one(selector,empty_union_part_vector,bucket,reduce); -//} - -//---------------------------------------------------------------------- - -namespace { - -class AlgorithmRunnerNonThread : public AlgorithmRunnerInterface { -public: - - void run_alg( const mesh::Selector & selector, - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets, - const AlgorithmInterface & algorithm, - void * reduce ) const ; - - AlgorithmRunnerNonThread() {} - ~AlgorithmRunnerNonThread() {} -}; - -void AlgorithmRunnerNonThread::run_alg( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & algorithm , - void * reduce ) const -{ - for ( std::vector< mesh::Bucket * >::const_iterator - i = buckets.begin() ; i != buckets.end() ; ++i ) { - algorithm.apply_one( selector , union_parts, **i , reduce ); - } -} - -} - -//---------------------------------------------------------------------- - -AlgorithmRunnerInterface * algorithm_runner_non_thread() -{ - static AlgorithmRunnerNonThread runner ; - return & runner ; -} - -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.hpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.hpp deleted file mode 100644 index 27e62a683a55..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunner.hpp +++ /dev/null @@ -1,368 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_algsup_AlgorithmRunner_hpp -#define stk_algsup_AlgorithmRunner_hpp - -#include -#include -#include -#include - -namespace stk_classic { - -//---------------------------------------------------------------------- - -class AlgorithmInterface ; -class AlgorithmRunnerInterface ; - -//---------------------------------------------------------------------- - -/** A local-serial algorithm runner */ -AlgorithmRunnerInterface * algorithm_runner_non_thread(); - -/** A local-parallel algorithm runner using pthreads */ -AlgorithmRunnerInterface * algorithm_runner_tpi( int nthreads ); - -/** A local-parallel algorithm runner using TBB */ -AlgorithmRunnerInterface * algorithm_runner_tbb( int nthreads ); - -//---------------------------------------------------------------------- - -class AlgorithmRunnerInterface { -public: - virtual ~AlgorithmRunnerInterface() {} - - /** \brief Run an algorithm. - * - * The Algorithm class must satisfy the following interface: - * - * \code - * class Algorithm { - * public: - * maximum_entity_count ; - * void apply( mesh::Bucket::iterator i , - * mesh::Bucket::iterator j , - * const mesh::PartVector & selected_parts ) const ; - * - * }; - * \endcode - */ - template< class Algorithm > - void run_parts( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm ) const ; - - /** \brief Run an algorithm. - * - * The Algorithm class must satisfy the following interface: - * - * \code - * class Algorithm { - * public: - * maximum_entity_count ; - * void apply( mesh::Bucket::iterator i , - * mesh::Bucket::iterator j ) const ; - * - * }; - * \endcode - */ - template< class Algorithm > - void run( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm ) const ; - - /** \brief Run an algorithm with a reduction operation. - * - * The Algorithm class must satisfy the following interface: - * - * \code - * class Algorithm { - * public: - * typedef reduce_type ; - * reduce_count ; - * void init( reduce_type * out ) const ; - * void join( reduce_type * inout , const reduce_type * in ) const ; - * - * maximum_entity_count ; - * void apply( mesh::Bucket::iterator i , - * mesh::Bucket::iterator j , - * const mesh::PartVector & selected_parts , - * reduce_type * reduce_inout ) const ; - * - * }; - * \endcode - * - * The apply method is passed a pointer to - * 'reduce_type value[ reduce_count ]' - * into which it must reduce its results and - * for which it has thread-safe access. - * The join method is passed two pointers to - * reduce_type[ reduce_count ] - * values such that it must reduce the 'in' value into the 'inout' value; - * this method has thread-safe access to both 'in' and 'inout' values. - */ - template< class Algorithm > - void run_parts( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm , - typename Algorithm::reduce_type * reduce_value ) const ; - - /** \brief Run an algorithm with a reduction operation. - * - * \code - * class Algorithm { - * public: - * typedef reduce_type ; - * reduce_count ; - * void init( reduce_type * out ) const ; - * void join( reduce_type * inout , const reduce_type * in ) const ; - * - * maximum_entity_count ; - * void apply( mesh::Bucket::iterator i , - * mesh::Bucket::iterator j , - * reduce_type * reduce_inout ) const ; - * - * }; - * \endcode - */ - template< class Algorithm > - void run( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm , - typename Algorithm::reduce_type * reduce_value ) const ; - -private: - AlgorithmRunnerInterface ( const AlgorithmRunnerInterface & ); - AlgorithmRunnerInterface & operator = ( const AlgorithmRunnerInterface & ); - -protected: - - AlgorithmRunnerInterface() {} - - /** Run many buckets in thread-parallel */ - virtual void run_alg( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & algorithm , - void * reduce ) const = 0 ; -}; - -//---------------------------------------------------------------------- - -/** Interface for internal wrapper-classes, not part of public API. -*/ -class AlgorithmInterface { -public: - const size_t m_maximum_entity_count ; - const size_t m_reduce_allocation_size ; - - virtual void init( void * out ) const = 0 ; - - virtual void join( void * inout , const void * in ) const = 0 ; - - virtual void apply( mesh::Bucket::iterator i , - mesh::Bucket::iterator j , - const mesh::PartVector & selected_parts , - void * reduce_inout ) const = 0 ; - - virtual ~AlgorithmInterface(); - - //void apply_one( const mesh::Selector & selector , - // const mesh::Bucket & bucket , - // void * reduce ) const ; - - void apply_one( const mesh::Selector & selector , - const mesh::PartVector & union_part_vector , - const mesh::Bucket & bucket , - void * reduce ) const ; - -protected: - - explicit AlgorithmInterface( ) - : m_maximum_entity_count( 0 ), - m_reduce_allocation_size( 0 ) {} - - AlgorithmInterface( size_t count ) - : m_maximum_entity_count( count ), - m_reduce_allocation_size( 0 ) {} - - AlgorithmInterface( size_t count , size_t size ) - : m_maximum_entity_count( count ), - m_reduce_allocation_size( size ) {} - -private: - AlgorithmInterface( const AlgorithmInterface & ); - AlgorithmInterface & operator = ( const AlgorithmInterface & ); -}; - -//---------------------------------------------------------------------- - -namespace { - -template< class Algorithm > -class AlgorithmWrapper : public AlgorithmInterface { -private: - void init( void * ) const {} - void join( void * , const void * ) const {} -public: - const Algorithm & m_alg ; - - void apply( mesh::Bucket::iterator i , - mesh::Bucket::iterator j , - const mesh::PartVector & parts, void * reduce ) const - { m_alg.apply( i , j ); } - - explicit AlgorithmWrapper( const Algorithm & alg ) - : AlgorithmInterface( alg.maximum_entity_count ), m_alg( alg ) {} -}; - -template< class Algorithm > -class AlgorithmWrapperParts : public AlgorithmInterface { -private: - void init( void * ) const {} - void join( void * , const void * ) const {} -public: - const Algorithm & m_alg ; - - void apply( mesh::Bucket::iterator i , - mesh::Bucket::iterator j , - const mesh::PartVector & selected_parts , void * reduce ) const - { m_alg.apply( i , j , selected_parts ); } - - explicit AlgorithmWrapperParts( const Algorithm & alg ) - : AlgorithmInterface( alg.maximum_entity_count ), m_alg( alg ) {} -}; - -template< class Algorithm > -class AlgorithmWrapperReduce : public AlgorithmInterface { -public: - typedef typename Algorithm::reduce_type reduce_type ; - - const Algorithm & m_alg ; - - void init( void * reduce_out ) const - { m_alg.init( (reduce_type *) reduce_out ); } - - void join( void * reduce_inout , const void * reduce_in ) const - { - m_alg.join( (reduce_type *) reduce_inout , - (const reduce_type *) reduce_in ); - } - - void apply( mesh::Bucket::iterator i , - mesh::Bucket::iterator j , - const mesh::PartVector & parts, void * reduce_inout ) const - { - m_alg.apply( i , j , (reduce_type*) reduce_inout ); - } - - explicit AlgorithmWrapperReduce( const Algorithm & alg ) - : AlgorithmInterface( alg.maximum_entity_count , - alg.reduce_count * sizeof( reduce_type ) ), - m_alg( alg ) {} -}; - -template< class Algorithm > -class AlgorithmWrapperPartsReduce : public AlgorithmInterface { -public: - typedef typename Algorithm::reduce_type reduce_type ; - - const Algorithm & m_alg ; - - void init( void * reduce_out ) const - { - m_alg.init( (reduce_type *) reduce_out ); - } - - void join( void * reduce_inout , const void * reduce_in ) const - { - m_alg.join( (reduce_type *) reduce_inout , - (const reduce_type *) reduce_in ); - } - - void apply( mesh::Bucket::iterator i , - mesh::Bucket::iterator j , - const mesh::PartVector & selected_parts , - void * reduce_inout ) const - { - m_alg.apply( i , j , selected_parts , (reduce_type*) reduce_inout ); - } - - explicit AlgorithmWrapperPartsReduce( const Algorithm & alg ) - : AlgorithmInterface( alg.maximum_entity_count , - alg.reduce_count * sizeof(reduce_type) ), - m_alg( alg ) {} -}; - -} - -template< class Algorithm > -inline -void AlgorithmRunnerInterface::run( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm , - typename Algorithm::reduce_type * reduce ) const -{ - const AlgorithmWrapperReduce wrap( algorithm ); - - run_alg( selector , union_parts, buckets , wrap , reduce ); -} - -template< class Algorithm > -inline -void AlgorithmRunnerInterface::run_parts( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm , - typename Algorithm::reduce_type * reduce ) const -{ - const AlgorithmWrapperPartsReduce wrap( algorithm ); - - run_alg( selector , union_parts, buckets , wrap , reduce ); -} - -template< class Algorithm > -inline -void AlgorithmRunnerInterface::run( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm ) const -{ - const AlgorithmWrapper wrap( algorithm ); - - run_alg( selector , union_parts, buckets , wrap , NULL ); -} - -template< class Algorithm > -inline -void AlgorithmRunnerInterface::run_parts( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const Algorithm & algorithm ) const -{ - const AlgorithmWrapperParts wrap( algorithm ); - - run_alg( selector , union_parts, buckets , wrap , NULL ); -} - -//---------------------------------------------------------------------- - -} //namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTBB.cpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTBB.cpp deleted file mode 100644 index b5d8eb797288..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTBB.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#ifdef STK_HAVE_TBB - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace { - -//---------------------------------------------------------------------- - -struct RunTBB { - const mesh::Selector & selector ; - const mesh::PartVector & union_parts ; - const std::vector & buckets ; - const AlgorithmInterface & alg ; - - void operator()(const tbb::blocked_range& r) const; - - RunTBB( const mesh::Selector & arg_selector , - const mesh::PartVector & arg_union_parts , - const std::vector & arg_buckets , - const AlgorithmInterface & arg_alg ); - - ~RunTBB(); -}; - -RunTBB::RunTBB( - const mesh::Selector & arg_selector , - const mesh::PartVector & arg_union_parts , - const std::vector & arg_buckets , - const AlgorithmInterface & arg_alg ) - : selector( arg_selector ), - union_parts( arg_union_parts ), - buckets( arg_buckets ), - alg( arg_alg ) -{} - -RunTBB::~RunTBB() -{ -} - -void RunTBB::operator()( const tbb::blocked_range & r ) const -{ - for ( int i = r.begin() ; i < r.end() ; ++i ) { - alg.apply_one( selector , union_parts , * buckets[i] , NULL ); - } -} - -struct RunTBBreduce { - const mesh::Selector & selector ; - const mesh::PartVector & union_parts ; - const std::vector & buckets ; - const AlgorithmInterface & alg ; - void * reduce ; - - void operator()(const tbb::blocked_range& r); - - void join( const RunTBBreduce & rhs ) const ; - - RunTBBreduce( const RunTBBreduce & rhs , tbb::split ); - - RunTBBreduce( const mesh::Selector & arg_selector , - const mesh::PartVector & arg_union_parts , - const std::vector & arg_buckets , - const AlgorithmInterface & arg_alg , - void * arg_reduce = NULL ); - - ~RunTBBreduce(); -}; - -RunTBBreduce::RunTBBreduce( const RunTBBreduce & rhs , tbb::split ) - : selector( rhs.selector ), - union_parts( rhs.union_parts ), - buckets( rhs.buckets ), - alg( rhs.alg ), - reduce( NULL ) -{ - if ( rhs.reduce ) { - reduce = malloc( alg.m_reduce_allocation_size ); //scalable_malloc ? - alg.init( reduce ); - } -} - -RunTBBreduce::~RunTBBreduce() -{ - if ( reduce ) { free( reduce ); /* scalable_free ? */} -} - -void RunTBBreduce::join( const RunTBBreduce & rhs ) const -{ - alg.join( reduce , rhs.reduce ); -} - -void RunTBBreduce::operator()( const tbb::blocked_range & r ) -{ - for ( int i = r.begin() ; i < r.end() ; ++i ) { - alg.apply_one( selector , union_parts, * buckets[i] , reduce ); - } -} - -RunTBBreduce::RunTBBreduce( - const mesh::Selector & arg_selector , - const mesh::PartVector & arg_union_parts , - const std::vector & arg_buckets , - const AlgorithmInterface & arg_alg , - void * arg_reduce ) - : selector( arg_selector ), - union_parts( arg_union_parts ), - buckets( arg_buckets ), - alg( arg_alg ), - reduce( arg_reduce ) -{} - -//---------------------------------------------------------------------- - -class AlgorithmRunnerTBB : public AlgorithmRunnerInterface { -public: - AlgorithmRunnerTBB(int nthreads) - : tbb_task_init_(NULL) - { - tbb_task_init_ = new tbb::task_scheduler_init(nthreads); - } - - ~AlgorithmRunnerTBB() - { - delete tbb_task_init_; - } - - void run_alg( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & alg , - void * reduce ) const ; - -private: - tbb::task_scheduler_init* tbb_task_init_; -}; - -void AlgorithmRunnerTBB::run_alg( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & alg , - void * reduce ) const -{ - static tbb::affinity_partitioner ap; - - if ( reduce && ! alg.m_reduce_allocation_size ) { - std::string msg("AlgorithmRunnerTBB: ERROR reduce value with zero size"); - throw std::invalid_argument(msg); - } - - if ( ! buckets.empty() ) { - - tbb::blocked_range range( 0 , buckets.size() ); - - if ( reduce ) { - RunTBBreduce tmp( selector , union_parts , buckets , alg, reduce ); - - tbb::parallel_reduce( range , tmp , ap ); - tmp.reduce = NULL ; /* Prevent the tbb::scalable_free( tmp.reduce ); */ - } - else { - RunTBB tmp( selector , union_parts , buckets , alg ); - - tbb::parallel_for( range, tmp , ap); - } - } -} - -} // namespace - -AlgorithmRunnerInterface * algorithm_runner_tbb( int nthreads ) -{ - static AlgorithmRunnerTBB runner(nthreads) ; - - return & runner ; -} - -} // namespace stk_classic - -#else - -namespace stk_classic { - -AlgorithmRunnerInterface * algorithm_runner_tbb( int nthreads ) -{ - return NULL ; -} - -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTPI.cpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTPI.cpp deleted file mode 100644 index 150225fa93b0..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/AlgorithmRunnerTPI.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - - - -#include - -#ifdef STK_HAVE_TPI - -#include - -#include - -#include -#include -#include - -namespace stk_classic { -namespace { - -//---------------------------------------------------------------------- - -struct RunTPI { - const mesh::Selector & selector ; - const mesh::PartVector & union_parts ; - const std::vector & buckets ; - const AlgorithmInterface & alg ; - - RunTPI( const mesh::Selector & arg_selector , - const mesh::PartVector & arg_union_parts , - const std::vector & arg_buckets , - const AlgorithmInterface & arg_alg ) - : selector( arg_selector ), - union_parts(arg_union_parts), - buckets( arg_buckets ), - alg( arg_alg ) - {} - - ~RunTPI() - {} -}; - -extern "C" { - -static void RunTPI_join( TPI_Work * work , const void * reduce ) -{ - const RunTPI & myself = * ((const RunTPI *) work->info ); - - myself.alg.join( work->reduce , reduce ); -} - -static void RunTPI_init( TPI_Work * work ) -{ - const RunTPI & myself = * ((const RunTPI *) work->info ); - - myself.alg.init( work->reduce ); -} - -static void RunTPI_apply( TPI_Work * work ) -{ - const RunTPI & myself = * ((const RunTPI *) work->info ); - - myself.alg.apply_one( myself.selector , - myself.union_parts , - * myself.buckets[ work->rank ] , - work->reduce - ); -} - -} - -class AlgorithmRunnerTPI : public AlgorithmRunnerInterface { -public: - - void run_alg( const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & alg , - void * reduce ) const ; - - AlgorithmRunnerTPI( int nthreads ) : result( 0 <= TPI_Init( nthreads ) ) {} - - const bool result ; -}; - -void AlgorithmRunnerTPI::run_alg( - const mesh::Selector & selector , - const mesh::PartVector & union_parts , - const std::vector< mesh::Bucket * > & buckets , - const AlgorithmInterface & alg , - void * reduce ) const -{ - if ( reduce && ! alg.m_reduce_allocation_size ) { - std::string msg("AlgorithmRunnerTPI: ERROR reduce value with zero size"); - throw std::invalid_argument(msg); - } - - if ( ! buckets.empty() ) { - - RunTPI tmp( selector, union_parts, buckets , alg ); - - if ( reduce ) { - TPI_Run_reduce( RunTPI_apply , & tmp , - buckets.size() , - RunTPI_join , - RunTPI_init , - alg.m_reduce_allocation_size , - reduce ); - } - else { - TPI_Run( RunTPI_apply , & tmp , buckets.size() , 0 ); - } - } -} - -} // namespace - -//---------------------------------------------------------------------- - -AlgorithmRunnerInterface * algorithm_runner_tpi( int nthreads ) -{ - static AlgorithmRunnerTPI runner( nthreads ); - - return runner.result ? & runner : NULL ; -} - -} // namespace stk_classic - -#else - -namespace stk_classic { - -AlgorithmRunnerInterface * algorithm_runner_tpi( int nthreads ) -{ - return NULL ; -} - -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/CMakeLists.txt b/packages/stk/stk_classic/stk_algsup/stk_algsup/CMakeLists.txt deleted file mode 100644 index e4b45031e854..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ - - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -# -# Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_algsup - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_base - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_algsup/) - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaCall.hpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaCall.hpp deleted file mode 100644 index ed44fea6972d..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaCall.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_algsup_CudaCall_hpp -#define stk_algsup_CudaCall_hpp - -#ifdef STK_HAVE_CUDA - -#include -#include - -//---------------------------------------------------------------- -inline -void stk_cuda_call(cudaError err , const char* name ) -{ - if ( err != cudaSuccess ) { - fprintf(stderr, "%s error: %s\n",name, cudaGetErrorString(err) ); - exit(-1); - } -} - -#define CUDA_CALL( cuda_fn ) stk_cuda_call( cuda_fn , #cuda_fn ) - -#endif - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaDeviceMgr.cpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaDeviceMgr.cpp deleted file mode 100644 index e3d641d3f067..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaDeviceMgr.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#ifdef STK_HAVE_CUDA - -#include - -namespace stk_classic { - -CudaDeviceMgr& CudaDeviceMgr::get_singleton() -{ - static CudaDeviceMgr cuda_device_mgr; - return cuda_device_mgr; -} - -CudaDeviceMgr::CudaDeviceMgr(int device) - : m_device(device) -{ - int deviceCount = 0; - cudaGetDeviceCount(&deviceCount); - if (deviceCount < 1) { - std::cout << "CudaDeviceMgr: no devices detected." << std::endl; - //what should we do here? Abort? Throw? Continue? - } - - if (m_device >= deviceCount) { - std::cout << "CudaDeviceMgr: specified device not valid, using device 0." << std::endl; - m_device = 0; - } - - //for now: if a cuda device is already in use, just use that one. In future we may - //want to allow for using multiple different devices... - - int deviceAlreadyBeingUsed = -1; - cudaGetDevice( &deviceAlreadyBeingUsed ); - if (deviceAlreadyBeingUsed >= 0 && deviceAlreadyBeingUsed < deviceCount) { - m_device = deviceAlreadyBeingUsed; - } - else { - cudaSetDevice(m_device); - } - - cudaDeviceProp deviceProp; - - cudaGetDeviceProperties(&deviceProp, m_device); - - //TODO: make this output only occur in debug mode or verbose mode, or something: - std::cout << "\nCudaDeviceMgr attached to device #"< - -namespace stk_classic { - -class CudaDeviceMgr { - public: - CudaDeviceMgr(int device=0); - - virtual ~CudaDeviceMgr() {} - - int get_device() const { return m_device; } - - static CudaDeviceMgr& get_singleton(); - - private: - int m_device; -};//class CudaMemoryMgr - -}//namespace stk_classic - -#endif - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.cpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.cpp deleted file mode 100644 index 5d301c88c228..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -namespace stk_classic { - -#ifdef STK_HAVE_CUDA - -CudaMemoryMgr& get_singleton() -{ - static CudaMemoryMgr cuda_memory_mgr; - return cuda_memory_mgr; -} - -#endif - -CudaMemoryMgr::~CudaMemoryMgr() -{ -#ifdef STK_HAVE_CUDA - std::map::iterator - iter = device_to_host_map.begin(), - iter_end = device_to_host_map.end(); - - for(; iter!=iter_end; ++iter) { - //cast away const so we can free the pointer: - void* dev_ptr = const_cast(iter->first); - CUDA_CALL( cudaFree(dev_ptr) ); - } -#endif -} - -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.hpp b/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.hpp deleted file mode 100644 index 4c926e1d00e1..000000000000 --- a/packages/stk/stk_classic/stk_algsup/stk_algsup/CudaMemoryMgr.hpp +++ /dev/null @@ -1,188 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_algsup_CudaMemoryMgr_hpp -#define stk_algsup_CudaMemoryMgr_hpp - -#include -#include -#include - -#include - -namespace stk_classic { - -/** Helper class for managing CUDA device memory. - * - * Tracks persistent mappings between host(cpu) buffers and CUDA device - * buffers, intended to be used for mapping bucket/field data pointers on - * the host to buffers on the device. - * This allows algorithm/bucket loops to repeatedly reference pointers to - * field data without performing the device allocation every time. - * - * This class also allows for creating and using device buffers that - * are not mapped to host buffers. - */ -class CudaMemoryMgr { - public: - /** Constructor */ - CudaMemoryMgr() - : host_to_device_map(), - device_to_host_map() - {} - - /** Destructor - * Upon destruction this class de-allocates all device-buffers that - * it was tracking. - */ - virtual ~CudaMemoryMgr(); - -#ifdef STK_HAVE_CUDA - - /** Return a device-pointer corresponding to the given host-ptr and size. - * The returned device-pointer points to a buffer which has been allocated - * on the CUDA device with length buf_size*sizeof(T), but not initialized. - * - * If a device-pointer has already been allocated for the given host-pointer - * (by a previous call to this method) then that (previously-allocated) device-pointer - * is returned. - */ - template - T* get_buffer(const T* host_ptr, size_t buf_size); - - /** Return a device-pointer allocated with the given size. - * The returned device-pointer points to a buffer which has been allocated - * on the CUDA device with length buf_size*sizeof(T), but not initialized. - */ - template - T* get_buffer(size_t buf_size); - - /** Destroy (free) the specified device-pointer. - * - * De-allocates the cuda-device buffer. - */ - template - void destroy_buffer(T*& device_ptr); - - /** Copy the contents of the given host-ptr to the given device-ptr. - * If the given device-ptr is not known (was not created by a previous - * call to get_buffer), an exception is thrown. - */ - template - void copy_to_buffer(const T* host_ptr, size_t buf_size, T* device_ptr); - - /** Copy the contents of the given device-ptr to the given host-ptr. - * If the given device-ptr is not known (was not created by a previous - * call to get_buffer), an exception is thrown. - */ - template - void copy_from_buffer(T* host_ptr, size_t buf_size, const T* device_ptr); - - static CudaMemoryMgr& get_singleton(); - -#endif - - private: - std::map host_to_device_map; - std::map device_to_host_map; -};//class CudaMemoryMgr - -#ifdef STK_HAVE_CUDA - -//------------------------------------------------------------------------------ -template -inline -T* CudaMemoryMgr::get_buffer(const T* host_ptr, size_t buf_size) -{ - T* device_ptr = NULL; - - std::map::iterator iter = host_to_device_map.find(host_ptr); - - if (iter == host_to_device_map.end()) { - void* void_device_ptr = NULL; - CUDA_CALL( cudaMalloc( &void_device_ptr, sizeof(T)*buf_size) ); - device_ptr = reinterpret_cast(void_device_ptr); - - host_to_device_map.insert( std::make_pair(host_ptr, device_ptr) ); - device_to_host_map.insert( std::make_pair(device_ptr, host_ptr) ); - } - else { - device_ptr = reinterpret_cast(iter->second); - } - - return device_ptr; -} - -//------------------------------------------------------------------------------ -template -inline -T* CudaMemoryMgr::get_buffer(size_t buf_size) -{ - T* device_ptr = NULL; - - CUDA_CALL( cudaMalloc( (void**)&device_ptr, sizeof(T)*buf_size) ); - - device_to_host_map.insert( std::make_pair(device_ptr, NULL) ); - - return device_ptr; -} - -//------------------------------------------------------------------------------ -template -inline -void CudaMemoryMgr::destroy_buffer(T*& device_ptr) -{ - std::map::iterator iter = device_to_host_map.find(device_ptr); - if (iter != device_to_host_map.end()) { - const void* host_ptr = iter->second; - if (host_ptr != NULL) { - std::map::iterator iter2 = host_to_device_map.find(host_ptr); - if (iter2 != host_to_device_map.end()) { - host_to_device_map.erase(iter2); - } - } - CUDA_CALL( cudaFree(device_ptr) ); - device_ptr = NULL; - device_to_host_map.erase(iter); - } -} - -//------------------------------------------------------------------------------ -template -inline -void CudaMemoryMgr::copy_to_buffer(const T* host_ptr, size_t buf_size, T* device_ptr) -{ - std::map::iterator iter = device_to_host_map.find(device_ptr); - if (iter == device_to_host_map.end()) { - //failed to find device_ptr in device_to_host_map - throw std::runtime_error("CudaMemoryMgr::copy_to_buffer ERROR, device_ptr not known."); - } - - CUDA_CALL( cudaMemcpy( device_ptr, host_ptr, sizeof(T)*buf_size, cudaMemcpyHostToDevice) ); -} - -//------------------------------------------------------------------------------ -template -inline -void CudaMemoryMgr::copy_from_buffer(T* host_ptr, size_t buf_size, const T* device_ptr) -{ - std::map::iterator iter = device_to_host_map.find(device_ptr); - if (iter == device_to_host_map.end()) { - //failed to find device_ptr in device_to_host_map - throw std::runtime_error("CudaMemoryMgr::copy_from_buffer ERROR, device_ptr not known."); - } - - CUDA_CALL( cudaMemcpy( host_ptr, device_ptr, sizeof(T)*buf_size, cudaMemcpyDeviceToHost) ); -} - -#endif - -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_algsup/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_algsup/unit_tests/CMakeLists.txt deleted file mode 100644 index a8725df06f97..000000000000 --- a/packages/stk/stk_classic/stk_algsup/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -APPEND_SET(SOURCES - UnitTestAlgorithmRunner.cpp - UnitTestCudaMgr.cpp - UnitTestMain.cpp - UnitTest_helpers.cpp - ) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_algsup_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1-4 - STANDARD_PASS_OUTPUT - ) diff --git a/packages/stk/stk_classic/stk_algsup/unit_tests/CudaTestMain.cu b/packages/stk/stk_classic/stk_algsup/unit_tests/CudaTestMain.cu deleted file mode 100644 index 489d4c8e4bbb..000000000000 --- a/packages/stk/stk_classic/stk_algsup/unit_tests/CudaTestMain.cu +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -/*--------------------------------------------------------------------*/ - -static void cuda_safe_call( cudaError e , const char * name ) -{ - if ( cudaSuccess != e ) { - fprintf(stderr,"%s error: %s\n",name,cudaGetErrorString(e) ); - exit( EXIT_FAILURE ); - } -} - -#define CUDA_SAFE_CALL( call ) cuda_safe_call( call , # call ) - -/*--------------------------------------------------------------------*/ - -// Kernel that executes on the CUDA device -__global__ void square_array(float *a, int N) -{ - int idx = blockIdx.x * blockDim.x + threadIdx.x; - if (idx>> (a_d, N); - - CUDA_SAFE_CALL( cudaThreadSynchronize() ); - - // Retrieve result from device and store it in host array - CUDA_SAFE_CALL( cudaMemcpy(a_h, a_d, sizeof(float)*N, cudaMemcpyDeviceToHost) ); - - // Print results - bool test_passed = true; - for (int i=0; i -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -static const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -class MyAlg { -public: - MyAlg() : maximum_entity_count(0), num_applys(0) {} - virtual ~MyAlg() {} - - void apply(stk_classic::mesh::Bucket::iterator /*ibeg*/, - stk_classic::mesh::Bucket::iterator /*iend*/) const - { - ++num_applys; - } - - unsigned maximum_entity_count; - mutable unsigned num_applys; -};//class MyAlg - -STKUNIT_UNIT_TEST( UnitTestAlgorithmRunner, UnitTest) -{ -#ifdef STK_HAS_MPI - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); -#else - stk_classic::ParallelMachine comm(0); -#endif - - const stk_classic::AlgorithmRunnerInterface* alg_runner = NULL; - -#ifdef STK_HAVE_TBB - const int num_threads = 1; - alg_runner = stk_classic::algorithm_runner_tbb(num_threads); -#elif defined(STK_HAVE_TPI) - const int num_threads = 1; - alg_runner = stk_classic::algorithm_runner_tpi(num_threads); -#else - alg_runner = stk_classic::algorithm_runner_non_thread(); -#endif - - STKUNIT_ASSERT( alg_runner != NULL ); - - const stk_classic::AlgorithmRunnerInterface* alg_run_nothread = stk_classic::algorithm_runner_non_thread(); - - STKUNIT_ASSERT( alg_run_nothread != NULL ); - - const unsigned spatial_dim = 3; - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dim); - - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - - stk_classic::mesh::BulkData bulk_data( meta_data, comm ); - - fill_utest_mesh_meta_data( fem_meta ); - fill_utest_mesh_bulk_data( bulk_data ); - - stk_classic::mesh::Selector selector = meta_data.locally_owned_part() | meta_data.globally_shared_part(); - std::vector used_node_buckets; - stk_classic::mesh::get_buckets(selector, bulk_data.buckets(NODE_RANK), used_node_buckets); - - MyAlg my_alg; - - stk_classic::mesh::PartVector empty_union_vector; - alg_run_nothread->run(selector, empty_union_vector, bulk_data.buckets(NODE_RANK), my_alg); - - unsigned num_applys = my_alg.num_applys; - unsigned num_applys_expected = used_node_buckets.size(); - - STKUNIT_ASSERT_EQUAL( num_applys, num_applys_expected ); - -#if defined(STK_HAVE_TBB) || defined(STK_HAVE_TPI) - my_alg.num_applys = 0; - - alg_runner->run(selector, empty_union_vector, bulk_data.buckets(NODE_RANK), my_alg); - - num_applys = my_alg.num_applys; - STKUNIT_ASSERT_EQUAL( num_applys, num_applys_expected ); -#endif - - my_alg.maximum_entity_count = 1000; - my_alg.num_applys = 0; - - alg_run_nothread->run(selector, empty_union_vector, bulk_data.buckets(NODE_RANK), my_alg); - - num_applys = my_alg.num_applys; - num_applys_expected = used_node_buckets.size(); - - STKUNIT_ASSERT_EQUAL( num_applys, num_applys_expected ); - -#if defined(STK_HAVE_TBB) || defined(STK_HAVE_TPI) - my_alg.num_applys = 0; - my_alg.num_applys = 0; - - alg_runner->run(selector, empty_union_vector, bulk_data.buckets(NODE_RANK), my_alg); - - num_applys = my_alg.num_applys; - STKUNIT_ASSERT_EQUAL( num_applys, num_applys_expected ); -#endif - -} diff --git a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestCudaMgr.cpp b/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestCudaMgr.cpp deleted file mode 100644 index 049b47fda8a6..000000000000 --- a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestCudaMgr.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -STKUNIT_UNIT_TEST( UnitTestCudaMgr, UnitTest) -{ -#ifdef STK_HAVE_CUDA - stk_classic::CudaDeviceMgr cuda_device; - stk_classic::CudaMemoryMgr cuda_memory; - - //create a vector (length 100) of ones: - std::vector ibuf(100, 1); - - //allocate a CUDA buffer and copy ibuf into it: - int* d_ibuf = cuda_memory.get_buffer(&ibuf[0], ibuf.size()); - cuda_memory.copy_to_buffer(&ibuf[0], ibuf.size(), d_ibuf); - - //create a vector (length 100) of zeros: - std::vector ibuf_copy(100,0); - - //copy the CUDA buffer into ibuf_copy: - cuda_memory.copy_from_buffer(&ibuf_copy[0], ibuf_copy.size(), d_ibuf); - - cuda_memory.destroy_buffer(d_ibuf); - - //test passes if ibuf_copy is now the same as ibuf: - STKUNIT_ASSERT( ibuf == ibuf_copy ); - -#else - std::cout << "\nSTK_HAVE_CUDA not enabled."<< std::endl; -#endif -} diff --git a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 33538cad68cc..000000000000 --- a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTest_helpers.cpp b/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTest_helpers.cpp deleted file mode 100644 index 144e5db4557b..000000000000 --- a/packages/stk/stk_classic/stk_algsup/unit_tests/UnitTest_helpers.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include -#include -#include - -#include -#include -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void fill_utest_mesh_meta_data(stk_classic::mesh::fem::FEMMetaData& fem_meta) -{ - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::Part& elem_block = fem_meta.declare_part( "block_1" , element_rank ); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( elem_block, hex_top ); - - const unsigned number_of_states = 1; - - ScalarField& temperature_field = fem_meta.declare_field( "temperature", number_of_states ); - ScalarField& pressure_field = fem_meta.declare_field( "pressure", number_of_states ); - VectorField& velocity_field = fem_meta.declare_field( "velocity", number_of_states ); - - stk_classic::mesh::put_field( temperature_field, NODE_RANK, elem_block ); - stk_classic::mesh::put_field( pressure_field, element_rank, elem_block ); - stk_classic::mesh::put_field( velocity_field, NODE_RANK, elem_block ); - - fem_meta.commit(); -} - -// Assume the following mesh of 4 hex8 elements on the first processor (proc 0). -// -// Global node and element numbering -// 3 7 11 15 19 -// +-------+-------+-------+-------+ -// / / / / /| -// 4/ 8/ 12/ 16/ 20/ | -// +-------+-------+-------+-------+ | -// | | | | | +18 -// | e1 | e2 | e3 | e4 | / -// | | | | |/ -// +-------+-------+-------+-------+ -// 1 5 9 13 17 -// -// Local node numbering -// 8 7 -// +-------+ -// / /| -// 5/ 6/ | -// +-------+ | -// | | +3 -// | e1 | / -// | |/ -// +-------+ -// 1 2 -// -// A similar mesh will be created on the other processors, but using different elem-ids. -// i.e., proc 0 has elements 1 - 4, proc 1 has elements 5 - 8, and so on. 4 nodes will be -// shared between each neighboring pair of processors. -//---------------------------------------------------------------------- - -void elem_node_ids( stk_classic::mesh::EntityId elem_id , stk_classic::mesh::EntityId node_ids[] ) -{ - if ( elem_id == 0 ) { - std::cout << "use_case_1, elem_node_ids: ERROR, elem_id (" - << elem_id << ") must be greater than 0." << std::endl; - return; - } - - const unsigned base = ( elem_id - 1 ) * 4 ; - node_ids[0] = base + 1 ; - node_ids[1] = base + 5 ; - node_ids[2] = base + 6 ; - node_ids[3] = base + 2 ; - node_ids[4] = base + 4 ; - node_ids[5] = base + 8 ; - node_ids[6] = base + 7 ; - node_ids[7] = base + 3 ; -} - -void fill_utest_mesh_bulk_data(stk_classic::mesh::BulkData& bulk_data) -{ - bulk_data.modification_begin(); - const unsigned num_elems = 4; - - const unsigned myProc = bulk_data.parallel_rank(); - - stk_classic::mesh::EntityId elem_id = 1 + myProc*num_elems; - stk_classic::mesh::EntityId node_ids[ shards::Hexahedron<8>::node_count ]; - - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - stk_classic::mesh::Part& elem_block = *(fem_meta.get_part( "block_1" )); - - for(unsigned i = 0; i - -namespace stk_classic { -namespace expreval { - -ConstantMap & -getConstantMap() -{ - static ConstantMap s_constantMap; - - if (s_constantMap.empty()) { - s_constantMap["E"] = s_e; - s_constantMap["PI"] = s_pi; - s_constantMap["FALSE"] = s_false; - s_constantMap["TRUE"] = s_true; - } - - return s_constantMap; -} - -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Constants.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Constants.hpp deleted file mode 100644 index c5acc00afff4..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Constants.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef stk_expreval_Constants_hpp -#define stk_expreval_Constants_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace expreval { - -/** - * @brief Typedef ConstantMap maps a constant name to a double constant. - * The mapping is case insensitive. - */ -typedef std::map ConstantMap; - -const double s_false = 0.0; -const double s_true = 1.0; -const double s_e = 2.7182818284590452354; -const double s_pi = 3.14159265358979323846; - -/** - * @brief Member function getConstantMap returns s reference to the defined - * constants. - * - * @return a ConstantMap reference to the defined - * constants. - */ -ConstantMap &getConstantMap(); - -} // namespace expreval -} // namespace stk_classic - -#endif // stk_expreval_Constants_hpp diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.cpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.cpp deleted file mode 100644 index 77f6165d9ded..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.cpp +++ /dev/null @@ -1,947 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2003 - 2011 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -/* - Loosely based on: (Less and less so each checkin, practically none) - File: Eval.c - Auth: Brian Allen Vanderburg II - Date: Wednesday, April 30, 2003 - Desc: Evaluation routines for the Eval library -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace stk_classic { -namespace expreval { - -/** - * @brief Enumeration Opcode lists the operation codes which can be - * executed using the execution virtual machine. - * - */ -enum Opcode { - OPCODE_UNDEFINED, - OPCODE_CONSTANT, - OPCODE_RVALUE, - OPCODE_STATEMENT, - OPCODE_ARGUMENT, - - OPCODE_TIERNARY, - - - - OPCODE_MULTIPLY, - OPCODE_DIVIDE, - OPCODE_MODULUS, - OPCODE_ADD, - OPCODE_SUBTRACT, - OPCODE_UNARY_MINUS, - OPCODE_FUNCTION, - - OPCODE_EQUAL, - OPCODE_NOT_EQUAL, - OPCODE_LESS, - OPCODE_GREATER, - OPCODE_LESS_EQUAL, - OPCODE_GREATER_EQUAL, - - OPCODE_UNARY_NOT, - OPCODE_LOGICAL_AND, - OPCODE_LOGICAL_OR, - - OPCODE_EXPONENIATION, - - OPCODE_ASSIGN -}; - - -class Node -{ - // - // 0,1,2,3,4 argument overloads allowed. Increase this - // value when 5 argument functions are added. Probably - // some way to automate this given that it's related to - // the number of CFunction classes defined. - // -public: - enum { MAXIMUM_NUMBER_OF_OVERLOADED_FUNCTION_NAMES = 5 }; - - explicit Node(Opcode opcode) - : m_opcode(opcode), - m_left(0), - m_right(0), - m_other(0) - {m_data.function.undefinedFunction = false;} - -private: - explicit Node(const Node &); - Node &operator=(const Node &); - -public: - ~Node() - {} - - double eval() const; - - const Opcode m_opcode; - - union _data - { - struct _constant - { - double value; - } constant; - - struct _variable - { - Variable *variable; - } variable; - - struct _function - { - CFunctionBase* function[MAXIMUM_NUMBER_OF_OVERLOADED_FUNCTION_NAMES]; - bool undefinedFunction; - } function; - } m_data; - - Node * m_left; - Node * m_right; - Node * m_other; -}; - - -double -Node::eval() const -{ - switch (m_opcode) { - case OPCODE_STATEMENT: - { - double value = 0.0; - for (const Node *statement = this; statement; statement = statement->m_right) - value = statement->m_left->eval(); - return value; - } - - case OPCODE_CONSTANT: - return m_data.constant.value; - - case OPCODE_RVALUE: - /* Directly access the variable */ - if (m_left) - return (*m_data.variable.variable)[m_left->eval()]; - else - return m_data.variable.variable->getValue(); - - case OPCODE_MULTIPLY: - return m_left->eval()*m_right->eval(); - - case OPCODE_EXPONENIATION: - return std::pow(m_left->eval(),m_right->eval()); - - case OPCODE_DIVIDE: - return m_left->eval()/m_right->eval(); - - case OPCODE_MODULUS: - return std::fmod(m_left->eval(), m_right->eval()); - - case OPCODE_ADD: - return m_left->eval() + m_right->eval(); - - case OPCODE_SUBTRACT: - return m_left->eval() - m_right->eval(); - - case OPCODE_EQUAL: - return m_left->eval() == m_right->eval() ? s_true : s_false; - - case OPCODE_NOT_EQUAL: - return m_left->eval() != m_right->eval() ? s_true : s_false; - - case OPCODE_LESS: - return m_left->eval() < m_right->eval() ? s_true : s_false; - - case OPCODE_GREATER: - return m_left->eval() > m_right->eval() ? s_true : s_false; - - case OPCODE_LESS_EQUAL: - return m_left->eval() <= m_right->eval() ? s_true : s_false; - - case OPCODE_GREATER_EQUAL: - return m_left->eval() >= m_right->eval() ? s_true : s_false; - - case OPCODE_LOGICAL_AND: { - double left = m_left->eval(); - double right = m_right->eval(); - return (left != s_false) && (right != s_false) ? s_true : s_false; - } - case OPCODE_LOGICAL_OR: { - double left = m_left->eval(); - double right = m_right->eval(); - - return (left != s_false) || (right != s_false) ? s_true : s_false; - } - case OPCODE_TIERNARY: - return m_left->eval() != s_false ? m_right->eval() : m_other->eval(); - - case OPCODE_UNARY_MINUS: - return -m_right->eval(); - - case OPCODE_UNARY_NOT: - return m_right->eval() == s_false ? s_true : s_false; - - case OPCODE_ASSIGN: - if (m_left) - return (*m_data.variable.variable)[m_left->eval()] = m_right->eval(); - else { - *m_data.variable.variable = m_right->eval(); - return m_data.variable.variable->getValue(); - } - - case OPCODE_FUNCTION: - { - double argv[20]; - - int argc = 0; - for (Node *arg = m_right; arg; arg = arg->m_right) - { - argv[argc++] = arg->m_left->eval(); - } - - for(unsigned int i=0; igetArgCount() == argc) { - return (*m_data.function.function[i])(argc, argv); - } - } - } - - default: // Unknown opcode - throw std::runtime_error("Evaluation error"); - } -} - -namespace Parser { - -Node *parseStatements(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseStatement(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseExpression(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseAssign(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator assign, LexemVector::const_iterator to); -Node *parseTerm(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator term, LexemVector::const_iterator to); -Node *parseFactor(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseRelation(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseLogical(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseUnary(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator unary, LexemVector::const_iterator to); -Node *parseTiernary(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator question, LexemVector::const_iterator colon, LexemVector::const_iterator to); -Node *parseFunction(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator lparen, LexemVector::const_iterator rparen, LexemVector::const_iterator to); -Node *parseFunctionArg(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseRValue(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseIndex(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator lbrack, LexemVector::const_iterator rbrack, LexemVector::const_iterator to); - -// Parser productions - -Node * -parseStatements( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if ((*from).getToken() == TOKEN_END) - return NULL; - - if ((*from).getToken() == TOKEN_SEMI) - return parseStatements(eval, from + 1, to); - - // Technically, there should be no check for TOKEN_END, but we allow a missing final TOKEN_SEMI - LexemVector::const_iterator it; - for (it = from; (*it).getToken() != TOKEN_SEMI && (*it).getToken() != TOKEN_END; ++it) - ; - - Node *statement = eval.newNode(OPCODE_STATEMENT); - statement->m_left = parseStatement(eval, from, it); - - // Technically, there should be no check for TOKEN_END, but we allow a missing final TOKEN_SEMI - if ((*it).getToken() != TOKEN_END) - statement->m_right = parseStatements(eval, it + 1, to); - - return statement; -} - - -Node * -parseStatement( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - return parseExpression(eval, from, to); -} - - -Node * -parseExpression( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - int paren_level = 0; // Paren level - int brack_level = 0; // Brack level - LexemVector::const_iterator lparen_open_it = to; // First open paren - LexemVector::const_iterator lparen_close_it = to; // Corresponding close paren - LexemVector::const_iterator lbrack_open_it = to; // First open bracket - LexemVector::const_iterator lbrack_close_it = to; // Corresponding close brack - LexemVector::const_iterator assign_it = to; // First = at paren_level 0 for assignment - LexemVector::const_iterator term_it = to; // Last + or - at paren_level 0 for adding or subtracting - LexemVector::const_iterator factor_it = to; // Last * or / at paren_level 0 for multiplying or dividing - LexemVector::const_iterator expon_it = to; // Last ^ for exponenation - - - LexemVector::const_iterator relation_it = to; // Last relational at paren_level 0 for relational operator - LexemVector::const_iterator logical_it = to; // Last logical at paren_level 0 for logical operator - LexemVector::const_iterator question_it = to; // Last tiernary at paren_level 0 for tiernary operator - LexemVector::const_iterator colon_it = to; - LexemVector::const_iterator unary_it = to; // First +,- at plevel 0 for positive,negative - LexemVector::const_iterator last_unary_it = to; // Last +,- found at plevel for for positive,negative - - // Scan the expression for the instances of the above tokens - for (LexemVector::const_iterator it = from; it != to; ++it) { - switch((*it).getToken()) { - case TOKEN_LPAREN: - if (paren_level == 0 && lparen_open_it == to - && brack_level == 0 && lbrack_open_it == to) - lparen_open_it = it; - paren_level++; - break; - - case TOKEN_RPAREN: - paren_level--; - - if (paren_level == 0 && lparen_close_it == to - && brack_level == 0 && lbrack_close_it == to) - lparen_close_it = it; - - if (paren_level < 0) - throw std::runtime_error("mismatched parenthesis"); - break; - - case TOKEN_LBRACK: - if (paren_level == 0 && lparen_open_it == to - && brack_level == 0 && lbrack_open_it == to) - lbrack_open_it = it; - brack_level++; - break; - - case TOKEN_RBRACK: - brack_level--; - - if (paren_level == 0 && lparen_close_it == to - && brack_level == 0 && lbrack_close_it == to) - lbrack_close_it = it; - - if (brack_level < 0) - throw std::runtime_error("mismatched bracket"); - break; - - case TOKEN_ASSIGN: - if (paren_level == 0 && assign_it == to) - assign_it = it; - break; - - case TOKEN_QUESTION: - if (paren_level == 0 && question_it == to) - question_it = it; - break; - - case TOKEN_COLON: - if (paren_level == 0) // && colon_it == to) - colon_it = it; - break; - - case TOKEN_EXPONENTIATION: - if (paren_level == 0) // && expon_it == to) - expon_it = it; - break; - - - case TOKEN_MULTIPLY: - case TOKEN_DIVIDE: - case TOKEN_PERCENT: - if (paren_level == 0) // && factor_it == to) - factor_it = it; - break; - - case TOKEN_EQUAL: - case TOKEN_NOT_EQUAL: - case TOKEN_LESS: - case TOKEN_GREATER: - case TOKEN_LESS_EQUAL: - case TOKEN_GREATER_EQUAL: - if (paren_level == 0 && relation_it == to) - relation_it = it; - break; - - case TOKEN_LOGICAL_AND: - case TOKEN_LOGICAL_OR: - if (paren_level == 0 && logical_it == to) - logical_it = it; - break; - - case TOKEN_PLUS: - case TOKEN_MINUS: - if (paren_level == 0) { - // After any of these, we are a unary operator, not a term - if (it == from || it == assign_it + 1 - || it == term_it + 1 || it == factor_it + 1 - || it == last_unary_it + 1 || it == expon_it + 1) - { // Unary operator - if (unary_it == to) // First unary operator? - unary_it = it; - last_unary_it = it; - } - else { // Term - term_it = it; - } - } - break; - - case TOKEN_NOT: - if (paren_level == 0) { - if (unary_it == to) /// First unary operator - unary_it = it; - last_unary_it = it; - } - break; - - default: - break; - } - } - - if (paren_level != 0) // paren_level should now be zero */ - throw std::runtime_error("mismatched parenthesis"); - - // This implement the operator hiearchy - // Assignment - if (assign_it != to) - return parseAssign(eval, from, assign_it, to); - - // Tiernary operator - if (question_it != to || colon_it != to) - return parseTiernary(eval, from, question_it, colon_it, to); - - // Logical - if (logical_it != to) - return parseLogical(eval, from, logical_it, to); - - // Relational - if (relation_it != to) - return parseRelation(eval, from, relation_it, to); - - // Term - if (term_it != to) - return parseTerm(eval, from, term_it, to); - - // Factor - if (factor_it != to) - return parseFactor(eval, from, factor_it, to); - - // Unary - if (unary_it != to) - return parseUnary(eval, from, unary_it, to); - - if (expon_it != to) - return parseFactor(eval, from, expon_it, to); - - - - // Parenthetical - if (lparen_open_it != to) { - if (lparen_open_it == from) { - if (lparen_close_it == to - 1 && lparen_close_it - lparen_open_it > 1) - return parseExpression(eval, lparen_open_it + 1, lparen_close_it); - else - throw std::runtime_error("syntax error parsing parentheses"); - } - - // Function - if (lparen_open_it == from + 1) { - if (lparen_close_it == to - 1) - return parseFunction(eval, from, lparen_open_it, lparen_close_it, to); - else // Closing paren not at to - throw std::runtime_error("syntax error 2"); - } - - throw std::runtime_error("syntax error 3"); - } - - // Bracket - if (lbrack_open_it != to) { - - // Array index - if (lbrack_open_it == from + 1) { - if (lbrack_close_it == to - 1) - return parseIndex(eval, from, lbrack_open_it, lbrack_close_it, to); - else // Closing brack not at to - throw std::runtime_error("syntax error 2"); - } - - throw std::runtime_error("syntax error 3"); - } - - // R-Value - return parseRValue(eval, from, to); -} - - -Node * -parseAssign( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator assign_it, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) // || from + 1 != assign_it) { - throw std::runtime_error("stk_classic::expreval::parseAssign: expected identifier"); - - Node *assign; - - if ((*(from + 1)).getToken() == TOKEN_ASSIGN || (*(from + 1)).getToken() == TOKEN_LBRACK) { - assign = eval.newNode(OPCODE_ASSIGN); - - assign->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - assign->m_data.variable.variable->setDependent(); - assign->m_right = parseExpression(eval, assign_it + 1, to); - - if ((*(from + 1)).getToken() == TOKEN_LBRACK) - assign->m_left = parseExpression(eval, from + 2, assign_it - 1); - } - else - throw std::runtime_error("syntax error"); - - return assign; -} - - -Node * -parseTerm( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator term_it, - LexemVector::const_iterator to) -{ - Node *term = eval.newNode((*term_it).getToken() == TOKEN_PLUS ? OPCODE_ADD : OPCODE_SUBTRACT); - - term->m_left = parseExpression(eval, from, term_it); - term->m_right = parseExpression(eval, term_it + 1, to); - - return term; -} - - -Node * -parseFactor( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator factor_it, - LexemVector::const_iterator to) -{ - Node *factor = eval.newNode - ( - (*factor_it).getToken() == TOKEN_MULTIPLY ? OPCODE_MULTIPLY : - ( - (*factor_it).getToken() == TOKEN_DIVIDE ? OPCODE_DIVIDE : - ( - (*factor_it).getToken() == TOKEN_EXPONENTIATION ? OPCODE_EXPONENIATION : OPCODE_MODULUS - ) - ) - ); - - factor->m_left = parseExpression(eval, from, factor_it); - factor->m_right = parseExpression(eval, factor_it + 1, to); - - return factor; -} - - -Node * -parseRelation( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator relation_it, - LexemVector::const_iterator to) -{ - Opcode relation_opcode = OPCODE_UNDEFINED; - - switch ((*relation_it).getToken()) { - case TOKEN_EQUAL: - relation_opcode = OPCODE_EQUAL; - break; - - case TOKEN_NOT_EQUAL: - relation_opcode = OPCODE_NOT_EQUAL; - break; - - case TOKEN_LESS: - relation_opcode = OPCODE_LESS; - break; - - case TOKEN_GREATER: - relation_opcode = OPCODE_GREATER; - break; - - case TOKEN_LESS_EQUAL: - relation_opcode = OPCODE_LESS_EQUAL; - break; - - case TOKEN_GREATER_EQUAL: - relation_opcode = OPCODE_GREATER_EQUAL; - break; - - default: - break; - } - - Node *relation = eval.newNode(relation_opcode); - - relation->m_left = parseExpression(eval, from, relation_it); - relation->m_right = parseExpression(eval, relation_it + 1, to); - - return relation; -} - - -Node * -parseLogical( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator logical_it, - LexemVector::const_iterator to) -{ - Node *logical = eval.newNode(((*logical_it).getToken() == TOKEN_LOGICAL_AND ? OPCODE_LOGICAL_AND : OPCODE_LOGICAL_OR)); - - logical->m_left = parseExpression(eval, from, logical_it); - logical->m_right = parseExpression(eval, logical_it + 1, to); - - return logical; -} - - -Node * -parseTiernary( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator question_it, - LexemVector::const_iterator colon_it, - LexemVector::const_iterator to) -{ - if (question_it == to || colon_it == to) - throw std::runtime_error("syntax error parsing ?: operator"); - - Node *tiernary = eval.newNode(OPCODE_TIERNARY); - - tiernary->m_left = parseExpression(eval, from, question_it); - tiernary->m_right = parseExpression(eval, question_it + 1, colon_it); - tiernary->m_other = parseExpression(eval, colon_it + 1, to); - - return tiernary; -} - - -Node * -parseUnary( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator unary_it, - LexemVector::const_iterator to) -{ - /* If it is a positive, just parse the internal of it */ - if ((*unary_it).getToken() == TOKEN_PLUS) - return parseExpression(eval, unary_it + 1, to); - else if ((*unary_it).getToken() == TOKEN_MINUS) { - Node *unary = eval.newNode(OPCODE_UNARY_MINUS); - unary->m_right = parseExpression(eval, unary_it + 1, to); - return unary; - } - else if ((*unary_it).getToken() == TOKEN_NOT) { - Node *unary = eval.newNode(OPCODE_UNARY_NOT); - unary->m_right = parseExpression(eval, unary_it + 1, to); - return unary; - } - else - throw std::runtime_error("syntax error parsing unary operator"); -} - - -Node * -parseFunction( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator lparen, - LexemVector::const_iterator rparen, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) - throw std::runtime_error("syntax error parsing function"); - - const std::string &function_name = (*from).getString(); - - CFunctionBase *c_function = NULL; - CFunctionMap::iterator it = getCFunctionMap().find(function_name); - Node *function = eval.newNode(OPCODE_FUNCTION); - // only 1 function found with that function name. - if ( getCFunctionMap().count(function_name) == 1 ) { - if (it != getCFunctionMap().end()) { - c_function = (*it).second; - } - function->m_data.function.function[0] = c_function; - - if (!c_function) - eval.getUndefinedFunctionSet().insert(function_name); - - } else { - std::pair ppp; - ppp = getCFunctionMap().equal_range(function_name); - - using std::cout; - using std::endl; - //cout << endl << "Range of \"function_name\" elements:" << endl; - int iCount=0; - for (CFunctionMap::iterator it2 = ppp.first; - it2 != ppp.second; - ++it2, - ++iCount) - { - //cout << " [" << (*it2).first << ", " << (*it2).second->getArgCount() << "]" << endl; - c_function = (*it2).second; - function->m_data.function.function[iCount] = c_function; - - if (!c_function) - eval.getUndefinedFunctionSet().insert(function_name); - } - if( iCount == Node::MAXIMUM_NUMBER_OF_OVERLOADED_FUNCTION_NAMES) { - //cout << "Found multiple functions with the same name" << endl; - throw std::runtime_error(std::string("Exceeded maximum number of overloaded function names for function named= ") + function_name); - } - } - function->m_right = parseFunctionArg(eval, lparen + 1, rparen); - - if (!c_function) { - function->m_data.function.undefinedFunction = true; - } - - return function; -} - - -Node * -parseIndex( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator lbrack, - LexemVector::const_iterator rbrack, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) - throw std::runtime_error("syntax error parsing array"); - - Node *index = eval.newNode(OPCODE_RVALUE); - index->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - index->m_left = parseExpression(eval, lbrack + 1, rbrack); - - return index; -} - - -Node * -parseFunctionArg( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if (from == to) - return NULL; - - LexemVector::const_iterator it; - for (it = from; it != to && (*it).getToken() != TOKEN_COMMA; ++it) - ; - - Node *argument = eval.newNode(OPCODE_ARGUMENT); - argument->m_left = parseExpression(eval, from, it); - if (it != to) - argument->m_right = parseFunctionArg(eval, it + 1, to); - return argument; -} - - -Node * -parseRValue( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if (from + 1 != to) - throw std::runtime_error(std::string("r-value not allowed following ") + (*from).getString()); - - switch ((*from).getToken()) { - case TOKEN_IDENTIFIER: - { - ConstantMap::iterator it = getConstantMap().find((*from).getString()); - if (it != getConstantMap().end()) { - Node *constant = eval.newNode(OPCODE_CONSTANT); - constant->m_data.constant.value = (*it).second; - return constant; - } - - // Define a variable - else { - Node *variable = eval.newNode(OPCODE_RVALUE); - variable->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - return variable; - } - } - - case TOKEN_REAL_CONSTANT: - case TOKEN_INTEGER_CONSTANT: - { - Node *constant = eval.newNode(OPCODE_CONSTANT); - constant->m_data.constant.value = (*from).getValue(); - return constant; - } - - default: - throw std::runtime_error("invalid rvalue"); - } -} - -} // namespace Parser - -Eval::Eval( - VariableMap::Resolver & resolver, - const std::string & expression) - : m_variableMap(resolver), - m_expression(expression), - m_syntaxStatus(false), - m_parseStatus(false), - m_headNode(0) -{} - - -Eval::~Eval() -{ - for (std::vector::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it) - delete (*it); -} - - -Node * -Eval::newNode( - int opcode) -{ - Node *new_node = new Node((Opcode) opcode); - m_nodes.push_back(new_node); - return new_node; -} - - -void -Eval::syntax() -{ - m_syntaxStatus = false; - m_parseStatus = false; - - try { - /* Validate the characters */ - LexemVector lex_vector = tokenize(m_expression); - - /* Call the multiparse routine to parse subexpressions */ - m_headNode = Parser::parseStatements(*this, lex_vector.begin(), lex_vector.end()); - - m_syntaxStatus = true; - } - catch (std::runtime_error & /* x */) { -// x << " while parsing expression: " << m_expression; -// RuntimeDoomed() << x.what(); - throw; - } -} - - -void -Eval::parse() -{ - try { - syntax(); - - if (m_syntaxStatus) { - if (!m_undefinedFunctionSet.empty()) { - std::ostringstream strout; - strout << "In expression '" << m_expression << "', the following functions are not defined:" << std::endl; - // for (iteration it(m_undefinedFunctionSet); it; ++it) - for (UndefinedFunctionSet::iterator it = m_undefinedFunctionSet.begin(); it != m_undefinedFunctionSet.end(); ++it) - strout << (*it) << std::endl; - throw std::runtime_error(strout.str()); - } - - resolve(); - - m_parseStatus = true; - } - } - catch (std::runtime_error & /* x */) { -// x << " while parsing expression: " << m_expression; -// RuntimeDoomed() << x.what(); - throw; - } -} - - -void -Eval::resolve() -{ - for (VariableMap::iterator it = m_variableMap.begin(); it != m_variableMap.end(); ++it) { - m_variableMap.getResolver().resolve(it); - } -} - - -double -Eval::evaluate() const -{ - /* Make sure it was parsed successfully */ - if (!m_parseStatus) - throw std::runtime_error(std::string("Expression '") + m_expression + "' did not parse successfully"); - - return m_headNode->eval(); -} - -bool -Eval::undefinedFunction() const -{ - /* Check for an undefined function in any allocated node */ - for (unsigned int i=0; im_data.function.undefinedFunction) return true; - } - return false; -} - -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.hpp deleted file mode 100644 index 8c4862ae493e..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Evaluator.hpp +++ /dev/null @@ -1,286 +0,0 @@ -#ifndef SIERRA_ExprEval_h -#define SIERRA_ExprEval_h - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace expreval { - -class Node; - -/** - * Class Eval parses and evaluates mathematical expressions. - * - */ -class Eval -{ -public: - typedef std::set UndefinedFunctionSet; - - /** - * Creates a new Eval instance. - * - * @param resolver a Resolver reference to the variable name - * resolver for this expression evaluator. - * - * @param expr a std::string const reference to the - * expression to be parsed. - */ - Eval(VariableMap::Resolver &resolver = VariableMap::getDefaultResolver(), const std::string &expr = ""); - -private: - explicit Eval(const Eval &); - Eval &operator=(const Eval &); - -public: - /** - * Destroys a Eval instance. - * - */ - ~Eval(); - - /** - * @brief Member function getExpression returns the original text of the expression. - * - * @return a std::string const reference to the - * expression. - */ - inline const std::string &getExpression() const { - return m_expression; - } - - /** - * @brief Member function setExpression gives the evaluator a new - * expression to parse. - * - * @param expression a std::string const refernce to the - * expression to be parsed. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &setExpression(const std::string &expression) { - m_expression = expression; - m_parseStatus = false; - return *this; - } - - /** - * @brief Member function getVariableMap returns a reference to the - * variable map of this expression. - * - * @return a VariableMap reference to the variable map. - */ - inline VariableMap &getVariableMap() { - return m_variableMap; - } - - /** - * @brief Member function getVariableMap returns a reference to the - * variable map of this expression. - * - * @return a VariableMap reference to the variable map. - */ - inline UndefinedFunctionSet &getUndefinedFunctionSet() { - return m_undefinedFunctionSet; - } - - /** - * @brief Member function getSyntaxStatus returns true if the expression has - * been syntaxd successfully. - * - * @return a bool value of true if the expression has - * been syntaxd successfully. - */ - inline bool getSyntaxStatus() const { - return m_syntaxStatus; - } - - /** - * @brief Member function getParseStatus returns true if the expression has - * been parsed successfully. - * - * @return a bool value of true if the expression has - * been parsed successfully. - */ - inline bool getParseStatus() const { - return m_parseStatus; - } - - /** - * @brief Member function setValue assigns a variables value in the - * variable map. - * - * @param name a std::string const reference of the name of the - * variable. - * - * @param value a double value to be assigned to the - * variable. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &setValue(const std::string &name, double value) { - VariableMap::iterator it = m_variableMap.find(name); - if (it != m_variableMap.end()) - *(*it).second = value; - return *this; - } - - /** - * @brief Member function getValue returns the value of the variable - * specified by name. - * - * @param name a std::string const reference to the variable's - * name. - * - * @return a double value of the variable. - */ - inline double getValue(const std::string &name) { - VariableMap::iterator it = m_variableMap.find(name); - if (it == m_variableMap.end()) - throw std::runtime_error(std::string("Variable ") + name + " not defined"); - return (*it).second->getValue(); - } - - /** - * @brief Member function newNode allocates a new node. The - * new node is allocated on a node list so that it may be - * deallocated properly on exception. - * - * @param opcode a int value of the opcode for the node. - * - * @return a Node pointer to the newly allocated node. - */ - Node *newNode(int op); - - /** - * @brief Member function bindVariable binds the variable to the address of - * the specified value. This address must remain in scope during the lifetime of the - * variable are until rebound to a new address. - * - * @param name a std::string const reference to the variable's - * name. - * - * @param value_ref a double reference to be used for this variable. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &bindVariable(const std::string &name, double &value_ref) { - VariableMap::iterator it = m_variableMap.find(name); - if (it != m_variableMap.end()) - (*it).second->bind(value_ref); - return *this; - } - - /** - * @brief Member function getVariable returns a reference to the variable - * specified by name. - * - * @param name a std::string const reference to the variable's - * name. - * - * @return a Variable reference to the specified - * variable. - */ - inline Variable &getVariable(const std::string &name) { - VariableMap::iterator it = m_variableMap.find(name); - if (it == m_variableMap.end()) - throw std::runtime_error(std::string("Variable ") + name + " not defined"); - - return *(*it).second; - } - - /** - * @brief Member function parse parses the expression. If successful, the - * parse status is set to true. - * - * @param expr a std::string const reference to the - * expression to parse. - * - */ - inline void syntaxCheck(const std::string &expr) { - setExpression(expr); - syntax(); - } - - /** - * @brief Member function syntax performs a syntax check on the current - * expression. If successful, the syntax status is set to true. - * - */ - void syntax(); - - /** - * @brief Member function parse parses the expression. If successful, the - * parse status is set to true. - * - * @param expr a std::string const reference to the - * expression to parse. - * - */ - inline void parse(const std::string &expr) { - setExpression(expr); - parse(); - } - - /** - * @brief Member function parse parses the current expression. If - * successful, the parse status is set to true. - * - */ - void parse(); - - /** - * @brief Member function resolve calls the variable name resolver for each - * variable in the variable map. - * - */ - void resolve(); - - /** - * @brief Member function evaluate evaluates the expression. - * - * @return a double value of the result on the - * expression evaluation. - */ - double evaluate() const; - - /** - * @brief Member function undefinedFunction checks if any allocated node - * represents an undefined (i.e. unknown at this point) function. - * - * @return The returned bool is true if any allocated node - * is an undefined function, as indicated by bool in the - * member union, which is set whenever a function is parsed. - */ - bool undefinedFunction() const; - -private: - VariableMap m_variableMap; ///< Variable map - UndefinedFunctionSet m_undefinedFunctionSet; ///< Vector of undefined functions - - std::string m_expression; ///< Expression which was parsed. - bool m_syntaxStatus; ///< True if syntax is correct - bool m_parseStatus; ///< True if parsed successfully - - Node * m_headNode; ///< Head of compiled expression - std::vector m_nodes; ///< Allocated nodes -}; - -} // namespace expreval -} // namespace stk_classic - -#endif // SIERRA_ExprEval_h diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.cpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.cpp deleted file mode 100644 index f1b338d55461..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.cpp +++ /dev/null @@ -1,1253 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2003 - 2011 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -/* - Loosely based on: (Less and less so each checkin, practically none) - File: Eval.c - Auth: Brian Allen Vanderburg II - Date: Wednesday, April 30, 2003 - Desc: Evaluation routines for the Eval library -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -namespace stk_classic { -namespace expreval { -namespace fad { - -typedef Sacado::Fad::DFad FADDouble; - -/** - * @brief Enumeration Opcode lists the operation codes which can be - * executed using the execution virtual machine. - * - */ -enum Opcode { - OPCODE_UNDEFINED, - OPCODE_CONSTANT, - OPCODE_RVALUE, - OPCODE_STATEMENT, - OPCODE_ARGUMENT, - - OPCODE_TIERNARY, - OPCODE_MULTIPLY, - OPCODE_DIVIDE, -// OPCODE_MODULUS, - OPCODE_ADD, - OPCODE_SUBTRACT, - OPCODE_UNARY_MINUS, - OPCODE_FUNCTION, - - OPCODE_EQUAL, - OPCODE_NOT_EQUAL, - OPCODE_LESS, - OPCODE_GREATER, - OPCODE_LESS_EQUAL, - OPCODE_GREATER_EQUAL, - - OPCODE_UNARY_NOT, - OPCODE_LOGICAL_AND, - OPCODE_LOGICAL_OR, - - OPCODE_EXPONENIATION, - OPCODE_ASSIGN -}; - - -class Node -{ -public: - explicit Node(Opcode opcode) - : m_opcode(opcode), - m_left(0), - m_right(0), - m_other(0) - {} - -private: - explicit Node(const Node &); - Node &operator=(const Node &); - -public: - ~Node() - {} - - FADDouble eval() const; - - const Opcode m_opcode; - - union _data - { - struct _constant - { - double value; - } constant; - - struct _variable - { - Eval::Variable *variable; - } variable; - - struct _function - { - CFunctionBase * function; - } function; - } m_data; - - Node * m_left; - Node * m_right; - Node * m_other; -}; - - -FADDouble -Node::eval() const -{ - switch (m_opcode) { - case OPCODE_STATEMENT: - { - FADDouble value = 0.0; - for (const Node *statement = this; statement; statement = statement->m_right) - value = statement->m_left->eval(); - return value; - } - - case OPCODE_CONSTANT: - return m_data.constant.value; - - case OPCODE_RVALUE: - /* Directly access the variable */ - if (m_left) - return (*m_data.variable.variable)[m_left->eval()]; - else - return m_data.variable.variable->getValue(); - - case OPCODE_MULTIPLY: - return m_left->eval()*m_right->eval(); - - case OPCODE_EXPONENIATION: - return std::pow(m_left->eval(),m_right->eval()); - - case OPCODE_DIVIDE: - return m_left->eval()/m_right->eval(); - -// case OPCODE_MODULUS: -// return std::fmod(m_left->eval(), m_right->eval()); - - case OPCODE_ADD: - return m_left->eval() + m_right->eval(); - - case OPCODE_SUBTRACT: - return m_left->eval() - m_right->eval(); - - case OPCODE_EQUAL: - return m_left->eval() == m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_NOT_EQUAL: - return m_left->eval() != m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_LESS: - return m_left->eval() < m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_GREATER: - return m_left->eval() > m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_LESS_EQUAL: - return m_left->eval() <= m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_GREATER_EQUAL: - return m_left->eval() >= m_right->eval() ? Eval::s_true : Eval::s_false; - - case OPCODE_LOGICAL_AND: { - FADDouble left = m_left->eval(); - FADDouble right = m_right->eval(); - return (left != Eval::s_false) && (right != Eval::s_false) ? Eval::s_true : Eval::s_false; - } - case OPCODE_LOGICAL_OR: { - FADDouble left = m_left->eval(); - FADDouble right = m_right->eval(); - - return (left != Eval::s_false) || (right != Eval::s_false) ? Eval::s_true : Eval::s_false; - } - case OPCODE_TIERNARY: - return m_left->eval() != Eval::s_false ? m_right->eval() : m_other->eval(); - - case OPCODE_UNARY_MINUS: - return -m_right->eval(); - - case OPCODE_UNARY_NOT: - return m_right->eval() == Eval::s_false ? Eval::s_true : Eval::s_false; - - case OPCODE_ASSIGN: - if (m_left) - return (*m_data.variable.variable)[m_left->eval()] = m_right->eval(); - else { - *m_data.variable.variable = m_right->eval(); - return m_data.variable.variable->getValue(); - } - - case OPCODE_FUNCTION: - { - FADDouble argv[20]; - - int argc = 0; - for (Node *arg = m_right; arg; arg = arg->m_right) - argv[argc++] = arg->m_left->eval(); - - return (*m_data.function.function)(argc, argv); - } - - default: // Unknown opcode - throw std::runtime_error("Evaluation error"); - } -} - -namespace Parser { - -Node *parseStatements(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseStatement(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseExpression(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseAssign(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator assign, LexemVector::const_iterator to); -Node *parseTerm(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator term, LexemVector::const_iterator to); -Node *parseFactor(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseRelation(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseLogical(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator factor, LexemVector::const_iterator to); -Node *parseUnary(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator unary, LexemVector::const_iterator to); -Node *parseTiernary(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator question, LexemVector::const_iterator colon, LexemVector::const_iterator to); -Node *parseFunction(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator lparen, LexemVector::const_iterator rparen, LexemVector::const_iterator to); -Node *parseFunctionArg(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseRValue(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator to); -Node *parseIndex(Eval &eval, LexemVector::const_iterator from, LexemVector::const_iterator lbrack, LexemVector::const_iterator rbrack, LexemVector::const_iterator to); - -// Parser productions - -Node * -parseStatements( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if ((*from).getToken() == TOKEN_END) - return NULL; - - if ((*from).getToken() == TOKEN_SEMI) - return parseStatements(eval, from + 1, to); - - // Technically, there should be no check for TOKEN_END, but we allow a missing final TOKEN_SEMI - LexemVector::const_iterator it; - for (it = from; (*it).getToken() != TOKEN_SEMI && (*it).getToken() != TOKEN_END; ++it) - ; - - Node *statement = eval.newNode(OPCODE_STATEMENT); - statement->m_left = parseStatement(eval, from, it); - - // Technically, there should be no check for TOKEN_END, but we allow a missing final TOKEN_SEMI - if ((*it).getToken() != TOKEN_END) - statement->m_right = parseStatements(eval, it + 1, to); - - return statement; -} - - -Node * -parseStatement( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - return parseExpression(eval, from, to); -} - - -Node * -parseExpression( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - int paren_level = 0; // Paren level - int brack_level = 0; // Brack level - LexemVector::const_iterator lparen_open_it = to; // First open paren - LexemVector::const_iterator lparen_close_it = to; // Corresponding close paren - LexemVector::const_iterator lbrack_open_it = to; // First open bracket - LexemVector::const_iterator lbrack_close_it = to; // Corresponding close brack - LexemVector::const_iterator assign_it = to; // First = at paren_level 0 for assignment - LexemVector::const_iterator term_it = to; // Last + or - at paren_level 0 for adding or subtracting - LexemVector::const_iterator factor_it = to; // Last * or / at paren_level 0 for multiplying or dividing - LexemVector::const_iterator relation_it = to; // Last relational at paren_level 0 for relational operator - LexemVector::const_iterator logical_it = to; // Last logical at paren_level 0 for logical operator - LexemVector::const_iterator question_it = to; // Last tiernary at paren_level 0 for tiernary operator - LexemVector::const_iterator colon_it = to; - LexemVector::const_iterator unary_it = to; // First +,- at plevel 0 for positive,negative - LexemVector::const_iterator last_unary_it = to; // Last +,- found at plevel for for positive,negative - - // Scan the expression for the instances of the above tokens - for (LexemVector::const_iterator it = from; it != to; ++it) { - switch((*it).getToken()) { - case TOKEN_LPAREN: - if (paren_level == 0 && lparen_open_it == to - && brack_level == 0 && lbrack_open_it == to) - lparen_open_it = it; - paren_level++; - break; - - case TOKEN_RPAREN: - paren_level--; - - if (paren_level == 0 && lparen_close_it == to - && brack_level == 0 && lbrack_close_it == to) - lparen_close_it = it; - - if (paren_level < 0) - throw std::runtime_error("mismatched parenthesis"); - break; - - case TOKEN_LBRACK: - if (paren_level == 0 && lparen_open_it == to - && brack_level == 0 && lbrack_open_it == to) - lbrack_open_it = it; - brack_level++; - break; - - case TOKEN_RBRACK: - brack_level--; - - if (paren_level == 0 && lparen_close_it == to - && brack_level == 0 && lbrack_close_it == to) - lbrack_close_it = it; - - if (brack_level < 0) - throw std::runtime_error("mismatched bracket"); - break; - - case TOKEN_ASSIGN: - if (paren_level == 0 && assign_it == to) - assign_it = it; - break; - - case TOKEN_QUESTION: - if (paren_level == 0 && question_it == to) - question_it = it; - break; - - case TOKEN_COLON: - if (paren_level == 0) // && colon_it == to) - colon_it = it; - break; - - case TOKEN_EXPONENTIATION: - case TOKEN_MULTIPLY: - case TOKEN_DIVIDE: -// case TOKEN_PERCENT: - if (paren_level == 0) // && factor_it == to) - factor_it = it; - break; - - case TOKEN_EQUAL: - case TOKEN_NOT_EQUAL: - case TOKEN_LESS: - case TOKEN_GREATER: - case TOKEN_LESS_EQUAL: - case TOKEN_GREATER_EQUAL: - if (paren_level == 0 && relation_it == to) - relation_it = it; - break; - - case TOKEN_LOGICAL_AND: - case TOKEN_LOGICAL_OR: - if (paren_level == 0 && logical_it == to) - logical_it = it; - break; - - case TOKEN_PLUS: - case TOKEN_MINUS: - if (paren_level == 0) { - // After any of these, we are a unary operator, not a term - if (it == from || it == assign_it + 1 - || it == term_it + 1 || it == factor_it + 1 - || it == last_unary_it + 1) - { // Unary operator - if (unary_it == to) // First unary operator? - unary_it = it; - last_unary_it = it; - } - else { // Term - term_it = it; - } - } - break; - - case TOKEN_NOT: - if (paren_level == 0) { - if (unary_it == to) /// First unary operator - unary_it = it; - last_unary_it = it; - } - break; - - default: - break; - } - } - - if (paren_level != 0) // paren_level should now be zero */ - throw std::runtime_error("mismatched parenthesis"); - - // This implement the operator hiearchy - // Assignment - if (assign_it != to) - return parseAssign(eval, from, assign_it, to); - - // Tiernary operator - if (question_it != to || colon_it != to) - return parseTiernary(eval, from, question_it, colon_it, to); - - // Logical - if (logical_it != to) - return parseLogical(eval, from, logical_it, to); - - // Relational - if (relation_it != to) - return parseRelation(eval, from, relation_it, to); - - // Term - if (term_it != to) - return parseTerm(eval, from, term_it, to); - - // Factor - if (factor_it != to) - return parseFactor(eval, from, factor_it, to); - - // Unary - if (unary_it != to) - return parseUnary(eval, from, unary_it, to); - - // Parenthetical - if (lparen_open_it != to) { - if (lparen_open_it == from) { - if (lparen_close_it == to - 1 && lparen_close_it - lparen_open_it > 1) - return parseExpression(eval, lparen_open_it + 1, lparen_close_it); - else - throw std::runtime_error("syntax error parsing parentheses"); - } - - // Function - if (lparen_open_it == from + 1) { - if (lparen_close_it == to - 1) - return parseFunction(eval, from, lparen_open_it, lparen_close_it, to); - else // Closing paren not at to - throw std::runtime_error("syntax error 2"); - } - - throw std::runtime_error("syntax error 3"); - } - - // Bracket - if (lbrack_open_it != to) { - - // Array index - if (lbrack_open_it == from + 1) { - if (lbrack_close_it == to - 1) - return parseIndex(eval, from, lbrack_open_it, lbrack_close_it, to); - else // Closing brack not at to - throw std::runtime_error("syntax error 2"); - } - - throw std::runtime_error("syntax error 3"); - } - - // R-Value - return parseRValue(eval, from, to); -} - - -Node * -parseAssign( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator assign_it, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) // || from + 1 != assign_it) { - throw std::runtime_error("stk_classic::expreval::parseAssign: expected identifier"); - - Node *assign; - - if ((*(from + 1)).getToken() == TOKEN_ASSIGN || (*(from + 1)).getToken() == TOKEN_LBRACK) { - assign = eval.newNode(OPCODE_ASSIGN); - - assign->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - assign->m_right = parseExpression(eval, assign_it + 1, to); - - if ((*(from + 1)).getToken() == TOKEN_LBRACK) - assign->m_left = parseExpression(eval, from + 2, assign_it - 1); - } - else - throw std::runtime_error("syntax error"); - - return assign; -} - - -Node * -parseTerm( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator term_it, - LexemVector::const_iterator to) -{ - Node *term = eval.newNode((*term_it).getToken() == TOKEN_PLUS ? OPCODE_ADD : OPCODE_SUBTRACT); - - term->m_left = parseExpression(eval, from, term_it); - term->m_right = parseExpression(eval, term_it + 1, to); - - return term; -} - - -Node * -parseFactor( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator factor_it, - LexemVector::const_iterator to) -{ - Node *factor = eval.newNode((*factor_it).getToken() == TOKEN_MULTIPLY ? OPCODE_MULTIPLY : OPCODE_DIVIDE); - - factor->m_left = parseExpression(eval, from, factor_it); - factor->m_right = parseExpression(eval, factor_it + 1, to); - - return factor; -} - - -Node * -parseRelation( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator relation_it, - LexemVector::const_iterator to) -{ - Opcode relation_opcode = OPCODE_UNDEFINED; - - switch ((*relation_it).getToken()) { - case TOKEN_EQUAL: - relation_opcode = OPCODE_EQUAL; - break; - - case TOKEN_NOT_EQUAL: - relation_opcode = OPCODE_NOT_EQUAL; - break; - - case TOKEN_LESS: - relation_opcode = OPCODE_LESS; - break; - - case TOKEN_GREATER: - relation_opcode = OPCODE_GREATER; - break; - - case TOKEN_LESS_EQUAL: - relation_opcode = OPCODE_LESS_EQUAL; - break; - - case TOKEN_GREATER_EQUAL: - relation_opcode = OPCODE_GREATER_EQUAL; - break; - - default: - break; - } - - Node *relation = eval.newNode(relation_opcode); - - relation->m_left = parseExpression(eval, from, relation_it); - relation->m_right = parseExpression(eval, relation_it + 1, to); - - return relation; -} - - -Node * -parseLogical( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator logical_it, - LexemVector::const_iterator to) -{ - Node *logical = eval.newNode(((*logical_it).getToken() == TOKEN_LOGICAL_AND ? OPCODE_LOGICAL_AND : OPCODE_LOGICAL_OR)); - - logical->m_left = parseExpression(eval, from, logical_it); - logical->m_right = parseExpression(eval, logical_it + 1, to); - - return logical; -} - - -Node * -parseTiernary( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator question_it, - LexemVector::const_iterator colon_it, - LexemVector::const_iterator to) -{ - if (question_it == to || colon_it == to) - throw std::runtime_error("syntax error parsing ?: operator"); - - Node *tiernary = eval.newNode(OPCODE_TIERNARY); - - tiernary->m_left = parseExpression(eval, from, question_it); - tiernary->m_right = parseExpression(eval, question_it + 1, colon_it); - tiernary->m_other = parseExpression(eval, colon_it + 1, to); - - return tiernary; -} - - -Node * -parseUnary( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator unary_it, - LexemVector::const_iterator to) -{ - /* If it is a positive, just parse the internal of it */ - if ((*unary_it).getToken() == TOKEN_PLUS) - return parseExpression(eval, unary_it + 1, to); - else if ((*unary_it).getToken() == TOKEN_MINUS) { - Node *unary = eval.newNode(OPCODE_UNARY_MINUS); - unary->m_right = parseExpression(eval, unary_it + 1, to); - return unary; - } - else if ((*unary_it).getToken() == TOKEN_NOT) { - Node *unary = eval.newNode(OPCODE_UNARY_NOT); - unary->m_right = parseExpression(eval, unary_it + 1, to); - return unary; - } - else - throw std::runtime_error("syntax error parsing unary operator"); -} - - -Node * -parseFunction( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator lparen, - LexemVector::const_iterator rparen, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) - throw std::runtime_error("syntax error parsing function"); - - const std::string &function_name = (*from).getString(); - - CFunctionBase *c_function = NULL; - Eval::CFunctionMap::iterator it = Eval::getCFunctionMap().find(function_name); - if (it != Eval::getCFunctionMap().end()) - c_function = (*it).second; - -// if (!c_function) -// throw std::runtime_error(std::string("Undefined function ") + function_name); - - Node *function = eval.newNode(OPCODE_FUNCTION); - function->m_data.function.function = c_function; - - if (!c_function) - eval.getUndefinedFunctionSet().insert(function_name); - - function->m_right = parseFunctionArg(eval, lparen + 1, rparen); - - // if (!c_function) - // throw std::runtime_error(std::string("Undefined function ") + function_name); - - return function; -} - - -Node * -parseIndex( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator lbrack, - LexemVector::const_iterator rbrack, - LexemVector::const_iterator to) -{ - if ((*from).getToken() != TOKEN_IDENTIFIER) - throw std::runtime_error("syntax error parsing array"); - - Node *index = eval.newNode(OPCODE_RVALUE); - index->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - index->m_left = parseExpression(eval, lbrack + 1, rbrack); - - return index; -} - - -Node * -parseFunctionArg( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if (from == to) - return NULL; - - LexemVector::const_iterator it; - for (it = from; it != to && (*it).getToken() != TOKEN_COMMA; ++it) - ; - - Node *argument = eval.newNode(OPCODE_ARGUMENT); - argument->m_left = parseExpression(eval, from, it); - if (it != to) - argument->m_right = parseFunctionArg(eval, it + 1, to); - return argument; -} - - -Node * -parseRValue( - Eval & eval, - LexemVector::const_iterator from, - LexemVector::const_iterator to) -{ - if (from + 1 != to) - throw std::runtime_error(std::string("r-value not allowed following ") + (*from).getString()); - - switch ((*from).getToken()) { - case TOKEN_IDENTIFIER: - { - Eval::ConstantMap::iterator it = Eval::getConstantMap().find((*from).getString()); - if (it != Eval::getConstantMap().end()) { - Node *constant = eval.newNode(OPCODE_CONSTANT); - constant->m_data.constant.value = (*it).second; - return constant; - } - - // Define a variable - else { - Node *variable = eval.newNode(OPCODE_RVALUE); - variable->m_data.variable.variable = eval.getVariableMap()[(*from).getString()]; - return variable; - } - } - - case TOKEN_REAL_CONSTANT: - case TOKEN_INTEGER_CONSTANT: - { - Node *constant = eval.newNode(OPCODE_CONSTANT); - constant->m_data.constant.value = (*from).getValue(); - return constant; - } - - default: - throw std::runtime_error("invalid rvalue"); - } -} - -} // namespace Parser - -extern "C" { - typedef FADDouble (*CExtern0)(); - typedef FADDouble (*CExtern1)(FADDouble); - typedef FADDouble (*CExtern2)(FADDouble, FADDouble); -} - - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern0 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(0), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch"); - - return (*m_function)(); - } - -private: - Signature m_function; -}; - - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern1 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(1), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch"); - - return (*m_function)(argv[0]); - } - -private: - Signature m_function; -}; - - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern2 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(2), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch"); - - return (*m_function)(argv[0], argv[1]); - } - -private: - Signature m_function; -}; - - -typedef CFunction CFunction0; -typedef CFunction CFunction1; -typedef CFunction CFunction2; - - -extern "C" { - static FADDouble real_rand() { - return (FADDouble) std::rand() / ((FADDouble)(RAND_MAX) + 1.0); - } - - static FADDouble real_srand(FADDouble x) { - std::srand(0); // (int) x); - return 0.0; - } - - static FADDouble randomize() { -#ifndef SIERRA_SRAND_OK - std::srand((::clock() + 1024) * ::time(NULL)); -#endif - return 0.0; - } -} - - -const double -Eval::s_e = 2.7182818284590452354; - -const double -Eval::s_pi = 3.14159265358979323846; - -const double -Eval::s_false = 0.0; - -const double -Eval::s_true = 1.0; - - -Eval::VariableMap::Resolver & -Eval::VariableMap::getDefaultResolver() -{ - static DefaultResolver default_resolver; - - return default_resolver; -} - - -Eval::ConstantMap & -Eval::getConstantMap() -{ - static Eval::ConstantMap s_constantMap; - - if (s_constantMap.empty()) { - s_constantMap["E"] = s_e; - s_constantMap["PI"] = s_pi; - s_constantMap["FALSE"] = Eval::s_false; - s_constantMap["TRUE"] = Eval::s_true; - } - - return s_constantMap; -} - - -class CFunctionExp : public CFunctionBase -{ -public: - CFunctionExp() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return exp(argv[0]); - } -}; - - -class CFunctionLog : public CFunctionBase -{ -public: - CFunctionLog() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return log(argv[0]); - } -}; - - -class CFunctionLog10 : public CFunctionBase -{ -public: - CFunctionLog10() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return log10(argv[0]); - } -}; - - -class CFunctionPow : public CFunctionBase -{ -public: - CFunctionPow() - : CFunctionBase(2) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return pow(argv[0], argv[1]); - } -}; - - -class CFunctionSqrt : public CFunctionBase -{ -public: - CFunctionSqrt() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return sqrt(argv[0]); - } -}; - - -class CFunctionAcos : public CFunctionBase -{ -public: - CFunctionAcos() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return acos(argv[0]); - } -}; - - -class CFunctionAsin : public CFunctionBase -{ -public: - CFunctionAsin() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return asin(argv[0]); - } -}; - - -class CFunctionAtan : public CFunctionBase -{ -public: - CFunctionAtan() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return atan(argv[0]); - } -}; - - -// class CFunctionAtan2 : public CFunctionBase -// { -// public: -// CFunctionAtan2() -// : CFunctionBase(2) -// {} - -// virtual FADDouble operator()(int argc, const FADDouble *argv) { -// return atan2(argv[0], argv[1]); -// } -// }; - - -class CFunctionCos : public CFunctionBase -{ -public: - CFunctionCos() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return cos(argv[0]); - } -}; - - -class CFunctionCosh : public CFunctionBase -{ -public: - CFunctionCosh() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return cosh(argv[0]); - } -}; - - -class CFunctionSin : public CFunctionBase -{ -public: - CFunctionSin() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return sin(argv[0]); - } -}; - - -class CFunctionSinh : public CFunctionBase -{ -public: - CFunctionSinh() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return sinh(argv[0]); - } -}; - - -class CFunctionTan : public CFunctionBase -{ -public: - CFunctionTan() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return tan(argv[0]); - } -}; - - -class CFunctionTanh : public CFunctionBase -{ -public: - CFunctionTanh() - : CFunctionBase(1) - {} - - virtual FADDouble operator()(int argc, const FADDouble *argv) { - return tanh(argv[0]); - } -}; - - -Eval::CFunctionMap::CFunctionMap() -{ - (*this)["rand"] = new CFunction0(real_rand); - (*this)["srand"] = new CFunction1(real_srand); - (*this)["randomize"] = new CFunction0(randomize); - - (*this)["exp"] = new CFunctionExp(); - (*this)["ln"] = new CFunctionLog(); - (*this)["log"] = new CFunctionLog(); - (*this)["log10"] = new CFunctionLog10(); - (*this)["pow"] = new CFunctionPow(); - (*this)["sqrt"] = new CFunctionSqrt(); - - (*this)["acos"] = new CFunctionAcos(); - (*this)["asin"] = new CFunctionAsin(); - (*this)["atan"] = new CFunctionAtan(); - (*this)["cos"] = new CFunctionCos(); - (*this)["cosh"] = new CFunctionCosh(); - (*this)["sin"] = new CFunctionSin(); - (*this)["sinh"] = new CFunctionSinh(); - (*this)["tan"] = new CFunctionTan(); - (*this)["tanh"] = new CFunctionTanh(); -} - -Eval::CFunctionMap::~CFunctionMap() -{ - for (CFunctionMap::iterator it = begin(); it != end(); ++it) - delete (*it).second; -} - - -Eval::CFunctionMap & -Eval::getCFunctionMap() -{ - static CFunctionMap s_functionMap; - - return s_functionMap; -} - -Eval::Eval( - VariableMap::Resolver & resolver, - const std::string & expression) - : m_variableMap(resolver), - m_expression(expression), - m_parseStatus(false), - m_headNode(0) -{} - - -Eval::~Eval() -{ - for (std::vector::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it) - delete (*it); -} - - -Node * -Eval::newNode( - int opcode) -{ - Node *new_node = new Node((Opcode) opcode); - m_nodes.push_back(new_node); - return new_node; -} - - -void -Eval::syntax() -{ - m_syntaxStatus = false; - m_parseStatus = false; - - try { - /* Validate the characters */ - LexemVector lex_vector = tokenize(m_expression); - - /* Call the multiparse routine to parse subexpressions */ - m_headNode = Parser::parseStatements(*this, lex_vector.begin(), lex_vector.end()); - - m_syntaxStatus = true; - } - catch (std::runtime_error & /* x */) { -// x << " while parsing expression: " << m_expression; -// RuntimeDoomed() << x.what(); - throw; - } -} - - -void -Eval::parse() -{ - try { - syntax(); - - if (m_syntaxStatus) { - if (!m_undefinedFunctionSet.empty()) { - std::ostringstream strout; - strout << "In expression '" << m_expression << "', the following functions are not defined:" << std::endl; - // for (iteration it(m_undefinedFunctionSet); it; ++it) - for (UndefinedFunctionSet::iterator it = m_undefinedFunctionSet.begin(); it != m_undefinedFunctionSet.end(); ++it) - strout << (*it) << std::endl; - throw std::runtime_error(strout.str()); - } - - resolve(); - - m_parseStatus = true; - } - } - catch (std::runtime_error & /* x */) { -// x << " while parsing expression: " << m_expression; -// RuntimeDoomed() << x.what(); - throw; - } -} - - -void -Eval::resolve() -{ - for (VariableMap::iterator it = m_variableMap.begin(); it != m_variableMap.end(); ++it) { - m_variableMap.getResolver().resolve(it); - } -} - - -FADDouble -Eval::evaluate() const -{ - /* Make sure it was parsed successfully */ - if (!m_parseStatus) - throw std::runtime_error(std::string("Expression '") + m_expression + "' did not parse successfully"); - - return m_headNode->eval(); -} - -} // namespace fad -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.hpp deleted file mode 100644 index cf3996b64282..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/ExprEvalFAD.hpp +++ /dev/null @@ -1,754 +0,0 @@ -#ifndef STK_ExprEvalFAD_hpp -#define STK_ExprEvalFAD_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace expreval { -namespace fad { - -typedef Sacado::Fad::DFad FADDouble; - -/** - * @brief Class CFunctionBase is a base class for calling a function from the - * expression evaluator. Classes which inherit from this function must implement a - * operator() function which accepts an argument count and an array of length - * that count of pointer to the argument values. This function should perform whatever - * argument manipulation is required to call the actual implementation of the function. - * - */ -class CFunctionBase -{ -public: - /** - * Creates a new CFunctionBase instance. - * - * @param arg_count an int value of the number of arguments - * expected when operator() is called. - */ - explicit CFunctionBase(int arg_count) - : m_argCount(arg_count) - {} - - virtual ~CFunctionBase() - {} - - /** - * @brief Member function operator() is the pure virtual interface to the - * function. This function is overloaded to implement the calculation to be performed - * when the function is called. - * - * @param argc an int value of the number of arguments. - * - * @param argv a FADDouble pointer to an array of FADDouble - * pointers to the actual function arguments. - * - * @return a FADDouble value of the result of the execution - * of the function. - */ - virtual FADDouble operator()(int argc, const FADDouble *argv) = 0; - - /** - * @brief Member function getArgCount returns the argument count for this - * function. - * - * @return an int value of the argument count for this - * function. - */ - int getArgCount() const { - return m_argCount; - } - -private: - int m_argCount; ///< Argument count for this function -}; - - -/** - * @brief Class CFunction declares a base template for template instantiation - * of C-like called functions. - * - */ -template -class CFunction; - -class Node; - -/** - * Class Eval parses and evaluates mathematical expressions. - * - */ -class Eval -{ -public: - static const double s_e; ///< Constant "e" - static const double s_pi; ///< Constant "pi" - static const double s_false; ///< Constant "false" - static const double s_true; ///< Constant "true" - -public: - /** - * @brief Class CFunctionMap maps function names to c-style function pointers via - * the CFunctionBase base class. The mapping is case insensitive. - * - */ - class CFunctionMap : public std::map - { - public: - /** - * Creates a new CFunctionMap instance. - * - * The CFunctionMap is populated with common C functions on construction. - * - */ - CFunctionMap(); - - /** - * Destroys a CFunctionMap instance. - * - */ - ~CFunctionMap(); - }; - - /** - * @brief Typedef ConstantMap maps a constant name to a double constant. - * The mapping is case insensitive. - * - */ - typedef std::map ConstantMap; - - typedef std::set UndefinedFunctionSet; - - /** - * @brief Class Variable defines a variable for the expression evaluation - * virtual machine. Typing is limited to int and double. While all operations are - * performed as doubles, the value and results may be retrieved and stored as integer - * values. - * - * Array indexing is also supported, but no bounds checkin is available and only double - * type array may be addressed. - * - * Variable are implemented as a pointer, "typed" by the Type enumeration - * to the actual value. At construction, this may point to a "local" double value or - * integer value, or the address may be specified. In either case, a type and address - * for the variable may be provided via variable "binding". - * - */ - class Variable - { - public: - /** - * @brief Enumeration Type lists the variable data types. double and - * int are currently supported. - * - */ - enum Type {FADDOUBLE}; - - /** - * Creates a new Variable instance. - * - */ - Variable() - : m_type(FADDOUBLE), - m_FADDoublePtr(&m_FADDoubleValue), - m_FADDoubleValue(0.0) - {} - - /** - * Creates a new Variable instance. The new variable will be local and - * have the type specified by type. - * - * @param type an Type value of the type of the new - * variable. - * - */ - explicit Variable(Type type) - : m_type(type) - { - switch (type) { - case FADDOUBLE: - m_FADDoublePtr = &m_FADDoubleValue; - m_FADDoubleValue = 0.0; - break; - } - } - - /** - * Creates a new Variable instance. The new variable will use the - * address specified by address and be of type FADDouble. This address must - * remain in scope during the lifetime of the variable are until rebound to a new - * address. - * - * @param address an FADDouble reference to the value for this - * variable. - * - */ - explicit Variable(FADDouble &address) - : m_type(FADDOUBLE), - m_FADDoublePtr(&address), - m_FADDoubleValue(0.0) - {} - - /** - * @brief Member function operator= assigns a new value to the variable. - * If the variable type is integer, the value is converted to integer before - * assignment. - * - * @param value a FADDouble value that is to be assigned to the - * variable. - * - * @return a Variable reference to the variable. - */ - Variable &operator=(const FADDouble &value) { - if (m_type == FADDOUBLE) - *m_FADDoublePtr = value; - return *this; - } - - /** - * @brief Member function operator= assigns a new value to the variable. - * If the variable type is FADDouble, the value is converted to FADDouble before assignment. - * - * @param value an int value that is to be assigned to the - * variable. - * - * @return a Variable reference to the variable. - */ - Variable &operator=(const int &value) { - if (m_type == FADDOUBLE) - *m_FADDoublePtr = (FADDouble) value; - return *this; - } - - /** - * @brief Member function operator[] returns a value from an array of - * FADDouble values. No bounds checkin is performed. Not even if the variable is and - * array is checked. - * - * @param index a FADDouble value of the zero based index into - * the array to retrieve the value. - * - * @return a FADDouble reference to the value. - */ - inline FADDouble &operator[](FADDouble index) { - if (m_type != FADDOUBLE) - throw std::runtime_error("Only FADDouble arrays allowed"); - - if ((void *) m_FADDoublePtr == 0) - throw std::runtime_error("Unbound variable"); - - int i = 0; // (int) index; - - return m_FADDoublePtr[i]; - } - - /** - * @brief Member function operator[] returns a value from an array of - * FADDouble values. No bounds checkin is performed. Not even if the variable is and - * array is checked. - * - * @param index a int value of the zero based index into the - * array to retrieve the value. - * - * @return a FADDouble reference to the value. - */ - inline FADDouble &operator[](int index) { - if (m_type != FADDOUBLE) - throw std::runtime_error("Only FADDouble arrays allowed"); - - if ((void *) m_FADDoublePtr == 0) - throw std::runtime_error("Unbound variable"); - - return m_FADDoublePtr[index]; - } - - /** - * @brief Member function bind binds variable to the address of the - * specified value. The type is converted to FADDouble. This address must remain in - * scope during the lifetime of the variable are until rebound to a new address. - * - * @param value_ref a FADDouble reference to be used for this variable. - * - * @return a Variable reference to the variable. - */ - inline Variable &bind(FADDouble &value_ref) { - m_type = FADDOUBLE; - m_FADDoublePtr = &value_ref; - return *this; - } - - /** - * @brief Member function unbind binds the variable to the local value - * and reinitializes that value to zero. The type is left unchanged. - * - * @return a Variable reference to the variable. - */ - inline Variable &unbind() { - switch (m_type) { - case FADDOUBLE: - m_FADDoublePtr = &m_FADDoubleValue; - m_FADDoubleValue = 0.0; - break; - } - return *this; - } - - /** - * @brief Member function getValue returns the variable value as a FADDouble. - * - * @return a FADDouble value of the value of the variable. - */ - inline FADDouble getValue() const { - switch (m_type) { - case FADDOUBLE: - return *m_FADDoublePtr; - } - throw std::runtime_error("Invalid variable type"); - } - - private: - Type m_type; ///< Variable data type - FADDouble * m_FADDoublePtr; ///< Pointer to value as FADDouble - FADDouble m_FADDoubleValue; ///< Local variable value as FADDouble - }; - - /** - * @brief Class VariableMap implements a mapping from name to a pointer to - * a Variable object. The mapping is case insensitive. - * - */ - class VariableMap : public std::map - { - public: - /** - * @brief Typedef value_type is the value_type of the - * std::map subclass. The mapping is case insensitive. - * - */ - typedef std::map::value_type value_type; - - /** - * @brief Class Resolver is a base class for a variable name to value - * resolver. After parsing of an expression, a list of variable names is collected. - * The resolve member function will be called for each of these during - * the expression resolve stage. This function may bind a new value to the variable, - * ignore the variable by leaving the initialized local binding, or throw an exception - * stating the variable cannot be resolved. - * - */ - class Resolver - { - public: - /** - * Creates a new Resolver instance. - * - */ - Resolver() - {} - - /** - * Destroys a Resolver instance. - * - */ - virtual ~Resolver() - {} - - /** - * @brief Member function resolve is the virtual member function for - * the variable resolver. - * - * @param it a VariableMap::iterator reference to the - * variable whose name is to be resolved. - */ - virtual void resolve(VariableMap::iterator &it) = 0; - }; - - private: - /** - * @brief Member function delete_variable is a function which will delete - * the variabel pointed to by t. - * - * @param t a value_type reference to the variable to be - * deleted. - */ - static void delete_variable(value_type &t) { - delete t.second; - } - - /** - * @brief Class DefaultResolver implement a default resolver. - * - */ - class DefaultResolver : public Resolver - { - public: - DefaultResolver() - {} - - /** - * Destroys a DefaultResolver instance. - * - */ - virtual ~DefaultResolver() - {} - - /** - * @brief Member function resolve implements the default resolvers - * function, whihc does nothing. I.E. lets the local variable values stand. - * - * @param it a VariableMap::iterator variable ... - */ - virtual void resolve(VariableMap::iterator &it) - {} - }; - - public: - /** - * @brief Member function getDefaultResolver returns a reference to the - * default resolver. - * - * @return a Resolver ... - */ - static Resolver &getDefaultResolver(); - - /** - * Creates a new VariableMap instance with the specified variable name - * resolver. - * - * @param resolver a Resolver reference to the variable name - * resolver for this variable map. - * - */ - VariableMap(Resolver &resolver = getDefaultResolver()) - : std::map(), - m_resolver(resolver) - {} - - /** - * Destroys a VariableMap instance. All variables are destroyed. - * - */ - ~VariableMap() { - std::for_each(begin(), end(), &delete_variable); - } - - /** - * @brief Member function operator[] ... - * - * @param s a std::string const reference to the variable's - * name. - * - * @return a Variable pointer to the new variable. - */ - Variable *operator[](const std::string &s) { - std::pair i = insert(std::pair(s, (Variable *) 0)); - if (i.second) - (*i.first).second = new Variable(); - return (*i.first).second; - } - - /** - * @brief Member function getResolver returns a reference to the name - * resolver. - * - * @return a Resolver reference to the variable name - * resolver. - */ - Resolver &getResolver() { - return m_resolver; - } - - private: - Resolver & m_resolver; ///< Reference to this variabl map name resolver - }; - - /** - * @brief Member function getCFunctionMap returns a reference to the - * C-style function map. - * - * @return a CFunctionMap reference to the C-style - * function map. - */ - static CFunctionMap &getCFunctionMap(); - - /** - * @brief Member function getConstantMap returns s reference to the defined - * constants. - * - * @return a ConstantMap reference to the defined - * constants. - */ - static ConstantMap &getConstantMap(); - - /** - * @brief Member function addFunction adds a C-style function to the - * C-style function map. - * - * @param name a std::string const reference to the function - * name. - * - * @param function a CFunctionBase pointer to the C-style - * function. - */ - static void addFunction(const std::string &name, CFunctionBase *function) { - getCFunctionMap()[name] = function; - } - - /** - * Creates a new Eval instance. - * - * @param resolver a Resolver reference to the variable name - * resolver for this expression evaluator. - * - * @param expr a std::string const reference to the - * expression to be parsed. - */ - Eval(VariableMap::Resolver &resolver = VariableMap::getDefaultResolver(), const std::string &expr = ""); - -private: - explicit Eval(const Eval &); - Eval &operator=(const Eval &); - -public: - /** - * Destroys a Eval instance. - * - */ - ~Eval(); - - /** - * @brief Member function getExpression returns the original text of the expression. - * - * @return a std::string const reference to the - * expression. - */ - inline const std::string &getExpression() const { - return m_expression; - } - - /** - * @brief Member function setExpression gives the evaluator a new - * expression to parse. - * - * @param expression a std::string const refernce to the - * expression to be parsed. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &setExpression(const std::string &expression) { - m_expression = expression; - m_parseStatus = false; - return *this; - } - - /** - * @brief Member function getVariableMap returns a reference to the - * variable map of this expression. - * - * @return a VariableMap reference to the variable map. - */ - inline VariableMap &getVariableMap() { - return m_variableMap; - } - - /** - * @brief Member function getVariableMap returns a reference to the - * variable map of this expression. - * - * @return a VariableMap reference to the variable map. - */ - inline UndefinedFunctionSet &getUndefinedFunctionSet() { - return m_undefinedFunctionSet; - } - - /** - * @brief Member function getSyntaxStatus returns true if the expression has - * been syntaxd successfully. - * - * @return a bool value of true if the expression has - * been syntaxd successfully. - */ - inline bool getSyntaxStatus() const { - return m_syntaxStatus; - } - - /** - * @brief Member function getParseStatus returns true if the expression has - * been parsed successfully. - * - * @return a bool value of true if the expression has - * been parsed successfully. - */ - inline bool getParseStatus() const { - return m_parseStatus; - } - - /** - * @brief Member function setValue assigns a variables value in the - * variable map. - * - * @param name a std::string const reference of the name of the - * variable. - * - * @param value a FADDouble value to be assigned to the - * variable. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &setValue(const std::string &name, FADDouble value) { - VariableMap::iterator it = m_variableMap.find(name); - if (it != m_variableMap.end()) - *(*it).second = value; - return *this; - } - - /** - * @brief Member function getValue returns the value of the variable - * specified by name. - * - * @param name a std::string const reference to the variable's - * name. - * - * @return a FADDouble value of the variable. - */ - inline FADDouble getValue(const std::string &name) { - VariableMap::iterator it = m_variableMap.find(name); - if (it == m_variableMap.end()) - throw std::runtime_error(std::string("Variable ") + name + " not defined"); - return (*it).second->getValue(); - } - - /** - * @brief Member function newNode allocates a new node. The - * new node is allocated on a node list so that it may be - * deallocated properly on exception. - * - * @param opcode a int value of the opcode for the node. - * - * @return a Node pointer to the newly allocated node. - */ - Node *newNode(int op); - - /** - * @brief Member function bindVariable binds the variable to the address of - * the specified value. This address must remain in scope during the lifetime of the - * variable are until rebound to a new address. - * - * @param name a std::string const reference to the variable's - * name. - * - * @param value_ref a FADDouble reference to be used for this variable. - * - * @return an Eval reference to this expression - * evaluator. - */ - inline Eval &bindVariable(const std::string &name, FADDouble &value_ref) { - VariableMap::iterator it = m_variableMap.find(name); - if (it != m_variableMap.end()) - (*it).second->bind(value_ref); - return *this; - } - - /** - * @brief Member function getVariable returns a reference to the variable - * specified by name. - * - * @param name a std::string const reference to the variable's - * name. - * - * @return a Variable reference to the specified - * variable. - */ - inline Variable &getVariable(const std::string &name) { - VariableMap::iterator it = m_variableMap.find(name); - if (it == m_variableMap.end()) - throw std::runtime_error(std::string("Variable ") + name + " not defined"); - - return *(*it).second; - } - - /** - * @brief Member function parse parses the expression. If successful, the - * parse status is set to true. - * - * @param expr a std::string const reference to the - * expression to parse. - * - */ - inline void syntaxCheck(const std::string &expr) { - setExpression(expr); - syntax(); - } - - /** - * @brief Member function syntax performs a syntax check on the current - * expression. If successful, the syntax status is set to true. - * - */ - void syntax(); - - /** - * @brief Member function parse parses the expression. If successful, the - * parse status is set to true. - * - * @param expr a std::string const reference to the - * expression to parse. - * - */ - inline void parse(const std::string &expr) { - setExpression(expr); - parse(); - } - - /** - * @brief Member function parse parses the current expression. If - * successful, the parse status is set to true. - * - */ - void parse(); - - /** - * @brief Member function resolve calls the variable name resolver for each - * variable in the variable map. - * - */ - void resolve(); - - /** - * @brief Member function evaluate evaluates the expression. - * - * @return a FADDouble value of the result on the - * expression evaluation. - */ - FADDouble evaluate() const; - -private: - VariableMap m_variableMap; ///< Variable map - UndefinedFunctionSet m_undefinedFunctionSet; ///< Vector of undefined functions - - std::string m_expression; ///< Expression which was parsed. - bool m_syntaxStatus; ///< True if syntax is correct - bool m_parseStatus; ///< True if parsed successfully - - Node * m_headNode; ///< Head of compiled expression - std::vector m_nodes; ///< Allocated nodes -}; - -} // namespace fad -} // namespace expreval -} // namespace stk_classic - -#endif // STK_ExprEvalFAD_hpp diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.cpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.cpp deleted file mode 100644 index ac0bc535ae26..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.cpp +++ /dev/null @@ -1,504 +0,0 @@ -#include -#include -#include -#include //Needed for erf and erfc on solaris. - -#include -#include - -#include - -namespace stk_classic { -namespace expreval { - - namespace bmp = boost::math::policies; - -typedef boost::math:: - weibull_distribution< double, - boost::math::policies::policy< bmp::overflow_error > > - weibull_dist; - -typedef boost::math:: - gamma_distribution< double, - bmp::policy< bmp::overflow_error > > - gamma_dist; - -typedef boost::math:: - normal_distribution< double, - bmp::policy< bmp::overflow_error > > - normal_dist; - -extern "C" { - typedef double (*CExtern0)(); - typedef double (*CExtern1)(double); - typedef double (*CExtern2)(double, double); - typedef double (*CExtern3)(double, double, double); - typedef double (*CExtern4)(double, double, double, double); -} - -static int sRandomRangeHighValue = 3191613; -static int sRandomRangeLowValue = 1739623; - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern0 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(0), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual double operator()(int argc, const double *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch, function should have 0 arguments"); - - return (*m_function)(); - } - -private: - Signature m_function; -}; - - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern1 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(1), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual double operator()(int argc, const double *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch, function should have 1 argument"); - - return (*m_function)(argv[0]); - } - -private: - Signature m_function; -}; - - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern2 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(2), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual double operator()(int argc, const double *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch, function should have 2 arguments"); - - return (*m_function)(argv[0], argv[1]); - } - -private: - Signature m_function; -}; - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern3 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(3), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual double operator()(int argc, const double *argv) { - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch, function should have 3 arguments"); - - return (*m_function)(argv[0], argv[1], argv[2]); - } - -private: - Signature m_function; -}; - -template <> -class CFunction : public CFunctionBase -{ -public: - typedef CExtern4 Signature; - - explicit CFunction(Signature function) - : CFunctionBase(4), - m_function(function) - {} - - virtual ~CFunction() - {} - - virtual double operator()(int argc, const double *argv) { - // KHP: Maybe only check in debug? - if (argc != getArgCount()) - throw std::runtime_error("Argument count mismatch, function should have 4 arguments"); - return (*m_function)(argv[0], argv[1], argv[2], argv[3]); - } - -private: - Signature m_function; -}; - -typedef CFunction CFunction0; -typedef CFunction CFunction1; -typedef CFunction CFunction2; -typedef CFunction CFunction3; -typedef CFunction CFunction4; - - -extern "C" { - /// extract signed integral value from floating-point number - static double ipart(double x) { - double y; - std::modf(x, &y); - return y; - } - - /// Extract fractional value from floating-point number - static double fpart(double x) { - double y; - return std::modf(x, &y); - } - - /// Interface to the pseudo-random number generator function rand - /// provided by ANSI C math library. - static double real_rand() { - return (double) std::rand() / ((double)(RAND_MAX) + 1.0); - } - - /// Sets x as the "seed". Interface to the srand function provided by the - /// ANSI C math library. - static double real_srand(double x) { - std::srand(static_cast(x)); - return 0.0; - } - - /// Return the current time - static double current_time() { - return static_cast(::time(NULL)); - } - - /// Sets the current time as the "seed" to randomize the next call to real_rand. - static double randomize() { - std::srand(::time(NULL)); - return 0.0; - } - - /// Sets x as the "seed" for the pseudo-random number generator. - static double random_seed(double x) { - int y = static_cast(x); - sRandomRangeHighValue = y; - sRandomRangeLowValue = ~y; - return 0.0; - } - - /// Non-platform specific (pseudo) random number generator. - static double random0() { - sRandomRangeHighValue = (sRandomRangeHighValue<<8) + (sRandomRangeHighValue>>8); - sRandomRangeHighValue += sRandomRangeLowValue; - sRandomRangeLowValue += sRandomRangeHighValue; - int val = std::abs(sRandomRangeHighValue); - return double(val) / double(RAND_MAX); - } - - /// Non-platform specific (pseudo) random number generator. - static double random1(double seed) { - random_seed(seed); - sRandomRangeHighValue = (sRandomRangeHighValue<<8) + (sRandomRangeHighValue>>8); - sRandomRangeHighValue += sRandomRangeLowValue; - sRandomRangeLowValue += sRandomRangeHighValue; - int val = std::abs(sRandomRangeHighValue); - return double(val) / double(RAND_MAX); - } - - /// Returns the angle (given in radians) in degrees. - static double deg(double a) { - return (180.0 / s_pi) * a; - } - - /// Returns the angle (given in degrees) in radians. - static double rad(double a) { - return (s_pi / 180.0) * a; - } - - /// Returns the minimum value among its arguments - static double min2(double a, double b) { - return std::min(a, b); - } - - /// Returns the minimum value among its arguments - static double min3(double a, double b, double c) { - return std::min(std::min(a, b), c); - } - - /// Returns the minimum value among its arguments - static double min4(double a, double b, double c, double d) { - return std::min(std::min(a, b), std::min(c,d)); - } - - /// Returns the maximum value among its arguments - static double max2(double a, double b) { - return std::max(a, b); - } - - /// Returns the maximum value among its arguments - static double max3(double a, double b, double c) { - return std::max(std::max(a, b), c); - } - - /// Returns the maximum value among its arguments - static double max4(double a, double b, double c, double d) { - return std::max(std::max(a, b), std::max(c,d)); - } - - /// Convert rectangular coordinates into polar radius. - static double recttopolr(double x, double y) { - return std::sqrt((x * x) + (y * y)); - } - - static double cosine_ramp3(double t, double rampStartTime, double rampEndTime) { - if( t < rampStartTime ) - { - return 0.0; - } - else if( t < rampEndTime ) - { - return (1.0 - std::cos((t-rampStartTime)*s_pi/(rampEndTime-rampStartTime)))/2.0; - } - else - { - return 1.0; - } - } - - static double cosine_ramp1(double t) { - return cosine_ramp3(t, 0.0, 1.0); - } - - static double cosine_ramp2(double t, double rampEndTime) { - return cosine_ramp3(t, 0.0, rampEndTime); - } - - /// Weibull distribution probability distribution function. - double weibull_pdf(double x, double shape, double scale) - { -#if defined(__PATHSCALE__) - return 0.0; -#else - weibull_dist weibull1(shape, scale); - return boost::math::pdf(weibull1, x); -#endif - } - - /// Normal (Gaussian) distribution probability distribution function. - double normal_pdf(double x, double mean, double standard_deviation) - { -#if defined(__PATHSCALE__) - return 0.0; -#else - normal_dist normal1(mean, standard_deviation); - return boost::math::pdf(normal1, x); -#endif - } - - /// Uniform distribution probability distribution function. - double uniform_pdf(double lower_range, double upper_range) - { - // Note, no error checking here... - return 1.0/(upper_range - lower_range); - } - - /// Exponential Uniform distribution probability distribution function - inline double exponential_pdf(double x, double beta) - { return std::exp(-x/beta)/beta; } - - /// Log Uniform distribution probability distribution function - inline double log_uniform_pdf(double x, double lower_range, double upper_range) - { return 1.0/(std::log(upper_range) - std::log(lower_range))/x; } - - /// Gamma continuous probability distribution function. - inline double gamma_pdf(double x, double shape, double scale) - { -#if defined(__PATHSCALE__) - return 0.0; -#else - return boost::math::pdf(gamma_dist(shape,scale), x); -#endif - } - - inline double phi(double beta) - { -#if defined(__PATHSCALE__) - return 0.0; -#else - return boost::math::pdf(normal_dist(0.,1.), beta); -#endif - } - - /// Returns a probability < 0.5 for negative beta and a probability > 0.5 for positive beta. - inline double Phi(double beta) - { -#if defined(__PATHSCALE__) - return 0.0; -#else - return boost::math::cdf(normal_dist(0.,1.), beta); -#endif - } - - inline double bounded_normal_pdf(double x, double mean, double std_dev, double lwr, double upr) - { - double Phi_lms = (lwr > -std::numeric_limits::max()) ? Phi((lwr-mean)/std_dev) : 0.; - double Phi_ums = (upr < std::numeric_limits::max()) ? Phi((upr-mean)/std_dev) : 1.; - return phi((x-mean)/std_dev)/(Phi_ums - Phi_lms)/std_dev; - } - - /// Returns -1 or 1 depending on whether x is negative or positive. - static double sign(double a) { - return (a >= 0.0 ) ? 1.0 : -1.0; - } - - /// Returns 1.0 if the input value t is greater than tstart and less than tstop. - static double unit_step3(double t, double tstart, double tstop) { - return (t < tstart || t > tstop) ? 0.0 : 1.0; - } - - /// Convert rectangular coordinates into polar angle. - static double recttopola(double x, double y) { - double tmp = std::atan2(y, x); - - /* Convert to 0.0 to 2 * PI */ - if (tmp < 0.0) { - return tmp + (2.0 * s_pi); - } else { - return tmp; - } - } - - /// Convert polar coordinates (r,theta) into x coordinate. - static double poltorectx(double r, double theta) { - return r * std::cos(theta); - } - - /// Convert polar coordinates (r,theta) into y coordinate. - static double poltorecty(double r, double theta) { - return r * std::sin(theta); - } -} - -CFunctionMap::CFunctionMap() -{ - /// These random number functions support calls to - /// the ANSI C random number generator. - (*this).insert(std::make_pair("rand", new CFunction0(real_rand))); - (*this).insert(std::make_pair("srand", new CFunction1(real_srand))); - (*this).insert(std::make_pair("randomize", new CFunction0(randomize))); - - /// These random number functions support a non-platform - /// specific random number function. - (*this).insert(std::make_pair("time", new CFunction0(current_time))); - (*this).insert(std::make_pair("random", new CFunction0(random0))); - (*this).insert(std::make_pair("random", new CFunction1(random1))); - - (*this).insert(std::make_pair("exp", new CFunction1(std::exp))); - (*this).insert(std::make_pair("ln", new CFunction1(std::log))); - (*this).insert(std::make_pair("log", new CFunction1(std::log))); - (*this).insert(std::make_pair("log10", new CFunction1(std::log10))); - (*this).insert(std::make_pair("pow", new CFunction2(std::pow))); - (*this).insert(std::make_pair("sqrt", new CFunction1(std::sqrt))); - (*this).insert(std::make_pair("erfc", new CFunction1(erfc))); - (*this).insert(std::make_pair("erf", new CFunction1(erf))); - - (*this).insert(std::make_pair("acos", new CFunction1(std::acos))); - (*this).insert(std::make_pair("asin", new CFunction1(std::asin))); - (*this).insert(std::make_pair("atan", new CFunction1(std::atan))); - (*this).insert(std::make_pair("atan2", new CFunction2(std::atan2))); - (*this).insert(std::make_pair("ceil", new CFunction1(std::ceil))); - (*this).insert(std::make_pair("cos", new CFunction1(std::cos))); - (*this).insert(std::make_pair("cosh", new CFunction1(std::cosh))); - (*this).insert(std::make_pair("floor", new CFunction1(std::floor))); - (*this).insert(std::make_pair("sin", new CFunction1(std::sin))); - (*this).insert(std::make_pair("sinh", new CFunction1(std::sinh))); - (*this).insert(std::make_pair("tan", new CFunction1(std::tan))); - (*this).insert(std::make_pair("tanh", new CFunction1(std::tanh))); - - (*this).insert(std::make_pair("abs", new CFunction1(std::fabs))); - (*this).insert(std::make_pair("fabs", new CFunction1(std::fabs))); - (*this).insert(std::make_pair("deg", new CFunction1(deg))); - (*this).insert(std::make_pair("mod", new CFunction2(std::fmod))); - (*this).insert(std::make_pair("fmod", new CFunction2(std::fmod))); - (*this).insert(std::make_pair("ipart", new CFunction1(ipart))); - (*this).insert(std::make_pair("fpart", new CFunction1(fpart))); - (*this).insert(std::make_pair("max", new CFunction2(max2))); - (*this).insert(std::make_pair("max", new CFunction3(max3))); - (*this).insert(std::make_pair("max", new CFunction4(max4))); - (*this).insert(std::make_pair("min", new CFunction2(min2))); - (*this).insert(std::make_pair("min", new CFunction3(min3))); - (*this).insert(std::make_pair("min", new CFunction4(min4))); - (*this).insert(std::make_pair("poltorectx", new CFunction2(poltorectx))); - (*this).insert(std::make_pair("poltorecty", new CFunction2(poltorecty))); - (*this).insert(std::make_pair("rad", new CFunction1(rad))); - (*this).insert(std::make_pair("recttopola", new CFunction2(recttopola))); - (*this).insert(std::make_pair("recttopolr", new CFunction2(recttopolr))); - - (*this).insert(std::make_pair("cos_ramp", new CFunction1(cosine_ramp1))); - (*this).insert(std::make_pair("cos_ramp", new CFunction2(cosine_ramp2))); - (*this).insert(std::make_pair("cos_ramp", new CFunction3(cosine_ramp3))); - (*this).insert(std::make_pair("cosine_ramp", new CFunction1(cosine_ramp1))); - (*this).insert(std::make_pair("cosine_ramp", new CFunction2(cosine_ramp2))); - (*this).insert(std::make_pair("cosine_ramp", new CFunction3(cosine_ramp3))); - - (*this).insert(std::make_pair("sign", new CFunction1(sign))); - (*this).insert(std::make_pair("unit_step", new CFunction3(unit_step3))); - - (*this).insert(std::make_pair("weibull_pdf", new CFunction3(weibull_pdf))); - (*this).insert(std::make_pair("normal_pdf", new CFunction3(normal_pdf))); - (*this).insert(std::make_pair("gamma_pdf", new CFunction3(gamma_pdf))); - (*this).insert(std::make_pair("log_uniform_pdf", new CFunction3(log_uniform_pdf))); - (*this).insert(std::make_pair("uniform_pdf", new CFunction2(uniform_pdf))); - (*this).insert(std::make_pair("exponential_pdf", new CFunction2(exponential_pdf))); -} - -CFunctionMap::~CFunctionMap() -{ - for (CFunctionMap::iterator it = begin(); it != end(); ++it) { - delete (*it).second; - } -} - -CFunctionMap & -getCFunctionMap() -{ - static CFunctionMap s_functionMap; - - return s_functionMap; -} - -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.hpp deleted file mode 100644 index d9731c554a7e..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Function.hpp +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef stk_expreval_function_hpp -#define stk_expreval_function_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace expreval { - -/** - * @brief Class CFunctionBase is a base class for calling a function from the - * expression evaluator. Classes which inherit from this function must implement a - * operator() function which accepts an argument count and an array of length - * that count of pointer to the argument values. This function should perform whatever - * argument manipulation is required to call the actual implementation of the function. - * - */ -class CFunctionBase -{ -public: - /** - * Creates a new CFunctionBase instance. - * - * @param arg_count an int value of the number of arguments - * expected when operator() is called. - */ - explicit CFunctionBase(int arg_count) - : m_argCount(arg_count) - {} - - virtual ~CFunctionBase() - {} - - /** - * @brief Member function operator() is the pure virtual interface to the - * function. This function is overloaded to implement the calculation to be performed - * when the function is called. - * - * @param argc an int value of the number of arguments. - * - * @param argv a double pointer to an array of double - * pointers to the actual function arguments. - * - * @return a double value of the result of the execution - * of the function. - */ - virtual double operator()(int argc, const double *argv) = 0; - - /** - * @brief Member function getArgCount returns the argument count for this - * function. - * - * @return an int value of the argument count for this - * function. - */ - int getArgCount() const { - return m_argCount; - } - -private: - int m_argCount; ///< Argument count for this function -}; - - -/** - * @brief Class CFunction declares a base template for template instantiation - * of C-like called functions. - * - */ -template -class CFunction; - -/** - * @brief Class CFunctionMap maps (function names, num arguments) to c-style function pointers via - * the CFunctionBase base class. The mapping is case insensitive. - * - */ -class CFunctionMap : public std::multimap< std::string, CFunctionBase *, LessCase> -{ -public: - /** - * Creates a new CFunctionMap instance. - * - * The CFunctionMap is populated with common C functions on construction. - * - */ - CFunctionMap(); - - /** - * Destroys a CFunctionMap instance. - * - */ - ~CFunctionMap(); -}; - -/** - * @brief Member function getCFunctionMap returns a reference to the - * C-style function map. - * - * @return a CFunctionMap reference to the C-style - * function map. - */ -CFunctionMap &getCFunctionMap(); - -/** - * @brief Member function addFunction adds a C-style function to the - * C-style function map. - * - * @param name a std::string const reference to the function - * name. - * - * @param function a CFunctionBase pointer to the C-style - * function. - */ -inline -void addFunction(const std::string &name, CFunctionBase *function) { - getCFunctionMap().insert(std::make_pair(name, function)); -} - -} // namespace expreval -} // namespace stk_classic - -#endif // stk_expreval_function_hpp diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.cpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.cpp deleted file mode 100644 index 2dd8b6df8d93..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace expreval { - -template -T convert_cast(const std::string &s) -{ - /* %TRACE% */ /* %TRACE% */ - std::istringstream is(s.c_str()); - T t = 0; - - is >> t; - - if (!is) { - std::ostringstream msg; - msg << "Unable to convert \"" << s << "\" to type " << typeid(T).name(); - throw std::runtime_error(msg.str().c_str()); - } - - - return t; -} - -template double convert_cast(const std::string &); -template float convert_cast(const std::string &); -template int convert_cast(const std::string &); -template unsigned convert_cast(const std::string &); -template long convert_cast(const std::string &); -template unsigned long convert_cast(const std::string &); - -namespace { - -bool -is_operator(Token token) { - return token == TOKEN_PLUS - || token == TOKEN_MINUS - || token == TOKEN_MULTIPLY - || token == TOKEN_DIVIDE - || token == TOKEN_PERCENT - || token == TOKEN_EXPONENTIATION - || token == TOKEN_QUESTION - || token == TOKEN_COLON - || token == TOKEN_SEMI - || token == TOKEN_ASSIGN - || token == TOKEN_LESS - || token == TOKEN_GREATER - || token == TOKEN_ARITHMETIC_OR - || token == TOKEN_ARITHMETIC_AND - || token == TOKEN_NOT - || token == TOKEN_EQUAL - || token == TOKEN_NOT_EQUAL - || token == TOKEN_GREATER_EQUAL - || token == TOKEN_LESS_EQUAL - || token == TOKEN_LOGICAL_OR - || token == TOKEN_LOGICAL_AND; -} - - -} // namespace - - -LexemVector -tokenize( - const std::string & expression) -{ - struct Graph - { - char ch; - Token token; - }; - - static Graph graph[] = { - {'+', TOKEN_PLUS}, - {'-', TOKEN_MINUS}, - {'*', TOKEN_MULTIPLY}, - {'/', TOKEN_DIVIDE}, - {'%', TOKEN_PERCENT}, - {'^', TOKEN_EXPONENTIATION}, - {'?', TOKEN_QUESTION}, - {',', TOKEN_COMMA}, - {':', TOKEN_COLON}, - {';', TOKEN_SEMI}, - {'(', TOKEN_LPAREN}, - {')', TOKEN_RPAREN}, - {'[', TOKEN_LBRACK}, - {']', TOKEN_RBRACK}, - {'=', TOKEN_ASSIGN}, - {'<', TOKEN_LESS}, - {'>', TOKEN_GREATER}, - {'|', TOKEN_ARITHMETIC_OR}, - {'&', TOKEN_ARITHMETIC_AND}, - {'!', TOKEN_NOT} - }; - - struct Digraph - { - char ch1; - char ch2; - Token token; - }; - - static Digraph digraph[] = { - {'=', '=', TOKEN_EQUAL}, - {'!', '=', TOKEN_NOT_EQUAL}, - {'>', '=', TOKEN_GREATER_EQUAL}, - {'<', '=', TOKEN_LESS_EQUAL}, - {'|', '|', TOKEN_LOGICAL_OR}, - {'&', '&', TOKEN_LOGICAL_AND} - }; - - LexemVector lex_vector; - - const char *it = expression.c_str(); - - while (*it != '\0') { - if (std::isspace(*it) || ::iscntrl(*it)) - ++it; - - // Parse constant [0-9]*(\.[0-9*])?(E([+-]?[0-9]*))? - // take unary plus and minus into account - else if (std::isdigit(*it) || *it == '.' - || ((*it == '-' || *it == '+') - && (std::isdigit(*(it + 1)) || *(it + 1) == '.') - && (lex_vector.empty() - || lex_vector.back().getToken() == TOKEN_COMMA - || lex_vector.back().getToken() == TOKEN_LPAREN - || is_operator(lex_vector.back().getToken())))) - { - bool is_real = false; - const char *from = it; - if (*it == '-' || *it == '+') - ++it; - while (std::isdigit(*it)) - ++it; - if (*it == '.') { - is_real = true; - ++it; - while (std::isdigit(*it)) - ++it; - } - if (*from == '.' && it == from + 1) - throw std::runtime_error(std::string("'.' is not a valid real number ") + *it); - if (*it == '.') - throw std::runtime_error(std::string("'.' is not a valid real number ") + *it); - if (std::toupper(*it) == 'E') { - is_real = true; - ++it; - if (*it == '+' || *it == '-') { - ++it; - } - while (std::isdigit(*it)) { - ++it; - } - } - if (is_real) - lex_vector.push_back(Lexem(TOKEN_REAL_CONSTANT, from, it)); - else - lex_vector.push_back(Lexem(TOKEN_INTEGER_CONSTANT, from, it)); - } - - // Parse literal - else if (*it == '"') { - std::string s; - ++it; - for (; *it && *it != '"'; ++it) { - if (*it == '\\') { - ++it; - if (*it) - switch (*it) { - case '"': - s += '"'; - break; - case '\\': - s += '\\'; - break; - case 'n': - s += '\n'; - break; - default: - s += *it; - } - } - else - s += *it; - } - ++it; - lex_vector.push_back(Lexem(TOKEN_LITERAL, s.c_str())); - } - - // Parse identifier [a-zA-Z][a-zA-Z0-9_.]* - else if (std::isalpha(*it)) { - const char *from = it; - while (std::isalpha(*it) || std::isdigit(*it) || *it == '_' || *it == '.') - ++it; - lex_vector.push_back(Lexem(TOKEN_IDENTIFIER, from, it)); - } - - // Parse graphs and digraphs - else if (ispunct(*it)) { - const char *from = it; - if (*(it + 1) != '\0') { - for (size_t i = 0; i < sizeof(digraph)/sizeof(digraph[0]); ++i) { - if (*it == digraph[i].ch1 && *(it + 1) == digraph[i].ch2) { - ++it; ++it; - lex_vector.push_back(Lexem(digraph[i].token, from, it)); - goto next_token; - } - } - } - - for (size_t i = 0; i < sizeof(graph)/sizeof(graph[0]); ++i) - if (*it == graph[i].ch) { - ++it; - lex_vector.push_back(Lexem(graph[i].token, from, it)); - goto next_token; - } - - throw std::runtime_error(std::string("std::expreval::tokenize: Invalid graphic character '") + *it + "'"); - } - - else - throw std::runtime_error("Impossible expression parse error"); - - next_token: - continue; - } - - lex_vector.push_back(Lexem(TOKEN_END, "")); - - return lex_vector; -} - -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.hpp deleted file mode 100644 index 07f76c7d9a26..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Lexer.hpp +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef stk_expreval_lexer_hpp -#define stk_expreval_lexer_hpp - -#include -#include - -namespace stk_classic { -namespace expreval { - -template -T convert_cast(const std::string &s); - -/** - * Enumeration Tokens defines the tokens returned by the lexer. - * - */ -enum Token { - TOKEN_PLUS, - TOKEN_MINUS, - TOKEN_MULTIPLY, - TOKEN_DIVIDE, - TOKEN_PERCENT, - TOKEN_QUESTION, - TOKEN_COMMA, - TOKEN_COLON, - TOKEN_SEMI, - TOKEN_LPAREN, - TOKEN_RPAREN, - TOKEN_LBRACK, - TOKEN_RBRACK, - TOKEN_ASSIGN, - TOKEN_LESS, - TOKEN_GREATER, - TOKEN_ARITHMETIC_OR, - TOKEN_ARITHMETIC_AND, - TOKEN_NOT, - TOKEN_EQUAL, - TOKEN_NOT_EQUAL, - TOKEN_GREATER_EQUAL, - TOKEN_LESS_EQUAL, - TOKEN_LOGICAL_OR, - TOKEN_LOGICAL_AND, - TOKEN_IDENTIFIER, - TOKEN_REAL_CONSTANT, - TOKEN_INTEGER_CONSTANT, - TOKEN_LITERAL, - TOKEN_EXPONENTIATION, - TOKEN_END -}; - - -/** - * Class Lexem associates a token with a simple expression of the type - * described by the token. - * - */ -class Lexem -{ -public: - /** - * Creates a new Lexem instance. - * - * @param token an int value of the token which describes the - * value. - * - * @param from a char const pointer to the beginning of the - * value. - * - * @param to a char const pointer to the end of the - * value. - */ - Lexem(Token token, const char *from, const char *to) - : m_token(token), - m_value(from, to) - {} - - /** - * Creates a new Lexem instance. - * - * @param token an int value of the token which describes the - * value. - * - * @param value a char const pointer to a c-style string of - * the value. - */ - Lexem(Token token, const char *value) - : m_token(token), - m_value(value) - {} - - /** - * Member function getToken returns the token. - * - * @return a Token. - */ - Token getToken() const { - return m_token; - } - - /** - * Member function getValue returns const reference to the value associated - * with the token. - * - * @return a std::string const reference to the value - * associated with the token. - */ - const std::string &getString() const { - return m_value; - } - - /** - * Member function getValue returns const reference to the value associated - * with the token. - * - * @return a std::string const reference to the value - * associated with the token. - */ - template - T getValue() const { - return convert_cast(m_value); - } - -private: - Token m_token; //< Token which describes the value - std::string m_value; //< Value -}; - -typedef std::vector LexemVector; - -LexemVector tokenize(const std::string &expression); - -} // namespace expreval -} // namespace stk_classic - -#endif // stk_expreval_lexer_hpp diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.cpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.cpp deleted file mode 100644 index fd3d2807bc3a..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include - -namespace stk_classic { -namespace expreval { - -VariableMap::Resolver & -VariableMap::getDefaultResolver() -{ - static DefaultResolver default_resolver; - - return default_resolver; -} - -} // namespace expreval -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.hpp b/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.hpp deleted file mode 100644 index 3ca4d92e445b..000000000000 --- a/packages/stk/stk_classic/stk_expreval/stk_expreval/Variable.hpp +++ /dev/null @@ -1,443 +0,0 @@ -#ifndef stk_expreval_Variable_hpp -#define stk_expreval_Variable_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace expreval { - -/** - * @brief Class Variable defines a variable for the expression evaluation - * virtual machine. Typing is limited to int and double. While all operations are - * performed as doubles, the value and results may be retrieved and stored as integer - * values. - * - * Array indexing is also supported, but no bounds checkin is available and only double - * type array may be addressed. - * - * Variable are implemented as a pointer, "typed" by the Type enumeration - * to the actual value. At construction, this may point to a "local" double value or - * integer value, or the address may be specified. In either case, a type and address - * for the variable may be provided via variable "binding". - * - */ -class Variable -{ -public: - /** - * @brief Enumeration Type lists the variable data types. double and - * int are currently supported. - * - */ - enum Type {DOUBLE, INTEGER}; - enum Use {DEPENDENT, INDEPENDENT}; - - /** - * Creates a new Variable instance. - * - */ - Variable() - : m_type(DOUBLE), - m_use(INDEPENDENT), - m_doublePtr(&m_doubleValue), - m_doubleValue(0.0) - {} - - /** - * Creates a new Variable instance. The new variable will be local and - * have the type specified by type. - * - * @param type an Type value of the type of the new - * variable. - * - */ - explicit Variable(Type type) - : m_type(type), - m_use(INDEPENDENT) - { - switch (type) { - case DOUBLE: - m_doublePtr = &m_doubleValue; - m_doubleValue = 0.0; - break; - case INTEGER: - m_intPtr = &m_intValue; - m_intValue = 0; - break; - } - } - - /** - * Creates a new Variable instance. The new variable will use the - * address specified by address and be of type double. This address must - * remain in scope during the lifetime of the variable are until rebound to a new - * address. - * - * @param address an double reference to the value for this - * variable. - * - */ - explicit Variable(double &address) - : m_type(DOUBLE), - m_use(INDEPENDENT), - m_doublePtr(&address), - m_doubleValue(0.0) - {} - - /** - * Creates a new Variable instance. The new variable will use the - * address specified by address and be of type int. This address must - * remain in scope during the lifetime of the variable are until rebound to a new - * address. - * - * @param address an int reference to the value for this - * variable. - * - */ - explicit Variable(int &address) - : m_type(INTEGER), - m_use(INDEPENDENT), - m_intPtr(&address), - m_intValue(0) - {} - - /** - * @brief Member function operator= assigns a new value to the variable. - * If the variable type is integer, the value is converted to integer before - * assignment. - * - * @param value a double value that is to be assigned to the - * variable. - * - * @return a Variable reference to the variable. - */ - Variable &operator=(const double &value) { - if (m_type == INTEGER) - *m_intPtr = (int) value; - else if (m_type == DOUBLE) - *m_doublePtr = value; - return *this; - } - - /** - * @brief Member function operator= assigns a new value to the variable. - * If the variable type is double, the value is converted to double before assignment. - * - * @param value an int value that is to be assigned to the - * variable. - * - * @return a Variable reference to the variable. - */ - Variable &operator=(const int &value) { - if (m_type == INTEGER) - *m_intPtr = value; - else if (m_type == DOUBLE) - *m_doublePtr = (double) value; - return *this; - } - -private: - Variable(const Variable &); - Variable &operator=(const Variable &); - -public: - - void setDependent() { - m_use = DEPENDENT; - } - - bool isDependent() const { - return m_use == DEPENDENT; - } - - /** - * @brief Member function operator[] returns a value from an array of - * double values. No bounds checkin is performed. Not even if the variable is and - * array is checked. - * - * @param index a double value of the zero based index into - * the array to retrieve the value. - * - * @return a double reference to the value. - */ - inline double &operator[](double index) { - if (m_type != DOUBLE) - throw std::runtime_error("Only double arrays allowed"); - - if ((void *) m_doublePtr == 0) - throw std::runtime_error("Unbound variable"); - - int i = (int) index; - - return m_doublePtr[i]; - } - - /** - * @brief Member function operator[] returns a value from an array of - * double values. No bounds checkin is performed. Not even if the variable is and - * array is checked. - * - * @param index a int value of the zero based index into the - * array to retrieve the value. - * - * @return a double reference to the value. - */ - inline double &operator[](int index) { - if (m_type != DOUBLE) - throw std::runtime_error("Only double arrays allowed"); - - if ((void *) m_doublePtr == 0) - throw std::runtime_error("Unbound variable"); - - return m_doublePtr[index]; - } - - /** - * @brief Member function bind binds variable to the address of the - * specified value. The type is converted to double. This address must remain in - * scope during the lifetime of the variable are until rebound to a new address. - * - * @param value_ref a double reference to be used for this variable. - * - * @return a Variable reference to the variable. - */ - inline Variable &bind(double &value_ref) { - m_type = DOUBLE; - m_doublePtr = &value_ref; - return *this; - } - - /** - * @brief Member function bind binds variable to the address of the - * specified value. The type is converted to int. This address must remain in scope - * during the lifetime of the variable are until rebound to a new address. - * - * @param value_ref a int reference to be used for this variable. - * - * @return a Variable reference to the variable. - */ - inline Variable &bind(int &value_ref) { - m_type = INTEGER; - m_intPtr = &value_ref; - return *this; - } - - /** - * @brief Member function unbind binds the variable to the local value - * and reinitializes that value to zero. The type is left unchanged. - * - * @return a Variable reference to the variable. - */ - inline Variable &unbind() { - switch (m_type) { - case DOUBLE: - m_doublePtr = &m_doubleValue; - m_doubleValue = 0.0; - break; - case INTEGER: - m_intPtr = &m_intValue; - m_intValue = 0; - break; - } - return *this; - } - - double *getAddress() const { - return m_doublePtr; - } - - /** - * @brief Member function getValue returns the variable value as a double. - * - * @return a double value of the value of the variable. - */ - inline double getValue() const { - switch (m_type) { - case DOUBLE: - return *m_doublePtr; - case INTEGER: - return (double) *m_intPtr; - } - throw std::runtime_error("Invalid variable type"); - } - -private: - Type m_type; ///< Variable data type - Use m_use; ///< Variable is dependent or independent - - union { - double * m_doublePtr; ///< Pointer to value as double - int * m_intPtr; ///< Pointer to value as integer - }; - union { - double m_doubleValue; ///< Local variable value as double - int m_intValue; ///< Local variable value as integer - }; -}; - - -/** - * @brief Class VariableMap implements a mapping from name to a pointer to - * a Variable object. The mapping is case insensitive. - * - */ -class VariableMap : public std::map -{ -public: - /** - * @brief Typedef value_type is the value_type of the - * std::map subclass. The mapping is case insensitive. - * - */ - typedef std::map::value_type value_type; - - /** - * @brief Class Resolver is a base class for a variable name to value - * resolver. After parsing of an expression, a list of variable names is collected. - * The resolve member function will be called for each of these during - * the expression resolve stage. This function may bind a new value to the variable, - * ignore the variable by leaving the initialized local binding, or throw an exception - * stating the variable cannot be resolved. - * - */ - class Resolver - { - public: - /** - * Creates a new Resolver instance. - * - */ - Resolver() - {} - - /** - * Destroys a Resolver instance. - * - */ - virtual ~Resolver() - {} - - /** - * @brief Member function resolve is the virtual member function for - * the variable resolver. - * - * @param it a VariableMap::iterator reference to the - * variable whose name is to be resolved. - */ - virtual void resolve(VariableMap::iterator &it) = 0; - }; - -private: - /** - * @brief Member function delete_variable is a function which will delete - * the variabel pointed to by t. - * - * @param t a value_type reference to the variable to be - * deleted. - */ - static void delete_variable(value_type &t) { - delete t.second; - } - - /** - * @brief Class DefaultResolver implement a default resolver. - * - */ - class DefaultResolver : public Resolver - { - public: - DefaultResolver() - {} - - /** - * Destroys a DefaultResolver instance. - * - */ - virtual ~DefaultResolver() - {} - - /** - * @brief Member function resolve implements the default resolvers - * function, which does nothing. I.E. lets the local variable values stand. - * - * @param it a VariableMap::iterator variable ... - */ - virtual void resolve(VariableMap::iterator &it) - {} - - }; - -public: - /** - * @brief Member function getDefaultResolver returns a reference to the - * default resolver. - * - * @return a Resolver ... - */ - static Resolver &getDefaultResolver(); - - /** - * Creates a new VariableMap instance with the specified variable name - * resolver. - * - * @param resolver a Resolver reference to the variable name - * resolver for this variable map. - * - */ - VariableMap(Resolver &resolver = getDefaultResolver()) - : std::map(), - m_resolver(resolver) - {} - - /** - * Destroys a VariableMap instance. All variables are destroyed. - * - */ - virtual ~VariableMap() { - std::for_each(begin(), end(), &delete_variable); - } - - /** - * @brief Member function operator[] ... - * - * @param s a std::string const reference to the variable's - * name. - * - * @return a Variable pointer to the new variable. - */ - Variable *operator[](const std::string &s) { - std::pair i = insert(std::pair(s, (Variable *) 0)); - if (i.second) - (*i.first).second = new Variable(); - return (*i.first).second; - } - - /** - * @brief Member function getResolver returns a reference to the name - * resolver. - * - * @return a Resolver reference to the variable name - * resolver. - */ - Resolver &getResolver() { - return m_resolver; - } - -private: - Resolver & m_resolver; ///< Reference to this variable map name resolver -}; - -} // namespace expreval -} // namespace stk_classic - -#endif // stk_expreval_Variable_hpp diff --git a/packages/stk/stk_classic/stk_expreval/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_expreval/unit_tests/CMakeLists.txt deleted file mode 100644 index 03477814e435..000000000000 --- a/packages/stk/stk_classic/stk_expreval/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_expreval_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluator.cpp b/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluator.cpp deleted file mode 100644 index 08b0004b32c1..000000000000 --- a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluator.cpp +++ /dev/null @@ -1,586 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include - -#include - -class UnitTestEvaluator -{ -public: - void testEvaluator(); -}; - -using namespace stk_classic::expreval; - -// expr_eval.bind("x", x); \ x -// expr_eval.setValue("x", x); \ x -// std::cout << std::setprecision(20) << x << "," << std::setprecision(20) << y << std::endl; \ x -namespace { - -STKUNIT_UNIT_TEST( UnitTestEvaluator, testEvaluator) -{ - UnitTestEvaluator unit; - - unit.testEvaluator(); -} - -bool -checkUndefinedFunction( - const char * expr) -{ - try { - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - if (expr_eval.undefinedFunction()) { - return true; - } else { - return false; - } - } - catch (std::runtime_error &x) { - return false; - } -} - -bool -notUndefinedFunction( - const char * expr) -{ - std::cout << "Not an undefined function " << expr << " ... "; - if (checkUndefinedFunction(expr)) { - std::cout << "fail" << std::endl; - return false; - } else { - std::cout << "pass" << std::endl; - return true; - } -} - -bool -undefinedFunction( - const char * expr) -{ - std::cout << "Undefined function " << expr << " ... "; - if (checkUndefinedFunction(expr)) { - std::cout << "pass" << std::endl; - return true; - } else { - std::cout << "fail" << std::endl; - return false; - } -} - -bool -syntax( - const char * expr) -{ - std::cout << "Syntax " << expr << " ... "; - try { - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "fail, " << x.what() << std::endl; - return false; - } - std::cout << "pass" << std::endl; - return true; -} - -bool -fail_syntax( - const char * expr) -{ - std::cout << "Invalid syntax " << expr << " ... "; - try { - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "pass" << std::endl; - return true; - } - std::cout << "fail, should have parse error" << std::endl; - return false; -} - -/* -bool -vectest( - const char * expr) -{ - std::cout << " syntax " << expr << " ... "; - try { - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "pass" << std::endl; - return true; - } - std::cout << "fail, should have parse error" << std::endl; - return false; -} -*/ - -bool -test_one_value(const char *expression, double gold_value) -{ - bool failed = false; - std::cout << "Evaluate " << expression << " ... "; - std::string by_expr = std::string("by=") + expression + ";"; - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), by_expr.c_str()); - expr_eval.parse(); - double result = expr_eval.evaluate(); - double absolute_error = fabs(result - gold_value); - if (absolute_error > fabs(1.0e-14*result)) - { - std::cout << expression << " = " << std::setprecision(20) << result - << " should be " << gold_value - << " error is " << absolute_error - << std::endl; - failed = true; - } else { - std::cout << "Expression= " << expression << " == " << result << "\n"; - } - std::cout << (failed ? "fail" : "pass") << std::endl; - return !failed; -} - -bool -evaluate_range( - const char * expr, - double xmin, - double xmax, - int numPoints = 100, - bool write_csv = false) -{ - std::ofstream expression_csv; - std::ofstream expression_gnu; - - std::string expression_csv_name = expr + std::string(".csv"); - if(write_csv) { - expression_csv.open(expression_csv_name.c_str()); - expression_csv << "### Evaluate " << expr << " from " << xmin << " to " << xmax<< " with " << numPoints << "\n"; - } - std::cout << "Evaluate " << expr << " from " << xmin << " to " << xmax << " with " << numPoints << "\n"; - - std::string by_expr = std::string("by=") + expr + ";"; - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), by_expr.c_str()); - expr_eval.parse(); - - double x, y, by, v[2]; - expr_eval.bindVariable("x", x); - expr_eval.bindVariable("by", by); - expr_eval.bindVariable("v", *v); - - double ymin = std::numeric_limits::max(); - double ymax = std::numeric_limits::min(); - - double start_x = xmin; - double range = (xmax - xmin); - double delta_x = range/numPoints; - for (int i = 0; i <= numPoints; ++i) { - x = start_x + i*delta_x; - y = expr_eval.evaluate(); - ymin = std::min(y, ymin); - ymax = std::max(y, ymax); - if(write_csv) { - expression_csv << std::setprecision(14) << x << ", " << std::setprecision(14) << y << "\n"; - } else { - std::cout << std::setprecision(14) << x << ", " << std::setprecision(14) << y << "\n"; - } - } - - //std::cout << "KHP: ymin= " << ymin << ", ymax= " << ymax << "\n"; - if(write_csv) { - // write a gnuplot input file corresponding to the csv file - std::string expression_gnu_name = expr + std::string(".gnu"); - expression_gnu.open(expression_gnu_name.c_str()); - expression_gnu << "set terminal postscript color" << "\n"; - expression_gnu << "set output \"" << expr << ".ps\"" << "\n"; - expression_gnu << "set grid" << "\n"; - //expression_gnu << "set autoscale" << "\n"; - expression_gnu << "set yrange [" << 1.1*ymin << ":" << 1.1*ymax << "]" << "\n"; - expression_gnu << "set key off" << "\n"; - expression_gnu << "set title " << "\"" << expr << "\"" << "\n"; - expression_gnu << "plot " << "\"" << expression_csv_name << "\"" << " using 1:2 with lines lw 4\n"; - } - return true; -} - -typedef double (TestFunc)(double); - -bool -test( - const char * expr, - TestFunc c_expr) -{ - bool failed = false; - std::cout << "Evaluate " << expr << " ... "; - std::string by_expr = std::string("by=") + expr + ";"; - stk_classic::expreval::Eval expr_eval(stk_classic::expreval::VariableMap::getDefaultResolver(), by_expr.c_str()); - expr_eval.parse(); - - double x, y, by, result = 0.0; - double v[2]; - - expr_eval.bindVariable("x", x); - expr_eval.bindVariable("by", by); - expr_eval.bindVariable("v", *v); - for (int i = 1; i < 100; ++i) { - x = v[1] = i*0.01; - y = (*c_expr)(x); - try { - result = expr_eval.evaluate(); - } - catch (std::runtime_error &exc) { - std::cout << expr << " at " - << std::setprecision(20) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << "(" << std::setprecision(20) << by - << ") threw exception " << exc.what() - << std::endl; - failed = true; - } - double absolute_error = fabs(result - y); - if (absolute_error > fabs(1.0e-14*result)) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << " error is " << absolute_error - << std::endl; - failed = true; - } - else if (by != result) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " does not match bound value " - << std::setprecision(20) << by - << std::endl; - failed = true; - } - } - - std::cout << (failed ? "fail" : "pass") << std::endl; - return !failed; -} - -bool -test( - const char * expr1, - const char * expr2) -{ - bool failed = false; - std::cout << "Evaluate " << expr1 << " vs " << expr2; - - std::string by_expr1 = std::string("by=") + expr1 + ";"; - stk_classic::expreval::Eval expr_eval1(stk_classic::expreval::VariableMap::getDefaultResolver(), by_expr1.c_str()); - expr_eval1.parse(); - - std::string by_expr2 = std::string("by=") + expr2 + ";"; - stk_classic::expreval::Eval expr_eval2(stk_classic::expreval::VariableMap::getDefaultResolver(), by_expr2.c_str()); - expr_eval2.parse(); - - double x, y, by, result = 0.0; - double v[2]; - - // Set up both expressions. - expr_eval1.bindVariable("x", x); - expr_eval1.bindVariable("by", by); - expr_eval1.bindVariable("v", *v); - - expr_eval2.bindVariable("x", x); - expr_eval2.bindVariable("by", by); - expr_eval2.bindVariable("v", *v); - - for (int i = 1; i < 100; ++i) { - x = v[1] = i*0.01; - try { - result = expr_eval1.evaluate(); - y = expr_eval2.evaluate(); - } - catch (std::runtime_error &exc) { - std::cout << expr1 << " at " - << std::setprecision(20) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << "(" << std::setprecision(20) << by - << ") threw exception " << exc.what() - << std::endl; - failed = true; - } - double absolute_error = fabs(result - y); - if (absolute_error > fabs(1.0e-14*result)) { - std::cout << expr1 << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << " error is " << absolute_error - << std::endl; - failed = true; - } - else if (by != result) { - std::cout << expr1 << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " does not match bound value " - << std::setprecision(20) << by - << std::endl; - failed = true; - } - } - - std::cout << (failed ? "fail" : "pass") << std::endl; - return !failed; -} - -#define EXPREVAL_DEFINE_TEST(name,expr1,expr2) \ -double name(double x) {return expr2;} \ -const char *name##_expr = #expr1 - -#define EXPREVAL_DEFINE_TEST1(name,expr) EXPREVAL_DEFINE_TEST(name,expr,expr) - -// Hierarchy tests -EXPREVAL_DEFINE_TEST1(h1, x*1.0/2.0*3.0); -EXPREVAL_DEFINE_TEST1(h2, x*1.0/2.0*3.0); -EXPREVAL_DEFINE_TEST1(h3, x*(4.0+5.0)/6.0); -EXPREVAL_DEFINE_TEST1(h4, x==0.5); -EXPREVAL_DEFINE_TEST1(h5, x>=0.5); -EXPREVAL_DEFINE_TEST1(h6, x<0.25 || x>0.75); -EXPREVAL_DEFINE_TEST1(h7, x>0.25 && x<0.75); -EXPREVAL_DEFINE_TEST1(h8, x*2>0.25 && x<0.75); -EXPREVAL_DEFINE_TEST1(h9, !(x - 0.5)); -EXPREVAL_DEFINE_TEST1(h10, x > 0.5 ? 5.0 : 7.0); -EXPREVAL_DEFINE_TEST1(h11, x*(x+1.0)); -EXPREVAL_DEFINE_TEST1(h12, x*1.0+2.0); -EXPREVAL_DEFINE_TEST1(h13, x*x+1.0); -EXPREVAL_DEFINE_TEST1(h14, x+x*1.0+2.0); -EXPREVAL_DEFINE_TEST1(h15, x > 0.5 ? x/2.0 + 1.0 : x*2.0 - 1.0); -EXPREVAL_DEFINE_TEST1(h16, x > 0.5 ? x > 0.75 ? x/2.0 + 1.0 : x*2.0 - 1.0 : x*5.0/2.0); -EXPREVAL_DEFINE_TEST(h17, v[1]=x*0.5;y=v[1],x*0.5); -EXPREVAL_DEFINE_TEST1(h18, x - -7); -EXPREVAL_DEFINE_TEST1(h19, x - -x); -EXPREVAL_DEFINE_TEST1(h20, x - - - 7); - -// Function tests -EXPREVAL_DEFINE_TEST(f1, abs(x), fabs(x)); -EXPREVAL_DEFINE_TEST(f2, mod(x,10.0), fmod(x,10.0)); -EXPREVAL_DEFINE_TEST1(f3, fabs(x)); -EXPREVAL_DEFINE_TEST1(f4, fmod(x,10.0)); -EXPREVAL_DEFINE_TEST1(f5, acos(x)); -EXPREVAL_DEFINE_TEST1(f6, asin(x)); -EXPREVAL_DEFINE_TEST1(f7, atan(x)); -EXPREVAL_DEFINE_TEST1(f8, ceil(x)); -EXPREVAL_DEFINE_TEST1(f9, cos(x)); -EXPREVAL_DEFINE_TEST1(f10, cosh(x)); -EXPREVAL_DEFINE_TEST1(f11, exp(x)); -EXPREVAL_DEFINE_TEST1(f12, floor(x)); -EXPREVAL_DEFINE_TEST1(f13, log(x)); -EXPREVAL_DEFINE_TEST1(f14, pow(x, 10.0)); -EXPREVAL_DEFINE_TEST(f15, x^2, pow(x, 2.0)); - -EXPREVAL_DEFINE_TEST1(f16, sin(x)); -EXPREVAL_DEFINE_TEST1(f17, sinh(x)); -EXPREVAL_DEFINE_TEST1(f18, sqrt(x)); -EXPREVAL_DEFINE_TEST1(f19, tan(x)); -EXPREVAL_DEFINE_TEST1(f20, tanh(x)); -EXPREVAL_DEFINE_TEST(f21, atan2(x, PI),atan2(x, stk_classic::expreval::s_pi)); -EXPREVAL_DEFINE_TEST(f22, ln(x),log(x)); -EXPREVAL_DEFINE_TEST(f23, deg(x),(180.0 / stk_classic::expreval::s_pi) * x); -EXPREVAL_DEFINE_TEST(f24, rad(x),(stk_classic::expreval::s_pi / 180.0) * x); -EXPREVAL_DEFINE_TEST(f25, max(x,1.0),std::max(x,1.0)); -EXPREVAL_DEFINE_TEST(f26, min(x,1.0),std::min(x,1.0)); -EXPREVAL_DEFINE_TEST(f27, recttopolr(x,1.0),sqrt(x*x+1.0*1.0)); -EXPREVAL_DEFINE_TEST(f28, recttopola(x,1.0),atan2(1.0, x)); -EXPREVAL_DEFINE_TEST(f29, poltorectx(x,PI/4.0),x*cos(stk_classic::expreval::s_pi/4.0)); -EXPREVAL_DEFINE_TEST(f30, poltorecty(x,PI/4.0),x*sin(stk_classic::expreval::s_pi/4.0)); -EXPREVAL_DEFINE_TEST1(f31, 0.4209+4.5e-4*x); - -// Bova tests -EXPREVAL_DEFINE_TEST1(b1, sin(x*.5)); -EXPREVAL_DEFINE_TEST1(b2, .5*.2*sin(.5*x)); -EXPREVAL_DEFINE_TEST1(b3, .5*sin(x)); - -// Pierson tests -EXPREVAL_DEFINE_TEST(k1, x^2, x*x); -EXPREVAL_DEFINE_TEST(k2, cosine_ramp(x), (1.0-cos(x*stk_classic::expreval::s_pi))/2); -EXPREVAL_DEFINE_TEST(k3, cosine_ramp(x, 1.0), (1.0-cos(x*stk_classic::expreval::s_pi/1.0))/2); -EXPREVAL_DEFINE_TEST(k4, cosine_ramp(x, 0.0, 1.0), (1.0-cos(x*stk_classic::expreval::s_pi/1.0))/2); - -#undef EXPREVAL_DEFINE_TEST1 - -} // namespace - -void -UnitTestEvaluator::testEvaluator() -{ - STKUNIT_EXPECT_TRUE(syntax("3^2")); - STKUNIT_EXPECT_TRUE(test_one_value("a=1;b=2;a+b",3)); - STKUNIT_EXPECT_TRUE(test_one_value("9%3" ,0)); - STKUNIT_EXPECT_TRUE(test_one_value("9 % 4" ,1)); - STKUNIT_EXPECT_TRUE(test_one_value("15%(1+1+1)",0)); - - STKUNIT_EXPECT_TRUE(test_one_value("max(1,2)",2)); - STKUNIT_EXPECT_TRUE(test_one_value("max(1,2,3)",3)); - STKUNIT_EXPECT_TRUE(test_one_value("max(1,2,3,4)",4)); - - STKUNIT_EXPECT_TRUE(test_one_value("min(4,3)",3)); - STKUNIT_EXPECT_TRUE(test_one_value("min(4,3,2)",2)); - STKUNIT_EXPECT_TRUE(test_one_value("min(4,3,2,1)",1)); - - STKUNIT_EXPECT_TRUE(test_one_value("a=3;a^2",9.)); - STKUNIT_EXPECT_TRUE(test_one_value("(1+2+3)^2",36.)); - STKUNIT_EXPECT_TRUE(test_one_value("(1+2+3+4)^(1+1)",100.)); - -#ifndef __PATHSCALE__ - double weibull_gold_value = 3.6787944117144233402; - STKUNIT_EXPECT_TRUE(test_one_value("shape=10;scale=1;weibull_pdf(1.0,shape,scale)", weibull_gold_value)); -#endif - -#ifndef __PATHSCALE__ - // Need a better test for distributions, perhaps something that computes the - // mean and standard deviation of the distribution. - double normal_gold_value = 0.79788456080286540573; - STKUNIT_EXPECT_TRUE(test_one_value("mean=0;standard_deviation=0.5;normal_pdf(0.0,mean,standard_deviation)", normal_gold_value)); -#endif - -#ifndef __PATHSCALE__ - // These tests just print a range of values of the input expressions. - // and optionally output to a CSV file along with an associated GNUPLOT input file. - // XMIN XMAX Pts Output - STKUNIT_EXPECT_TRUE(evaluate_range("weibull_pdf(x,3,1)" , 0, 3, 3000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("normal_pdf(x,1,.2)" , 0, 2, 3000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("gamma_pdf(x,10,1.0)" , 0, 4, 3000, false )); -#endif - - STKUNIT_EXPECT_TRUE(evaluate_range("exponential_pdf(x,2)" , 0, 6, 3000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("log_uniform_pdf(x,10,1.0)", 0, 4, 3000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("unit_step(x,0.1,0.2)" , 0, .3, 3000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("cosine_ramp(x,1,2)" , 0.0, 3.0, 3000, true )); - STKUNIT_EXPECT_TRUE(evaluate_range("cosine_ramp(x,0,1)" , 0.0, 2.0, 2000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("cosine_ramp(x,1)" , 0.0, 2.0, 2000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("cosine_ramp(x)" , 0.0, 2.0, 2000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("random()" , -1.0, 1.0, 2000, false )); - STKUNIT_EXPECT_TRUE(evaluate_range("sign(sin(x))" , 0, 12, 12000, false )); // square wave - - STKUNIT_EXPECT_TRUE(syntax("2*2")); - STKUNIT_EXPECT_TRUE(syntax("")); - STKUNIT_EXPECT_TRUE(syntax(";")); - STKUNIT_EXPECT_TRUE(syntax(";;")); - STKUNIT_EXPECT_TRUE(syntax(";;;")); - STKUNIT_EXPECT_TRUE(syntax("x*0.1")); - STKUNIT_EXPECT_TRUE(syntax("x*-0.1")); - STKUNIT_EXPECT_TRUE(syntax("x*+0.1")); - STKUNIT_EXPECT_TRUE(syntax("x--7.0")); - STKUNIT_EXPECT_TRUE(syntax("x*-x")); - STKUNIT_EXPECT_TRUE(syntax("x*+x")); - STKUNIT_EXPECT_TRUE(syntax("v[0]=v[1]*0.1")); - STKUNIT_EXPECT_TRUE(syntax("x--x")); - STKUNIT_EXPECT_TRUE(syntax("x---x")); - STKUNIT_EXPECT_TRUE(fail_syntax("0.01.02")); - STKUNIT_EXPECT_TRUE(fail_syntax("5*.e+10")); - STKUNIT_EXPECT_TRUE(fail_syntax("x y")); - STKUNIT_EXPECT_TRUE(fail_syntax("x(y")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*(y+1")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*y)")); - STKUNIT_EXPECT_TRUE(fail_syntax("cos(x")); - STKUNIT_EXPECT_TRUE(fail_syntax("(x)y")); - STKUNIT_EXPECT_TRUE(fail_syntax("()")); - STKUNIT_EXPECT_TRUE(undefinedFunction("stress(1)")); - STKUNIT_EXPECT_TRUE(notUndefinedFunction("sin(1)")); - STKUNIT_EXPECT_TRUE(notUndefinedFunction("0.01.02")); - STKUNIT_EXPECT_TRUE(syntax("rand()")); - STKUNIT_EXPECT_TRUE(syntax("cosine_ramp(x,y)")); - STKUNIT_EXPECT_TRUE(syntax("random()")); - STKUNIT_EXPECT_TRUE(syntax("random(1)")); - STKUNIT_EXPECT_TRUE(syntax("time()")); - STKUNIT_EXPECT_TRUE(syntax("random(time())")); - -#ifndef __PATHSCALE__ - STKUNIT_EXPECT_TRUE(syntax("weibull_pdf(x, alpha, beta)")); - STKUNIT_EXPECT_TRUE(syntax("normal_pdf(x, alpha, beta)")); -#endif - -#define EXPREVAL_TEST(name) test(name##_expr, name) - - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h1)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h2)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h3)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h4)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h5)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h6)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h7)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h8)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h9)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h10)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h11)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h12)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h13)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h14)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h15)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h16)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h17)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h18)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h19)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(h20)); - - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f1)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f2)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f3)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f4)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f5)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f6)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f7)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f8)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f9)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f10)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f11)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f12)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f13)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f14)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f15)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f16)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f17)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f18)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f19)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f20)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f21)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f22)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f23)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f24)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f25)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f26)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f27)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f28)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f29)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f30)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(f31)); - - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(b1)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(b2)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(b3)); - - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(k1)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(k2)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(k3)); - STKUNIT_EXPECT_TRUE(EXPREVAL_TEST(k4)); - -#undef EXPREVAL_TEST -} diff --git a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluatorFAD.cpp b/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluatorFAD.cpp deleted file mode 100644 index 1033a3e84c40..000000000000 --- a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestEvaluatorFAD.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#include -#include -#include - -#include - -#include - -class UnitTestEvaluatorFAD -{ -public: - void testEvaluator(); -}; - -using namespace stk_classic::expreval; - -// expr_eval.bind("x", x); \ x -// expr_eval.setValue("x", x); \ x -// std::cout << std::setprecision(20) << x << "," << std::setprecision(20) << y << std::endl; \ x -namespace { - -STKUNIT_UNIT_TEST( UnitTestEvaluatorFAD, testEvaluator) -{ - UnitTestEvaluatorFAD unit; - - unit.testEvaluator(); -} - - - -bool -syntax( - const char * expr) -{ - std::cout << "Syntax " << expr << " ... "; - try { - stk_classic::expreval::fad::Eval expr_eval(stk_classic::expreval::fad::Eval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "fail, " << x.what() << std::endl; - return false; - } - std::cout << "pass" << std::endl; - return true; -} - - -bool -fail_syntax( - const char * expr) -{ - std::cout << "Invalid syntax " << expr << " ... "; - try { - stk_classic::expreval::fad::Eval expr_eval(stk_classic::expreval::fad::Eval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "pass" << std::endl; - return true; - } - std::cout << "fail, should have parse error" << std::endl; - return false; -} - -/* -bool -vectest( - const char * expr) -{ - std::cout << " syntax " << expr << " ... "; - try { - stk_classic::expreval::fad::Eval expr_eval(stk_classic::expreval::fad::Eval::VariableMap::getDefaultResolver(), expr); - expr_eval.parse(); - } - catch (std::runtime_error &x) { - std::cout << "pass" << std::endl; - return true; - } - std::cout << "fail, should have parse error" << std::endl; - return false; -} -*/ - -typedef stk_classic::expreval::fad::FADDouble FADDouble; -typedef FADDouble (TestFunc)(stk_classic::expreval::fad::FADDouble); - -bool -test( - const char * expr, - TestFunc c_expr) -{ - bool failed = false; - std::cout << "Evaluate " << expr << " ... "; - std::string by_expr = std::string("by=") + expr + ";"; - stk_classic::expreval::fad::Eval expr_eval(stk_classic::expreval::fad::Eval::VariableMap::getDefaultResolver(), by_expr.c_str()); - expr_eval.parse(); - - // result and by are the ExprEvalFAD results - // y is the c++ result - - FADDouble x, y, by, result; - FADDouble v[2]; - - expr_eval.bindVariable("x", x); - expr_eval.bindVariable("by", by); - expr_eval.bindVariable("v", *v); - for (int i = 1; i < 100; ++i) { - x = v[1] = FADDouble(1, 0, i*0.01); - - y = (*c_expr)(x); - try { - result = expr_eval.evaluate(); - } - catch (std::runtime_error &exc) { - std::cout << expr << " at " - << std::setprecision(20) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << "(" << std::setprecision(20) << by - << ") threw exception " << exc.what() - << std::endl; - failed = true; - } - FADDouble absolute_error = fabs(result - y); - if (absolute_error > fabs(1.0e-14*result)) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << " error is " << absolute_error - << std::endl; - failed = true; - } - else if (by != result) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " does not match bound value " - << std::setprecision(20) << by - << std::endl; - failed = true; - } - if (absolute_error.dx(0) > fabs(1.0e-14*result.dx(0))) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " should be " << y - << " error is " << absolute_error - << std::endl; - failed = true; - } - else if (by != result) { - std::cout << expr << " at " - << std::setprecision(2) << x << " is " - << std::setprecision(20) << result - << " does not match bound value " - << std::setprecision(20) << by - << std::endl; - failed = true; - } - } - - std::cout << (failed ? "fail" : "pass") << std::endl; - return !failed; -} - -#define EXPREVALFAD_DEFINE_TEST(name,expr1,expr2) \ -FADDouble name(FADDouble x) {return expr2;} \ -const char *name##_expr = #expr1 - -#define EXPREVALFAD_DEFINE_TEST_1(name,expr) EXPREVALFAD_DEFINE_TEST(name,expr,expr) - - // Hiearchy tests -EXPREVALFAD_DEFINE_TEST_1(h1, x*1.0/2.0*3.0); -EXPREVALFAD_DEFINE_TEST_1(h2, x*1.0/2.0*3.0); -EXPREVALFAD_DEFINE_TEST_1(h3, x*(4.0+5.0)/6.0); -// EXPREVALFAD_DEFINE_TEST_1(h4, x==0.5); -// EXPREVALFAD_DEFINE_TEST_1(h5, x>=0.5); -// EXPREVALFAD_DEFINE_TEST_1(h6, x<0.25 || x>0.75); -// EXPREVALFAD_DEFINE_TEST_1(h7, x>0.25 && x<0.75); -// EXPREVALFAD_DEFINE_TEST_1(h8, x*2>0.25 && x<0.75); -// EXPREVALFAD_DEFINE_TEST_1(h9, !(x - 0.5)); -// EXPREVALFAD_DEFINE_TEST_1(h10, x > 0.5 ? 5.0 : 7.0); -EXPREVALFAD_DEFINE_TEST_1(h11, x*(x+1.0)); -EXPREVALFAD_DEFINE_TEST_1(h12, x*1.0+2.0); -EXPREVALFAD_DEFINE_TEST_1(h13, x*x+1.0); -EXPREVALFAD_DEFINE_TEST_1(h14, x+x*1.0+2.0); -EXPREVALFAD_DEFINE_TEST(h17, v[1]=x*0.5;y=v[1],x*0.5); -EXPREVALFAD_DEFINE_TEST_1(h18, x - -7); -EXPREVALFAD_DEFINE_TEST_1(h19, x - -x); -EXPREVALFAD_DEFINE_TEST_1(h20, x - - - 7); - - // Function tests -// EXPREVALFAD_DEFINE_TEST(f1, abs(x), fabs(x)); -// EXPREVALFAD_DEFINE_TEST(f2, mod(x,10.0),fmod(x,10.0)); -// EXPREVALFAD_DEFINE_TEST_1(f3, fabs(x)); -// EXPREVALFAD_DEFINE_TEST_1(f4, fmod(x,10.0)); -EXPREVALFAD_DEFINE_TEST_1(f5, acos(x)); -EXPREVALFAD_DEFINE_TEST_1(f6, asin(x)); -EXPREVALFAD_DEFINE_TEST_1(f7, atan(x)); -EXPREVALFAD_DEFINE_TEST_1(f8, cos(x)); -EXPREVALFAD_DEFINE_TEST_1(f9, cosh(x)); -EXPREVALFAD_DEFINE_TEST_1(f10, exp(x)); -// EXPREVALFAD_DEFINE_TEST_1(f11, ceil(x)); -// EXPREVALFAD_DEFINE_TEST_1(f12, floor(x)); -EXPREVALFAD_DEFINE_TEST_1(f13, log(x)); -EXPREVALFAD_DEFINE_TEST_1(f14, pow(x, 10.0)); -// EXPREVALFAD_DEFINE_TEST(f15, pow10(x),pow(x,10.0)); -EXPREVALFAD_DEFINE_TEST_1(f16, sin(x)); -EXPREVALFAD_DEFINE_TEST_1(f17, sinh(x)); -EXPREVALFAD_DEFINE_TEST_1(f18, sqrt(x)); -EXPREVALFAD_DEFINE_TEST_1(f19, tan(x)); -EXPREVALFAD_DEFINE_TEST_1(f20, tanh(x)); -// EXPREVALFAD_DEFINE_TEST(f21, atan2(x, PI),atan2(x, stk_classic::expreval::fad::Eval::s_pi)); -EXPREVALFAD_DEFINE_TEST(f22, ln(x), log(x)); -// EXPREVALFAD_DEFINE_TEST(f23, deg(x),(180.0 / Expr::Eval::s_pi) * x); -// EXPREVALFAD_DEFINE_TEST(f24, rad(x),(Expr::Eval::s_pi / 180.0) * x); -// EXPREVALFAD_DEFINE_TEST(f25, max(x,1.0),std::max(x,1.0)); -// EXPREVALFAD_DEFINE_TEST(f26, min(x,1.0),std::min(x,1.0)); -// EXPREVALFAD_DEFINE_TEST(f27, recttopolr(x,1.0),sqrt(x*x+1.0*1.0)); -// EXPREVALFAD_DEFINE_TEST(f28, recttopola(x,1.0),atan2(1.0, x)); -// EXPREVALFAD_DEFINE_TEST(f29, poltorectx(x,PI/4.0),x*cos(Expr::Eval::s_pi/4.0)); -// EXPREVALFAD_DEFINE_TEST(f30, poltorecty(x,PI/4.0),x*sin(Expr::Eval::s_pi/4.0)); -EXPREVALFAD_DEFINE_TEST_1(f31, 0.4209+4.5e-4*x); - -// Bova tests -EXPREVALFAD_DEFINE_TEST_1(b1, sin(x*.5)); -EXPREVALFAD_DEFINE_TEST_1(b2, .5*.2*sin(.5*x)); -EXPREVALFAD_DEFINE_TEST_1(b3, .5*sin(x)); - -} // namespace - -void -UnitTestEvaluatorFAD::testEvaluator() -{ - STKUNIT_EXPECT_TRUE(syntax("")); - STKUNIT_EXPECT_TRUE(syntax(";")); - STKUNIT_EXPECT_TRUE(syntax(";;")); - STKUNIT_EXPECT_TRUE(syntax(";;;")); - STKUNIT_EXPECT_TRUE(syntax("x*0.1")); - STKUNIT_EXPECT_TRUE(syntax("x*-0.1")); - STKUNIT_EXPECT_TRUE(syntax("x*+0.1")); - STKUNIT_EXPECT_TRUE(syntax("x--7.0")); - STKUNIT_EXPECT_TRUE(syntax("x*-x")); - STKUNIT_EXPECT_TRUE(syntax("x*+x")); - STKUNIT_EXPECT_TRUE(syntax("v[0]=v[1]*0.1")); - STKUNIT_EXPECT_TRUE(syntax("x--x")); - STKUNIT_EXPECT_TRUE(syntax("x---x")); - STKUNIT_EXPECT_TRUE(fail_syntax("0.01.02")); - STKUNIT_EXPECT_TRUE(fail_syntax("5*.e+10")); - STKUNIT_EXPECT_TRUE(fail_syntax("x y")); - STKUNIT_EXPECT_TRUE(fail_syntax("x(y")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*(y+1")); - STKUNIT_EXPECT_TRUE(fail_syntax("x*y)")); - STKUNIT_EXPECT_TRUE(fail_syntax("cos(x")); - STKUNIT_EXPECT_TRUE(fail_syntax("(x)y")); - STKUNIT_EXPECT_TRUE(fail_syntax("()")); - STKUNIT_EXPECT_TRUE(syntax("rand()")); - -#define EXPREVALFAD_TEST(name) test(name##_expr, name) - - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h1)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h2)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h3)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h4)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h5)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h6)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h7)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h8)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h9)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h10)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h11)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h12)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h13)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h14)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h16)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h17)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h18)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h19)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(h20)); - -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f1)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f2)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f3)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f4)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f5)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f6)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f7)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f8)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f9)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f10)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f11)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f12)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f13)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f14)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f15)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f16)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f17)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f18)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f19)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f20)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f21)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f22)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f23)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f24)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f25)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f26)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f27)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f28)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f29)); -// STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f30)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(f31)); - - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(b1)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(b2)); - STKUNIT_EXPECT_TRUE(EXPREVALFAD_TEST(b3)); - -#undef EXPREVALFAD_TEST -} diff --git a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestMain.cpp deleted file mode 100644 index b3cf8e41f4de..000000000000 --- a/packages/stk/stk_classic/stk_expreval/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_expreval/use_cases/CMakeLists.txt b/packages/stk/stk_classic/stk_expreval/use_cases/CMakeLists.txt deleted file mode 100644 index 060bca2bae93..000000000000 --- a/packages/stk/stk_classic/stk_expreval/use_cases/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_expreval_use_cases - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_expreval/use_cases/UseCaseMain.cpp b/packages/stk/stk_classic/stk_expreval/use_cases/UseCaseMain.cpp deleted file mode 100644 index 33538cad68cc..000000000000 --- a/packages/stk/stk_classic/stk_expreval/use_cases/UseCaseMain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_integration_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_integration_tests/CMakeLists.txt deleted file mode 100644 index caa8ea8a7c55..000000000000 --- a/packages/stk/stk_classic/stk_integration_tests/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -TRIBITS_ADD_TEST_DIRECTORIES(stk_mesh) - diff --git a/packages/stk/stk_classic/stk_integration_tests/stk_mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_integration_tests/stk_mesh/CMakeLists.txt deleted file mode 100644 index 612d2e6b54e1..000000000000 --- a/packages/stk/stk_classic/stk_integration_tests/stk_mesh/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_mesh) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_mesh_integration_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_integration_tests/stk_mesh/IntegrationTestMain.cpp b/packages/stk/stk_classic/stk_integration_tests/stk_mesh/IntegrationTestMain.cpp deleted file mode 100644 index b3cf8e41f4de..000000000000 --- a/packages/stk/stk_classic/stk_integration_tests/stk_mesh/IntegrationTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_io/CMakeLists.txt b/packages/stk/stk_classic/stk_io/CMakeLists.txt deleted file mode 100644 index a28e3755df47..000000000000 --- a/packages/stk/stk_classic/stk_io/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -ADD_SUBDIRECTORY(stk_io) - -IF (${PACKAGE_NAME}_ENABLE_TESTS) - TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) -ENDIF(${PACKAGE_NAME}_ENABLE_TESTS) - diff --git a/packages/stk/stk_classic/stk_io/doc/Doxyfile b/packages/stk/stk_classic/stk_io/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_io/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_io/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_io/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_io/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_io/doc/Doxyfile.input b/packages/stk/stk_classic/stk_io/doc/Doxyfile.input deleted file mode 100644 index 623024568857..000000000000 --- a/packages/stk/stk_classic/stk_io/doc/Doxyfile.input +++ /dev/null @@ -1,18 +0,0 @@ -#BANNER @copydoc stk_io_banner -#HOWTO @copydoc stk_io_howto - -# Note, any path you set here will have to be set twice; once for when doxygen -# is run from this directory, and once for when doxygen is run from the -# TPLs_src/Trilinos/packages/stk/doc directory. - -# Put local appends here! Note: Please only put append-type changes -# (IE, VAR += CHANGE) in this section. All the STK products must -# use the same configuration because, when doxygen is run from stk/doc -# to assemble HTML for the entire STK, any configuration overrides -# that happened here would affect the html generation for ALL the -# STK products. - -INPUT += ../stk_io/doc/index.dox \ - ../stk_io/stk_io \ - ../stk_io/unit_tests \ - ../stk_usecases/io diff --git a/packages/stk/stk_classic/stk_io/doc/index.dox b/packages/stk/stk_classic/stk_io/doc/index.dox deleted file mode 100644 index 9d7ae94dda9f..000000000000 --- a/packages/stk/stk_classic/stk_io/doc/index.dox +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * \page stk_io_banner Sierra Toolkit I/O - * - * \ref stk_io_module "Sierra Toolkit I/O Routines" - * - * The Sierra Toolkit IO product contains functions related to the transfer of data between the - * Ioss classes and the stk_classic::mesh classes. These functions do not provide a total turnkey mesh - * reading or results writing capability; rather, they provide helper functions for the - * application to use which make it easier to read and/or write the data. The application has - * full control over the mesh reading and results/restart writing. - * - * The basic flow chart for reading mesh data from the Ioss and defining and populating an - * stk_classic::mesh structure is shown in the \ref stk_example_io namespace and the - * stk_io/use_cases/io_example.cpp file. - * - * \addtogroup stk_io_module Sierra Toolkit I/O Routines - * - * The Sierra Toolkit IO product contains functions related to the transfer of data between the - * Ioss classes and the stk_classic::mesh classes. These functions do not provide a total turnkey mesh - * reading or results writing capability; rather, they provide helper functions for the - * application to use which make it easier to read and/or write the data. The application has - * full control over the mesh reading and results/restart writing. - * - */ - diff --git a/packages/stk/stk_classic/stk_io/stk_io/CMakeLists.txt b/packages/stk/stk_classic/stk_io/stk_io/CMakeLists.txt deleted file mode 100644 index cf6032d35feb..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ - - - -# -# A) Package-specific configuration options -# - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../util/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../stk_util) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../seacas/ioss/src) - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_io - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_base stkclassic_mesh_fem - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION -${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_io/) - -# AGS: I moved this to the bottom so that the link order was correct -# with -lstk_io_uti before -lstk_io. I think the DEPLIBS added in -# util/CMakeLists.txt should have done this, but it didn't work for me. -ADD_SUBDIRECTORY(util) diff --git a/packages/stk/stk_classic/stk_io/stk_io/IossBridge.cpp b/packages/stk/stk_classic/stk_io/stk_io/IossBridge.cpp deleted file mode 100644 index d1cb2922e21e..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/IossBridge.cpp +++ /dev/null @@ -1,1737 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { - -stk_classic::mesh::EntityRank get_entity_rank(const Ioss::GroupingEntity *entity, - const stk_classic::mesh::MetaData &meta) -{ - switch (entity->type()) { - case Ioss::NODEBLOCK: - return stk_classic::io::node_rank(meta); - - case Ioss::NODESET: - return stk_classic::io::node_rank(meta); - - case Ioss::ELEMENTBLOCK: - return stk_classic::io::element_rank(meta); - - case Ioss::SUPERELEMENT: - return stk_classic::io::element_rank(meta); - - case Ioss::SIDESET: - { - const Ioss::SideSet *sset = dynamic_cast(entity); - assert(sset != NULL); - int my_rank = sset->max_parametric_dimension(); - if (my_rank == 2) - return stk_classic::io::face_rank(meta); - if (my_rank == 1) - return stk_classic::io::edge_rank(meta); - if (my_rank == 0) - return stk_classic::io::node_rank(meta); - else - return stk_classic::mesh::InvalidEntityRank; - } - - case Ioss::SIDEBLOCK: - { - const Ioss::SideBlock *sblk = dynamic_cast(entity); - assert(sblk != NULL); - int rank = sblk->topology()->parametric_dimension(); - if (rank == 2) - return stk_classic::io::face_rank(meta); - if (rank == 1) - return stk_classic::io::edge_rank(meta); - if (rank == 0) - return stk_classic::io::node_rank(meta); - else - return stk_classic::mesh::InvalidEntityRank; - } - default: - return stk_classic::mesh::InvalidEntityRank; - } -} - -const CellTopologyData *map_ioss_to_topology( const std::string &element_type , - const int node_count) -{ - /// \todo REFACTOR Is there a good type to return for an "unknown" - /// topology type other than NULL? - - const CellTopologyData* celltopo = NULL ; - - const char *etype = element_type.c_str(); - if ( 0 == strncasecmp( "circle" , etype , 6 ) ) { - celltopo = shards::getCellTopologyData< shards::Particle >(); - } - else if ( 0 == strncasecmp( "sphere" , etype , 6) ) { - celltopo = shards::getCellTopologyData< shards::Particle >(); - } - // bar, beam, truss, rod... - else if ( 0 == strncasecmp( "bar" , etype , 3 ) ) { - if ( node_count == 2 ) { - celltopo = shards::getCellTopologyData< shards::Beam<2> >(); - } - else if ( node_count == 3 ) { - celltopo = shards::getCellTopologyData< shards::Beam<3> >(); - } - } - else if ( 0 == strncasecmp( "shellline2d" , etype , 11 ) ) { - if ( node_count == 2) { - celltopo = shards::getCellTopologyData< shards::ShellLine<2> >(); - } - else if ( node_count == 3) { - celltopo = shards::getCellTopologyData< shards::ShellLine<3> >(); - } - } else if ( 0 == strncasecmp( "shell" , etype , 5 ) ) { - // shell4, shell8, shell9 - if ( node_count == 4 ) { - celltopo = shards::getCellTopologyData< shards::ShellQuadrilateral<4> >(); - } - else if ( node_count == 8 ) { - celltopo = shards::getCellTopologyData< shards::ShellQuadrilateral<8> >(); - } - else if ( node_count == 9 ) { - celltopo = shards::getCellTopologyData< shards::ShellQuadrilateral<9> >(); - } - } - else if ( 0 == strncasecmp( "quad" , etype , 3 ) ) { - // The 2D types would be quad4, quad8, and quad9. - // The 3D types would be quad faces of a hex... quadface4, - // quadface8, quadface9. - if ( node_count == 4 ) { - celltopo = shards::getCellTopologyData< shards::Quadrilateral<4> >(); - } - else if ( node_count == 8 ) { - celltopo = shards::getCellTopologyData< shards::Quadrilateral<8> >(); - } - else if ( node_count == 9 ) { - celltopo = shards::getCellTopologyData< shards::Quadrilateral<9> >(); - } - } - else if ( 0 == strncasecmp( "trishell" , etype , 8 ) ) { - if ( node_count == 3 ) { - celltopo = shards::getCellTopologyData< shards::ShellTriangle<3> >(); - } - else if ( node_count == 6 ) { - celltopo = shards::getCellTopologyData< shards::ShellTriangle<6> >(); - } - } - - else if (0 == strncasecmp("triface", etype, 7) || - 0 == strncasecmp("tri", etype, 3)) { - if ( node_count == 3 ) { - celltopo = shards::getCellTopologyData< shards::Triangle<3> >(); - } - else if ( node_count == 4 ) { - celltopo = shards::getCellTopologyData< shards::Triangle<4> >(); - } - else if ( node_count == 6 ) { - celltopo = shards::getCellTopologyData< shards::Triangle<6> >(); - } - } - - else if ( 0 == strncasecmp( "pyramid" , etype , 7 ) ) { - if ( node_count == 5 ) { - celltopo = shards::getCellTopologyData< shards::Pyramid<5> >(); - } - else if ( node_count == 13 ) { - celltopo = shards::getCellTopologyData< shards::Pyramid<13> >(); - } - else if ( node_count == 14 ) { - celltopo = shards::getCellTopologyData< shards::Pyramid<14> >(); - } - } - - /// \todo REFACTOR Need to handle 8-node tet... - else if ( 0 == strncasecmp( "tetra" , etype , 5 ) ) { - if ( node_count == 4 ) { - celltopo = shards::getCellTopologyData< shards::Tetrahedron<4> >(); - } - else if ( node_count == 8 ) { - celltopo = shards::getCellTopologyData< shards::Tetrahedron<8> >(); - } - else if ( node_count == 10 ) { - celltopo = shards::getCellTopologyData< shards::Tetrahedron<10> >(); - } - } - else if ( 0 == strncasecmp( "wedge" , etype , 5 ) ) { - if ( node_count == 6 ) { - celltopo = shards::getCellTopologyData< shards::Wedge<6> >(); - } - else if ( node_count == 15 ) { - celltopo = shards::getCellTopologyData< shards::Wedge<15> >(); - } - else if ( node_count == 18 ) { - celltopo = shards::getCellTopologyData< shards::Wedge<18> >(); - } - } - else if ( 0 == strncasecmp( "hex" , etype , 3 ) ) { - if ( node_count == 8 ) { - celltopo = shards::getCellTopologyData< shards::Hexahedron<8> >(); - } - else if ( node_count == 20 ) { - celltopo = shards::getCellTopologyData< shards::Hexahedron<20> >(); - } - else if ( node_count == 27 ) { - celltopo = shards::getCellTopologyData< shards::Hexahedron<27> >(); - } - } - - else if (0 == strncasecmp("edge", etype, 4)) { - if ( node_count == 2) { - // edge2, edge2d2, edge3d2 - celltopo = shards::getCellTopologyData< shards::Line<2> >(); - } - else if ( node_count == 3) { - // edge3, edge2d3, edge3d3 - celltopo = shards::getCellTopologyData< shards::Line<3> >(); - } - } - - else if (0 == strncasecmp("node", etype, 4)) { - celltopo = shards::getCellTopologyData< shards::Node >(); - } - - if ( NULL == celltopo ) { - std::ostringstream oss; - oss << "ERROR, unsupported topology name = '" << element_type - << "' , node_count = " << node_count; - throw std::runtime_error(oss.str()); - } - - return celltopo; -} - -template -const stk_classic::mesh::FieldBase *declare_ioss_field_internal(stk_classic::mesh::MetaData &meta, - stk_classic::mesh::EntityRank type, - stk_classic::mesh::Part &part, - const Ioss::Field &io_field, - bool use_cartesian_for_scalar, T /*dummy*/) -{ - stk_classic::mesh::FieldBase *field_ptr = NULL; - std::string field_type = io_field.transformed_storage()->name(); - std::string name = io_field.get_name(); - size_t num_components = io_field.transformed_storage()->component_count(); - - if (field_type == "scalar" || num_components == 1) { - if (!use_cartesian_for_scalar) { - stk_classic::mesh::Field & field = meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part); - field_ptr = &field; - } else { - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, 1); - field_ptr = &field; - } - } - else if (field_type == "vector_2d") { - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, 2); - field_ptr = &field; - } - else if (field_type == "vector_3d") { - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, 3); - field_ptr = &field; - } - else if (field_type == "sym_tensor_33") { - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, 6); - field_ptr = &field; - } - else if (field_type == "full_tensor_36") { - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, 9); - field_ptr = &field; - } - else { - // Just create a field with the correct number of components... - stk_classic::mesh::Field & field = - meta.declare_field >(name); - stk_classic::mesh::put_field(field, type, part, num_components); - field_ptr = &field; - } - - if (field_ptr != NULL) { - stk_classic::io::set_field_role(*field_ptr, io_field.get_role()); - } - return field_ptr; -} - -const stk_classic::mesh::FieldBase *declare_ioss_field(stk_classic::mesh::MetaData &meta, - stk_classic::mesh::EntityRank type, - stk_classic::mesh::Part &part, - const Ioss::Field &io_field, - bool use_cartesian_for_scalar) -{ - const stk_classic::mesh::FieldBase *field_ptr = NULL; - if (io_field.get_type() == Ioss::Field::INTEGER) { - field_ptr = declare_ioss_field_internal(meta, type, part, io_field, use_cartesian_for_scalar, (int)1); - } else if (io_field.get_type() == Ioss::Field::REAL) { - field_ptr = declare_ioss_field_internal(meta, type, part, io_field, use_cartesian_for_scalar, (double)1.0); - } else if (io_field.get_type() == Ioss::Field::COMPLEX) { - field_ptr = declare_ioss_field_internal(meta, type, part, io_field, use_cartesian_for_scalar, std::complex(0.0,0.0)); - } else { - std::ostringstream errmsg; - errmsg << "ERROR: Unrecognized field type for IO field '" - << io_field.get_name() << "'."; - throw std::runtime_error(errmsg.str()); - } - return field_ptr; -} - -template -void internal_field_data_from_ioss(const Ioss::Field &io_field, - const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - T /*dummy */) -{ - size_t field_component_count = io_field.transformed_storage()->component_count(); - - std::vector io_field_data; - size_t io_entity_count = io_entity->get_field_data(io_field.get_name(), io_field_data); - assert(io_field_data.size() == entities.size() * field_component_count); - - size_t entity_count = entities.size(); - - if (io_entity_count != entity_count) { - std::ostringstream errmsg; - errmsg << "ERROR: Field count mismatch for IO field '" - << io_field.get_name() << "'. The IO system has " << io_entity_count - << " entries, but the stk:mesh system has " << entity_count - << " entries. The two counts must match."; - throw std::runtime_error(errmsg.str()); - } - - for (size_t i=0; i < entity_count; ++i) { - /// \todo REFACTOR Is there a way to get the data from a - /// "FieldBase*" field as a T* without the cast? - if (entities[i] != NULL) { - T *fld_data = (T*)stk_classic::mesh::field_data(*field, *entities[i]); - assert(fld_data != NULL); - for(size_t j=0; j -void internal_field_data_to_ioss(const Ioss::Field &io_field, - const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - T /*dummy */) -{ - size_t field_component_count = io_field.transformed_storage()->component_count(); - size_t entity_count = entities.size(); - - std::vector io_field_data(entity_count*field_component_count); - - for (size_t i=0; i < entity_count; ++i) { - /// \todo REFACTOR Is there a way to get the data from a - /// "FieldBase*" field as a T* without the cast? - if (entities[i] != NULL) { - T *fld_data = (T*)stk_classic::mesh::field_data(*field, *entities[i]); - assert(fld_data != NULL); - for(size_t j=0; jput_field_data(io_field.get_name(), io_field_data); - assert(io_field_data.size() == entities.size() * field_component_count); - - if (io_entity_count != entity_count) { - std::ostringstream errmsg; - errmsg << "ERROR: Field count mismatch for IO field '" - << io_field.get_name() << "'. The IO system has " << io_entity_count - << " entries, but the stk:mesh system has " << entity_count - << " entries. The two counts must match."; - throw std::runtime_error(errmsg.str()); - } -} - -}//namespace - -namespace stk_classic { -namespace io { - -size_t db_api_int_size(const Ioss::GroupingEntity *entity) -{ - return entity->get_database()->int_byte_size_api(); -} - -bool invalid_rank(stk_classic::mesh::EntityRank rank) -{ - return rank == mesh::InvalidEntityRank; -} - -stk_classic::mesh::EntityRank part_primary_entity_rank(const stk_classic::mesh::Part &part) -{ - if (mesh::MetaData::get(part).universal_part() == part) { - return stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - } - else { - return part.primary_entity_rank(); - } -} - -stk_classic::mesh::EntityRank element_rank(const stk_classic::mesh::MetaData &meta) -{ - return stk_classic::mesh::fem::FEMMetaData::get(meta).element_rank(); -} - -stk_classic::mesh::EntityRank side_rank(const stk_classic::mesh::MetaData &meta) -{ - return stk_classic::mesh::fem::FEMMetaData::get(meta).side_rank(); -} - -stk_classic::mesh::EntityRank face_rank(const stk_classic::mesh::MetaData &meta) -{ - return stk_classic::mesh::fem::FEMMetaData::get(meta).face_rank(); -} - -stk_classic::mesh::EntityRank edge_rank(const stk_classic::mesh::MetaData &meta) -{ - return stk_classic::mesh::fem::FEMMetaData::get(meta).edge_rank(); -} - -stk_classic::mesh::EntityRank node_rank(const stk_classic::mesh::MetaData& meta) -{ - return stk_classic::mesh::fem::FEMMetaData::NODE_RANK; -} - -void set_cell_topology(stk_classic::mesh::Part &part, const CellTopologyData * const cell_topology) -{ - stk_classic::mesh::fem::set_cell_topology(part, cell_topology); -} - -const CellTopologyData *get_cell_topology(const stk_classic::mesh::Part &part) -{ - return stk_classic::mesh::fem::FEMMetaData::get(part).get_cell_topology(part).getCellTopologyData(); -} - -void initialize_spatial_dimension(stk_classic::mesh::fem::FEMMetaData & fem_meta, size_t spatial_dimension, - const std::vector &entity_rank_names) -{ - if (!fem_meta.is_FEM_initialized() ) { - fem_meta.FEM_initialize(spatial_dimension, entity_rank_names); - } -} - -void initialize_spatial_dimension(stk_classic::mesh::MetaData &meta, size_t spatial_dimension, - const std::vector &entity_rank_names) -{ - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(meta); - initialize_spatial_dimension(fem_meta, spatial_dimension, entity_rank_names); -} - -void get_io_field_type(const stk_classic::mesh::FieldBase *field, - const stk_classic::mesh::FieldRestriction &res, - std::pair *result) -{ - static const std::string invalid("invalid"); - static const std::string scalar("scalar"); - static const std::string vector_2d("vector_2d"); - static const std::string vector_3d("vector_3d"); - static const std::string quaternion_2d("quaternion_2d"); - static const std::string quaternion_3d("quaternion_3d"); - static const std::string full_tensor_36("full_tensor_36"); - static const std::string full_tensor_32("full_tensor_32"); - static const std::string full_tensor_22("full_tensor_22"); - static const std::string full_tensor_16("full_tensor_16"); - static const std::string full_tensor_12("full_tensor_12"); - static const std::string sym_tensor_33("sym_tensor_33"); - static const std::string sym_tensor_31("sym_tensor_31"); - static const std::string sym_tensor_21("sym_tensor_21"); - static const std::string sym_tensor_13("sym_tensor_13"); - static const std::string sym_tensor_11("sym_tensor_11"); - static const std::string sym_tensor_10("sym_tensor_10"); - static const std::string asym_tensor_03("asym_tensor_03"); - static const std::string asym_tensor_02("asym_tensor_02"); - static const std::string asym_tensor_01("asym_tensor_01"); - static const std::string matrix_22("matrix_22"); - static const std::string matrix_33("matrix_33"); - - const unsigned rank = field->rank(); - const shards::ArrayDimTag * const * const tags = field->dimension_tags(); - - result->second = Ioss::Field::INVALID; - - if ( field->type_is() ) { - result->second = Ioss::Field::REAL; - } - else if ( field->type_is() ) { - result->second = Ioss::Field::INTEGER; - } - - if ( 0 == rank ) { - result->first = scalar ; - } - else if ( 1 == rank ) { - size_t num_comp = res.stride(0); - if ( tags[0] == & stk_classic::mesh::Cartesian::tag() && 1 == num_comp ) { - result->first = scalar ; - } - else if ( tags[0] == & stk_classic::mesh::Cartesian::tag() && 2 == num_comp ) { - result->first = vector_2d ; - } - else if ( tags[0] == & stk_classic::mesh::Cartesian::tag() && 3 == num_comp ) { - result->first = vector_3d ; - } - else if ( tags[0] == & stk_classic::mesh::FullTensor::tag() && 9 == num_comp ) { - result->first = full_tensor_36 ; - } - else if ( tags[0] == & stk_classic::mesh::FullTensor::tag() && 5 == num_comp ) { - result->first = full_tensor_32 ; - } - else if ( tags[0] == & stk_classic::mesh::FullTensor::tag() && 4 == num_comp ) { - result->first = full_tensor_22 ; - } - else if ( tags[0] == & stk_classic::mesh::FullTensor::tag() && 3 == num_comp ) { - result->first = full_tensor_12 ; - } - else if ( tags[0] == & stk_classic::mesh::SymmetricTensor::tag() && 6 == num_comp ) { - result->first = sym_tensor_33 ; - } - else if ( tags[0] == & stk_classic::mesh::SymmetricTensor::tag() && 4 == num_comp ) { - result->first = sym_tensor_31 ; - } - else if ( tags[0] == & stk_classic::mesh::SymmetricTensor::tag() && 3 == num_comp ) { - result->first = sym_tensor_21 ; - } - } - - if ( result->first.empty() ) { - size_t num_comp = res.stride(rank-1); - std::ostringstream tmp ; - tmp << "Real[" << num_comp << "]" ; - result->first = tmp.str(); - } -} - -//---------------------------------------------------------------------- -const Ioss::GroupingEntity *get_associated_ioss_entity(const mesh::Part &part) -{ - const Ioss::GroupingEntity *entity = part.attribute(); - if (!entity || entity->type() == Ioss::INVALID_TYPE) { - return NULL; - } else { - return entity; - } -} - -void put_io_part_attribute(mesh::Part & part, Ioss::GroupingEntity *entity) -{ - if (part.attribute() != NULL) { - std::string msg = "stk_classic::io::put_io_part_attribute( "; - msg += part.name(); - msg += " ) FAILED:"; - msg += " io_part_attribute is already defined"; - throw std::runtime_error( msg ); - } - - mesh::MetaData & meta = mesh::MetaData::get(part); - if (entity) { - meta.declare_attribute_no_delete(part, entity); - } else { - Ioss::GroupingEntity *attr = new Ioss::NullEntity(); - meta.declare_attribute_with_delete(part, attr); - } -} - -void remove_io_part_attribute(mesh::Part & part) -{ - const Ioss::GroupingEntity *entity = part.attribute(); - if (entity == NULL) { - std::string msg = "stk_classic::io::remove_io_part_attribute( "; - msg += part.name(); - msg += " ) FAILED:"; - msg += " io_part_attribute is not defined on this part"; - throw std::runtime_error( msg ); - } else { - mesh::MetaData & meta = mesh::MetaData::get(part); - bool success = meta.remove_attribute(part, entity); - if (!success) { - std::string msg = "stk_classic::io::remove_io_part_attribute( "; - msg += part.name(); - msg += " ) FAILED:"; - msg += " meta.remove_attribute(..) returned failure."; - throw std::runtime_error( msg ); - } - - if (entity->type() == Ioss::INVALID_TYPE) { - delete entity; - } - - } -} - -/** Determine whether the field is defined on the specified part - * and should also be associated with a Ioss GroupingEntity for - * input or output - */ -bool is_valid_part_field(const stk_classic::mesh::FieldBase *field, - const stk_classic::mesh::EntityRank part_type, - const stk_classic::mesh::Part &part, - const stk_classic::mesh::Part &universal, - const Ioss::Field::RoleType filter_role, - bool add_all) -{ - const Ioss::Field::RoleType *role = stk_classic::io::get_field_role(*field); - - if (!add_all && role == NULL) { - return false; - } - - if (role != NULL && *role != filter_role) - return false; - - const stk_classic::mesh::FieldBase::Restriction &res = field->restriction(part_type, part); - if (res.dimension() > 0) { - // The field exists on the current 'part'. Now check (for - // node types only) whether the 'part' is *either* the - // universal_part() *or* the field *doesn't* exist on the - // universal part... - // Note that for "node" type parts, the IO database has a part - // (nodeblock) that corresponds to the universal_part(), so - // fields defined on all nodes are output on the nodeblock and - // fields defined on only a subset of the parts should be - // output on that subset which maps to a nodeset. For other - // part types, there is no IO entity that corresponds to a - // universal part, so fields must be output on the part they - // exist on. There may be a problem if we start using element - // sets ..., but wait until we get to that point; current code - // works with current entity set. - if (part_type != node_rank(mesh::MetaData::get(part)) || part == universal) { - return true; - } - - const stk_classic::mesh::FieldBase::Restriction &res_universe = field->restriction(part_type, universal); - if (res_universe.dimension() <= 0) { - // Field exists on current part, but not on the universal - // set (and this part is not the universal part) - return true; - } - } - return false; -} - -/// \todo QUESTION Should this function be at the application level, -/// or provided by stk_io? In either case, applications should have -/// capabilty to register new mappings. -// ======================================================================== -const CellTopologyData *map_topology_ioss_to_cell(const Ioss::ElementTopology *topology) -{ - /// \todo REFACTOR Consider either using or integrating the - /// Trilinos CellTopology package into or with the - /// Ioss::ElementTopology classes. That would then totally - /// eliminate the need for these fragile mapping functions. - /// However, it would still need to be extensible via application - /// registration of new type mappings. - - std::string name = topology->name(); - int io_nodes_per_element = topology->number_nodes(); - - const CellTopologyData *cell_topology = map_ioss_to_topology(name, io_nodes_per_element); - - return cell_topology; -} - -std::string map_topology_cell_to_ioss( const CellTopologyData *cell_top, - int spatial_dimension) -{ - std::string extype = "unknown"; - - if (cell_top == NULL) - return extype; - - if(strcmp(cell_top->name, "super") == 0) { - std::stringstream oss; - oss << "super" << cell_top->node_count; - return oss.str(); - } - else if(strncasecmp(cell_top->name, "super", 5) == 0) { - return cell_top->name; - } - - switch( cell_top->key ) { - case shards::Node::key : extype.assign( "node" ); break ; - case shards::Particle::key : - if (spatial_dimension == 2) extype = "circle1"; - else extype = "sphere1"; - break ; - - case shards::Beam<2>::key : - extype = "bar2"; - break ; - - case shards::Beam<3>::key : - extype = "bar3"; - break ; - - case shards::Line<2>::key : - extype = "edge2"; - break ; - case shards::Line<3>::key : - extype = "edge3"; - break ; - - case shards::ShellLine<2>::key : extype.assign( "shellline2d2" ); break ; - case shards::ShellLine<3>::key : extype.assign( "shellline2d3" ); break ; - - case shards::Triangle<3>::key : - extype = "tri3"; - break ; - case shards::Triangle<4>::key : - extype = "tri4"; - break ; - case shards::Triangle<6>::key : - extype = "tri6"; - break ; - - case shards::ShellTriangle<3>::key : extype.assign( "trishell3" ); break ; - case shards::ShellTriangle<6>::key : extype.assign( "trishell6" ); break ; - - case shards::Quadrilateral<4>::key : - extype = "quad4"; - break ; - case shards::Quadrilateral<8>::key : - extype = "quad8"; - break ; - case shards::Quadrilateral<9>::key : - extype = "quad9"; - break ; - - case shards::ShellQuadrilateral<4>::key : extype.assign( "shell4" ); break ; - case shards::ShellQuadrilateral<8>::key : extype.assign( "shell8" ); break ; - case shards::ShellQuadrilateral<9>::key : extype.assign( "shell9" ); break ; - - case shards::Tetrahedron< 4>::key : extype.assign( "tetra4" ); break ; - case shards::Tetrahedron<8>::key : extype.assign( "tetra8" ); break ; - case shards::Tetrahedron<10>::key : extype.assign( "tetra10" ); break ; - - case shards::Pyramid< 5>::key : extype.assign( "pyramid5" ); break ; - case shards::Pyramid<13>::key : extype.assign( "pyramid13" ); break ; - case shards::Pyramid<14>::key : extype.assign( "pyramid14" ); break ; - - case shards::Wedge< 6>::key : extype.assign( "wedge6" ); break ; - case shards::Wedge<15>::key : extype.assign( "wedge15" ); break ; - case shards::Wedge<18>::key : extype.assign( "wedge18" ); break ; - - case shards::Hexahedron< 8>::key : extype.assign( "hex8" ); break ; - case shards::Hexahedron<20>::key : extype.assign( "hex20" ); break ; - case shards::Hexahedron<27>::key : extype.assign( "hex27" ); break ; - - default: - std::ostringstream oss; - oss << "stk_classic::io::map_topology_to_ioss( '" << cell_top->name - << "' ) ERROR unmapped topology" << std::endl ; - throw std::runtime_error(oss.str()); - } - - return extype ; -} - -void internal_part_processing(Ioss::GroupingEntity *entity, stk_classic::mesh::fem::FEMMetaData &meta) -{ - internal_part_processing(entity, meta.get_meta_data(meta)); -} - -void internal_part_processing(Ioss::EntityBlock *entity, stk_classic::mesh::fem::FEMMetaData &meta) -{ - internal_part_processing(entity, meta.get_meta_data(meta)); -} - -void internal_part_processing(Ioss::GroupingEntity *entity, stk_classic::mesh::MetaData &meta) -{ - if (include_entity(entity)) { - stk_classic::mesh::fem::FEMMetaData * fem_meta = const_cast(meta.get_attribute()); - mesh::EntityRank type = get_entity_rank(entity, meta); - if (fem_meta) { - stk_classic::mesh::Part & part = fem_meta->declare_part(entity->name(), type); - stk_classic::io::put_io_part_attribute(part, entity); - } else { - stk_classic::mesh::Part & part = meta.declare_part(entity->name(), type); - stk_classic::io::put_io_part_attribute(part, entity); - } - } -} - -void internal_part_processing(Ioss::EntityBlock *entity, stk_classic::mesh::MetaData &meta) -{ - if (include_entity(entity)) { - mesh::EntityRank type = get_entity_rank(entity, meta); - stk_classic::mesh::fem::FEMMetaData * fem_meta = const_cast(meta.get_attribute()); - //const stk_classic::mesh::fem::FEMMetaData * fem_meta = meta.get_attribute(); - stk_classic::mesh::Part * part = NULL; - if( fem_meta ) - part = &fem_meta->declare_part(entity->name(), type); - else - part = &meta.declare_part(entity->name(), type); - stk_classic::io::put_io_part_attribute(*part, entity); - - const Ioss::ElementTopology *topology = entity->topology(); - // Check spatial dimension of the element topology here so we - // can issue a more meaningful error message. If the - // dimension is bad and we continue to the following calls, - // there is an exception and we get unintelligible (to the - // user) error messages. Could also do a catch... - - if (entity->type() == Ioss::ELEMENTBLOCK) { - assert(topology != NULL); - if (fem_meta && (topology->spatial_dimension() < (int)fem_meta->spatial_dimension())) { - // NOTE: The comparison is '<' and not '!=' since a 2D mesh - // can contain a "3d" element -- a Beam is both a 2D and - // 3D element... - - std::ostringstream msg ; - msg << "\n\nERROR: Element Block " << entity->name() - << " contains " << topology->name() << " elements with spatial dimension " - << topology->spatial_dimension() - << "\n which does not match the spatial dimension of the model which is " - << fem_meta->spatial_dimension() << "\n\n"; - throw std::runtime_error( msg.str() ); - } - } - - const CellTopologyData * const cell_topology = map_topology_ioss_to_cell(topology); - // \todo IMPLEMENT Determine whether application can work - // with this topology type... Perhaps map_topology_ioss_to_cell only - // returns a valid topology if the application has registered - // that it can handle that specific topology. - - if (cell_topology != NULL) { - if( fem_meta ) { - const stk_classic::mesh::fem::CellTopology cell_topo(cell_topology); - stk_classic::mesh::fem::set_cell_topology(*part, cell_topo); - } - stk_classic::io::set_cell_topology(*part, cell_topology); - } else { - // \todo IMPLEMENT handle cell_topolgy mapping error... - } - stk_classic::io::define_io_fields(entity, Ioss::Field::ATTRIBUTE, *part, type); - } -} - -//---------------------------------------------------------------------- -/** Add all stk_classic::Fields on the entities of the specified part_type - * on the specified part of the specified role * to the specified - * Ioss::GroupingEntity - */ -void ioss_add_fields(const stk_classic::mesh::Part &part, - const stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *entity, - const Ioss::Field::RoleType filter_role, - const bool add_all) -{ - const stk_classic::mesh::MetaData & meta = mesh::MetaData::get(part); - const stk_classic::mesh::Part &universal = meta.universal_part(); - - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role, add_all)) { - const stk_classic::mesh::FieldBase::Restriction &res = f->restriction(part_type, part); - std::pair field_type; - get_io_field_type(f, res, &field_type); - if (field_type.second != Ioss::Field::INVALID) { - size_t entity_size = entity->get_property("entity_count").get_int(); - const std::string& name = f->name(); - entity->field_add(Ioss::Field(name, field_type.second, field_type.first, - filter_role, entity_size)); - } - } - } -} - -/** - * For the given Ioss::GroupingEntity "entity", find all fields that - * exist on the input database of type "role" and declare them on - * the give stk_classic::mesh::Part "part". The "part_type" argument - * specifies the entity type (node, element, ...) that the field - * should be declared on for this "part" - * - * The "role" will typically be either "ATTRIBUTE" or "TRANSIENT" - */ -void define_io_fields(Ioss::GroupingEntity *entity, - Ioss::Field::RoleType role, - stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type) -{ - stk_classic::mesh::MetaData &meta = mesh::MetaData::get(part); - - bool use_cartesian_for_scalar = false; - if (role == Ioss::Field::ATTRIBUTE) - use_cartesian_for_scalar = true; - - Ioss::NameList names; - entity->field_describe(role, &names); - - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - // \todo IMPLEMENT Need a field selection mechanism and a field naming - // (ioss_name -> stk_classic::name) For now, select all and give the - // stk field the same name as the ioss field. - - // Skip the attribute field that is named "attribute" - if (*I == "attribute" && names.size() > 1) - continue; - - // \todo IMPLEMENT Need to determine whether these are - // multi-state fields or constant, or interpolated, or ... - Ioss::Field io_field = entity->get_field(*I); - declare_ioss_field(meta, part_type, part, io_field, use_cartesian_for_scalar); - } -} - -template -void get_entity_list(Ioss::GroupingEntity *io_entity, - stk_classic::mesh::EntityRank part_type, - const stk_classic::mesh::BulkData &bulk, - std::vector &entities, INT /*dummy*/) -{ - std::vector ids ; - io_entity->get_field_data("ids", ids); - - size_t count = ids.size(); - entities.reserve(count); - - for(size_t i=0; i &entities) -{ - if (db_api_int_size(io_entity) == 4) { - get_entity_list(io_entity, part_type, bulk, entities, (int)0); - } else { - get_entity_list(io_entity, part_type, bulk, entities, (int64_t)0); - } -} - -void field_data_from_ioss(const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - const std::string &io_fld_name) -{ - /// \todo REFACTOR Need some additional compatability checks between - /// Ioss field and stk_classic::mesh::Field; better error messages... - - if (field != NULL && io_entity->field_exists(io_fld_name)) { - const Ioss::Field &io_field = io_entity->get_fieldref(io_fld_name); - if (field->type_is()) { - internal_field_data_from_ioss(io_field, field, entities, io_entity, - static_cast(1.0)); - } else if (field->type_is()) { - // Make sure the IO field type matches the STK field type. - // By default, all IO fields are created of type 'double' - if (db_api_int_size(io_entity) == 4) { - if (io_field.get_type() != Ioss::Field::INTEGER) { - Ioss::Field &tmp = const_cast(io_field); - tmp.reset_type(Ioss::Field::INTEGER); - } - internal_field_data_from_ioss(io_field, field, entities, io_entity, - static_cast(1)); - } else { - if (io_field.get_type() != Ioss::Field::INT64) { - Ioss::Field &tmp = const_cast(io_field); - tmp.reset_type(Ioss::Field::INT64); - } - internal_field_data_from_ioss(io_field, field, entities, io_entity, - static_cast(1)); - } - } - } -} - -void field_data_to_ioss(const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - const std::string &io_fld_name, - Ioss::Field::RoleType filter_role) -{ - /// \todo REFACTOR Need some additional compatability checks between - /// Ioss field and stk_classic::mesh::Field; better error messages... - - if (field != NULL && io_entity->field_exists(io_fld_name)) { - const Ioss::Field &io_field = io_entity->get_fieldref(io_fld_name); - if (io_field.get_role() == filter_role) { - if (field->type_is()) { - internal_field_data_to_ioss(io_field, field, entities, io_entity, - static_cast(1.0)); - } else if (field->type_is()) { - if (io_field.get_type() != Ioss::Field::INTEGER) { - Ioss::Field &tmp = const_cast(io_field); - tmp.reset_type(Ioss::Field::INTEGER); - } - // FIX 64? - internal_field_data_to_ioss(io_field, field, entities, io_entity, - static_cast(1)); - } - } - } -} - -//---------------------------------------------------------------------- - -// ---------------------------------------------------------------------- -// Returns true if 'entity' should be a 'part' in the analysis mesh. -// Returns false if the application is only using a subset of the -// database entities and this entity is not to be used. The -// "omitted" property is set by the application during parsing or -// pre-mesh reading time. -bool include_entity(const Ioss::GroupingEntity *entity) -{ - assert(entity); - - // Check whether entity has "omitted" property... - bool omitted = (entity->property_exists("omitted")) && - (entity->get_property("omitted").get_int() == 1); - - return !omitted; -} - -namespace { - -void define_side_block(stk_classic::mesh::Part &part, - Ioss::SideSet *sset, - stk_classic::mesh::EntityRank type, - size_t side_count, int spatial_dimension) -{ - const stk_classic::mesh::EntityRank siderank = side_rank(mesh::MetaData::get(part)); - const stk_classic::mesh::EntityRank edgerank = edge_rank(mesh::MetaData::get(part)); - ThrowRequire(type == siderank || type == edgerank); - - const CellTopologyData *const side_topology = stk_classic::io::get_cell_topology(part) ? - stk_classic::io::get_cell_topology(part) : - stk_classic::mesh::fem::FEMMetaData::get(part).get_cell_topology(part).getCellTopologyData(); - - if (side_topology == NULL && side_count > 0) { - // Non-empty side blocks must have an associated topology - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Part " << part.name() << " returned NULL from get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - - std::string io_topo = map_topology_cell_to_ioss(side_topology, spatial_dimension); - std::string element_topo_name = "unknown"; - - // Get sideblock parent element topology quantities... - // Try to decode from part name... - std::vector tokens; - stk_classic::util::tokenize(part.name(), "_", tokens); - if (tokens.size() >= 4) { - // Name of form: "name_eltopo_sidetopo_id" or - // "name_block_id_sidetopo_id" - // "name" is typically "surface". - const Ioss::ElementTopology *element_topo = Ioss::ElementTopology::factory(tokens[tokens.size()-3], true); - if (element_topo != NULL) { - element_topo_name = element_topo->name(); - } - } - - Ioss::SideBlock *side_block = new Ioss::SideBlock( sset->get_database() , - part.name() , - io_topo, element_topo_name, side_count); - assert(sset->get_side_block(part.name()) == NULL); - sset->add(side_block); - - const mesh::Field *df = get_distribution_factor_field(part); - if (df != NULL) { - int nodes_per_side = side_topology->node_count; - std::string storage_type = "Real["; - storage_type += Ioss::Utils::to_string(nodes_per_side); - storage_type += "]"; - side_block->field_add(Ioss::Field("distribution_factors", Ioss::Field::REAL, storage_type, - Ioss::Field::MESH, side_count)); - } - - // Add the attribute fields. - ioss_add_fields(part, part_primary_entity_rank(part), side_block, Ioss::Field::ATTRIBUTE); -} - -void define_side_blocks(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk_data, - Ioss::SideSet *sset, - stk_classic::mesh::EntityRank type, - int spatial_dimension, - const stk_classic::mesh::Selector *anded_selector) -{ - mesh::MetaData & meta = mesh::MetaData::get(part); - ThrowRequire(type == face_rank(meta) || type == edge_rank(meta)); - - const stk_classic::mesh::PartVector &blocks = part.subsets(); - if (blocks.size() > 0) { - for (size_t j = 0; j < blocks.size(); j++) { - mesh::Part & side_block_part = *blocks[j]; - stk_classic::mesh::EntityRank side_rank = side_block_part.primary_entity_rank(); - mesh::Selector selector = meta.locally_owned_part() & side_block_part; - if (anded_selector) selector &= *anded_selector; - - size_t num_side = count_selected_entities(selector, bulk_data.buckets(side_rank)); - - define_side_block(side_block_part, sset, side_rank, num_side, spatial_dimension); - } - } else { - stk_classic::mesh::EntityRank side_rank = part.primary_entity_rank(); - mesh::Selector selector = meta.locally_owned_part() & part; - if (anded_selector) selector &= *anded_selector; - size_t num_side = count_selected_entities(selector, bulk_data.buckets(side_rank)); - define_side_block(part, sset, side_rank, num_side, spatial_dimension); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void define_node_block(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - Ioss::Region &io_region, - const stk_classic::mesh::Selector *anded_selector) -{ - //-------------------------------- - // Set the spatial dimension: - mesh::MetaData & meta = mesh::MetaData::get(part); - - /// \todo REFACTOR The coordinate field would typically be - /// stored by the app and wouldn't need to be accessed via - /// string lookup. App infrastructure is not shown here, so - /// lookup by string for the example. - mesh::Field *coord_field = - meta.get_field >(std::string("coordinates")); - assert(coord_field != NULL); - const mesh::FieldBase::Restriction &res = coord_field->restriction(node_rank(meta), part); - - /** \todo REFACTOR Need a clear way to query dimensions - * from the field restriction. - */ - const int spatial_dim = res.dimension() ; - - //-------------------------------- - // Create the special universal node block: - - mesh::Selector selector = meta.locally_owned_part() | meta.globally_shared_part(); - if (anded_selector) selector &= *anded_selector; - - size_t num_nodes = count_selected_entities(selector, bulk.buckets(node_rank(meta))); - - const std::string name("nodeblock_1"); - - Ioss::NodeBlock * const nb = new Ioss::NodeBlock(io_region.get_database(), - name, num_nodes, spatial_dim); - io_region.add( nb ); - - // Add the attribute fields. - ioss_add_fields(part, part_primary_entity_rank(part), nb, Ioss::Field::ATTRIBUTE); -} - - -void define_element_block(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - Ioss::Region &io_region, - const stk_classic::mesh::Selector *anded_selector) -{ - - mesh::MetaData & meta = mesh::MetaData::get(part); - const stk_classic::mesh::EntityRank elem_rank = element_rank(meta); - - const CellTopologyData * const cell_top = - stk_classic::io::get_cell_topology(part) ? - stk_classic::io::get_cell_topology(part) : - stk_classic::mesh::fem::FEMMetaData::get(part).get_cell_topology(part).getCellTopologyData(); - - if (cell_top == NULL) { - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Part " << part.name() << " returned NULL from get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - - mesh::Selector selector = meta.locally_owned_part() & part; - if (anded_selector) selector &= *anded_selector; - const size_t num_elems = count_selected_entities( selector, bulk.buckets(elem_rank)); - - int spatial_dim = io_region.get_property("spatial_dimension").get_int(); - - // Defer the counting of attributes until after we define the - // element block so we can count them as we add them as fields to - // the element block - Ioss::ElementBlock *eb = new Ioss::ElementBlock(io_region.get_database() , - part.name() , - map_topology_cell_to_ioss(cell_top, spatial_dim) , - num_elems); - io_region.add(eb); - - // Add the attribute fields. - ioss_add_fields(part, part_primary_entity_rank(part), eb, Ioss::Field::ATTRIBUTE); -} - -void define_side_set(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - Ioss::Region &io_region, - const stk_classic::mesh::Selector *anded_selector) -{ - const stk_classic::mesh::EntityRank si_rank = side_rank(mesh::MetaData::get(part)); - - bool create_sideset = true; - if (part.subsets().empty()) { - // Only define a sideset for this part if its superset part is - // not a side-containing part.. (i.e., this part is not a subset part - // in a surface...) - const stk_classic::mesh::PartVector &supersets = part.supersets(); - for (size_t i=0; i < supersets.size(); i++) { - if (is_part_io_part(*supersets[i]) && supersets[i]->primary_entity_rank() == si_rank) { - create_sideset = false; - break; - } - } - } - if (create_sideset) { - Ioss::SideSet * const ss = new Ioss::SideSet(io_region.get_database(), part.name()); - - io_region.add(ss); - int spatial_dim = io_region.get_property("spatial_dimension").get_int(); - define_side_blocks(part, bulk, ss, si_rank, spatial_dim, anded_selector); - } -} - -void define_node_set(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - Ioss::Region &io_region, - const stk_classic::mesh::Selector *anded_selector) -{ - mesh::MetaData & meta = mesh::MetaData::get(part); - - mesh::Selector selector = ( meta.locally_owned_part() | meta.globally_shared_part() ) & part; - if (anded_selector) selector &= *anded_selector; - - const size_t num_nodes = - count_selected_entities(selector, bulk.buckets(node_rank(meta))); - - Ioss::NodeSet * const ns = - new Ioss::NodeSet( io_region.get_database(), part.name(), num_nodes); - io_region.add(ns); - - // Add the attribute fields. - ioss_add_fields(part, part_primary_entity_rank(part), ns, Ioss::Field::ATTRIBUTE); -} -} // namespace - -struct part_compare { - bool operator() (stk_classic::mesh::Part *i, stk_classic::mesh::Part *j) { return (i->name() < j->name()); } -}; - -void define_output_db(Ioss::Region & io_region , - const mesh::BulkData &bulk_data, - const Ioss::Region *input_region, - const stk_classic::mesh::Selector *anded_selector, - const bool sort_stk_parts) -{ - const mesh::MetaData & meta_data = mesh::MetaData::get(bulk_data); - - const stk_classic::mesh::EntityRank no_rank = node_rank(meta_data); - const stk_classic::mesh::EntityRank el_rank = element_rank(meta_data); - const stk_classic::mesh::EntityRank fa_rank = face_rank(meta_data); - const stk_classic::mesh::EntityRank ed_rank = edge_rank(meta_data); - - io_region.begin_mode( Ioss::STATE_DEFINE_MODEL ); - - define_node_block(meta_data.universal_part(), bulk_data, io_region, anded_selector); - - // All parts of the meta data: - //const mesh::PartVector & all_parts = meta_data.get_parts(); - const mesh::PartVector & all_parts_unsorted = meta_data.get_parts(); - - // sort parts so they go out the same on all processors (srk: this was induced by streaming refine) - mesh::PartVector all_parts = all_parts_unsorted; - if (sort_stk_parts) - std::sort(all_parts.begin(), all_parts.end(), part_compare()); - - for (mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - - mesh::Part * const part = *i ; - - if (is_part_io_part(*part)) { - if (invalid_rank(part->primary_entity_rank())) - continue; - else if (part->primary_entity_rank() == no_rank) - define_node_set(*part, bulk_data, io_region, anded_selector); - else if (part->primary_entity_rank() == el_rank) - define_element_block(*part, bulk_data, io_region, anded_selector); - else if (part->primary_entity_rank() == fa_rank) - define_side_set(*part, bulk_data, io_region, anded_selector); - else if (part->primary_entity_rank() == ed_rank) - define_side_set(*part, bulk_data, io_region, anded_selector); - } - } - - if (input_region != NULL) - io_region.synchronize_id_and_name(input_region, true); - - // for streaming refinement, each "pseudo-processor" doesn't know about others, so we pick a sort order - // and use it for all pseudo-procs - the original_block_order property is used to set the order - // on all procs. - if (sort_stk_parts) - { - int offset=0; - for (mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - - mesh::Part * const part = *i ; - - if (is_part_io_part(*part)) { - if (invalid_rank(part->primary_entity_rank())) - continue; - else if (part->primary_entity_rank() == el_rank) - { - Ioss::GroupingEntity *element_block = io_region.get_entity(part->name()); - if (element_block) - { - if (element_block->property_exists("original_block_order")) { - element_block->property_erase("original_block_order"); - } - element_block->property_add(Ioss::Property("original_block_order", offset)); - ++offset; - } - } - } - } - } - - io_region.end_mode( Ioss::STATE_DEFINE_MODEL ); -} - -//---------------------------------------------------------------------- - -namespace { - -size_t get_entities(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - std::vector &entities, - bool include_shared, - const stk_classic::mesh::Selector *anded_selector) -{ - mesh::MetaData & meta = mesh::MetaData::get(part); - mesh::EntityRank type = part_primary_entity_rank(part); - if (invalid_rank(type)) - type = node_rank(meta); - - mesh::Selector own_share = meta.locally_owned_part(); - if (include_shared) - own_share |= meta.globally_shared_part(); - - mesh::Selector selector = part & own_share; - if (anded_selector) selector &= *anded_selector; - - get_selected_entities(selector, bulk.buckets(type), entities); - return entities.size(); -} - - -template -void write_side_data_to_ioss( Ioss::GroupingEntity & io , - mesh::Part * const part , - const mesh::BulkData & bulk_data, - const stk_classic::mesh::Selector *anded_selector, INT /*dummy*/ ) -{ - //std::cout << "tmp write_side_data_to_ioss part= " << part->name() << std::endl; - const mesh::MetaData & meta_data = mesh::MetaData::get(*part); - - std::vector sides ; - size_t num_sides = get_entities(*part, bulk_data, sides, false, anded_selector); - - std::vector elem_side_ids; elem_side_ids.reserve(num_sides*2); - - stk_classic::mesh::EntityRank elem_rank = element_rank(meta_data); - for(size_t i=0; ientity()->identifier()); - elem_side_ids.push_back(rel->identifier() + 1) ; // Ioss is 1-based, mesh is 0-based. - } - - const size_t num_side_written = io.put_field_data("element_side",elem_side_ids); - - if ( num_sides != num_side_written ) { - std::ostringstream msg ; - - msg << "stk_classic::io::write_side_data_to_ioss FAILED for " ; - msg << io.name(); - msg << " in Ioss::GroupingEntity::put_field_data:" ; - msg << " num_sides = " << num_sides ; - msg << " , num_side_written = " << num_side_written ; - throw std::runtime_error( msg.str() ); - } - - const mesh::Field *df = get_distribution_factor_field(*part); - if (df != NULL) { - field_data_to_ioss(df, sides, &io, "distribution_factors", Ioss::Field::MESH); - } - - const std::vector &fields = meta_data.get_fields(); - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const mesh::FieldBase *f = *I ; ++I ; - const Ioss::Field::RoleType *role = stk_classic::io::get_field_role(*f); - if (role != NULL && *role == Ioss::Field::ATTRIBUTE) { - stk_classic::io::field_data_to_ioss(f, sides, &io, f->name(), Ioss::Field::ATTRIBUTE); - } - } -} - -//---------------------------------------------------------------------- -template -void output_node_block(Ioss::NodeBlock &nb, - stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - const stk_classic::mesh::Selector *anded_selector, INT /*dummy*/) -{ - //---------------------------------- - // Exactly one node block to obtain the nodal coordinates and ids: - // Note that the "ids" field of the nodes needs to be written - // before any other bulk data that uses node ids since it sets up - // the global->local mapping of nodes for the output database. - // Similarly for the element "ids" field related to bulk data - // using element ids. - std::vector nodes ; - size_t num_nodes = get_entities(part, bulk, nodes, true, anded_selector); - - std::vector node_ids; node_ids.reserve(num_nodes); - for(size_t i=0; i &fields = meta_data.get_fields(); - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const mesh::FieldBase *f = *I ; ++I ; - if (stk_classic::io::is_valid_part_field(f, part_primary_entity_rank(part), part, - meta_data.universal_part(), Ioss::Field::ATTRIBUTE, false)) { - stk_classic::io::field_data_to_ioss(f, nodes, &nb, f->name(), Ioss::Field::ATTRIBUTE); - } - } -} - -template -void output_element_block(Ioss::ElementBlock *block, - const stk_classic::mesh::BulkData &bulk, - const stk_classic::mesh::Selector *anded_selector, INT /*dummy*/) -{ - const stk_classic::mesh::MetaData & meta_data = mesh::MetaData::get(bulk); - const std::string& name = block->name(); - mesh::Part* part = meta_data.get_part(name); - - assert(part != NULL); - std::vector elements; - size_t num_elems = get_entities(*part, bulk, elements, false, anded_selector); - - const CellTopologyData * cell_topo = - stk_classic::io::get_cell_topology(*part) ? - stk_classic::io::get_cell_topology(*part) : - stk_classic::mesh::fem::FEMMetaData::get(*part).get_cell_topology(*part).getCellTopologyData(); - if (cell_topo == NULL) { - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Part " << part->name() << " returned NULL from get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - size_t nodes_per_elem = cell_topo->node_count; - - std::vector elem_ids; elem_ids.reserve(num_elems); - std::vector connectivity; connectivity.reserve(num_elems*nodes_per_elem); - - stk_classic::mesh::EntityRank no_rank = node_rank(meta_data); - for (size_t i = 0; i < num_elems; ++i) { - - elem_ids.push_back(elements[i]->identifier()); - - const mesh::PairIterRelation elem_nodes = elements[i]->relations(no_rank); - - for (size_t j = 0; j < nodes_per_elem; ++j) { - connectivity.push_back(elem_nodes[j].entity()->identifier()); - } - } - - const size_t num_ids_written = block->put_field_data("ids", elem_ids); - const size_t num_con_written = block->put_field_data("connectivity", connectivity); - - if ( num_elems != num_ids_written || num_elems != num_con_written ) { - std::ostringstream msg ; - msg << " FAILED in Ioss::ElementBlock::put_field_data:" << std::endl ; - msg << " num_elems = " << num_elems << std::endl ; - msg << " num_ids_written = " << num_ids_written << std::endl ; - msg << " num_connectivity_written = " << num_con_written << std::endl ; - throw std::runtime_error( msg.str() ); - } - - stk_classic::mesh::EntityRank elem_rank = element_rank(meta_data); - const std::vector &fields = meta_data.get_fields(); - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const mesh::FieldBase *f = *I ; ++I ; - const Ioss::Field::RoleType *role = stk_classic::io::get_field_role(*f); - if (role != NULL && *role == Ioss::Field::ATTRIBUTE) { - const mesh::FieldBase::Restriction &res = f->restriction(elem_rank, *part); - if (res.dimension() > 0) { - stk_classic::io::field_data_to_ioss(f, elements, block, f->name(), Ioss::Field::ATTRIBUTE); - } - } - } -} - -template -void output_node_set(Ioss::NodeSet *ns, const stk_classic::mesh::BulkData &bulk, - const stk_classic::mesh::Selector *anded_selector, INT /*dummy*/) -{ - const stk_classic::mesh::MetaData & meta_data = mesh::MetaData::get(bulk); - const std::string& name = ns->name(); - stk_classic::mesh::Part* part = meta_data.get_part(name); - assert(part != NULL); - - std::vector nodes ; - size_t num_nodes = get_entities(*part, bulk, nodes, true, anded_selector); - - std::vector node_ids; node_ids.reserve(num_nodes); - for(size_t i=0; iput_field_data("ids", node_ids); - if ( num_nodes != num_ids_written ) { - std::ostringstream msg ; - msg << " FAILED in Ioss::NodeSet::put_field_data:" - << " num_nodes = " << num_nodes - << ", num_ids_written = " << num_ids_written; - throw std::runtime_error( msg.str() ); - } - - stk_classic::mesh::Field *df_field = - meta_data.get_field >("distribution_factors"); - if (df_field != NULL) { - stk_classic::io::field_data_to_ioss(df_field, nodes, ns, "distribution_factors", Ioss::Field::MESH); - } - - const std::vector &fields = meta_data.get_fields(); - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const mesh::FieldBase *f = *I ; ++I ; - const Ioss::Field::RoleType *role = stk_classic::io::get_field_role(*f); - if (role != NULL && *role == Ioss::Field::ATTRIBUTE) { - const mesh::FieldBase::Restriction &res = f->restriction(0, *part); - if (res.dimension() > 0) { - stk_classic::io::field_data_to_ioss(f, nodes, ns, f->name(), Ioss::Field::ATTRIBUTE); - } - } - } -} - -template -void output_side_set(Ioss::SideSet *ss, - const stk_classic::mesh::BulkData &bulk, - const stk_classic::mesh::Selector *anded_selector, INT dummy) -{ - const stk_classic::mesh::MetaData & meta_data = mesh::MetaData::get(bulk); - size_t block_count = ss->block_count(); - for (size_t i=0; i < block_count; i++) { - Ioss::SideBlock *block = ss->get_block(i); - if (stk_classic::io::include_entity(block)) { - stk_classic::mesh::Part * const part = meta_data.get_part(block->name()); - stk_classic::io::write_side_data_to_ioss(*block, part, bulk, anded_selector, dummy); - } - } -} - -} // namespace - -void write_output_db(Ioss::Region& io_region, - const stk_classic::mesh::BulkData& bulk, - const stk_classic::mesh::Selector *anded_selector) -{ - const stk_classic::mesh::MetaData & meta = mesh::MetaData::get(bulk); - - bool ints64bit = db_api_int_size(&io_region) == 8; - - io_region.begin_mode( Ioss::STATE_MODEL ); - - int64_t z64 = 0; - int z32 = 0; - - Ioss::NodeBlock & nb = *io_region.get_node_blocks()[0]; - if (ints64bit) - output_node_block(nb, meta.universal_part(), bulk, anded_selector, z64); - else - output_node_block(nb, meta.universal_part(), bulk, anded_selector, z32); - - //---------------------------------- - const Ioss::ElementBlockContainer& elem_blocks = io_region.get_element_blocks(); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - if (ints64bit) - output_element_block(*it, bulk, anded_selector, z64); - else - output_element_block(*it, bulk, anded_selector, z32); - } - - //---------------------------------- - const Ioss::NodeSetContainer& node_sets = io_region.get_nodesets(); - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - if (ints64bit) - output_node_set(*it, bulk, anded_selector, z64); - else - output_node_set(*it, bulk, anded_selector, z32); - } - - //---------------------------------- - const Ioss::SideSetContainer& side_sets = io_region.get_sidesets(); - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - if (ints64bit) - output_side_set(*it, bulk, anded_selector, z64); - else - output_side_set(*it, bulk, anded_selector, z32); - } - - io_region.end_mode( Ioss::STATE_MODEL ); -} - -//---------------------------------------------------------------------- -bool is_part_io_part(stk_classic::mesh::Part &part) -{ - return NULL != part.attribute(); -} - -const stk_classic::mesh::Field *get_distribution_factor_field(const stk_classic::mesh::Part &p) -{ - return p.attribute >(); -} - -void set_distribution_factor_field(stk_classic::mesh::Part &p, - const stk_classic::mesh::Field &df_field) -{ - stk_classic::mesh::MetaData &m = mesh::MetaData::get(p); - m.declare_attribute_no_delete(p,&df_field); -} - -const Ioss::Field::RoleType* get_field_role(const stk_classic::mesh::FieldBase &f) -{ - return f.attribute(); -} - -void set_field_role(stk_classic::mesh::FieldBase &f, const Ioss::Field::RoleType &role) -{ - Ioss::Field::RoleType *my_role = new Ioss::Field::RoleType(role); - stk_classic::mesh::MetaData &m = mesh::MetaData::get(f); - const Ioss::Field::RoleType *check = m.declare_attribute_with_delete(f, my_role); - if ( check != my_role ) { - if (*check != *my_role) { - std::ostringstream msg ; - msg << " FAILED in IossBridge -- set_field_role:" - << " The role type had already been set to " << *check - << ", so it is not possible to change it to " << *my_role; - throw std::runtime_error( msg.str() ); - } - delete my_role; - } -} - -}//namespace io -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_io/stk_io/IossBridge.hpp b/packages/stk/stk_classic/stk_io/stk_io/IossBridge.hpp deleted file mode 100644 index 4af2bd54a1b9..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/IossBridge.hpp +++ /dev/null @@ -1,335 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_io_IossBridge_hpp -#define stk_io_IossBridge_hpp - -#include -#include -#include -#include -#include - -// TODO: remove this and uses of USE_FEMMETADATA once the migration is done (srkenno@sandia.gov) - -#define USE_FEMMETADATA -#ifdef USE_FEMMETADATA -#include -#endif - -#include -#include -#include -#include -#include - -namespace Ioss { -class Region; -class GroupingEntity; -class EntityBlock; -class SideSet; -class Field; -class ElementTopology; -} - -struct CellTopologyData; - -namespace stk_classic { - -/** - * The stk_classic::io namespace contains functions related to the - * transfer of data between the Ioss classes and the stk_classic::mesh - * classes. These functions do not provide a total turnkey mesh - * reading or results writing capability; rather, they provide - * helper functions for the application to use which make it - * easier to read and/or write the data. The application has full - * control over the mesh reading and results/restart writing. - * - * The basic flow chart for reading mesh data from the Ioss and - * defining and populating an stk_classic::mesh structure is shown in the - * use_cases/io_example.cpp file. - */ -namespace io { - -/** \addtogroup stk_io_module - * \{ - */ -/** Returns true if the Ioss 'entity' should be a 'part' in the - * analysis mesh. Returns false if the application is only using - * a subset of the database entities and this entity is not to be - * used. The function checks whether the "omitted" property exists - * and if it does, whether the value of the property is "1". The - * "omitted" property is set by the application during parsing or - * pre-mesh reading time. - */ -bool include_entity(const Ioss::GroupingEntity *entity); - -void internal_part_processing(Ioss::GroupingEntity *entity, stk_classic::mesh::fem::FEMMetaData &meta); - -void internal_part_processing(Ioss::EntityBlock *entity, stk_classic::mesh::fem::FEMMetaData &meta); - -//! \deprecated -void internal_part_processing(Ioss::GroupingEntity *entity, stk_classic::mesh::MetaData &meta); - -//! \deprecated -void internal_part_processing(Ioss::EntityBlock *entity, stk_classic::mesh::MetaData &meta); - -/** This is the primary function used by an application to define - * the stk_classic::mesh which corresponds to the Ioss mesh read from the - * finite element model (e.g. exodusII file). For all entities in - * the passed in 'entities' list, the function will determine - * whether the entity should be included (see stk_classic::io::include_entity()), - * and it will then delcare a part corresponding to the - * entity. It also adds the io_part attribute (see - * stk_classic::io::define_output_db()) which will cause the part to be output to a - * results or restart file. - */ -template -void default_part_processing(const std::vector &entities, - stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - for(size_t i=0; i < entities.size(); i++) { - T* entity = entities[i]; - internal_part_processing(entity, fem_meta); - } -} - -//! \deprecated -template -void default_part_processing(const std::vector &entities, stk_classic::mesh::MetaData &meta, - const stk_classic::mesh::EntityRank) -{ - stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(meta); - default_part_processing (entities, fem_meta); -} - -/** Given the newly created Ioss::Region 'io_region', define the - * model corresponding to the stk_classic::mesh 'bulk_data'. If the - * optional 'input_region' is passed as an argument, then - * synchronize all names and ids found on 'input_region' to the - * output region 'io_region'. The routine will query all parts - * in 'bulk_data' and if they are io_parts (define by the existance - * of the IOPartAttribute attribute on the part), then a - * corresponding Ioss entity will be defined. This routine only - * deals with the non-transient portion of the model; no transient - * fields are defined at this point. - * - * \param[in] sort_stk_parts Force a sorted order on the stk_mesh - * parts so all pieces of a decomposed mesh have consistent part - * ordering. Normally not necessary, since MetaData is created - * from a parallel-consistent data base. It is useful in cases - * such as streaming refinement where each piece of a parallel- - * decomposed mesh is read in sequentially and parts are thus - * possibly created in different orderings. - * - */ -void define_output_db( Ioss::Region & io_region, - const mesh::BulkData& bulk_data, - const Ioss::Region *input_region = NULL, - const stk_classic::mesh::Selector *anded_selector = NULL, - const bool sort_stk_parts = false); - - -/** Given an Ioss::Region 'io_region' which has already had its - * metadata defined via 'define_output_db()' call; transfer all bulk - * data (node coordinates, element connectivity, ...) to the - * output database that corresponds to this Ioss::Region. At - * return, all non-transient portions of the output database will - * have been output. - */ -void write_output_db( Ioss::Region & io_region , - const mesh::BulkData& bulk, - const stk_classic::mesh::Selector *anded_selector = NULL); - - -//---------------------------------------------------------------------- - -/** Determine whether the field is defined on the specified part - * and should also be associated with an Ioss::GroupingEntity for - * input or output. - * - * The 'universal' part is argument currently only used for an - * EntityRank of type 'node'. In this case, the field is only - * valid if it does exist on 'part', but does not exist on - * 'universal' unless 'part' and 'universal' are the same part. - * The motivation for this is that an Ioss::NodeBlock corresponds - * to the universal part and an Ioss::NodeSet corresponds to the - * sub part. Without the check, all nodeblock fields would also be - * defined on the nodeset which is not what is desired. - * - * The 'filter_role' only selects fields with the specified role - * (e.g., TRANSIENT, ATTRIBUTE, ..., see Ioss documentation for - * valid roles) unless 'add_all == true' is specified. - * - * The field's role is defined via a call to - * 'stk_classic::io::set_field_role' - */ -bool is_valid_part_field(const stk_classic::mesh::FieldBase *field, - const stk_classic::mesh::EntityRank part_type, - const stk_classic::mesh::Part &part, - const stk_classic::mesh::Part &universal, - const Ioss::Field::RoleType filter_role, - const bool add_all = false); - -/** Add all stk_classic::Fields on the specified part of the specified - * filter_role to the specified Ioss::GroupingEntity. Retrieves - * all fields; calls 'is_valid_part_field'; and adds those that - * return true. - */ -void ioss_add_fields(const stk_classic::mesh::Part &part, - const stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *entity, - const Ioss::Field::RoleType filter_role, - const bool add_all = false); - -/** - * For the given Ioss::GroupingEntity "entity", find all fields that - * exist on the input database of type "role" and declare them on - * the give stk_classic::mesh::Part "part". The "part_type" argument - * specifies the entity type (node, element, ...) that the field - * should be declared on for this "part" - * - * The "role" will typically be either "ATTRIBUTE" or "TRANSIENT" - * - * This is essentially the complement of the 'ioss_add_fields' - * function. - */ -void define_io_fields(Ioss::GroupingEntity *entity, - Ioss::Field::RoleType role, - stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type); - -/** Given an Ioss::ElementTopolgy, return the corresponding - * CellTopologyData. If a corresponding topology is not found, a - * runtime error exception will be thrown. - */ -const CellTopologyData *map_topology_ioss_to_cell(const Ioss::ElementTopology *topology); - -/** Given a CellTopologyData and a spatial_dimension, return the - * corresponding Ioss::ElementTopology. If a corresponding - * topology is not found, a runtime error exception will be - * thrown. - */ -std::string map_topology_cell_to_ioss( const CellTopologyData *cell_top, - int spatial_dimension); - -/** - * For the given Ioss entity, create a vector of stk_classic::mesh::Entity - * pointers such that the entities in the 'entities' list match - * the order of the entities in the Ioss entity. If there is not a - * corresponding stk_classic::mesh::Entity, the entry at that location - * will be NULL. Upon return, the size of the 'entities' list - * should match the number of entities in 'io_entity'. The returned - * list is typically used to get/put field data from/to an - * Ioss::GroupingEntity to/from an stk_classic::mesh::Field. See - * stk_classic::io::field_data_from_ioss() and stk_classic::io::field_data_to_ioss() for examples. - */ -void get_entity_list(Ioss::GroupingEntity *io_entity, - stk_classic::mesh::EntityRank part_type, - const stk_classic::mesh::BulkData &bulk, - std::vector &entities); - -/** - * Fill the specified 'field' with data from the Ioss field named - * 'io_fld_name' on the Ioss entity 'io_entity'. The mapping from - * the meshobjects in the Ioss io_entity to the - * stk_classic::mesh::Entities is given by the 'entities' list. - */ -void field_data_from_ioss(const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - const std::string &io_fld_name); - -/** - * Extract data from the specified 'field' and put it to the Ioss - * field named 'io_fld_name' on the Ioss entity 'io_entity'. The - * mapping from the meshobjects in the Ioss io_entity to the - * stk_classic::mesh::Entities is given by the 'entities' list. - */ -void field_data_to_ioss(const stk_classic::mesh::FieldBase *field, - std::vector &entities, - Ioss::GroupingEntity *io_entity, - const std::string &io_fld_name, - Ioss::Field::RoleType filter_role); - - -/** Returns the stk_classic::mesh::Field which contains the distribution - * factors for the specified part 'p'. Returns NULL if there is - * no such field. - */ -const mesh::Field *get_distribution_factor_field(const mesh::Part &p); - -/** Defines the stk_classic::mesh::Field which contains the distribution - * factors for the specified part 'p'. - */ -void set_distribution_factor_field(mesh::Part &p, - const mesh::Field &df_field); - -/** Returns the Ioss::Field::RoleType of the mesh::Field 'f'. - * This must have earlier been defined using - * stk_classic::io::set_field_role(). Returns NULL if the role was not - * defined. - */ -const Ioss::Field::RoleType* get_field_role(const mesh::FieldBase &f); - -/** Defines the Ioss::Field::RoleType of the mesh::Field 'f' to be - * 'role'. - */ -void set_field_role(mesh::FieldBase &f, const Ioss::Field::RoleType &role); - -/** Returns whether the mesh::Part 'p' should be output to a - * results or restart database. Or, in other words, whether the - * part should have an Ioss::GroupingEntity of the correct type - * defined in an Ioss::Region. The function will return true if - * the part 'p' has an IOPartAttribute defined on it. The - * attributed is defined via the stk_classic::io::put_io_part_attribute() - * function. - */ -bool is_part_io_part(mesh::Part &part); - -/** Define an attribute on the specified part 'part' indicating that - * this part should be used for io. \see is_part_io_part() - */ -void put_io_part_attribute( mesh::Part &part, Ioss::GroupingEntity *entity = NULL); - -/** Remove the existing attribute on the specified part 'part' that indicates that - * this part should be used for io. \see is_part_io_part() - */ -void remove_io_part_attribute(mesh::Part &part); - -const Ioss::GroupingEntity *get_associated_ioss_entity(const mesh::Part &part); - -size_t db_api_int_size(const Ioss::GroupingEntity *entity); - -// To minimize ifdefs for the deprecated code: -bool invalid_rank(mesh::EntityRank rank); -mesh::EntityRank part_primary_entity_rank(const mesh::Part &part); -mesh::EntityRank element_rank(const mesh::MetaData &meta); -mesh::EntityRank side_rank(const mesh::MetaData &meta); -mesh::EntityRank face_rank(const mesh::MetaData &meta); -mesh::EntityRank edge_rank(const mesh::MetaData &meta); -mesh::EntityRank node_rank(const mesh::MetaData &meta); -void set_cell_topology(mesh::Part &part, const CellTopologyData * const cell_topology); -const CellTopologyData *get_cell_topology(const mesh::Part &part); - -void initialize_spatial_dimension(mesh::fem::FEMMetaData &fem_meta, size_t spatial_dimension, const std::vector &entity_rank_names); - -//! \deprecated -void initialize_spatial_dimension(mesh::MetaData &meta, size_t spatial_dimension, const std::vector &entity_rank_names); - -void get_io_field_type(const stk_classic::mesh::FieldBase *field, - const stk_classic::mesh::FieldRestriction &res, - std::pair *result); -/** - * \} - */ - -}//namespace io -}//namespace stk_classic -#endif - diff --git a/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.cpp b/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.cpp deleted file mode 100644 index ea305d12050f..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.cpp +++ /dev/null @@ -1,1080 +0,0 @@ - /*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -namespace { -void process_surface_entity(Ioss::SideSet *sset, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - assert(sset->type() == Ioss::SIDESET); - const Ioss::SideBlockContainer& blocks = sset->get_side_blocks(); - stk_classic::io::default_part_processing(blocks, fem_meta); - - stk_classic::mesh::Part* const ss_part = fem_meta.get_part(sset->name()); - assert(ss_part != NULL); - - stk_classic::mesh::Field *distribution_factors_field = NULL; - bool surface_df_defined = false; // Has the surface df field been defined yet? - - size_t block_count = sset->block_count(); - for (size_t i=0; i < block_count; i++) { - Ioss::SideBlock *sb = sset->get_block(i); - if (stk_classic::io::include_entity(sb)) { - stk_classic::mesh::Part * const sb_part = fem_meta.get_part(sb->name()); - assert(sb_part != NULL); - fem_meta.declare_part_subset(*ss_part, *sb_part); - - if (sb->field_exists("distribution_factors")) { - if (!surface_df_defined) { - std::string field_name = sset->name() + "_df"; - distribution_factors_field = - &fem_meta.declare_field >(field_name); - stk_classic::io::set_field_role(*distribution_factors_field, Ioss::Field::MESH); - stk_classic::io::set_distribution_factor_field(*ss_part, *distribution_factors_field); - surface_df_defined = true; - } - stk_classic::io::set_distribution_factor_field(*sb_part, *distribution_factors_field); - int side_node_count = sb->topology()->number_nodes(); - stk_classic::mesh::put_field(*distribution_factors_field, - stk_classic::io::part_primary_entity_rank(*sb_part), - *sb_part, side_node_count); - } - } - } -} - - size_t get_entities(stk_classic::mesh::Part &part, - const stk_classic::mesh::BulkData &bulk, - std::vector &entities, - const stk_classic::mesh::Selector *anded_selector) - { - stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(part); - stk_classic::mesh::EntityRank type = stk_classic::io::part_primary_entity_rank(part); - - stk_classic::mesh::Selector own = meta.locally_owned_part(); - stk_classic::mesh::Selector selector = part & own; - if (anded_selector) selector &= *anded_selector; - - get_selected_entities(selector, bulk.buckets(type), entities); - return entities.size(); - } -} - -// ======================================================================== -template -void process_surface_entity(const Ioss::SideSet* sset, stk_classic::mesh::BulkData & bulk, INT /*dummy*/) -{ - assert(sset->type() == Ioss::SIDESET); - - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - size_t block_count = sset->block_count(); - for (size_t i=0; i < block_count; i++) { - Ioss::SideBlock *block = sset->get_block(i); - if (stk_classic::io::include_entity(block)) { - std::vector side_ids ; - std::vector elem_side ; - - stk_classic::mesh::Part * const sb_part = fem_meta.get_part(block->name()); - stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank(); - - block->get_field_data("ids", side_ids); - block->get_field_data("element_side", elem_side); - - assert(side_ids.size() * 2 == elem_side.size()); - stk_classic::mesh::PartVector add_parts( 1 , sb_part ); - - size_t side_count = side_ids.size(); - std::vector sides(side_count); - for(size_t is=0; is *df_field = - stk_classic::io::get_distribution_factor_field(*sb_part); - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors"); - } - - // Add all attributes as fields. - // If the only attribute is 'attribute', then add it; otherwise the other attributes are the - // named components of the 'attribute' field, so add them instead. - Ioss::NameList names; - block->field_describe(Ioss::Field::ATTRIBUTE, &names); - for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if(*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = fem_meta.get_field (*I); - if (field) - stk_classic::io::field_data_from_ioss(field, sides, block, *I); - } - } - } -} - -void process_surface_entity(const Ioss::SideSet* sset, stk_classic::mesh::BulkData & bulk) -{ - if (stk_classic::io::db_api_int_size(sset) == 4) - process_surface_entity(sset, bulk, (int)0); - else - process_surface_entity(sset, bulk, (int64_t)0); -} - -void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - assert(nb->field_exists("mesh_model_coordinates")); - Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); - int spatial_dim = coordinates.transformed_storage()->component_count(); - - stk_classic::mesh::Field & coord_field = - fem_meta.declare_field >("coordinates"); - - stk_classic::mesh::put_field( coord_field, fem_meta.node_rank(), fem_meta.universal_part(), spatial_dim); - stk_classic::io::define_io_fields(nb, Ioss::Field::ATTRIBUTE, fem_meta.universal_part(), 0); -} - -void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - // This must be called after the "process_element_blocks" call - // since there may be nodes that exist in the database that are - // not part of the analysis mesh due to subsetting of the element - // blocks. - - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - std::vector nodes; - stk_classic::io::get_entity_list(nb, fem_meta.node_rank(), bulk, nodes); - - stk_classic::mesh::Field *coord_field = - fem_meta.get_field >("coordinates"); - - stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates"); - - // Add all attributes as fields. - // If the only attribute is 'attribute', then add it; otherwise the other attributes are the - // named components of the 'attribute' field, so add them instead. - Ioss::NameList names; - nb->field_describe(Ioss::Field::ATTRIBUTE, &names); - for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if(*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = fem_meta.get_field (*I); - if (field) - stk_classic::io::field_data_from_ioss(field, nodes, nb, *I); - } -} - -// ======================================================================== -void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - stk_classic::io::default_part_processing(elem_blocks, fem_meta); -} - -template -void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, INT /*dummy*/) -{ - const stk_classic::mesh::fem::FEMMetaData& fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string &name = entity->name(); - stk_classic::mesh::Part* const part = fem_meta.get_part(name); - assert(part != NULL); - - const CellTopologyData* cell_topo = stk_classic::io::get_cell_topology(*part); - if (cell_topo == NULL) { - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Part " << part->name() << " returned NULL from get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - - std::vector elem_ids ; - std::vector connectivity ; - - entity->get_field_data("ids", elem_ids); - entity->get_field_data("connectivity", connectivity); - - size_t element_count = elem_ids.size(); - int nodes_per_elem = cell_topo->node_count ; - - std::vector id_vec(nodes_per_elem); - std::vector elements(element_count); - - for(size_t i=0; ifield_describe(Ioss::Field::ATTRIBUTE, &names); - for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if(*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = fem_meta.get_field (*I); - if (field) - stk_classic::io::field_data_from_ioss(field, elements, entity, *I); - } - } - } -} - -// ======================================================================== -// ======================================================================== -void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - stk_classic::io::default_part_processing(node_sets, fem_meta); - - stk_classic::mesh::Field & distribution_factors_field = - fem_meta.declare_field >("distribution_factors"); - stk_classic::io::set_field_role(distribution_factors_field, Ioss::Field::MESH); - - /** \todo REFACTOR How to associate distribution_factors field - * with the nodeset part if a node is a member of multiple - * nodesets - */ - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = fem_meta.get_part(entity->name()); - assert(part != NULL); - assert(entity->field_exists("distribution_factors")); - - stk_classic::mesh::put_field(distribution_factors_field, fem_meta.node_rank(), *part); - } - } -} - -// ======================================================================== -// ======================================================================== -void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - stk_classic::io::default_part_processing(side_sets, fem_meta); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, fem_meta); - } - } -} - -// ======================================================================== -template -void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, INT /*dummy*/) -{ - // Should only process nodes that have already been defined via the element - // blocks connectivity lists. - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string & name = entity->name(); - stk_classic::mesh::Part* const part = fem_meta.get_part(name); - assert(part != NULL); - stk_classic::mesh::PartVector add_parts( 1 , part ); - - std::vector node_ids ; - size_t node_count = entity->get_field_data("ids", node_ids); - - std::vector nodes(node_count); - stk_classic::mesh::EntityRank n_rank = fem_meta.node_rank(); - for(size_t i=0; i *df_field = - fem_meta.get_field >("distribution_factors"); - - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors"); - } - - // Add all attributes as fields. - // If the only attribute is 'attribute', then add it; otherwise the other attributes are the - // named components of the 'attribute' field, so add them instead. - Ioss::NameList names; - entity->field_describe(Ioss::Field::ATTRIBUTE, &names); - for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if(*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = fem_meta.get_field (*I); - if (field) - stk_classic::io::field_data_from_ioss(field, nodes, entity, *I); - } - } - } -} - -// ======================================================================== -void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } -} - -// ======================================================================== -void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role, - const stk_classic::mesh::Selector *anded_selector=NULL) -{ - std::vector entities; - if (io_entity->type() == Ioss::SIDEBLOCK) { - // Temporary Kluge to handle sideblocks which contain internally generated sides - // where the "ids" field on the io_entity doesn't work to get the correct side... - // NOTE: Could use this method for all entity types, but then need to correctly - // specify whether shared entities are included/excluded (See IossBridge version). - size_t num_sides = get_entities(part, bulk, entities, anded_selector); - if (num_sides != (size_t)io_entity->get_property("entity_count").get_int()) { - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Number of sides on part " << part.name() << " (" << num_sides - << ") does not match number of sides in the associated Ioss SideBlock named " - << io_entity->name() << " (" << io_entity->get_property("entity_count").get_int() - << ")."; - throw std::runtime_error( msg.str() ); - } - } else { - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - } - - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - const std::vector &fields = fem_meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role); - } -} - -void internal_process_output_request(stk_classic::io::MeshData &mesh_data, - stk_classic::mesh::BulkData &bulk, - int step, - const std::set &exclude) -{ - Ioss::Region *region = mesh_data.m_output_region; - region->begin_state(step); - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - // Special processing for nodeblock (all nodes in model)... - put_field_data(bulk, fem_meta.universal_part(), fem_meta.node_rank(), - region->get_node_blocks()[0], Ioss::Field::Field::TRANSIENT, - mesh_data.m_anded_selector); - - // Now handle all non-nodeblock parts... - const stk_classic::mesh::PartVector & all_parts = fem_meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part) && !exclude.count(part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region->get_entity(part->name()); - if (entity != NULL && entity->type() != Ioss::SIDESET) { - put_field_data(bulk, *part, stk_classic::io::part_primary_entity_rank(*part), - entity, Ioss::Field::Field::TRANSIENT, - mesh_data.m_anded_selector); - } - } - } - region->end_state(step); -} - -namespace stk_classic { -namespace io { - -MeshData::~MeshData() -{ - delete m_input_region; - delete m_output_region; -} - -void show_mesh_help() -{ - std::cerr << "Options are:\n" - << "\n" - << "filename -- specify the name of the file from which to read the\n" - << " mesh file. If the --directory option is specified, it will be\n" - << " prepended to the filename unless the filename specifies an absolute path.\n" - << "\n" - << "gen:NxMxL -- internally generate a hex mesh of size N by M by L\n" - << " intervals. See 'Generated Options' below for more options.\n" - << "\n" - << "Generated Options:\n" - << "shell:xXyYzZ\n" - << "The argument specifies whether there is a shell block\n" - << "at the location. 'x' is minX, 'X' is maxX, etc.\n" - << "\n" - << "help -- no argument, shows valid options\n" - << "\n" - << "show -- no argument, prints out a summary of the settings used to\n" - << "generate the mesh. The output will look similar to:\n" - << " \"10x12x8|shell:xX|bbox:-10,-10,-10,10,10,10|show\"\n" - << "\n" - << " Mesh Parameters:\n" - << "\tIntervals: 10 by 12 by 8\n" - << "\tX = 2 * (0..10) + -10 Range: -10 <= X <= 10\n" - << "\tY = 1.66667 * (0..12) + -10 Range: -10 <= Y <= 10\n" - << "\tZ = 2.5 * (0..8) + -10 Range: -10 <= Z <= 10\n" - << "\tNode Count (total) = 1287\n" - << "\tElement Count (total) = 1152\n" - << "\tBlock Count = 3\n" - << "\n" - << "shell:xXyYzZ \n" - << "which specifies whether there is a shell block at that\n" - << "location. 'x' is minimum x face, 'X' is maximum x face,\n" - << "similarly for y and z. Note that the argument string is a\n" - << "single multicharacter string. You can add multiple shell blocks\n" - << "to a face, for example, shell:xxx would add three layered shell\n" - << "blocks on the minimum x face. An error is output if a non\n" - << "xXyYzZ character is found, but execution continues.\n" - << "\n" - << "zdecomp:n0 n1,n2,...,n#proc-1\n" - << "which are the number of intervals in the z direction for each\n" - << "processor in a pallel run. If this option is specified, then\n" - << "the total number of intervals in the z direction is the sum of\n" - << "the n0, n1, ... An interval count must be specified for each\n" - << "processor. If this option is not specified, then the number of\n" - << "intervals on each processor in the z direction is numZ/numProc\n" - << "with the extras added to the lower numbered processors.\n" - << "\n" - << "scale:xs,ys,zs\n" - << "which are the scale factors in the x, y, and z directions. All\n" - << "three must be specified if this option is present.\n" - << "\n" - << "- offset -- argument = xoff, yoff, zoff which are the offsets in the\n" - << "x, y, and z directions. All three must be specified if this option\n" - << "is present.\n" - << "\n" - << "- bbox -- argument = xmin, ymin, zmin, xmax, ymax, zmax\n" - << "which specify the lower left and upper right corners of\n" - << "the bounding box for the generated mesh. This will\n" - << "calculate the scale and offset which will fit the mesh in\n" - << "the specified box. All calculations are based on the currently\n" - << "active interval settings. If scale or offset or zdecomp\n" - << "specified later in the option list, you may not get the\n" - << "desired bounding box.\n" - << "\n" - << "- rotate -- argument = axis,angle,axis,angle,...\n" - << "where axis is 'x', 'y', or 'z' and angle is the rotation angle in\n" - << "degrees. Multiple rotations are cumulative. The composite rotation\n" - << "matrix is applied at the time the coordinates are retrieved after\n" - << "scaling and offset are applied.\n" - << "\n" - << "The unrotated coordinate of a node at grid location i,j,k is:\n" - << "\n" - << "\tx = x_scale * i + x_off,\n" - << "\ty = z_scale * j + y_off,\n" - << "\tz = z_scale * k + z_off,\n" - << "\n" - << "The extent of the unrotated mesh will be:\n" - << "\n" - << "\tx_off <= x <= x_scale * numX + x_off\n" - << "\ty_off <= y <= y_scale * numY + y_off\n" - << "\tz_off <= z <= z_scale * numZ + z_off\n" - << "\n" - << "If an unrecognized option is specified, an error message will be\n" - << "output and execution will continue.\n" - << "\n" - << "An example of valid input is:\n" - << "\n" - << "\t\"10x20x40|scale:1,0.5,0.25|offset:-5,-5,-5|shell:xX\"\n" - << "\n" - << "\n" - << "This would create a mesh with 10 intervals in x, 20 in y, 40 in z\n" - << "The mesh would be centered on 0,0,0 with a range of 10 in each\n" - << "direction. There would be a shell layer on the min and max\n" - << "x faces.\n" - << "\n" - << "NOTE: All options are processed in the order they appear in\n" - << "the parameters string (except rotate which is applied at the\n" - << "time the coordinates are generated/retrieved)\n" - << "\n"; -} - -void create_input_mesh(const std::string &mesh_type, - const std::string &mesh_filename, - stk_classic::ParallelMachine comm, - stk_classic::mesh::fem::FEMMetaData &fem_meta, - stk_classic::io::MeshData &mesh_data, - bool lower_case_variable_names) -{ - Ioss::Region *in_region = mesh_data.m_input_region; - if (in_region == NULL) { - // If in_region is NULL, then open the file; - // If in_region is non-NULL, then user has given us a valid Ioss::Region that - // should be used. - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename, - Ioss::READ_MODEL, comm, - mesh_data.m_property_manager); - - // set up the casing for variable names - dbi->set_lower_case_variable_names(lower_case_variable_names); - - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << mesh_filename - << "' of type '" << mesh_type << "'\n"; - Ioss::NameList db_types; - Ioss::IOFactory::describe(&db_types); - std::cerr << "\nSupported database types:\n\t"; - for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) { - std::cerr << *IF << " "; - } - std::cerr << "\n\n"; - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - in_region = new Ioss::Region(dbi, "input_model"); - mesh_data.m_input_region = in_region; - } - - size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int(); - initialize_spatial_dimension(fem_meta, spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - - process_elementblocks(*in_region, fem_meta); - process_nodeblocks(*in_region, fem_meta); - process_sidesets(*in_region, fem_meta); - process_nodesets(*in_region, fem_meta); -} - -void create_input_mesh(const std::string &mesh_type, - const std::string &mesh_filename, - stk_classic::ParallelMachine comm, - stk_classic::mesh::fem::FEMMetaData &fem_meta, - stk_classic::io::MeshData &mesh_data, - const std::vector& names_to_add, - bool lower_case_variable_names) -{ - Ioss::Region *in_region = mesh_data.m_input_region; - if (in_region == NULL) { - // If in_region is NULL, then open the file; - // If in_region is non-NULL, then user has given us a valid Ioss::Region that - // should be used. - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename, - Ioss::READ_MODEL, comm, - mesh_data.m_property_manager); - - // set up the casing for variable names - dbi->set_lower_case_variable_names(lower_case_variable_names); - - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << mesh_filename - << "' of type '" << mesh_type << "'\n"; - Ioss::NameList db_types; - Ioss::IOFactory::describe(&db_types); - std::cerr << "\nSupported database types:\n\t"; - for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) { - std::cerr << *IF << " "; - } - std::cerr << "\n\n"; - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - in_region = new Ioss::Region(dbi, "input_model"); - mesh_data.m_input_region = in_region; - } - - size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int(); - - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - - for(std::size_t i = 0; i < names_to_add.size(); i++) - entity_rank_names.push_back(names_to_add[i]); - - initialize_spatial_dimension(fem_meta, spatial_dimension, entity_rank_names); - - process_elementblocks(*in_region, fem_meta); - process_nodeblocks(*in_region, fem_meta); - process_sidesets(*in_region, fem_meta); - process_nodesets(*in_region, fem_meta); -} - - -void create_output_mesh(const std::string &filename, - stk_classic::ParallelMachine comm, - stk_classic::mesh::BulkData &bulk_data, - MeshData &mesh_data, - bool lower_case_variable_names) -{ - Ioss::Region *out_region = NULL; - - std::string out_filename = filename; - if (filename.empty()) { - out_filename = "default_output_mesh"; - } else { - // These filenames may be coming from the generated options which - // may have forms similar to: "2x2x1|size:.05|height:-0.1,1" - // Strip the name at the first "+:|," character: - std::vector tokens; - stk_classic::util::tokenize(out_filename, "+|:,", tokens); - out_filename = tokens[0]; - } - - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create("exodusII", out_filename, - Ioss::WRITE_RESULTS, - comm, mesh_data.m_property_manager); - // set up the casing for variable names - dbo->set_lower_case_variable_names(lower_case_variable_names); - - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type 'exodusII'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - out_region = new Ioss::Region(dbo, "results_output"); - - stk_classic::io::define_output_db(*out_region, bulk_data, mesh_data.m_input_region, mesh_data.m_anded_selector); - stk_classic::io::write_output_db(*out_region, bulk_data, mesh_data.m_anded_selector); - mesh_data.m_output_region = out_region; -} - -// ======================================================================== -int process_output_request(MeshData &mesh_data, - stk_classic::mesh::BulkData &bulk, - double time, - const std::set &exclude) -{ - Ioss::Region *region = mesh_data.m_output_region; - region->begin_mode(Ioss::STATE_TRANSIENT); - - int out_step = region->add_state(time); - internal_process_output_request(mesh_data, bulk, out_step,exclude); - - region->end_mode(Ioss::STATE_TRANSIENT); - - return out_step; -} - -// ======================================================================== -void populate_bulk_data(stk_classic::mesh::BulkData &bulk_data, - MeshData &mesh_data) -{ - Ioss::Region *region = mesh_data.m_input_region; - - if (region) { - - bulk_data.modification_begin(); - process_mesh_bulk_data(region, bulk_data); - bulk_data.modification_end(); - - } else { - std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in populate_bulk_data.\n"; - std::exit(EXIT_FAILURE); - } -} - -// ======================================================================== -void process_mesh_bulk_data(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data) -{ - bool ints64bit = db_api_int_size(region) == 8; - if (ints64bit) { - int64_t zero = 0; - process_elementblocks(*region, bulk_data, zero); - process_nodeblocks(*region, bulk_data); - process_nodesets(*region, bulk_data, zero); - process_sidesets(*region, bulk_data); - } else { - int zero = 0; - process_elementblocks(*region, bulk_data, zero); - process_nodeblocks(*region, bulk_data); - process_nodesets(*region, bulk_data, zero); - process_sidesets(*region, bulk_data); - } -} - -namespace { -// ======================================================================== -// Transfer transient field data from mesh file for io_entity to -// the corresponding stk_mesh entities If there is a stk_mesh -// field with the same name as the database field. -// Assumes that mesh is positioned at the correct state for reading. -void internal_process_input_request(Ioss::GroupingEntity *io_entity, - stk_classic::mesh::EntityRank entity_rank, - stk_classic::mesh::BulkData &bulk) -{ - assert(io_entity != NULL); - std::vector entity_list; - stk_classic::io::get_entity_list(io_entity, entity_rank, bulk, entity_list); - - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - Ioss::NameList names; - io_entity->field_describe(Ioss::Field::TRANSIENT, &names); - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - stk_classic::mesh::FieldBase *field = fem_meta.get_field(*I); - if (field) { - stk_classic::io::field_data_from_ioss(field, entity_list, io_entity, *I); - } - } -} - -void input_nodeblock_fields(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - internal_process_input_request(nb, fem_meta.node_rank(), bulk); -} - -void input_elementblock_fields(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - for(size_t i=0; i < elem_blocks.size(); i++) { - if (stk_classic::io::include_entity(elem_blocks[i])) { - internal_process_input_request(elem_blocks[i], fem_meta.element_rank(), bulk); - } - } -} - -void input_nodeset_fields(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - const Ioss::NodeSetContainer& nodesets = region.get_nodesets(); - for(size_t i=0; i < nodesets.size(); i++) { - if (stk_classic::io::include_entity(nodesets[i])) { - internal_process_input_request(nodesets[i], fem_meta.node_rank(), bulk); - } - } -} - -void input_sideset_fields(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - if (fem_meta.spatial_dimension() <= fem_meta.side_rank()) - return; - - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - if (stk_classic::io::include_entity(entity)) { - const Ioss::SideBlockContainer& blocks = entity->get_side_blocks(); - for(size_t i=0; i < blocks.size(); i++) { - if (stk_classic::io::include_entity(blocks[i])) { - internal_process_input_request(blocks[i], fem_meta.side_rank(), bulk); - } - } - } - } -} - -void define_input_nodeblock_fields(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, - fem_meta.universal_part(), fem_meta.node_rank()); -} - -void define_input_elementblock_fields(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - for(size_t i=0; i < elem_blocks.size(); i++) { - if (stk_classic::io::include_entity(elem_blocks[i])) { - stk_classic::mesh::Part* const part = fem_meta.get_part(elem_blocks[i]->name()); - assert(part != NULL); - stk_classic::io::define_io_fields(elem_blocks[i], Ioss::Field::TRANSIENT, - *part, part_primary_entity_rank(*part)); - } - } -} - -void define_input_nodeset_fields(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - const Ioss::NodeSetContainer& nodesets = region.get_nodesets(); - for(size_t i=0; i < nodesets.size(); i++) { - if (stk_classic::io::include_entity(nodesets[i])) { - stk_classic::mesh::Part* const part = fem_meta.get_part(nodesets[i]->name()); - assert(part != NULL); - stk_classic::io::define_io_fields(nodesets[i], Ioss::Field::TRANSIENT, - *part, part_primary_entity_rank(*part)); - } - } -} - -void define_input_sideset_fields(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - if (fem_meta.spatial_dimension() <= fem_meta.side_rank()) - return; - - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - if (stk_classic::io::include_entity(entity)) { - const Ioss::SideBlockContainer& blocks = entity->get_side_blocks(); - for(size_t i=0; i < blocks.size(); i++) { - if (stk_classic::io::include_entity(blocks[i])) { - stk_classic::mesh::Part* const part = fem_meta.get_part(blocks[i]->name()); - assert(part != NULL); - stk_classic::io::define_io_fields(blocks[i], Ioss::Field::TRANSIENT, - *part, part_primary_entity_rank(*part)); - } - } - } - } -} - -} - -// ======================================================================== -// Iterate over all Ioss entities in the input mesh database and -// define a stk_field for all transient fields found. The stk -// field will have the same name as the field on the database. -// -// Note that all fields found on the database will have a -// corresponding stk field defined. If you want just a selected -// subset of the defined fields, you will need to define the -// fields manually. -// -// To populate the stk field with data from the database, call -// process_input_request(). -void define_input_fields(MeshData &mesh_data, stk_classic::mesh::fem::FEMMetaData &fem_meta) -{ - Ioss::Region *region = mesh_data.m_input_region; - if (region) { - define_input_nodeblock_fields(*region, fem_meta); - define_input_elementblock_fields(*region, fem_meta); - define_input_nodeset_fields(*region, fem_meta); - define_input_sideset_fields(*region, fem_meta); - } else { - std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n"; - std::exit(EXIT_FAILURE); - } -} - -// ======================================================================== -// Iterate over all fields defined in the stk mesh data structure. -// If the field has the io_attribute set, then define that field -// on the corresponding io entity on the output mesh database. -// The database field will have the same name as the stk field. -// -// To export the data to the database, call -// process_output_request(). - -void define_output_fields(const MeshData &mesh_data, const stk_classic::mesh::fem::FEMMetaData &fem_meta, - bool add_all_fields) -{ - Ioss::Region *region = mesh_data.m_output_region; - if (region) { - region->begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields(fem_meta.universal_part(), fem_meta.node_rank(), - region->get_node_blocks()[0], - Ioss::Field::TRANSIENT, add_all_fields); - - const stk_classic::mesh::PartVector & all_parts = fem_meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region->get_entity(part->name()); - if (entity != NULL) { - stk_classic::io::ioss_add_fields(*part, part_primary_entity_rank(*part), - entity, Ioss::Field::TRANSIENT, add_all_fields); - } - } - } - region->end_mode(Ioss::STATE_DEFINE_TRANSIENT); - } else { - std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n"; - std::exit(EXIT_FAILURE); - } -} -// ======================================================================== -void process_input_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, double time) -{ - // Find the step on the database with time closest to the requested time... - Ioss::Region *region = mesh_data.m_input_region; - int step_count = region->get_property("state_count").get_int(); - double delta_min = 1.0e30; - int step_min = 0; - for (int istep = 0; istep < step_count; istep++) { - double state_time = region->get_state_time(istep+1); - double delta = state_time - time; - if (delta < 0.0) delta = -delta; - if (delta < delta_min) { - delta_min = delta; - step_min = istep; - if (delta == 0.0) break; - } - } - // Exodus steps are 1-based; - process_input_request(mesh_data, bulk, step_min+1); -} - -void process_input_request(MeshData &mesh_data, - stk_classic::mesh::BulkData &bulk, - int step) -{ - if (step <= 0) - return; - - Ioss::Region *region = mesh_data.m_input_region; - if (region) { - bulk.modification_begin(); - - input_mesh_fields(region, bulk, step); - - bulk.modification_end(); - - } else { - std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n"; - std::exit(EXIT_FAILURE); - } -} - -void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk, - double time) -{ - // Find the step on the database with time closest to the requested time... - int step_count = region->get_property("state_count").get_int(); - double delta_min = 1.0e30; - int step_min = 0; - for (int istep = 0; istep < step_count; istep++) { - double state_time = region->get_state_time(istep+1); - double delta = state_time - time; - if (delta < 0.0) delta = -delta; - if (delta < delta_min) { - delta_min = delta; - step_min = istep; - if (delta == 0.0) break; - } - } - // Exodus steps are 1-based; - input_mesh_fields(region, bulk, step_min+1); -} - -void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk, - int step) -{ - // Pick which time index to read into solution field. - region->begin_state(step); - - input_nodeblock_fields(*region, bulk); - input_elementblock_fields(*region, bulk); - input_nodeset_fields(*region, bulk); - input_sideset_fields(*region, bulk); - - region->end_state(step); -} - -// ======================================================================== -template -void get_element_block_sizes(MeshData &mesh_data, - std::vector& el_blocks) -{ - Ioss::Region *io = mesh_data.m_input_region; - const Ioss::ElementBlockContainer& elem_blocks = io->get_element_blocks(); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - if (stk_classic::io::include_entity(entity)) { - el_blocks.push_back(entity->get_property("entity_count").get_int()); - } - } -} -template void get_element_block_sizes(MeshData &mesh_data, std::vector& el_blocks); -template void get_element_block_sizes(MeshData &mesh_data, std::vector& el_blocks); -} // namespace io -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.hpp b/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.hpp deleted file mode 100644 index 7e689b414d79..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/MeshReadWriteUtils.hpp +++ /dev/null @@ -1,353 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_IO_MESHREADWRITEUTILS_HPP -#define STK_IO_MESHREADWRITEUTILS_HPP -#include -#include -#include -#include -#include - -namespace Ioss { - class Region; -} - -namespace stk_classic { - namespace mesh { - class Part; - class BulkData; - class Selector; - namespace fem { - class FEMMetaData; - } - } - namespace io { - class MeshData { - // Used to maintain state between the meta data and bulk data - // portions of the mesh generation process for use cases. - public: - MeshData() : m_input_region(NULL), m_output_region(NULL), - m_anded_selector(NULL) - {} - - ~MeshData(); - - /*! - * The `m_property_manager` member data contains properties that - * can be used to set database-specific options in the - * Ioss::DatabaseIO class. Examples include compression, name - * lengths, integer sizes, floating point sizes. By convention, - * the property name is all uppercase. Some existing properties - * recognized by the Exodus Ioex::DatabaseIO class are: - * - * | Property | Value - * |-----------------------|------------------- - * | COMPRESSION_LEVEL | In the range [0..9]. A value of 0 indicates no compression - * | COMPRESSION_SHUFFLE | (true/false) to enable/disable hdf5's shuffle compression algorithm. - * | FILE_TYPE | netcdf4 - * | MAXIMUM_NAME_LENGTH | Maximum length of names that will be returned/passed via api call. - * | INTEGER_SIZE_DB | 4 or 8 indicating byte size of integers stored on the database. - * | INTEGER_SIZE_API | 4 or 8 indicating byte size of integers used in api functions. - * | LOGGING | (true/false) to enable/disable logging of field input/output - * | FIELD_SUFFIX_SEPARATOR| character separating field basename from suffix in auto field recognition. - * | | E.g., if '_' (default), then a_x, a_y, a_z would be a 3d vector field 'a'. - */ - Ioss::PropertyManager m_property_manager; - - Ioss::Region *m_input_region; - Ioss::Region *m_output_region; - - /*! - * An optional selector used for filtering entities on the - * output database. This can be used for specifying - * active/inactive entities. If present, then this selector is - * *anded* with the normal selectors use for output - */ - stk_classic::mesh::Selector *m_anded_selector; - - private: - MeshData(const MeshData&); // Do not implement - MeshData& operator=(const MeshData&); // Do not implement - - }; - - /** Output a help message showing the valid options for the mesh - read and options for generated mesh. - */ - void show_mesh_help(); - - /** - * Read/Generate the metadata for mesh of the specified type. By - * default, all entities in the mesh (nodeblocks, element blocks, - * nodesets, sidesets) will have an associated stk mesh part - * created for it. - * - * If the mesh_data argument contains a non-null m_input_region - * data member, then this is assumed to be a valid Ioss::Region* - * that should be used instead of opening the file and creating a - * new Ioss::Region. - * - * Following this call, the 'populate_bulk_data()' function should - * be called to read the bulk data from the mesh and generate the - * corresponding stk mesh entities (nodes, elements, faces, ...) - * - * Only the non-transient data stored in the mesh database will be - * accessed in this function. To access any transient field data - * that may be on the mesh database, use the - * 'define_input_fields()' function. - * - * \param[in] type The format of the mesh that will be - * "read". Valid types are "exodus", "generated", "pamgen". - * - * \param[in] filename If the mesh type is file based ("exodus"), - * then this contains the full pathname to the file containing the - * mesh information. If the mesh type is a generated type, then - * this parameter contains data used by the generation routines. - * See the output from the show_mesh_help() function for details. - * - * \param[in] comm MPI Communicator to be used for all parallel - * communication needed to generate the mesh. - * - * \param[in,out] meta_data The STK meta data object which will - * be populated with parts and fields based on the mesh model - * described by the mesh in filename. The meta_data will not be - * committed by this function, so the caller will need to call - * meta_data.commit() after the function returns. - * - * \param[in,out] mesh_data A small class used for maintaining - * some state used by the stk_io routines. - * - * \param[in] lower_case_variable_names Sets the case for any varaible - * names. If true then characters are forced to be lower case. - * - */ - void create_input_mesh(const std::string &type, - const std::string &filename, - MPI_Comm comm, - stk_classic::mesh::fem::FEMMetaData &metadata, - MeshData &mesh_data, - bool lower_case_variable_names=true); - - /** - * Read/Generate the metadata for mesh of the specified type. By - * default, all entities in the mesh (nodeblocks, element blocks, - * nodesets, sidesets) will have an associated stk mesh part - * created for it. - * - * This version of the above call accepts a std::vector - * argument of names to add to the entity_rank_names prior to populating - * it from the mesh file. - * - * If the mesh_data argument contains a non-null m_input_region - * data member, then this is assumed to be a valid Ioss::Region* - * that should be used instead of opening the file and creating a - * new Ioss::Region. - * - * Following this call, the 'populate_bulk_data()' function should - * be called to read the bulk data from the mesh and generate the - * corresponding stk mesh entities (nodes, elements, faces, ...) - * - * Only the non-transient data stored in the mesh database will be - * accessed in this function. To access any transient field data - * that may be on the mesh database, use the - * 'define_input_fields()' function. - * - * \param[in] type The format of the mesh that will be - * "read". Valid types are "exodus", "generated", "pamgen". - * - * \param[in] filename If the mesh type is file based ("exodus"), - * then this contains the full pathname to the file containing the - * mesh information. If the mesh type is a generated type, then - * this parameter contains data used by the generation routines. - * See the output from the show_mesh_help() function for details. - * - * \param[in] comm MPI Communicator to be used for all parallel - * communication needed to generate the mesh. - * - * \param[in,out] meta_data The STK meta data object which will - * be populated with parts and fields based on the mesh model - * described by the mesh in filename. The meta_data will not be - * committed by this function, so the caller will need to call - * meta_data.commit() after the function returns. - * - * \param[in,out] mesh_data A small class used for maintaining - * some state used by the stk_io routines. - * - * \param[in] names_to_add to the entity_rank_names array prior - * to reading the mesh. - * - * \param[in] lower_case_variable_names Sets the case for any varaible - * names. If true then characters are forced to be lower case. - * - */ - void create_input_mesh(const std::string &type, - const std::string &filename, - MPI_Comm comm, - stk_classic::mesh::fem::FEMMetaData &metadata, - MeshData &mesh_data, - const std::vector& names_to_add, - bool lower_case_variable_names=true); - - /** - * Read/Generate the bulk data for the mesh. The bulk_data must - * have been constructed using the meta_data passed to the - * create_input_mesh() function and the mesh_data must also be the - * same. This function will create all stk mesh entities (nodes, - * elements) with the correct nodeal coordinates, element - * connectivity, element attribute data, and nodeset and sideset - * membership. Note that meta_data.commit() needs to be called - * prior to calling this function. - */ - void populate_bulk_data(stk_classic::mesh::BulkData &bulk_data, stk_classic::io::MeshData &mesh_data); - - /** - * Read/Generate the bulk data for the mesh. The bulk_data must - * have been constructed using the meta_data passed to the - * create_input_mesh() function and the mesh_data must also be the - * same. This function will create all stk mesh entities (nodes, - * elements) with the correct nodal coordinates, element - * connectivity, element attribute data, and nodeset and sideset - * membership. Note that meta_data.commit() followed by - * bulk_data.modification_begin() needs to be called - * prior to calling this function. Further, bulk_data.modification_end() - * must be called upon return from this function. The above populate_bulk_data call - * is a wrapper for this function. - */ - void process_mesh_bulk_data(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data); - - /** - * Iterate over all Ioss entities in the input mesh database and - * define a stk field for each transient field found. The stk - * field will have the same name as the field on the database. - * - * Note that all transient fields found on the mesh database will - * have a corresponding stk field defined. If you want just a - * selected subset of the database fields defined in the stk mesh, - * you need to define the fields manually. - * - * To populate the stk field with data from the database, call - * process_input_request(). - * - */ - void define_input_fields(MeshData &mesh_data, stk_classic::mesh::fem::FEMMetaData &meta_data); - - /** - * For all transient input fields defined either manually or via - * the define_input_fields() function, read the data at the - * specified database step 'step' (1-based) and populate the stk - * data structures with those values. - */ - void process_input_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, int step); - - /** - * For all transient input fields defined either manually or via - * the define_input_fields() function, read the data at the - * specified database time 'time' and populate the stk - * data structures with those values. The database time closest - * to the specified time will be used with no interpolation (yet). - */ - void process_input_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, double time); - - /** - * For all transient input fields defined either manually or via - * the define_input_fields() function, read the data at the - * specified database step 'step' (1-based) and populate the stk - * data structures with those values. Note that - * bulk_data.modification_begin() needs to be called prior to - * calling this function. Further, bulk_data.modification_end() - * must be called upon return from this function. Also note - * that the two above functions are wrappers for this one. - */ - void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data, int step); - - /** - * For all transient input fields defined either manually or via - * the define_input_fields() function, read the data at the - * specified database time 'time' and populate the stk - * data structures with those values. The database time closest - * to the specified time will be used with no interpolation (yet). Note that - * bulk_data.modification_begin() needs to be called prior to - * calling this function. Further, bulk_data.modification_end() - * must be called upon return from this function. - */ - void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data, double time); - - /** - * Create an exodus mesh database with the specified - * filename. This function creates the exodus metadata which - * is the number and type of element blocks, nodesets, and - * sidesets; and then outputs the mesh bulk data such as the - * node coordinates, id maps, element connectivity. When the - * function returns, the non-transient portion of the mesh will - * have been defined. - * - * A stk part will have a corresponding exodus entity (element - * block, nodeset, sideset) defined if the "is_io_part()" function - * returns true. By default, all parts read from the mesh - * database in the create_input_mesh() function will return true - * as will all stk parts on which the function - * stk_classic::io::put_io_part_attribute() was called. The function - * stk_classic::io::remove_io_part_attribute(part) can be called to omit a - * part from being output. - * - * \param[in] filename The full pathname to the file which will be - * created and the mesh data written to. If the file already - * exists, it will be overwritten. - * - * \param[in] comm MPI Communicator to be used for all parallel - * communication needed by the mesh routines. - * - * \param[in] bulk The STK bulk data object defining the stk mesh. - * - * \param[in,out] mesh_data A small class used for maintaining - * some state used by the stk_io routines. - * - * \param[in] lower_case_variable_names Sets the case for any varaible - * names. If true then characters are forced to be lower case. - * - */ - void create_output_mesh(const std::string &filename, - MPI_Comm comm, - stk_classic::mesh::BulkData &bulk_data, - MeshData &mesh_data, - bool lower_case_variable_names=true); - - /** - * Iterate over all stk fields and for each transient field - * defined on a part that is output to the mesh file, define a - * corresponding database field. The database field will have the - * same name as the stk field. A transient field will be defined - * if the stk_classic::io::is_valid_part_field() returns true. This can - * be set via a call to stk_classic::io::set_field_role(). - * - * If the 'add_all_fields' param is true, then all transient - * stk fields will have a corresponding database field defined. - */ - void define_output_fields(const MeshData &mesh_data, - const stk_classic::mesh::fem::FEMMetaData &fem_meta, - bool add_all_fields = false); - - /** - * Add a transient step to the mesh database at time 'time' and - * output the data for all defined fields to the database. - */ - int process_output_request(MeshData &mesh_data, - stk_classic::mesh::BulkData &bulk, - double time, - const std::set &exclude=std::set()); - /** - * Method to query a MeshData for the number of element blocks and the - * number of elements in each. MeshData is input, std:vector is output - */ - template - void get_element_block_sizes(MeshData &mesh_data, - std::vector& el_blocks); - } -} -#endif diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/CMakeLists.txt b/packages/stk/stk_classic/stk_io/stk_io/util/CMakeLists.txt deleted file mode 100644 index e5befd0de18e..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../seacas/libraries/ioss/src) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_io_util - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - DEPLIBS stkclassic_io - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_io/util/) diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/Gears.cpp b/packages/stk/stk_classic/stk_io/stk_io/util/Gears.cpp deleted file mode 100644 index eeee10ca1831..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/Gears.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace io { -namespace util { - -//---------------------------------------------------------------------- - -GearFields::GearFields( stk_classic::mesh::fem::FEMMetaData & S ) - : gear_coord( S.get_meta_data(S).declare_field( std::string("gear_coordinates") ) ), - model_coord( S.get_meta_data(S).declare_field( std::string("coordinates") ) ) -{ - const stk_classic::mesh::Part & universe = S.get_meta_data(S).universal_part(); - - stk_classic::mesh::put_field( gear_coord , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universe , SpatialDimension ); - stk_classic::mesh::put_field( model_coord , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universe , SpatialDimension ); -} - -//---------------------------------------------------------------------- - -namespace { - -stk_classic::mesh::EntityId -identifier( size_t nthick , // Number of entities through the thickness - size_t nradius , // Number of entities through the radius - size_t iz , // Thickness index - size_t ir , // Radial index - size_t ia ) // Angle index -{ - return static_cast(iz + nthick * ( ir + nradius * ia )); -} - -} - - -Gear::Gear( stk_classic::mesh::fem::FEMMetaData & S , - const std::string & name , - const GearFields & gear_fields , - const double center[] , - const double rad_min , - const double rad_max , - const size_t rad_num , - const double z_min , - const double z_max , - const size_t z_num , - const size_t angle_num , - const int turn_direction ) - : m_mesh_fem_meta_data( &S ), - m_mesh_meta_data( S.get_meta_data(S) ), - m_mesh( NULL ), - m_gear( S.declare_part(std::string("Gear_").append(name), m_mesh_fem_meta_data->element_rank()) ), - m_surf( S.declare_part(std::string("Surf_").append(name), m_mesh_fem_meta_data->side_rank()) ), - m_gear_coord( gear_fields.gear_coord ), - m_model_coord(gear_fields.model_coord ) -{ - typedef shards::Hexahedron<> Hex ; - typedef shards::Quadrilateral<> Quad ; - enum { SpatialDimension = GearFields::SpatialDimension }; - - stk_classic::io::put_io_part_attribute(m_gear); - stk_classic::io::put_io_part_attribute(m_surf); - stk_classic::mesh::fem::CellTopology hex_top (shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - - stk_classic::mesh::fem::set_cell_topology( m_gear, hex_top ); - stk_classic::mesh::fem::set_cell_topology( m_surf, quad_top ); - - // Meshing parameters for this gear: - - const double TWO_PI = 2.0 * acos( static_cast(-1.0) ); - - m_center[0] = center[0] ; - m_center[1] = center[1] ; - m_center[2] = center[2] ; - - m_z_min = z_min ; - m_z_max = z_max ; - m_z_inc = (z_max - z_min) / static_cast(z_num - 1); - - m_rad_min = rad_min ; - m_rad_max = rad_max ; - m_rad_inc = (rad_max - rad_min) / static_cast(rad_num - 1); - - m_ang_inc = TWO_PI / static_cast(angle_num) ; - - m_rad_num = rad_num ; - m_z_num = z_num ; - m_angle_num = angle_num ; - m_turn_dir = turn_direction ; -} - - -//---------------------------------------------------------------------- - -stk_classic::mesh::Entity &Gear::create_node(const std::vector & parts , - stk_classic::mesh::EntityId node_id_base , - size_t iz , - size_t ir , - size_t ia ) const -{ - const double angle = m_ang_inc * ia ; - const double cos_angle = cos( angle ); - const double sin_angle = sin( angle ); - - const double radius = m_rad_min + m_rad_inc * ir ; - const double x = m_center[0] + radius * cos_angle ; - const double y = m_center[1] + radius * sin_angle ; - const double z = m_center[2] + m_z_min + m_z_inc * iz ; - - // Create the node and set the model_coordinates - - stk_classic::mesh::EntityId id_gear = identifier( m_z_num, m_rad_num, iz, ir, ia ); - stk_classic::mesh::EntityId id = node_id_base + id_gear ; - - stk_classic::mesh::Entity & node = m_mesh->declare_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, id , parts ); - - double * const gear_data = field_data( m_gear_coord , node ); - double * const model_data = field_data( m_model_coord , node ); - - gear_data[0] = radius ; - gear_data[1] = angle ; - gear_data[2] = z - m_center[2] ; - - model_data[0] = x ; - model_data[1] = y ; - model_data[2] = z ; - - return node; -} - -//---------------------------------------------------------------------- - -void Gear::mesh( stk_classic::mesh::BulkData & M ) -{ - stk_classic::mesh::EntityRank element_rank; - stk_classic::mesh::EntityRank side_rank ; - if (m_mesh_fem_meta_data) { - element_rank = m_mesh_fem_meta_data->element_rank(); - side_rank = m_mesh_fem_meta_data->side_rank(); - } - else { - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(M); - element_rank = fem.element_rank(); - side_rank = fem.side_rank(); - } - - M.modification_begin(); - - m_mesh = & M ; - - const unsigned p_size = M.parallel_size(); - const unsigned p_rank = M.parallel_rank(); - - std::vector counts ; - stk_classic::mesh::comm_mesh_counts(M, counts); - - // max_id is no longer available from comm_mesh_stats. - // If we assume uniform numbering from 1.., then max_id - // should be equal to counts... - const stk_classic::mesh::EntityId node_id_base = counts[ stk_classic::mesh::fem::FEMMetaData::NODE_RANK ] + 1 ; - const stk_classic::mesh::EntityId elem_id_base = counts[ element_rank ] + 1 ; - - const unsigned long elem_id_gear_max = - m_angle_num * ( m_rad_num - 1 ) * ( m_z_num - 1 ); - - std::vector elem_parts ; - std::vector face_parts ; - std::vector node_parts ; - - { - stk_classic::mesh::Part * const p_gear = & m_gear ; - stk_classic::mesh::Part * const p_surf = & m_surf ; - - elem_parts.push_back( p_gear ); - face_parts.push_back( p_surf ); - } - - for ( unsigned ia = 0 ; ia < m_angle_num ; ++ia ) { - for ( unsigned ir = 0 ; ir < m_rad_num - 1 ; ++ir ) { - for ( unsigned iz = 0 ; iz < m_z_num - 1 ; ++iz ) { - - stk_classic::mesh::EntityId elem_id_gear = identifier( m_z_num-1 , m_rad_num-1 , iz , ir , ia ); - - if ( ( ( elem_id_gear * p_size ) / elem_id_gear_max ) == p_rank ) { - - stk_classic::mesh::EntityId elem_id = elem_id_base + elem_id_gear ; - - // Create the node and set the model_coordinates - - const size_t ia_1 = ( ia + 1 ) % m_angle_num ; - const size_t ir_1 = ir + 1 ; - const size_t iz_1 = iz + 1 ; - - stk_classic::mesh::Entity * node[8] ; - - node[0] = &create_node( node_parts, node_id_base, iz , ir , ia_1 ); - node[1] = &create_node( node_parts, node_id_base, iz_1, ir , ia_1 ); - node[2] = &create_node( node_parts, node_id_base, iz_1, ir , ia ); - node[3] = &create_node( node_parts, node_id_base, iz , ir , ia ); - node[4] = &create_node( node_parts, node_id_base, iz , ir_1, ia_1 ); - node[5] = &create_node( node_parts, node_id_base, iz_1, ir_1, ia_1 ); - node[6] = &create_node( node_parts, node_id_base, iz_1, ir_1, ia ); - node[7] = &create_node( node_parts, node_id_base, iz , ir_1, ia ); -#if 0 /* VERIFY_CENTROID */ - - // Centroid of the element for verification - - const double TWO_PI = 2.0 * acos( (double) -1.0 ); - const double angle = m_ang_inc * ( 0.5 + (double) ia ); - const double z = m_center[2] + m_z_min + m_z_inc * (0.5 + (double)iz); - - double c[3] = { 0 , 0 , 0 }; - - for ( size_t j = 0 ; j < 8 ; ++j ) { - double * const coord_data = field_data( m_model_coord , *node[j] ); - c[0] += coord_data[0] ; - c[1] += coord_data[1] ; - c[2] += coord_data[2] ; - } - c[0] /= 8 ; c[1] /= 8 ; c[2] /= 8 ; - c[0] -= m_center[0] ; - c[1] -= m_center[1] ; - - double val_a = atan2( c[1] , c[0] ); - if ( val_a < 0 ) { val_a += TWO_PI ; } - const double err_a = angle - val_a ; - const double err_z = z - c[2] ; - - const double eps = 100 * std::numeric_limits::epsilon(); - - if ( err_z < - eps || eps < err_z || - err_a < - eps || eps < err_a ) { - std::string msg ; - msg.append("problem setup element centroid error" ); - throw std::logic_error( msg ); - } -#endif - - stk_classic::mesh::Entity & elem = - M.declare_entity( element_rank, elem_id, elem_parts ); - - for ( size_t j = 0 ; j < 8 ; ++j ) { - M.declare_relation( elem , * node[j] , - static_cast(j) ); - } - } - } - } - } - - // Array of faces on the surface - - { - const size_t ir = m_rad_num - 1 ; - - for ( size_t ia = 0 ; ia < m_angle_num ; ++ia ) { - for ( size_t iz = 0 ; iz < m_z_num - 1 ; ++iz ) { - - stk_classic::mesh::EntityId elem_id_gear = - identifier( m_z_num-1 , m_rad_num-1 , iz , ir-1 , ia ); - - if ( ( ( elem_id_gear * p_size ) / elem_id_gear_max ) == p_rank ) { - - stk_classic::mesh::EntityId elem_id = elem_id_base + elem_id_gear ; - - unsigned face_ord = 5 ; - stk_classic::mesh::EntityId face_id = elem_id * 10 + face_ord + 1; - - stk_classic::mesh::Entity * node[4] ; - - const size_t ia_1 = ( ia + 1 ) % m_angle_num ; - const size_t iz_1 = iz + 1 ; - - node[0] = &create_node( node_parts, node_id_base, iz , ir , ia_1 ); - node[1] = &create_node( node_parts, node_id_base, iz_1, ir , ia_1 ); - node[2] = &create_node( node_parts, node_id_base, iz_1, ir , ia ); - node[3] = &create_node( node_parts, node_id_base, iz , ir , ia ); - - stk_classic::mesh::Entity & face = - M.declare_entity( side_rank, face_id, face_parts ); - - for ( size_t j = 0 ; j < 4 ; ++j ) { - M.declare_relation( face , * node[j] , - static_cast(j) ); - } - - stk_classic::mesh::Entity & elem = * M.get_entity(element_rank, elem_id); - - M.declare_relation( elem , face , face_ord ); - } - } - } - } - M.modification_begin(); -} - -//---------------------------------------------------------------------- -// Iterate nodes and turn them by the angle - -void Gear::turn( double /* turn_angle */ ) const -{ -#if 0 - const unsigned Length = 3 ; - - const std::vector & ks = m_mesh->buckets( stk_classic::mesh::Node ); - const std::vector::const_iterator ek = ks.end(); - std::vector::const_iterator ik = ks.begin(); - for ( ; ik != ek ; ++ik ) { - stk_classic::mesh::Bucket & k = **ik ; - if ( k.has_superset( m_gear ) ) { - const size_t n = k.size(); - double * const bucket_gear_data = stk_classic::mesh::field_data( m_gear_coord, k.begin() ); - double * const bucket_model_data = stk_classic::mesh::field_data( m_model_coord, k.begin() ); - - for ( size_t i = 0 ; i < n ; ++i ) { - double * const gear_data = bucket_gear_data + i * Length ; - double * const model_data = bucket_model_data + i * Length ; - double * const current_data = bucket_current_data + i * Length ; - double * const disp_data = bucket_disp_data + i * Length ; - - const double radius = gear_data[0] ; - const double angle = gear_data[1] + turn_angle * m_turn_dir ; - - current_data[0] = m_center[0] + radius * cos( angle ); - current_data[1] = m_center[1] + radius * sin( angle ); - current_data[2] = m_center[2] + gear_data[2] ; - - disp_data[0] = current_data[0] - model_data[0] ; - disp_data[1] = current_data[1] - model_data[1] ; - disp_data[2] = current_data[2] - model_data[2] ; - } - } - } -#endif -} - -//---------------------------------------------------------------------- - -} -} -} diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/Gears.hpp b/packages/stk/stk_classic/stk_io/stk_io/util/Gears.hpp deleted file mode 100644 index 4a4203945aa6..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/Gears.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_io_util_Gears_hpp -#define stk_io_util_Gears_hpp - -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -class MetaData; -class BulkData; -} - -namespace io { -namespace util { - -struct GearFields { - - enum { SpatialDimension = 3 }; - - typedef stk_classic::mesh::Field CartesianField ; - typedef stk_classic::mesh::Field CylindricalField ; - - CylindricalField & gear_coord ; - CartesianField & model_coord ; - - GearFields( stk_classic::mesh::MetaData & S ); - GearFields( stk_classic::mesh::fem::FEMMetaData & S ); - -private: - GearFields(); - GearFields( const GearFields & ); - GearFields & operator = ( const GearFields & ); -}; - -class Gear { -public: - Gear( stk_classic::mesh::fem::FEMMetaData & S , - const std::string & name , - const GearFields & gear_fields , - const double center[] , - const double rad_min , - const double rad_max , - const size_t rad_num , - const double z_min , - const double z_max , - const size_t z_num , - const size_t angle_num , - const int turn_direction ); - - void mesh( stk_classic::mesh::BulkData &M ); - void turn( double turn_angle ) const ; - - stk_classic::mesh::fem::FEMMetaData *m_mesh_fem_meta_data ; - stk_classic::mesh::MetaData & m_mesh_meta_data ; - stk_classic::mesh::BulkData * m_mesh ; - stk_classic::mesh::Part & m_gear ; - stk_classic::mesh::Part & m_surf ; - const GearFields::CylindricalField & m_gear_coord ; - const GearFields::CartesianField & m_model_coord ; - -private: - - Gear( const Gear & ); - Gear & operator = ( const Gear & ); - - double m_center[3] ; - double m_z_min ; - double m_z_max ; - double m_z_inc ; - double m_rad_min ; - double m_rad_max ; - double m_rad_inc ; - double m_ang_inc ; - size_t m_rad_num ; - size_t m_z_num ; - size_t m_angle_num ; - int m_turn_dir ; - - stk_classic::mesh::Entity &create_node( const std::vector &parts , - stk_classic::mesh::EntityId node_id_base , - size_t iz , - size_t ir , - size_t ia ) const ; -}; - -} -} -} - -#endif - diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.cpp b/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.cpp deleted file mode 100644 index fa7c7e267401..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "Gmesh_STKmesh_Fixture.hpp" - -#include - -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include - -using namespace stk_classic::io::util; - -static const size_t spatial_dimension = 3; - -/////////////////////////////////////////////////////////////////////////////// -Gmesh_STKmesh_Fixture::Gmesh_STKmesh_Fixture(stk_classic::ParallelMachine comm, - const std::string& gmesh_spec) -/////////////////////////////////////////////////////////////////////////////// - : - m_meta_data(spatial_dimension), - m_bulk_data(m_meta_data.get_meta_data(m_meta_data), comm), - m_num_x(0), - m_num_y(0), - m_num_z(0) -{ - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - stk_classic::io::MeshData mesh_data; - stk_classic::io::create_input_mesh("generated", gmesh_spec, comm, - m_meta_data, m_mesh_data); - - const Iogn::DatabaseIO* database = - dynamic_cast(m_mesh_data.m_input_region->get_database()); - - // compute m_num_{x|y|z} - m_num_x = database->get_generated_mesh()->get_num_x(); - m_num_y = database->get_generated_mesh()->get_num_y(); - m_num_z = database->get_generated_mesh()->get_num_z(); - - // get face parts names; need to convert these to strings - const std::vector sideset_names = database->get_sideset_names(); - - for (std::vector::const_iterator itr = sideset_names.begin(); - itr != sideset_names.end(); ++itr) { - m_sideset_names.push_back(*itr); - m_sideset_parts.push_back(m_meta_data.get_part(*itr)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -void Gmesh_STKmesh_Fixture::commit() -/////////////////////////////////////////////////////////////////////////////// -{ - m_meta_data.commit(); - - stk_classic::io::populate_bulk_data(m_bulk_data, m_mesh_data); -} - -/////////////////////////////////////////////////////////////////////////////// -size_t Gmesh_STKmesh_Fixture::getSurfElemCount(size_t surf_id) const -/////////////////////////////////////////////////////////////////////////////// -{ - if (Iogn::GeneratedMesh::PZ < surf_id) { - throw std::runtime_error("Invalid surface id"); - } - - switch( surf_id ) - { - case Iogn::GeneratedMesh::MX: - case Iogn::GeneratedMesh::PX: - return m_num_y*m_num_z; - break; - case Iogn::GeneratedMesh::MY: - case Iogn::GeneratedMesh::PY: - return m_num_x*m_num_z; - break; - case Iogn::GeneratedMesh::MZ: - case Iogn::GeneratedMesh::PZ: - return m_num_x*m_num_y; - break; - } - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -std::pair -Gmesh_STKmesh_Fixture::getSurfCoordInfo(size_t surf_id) const -/////////////////////////////////////////////////////////////////////////////// -{ - if (Iogn::GeneratedMesh::PZ < surf_id) { - throw std::runtime_error("Invalid surface id"); - } - - switch( surf_id ) - { - case Iogn::GeneratedMesh::MX: - return std::make_pair(0, 0.0); - break; - case Iogn::GeneratedMesh::PX: - return std::make_pair(0, (double)m_num_x); - break; - case Iogn::GeneratedMesh::MY: - return std::make_pair(1, 0.0); - break; - case Iogn::GeneratedMesh::PY: - return std::make_pair(1, (double)m_num_y); - break; - case Iogn::GeneratedMesh::MZ: - return std::make_pair(2, 0.0); - break; - case Iogn::GeneratedMesh::PZ: - return std::make_pair(2, (double)m_num_z); - break; - } - - return std::make_pair(-1, -1.0); -} - -/////////////////////////////////////////////////////////////////////////////// -size_t Gmesh_STKmesh_Fixture::getSideCount() const -/////////////////////////////////////////////////////////////////////////////// -{ - return 2 * (m_num_x*m_num_y + m_num_x*m_num_z + m_num_y*m_num_z); -} - -/////////////////////////////////////////////////////////////////////////////// -size_t Gmesh_STKmesh_Fixture::getElemCount() const -/////////////////////////////////////////////////////////////////////////////// -{ - return m_num_x * m_num_y * m_num_z; -} - -/////////////////////////////////////////////////////////////////////////////// -size_t Gmesh_STKmesh_Fixture::getNodeCount() const -/////////////////////////////////////////////////////////////////////////////// -{ - return (m_num_x+1)*(m_num_y+1)*(m_num_z+1); -} diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.hpp b/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.hpp deleted file mode 100644 index 862a14cf8772..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/Gmesh_STKmesh_Fixture.hpp +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef stk_io_util_Gmesh_STKmesh_Fixture_hpp -#define stk_io_util_Gmesh_STKmesh_Fixture_hpp - -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace io { -namespace util { - -/** - * This class implements a Stk-mesh based fixture that uses a generated - * mesh as the basis of the fixture. - */ -class Gmesh_STKmesh_Fixture -{ - public: - - /** - * Construct a fixture. Note that the fixture won't be completed until commit - * is called; the intent is to give the client a chance to make additional - * changes to the meta-data. - * - * @param comm The comm object for all processors using the fixture - * @param gmesh_spec The specification for the mesh. See Iogn::GeneratedMesh - * for documentation on how to specify meshes. - */ - Gmesh_STKmesh_Fixture(stk_classic::ParallelMachine comm, const std::string& gmesh_spec); - - /** - * Commits the meta-data of the mesh and populates the bulk-data. Don't call - * this until you are done modifying the meta-data. - */ - void commit(); - - /** - * For a given surface, return the number of elements in the surface - * - * @param surf_id The surface we are interested in. - */ - size_t getSurfElemCount(size_t surf_id) const; - - /** - * For a given surface, return the relevant dimension and expected value - * of that dimension. For example, for surface PY, (1, m_num_y) would be - * returned; 1 refers to the Y dimension and m_num_y is the expected - * Y-coordinate value for all the nodes on the PY surface. - * - * @surf_id The surface we are interested in. - */ - std::pair getSurfCoordInfo(size_t surf_id) const; - - /** - * Get the total number of side entities in this mesh. - */ - size_t getSideCount() const; - - /** - * Get the total number of elements in this mesh. - */ - size_t getElemCount() const; - - /** - * Get the total number of nodes in this mesh. - */ - size_t getNodeCount() const; - - /** - * Get the names of all the sideset parts. - */ - const std::vector & getSidesetNames() const - { return m_sideset_names; } - - /** - * Get all the sideset parts. - */ - const stk_classic::mesh::PartVector & getSideParts() const - { return m_sideset_parts; } - - /** - * Get a reference to the meta data for the stk-mesh. - const stk_classic::mesh::MetaData & getMetaData() const - { return m_meta_data.get_meta_data(m_meta_data); } - */ - - stk_classic::mesh::MetaData & getMetaData() - { return m_meta_data.get_meta_data(m_meta_data); } - - const stk_classic::mesh::fem::FEMMetaData & getFEMMetaData() const - { return m_meta_data; } - - stk_classic::mesh::fem::FEMMetaData & getFEMMetaData() - { return m_meta_data; } - - /** - * Get a reference to the bulk data for the stk-mesh. - */ - const stk_classic::mesh::BulkData & getBulkData() const - { return m_bulk_data; } - - stk_classic::mesh::BulkData & getBulkData() - { return m_bulk_data; } - - private: - ///> The meta data for the stk-mesh - stk_classic::mesh::fem::FEMMetaData m_meta_data; - - ///> The bulk data for the stk-mesh - stk_classic::mesh::BulkData m_bulk_data; - - /** - * The mesh-data for the mesh. This is a special object that maintains some - * state between the meta data and bulk data portions of the mesh generation - * process for use cases. - */ - stk_classic::io::MeshData m_mesh_data; - - ///> The names of all the side parts - std::vector m_sideset_names; - - ///> Collection of all the side parts - stk_classic::mesh::PartVector m_sideset_parts; - - ///> The number of elements in the X dimension for the mesh - int m_num_x; - - ///> The number of elements in the Y dimension for the mesh - int m_num_y; - - ///> The number of elements in the Z dimension for the mesh - int m_num_z; -}; - -}//namespace util -}//namespace io -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.cpp b/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.cpp deleted file mode 100644 index bc0cedc4dfeb..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include -#include - -#include -#include - -namespace stk_classic { -namespace io { -namespace util { - -IO_Fixture::IO_Fixture(stk_classic::ParallelMachine comm) - : m_comm(comm) - , m_fem_meta_data(NULL) - , m_bulk_data(NULL) - , m_ioss_input_region(NULL) - , m_ioss_output_region(NULL) - , m_mesh_type() - , m_mesh_data() -{} - -IO_Fixture::~IO_Fixture() -{ - // There are duplicate pointers in the IO_Fixture class - // If both try to delete, bad things happen... - m_mesh_data.m_input_region = NULL; - m_mesh_data.m_output_region = NULL; -} - -void IO_Fixture::output_ioss_region(Teuchos::RCP ioss_output_region) { - m_ioss_output_region = ioss_output_region; - m_mesh_data.m_output_region = m_ioss_output_region.get(); -} - -void IO_Fixture::create_output_mesh( - const std::string & base_exodus_filename, - bool add_transient, - bool add_all_fields - ) -{ - // TODO: Check that the meta-data has a coordinates field and IO parts defined. - - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create( - "exodusII", - base_exodus_filename, - Ioss::WRITE_RESULTS, - bulk_data().parallel() - ); - - ThrowErrorMsgIf(dbo == NULL || !dbo->ok(), - "ERROR: Could not open results database '" << base_exodus_filename << - "' of type 'exodusII'"); - - // If the m_ioss_input_region exists for this fixture, - // check the integer size it is using and replicate that - // on the output mesh... - if (!Teuchos::is_null(m_ioss_input_region)) { - if (m_ioss_input_region->get_database()->int_byte_size_api() == 8) - dbo->set_int_byte_size_api(Ioss::USE_INT64_API); - } - - // NOTE: 'm_ioss_output_region' owns 'dbo' pointer at this time - const std::string name = std::string("results_output_")+base_exodus_filename; - m_ioss_output_region = Teuchos::rcp(new Ioss::Region(dbo, name)); - m_mesh_data.m_output_region = m_ioss_output_region.get(); - - /* Given the newly created Ioss::Region 'm_ioss_output_region', define the - * model corresponding to the stk_classic::mesh 'bulk_data'. If the - * optional 'input_region' is passed as an argument, then - * synchronize all names and ids found on 'input_region' to the - * output region 'm_ioss_output_region'. The routine will query all parts - * in 'bulk_data' and if they are io_parts (define by the existance - * of the IOPartAttribute attribute on the part), then a - * corresponding Ioss entity will be defined. This routine only - * deals with the non-transient portion of the model; no transient - * fields are defined at this point. - */ - stk_classic::io::define_output_db( *m_ioss_output_region, bulk_data(), m_ioss_input_region.get(), - m_mesh_data.m_anded_selector); - - /* Given an Ioss::Region 'm_ioss_output_region' which has already had its - * metadata defined via 'define_output_db()' call; transfer all bulk - * data (node coordinates, element connectivity, ...) to the - * output database that corresponds to this Ioss::Region. At - * return, all non-transient portions of the output database will - * have been output. - */ - stk_classic::io::write_output_db( *m_ioss_output_region, bulk_data(), - m_mesh_data.m_anded_selector); - - if (add_transient) { - m_ioss_output_region->begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields( - meta_data().universal_part(), - meta_data().node_rank(), - m_ioss_output_region->get_node_blocks()[0], - Ioss::Field::TRANSIENT, - add_all_fields - ); - - const stk_classic::mesh::PartVector & all_parts = meta_data().get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); - ip != all_parts.end(); - ++ip - ) - { - stk_classic::mesh::Part & part = **ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = m_ioss_output_region->get_entity(part.name()); - if (entity != NULL && entity->type() == Ioss::ELEMENTBLOCK) { - stk_classic::io::ioss_add_fields( - part, - part.primary_entity_rank(), - entity, - Ioss::Field::TRANSIENT, - add_all_fields - ); - } - } - } - m_ioss_output_region->end_mode(Ioss::STATE_DEFINE_TRANSIENT); - } -} - -void IO_Fixture::add_timestep_to_output_mesh( double time ) -{ - ThrowErrorMsgIf( Teuchos::is_null(m_ioss_output_region), - "Please call create_output_mesh before add_timestep_to_output_mesh" ); - stk_classic::io::process_output_request(m_mesh_data, bulk_data(), time); -} - -void IO_Fixture::set_meta_data( Teuchos::RCP arg_meta_data ) -{ - ThrowErrorMsgIf( !Teuchos::is_null(m_fem_meta_data), - "Meta data already initialized" ); - m_fem_meta_data = arg_meta_data; -} - -void IO_Fixture::set_bulk_data( Teuchos::RCP arg_bulk_data ) -{ - ThrowErrorMsgIf( !Teuchos::is_null(m_bulk_data), - "Bulk data already initialized" ); - m_bulk_data = arg_bulk_data; -} - -void IO_Fixture::initialize_meta_data( const std::string & base_filename, const std::string & mesh_type) -{ - ThrowErrorMsgIf( !Teuchos::is_null(m_fem_meta_data), - "Meta data already initialized" ); - ThrowErrorMsgIf( !Teuchos::is_null(m_ioss_input_region), - "Input region was already initialized"); - - m_fem_meta_data = Teuchos::rcp( new stk_classic::mesh::fem::FEMMetaData()); - m_mesh_type = mesh_type; - - Ioss::Init::Initializer init_db; - - stk_classic::io::create_input_mesh( - m_mesh_type, - base_filename, - m_comm, - meta_data(), - m_mesh_data - ); - - // TODO: Restore this once m_mesh_data is fixed - m_ioss_input_region = Teuchos::rcp( m_mesh_data.m_input_region ); -} - -void IO_Fixture::initialize_bulk_data() -{ - ThrowErrorMsgIf( !Teuchos::is_null(m_bulk_data), - "Bulk data already initialized" ); - - // TODO: Probable better to check m_ioss_input_region once that's fixed - ThrowErrorMsgIf( m_mesh_type == "", - "Can only use this method if meta-data was initialized with initialize_meta_data"); - - m_bulk_data = Teuchos::rcp( new stk_classic::mesh::BulkData(stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data()), m_comm)); - - stk_classic::io::populate_bulk_data( - bulk_data(), - m_mesh_data - ); -} - -void IO_Fixture::set_input_ioss_region( Teuchos::RCP input_region ) -{ - ThrowErrorMsgIf( !Teuchos::is_null(m_ioss_input_region), - "Input region was already initialized"); - - m_ioss_input_region = input_region; -} - -} // namespace util -} // namespace io -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.hpp b/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.hpp deleted file mode 100644 index 3c1ce4d118c3..000000000000 --- a/packages/stk/stk_classic/stk_io/stk_io/util/IO_Fixture.hpp +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef STK_IO_UTIL_IO_FIXTURE_HPP -#define STK_IO_UTIL_IO_FIXTURE_HPP - -#include - -#include -#include - -#include - -#include -#include - -#include - -#include - -#include - -namespace stk_classic { -namespace io { -namespace util { - -/** - * This purpose of this class is to provide a simple interface for - * reading/writing an exodus file to/from a "fixture" (a MetaData and BulkData) - */ -class IO_Fixture -{ - public: - - typedef stk_classic::mesh::Field< double, stk_classic::mesh::Cartesian> coord_field_type; - - IO_Fixture(stk_classic::ParallelMachine comm); - ~IO_Fixture(); - - /** - * Use the mesh defined by the initialized meta and bulk data to create an - * exodus database. After this has been called, calls to add_timestep_to_output_mesh - * can be made. - */ - void create_output_mesh( - const std::string & base_exodus_filename, - bool add_transient = true, - bool add_all_fields = false - ); - /** - * Add timestep and write transiant io-fields to exodus file created by last call - * to create_output_mesh. Assumes that create_output_mesh has - * been called. - */ - void add_timestep_to_output_mesh( double time ); - - /** - * Set this fixture's meta data directly with your own meta data. - */ - void set_meta_data( Teuchos::RCP arg_meta_data ); - - /** - * Set this fixture's bulk data directly with your own meta data. - */ - void set_bulk_data( Teuchos::RCP arg_bulk_data ); - - /** - * Set the input region. Use this if you initialzed meta/bulk data with the - * setters instead of the initializers. - */ - void set_input_ioss_region( Teuchos::RCP input_region ); - - /** - * Initialize this fixtures's meta data by reading an input file. Use of this - * method means you can call initialize_bulk_data to initialize the - * bulk data of the fixture. - */ - void initialize_meta_data( const std::string & base_filename, - const std::string & type = "exodusii" ); - - /** - * Initialize this fixtures's bulk data by reading an input file. Only call - * this method if you used initialize_meta_data to initialize this - * fixture's meta data. The same file will be used to initialize the bulk data - * as was used to initialize the meta data. - */ - void initialize_bulk_data(); - - stk_classic::mesh::fem::FEMMetaData & meta_data() - { - ThrowRequire( !Teuchos::is_null(m_fem_meta_data)) ; - return *m_fem_meta_data; - } - - stk_classic::mesh::BulkData & bulk_data() - { - ThrowRequire( !Teuchos::is_null(m_bulk_data)) ; - return *m_bulk_data; - } - - stk_classic::io::MeshData & mesh_data() - { - return m_mesh_data; - } - - coord_field_type & get_coordinate_field() - { - coord_field_type * coord_field = meta_data().get_field("coordinates"); - ThrowRequire( coord_field != NULL); - return * coord_field; - } - - Teuchos::RCP input_ioss_region() { return m_ioss_input_region; } - Teuchos::RCP output_ioss_region() { return m_ioss_output_region; } - void output_ioss_region(Teuchos::RCP); - - private: - stk_classic::ParallelMachine m_comm; - Teuchos::RCP m_fem_meta_data; - Teuchos::RCP m_bulk_data; - - Teuchos::RCP m_ioss_input_region; - Teuchos::RCP m_ioss_output_region; - - std::string m_mesh_type; - stk_classic::io::MeshData m_mesh_data; - - //disallow copy constructor and assignment operator - IO_Fixture( const IO_Fixture & ); - IO_Fixture & operator = ( const IO_Fixture & ); -}; - -} // namespace util -} // namespace io -} // namespace stk_classic - -#endif //STK_IO_UTIL_IO_FIXTURE_HPP diff --git a/packages/stk/stk_classic/stk_io/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_io/unit_tests/CMakeLists.txt deleted file mode 100644 index 91b7194eb489..000000000000 --- a/packages/stk/stk_classic/stk_io/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_io) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_io/util) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../seacas/libraries/ioss/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -APPEND_SET(SOURCES -UnitTestGmeshFixture.cpp -UnitTestMain.cpp -UnitTestTopologyMap.cpp -) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_io_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestGmeshFixture.cpp b/packages/stk/stk_classic/stk_io/unit_tests/UnitTestGmeshFixture.cpp deleted file mode 100644 index 5424bc5bc44d..000000000000 --- a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestGmeshFixture.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#include -#include - -#include -#include - -# include - -#include - -#include -#include - -#include - -#include - -enum { SpaceDim = 3 }; - -STKUNIT_UNIT_TEST(UnitTestGmeshFixture, testUnit) -{ - const size_t num_x = 1; - const size_t num_y = 2; - const size_t num_z = 3; - const size_t num_surf = 6; - std::string config_mesh = Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|sideset:xXyYzZ"; - stk_classic::io::util::Gmesh_STKmesh_Fixture fixture(MPI_COMM_WORLD, config_mesh); - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get( fixture.getMetaData() ); - - fixture.commit(); - - const std::vector & sideset_names = fixture.getSidesetNames(); - STKUNIT_ASSERT_EQUAL( num_surf, sideset_names.size() ); - - for( size_t i = 0; i < num_surf; ++i ) { - std::string surf_name = (std::string)"surface_" + Ioss::Utils::to_string(i+1); - STKUNIT_ASSERT(surf_name == sideset_names[i]); - } - - std::vector num_surf_elem(3); - num_surf_elem[0] = num_y * num_z; - num_surf_elem[1] = num_x * num_z; - num_surf_elem[2] = num_x * num_y; - - for( size_t i = 0; i < num_surf/2; ++i ) - { - STKUNIT_ASSERT_EQUAL( num_surf_elem[i], fixture.getSurfElemCount(2*i) ); - STKUNIT_ASSERT_EQUAL( num_surf_elem[i], fixture.getSurfElemCount(2*i+1) ); - } - - const size_t total_side_count = 2 * (num_surf_elem[0]+num_surf_elem[1]+num_surf_elem[2]); - STKUNIT_ASSERT_EQUAL( total_side_count, fixture.getSideCount() ); - - const size_t total_elem_count = num_x * num_y * num_z; - STKUNIT_ASSERT_EQUAL( total_elem_count, fixture.getElemCount() ); - - const size_t total_node_count = (num_x+1) * (num_y+1) * (num_z+1); - STKUNIT_ASSERT_EQUAL( total_node_count, fixture.getNodeCount() ); - - // Needed to test field data - stk_classic::mesh::Field * coord_field = - fixture.getMetaData().get_field >("coordinates"); - STKUNIT_ASSERT( coord_field ); - - // All side buckets - const std::vector & all_side_buckets = fixture.getBulkData().buckets( fem_meta.side_rank() ); - - std::vector entities; - - const stk_classic::mesh::PartVector & side_parts = fixture.getSideParts(); - STKUNIT_ASSERT_EQUAL( sideset_names.size(), side_parts.size() ); - - for( size_t ifset = 0; ifset < side_parts.size(); ++ifset ) - { - std::pair expected = fixture.getSurfCoordInfo(ifset); - - stk_classic::mesh::Selector selector = *side_parts[ifset]; - entities.clear(); - stk_classic::mesh::get_selected_entities(selector, all_side_buckets, entities); - STKUNIT_ASSERT_EQUAL( fixture.getSurfElemCount(ifset), entities.size() ); - - for ( size_t i = 0 ; i < entities.size() ; ++i ) { - stk_classic::mesh::Entity & side = *entities[i] ; - - const CellTopologyData * cell_topology = stk_classic::mesh::fem::get_cell_topology(side).getCellTopologyData(); - - STKUNIT_ASSERT( cell_topology ); - - stk_classic::mesh::PairIterRelation rel = side.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - STKUNIT_ASSERT_EQUAL( cell_topology->node_count, rel.size() ); - - for ( unsigned j = 0 ; j < cell_topology->node_count ; ++j ) - { - stk_classic::mesh::Entity & rel_node = *rel[j].entity(); - double * coords = stk_classic::mesh::field_data(*coord_field, rel_node); - STKUNIT_ASSERT( coords ); - //std::cerr << "( " << coords[0] << ", " << coords[1] << ", " << coords[2] << ")" << std::endl; - - STKUNIT_ASSERT_DOUBLE_EQ(expected.second, coords[expected.first]); - } - //std::cerr << std::endl; - } - } -} - diff --git a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestIOFixture.cpp b/packages/stk/stk_classic/stk_io/unit_tests/UnitTestIOFixture.cpp deleted file mode 100644 index 8e39ec80f029..000000000000 --- a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestIOFixture.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include - -#include -#include -#include - -#include -#include - -namespace { - -void activate_entities(stk_classic::io::util::IO_Fixture &fixture, - stk_classic::mesh::Part &active_part) -{ - // Seed generator so multiple calls produce same result - srand(999999u); - stk_classic::mesh::fem::FEMMetaData & meta = fixture.meta_data(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - - stk_classic::mesh::EntityRank elem_rank = meta.element_rank(); - - stk_classic::mesh::PartVector add_parts(1, &active_part); - - bulk.modification_begin(); - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - if (stk_classic::io::is_part_io_part(*part) && part->primary_entity_rank() == elem_rank) { - // Get all entities (elements) on this part... - std::vector entities; - stk_classic::mesh::Selector select = meta.locally_owned_part() & *part; - stk_classic::mesh::get_selected_entities(select, bulk.buckets(elem_rank), entities); - for (size_t i=0; i < entities.size(); i++) { - if (rand() > (RAND_MAX/4)*3) - bulk.change_entity_parts(*entities[i], add_parts); - } - } - } - bulk.modification_end(); -} - -} - -STKUNIT_UNIT_TEST( IOFixture, iofixture ) -{ - // A simple test for reading and writing an exodus file using the IOFixture. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - stk_classic::io::util::IO_Fixture fixture(pm); - - std::string input_base_filename = "unit_test.g"; - - // Initialize meta data from exodus file - fixture.initialize_meta_data( input_base_filename, "exodusii" ); - - stk_classic::mesh::fem::FEMMetaData & meta_data = fixture.meta_data(); - - // Commit meta_data - meta_data.commit(); - - // bulk_data initialize (from exodus file) - fixture.initialize_bulk_data(); - - // exodus file creation - std::string output_base_filename = "unit_test_output.e"; - fixture.create_output_mesh( output_base_filename, "exodusii" ); - - // process output - const double time_step = 0; - fixture.add_timestep_to_output_mesh( time_step ); - - // Since correctness can only be established by running SEACAS tools, correctness - // checking is left to the test XML. -} - -STKUNIT_UNIT_TEST( IOFixture, active_only ) -{ - // A simple test for reading and writing an exodus file using the IOFixture. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - stk_classic::io::util::IO_Fixture fixture(pm); - - std::string input_base_filename = "unit_test.g"; - - // Initialize meta data from exodus file - fixture.initialize_meta_data( input_base_filename, "exodusii" ); - stk_classic::mesh::fem::FEMMetaData & meta_data = fixture.meta_data(); - - // Add an "active" part... - stk_classic::mesh::Part &active = meta_data.declare_part("active", meta_data.element_rank()); - meta_data.commit(); - - // bulk_data initialize (from exodus file) - fixture.initialize_bulk_data(); - - // Put some entities into the "active" part... - // This will be used to test the I/O filtering via a selector... - activate_entities(fixture, active); - - // Set the output filter on the mesh_data... - stk_classic::mesh::Selector active_selector(active); - fixture.mesh_data().m_anded_selector = &active_selector; - - // exodus file creation - std::string output_base_filename = "unit_test_output_filtered.e"; - fixture.create_output_mesh( output_base_filename, "exodusii" ); - - // process output - const double time_step = 0; - fixture.add_timestep_to_output_mesh( time_step ); - - - // Since correctness can only be established by running SEACAS tools, correctness - // checking is left to the test XML. -} - -STKUNIT_UNIT_TEST( IOFixture, active_and_all ) -{ - // A simple test for reading and writing two exodus files using the IOFixture. - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - stk_classic::io::util::IO_Fixture fixture(pm); - - std::string input_base_filename = "unit_test.g"; - - // Initialize meta data from exodus file - fixture.initialize_meta_data( input_base_filename, "exodusii" ); - stk_classic::mesh::fem::FEMMetaData & meta_data = fixture.meta_data(); - - // Add an "active" part... - stk_classic::mesh::Part &active = meta_data.declare_part("active", meta_data.element_rank()); - meta_data.commit(); - - // bulk_data initialize (from exodus file) - fixture.initialize_bulk_data(); - - // Put some entities into the "active" part... - // This will be used to test the I/O filtering via a selector... - activate_entities(fixture, active); - - // Set the output filter on the mesh_data... - stk_classic::mesh::Selector active_selector(active); - fixture.mesh_data().m_anded_selector = &active_selector; - - // exodus file creation - std::string filtered_output_base_filename = "unit_test_output_first_of_two.e"; - fixture.create_output_mesh( filtered_output_base_filename, "exodusii" ); - - // process output - double time_step = 0; - fixture.add_timestep_to_output_mesh( time_step ); - - - Teuchos::RCP active_output_ioss_region = fixture.output_ioss_region(); - - // Set the output filter on the mesh_data... - stk_classic::mesh::Selector universal_selector(meta_data.universal_part()); - fixture.mesh_data().m_anded_selector = &universal_selector; - - // exodus file creation - std::string unfiltered_output_base_filename = "unit_test_output_second_of_two.e"; - fixture.create_output_mesh( unfiltered_output_base_filename, "exodusii" ); - fixture.add_timestep_to_output_mesh( time_step ); - - Teuchos::RCP universal_output_ioss_region = fixture.output_ioss_region(); - - ++time_step; - - fixture.output_ioss_region(active_output_ioss_region); - fixture.mesh_data().m_anded_selector = &active_selector; - fixture.add_timestep_to_output_mesh( time_step ); - - fixture.output_ioss_region(universal_output_ioss_region); - fixture.mesh_data().m_anded_selector = &universal_selector; - fixture.add_timestep_to_output_mesh( time_step ); - - ++time_step; - - fixture.output_ioss_region(active_output_ioss_region); - fixture.mesh_data().m_anded_selector = &active_selector; - fixture.add_timestep_to_output_mesh( time_step ); - - fixture.output_ioss_region(universal_output_ioss_region); - fixture.mesh_data().m_anded_selector = &universal_selector; - fixture.add_timestep_to_output_mesh( time_step ); - // Since correctness can only be established by running SEACAS tools, correctness - // checking is left to the test XML. -} - -STKUNIT_UNIT_TEST( IOFixture, large_mesh_test ) -{ - // A simple test for reading and writing two exodus files using the IOFixture. - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - stk_classic::io::util::IO_Fixture fixture(pm); - - std::string input_base_filename = "1mCube_20x20x20.g"; - - // Initialize meta data from exodus file - fixture.initialize_meta_data( input_base_filename, "exodusii" ); - stk_classic::mesh::fem::FEMMetaData & meta_data = fixture.meta_data(); - - // Commit - meta_data.commit(); - - // bulk_data initialize (from exodus file) - fixture.initialize_bulk_data(); - stk_classic::mesh::BulkData &bulk_data = fixture.bulk_data(); - - const std::vector< stk_classic::mesh::Bucket * > & element_buckets - = bulk_data.buckets( meta_data.element_rank()); - - // iterate elements and check num nodal relations - for ( std::vector::const_iterator ib = element_buckets.begin() ; - ib != element_buckets.end() ; ++ib ) { - stk_classic::mesh::Bucket & b = **ib ; - const int length = b.size(); - for ( int k = 0 ; k < length ; ++k ) { - // get element - stk_classic::mesh::Entity &elem = b[k]; - stk_classic::mesh::PairIterRelation elem_node_rels = elem.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - STKUNIT_EXPECT_EQ( 8u, elem_node_rels.size()); - } - } -} diff --git a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_io/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 33538cad68cc..000000000000 --- a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestTopologyMap.cpp b/packages/stk/stk_classic/stk_io/unit_tests/UnitTestTopologyMap.cpp deleted file mode 100644 index e55efa0b4210..000000000000 --- a/packages/stk/stk_classic/stk_io/unit_tests/UnitTestTopologyMap.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -namespace { -template -int my_assert(T a, T b, U msg) { - if (a != b) { - std::cerr << "\tERROR: '" << msg << "' assertion failed: " << a << " is not equal to " << b << "\n"; - return 1; - } - return 0; -} -} - -namespace { -int testElement(const std::string &name) -{ - int errors = 0; - Ioss::ElementTopology *element = Ioss::ElementTopology::factory(name); - if (element == NULL) { - std::cerr << "\tERROR: Element type '" << name << "' could not be constructed."; - // Must return since we have a NULL pointer and can't do further tests... - return 1; - } - if (element->name() != name) { - // This is an alias. Don't run it through the rest of the tests - std::cerr << "Element '" << name << "' is an alias for element '" << element->name() << "'\n"; - return 0; - } - - std::cerr << "Testing element '" << name << "'\n"; - // Currently not supported in shards: - if (element->name() == "unknown" || - element->name() == "tetra7" || element->name() == "tetra11" || - element->name() == "tetra14" || element->name() == "tetra15" || - element->name() == "tri7" || - element->name() == "trishell4" || element->name() == "trishell7" || - element->name() == "wedge20" || element->name() == "wedge21" || - element->name() == "wedge16") { - std::cerr << "\tERROR (EXPECTED): No support for '" << element->name() << "'\n"; - return 0; - } - - // Get the corresponding shards CellTopologyData* .. - const CellTopologyData *cell_data = stk_classic::io::map_topology_ioss_to_cell(element); - if (cell_data == NULL) { - std::cerr << "\tERROR: Could not find a shards CellTopology corresponding to the Ioss::ElementTopology element '" - << name << "'."; - // Must return since we have a NULL pointer and can't do further tests... - return 1; - } - - // See if we get the same element back when converting from - // CellTopologyData to Ioss::ElementToplogy - std::string new_name = stk_classic::io::map_topology_cell_to_ioss(cell_data, element->spatial_dimension()); - Ioss::ElementTopology *new_element = Ioss::ElementTopology::factory(new_name); - if (element->name() != new_element->name()) { - std::cerr << "\tERROR: New name = '" << new_element->name() - << "' doesn't match old name '" << element->name() - << "'\n"; - errors++; - } - - shards::CellTopology cell(cell_data); - - // At this point, 'element' is the Ioss element topology and - // 'cell' is the corresponding shards CellTopology data pointer. - // Make sure that they agree on all subcell details... - // Exceptions: - // 1. An Ioss Node has 1 node per element; a shards Node has 0 nodes per element... - - errors += my_assert(cell.getNodeCount(), - static_cast(element->number_nodes()), - "node count"); - errors += my_assert(cell.getVertexCount(), - static_cast(element->number_corner_nodes()), - "vertex count"); - - // NOTE: CellTopology and Ioss disagree on parametric dimension. - int add_to = element->spatial_dimension() != element->parametric_dimension() && element->is_element() ? 1 : 0; - errors += my_assert(cell.getDimension(), - static_cast(element->parametric_dimension()+add_to), - "parametric dimension"); - errors += my_assert(cell.getEdgeCount(), - static_cast(element->number_edges()), - "edge count"); - - // NOTE: Ioss counts edges and faces as boundaries for shell elements - int add_boundary = 0; - if (add_to == 1 && element->spatial_dimension() == 3 && element->parametric_dimension() == 2) - add_boundary = cell.getEdgeCount(); - - if (element->name() == "edge2" || element->name() == "edge3") - add_boundary += 2; - - errors += my_assert(cell.getSideCount() + add_boundary, - static_cast(element->number_boundaries()), - "boundary count"); - - - // Check face topologies for all elements... - if (element->is_element()) { - if (cell.getDimension() == 3) { - int face_count = element->number_faces(); - for (int i=0; i < face_count; i++) { - Ioss::ElementTopology *face = element->face_type(i+1); - const CellTopologyData *cell_face = cell.getCellTopologyData(cell.getDimension()-1,i); - errors += my_assert(face->name(), - stk_classic::io::map_topology_cell_to_ioss(cell_face,face->spatial_dimension()), - "face type"); - - Ioss::IntVector fcon = element->face_connectivity(i+1); - size_t node_count = fcon.size(); - for (size_t j=0; j < node_count; j++) { - std::ostringstream msg; - msg << "face node connectivity for node " << j << " on face " << i; - errors += my_assert(fcon[j], - static_cast(cell.getNodeMap(cell.getDimension()-1, i, j)), - msg.str()); - } - } - - int edge_count = element->number_edges(); - for (int i=0; i < edge_count; i++) { - - Ioss::IntVector fcon = element->edge_connectivity(i+1); - size_t node_count = fcon.size(); - for (size_t j=0; j < node_count; j++) { - std::ostringstream msg; - msg << "edge node connectivity for node " << j << " on edge " << i; - errors += my_assert(fcon[j], - static_cast(cell.getNodeMap(cell.getDimension()-2, i, j)), - msg.str()); - } - } - } - else if (cell.getDimension() == 2) { - int edge_count = element->number_edges(); - for (int i=0; i < edge_count; i++) { - Ioss::ElementTopology *edge = element->edge_type(i+1); - const CellTopologyData *cell_edge = cell.getCellTopologyData(cell.getDimension()-1,i); - errors += my_assert(edge->name(), - stk_classic::io::map_topology_cell_to_ioss(cell_edge, edge->spatial_dimension()), - "edge type"); - - Ioss::IntVector econ = element->edge_connectivity(i+1); - size_t node_count = econ.size(); - for (size_t j=0; j < node_count; j++) { - std::ostringstream msg; - msg << "edge node connectivity for node " << j << " on edge " << i; - errors += my_assert(econ[j], - static_cast(cell.getNodeMap(cell.getDimension()-1, i, j)), - msg.str()); - } - } - - } - } - return errors; -} -} - -STKUNIT_UNIT_TEST(UnitTestTopology, testUnit) -{ - Ioss::StorageInitializer initialize_storage; - Ioss::Initializer initialize_topologies; - - Ioss::NameList elements; - int element_count = Ioss::ElementTopology::describe(&elements); - - int errors = 0; - for (int i=0; i < element_count; i++) { - // FIXME: Need to totally skip tetra7 for now - if (elements[i] == "tetra7" || - elements[i] == "tetra11" || - elements[i] == "trishell4" || - elements[i] == "trishell7") { - continue; - } - - int current_error = testElement(elements[i]); - if (elements[i] != "node" && - elements[i] != "rod3d2" && - elements[i] != "rod3d3" && - elements[i] != "tri4a" /*FIXME?*/) { - errors += current_error; - } - else { - if (current_error > 0) - std::cerr << "\t\tIGNORING " << elements[i] << " ERRORS...\n"; - } - } - STKUNIT_ASSERT(errors == 0); -} - - diff --git a/packages/stk/stk_classic/stk_linsys/CMakeLists.txt b/packages/stk/stk_classic/stk_linsys/CMakeLists.txt deleted file mode 100644 index 82d919faad79..000000000000 --- a/packages/stk/stk_classic/stk_linsys/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -ADD_SUBDIRECTORY(stk_linsys) - -TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - diff --git a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile b/packages/stk/stk_classic/stk_linsys/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.input b/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.input deleted file mode 100644 index 41ff19952e5d..000000000000 --- a/packages/stk/stk_classic/stk_linsys/doc/Doxyfile.input +++ /dev/null @@ -1,20 +0,0 @@ -#BANNER @copydoc stk_linsys_banner -#HOWTO @copydoc stk_linsys_howto - -# Note, any path you set here will have to be set twice; once for when doxygen -# is run from this directory, and once for when doxygen is run from the -# TPLs_src/Trilinos/packages/stk/doc directory. - -# Put local appends here! Note: Please only put append-type changes -# (IE, VAR += CHANGE) in this section. All the STK products must -# use the same configuration because, when doxygen is run from stk/doc -# to assemble HTML for the entire STK, any configuration overrides -# that happen here will affect the html generation for ALL the -# STK products. - -INPUT += ../../stk_linsys/doc/index.dox \ - ../../stk_linsys/stk_linsys \ - ../stk_linsys/doc/index.dox \ - ../stk_linsys/stk_linsys - - diff --git a/packages/stk/stk_classic/stk_linsys/doc/index.dox b/packages/stk/stk_classic/stk_linsys/doc/index.dox deleted file mode 100644 index c035294326d6..000000000000 --- a/packages/stk/stk_classic/stk_linsys/doc/index.dox +++ /dev/null @@ -1,11 +0,0 @@ -/** - * \page stk_linsys_banner Sierra Toolkit Linear System - * - * \ref stk_linsys_module "Sierra Toolkit Linear-System Assembly" - *

- * The Sierra Toolkit Linear-System Assembly package supports assembly of - * matrix/vector contributions from stk_classic::mesh data into FEI interfaces which - * in turn support Trilinos and FETI data structures. - *

- * - */ diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.cpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.cpp deleted file mode 100644 index 20bbdd944628..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace linsys { - -AggregateLinearSystem::AggregateLinearSystem(MPI_Comm comm, fei::SharedPtr factory, size_t num_matrices, size_t num_rhsvecs) - : m_fei_factory(factory), - m_linear_system(comm, factory), - m_matrices(num_matrices), - m_rhsvecs(num_rhsvecs) -{ -} - -AggregateLinearSystem::~AggregateLinearSystem() -{ -} - -void -AggregateLinearSystem::set_parameters(Teuchos::ParameterList& paramlist) -{ - m_linear_system.set_parameters(paramlist); -} - -void -AggregateLinearSystem::set_num_matrices_rhsvecs(size_t num_matrices, size_t num_rhsvecs) -{ - m_matrices.resize(num_matrices); - m_rhsvecs.resize(num_rhsvecs); -} - -void -AggregateLinearSystem::synchronize_mappings_and_structure() -{ - m_linear_system.synchronize_mappings_and_structure(); -} - -void -AggregateLinearSystem::create_fei_LinearSystem() -{ - m_linear_system.create_fei_LinearSystem(); - - fei::SharedPtr mgraph = m_linear_system.get_fei_MatrixGraph(); - - for(size_t i=0; icreateMatrix(mgraph); - } - - bool is_soln_vec = false; - for(size_t i=0; icreateVector(mgraph,is_soln_vec); - } -} - -fei::SharedPtr -AggregateLinearSystem::get_matrix(size_t index) -{ - if (index >= m_matrices.size()) { - throw std::runtime_error("stk_classic::linsys::AggregateLinearSystem::get_matrix ERROR, index out of range."); - } - - return m_matrices[index]; -} - -fei::SharedPtr -AggregateLinearSystem::get_rhsvec(size_t index) -{ - if (index >= m_rhsvecs.size()) { - throw std::runtime_error("stk_classic::linsys::AggregateLinearSystem::get_rhsvec ERROR, index out of range."); - } - - return m_rhsvecs[index]; -} - -void -AggregateLinearSystem::aggregate_system(const std::vector& mat_scalars, - const std::vector& rhs_scalars) -{ - if (mat_scalars.size() != m_matrices.size()) { - throw std::runtime_error("stk_classic::linsys::AggregateLinearSystem::aggregate_system ERROR, mat_scalars.size() != m_matrices.size()."); - } - - if (rhs_scalars.size() != m_rhsvecs.size()) { - throw std::runtime_error("stk_classic::linsys::AggregateLinearSystem::aggregate_system ERROR, rhs_scalars.size() != m_rhsvecs.size()."); - } - - fei::SharedPtr fei_linsys = m_linear_system.get_fei_LinearSystem(); - fei::SharedPtr matrix = fei_linsys->getMatrix(); - fei::SharedPtr rhsvec = fei_linsys->getRHS(); - - matrix->gatherFromOverlap(); - matrix->putScalar(0.0); - - for(size_t i=0; igatherFromOverlap(); - rhsvec->putScalar(0.0); - - for(size_t i=0; iputScalar(0); - } - for(size_t i=0; iputScalar(0); - } -} - -const fei::SharedPtr -AggregateLinearSystem::get_fei_MatrixGraph() const -{ - return m_linear_system.get_fei_MatrixGraph(); -} - -fei::SharedPtr -AggregateLinearSystem::get_fei_MatrixGraph() -{ - return m_linear_system.get_fei_MatrixGraph(); -} - -const fei::SharedPtr -AggregateLinearSystem::get_fei_LinearSystem() const -{ - return m_linear_system.get_fei_LinearSystem(); -} - -fei::SharedPtr -AggregateLinearSystem::get_fei_LinearSystem() -{ - return m_linear_system.get_fei_LinearSystem(); -} - -void -AggregateLinearSystem::write_files(const std::string& base_name) const -{ - for(size_t i=0; iwriteToFile(Aname.c_str()); - } - for(size_t i=0; iwriteToFile(bname.c_str()); - } -} - -int -AggregateLinearSystem::solve(int &status, const Teuchos::ParameterList & params ) -{ - return m_linear_system.solve(status, params); -} - -}//namespace linsys -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.hpp deleted file mode 100644 index 1026798c5e01..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/AggregateLinearSystem.hpp +++ /dev/null @@ -1,137 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_AggregateLinearSystem_hpp -#define stk_linsys_AggregateLinearSystem_hpp - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace linsys { - -/** Container for holding and manipulating collections of matrices and vectors. - * - * This class provides the ability to form a linear system in which the matrix is - * a linear combination of other matrices, and the right-hand-side is a linear combination - * of other vectors. - * If n matrices A[0..n-1] and m vectors b[0..n-1] are each assembled, then the - * 'aggregate' linear-system is formed with A = sum(alpha[i]*A[i]) and - * b = sum(beta[i]*b[i]) where alpha and beta are arrays of scalars provided by - * the calling code. - */ -class AggregateLinearSystem : public LinearSystemInterface { - public: - /** Constructor */ - AggregateLinearSystem(MPI_Comm comm, fei::SharedPtr factory, size_t num_matrices=1, size_t num_rhsvecs=1); - - /** Destructor */ - virtual ~AggregateLinearSystem(); - - void set_parameters(Teuchos::ParameterList& paramlist); - - /** set the number of matrices and right-hand-sides */ - void set_num_matrices_rhsvecs(size_t num_matrices, size_t num_rhsvecs); - - /** This is a collective call -- will hang if only a subset of processors - * call it. - * Internally calls fei::MatrixGraph::initComplete() and - * DofMapper::finalize(). - */ - void synchronize_mappings_and_structure(); - - /** Uses the fei::Factory (that was passed as a constructor argument) to - * create a fei::LinearSystem and populate it with a fei::Matrix and - * fei::Vectors. - */ - void create_fei_LinearSystem(); - - /** Return the matrix at offset 'index' in the internally-stored array of matrices. - */ - fei::SharedPtr get_matrix(size_t index); - - /** Return the rhs-vec at offset 'index' in the internally-stored array of rhs-vectors. - */ - fei::SharedPtr get_rhsvec(size_t index); - - /** Given arrays of scalars (which must have the same lengths as specified when - * this class was constructed), form an aggregate linear system as described in - * the class-description comments above. - */ - void aggregate_system(const std::vector& mat_scalars, - const std::vector& rhs_scalars); - - /** This is a collective call -- will hang if only a subset of processors - * call it. - * Internally calls fei::LinearSystem::loadComplete(), which in turn calls - * fei::Matrix::globalAssemble() and fei::Vector::gatherFromOverlap(). - * These operations perform communication to move shared contributions - * to owning processors, etc. - */ - void finalize_assembly(); - - /** Return DOF-mapping object */ - const DofMapper& get_DofMapper() const; - - /** Return DOF-mapping object */ - DofMapper& get_DofMapper(); - - void reset_to_zero(); - - /** Return fei::MatrixGraph object */ - const fei::SharedPtr get_fei_MatrixGraph() const; - - /** Return fei::MatrixGraph object */ - fei::SharedPtr get_fei_MatrixGraph(); - - /** Return fei::LinearSystem object */ - const fei::SharedPtr get_fei_LinearSystem() const; - - /** Return fei::LinearSystem object */ - fei::SharedPtr get_fei_LinearSystem(); - - void write_files(const std::string& base_name) const; - - /** Solve the linear system - * Note that the caller is expected to have already called the method - * 'aggregate_system' if multiple matrices/rhs-vectors are being used. - * - * @param status Output flag indicating the termination condition of the - * underlying linear-solver. Values are solver-specific. In general, 0 - * indicates that the solver achieved a solution that satisfied the - * stopping test, within the iteration limit, etc. If an iterative solver - * fails to converge, this status value will generally be non-zero, but - * the actual value can vary by solver-library. - * - * @param params Teuchos::ParameterList for the solver - * - * @return error-code 0 if successful. Note that a 0 error-return does not - * necessarily mean that the underlying solver achieved a solution. It - * simply means that no fatal errors were encountered, such as allocation - * failures, etc. - */ - int solve(int & status, const Teuchos::ParameterList & params); - - private: - - fei::SharedPtr m_fei_factory; - stk_classic::linsys::LinearSystem m_linear_system; - - std::vector > m_matrices; - std::vector > m_rhsvecs; -};//class AggregateLinearSystem - -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/CMakeLists.txt b/packages/stk/stk_classic/stk_linsys/stk_linsys/CMakeLists.txt deleted file mode 100644 index a29b2b38ce22..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_linsys - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_base - SOURCES ${SOURCES} - ) diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.cpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.cpp deleted file mode 100644 index c3973f8229cb..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include -#include -#include - -#include - -namespace stk_classic { -namespace linsys { - -DofMapper::DofMapper(MPI_Comm comm, bool create_reverse_mappings) - : m_field_id_map(), - m_fei_vecspace(new fei::VectorSpace(comm)), - m_reverse_mappings_enabled(create_reverse_mappings), - m_fei_reversemap(NULL) -{ -} - -DofMapper::~DofMapper() -{ - delete m_fei_reversemap; -} - -namespace { - -void throw_fei_err(const std::string& mesg, int err) -{ - std::ostringstream osstr; - osstr << mesg << err; - std::string str = osstr.str(); - throw std::runtime_error(str); -} - -}//namespace - -void -DofMapper::add_dof_mappings(const stk_classic::mesh::BulkData& mesh_bulk, - const stk_classic::mesh::Selector& selector, - stk_classic::mesh::EntityRank ent_type, - const stk_classic::mesh::FieldBase& field) -{ - int idType = static_cast(ent_type); - - m_fei_vecspace->defineIDTypes( 1, &idType ); - - int field_id = impl::map_field_to_int(m_field_id_map, field); - - const std::vector& all_buckets = mesh_bulk.buckets(ent_type); - std::vector buckets; - stk_classic::mesh::get_buckets(selector, all_buckets, buckets); - - bool already_declared_fei_field = false; - - for(size_t i=0; idefineFields(1, &field_id, &field_size); - already_declared_fei_field = true; - } - - std::vector ids(buckets[i]->size()); - - stk_classic::mesh::Bucket::iterator - iter = buckets[i]->begin(), iter_end = buckets[i]->end(); - - int num_ids = 0; - - for(; iter != iter_end; ++iter) { - stk_classic::mesh::Entity& entity = *iter; - ids[num_ids++] = impl::entityid_to_int(entity.identifier()); - } - - int err = m_fei_vecspace->addDOFs(field_id, idType, num_ids, &ids[0]); - if (err != 0) throw_fei_err("stk_classic::linsys::DofMapper::add_dof_mappings ERROR: fei::VectorSpace::addDOFs returned error-code=",err); - } - - std::vector shared_ids; - std::vector sharing_procs; - - const std::vector& entity_comm = mesh_bulk.entity_comm(); - for(size_t i=0; ientity_rank() != ent_type) continue; - if (!stk_classic::mesh::field_data_valid(field, *ent)) continue; - - const stk_classic::mesh::PairIterEntityComm ec = ent->sharing(); - - for ( size_t j = 0 ; j < ec.size() ; ++j ) { - shared_ids.push_back(impl::entityid_to_int(ent->identifier())); - sharing_procs.push_back(ec[j].proc); - } - } - - if (shared_ids.size() > 0) { - std::vector num_sharing_procs_per_id(shared_ids.size(), 1); - - int err = m_fei_vecspace->initSharedIDs(shared_ids.size(), idType, - &shared_ids[0], &num_sharing_procs_per_id[0], - &sharing_procs[0]); - if (err != 0) throw_fei_err("stk_classic::linsys::DofMapper::add_dof_mappings ERROR: fei::VectorSpace::initSharedIDs returned error-code=",err); - } -} - -void -DofMapper::finalize() -{ - int err = m_fei_vecspace->initComplete(); - if (err != 0) throw_fei_err("stk_classic::linsys::DofMapper::finalize ERROR: fei::VectorSpace::initComplete returned error-code=",err); - - if (m_reverse_mappings_enabled) { - delete m_fei_reversemap; - m_fei_reversemap = new fei::ReverseMapper(*m_fei_vecspace); - } -} - -int -DofMapper::get_field_id(const stk_classic::mesh::FieldBase& field) const -{ - return impl::query_field_to_int_mapping(m_field_id_map, field); -} - -int -DofMapper::get_global_index(stk_classic::mesh::EntityRank ent_type, - stk_classic::mesh::EntityId ent_id, - stk_classic::mesh::FieldBase& field, - int offset_into_field) -{ - int err = 0, index = 0; - int field_id = get_field_id(field); - int int_id = impl::entityid_to_int(ent_id); - - try { - err = m_fei_vecspace->getGlobalIndex(ent_type, int_id, field_id, index); - if (err != 0) throw_fei_err("fei::VectorSpace::getGlobalIndex error=",err); - } - catch (...) { - std::ostringstream msg; - msg << "stk_classic::linsys::DofMapper::get_global_index ERROR: " - << "fei::VectorSpace::getGlobalIndex returned error-code ("<getEqnRecord(global_index); - - ent_type = eqrec.IDType; - ent_id = eqrec.ID; - offset_into_field = eqrec.offset; - field = impl::get_field(m_field_id_map, eqrec.fieldID); -} - -}//namespace linsys -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.hpp deleted file mode 100644 index 97bc1ec64822..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/DofMapper.hpp +++ /dev/null @@ -1,152 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_DofMapper_hpp -#define stk_linsys_DofMapper_hpp - -#include - -#include -#include -#include - -#include -#include - -namespace stk_classic { -/** Linear-System Assembly -*/ -namespace linsys { - -/** \addtogroup stk_linsys_module - * \{ - */ - -/** Perform mappings between degrees-of-freedom and equation-indices. - -A degree-of-freedom is specified by four things: - (entity-type,entity-id,field,offset-into-field) - -An equation-index is a member of a globally contiguous, zero-based index space. - -A DOF-mapping allows the caller to provide a degree-of-freedom and obtain an equation-index. -A reverse DOF-mapping allows the caller to provide an equation-index and obtain a degree-of-freedom. - -By default this DofMapper class provides DOF-mappings and reverse-DOF-mappings. Providing reverse -DOF-mappings consumes extra memory since it requires constructing an additional FEI object to do -the reverse lookups. If this is not desired, reverse-mappings can be disabled using DofMapper's -second constructor argument. - -The FEI library is utilized for accumulating and storing the mappings. (fei::VectorSpace provides -DOF-mappings, and fei::ReverseMapper provides reverse-DOF-mappings.) - -Since the FEI works entirely with primitive data types (e.g., int) and has no knowledge -of stk_classic::mesh types, this DofMapper class essentially acts as a translation bridge -between stk_classic::mesh and the FEI library. -*/ -class DofMapper { - public: - /** Constructor that internally creates an fei::VectorSpace object.*/ - DofMapper(MPI_Comm comm, bool create_reverse_mappings=true); - - /** Constructor that accepts an existing fei::VectorSpace object.*/ -// DofMapper(fei::SharedPtr vspace, bool create_reverse_mappings=true); - - /** Destructor */ - virtual ~DofMapper(); - - /** Given a mesh, an entity-type and a field, store the resulting DOF mappings. - * This method iterates the buckets for the specified entity-type, and for each - * bucket that has the given field and is selected by the specified selector. - * DOF-mappings are stored for each entity-id in the bucket. - * - * This method may be called repeatedly, to add dof mappings for different parts, - * different entity-types, different fields, etc. - */ - void add_dof_mappings( const stk_classic::mesh::BulkData& mesh_bulk, - const stk_classic::mesh::Selector& selector, - stk_classic::mesh::EntityRank ent_type, - const stk_classic::mesh::FieldBase& field ); - - /** This method internally calls fei::VectorSpace::initComplete(), which finalizes - * and synchronizes the DOF-mappings (ensures that indices for shared-entities are - * consistent, etc.). Also, if reverse-mappings are not disabled, this method - * creates the reverse-mappings object. (The get_dof() method is not available until - * after this has happened.) - * - * This is a collective method, must be called on all processors. - */ - void finalize(); - - /** Query whether reverse-DOF-mappings are enabled. - * (See second constructor argument above.) - */ - bool reverse_mappings_enabled() const { return m_reverse_mappings_enabled; } - - /** Return the integer id that the specified field is mapped to. - * The integer id is the FEI's representation of the field. - */ - int get_field_id(const stk_classic::mesh::FieldBase& field) const; - - /** Return a global equation index for the specified entity type/id pair and field. - * - * Note: this method should be const, but it calls an fei query that is not const. - * When the fei method is corrected, this method will be made const. - * - * Note2: this method may not work correctly until after 'finalize()' has been called. - */ - int get_global_index(stk_classic::mesh::EntityRank ent_type, - stk_classic::mesh::EntityId ent_id, - stk_classic::mesh::FieldBase& field, - int offset_into_field=0); - - /** Given a global_index, return the specification for the DOF that it corresponds to. - * Throw an exception if the global_index is not found, or if DofMapper::finalize() has - * not been called. - * Note: this method will be const after the corresponding fei query is corrected for constness. - */ - void get_dof(int global_index, - stk_classic::mesh::EntityRank& ent_type, - stk_classic::mesh::EntityId& ent_id, - const stk_classic::mesh::FieldBase*& field, - int& offset_into_field) const; - - /** Return the underlying fei::VectorSpace object. - */ - const fei::SharedPtr get_fei_VectorSpace() const { return m_fei_vecspace; } - - /** Return the underlying fei::VectorSpace object. - */ - fei::SharedPtr get_fei_VectorSpace() { return m_fei_vecspace; } - - const FieldIdMap& get_FieldIdMap() const { return m_field_id_map; } - - FieldIdMap& get_FieldIdMap() { return m_field_id_map; } - - private: - - FieldIdMap m_field_id_map; - - //we store the fei::VectorSpace in a fei::SharedPtr because other fei APIs expect it - //to be that way. e.g., the constructor for fei::MatrixGraph requires a VectorSpace in a - //fei::SharedPtr... - fei::SharedPtr m_fei_vecspace; - bool m_reverse_mappings_enabled; - fei::ReverseMapper* m_fei_reversemap; - - DofMapper(const DofMapper &); - void operator = (const DofMapper &); -};//class DofMapper - -/** \} */ - -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/FeiBaseIncludes.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/FeiBaseIncludes.hpp deleted file mode 100644 index bdfcc24a02d2..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/FeiBaseIncludes.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_FeiBaseIncludes_hpp -#define stk_linsys_FeiBaseIncludes_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/FieldIdMap.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/FieldIdMap.hpp deleted file mode 100644 index d84ca8b949aa..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/FieldIdMap.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_FieldIdMap_hpp -#define stk_linsys_FieldIdMap_hpp - -#include -#include - -namespace stk_classic { -namespace linsys { - -/** Mappings from stk_classic::mesh::Field objects to integer ids used by fei objects. - */ -typedef std::map FieldIdMap; - -}//namespace linsys -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.cpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.cpp deleted file mode 100644 index 67c723fa7a6d..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include - -namespace stk_classic { -namespace linsys { -namespace impl { - -int -map_field_to_int(FieldIdMap& field_id_map, - const stk_classic::mesh::FieldBase& field) -{ - FieldIdMap::iterator iter = field_id_map.find(&field); - - if (iter == field_id_map.end()) { - iter = field_id_map.insert(iter, std::make_pair(&field,field_id_map.size())); - } - - return iter->second; -} - -int -query_field_to_int_mapping(const FieldIdMap& field_id_map, - const stk_classic::mesh::FieldBase& field) -{ - FieldIdMap::const_iterator iter = field_id_map.find(&field); - - if (iter == field_id_map.end()) { - std::ostringstream msg; - msg << "stk_classic::linsys::query_field_to_int_mapping ERROR: " - << " field with name '"<second; -} - -const stk_classic::mesh::FieldBase* -get_field(const FieldIdMap& field_id_map, - int field_id) -{ - FieldIdMap::const_iterator - iter = field_id_map.begin(), iter_end = field_id_map.end(); - - while(iter!=iter_end && iter->second != field_id) ++iter; - - if (iter == iter_end) { - std::ostringstream msg; - msg << "stk_classic::linsys::get_dof ERROR: " - << "field_id ("<first; -} - -int entitytype_to_int(stk_classic::mesh::EntityRank entity_rank) -{ - int int_type = static_cast(entity_rank); - - verify_convertible_to_int(entity_rank, "stk_classic::linsys::entitytype_to_int"); - - return int_type; -} - -int entityid_to_int(stk_classic::mesh::EntityId id) -{ - int int_id = static_cast(id); - - verify_convertible_to_int(id, "stk_classic::linsys::entityid_to_int"); - - return int_id; -} - -}//namespace impl -}//namespace linsys -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.hpp deleted file mode 100644 index 38ae1351ad79..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/ImplDetails.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_ImplDetails_hpp -#define stk_linsys_ImplDetails_hpp - -#include - -#include -#include -#include -#include - -namespace stk_classic { - -/** Linear-System Assembly -*/ -namespace linsys { - -/** Implementation Details -- not generally of interest for the public API -*/ -namespace impl { - -/** Given a map and a Field, return the int id that the field is mapped to. - The field will be added to the map if not already present. - This is useful because FEI classes/functions use integer ids for fields. -*/ -int map_field_to_int(FieldIdMap& field_id_map, - const stk_classic::mesh::FieldBase& field); - -/** Given a map and a Field, return the int id that the field is mapped to. - If the field is not found in the map, an exception is thrown. - This is useful because FEI classes/functions use integer ids for fields. -*/ -int -query_field_to_int_mapping(const FieldIdMap& field_id_map, - const stk_classic::mesh::FieldBase& field); - -/** Given an integer field_id, return a reference to the corresponding field. - Throw an exception if field_id not found. -*/ -const stk_classic::mesh::FieldBase* get_field(const FieldIdMap& field_id_map, - int field_id); - -/** Given an EntityId, return the value as an int. - Throws an exception if id is too large to represent as an int. - This is useful because FEI classes/functions use integer ids for entities. -*/ -int entityid_to_int(stk_classic::mesh::EntityId id); - -/** Given an EntityRank, return the value as an int. - Throws an exception if id is too large to represent as an int. - This is useful because FEI classes/functions use integer ids for entity-types. -*/ -int entitytype_to_int(stk_classic::mesh::EntityRank entity_rank); - -/** Determine whether 'id' can be converted to an int. - * If so, do nothing. If 'id' is too large to be represented - * as an int, throw an exception (std::runtime_error). - */ -template -void verify_convertible_to_int(T id, const char* caller) -{ - if (sizeof(T) <= sizeof(int)) return; - - T intmax = std::numeric_limits::max(); - if (intmax < id) { - std::ostringstream msg; - msg << caller << " ERROR, id " << id << " is too large to convert to int."; - std::string str = msg.str(); - throw std::runtime_error(str); - } -} - -}//namespace impl -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.cpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.cpp deleted file mode 100644 index bba5798f940b..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace linsys { - -LinearSystem::LinearSystem(MPI_Comm comm, fei::SharedPtr factory) - : m_fei_factory(factory), - m_dof_mapper(comm), - m_fei_mgraph(new fei::MatrixGraph_Impl2(m_dof_mapper.get_fei_VectorSpace(), fei::SharedPtr())), - m_fei_linearsystem(), - m_param_set() -{ -} - -LinearSystem::~LinearSystem() -{ -} - -void -LinearSystem::set_parameters(Teuchos::ParameterList& paramlist) -{ - Trilinos_Helpers::copy_parameterlist(paramlist, m_param_set); - m_dof_mapper.get_fei_VectorSpace()->setParameters(m_param_set); - if (m_fei_factory.get() != NULL) { - m_fei_factory->parameters(m_param_set); - } - if (m_fei_mgraph.get() != NULL) { - m_fei_mgraph->setParameters(m_param_set); - } -} - -void -LinearSystem::synchronize_mappings_and_structure() -{ - m_fei_mgraph->initComplete(); - m_dof_mapper.finalize(); -} - -void -LinearSystem::create_fei_LinearSystem() -{ - m_fei_linearsystem = m_fei_factory->createLinearSystem(m_fei_mgraph); - m_fei_linearsystem->parameters(m_param_set); - - fei::SharedPtr mtx = m_fei_factory->createMatrix(m_fei_mgraph); - mtx->parameters(m_param_set); - m_fei_linearsystem->setMatrix(mtx); - fei::SharedPtr rhs = m_fei_factory->createVector(m_fei_mgraph); - m_fei_linearsystem->setRHS(rhs); - fei::SharedPtr soln = m_fei_factory->createVector(m_fei_mgraph,true); - m_fei_linearsystem->setSolutionVector(soln); -} - -void -LinearSystem::finalize_assembly() -{ - m_fei_linearsystem->loadComplete(); -} - -const DofMapper& -LinearSystem::get_DofMapper() const -{ - return m_dof_mapper; -} - -DofMapper& -LinearSystem::get_DofMapper() -{ - return m_dof_mapper; -} - -void -LinearSystem::reset_to_zero() -{ - fei::SharedPtr mtx = m_fei_linearsystem->getMatrix(); - if (mtx.get() != NULL) { - mtx->putScalar(0); - } - - fei::SharedPtr rhs = m_fei_linearsystem->getRHS(); - if (rhs.get() != NULL) { - rhs->putScalar(0); - } -} - -const fei::SharedPtr -LinearSystem::get_fei_MatrixGraph() const -{ - return m_fei_mgraph; -} - -fei::SharedPtr -LinearSystem::get_fei_MatrixGraph() -{ - return m_fei_mgraph; -} - -const fei::SharedPtr -LinearSystem::get_fei_LinearSystem() const -{ - return m_fei_linearsystem; -} - -fei::SharedPtr -LinearSystem::get_fei_LinearSystem() -{ - return m_fei_linearsystem; -} - -void -LinearSystem::write_files(const std::string& base_name) const -{ - fei::SharedPtr A = m_fei_linearsystem->getMatrix(); - if (A.get() != NULL) { - std::ostringstream ossA; - ossA << "A_" << base_name << ".mtx"; - std::string Aname = ossA.str(); - A->writeToFile(Aname.c_str()); - } - fei::SharedPtr b = m_fei_linearsystem->getRHS(); - if (b.get() != NULL) { - std::ostringstream ossb; - ossb << "b_" << base_name << ".vec"; - std::string bname = ossb.str(); - b->writeToFile(bname.c_str()); - } -} - -int -LinearSystem::solve(int &status, const Teuchos::ParameterList & params ) -{ - return fei_solve(status, *m_fei_linearsystem, params); -} - -}//namespace linsys -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.hpp deleted file mode 100644 index 7be09c2a1aa7..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystem.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_LinearSystem_hpp -#define stk_linsys_LinearSystem_hpp - -#include -#include -#include - -#include - -namespace stk_classic { -namespace linsys { - -/** Container of linear-system (matrix, vectors) and mapping objects. - * - */ -class LinearSystem : public LinearSystemInterface { - public: - /** Constructor */ - LinearSystem(MPI_Comm comm, fei::SharedPtr factory); - - /** Destructor */ - virtual ~LinearSystem(); - - void set_parameters(Teuchos::ParameterList& paramlist); - - /** This is a collective call -- will hang if only a subset of processors - * call it. - * Internally calls fei::MatrixGraph::initComplete() and - * DofMapper::finalize(). - */ - void synchronize_mappings_and_structure(); - - /** Uses the fei::Factory (that was passed as a constructor argument) to - * create a fei::LinearSystem and populate it with a fei::Matrix and - * fei::Vectors. - */ - void create_fei_LinearSystem(); - - /** This is a collective call -- will hang if only a subset of processors - * call it. - * Internally calls fei::LinearSystem::loadComplete(), which in turn calls - * fei::Matrix::globalAssemble() and fei::Vector::gatherFromOverlap(). - * These operations perform communication to move shared contributions - * to owning processors, etc. - */ - void finalize_assembly(); - - /** Return DOF-mapping object */ - const DofMapper& get_DofMapper() const; - - /** Return DOF-mapping object */ - DofMapper& get_DofMapper(); - - void reset_to_zero(); - - /** Return fei::MatrixGraph object */ - const fei::SharedPtr get_fei_MatrixGraph() const; - - /** Return fei::MatrixGraph object */ - fei::SharedPtr get_fei_MatrixGraph(); - - /** Return fei::LinearSystem object */ - const fei::SharedPtr get_fei_LinearSystem() const; - - /** Return fei::LinearSystem object */ - fei::SharedPtr get_fei_LinearSystem(); - - void write_files(const std::string& base_name) const; - -/** Solve the linear system - * - * @param status Output flag indicating the termination condition of the - * underlying linear-solver. Values are solver-specific. In general, 0 - * indicates that the solver achieved a solution that satisfied the - * stopping test, within the iteration limit, etc. If an iterative solver - * fails to converge, this status value will generally be non-zero, but - * the actual value can vary by solver-library. - * - * @param params Teuchos::ParameterList for the solver - * - * @return error-code 0 if successful. Note that a 0 error-return does not - * necessarily mean that the underlying solver achieved a solution. It - * simply means that no fatal errors were encountered, such as allocation - * failures, etc. - */ - int solve(int & status, const Teuchos::ParameterList & params); - - private: - - fei::SharedPtr m_fei_factory; - DofMapper m_dof_mapper; - fei::SharedPtr m_fei_mgraph; - - fei::SharedPtr m_fei_linearsystem; - fei::ParameterSet m_param_set; -};//class LinearSystem - -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystemInterface.hpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystemInterface.hpp deleted file mode 100644 index 78e8cd083b4a..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinearSystemInterface.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_LinearSystemInterface_hpp -#define stk_linsys_LinearSystemInterface_hpp - -#include -#include - -#include - -namespace stk_classic { -namespace linsys { - -class LinearSystemInterface { - public: - virtual ~LinearSystemInterface() {} - - virtual void set_parameters(Teuchos::ParameterList& paramlist) = 0; - - virtual void synchronize_mappings_and_structure() = 0; - virtual void create_fei_LinearSystem() = 0; - virtual void finalize_assembly() = 0; - - /** Return DOF-mapping object */ - virtual const DofMapper& get_DofMapper() const = 0; - - /** Return DOF-mapping object */ - virtual DofMapper& get_DofMapper() = 0; - - /** set all matrix/vector coefficients to zero (if allocated) */ - virtual void reset_to_zero() = 0; - - /** Return fei::MatrixGraph object */ - virtual const fei::SharedPtr get_fei_MatrixGraph() const = 0; - - /** Return fei::MatrixGraph object */ - virtual fei::SharedPtr get_fei_MatrixGraph() = 0; - - /** Return fei::LinearSystem object */ - virtual const fei::SharedPtr get_fei_LinearSystem() const = 0; - - /** Return fei::LinearSystem object */ - virtual fei::SharedPtr get_fei_LinearSystem() = 0; - - /** Write matrix and vector objects out to file. - * Use 'base_name' in the file-names. - */ - virtual void write_files(const std::string& base_name) const = 0; - - /** Solve the linear system - * - * @param status Output flag indicating the termination condition of the - * underlying linear-solver. Values are solver-specific. In general, 0 - * indicates that the solver achieved a solution that satisfied the - * stopping test, within the iteration limit, etc. If an iterative solver - * fails to converge, this status value will generally be non-zero, but - * the actual value can vary by solver-library. - * - * @param params Teuchos::ParameterList for the solver - * - * @return error-code 0 if successful. Note that a 0 error-return does not - * necessarily mean that the underlying solver achieved a solution. It - * simply means that no fatal errors were encountered, such as allocation - * failures, etc. - */ - virtual int solve(int & status, const Teuchos::ParameterList & params) = 0; - -};//class LinearSystemInterface - -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/Linsys.dox b/packages/stk/stk_classic/stk_linsys/stk_linsys/Linsys.dox deleted file mode 100644 index 3b1b0ab603a0..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/Linsys.dox +++ /dev/null @@ -1,8 +0,0 @@ - -namespace stk_classic { -namespace linsys { -}//namespace linsys -}//namespace stk_classic - -/** \defgroup stk_linsys_module Sierra Toolkit Linear-System Assembly - */ diff --git a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinsysFunctions.cpp b/packages/stk/stk_classic/stk_linsys/stk_linsys/LinsysFunctions.cpp deleted file mode 100644 index 532955609238..000000000000 --- a/packages/stk/stk_classic/stk_linsys/stk_linsys/LinsysFunctions.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include -#include - -#include -#include -#include - - -namespace stk_classic { -namespace linsys { - -void add_connectivities(stk_classic::linsys::LinearSystemInterface& ls, - stk_classic::mesh::EntityRank entity_rank, - stk_classic::mesh::EntityRank connected_entity_rank, - const stk_classic::mesh::FieldBase& field, - const stk_classic::mesh::Selector& selector, - const stk_classic::mesh::BulkData& mesh_bulk) -{ - const std::vector& mesh_buckets = mesh_bulk.buckets(entity_rank); - std::vector part_buckets; - stk_classic::mesh::get_buckets(selector, mesh_buckets, part_buckets); - - if (part_buckets.empty()) return; - - DofMapper& dof_mapper = ls.get_DofMapper(); - - dof_mapper.add_dof_mappings(mesh_bulk, selector, connected_entity_rank, field); - - int field_id = dof_mapper.get_field_id(field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(connected_entity_rank); - int num_connected = rel.second - rel.first; - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - - int pattern_id = matgraph->definePattern(num_connected, connected_entity_rank, field_id); - - int num_entities = 0; - for(size_t i=0; isize(); - } - - int block_id = matgraph->initConnectivityBlock(num_entities, pattern_id); - - std::vector connected_ids(num_connected); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& entity = *b_iter; - rel = entity.relations(connected_entity_rank); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - connected_ids[j] = rel.first->entity()->identifier(); - } - int conn_id = entity.identifier(); - matgraph->initConnectivity(block_id, conn_id, &connected_ids[0]); - } - } -} - -void dirichlet_bc(stk_classic::linsys::LinearSystemInterface& ls, - const stk_classic::mesh::BulkData& mesh, - const stk_classic::mesh::Part& bcpart, - stk_classic::mesh::EntityRank entity_rank, - const stk_classic::mesh::FieldBase& field, - unsigned field_component, - double prescribed_value) -{ - std::vector buckets; - stk_classic::mesh::Selector selector(bcpart); - stk_classic::mesh::get_buckets(selector, mesh.buckets(entity_rank), buckets); - - int field_id = ls.get_DofMapper().get_field_id(field); - std::vector entity_ids; - - for(size_t i=0; ibegin(), iend = buckets[i]->end(); - for(; iter!=iend; ++iter) { - const stk_classic::mesh::Entity& entity = *iter; - entity_ids.push_back(stk_classic::linsys::impl::entityid_to_int(entity.identifier())); - } - } - - std::vector prescribed_values(entity_ids.size(), prescribed_value); - - ls.get_fei_LinearSystem()->loadEssentialBCs(entity_ids.size(), - &entity_ids[0], - stk_classic::linsys::impl::entitytype_to_int(entity_rank), - field_id, field_component, - &prescribed_values[0]); -} - -int fei_solve(int & status, fei::LinearSystem &fei_ls, const Teuchos::ParameterList & params ) -{ -//Note: hard-coded to Trilinos/Aztec!!! - Solver_AztecOO solver_az; - - fei::ParameterSet param_set; - - Trilinos_Helpers::copy_parameterlist(params, param_set); - - int iterationsTaken = 0; - - return solver_az.solve( & fei_ls, - NULL, - param_set, - iterationsTaken, - status - ); -} - -double compute_residual_norm2(fei::LinearSystem& fei_ls, fei::Vector& r) -{ - fei::SharedPtr A = fei_ls.getMatrix(); - fei::SharedPtr x = fei_ls.getSolutionVector(); - fei::SharedPtr b = fei_ls.getRHS(); - - //form r = A*x - A->multiply(x.get(), &r); - //form r = b - r (i.e., r = b - A*x) - r.update(1, b.get(), -1); - -//!!!!!! fix this !!!!!!!!! -//terrible data copy. fei::Vector should provide a norm operation instead -//of making me roll my own here... - - std::vector indices; - r.getVectorSpace()->getIndices_Owned(indices); - std::vector coefs(indices.size()); - r.copyOut(indices.size(), &indices[0], &coefs[0]); - double local_sum = 0; - for(size_t i=0; igetCommunicator(); - double global_sum = 0; - int num_doubles = 1; - MPI_Allreduce(&local_sum, &global_sum, num_doubles, MPI_DOUBLE, MPI_SUM, comm); -#else - double global_sum = local_sum; -#endif - return std::sqrt(global_sum); -} - -void copy_vector_to_mesh( fei::Vector & vec, - const DofMapper & dof, - stk_classic::mesh::BulkData & mesh_bulk_data - ) -{ - vec.scatterToOverlap(); - - std::vector shared_and_owned_indices; - - vec.getVectorSpace()->getIndices_SharedAndOwned(shared_and_owned_indices); - - size_t num_values = shared_and_owned_indices.size(); - - if(num_values == 0) { - return; - } - - std::vector values(num_values); - vec.copyOut(num_values,&shared_and_owned_indices[0],&values[0]); - - stk_classic::mesh::EntityRank ent_type; - stk_classic::mesh::EntityId ent_id; - const stk_classic::mesh::FieldBase * field; - int offset_into_field; - - for(size_t i = 0; i < num_values; ++i) - { - - dof.get_dof( shared_and_owned_indices[i], - ent_type, - ent_id, - field, - offset_into_field - ); - - stk_classic::mesh::Entity & entity = *mesh_bulk_data.get_entity(ent_type, ent_id); - - void * data = stk_classic::mesh::field_data(*field,entity); - - if(!(field->type_is()) || data == NULL) { - std::ostringstream oss; - oss << "stk_classic::linsys::copy_vector_to_mesh ERROR, bad data type, or "; - oss << " field (" << field->name() << ") not found on entity with type " << entity.entity_rank(); - oss << " and ID " << entity.identifier(); - std::string str = oss.str(); - throw std::runtime_error(str.c_str()); - } - - double * double_data = reinterpret_cast(data); - - double_data[offset_into_field] = values[i]; - - } -} - -void scale_matrix(double scalar, fei::Matrix& matrix) -{ - fei::SharedPtr vspace = matrix.getMatrixGraph()->getRowSpace(); - - int numRows = vspace->getNumIndices_Owned(); - std::vector rows(numRows); - vspace->getIndices_Owned(numRows, &rows[0], numRows); - - std::vector indices; - std::vector coefs; - - for(size_t i=0; i vspace = src_matrix.getMatrixGraph()->getRowSpace(); - - int numRows = vspace->getNumIndices_Owned(); - std::vector rows(numRows); - vspace->getIndices_Owned(numRows, &rows[0], numRows); - - std::vector indices; - std::vector coefs; - - for(size_t i=0; i vspace = vec.getVectorSpace(); - - int numIndices = vspace->getNumIndices_Owned(); - std::vector indices(numIndices); - vspace->getIndices_Owned(numIndices, &indices[0], numIndices); - - std::vector coefs(numIndices); - - vec.copyOut(numIndices, &indices[0], &coefs[0]); - - for(size_t j=0; j vspace = src_vector.getVectorSpace(); - - int numIndices = vspace->getNumIndices_Owned(); - std::vector indices(numIndices); - vspace->getIndices_Owned(numIndices, &indices[0], numIndices); - - std::vector coefs(numIndices); - - src_vector.copyOut(numIndices, &indices[0], &coefs[0]); - - for(size_t j=0; j - -#include -#include -#include - -#include - - -namespace stk_classic { -namespace linsys { - -/** Add connectivities (matrix-graph sparsity contributions) to the - fei::MatrixGraph object in the specified LinearSystemInterface object. - - Connectivities are connections between two types of entities that - are related to each other in the mesh. The most common example of - this is element-to-node connectivities. So when from_type is element - and to_connected_type is node, the matrix-graph will be populated with - connectivities for nodes connected to each element selected by the - given selector. - -*/ -void add_connectivities(stk_classic::linsys::LinearSystemInterface& ls, - stk_classic::mesh::EntityRank from_type, - stk_classic::mesh::EntityRank to_connected_type, - const stk_classic::mesh::FieldBase& field, - const stk_classic::mesh::Selector& selector, - const stk_classic::mesh::BulkData& mesh_bulk); - -/** Apply a Dirichlet boundary-condition for the specified field, on - * entities of the specified entity-type which are members of the - * specified Part. - * Obtains the list of entity-ids and passes that along with - * the prescribed value, etc., to the fei::LinearSystem object. - * The corresponding modifications to the matrix and vector will be made - * when LinearSystemInterface::finalize_assembly() is called. - */ -void dirichlet_bc(stk_classic::linsys::LinearSystemInterface& ls, - const stk_classic::mesh::BulkData& mesh, - const stk_classic::mesh::Part& bcpart, - stk_classic::mesh::EntityRank entity_rank, - const stk_classic::mesh::FieldBase& field, - unsigned field_component, - double prescribed_value); - - -/** Create an fei::Solver instance and perform a linear-solve on the - * matrix and vectors contained in the given fei::LinearSystem instance. - * - * @param status Output flag indicating the termination condition of the - * underlying linear-solver. Values are solver-specific. In general, 0 - * indicates that the solver achieved a solution that satisfied the - * stopping test, within the iteration limit, etc. If an iterative solver - * fails to converge, this status value will generally be non-zero, but - * the actual value can vary by solver-library. - * - * @return error-code 0 if successful. Note that a 0 error-return does not - * necessarily mean that the underlying solver achieved a solution. It - * simply means that no fatal errors were encountered, such as allocation - * failures, etc. - */ -int fei_solve(int & status, fei::LinearSystem &fei_ls, const Teuchos::ParameterList & params); - -/** Return a 2-norm of |b - A*x| - */ -double compute_residual_norm2(fei::LinearSystem& fei_ls, fei::Vector& r); - -/** Copy the contents of an fei::Vector to the corresponding field-data - * locations in a stk_classic::mesh::BulkData instance. - * This function first calls vec.scatterToOverlap() to ensure that coefficients - * for shared-entities are available on all sharing processors. - */ -void copy_vector_to_mesh( fei::Vector & vec, - const DofMapper & dof, - stk_classic::mesh::BulkData & mesh_bulk_data - ); - -/** Scale matrix by a scalar: matrix = scalar*matrix - */ -void scale_matrix(double scalar, fei::Matrix& matrix); - -/** Add a scaled matrix to another: dest += scalar*src - */ -void add_matrix_to_matrix(double scalar, - const fei::Matrix& src_matrix, - fei::Matrix& dest_matrix); - -/** Scale vector by a scalar: vec = scalar*vec - */ -void scale_vector(double scalar, - fei::Vector& vec); - -/** Add a scaled vector to another: dest += scalar*src - */ -void add_vector_to_vector(double scalar, - const fei::Vector& src_vector, - fei::Vector& dest_vector); - -}//namespace linsys -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_linsys/unit_tests/CMakeLists.txt deleted file mode 100644 index 595d9c7b4b13..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -APPEND_SET(SOURCES -UnitTest_helpers.cpp -UnitTestLinearSystem.cpp -UnitTestMain.cpp -UnitTestDofMapper.cpp -UnitTestImpl.cpp -UnitTestLinsysFunctions.cpp - ) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - linsys_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestDofMapper.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestDofMapper.cpp deleted file mode 100644 index ca22b9b69f09..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestDofMapper.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -static const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -namespace stk_linsys_unit_tests { - -static const size_t spatial_dimension = 3; - -//------------- here is the DofMapper unit-test... ----------------------- - -void testDofMapper( MPI_Comm comm ) -{ - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension); - - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - - fill_utest_mesh_meta_data( fem_meta ); - fill_utest_mesh_bulk_data( bulk_data ); - - stk_classic::mesh::Selector selector = meta_data.locally_owned_part() | meta_data.globally_shared_part() ; - std::vector count; - stk_classic::mesh::count_entities(selector, bulk_data, count); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - std::vector nodes; - stk_classic::mesh::get_entities(bulk_data, NODE_RANK, nodes); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Now we're ready to test the DofMapper: - - stk_classic::linsys::DofMapper dof_mapper(comm); - - const stk_classic::mesh::Selector select_used = meta_data.locally_owned_part() | meta_data.globally_shared_part(); - - dof_mapper.add_dof_mappings(bulk_data, select_used, - NODE_RANK, *temperature_field); - - stk_classic::mesh::EntityRank ent_type; - stk_classic::mesh::EntityId ent_id; - const stk_classic::mesh::FieldBase* field = NULL; - int offset_into_field; - int index = 0; - //DofMapper::get_dof can't be called until after DofMapper::finalize() has - //been called. - //We'll call it now to verify that an exception is thrown: - std::cout << "Testing error condition: " << std::endl; - STKUNIT_ASSERT_THROW(dof_mapper.get_dof(index, ent_type, ent_id, field, offset_into_field), std::runtime_error ); - std::cout << "...Completed testing error condition." << std::endl; - - dof_mapper.finalize(); - - //find a node that is in the locally-used part: - size_t i_node = 0; - while(! select_used( nodes[i_node]->bucket() ) && i_node fei_vspace = dof_mapper.get_fei_VectorSpace(); - int numIndices = fei_vspace->getGlobalNumIndices(); - STKUNIT_ASSERT_EQUAL( numIndices, (int)(numProcs*20 - (numProcs-1)*4) ); - - dof_mapper.get_dof(index, ent_type, ent_id, field, offset_into_field); - - STKUNIT_ASSERT_EQUAL( ent_type, nodes[i_node]->entity_rank() ); - STKUNIT_ASSERT_EQUAL( ent_id, nodes[i_node]->identifier() ); - STKUNIT_ASSERT_EQUAL( field->name() == temperature_field->name(), true ); - STKUNIT_ASSERT_EQUAL( offset_into_field, (int)0 ); -} - -} // namespace stk_linsys_unit_tests - -STKUNIT_UNIT_TEST(UnitTestingOfDofMapper, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_linsys_unit_tests::testDofMapper ( MPI_COMM_WORLD ); -} - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestImpl.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestImpl.cpp deleted file mode 100644 index 4c40929899ed..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestImpl.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include -#include - -#include -#include - -namespace stk_linsys_unit_tests { - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -static const size_t spatial_dimension = 3; - -//------------- here is the unit-test of stk_classic::linsys::impl functions... ----------------------- - -void testImpl( MPI_Comm comm ) -{ - //First create and initialize a MetaData to use in our testing: - - stk_classic::mesh::MetaData meta_data( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - - const unsigned number_of_states = 1; - - ScalarField& temperature_field = meta_data.declare_field( "temperature", number_of_states ); - ScalarField& pressure_field = meta_data.declare_field( "pressure", number_of_states ); - VectorField& velocity_field = meta_data.declare_field( "velocity", number_of_states ); - - meta_data.commit(); - - - //Now test the linsys::impl::map_field_to_int function: - - stk_classic::linsys::FieldIdMap field_id_map; - - int fieldid = stk_classic::linsys::impl::map_field_to_int(field_id_map, temperature_field); - STKUNIT_ASSERT_EQUAL( fieldid, (int)0 ); - - fieldid = stk_classic::linsys::impl::query_field_to_int_mapping(field_id_map, temperature_field); - STKUNIT_ASSERT_EQUAL( fieldid, (int)0 ); - - //test query_field_to_int_mapping for the case where the specified field is not in the map. - //(an exception should be thrown in this case) - std::cout << "\nTesting query_field_to_int_mapping with un-mapped field..." << std::endl; - bool threw_exc0 = false; - try { - fieldid = stk_classic::linsys::impl::query_field_to_int_mapping(field_id_map, pressure_field); - } - catch(std::exception& exc) { - threw_exc0 = true; - std::cout << "Caught expected exception: " << exc.what() << std::endl; - } - STKUNIT_ASSERT_EQUAL( threw_exc0, (bool)true ); - - //now add the pressure field... - fieldid = stk_classic::linsys::impl::map_field_to_int(field_id_map, pressure_field); - STKUNIT_ASSERT_EQUAL( fieldid, (int)1 ); - - fieldid = stk_classic::linsys::impl::map_field_to_int(field_id_map, velocity_field); - STKUNIT_ASSERT_EQUAL( fieldid, (int)2 ); - - //here the pressure field is already in the map. - fieldid = stk_classic::linsys::impl::map_field_to_int(field_id_map, pressure_field); - STKUNIT_ASSERT_EQUAL( fieldid, (int)1 ); - - //confirm that the map is the expected size: - STKUNIT_ASSERT_EQUAL( field_id_map.size(), (size_t)3 ); - - //test the linsys::impl::get_field function: - const stk_classic::mesh::FieldBase* field = stk_classic::linsys::impl::get_field(field_id_map, 2); - - STKUNIT_ASSERT_EQUAL( field->name() == velocity_field.name(), true ); - - //call linsys::impl::get_field with an unknown field-id to confirm that an - //exception is thrown. - bool threw_exc1 = false; - try { - field = stk_classic::linsys::impl::get_field(field_id_map, 5); - } - catch(std::exception& exc) { - threw_exc1 = true; - std::cout << "Caught expected exception: " << exc.what() << std::endl; - } - STKUNIT_ASSERT_EQUAL( threw_exc1, (bool)true ); - - //Now test the linsys::impl::entityid_to_int function: - - stk_classic::mesh::EntityId id = 42; - int int_id1 = stk_classic::linsys::impl::entityid_to_int(id); - - STKUNIT_ASSERT_EQUAL( int_id1, (int)42 ); - - //3 billion is too large to represent as int... - uint64_t big_id = 3000000000u; - STKUNIT_ASSERT_THROW( stk_classic::linsys::impl::verify_convertible_to_int(big_id, "linsys unit-test"), std::runtime_error); -} - -} // namespace stk_linsys_unit_tests - -STKUNIT_UNIT_TEST(UnitTestImpl, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_linsys_unit_tests::testImpl ( MPI_COMM_WORLD ); -} - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinearSystem.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinearSystem.cpp deleted file mode 100644 index 67f3150396a5..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinearSystem.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -static const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -namespace stk_linsys_unit_tests { - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void get_local_coefs(const fei::Vector& vec, std::vector& coefs) -{ - fei::SharedPtr vspace = vec.getVectorSpace(); - std::vector indices; - vspace->getIndices_Owned(indices); - coefs.resize(indices.size()); - vec.copyOut(indices.size(), &indices[0], &coefs[0]); -} - -void get_first_local_row_coefs(const fei::Matrix& mat, std::vector& row_coefs) -{ - row_coefs.clear(); - fei::SharedPtr vspace = mat.getMatrixGraph()->getRowSpace(); - std::vector row_numbers; - vspace->getIndices_Owned(row_numbers); - std::vector col_indices; - int rowlength = 0; - if (row_numbers.size() > 0) { - mat.getRowLength(row_numbers[0], rowlength); - if (rowlength > 0) { - col_indices.resize(rowlength); - row_coefs.resize(rowlength); - mat.copyOutRow(row_numbers[0], rowlength, &row_coefs[0], &col_indices[0]); - } - } -} - -STKUNIT_UNIT_TEST(UnitTestLinearSystem, test1) -{ - static const size_t spatial_dimension = 3; - - MPI_Comm comm = MPI_COMM_WORLD; - - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - - //create a boundary-condition part for testing later: - stk_classic::mesh::Part& bcpart = fem_meta.declare_part("bcpart"); - - fill_utest_mesh_meta_data( fem_meta ); - fill_utest_mesh_bulk_data( bulk_data ); - - //------------------------------ - //put a node in our boundary-condition part. arbitrarily choose the - //first locally-owned node: - - bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(meta_data.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - bulk_data.buckets(NODE_RANK), - local_nodes); - - stk_classic::mesh::EntityId bc_node_id = 0; - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - bulk_data.change_entity_parts(*local_nodes[0], partvector); - bc_node_id = stk_classic::linsys::impl::entityid_to_int(local_nodes[0]->identifier()); - } - (void)bc_node_id; // to avoid a set but not used warning from gcc 4.6.3 - - bulk_data.modification_end(); - //------------------------------ - - stk_classic::mesh::Selector select_used = meta_data.locally_owned_part() | meta_data.globally_shared_part() ; - std::vector count; - stk_classic::mesh::count_entities(select_used, bulk_data, count); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - std::vector nodes; - stk_classic::mesh::get_entities(bulk_data, NODE_RANK, nodes); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Now we're ready to test the LinearSystem object: - - fei::SharedPtr factory(new Factory_Trilinos(comm)); - stk_classic::linsys::LinearSystem ls(comm,factory); - - stk_classic::linsys::add_connectivities(ls, element_rank, NODE_RANK, - *temperature_field, select_owned, bulk_data); - - ls.synchronize_mappings_and_structure(); - - const stk_classic::linsys::LinearSystem& const_ls = ls; - const fei::SharedPtr const_mgraph = const_ls.get_fei_MatrixGraph(); - fei::SharedPtr mgraph = ls.get_fei_MatrixGraph(); - - const fei::MatrixGraph* const_mgraph_ptr = const_mgraph.get(); - fei::MatrixGraph* mgraph_ptr = mgraph.get(); - - STKUNIT_ASSERT_EQUAL( mgraph_ptr, (fei::MatrixGraph*)const_mgraph_ptr ); - - ls.create_fei_LinearSystem(); - - const fei::LinearSystem* const_linsys_ptr = const_ls.get_fei_LinearSystem().get(); - fei::LinearSystem* linsys_ptr = ls.get_fei_LinearSystem().get(); - - STKUNIT_ASSERT_EQUAL( (fei::LinearSystem*)const_linsys_ptr, linsys_ptr); - - int numProcs = 1, myProc = 0; - myProc = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - numProcs = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - STKUNIT_ASSERT(numProcs>=1); - - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - int num_local_rows = matrix->getLocalNumRows(); - int expected_num_local_rows = myProc==0 ? 20 : 16; - - STKUNIT_ASSERT_EQUAL( num_local_rows, expected_num_local_rows ); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - const stk_classic::linsys::DofMapper& const_dof_mapper = const_ls.get_DofMapper(); - - STKUNIT_ASSERT_EQUAL( (stk_classic::linsys::DofMapper*)&dof_mapper , (stk_classic::linsys::DofMapper*)&const_dof_mapper ); - - assemble_elem_matrices_and_vectors(bulk_data, *temperature_field, ls); - - Teuchos::ParameterList params; - int status = 0, return_code = 0; - return_code = ls.solve(status, params); - STKUNIT_ASSERT_EQUAL(return_code, (int)0); -} - -STKUNIT_UNIT_TEST(UnitTestAggregateLinearSystem, test1) -{ - static const size_t spatial_dimension = 3; - - MPI_Comm comm = MPI_COMM_WORLD; - - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - - //create a boundary-condition part for testing later: - stk_classic::mesh::Part& bcpart = fem_meta.declare_part("bcpart"); - - fill_utest_mesh_meta_data( fem_meta ); - fill_utest_mesh_bulk_data( bulk_data ); - - //------------------------------ - //put a node in our boundary-condition part. arbitrarily choose the - //first locally-owned node: - - bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(meta_data.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - bulk_data.buckets(NODE_RANK), - local_nodes); - - stk_classic::mesh::EntityId bc_node_id = 0; - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - bulk_data.change_entity_parts(*local_nodes[0], partvector); - bc_node_id = stk_classic::linsys::impl::entityid_to_int(local_nodes[0]->identifier()); - } - (void)bc_node_id; // to avoid a set but not used warning from gcc 4.6.3 - - bulk_data.modification_end(); - //------------------------------ - - stk_classic::mesh::Selector select_used = meta_data.locally_owned_part() | meta_data.globally_shared_part() ; - std::vector count; - stk_classic::mesh::count_entities(select_used, bulk_data, count); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - std::vector nodes; - stk_classic::mesh::get_entities(bulk_data, NODE_RANK, nodes); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Now we're ready to test the AggregateLinearSystem object: - - fei::SharedPtr factory(new Factory_Trilinos(comm)); - size_t num_matrices = 2; - size_t num_rhsvecs = 2; - stk_classic::linsys::AggregateLinearSystem ls(comm,factory, num_matrices, num_rhsvecs); - - stk_classic::linsys::add_connectivities(ls, element_rank, NODE_RANK, - *temperature_field, select_owned, bulk_data); - - ls.synchronize_mappings_and_structure(); - - const stk_classic::linsys::LinearSystemInterface& const_ls = ls; - const fei::SharedPtr const_mgraph = const_ls.get_fei_MatrixGraph(); - fei::SharedPtr mgraph = ls.get_fei_MatrixGraph(); - - const fei::MatrixGraph* const_mgraph_ptr = const_mgraph.get(); - fei::MatrixGraph* mgraph_ptr = mgraph.get(); - - STKUNIT_ASSERT_EQUAL( mgraph_ptr, (fei::MatrixGraph*)const_mgraph_ptr ); - - ls.create_fei_LinearSystem(); - - const fei::LinearSystem* const_linsys_ptr = const_ls.get_fei_LinearSystem().get(); - fei::LinearSystem* linsys_ptr = ls.get_fei_LinearSystem().get(); - - STKUNIT_ASSERT_EQUAL( (fei::LinearSystem*)const_linsys_ptr, linsys_ptr); - - int numProcs = 1, myProc = 0; - myProc = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - numProcs = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - STKUNIT_ASSERT(numProcs >= 1); - - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - int num_local_rows = matrix->getLocalNumRows(); - int expected_num_local_rows = myProc==0 ? 20 : 16; - - STKUNIT_ASSERT_EQUAL( num_local_rows, expected_num_local_rows ); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - const stk_classic::linsys::DofMapper& const_dof_mapper = const_ls.get_DofMapper(); - - STKUNIT_ASSERT_EQUAL( (stk_classic::linsys::DofMapper*)&dof_mapper , (stk_classic::linsys::DofMapper*)&const_dof_mapper ); - - fei::SharedPtr mat0 = ls.get_matrix(0); - fei::SharedPtr rhs0 = ls.get_rhsvec(0); - assemble_elem_matrices_and_vectors(bulk_data, *temperature_field, dof_mapper, *mat0, *rhs0); - fei::SharedPtr mat1 = ls.get_matrix(1); - fei::SharedPtr rhs1 = ls.get_rhsvec(1); - assemble_elem_matrices_and_vectors(bulk_data, *temperature_field, dof_mapper, *mat1, *rhs1); - - //grab a copy of rhs1's coefficients for later comparison: - std::vector rhs1_coefs; - get_local_coefs(*rhs1, rhs1_coefs); - - //grab a copy of mat1's first-row coefs for later comparison: - std::vector mat1_row_coefs; - get_first_local_row_coefs(*mat1, mat1_row_coefs); - - std::vector mat_scalars(num_matrices, 1.0); - std::vector rhs_scalars(num_rhsvecs, 1.0); - ls.aggregate_system(mat_scalars, rhs_scalars); - - fei::SharedPtr rhs = ls.get_fei_LinearSystem()->getRHS(); - fei::SharedPtr mat = ls.get_fei_LinearSystem()->getMatrix(); - - //grab a copy of rhs's coefficients: - std::vector rhs_coefs; - get_local_coefs(*rhs, rhs_coefs); - - //grab a copy of mat's first-row coefs: - std::vector mat_row_coefs; - get_first_local_row_coefs(*mat, mat_row_coefs); - - //rhs and rhs1 should have the same length: - bool rhs_test_passed = rhs_coefs.size() == rhs1_coefs.size(); - STKUNIT_ASSERT(rhs_test_passed); - - //mat and mat1 should have the same length for the first local row: - bool mat_test_passed = mat_row_coefs.size() == mat1_row_coefs.size(); - STKUNIT_ASSERT(mat_test_passed); - - for(size_t i=0; i 0.1) { - rhs_test_passed = std::abs(rhs_coefs[0]/rhs1_coefs[0] - 2.0) < 1.e-8; - STKUNIT_ASSERT(rhs_test_passed); - } - } - - for(size_t i=0; i 0.1) { - mat_test_passed = std::abs(mat_row_coefs[0]/mat1_row_coefs[0] - 2.0) < 1.e-8; - STKUNIT_ASSERT(mat_test_passed); - } - } - - Teuchos::ParameterList params; - int status = 0, return_code = 0; - return_code = ls.solve(status, params); - STKUNIT_ASSERT_EQUAL(return_code, (int)0); -} - -} // namespace stk_linsys_unit_tests - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinsysFunctions.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinsysFunctions.cpp deleted file mode 100644 index 77e92d6228b0..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestLinsysFunctions.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -namespace stk_linsys_unit_tests { - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -bool confirm_vector_values(const fei::Vector& vec, double expected_value) -{ - std::vector indices; - fei::SharedPtr vspace = vec.getVectorSpace(); - vspace->getIndices_Owned(indices); - bool result = true; - if (indices.size() > 0) { - std::vector coefs(indices.size()); - vec.copyOut(indices.size(), &indices[0], &coefs[0]); - - for(size_t i=0; i 1.e-13) { - result = false; - break; - } - } - } - return result; -} - -bool confirm_matrix_values(const fei::Matrix& mat, double expected_value) -{ - std::vector rows; - fei::SharedPtr rspace = mat.getMatrixGraph()->getRowSpace(); - rspace->getIndices_Owned(rows); - bool result = true; - std::vector indices; - std::vector coefs; - for(size_t i=0; i 1.e-13) { - result = false; - break; - } - } - } - return result; -} - -//------------- LinsysFunctions unit-tests... ----------------------- - -STKUNIT_UNIT_TEST(UnitTestLinsysFunctions, test1) -{ - static const size_t spatial_dimension = 3; - - MPI_Barrier( MPI_COMM_WORLD ); - MPI_Comm comm = MPI_COMM_WORLD; - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - stk_classic::mesh::fem::FEMMetaData fem_meta2; - fem_meta.FEM_initialize(spatial_dimension); - fem_meta2.FEM_initialize(spatial_dimension); - - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::MetaData & meta_data2 = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta2); - - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - stk_classic::mesh::BulkData bulk_data2( meta_data2, comm, bucket_size ); - - //create a boundary-condition part for testing later: - stk_classic::mesh::Part& bcpart = fem_meta.declare_part("bcpart"); - - fill_utest_mesh_meta_data( fem_meta ); - - bool use_temperature=false; - fill_utest_mesh_meta_data( fem_meta2, use_temperature ); - - fill_utest_mesh_bulk_data( bulk_data ); - fill_utest_mesh_bulk_data( bulk_data2 ); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( bulk_data ); - - //put a node in our boundary-condition part. arbitrarily choose the - //first locally-owned node: - - bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(meta_data.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - bulk_data.buckets(NODE_RANK), - local_nodes); - - stk_classic::mesh::EntityId bc_node_id = 0; - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - bulk_data.change_entity_parts(*local_nodes[0], partvector); - bc_node_id = stk_classic::linsys::impl::entityid_to_int(local_nodes[0]->identifier()); - } - - bulk_data.modification_end(); - - stk_classic::mesh::Selector selector = ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ) & *meta_data.get_part("block_1"); - std::vector count; - stk_classic::mesh::count_entities(selector, bulk_data, count); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Create a fei Factory and stk_classic::linsys::LinearSystem object: - - fei::SharedPtr factory(new Factory_Trilinos(comm)); - - stk_classic::linsys::LinearSystem ls(comm, factory); - - stk_classic::linsys::add_connectivities(ls, element_rank, NODE_RANK, - *temperature_field, selector, bulk_data); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - int num_blocks = matgraph->getNumConnectivityBlocks(); - - STKUNIT_ASSERT_EQUAL( num_blocks, (int)1 ); - - ls.synchronize_mappings_and_structure(); - ls.create_fei_LinearSystem(); - - //put 0 throughout the matrix and 3 throughout the rhs: - fei::SharedPtr mat = ls.get_fei_LinearSystem()->getMatrix(); - ls.get_fei_LinearSystem()->getMatrix()->putScalar(0); - ls.get_fei_LinearSystem()->getRHS()->putScalar(3.0); - - //put 10 on the matrix diagonal to ensure it will be easy to solve later. - fei::SharedPtr vspace = ls.get_fei_LinearSystem()->getRHS()->getVectorSpace(); - int numLocalRows = vspace->getNumIndices_Owned(); - std::vector local_rows(numLocalRows); - vspace->getIndices_Owned(numLocalRows, &local_rows[0], numLocalRows); - - for(size_t i=0; isumIn(1, &local_rows[i], 1, &col, &coefPtr); - } - - //now we'll impose a dirichlet bc on our one-node bcpart: - stk_classic::linsys::dirichlet_bc(ls, bulk_data, bcpart, NODE_RANK, - *temperature_field, 0, 9.0); - - ls.finalize_assembly(); - - //now confirm that the rhs value for the equation corresponding to our - //bc node is 9.0: - - fei::SharedPtr rhsvec = ls.get_fei_LinearSystem()->getRHS(); - double rhs_bc_val = 0; - int bc_eqn_index = ls.get_DofMapper().get_global_index(NODE_RANK, - bc_node_id, *temperature_field); - rhsvec->copyOut(1, &bc_eqn_index, &rhs_bc_val); - - bool bc_val_is_correct = std::abs(rhs_bc_val - 9.0) < 1.e-13; - STKUNIT_ASSERT( bc_val_is_correct ); - - stk_classic::linsys::copy_vector_to_mesh( *rhsvec, ls.get_DofMapper(), bulk_data); - - stk_classic::mesh::Entity* bc_node = bulk_data.get_entity(NODE_RANK, local_nodes[0]->identifier()); - - stk_classic::mesh::FieldTraits::data_type* bc_node_data = stk_classic::mesh::field_data(*temperature_field, *bc_node); - - bool bc_node_data_is_correct = std::abs(bc_node_data[0] - 9.0) < 1.e-13; - STKUNIT_ASSERT( bc_node_data_is_correct ); - - //now make sure we get a throw if we use the wrong bulk-data (that doesn't have the - //temperature field defined) - STKUNIT_ASSERT_THROW(stk_classic::linsys::copy_vector_to_mesh( *rhsvec, ls.get_DofMapper(), bulk_data2), std::runtime_error); - - //obtain and zero the solution vector - fei::SharedPtr solnvec = ls.get_fei_LinearSystem()->getSolutionVector(); - solnvec->putScalar(0); - - //copy the vector of zeros into the mesh: - stk_classic::linsys::copy_vector_to_mesh( *solnvec, ls.get_DofMapper(), bulk_data); - - //assert that our bc node's data is now zero. - bc_node_data_is_correct = std::abs(bc_node_data[0] - 0) < 1.e-13; - STKUNIT_ASSERT( bc_node_data_is_correct ); - - //call the linear-system solve function. - //(note that when we add options to the solve method, we'll need to enhance this - //testing to exercise various specific solves.) - Teuchos::ParameterList params; - - int status = 0; - ls.solve(status, params); - - //copy the solution-vector into the mesh: - stk_classic::linsys::copy_vector_to_mesh( *solnvec, ls.get_DofMapper(), bulk_data); - - //now assert that the value 9 (bc value) produced by the solve is in this - //node's data. - //note that we use a loose tolerance, because the default solver tolerance - //is (I think) only 1.e-6. - bc_node_data_is_correct = std::abs(bc_node_data[0] - 9.0) < 1.e-6; - STKUNIT_ASSERT( bc_node_data_is_correct ); - STKUNIT_ASSERT(bc_node_data_is_correct); -} - -STKUNIT_UNIT_TEST(UnitTestLinsysFunctions, test2) -{ - static const size_t spatial_dimension = 3; - - MPI_Barrier( MPI_COMM_WORLD ); - MPI_Comm comm = MPI_COMM_WORLD; - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - - fill_utest_mesh_meta_data( fem_meta ); - - fill_utest_mesh_bulk_data( bulk_data ); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( bulk_data ); - - stk_classic::mesh::Selector selector = ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ) & *meta_data.get_part("block_1"); - std::vector count; - stk_classic::mesh::count_entities(selector, bulk_data, count); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Create a fei Factory and stk_classic::linsys::LinearSystem object: - - fei::SharedPtr factory(new Factory_Trilinos(comm)); - - stk_classic::linsys::LinearSystem ls(comm, factory); - - stk_classic::linsys::add_connectivities(ls, element_rank, NODE_RANK, - *temperature_field, selector, bulk_data); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - int num_blocks = matgraph->getNumConnectivityBlocks(); - - STKUNIT_ASSERT_EQUAL( num_blocks, (int)1 ); - - ls.synchronize_mappings_and_structure(); - ls.create_fei_LinearSystem(); - - //put 3 throughout the matrix and 3 throughout the rhs: - fei::SharedPtr mat = ls.get_fei_LinearSystem()->getMatrix(); - mat->putScalar(3.0); - ls.get_fei_LinearSystem()->getRHS()->putScalar(3.0); - - fei::SharedPtr rhsvec = ls.get_fei_LinearSystem()->getRHS(); - - stk_classic::linsys::scale_vector(2, *rhsvec); - stk_classic::linsys::scale_matrix(2, *mat); - - //now confirm that the rhs and matrix contain 6: - - bool result = confirm_vector_values(*rhsvec, 6); - STKUNIT_ASSERT( result ); - result = confirm_matrix_values(*mat, 6); - STKUNIT_ASSERT( result ); -} - -STKUNIT_UNIT_TEST(UnitTestLinsysFunctions, test3) -{ - static const size_t spatial_dimension = 3; - - MPI_Barrier( MPI_COMM_WORLD ); - MPI_Comm comm = MPI_COMM_WORLD; - //First create and fill MetaData and BulkData objects: - - const unsigned bucket_size = 100; //for a real application mesh, bucket_size would be much bigger... - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data, comm, bucket_size ); - - fill_utest_mesh_meta_data( fem_meta ); - - fill_utest_mesh_bulk_data( bulk_data ); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( bulk_data ); - - stk_classic::mesh::Selector selector = ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ) & *meta_data.get_part("block_1"); - std::vector count; - stk_classic::mesh::count_entities(selector, bulk_data, count); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - STKUNIT_ASSERT_EQUAL( count[element_rank], (unsigned)4 ); - STKUNIT_ASSERT_EQUAL( count[NODE_RANK], (unsigned)20 ); - - ScalarField* temperature_field = meta_data.get_field("temperature"); - - //Create a fei Factory and stk_classic::linsys::LinearSystem object: - - fei::SharedPtr factory(new Factory_Trilinos(comm)); - - stk_classic::linsys::LinearSystem ls(comm, factory); - - stk_classic::linsys::add_connectivities(ls, element_rank, NODE_RANK, - *temperature_field, selector, bulk_data); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - int num_blocks = matgraph->getNumConnectivityBlocks(); - - STKUNIT_ASSERT_EQUAL( num_blocks, (int)1 ); - - ls.synchronize_mappings_and_structure(); - ls.create_fei_LinearSystem(); - - //put 3 throughout the matrix and 3 throughout the rhs: - fei::SharedPtr mat = ls.get_fei_LinearSystem()->getMatrix(); - mat->putScalar(3.0); - ls.get_fei_LinearSystem()->getRHS()->putScalar(3.0); - - fei::SharedPtr rhsvec = ls.get_fei_LinearSystem()->getRHS(); - - stk_classic::linsys::scale_vector(2, *rhsvec); - stk_classic::linsys::scale_matrix(2, *mat); - - //now the rhs and matrix contain 6. - - //create another matrix and vector: - fei::SharedPtr mat2 = factory->createMatrix(matgraph); - fei::SharedPtr vec2 = factory->createVector(matgraph); - mat2->putScalar(3.0); - vec2->putScalar(3.0); - - //add 3*mat to mat2 - stk_classic::linsys::add_matrix_to_matrix(3.0, *mat, *mat2); - - //confirm that mat2 contains 21: - bool result = confirm_matrix_values(*mat2, 21); - STKUNIT_ASSERT(result); - - //add 3*rhsvec to vec2: - stk_classic::linsys::add_vector_to_vector(3.0, *rhsvec, *vec2); - - //confirm that vec2 contains 21: - result = confirm_vector_values(*vec2, 21); - STKUNIT_ASSERT(result); -} - -} // namespace stk_linsys_unit_tests diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 440f082689bb..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.cpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.cpp deleted file mode 100644 index c5082be99f68..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void fill_utest_mesh_meta_data(stk_classic::mesh::fem::FEMMetaData& fem_meta, bool use_temperature) -{ - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::Part& elem_block = fem_meta.declare_part( "block_1" , element_rank ); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( elem_block, hex_top ); - - const unsigned number_of_states = 1; - - if (use_temperature) { - ScalarField& temperature_field = fem_meta.declare_field( "temperature", number_of_states ); - stk_classic::mesh::put_field( temperature_field, NODE_RANK, elem_block ); - } - - ScalarField& pressure_field = fem_meta.declare_field( "pressure", number_of_states ); - VectorField& velocity_field = fem_meta.declare_field( "velocity", number_of_states ); - - stk_classic::mesh::put_field( pressure_field, element_rank, elem_block ); - stk_classic::mesh::put_field( velocity_field, NODE_RANK, elem_block ); - - fem_meta.commit(); -} - -// Assume the following mesh of 4 hex8 elements on the first processor (proc 0). -// -// Global node and element numbering -// 3 7 11 15 19 -// +-------+-------+-------+-------+ -// / / / / /| -// 4/ 8/ 12/ 16/ 20/ | -// +-------+-------+-------+-------+ | -// | | | | | +18 -// | e1 | e2 | e3 | e4 | / -// | | | | |/ -// +-------+-------+-------+-------+ -// 1 5 9 13 17 -// -// Local node numbering -// 8 7 -// +-------+ -// / /| -// 5/ 6/ | -// +-------+ | -// | | +3 -// | e1 | / -// | |/ -// +-------+ -// 1 2 -// -// A similar mesh will be created on the other processors, but using different elem-ids. -// i.e., proc 0 has elements 1 - 4, proc 1 has elements 5 - 8, and so on. 4 nodes will be -// shared between each neighboring pair of processors. -//---------------------------------------------------------------------- - -void elem_node_ids( stk_classic::mesh::EntityId elem_id , stk_classic::mesh::EntityId node_ids[] ) -{ - if ( elem_id == 0 ) { - std::cout << "use_case_1, elem_node_ids: ERROR, elem_id (" - << elem_id << ") must be greater than 0." << std::endl; - return; - } - - const unsigned base = ( elem_id - 1 ) * 4 ; - node_ids[0] = base + 1 ; - node_ids[1] = base + 5 ; - node_ids[2] = base + 6 ; - node_ids[3] = base + 2 ; - node_ids[4] = base + 4 ; - node_ids[5] = base + 8 ; - node_ids[6] = base + 7 ; - node_ids[7] = base + 3 ; -} - -void fill_utest_mesh_bulk_data(stk_classic::mesh::BulkData& bulk_data) -{ - bulk_data.modification_begin(); - - const unsigned num_elems = 4; - - //int numProcs = 1; - //numProcs = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - - int myProc = 0; - myProc = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - - stk_classic::mesh::EntityId elem_id = 1 + myProc*num_elems; - stk_classic::mesh::EntityId node_ids[ shards::Hexahedron<8>::node_count ]; - - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - stk_classic::mesh::Part& elem_block = *(fem_meta.get_part( "block_1" )); - - for(unsigned i = 0; i& mesh_buckets = mesh.buckets(element_rank); - - std::vector part_buckets; - stk_classic::mesh::Selector select_owned(stk_classic::mesh::MetaData::get(mesh).locally_owned_part()); - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - int field_id = dof_mapper.get_field_id(field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - int pattern_id = matgraph->definePattern(num_nodes_per_elem, NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - fei::SharedPtr rhs = ls.get_fei_LinearSystem()->getRHS(); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix->sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs->sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } -} - -void assemble_elem_matrices_and_vectors(stk_classic::mesh::BulkData& mesh, ScalarField& field, stk_classic::linsys::DofMapper& dof_mapper, fei::Matrix& matrix, fei::Vector& rhs) -{ - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - const std::vector& mesh_buckets = mesh.buckets(element_rank); - - std::vector part_buckets; - stk_classic::mesh::Selector select_owned(stk_classic::mesh::MetaData::get(mesh).locally_owned_part()); - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - int field_id = dof_mapper.get_field_id(field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - fei::SharedPtr matgraph = matrix.getMatrixGraph(); - int pattern_id = matgraph->definePattern(num_nodes_per_elem, NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix.sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs.sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } -} - diff --git a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.hpp b/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.hpp deleted file mode 100644 index f4551937b88f..000000000000 --- a/packages/stk/stk_classic/stk_linsys/unit_tests/UnitTest_helpers.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_linsys_unit_tests_UnitTest_helpers_hpp -#define stk_linsys_unit_tests_UnitTest_helpers_hpp - -#include -#include - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void fill_utest_mesh_meta_data(stk_classic::mesh::fem::FEMMetaData& fem_meta, bool use_temperature=true); -void fill_utest_mesh_bulk_data(stk_classic::mesh::BulkData& bulk_data); - -void assemble_elem_matrices_and_vectors(stk_classic::mesh::BulkData& mesh, ScalarField& field, stk_classic::linsys::LinearSystemInterface& ls); - -void assemble_elem_matrices_and_vectors(stk_classic::mesh::BulkData& mesh, ScalarField& field, stk_classic::linsys::DofMapper& dof_mapper, fei::Matrix& matrix, fei::Vector& rhs); - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/CMakeLists.txt deleted file mode 100644 index f943c6ca13ab..000000000000 --- a/packages/stk/stk_classic/stk_mesh/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ - -ADD_SUBDIRECTORY(stk_mesh) - - -# The use cases and unit test currently depend on boost::program_options through -# lib stk_util_use_cases. -IF ( TPL_Enable_BoostLib AND ${PACKAGE_NAME}_ENABLE_TESTS) - TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - TRIBITS_ADD_TEST_DIRECTORIES(use_cases) -ENDIF() - - diff --git a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile b/packages/stk/stk_classic/stk_mesh/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.input b/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.input deleted file mode 100644 index 66372da07549..000000000000 --- a/packages/stk/stk_classic/stk_mesh/doc/Doxyfile.input +++ /dev/null @@ -1,20 +0,0 @@ -#BANNER @copydoc stk_mesh_banner -#HOWTO @copydoc stk_mesh_howto - -# Note, any path you set here will have to be set twice; once for when doxygen -# is run from this directory, and once for when doxygen is run from the -# TPLs_src/Trilinos/packages/stk/doc directory. - -# Put local appends here! Note: Please only put append-type changes -# (IE, VAR += CHANGE) in this section. All the STK products must -# use the same configuration because, when doxygen is run from stk/doc -# to assemble HTML for the entire STK, any configuration overrides -# that happened here would affect the html generation for ALL the -# STK products. - -EXAMPLE_PATH += ../use_cases \ - ../stk_mesh/use_cases - -INPUT += ../stk_mesh/doc/index.dox \ - ../stk_mesh/stk_mesh \ - ../stk_mesh/unit_tests diff --git a/packages/stk/stk_classic/stk_mesh/doc/index.dox b/packages/stk/stk_classic/stk_mesh/doc/index.dox deleted file mode 100644 index 160addd7eca1..000000000000 --- a/packages/stk/stk_classic/stk_mesh/doc/index.dox +++ /dev/null @@ -1,263 +0,0 @@ -/** - * \page stk_mesh_banner Sierra Toolkit Mesh - * - * \ref stk_mesh_module "Sierra Toolkit Mesh" - *

- * The Sierra Toolkit Mesh supports parallel distributed, - * heterogeneous, and dynamically modifiable unstructured meshes - * with computational field data. - *

- * - * \addtogroup stk_mesh_module - * \{ - * - * \page stk_mesh_howto Mesh How To ... - * - * Sierra Mesh - * - * - \ref stk_mesh_example "Simple Mesh Example"
- * - * \page stk_mesh_documentation STK Mesh Documentation... - * - * STK Mesh Documentation - * - * Getting Started - * - \ref stk_mesh_first_steps "First Steps"
- * - \ref stk_mesh_tutorials_examples "Tutorials and Examples"
- * - \ref stk_mesh_demonstrations "Demonstrations"
- * - \ref stk_mesh_installation "Installation"
- * - * API Reference - * - \ref stk_mesh_class_function_documentation "Class and Function Documentation"
- * - \ref stk_mesh_modules "Modules and Extensions to STK"
- * - \ref stk_mesh_tutorials_examples "Tutorials and Examples"
- * - \ref stk_mesh_how_to_best_practices "How-To's and Best Practices"
- * - \ref stk_mesh_vocabulary "Vocabulary"
- * - \ref stk_mesh_whats_new "What's New in STK"
- * - * Working with STK (include development issues here?) - * - \ref stk_mesh_building "Building STK mesh"
- * - \ref stk_mesh_running "Running STK mesh"
- * - \ref stk_mesh_testing_and_debugging "Unit Testing and Debugging"
- * - * Community and Resources - * - \ref stk_mesh_online_resources "Online Resources"
- * - \ref stk_mesh_faq "FAQ"
- * - \ref stk_mesh_developers "Developers"
- * - \ref stk_mesh_support_training_services "Support, Training and Services"
- * - * Contributing - * - \ref stk_mesh_report_bugs_make_suggestions "Report Bugs and Make Suggestions"
- * - \ref stk_mesh_repository "Repository"
- * - \ref stk_mesh_credits "Credits"
- * - * Licenses - * - \ref stk_mesh_license_for_STK "BSD"
- * - \ref stk_mesh_licenses_in_STK "Licenses Used in STK"
- * - * \page stk_mesh_first_steps First Steps - * - * \page stk_mesh_demonstrations Demonstrations - * - Internal Force Calculation (Use Case 14) - * - Gears Demonstration & video - * - * \page stk_mesh_installation Installation - * - Use the Trilinos cmake installation instructions to install stk_mesh. - * - * \page stk_mesh_class_function_documentation Class and Function Documentation - * This page includes information on the classes and functions in STK. - * This page also includes a description of the namespace conventions in STK. - * This page also includes a description of the global objects in STK. - * - * \page stk_mesh_modules Modules and Extensions to STK - * This page explains the various STK modules and extension points in STK. - * - * \page stk_mesh_tutorials_examples Tutorials and Examples - * \ingroup stk_mesh_module - * - \ref stk_mesh_use_case_1 "Use Case 1" - * - * \page stk_mesh_how_to_best_practices How-To's and Best Practices - * - How-To's - * - How to create a fast-gather for nodal fields from an element? - * - How do I read from an exodus file? - * - How do I create a mesh by hand? - * - How do I create full topological adjacency entities in stk_mesh? - * - Design Decisions: - * - Why are parts used to determine bucket decomposition? - * - Why are attributes const? - * - Why is modified status propagated upward through relations? - * - Why can't we add parts after meta data is committed? - * - Why are attributes settable on meta data for parts, but you can only get them off of the parts? - * - etc. - * - Free Function Philosophy: - * - We endorse the use of free functions that provide the following benefits while outweighing the following disadvantages. - * - Benefits: - * - Provide extension without modification to the API in cooperation with the Open Closed Principle - * - Help encourage the Single Responsibility Principle and cohesion through a minimally defined API - * - Disadvantages: - * - Too many ways to do things - * - Too hard to find where the free functions are defined - * - Often belong in the user-space - * - * \page stk_mesh_vocabulary Vocabulary - * This page explains the vocabulary used in stk_mesh. - * - * \page stk_mesh_building Building STK mesh - * - Sierra (bake or bjam) - * - Trilinos (cmake) - * - * \page stk_mesh_running Running STK mesh - * - * \page stk_mesh_testing_and_debugging Unit Testing and Debugging - *

To run unit tests

- * - Build the stk_mesh product and look for the unit test (name/loc will depend on if you build Sierra-style or Trilinos-style). - * - You can run the exectuble in serial or in parallel with MPI - * - You can select specific unit-tests to run using the --gtest_filter flag - * - Example, to run all Entity unit tests: -- --gtest_filter=UnitTestEntity.* - * - Example, to run a specific unit test: -- --gtest_filter=UnitTestEntity.testEntityKey - * - *

To debug unit tests

- * - A unit-test can fail for a number of reasons - * - One of the macro assertions has failed; gtest will print the name -of the failing unit test, line file and line number of the failing -check, and some details about the failing check. - * - An uncaught exception was raised; the exception will be printed -along with a stacktrace. Since Gtest prints test names as it starts -them, it should be obvious which test caused the problem. - * - The program crashed, probably due to a segfault. Since Gtest -prints test names as it starts them, it should be obvious which test -caused the problem. - * - * - When debugging, it is usually best to only run the failing test (use gtest_filter to select the failing test) - * - * - Serial debugging can be done in gdb or totalview - * - GDB - * - gdb - * - % run -- --gtest_filter= - * - Totalview - * - mpirun -np 1 -tv -- --gtest_filter= - * - * - Parallel debugging should be done with totalview, but it is possible to do it with GDB as well - * - GDB - * - How to set this up is beyond the scope of this document. A good description can be found here: http://www.open-mpi.org/faq/?category=debugging - * - Totalview - * - mpirun -np -tv -- --gtest_filter= - * - To find where an exception is being generated, a common technique is to set a breakpoint at __cxa_throw - * - * - Debugging memory problems can be done with valgrind - * - In serial: valgrind -- --gtest_filter= - * - In parallel it is more difficult - * - If you have access to the sntools, you can use mpigrind: - * - mpigrind mpirun -np -- --gtest_filter= - * - Otherwise, you'll have to create a script that runs the test under valgrind and then run mpirun on that script. - * - *

Unit test development

- * - Individual Unit Tests: - * - Test one part of functionality at a time and put each test in its own STKUNIT_UNIT_TEST macro. - * - Name each test with a descriptive name. - * - Aim for short and concise unit tests that each fit on a single page - * - Use descriptive names for variables - * - Name/label all magic-numbers including 0 and 1. - * - Aim for positive logic in testing, try to be obvious - * - If using a complex fixture, use ascii art to document the fixture - * - If the unit_test is complex, have a comment at the top of the unit test describing what you're testing and why - * - * - General Notes: - * - Remember that these tests will be read 10x more than they're written (especially during refactoring) - * - Place code in namespace stk_classic::unit_test - * - Use namespaces judiciously to improve readability ( Prefer: using stk_classic::mesh::MetaData; over using namespace stk_classic; and namespace stk_classic { ) - * - Avoid “unsigned” and use pre-defined typedefs instead (EntityRank, size_t, PartOrdinal, FieldOrdinal, etc…) - * - * - STKUNIT macros for verifying results inside STKUNIT_UNIT_TEST macro: - * - STKUNIT_EXPECT_* vs. STKUNIT_ASSERT_*, the ASSERT will stop the unit test at this line on failure. - * - Boolean values: STKUNIT_ASSERT_[EQ, NE, LE, LT, GE, GT, TRUE, FALSE] - * - String values: STKUNIT_ASSERT_[STREQ, STRNE, STRCASEEQ, STRCASENE] (CASE means ignore case) - * - Exceptions: STKUNIT_ASSERT_[THROW, NO_THROW] - * - Floating point values: STKUNIT_ASSERT_[DOUBLE_EQ, NEAR] - - *

Software Architecture

- * - The site Resources for Software Architects has excellent free documentation. - * - Domain Modeling expresses the requirements for software within a -conceptual model of the problem domain. Such a model spans the -software’s requirements, architectural design (the decomposition of -software into architectural components and relationships among those -components), and key concepts of the software design. - * - *

Should I continue to copy verbatim out of the wiki?

- * - * \page stk_mesh_online_resources Online Resources - * - * \page stk_mesh_faq FAQ - * - How is Stk_mesh different from Moab? - * - How is Stk_mesh different from libMesh? - * - * \page stk_mesh_developers Developers - * - Sierra Tool-Kit Developers (in alphabetical order) - * - Dave Baur - * - Todd Coffey - * - Carter Edwards - * - Jim Foucar - * - Russell Hooper - * - James Overfelt - * - Greg Sjaardema - * - Dan Sunderland - * - Alan Williams - * - Sierra Tool-Kit Product Owner: - * - Mike Glass - * - * \page stk_mesh_support_training_services Support, Training and Services - * - For support, contact the Sierra Tool-Kit user email list: - * - Our Tutorial and Training materials are currently under development - * - For Services, please contact our product owner: Mike Glass - * - * \page stk_mesh_report_bugs_make_suggestions Report Bugs and Make Suggestions - * - To report bugs or make suggestions, please send them to - * - * \page stk_mesh_repository Repository - * - The Sierra Tool-Kit repository is located at software.sandia.gov - * - * \page stk_mesh_credits Credits - * - The following people have contributed to the Sierra Tool-Kit (in alphabetical order): - * - Roscoe Bartlett - * - Dave Baur - * - Noel Belcourt - * - Bill Cochran - * - Todd Coffey - * - Stefan Domino - * - Carter Edwards - * - Jim Foucar - * - Mike Glass - * - Russell Hooper - * - Elijah Newren - * - James Overfelt - * - Kendall Pierson - * - Greg Sjaardema - * - Dan Sunderland - * - Alan Williams - * - * \page stk_mesh_license_for_STK BSD - * - The Sierra Tool-Kit is currently distributed with Trilinos under the BSD license. - * - * \page stk_mesh_use_case_1 Use Case 1 - * \ingroup stk_mesh_module - * This is a hello world example for how to construct a stk mesh. - * \dontinclude UseCase_1.hpp - * First, these two headers need to be included: - * \skip doxygen tutorial start #includes - * \until end code snippet - * Then a simple class is created which contains MetaData and BulkData: - * \skip UseCase_1_Mesh - * \until }; - * Second, we have the definition file with the bare minimum of includes: - * \dontinclude UseCase_1.cpp - * \skip doxygen tutorial start #includes - * \until end code snippet - * And here we have a small function which creates the vector of rank - * names for MetaData. - * \skip use_case_1_rank_names - * \until } - * And finally we have the constructor which sets up MetaData and BulkData - * in a very trivial way: - * \skip doxygen tutorial start source - * \until end code snippet - * \} */ diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/stk_mesh/CMakeLists.txt deleted file mode 100644 index 1cd144db71d9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -ADD_SUBDIRECTORY(base) -ADD_SUBDIRECTORY(fem) -IF (${PACKAGE_NAME}_ENABLE_TESTS) - ADD_SUBDIRECTORY(fixtures) -ENDIF(${PACKAGE_NAME}_ENABLE_TESTS) - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.cpp deleted file mode 100644 index 4ba8b4e5b4a9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -bool bucket_part_equal( const unsigned * lhs , const unsigned * rhs ) -{ - bool result = true ; - { - const unsigned * const end_lhs = lhs + *lhs ; - while ( result && end_lhs != lhs ) { - result = *lhs == *rhs ; - ++lhs ; ++rhs ; - } - } - return result ; -} - -inline -bool bucket_key_less( const unsigned * lhs , const unsigned * rhs ) -{ - const unsigned * const last_lhs = lhs + ( *lhs < *rhs ? *lhs : *rhs ); - while ( last_lhs != lhs && *lhs == *rhs ) { ++lhs ; ++rhs ; } - return *lhs < *rhs ; -} - -// The part count and part ordinals are less -bool BucketLess::operator()( const Bucket * lhs_bucket , - const unsigned * rhs ) const -{ return bucket_key_less( lhs_bucket->key() , rhs ); } - -bool BucketLess::operator()( const unsigned * lhs , - const Bucket * rhs_bucket ) const -{ return bucket_key_less( lhs , rhs_bucket->key() ); } - -//---------------------------------------------------------------------- - -bool Bucket::member( const Part & part ) const -{ - const unsigned * const i_beg = key() + 1 ; - const unsigned * const i_end = key() + key()[0] ; - - const unsigned ord = part.mesh_meta_data_ordinal(); - const unsigned * const i = std::lower_bound( i_beg , i_end , ord ); - - return i_end != i && ord == *i ; -} - -bool Bucket::member_all( const PartVector & parts ) const -{ - const unsigned * const i_beg = key() + 1 ; - const unsigned * const i_end = key() + key()[0] ; - - const PartVector::const_iterator ip_end = parts.end(); - PartVector::const_iterator ip = parts.begin() ; - - bool result_all = true ; - - for ( ; result_all && ip_end != ip ; ++ip ) { - const unsigned ord = (*ip)->mesh_meta_data_ordinal(); - const unsigned * const i = std::lower_bound( i_beg , i_end , ord ); - result_all = i_end != i && ord == *i ; - } - return result_all ; -} - -bool Bucket::member_any( const PartVector & parts ) const -{ - const unsigned * const i_beg = key() + 1 ; - const unsigned * const i_end = key() + key()[0] ; - - const PartVector::const_iterator ip_end = parts.end(); - PartVector::const_iterator ip = parts.begin() ; - - bool result_none = true ; - - for ( ; result_none && ip_end != ip ; ++ip ) { - const unsigned ord = (*ip)->mesh_meta_data_ordinal(); - const unsigned * const i = std::lower_bound( i_beg , i_end , ord ); - result_none = i_end == i || ord != *i ; - } - return ! result_none ; -} - -bool Bucket::member_any( const OrdinalVector & parts ) const -{ - const unsigned * const i_beg = key() + 1 ; - const unsigned * const i_end = key() + key()[0] ; - - const OrdinalVector::const_iterator ip_end = parts.end(); - OrdinalVector::const_iterator ip = parts.begin() ; - - bool result_none = true ; - - for ( ; result_none && ip_end != ip ; ++ip ) { - const unsigned ord = *ip; - const unsigned * const i = std::lower_bound( i_beg , i_end , ord ); - result_none = i_end == i || ord != *i ; - } - return ! result_none ; -} - -//---------------------------------------------------------------------- - -bool has_superset( const Bucket & bucket, const unsigned & ordinal ) -{ - std::pair - part_ord = bucket.superset_part_ordinals(); - - part_ord.first = - std::lower_bound( part_ord.first , part_ord.second , ordinal ); - - return part_ord.first < part_ord.second && ordinal == *part_ord.first ; -} - -bool has_superset( const Bucket & bucket , const Part & p ) -{ - const unsigned ordinal = p.mesh_meta_data_ordinal(); - return has_superset(bucket,ordinal); -} - -bool has_superset( const Bucket & bucket , const PartVector & ps ) -{ - const std::pair - part_ord = bucket.superset_part_ordinals(); - - bool result = ! ps.empty(); - - for ( PartVector::const_iterator - i = ps.begin() ; result && i != ps.end() ; ++i ) { - - const unsigned ordinal = (*i)->mesh_meta_data_ordinal(); - - const unsigned * iter = - std::lower_bound( part_ord.first , part_ord.second , ordinal ); - - result = iter < part_ord.second && ordinal == *iter ; - } - return result ; -} - -void Bucket::supersets( PartVector & ps ) const -{ - const MetaData & mesh_meta_data = MetaData::get( *this ); - - std::pair - part_ord = superset_part_ordinals(); - - ps.resize( part_ord.second - part_ord.first ); - - for ( unsigned i = 0 ; - part_ord.first < part_ord.second ; ++(part_ord.first) , ++i ) { - ps[i] = & mesh_meta_data.get_part( * part_ord.first ); - } -} - -void Bucket::supersets( OrdinalVector & ps ) const -{ - std::pair - part_ord = superset_part_ordinals(); - - ps.resize( part_ord.second - part_ord.first ); - - for ( unsigned i = 0 ; - part_ord.first < part_ord.second ; ++(part_ord.first) , ++i ) { - ps[i] = *part_ord.first; - } -} - -//---------------------------------------------------------------------- - -bool field_data_valid( const FieldBase & f , - const Bucket & k , - unsigned ord , - const char * required_by ) -{ - const MetaData * const k_mesh_meta_data = & MetaData::get(k); - const MetaData * const f_mesh_meta_data = & MetaData::get(f); - const bool ok_mesh_meta_data = k_mesh_meta_data == f_mesh_meta_data ; - const bool ok_ord = ord < k.size() ; - const bool exists = ok_mesh_meta_data && ok_ord && - NULL != field_data( f , k.begin() ); - - if ( required_by && ! exists ) { - std::ostringstream msg_begin ; - msg_begin << "For args: " ; - msg_begin << f << " , " ; - msg_begin << k << " , " ; - msg_begin << ord << " , " ; - msg_begin << required_by ; - msg_begin << "; operation FAILED with " ; - ThrowErrorMsgIf( ! ok_mesh_meta_data, - msg_begin.str() << " different MetaData"); - ThrowErrorMsgIf( ! ok_ord, msg_begin.str() << - " Ordinal " << ord << " >= " << " size " << k.size()); - ThrowErrorMsg( msg_begin.str() << " no data"); - } - - return exists ; -} - -//---------------------------------------------------------------------- -bool Bucket::assert_correct() const { - // test equivalent() method - const Bucket* bucket = this; - const Bucket * first = m_bucketImpl.first_bucket_in_family(); - if (!first || ! bucket->equivalent(*first) || ! first->equivalent(*bucket) ) - return false; - - // other tests... - - return true; -} - -//---------------------------------------------------------------------- - -std::ostream & operator << ( std::ostream & s , const Bucket & k ) -{ - const MetaData & mesh_meta_data = MetaData::get(k); - const std::string & entity_rank_name = - k.entity_rank() == InvalidEntityRank ? "Nil" : - mesh_meta_data.entity_rank_names()[ k.entity_rank() ]; - - PartVector parts ; k.supersets( parts ); - - s << "Bucket( " << entity_rank_name << " : " ; - for ( PartVector::iterator i = parts.begin() ; i != parts.end() ; ++i ) { - s << (*i)->name() << " " ; - } - s << ")" ; - - return s ; -} - - -std::ostream & -print( std::ostream & os , const std::string & indent , const Bucket & bucket ) -{ - const MetaData & mesh_meta_data = MetaData::get(bucket); - const std::string & entity_rank_name = - bucket.entity_rank() == InvalidEntityRank ? "Nil" : - mesh_meta_data.entity_rank_names()[ bucket.entity_rank() ]; - - const std::pair - part_ids = bucket.superset_part_ordinals(); - - os << "Bucket(" << std::endl << indent << "Part intersection {" ; - - for ( const unsigned * i = part_ids.first ; i < part_ids.second ; ++i ) { - const Part & part = mesh_meta_data.get_part( *i ); - os << " " << part.name(); - } - - os << " }" << std::endl << indent << entity_rank_name << " members {" ; - - for ( unsigned j = 0 ; j < bucket.size() ; ++j ) { - const EntityId id = bucket[j].identifier(); - os << " " << id ; - } - os << " } )" << std::endl ; - - return os ; -} - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.hpp deleted file mode 100644 index f4eef3e247fe..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Bucket.hpp +++ /dev/null @@ -1,299 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_Bucket_hpp -#define stk_mesh_Bucket_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -//---------------------------------------------------------------------- - -#ifdef SIERRA_MIGRATION - -namespace sierra { -namespace Fmwk { - -class MeshBulkData; - -} -} - - -#endif - -namespace stk_classic { -namespace mesh { - -namespace impl { -class BucketRepository; -} // namespace impl - - -/** \addtogroup stk_mesh_module - * \{ - */ - -/** \brief Print the \ref stk_classic::mesh::Part "part" names - * for which this bucket is a subset. - */ -std::ostream & operator << ( std::ostream & , const Bucket & ); - -/** \brief Print the parts and entities of this bucket */ -std::ostream & -print( std::ostream & , const std::string & indent , const Bucket & ); - -// The part count and parts are equal -bool bucket_part_equal( const unsigned * lhs , const unsigned * rhs ); - -//---------------------------------------------------------------------- -/** \brief Is this bucket a subset of the given - * \ref stk_classic::mesh::Part "part" - */ -bool has_superset( const Bucket & , const Part & p ); - -/** \brief Is this bucket a subset of the given - * \ref stk_classic::mesh::Part "part" by partID - */ -bool has_superset( const Bucket & , const unsigned & ordinal ); - -/** \brief Is this bucket a subset of all of the given - * \ref stk_classic::mesh::Part "parts" - */ -bool has_superset( const Bucket & , const PartVector & ); - - -//---------------------------------------------------------------------- -/** \brief A container for the \ref stk_mesh_field_data "field data" - * of a homogeneous collection of - * \ref stk_classic::mesh::Entity "entities". - * - * The entities are homogeneous in that they are of the same entity type - * and are members of the same of parts. - */ -class Bucket { -private: - friend class impl::BucketRepository; - friend class impl::BucketImpl; - - impl::BucketImpl m_bucketImpl; - -#ifdef SIERRA_MIGRATION - const void* m_fmwk_mesh_bulk_data; -#endif - -public: - - //-------------------------------- - // Container-like types and methods: - - typedef boost::indirect_iterator iterator ; - - /** \brief Beginning of the bucket */ - inline iterator begin() const { return iterator(m_bucketImpl.begin()); } - - /** \brief End of the bucket */ - inline iterator end() const { return iterator(m_bucketImpl.end()); } - - /** \brief Number of entities associated with this bucket */ - size_t size() const { return m_bucketImpl.size() ; } - - /** \brief Capacity of this bucket */ - size_t capacity() const { return m_bucketImpl.capacity() ; } - - /** \brief Query the i^th entity */ - Entity & operator[] ( size_t i ) const { return m_bucketImpl[i] ; } - - /** \brief Query the size of this field data specified by FieldBase */ - unsigned field_data_size(const FieldBase & field) const - { return m_bucketImpl.field_data_size(field); } - - /** \brief Query the stride of this field data specified by FieldBase */ - const FieldBase::Restriction::size_type * field_data_stride( const FieldBase & field ) const - { return m_bucketImpl.field_data_stride(field); } - - /** \brief Query the location of this field data specified by FieldBase and Entity */ - unsigned char * field_data_location( const FieldBase & field, const Entity & entity ) const - { return m_bucketImpl.field_data_location(field,entity); } - - /** \brief Query the location of this field data specified by FieldBase and Entity-bucket-ordinal */ - unsigned char * field_data_location( const FieldBase & field, unsigned ordinal ) const - { return m_bucketImpl.field_data_location(field, ordinal); } - - /** \brief Query the location of this field data specified by FieldBase and Entity-bucket-ordinal - This method should only be called if the caller knows that the field exists on the bucket. - In an attempt to improve performance, this method skips the if-test that is normally done. - */ - unsigned char * fast_field_data_location( const FieldBase & field, unsigned ordinal ) const - { return m_bucketImpl.fast_field_data_location(field, ordinal); } - - /** \brief Query the location of this field data specified by FieldBase */ - unsigned char * field_data_location( const FieldBase & field ) const - { return m_bucketImpl.field_data_location(field); } - - /** \brief Query the location of this field data specified by FieldBase and Entity */ - template< class field_type > - typename FieldTraits< field_type >::data_type * - field_data( const field_type & field , const Entity & entity ) const - { return m_bucketImpl.field_data(field,entity.bucket_ordinal()); } - - //-------------------------------- - /** \brief The \ref stk_classic::mesh::BulkData "bulk data manager" - * that owns this bucket. - */ - BulkData & mesh() const { return m_bucketImpl.mesh(); } - - /** \brief Type of entities in this bucket */ - unsigned entity_rank() const { return m_bucketImpl.entity_rank(); } - - /** \brief This bucket is a subset of these \ref stk_classic::mesh::Part "parts" */ - void supersets( PartVector & ) const ; - void supersets( OrdinalVector & ) const ; - - //-------------------------------- - /** \brief Bucket is a subset of the given part */ - bool member( const Part & ) const ; - - /** \brief Bucket is a subset of all of the given parts */ - bool member_all( const PartVector & ) const ; - bool member_all( const OrdinalVector & ) const ; - - /** \brief Bucket is a subset of any of the given parts */ - bool member_any( const PartVector & ) const ; - bool member_any( const OrdinalVector & ) const ; - - //-------------------------------- - /** Query bucket's supersets' ordinals. */ - std::pair - superset_part_ordinals() const { return m_bucketImpl.superset_part_ordinals() ; } - - /** \brief Equivalent buckets have the same parts - */ - bool equivalent( const Bucket& b ) const { - return m_bucketImpl.equivalent(b.m_bucketImpl); - } - -#ifndef DOXYGEN_COMPILE - const unsigned * key() const { return m_bucketImpl.key() ; } -#endif /* DOXYGEN_COMPILE */ - - /** \brief The allocation size, in bytes, of this bucket */ - unsigned allocation_size() const { return m_bucketImpl.allocation_size() ; } - - /** \brief A method to assist in unit testing - accesses private data as necessary. */ - bool assert_correct() const; - -#ifdef SIERRA_MIGRATION - typedef std::pair EntityRange; - - bool is_empty() const { return size() == 0; } - - const sierra::Fmwk::MeshBulkData* get_bulk_data() const - { - return static_cast(m_fmwk_mesh_bulk_data); - } - - template - void set_bulk_data(const T* bulk_ptr) { m_fmwk_mesh_bulk_data = bulk_ptr; } -#endif - -private: - /** \brief The \ref stk_classic::mesh::BulkData "bulk data manager" - * that owns this bucket. - */ - BulkData & bulk_data() const { return m_bucketImpl.mesh(); } - - // Only reason to define this at all is to ensure it's private - ~Bucket() {} - - Bucket(); - Bucket( const Bucket & ); - Bucket & operator = ( const Bucket & ); - - Bucket( BulkData & arg_mesh , - EntityRank arg_entity_rank, - const std::vector & arg_key, - size_t arg_capacity - ); - - friend class ::stk_classic::mesh::BulkData; -}; - - -struct BucketLess { - bool operator()( const Bucket * lhs_bucket , const unsigned * rhs ) const ; - bool operator()( const unsigned * lhs , const Bucket * rhs_bucket ) const ; -}; - - -inline -std::vector::iterator -lower_bound( std::vector & v , const unsigned * key ) -{ return std::lower_bound( v.begin() , v.end() , key , BucketLess() ); } - -inline -Bucket::Bucket( BulkData & arg_mesh , - EntityRank arg_entity_rank, - const std::vector & arg_key, - size_t arg_capacity - ) - : m_bucketImpl(arg_mesh,arg_entity_rank,arg_key,arg_capacity) -{} - -/** \} */ - -inline -bool Bucket::member_all( const OrdinalVector& parts ) const -{ - const unsigned * const i_beg = key() + 1 ; - const unsigned * const i_end = key() + key()[0] ; - - const OrdinalVector::const_iterator ip_end = parts.end(); - OrdinalVector::const_iterator ip = parts.begin() ; - - bool result_all = true ; - - for ( ; result_all && ip_end != ip ; ++ip ) { - const unsigned ord = *ip; - result_all = contains_ordinal(i_beg, i_end, ord); - } - return result_all ; -} - -struct To_Ptr : std::unary_function -{ - Entity* operator()(Entity& entity) const - { - return &entity; - } -}; - -// Sometimes, we want a bucket-iterator to dereference to an Entity* -typedef boost::transform_iterator BucketPtrIterator; - -typedef Bucket::iterator BucketIterator; - -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.cpp deleted file mode 100644 index 9f4a830863e8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -namespace { - -std::vector< parallel::DistributedIndex::KeySpan> -convert_entity_keys_to_spans( const MetaData & meta ) -{ - // Make sure the distributed index can handle the EntityKey - - enum { OK = StaticAssert< - SameType< EntityKey::raw_key_type, - parallel::DistributedIndex::KeyType >::value >::OK }; - - // Default constructed EntityKey has all bits set. - - const EntityKey invalid_key ; - const EntityId min_id = 1 ; - const EntityId max_id = invalid_key.id(); - - const size_t rank_count = meta.entity_rank_count(); - - std::vector< parallel::DistributedIndex::KeySpan> spans( rank_count ); - - for ( size_t rank = 0 ; rank < rank_count ; ++rank ) { - EntityKey key_min( rank , min_id ); - EntityKey key_max( rank , max_id ); - spans[rank].first = key_min.raw_key(); - spans[rank].second = key_max.raw_key(); - } - - return spans ; -} - -void ensure_part_superset_consistency( const Entity& entity ) -{ - std::ostringstream errs; - PartVector parts; - Bucket& bucket = entity.bucket(); - bucket.supersets(parts); - BOOST_FOREACH(Part* part, parts) { - const PartVector& supersets = part->supersets(); - BOOST_FOREACH(Part* superset, supersets) { - if (!bucket.member(*superset)) { - errs << " Due to being a member part " << part->name() << ", should have been a member of " << superset->name() << std::endl; - } - } - } - ThrowRequireMsg( errs.str() == "", - "Entity " << print_entity_key(entity) << " has bad part list:\n" << errs.str() ); -} - -} - -//---------------------------------------------------------------------- - -BulkData::BulkData( MetaData & mesh_meta_data , - ParallelMachine parallel , - unsigned bucket_max_size , - bool use_memory_pool ) - : m_entities_index( parallel, convert_entity_keys_to_spans(mesh_meta_data) ), - m_entity_repo(use_memory_pool), - m_bucket_repository( - *this, bucket_max_size, - mesh_meta_data.entity_rank_count(), - m_entity_repo - ), - m_entity_comm(), - m_ghosting(), - - m_mesh_meta_data( mesh_meta_data ), - m_parallel_machine( parallel ), - m_parallel_size( parallel_machine_size( parallel ) ), - m_parallel_rank( parallel_machine_rank( parallel ) ), - m_sync_count( 0 ), - m_sync_state( MODIFIABLE ), - m_meta_data_verified( false ), - m_optimize_buckets(false), - m_mesh_finalized(false) -{ - create_ghosting( "shared" ); - create_ghosting( "shared_aura" ); - - m_sync_state = SYNCHRONIZED ; -} - -BulkData::~BulkData() -{ - try { - while ( ! m_ghosting.empty() ) { - delete m_ghosting.back(); - m_ghosting.pop_back(); - } - } catch(...){} - - try { m_entity_comm.clear(); } catch(...){} - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void BulkData::require_ok_to_modify() const -{ - ThrowRequireMsg( m_sync_state != SYNCHRONIZED, - "NOT in the ok-to-modify state" ); -} - -void BulkData::require_entity_owner( const Entity & entity , - unsigned owner ) const -{ - const bool error_not_owner = owner != entity.owner_rank() ; - - ThrowRequireMsg( !error_not_owner, - "Entity " << print_entity_key(entity) << " owner is " << - entity.owner_rank() << ", expected " << owner); -} - -void BulkData::require_good_rank_and_id(EntityRank ent_rank, EntityId ent_id) const -{ - const size_t rank_count = m_mesh_meta_data.entity_rank_count(); - const bool ok_id = entity_id_valid(ent_id); - const bool ok_rank = ent_rank < rank_count ; - - ThrowRequireMsg( ok_rank, - "Bad key rank: " << ent_rank << " for id " << ent_id ); - - ThrowRequireMsg( ok_id, "Bad key id for key: " << - print_entity_key(m_mesh_meta_data, EntityKey(ent_rank, ent_id) ) ); -} - -void BulkData::require_metadata_committed() const -{ - ThrowRequireMsg( m_mesh_meta_data.is_commit(), "MetaData not committed." ); -} - -//---------------------------------------------------------------------- - -bool BulkData::modification_begin() -{ - Trace_("stk_classic::mesh::BulkData::modification_begin"); - - parallel_machine_barrier( m_parallel_machine ); - - ThrowRequireMsg( m_mesh_finalized == false, "Unable to modifiy, BulkData has been finalized."); - - if ( m_sync_state == MODIFIABLE && m_mesh_finalized == false ) return false ; - - if ( ! m_meta_data_verified ) { - require_metadata_committed(); - - if (parallel_size() > 1) { - verify_parallel_consistency( m_mesh_meta_data , m_parallel_machine ); - } - - m_meta_data_verified = true ; - - m_bucket_repository.declare_nil_bucket(); - } - else { - ++m_sync_count ; - - // Clear out the previous transaction information - // m_transaction_log.flush(); - - m_entity_repo.clean_changes(); - } - - m_sync_state = MODIFIABLE ; - - return true ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// The add_parts must be full ordered and consistent, -// i.e. no bad parts, all supersets included, and -// owner & used parts match the owner value. - -//---------------------------------------------------------------------- - -Entity & BulkData::declare_entity( EntityRank ent_rank , EntityId ent_id , - const PartVector & parts ) -{ - require_ok_to_modify(); - - require_good_rank_and_id(ent_rank, ent_id); - - EntityKey key( ent_rank , ent_id ); - TraceIfWatching("stk_classic::mesh::BulkData::declare_entity", LOG_ENTITY, key); - DiagIfWatching(LOG_ENTITY, key, "declaring entity with parts " << parts); - - std::pair< Entity * , bool > result = m_entity_repo.internal_create_entity( key ); - - Entity* declared_entity = result.first; - - if ( result.second ) { - // A new application-created entity - m_entity_repo.set_entity_owner_rank( *declared_entity, m_parallel_rank); - m_entity_repo.set_entity_sync_count( *declared_entity, m_sync_count); - DiagIfWatching(LOG_ENTITY, key, "new entity: " << *declared_entity); - } - else { - // An existing entity, the owner must match. - require_entity_owner( *declared_entity , m_parallel_rank ); - DiagIfWatching(LOG_ENTITY, key, "existing entity: " << *declared_entity); - } - - //------------------------------ - - Part * const owns = & m_mesh_meta_data.locally_owned_part(); - - std::vector rem ; - std::vector add( parts ); - add.push_back( owns ); - - change_entity_parts( *declared_entity , add , rem ); - - // m_transaction_log.insert_entity ( *(result.first) ); - - return *declared_entity ; -} - -void BulkData::change_entity_id( EntityId id, Entity & entity) -{ - require_ok_to_modify(); - require_good_rank_and_id(entity.entity_rank(),id); - - EntityKey key(entity.entity_rank(),id); - EntityKey old_key = entity.key(); - - m_entity_repo.update_entity_key(key,entity); - - //We also need to swap the comm-vectors for these entities: - entity_comm_swap(key, old_key); -} - -//---------------------------------------------------------------------- - -// TODO Change the methods below to requirements (private, const invariant checkers) - -// Do not allow any of the induced part memberships to explicitly -// appear in the add or remove parts lists. -// 1) Intersection part -// 2) PartRelation target part -// 3) Part that does not match the entity rank. - -void BulkData::internal_verify_change_parts( const MetaData & meta , - const Entity & entity , - const PartVector & parts ) const -{ - const std::vector & rank_names = meta.entity_rank_names(); - const EntityRank undef_rank = InvalidEntityRank; - const EntityRank entity_rank = entity.entity_rank(); - - bool ok = true ; - std::ostringstream msg ; - - for ( PartVector::const_iterator - i = parts.begin() ; i != parts.end() ; ++i ) { - - const Part * const p = *i ; - const unsigned part_rank = p->primary_entity_rank(); - - bool intersection_ok, rel_target_ok, rank_ok; - internal_basic_part_check(p, entity_rank, undef_rank, intersection_ok, rel_target_ok, rank_ok); - - if ( !intersection_ok || !rel_target_ok || !rank_ok ) { - if ( ok ) { - ok = false ; - msg << "change parts for entity " << print_entity_key( entity ); - msg << " , { " ; - } - else { - msg << " , " ; - } - - msg << p->name() << "[" ; - if ( part_rank < rank_names.size() ) { - msg << rank_names[ part_rank ]; - } - else { - msg << part_rank ; - } - msg << "] " ; - if ( !intersection_ok ) { msg << "is_intersection " ; } - if ( !rel_target_ok ) { msg << "is_relation_target " ; } - if ( !rank_ok ) { msg << "is_bad_rank " ; } - } - } - - ThrowErrorMsgIf( !ok, msg.str() << "}" ); -} - -void BulkData::internal_verify_change_parts( const MetaData & meta , - const Entity & entity , - const OrdinalVector & parts ) const -{ - const std::vector & rank_names = meta.entity_rank_names(); - const EntityRank undef_rank = InvalidEntityRank; - const EntityRank entity_rank = entity.entity_rank(); - - bool ok = true ; - std::ostringstream msg ; - - for ( OrdinalVector::const_iterator - i = parts.begin() ; i != parts.end() ; ++i ) { - - const Part * const p = meta.get_parts()[*i] ; - const unsigned part_rank = p->primary_entity_rank(); - - bool intersection_ok, rel_target_ok, rank_ok; - internal_basic_part_check(p, entity_rank, undef_rank, intersection_ok, rel_target_ok, rank_ok); - - if ( !intersection_ok || !rel_target_ok || !rank_ok ) { - if ( ok ) { - ok = false ; - msg << "change parts for entity " << print_entity_key( entity ); - msg << " , { " ; - } - else { - msg << " , " ; - } - - msg << p->name() << "[" ; - if ( part_rank < rank_names.size() ) { - msg << rank_names[ part_rank ]; - } - else { - msg << part_rank ; - } - msg << "] " ; - if ( !intersection_ok ) { msg << "is_intersection " ; } - if ( !rel_target_ok ) { msg << "is_relation_target " ; } - if ( !rank_ok ) { msg << "is_bad_rank " ; } - } - } - - ThrowErrorMsgIf( !ok, msg.str() << "}" ); -} - -//---------------------------------------------------------------------- - -namespace { - -void filter_out( std::vector & vec , - const PartVector & parts , - PartVector & removed ) -{ - std::vector::iterator i , j ; - i = j = vec.begin(); - - PartVector::const_iterator ip = parts.begin() ; - - while ( j != vec.end() && ip != parts.end() ) { - Part * const p = *ip ; - if ( p->mesh_meta_data_ordinal() < *j ) { ++ip ; } - else if ( *j < p->mesh_meta_data_ordinal() ) { *i = *j ; ++i ; ++j ; } - else { - removed.push_back( p ); - ++j ; - ++ip ; - } - } - - if ( i != j ) { vec.erase( i , j ); } -} - -void filter_out( std::vector & vec , - const OrdinalVector & parts , - OrdinalVector & removed ) -{ - std::vector::iterator i , j ; - i = j = vec.begin(); - - OrdinalVector::const_iterator ip = parts.begin() ; - - while ( j != vec.end() && ip != parts.end() ) { - if ( *ip < *j ) { ++ip ; } - else if ( *j < *ip ) { *i = *j ; ++i ; ++j ; } - else { - removed.push_back( *ip ); - ++j ; - ++ip ; - } - } - - if ( i != j ) { vec.erase( i , j ); } -} - -void merge_in( std::vector & vec , const PartVector & parts ) -{ - std::vector::iterator i = vec.begin(); - PartVector::const_iterator ip = parts.begin() ; - - for ( ; i != vec.end() && ip != parts.end() ; ++i ) { - - const unsigned ord = (*ip)->mesh_meta_data_ordinal(); - - if ( ord <= *i ) { - if ( ord < *i ) { i = vec.insert( i , ord ); } - // Now have: ord == *i - ++ip ; - } - } - - for ( ; ip != parts.end() ; ++ip ) { - const unsigned ord = (*ip)->mesh_meta_data_ordinal(); - vec.push_back( ord ); - } -} - -void merge_in( std::vector & vec , const OrdinalVector & parts ) -{ - std::vector::iterator i = vec.begin(); - OrdinalVector::const_iterator ip = parts.begin() ; - - for ( ; i != vec.end() && ip != parts.end() ; ++i ) { - - const unsigned ord = *ip; - - if ( ord <= *i ) { - if ( ord < *i ) { i = vec.insert( i , ord ); } - // Now have: ord == *i - ++ip ; - } - } - - for ( ; ip != parts.end() ; ++ip ) { - vec.push_back( *ip ); - } -} - -} - -// The 'add_parts' and 'remove_parts' are complete and disjoint. -// Changes need to have parallel resolution during -// modification_end. - -void BulkData::internal_change_entity_parts( - Entity & entity , - const PartVector & add_parts , - const PartVector & remove_parts ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::internal_change_entity_parts", LOG_ENTITY, entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - DiagIfWatching(LOG_ENTITY, entity.key(), "add_parts: " << add_parts); - DiagIfWatching(LOG_ENTITY, entity.key(), "remove_parts: " << remove_parts); - - Bucket * const k_old = m_entity_repo.get_entity_bucket( entity ); - - const unsigned i_old = entity.bucket_ordinal() ; - - if ( k_old && k_old->member_all( add_parts ) && - ! k_old->member_any( remove_parts ) ) { - // Is already a member of all add_parts, - // is not a member of any remove_parts, - // thus nothing to do. - return ; - } - - PartVector parts_removed ; - - OrdinalVector parts_total ; // The final part list - - //-------------------------------- - - if ( k_old ) { - // Keep any of the existing bucket's parts - // that are not a remove part. - // This will include the 'intersection' parts. - // - // These parts are properly ordered and unique. - - const std::pair - bucket_parts = k_old->superset_part_ordinals(); - - const unsigned * parts_begin = bucket_parts.first; - const unsigned * parts_end = bucket_parts.second; - - const unsigned num_bucket_parts = parts_end - parts_begin; - parts_total.reserve( num_bucket_parts + add_parts.size() ); - parts_total.insert( parts_total.begin(), parts_begin , parts_end); - - if ( !remove_parts.empty() ) { - parts_removed.reserve(remove_parts.size()); - filter_out( parts_total , remove_parts , parts_removed ); - } - } - else { - parts_total.reserve(add_parts.size()); - } - - if ( !add_parts.empty() ) { - merge_in( parts_total , add_parts ); - } - - if ( parts_total.empty() ) { - // Always a member of the universal part. - const unsigned univ_ord = - m_mesh_meta_data.universal_part().mesh_meta_data_ordinal(); - parts_total.push_back( univ_ord ); - } - - //-------------------------------- - // Move the entity to the new bucket. - - Bucket * k_new = - m_bucket_repository.declare_bucket( - entity.entity_rank(), - parts_total.size(), - & parts_total[0] , - m_mesh_meta_data.get_fields() - ); - - // If changing buckets then copy its field values from old to new bucket - - if ( k_old ) { - m_bucket_repository.copy_fields( *k_new , k_new->size() , *k_old , i_old ); - } - else { - m_bucket_repository.initialize_fields( *k_new , k_new->size() ); - } - - // Set the new bucket - m_entity_repo.change_entity_bucket( *k_new, entity, k_new->size() ); - m_bucket_repository.add_entity_to_bucket( entity, *k_new ); - - // If changing buckets then remove the entity from the bucket, - if ( k_old && k_old->capacity() > 0) { m_bucket_repository.remove_entity( k_old , i_old ); } - - // Update the change counter to the current cycle. - m_entity_repo.set_entity_sync_count( entity, m_sync_count ); - - // Propagate part changes through the entity's relations. - - internal_propagate_part_changes( entity , parts_removed ); - -#ifndef NDEBUG - //ensure_part_superset_consistency( entity ); -#endif -} - -void BulkData::internal_change_entity_parts( - Entity & entity , - const OrdinalVector & add_parts , - const OrdinalVector & remove_parts, - bool always_propagate_internal_changes ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::internal_change_entity_parts", LOG_ENTITY, entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - DiagIfWatching(LOG_ENTITY, entity.key(), "add_parts: " << add_parts); - DiagIfWatching(LOG_ENTITY, entity.key(), "remove_parts: " << remove_parts); - - Bucket * const k_old = m_entity_repo.get_entity_bucket( entity ); - - const unsigned i_old = entity.bucket_ordinal() ; - - if ( k_old && k_old->member_all( add_parts ) && - ! k_old->member_any( remove_parts ) ) { - // Is already a member of all add_parts, - // is not a member of any remove_parts, - // thus nothing to do. - return ; - } - - OrdinalVector parts_removed ; - - OrdinalVector parts_total ; // The final part list - - //-------------------------------- - - if ( k_old ) { - // Keep any of the existing bucket's parts - // that are not a remove part. - // This will include the 'intersection' parts. - // - // These parts are properly ordered and unique. - - const std::pair - bucket_parts = k_old->superset_part_ordinals(); - - const unsigned * parts_begin = bucket_parts.first; - const unsigned * parts_end = bucket_parts.second; - - const unsigned num_bucket_parts = parts_end - parts_begin; - parts_total.reserve( num_bucket_parts + add_parts.size() ); - parts_total.insert( parts_total.begin(), parts_begin , parts_end); - - if ( !remove_parts.empty() ) { - parts_removed.reserve(remove_parts.size()); - filter_out( parts_total , remove_parts , parts_removed ); - } - } - else { - parts_total.reserve(add_parts.size()); - } - - if ( !add_parts.empty() ) { - merge_in( parts_total , add_parts ); - } - - if ( parts_total.empty() ) { - // Always a member of the universal part. - const unsigned univ_ord = - m_mesh_meta_data.universal_part().mesh_meta_data_ordinal(); - parts_total.push_back( univ_ord ); - } - - //-------------------------------- - // Move the entity to the new bucket. - - Bucket * k_new = - m_bucket_repository.declare_bucket( - entity.entity_rank(), - parts_total.size(), - & parts_total[0] , - m_mesh_meta_data.get_fields() - ); - - // If changing buckets then copy its field values from old to new bucket - - if ( k_old ) { - m_bucket_repository.copy_fields( *k_new , k_new->size() , *k_old , i_old ); - } - else { - m_bucket_repository.initialize_fields( *k_new , k_new->size() ); - } - - // Set the new bucket - m_entity_repo.change_entity_bucket( *k_new, entity, k_new->size() ); - m_bucket_repository.add_entity_to_bucket( entity, *k_new ); - - // If changing buckets then remove the entity from the bucket, - if ( k_old && k_old->capacity() > 0) { m_bucket_repository.remove_entity( k_old , i_old ); } - - // Update the change counter to the current cycle. - m_entity_repo.set_entity_sync_count( entity, m_sync_count ); - - // Propagate part changes through the entity's relations. - //(Only propagate part changes for parts which have a primary-entity-rank that matches - // the entity's rank. Other parts don't get induced...) - - const PartVector& all_parts = m_mesh_meta_data.get_parts(); - - OrdinalVector rank_parts_removed; - for(OrdinalVector::const_iterator pr=parts_removed.begin(), prend=parts_removed.end(); pr!=prend; ++pr) { - if (all_parts[*pr]->primary_entity_rank() == entity.entity_rank()) { - rank_parts_removed.push_back(*pr); - } - } - - if (always_propagate_internal_changes || - !rank_parts_removed.empty() || !m_mesh_meta_data.get_field_relations().empty()) { - internal_propagate_part_changes( entity , rank_parts_removed ); - } - -#ifndef NDEBUG - //ensure_part_superset_consistency( entity ); -#endif -} - -//---------------------------------------------------------------------- - -bool BulkData::destroy_entity( Entity * & entity_in ) -{ - Entity & entity = *entity_in ; - - TraceIfWatching("stk_classic::mesh::BulkData::destroy_entity", LOG_ENTITY, entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - - require_ok_to_modify( ); - - bool has_upward_relation = false ; - - for ( PairIterRelation - irel = entity.relations() ; - ! irel.empty() && ! has_upward_relation ; ++irel ) { - - has_upward_relation = entity.entity_rank() <= irel->entity_rank(); - } - - if ( has_upward_relation ) { return false ; } - - if ( EntityLogDeleted == entity.log_query() ) { - // Cannot already be destroyed. - return false ; - } - //------------------------------ - // Immediately remove it from relations and buckets. - // Postpone deletion until modification_end to be sure that - // 1) No attempt is made to re-create it. - // 2) Parallel index is cleaned up. - // 3) Parallel sharing is cleaned up. - // 4) Parallel ghosting is cleaned up. - // - // Must clean up the parallel lists before fully deleting the entity. - - // It is important that relations be destroyed in reverse order so that - // the higher (back) relations are destroyed first. - while ( ! entity.relations().empty() ) { - destroy_relation( entity , - * entity.relations().back().entity(), - entity.relations().back().identifier()); - } - - // We need to save these items and call remove_entity AFTER the call to - // destroy_later because remove_entity may destroy the bucket - // which would cause problems in m_entity_repo.destroy_later because it - // makes references to the entity's original bucket. - Bucket& orig_bucket = entity.bucket(); - unsigned orig_bucket_ordinal = entity.bucket_ordinal(); - - // Set the bucket to 'bucket_nil' which: - // 1) has no parts at all - // 2) has no field data - // 3) has zero capacity - // - // This keeps the entity-bucket methods from catastrophically failing - // with a bad bucket pointer. - - m_entity_repo.destroy_later( entity, m_bucket_repository.get_nil_bucket() ); - - m_bucket_repository.remove_entity( &orig_bucket , orig_bucket_ordinal ); - - // Add destroyed entity to the transaction - // m_transaction_log.delete_entity ( *entity_in ); - - // Set the calling entity-pointer to NULL; - // hopefully the user-code will clean up any outstanding - // references to this entity. - - entity_in = NULL ; - - return true ; -} - -//---------------------------------------------------------------------- - -void BulkData::generate_new_entities(const std::vector& requests, - std::vector& requested_entities) -{ - Trace_("stk_classic::mesh::BulkData::generate_new_entities"); - - typedef stk_classic::parallel::DistributedIndex::KeyType KeyType; - std::vector< std::vector > - requested_key_types; - m_entities_index.generate_new_keys(requests, requested_key_types); - - //generating 'owned' entities - Part * const owns = & m_mesh_meta_data.locally_owned_part(); - - std::vector rem ; - std::vector add; - add.push_back( owns ); - - requested_entities.clear(); - unsigned cnt=0; - for (std::vector< std::vector >::const_iterator itr = requested_key_types.begin(); itr != requested_key_types.end(); ++itr) { - const std::vector& key_types = *itr; - for (std::vector::const_iterator - kitr = key_types.begin(); kitr != key_types.end(); ++kitr) { - ++cnt; - } - } - requested_entities.reserve(cnt); - - for (std::vector< std::vector >::const_iterator itr = requested_key_types.begin(); itr != requested_key_types.end(); ++itr) { - const std::vector& key_types = *itr; - for (std::vector::const_iterator - kitr = key_types.begin(); kitr != key_types.end(); ++kitr) { - EntityKey key(&(*kitr)); - std::pair result = m_entity_repo.internal_create_entity(key); - - //if an entity is declare with the declare_entity function in - //the same modification cycle as the generate_new_entities - //function, and it happens to generate a key that was declare - //previously in the same cycle it is an error - ThrowErrorMsgIf( ! result.second, - "Generated " << print_entity_key(m_mesh_meta_data, key) << - " which was already used in this modification cycle."); - - // A new application-created entity - - Entity* new_entity = result.first; - - m_entity_repo.set_entity_owner_rank( *new_entity, m_parallel_rank); - m_entity_repo.set_entity_sync_count( *new_entity, m_sync_count); - - //add entity to 'owned' part - change_entity_parts( *new_entity , add , rem ); - requested_entities.push_back(new_entity); - } - } -} - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.hpp deleted file mode 100644 index 928ca4cec41c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkData.hpp +++ /dev/null @@ -1,725 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_BulkData_hpp -#define stk_mesh_BulkData_hpp - -//---------------------------------------------------------------------- - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- -/** \brief Manager for an integrated collection of - * \ref stk_classic::mesh::Entity "entities", - * \ref stk_classic::mesh::Relation "entity relations", and - * \ref stk_classic::mesh::Bucket "buckets" of - * \ref stk_mesh_field_data "field data". - * - * Bulk data should be distributed among all processors. - */ -class BulkData { -public: - - void optimize_buckets_at_modification_end(bool b) { m_optimize_buckets = b; } - - inline static BulkData & get( const Bucket & bucket); - inline static BulkData & get( const Entity & entity); - inline static BulkData & get( const Ghosting & ghost); - - enum BulkDataSyncState { MODIFIABLE = 1 , SYNCHRONIZED = 2 }; - - ~BulkData(); - - /** \brief Construct mesh bulk data manager conformal to the given - * \ref stk_classic::mesh::MetaData "meta data manager" and will - * distribute bulk data over the given parallel machine. - * - * - The maximum number of entities per bucket may be supplied. - * - The bulk data is in the synchronized or "locked" state. - */ - BulkData( MetaData & mesh_meta_data , - ParallelMachine parallel , - unsigned bucket_max_size = 1000 , - bool use_memory_pool = true ); - - //------------------------------------ - /** \brief The meta data manager for this bulk data manager. */ - const MetaData & mesh_meta_data() const { return m_mesh_meta_data ; } - - /** \brief The parallel machine */ - ParallelMachine parallel() const { return m_parallel_machine ; } - - /** \brief Size of the parallel machine */ - unsigned parallel_size() const { return m_parallel_size ; } - - /** \brief Rank of the parallel machine's local processor */ - unsigned parallel_rank() const { return m_parallel_rank ; } - - //------------------------------------ - /** \brief Bulk data has two states: - * guaranteed to be parallel synchronized or - * modification in progress and may be parallel inconsistent. - */ - BulkDataSyncState synchronized_state() const { return m_sync_state ; } - - /** \brief Count of the number of times that the bulk data has been - * parallel synchronized. This count gets updated with - * each call to 'modification_end'. - */ - size_t synchronized_count() const { return m_sync_count ; } - - /** \brief Begin a modification phase during which the mesh bulk data - * could become parallel inconsistent. This is a parallel - * synchronous call. The first time this method is called - * the mesh meta data is verified to be committed and - * parallel consistent. An exception is thrown if this - * verification fails. - * - * \return True if transitioned out of the guaranteed - * parallel consistent state to the "ok to modify" state. - * False if already in this state. - */ - bool modification_begin(); - - /** \brief Parallel synchronization of modifications and - * transition to the guaranteed parallel consistent state. - * - * Parallel synchronization of accumulated local modifications - * is probably an expensive operation. Operations include: - * - Determining ownership and sharing of created entities. - * - Synchronizing entity membership in parts for shared entities. - * - Refreshing the shared entities ghosting (e.g. aura). - * - Updating ghost entities that have change part membership. - * - Sorting buckets' entities for a well-defined ordering. - * - * \return True if transitioned from the "ok to modify" state. - * False if already already in this state. - * - * \exception If modification resolution errors occur then - * a parallel-consistent exception will be thrown. - */ - bool modification_end(); - - bool final_modification_end() - { - optimize_buckets_at_modification_end(true); - const bool mod_flag = modification_end(); - - //call modification_begin and end one last time to free deleted entities - modification_begin(); - modification_end(); - - m_mesh_finalized = true; - - return mod_flag; - } - - /** \brief Give away ownership of entities to other parallel processes. - * - * A parallel-synchronous operation while the mesh is in the - * ok-to-modify state. - * - * Each owning process inputs a list of entities and the - * new owning process. Upon completion of the call the owning - * processes have the newly owned entities as well as the closure - * of those entities (without changing the ownership of the closure - * entities). If a previous owner no longer needs a - * changed-owner entity to support the closure of a still-owned - * entity then the changed-owner entity is deleted from that process. - * All ghosts of all entities effected by the changed ownerships - * deleted. - */ - void change_entity_owner( const std::vector & arg_change); - - /** \brief Rotate the field data of multistate fields. - * - *
-   *  Rotation of states:
-   *    StateN   <- StateNP1 (StateOld <- StateNew)
-   *    StateNM1 <- StateN   (StateNM1 <- StateOld)
-   *    StateNM2 <- StateNM1
-   *    StateNM3 <- StateNM2
-   *    StateNM3 <- StateNM2
-   *  
- */ - void update_field_data_states() const { m_bucket_repository.update_field_data_states(); } - - /** \brief Copy field data from src entity to Dest entity - * - Fields that exist on the src that don't exist on the dest will - * be ignored - * - Fields that exist on the dest that don't exist on the src will - * be zeroed or initialized with the Field-specified initial-value. - */ - void copy_entity_fields( const Entity & src, Entity & dest) { - //TODO fix const correctness for src - Entity & non_const_src = const_cast(src); - m_bucket_repository.copy_fields( - dest.bucket(), - dest.bucket_ordinal(), - non_const_src.bucket(), - non_const_src.bucket_ordinal() - ); - } - - //------------------------------------ - /** \brief Query all buckets of a given entity rank */ - const std::vector & buckets( EntityRank rank ) const - { return m_bucket_repository.buckets(rank); } - -#ifndef SWIG //SRK - AllBucketsRange get_bucket_range() const - { - return m_bucket_repository.get_bucket_range(); - } - - AllBucketsRange get_bucket_range( EntityRank rank ) const - { - return m_bucket_repository.get_bucket_range(rank); - } -#endif - - /** \brief Get entity with a given key */ - Entity * get_entity( EntityRank entity_rank , EntityId entity_id ) const { - require_good_rank_and_id(entity_rank, entity_id); - return m_entity_repo.get_entity( EntityKey(entity_rank, entity_id)); - } - - /** \brief Get entity with a given key */ - Entity * get_entity( const EntityKey key ) const { - return m_entity_repo.get_entity(key); - } - - //------------------------------------ - /** \brief Create or retrieve a locally owned entity of a - * given rank and id. - * - * A parallel-local operation. - * - * The entity is created as locally owned and a member of the input - * mesh parts. The entity a member of the meta data's locally owned - * mesh part and the entity's owner_rank() == parallel_rank(). - * - * If two or more processes create an entity of the same rank - * and identifier then the sharing and ownership of these entities - * will be resolved by the call to 'modification_end'. - */ - Entity & declare_entity( EntityRank ent_rank , - EntityId ent_id , const PartVector& parts); - - void change_entity_id( EntityId id, Entity & entity); - - /** \brief Change the parallel-locally-owned entity's - * part membership by adding and/or removing parts - * - * A parallel-local operation. - * - * If the locally owned entity is shared or ghosted then - * the change will be propogated to the sharing or ghosting - * processes by modification_end. - */ - void change_entity_parts( Entity & entity, - const PartVector & add_parts , - const PartVector & remove_parts = PartVector() ) - { - change_entity_parts(entity, - add_parts.begin(), add_parts.end(), - remove_parts.begin(), remove_parts.end()); - } - -//Optional parameter 'always_propagate_internal_changes' is always true except when this function -//is being called from the sierra-framework. The fmwk redundantly does its own propagation of the -//internal part changes (mostly induced-part stuff), so it's a performance optimization to avoid -//the propagation that stk-mesh does. - template - void change_entity_parts( Entity & entity, - AddIterator begin_add_parts, AddIterator end_add_parts, - RemoveIterator begin_remove_parts, RemoveIterator end_remove_parts, - bool always_propagate_internal_changes=true ); - - /** \brief Request the destruction an entity on the local process. - * - * \paragraph destroy_requirements Requirements - * - * An entity cannot be the 'to' member of a relation. - * These relations must first be explicitly removed or the - * 'from' entity be explicitly destroyed. - * - * \paragraph destroy_locally_owned Destroy Locally Owned - * - * Destrunction of entities in the 'locally_owned_part' schedules - * all ghost copies of that entity for destruction during - * modification_end. If the entity ia shared with - * another process and that process does not also destroy the - * entity then ownership of the entity will be transfered to - * a sharing process during modification_end. - * - * \paragraph destroy_globally_shared Destroy Locally Used - * - * Entities in the 'globally_shared_part' are deleted - * on the local process and removed from the sharing lists on - * other processes during modication_end. - * - * \paragraph destroy_ghosted Destroy Ghosted - * - * Entities not in the 'locally_owned_part' and 'globally_shared_part' - * are ghosted. - * These entities are removed from all ghosting lists - * during 'modification_end'. - * - * \return True if the request for destruction is accepted; i.e., - * if the entity is not the 'to' member of a relation. - */ - bool destroy_entity( Entity * & entity ); - - //------------------------------------ - - /** \brief Generate a set of entites with globally unique id's - * - * Each processor fills a request vector asking for a number of new - * entities of the given ranks. - * - * ex. request = { 0, 4, 8} - * request 0 entites of rank 0, 4 entites of rank 1, and 8 entites - * of rank 2 - */ - void generate_new_entities(const std::vector& requests, - std::vector& requested_entities); - - //------------------------------------ - /** \brief Declare a relation and its converse between - * entities in the same mesh. - * - * A parallel-local mesh modificaton operation. - * - * This mapping ( e_from , local_id ) -> e_to must be unique. - * - * Relations between entities induces part membership as follows. - * 1) If 'e_from' is a member of 'part' and - * part.primary_entity_rank() == e_from.entity_rank() - * then 'e_to' has induced membership in 'part'. - * 2) If there exists a part relation 'part_rel' such that - * 'e_from' is a member of part_rel.m_root and - * the entity relation conforms to the part relation - * then 'e_to' has induced membership in part_rel.m_target. - * - * Note that relation-declarations must be symmetric across all - * sharers of the involved entities within a modification cycle. - */ - void declare_relation( Entity & e_from , - Entity & e_to , - const RelationIdentifier local_id ); - - /** \brief Declare a collection of relations by simply iterating - * the input and calling declare_relation on each entry. - */ - void declare_relation( Entity & entity, const std::vector & rel); - - /** \brief Remove all relations between two entities. - * - * If the relation induced a part membership for 'e_to' and 'e_to' - * is not shared with another processor then that part membership - * is removed if and only if there does not exist another relation - * inducing the same part membership. - * If 'e_to' is shared then the check for removing the induced - * relatinship does not occur for that entity until the call to - * 'modification_end'. - * The local_id arg is used to differentiate the case when there are - * multiple relationships between e_from and e_to. - * - * Returns true if we were able to destroy the relation. - */ - bool destroy_relation( Entity & e_from , - Entity & e_to, - const RelationIdentifier local_id ); - - //------------------------------------ - //------------------------------------ - /** \brief All entities with communication information. */ - const std::vector & entity_comm() const - { return m_entity_comm ; } - - //------------------------------------ - /** \brief Query the shared-entity aura. - * Is likely to be stale if ownership or sharing has changed - * and the 'modification_end' has not been called. - */ - Ghosting & shared_aura() const { return * m_ghosting[1] ; } - - /** \brief Asymmetric parallel relations for owner-to-ghosted mesh entities. - * - * - A collective parallel operation that must have the - * same name on all processors of this distributed mesh. - */ - Ghosting & create_ghosting( const std::string & name ); - - /** \brief Change the members of a ghosting list on the sending processor. - * - * - A collective parallel operation. - * - The ghosting must belong to this mesh. - * - Cannot change the 'shared_aura' in this manner. - * - Add locally owned entities to the input ghosting on the given - * destination processor. The closure of the input entities - * will be ghosted. - * - Request removal of ghosted entities on the ghosting processor. - * This request will only be honored if the ghosted entity is - * not in the closure of another ghosted entity which will remain - * in or be added to this ghosting. - * - * To destroy all ghosted entities in a particular ghosting: - * mesh.change_ghosting( ghosts , std::vector() , - * ghosts.receive() ); - */ - void change_ghosting( Ghosting & ghosts, - const std::vector & add_send , - const std::vector & remove_receive ); - - /** \brief Empty every single Ghosting. - * Same result, but more efficient than, calling - * change_ghosting to remove every single ghosted entity. - */ - void destroy_all_ghosting(); - - /** \brief Query all ghostings */ - const std::vector & ghostings() const { return m_ghosting ; } - - /** \brief Entity Comm functions that are now moved to BulkData - * These functions are only here for backwards compatibility. - * We plan to remove all comm accessors from the Entity in the future. - */ - PairIterEntityComm entity_comm(const EntityKey & key) const { return m_entity_comm_map.comm(key); } - PairIterEntityComm entity_comm_sharing(const EntityKey & key) const { return m_entity_comm_map.sharing(key); } - PairIterEntityComm entity_comm(const EntityKey & key, const Ghosting & sub ) const { return m_entity_comm_map.comm(key,sub); } - bool entity_comm_insert( const EntityKey & key, const EntityCommInfo & val) { return m_entity_comm_map.insert(key,val); } - bool entity_comm_erase( const EntityKey & key, const EntityCommInfo & val) { return m_entity_comm_map.erase(key,val); } - bool entity_comm_erase( const EntityKey & key, const Ghosting & ghost) { return m_entity_comm_map.erase(key,ghost); } - void entity_comm_clear_ghosting(const EntityKey & key ) { m_entity_comm_map.comm_clear_ghosting(key); } - void entity_comm_clear(const EntityKey & key) { m_entity_comm_map.comm_clear(key); } - void entity_comm_swap(const EntityKey & key1, const EntityKey & key2) { m_entity_comm_map.comm_swap(key1, key2); } - -private: - - /** \brief The meta data manager for this bulk data manager. */ - MetaData & meta_data() const { return m_mesh_meta_data ; } - -#ifndef DOXYGEN_COMPILE - - BulkData(); - BulkData( const BulkData & ); - BulkData & operator = ( const BulkData & ); - - /** \brief Parallel index for entity keys */ - parallel::DistributedIndex m_entities_index ; - impl::EntityRepository m_entity_repo ; - impl::BucketRepository m_bucket_repository ; - std::vector m_entity_comm ; - std::vector m_ghosting ; /**< Aura is [1] */ - - // Other information: - MetaData & m_mesh_meta_data ; - ParallelMachine m_parallel_machine ; - unsigned m_parallel_size ; - unsigned m_parallel_rank ; - size_t m_sync_count ; - BulkDataSyncState m_sync_state ; - bool m_meta_data_verified ; - bool m_optimize_buckets; - bool m_mesh_finalized; - EntityComm m_entity_comm_map; - - /** - * For all processors sharing an entity, find one to be the new - * owner. - */ - unsigned determine_new_owner( Entity & ) const ; - - /* Entity modification consequences: - * 1) Change entity relation => update via part relation => change parts - * 2) Change parts => update forward relations via part relation - * => update via field relation - */ - void internal_change_entity_parts( Entity & , - const PartVector & add_parts , - const PartVector & remove_parts ); - -//Optional parameter 'always_propagate_internal_changes' is always true except when this function -//is being called from the sierra-framework. The fmwk redundantly does its own propagation of the -//internal part changes (mostly induced-part stuff), so it's a performance optimization to avoid -//the propagation that stk-mesh does. - void internal_change_entity_parts( Entity & , - const OrdinalVector & add_parts , - const OrdinalVector & remove_parts, - bool always_propagate_internal_changes=true); - - void internal_propagate_part_changes( Entity & entity, const PartVector & removed ); - void internal_propagate_part_changes( Entity & entity, const OrdinalVector & removed ); - - void internal_change_ghosting( Ghosting & ghosts, - const std::vector & add_send , - const std::vector & remove_receive ); - - bool internal_modification_end( bool regenerate_aura ); - void internal_resolve_shared_modify_delete(); - void internal_resolve_shared_modify_delete_second_pass(); - void internal_resolve_ghosted_modify_delete(); - void internal_resolve_parallel_create(); - void internal_resolve_shared_membership(); - - void internal_update_distributed_index( std::vector & shared_new ); - - /** \brief Regenerate the shared-entity aura, - * adding and removing ghosted entities as necessary. - * - * - a collective parallel operation. - */ - void internal_regenerate_shared_aura(); - - void internal_basic_part_check(const Part* part, - const unsigned entity_rank, - const unsigned undef_rank, - bool& intersection_ok, - bool& rel_target_ok, - bool& rank_ok) const; - - // Returns false if there is a problem. It is expected that - // verify_change_parts will be called if quick_verify_change_part detects - // a problem, therefore we leave the generation of an exception to - // verify_change_parts. We want this function to be as fast as - // possible. - bool internal_quick_verify_change_part(const Part* part, - const unsigned entity_rank, - const unsigned undef_rank) const; - - void internal_verify_change_parts( const MetaData & meta , - const Entity & entity , - const PartVector & parts ) const; - - void internal_verify_change_parts( const MetaData & meta , - const Entity & entity , - const OrdinalVector & parts ) const; - - //------------------------------------ - - /** \name Invariants/preconditions for MetaData. - * \{ - */ - - /** \brief All non-const methods assert this */ - void require_ok_to_modify() const ; - - void require_entity_owner( const Entity & entity, unsigned owner) const ; - - void require_metadata_committed() const; - - void require_good_rank_and_id(EntityRank ent_rank, EntityId ent_id) const; - - void require_valid_relation( const char action[] , - const BulkData & mesh , - const Entity & e_from , - const Entity & e_to ); - - /** \} */ - - //------------------------------------ - - // FIXME: Remove this friend once unit-testing has been refactored - friend class UnitTestModificationEndWrapper; - friend class ::stk_classic::mesh::MetaData; -#endif /* DOXYGEN_COMPILE */ -}; - -BulkData & BulkData::get( const Bucket & bucket) { - return bucket.bulk_data(); -} - -BulkData & BulkData::get( const Entity & entity) { - return BulkData::get(entity.bucket()); -} - -BulkData & BulkData::get( const Ghosting & ghost) { - return ghost.bulk_data(); -} - -/** \} */ - -/** \brief Free function for setting relations on entities. - * \relates BulkData - * \relates BucketRepository - */ -// TODO - Does this need to be in the public API? It's only used internally. -// In what context would a client ever call this? -void set_field_relations( Entity & e_from , - Entity & e_to , - const unsigned ident ); - -inline -void BulkData::internal_basic_part_check(const Part* part, - const unsigned entity_rank, - const unsigned undef_rank, - bool& intersection_ok, - bool& rel_target_ok, - bool& rank_ok) const -{ - // const unsigned part_rank = part->primary_entity_rank(); - - intersection_ok = part->intersection_of().empty(); - rel_target_ok = ( part->relations().empty() || - part != part->relations().begin()->m_target ); - // Do we allow arbitrary part changes to entities regardless of part rank? For the sake of the migration, we will for now. -#ifdef SIERRA_MIGRATION - rank_ok = true; -#else - const unsigned part_rank = part->primary_entity_rank(); - rank_ok = ( entity_rank == part_rank || - undef_rank == part_rank ); -#endif -} - -inline bool BulkData::internal_quick_verify_change_part(const Part* part, - const unsigned entity_rank, - const unsigned undef_rank) const -{ - bool intersection_ok, rel_target_ok, rank_ok; - internal_basic_part_check(part, entity_rank, undef_rank, intersection_ok, rel_target_ok, rank_ok); - return intersection_ok && rel_target_ok && rank_ok; -} - -//Optional parameter 'always_propagate_internal_changes' is always true except when this function -//is being called from the sierra-framework. The fmwk redundantly does its own propagation of the -//internal part changes (mostly induced-part stuff), so it's a performance optimization to avoid -//the propagation that stk-mesh does. -template -void BulkData::change_entity_parts( Entity & entity, - AddIterator begin_add_parts, AddIterator end_add_parts, - RemoveIterator begin_remove_parts, RemoveIterator end_remove_parts, - bool always_propagate_internal_changes) -{ - TraceIfWatching("stk_classic::mesh::BulkData::change_entity_parts", LOG_ENTITY, entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - //DiagIfWatching(LOG_ENTITY, entity.key(), "add_parts: " << add_parts); - //DiagIfWatching(LOG_ENTITY, entity.key(), "remove_parts: " << remove_parts); - - require_ok_to_modify(); - - require_entity_owner( entity , m_parallel_rank ); - - const EntityRank entity_rank = entity.entity_rank(); - const EntityRank undef_rank = InvalidEntityRank; - - // Transitive addition and removal: - // 1) Include supersets of add_parts - // 2) Do not include a remove_part if it appears in the add_parts - // 3) Include subsets of remove_parts - - // most parts will at least have universal and topology part as supersets - const unsigned expected_min_num_supersets = 2; - - OrdinalVector a_parts; - a_parts.reserve( std::distance(begin_add_parts, end_add_parts) * (expected_min_num_supersets + 1) ); - for(AddIterator add_iter=begin_add_parts; add_iter!=end_add_parts; ++add_iter) { - a_parts.push_back((*add_iter)->mesh_meta_data_ordinal()); - } - bool quick_verify_check = true; - - for ( AddIterator ia = begin_add_parts; ia != end_add_parts ; ++ia ) { - quick_verify_check = quick_verify_check && - internal_quick_verify_change_part(*ia, entity_rank, undef_rank); - const PartVector& supersets = (*ia)->supersets(); - for(PartVector::const_iterator s_iter=supersets.begin(), s_end=supersets.end(); - s_iter!=s_end; ++s_iter) { - a_parts.push_back((*s_iter)->mesh_meta_data_ordinal()); - } - } - - order(a_parts); - - OrdinalVector::const_iterator a_parts_begin = a_parts.begin(), - a_parts_end = a_parts.end(); - OrdinalVector r_parts ; - - for ( RemoveIterator ir = begin_remove_parts; ir != end_remove_parts ; ++ir ) { - - // The following guards should be in the public interface to - // changing parts. However, internal mechanisms such as changing - // ownership calls this function to add or remove an entity from - // the three special parts. Without refactoring, these guards - // cannot be put in place. - /* - ThrowErrorMsgIf( m_mesh_meta_data.universal_part() == **ir, - "Cannot remove entity from universal part" ); - ThrowErrorMsgIf( m_mesh_meta_data.locally_owned_part() == **ir, - "Cannot remove entity from locally owned part" ); - ThrowErrorMsgIf( m_mesh_meta_data.globally_shared_part() == **ir, - "Cannot remove entity from globally shared part" ); - */ - - quick_verify_check = quick_verify_check && - internal_quick_verify_change_part(*ir, entity_rank, undef_rank); - - if ( ! contains_ordinal( a_parts_begin, a_parts_end , (*ir)->mesh_meta_data_ordinal() ) ) { - r_parts.push_back( (*ir)->mesh_meta_data_ordinal() ); - for ( PartVector::const_iterator cur_part = (*ir)->subsets().begin() ; - cur_part != (*ir)->subsets().end() ; - ++cur_part ) - if ( entity.bucket().member ( **cur_part ) ) - r_parts.push_back ( (*cur_part)->mesh_meta_data_ordinal() ); - } - } - - order(r_parts); - - // If it looks like we have a problem, run the full check and we should - // expect to see an exception thrown; otherwise, only do the full check in - // debug mode because it incurs significant overhead. - if ( ! quick_verify_check ) { - internal_verify_change_parts( m_mesh_meta_data , entity , a_parts ); - internal_verify_change_parts( m_mesh_meta_data , entity , r_parts ); - ThrowRequireMsg(false, "Expected throw from verify methods above."); - } - else { -#ifndef NDEBUG - internal_verify_change_parts( m_mesh_meta_data , entity , a_parts ); - internal_verify_change_parts( m_mesh_meta_data , entity , r_parts ); -#endif - } - - internal_change_entity_parts( entity , a_parts , r_parts , always_propagate_internal_changes ); - - return ; -} - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif // stk_mesh_BulkData_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataEndSync.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataEndSync.cpp deleted file mode 100644 index 5a9874f55ccf..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataEndSync.cpp +++ /dev/null @@ -1,1117 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -//---------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -bool comm_mesh_verify_parallel_consistency( - BulkData & M , std::ostream & error_log ); - -//---------------------------------------------------------------------- - -unsigned BulkData::determine_new_owner( Entity & entity ) const -{ - // We will decide the new owner by looking at all the processes sharing - // this entity. The new owner will be the sharing process with lowest rank. - - // The local process is a candidate only if the entity is not destroyed. - unsigned new_owner = - EntityLogDeleted == entity.log_query() ? ~0u : m_parallel_rank ; - - for ( PairIterEntityComm - share = m_entity_comm_map.sharing(entity.key()); ! share.empty() ; ++share ) { - if ( share->proc < m_parallel_size && - ( new_owner < share->proc || m_parallel_size <= new_owner ) ) { - new_owner = share->proc ; - } - } - - return new_owner ; -} - -//---------------------------------------------------------------------- - -namespace { - -// A method for quickly finding an entity -Entity* find_entity(const EntityVector& entities, const EntityKey& key, - bool expect_success = false) -{ - EntityVector::const_iterator itr = - std::lower_bound(entities.begin(), - entities.end(), - key, - EntityLess()); - if (itr == entities.end() || (*itr)->key() != key) { - ThrowRequireMsg(!expect_success, - "Expected to be able to find entity of type: " << - key.type() << " and rank: " << key.rank()); - return NULL; - } - return *itr; -} - -struct EntityProcState { - EntityProc entity_proc; - EntityModificationLog state; - - bool operator<(const EntityProcState& rhs) const - { - EntityLess el; - return el(entity_proc, rhs.entity_proc); - } -}; - -bool pack_entity_modification( const BulkData & mesh , - const bool pack_shared , - CommAll & comm ) -{ - bool flag = false ; - - const std::vector & entity_comm = mesh.entity_comm(); - - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( entity.log_query() == EntityLogModified || - entity.log_query() == EntityLogDeleted ) { - - for ( PairIterEntityComm ec = mesh.entity_comm(entity.key()); ! ec.empty() ; ++ec ) { - const bool shared = 0 == ec->ghost_id ; - if ( pack_shared == shared ) { - comm.send_buffer( ec->proc ) - .pack( entity.key() ) - .pack( entity.log_query() ); - - flag = true ; - } - } - } - } - - return flag ; -} - -void communicate_entity_modification( const BulkData & mesh , - const bool shared , - std::vector & data ) -{ - CommAll comm( mesh.parallel() ); - - // Sizing send buffers: - const bool local_mod = pack_entity_modification( mesh , shared , comm ); - - // Allocation of send and receive buffers: - const bool global_mod = - comm.allocate_buffers( comm.parallel_size() / 4 , false , local_mod ); - - if ( global_mod ) { - const std::vector & entity_comm = mesh.entity_comm(); - - // Packing send buffers: - pack_entity_modification( mesh , shared , comm ); - - comm.communicate(); - - for ( unsigned p = 0 ; p < comm.parallel_size() ; ++p ) { - CommBuffer & buf = comm.recv_buffer( p ); - EntityKey key ; - EntityProcState tmp ; - - while ( buf.remaining() ) { - - buf.unpack( key ) - .unpack( tmp.state ); - - // search through entity_comm, should only receive info on entities - // that are communicated. - tmp.entity_proc.first = find_entity(entity_comm, key, true); - tmp.entity_proc.second = p ; - - data.push_back( tmp ); - } - } - } - - std::sort( data.begin() , data.end() ); -} - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -// Postconditions: -// * DistributedIndex is updated based on entity creation/deletions in the -// last modification cycle. -// * Comm lists for shared entities are up-to-date. -// * shared_new contains all entities that were modified/created on a -// different process -void BulkData::internal_update_distributed_index( - std::vector & shared_new ) -{ - Trace_("stk_classic::mesh::BulkData::internal_update_distributed_index"); - - std::vector< parallel::DistributedIndex::KeyType > - local_created_or_modified , // only store locally owned/shared entities - del_entities_keys ; - - // Iterate over all entities known to this process, putting - // locally deleted entities in del_entities_keys, and putting - // modified shared/owned entities in local_created_or_modified. - for ( impl::EntityRepository::iterator - i = m_entity_repo.begin() ; i != m_entity_repo.end() ; ++i ) { - - Entity & entity = * i->second ; - - if ( EntityLogDeleted == entity.log_query() ) { - // Has been destroyed - del_entities_keys.push_back( entity.key().raw_key() ); - } - else if ( entity.log_query() != EntityLogNoChange && - in_owned_closure( entity , m_parallel_rank ) ) { - // Has been changed and is in owned closure, may be shared - local_created_or_modified.push_back( entity.key().raw_key() ); - } - } - - // Update distributed index. Note that the DistributedIndex only - // tracks ownership and sharing information. - m_entities_index.update_keys( local_created_or_modified , del_entities_keys ); - - if (parallel_size() > 1) { - // Retrieve data regarding which processes use the local_created_or_modified - // including this process. - std::vector< parallel::DistributedIndex::KeyProc > - global_created_or_modified ; - m_entities_index.query_to_usage( local_created_or_modified , - global_created_or_modified ); - - //------------------------------ - // Take the usage data and update the sharing comm lists - { - Entity * entity = NULL ; - - // Iterate over all global modifications to this entity, this vector is - // sorted, so we're guaranteed that all modifications to a particular - // entities will be adjacent in this vector. - for ( std::vector< parallel::DistributedIndex::KeyProc >::iterator - i = global_created_or_modified.begin() ; - i != global_created_or_modified.end() ; ++i ) { - - EntityKey key( & i->first ); - unsigned modifying_proc = i->second; - - // key should not be in del_entities_keys - ThrowAssertMsg( !std::binary_search(del_entities_keys.begin(), - del_entities_keys.end(), - i->first), - "Key: " << print_entity_key(mesh_meta_data(), key) << - " was locally deleted, but somehow was included in global_created_or_modified; " << - " this probably means there's problem in DistributedIndex." ); - - if ( m_parallel_rank != modifying_proc ) { - // Another process also created or updated this entity. - - // Only want to look up entities at most once - if ( entity == NULL || entity->key() != key ) { - // Have not looked this entity up by key - entity = get_entity( key ); - - shared_new.push_back( entity ); - } - - // Add the other_process to the entity's sharing info. - m_entity_comm_map.insert(entity->key(), EntityCommInfo( 0, // sharing - modifying_proc ) ); - } - } - } - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -// Enforce that shared entities must be in the owned closure: - -void destroy_dependent_ghosts( BulkData & mesh , Entity * entity ) -{ - for ( ; ; ) { - PairIterRelation rel = entity->relations(); - - if ( rel.empty() ) { break ; } - - Entity * e = rel.back().entity(); - - if ( e->entity_rank() < entity->entity_rank() ) { break ; } - - ThrowRequireMsg( !in_owned_closure( *e , mesh.parallel_rank()), - "Entity " << print_entity_key(e) << " should not be in closure." ); - - destroy_dependent_ghosts( mesh , e ); - } - - mesh.destroy_entity( entity ); -} - -// Entities with sharing information that are not in the owned closure -// have been modified such that they are no longer shared. -// These may no longer be needed or may become ghost entities. -// There is not enough information so assume they are to be deleted -// and let these entities be re-ghosted if they are needed. - -// Open question: Should an owned and shared entity that does not -// have an upward relation to an owned entity be destroyed so that -// ownership transfers to another process? - -void resolve_shared_removed_from_owned_closure( BulkData & mesh ) -{ - for ( std::vector::const_reverse_iterator - i = mesh.entity_comm().rbegin() ; - i != mesh.entity_comm().rend() ; ++i) { - - Entity * entity = *i ; - - if ( ! mesh.entity_comm_sharing(entity->key()).empty() && - ! in_owned_closure( *entity , mesh.parallel_rank() ) ) { - - destroy_dependent_ghosts( mesh , entity ); - } - } -} - -} - -// Resolve modifications for shared entities: -// If not locally destroyed and remotely modified -// then set to locally modified. -// If remotely destroyed then determine the new owner. -// -// Post condition: -// Shared entities are in-sync with respect to modification state. -// Shared communication lists are updated to reflect all deletions. -// Ownership has been re-assigned as necessary for deletion -// of shared entities. - -void BulkData::internal_resolve_shared_modify_delete() -{ - Trace_("stk_classic::mesh::BulkData::internal_resolve_shared_modify_delete"); - - ThrowRequireMsg(parallel_size() > 1, "Do not call this in serial"); - - resolve_shared_removed_from_owned_closure( *this ); - - std::vector< EntityProcState > remote_mod ; - - // Communicate entity modification state for shared entities - // the resulting vector is sorted by entity and process. - const bool communicate_shared = true ; - communicate_entity_modification( *this , communicate_shared , remote_mod ); - - // We iterate backwards over remote_mod to ensure that we hit the - // higher-ranking entities first. - for ( std::vector::reverse_iterator - i = remote_mod.rbegin(); i != remote_mod.rend() ; ) { - - Entity * const entity = i->entity_proc.first ; - const bool locally_destroyed = EntityLogDeleted == entity->log_query(); - bool remote_owner_destroyed = false; - - // Iterate over all of this entity's remote changes - for ( ; i != remote_mod.rend() && i->entity_proc.first == entity ; ++i ) { - - const unsigned remote_proc = i->entity_proc.second ; - const bool remotely_destroyed = EntityLogDeleted == i->state ; - - // When a shared entity is remotely modified or destroyed - // then the local copy is also modified. This modification - // status is applied to all related higher ranking entities. - - if ( ! locally_destroyed ) { - m_entity_repo.log_modified( *entity ); - } - - // A shared entity is being deleted on the remote process. - // Remove it from the sharing communication list. - // Ownership changes are processed later, but we'll need - // to know if the remote owner destroyed the entity in order - // to correctly resolve ownership (it is not sufficient to just - // look at the comm list of the entity since there is no - // guarantee that the comm list is correct or up-to-date). - - if ( remotely_destroyed ) { - m_entity_comm_map.erase(entity->key(), EntityCommInfo(0,remote_proc) ); - - // check if owner is destroying - if ( entity->owner_rank() == remote_proc ) { - remote_owner_destroyed = true ; - } - } - } - - // Have now processed all remote changes knowledge for this entity. - - PairIterEntityComm new_sharing = m_entity_comm_map.sharing(entity->key()); - const bool exists_somewhere = ! ( remote_owner_destroyed && - locally_destroyed && - new_sharing.empty() ); - - // If the entity has been deleted everywhere, nothing left to do - if ( exists_somewhere ) { - - const bool old_local_owner = m_parallel_rank == entity->owner_rank(); - - // Giving away ownership to another process in the sharing list: - const bool give_ownership = locally_destroyed && old_local_owner ; - - // If we are giving away ownership or the remote owner destroyed - // the entity, then we need to establish a new owner - if ( give_ownership || remote_owner_destroyed ) { - - const unsigned new_owner = determine_new_owner( *entity ); - - m_entity_repo.set_entity_owner_rank( *entity, new_owner ); - m_entity_repo.set_entity_sync_count( *entity, m_sync_count ); - } - - if ( ! locally_destroyed ) { - - PartVector add_part , remove_part ; - - if ( new_sharing.empty() ) { - // Is no longer shared, remove the shared part. - remove_part.push_back(& m_mesh_meta_data.globally_shared_part()); - } - - const bool new_local_owner = m_parallel_rank == entity->owner_rank(); - - const bool local_claimed_ownership = - ( ! old_local_owner && new_local_owner ); - - if ( local_claimed_ownership ) { - // Changing remotely owned to locally owned - add_part.push_back( & m_mesh_meta_data.locally_owned_part() ); - } - - if ( ! add_part.empty() || ! remove_part.empty() ) { - internal_change_entity_parts( *entity , add_part , remove_part ); - } - } // if ( ! locally_destroyed ) - } // if ( exists_somewhere ) - } // remote mod loop - - // Erase all sharing communication lists for Destroyed entities: - for ( std::vector::const_reverse_iterator - i = entity_comm().rbegin() ; i != entity_comm().rend() ; ++i) { - Entity * entity = *i ; - - if ( EntityLogDeleted == entity->log_query() ) { - // m_ghosting[0] is the SHARED communication - m_entity_comm_map.erase(entity->key(), *m_ghosting[0] ); - } - } -} - - - -//---------------------------------------------------------------------- -// Resolve modifications for ghosted entities: -// If a ghosted entity is modified or destroyed on the owning -// process then the ghosted entity must be destroyed. -// -// Post condition: -// Ghosted entities of modified or deleted entities are destroyed. -// Ghosted communication lists are cleared to reflect all deletions. - -void BulkData::internal_resolve_ghosted_modify_delete() -{ - Trace_("stk_classic::mesh::BulkData::internal_resolve_ghosted_modify_delete"); - - ThrowRequireMsg(parallel_size() > 1, "Do not call this in serial"); - // Resolve modifications for ghosted entities: - - std::vector remote_mod ; - - // Communicate entity modification state for ghost entities - const bool communicate_shared = false ; - communicate_entity_modification( *this , communicate_shared , remote_mod ); - - const size_t ghosting_count = m_ghosting.size(); - - std::vector< int > ghosting_change_flags( ghosting_count , 0 ); - - // We iterate backwards over remote_mod to ensure that we hit the - // higher-ranking entities first. This is important because higher-ranking - // entities like element must be deleted before the nodes they have are - // deleted. - for ( std::vector::reverse_iterator - i = remote_mod.rbegin(); i != remote_mod.rend() ; ++i ) { - Entity * entity = i->entity_proc.first ; - const unsigned remote_proc = i->entity_proc.second ; - const bool local_owner = entity->owner_rank() == m_parallel_rank ; - const bool remotely_destroyed = EntityLogDeleted == i->state ; - const bool locally_destroyed = EntityLogDeleted == entity->log_query(); - - if ( local_owner ) { // Sending to 'remote_proc' for ghosting - - if ( remotely_destroyed ) { - - // remove from ghost-send list - - for ( size_t j = ghosting_count ; j-- ; ) { - if ( m_entity_comm_map.erase( entity->key(), EntityCommInfo( j , remote_proc ) ) ) { - ghosting_change_flags[ j ] = true ; - } - } - } - - // Remotely modified ghosts are ignored - - } - else { // Receiving from 'remote_proc' for ghosting - - // Owner modified or destroyed, must locally destroy. - - for ( PairIterEntityComm ec = m_entity_comm_map.comm(entity->key()) ; ! ec.empty() ; ++ec ) { - ghosting_change_flags[ ec->ghost_id ] = true ; - } - - // This is a receive ghost so the only communication information - // is the ghosting information, can clear it all out. - m_entity_comm_map.comm_clear(entity->key()); - - if ( ! locally_destroyed ) { - - // If mesh modification causes a ghost entity to become - // a member of an owned-closure then do not automatically - // destroy it. The new sharing status will be resolved - // in 'internal_resolve_parallel_create'. - - if ( ! in_owned_closure( *entity , m_parallel_rank ) ) { - - const bool destroy_entity_successful = destroy_entity(entity); - ThrowRequireMsg(destroy_entity_successful, - "Could not destroy ghost entity " << print_entity_key(entity)); - } - } - } - } // end loop on remote mod - - // Erase all ghosting communication lists for: - // 1) Destroyed entities. - // 2) Owned and modified entities. - - for ( std::vector::const_reverse_iterator - i = entity_comm().rbegin() ; i != entity_comm().rend() ; ++i) { - - Entity & entity = **i ; - - const bool locally_destroyed = EntityLogDeleted == entity.log_query(); - const bool locally_owned_and_modified = - EntityLogModified == entity.log_query() && - m_parallel_rank == entity.owner_rank() ; - - if ( locally_destroyed || locally_owned_and_modified ) { - - // m_ghosting[0] is the SHARED communication - - for ( size_t j = ghosting_count ; j-- ; ) { - if ( m_entity_comm_map.erase( entity.key(), *m_ghosting[j] ) ) { - ghosting_change_flags[ j ] = true ; - } - } - } - } - - std::vector< int > ghosting_change_flags_global( ghosting_count , 0 ); - - all_reduce_sum( m_parallel_machine , - & ghosting_change_flags[0] , - & ghosting_change_flags_global[0] , - ghosting_change_flags.size() ); - - for ( unsigned ic = 0 ; ic < ghosting_change_flags_global.size() ; ++ic ) { - if ( ghosting_change_flags_global[ic] ) { - m_ghosting[ic]->m_sync_count = m_sync_count ; - } - } -} - -//---------------------------------------------------------------------- - -// Postconditions: -// * All shared entities have parallel-consistent owner -// * Part membership of shared entities is up-to-date -// * m_entity_comm is up-to-date -void BulkData::internal_resolve_parallel_create() -{ - Trace_("stk_classic::mesh::BulkData::internal_resolve_parallel_create"); - - ThrowRequireMsg(parallel_size() > 1, "Do not call this in serial"); - - std::vector shared_modified ; - - // Update the parallel index and - // output shared and modified entities. - internal_update_distributed_index( shared_modified ); - - // ------------------------------------------------------------ - // Claim ownership on all shared_modified entities that I own - // and which were not created in this modification cycle. All - // sharing procs will need to be informed of this claim. - CommAll comm_all( m_parallel_machine ); - - for ( int phase = 0; phase < 2; ++phase ) { - for ( std::vector::iterator - i = shared_modified.begin() ; i != shared_modified.end() ; ++i ) { - Entity & entity = **i ; - if ( entity.owner_rank() == m_parallel_rank && - entity.log_query() != EntityLogCreated ) { - - for ( PairIterEntityComm - jc = m_entity_comm_map.sharing(entity.key()) ; ! jc.empty() ; ++jc ) { - comm_all.send_buffer( jc->proc ) .pack( entity.key() ); - } - } - } - - if (phase == 0) { //allocation phase - comm_all.allocate_buffers( m_parallel_size / 4 ); - } - else { // communication phase - comm_all.communicate(); - } - } - - for ( unsigned p = 0 ; p < m_parallel_size ; ++p ) { - CommBuffer & buf = comm_all.recv_buffer( p ); - EntityKey key ; - while ( buf.remaining() ) { - buf.unpack( key ); - - Entity & entity = * get_entity( key ); - - // Set owner, will correct part membership later - m_entity_repo.set_entity_owner_rank( entity, p); - } - } - - // ------------------------------------------------------------ - // Update shared created entities. - // - Revise ownership to selected processor - // - Update sharing. - // - Work backward so the 'in_owned_closure' function - // can evaluate related higher ranking entities. - - std::ostringstream error_msg ; - int error_flag = 0 ; - - PartVector shared_part , owned_part ; - shared_part.push_back( & m_mesh_meta_data.globally_shared_part() ); - owned_part.push_back( & m_mesh_meta_data.locally_owned_part() ); - - std::vector::const_reverse_iterator iend = shared_modified.rend(); - for ( std::vector::const_reverse_iterator - i = shared_modified.rbegin() ; i != iend ; ++i) { - - Entity * entity = *i ; - - if ( entity->owner_rank() == m_parallel_rank && - entity->log_query() == EntityLogCreated ) { - - // Created and not claimed by an existing owner - - const unsigned new_owner = determine_new_owner( *entity ); - - m_entity_repo.set_entity_owner_rank( *entity, new_owner); - } - - if ( entity->owner_rank() != m_parallel_rank ) { - // Do not own it and still have it. - // Remove the locally owned, add the globally_shared - m_entity_repo.set_entity_sync_count( *entity, m_sync_count); - internal_change_entity_parts( *entity , shared_part /*add*/, owned_part /*remove*/); - } - else if ( ! m_entity_comm_map.sharing(entity->key()).empty() ) { - // Own it and has sharing information. - // Add the globally_shared - internal_change_entity_parts( *entity , shared_part /*add*/, PartVector() /*remove*/ ); - } - else { - // Own it and does not have sharing information. - // Remove the globally_shared - internal_change_entity_parts( *entity , PartVector() /*add*/, shared_part /*remove*/); - } - - // Newly created shared entity had better be in the owned closure - if ( ! in_owned_closure( *entity , m_parallel_rank ) ) { - if ( 0 == error_flag ) { - error_flag = 1 ; - error_msg - << "\nP" << m_parallel_rank << ": " << " FAILED\n" - << " The following entities were declared on multiple processors,\n" - << " cannot be parallel-shared, and were declared with" - << " parallel-ghosting information. {\n"; - } - error_msg << " " << print_entity_key(entity); - error_msg << " also declared on" ; - for ( PairIterEntityComm ec = entity->sharing(); ! ec.empty() ; ++ec ) { - error_msg << " P" << ec->proc ; - } - error_msg << "\n" ; - } - } - - // Parallel-consistent error checking of above loop - if ( error_flag ) { error_msg << "}\n" ; } - all_reduce( m_parallel_machine , ReduceMax<1>( & error_flag ) ); - ThrowErrorMsgIf( error_flag, error_msg.str() ); - - // ------------------------------------------------------------ - // Update m_entity_comm based on shared_modified - - const size_t n_old = m_entity_comm.size(); - - m_entity_comm.insert( m_entity_comm.end() , - shared_modified.begin() , shared_modified.end() ); - - std::inplace_merge( m_entity_comm.begin() , - m_entity_comm.begin() + n_old , - m_entity_comm.end() , - EntityLess() ); - - { - std::vector::iterator i = - std::unique( m_entity_comm.begin() , m_entity_comm.end() ); - - m_entity_comm.erase( i , m_entity_comm.end() ); - } -} - -//---------------------------------------------------------------------- - -bool BulkData::modification_end() -{ - Trace_("stk_classic::mesh::BulkData::modification_end"); - - return internal_modification_end( true ); -} - -#if 0 - -namespace { - -// Very, very handy for debugging parallel resolution... - -void print_comm_list( const BulkData & mesh , bool doit ) -{ - if ( doit ) { - std::ostringstream msg ; - - msg << std::endl ; - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - - Entity & entity = **i ; - msg << "P" << mesh.parallel_rank() << ": " ; - - print_entity_key( msg , MetaData::get(mesh) , entity.key() ); - - msg << " owner(" << entity.owner_rank() << ")" ; - - if ( EntityLogModified == entity.log_query() ) { msg << " mod" ; } - else if ( EntityLogDeleted == entity.log_query() ) { msg << " del" ; } - else { msg << " " ; } - - for ( PairIterEntityComm ec = mesh.entity_comm(entity.key()); ! ec.empty() ; ++ec ) { - msg << " (" << ec->ghost_id << "," << ec->proc << ")" ; - } - msg << std::endl ; - } - - std::cout << msg.str(); - } -} - -} - -#endif - -bool BulkData::internal_modification_end( bool regenerate_aura ) -{ - Trace_("stk_classic::mesh::BulkData::internal_modification_end"); - - if ( m_sync_state == SYNCHRONIZED ) { return false ; } - - if (parallel_size() > 1) { - // Resolve modification or deletion of shared entities - // which can cause deletion of ghost entities. - internal_resolve_shared_modify_delete(); - - // Resolve modification or deletion of ghost entities - // by destroying ghost entities that have been touched. - internal_resolve_ghosted_modify_delete(); - - // Resolution of shared and ghost modifications can empty - // the communication information for entities. - // If there is no communication information then the - // entity must be removed from the communication list. - { - std::vector::iterator i = m_entity_comm.begin(); - bool changed = false ; - for ( ; i != m_entity_comm.end() ; ++i ) { - if ( m_entity_comm_map.comm((*i)->key()).empty() ) { *i = NULL ; changed = true ; } - } - if ( changed ) { - i = std::remove( m_entity_comm.begin() , - m_entity_comm.end() , (Entity *) NULL ); - m_entity_comm.erase( i , m_entity_comm.end() ); - } - } - - // Resolve creation of entities: discover sharing and set unique ownership. - internal_resolve_parallel_create(); - - // Resolve part membership for shared entities. - // This occurs after resolving creation so created and shared - // entities are resolved along with previously existing shared entities. - internal_resolve_shared_membership(); - - // Regenerate the ghosting aura around all shared mesh entities. - if ( regenerate_aura ) { internal_regenerate_shared_aura(); } - - // ------------------------------ - // Verify parallel consistency of mesh entities. - // Unique ownership, communication lists, sharing part membership, - // application part membership consistency. - std::ostringstream msg ; - bool is_consistent = true; - is_consistent = comm_mesh_verify_parallel_consistency( *this , msg ); - ThrowErrorMsgIf( !is_consistent, msg.str() ); - } - else { - std::vector shared_modified ; - internal_update_distributed_index( shared_modified ); - } - - // ------------------------------ - // The very last operation performed is to sort the bucket entities. - // This does not change the entities, relations, or field data. - // However, it insures that the ordering of entities and buckets - // is independent of the order in which a set of changes were - // performed. - // - //optimize_buckets combines multiple buckets in a bucket-family into - //a single larger bucket, and also does a sort. - //If optimize_buckets has not been requested, still do the sort. - if (m_optimize_buckets) m_bucket_repository.optimize_buckets(); - else m_bucket_repository.internal_sort_bucket_entities(); - - // ------------------------------ - - m_sync_state = SYNCHRONIZED ; - - return true ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -enum { PART_ORD_UNIVERSAL = 0 }; -enum { PART_ORD_OWNED = 1 }; -enum { PART_ORD_SHARED = 2 }; - -namespace { - -void pack_induced_memberships( CommAll & comm , - const std::vector & entity_comm ) -{ - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( in_shared( entity , entity.owner_rank() ) ) { - // Is shared with owner, send to owner. - - OrdinalVector empty , induced ; - - induced_part_membership( entity , empty , induced ); - - CommBuffer & buf = comm.send_buffer( entity.owner_rank() ); - - unsigned tmp = induced.size(); - - buf.pack( tmp ); - - for ( OrdinalVector::iterator - j = induced.begin() ; j != induced.end() ; ++j ) { - buf.pack( *j ); - } - } - } -} - -void generate_send_list( const size_t sync_count , - const unsigned p_rank , - const std::vector & entity_comm , - std::vector & send_list ) -{ - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( entity.owner_rank() == p_rank && - entity.synchronized_count() == sync_count ) { - - for ( PairIterEntityComm ec = entity.comm() ; ! ec.empty() ; ++ec ) { - EntityProc tmp( & entity , ec->proc ); - send_list.push_back( tmp ); - } - } - } - - { - std::sort( send_list.begin() , send_list.end() , EntityLess() ); - std::vector::iterator i = - std::unique( send_list.begin() , send_list.end() ); - send_list.erase( i , send_list.end() ); - } -} - -void pack_part_memberships( CommAll & comm , - const std::vector & send_list ) -{ - for ( std::vector::const_iterator - i = send_list.begin() ; i != send_list.end() ; ++i ) { - - Entity & entity = * i->first ; - - std::pair - part_ord = entity.bucket().superset_part_ordinals(); - - // I am the owner; therefore, the first three members are - // universal, uses, and owns. Don't send them. - - // I am the owner. The first two memberships are - // universal_part and locally_owned_part. The third - // membership may be globally_shared_part ; - - const unsigned count_all = part_ord.second - part_ord.first ; - const unsigned count_skip = - ( 2 < count_all && part_ord.first[2] == PART_ORD_SHARED ) ? 3 : 2 ; - - const unsigned count_send = count_all - count_skip ; - - const unsigned * const start_send = part_ord.first + count_skip ; - - comm.send_buffer( i->second ).pack( entity.key() ) - .pack( count_send ) - .pack( start_send , count_send ); - } -} - -} - -// Mesh entity membership changes must be synchronized among -// processes that share mesh entities and propagated to -// processes that ghost copies of the mesh entities. -// -// Precondition: correct shared and ghosting lists. -// -// Part memberships may have been added or removed -// either explicitly or indirectly via entity relationships -// being added or removed. - -void BulkData::internal_resolve_shared_membership() -{ - Trace_("stk_classic::mesh::BulkData::internal_resolve_shared_membership"); - - ThrowRequireMsg(parallel_size() > 1, "Do not call this in serial"); - - const MetaData & meta = m_mesh_meta_data ; - ParallelMachine p_comm = m_parallel_machine ; - const unsigned p_rank = m_parallel_rank ; - const unsigned p_size = m_parallel_size ; - const PartVector & all_parts = meta.get_parts(); - - const Part & part_universal = meta.universal_part(); - const Part & part_owned = meta.locally_owned_part(); - const Part & part_shared = meta.globally_shared_part(); - - // Quick verification of part ordinal assumptions - - ThrowRequireMsg(PART_ORD_UNIVERSAL == part_universal.mesh_meta_data_ordinal(), - "Universal part ordinal is wrong, expected " - << PART_ORD_UNIVERSAL << ", got: " - << part_universal.mesh_meta_data_ordinal()); - - ThrowRequireMsg(PART_ORD_OWNED == part_owned.mesh_meta_data_ordinal(), - "Owned part ordinal is wrong, expected " - << PART_ORD_OWNED << ", got: " - << part_owned.mesh_meta_data_ordinal()); - - ThrowRequireMsg(PART_ORD_SHARED == part_shared.mesh_meta_data_ordinal(), - "Shared part ordinal is wrong, expected " - << PART_ORD_SHARED << ", got: " - << part_shared.mesh_meta_data_ordinal()); - - // Shared entities may have been modified due to relationship changes. - // Send just the current induced memberships from the sharing to - // the owning processes. - { - CommAll comm( p_comm ); - - pack_induced_memberships( comm , m_entity_comm ); - - comm.allocate_buffers( p_size / 4 ); - - pack_induced_memberships( comm , m_entity_comm ); - - comm.communicate(); - - for ( std::vector::iterator - i = m_entity_comm.begin() ; i != m_entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( entity.owner_rank() == p_rank ) { - // Receiving from all sharing processes - - OrdinalVector empty , induced_parts , current_parts , remove_parts ; - - induced_part_membership( entity , empty , induced_parts ); - - for ( PairIterEntityComm - ec = entity.sharing() ; ! ec.empty() ; ++ec ) { - - CommBuffer & buf = comm.recv_buffer( ec->proc ); - - unsigned count = 0 ; buf.unpack( count ); - for ( unsigned j = 0 ; j < count ; ++j ) { - unsigned part_ord = 0 ; buf.unpack( part_ord ); - insert_ordinal( induced_parts , part_ord ); - } - } - - // Remove any part that is an induced part but is not - // in the induced parts list. - - entity.bucket().supersets( current_parts ); - - OrdinalVector::const_iterator induced_parts_begin = induced_parts.begin(), - induced_parts_end = induced_parts.end(); - - for ( OrdinalVector::iterator - p = current_parts.begin() ; p != current_parts.end() ; ++p ) { - if ( membership_is_induced( *meta.get_parts()[*p] , entity.entity_rank() ) && - ! contains_ordinal( induced_parts_begin, induced_parts_end , *p ) ) { - remove_parts.push_back( *p ); - } - } - - internal_change_entity_parts( entity, induced_parts, remove_parts ); - } - } - } - - //------------------------------ - // The owners have complete knowledge of memberships. - // Send membership information to sync the shared and ghosted copies. - // Only need to do this for entities that have actually changed. - - { - std::vector send_list ; - - generate_send_list( m_sync_count, p_rank, m_entity_comm, send_list); - - CommAll comm( p_comm ); - - pack_part_memberships( comm , send_list ); - - comm.allocate_buffers( p_size / 4 ); - - pack_part_memberships( comm , send_list ); - - comm.communicate(); - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = comm.recv_buffer( p ); - while ( buf.remaining() ) { - - PartVector owner_parts , current_parts , remove_parts ; - - EntityKey key ; buf.unpack( key ); - unsigned count = 0 ; buf.unpack( count ); - for ( unsigned j = 0 ; j < count ; ++j ) { - unsigned part_ord = 0 ; buf.unpack( part_ord ); - insert( owner_parts , * all_parts[ part_ord ] ); - } - - // Any current part that is not a member of owners_parts - // must be removed. - - Entity * const entity = find_entity(m_entity_comm, key, true); - - entity->bucket().supersets( current_parts ); - - for ( PartVector::iterator - ip = current_parts.begin() ; ip != current_parts.end() ; ++ip ) { - Part * const part = *ip ; - const unsigned part_ord = part->mesh_meta_data_ordinal(); - if ( PART_ORD_UNIVERSAL != part_ord && - PART_ORD_OWNED != part_ord && - PART_ORD_SHARED != part_ord && - ! contain( owner_parts , *part ) ) { - remove_parts.push_back( part ); - } - } - - internal_change_entity_parts( *entity , owner_parts , remove_parts ); - } - } - } -} - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataGhosting.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataGhosting.cpp deleted file mode 100644 index c287efaa7679..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataGhosting.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using std::strcmp; - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -Ghosting & BulkData::create_ghosting( const std::string & name ) -{ - Trace_("stk_classic::mesh::BulkData::create_ghosting"); - - require_ok_to_modify(); - - // Verify name is the same on all processors, - // if not then throw an exception on all processors. - if (parallel_size() > 1) { - CommBroadcast bc( parallel() , 0 ); - - if ( bc.parallel_rank() == 0 ) { - bc.send_buffer().skip( name.size() + 1 ); - } - - bc.allocate_buffer(); - - if ( bc.parallel_rank() == 0 ) { - bc.send_buffer().pack( name.c_str() , name.size() + 1 ); - } - - bc.communicate(); - - const char * const bc_name = - reinterpret_cast( bc.recv_buffer().buffer() ); - - int error = 0 != strcmp( bc_name , name.c_str() ); - - all_reduce( parallel() , ReduceMax<1>( & error ) ); - - ThrowErrorMsgIf( error, "Parallel name inconsistency"); - } - - Ghosting * const g = - new Ghosting( *this , name , m_ghosting.size() , m_sync_count ); - - m_ghosting.push_back( g ); - - return *g ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -void insert_transitive_closure( std::set & new_send , - const EntityProc & entry ); - -void comm_recv_to_send( - BulkData & mesh , - const std::set< Entity * , EntityLess > & new_recv , - std::set< EntityProc , EntityLess > & new_send ); - -void comm_sync_send_recv( - BulkData & mesh , - std::set< EntityProc , EntityLess > & new_send , - std::set< Entity * , EntityLess > & new_recv ); - -} // namespace <> - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void BulkData::destroy_all_ghosting() -{ - Trace_("stk_classic::mesh::BulkData::destroy_all_ghosting"); - - require_ok_to_modify(); - - // Clear Ghosting data - - for ( std::vector::iterator - ig = m_ghosting.begin() ; ig != m_ghosting.end() ; ++ig ) { - Ghosting & gh = **ig ; - gh.m_sync_count = m_sync_count ; - } - - // Iterate backwards so as not to invalidate a closure. - - std::vector::iterator ie = m_entity_comm.end(); - - while ( ie != m_entity_comm.begin() ) { - - Entity * entity = *--ie ; - - if ( in_receive_ghost( *entity ) ) { - m_entity_comm_map.comm_clear(entity->key()); - destroy_entity( entity ); - *ie = NULL ; - } - else { - m_entity_comm_map.comm_clear_ghosting(entity->key()); - if ( m_entity_comm_map.comm(entity->key()).empty() ) { - *ie = NULL ; - } - } - } - - ie = std::remove( m_entity_comm.begin() , - m_entity_comm.end() , (Entity*) NULL ); - - m_entity_comm.erase( ie , m_entity_comm.end() ); -} - -//---------------------------------------------------------------------- - -void BulkData::change_ghosting( - Ghosting & ghosts , - const std::vector & add_send , - const std::vector & remove_receive ) -{ - Trace_("stk_classic::mesh::BulkData::change_ghosting"); - - //---------------------------------------- - // Verify inputs: - - require_ok_to_modify(); - - const bool ok_mesh = & BulkData::get(ghosts) == this ; - const bool ok_ghost = 1 < ghosts.ordinal(); - bool ok_add = true ; - bool ok_remove = true ; - - // Verify all 'add' are locally owned. - - for ( std::vector::const_iterator - i = add_send.begin() ; ok_add && i != add_send.end() ; ++i ) { - ok_add = i->first->owner_rank() == parallel_rank(); - } - - // Verify all 'remove' are members of the ghosting. - - for ( std::vector::const_iterator - i = remove_receive.begin() ; - ok_remove && i != remove_receive.end() ; ++i ) { - ok_remove = in_receive_ghost( ghosts , **i ); - } - - int ok = ok_mesh && ok_ghost && ok_add && ok_remove ; - - all_reduce( parallel() , ReduceMin<1>( & ok ) ); - - if ( 0 == ok ) { - std::ostringstream msg ; - msg << "For ghosts " << ghosts.name() << ", " ; - if ( ! ok_mesh ) { msg << " : Mesh does not own this ghosting" ; } - if ( ! ok_ghost ) { msg << " : Cannot modify this ghosting" ; } - if ( ! ok_add ) { - msg << " : Not owned add {" ; - for ( std::vector::const_iterator - i = add_send.begin() ; i != add_send.end() ; ++i ) { - if ( i->first->owner_rank() != parallel_rank() ) { - msg << " " << print_entity_key( i->first ); - } - } - msg << " }" ; - } - if ( ! ok_remove ) { - msg << " : Not in ghost receive {" ; - for ( std::vector::const_iterator - i = remove_receive.begin() ; i != remove_receive.end() ; ++i ) { - if ( ! in_receive_ghost( ghosts , **i ) ) { - msg << " " << print_entity_key( *i ); - } - } - } - - ThrowErrorMsg( msg.str() ); - } - //---------------------------------------- - // Change the ghosting: - - internal_change_ghosting( ghosts , add_send , remove_receive ); -} - -//---------------------------------------------------------------------- - -void BulkData::internal_change_ghosting( - Ghosting & ghosts , - const std::vector & add_send , - const std::vector & remove_receive ) -{ - Trace_("stk_classic::mesh::BulkData::internal_change_ghosting"); - - const MetaData & meta = m_mesh_meta_data ; - const unsigned rank_count = meta.entity_rank_count(); - const unsigned p_size = m_parallel_size ; - - //------------------------------------ - // Copy ghosting lists into more efficiently editted container. - // The send and receive lists must be in entity rank-order. - - std::set< EntityProc , EntityLess > new_send ; - std::set< Entity * , EntityLess > new_recv ; - - //------------------------------------ - // Insert the current ghost receives and then remove from that list. - - // This if-check is an optimization; if remove_receive is m_entity_comm, - // then we are removing all ghosting information and new_recv should - // be left empty. - if ( & entity_comm() != & remove_receive ) { - - // Iterate over all entities with communication information, adding - // the entity if it's a ghost on this process. new_recv will contain - // all ghosts on this process by the end of the loop. - for ( std::vector::const_iterator - i = entity_comm().begin() ; i != entity_comm().end() ; ++i ) { - Entity * const entity = *i ; - if ( in_receive_ghost( ghosts , *entity ) ) { - new_recv.insert( entity ); - } - } - - // Remove any entities that are in the remove list. - - for ( std::vector< Entity * >::const_iterator - i = remove_receive.begin() ; i != remove_receive.end() ; ++i ) { - new_recv.erase( *i ); - } - - // Keep the closure of the remaining received ghosts. - // Working from highest-to-lowest key (rank entity type) - // results in insertion of the closure because - // inserted entities will get looped over after they are inserted. - - // Insertion will not invalidate the associative container's iterator. - - for ( std::set< Entity * , EntityLess >::reverse_iterator - i = new_recv.rbegin() ; i != new_recv.rend() ; ++i) { - const unsigned erank = (*i)->entity_rank(); - - for ( PairIterRelation - irel = (*i)->relations(); ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < erank && - in_receive_ghost( ghosts , * irel->entity() ) ) { - new_recv.insert( irel->entity() ); - } - } - } - } - - // Initialize the new_send from the new_recv - comm_recv_to_send( *this , new_recv , new_send ); - - //------------------------------------ - // Add the specified entities and their closure to the send ghosting - - for ( std::vector< EntityProc >::const_iterator - i = add_send.begin() ; i != add_send.end() ; ++i ) { - insert_transitive_closure( new_send , *i ); - } - - // Synchronize the send and receive list. - // If the send list contains a not-owned entity - // inform the owner and receiver to add that entity - // to their ghost send and receive lists. - - comm_sync_send_recv( *this , new_send , new_recv ); - - // The new_send list is now parallel complete and parallel accurate - // The new_recv has those ghost entities that are to be kept. - //------------------------------------ - // Remove the ghost entities that will not remain. - // If the last reference to the receive ghost entity then delete it. - - bool removed = false ; - - for ( std::vector::reverse_iterator - i = m_entity_comm.rbegin() ; i != m_entity_comm.rend() ; ++i) { - Entity * entity = *i ; - - const bool is_owner = entity->owner_rank() == m_parallel_rank ; - const bool remove_recv = ( ! is_owner ) && - 0 == new_recv.count( entity ); - - if ( is_owner ) { - // Is owner, potentially removing ghost-sends - // Have to make a copy - - std::vector comm_ghost ; - const PairIterEntityComm ec = m_entity_comm_map.comm(entity->key(),ghosts); - comm_ghost.assign( ec.first , ec.second ); - - for ( ; ! comm_ghost.empty() ; comm_ghost.pop_back() ) { - const EntityCommInfo tmp = comm_ghost.back(); - - if ( 0 == new_send.count( EntityProc( entity , tmp.proc ) ) ) { - m_entity_comm_map.erase(entity->key(),tmp); - } - } - } - else if ( remove_recv ) { - m_entity_comm_map.erase(entity->key(),ghosts); - } - - if ( m_entity_comm_map.comm(entity->key()).empty() ) { - removed = true ; - *i = NULL ; // No longer communicated - if ( remove_recv ) { - ThrowRequireMsg( destroy_entity( entity ), - " FAILED attempt to destroy entity: " << print_entity_key(entity) ); - } - } - } - - if ( removed ) { - std::vector::iterator i = - std::remove( m_entity_comm.begin() , - m_entity_comm.end() , (Entity*) NULL ); - m_entity_comm.erase( i , m_entity_comm.end() ); - } - - //------------------------------------ - // Push newly ghosted entities to the receivers and update the comm list. - // Unpacking must proceed in entity-rank order so that higher ranking - // entities that have relations to lower ranking entities will have - // the lower ranking entities unpacked first. The higher and lower - // ranking entities may be owned by different processes, - // as such unpacking must be performed in rank order. - - { - const size_t entity_comm_size = m_entity_comm.size(); - - CommAll comm( m_parallel_machine ); - - for ( std::set< EntityProc , EntityLess >::iterator - j = new_send.begin(); j != new_send.end() ; ++j ) { - - Entity & entity = * j->first ; - const unsigned int proc = j->second ; - - if ( ! in_ghost( ghosts , entity , proc ) ) { - // Not already being sent , must send it. - CommBuffer & buf = comm.send_buffer( proc ); - buf.pack( entity.entity_rank() ); - pack_entity_info( buf , entity ); - pack_field_values( buf , entity ); - } - } - - comm.allocate_buffers( p_size / 4 ); - - for ( std::set< EntityProc , EntityLess >::iterator - j = new_send.begin(); j != new_send.end() ; ++j ) { - - Entity & entity = * j->first ; - const unsigned int proc = j->second ; - - if ( ! in_ghost( ghosts , entity , proc ) ) { - // Not already being sent , must send it. - CommBuffer & buf = comm.send_buffer( proc ); - buf.pack( entity.entity_rank() ); - pack_entity_info( buf , entity ); - pack_field_values( buf , entity ); - - m_entity_comm_map.insert(entity.key(), EntityCommInfo(ghosts.ordinal(), proc)); - - m_entity_comm.push_back( & entity ); - } - } - - comm.communicate(); - - std::ostringstream error_msg ; - int error_count = 0 ; - - for ( unsigned rank = 0 ; rank < rank_count ; ++rank ) { - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = comm.recv_buffer(p); - while ( buf.remaining() ) { - // Only unpack if of the current entity rank. - // If not the current entity rank, break the iteration - // until a subsequent entity rank iteration. - { - unsigned this_rank = ~0u ; - buf.peek( this_rank ); - - if ( this_rank != rank ) break ; - - buf.unpack( this_rank ); - } - - PartVector parts ; - std::vector relations ; - EntityKey key ; - unsigned owner = ~0u ; - - unpack_entity_info( buf, *this, key, owner, parts, relations ); - - // Must not have the locally_owned_part or globally_shared_part - - remove( parts , meta.locally_owned_part() ); - remove( parts , meta.globally_shared_part() ); - - std::pair result = - m_entity_repo.internal_create_entity( key ); - - Entity* entity = result.first; - const bool created = result.second ; - const bool recreated = EntityLogDeleted == entity->log_query(); - - if ( created || recreated ) { - m_entity_repo.log_created_parallel_copy( *(entity) ); - m_entity_repo.set_entity_owner_rank( *(entity), owner); - } - - require_entity_owner( * entity , owner ); - - internal_change_entity_parts( * entity , parts , PartVector() ); - - declare_relation( * entity , relations ); - - if ( ! unpack_field_values( buf , * entity , error_msg ) ) { - ++error_count ; - } - - const EntityCommInfo tmp( ghosts.ordinal() , owner ); - - if ( m_entity_comm_map.insert(entity->key(),tmp) ) { - m_entity_comm.push_back( entity ); - } - } - } - } - - if (parallel_size() > 1) { - all_reduce( m_parallel_machine , ReduceSum<1>( & error_count ) ); - } - - ThrowErrorMsgIf( error_count, error_msg.str() ); - - if ( entity_comm_size < m_entity_comm.size() ) { - // Added new ghosting entities to the list, - // must now sort and merge. - - std::vector::iterator i = m_entity_comm.begin(); - i += entity_comm_size ; - std::sort( i , m_entity_comm.end() , EntityLess() ); - std::inplace_merge( m_entity_comm.begin() , i , - m_entity_comm.end() , EntityLess() ); - m_entity_comm.erase( std::unique( m_entity_comm.begin() , m_entity_comm.end() ) , - m_entity_comm.end() ); - } - } - - ghosts.m_sync_count = m_sync_count ; -} - -//---------------------------------------------------------------------- - -namespace { - -void insert_transitive_closure( std::set & new_send , - const EntityProc & entry ) -{ - // Do not insert if I can determine that this entity is already - // owned or shared by the receiving processor. - - if ( entry.second != entry.first->owner_rank() && - ! in_shared( * entry.first , entry.second ) ) { - - std::pair< std::set::iterator , bool > - result = new_send.insert( entry ); - - if ( result.second ) { - // A new insertion, must also insert the closure - - const unsigned etype = entry.first->entity_rank(); - PairIterRelation irel = entry.first->relations(); - - for ( ; ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < etype ) { - EntityProc tmp( irel->entity() , entry.second ); - insert_transitive_closure( new_send , tmp ); - } - } - } - } -} - -// Fill a new send list from the receive list. - -void comm_recv_to_send( - BulkData & mesh , - const std::set< Entity * , EntityLess > & new_recv , - std::set< EntityProc , EntityLess > & new_send ) -{ - const unsigned parallel_size = mesh.parallel_size(); - - CommAll all( mesh.parallel() ); - - for ( int phase = 0; phase < 2; ++phase) { - for ( std::set< Entity * , EntityLess >::const_iterator - i = new_recv.begin() ; i != new_recv.end() ; ++i ) { - const unsigned owner = (*i)->owner_rank(); - const EntityKey key = (*i)->key(); - all.send_buffer( owner ).pack( key ); - } - if (phase == 0) { //allocation phase - all.allocate_buffers( parallel_size / 4 , false /* Not symmetric */ ); - } - else { //communication phase - all.communicate(); - } - } - - for ( unsigned proc_rank = 0 ; proc_rank < parallel_size ; ++proc_rank ) { - CommBuffer & buf = all.recv_buffer(proc_rank); - while ( buf.remaining() ) { - EntityKey key ; - buf.unpack( key ); - EntityProc tmp( mesh.get_entity( key ) , proc_rank ); - new_send.insert( tmp ); - } - } -} - -// Synchronize the send list to the receive list. - -void comm_sync_send_recv( - BulkData & mesh , - std::set< EntityProc , EntityLess > & new_send , - std::set< Entity * , EntityLess > & new_recv ) -{ - const unsigned parallel_rank = mesh.parallel_rank(); - const unsigned parallel_size = mesh.parallel_size(); - - CommAll all( mesh.parallel() ); - - // Communication sizing: - - for ( std::set< EntityProc , EntityLess >::iterator - i = new_send.begin() ; i != new_send.end() ; ++i ) { - const unsigned owner = i->first->owner_rank(); - all.send_buffer( i->second ).skip(2); - if ( owner != parallel_rank ) { - all.send_buffer( owner ).skip(2); - } - } - - all.allocate_buffers( parallel_size / 4 , false /* Not symmetric */ ); - - // Communication packing (with message content comments): - for ( std::set< EntityProc , EntityLess >::iterator - i = new_send.begin() ; i != new_send.end() ; ) { - const unsigned owner = i->first->owner_rank(); - - // Inform receiver of ghosting, the receiver does not own - // and does not share this entity. - // The ghost either already exists or is a to-be-done new ghost. - // This status will be resolved on the final communication pass - // when new ghosts are packed and sent. - - const EntityKey &entity_key = i->first->key(); - const uint64_t &proc = i->second; - - all.send_buffer( i->second ).pack(entity_key).pack(proc); - - if ( owner != parallel_rank ) { - // I am not the owner of this entity. - // Inform the owner of this ghosting need. - all.send_buffer( owner ).pack(entity_key).pack(proc); - - // Erase it from my processor's ghosting responsibility: - // The iterator passed to the erase method will be invalidated. - std::set< EntityProc , EntityLess >::iterator jrem = i ; ++i ; - new_send.erase( jrem ); - } - else { - ++i ; - } - } - - all.communicate(); - - // Communication unpacking: - for ( unsigned p = 0 ; p < parallel_size ; ++p ) { - CommBuffer & buf = all.recv_buffer(p); - while ( buf.remaining() ) { - - EntityKey entity_key; - uint64_t proc(0); - - buf.unpack(entity_key).unpack(proc); - - Entity * const e = mesh.get_entity( entity_key ); - - if ( parallel_rank != proc ) { - // Receiving a ghosting need for an entity I own. - // Add it to my send list. - ThrowRequireMsg( e != NULL, - "Unknown entity key: " << - MetaData::get(mesh).entity_rank_name(entity_key.rank()) << - "[" << entity_key.id() << "]"); - EntityProc tmp( e , proc ); - new_send.insert( tmp ); - } - else if ( e != NULL ) { - // I am the receiver for this ghost. - // If I already have it add it to the receive list, - // otherwise don't worry about it - I will receive - // it in the final new-ghosting communication. - new_recv.insert( e ); - } - } - } -} - -void insert_upward_relations(Entity& rel_entity, - const EntityRank rank_of_orig_entity, - const unsigned my_rank, - const unsigned share_proc, - std::vector& send) -{ - // If related entity is higher rank, I own it, and it is not - // already shared by proc, ghost it to the sharing processor. - if ( rank_of_orig_entity < rel_entity.entity_rank() && - rel_entity.owner_rank() == my_rank && - ! in_shared( rel_entity , share_proc ) ) { - - EntityProc entry( &rel_entity , share_proc ); - send.push_back( entry ); - - // There may be even higher-ranking entities that need to be ghosted, so we must recurse - for ( PairIterRelation rel = rel_entity.relations() ; ! rel.empty() ; ++rel ) { - Entity * const rel_of_rel_entity = rel->entity(); - insert_upward_relations(*rel_of_rel_entity, rel_entity.entity_rank(), my_rank, share_proc, send); - } - } -} - -} // namespace <> - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void BulkData::internal_regenerate_shared_aura() -{ - Trace_("stk_classic::mesh::BulkData::internal_regenerate_shared_aura"); - - require_ok_to_modify(); - - std::vector send ; - - // Iterate over all entities with communication info, get the sharing - // comm info for each entity, and ensure that upwardly related - // entities to the shared entity are ghosted on the sharing proc. - for ( std::vector::const_iterator - i = entity_comm().begin() ; i != entity_comm().end() ; ++i ) { - - Entity & entity = **i ; - - const unsigned erank = entity.entity_rank(); - - const PairIterEntityComm sharing = entity.sharing(); - - for ( size_t j = 0 ; j < sharing.size() ; ++j ) { - - const unsigned share_proc = sharing[j].proc ; - - for ( PairIterRelation rel = entity.relations() ; ! rel.empty() ; ++rel ) { - - Entity * const rel_entity = rel->entity(); - - insert_upward_relations(*rel_entity, erank, m_parallel_rank, share_proc, send); - } - } - } - - // Add new aura, remove all of the old aura. - // The change_ghosting figures out what to actually delete and add. - internal_change_ghosting( shared_aura() , send , m_entity_comm ); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataOwner.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataOwner.cpp deleted file mode 100644 index e2aa56125200..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataOwner.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -namespace { - -// Given an entity, if it's a ghost, insert the closure of the entity -// into work_list. -void insert_closure_ghost( Entity * const entity , - const unsigned proc_local , - std::set & work_list ) -{ - if ( ! in_owned_closure( *entity , proc_local ) ) { - // This entity is a ghost, put it on the work_list - // along with all ghosts in its closure - - std::pair< std::set::iterator , bool > - result = work_list.insert( entity ); - - if ( result.second ) { - // This ghost entity is new to the list, traverse its closure. - - const unsigned entity_rank = entity->entity_rank(); - - // Recurse over downward relations - for ( PairIterRelation - irel = entity->relations() ; ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < entity_rank ) { - insert_closure_ghost( irel->entity() , proc_local ,work_list ); - } - } - } - } -} - -// Given an entity, insert the closures of every entity that has this entity -// in its closure. Only ghosts will be inserted. -void insert_transitive_ghost( Entity * const entity , - const unsigned proc_local , - std::set & work_list ) -{ - insert_closure_ghost( entity , proc_local , work_list ); - - // Transitive: - // If this entity is a member of another entity's closure - // then that other entity is part of the traversal. - - const unsigned entity_rank = entity->entity_rank(); - - // Recurse over upward relations - for ( PairIterRelation rel = entity->relations(); ! rel.empty() ; ++rel ) { - if ( entity_rank < rel->entity_rank() ) { - insert_transitive_ghost( rel->entity() , proc_local , work_list ); - } - } -} - -//---------------------------------------------------------------------- - -// Add EntityProc pairs to send_list for every entity in the closure of the -// entity in send_entry. All these entities will be sent to the same proc as -// the original send_entry. -void insert_closure_send( - const EntityProc send_entry , - std::set & send_list ) -{ - ThrowRequireMsg( send_entry.first->log_query() != EntityLogDeleted, - "Cannot send destroyed entity " << print_entity_key(send_entry.first)); - - std::pair< std::set::iterator , bool > - result = send_list.insert( send_entry ); - - if ( result.second ) { - // First time this entity was inserted into the send_list. - - const unsigned erank = send_entry.first->entity_rank(); - PairIterRelation irel = send_entry.first->relations(); - - // Recurse over downward relations - for ( ; ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < erank ) { - const EntityProc rel_send_entry( irel->entity(), send_entry.second ); - - insert_closure_send( rel_send_entry , send_list ); - } - } - } -} - -//---------------------------------------------------------------------- - -bool member_of_owned_closure( const Entity & e , const unsigned p_rank ) -{ - bool result = p_rank == e.owner_rank(); - - const unsigned entity_rank = e.entity_rank(); - - // Any higher ranking entities locally owned? - for ( PairIterRelation - irel = e.relations(); ! result && ! irel.empty() ; ++irel ) { - result = entity_rank < irel->entity_rank() && - p_rank == irel->entity()->owner_rank(); - } - - // Any higher ranking entity member of an owned closure? - for ( PairIterRelation - irel = e.relations(); ! result && ! irel.empty() ; ++irel ) { - result = entity_rank < irel->entity_rank() && - member_of_owned_closure( * irel->entity() , p_rank ); - } - - return result ; -} - -//---------------------------------------------------------------------- - -// Given a vector of local ownership changes, remove duplicates and -// sanity check. -void clean_and_verify_parallel_change( - const BulkData & mesh , - std::vector & local_change ) -{ - const MetaData & meta = MetaData::get(mesh); - const unsigned p_rank = mesh.parallel_rank(); - const unsigned p_size = mesh.parallel_size(); - const ParallelMachine p_comm = mesh.parallel(); - - size_t error_count = 0 ; - - std::ostringstream error_msg ; - - // Order and eliminate redundancies: - { - std::vector::iterator i = local_change.begin() , - j = local_change.end() ; - std::sort( i , j , EntityLess() ); - i = std::unique( i , j ); - local_change.erase( i , j ); - } - - for ( std::vector::iterator - i = local_change.begin() ; i != local_change.end() ; ++i ) { - std::vector::iterator next = i+1 ; - Entity * const entity = i->first ; - const unsigned new_owner = i->second ; - - // Verification: - // 1) Cannot change the ownership of an entity that you've already marked as deleted - // 2) Cannot change the ownership of an entity you do not own - // 3) New owner must exist - // 4) Cannot grant ownership to two different owners - - const bool bad_null = NULL == entity ; - - // Cannot change the ownership of an entity that you've already marked as deleted - const bool bad_marked_deleted = ! bad_null && EntityLogDeleted == entity->log_query(); - - // Cannot change the ownership of an entity you do not own - const bool bad_process_not_entity_owner = ! bad_null && entity->owner_rank() != p_rank ; - - // New owner must exist - const bool bad_new_owner_does_not_exist = p_size <= new_owner ; - - // Cannot grant ownership to two different owners - const bool bad_inconsistent_change = ! bad_null && next != local_change.end() && entity == next->first ; - - if ( bad_null || - bad_process_not_entity_owner || - bad_new_owner_does_not_exist || - bad_inconsistent_change || - bad_marked_deleted) - { - ++error_count ; - - error_msg << " P" << p_rank << ": " ; - if ( bad_null ) { error_msg << " NULL ENTITY" ; } - else { print_entity_key( error_msg , meta , entity->key() ); } - if ( bad_marked_deleted ) { error_msg << " HAS_BEEN_DELETED" ; } - if ( bad_process_not_entity_owner ) { error_msg << " NOT_CURRENT_OWNER" ; } - if ( bad_new_owner_does_not_exist ) { - error_msg << " BAD_NEW_OWNER( " << new_owner << " )" ; - } - if ( bad_inconsistent_change ) { - error_msg << " CONFLICTING_NEW_OWNER( " << new_owner ; - error_msg << " != " << next->second << " )" ; - } - error_msg << std::endl ; - } - else if ( new_owner == p_rank ) { - // Eliminate non-changes - i->first = NULL ; - i->second = 0 ; - } - } - - all_reduce( p_comm , ReduceSum<1>( & error_count ) ); - - if ( error_count ) { - all_write_string( p_comm , std::cerr , error_msg.str() ); - - ThrowErrorMsg("Bad change ownership directives\n"); - } - - // Filter out non-changes (entity will be NULL - { - std::vector::iterator i = local_change.begin(), - j = local_change.end(); - i = std::remove( i , j , EntityProc(NULL,0) ); - local_change.erase( i , j ); - } -} - -//---------------------------------------------------------------------- -// Generate a parallel consistent list of ownership changes: -// 1) Shared entities (not owned but in closure of an owned entity), -// 2) Ghosted entities (not owned and not in closure of an owned entity), and -// 3) Parallel index. - -void generate_parallel_change( const BulkData & mesh , - const std::vector & local_change , - std::vector & shared_change , - std::vector & ghosted_change ) -{ - const unsigned p_size = mesh.parallel_size(); - - CommAll comm( mesh.parallel() ); - - std::vector procs ; - - // pack and communicate change owner information to all - // processes that know about the entity - for ( int phase = 0; phase < 2; ++phase) { - for ( std::vector::const_iterator - ip = local_change.begin() ; ip != local_change.end() ; ++ip ) { - Entity & entity = * ip->first ; - unsigned new_owner = ip->second; - comm_procs( entity , procs ); - for ( std::vector::iterator - j = procs.begin() ; j != procs.end() ; ++j ) - { - comm.send_buffer( *j ) - .pack( entity.key() ) - .pack( new_owner ); - } - } - if (phase == 0) { // allocation phase - comm.allocate_buffers( p_size / 4 , 0 ); - } - else { // communication phase - comm.communicate(); - } - } - - // unpack communicated owner information into the - // ghosted and shared change vectors. - for ( unsigned ip = 0 ; ip < p_size ; ++ip ) { - CommBuffer & buf = comm.recv_buffer( ip ); - while ( buf.remaining() ) { - EntityProc entry ; - EntityKey key ; - buf.unpack( key ) - .unpack( entry.second ); - - entry.first = mesh.get_entity( key ); - - if ( in_receive_ghost( * entry.first ) ) { - ghosted_change.push_back( entry ); - } - else { - shared_change.push_back( entry ); - } - } - } - - std::sort( shared_change.begin() , shared_change.end() , EntityLess() ); - std::sort( ghosted_change.begin() , ghosted_change.end() , EntityLess() ); -} - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void BulkData::change_entity_owner( const std::vector & arg_change ) -{ - Trace_("stk_classic::mesh::BulkData::change_entity_owner"); - DiagIf(LOG_ENTITY, "arg_change: " << arg_change); - - const MetaData & meta = m_mesh_meta_data ; - const unsigned p_rank = m_parallel_rank ; - const unsigned p_size = m_parallel_size ; - ParallelMachine p_comm = m_parallel_machine ; - - //------------------------------ - // Verify the input changes, generate a clean local change list, and - // generate the remote change list so that all processes know about - // pending changes. - - std::vector local_change( arg_change ); - - // Parallel synchronous clean up and verify the requested changes: - clean_and_verify_parallel_change( *this , local_change ); - - //---------------------------------------- - // Parallel synchronous determination of changing shared and ghosted. - - // The two vectors below will contain changes to ghosted and shared - // entities on this process coming from change-entity-owner requests - // on other processes. - std::vector ghosted_change ; - std::vector shared_change ; - - generate_parallel_change( *this , local_change , - shared_change , ghosted_change ); - - //------------------------------ - // Have enough information to delete all effected ghosts. - // If the closure of a ghost contains a changing entity - // then that ghost must be deleted. - // Request that all ghost entities in the closure of the ghost be deleted. - - typedef std::set EntityProcSet; - typedef std::set EntitySet; - - // Compute the closure of all the locally changing entities - EntityProcSet send_closure ; - for ( std::vector::iterator - i = local_change.begin() ; i != local_change.end() ; ++i ) { - insert_closure_send( *i , send_closure ); - } - - // Calculate all the ghosts that are impacted by the set of ownership - // changes. We look at ghosted, shared, and local changes looking for ghosts - // that are either in the closure of the changing entity, or have the - // changing entity in their closure. All modified ghosts will be removed. - { - EntitySet modified_ghosts ; - - for ( std::vector::const_iterator - i = ghosted_change.begin() ; i != ghosted_change.end() ; ++i ) { - insert_transitive_ghost( i->first , m_parallel_rank , modified_ghosts ); - } - - for ( std::vector::const_iterator - i = shared_change.begin() ; i != shared_change.end() ; ++i ) { - insert_transitive_ghost( i->first , m_parallel_rank , modified_ghosts ); - } - - for ( EntityProcSet::iterator - i = send_closure.begin() ; i != send_closure.end() ; ++i ) { - insert_transitive_ghost( i->first , m_parallel_rank , modified_ghosts ); - } - - // The ghosted change list will become invalid - ghosted_change.clear(); - - std::vector empty_add ; - std::vector remove_modified_ghosts( modified_ghosts.begin() , - modified_ghosts.end() ); - - // Skip 'm_ghosting[0]' which is the shared subset. - for ( std::vector::iterator - ig = m_ghosting.begin() + 1; ig != m_ghosting.end() ; ++ig ) { - // parallel synchronous: - internal_change_ghosting( **ig , empty_add , remove_modified_ghosts ); - } - } - - //------------------------------ - // Consistently change the owner on all processes. - // 1) The local_change list is giving away ownership. - // 2) The shared_change may or may not be receiving ownership - - { - PartVector owned; - owned.push_back(& meta.locally_owned_part()); - - for ( std::vector::iterator - i = local_change.begin() ; i != local_change.end() ; ++i ) { - // Giving ownership, change the parts first and then - // the owner rank to pass the ownership test. - Entity* entity = i->first; - - change_entity_parts( *entity , PartVector() , owned ); - - m_entity_repo.set_entity_owner_rank( *entity, i->second ); - } - - for ( std::vector::iterator - i = shared_change.begin() ; i != shared_change.end() ; ++i ) { - Entity* entity = i->first; - m_entity_repo.set_entity_owner_rank( *entity, i->second); - if ( p_rank == i->second ) { // I receive ownership - change_entity_parts( *entity , owned , PartVector() ); - } - } - } - - //------------------------------ - // Send entities, along with their closure, to the new owner processes - { - std::ostringstream error_msg ; - int error_count = 0 ; - - CommAll comm( p_comm ); - - for ( std::set::iterator - i = send_closure.begin() ; i != send_closure.end() ; ++i ) { - CommBuffer & buffer = comm.send_buffer( i->second ); - Entity & entity = * i->first ; - pack_entity_info( buffer , entity ); - pack_field_values( buffer , entity ); - } - - comm.allocate_buffers( p_size / 4 ); - - for ( std::set::iterator - i = send_closure.begin() ; i != send_closure.end() ; ++i ) { - CommBuffer & buffer = comm.send_buffer( i->second ); - Entity & entity = * i->first ; - pack_entity_info( buffer , entity ); - pack_field_values( buffer , entity ); - } - - comm.communicate(); - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = comm.recv_buffer(p); - while ( buf.remaining() ) { - PartVector parts ; - std::vector relations ; - EntityKey key ; - unsigned owner = ~0u ; - - unpack_entity_info( buf, *this, key, owner, parts, relations ); - - // Received entity information will be correct, - // modulo the owned and shared parts - - remove( parts , meta.globally_shared_part() ); - - if ( owner == p_rank ) { - // Must have the locally_owned_part - insert( parts , meta.locally_owned_part() ); - } - else { - // Must not have the locally_owned_part - remove( parts , meta.locally_owned_part() ); - } - - std::pair result = - m_entity_repo.internal_create_entity( key ); - - Entity* entity = result.first; - - m_entity_repo.log_created_parallel_copy( *entity ); - - // The entity was copied and not created. - - m_entity_repo.set_entity_owner_rank( *entity, owner); - - internal_change_entity_parts( *entity , parts , PartVector() ); - - declare_relation( *entity , relations ); - - if ( ! unpack_field_values( buf , *entity , error_msg ) ) { - ++error_count ; - } - } - } - - all_reduce( p_comm , ReduceSum<1>( & error_count ) ); - ThrowErrorMsgIf( error_count, error_msg.str() ); - - // Any entity that I sent and is not in an owned closure is deleted. - // The owned closure will be effected by received entities, so can - // only clean up after the newly owned entities have been received. - // Destroy backwards so as not to invalidate closures in the process. - - { - Entity * entity = NULL ; - - for ( std::set::iterator - i = send_closure.end() ; i != send_closure.begin() ; ) { - - Entity * e = (--i)->first ; - - // The same entity may be sent to more than one process. - // Only evaluate it once. - - if ( entity != e ) { - entity = e ; - if ( ! member_of_owned_closure( *e , p_rank ) ) { - ThrowRequireMsg( destroy_entity( e ), - "Failed to destroy entity " << print_entity_key(e) ); - } - } - } - } - - send_closure.clear(); // Has been invalidated - } -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallel.dox b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallel.dox deleted file mode 100644 index 81a7f6ea7bd4..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallel.dox +++ /dev/null @@ -1,41 +0,0 @@ - -/** \addtogroup stk_mesh_bulk_data_parallel - * - * Parallel distributed \ref stk_classic::mesh::Entity "entities" have - * relations to entities that cross proessor boundaries. - * Such a cross-processor relation can be viewed as follows. - * - * ( domain_entity , domain_proc ) -> ( range_entity , range_proc ) - * - * Mesh-specific parallel communication operations use - * a collection of cross-processor relations to determine what - * information is sent or received among processors. - * These operations send data from the domain_entity on the - * domain_processor to the range_entity on the range_processor. - * These communication operations are most efficient when all - * message data between a given pair of processors is packaged - * into a single message. - * - * Efficient packing and unpacking of mesh-specific - * parallel communication messages is supported by - * structuring the cross-processor relations as follows. - * - * Given a collection of cross-processor relations: - * - * { ( ( domain_entity , domain_proc ) -> - ( range_entity , range_proc ) )[k] } - * - * Form the following two correlated vectors on the - * domain and range processors. - * - on the domain_proc : { ( domain_entity , range_proc )[k] } - * - on the range_proc : { ( range_entity , domain_proc )[k] } - * - * Members of the domain processor's vector are ordered by the - * domain entity key and then by range processor. - * Members of the range processor's vector are ordered conformally - * with the domain processor's ordering. - * Thus message packing and unpacking can be performed by - * iterating the cross-processor relation vectors. - */ - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallelVerify.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallelVerify.cpp deleted file mode 100644 index c421ad8ec289..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataParallelVerify.cpp +++ /dev/null @@ -1,548 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -namespace { - -bool verify_parallel_attributes( BulkData & M , std::ostream & error_log ); - -void pack_owned_verify( CommAll & all , const BulkData & mesh ); - -bool unpack_not_owned_verify( CommAll & comm_all , - const BulkData & mesh , - std::ostream & error_log ); - -} - -bool comm_mesh_verify_parallel_consistency( - BulkData & M , std::ostream & error_log ) -{ - int result = 1 ; - - // Verify consistency of parallel attributes - - result = verify_parallel_attributes( M , error_log ); - - if (M.parallel_size() > 1) { - all_reduce( M.parallel() , ReduceMin<1>( & result ) ); - } - - // Verify entities against owner. - - if ( result ) { - CommAll all( M.parallel() ); - - pack_owned_verify( all , M ); - - all.allocate_buffers( all.parallel_size() / 4 ); - - pack_owned_verify( all , M ); - - all.communicate(); - - result = unpack_not_owned_verify( all , M , error_log ); - - if (M.parallel_size() > 1) { - all_reduce( M.parallel() , ReduceMin<1>( & result ) ); - } - } - - return result == 1 ; -} - -namespace { - -bool ordered_comm( const Entity & entity ) -{ - const PairIterEntityComm ec = entity.comm(); - const size_t n = ec.size(); - for ( size_t i = 1 ; i < n ; ++i ) { - if ( ! ( ec[i-1] < ec[i] ) ) { - return false ; - } - } - return true ; -} - -bool verify_parallel_attributes( BulkData & M , std::ostream & error_log ) -{ - bool result = true ; - - const MetaData & S = MetaData::get(M); - Part & owns_part = S.locally_owned_part(); - Part & shares_part = S.globally_shared_part(); - - const unsigned p_rank = M.parallel_rank(); - - const size_t EntityRankEnd = MetaData::get(M).entity_rank_count(); - - size_t comm_count = 0 ; - - for ( size_t itype = 0 ; itype < EntityRankEnd ; ++itype ) { - const std::vector< Bucket * > & all_buckets = M.buckets( itype ); - - const std::vector::const_iterator i_end = all_buckets.end(); - std::vector::const_iterator i = all_buckets.begin(); - - while ( i != i_end ) { - Bucket & bucket = **i ; ++i ; - - const bool has_owns_part = has_superset( bucket , owns_part ); - const bool has_shares_part = has_superset( bucket , shares_part ); - - const Bucket::iterator j_end = bucket.end(); - Bucket::iterator j = bucket.begin(); - - while ( j != j_end ) { - Entity & entity = *j ; ++j ; - - bool this_result = true ; - - const unsigned p_owner = entity.owner_rank(); - const bool ordered = ordered_comm( entity ); - const bool shares = in_shared( entity ); - const bool recv_ghost = in_receive_ghost( entity ); - const bool send_ghost = in_send_ghost( entity ); - const bool owned_closure = in_owned_closure( entity , p_rank ); - - if ( ! ordered ) { - error_log << "Problem is unordered" << std::endl; - this_result = false ; - } - - // Owner consistency: - - if ( has_owns_part && p_owner != p_rank ) { - error_log << "problem is owner-consistency check 1: " - << "has_owns_part: " << has_owns_part << ", " - << "p_owner: " << p_owner << ", " - << "p_rank: " << p_rank << std::endl; - this_result = false ; - } - - if ( ! has_owns_part && p_owner == p_rank ) { - error_log << "problem is owner-consistency check 2: " - << "has_owns_part: " << has_owns_part << ", " - << "p_owner: " << p_owner << ", " - << "p_rank: " << p_rank << std::endl; - this_result = false ; - } - - if ( has_shares_part != shares ) { - error_log << "problem is owner-consistency check 3: " - << "has_shares_part: " << has_shares_part << ", " - << "shares: " << shares << std::endl; - this_result = false ; - } - - // Definition of 'closure' - - if ( ( has_owns_part || has_shares_part ) != owned_closure ) { - error_log << "problem is closure check 1: " - << "has_owns_part: " << has_owns_part << ", " - << "has_shares_part: " << has_shares_part << ", " - << "owned_closure: " << owned_closure << std::endl; - this_result = false ; - } - - // Must be either owned_closure or recv_ghost but not both. - - if ( owned_closure && recv_ghost ) { - error_log << "problem is recv ghost check 1: " - << "owned_closure: " << owned_closure << ", " - << "recv_ghost: " << recv_ghost << std::endl; - this_result = false ; - } - if ( ! owned_closure && ! recv_ghost ) { - error_log << "problem is recv ghost check 2: " - << "owned_closure: " << owned_closure << ", " - << "recv_ghost: " << recv_ghost << std::endl; - this_result = false ; - } - - // If sending as a ghost then I must own it - - if ( ! has_owns_part && send_ghost ) { - error_log << "problem is send ghost check 1: " - << "has_owns_part: " << has_owns_part << ", " - << "send_ghost: " << send_ghost << std::endl; - this_result = false ; - } - - // If shared then I am owner or owner is in the shared list - - if ( shares && p_owner != p_rank ) { - PairIterEntityComm ip = entity.sharing(); - for ( ; ! ip.empty() && p_owner != ip->proc ; ++ip ); - if ( ip.empty() ) { - error_log << "problem is shared check 1" << std::endl; - this_result = false ; - } - } - - if ( shares || recv_ghost || send_ghost ) { ++comm_count ; } - - if ( ! this_result ) { - result = false ; - error_log << "P" << M.parallel_rank() << ": " ; - print_entity_key( error_log , MetaData::get(M), entity.key() ); - error_log << " ERROR: owner(" << p_owner - << ") owns(" << has_owns_part - << ") shares(" << has_shares_part - << ") owned_closure(" << owned_closure - << ") recv_ghost(" << recv_ghost - << ") send_ghost(" << send_ghost - << ") comm(" ; - PairIterEntityComm ip = entity.comm(); - for ( ; ! ip.empty() ; ++ip ) { - error_log << " " << ip->ghost_id << ":" << ip->proc ; - } - error_log << " )" << std::endl ; - } - } - } - } - - for ( std::vector::const_iterator - i = M.entity_comm().begin() ; - i != M.entity_comm().end() ; ++i ) { - - const PairIterEntityComm ec = (*i)->comm(); - - if ( ec.empty() ) { - print_entity_key( error_log , MetaData::get(M), (*i)->key() ); - error_log << " ERROR: in entity_comm but has no comm info" << std::endl ; - result = false ; - } - } - - if ( M.entity_comm().size() != comm_count ) { - error_log << " ERROR: entity_comm.size() = " << M.entity_comm().size(); - error_log << " != " << comm_count << " = entities with comm info" ; - error_log << std::endl ; - result = false ; - } - - return result ; -} - -//---------------------------------------------------------------------------- -// Packing my owned entities. - -void insert( std::vector & vec , unsigned val ) -{ - std::vector::iterator j = - std::lower_bound( vec.begin() , vec.end() , val ); - if ( j == vec.end() || *j != val ) { - vec.insert( j , val ); - } -} - -void pack_owned_verify( CommAll & all , const BulkData & mesh ) -{ - const std::vector & entity_comm = mesh.entity_comm(); - const unsigned p_rank = all.parallel_rank(); - - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( entity.owner_rank() == p_rank ) { - - std::vector share_proc ; - std::vector ghost_proc ; - - const PairIterEntityComm comm = entity.comm(); - - for ( size_t j = 0 ; j < comm.size() ; ++j ) { - if ( comm[j].ghost_id == 0 ) { - // Will be ordered by proc - share_proc.push_back( comm[j].proc ); - } - else { - // No guarantee of ordering by proc - insert( ghost_proc , comm[j].proc ); - } - } - - const unsigned share_count = share_proc.size(); - - for ( size_t j = 0 ; j < share_proc.size() ; ++j ) { - - // Sharing process, send sharing process list - - const unsigned p = share_proc[j] ; - - CommBuffer & buf = all.send_buffer( p ); - - pack_entity_info( buf , entity ); - - buf.pack( share_count ); - - // Pack what the receiver should have: - // My list, remove receiver, add myself - size_t k = 0 ; - for ( ; k < share_count && share_proc[k] < p_rank ; ++k ) { - if ( k != j ) { buf.pack( share_proc[k] ); } - } - buf.pack( p_rank ); - for ( ; k < share_count ; ++k ) { - if ( k != j ) { buf.pack( share_proc[k] ); } - } - } - - for ( size_t j = 0 ; j < ghost_proc.size() ; ++j ) { - const unsigned p = ghost_proc[j] ; - - CommBuffer & buf = all.send_buffer( p ); - - pack_entity_info( buf , entity ); - - // What ghost subsets go to this process? - unsigned count = 0 ; - for ( size_t k = 0 ; k < comm.size() ; ++k ) { - if ( comm[k].ghost_id != 0 && comm[k].proc == p ) { - ++count ; - } - } - buf.pack( count ); - for ( size_t k = 0 ; k < comm.size() ; ++k ) { - if ( comm[k].ghost_id != 0 && comm[k].proc == p ) { - buf.pack( comm[k].ghost_id ); - } - } - } - } - } -} - -//---------------------------------------------------------------------------- -// Unpacking all of my not-owned entities. - -bool unpack_not_owned_verify( CommAll & comm_all , - const BulkData & mesh , - std::ostream & error_log ) -{ - const MetaData & meta = MetaData::get(mesh); - Part * const owns_part = & meta.locally_owned_part(); - Part * const shares_part = & meta.globally_shared_part(); - const PartVector & mesh_parts = meta.get_parts(); - const unsigned p_rank = mesh.parallel_rank(); - const std::vector & entity_comm = mesh.entity_comm(); - - bool result = true ; - - EntityKey recv_entity_key ; - unsigned recv_owner_rank = 0 ; - unsigned recv_comm_count = 0 ; - std::vector recv_parts ; - std::vector recv_relations ; - std::vector recv_comm ; - - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - - Entity & entity = **i ; - - if ( entity.owner_rank() != p_rank ) { - - const Bucket & bucket = entity.bucket(); - - std::pair - part_ordinals = bucket.superset_part_ordinals(); - - CommBuffer & buf = comm_all.recv_buffer( entity.owner_rank() ); - - unpack_entity_info( buf , mesh , - recv_entity_key , recv_owner_rank , - recv_parts , recv_relations ); - - recv_comm_count = 0 ; - buf.unpack( recv_comm_count ); - recv_comm.resize( recv_comm_count ); - buf.unpack( & recv_comm[0] , recv_comm_count ); - - // Match key and owner - - const bool bad_key = entity.key() != recv_entity_key ; - const bool bad_own = entity.owner_rank() != recv_owner_rank ; - bool bad_part = false ; - bool bad_rel = false ; - bool bad_comm = false ; - - // Compare communication information: - - if ( ! bad_key && ! bad_own ) { - const PairIterEntityComm ec = entity.comm(); - const unsigned ec_size = ec.size(); - bad_comm = ec_size != recv_comm.size(); - if ( ! bad_comm ) { - size_t j = 0 ; - if ( in_shared( entity ) ) { - for ( ; j < ec_size && - ec[j].ghost_id == 0 && - ec[j].proc == recv_comm[j] ; ++j ); - bad_comm = j != ec_size ; - } - else { - for ( ; j < ec_size && - ec[j].ghost_id == recv_comm[j] && - ec[j].proc == entity.owner_rank() ; ++j ); - bad_comm = j != ec_size ; - } - } - } - - // Compare everything but the owns part and uses part - - if ( ! bad_key && ! bad_own && ! bad_comm ) { - - const unsigned * k = part_ordinals.first ; - - std::vector::iterator ip = recv_parts.begin(); - - for ( ; ! bad_part && ip != recv_parts.end() ; ++ip ) { - if ( owns_part != *ip ) { - if ( shares_part != *ip ) { - // All not-owned and not-shares parts must match: - bad_part = k == part_ordinals.second || - (*ip)->mesh_meta_data_ordinal() != *k ; - ++k ; - } - else if ( k != part_ordinals.second && - *k == shares_part->mesh_meta_data_ordinal() ) { - // shares-part matches - ++k ; - } - } - } - } - - // Compare the closure relations: - if ( ! bad_key && ! bad_own && ! bad_comm && ! bad_part ) { - - PairIterRelation ir = entity.relations(); - - std::vector::iterator jr = recv_relations.begin() ; - - for ( ; ! bad_rel && jr != recv_relations.end() && - jr->entity_rank() < entity.entity_rank() ; ++jr , ++ir ) { - bad_rel = ir.empty() || *jr != *ir ; - } - } - - // The rest of this code is just error handling - if ( bad_key || bad_own || bad_comm || bad_part || bad_rel ) { - error_log << "P" << p_rank << ": " ; - print_entity_key( error_log , meta, entity.key() ); - error_log << " owner(" << entity.owner_rank() << ")" ; - - if ( bad_key || bad_own ) { - error_log << " != received " ; - print_entity_key( error_log , meta, recv_entity_key ); - error_log << " owner(" << recv_owner_rank - << ")" << std::endl ; - } - else if ( bad_comm ) { - const PairIterEntityComm ec = entity.comm(); - if ( in_shared( entity ) ) { - error_log << " sharing(" ; - for ( size_t j = 0 ; j < ec.size() && - ec[j].ghost_id == 0 ; ++j ) { - error_log << " " << ec[j].proc ; - } - error_log << " ) != received sharing(" ; - for ( size_t j = 0 ; j < recv_comm.size() ; ++j ) { - error_log << " " << recv_comm[j] ; - } - error_log << " )" << std::endl ; - } - else { - error_log << " ghosting(" ; - for ( size_t j = 0 ; j < ec.size() ; ++j ) { - error_log << " (g" << ec[j].ghost_id ; - error_log << ",p" << ec[j].proc ; - error_log << ")" ; - } - error_log << " ) != received ghosting(" ; - for ( size_t j = 0 ; j < recv_comm.size() ; ++j ) { - error_log << " (g" << recv_comm[j] ; - error_log << ",p" << entity.owner_rank(); - error_log << ")" ; - } - error_log << " )" << std::endl ; - } - } - else if ( bad_part ) { - error_log << " Parts( " ; - - for ( const unsigned * k = part_ordinals.first ; - k < part_ordinals.second ; ++k ) { - error_log << " \"" << mesh_parts[ *k ]->name() << "\"" ; - } - error_log << " ) != received Parts( " ; - - for ( std::vector::iterator - ip = recv_parts.begin(); - ip != recv_parts.end() ; ++ip ) { - error_log << " \"" << (*ip)->name() << "\"" ; - } - error_log << " )" << std::endl ; - } - else if ( bad_rel ) { - error_log << " Relations(" ; - PairIterRelation ir = entity.relations(); - for ( ; ! ir.empty() && - ir->entity_rank() < entity.entity_rank() ; ++ir ) { - error_log << " " << *ir ; - } - error_log << " ) != received Relations(" ; - std::vector::iterator jr = recv_relations.begin() ; - for ( ; jr != recv_relations.end() && - jr->entity_rank() < entity.entity_rank() ; ++jr ) { - error_log << " " << *jr ; - } - error_log << " )" << std::endl ; - } - result = false ; - } - } - } - - return result ; -} - -} // namespace<> - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataRelation.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataRelation.cpp deleted file mode 100644 index a28e0526b460..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkDataRelation.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -void set_field_relations( Entity & e_from , - Entity & e_to , - const unsigned ident ) -{ - const std::vector & field_rels = - MetaData::get(e_from).get_field_relations(); - - for ( std::vector::const_iterator - j = field_rels.begin() ; j != field_rels.end() ; ++j ) { - - const FieldRelation & fr = *j ; - - void ** const ptr = (void**) field_data( * fr.m_root , e_from ); - - if ( ptr ) { - - void * const src = field_data( * fr.m_target , e_to ); - - const size_t number = - field_data_size(*fr.m_root,e_from) / sizeof(void*); - - const size_t offset = - (*fr.m_function)( e_from.entity_rank() , - e_to.entity_rank() , ident ); - - if ( offset < number ) { - ptr[ offset ] = src ; - } - } - } -} - -namespace { - -void clear_field_relations( Entity & e_from , - const unsigned type , - const unsigned ident ) -{ - const std::vector & field_rels = - MetaData::get(e_from).get_field_relations(); - - for ( std::vector::const_iterator - j = field_rels.begin() ; j != field_rels.end() ; ++j ) { - - const FieldRelation & fr = *j ; - - void ** const ptr = (void**) field_data( * fr.m_root , e_from ); - - if ( ptr ) { - - const size_t number = - field_data_size(*fr.m_root,e_from) / sizeof(void*); - - const size_t offset = - (*fr.m_function)( e_from.entity_rank() , type , ident ); - - if ( offset < number ) { - ptr[ offset ] = NULL ; - } - } - } -} - -} // empty namespace - -//---------------------------------------------------------------------- - -void BulkData::require_valid_relation( const char action[] , - const BulkData & mesh , - const Entity & e_from , - const Entity & e_to ) -{ - const bool error_mesh_from = & mesh != & BulkData::get(e_from); - const bool error_mesh_to = & mesh != & BulkData::get(e_to); - const bool error_type = e_from.entity_rank() <= e_to.entity_rank(); - const bool error_nil_from = EntityLogDeleted == e_from.log_query(); - const bool error_nil_to = EntityLogDeleted == e_to.log_query(); - - if ( error_mesh_from || error_mesh_to || error_type || - error_nil_from || error_nil_to ) { - std::ostringstream msg ; - - msg << "Could not " << action << " relation from entity " - << print_entity_key(e_from) << " to entity " - << print_entity_key(e_to) << "\n"; - - ThrowErrorMsgIf( error_mesh_from || error_mesh_to, - msg.str() << (error_mesh_from ? "e_from" : "e_to" ) << - " not member of this mesh"); - ThrowErrorMsgIf( error_nil_from || error_nil_to, - msg.str() << (error_mesh_from ? "e_from" : "e_to" ) << - " was destroyed"); - ThrowErrorMsgIf( error_type, msg.str() << - "A relation must be from higher to lower ranking entity"); - } -} - -//---------------------------------------------------------------------- - -void BulkData::declare_relation( Entity & e_from , - Entity & e_to , - const RelationIdentifier local_id ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::declare_relation", LOG_ENTITY, e_from.key()); - TraceIfWatchingDec("stk_classic::mesh::BulkData::declare_relation", LOG_ENTITY, e_to.key(), 1); - DiagIfWatching(LOG_ENTITY, e_from.key(), - "from: " << e_from << "; " << - "to: " << e_to << "; " << - "id: " << local_id); - DiagIfWatching(LOG_ENTITY, e_to.key(), - "from: " << e_from << "; " << - "to: " << e_to << "; " << - "id: " << local_id); - - require_ok_to_modify(); - - require_valid_relation( "declare" , *this , e_from , e_to ); - - // TODO: Don't throw if exact relation already exists, that should be a no-op. - // Should be an exact match if relation of local_id already exists (e_to should be the same). - m_entity_repo.declare_relation( e_from, e_to, local_id, m_sync_count); - - OrdinalVector add , empty ; - - // Deduce and set new part memberships: - - induced_part_membership( e_from, empty, e_to.entity_rank(), local_id, add ); - - internal_change_entity_parts( e_to , add , empty ); - - set_field_relations( e_from , e_to , local_id ); -} - -//---------------------------------------------------------------------- - -void BulkData::declare_relation( Entity & entity , - const std::vector & rel ) -{ - require_ok_to_modify(); - - const unsigned erank = entity.entity_rank(); - - std::vector::const_iterator i ; - for ( i = rel.begin() ; i != rel.end() ; ++i ) { - Entity & e = * i->entity(); - const unsigned n = i->identifier(); - if ( e.entity_rank() < erank ) { - declare_relation( entity , e , n ); - } - else if ( erank < e.entity_rank() ) { - declare_relation( e , entity , n ); - } - else { - ThrowErrorMsg("Given entities of the same entity rank. entity is " << - print_entity_key(entity)); - } - } -} - -//---------------------------------------------------------------------- - -bool BulkData::destroy_relation( Entity & e_from , - Entity & e_to, - const RelationIdentifier local_id ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::destroy_relation", LOG_ENTITY, e_from.key()); - TraceIfWatchingDec("stk_classic::mesh::BulkData::destroy_relation", LOG_ENTITY, e_to.key(), 1); - DiagIfWatching(LOG_ENTITY, e_from.key(), - "from: " << e_from << "; " << - "to: " << e_to << "; " << - "id: " << local_id); - DiagIfWatching(LOG_ENTITY, e_to.key(), - "from: " << e_from << "; " << - "to: " << e_to << "; " << - "id: " << local_id); - - require_ok_to_modify(); - - require_valid_relation( "destroy" , *this , e_from , e_to ); - - //------------------------------ - // When removing a relationship may need to - // remove part membership and set field relation pointer to NULL - - if ( parallel_size() < 2 || m_entity_comm_map.sharing(e_to.key()).empty() ) { - - //------------------------------ - // 'keep' contains the parts deduced from kept relations - // 'del' contains the parts deduced from deleted relations - // that are not in 'keep' - // Only remove these part memberships the entity is not shared. - // If the entity is shared then wait until modificaton_end_synchronize. - //------------------------------ - - OrdinalVector del, keep, empty; - - // For all relations that are *not* being deleted, add induced parts for - // these relations to the 'keep' vector - for ( PairIterRelation i = e_to.relations(); !i.empty(); ++i ) { - if (e_to.entity_rank() < i->entity_rank()) { // Need to look at back rels only - if ( !( i->entity() == & e_from && i->identifier() == local_id ) ) { - induced_part_membership( * i->entity(), empty, e_to.entity_rank(), - i->identifier(), keep, - false /*Do not look at supersets*/); - } - } - } - - // Find the relation this is being deleted and add the parts that are - // induced from that relation (and that are not in 'keep') to 'del' - for ( PairIterRelation i = e_from.relations() ; !i.empty() ; ++i ) { - if ( i->entity() == & e_to && i->identifier() == local_id ) { - induced_part_membership( e_from, keep, e_to.entity_rank(), - i->identifier(), del, - false /*Do not look at supersets*/); - clear_field_relations( e_from , e_to.entity_rank() , - i->identifier() ); - break; // at most 1 relation can match our specification - } - } - - if ( !del.empty() ) { - internal_change_entity_parts( e_to , empty , del ); - } - } - else { - // Just clear the field, part membership will be handled by modification end - for ( PairIterRelation i = e_from.relations() ; !i.empty() ; ++i ) { - if ( i->entity() == & e_to && i->identifier() == local_id ) { - clear_field_relations( e_from , e_to.entity_rank() , - i->identifier() ); - break; // at most 1 relation can match our specification - } - } - } - - //delete relations from the entities - return m_entity_repo.destroy_relation( e_from, e_to, local_id); -} - -//---------------------------------------------------------------------- -// Deduce propagation of part membership changes to a 'from' entity -// to the related 'to' entities. There can be both additions and -// removals. - -void BulkData::internal_propagate_part_changes( - Entity & entity , - const PartVector & removed ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::internal_propagate_part_changes", - LOG_ENTITY, - entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - DiagIfWatching(LOG_ENTITY, entity.key(), "Removed: " << removed); - - const unsigned etype = entity.entity_rank(); - - PairIterRelation rel = entity.relations(); - - OrdinalVector to_del , to_add , empty ; - - for ( ; ! rel.empty() ; ++rel ) { - const unsigned rel_type = rel->entity_rank(); - const unsigned rel_ident = rel->identifier(); - - if ( rel_type < etype ) { // a 'to' entity - - Entity & e_to = * rel->entity(); - - to_del.clear(); - to_add.clear(); - empty.clear(); - - // Induce part membership from this relationship to - // pick up any additions. - induced_part_membership( entity, empty, - rel_type, rel_ident, to_add ); - - if ( ! removed.empty() ) { - // Something was removed from the 'from' entity, - // deduce what may have to be removed from the 'to' entity. - - // Deduce parts for 'e_to' from all upward relations. - // Any non-parallel part that I removed that is not deduced for - // 'e_to' must be removed from 'e_to' - - for ( PairIterRelation - to_rel = e_to.relations(); ! to_rel.empty() ; ++to_rel ) { - if ( e_to.entity_rank() < to_rel->entity_rank() && - & entity != to_rel->entity() /* Already did this entity */ ) { - // Relation from to_rel->entity() to e_to - induced_part_membership( * to_rel->entity(), empty, - e_to.entity_rank(), - to_rel->identifier(), - to_add ); - } - } - - OrdinalVector::const_iterator to_add_begin = to_add.begin(), - to_add_end = to_add.end(); - - for ( PartVector::const_iterator - j = removed.begin() ; j != removed.end() ; ++j ) { - if ( ! contains_ordinal( to_add_begin, to_add_end , (*j)->mesh_meta_data_ordinal() ) ) { - induced_part_membership( **j, etype, rel_type, rel_ident, to_del ); - } - } - } - - if ( parallel_size() < 2 || m_entity_comm_map.sharing(e_to.key()).empty() ) { - // Entirely local, ok to remove memberships now - internal_change_entity_parts( e_to , to_add , to_del ); - } - else { - // Shared, do not remove memberships now. - // Wait until modification_end. - internal_change_entity_parts( e_to , to_add , empty ); - } - - set_field_relations( entity, e_to, rel_ident ); - } - else if ( etype < rel_type ) { // a 'from' entity - Entity & e_from = * rel->entity(); - - set_field_relations( e_from, entity, rel_ident ); - } - } -} - -void BulkData::internal_propagate_part_changes( - Entity & entity , - const OrdinalVector & removed ) -{ - TraceIfWatching("stk_classic::mesh::BulkData::internal_propagate_part_changes", - LOG_ENTITY, - entity.key()); - DiagIfWatching(LOG_ENTITY, entity.key(), "entity state: " << entity); - DiagIfWatching(LOG_ENTITY, entity.key(), "Removed: " << removed); - - const unsigned etype = entity.entity_rank(); - - PairIterRelation rel = entity.relations(); - - OrdinalVector to_del , to_add , empty ; - - const PartVector& all_parts = m_mesh_meta_data.get_parts(); - - for ( ; ! rel.empty() ; ++rel ) { - const unsigned rel_type = rel->entity_rank(); - const unsigned rel_ident = rel->identifier(); - - if ( rel_type < etype ) { // a 'to' entity - - Entity & e_to = * rel->entity(); - - to_del.clear(); - to_add.clear(); - empty.clear(); - - // Induce part membership from this relationship to - // pick up any additions. - induced_part_membership( entity, empty, - rel_type, rel_ident, to_add ); - - if ( ! removed.empty() ) { - // Something was removed from the 'from' entity, - // deduce what may have to be removed from the 'to' entity. - - // Deduce parts for 'e_to' from all upward relations. - // Any non-parallel part that I removed that is not deduced for - // 'e_to' must be removed from 'e_to' - - for ( PairIterRelation - to_rel = e_to.relations(); ! to_rel.empty() ; ++to_rel ) { - if ( e_to.entity_rank() < to_rel->entity_rank() && - & entity != to_rel->entity() /* Already did this entity */ ) { - // Relation from to_rel->entity() to e_to - induced_part_membership( * to_rel->entity(), empty, - e_to.entity_rank(), - to_rel->identifier(), - to_add ); - } - } - - OrdinalVector::const_iterator to_add_begin = to_add.begin(), - to_add_end = to_add.end(); - - for ( OrdinalVector::const_iterator - j = removed.begin() ; j != removed.end() ; ++j ) { - if ( ! contains_ordinal( to_add_begin, to_add_end , *j ) ) { - induced_part_membership( *all_parts[*j], etype, rel_type, rel_ident, to_del ); - } - } - } - - if ( parallel_size() < 2 || m_entity_comm_map.sharing(e_to.key()).empty() ) { - // Entirely local, ok to remove memberships now - internal_change_entity_parts( e_to , to_add , to_del ); - } - else { - // Shared, do not remove memberships now. - // Wait until modification_end. - internal_change_entity_parts( e_to , to_add , empty ); - } - - set_field_relations( entity, e_to, rel_ident ); - } - else if ( etype < rel_type ) { // a 'from' entity - Entity & e_from = * rel->entity(); - - set_field_relations( e_from, entity, rel_ident ); - } - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.cpp deleted file mode 100644 index 45271c6dfe52..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -#include -#include -#include - - -namespace stk_classic { -namespace mesh { - -typedef std::set EntitySet; -typedef std::set EntityProcSet; - -namespace { - -void construct_transitive_closure( EntitySet & closure , Entity & entry ) -{ - - std::pair< EntitySet::const_iterator , bool > - result = closure.insert( & entry ); - - // A new insertion, must also insert the closure - if ( result.second ) { - - const unsigned erank = entry.entity_rank(); - PairIterRelation irel = entry.relations(); - - for ( ; irel.first != irel.second ; ++irel.first ) { - // insert entities with relations of lower rank into the closure - if ( irel.first->entity_rank() < erank ) { - Entity * tmp = irel.first->entity(); - construct_transitive_closure( closure , *tmp ); - } - } - } -} - -void find_local_closure ( EntitySet & closure, const EntityVector & entities) -{ - for (EntityVector::const_iterator i = entities.begin(); - i != entities.end(); ++i) - { - construct_transitive_closure(closure, **i); - } -} - -void construct_communication_set( const BulkData & bulk, const EntitySet & closure, EntityProcSet & communication_set) -{ - if (bulk.parallel_size() < 2) return; - - for ( EntitySet::const_iterator - i = closure.begin(); i != closure.end(); ++i) { - - Entity & entity = **i; - - const bool owned = bulk.parallel_rank() == entity.owner_rank(); - - // Add sharing processes and ghost-send processes to communication_set - - for ( PairIterEntityComm ec = entity.comm(); ! ec.empty() ; ++ec ) { - if ( owned || ec->ghost_id == 0 ) { - EntityProc tmp( & entity , ec->proc ); - communication_set.insert( tmp ); - } - } - } -} - -size_t count_non_used_entities( const BulkData & bulk, const EntityVector & entities) -{ - const unsigned proc_local = bulk.parallel_rank(); - size_t non_used_entities = 0; - - for ( EntityVector::const_iterator - i = entities.begin(); i != entities.end(); ++i ) { - if ( ! in_owned_closure( **i , proc_local ) ) { - ++non_used_entities; - } - } - - return non_used_entities; -} - -} - - - -void find_closure( const BulkData & bulk, - const std::vector< Entity *> & entities, - std::vector< Entity *> & entities_closure) -{ - - entities_closure.clear(); - - - EntityProcSet send_list; - EntitySet temp_entities_closure; - - const bool bulk_not_synchronized = bulk.synchronized_state() != BulkData::SYNCHRONIZED; - const size_t non_used_entities = bulk_not_synchronized ? 0 : count_non_used_entities(bulk, entities); - - const bool local_bad_input = bulk_not_synchronized || (0 < non_used_entities); - - //Can skip if error on input - if ( !local_bad_input) { - - find_local_closure(temp_entities_closure, entities); - - construct_communication_set(bulk, temp_entities_closure, send_list); - } - - - CommAll all( bulk.parallel() ); - - //pack send_list for sizing - for ( EntityProcSet::const_iterator - ep = send_list.begin() ; ep != send_list.end() ; ++ep ) { - all.send_buffer( ep->second).pack(ep->first->key()); - } - - - const bool global_bad_input = all.allocate_buffers( bulk.parallel_size() / 4 , false, local_bad_input ); - - if (global_bad_input) { - - std::ostringstream msg; - //parallel consisent throw - if (bulk_not_synchronized) { - msg << "stk_classic::mesh::find_closure( const BulkData & bulk, ... ) bulk is not synchronized"; - } - else if ( 0 < non_used_entities) { - msg << "stk_classic::mesh::find_closure( const BulkData & bulk, std::vector entities, ... ) \n" - << "entities contains " << non_used_entities << " non locally used entities \n"; - } - - throw std::runtime_error(msg.str()); - } - - - //pack send_list - for ( EntityProcSet::const_iterator - ep = send_list.begin() ; ep != send_list.end() ; ++ep ) { - all.send_buffer( ep->second).pack(ep->first->key()); - } - - - all.communicate(); - - //unpack the send_list into the temp entities closure set - for ( unsigned p = 0 ; p < bulk.parallel_size() ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - EntityKey k ; - while ( buf.remaining() ) { - buf.unpack( k ); - Entity * e = bulk.get_entity(k); - temp_entities_closure.insert(e); - } - } - - //copy the set into the entities_closure vector - entities_closure.assign(temp_entities_closure.begin(), temp_entities_closure.end()); -} - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.hpp deleted file mode 100644 index abbc8f83ee4e..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/BulkModification.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_BASE_BULK_MODIFICATION_HPP -#define STK_MESH_BASE_BULK_MODIFICATION_HPP - -#include -#include - -namespace stk_classic { -namespace mesh { - - /** \brief Determine closure of the entities vector - * - * \param bulk BulkData must be in a parallel consistent state. - * - * \param entities Each entity must be in the locally_used part. - * - * \param entities_closure Parallel consistent closure of the input - * vector. This vector will be sorted and unique. May include - * ghosted entities. - */ -void find_closure( const BulkData & bulk, - const std::vector< Entity *> & entities, - std::vector< Entity *> & entities_closure); - -} // namespace mesh -} // namespace stk_classic - - -#endif // STK_MESH_BASE_BULK_MODIFICATION_HPP diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/CMakeLists.txt deleted file mode 100644 index fc50a5b0f11e..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -SET(HEADERS_IMPL "") -SET(SOURCES_IMPL "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -# INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -# INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../stk_util) -# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/..) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -FILE(GLOB HEADERS_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/*.hpp) -FILE(GLOB SOURCES_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/*.cpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_mesh_base - NOINSTALLHEADERS ${HEADERS} ${HEADERS_IMPL} - SOURCES ${SOURCES} ${SOURCES_IMPL} - DEPLIBS stkclassic_util_env stkclassic_util_parallel - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_mesh/base/) - -INSTALL(FILES ${HEADERS_IMPL} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_mesh/baseImpl/) diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.cpp deleted file mode 100644 index 54314e765178..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - - -namespace stk_classic { -namespace mesh { - -bool comm_mesh_counts( BulkData & M , - std::vector & counts , - bool local_flag ) -{ - const size_t zero = 0 ; - - // Count locally owned entities - - const MetaData & S = MetaData::get(M); - const unsigned entity_rank_count = S.entity_rank_count(); - const size_t comm_count = entity_rank_count + 1 ; - - std::vector local( comm_count , zero ); - std::vector global( comm_count , zero ); - - ParallelMachine comm = M.parallel(); - Part & owns = S.locally_owned_part(); - - for ( unsigned i = 0 ; i < entity_rank_count ; ++i ) { - const std::vector & ks = M.buckets( i ); - - std::vector::const_iterator ik ; - - for ( ik = ks.begin() ; ik != ks.end() ; ++ik ) { - if ( has_superset( **ik , owns ) ) { - local[i] += (*ik)->size(); - } - } - } - - local[ entity_rank_count ] = local_flag ; - - all_reduce_sum( comm , & local[0] , & global[0] , comm_count ); - - counts.assign( global.begin() , global.begin() + entity_rank_count ); - - return 0 < global[ entity_rank_count ] ; -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.hpp deleted file mode 100644 index 961b85e450f5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Comm.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_Comm_hpp -#define stk_mesh_Comm_hpp - -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_bulk_data_parallel - * \{ - */ - -/** \brief Global counts for a mesh's entities. */ -bool comm_mesh_counts( BulkData & , - std::vector & counts , - bool = false ); - -//---------------------------------------------------------------------- - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.cpp deleted file mode 100644 index 4ec9b01793cb..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -namespace { - -std::size_t stride( std::size_t size , std::size_t align ) -{ - if ( align && size % align ) { size += align - size % align ; } - return size ; -} - -} - -DataTraits::DataTraits( const std::type_info & arg_type , - const char * const arg_name , - std::size_t arg_size , - std::size_t arg_align ) - : type_info( arg_type ), - size_of( arg_size ), - is_void( false ), - is_integral( false ), - is_floating_point( false ), - is_pointer( false ), - is_enum( false ), - is_class( false ), - is_pod( false ), - is_signed( false ), - is_unsigned( false ), - alignment_of( arg_align ), - stride_of( stride( arg_size , arg_align ) ), - remove_pointer( NULL ), - name( arg_name ), - enum_info(), - class_info() -{} - -DataTraits::DataTraits( const std::type_info & arg_type , - const DataTraits & arg_traits ) - : type_info( arg_type ), - size_of( sizeof(void*) ), - is_void( false ), - is_integral( false ), - is_floating_point( false ), - is_pointer( true ), - is_enum( false ), - is_class( false ), - is_pod( false ), - is_signed( false ), - is_unsigned( false ), - alignment_of( sizeof(void*) ), - stride_of( sizeof(void*) ), - remove_pointer( & arg_traits ), - name(), - enum_info(), - class_info() -{ - name.assign( arg_traits.name ).append("*"); -} - -//---------------------------------------------------------------------- - -namespace { - -class DataTraitsVoid : public DataTraits { -public: - - DataTraitsVoid() - : DataTraits( typeid(void) , "void" , 0 , 0 ) - { is_void = true ; } - - void construct( void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void destroy( void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void pack( CommBuffer & , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void unpack( CommBuffer & , void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void print( std::ostream & , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void copy( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void sum( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void max( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void min( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_and( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_or( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_xor( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } -}; - -} - -template<> const DataTraits & data_traits() -{ static const DataTraitsVoid traits ; return traits ; } - -//---------------------------------------------------------------------- - -namespace { - -template< typename A , typename B > -struct IsSameType { enum { value = false }; }; - -template< typename A > -struct IsSameType { enum { value = true }; }; - - -template< typename T > -class DataTraitsCommon : public DataTraits { -public: - - explicit DataTraitsCommon( const char * arg_name ) - : DataTraits( typeid(T) , arg_name , sizeof(T) , sizeof(T) ) - { - is_pod = true ; - - is_integral = IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value ; - - is_signed = IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value ; - - is_unsigned = IsSameType::value || - IsSameType::value || - IsSameType::value || - IsSameType::value ; - - is_floating_point = IsSameType::value || - IsSameType::value ; - } - - void construct( void * v , std::size_t n ) const - { - T * x = reinterpret_cast( v ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ = 0 ; } - } - - void destroy( void * v , std::size_t n ) const {} - - void pack( CommBuffer & buf , const void * v , std::size_t n ) const - { - const T * x = reinterpret_cast( v ); - buf.pack( x , n ); - } - - void unpack( CommBuffer & buf , void * v , std::size_t n ) const - { - T * x = reinterpret_cast( v ); - buf.unpack( x , n ); - } - - void copy( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ = *y++ ; }; - } - - void sum( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ += *y++ ; }; - } - - virtual void print( std::ostream & s , const void * v , std::size_t n ) const - { - if ( n ) { - const T * x = reinterpret_cast( v ); - const T * const x_end = x + n ; - s << *x++ ; - while ( x_end != x ) { s << " " << *x++ ; } - } - } - - virtual void max( void * vx , const void * vy , std::size_t n ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void min( void * vx , const void * vy , std::size_t n ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_and( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_or( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_xor( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } -}; - -template< typename T > -class DataTraitsNumeric : public DataTraitsCommon { -public: - - explicit DataTraitsNumeric( const char * arg_name ) - : DataTraitsCommon( arg_name ) {} - - virtual void max( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x , ++y ) { if ( *x < *y ) { *x = *y ; } } - } - - virtual void min( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x , ++y ) { if ( *x > *y ) { *x = *y ; } } - } -}; - -template< typename T > -class DataTraitsComplex : public DataTraitsCommon { -public: - - explicit DataTraitsComplex( const char * arg_name ) - : DataTraitsCommon( arg_name ) {} -}; - -template< typename T > -class DataTraitsIntegral : public DataTraitsNumeric { -public: - DataTraitsIntegral( const char * name ) : DataTraitsNumeric( name ) {} - - virtual void bit_and( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ &= *y++ ; } - } - - virtual void bit_or( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ |= *y++ ; } - } - - virtual void bit_xor( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ ^= *y++ ; } - } -}; - -class DataTraitsChar : public DataTraitsIntegral { -public: - DataTraitsChar() : DataTraitsIntegral( "char" ) {} - - virtual void print( std::ostream & s , const void * v , std::size_t n ) const - { - if ( n ) { - const char * x = reinterpret_cast( v ); - const char * const x_end = x + n ; - s << int(*x++) ; - while ( x_end != x ) { s << " " << int(*x++) ; } - } - } -}; - -class DataTraitsUnsignedChar : public DataTraitsIntegral { -public: - DataTraitsUnsignedChar() - : DataTraitsIntegral( "unsigned char" ) {} - - virtual void print( std::ostream & s , const void * v , std::size_t n ) const - { - if ( n ) { - const unsigned char * x = reinterpret_cast( v ); - const unsigned char * const x_end = x + n ; - s << unsigned(*x++) ; - while ( x_end != x ) { s << " " << unsigned(*x++) ; } - } - } -}; - -} - -#define DATA_TRAITS_NUMERIC( T ) \ -template<> \ -const DataTraits & data_traits() \ -{ static const DataTraitsNumeric traits( #T ); return traits ; } - -#define DATA_TRAITS_COMPLEX( T ) \ -template<> \ -const DataTraits & data_traits() \ -{ static const DataTraitsComplex traits( #T ); return traits ; } - -#define DATA_TRAITS_INTEGRAL( T ) \ -template<> \ -const DataTraits & data_traits() \ -{ static const DataTraitsIntegral traits( #T ); return traits ; } - -template<> -const DataTraits & data_traits() -{ static const DataTraitsChar traits ; return traits ; } - -template<> -const DataTraits & data_traits() -{ static const DataTraitsUnsignedChar traits ; return traits ; } - -DATA_TRAITS_INTEGRAL( short ) -DATA_TRAITS_INTEGRAL( unsigned short ) -DATA_TRAITS_INTEGRAL( int ) -DATA_TRAITS_INTEGRAL( unsigned int ) -DATA_TRAITS_INTEGRAL( long ) -DATA_TRAITS_INTEGRAL( unsigned long ) -DATA_TRAITS_NUMERIC( float ) -DATA_TRAITS_NUMERIC( double ) -DATA_TRAITS_COMPLEX( std::complex ) // TODO: Probably not right -DATA_TRAITS_COMPLEX( std::complex ) // TODO: Probably not right - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -template< typename T > -class DataTraitsPointerToFundamental : public DataTraits { -public: - - DataTraitsPointerToFundamental() - : DataTraits( typeid(T*) , data_traits() ) {} - - void construct( void * v , std::size_t n ) const - { - void ** x = reinterpret_cast(v); - void ** const x_end = x + n ; - while ( x_end != x ) { *x++ = NULL ; } - } - - void destroy( void * v , std::size_t n ) const - { - void ** x = reinterpret_cast(v); - void ** const x_end = x + n ; - while ( x_end != x ) { *x++ = NULL ; } - } - - void copy( void * vx , const void * vy , std::size_t n ) const - { - void * const * y = reinterpret_cast(vy); - void ** x = reinterpret_cast(vx); - void ** const x_end = x + n ; - while ( x_end != x ) { *x++ = *y++ ; } - } - - void pack( CommBuffer & , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void unpack( CommBuffer & , void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void print( std::ostream & , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void sum( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void max( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void min( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_and( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_or( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - virtual void bit_xor( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } -}; - -} - -#define DATA_TRAITS_POINTER( T ) \ -template<> const DataTraits & data_traits() \ -{ static const DataTraitsPointerToFundamental traits ; return traits ; } - -DATA_TRAITS_POINTER( char ) -DATA_TRAITS_POINTER( unsigned char ) -DATA_TRAITS_POINTER( short ) -DATA_TRAITS_POINTER( unsigned short ) -DATA_TRAITS_POINTER( int ) -DATA_TRAITS_POINTER( unsigned int ) -DATA_TRAITS_POINTER( long ) -DATA_TRAITS_POINTER( unsigned long ) -DATA_TRAITS_POINTER( float ) -DATA_TRAITS_POINTER( double ) -DATA_TRAITS_POINTER( void ) -DATA_TRAITS_POINTER( std::complex ) -DATA_TRAITS_POINTER( std::complex ) - -//---------------------------------------------------------------------- - -} -} - - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.hpp deleted file mode 100644 index 73dc09b97a5f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraits.hpp +++ /dev/null @@ -1,171 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef STK_MESH_DATA_TRAITS_HPP -#define STK_MESH_DATA_TRAITS_HPP - -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -class DataTraits ; - -//---------------------------------------------------------------------- -/** \brief Query singleton for data traits of a given data type. */ -template< typename T > const DataTraits & data_traits(); - -/** \brief Query DataTraits for a given data value. */ -template< typename T > -inline -const DataTraits & data_traits( const T & ) { return data_traits(); } - -//---------------------------------------------------------------------- -// Data traits for the fundamental computational data types: - -template<> const DataTraits & data_traits< void >(); -template<> const DataTraits & data_traits< signed char >(); -template<> const DataTraits & data_traits< unsigned char >(); -template<> const DataTraits & data_traits< signed short >(); -template<> const DataTraits & data_traits< unsigned short >(); -template<> const DataTraits & data_traits< signed int >(); -template<> const DataTraits & data_traits< unsigned int >(); -template<> const DataTraits & data_traits< signed long >(); -template<> const DataTraits & data_traits< unsigned long >(); -template<> const DataTraits & data_traits< float >(); -template<> const DataTraits & data_traits< double >(); -template<> const DataTraits & data_traits< std::complex >(); -template<> const DataTraits & data_traits< std::complex >(); - -template<> const DataTraits & data_traits< void * >(); -template<> const DataTraits & data_traits< signed char * >(); -template<> const DataTraits & data_traits< unsigned char * >(); -template<> const DataTraits & data_traits< signed short * >(); -template<> const DataTraits & data_traits< unsigned short * >(); -template<> const DataTraits & data_traits< signed int * >(); -template<> const DataTraits & data_traits< unsigned int * >(); -template<> const DataTraits & data_traits< signed long * >(); -template<> const DataTraits & data_traits< unsigned long * >(); -template<> const DataTraits & data_traits< float * >(); -template<> const DataTraits & data_traits< double * >(); -template<> const DataTraits & data_traits< std::complex * >(); -template<> const DataTraits & data_traits< std::complex * >(); - -//---------------------------------------------------------------------- - -class DataTraits { -public: - //------------------------------ - // Standard properties: - const std::type_info & type_info ; - std::size_t size_of ; - - //------------------------------ - // TR1 primary type categories: - bool is_void ; - bool is_integral ; - bool is_floating_point ; - bool is_array ; - bool is_pointer ; - bool is_enum ; - bool is_class ; - - // TR1 type properties: - bool is_pod ; - bool is_signed ; // only if 'is_integral' - bool is_unsigned ; // only if 'is_integral' - std::size_t alignment_of ; - - // For memory management contiguous arrays of data: - // Array must start aligned with 'alignment_of' and - // stride by 'stride_of'. - std::size_t stride_of ; - - // TR1 type manipulators: - const DataTraits * remove_pointer ; // if 'is_pointer' - - //------------------------------ - /** \brief Namespace-qualified text name as it appears in source code */ - std::string name ; - - //------------------------------ - // Only If 'is_enum' - struct EnumMember { - std::string name ; - long value ; - }; - std::vector< EnumMember > enum_info ; - - //------------------------------ - // Only If 'is_class': - struct ClassMember { - std::string name ; - const DataTraits * traits ; - std::size_t offset ; - }; - std::vector< ClassMember > class_info ; - - //------------------------------ - // Functions required for all field data: - - virtual void construct( void * , std::size_t ) const = 0 ; - virtual void destroy( void * , std::size_t ) const = 0 ; - virtual void copy( void * , const void * , std::size_t ) const = 0 ; - virtual void pack( CommBuffer & , const void * , std::size_t ) const = 0 ; - virtual void unpack( CommBuffer & , void * , std::size_t ) const = 0 ; - virtual void print( std::ostream & , const void * , std::size_t ) const = 0 ; - - //------------------------------ - // Commutative and associative ops - // required for is_integral and is_floating_point data. - // In-place reduction: x[0..(n-1)] op= y[0..(n-1)] - virtual void sum( void * x , const void * y , std::size_t n ) const = 0 ; - virtual void max( void * x , const void * y , std::size_t n ) const = 0 ; - virtual void min( void * x , const void * y , std::size_t n ) const = 0 ; - - // Commutative and associative ops - // required for is_integral data. - // In-place reduction: x[0..(n-1)] op= y[0..(n-1)] - virtual void bit_and( void * x , const void * y, std::size_t n ) const = 0 ; - virtual void bit_or( void * x , const void * y, std::size_t n ) const = 0 ; - virtual void bit_xor( void * x , const void * y, std::size_t n ) const = 0 ; - - //------------------------------ - -protected: - - //------------------------------ - /** \brief CTOR for most types. */ - DataTraits( const std::type_info & arg_type , - const char * const arg_name , - const std::size_t arg_size , - const std::size_t arg_align ); - - /** \brief CTOR for pointer type */ - DataTraits( const std::type_info & arg_type , const DataTraits & ); - - virtual ~DataTraits() {} -private: - DataTraits(); - DataTraits( const DataTraits & ); - DataTraits & operator = ( const DataTraits & ); -}; - -} // namespace mesh -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsClass.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsClass.hpp deleted file mode 100644 index 507796bbcf3a..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsClass.hpp +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -namespace { - -template< typename T > -class DataTraitsClassPOD : public DataTraits { -public: - DataTraitsClassPOD( const char * name , std::size_t n ) - : DataTraits( typeid(T) , name , sizeof(T) , 1 ) - { - is_pod = true ; - is_class = true ; - class_info.reserve( n ); - } - - void set_stride( const void * first , const void * second ) - { - stride_of = reinterpret_cast(second) - - reinterpret_cast(first); - } - - void add_member( const char * n , const DataTraits & t , - const void * base , const void * member ) - { - const std::size_t i = class_info.size(); - const std::size_t d = reinterpret_cast(member) - - reinterpret_cast(base); - class_info.resize( i + 1 ); - class_info[i].name.assign( n ); - class_info[i].traits = & t ; - class_info[i].offset = d ; - if ( alignment_of < t.alignment_of ) { alignment_of = t.alignment_of ; } - } - - void construct( void * v , std::size_t n ) const - { - T * x = reinterpret_cast( v ); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x ) { new(x) T(); } - } - - void destroy( void * v , std::size_t n ) const - { - T * x = reinterpret_cast( v ); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x ) { x->~T(); } - } - - void copy( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast( vy ); - T * x = reinterpret_cast( vx ); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ = *y++ ; }; - } - - void pack( CommBuffer & buf , const void * v , std::size_t n ) const - { - const T * x = reinterpret_cast( v ); - buf.pack( x , n ); - } - - void unpack( CommBuffer & buf , void * v , std::size_t n ) const - { - T * x = reinterpret_cast( v ); - buf.unpack( x , n ); - } - - void print( std::ostream & s , const void * v , std::size_t n ) const - { ThrowErrorMsg( "not supported" ); } - - void sum( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void max( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void min( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_and( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_or( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_xor( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } -}; - -} - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_POD_CLASS_2( C , M1 , M2 ) \ -namespace { \ -class DataTraitsClass ## C : public DataTraitsClassPOD { \ -public: \ - DataTraitsClass ## C () : DataTraitsClassPOD( # C , 2 ) \ - { \ - C tmp[1] ; \ - set_stride( tmp , tmp + 1 ); \ - add_member( # M1 , data_traits( tmp->M1 ) , tmp , & tmp->M1 ); \ - add_member( # M2 , data_traits( tmp->M2 ) , tmp , & tmp->M2 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< C >() \ -{ static const DataTraitsClass ## C traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_POD_CLASS_3( C , M1 , M2 , M3 ) \ -namespace { \ -class DataTraitsClass ## C : public DataTraitsClassPOD { \ -public: \ - DataTraitsClass ## C () : DataTraitsClassPOD( # C , 3 ) \ - { \ - C tmp[1] ; \ - set_stride( tmp , tmp + 1 ); \ - add_member( # M1 , data_traits( tmp->M1 ) , tmp , & tmp->M1 ); \ - add_member( # M2 , data_traits( tmp->M2 ) , tmp , & tmp->M2 ); \ - add_member( # M3 , data_traits( tmp->M3 ) , tmp , & tmp->M3 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< C >() \ -{ static const DataTraitsClass ## C traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_POD_CLASS_4( C , M1 , M2 , M3 , M4 ) \ -namespace { \ -class DataTraitsClass ## C : public DataTraitsClassPOD { \ -public: \ - DataTraitsClass ## C () : DataTraitsClassPOD( # C , 4 ) \ - { \ - C tmp[1] ; \ - set_stride( tmp , tmp + 1 ); \ - add_member( # M1 , data_traits( tmp->M1 ) , tmp , & tmp->M1 ); \ - add_member( # M2 , data_traits( tmp->M2 ) , tmp , & tmp->M2 ); \ - add_member( # M3 , data_traits( tmp->M3 ) , tmp , & tmp->M3 ); \ - add_member( # M4 , data_traits( tmp->M4 ) , tmp , & tmp->M4 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< C >() \ -{ static const DataTraitsClass ## C traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_POD_CLASS_5( C , M1 , M2 , M3 , M4 , M5 ) \ -namespace { \ -class DataTraitsClass ## C : public DataTraitsClassPOD { \ -public: \ - DataTraitsClass ## C () : DataTraitsClassPOD( # C , 5 ) \ - { \ - C tmp[1] ; \ - set_stride( tmp , tmp + 1 ); \ - add_member( # M1 , data_traits( tmp->M1 ) , tmp , & tmp->M1 ); \ - add_member( # M2 , data_traits( tmp->M2 ) , tmp , & tmp->M2 ); \ - add_member( # M3 , data_traits( tmp->M3 ) , tmp , & tmp->M3 ); \ - add_member( # M4 , data_traits( tmp->M4 ) , tmp , & tmp->M4 ); \ - add_member( # M5 , data_traits( tmp->M5 ) , tmp , & tmp->M5 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< C >() \ -{ static const DataTraitsClass ## C traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_POD_CLASS_6( C , M1 , M2 , M3 , M4 , M5 , M6 ) \ -namespace { \ -class DataTraitsClass ## C : public DataTraitsClassPOD { \ -public: \ - DataTraitsClass ## C () : DataTraitsClassPOD( # C , 5 ) \ - { \ - C tmp[1] ; \ - set_stride( tmp , tmp + 1 ); \ - add_member( # M1 , data_traits( tmp->M1 ) , tmp , & tmp->M1 ); \ - add_member( # M2 , data_traits( tmp->M2 ) , tmp , & tmp->M2 ); \ - add_member( # M3 , data_traits( tmp->M3 ) , tmp , & tmp->M3 ); \ - add_member( # M4 , data_traits( tmp->M4 ) , tmp , & tmp->M4 ); \ - add_member( # M5 , data_traits( tmp->M5 ) , tmp , & tmp->M5 ); \ - add_member( # M6 , data_traits( tmp->M6 ) , tmp , & tmp->M6 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< C >() \ -{ static const DataTraitsClass ## C traits ; return traits ; } - -//---------------------------------------------------------------------- - -} -} - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsEnum.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsEnum.hpp deleted file mode 100644 index 85e265a1c7c4..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DataTraitsEnum.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -template< typename EnumType > class DataTraitsEnum ; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -template< typename T > -class DataTraitsEnum : public DataTraits { -public: - DataTraitsEnum( const char * name , std::size_t n ) - : DataTraits( typeid(T) , name , sizeof(T) , sizeof(T) ) - { - is_pod = true ; - is_enum = true ; - enum_info.reserve( n ); - } - - void add_member( const char * n , T v ) - { - const std::size_t i = enum_info.size(); - enum_info.resize( i + 1 ); - enum_info[i].name.assign( n ); - enum_info[i].value = static_cast( v ); - } - - void construct( void * v , std::size_t n ) const - { - const T init = static_cast( enum_info.front().value ); - T * x = reinterpret_cast(v); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ = init ; } - } - - void destroy( void * v , std::size_t n ) const {} - - void copy( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast(vy); - T * x = reinterpret_cast(vx); - T * const x_end = x + n ; - while ( x_end != x ) { *x++ = *y++ ; } - } - - void max( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast(vy); - T * x = reinterpret_cast(vx); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x , ++y ) { if ( *x < *y ) { *x = *y ; } } - } - - void min( void * vx , const void * vy , std::size_t n ) const - { - const T * y = reinterpret_cast(vy); - T * x = reinterpret_cast(vx); - T * const x_end = x + n ; - for ( ; x_end != x ; ++x , ++y ) { if ( *x > *y ) { *x = *y ; } } - } - - void print_one( std::ostream & s , T v ) const - { - std::vector::const_iterator i = enum_info.begin(); - for ( ; i != enum_info.end() && i->value != v ; ++i ); - if ( i != enum_info.end() ) { - s << i->name ; - } - else { - s << name << "( " << static_cast( v ) << " VALUE_NOT_VALID )" ; - } - } - - void print( std::ostream & s , const void * v , std::size_t n ) const - { - if ( n ) { - const T * x = reinterpret_cast(v); - const T * const x_end = x + n ; - print_one( s , *x++ ); - while ( x_end != x ) { s << " " ; print_one( s , *x++ ); } - } - } - - void pack( CommBuffer & buf , const void * v , std::size_t n ) const - { - const T * x = reinterpret_cast(v); - buf.pack( x , n ); - } - - void unpack( CommBuffer & buf , void * v , std::size_t n ) const - { - T * x = reinterpret_cast(v); - buf.unpack( x , n ); - } - - void sum( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_and( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_or( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } - - void bit_xor( void * , const void * , std::size_t ) const - { ThrowErrorMsg( "not supported" ); } -}; - -} - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_ENUM_1( T , V1 ) \ -namespace { \ -class DataTraitsEnum ## T : public DataTraitsEnum { \ -public: \ - DataTraitsEnum ## T () : DataTraitsEnum( # T , 1 ) \ - { add_member( # V1 , V1 ); } \ -}; \ -} \ -template<> const DataTraits & data_traits< T >() \ -{ static const DataTraitsEnum ## T traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_ENUM_2( T , V1 , V2 ) \ -namespace { \ -class DataTraitsEnum ## T : public DataTraitsEnum { \ -public: \ - DataTraitsEnum ## T () : DataTraitsEnum( # T , 2 ) \ - { \ - add_member( # V1 , V1 ); \ - add_member( # V2 , V2 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< T >() \ -{ static const DataTraitsEnum ## T traits ; return traits ; } - -//---------------------------------------------------------------------- - -#define DATA_TRAITS_ENUM_3( T , V1 , V2 , V3 ) \ -namespace { \ -class DataTraitsEnum ## T : public DataTraitsEnum { \ -public: \ - DataTraitsEnum ## T () : DataTraitsEnum( # T , 3 ) \ - { \ - add_member( # V1 , V1 ); \ - add_member( # V2 , V2 ); \ - add_member( # V3 , V3 ); \ - } \ -}; \ -} \ -template<> const DataTraits & data_traits< T >() \ -{ static const DataTraitsEnum ## T traits ; return traits ; } - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.cpp deleted file mode 100644 index 757fc853cfb0..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2000 - 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifdef STK_MESH_TRACE_ENABLED - -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -namespace { - -static stk_classic::diag::Writer* s_diagWriter = NULL; - -} - -void initDiagWriter(std::ostream& stream) -{ - s_diagWriter = new stk_classic::diag::Writer(stream.rdbuf(), - theDiagWriterParser().parse(std::getenv("MESHLOG"))); -} - -stk_classic::diag::Writer & theDiagWriter() -{ - ThrowRequireMsg(s_diagWriter != NULL, "Please call initDiagWwriter before theDiagWriter"); - return *s_diagWriter; -} - -DiagWriterParser & theDiagWriterParser() -{ - static DiagWriterParser parser; - - return parser; -} - -DiagWriterParser::DiagWriterParser() - : stk_classic::diag::WriterParser() -{ - mask("entity", (unsigned long) (LOG_ENTITY), "Display entity diagnostic information"); - mask("bucket", (unsigned long) (LOG_BUCKET), "Display bucket diagnostic information"); - mask("part", (unsigned long) (LOG_PART), "Display bucket diagnostic information"); - mask("field", (unsigned long) (LOG_FIELD), "Display bucket diagnostic information"); -} - -namespace { - -void bootstrap() -{ -// diag::registerWriter("meshlog", meshlog, theDiagWriterParser()); -} - -std::string log_to_str(EntityModificationLog log) -{ - if (log == 0) { - return "Not changed"; - } - else if (log == 1) { - return "Created"; - } - else if (log == 2) { - return "Modified"; - } - else if (log == 3) { - return "Marked deleted"; - } - else { - ThrowRequireMsg(false, "Unknown log " << log); - } - return ""; -} - -stk_classic::Bootstrap x(&bootstrap); - -} // namespace - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const Part& part) -{ - return writer << "Part[" << part.name() << ", " << part.mesh_meta_data_ordinal() << "]"; -} - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const Entity& entity) -{ - // Get bucket of entity - Bucket* bucket = NULL; - try { - bucket = &(entity.bucket()); - } - catch (...) {} // leave bucket as NULL if it's not found - - std::string ownership_info = "unregistered"; - std::string entity_key_str; - EntityKey key = entity.key(); - if (bucket) { - MetaData& meta_data = MetaData::get(*bucket); - Part & owned = meta_data.locally_owned_part(); - Part & shared = meta_data.globally_shared_part(); - if (bucket->member(owned)) { - ownership_info = "owned"; - } - else if (bucket->member(shared)) { - ownership_info = "shared"; - } - else if (bucket->size() == 0) { - ownership_info = "marked deleted"; - } - else { - ownership_info = "ghosted"; - } - entity_key_str = print_entity_key(meta_data, key); - } - else { - std::ostringstream out; - out << "(rank:" << key.rank() << ",id:" << key.id() << ")"; - entity_key_str = out.str(); - } - - writer << "Entity[key:" << entity_key_str << - ", ownership:" << ownership_info << - ", log:" << log_to_str(entity.log_query()) << - ", owner:" << entity.owner_rank(); - - // print comm info - writer << ", COMM: "; - PairIterEntityComm comm_itr = entity.comm(); - for ( ; !comm_itr.empty(); ++comm_itr ) { - writer << "(ghost:" << comm_itr->ghost_id << ", proc:" << comm_itr->proc << ") "; - } - return writer << "]"; -} - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const EntityKey& key) -{ - return writer << "Entity[rank:" << key.rank() << ", id:" << key.id() << "]"; -} - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const EntityProc& entity_proc) -{ - return writer << "EntityProc[entity:" << *entity_proc.first << ", proc: " << entity_proc.second << "]"; -} - -} // namespace mesh -} // namespace stk_classic - -#else -int dummy_DiagWriter() -{ - // This function is present just to put a symbol in the object - // file and eliminate a "empty object file" warning on the mac... - return 1; -} -#endif // STK_MESH_TRACE_ENABLED diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.hpp deleted file mode 100644 index 8646f4a40b93..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef stk_mesh_DiagWriter_h -#define stk_mesh_DiagWriter_h - -#ifdef STK_MESH_TRACE_ENABLED - -#include -#include -#include -#include - -#include -#include - -// Note, this classes/functions in this header are for internal use only. -// The API for tracing is defined in Trace.hpp - -namespace stk_classic { -namespace mesh { - -class Part; -class Entity; -union EntityKey; - -// Must be called before theDiagWriter/meshlog -void initDiagWriter(std::ostream& stream); - -stk_classic::diag::Writer &theDiagWriter(); -#define meshlog stk_classic::mesh::theDiagWriter() - -class DiagWriterParser : public diag::WriterParser -{ -public: - DiagWriterParser(); -}; - -DiagWriterParser &theDiagWriterParser(); - -typedef diag::Tracespec Tracespec; -typedef diag::Traceback Traceback; - -/** - * Defines the Trace objects that will be used in stk... this class - * mostly just ensures that the correct DiagWriter is used for - * tracing. - */ -class Trace : public diag::Trace -{ -public: - explicit Trace(const char *message) - : diag::Trace(meshlog, message) - {} - - Trace(const char *message, int print_mask) - : diag::Trace(meshlog, message, print_mask) - {} - - Trace(const char *message, int print_mask, bool do_trace) - : diag::Trace(meshlog, message, print_mask, do_trace) - {} -}; - -// If Writer does not know how to output an object you want to trace, you -// can address that here by defining an operator<< for that object. Note -// that Writer handles vectors and pointers automatically. - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const Part& part); - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const Entity& entity); - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const EntityKey& key); - -stk_classic::diag::Writer& operator<<(stk_classic::diag::Writer& writer, const EntityProc& entity_proc); - -} // namespace mesh -} // namespace stk_classic - -#endif // STKMESH_TRACE_ENABLED - -#endif // stk_mesh_DiagWriter_h diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter_fwd.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter_fwd.hpp deleted file mode 100644 index e9a4156ea00a..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/DiagWriter_fwd.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef stk_mesh_DiagWriter_fwd_h -#define stk_mesh_DiagWriter_fwd_h - -#include - -namespace stk_classic { -namespace mesh { - -enum LogMask { - LOG_ALWAYS = stk_classic::LOG_ALWAYS, - LOG_TRACE = stk_classic::LOG_TRACE, - LOG_TRACE_STATS = stk_classic::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = stk_classic::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = stk_classic::LOG_MEMBERS, - - LOG_STREAM_COMMON = LOG_TRACE | LOG_TRACE_STATS, - LOG_BUCKET = 0x00000100, - LOG_ENTITY = 0x00000200, - LOG_PART = 0x00000300, - LOG_FIELD = 0x00000400, - - LOG_MOD_END = 0x00000800 -}; - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_DiagWriter_fwd_h diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.cpp deleted file mode 100644 index f45fc3a89d36..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef SIERRA_MIGRATION -namespace { -static const std::vector dummy_vector; -} - -namespace sierra { -namespace Fmwk { - -const unsigned int INVALID_LOCAL_ID = std::numeric_limits::max(); -const stk_classic::mesh::RelationIterator INVALID_RELATION_ITR = dummy_vector.end(); // Some STL implementation use POD for iterators - -unsigned get_derived_type(const stk_classic::mesh::Entity&); - -} -} -#endif - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -std::string print_entity_key(const Entity& entity) -{ - return print_entity_key(MetaData::get(entity), - entity.key()); -} - -std::string print_entity_key(const Entity* entity) -{ - if (entity == NULL) { - return "NULL ENTITY"; - } - else { - return print_entity_key(*entity); - } -} - - - - -// -//---------------------------------------------------------------------- - -#ifdef SIERRA_MIGRATION - - -std::string Entity::TypeToString (Entity::ObjectTypeEnum type) { - if(type == NODE ) return "NODE"; - if(type == EDGE ) return "EDGE"; - if(type == FACE ) return "FACE"; - if(type == ELEMENT ) return "ELMENT"; - if(type == CONSTRAINT) return "CONSTRANT"; - if(type == BASE_CLASS) return "BASE_CLASS"; - return "UNKNOWN"; - - } - - -// --------------------------------------------------------------------- - -void Entity::compress_relation_capacity() -{ - m_entityImpl.compress_relation_capacity(); -#ifdef SIERRA_MIGRATION - if (!m_fmwk_attrs->aux_relations.empty()) { - RelationVector tmp(m_fmwk_attrs->aux_relations); - tmp.swap(m_fmwk_attrs->aux_relations); - } -#endif -} - -void Entity::internal_swap_in_real_entity(const int globalId) -{ - ThrowRequire(globalId > 0); - m_fmwk_attrs->global_id = globalId; - - BulkData::get(*this).change_entity_id(globalId, *this); - - internal_verify_initialization_invariant(); - - // Issue: Fmwk-managed relations (also called auxiliary relations, are not - // being resorted here, so we have to use a different < operator - // when looking for relations - -#ifndef NDEBUG - internal_verify_meshobj_invariant(); -#endif -} - -// --------------------------------------------------------------------- - -void Entity::reserve_relation(const unsigned num) -{ - if (num == 0 && aux_relations().empty()) { - RelationVector tmp; - aux_relations().swap(tmp); // clear memory of m_relations. - } - else { - aux_relations().reserve(num); - } -} - -// --------------------------------------------------------------------- - -namespace { - -struct IgnoreIdOrder -{ - bool operator()(const Relation& lhs, const Relation& rhs) - { - bool result = false; - - if (lhs.entity_rank() != rhs.entity_rank()) { - result = lhs.entity_rank() < rhs.entity_rank(); - } - else if (lhs.getRelationType() != rhs.getRelationType()) { - result = lhs.getRelationType() < rhs.getRelationType(); - } - else { - result = lhs.identifier() < rhs.identifier(); - } - return result; - } -}; - -} - -RelationIterator Entity::find_relation(const Relation& relation) const -{ - // Extremely hacky: It would be better to set up the < operator for relations so that lower_bound - // can return the desired iterator, but any sane definition would probably force a change in - // relation ordering and that's more than I'm willing to take on now. - // - // The current semantics for relation-searching is as follows: - // Ordered based on derived_type, relation_type, and ordinal in descending precedence - // If multiple relations have the same derived_type, relation_type, and ordinal, a linear - // scan takes place looking for a matching meshobj. If no such meshobj was found, then - // we are left with an iterator pointing to the first relation with a different derived_type, - // relation_type, or ordinal. To sum up, the result of the search can either be equivalent to - // lower_bound OR upper_bound depending upon the state of the relations... YUCK! - - const Relation::RelationType relation_type = relation.getRelationType(); - - RelationIterator rel = std::lower_bound(internal_begin_relation(relation_type), - internal_end_relation(relation_type), - relation, - IgnoreIdOrder()); - - // Should only loop if we are looking at back-relations, otherwise, relations with - // matching specifications are not legal. - while (rel != internal_end_relation(relation_type) && - same_specification(*rel, relation) && - rel->getMeshObj() != relation.getMeshObj()) - ++rel; - - return rel; -} - -// --------------------------------------------------------------------- - -bool Entity::update_relation( - const RelationIterator ir , - const bool back_rel_flag) const -{ - const Relation::RelationType relType = ir->getRelationType(); - ThrowAssert(verify_relation_ordering(internal_begin_relation(relType), internal_end_relation(relType))); - ThrowAssertMsg(!internal_is_handled_generically(relType), - "update_relation should not be called for STK-managed relations"); - - Entity & meshObj = *ir->getMeshObj() ; - - const Relation::RelationType backRelType = back_relation_type(relType); - - ThrowAssert(verify_relation_ordering(meshObj.internal_begin_relation(backRelType), meshObj.internal_end_relation(backRelType))); - - // Create the corresponding back relation to ir - Relation backRel_obj(const_cast(this), backRelType, ir->getOrdinal(), ir->getOrientation()); - RelationIterator backRel_itr = meshObj.find_relation(backRel_obj); - - const bool exists = backRel_itr != meshObj.internal_end_relation(backRelType) && *backRel_itr == backRel_obj; - - if (exists && !back_rel_flag) { - // Remove back relation and increment the counter - - meshObj.erase_and_clear_if_empty(backRel_itr); - - //ThrowAssert(sierra::Fmwk::get_derived_type(meshObj) != Entity::ELEMENT); - - meshObj.inc_connection(); - } - else if (!exists && back_rel_flag) { - // Insert back relation - - const unsigned k = backRel_itr - meshObj.internal_begin_relation(backRelType) ; - - meshObj.reserve_relation(meshObj.aux_relations().size() + 1); - - meshObj.aux_relations().insert(meshObj.aux_relations().begin() + k, backRel_obj); - - //ThrowAssert(sierra::Fmwk::get_derived_type(meshObj) != Entity::ELEMENT); - - meshObj.dec_connection(); - } - - ThrowAssert(verify_relation_ordering(meshObj.internal_begin_relation(relType), meshObj.internal_end_relation(relType))); - - return true; -} - -// --------------------------------------------------------------------- - -void Entity::erase_and_clear_if_empty(RelationIterator rel_itr) -{ - ThrowRequire(!internal_is_handled_generically(rel_itr->getRelationType())); - - RelationVector& aux_relations = m_fmwk_attrs->aux_relations; - aux_relations.erase(aux_relations.begin() + (rel_itr - aux_relations.begin())); // Need to convert to non-const iterator - - if (aux_relations.empty()) { - reserve_relation(0); - } -} - -// --------------------------------------------------------------------- - -void Entity::internal_verify_meshobj_invariant() const -{ - PairIterRelation stk_relations = relations(); - for ( ; !stk_relations.empty(); ++stk_relations ) { - ThrowRequireMsg(stk_relations->getMeshObj() != NULL, "Problem with: " << *stk_relations); - } - - RelationVector& aux_relations = m_fmwk_attrs->aux_relations; - for (RelationVector::const_iterator itr = aux_relations.begin(), end = aux_relations.end(); itr != end; ++itr) { - ThrowRequireMsg(itr->getMeshObj() != NULL, "Problem with: " << *itr); - } -} - -// --------------------------------------------------------------------- - -void Entity::set_relation_orientation(RelationIterator rel, unsigned orientation) -{ - const Relation::RelationType backRelType = back_relation_type(rel->getRelationType()); - - Entity & meshObj = *rel->getMeshObj(); - Relation backRel_obj(const_cast(this), backRelType, rel->getOrdinal(), rel->getOrientation()); - RelationIterator backRel_itr = meshObj.find_relation(backRel_obj); - - const bool exists = backRel_itr != meshObj.internal_end_relation(backRelType) && *backRel_itr == backRel_obj; - ThrowRequire(exists); - - // Allow clients to make changes to orientation - // Orientations do not affect Relation ordering, so this is safe. - const_cast(&*rel)->setOrientation(orientation); - const_cast(&*backRel_itr)->setOrientation(orientation); -} - -#endif - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.hpp deleted file mode 100644 index d401038739e6..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Entity.hpp +++ /dev/null @@ -1,589 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_base_Entity_hpp -#define stk_mesh_base_Entity_hpp - -#include -#include -#include -#include - -#include - -#include - -#include - -#ifdef SIERRA_MIGRATION -#include - -namespace stk_classic { -namespace mesh { -typedef RelationVector::const_iterator RelationIterator; -typedef boost::iterator_range RelationRange; -class Entity; - -//On a *strictly temporary* basis, we need to stick the following -//fmwk stuff on an entity, just to help us through the sierra migration. -//Move along folks, there's nothing to see here. -struct fmwk_attributes { - // Each member has an explanation of why it can't be handled by Entity. - - // Relations of this mesh object that can't be managed by STK such as PARENT/CHILD - RelationVector aux_relations; - - // Not a supported STK_Mesh concept - const void* shared_attr; - - // Cannot just use the id embedded in the entity-key because of negative global-ids - // for temporaries. - int global_id; - - // Can't use STK_Mesh's notion of this entity's owner because STK_Mesh is being used - // in serial mode and therefore every process will thinks it owns everything. - int owner; - - // Not a supported STK_Mesh concept - unsigned short connect_count; -}; - -} -} - -namespace sierra { -namespace Fmwk { - -class MeshObjRoster; -class MeshObjSharedAttr; -class MeshBulkData; - -extern const unsigned int INVALID_LOCAL_ID; -extern const stk_classic::mesh::RelationIterator INVALID_RELATION_ITR; - -namespace detail { -bool set_attributes( stk_classic::mesh::Entity & , const int , const MeshObjSharedAttr*, const int); -bool set_attributes( stk_classic::mesh::Entity & , const MeshObjSharedAttr*, const int); -void unset_shared_attr(stk_classic::mesh::Entity& ); -} - -namespace roster_only { -void destroy_meshobj(stk_classic::mesh::Entity*); -void set_shared_attr(stk_classic::mesh::Entity&, const MeshObjSharedAttr*); -} - -const MeshObjSharedAttr * get_shared_attr(const stk_classic::mesh::Entity&); -bool insert_relation( stk_classic::mesh::Entity * const, const stk_classic::mesh::Relation::RelationType, stk_classic::mesh::Entity * const, const unsigned, const unsigned, const bool, MeshBulkData &); -bool remove_relation(stk_classic::mesh::Entity &, const stk_classic::mesh::RelationIterator, MeshBulkData &); -bool verify_relations(const stk_classic::mesh::Entity &); -} -} -#endif - -namespace stk_classic { -namespace mesh { - -namespace impl { - -class EntityRepository; -class BucketRepository; - -} - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- -/** \brief A fundamental unit within the discretization of a problem domain, - * including but not limited to nodes, edges, sides, and elements. - * - * Entities are distributed among parallel processors. - * A given entity may reside on more than one processor; - * however, it is owned by exactly one of the processors - * on which it resides. - * - * Note that an Entity's state comprises: - * - existence - Whether this entity has been created and is not destroyed - * - owner - The rank of the owning process - * - part-membership - The set of parts this entity belongs to - * - relations - Relationships between other Entities - * When any of the above changes, the Entity's log state may change - */ -class Entity { -public: - ~Entity() {} - - /** \brief Query the current state of the entity log */ - EntityModificationLog log_query() const { return m_entityImpl.log_query(); } - - /** \brief The rank of this entity. */ - EntityRank entity_rank() const { return m_entityImpl.entity_rank(); } - - /** \brief Identifier for this entity which is globally unique - * for a given entity type. - */ - EntityId identifier() const { return m_entityImpl.identifier(); } - - /** \brief The globally unique key ( entity type + identifier ) - * of this entity. - */ - const EntityKey & key() const { return m_entityImpl.key(); } - - /** \brief The bucket which holds this mesh entity's field data */ - Bucket & bucket() const { return m_entityImpl.bucket(); } - Bucket * bucket_ptr() const { return m_entityImpl.bucket_ptr(); } - - /** \brief The ordinal for this entity within its bucket. */ - unsigned bucket_ordinal() const { return m_entityImpl.bucket_ordinal(); } - - /** \brief The mesh bulk data synchronized_count when this entity's - * part membership was most recently modified. - * - * If ( mesh.synchronized_state() == false && - * mesh.synchronized_count() == entity.synchronized_count() ) - * then entity was modified during this modification phase. - */ - size_t synchronized_count() const { return m_entityImpl.synchronized_count(); } - - //------------------------------------ - /** \brief All \ref stk_classic::mesh::Relation "Entity relations" - * for which this entity is a member. The relations are ordered - * from lowest entity-rank to highest entity-rank. - */ - PairIterRelation relations() const { return m_entityImpl.relations(); } - - /** \brief \ref stk_classic::mesh::Relation "Entity relations" for which this - * entity is a member, the other entity is of a given type. - */ - PairIterRelation relations( EntityRank type ) const { return m_entityImpl.relations(type); } - PairIterRelation node_relations() const { return m_entityImpl.node_relations(); } - -#ifdef SIERRA_MIGRATION - RelationIterator node_relation(unsigned ordinal) const { return m_entityImpl.node_relation(ordinal); } -#endif - - //------------------------------------ - /** \brief Parallel processor rank of the processor which owns this entity */ - unsigned owner_rank() const { return m_entityImpl.owner_rank(); } - - /** \brief Parallel processes which share this entity. */ - PairIterEntityComm sharing() const { return m_entityImpl.sharing(); } - - /** \brief Complete communicaiton list for this entity */ - PairIterEntityComm comm() const { return m_entityImpl.comm(); } - - /** \brief Subset communicaiton list for this entity */ - PairIterEntityComm comm( const Ghosting & sub ) const { return m_entityImpl.comm( sub ); } - -// RelationVector& rel_vec() { return m_entityImpl.rel_vec(); } - void compress_relation_capacity(); - -private: - - void set_key(const EntityKey& arg_key) { m_entityImpl.set_key(arg_key); } - - impl::EntityImpl m_entityImpl; - - explicit Entity( const EntityKey & arg_key ); - - Entity(); - Entity & operator = ( const Entity & ); ///< Assignment operator not allowed - -#ifndef DOXYGEN_COMPILE - friend class impl::EntityRepository ; - friend class impl::EntityImpl ; -#endif /* DOXYGEN_COMPILE */ - - - -// Issue: We began the migration of Fmwk MeshObj with an implementation that -// had a stk entity pointer underneath the MeshObj that could be used to manage -// the state that stk entities can manage while leaving the rest to MeshObj. -// This proved to be a performance killer since many operations required an -// extra dereference (the entity pointer) compared to before, causing lots of -// additional cache misses even for simple operations. -// -// The solution is similar to what we did with Relation; we will use the preprocessor -// to add in the Fmwk pieces of the class API when the class is being compiled -// with Sierra. -#ifdef SIERRA_MIGRATION - public: - friend class sierra::Fmwk::MeshObjRoster; - // These are free functions to facilitate the stk migration: - friend const sierra::Fmwk::MeshObjSharedAttr * sierra::Fmwk::get_shared_attr(const Entity &); - friend bool sierra::Fmwk::detail::set_attributes( Entity &, const int, const sierra::Fmwk::MeshObjSharedAttr *, const int); - friend bool sierra::Fmwk::detail::set_attributes( Entity &, const sierra::Fmwk::MeshObjSharedAttr *, const int); - friend void sierra::Fmwk::detail::unset_shared_attr(Entity &); - friend bool sierra::Fmwk::insert_relation( Entity * const, const stk_classic::mesh::Relation::RelationType, Entity * const, const unsigned, const unsigned, const bool, sierra::Fmwk::MeshBulkData &); - friend bool sierra::Fmwk::remove_relation(Entity &, const stk_classic::mesh::RelationIterator, sierra::Fmwk::MeshBulkData &); - friend bool sierra::Fmwk::verify_relations(const Entity &); - friend void sierra::Fmwk::roster_only::destroy_meshobj(stk_classic::mesh::Entity*); - friend void sierra::Fmwk::roster_only::set_shared_attr(stk_classic::mesh::Entity&, const sierra::Fmwk::MeshObjSharedAttr*); - - typedef unsigned DerivedType; ///< Derived type identifier, the admissible values may be extended - - /** - * Predefined derived type identifiers. - */ - enum ObjectTypeEnum { - NODE = 0, EDGE = 1, FACE = 2, ELEMENT = 3, CONSTRAINT = 4, NUM_TYPES = 5, BASE_CLASS = 0x00ff - }; - static std::string TypeToString (ObjectTypeEnum type); - - - - template - void init_fmwk( - const int id, - const SharedAttr* attr, - const int owner, - const int parallel_rank, - const int parallel_size) - { - ThrowAssertMsg(aux_relations().capacity() == 0, "Leftover memory found in relation vector"); - - m_fmwk_attrs->global_id = id; - m_fmwk_attrs->shared_attr = attr; - m_fmwk_attrs->owner = owner; - m_fmwk_attrs->connect_count = 0; - m_local_id = sierra::Fmwk::INVALID_LOCAL_ID; - - if (attr->locally_owned() && owner_processor_rank() == -1) { - m_fmwk_attrs->owner = parallel_rank; - ThrowAssert(owner_processor_rank() < parallel_size); - } - - internal_verify_initialization_invariant(); - } - - /** - * Get global identifier - */ - int global_id() const { - return m_fmwk_attrs->global_id; - } - - /** - At MeshObj construction, local_id is set to INVALID_LOCAL_ID. - local_id is set to a valid value when MeshObjRoster::compact_roster is called, - which occurs when optimize_roster is called, or when any of the commit_global_* - methods are called. - - When set to valid values, local_ids are contiguous and start at 0 on - the local MPI process for MeshObjs of each derived-type. - They are in the same order as the global_ids. - i.e., if meshobjA.local_id() < meshobjB.local_id(), - then meshobjA.global_id() < meshobjB.global_id() if meshobjA and meshobjB have - the same derived-type. - */ - inline unsigned local_id() const { return m_local_id; } - void set_local_id(unsigned int l_id) { m_local_id = l_id; } - - int owner_processor_rank() const { return m_fmwk_attrs->owner; } - void set_owner_processor_rank(int owner) { m_fmwk_attrs->owner = owner; } - - /** - * Number of connections to this mesh object. - * The connection count should be used to track inter-mesh object - * relationships to this mesh object that are not expressed by a - * corresponding relationship owned by this mesh object. - */ - unsigned size_connection() const { - return m_fmwk_attrs->connect_count; - } - - /** - * Increment the connection count. - */ - unsigned inc_connection() { - ++m_fmwk_attrs->connect_count; - ThrowAssert(m_fmwk_attrs->connect_count /* Did not roll over */); - return m_fmwk_attrs->connect_count; - } - - /** - * Decrement the connection count. - */ - unsigned dec_connection() { - ThrowAssert(m_fmwk_attrs->connect_count /* Will not roll-under */); - --m_fmwk_attrs->connect_count; - return m_fmwk_attrs->connect_count; - } - - RelationIterator aux_relation_begin() const { return m_fmwk_attrs->aux_relations.begin(); } - RelationIterator aux_relation_end() const { return m_fmwk_attrs->aux_relations.end(); } - - RelationVector& aux_relations() { return m_fmwk_attrs->aux_relations; } - - /** - * iterator to first relationship within the collection that mananges - * relations of the given type. - */ - RelationIterator internal_begin_relation(const Relation::RelationType relation_type) const { - if (internal_is_handled_generically(relation_type)) { - return relations().first; - } - else { - return aux_relation_begin(); - } - } - - /** - * iterator to 'end' relationship within the collection that mananges - * relations of the given type. - */ - RelationIterator internal_end_relation(const Relation::RelationType relation_type) const { - if (internal_is_handled_generically(relation_type)) { - return relations().second; - } - else { - return aux_relation_end(); - } - } - - void set_shared_attr(const void* attr) { m_fmwk_attrs->shared_attr = attr; } - const void* get_shared_attr() const { return m_fmwk_attrs->shared_attr; } - - // TODO: Refactor clients so that this method is no longer needed - void set_relation_orientation(RelationIterator rel, unsigned orientation); - - private: - - /** - * Reserve storage for a total of 'num' relationships - * If 'num' is more that the current number of relationships - * then additional storage is allocated but not used. - * If 'num' is less that the current number of relationships - * then no action is taken. - */ - void reserve_relation(const unsigned num); - - /** - * Update the back-relation - * If back_rel_flag then insert the back-pointer if it does not exist - * else remove the back-pointer and increment the related object's counter. - * - * In general, clients should not be calling this. MeshObj should be managing - * its own back relations. - */ - bool update_relation(const RelationIterator ir, const bool back_rel_flag) const; - - RelationIterator find_relation(const Relation& relation) const; - - void erase_and_clear_if_empty(RelationIterator rel_itr); - - void internal_verify_meshobj_invariant() const; - - void internal_swap_in_real_entity(const int globalId); - - void internal_verify_initialization_invariant() { - // If this MeshObj has a proper ID (fully initialized), then the id should match - // the id in the entity-key; otherwise they should not match. - ThrowAssert( !(m_fmwk_attrs->global_id < 0 && key().id() == static_cast(m_fmwk_attrs->global_id)) && - !(m_fmwk_attrs->global_id > 0 && key().id() != static_cast(m_fmwk_attrs->global_id)) ); - - } - - unsigned stk_entity_rank() const { return key().rank(); } - - bool internal_is_handled_generically(const Relation::RelationType relation_type) const - { - return relation_type == Relation::USES || relation_type == Relation::USED_BY; - } - - // - // Members needed to support Fmwk_MeshObj API - // - - fmwk_attributes* m_fmwk_attrs; - - // Not a supported STK_Mesh concept, but fmwk requires it. We have it - // here instead of in m_fmwk_attrs for performance reasons (saves a - // memory hop when accessing local_id). - unsigned m_local_id; -#endif -}; - -#ifdef SIERRA_MIGRATION - -inline -Relation::RelationType -back_relation_type(const Relation::RelationType relType) -{ - /* %TRACE[NONE]% */ /* %TRACE% */ - switch(relType) { - case Relation::USES: - return Relation::USED_BY; - case Relation::USED_BY: - return Relation::USES; - case Relation::CHILD: - return Relation::PARENT; - case Relation::PARENT: - return Relation::CHILD; - default: - return relType; - } -} - -// Made publicly available so that MeshObj.C can use it -template -bool -verify_relation_ordering(Iterator begin, Iterator end) -{ - for (Iterator itr = begin; itr != end; ) { - Iterator prev = itr; - ++itr; - if (itr != end) { - - if (itr->entity_rank() < prev->entity_rank()) { - return false ; - } - - if (itr->entity_rank() == prev->entity_rank()) { - - if (itr->getRelationType() < prev->getRelationType()) { - return false ; - } - - if (itr->getRelationType() == prev->getRelationType()) { - - if (itr->getOrdinal() < prev->getOrdinal()) { - return false ; - } - } - } - } - } - return true ; -} - -template -bool -verify_relation_ordering(Range range) -{ - return verify_relation_ordering(boost::const_begin(range), boost::const_end(range)); -} - -#endif - -/** \brief Comparison operator for entities compares the entities' keys */ -class EntityLess { -public: - ~EntityLess() {} - EntityLess() {} - EntityLess( const EntityLess & ) {} - EntityLess & operator = ( const EntityLess & ) { return *this ; } - - /** \brief Comparison operator */ - bool operator()(const Entity& lhs, const Entity& rhs) const - { return lhs.key() < rhs.key(); } - - bool operator()(const Entity& lhs, const EntityKey & rhs) const - { return lhs.key() < rhs ; } - - /** \brief Comparison operator */ - bool operator()(const Entity* lhs, const Entity* rhs) const - { - const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ; - const EntityKey rhs_key = rhs ? rhs->key() : EntityKey() ; - return lhs_key < rhs_key ; - } - - bool operator()(const Entity* lhs, const Entity& rhs) const - { - const EntityKey lhs_key = lhs ? lhs->key() : EntityKey(); - return lhs_key < rhs.key() ; - } - - bool operator()(const Entity& lhs, const Entity* rhs) const - { - const EntityKey rhs_key = rhs ? rhs->key() : EntityKey(); - return lhs.key() < rhs_key ; - } - - bool operator()(const Entity* lhs, const EntityKey & rhs) const - { - const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ; - return lhs_key < rhs ; - } - - bool operator()( const EntityProc & lhs, const EntityProc & rhs) const - { - const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ; - const EntityKey rhs_key = rhs.first ? rhs.first->key() : EntityKey() ; - return lhs_key != rhs_key ? lhs_key < rhs_key : lhs.second < rhs.second ; - } - - bool operator()( const EntityProc & lhs, const Entity & rhs) const - { - const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ; - return lhs_key < rhs.key(); - } - - bool operator()( const EntityProc & lhs, const Entity * rhs) const - { - const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ; - const EntityKey rhs_key = rhs ? rhs->key() : EntityKey() ; - return lhs_key < rhs_key ; - } - - bool operator()( const EntityProc & lhs, const EntityKey & rhs) const - { - const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ; - return lhs_key < rhs ; - } - -}; //class EntityLess - -class EntityEqual -{ -public: - bool operator()(const stk_classic::mesh::Entity* lhs, const stk_classic::mesh::Entity* rhs) const - { - const stk_classic::mesh::EntityKey lhs_key = lhs ? lhs->key() : stk_classic::mesh::EntityKey(); - const stk_classic::mesh::EntityKey rhs_key = rhs ? rhs->key() : stk_classic::mesh::EntityKey(); - return lhs_key == rhs_key; - } - - bool operator()(const stk_classic::mesh::Entity& lhs, const stk_classic::mesh::Entity& rhs) const - { - const stk_classic::mesh::EntityKey lhs_key = lhs.key(); - const stk_classic::mesh::EntityKey rhs_key = rhs.key(); - return lhs_key == rhs_key; - } -}; - -std::string print_entity_key(const Entity& entity); - -std::string print_entity_key(const Entity* entity); - -inline -Entity::Entity() - : m_entityImpl() -#ifdef SIERRA_MIGRATION - , m_fmwk_attrs(NULL) -#endif -{} - -inline -Entity::Entity( const EntityKey & arg_key ) - : m_entityImpl( arg_key ) -#ifdef SIERRA_MIGRATION - , m_fmwk_attrs(NULL) -#endif -{} - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -#endif /* stk_mesh_base_Entity_hpp */ diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.cpp deleted file mode 100644 index 9f8b137e90a1..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------------- - -bool in_shared( const Entity & entity ) -{ - PairIterEntityComm ec = entity.comm(); - return ! ec.empty() && ec.front().ghost_id == 0 ; -} - -bool in_shared( const Entity & entity , unsigned proc ) -{ - for ( PairIterEntityComm ec = entity.comm(); - ! ec.empty() && ec->ghost_id == 0 ; ++ec ) { - if ( proc == ec->proc ) { - return true ; - } - } - return false ; -} - -bool in_receive_ghost( const Entity & entity ) -{ - // Ghost communication with owner. - PairIterEntityComm ec = entity.comm(); - return ! ec.empty() && ec.front().ghost_id != 0 && - ec.front().proc == entity.owner_rank(); -} - -bool in_receive_ghost( const Ghosting & ghost , const Entity & entity ) -{ - return in_ghost( ghost , entity , entity.owner_rank() ); -} - -bool in_send_ghost( const Entity & entity ) -{ - // Ghost communication with non-owner. - PairIterEntityComm ec = entity.comm(); - return ! ec.empty() && ec.back().ghost_id != 0 && - ec.back().proc != entity.owner_rank(); -} - -bool in_send_ghost( const Entity & entity , unsigned proc ) -{ - for ( PairIterEntityComm ec = entity.comm(); ! ec.empty() ; ++ec ) { - if ( ec->ghost_id != 0 && - ec->proc != entity.owner_rank() && - ec->proc == proc ) { - return true ; - } - } - return false ; -} - -bool in_ghost( const Ghosting & ghost , const Entity & entity , unsigned p ) -{ - // Ghost communication from owner. - EntityCommInfo tmp( ghost.ordinal() , p ); - - std::vector::const_iterator i = - std::lower_bound( entity.comm().begin() , entity.comm().end() , tmp ); - - return i != entity.comm().end() && tmp == *i ; -} - -/** \brief Is in owned closure of the given process, - * typically the local process. - */ -bool in_owned_closure( const Entity & entity , unsigned proc ) -{ - // TODO: This function has a potential performance problem if relations - // are dense. - - // Does proc own this entity? If so, we're done - bool result = entity.owner_rank() == proc ; - - if ( ! result ) { - const unsigned erank = entity.entity_rank(); - - // Does entity have an upward relation to an entity owned by proc - for ( PairIterRelation - rel = entity.relations(); ! result && ! rel.empty() ; ++rel ) { - result = erank < rel->entity_rank() && - in_owned_closure( * rel->entity(), proc); - } - } - - return result ; -} - -void comm_procs( const Entity & entity , std::vector & procs ) -{ - procs.clear(); - for ( PairIterEntityComm ec = entity.comm(); ! ec.empty() ; ++ec ) { - procs.push_back( ec->proc ); - } - std::sort( procs.begin() , procs.end() ); - std::vector::iterator - i = std::unique( procs.begin() , procs.end() ); - procs.erase( i , procs.end() ); -} - -void comm_procs( const Ghosting & ghost , - const Entity & entity , std::vector & procs ) -{ - procs.clear(); - for ( PairIterEntityComm ec = entity.comm(); ! ec.empty() ; ++ec ) { - if ( ec->ghost_id == ghost.ordinal() ) { - procs.push_back( ec->proc ); - } - } -} - - -//---------------------------------------------------------------------------- - -void pack_entity_info( CommBuffer & buf , const Entity & entity ) -{ - const EntityKey & key = entity.key(); - const unsigned owner = entity.owner_rank(); - const std::pair - part_ordinals = entity.bucket().superset_part_ordinals(); - const PairIterRelation relations = entity.relations(); - - const unsigned nparts = part_ordinals.second - part_ordinals.first ; - const unsigned nrel = relations.size(); - - buf.pack( key ); - buf.pack( owner ); - buf.pack( nparts ); - buf.pack( part_ordinals.first , nparts ); - buf.pack( nrel ); - - for ( unsigned i = 0 ; i < nrel ; ++i ) { - buf.pack( relations[i].entity()->key() ); - buf.pack( relations[i].identifier() ); - buf.pack( relations[i].attribute() ); - } -} - -void unpack_entity_info( - CommBuffer & buf, - const BulkData & mesh , - EntityKey & key , - unsigned & owner , - PartVector & parts , - std::vector & relations ) -{ - unsigned nparts = 0 ; - unsigned nrel = 0 ; - - buf.unpack( key ); - buf.unpack( owner ); - buf.unpack( nparts ); - - parts.resize( nparts ); - - for ( unsigned i = 0 ; i < nparts ; ++i ) { - unsigned part_ordinal = ~0u ; - buf.unpack( part_ordinal ); - parts[i] = & MetaData::get(mesh).get_part( part_ordinal ); - } - - buf.unpack( nrel ); - - relations.clear(); - relations.reserve( nrel ); - - for ( unsigned i = 0 ; i < nrel ; ++i ) { - EntityKey rel_key ; - unsigned rel_id = 0 ; - unsigned rel_attr = 0 ; - buf.unpack( rel_key ); - buf.unpack( rel_id ); - buf.unpack( rel_attr ); - Entity * const entity = - mesh.get_entity( entity_rank(rel_key), entity_id(rel_key) ); - if ( entity && EntityLogDeleted != entity->log_query() ) { - Relation rel( * entity, rel_id ); - rel.set_attribute(rel_attr); - relations.push_back( rel ); - } - } -} - - -//---------------------------------------------------------------------- - -void pack_field_values( CommBuffer & buf , Entity & entity ) -{ - const Bucket & bucket = entity.bucket(); - const BulkData & mesh = BulkData::get(bucket); - const MetaData & mesh_meta_data = MetaData::get(mesh); - - const std::vector< FieldBase * > & fields = mesh_meta_data.get_fields(); - - for ( std::vector< FieldBase * >::const_iterator - i = fields.begin() ; i != fields.end() ; ++i ) { - - const FieldBase & f = **i ; - - if ( f.data_traits().is_pod ) { - const unsigned size = field_data_size( f , bucket ); - - buf.pack( size ); - - if ( size ) { - unsigned char * const ptr = - reinterpret_cast( field_data( f , entity ) ); - buf.pack( ptr , size ); - } - } - } -} - -bool unpack_field_values( - CommBuffer & buf , Entity & entity , std::ostream & error_msg ) -{ - const Bucket & bucket = entity.bucket(); - const BulkData & mesh = BulkData::get(bucket); - const MetaData & mesh_meta_data = MetaData::get(mesh); - - const std::vector< FieldBase * > & fields = mesh_meta_data.get_fields(); - - const std::vector< FieldBase * >::const_iterator i_end = fields.end(); - const std::vector< FieldBase * >::const_iterator i_beg = fields.begin(); - - std::vector< FieldBase * >::const_iterator i ; - - bool ok = true ; - - for ( i = i_beg ; i_end != i ; ) { - const FieldBase & f = **i ; ++i ; - - if ( f.data_traits().is_pod ) { - - const unsigned size = field_data_size( f , bucket ); - unsigned recv_data_size = 0 ; - buf.unpack( recv_data_size ); - - if ( size != recv_data_size ) { - if ( ok ) { - ok = false ; - print_entity_key( error_msg , mesh_meta_data , entity.key() ); - } - error_msg << " " << f.name(); - error_msg << " " << size ; - error_msg << " != " << recv_data_size ; - buf.skip( recv_data_size ); - } - else if ( size ) { // Non-zero and equal - unsigned char * ptr = - reinterpret_cast( field_data( f , entity ) ); - buf.unpack( ptr , size ); - } - } - } - - return ok ; -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.hpp deleted file mode 100644 index 3ba212ade6b5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityComm.hpp +++ /dev/null @@ -1,239 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_EntityComm_hpp -#define stk_mesh_EntityComm_hpp - -//---------------------------------------------------------------------- - -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -class EntityComm -{ -public: - typedef boost::unordered_map map_type; - - PairIterEntityComm sharing( const EntityKey & key ) const; - PairIterEntityComm comm( const EntityKey & key ) const; - PairIterEntityComm comm( const EntityKey & key, const Ghosting & sub ) const; - - bool insert( const EntityKey & key, const EntityCommInfo & val ); - bool erase( const EntityKey & key, const EntityCommInfo & val ); - bool erase( const EntityKey & key, const Ghosting & ghost ); - void comm_clear_ghosting(const EntityKey & key ); - void comm_clear(const EntityKey & key ); - void comm_swap(const EntityKey & key1, const EntityKey & key2); - -private: - map_type m_comm_map; -}; - -inline PairIterEntityComm EntityComm::sharing( const EntityKey & key ) const -{ - map_type::const_iterator it = m_comm_map.find(key); - if (it == m_comm_map.cend()) { - return PairIterEntityComm(); - } - const EntityCommInfoVector & m_comm = it->second; - - EntityCommInfoVector::const_iterator i = m_comm.begin(); - EntityCommInfoVector::const_iterator e = m_comm.end(); - - e = std::lower_bound( i , e , EntityCommInfo(1, // ghost id, 1->aura - 0 ) ); // proc - - // Contains everything up the first aura comm (IE, only contains shared comms) - return PairIterEntityComm( i , e ); -} - -inline PairIterEntityComm EntityComm::comm( const EntityKey & key ) const -{ - map_type::const_iterator it = m_comm_map.find(key); - if (it == m_comm_map.cend()) { - return PairIterEntityComm(); - } - const EntityCommInfoVector & m_comm = it->second; - return PairIterEntityComm(m_comm); -} - -inline PairIterEntityComm EntityComm::comm( const EntityKey & key, const Ghosting & sub ) const -{ - map_type::const_iterator it = m_comm_map.find(key); - if (it == m_comm_map.cend()) { - return PairIterEntityComm(); - } - const EntityCommInfoVector & m_comm = it->second; - - const EntityCommInfo s_begin( sub.ordinal() , 0 ); - const EntityCommInfo s_end( sub.ordinal() + 1 , 0 ); - - EntityCommInfoVector::const_iterator i = m_comm.begin(); - EntityCommInfoVector::const_iterator e = m_comm.end(); - - i = std::lower_bound( i , e , s_begin ); - e = std::lower_bound( i , e , s_end ); - - return PairIterEntityComm( i , e ); -} - -inline bool EntityComm::insert( const EntityKey & key, const EntityCommInfo & val ) -{ - TraceIfWatching("stk_classic::mesh::EntityComm::insert", LOG_ENTITY, key()); - EntityCommInfoVector & m_comm = m_comm_map[key]; - - std::vector< EntityCommInfo >::iterator i = - std::lower_bound( m_comm.begin() , m_comm.end() , val ); - - const bool result = ((i == m_comm.end()) || (val != *i)); - - if ( result ) { - m_comm.insert( i , val ); - } - - return result ; -} - -inline bool EntityComm::erase( const EntityKey & key, const EntityCommInfo & val ) -{ - TraceIfWatching("stk_classic::mesh::EntityComm::erase(comm)", LOG_ENTITY, key()); - EntityCommInfoVector & m_comm = m_comm_map[key]; - - std::vector< EntityCommInfo >::iterator i = - std::lower_bound( m_comm.begin() , m_comm.end() , val ); - - const bool result = ( (i != m_comm.end()) && (val == *i) ) ; - - if ( result ) { - m_comm.erase( i ); - } - - return result ; -} - -inline bool EntityComm::erase( const EntityKey & key, const Ghosting & ghost ) -{ - TraceIfWatching("stk_classic::mesh::EntityComm::erase(ghost)", LOG_ENTITY, key()); - EntityCommInfoVector & m_comm = m_comm_map[key]; - - const EntityCommInfo s_begin( ghost.ordinal() , 0 ); - const EntityCommInfo s_end( ghost.ordinal() + 1 , 0 ); - - EntityCommInfoVector::iterator i = m_comm.begin(); - EntityCommInfoVector::iterator e = m_comm.end(); - - i = std::lower_bound( i , e , s_begin ); - e = std::lower_bound( i , e , s_end ); - - const bool result = i != e ; - - if ( result ) { - m_comm.erase( i , e ); - } - - return result ; -} - -inline void EntityComm::comm_clear_ghosting(const EntityKey & key) -{ - TraceIfWatching("stk_classic::mesh::EntityComm::comm_clear_ghosting", LOG_ENTITY, key()); - EntityCommInfoVector & m_comm = m_comm_map[key]; - - std::vector< EntityCommInfo >::iterator j = m_comm.begin(); - while ( j != m_comm.end() && j->ghost_id == 0 ) { ++j ; } - m_comm.erase( j , m_comm.end() ); -} - -inline void EntityComm::comm_clear(const EntityKey & key) -{ - TraceIfWatching("stk_classic::mesh::EntityComm::comm_clear", LOG_ENTITY, key()); - EntityCommInfoVector& commvec = m_comm_map[key]; - commvec.clear(); -} - -inline void EntityComm::comm_swap(const EntityKey & key1, const EntityKey & key2) -{ - map_type::iterator it1 = m_comm_map.find(key1); - map_type::iterator it2 = m_comm_map.find(key2); - - if (it1 == m_comm_map.cend() && it2 == m_comm_map.cend()) { - return; - } - - EntityCommInfoVector & comm1 = it1 == m_comm_map.cend() ? m_comm_map[key1] : it1->second; - EntityCommInfoVector & comm2 = it2 == m_comm_map.cend() ? m_comm_map[key2] : it2->second; - - comm1.swap(comm2); -} - -/** \brief Is shared with any other process */ -bool in_shared( const Entity & entity ); - -/** \brief Is shared with a given process */ -bool in_shared( const Entity & entity , unsigned proc ); - -/** \brief Is a receive ghost copy of an entity */ -bool in_receive_ghost( const Entity & entity ); - -/** \brief Is a receive ghost copy of an entity */ -bool in_receive_ghost( const Ghosting & ghost , const Entity & entity ); - -/** \brief Is sent to a ghost copy of an entity on any process */ -bool in_send_ghost( const Entity & entity ); - -/** \brief Is sent to a ghost copy of an entity on a given process */ -bool in_send_ghost( const Entity & entity , unsigned proc ); - -/** \brief Is in ghosting either send to 'p' or receive from 'p' */ -bool in_ghost( const Ghosting & ghost , const Entity & entity , unsigned p ); - -/** \brief Is in owned closure of the given process, - * typically the local process. - */ -bool in_owned_closure( const Entity & entity , unsigned proc ); - -/** \brief List of all entity communication processes, sorted */ -void comm_procs( const Entity & entity , std::vector & procs ); - -/** \brief List of entity communication processes for a given ghost, sorted */ -void comm_procs( const Ghosting & ghost , - const Entity & entity , std::vector & procs ); - -//---------------------------------------------------------------------- - -void pack_entity_info( CommBuffer & buf , const Entity & entity ); - -void unpack_entity_info( - CommBuffer & buf, - const BulkData & mesh , - EntityKey & key , - unsigned & owner , - PartVector & parts , - std::vector & relations ); - -/** \brief Pack an entity's field values into a buffer */ -void pack_field_values( CommBuffer & , Entity & ); - -/** \brief Unpack an entity's field values from a buffer */ -bool unpack_field_values( CommBuffer & , Entity & , std::ostream & error_msg ); - -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.cpp deleted file mode 100644 index f09cfc96c7db..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { - -EntityKey::EntityKey( EntityRank entity_rank , - EntityKey::raw_key_type entity_id ) - : key( ( raw_key_type(entity_rank) << id_digits ) | entity_id ) -{ - enum { OK = StaticAssert< sizeof(EntityKey) == - sizeof(EntityKey::raw_key_type) >::OK }; - - ThrowAssertMsg( rank() == entity_rank, - "entity_rank out of range, entity_rank= " << entity_rank << " rank() = " << rank() << " entity_id= " << entity_id << " id() = " << id() ); - - ThrowAssertMsg( id() == entity_id, - "entity_id out of range, entity_rank= " << entity_rank << " rank() = " << rank() << " entity_id= " << entity_id << " id() = " << id() ); -} - - -} -} - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.hpp deleted file mode 100644 index e8bf490478fe..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/EntityKey.hpp +++ /dev/null @@ -1,193 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_EntityKey_hpp -#define stk_mesh_EntityKey_hpp - -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - - -// Note: EntityRank and EntityId typedefs are defined in Types.hpp - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- -/** \brief Integer type for the entity keys, which is an encoding - * of the entity type and entity identifier. - * - * This type is used to fully order entities and entity pointers - * in numerous containers. Ordering is first by type and second - * by identifier. Values of this type are frequently compared for - * ordering and equality, and are frequently communicated between - * parallel processes. Thus the motivation for this type to be - * a "plain old data" type. - * - * Notes on construction and validity: - * - * EntityKey takes constructor arguments entity_rank and entity_id which - * are restricted to lie in a sub-range of what can be represented by the - * EntityRank and EntityId types. The sub-range allowed by EntityKey is - * dictated by the amount of space used to store the internal encoding of - * those values (described further in the comments for the EntityKey - * constructor below). - * - * The function entity_key_valid attempts to determine that the key was - * not created by some erroneous operation such as assignment from a - * smaller type like a 32-bit int. - * - * Note that an instance of stk_classic::mesh may place further restrictions on a - * 'valid' key, such as requiring that - * 0 <= entity_rank(key) < meta_data.entity_rank_count(). - * - * Typically stk_classic::mesh does not take EntityKeys as input. A user of - * stk_classic::mesh would (for instance) request that an Entity be created by - * specifying an entity-type and entity-id as input. The resulting - * Entity would then hold a mesh-created EntityKey that could be queried. - * Thus stk_classic::mesh can control the validity of EntityKeys associated with - * the mesh. - */ -union EntityKey { -public: - typedef uint64_t raw_key_type ; - - enum { rank_digits = 8 }; - -private: - - enum { - invalid_key = ~raw_key_type(0) , - raw_digits = std::numeric_limits::digits , - id_digits = raw_digits - rank_digits , - id_mask = ~raw_key_type(0) >> rank_digits - }; - - raw_key_type key ; - - struct { - raw_key_type id : id_digits ; - raw_key_type rank : rank_digits ; - } normal_view ; - - struct { - raw_key_type rank : rank_digits ; - raw_key_type id : id_digits ; - } reverse_view ; - -public: - /** \brief Destructor */ - ~EntityKey() {} - - /** Default constructor. - * Note that entity_key_valid(key) == false if key is default-constructed. - */ - EntityKey() : key(invalid_key) { } - - EntityKey( const EntityKey & rhs ) : key( rhs.key ) {} - - EntityKey & operator = ( const EntityKey & rhs ) - { key = rhs.key ; return *this ; } - - /** Constructor - * - * \param entity_rank is required to lie in the range 0 to 255 (which is - * the limit of what can be stored in 8 bits). This limit may be raised - * if we decide to use more than 8 bits for encoding an entity-type. - * - * \param entity_id is required to lie in the range 1 to 2^id_digits. - * - * If entity_rank or entity_id lie outside these ranges an exception will - * be thrown. - */ - EntityKey( EntityRank entity_rank, raw_key_type entity_id ); - - raw_key_type id() const { return key & id_mask ; } - - EntityRank rank() const { return key >> id_digits ; } - - EntityRank type() const { return rank(); } - - bool operator==(const EntityKey &rhs) const { - return key == rhs.key; - } - - bool operator!=(const EntityKey &rhs) const { - return !(key == rhs.key); - } - - bool operator<(const EntityKey &rhs) const { - return key < rhs.key; - } - - bool operator>(const EntityKey &rhs) const { - return rhs.key < key; - } - - bool operator<=(const EntityKey &rhs) const { - return !(key < rhs.key); - } - - bool operator>=(const EntityKey &rhs) const { - return !(rhs.key < key); - } - - //------------------------------ - // As safe and explict a conversion - // as possible between the raw_key_type and value. - - explicit EntityKey( const raw_key_type * const value ) - : key( *value ) {} - - raw_key_type raw_key() const { return key ; } -}; - -// Functions for encoding / decoding entity keys. - -/** \brief Given an entity key, return an entity type (rank). */ -inline -EntityRank entity_rank( const EntityKey & key ) { - return key.rank(); -} - -/** \brief Given an entity key, return the identifier for the entity. */ -inline -EntityId entity_id( const EntityKey & key ) { - return key.id(); -} - -/** \brief Query if an entity key is valid */ -inline -bool entity_key_valid( const EntityKey & key ) { - return key != EntityKey(); -} - -inline -bool entity_id_valid( EntityKey::raw_key_type id ) { - return 0 < id && id <= EntityKey().id(); -} - -inline -size_t hash_value( EntityKey key) { - return boost::hash_value(key.raw_key()); -} - - - -} // namespace mesh -} // namespace stk_classic - -#endif /* stk_mesh_EntityKey_hpp */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Field.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Field.hpp deleted file mode 100644 index 137c75799b35..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Field.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_Field_hpp -#define stk_mesh_Field_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -/** \ingroup stk_mesh_module - * \brief Field with defined data type and multi-dimensions (if any) - * - * Conceptually, a field describes computational data that is associated with - * mesh entities. The data is not related to connectivity or mesh structure; rather, - * it is used to track some property (like velocity) that is relevant to the - * problem being solved. - * - * A field specification has three components - * - Field type: Defines the type of this field's data. This can be scalar or multidimensional. - * If multidimensional (dimensions >= 1), a specification of each dimension will need - * to be provided in the form of a shards::ArrayDimTag. Many common ArrayDimTags are defined - * in stk_mesh/fem/CoordinateSystems.hpp, but apps are free to define their own as well. - * - Examples: - * - A scalar double field-type: - * stk_classic::mesh::Field - * - A vector field type using the Cartesian array-dim-tag from CoordinateSystems: - * stk_classic::mesh::Field - * - * - Field declaration: Defines/creates a specific field of a specified type. The API for - * declaring fields is in (FEM)MetaData. Declaration of a field requires a field-type, - * field name, and number of states. The number of states defines the "memory" of the Field; - * if number-of-states is N, the last N values of the field are stored, and the user - * can advance/rotate the states by calling BulkData::update_field_data_states(). FieldState.hpp - * contains an enum that clients should use to refer to the various states. - * - Examples: - * typedef stk_classic::mesh::Field CoordFieldType; - * CoordFieldType& coord_field = meta.declare_field("", ); - * - * - Field restrictions: Defines the set of entities that have a field and the dimensions of the - * field (maximum of 7 dimensions). FieldRestrictions are applied to Parts and entities pick - * up the field by being placed in the associated part. Also, FieldRestrictions allow the same - * Field to be applied to different ranks of entities. E.g., you could apply a velocity Field - * to both Faces and Edges through two different FieldRestrictions for each of the different ranks. - * Also, FieldRestrictions can apply a nodal field to all nodes in an element ranked part. This - * depends on the concept of induced part membership since you can't put a node directly in an - * element ranked part, but any nodes reachable through downward relations from elements that are - * in the part will be induced into the part and therefore pick up the field. This allows you to - * specify special nodal fields for different element types. - * - * The public API for declaring field restrictions is in MetaData.hpp; - * we strongly recommend using the put_field free functions to create your field restrictions. A - * field may have many restrictions, but the restrictions have to be compatible with each other; - * restrictions can overlap if an entity is a member of two parts A,B and you declare restrictions - * for a field for both A and B. If such a situation arises, the dimensionality of both restrictions - * must be identical. - * - Examples: - * - Put a scalar field on all nodes in a part - * typedef stk_classic::mesh::Field ScalarFieldType; - * ScalarFieldType& field = meta.declare_field("", ); - * stk_classic::mesh::put_field(field, fem::FEMMetaData::NODE_RANK, ); - * - * - Put a 1d (of size 3) field of doubles on all nodes in a part - * typedef stk_classic::mesh::Field CoordFieldType; - * CoordFieldType& field = meta.declare_field("", ); - * stk_classic::mesh::put_field(field, fem::FEMMetaData::NODE_RANK, , Cartesian3d::Size); - * - * - Put a 2d (of sizes 3 and 3) field of doubles on all nodes in a part - * typedef stk_classic::mesh::Field MultiDimFieldType; - * MultiFieldType& field = meta.declare_field("", ); - * stk_classic::mesh::put_field(field, fem::FEMMetaData::NODE_RANK, , Cartesian3d::Size, Cartesian3d::Size); - * - * Items of interest - * - Accessing field data: see FieldData.hpp - * - Field relations: see FieldRelations.hpp - * - * Field-related API - * - stk_mesh/base/MetaData - Methods for... - * - declaring fields - * - declaring field restrictions - * - declaring field attributes - * - declaring field relations - * - querying fields by name - * - stk_mesh/base/BulkData - Methods for advancing field state - * - stk_mesh/base/FieldData - Defines API for accessing field data - * - stk_mesh/base/FieldBase - Defines member-function API for Field objects - * - stk_mesh/base/Field - Place to put Field template, not much API here - * - stk_mesh/base/FieldParallel - Free functions for some parallel operations - * - stk_mesh/base/FieldRestriction - Defines FieldRestriction class - * - stk_mesh/base/FieldRelation - Defines FieldRelation class - * - stk_mesh/base/FieldState - Defines enums to refer to field states - * - stk_mesh/base/FieldTraits - Defines API for querying field-types - * - stk_mesh/fem/CoordinateSystems - Defines common ArrayDimTags (used for defining Field types) - * - stk_mesh/fem/TopologyDimensions - Contains useful Field types / ArrayDimTags for setting up field relations - * - Type-related in ArrayDim, DataTraits - * - * - TODO Describe relationship with Buckets - */ -// Implementation Details: -// The template arguments below describe the field type. Scalar is the scalar -// type of data contained by the field. The TagN describe each dimension of the -// Field, these are expected to be ArrayDimTags. Unused dimensions can be ignored. -template< typename Scalar , class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7 > -class Field : public FieldBase { -public: - - /** \brief Query this field for a given field state. */ - Field & field_of_state( FieldState input_state ) const { - return static_cast( * FieldBase::field_state(input_state) ); - } - -private: - -#ifndef DOXYGEN_COMPILE - - ~Field(); - Field(); - Field( const Field & ); - Field & operator = ( const Field & ); - -#endif /* DOXYGEN_COMPILE */ -}; - -} // namespace mesh -} // namespace stk_classic - -#endif /* stk_mesh_Field_hpp */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.cpp deleted file mode 100644 index 04006a8f5f04..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace mesh { - -std::ostream & operator << ( std::ostream & s , const FieldBase & field ) -{ - s << "FieldBase<" ; - s << field.data_traits().name ; - for ( unsigned i = 0 ; i < field.rank() ; ++i ) { - s << "," << field.dimension_tags()[i]->name(); - } - s << ">" ; - - s << "[ name = \"" ; - s << field.name() ; - s << "\" , #states = " ; - s << field.number_of_states(); - s << " ]" ; - return s ; -} - -std::ostream & print( std::ostream & s , - const char * const b , - const FieldBase & field ) -{ - const PartVector & all_parts = MetaData::get(field).get_parts(); - const std::vector & rMap = field.restrictions(); - s << field ; - s << " {" ; - for ( std::vector::const_iterator - i = rMap.begin() ; i != rMap.end() ; ++i ) { - s << std::endl << b << " " ; - i->print( s, i->entity_rank(), * all_parts[ i->part_ordinal() ], field.rank() ); - } - s << std::endl << b << "}" ; - return s ; -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.hpp deleted file mode 100644 index 2a6480000f84..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldBase.hpp +++ /dev/null @@ -1,200 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_base_FieldBase_hpp -#define stk_mesh_base_FieldBase_hpp - -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include - -namespace stk_classic { -namespace mesh { - -class UnitTestFieldImpl; - -namespace impl { - -class FieldRepository; - -} - -//---------------------------------------------------------------------- -/** \ingroup stk_stk_mesh_module - * \brief Field base class with an anonymous data type and - * anonymous multi-dimension. - * - * This class is the base class for all Fields. It defines the member-function - * API for Field objects. Note that the entire Field API is much broader than - * what's defined in this class. See Field.hpp for more. - */ -// Implementation details: -// Simply wraps a FieldBaseImpl object which is kept as a member, all calls are -// inlined and passed through to the impl object. This design is analogous -// to the "P-impl" pattern. -class FieldBase -{ - public: - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns this field - */ - MetaData & mesh_meta_data() const { return m_impl.meta_data(); } - /** \brief Internally generated ordinal of this field that is unique - * within the owning \ref stk_classic::mesh::MetaData "meta data manager". - */ - unsigned mesh_meta_data_ordinal() const { return m_impl.ordinal(); } - - /** \brief Application-defined text name of this field */ - const std::string & name() const { return m_impl.name() ; } - - /** \brief Query if the type is Type */ - template bool type_is() const - { return m_impl.type_is(); } - - /** \brief Return the \ref stk_classic::mesh::DataTraits "data traits" - * for this field's type - */ - const DataTraits & data_traits() const { return m_impl.data_traits() ; } - - /** \brief Number of states of this field */ - unsigned number_of_states() const { return m_impl.number_of_states() ; } - - /** \brief FieldState of this field */ - FieldState state() const { return m_impl.state() ; } - - /** \brief Multi-dimensional array rank of this field, - * which is zero for a scalar field. - */ - unsigned rank() const { return m_impl.rank(); } - - /** \brief Multi-dimensional - * \ref shards::ArrayDimTag "array dimension tags" - * of this field. - */ - const shards::ArrayDimTag * const * dimension_tags() const - { return m_impl.dimension_tags() ; } - - /** \brief Maximum field data allocation size declared for this - * field for the given entity rank. - */ - unsigned max_size( EntityRank entity_rank) const { - return m_impl.max_size( entity_rank ); - } - - //---------------------------------------- - - /** \brief Query attribute that has been attached to this field */ - template - const A * attribute() const { return m_impl.attribute(); } - - typedef FieldRestriction Restriction; - - /** \brief A fields' restrictions are maintained in a std::vector */ - typedef FieldRestrictionVector RestrictionVector; - - /** \brief Vector of field restriction which is volatile until the owning - * \ref stk_classic::mesh::MetaData "meta data manager" is committed. - */ - const RestrictionVector &restrictions() const { - return m_impl.restrictions(); - } - - const RestrictionVector &selector_restrictions() const { - return m_impl.selector_restrictions(); - } - - /** \brief Query a field restriction, result is volatile until the owning - * \ref stk_classic::mesh::MetaData "meta data manager" is committed. - */ - const Restriction & restriction( unsigned entity_rank , const Part & part ) const { - return m_impl.restriction( entity_rank, part); - } - - //---------------------------------------- - - FieldBase * field_state( FieldState fstate) const { - return m_impl.field_state(fstate); - } - - const void* get_initial_value() const { return m_impl.get_initial_value(); } - - void* get_initial_value() { return m_impl.get_initial_value(); } - - unsigned get_initial_value_num_bytes() const { return m_impl.get_initial_value_num_bytes(); } - -private: - - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns this field - */ - MetaData & meta_data() const { return m_impl.meta_data(); } - - friend class ::stk_classic::mesh::MetaData ; - friend class ::stk_classic::mesh::impl::FieldRepository ; - friend class ::stk_classic::mesh::impl::FieldBaseImpl ; - - /** \brief Allow the unit test driver access */ - friend class ::stk_classic::mesh::UnitTestFieldImpl ; - - FieldBase( - MetaData * arg_mesh_meta_data , - unsigned arg_ordinal , - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank, - const shards::ArrayDimTag * const * arg_dim_tags, - unsigned arg_number_of_states , - FieldState arg_this_state - ) - : m_impl( - arg_mesh_meta_data, - arg_ordinal, - arg_name, - arg_traits, - arg_rank, - arg_dim_tags, - arg_number_of_states, - arg_this_state - ) - {} - - // WORKAROUND 5/19/2010 [DGB]: intel 10.? and pgi do not link if this is made virtual - // virtual ~FieldBase(); - - impl::FieldBaseImpl m_impl; - - //the following functions are declared but not defined - FieldBase(); - FieldBase( const FieldBase & ); - FieldBase & operator = ( const FieldBase & ); -}; - -/** \brief Print the field type, text name, and number of states. */ -std::ostream & operator << ( std::ostream & , const FieldBase & ); - -/** \brief Print field and field restrictions on new lines. */ -std::ostream & print( std::ostream & , - const char * const , const FieldBase & ); - -} //namespace mesh -} //namespace stk_classic - -#endif //stk_mesh_base_FieldBase_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.cpp deleted file mode 100644 index 01fd6ffdbeb4..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -const EntityDimension & EntityDimension::tag() -{ static const EntityDimension self ; return self ; } - -const char * EntityDimension::name() const -{ static const char n[] = "EntityDimension" ; return n ; } - -//---------------------------------------------------------------------- - -}//namespace mesh -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.dox b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.dox deleted file mode 100644 index 07b15eff4b78..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.dox +++ /dev/null @@ -1,62 +0,0 @@ -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_field_data - * - * \section stk_mesh_field_introduction Introduction - * - * The data for a given - * \ref stk_classic::mesh::Field "field" is allocated in one or more - * \ref shards::Array "multi-dimensional arrays". - * The contiguous memory for each array resides within a - * \ref stk_classic::mesh::Bucket "bucket". - * - * \section mdarray Multi-dimensional Array View - * - * Contiguous array field data may be accessed as an - * \ref shards::Array "multidimensional array" through the - * \ref stk_classic::mesh::EntityArray "EntityArray" or - * \ref stk_classic::mesh::BucketArray "BucketArray" wrappers to the - * \ref shards::Array "multidimensional array" class. - * - * For example, given a reference to an application-defined - * \ref stk_classic::mesh::Field "field" these arrays are obtained as follows. - *
- *  typedef Field<...> MyFieldType ;
- *  const MyFieldType & my_field = ... ; // obtained from somewhere
- *  const Entity & entity = ... ;        // obtained from somewhere
- *  const Bucket & bucket = ... ;        // obtained from somewhere
- *
- *  EntityArray< MyFieldType > entity_data( my_field , entity );
- *  BucketArray< MyFieldType > bucket_data( my_field , bucket );
- *  
- * In this example the entity_data and bucket_data are - * \ref shards::Array "multidimensional array" objects conforming to the - * scalar type and dimensions specified by MyFieldType . - * As such the dimensions and members of the arrays can be accessed - * through the \ref shards::Array "multidimensional array" interface. - * - * A \ref stk_classic::mesh::Bucket "bucket" provides field data for a - * homogeneous collection of entities. - * As such when an application defines a multi-dimensional array field - * with variable dimensions then these dimensions will be - * constant for a given bucket; but may vary with different buckets. - * - * \section raw_pointer Raw Data View - * - * The field_data functions return a pointer to the - * field data for a given field and entity or bucket. - * For example, if the scalar type of MyFieldType is "double" then - * a raw pointer to the field data is obtained as follows. - *
- *  double * entity_data_ptr = field_data( my_field , entity );
- *  double * bucket_data_ptr = field_data( my_field , bucket );
- *  
- * When this "raw" interface is used and the field data is a - * multi-dimensional array then the application is on its own - * to obtain the array dimensions. - */ - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.hpp deleted file mode 100644 index 5ee353ba3193..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldData.hpp +++ /dev/null @@ -1,321 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_FieldData_hpp -#define stk_mesh_FieldData_hpp - -//---------------------------------------------------------------------- - -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_field_data - * \{ - * - * This file contains the portion of the Field API that is related to - * retrieving field data. It defines the EntityArray and BucketArray - * structs, which represent the interface between shards arrays and - * field data. The API for retrieving a raw pointer to the data is - * simpler, but the EntityArray/BucketArray system can be nice if the - * Field-type is complex because they handle the striding for you. - * - * Note that getting field-data on a per-entity basis is not efficient - * for a large number of entities; use bucket field-data instead. - * - * Examples: - * - Get raw data for an entity: - * double* data = stk_classic::mesh::field_data(field, entity); - * - * - Get raw data for a bucket: - * double* data = stk_classic::mesh::field_data(field, bucket); - * - * - Get EntityArray data for an entity, assuming field type: Field: - * EntityArray > data_array(field, entity); - * - * - Get BucketArray data for a bucket, assuming field type: Field: - * BucketArray > data_array(field, bucket); - * - * - Using (Entity|Bucket)Array, assuming we are dealing with coordinates: - * int num_coords_per_node = data_array.dimension(0); - * int num_nodes_in_bucket = data_array.dimension(1); - * for (int n = 0; n < num_nodes_in_bucket; ++n) { - * for (int c = 0; c < num_coords_per_node; ++c) { - * cout << data_data(c, n) << ", "; - * } - * cout << endl; - * } - */ - -/** \class BucketArray - * \brief \ref stk_classic::mesh::Field "Field" data \ref shards::Array "Array" - * for a given array field and bucket - */ -template< class FieldType > struct BucketArray {}; - -/** \class EntityArray - * \brief \ref stk_classic::mesh::Field "Field" data \ref shards::Array "Array" - * for a given array field and entity - */ -template< class FieldType > struct EntityArray {}; - -//---------------------------------------------------------------------- -/** \brief Check for existence of field data. - * - * \exception std::runtime_error - * Thrown if required_by != NULL and the field data does not exist. - */ -bool field_data_valid( const FieldBase & f , - const Bucket & k , - unsigned ord = 0, - const char * required_by = NULL ); - -/** \brief Check for existence of field data. - * - * \exception std::runtime_error - * Thrown if required_by != NULL and the field data does not exist. - */ -inline -bool field_data_valid( const FieldBase & f , - const Entity & e , - const char * required_by = NULL ) -{ return field_data_valid( f, e.bucket(), e.bucket_ordinal(), required_by ); } - -//---------------------------------------------------------------------- - -/** \brief Size, in bytes, of the field data for each entity */ -inline -unsigned field_data_size( const FieldBase & f , const Bucket & k ) -{ - return k.field_data_size(f); -} - -/** \brief Size, in bytes, of the field data for each entity */ -inline -unsigned field_data_size( const FieldBase & f , const Entity & e ) -{ return field_data_size( f , e.bucket() ); } - -//---------------------------------------------------------------------- - - -/** \brief Pointer to the field data array */ -template< class field_type > -inline -typename FieldTraits< field_type >::data_type * -field_data( const field_type & f , const Bucket::iterator i ) -{ - return field_data(f,*i); -} - - -/** \brief Pointer to the field data array */ -template< class field_type > -inline -typename FieldTraits< field_type >::data_type * -field_data( const field_type & f , const Entity & e ) -{ - return e.bucket().field_data( f, e ); -} - -//---------------------------------------------------------------------- - -#ifndef DOXYGEN_COMPILE - -template< typename ScalarType > -struct EntityArray< Field > - : public shards::Array -{ - typedef Field field_type ; - typedef shards::Array - array_type ; - - EntityArray( const field_type & f , const Entity & e ) - : array_type( field_data( f , e ) ) {} - -private: - EntityArray(); - EntityArray( const EntityArray & ); - EntityArray & operator = ( const EntityArray & ); -}; -#endif /* DOXYGEN_COMPILE */ - -/** \brief \ref stk_classic::mesh::Field "Field" data \ref shards::Array "Array" - * for a given array field and entity - */ -template< typename ScalarType , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7 > -struct EntityArray< Field > - : public shards::Array -{ -#ifndef DOXYGEN_COMPILE -private: - typedef unsigned char * byte_p ; - EntityArray(); - EntityArray( const EntityArray & ); - EntityArray & operator = ( const EntityArray & ); -public: - - typedef Field field_type ; - - typedef - shards::Array - array_type ; - - EntityArray( const field_type & f , const Entity & e ) : array_type() - { - const Bucket & b = e.bucket(); - if (b.field_data_size(f)) { - array_type::assign_stride( - (ScalarType*)(b.field_data_location(f, e ) ), - b.field_data_stride(f) - ); - } - } -#endif /* DOXYGEN_COMPILE */ -}; - -//---------------------------------------------------------------------- -/** \brief Implement ArrayDimTag for the entity count dimension - * of a BucketArray. - * - * \ref stk_mesh_field_data "array field data" obtained from a - * \ref stk_classic::mesh::Bucket "bucket". - */ -struct EntityDimension : public shards::ArrayDimTag { - - const char * name() const ; - - static const EntityDimension & tag(); ///< Singleton - -private: - EntityDimension() {} - EntityDimension( const EntityDimension & ); - EntityDimension & operator = ( const EntityDimension & ); -}; - - -/** \brief \ref stk_classic::mesh::Field "Field" data \ref shards::Array "Array" - * for a given scalar field and bucket - */ -template< typename ScalarType > -struct BucketArray< Field > - : public -shards::Array -{ -#ifndef DOXYGEN_COMPILE -private: - typedef unsigned char * byte_p ; - BucketArray(); - BucketArray( const BucketArray & ); - BucketArray & operator = ( const BucketArray & ); - -public: - - typedef Field field_type ; - typedef - shards::Array - array_type ; - - BucketArray( const field_type & f , const Bucket & k ) - { - if (k.field_data_size(f)) { - array_type::assign( (ScalarType*)( k.field_data_location(f,k[0]) ) , - k.size() ); - - } - } - - BucketArray( const field_type & f, - const Bucket::iterator i, - const Bucket::iterator j) - { - const ptrdiff_t n = j - i ; - - if ( i->bucket().field_data_size(f) && 0 < n ) { - array_type::assign( - (ScalarType*)( i->bucket().field_data_location( f, *i ) ), - (typename array_type::size_type) n ); - } - } - -#endif /* DOXYGEN_COMPILE */ -}; - -//---------------------------------------------------------------------- -/** \brief \ref stk_classic::mesh::Field "Field" data \ref shards::Array "Array" - * for a given array field and bucket - */ -template< typename ScalarType , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7 > -struct BucketArray< Field > - : public shards::ArrayAppend< - shards::Array , - EntityDimension >::type -{ -private: -#ifndef DOXYGEN_COMPILE - typedef unsigned char * byte_p ; - BucketArray(); - BucketArray( const BucketArray & ); - BucketArray & operator = ( const BucketArray & ); -public: - - typedef Field field_type ; - - typedef typename shards::ArrayAppend< - shards::Array , - EntityDimension >::type array_type ; - - BucketArray( const field_type & f , const Bucket & b ) - { - if ( b.field_data_size(f) ) { - array_type::assign_stride( - (ScalarType*)( b.field_data_location(f,b[0]) ), - b.field_data_stride(f) , (typename array_type::size_type) b.size() ); - } - } - - BucketArray( const field_type & f, - const Bucket::iterator i, - const Bucket::iterator j) - { - const ptrdiff_t distance = j - i ; - - if ( 0 < distance ) { - - const Bucket & b = i->bucket(); - - if ( b.field_data_size(f) ) { - array_type::assign_stride( - (ScalarType*)( b.field_data_location(f,*i) ), - b.field_data_stride(f) , (typename array_type::size_type) distance ); - } - } - } - - -#endif /* DOXYGEN_COMPILE */ -}; - -//---------------------------------------------------------------------- - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -#endif /* stk_mesh_FieldData_hpp */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.cpp deleted file mode 100644 index ea9004c87223..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include -#include - -#include -#include -#include - - -namespace stk_classic { -namespace mesh { - -void communicate_field_data( - const Ghosting & ghosts , - const std::vector< const FieldBase *> & fields ) -{ - if ( fields.empty() ) { return; } - - const BulkData & mesh = BulkData::get(ghosts); - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - const std::vector::const_iterator fe = fields.end(); - const std::vector::const_iterator fb = fields.begin(); - std::vector::const_iterator fi ; - - // Sizing for send and receive - - const unsigned zero = 0 ; - std::vector send_size( parallel_size , zero ); - std::vector recv_size( parallel_size , zero ); - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - Entity & e = **i ; - const bool owned = e.owner_rank() == parallel_rank ; - - unsigned e_size = 0 ; - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - e_size += field_data_size( f , e ); - } - - for ( PairIterEntityComm ec = e.comm() ; ! ec.empty() ; ++ec ) { - if ( ghosts.ordinal() == ec->ghost_id ) { - if ( owned ) { - send_size[ ec->proc ] += e_size ; - } - else { - recv_size[ ec->proc ] += e_size ; - } - } - } - } - - // Allocate send and receive buffers: - - CommAll sparse ; - - { - const unsigned * const s_size = & send_size[0] ; - const unsigned * const r_size = & recv_size[0] ; - sparse.allocate_buffers( mesh.parallel(), parallel_size / 4 , s_size, r_size); - } - - // Send packing: - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - Entity & e = **i ; - if ( e.owner_rank() == parallel_rank ) { - - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - const unsigned size = field_data_size( f , e ); - - if ( size ) { - unsigned char * ptr = - reinterpret_cast(field_data( f , e )); - - for ( PairIterEntityComm ec = e.comm() ; ! ec.empty() ; ++ec ) { - - if ( ghosts.ordinal() == ec->ghost_id ) { - CommBuffer & b = sparse.send_buffer( ec->proc ); - b.pack( ptr , size ); - } - } - } - } - } - } - - // Communicate: - - sparse.communicate(); - - // Unpack for recv: - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - Entity & e = **i ; - if ( e.owner_rank() != parallel_rank ) { - - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - const unsigned size = field_data_size( f , e ); - - if ( size ) { - unsigned char * ptr = - reinterpret_cast(field_data( f , e )); - - for ( PairIterEntityComm ec = e.comm() ; ! ec.empty() ; ++ec ) { - - if ( ghosts.ordinal() == ec->ghost_id ) { - CommBuffer & b = sparse.recv_buffer( ec->proc ); - b.unpack( ptr , size ); - } - } - } - } - } - } -} - -// Heterogeneity? - -void communicate_field_data( - ParallelMachine machine, - const std::vector & domain , - const std::vector & range , - const std::vector & fields) -{ - if ( fields.empty() ) { return; } - - const unsigned parallel_size = parallel_machine_size( machine ); - const unsigned parallel_rank = parallel_machine_rank( machine ); - const bool asymmetric = & domain != & range ; - - const std::vector::const_iterator fe = fields.end(); - const std::vector::const_iterator fb = fields.begin(); - std::vector::const_iterator fi ; - - // Sizing for send and receive - - const unsigned zero = 0 ; - std::vector send_size( parallel_size , zero ); - std::vector recv_size( parallel_size , zero ); - - std::vector::const_iterator i ; - - for ( i = domain.begin() ; i != domain.end() ; ++i ) { - Entity & e = * i->first ; - const unsigned p = i->second ; - - if ( asymmetric || parallel_rank == e.owner_rank() ) { - unsigned e_size = 0 ; - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - e_size += field_data_size( f , e ); - } - send_size[ p ] += e_size ; - } - } - - for ( i = range.begin() ; i != range.end() ; ++i ) { - Entity & e = * i->first ; - const unsigned p = i->second ; - - if ( asymmetric || p == e.owner_rank() ) { - unsigned e_size = 0 ; - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - e_size += field_data_size( f , e ); - } - recv_size[ p ] += e_size ; - } - } - - // Allocate send and receive buffers: - - CommAll sparse ; - - { - const unsigned * const s_size = & send_size[0] ; - const unsigned * const r_size = & recv_size[0] ; - sparse.allocate_buffers( machine, parallel_size / 4 , s_size, r_size); - } - - // Pack for send: - - for ( i = domain.begin() ; i != domain.end() ; ++i ) { - Entity & e = * i->first ; - const unsigned p = i->second ; - - if ( asymmetric || parallel_rank == e.owner_rank() ) { - CommBuffer & b = sparse.send_buffer( p ); - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - const unsigned size = field_data_size( f , e ); - if ( size ) { - unsigned char * ptr = reinterpret_cast(field_data( f , e )); - b.pack( ptr , size ); - } - } - } - } - - // Communicate: - - sparse.communicate(); - - // Unpack for recv: - - for ( i = range.begin() ; i != range.end() ; ++i ) { - Entity & e = * i->first ; - const unsigned p = i->second ; - - if ( asymmetric || p == e.owner_rank() ) { - CommBuffer & b = sparse.recv_buffer( p ); - for ( fi = fb ; fi != fe ; ++fi ) { - const FieldBase & f = **fi ; - const unsigned size = field_data_size( f , e ); - if ( size ) { - unsigned char * ptr = reinterpret_cast(field_data( f , e )); - b.unpack( ptr , size ); - } - } - } - } -} - -//---------------------------------------------------------------------- - -void communicate_field_data( - const BulkData & mesh , - const unsigned field_count , - const FieldBase * fields[] , - CommAll & sparse ) -{ - const std::vector & entity_comm = mesh.entity_comm(); - - const unsigned parallel_size = mesh.parallel_size(); - - // Sizing for send and receive - - const unsigned zero = 0 ; - std::vector msg_size( parallel_size , zero ); - - size_t j = 0; - - for ( j = 0 ; j < field_count ; ++j ) { - const FieldBase & f = * fields[j] ; - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - Entity & e = **i ; - const unsigned size = field_data_size( f , e ); - if ( size ) { - for ( PairIterEntityComm - ec = e.comm() ; ! ec.empty() && ec->ghost_id == 0 ; ++ec ) { - msg_size[ ec->proc ] += size ; - } - } - } - } - - // Allocate send and receive buffers: - - { - const unsigned * const s_size = & msg_size[0] ; - sparse.allocate_buffers( mesh.parallel(), parallel_size / 4 , s_size, s_size); - } - - // Pack for send: - - for ( j = 0 ; j < field_count ; ++j ) { - const FieldBase & f = * fields[j] ; - for ( std::vector::const_iterator - i = entity_comm.begin() ; i != entity_comm.end() ; ++i ) { - Entity & e = **i ; - const unsigned size = field_data_size( f , e ); - if ( size ) { - unsigned char * ptr = - reinterpret_cast(field_data( f , e )); - for ( PairIterEntityComm - ec = e.comm() ; ! ec.empty() && ec->ghost_id == 0 ; ++ec ) { - CommBuffer & b = sparse.send_buffer( ec->proc ); - b.pack( ptr , size ); - } - } - } - } - - // Communicate: - - sparse.communicate(); -} - -void communicate_field_data_verify_read( CommAll & sparse ) -{ - std::ostringstream msg ; - int error = 0 ; - for ( unsigned p = 0 ; p < sparse.parallel_size() ; ++p ) { - if ( sparse.recv_buffer( p ).remaining() ) { - msg << "P" << sparse.parallel_rank() - << " Unread data from P" << p << std::endl ; - error = 1 ; - } - } - all_reduce( sparse.parallel() , ReduceSum<1>( & error ) ); - ThrowErrorMsgIf( error, msg.str() ); -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.hpp deleted file mode 100644 index 9d2d000293f5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldParallel.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_FieldParallel_hpp -#define stk_mesh_FieldParallel_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -/** - * This file contains some helper functions that are part of the Field API. - * These functions are for making certain parallel operations more convenient. - */ - -/** Communicate field data from domain to range. - * The fields array must be identical on all processors. - * All fields and mesh entities must belong to the same mesh. - * If symmetric ( & domain == & range) then from owned to not owned. - */ -void communicate_field_data( - ParallelMachine machine, - const std::vector & domain , - const std::vector & range , - const std::vector< const FieldBase *> & fields ); - -void communicate_field_data( - const Ghosting & ghosts , - const std::vector< const FieldBase *> & fields ); - -/** Communicate field data among shared entities */ -void communicate_field_data( - const BulkData & mesh , - const unsigned field_count , - const FieldBase * fields[] , - CommAll & sparse ); - -void communicate_field_data_verify_read( CommAll & ); - -//---------------------------------------------------------------------- - -namespace { - -//---------------------------------------------------------------------- -/** Parallel reduction of shared entities' field data. - * In the anonymous namespace to avoid redundant link symbols. - * - * example usage: - * parallel_reduce( mesh , sum( field ) ); - * - * where the operations are: sum, max, min - */ -template< class OpField > -void parallel_reduce( const BulkData & mesh , - const OpField & op ) -{ - const FieldBase * fields[1] = { & op.field }; - - CommAll sparse ; - - communicate_field_data( mesh, 1, fields, sparse ); - - op( mesh.entity_comm() , sparse ); - - // For debugging: - // communicate_field_data_verify_read( sparse ); -} - -/** Parallel reduction of shared entities' field data. - * In the anonymous namespace to avoid redundant link symbols. - * - * example usage: - * parallel_reduce( mesh , sum( fieldA ) , max( fieldB ) ); - */ -template< class OpField1 , class OpField2 > -void parallel_reduce( const BulkData & mesh , - const OpField1 & op1 , - const OpField2 & op2 ) -{ - const FieldBase * fields[2] = { & op1.field , & op2.field }; - - CommAll sparse ; - - communicate_field_data( mesh, 2, fields, sparse ); - - op1( mesh.entity_comm() , sparse ); - op2( mesh.entity_comm() , sparse ); - - // For debugging: - // communicate_field_data_verify_read( sparse ); -} - -//---------------------------------------------------------------------- - -template< class ReduceOp , - class Type , class Tag1, class Tag2, class Tag3 , - class Tag4 , class Tag5, class Tag6, class Tag7 > -struct ParallelReduceField { - typedef Field field_type ; - - const field_type & field ; - - ParallelReduceField( const field_type & f ) : field(f) {} - ParallelReduceField( const ParallelReduceField & p ) : field(p.field) {} - - void operator()( const std::vector & entity_comm , - CommAll & sparse ) const ; - -private: - ParallelReduceField & operator = ( const ParallelReduceField & ); -}; - -template< class ReduceOp , - class Type , class Tag1, class Tag2, class Tag3 , - class Tag4 , class Tag5, class Tag6, class Tag7 > -void ParallelReduceField< ReduceOp , Type , Tag1, Tag2, Tag3 , - Tag4 , Tag5, Tag6, Tag7 >:: - operator()( const std::vector & entity_comm , - CommAll & sparse ) const -{ - typedef EntityArray< field_type > array_type ; - - for ( std::vector::const_iterator - i = entity_comm.begin(); i != entity_comm.end() ; ++i ) { - Entity & entity = **i ; - array_type array( field , entity ); - Type * const ptr_beg = array.contiguous_data(); - Type * const ptr_end = ptr_beg + array.size(); - - if (ptr_beg == NULL || ptr_end == NULL) continue; - - for ( PairIterEntityComm - ec = entity.comm() ; ! ec.empty() && ec->ghost_id == 0 ; ++ec ) { - - CommBuffer & b = sparse.recv_buffer( ec->proc ); - - for ( Type * ptr = ptr_beg ; ptr < ptr_end ; ++ptr ) { - Type tmp ; - b.template unpack( (unsigned char *)(&tmp), sizeof(Type) ); - ReduceOp( ptr , & tmp ); - } - } - } -} - -} - -//---------------------------------------------------------------------- - -template< class Type , class Tag1, class Tag2, class Tag3 , - class Tag4 , class Tag5, class Tag6, class Tag7 > -ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7> -inline -sum( const Field & f ) -{ - return ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7>( f ); -} - -template< class Type , class Tag1, class Tag2, class Tag3 , - class Tag4 , class Tag5, class Tag6, class Tag7 > -ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7> -inline -max( const Field & f ) -{ - return ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7>( f ); -} - -template< class Type , class Tag1, class Tag2, class Tag3 , - class Tag4 , class Tag5, class Tag6, class Tag7 > -ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7> -inline -min( const Field & f ) -{ - return ParallelReduceField,Type,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7>( f ); -} - -} // namespace mesh -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRelation.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRelation.hpp deleted file mode 100644 index 74e3dc798d3e..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRelation.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_FieldRelation_hpp -#define stk_mesh_FieldRelation_hpp - -namespace stk_classic { -namespace mesh { - -class FieldBase; - -//---------------------------------------------------------------------- -/** \ingroup stk_mesh_relation_stencil - * \brief A defined entity-relationship between a field of a pointer type - * and the field that it should point to. - * An internal class that should never need to be - * directly used within application code. - * - * Let - * - rel be the \ref stk_classic::mesh::Relation "relation" from - * \ref stk_classic::mesh::Entity "entity" e1 to - * \ref stk_classic::mesh::Entity "entity" e2 - * - * If - * - \ref stk_classic::mesh::Field "field" m_root - * has a pointer scalar type 'T *' AND - * - \ref stk_classic::mesh::Field "field" m_target - * has a scalar type 'T' AND - * - \ref stk_mesh_field_data "field_data"( *m_root , e1 ) exists AND - * - \ref stk_mesh_field_data "field_data"( *m_target , e2 ) exists AND - * - \ref stk_classic::mesh::Relation "relation" rel is in the domain of - * \ref stk_mesh_relation_stencil "relation stencil" m_function - * - * then - *
- *    index = (*m_function)( e1.entity_rank() ,
- *                           e2.entity_rank() ,
- *                           rel.identifier() ,
- *                           rel.kind() );
- *
- *    field_data(*m_root,e1)[index] == field_data(*m_target,e2)
- *  
- * - * A common use case is, given an element, process a certain field that is - * on its nodes. This can be done by iterating over the element's node relations - * and getting the field data off the nodes directly, but it can be cleaner and - * faster to set up a field relation instead. A field relation formally defines - * a relationship between a field on the element and a field on it's nodes - * (or some other lower-than-element entity rank). The API for setting up a - * field relation is in MetaData.hpp. See Field.hpp for a full discussion of Fields. - * - Example: - * // Declare nodal field - * typedef Field VectorFieldType; // Cartesian ArrayDimTag comes from CoordinateSystems.hpp - * VectorFieldType& coord_field = meta.declare_field("coordinates"); - * - * // Declare element field, ElementNodePointerField is a typedef from TopologyDimensions.hpp - * ElementNodePointerField elem_node_coord_field = meta.declare_field("elem_node_coord_field"); - * - * // Add field restriction for nodal field - * put_field( coord_field, , ); - * - * // Declare field relation! Stencil defines order in which nodal fields are accessed - * meta.declare_field_relation(elem_node_coord_field, fem::get_element_node_stencil(3), coord_field); - * - * // Add field restriction for element field - * put_field( elem_node_coord_field, , ); - */ -struct FieldRelation { - /** \brief relation domain part */ - FieldBase * m_root ; - - /** \brief relation range part */ - FieldBase * m_target ; - - /** \brief \ref stk_mesh_relation_stencil "relation stencil" */ - relation_stencil_ptr m_function ; - -#ifndef DOXYGEN_COMPILE - - FieldRelation() : m_root( NULL ), m_target( NULL ), m_function( NULL ) {} - - FieldRelation( const FieldRelation & rhs ) - : m_root( rhs.m_root ), - m_target( rhs.m_target ), - m_function( rhs.m_function ) {} - - FieldRelation & operator = ( const FieldRelation & rhs ) - { - m_root = rhs.m_root ; - m_target = rhs.m_target ; - m_function = rhs.m_function ; - return *this ; - } - -#endif /* DOXYGEN_COMPILE */ -}; - -} // namespace mesh -} // namespace stk_classic - -#endif //stk_mesh_FieldRelation_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.cpp deleted file mode 100644 index a67f75aae98b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - - void FieldRestriction::print( - std::ostream & os, - const EntityRank & entity_rank, - const Part & part, - FieldArrayRank field_rank - ) const - { - os << "{ entity_rank(" << entity_rank << ") part(" << part.name() << ") : " ; - os << m_stride[0] ; - for ( FieldArrayRank i = 1 ; i < field_rank ; ++i ) { - if ( ! m_stride[i] ) { - os << " , 0 " ; - } - else if ( m_stride[i] % m_stride[i-1] ) { - os << " , " << m_stride[i] << " / " << m_stride[i-1] ; - } - else { - os << " , " << m_stride[i] / m_stride[i-1] ; - } - } - os << " }" ; - } - - std::string print_restriction( - const FieldRestriction & restr, - const EntityRank & entity_rank, - const Part & part, - FieldArrayRank field_rank - ) - { - std::ostringstream oss; - restr.print(oss, entity_rank, part, field_rank); - return oss.str(); - } - -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.hpp deleted file mode 100644 index 07a85b020fa9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldRestriction.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_baseImpl_FieldRestriction_hpp -#define stk_mesh_baseImpl_FieldRestriction_hpp - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -/** - * A field restrictions is one of the three fundamental components of a field specification - * (see Field.hpp for a full discusssion); it defines a set of entities that have a field. - * - * This class encapsulates a minimal set of data for a field restriction. The API for - * declaring field restrictions is in MetaData.hpp. - */ -class FieldRestriction { - public: - - typedef shards::array_traits::int_t size_type ; - - FieldRestriction() - : m_entityrank_partordinal(InvalidEntityRank,InvalidPartOrdinal), - m_selector() - { - Copy( m_stride , size_type(0) ); - } - - FieldRestriction( const FieldRestriction & rhs ) - : m_entityrank_partordinal( rhs.m_entityrank_partordinal ), - m_selector( rhs.m_selector ) - { - Copy< MaximumFieldDimension >( m_stride , rhs.m_stride ); - } - - FieldRestriction & operator = ( const FieldRestriction & rhs ) - { - m_entityrank_partordinal = rhs.m_entityrank_partordinal ; - m_selector = rhs.m_selector; - Copy< MaximumFieldDimension >( m_stride , rhs.m_stride ); - return *this ; - } - - FieldRestriction( EntityRank input_rank , PartOrdinal input_ordinal) - : m_entityrank_partordinal( input_rank, input_ordinal ), - m_selector() - { - Copy< MaximumFieldDimension >( m_stride , size_type(0) ); - } - - FieldRestriction( EntityRank input_rank, const Selector& input_selector) - : m_entityrank_partordinal( input_rank, InvalidPartOrdinal ), - m_selector(input_selector) - { - } - - void set_entity_rank(EntityRank ent_rank) { m_entityrank_partordinal.first = ent_rank; } - - EntityRank entity_rank() const - { - return m_entityrank_partordinal.first; - } - - void set_part_ordinal(PartOrdinal ord) { m_entityrank_partordinal.second = ord; } - - PartOrdinal part_ordinal() const - { - return m_entityrank_partordinal.second; - } - - const Selector& selector() const - { - return m_selector; - } - - size_type & stride( Ordinal index ) { return m_stride[index]; } - const size_type & stride( Ordinal index ) const { return m_stride[index]; } - - size_type dimension() const { return m_stride[0]; } - - bool operator < ( const FieldRestriction & rhs ) const - { - return this->m_entityrank_partordinal < rhs.m_entityrank_partordinal; - } - bool operator == ( const FieldRestriction & rhs ) const - { - return this->m_entityrank_partordinal == rhs.m_entityrank_partordinal && - this->m_selector == rhs.m_selector; - } - bool operator != ( const FieldRestriction & rhs ) const - { - return this->m_entityrank_partordinal != rhs.m_entityrank_partordinal || - this->m_selector != rhs.m_selector; - } - - bool not_equal_stride( const FieldRestriction & rhs ) const - { - return Compare< MaximumFieldDimension >::not_equal( this->m_stride , rhs.m_stride ); - } - - void print( - std::ostream & os, - const EntityRank & entity_rank, - const Part & part, - FieldArrayRank field_rank - ) const; - - private: - std::pair m_entityrank_partordinal; - Selector m_selector; - size_type m_stride[ MaximumFieldDimension ]; -}; - -typedef std::vector FieldRestrictionVector; - -std::string print_restriction( - const FieldRestriction & restr, - const EntityRank & entity_rank, - const Part & part, - FieldArrayRank field_rank - ); - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_baseImpl_FieldRestriction_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldState.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldState.hpp deleted file mode 100644 index a3f2e2ee04a8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldState.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_FieldState_hpp -#define stk_mesh_FieldState_hpp - -namespace stk_classic { -namespace mesh { - - /** \addtogroup stk_mesh_module - * \{ - */ - -/** \brief Enumeration of states for multi-state - * \ref stk_classic::mesh::Field "fields". - * - * A field may be declared to have field data for multiple states. - * - Field states StateNone, StateNew, or StateNP1 - * refer to the current or newest of a field. - * - Field states StateOld or StateN refer to - * the previous state of a field with two or more states. - * - The remaining field states StateNM1, StateNM2, - * StateNM3, StateNM4 refer to prior states - * N-1, N-2, N-3, and N-4 accordingly. - * - * See Field.hpp for more. - */ -enum FieldState { - StateNone = 0, ///< \brief State of a field with one state - StateNew = 0, ///< \brief Newest state of a field with two states - StateNP1 = 0, ///< \brief Newest state of a field with three+ states - StateOld = 1, ///< \brief Previous state of a field with two states - StateN = 1, ///< \brief Previous state of a field with three+ states - StateNM1 = 2, ///< \brief Previous-1 state of a field with three+ states - StateNM2 = 3, ///< \brief Previous-2 state of a field with four+ states - StateNM3 = 4, ///< \brief Previous-3 state of a field with five+ states - StateNM4 = 5 ///< \brief Previous-4 state of a field with six states -}; - -/** \brief Maximum number of states that a \ref stk_classic::mesh::Field "field" - * can have. - */ -enum { MaximumFieldStates = 6 }; - -/** \} */ - -} //namespace mesh -} //namespace stk_classic - -#endif //stk_mesh_FieldState_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldTraits.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldTraits.hpp deleted file mode 100644 index 40050aa30bbe..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FieldTraits.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United Traitss Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_base_FieldTraits_hpp -#define stk_mesh_base_FieldTraits_hpp - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -/** - * FieldTraits provide an API for making queries about field types. - * Examples: - * - Get the scalar data type contained by a field - * stk_classic::mesh::FieldTraits< field_type >::data_type - * - Get the dimensional rank (number of dimensions) in a field type - * stk_classic::mesh::FieldTraits< field_type >::Rank - */ - -template<> -struct FieldTraits -{ -public: - typedef shards::array_traits::Helper - Helper ; - - typedef void data_type ; ///< \brief Data type of the field's members - typedef void tag1 ; ///< \brief Array dimension tag - typedef void tag2 ; ///< \brief Array dimension tag - typedef void tag3 ; ///< \brief Array dimension tag - typedef void tag4 ; ///< \brief Array dimension tag - typedef void tag5 ; ///< \brief Array dimension tag - typedef void tag6 ; ///< \brief Array dimension tag - typedef void tag7 ; ///< \brief Array dimension tag - - /** \brief Multidimensional array rank */ - enum { Rank = 0 }; - - static void assign_tags( const shards::ArrayDimTag ** tags ) {} -}; - - -/** \brief Scalar type and multi-dimensional array traits of a Field */ -template< typename Scalar > -struct FieldTraits< Field > -{ -public: - typedef shards::array_traits::Helper - Helper ; - - typedef Scalar data_type ; ///< \brief Data type of the field's members - typedef void tag1 ; ///< \brief Array dimension tag - typedef void tag2 ; ///< \brief Array dimension tag - typedef void tag3 ; ///< \brief Array dimension tag - typedef void tag4 ; ///< \brief Array dimension tag - typedef void tag5 ; ///< \brief Array dimension tag - typedef void tag6 ; ///< \brief Array dimension tag - typedef void tag7 ; ///< \brief Array dimension tag - - /** \brief Multidimensional array rank */ - enum { Rank = 0 }; - - static void assign_tags( const shards::ArrayDimTag ** tags ) {} -}; - -/** \brief Scalar type and multi-dimensional array traits of a Field */ -template< typename Scalar , - class Tag1 , class Tag2 , class Tag3 , class Tag4 , - class Tag5 , class Tag6 , class Tag7 > -struct FieldTraits< Field > -{ -public: - typedef shards::array_traits::Helper - Helper ; - - typedef Scalar data_type ; ///< \brief Data type of the field's members - typedef Tag1 tag1 ; ///< \brief Array dimension tag - typedef Tag2 tag2 ; ///< \brief Array dimension tag - typedef Tag3 tag3 ; ///< \brief Array dimension tag - typedef Tag4 tag4 ; ///< \brief Array dimension tag - typedef Tag5 tag5 ; ///< \brief Array dimension tag - typedef Tag6 tag6 ; ///< \brief Array dimension tag - typedef Tag7 tag7 ; ///< \brief Array dimension tag - - /** \brief Multidimensional array rank */ - enum { Rank = Helper::Rank }; - - static void assign_tags( const shards::ArrayDimTag ** tags ) - { Helper::assign_tags( tags ); } -}; - - -} //namespace mesh -} //namespace stk_classic - -#endif //stk_mesh_base_FieldTraits_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FindRestriction.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FindRestriction.hpp deleted file mode 100644 index 62b3e8d8e408..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/FindRestriction.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_base_FindRestriction_hpp -#define stk_mesh_base_FindRestriction_hpp - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -namespace { -inline -const FieldBase::Restriction & empty_field_restriction() -{ - //NOT THREAD SAFE - static const FieldBase::Restriction empty ; - return empty ; -} -}//namespace anonymous - -//Given a field and a range of parts, determine whether the field has a restriction -//for the part range. (Common usage is to provide the part-range from a bucket; i.e., -//determine whether the field should be allocated in the bucket.) -template -const FieldBase::Restriction& find_restriction(const FieldBase& field, - EntityRank erank, - PartIterator pbegin, - PartIterator pend, - Compare comp) -{ - GetPartIterOrdinal get_part_ordinal; - - const FieldBase::Restriction & empty = empty_field_restriction(); - const FieldBase::Restriction * restriction = & empty ; - - const std::vector & restr_vec = field.restrictions(); - const std::vector::const_iterator iend = restr_vec.end(); - std::vector::const_iterator ibeg = restr_vec.begin(); - - //NOT THREAD SAFE - static FieldRestriction restr; - - for ( PartIterator it = pbegin; it != pend && iend != ibeg ; ++it ) { - - restr.set_entity_rank(erank); - restr.set_part_ordinal(get_part_ordinal(it)); - - //lower_bound returns an iterator to either the insertion point for the - //'restr' argument, or to a matching restriction. - //It only returns the 'end' iterator if 'restr' is past the end of the - //vector of restrictions being searched. - //This depends on the input part ordinals being sorted, and on the restriction - //vector being sorted by part ordinal. - - ibeg = std::lower_bound( ibeg , iend , restr ); - - if ( (iend != ibeg) && (*ibeg == restr) ) { - if ( restriction == & empty ) { restriction = & *ibeg ; } - - if ( ibeg->not_equal_stride(*restriction) ) { - - Part & p_old = MetaData::get(field).get_part( ibeg->part_ordinal() ); - Part & p_new = MetaData::get(field).get_part( restriction->part_ordinal() ); - - std::ostringstream msg ; - msg << " FAILED WITH INCOMPATIBLE DIMENSIONS FOR " ; - msg << field ; - msg << " Part[" << p_old.name() ; - msg << "] and Part[" << p_new.name() ; - msg << "]" ; - - ThrowErrorMsg( msg.str() ); - } - } - } - - const std::vector & sel_res = field.selector_restrictions(); - std::pair part_range = std::make_pair(pbegin, pend); - for(std::vector::const_iterator it=sel_res.begin(), it_end=sel_res.end(); it != it_end; ++it) { - const Selector& selector = it->selector(); - if (it->entity_rank() == erank && selector.apply(part_range, comp)) { - if (restriction == &empty) { - restriction = &*it; - } - if (it->not_equal_stride(*restriction)) { - ThrowErrorMsg("find_restriction calculation failed with different field-restriction selectors giving incompatible sizes."); - } - } - } - - return *restriction ; -} - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_base_FindRestriction_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.cpp deleted file mode 100644 index a232254a8e51..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -//---------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -AllSelectedBucketsRange get_buckets( const Selector & selector, const BulkData& mesh ) -{ - AllBucketsRange all_buckets = mesh.get_bucket_range(); - return get_selected_bucket_range(all_buckets, selector); -} - -AllBucketsRange get_buckets( const BulkData& mesh ) -{ - return mesh.get_bucket_range(); -} - -AllBucketsRange get_buckets( EntityRank entity_rank, const BulkData& mesh ) -{ - return mesh.get_bucket_range(entity_rank); -} - -AllSelectedBucketsRange get_buckets( const Selector & selector, const AllBucketsRange& range) -{ - return get_selected_bucket_range(range, selector); -} - -void copy_ids( std::vector & v , const PartVector & p ) -{ - { - const size_t n = p.size(); - v.resize( n ); - for ( size_t k = 0 ; k < n ; ++k ) { - v[k] = p[k]->mesh_meta_data_ordinal(); - } - } - - { - std::vector::iterator i = v.begin() , j = v.end(); - std::sort( i , j ); - i = std::unique( i , j ); - v.erase( i , j ); - } -} - -void get_involved_parts( - const PartVector & union_parts, - const Bucket & candidate, - PartVector & involved_parts - ) -{ - involved_parts.clear(); - if (union_parts.size() == 0) { - return; - } - - // Used to convert part ordinals to part pointers: - MetaData & meta_data = MetaData::get( * union_parts[0]); - const PartVector & all_parts = meta_data.get_parts(); - - const std::pair - bucket_part_begin_end_iterators = candidate.superset_part_ordinals(); // sorted and unique - - std::vector union_parts_ids; - copy_ids( union_parts_ids , union_parts ); // sorted and unique - std::vector::const_iterator union_part_id_it = union_parts_ids.begin(); - const unsigned * bucket_part_id_it = bucket_part_begin_end_iterators.first ; - - while ( union_part_id_it != union_parts_ids.end() && - bucket_part_id_it != bucket_part_begin_end_iterators.second ) - { - if ( *union_part_id_it < *bucket_part_id_it ) { - ++union_part_id_it ; - } - else if ( *bucket_part_id_it < *union_part_id_it ) { - ++bucket_part_id_it ; - } - else { - // Find every match: - Part * const part = all_parts[ *union_part_id_it ]; - involved_parts.push_back( part ); - ++union_part_id_it; - ++bucket_part_id_it; - } - } - -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.hpp deleted file mode 100644 index 1f253b28800c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetBuckets.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_GetBucket_hpp -#define stk_mesh_GetBucket_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- - -/* \brief Select buckets from the input to the output. Buckets in the input - * vector will be placed in the output vector if the bucket is - * selected by the selector argument. - * On entry, the output vector is cleared before being filled with - * selected buckets. - */ -template -inline -void get_buckets( const SELECTOR & selector , - const std::vector< Bucket * > & input , - std::vector< Bucket * > & output ) -{ - output.clear(); - for(const auto& b : input ) { - if ( selector( *b ) ) { output.push_back( b ); } - } -} - -/** - * For all the buckets in the mesh, return a range of selected buckets. - */ -AllSelectedBucketsRange get_buckets( const Selector & selector, const BulkData& mesh ); - -/** - * Return a range of all buckets in the mesh - */ -AllBucketsRange get_buckets( const BulkData& mesh ); - -/** - * Return a range of buckets for a certain rank. - */ -AllBucketsRange get_buckets( EntityRank entity_rank, const BulkData& mesh ); - -/** - * Return a range of selected buckets within a bucket range - */ -AllSelectedBucketsRange get_buckets( const Selector & selector, const AllBucketsRange& range); - -/* \brief Get the parts from the union part vector that the bucket is - * contained in. - */ -void get_involved_parts( const PartVector & union_parts, - const Bucket & candidate, - PartVector & involved_parts); - -//---------------------------------------------------------------------- -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.cpp deleted file mode 100644 index df7bf16052f8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -void get_entities( const BulkData & mesh , EntityRank entity_rank , - std::vector< Entity*> & entities ) -{ - const std::vector & ks = mesh.buckets( entity_rank ); - entities.clear(); - - size_t count = 0; - - const std::vector::const_iterator ie = ks.end(); - std::vector::const_iterator ik = ks.begin(); - - for ( ; ik != ie ; ++ik ) { count += (*ik)->size(); } - - entities.reserve(count); - - ik = ks.begin(); - - for ( ; ik != ie ; ++ik ) { - const Bucket & k = **ik ; - size_t n = k.size(); - for(size_t i = 0; i < n; ++i) { - entities.push_back(&k[i]); - } - } - - std::sort(entities.begin(), entities.end(), EntityLess()); -} - -BucketVectorEntityIteratorRange get_entities( EntityRank entity_rank, const BulkData& mesh ) -{ - const std::vector& buckets = mesh.buckets(entity_rank); - return get_entity_range(buckets); -} - -unsigned count_selected_entities( - const Selector & selector , - const std::vector< Bucket * > & input_buckets ) -{ - size_t count = 0; - - const std::vector::const_iterator ie = input_buckets.end(); - std::vector::const_iterator ik = input_buckets.begin(); - - for ( ; ik != ie ; ++ik ) { - const Bucket & k = ** ik ; - if ( selector( k ) ) { count += k.size(); } - } - - return count ; -} - - -void get_selected_entities( const Selector & selector , - const std::vector< Bucket * > & input_buckets , - std::vector< Entity * > & entities ) -{ - size_t count = count_selected_entities(selector,input_buckets); - - entities.resize(count); - - const std::vector::const_iterator ie = input_buckets.end(); - std::vector::const_iterator ik = input_buckets.begin(); - - for ( size_t j = 0 ; ik != ie ; ++ik ) { - const Bucket & k = ** ik ; - if ( selector( k ) ) { - const size_t n = k.size(); - for ( size_t i = 0; i < n; ++i, ++j ) { - entities[j] = &k[i] ; - } - } - } - - std::sort(entities.begin(), entities.end(), EntityLess()); -} - -#if 0 -//this code is broken -// \TODO fix -SelectedBucketRangeEntityIteratorRange get_selected_entities( const Selector & selector, - const AllBucketsRange& bucket_range ) -{ - return get_selected_bucket_entity_range(bucket_range, selector); -} -#endif - -//---------------------------------------------------------------------- - -void count_entities( - const Selector & selector , - const BulkData & mesh , - std::vector< EntityRank > & count ) -{ - const size_t nranks = MetaData::get(mesh).entity_rank_count(); - - count.resize( nranks ); - - for ( size_t i = 0 ; i < nranks ; ++i ) { - count[i] = 0 ; - - const std::vector & ks = mesh.buckets( i ); - - std::vector::const_iterator ik ; - - for ( ik = ks.begin() ; ik != ks.end() ; ++ik ) { - if ( selector(**ik) ) { - count[i] += (*ik)->size(); - } - } - } -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.hpp deleted file mode 100644 index 9c154309131c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/GetEntities.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_GetEntities_hpp -#define stk_mesh_GetEntities_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- - -/** \brief Local count selected entities of each type. - * - * \param selector - * \param mesh - * \param count - */ -void count_entities( const Selector & selector , - const BulkData & mesh , - std::vector & count ); - -/** \brief Get all entities of the specified type, sorted by ID. */ -void get_entities( const BulkData & mesh , EntityRank entity_rank, - std::vector< Entity*> & entities); - -// Note: Order will be different than above method because above method sorts -// TODO: remove underscore once API and STK_Mesh are in different namespaces -BucketVectorEntityIteratorRange get_entities( EntityRank entity_rank, const BulkData& mesh ); - -/** \brief Count entities in selected buckets (selected by the - * given selector instance), and sorted by ID. - */ -unsigned count_selected_entities( const Selector & selector , - const std::vector< Bucket * > & input_buckets ); - -/** \brief Get entities in selected buckets (selected by the - * given selector instance), and sorted by ID. - */ -void get_selected_entities( const Selector & selector , - const std::vector< Bucket * > & input_buckets , - std::vector< Entity * > & entities ); - -SelectedBucketRangeEntityIteratorRange get_selected_entities( const Selector & selector, - const AllBucketsRange& bucket_range ); - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif // stk_mesh_GetEntities_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.cpp deleted file mode 100644 index ca449045e75b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -void Ghosting::send_list( std::vector< EntityProc > & v ) const -{ - for ( std::vector::const_iterator - i = m_mesh.entity_comm().begin() ; - i != m_mesh.entity_comm().end() ; ++i ){ - Entity * const entity = *i ; - if ( entity->owner_rank() == m_mesh.parallel_rank() ) { - for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) { - if ( ec->ghost_id == m_ordinal ) { - v.push_back( EntityProc( entity , ec->proc ) ); - } - } - } - } -} - -void Ghosting::receive_list( std::vector< Entity * > & v ) const -{ - for ( std::vector::const_iterator - i = m_mesh.entity_comm().begin() ; - i != m_mesh.entity_comm().end() ; ++i ){ - Entity * const entity = *i ; - if ( entity->owner_rank() != m_mesh.parallel_rank() ) { - for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) { - if ( ec->ghost_id == m_ordinal ) { - v.push_back( entity ); - } - } - } - } -} - -std::ostream& Ghosting::operator<<(std::ostream& out) const -{ - out << "Ghosting object: name: " << name() - << ", ordinal: " << ordinal() << "\n"; - - out << " Locally owned entities ghosted on other processors (send list):\n"; - - for ( std::vector::const_iterator - i = m_mesh.entity_comm().begin() ; - i != m_mesh.entity_comm().end() ; ++i ){ - Entity * const entity = *i ; - if ( entity->owner_rank() == m_mesh.parallel_rank() ) { - for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) { - if ( ec->ghost_id == m_ordinal ) { - out << " "; - print_entity_key( out, MetaData::get(m_mesh), entity->key() ); - out << ", sending ghost to " << ec->proc << ", status is: " - << entity->log_query() << "\n"; - } - } - } - } - - out << " Entities ghosted on this processor from the owner (recv list):\n"; - for ( std::vector::const_iterator - i = m_mesh.entity_comm().begin() ; - i != m_mesh.entity_comm().end() ; ++i ){ - Entity * const entity = *i ; - if ( entity->owner_rank() != m_mesh.parallel_rank() ) { - for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) { - if ( ec->ghost_id == m_ordinal ) { - out << " "; - print_entity_key( out, MetaData::get(m_mesh), entity->key() ); - out << ", owner of ghost is " << entity->owner_rank() - << ", status is: " << entity->log_query() << "\n"; - } - } - } - } - return out; -} - -std::ostream& operator<<(std::ostream& out, const Ghosting& rhs) -{ - return rhs.operator<<(out); -} - -} -} - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.hpp deleted file mode 100644 index 54e70e4cf7fa..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Ghosting.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_Ghosting_hpp -#define stk_mesh_Ghosting_hpp - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -/** \brief Data for ghosting mesh entities. - * - * This class is a member of the BulkData 'aggregate'. - * As such the BulkData class is the only one allowed to modify it, - * the "aggregate owner modifies" rule. Thus all public methods - * are const and the BulkData (owner) class is a friend. - */ -class Ghosting { -public: - - /** \brief Text name for printing purposes only */ - const std::string & name() const { return m_name ; } - - /** \brief Ordinal to identify the ghosting subset */ - unsigned ordinal() const { return m_ordinal ; } - - /** \brief Bulk data synchronization count when this - * ghosting object was last modified. - */ - size_t synchronized_count() const { return m_sync_count ; } - - /** \brief Locally owned entities ghosted on other processors. - * - * This generated communication list for sending updates - * is sorted by entity key and processor rank. - */ - void send_list( std::vector< EntityProc > & ) const ; - - /** \brief Entities ghosted on this processor from the owner. - * - * This generated communication list for receiving updates - * is sorted by entity key. - */ - void receive_list( std::vector< Entity * > & ) const ; - - /** \brief Print the details of this object for debugging - */ - std::ostream& operator<<(std::ostream& out) const; - -private: - /** \brief A Ghosting object is owned by a BulkData object, - * and as such can only be modified by its owner. - */ - - BulkData & bulk_data() const { return m_mesh ; } - friend class BulkData ; - - BulkData & m_mesh ; ///< Owner - const std::string m_name ; ///< Name for printing purposes - size_t m_sync_count ; ///< Bulk data sync count - unsigned m_ordinal ; - - Ghosting( BulkData & M , const std::string & n , unsigned ord , size_t count ) - : m_mesh( M ) , m_name( n ), m_sync_count( count ), m_ordinal( ord ) {} - - ~Ghosting() {} - - // None of the following are implemented: - Ghosting(); - Ghosting( const Ghosting & ); - Ghosting & operator = ( const Ghosting & ); -}; - -std::ostream& operator<<(std::ostream& out, const Ghosting& rhs); - -} -} - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.cpp deleted file mode 100644 index bbd5bfb2fe23..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include - -namespace stk_classic { -namespace mesh { - -BucketVectorEntityIteratorRange get_entity_range(const std::vector& buckets) -{ - if ( buckets.empty() ) { - BucketVectorEntityIterator end_itr(buckets.end()); - return std::make_pair(end_itr, end_itr); - } - else { - return std::make_pair(BucketVectorEntityIterator(buckets.begin(), BucketPtrIterator((*buckets.begin())->begin()), buckets.end()), - BucketVectorEntityIterator(buckets.end())); - } -} - -SelectedBucketVectorEntityIteratorRange get_entity_range(const std::vector& buckets, const Selector& selector) -{ - if ( buckets.empty() ) { - SelectedBucketVectorIterator end_select_itr(buckets.end()); - //SelectedBucketVectorIterator end_select_itr(selector, buckets.end(), buckets.end()); - SelectedBucketVectorEntityIterator end_itr(end_select_itr); - return std::make_pair(end_itr, end_itr); - } - else { - //SelectedBucketVectorIterator end_select_itr(selector, buckets.end(), buckets.end()); - SelectedBucketVectorIterator end_select_itr(buckets.end()); - return std::make_pair(SelectedBucketVectorEntityIterator(SelectedBucketVectorIterator(selector, buckets.begin(), buckets.end()), - BucketPtrIterator((*buckets.begin())->begin()), - end_select_itr), - SelectedBucketVectorEntityIterator(end_select_itr)); - } -} - -AllBucketsRange get_bucket_range(const std::vector >& buckets) -{ - if (buckets.empty()) { - AllBucketsIterator end_itr(buckets.end()); - return std::make_pair(end_itr, end_itr); - } - else { - return std::make_pair(AllBucketsIterator(buckets.begin(), buckets.begin()->begin(), buckets.end()), - AllBucketsIterator(buckets.end())); - } -} - -AllBucketsRange get_bucket_range(const std::vector >& buckets, - std::vector >::const_iterator itr) -{ - AllBucketsIterator end_itr(itr+1); - return std::make_pair(AllBucketsIterator(itr, itr->begin(), itr+1), - end_itr); -} - -AllSelectedBucketsRange get_selected_bucket_range(const AllBucketsRange& bucket_range, const Selector& selector) -{ - return std::make_pair(AllSelectedBucketsIterator(selector, bucket_range.first, bucket_range.second), - AllSelectedBucketsIterator(selector, bucket_range.second, bucket_range.second)); -} - -SelectedBucketVectorIteratorRange get_selected_bucket_range(const std::vector& buckets, const Selector& selector) -{ - return std::make_pair(SelectedBucketVectorIterator(selector, buckets.begin(), buckets.end()), - SelectedBucketVectorIterator(buckets.end())); -} - -#if 0 -//this code is broken -// \TODO fix -SelectedBucketRangeEntityIteratorRange get_selected_bucket_entity_range(const AllBucketsRange& bucket_range, const Selector& selector) -{ - - if (bucket_range.first == bucket_range.second) { - AllSelectedBucketsIterator end_select_itr(bucket_range.second); - //AllSelectedBucketsIterator end_select_itr(selector, bucket_range.second, bucket_range.second); - SelectedBucketRangeEntityIterator end_itr(end_select_itr); - return std::make_pair(end_itr, end_itr); - } - else { - AllSelectedBucketsRange selected_bucket_range = get_selected_bucket_range(bucket_range, selector); - return std::make_pair(SelectedBucketRangeEntityIterator(selected_bucket_range.first, - BucketPtrIterator( (*selected_bucket_range.first)->begin()), - selected_bucket_range.second), - SelectedBucketRangeEntityIterator(selected_bucket_range.second)); - } -} -#endif - -} //namespace mesh -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.hpp deleted file mode 100644 index b4091993d62a..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Iterators.hpp +++ /dev/null @@ -1,324 +0,0 @@ -#ifndef Toolkit_Iterators_hpp -#define Toolkit_Iterators_hpp - -#include -#include - -#include - -#include -#include - -namespace stk_classic { -namespace mesh { - -// Requirements: -// Dereference of HighLevelItrType gives a container (OR pointer to container) with iterators compatible with LowLevelItrType -// Dereference of LowLevelItrType gives ValueType -// LowLevelItrType must default-construct to a deterministic invalid value -// -// Incrementing this iterator will take us to the next valid low-level iterator, skipping past -// empty high-level containers, until the end iterator. -template -class TwoLevelIterator : public std::iterator -{ - public: - typedef TwoLevelIterator self; - - // Construct an iterator from a starting point specified by high_itr and low_itr - TwoLevelIterator(HighLevelItrType high_itr, LowLevelItrType low_itr, HighLevelItrType high_end_itr) : - m_high_itr(high_itr), - m_low_itr(low_itr), - m_high_end_itr(high_end_itr) - { - if (high_itr != high_end_itr) { - find_next_valid_item(); - } - } - - // Construct the "end" iterator - TwoLevelIterator(HighLevelItrType high_end_itr) : - m_high_itr(high_end_itr), - m_low_itr(), - m_high_end_itr(high_end_itr) - {} - - TwoLevelIterator() : - m_high_itr(), - m_low_itr(), - m_high_end_itr() - {} - - bool operator==(const self& rhs) const - { - return (m_high_itr == rhs.m_high_itr && m_low_itr == rhs.m_low_itr); - } - - bool operator!=(const self& rhs) const - { - return !(*this == rhs); - } - - // x++ - self operator++(int) - { - self copy = *this; - increment(); - return copy; - } - - // ++x - self& operator++() - { - increment(); - return *this; - } - - typename LowLevelItrType::reference operator*() const - { - return *m_low_itr; - } - - typename LowLevelItrType::pointer operator->() const - { - return &*m_low_itr; - } - - private: - void find_next_valid_item() - { - // if low_itr is at the end of current container, go to next container - while (m_low_itr == get_end(*m_high_itr)) { - ++m_high_itr; - if (m_high_itr == m_high_end_itr) { - // We reached the end! Set low_itr to invalid and return - m_low_itr = LowLevelItrType(); - return; - } - m_low_itr = get_begin(*m_high_itr); - } - } - - // The 4 methods below are needed for supporting the notion that high_itr - // can dereference to a container or a pointer to a container. - - template - LowLevelItrType - get_begin(Cont& container) - { - return LowLevelItrType(container.begin()); - } - - template - LowLevelItrType - get_end(Cont& container) - { - return LowLevelItrType(container.end()); - } - - template - LowLevelItrType - get_begin(Cont* container_ptr) - { - return LowLevelItrType(container_ptr->begin()); - } - - template - LowLevelItrType - get_end(Cont* container_ptr) - { - return LowLevelItrType(container_ptr->end()); - } - - void increment() - { - ++m_low_itr; - find_next_valid_item(); - } - - HighLevelItrType m_high_itr; - LowLevelItrType m_low_itr; - HighLevelItrType m_high_end_itr; -}; - -// Requirements: -// BucketIteratorType must dereference to a Bucket* -// -// Incrementing this iterator will take us to the next *selected* bucket, skipping past -// unselected buckets, until the end. -// -// As long as we're using a pointer as the value type, we need to -// specify the reference type to be the value_type in order for this -// class to work with boost -template -class SelectedBucketIterator : public std::iterator -{ - public: - typedef SelectedBucketIterator self; - - SelectedBucketIterator(const Selector& selector, BucketIteratorType bucket_itr, BucketIteratorType bucket_end_itr) : - m_bucket_itr(bucket_itr), - m_bucket_end_itr(bucket_end_itr), - m_selector(selector) - { - if (bucket_itr != bucket_end_itr) { - find_next_valid_item(); - } - } - - // Construct the "end" iterator - SelectedBucketIterator(BucketIteratorType bucket_end_itr) : - m_bucket_itr(bucket_end_itr), - m_bucket_end_itr(bucket_end_itr), - m_selector() - {} - - SelectedBucketIterator() : - m_bucket_itr(), - m_bucket_end_itr(), - m_selector() - {} - - SelectedBucketIterator(const self& rhs) : - m_bucket_itr(rhs.m_bucket_itr), - m_bucket_end_itr(rhs.m_bucket_end_itr), - m_selector(rhs.m_selector) - {} - - self& operator=(const self& rhs) - { - m_bucket_itr = rhs.m_bucket_itr; - m_bucket_end_itr = rhs.m_bucket_end_itr; - m_selector = rhs.m_selector; - - return *this; - } - - bool operator==(const self& rhs) const - { - return (m_bucket_itr == rhs.m_bucket_itr); - } - - bool operator==(const BucketIteratorType& rhs) const - { - return (m_bucket_itr == rhs); - } - - bool operator!=(const self& rhs) const - { - return !(*this == rhs); - } - - // x++ - self operator++(int) - { - self copy = *this; - increment(); - return copy; - } - - // ++x - self& operator++() - { - increment(); - return *this; - } - - // The method below is why boost::filter_iterator won't work for us. filter_iterator - // deferences to a reference, tranform iterator dereferences to a copy, making them - // incompatible. - typename BucketIteratorType::value_type operator*() const - { - return *m_bucket_itr; - } - - typename BucketIteratorType::pointer operator->() const - { - return &*m_bucket_itr; - } - - private: - void find_next_valid_item() - { - while (m_bucket_itr != m_bucket_end_itr && !m_selector(**m_bucket_itr)) { - ++m_bucket_itr; - } - } - - void increment() - { - ++m_bucket_itr; - find_next_valid_item(); - } - - BucketIteratorType m_bucket_itr; - BucketIteratorType m_bucket_end_itr; - Selector m_selector; -}; - -// Iterator for iterating over all entities within each bucket of a vector of buckets -typedef TwoLevelIterator::const_iterator, BucketPtrIterator> BucketVectorEntityIterator; -typedef std::pair BucketVectorEntityIteratorRange; - -// Iterator for iterating over selected buckets within a vector of buckets -typedef SelectedBucketIterator::const_iterator> SelectedBucketVectorIterator; -//typedef boost::filter_iterator::const_iterator> SelectedBucketVectorIterator; -typedef std::pair SelectedBucketVectorIteratorRange; - -// Iterator for iterating over all entities within each *selected* bucket of a vector of buckets -typedef TwoLevelIterator SelectedBucketVectorEntityIterator; -typedef std::pair SelectedBucketVectorEntityIteratorRange; - -// Iterator for iterating over all buckets in a vector of vectors of buckets -typedef TwoLevelIterator >::const_iterator, std::vector::const_iterator> AllBucketsIterator; -typedef std::pair AllBucketsRange; - -// Iterator for iterating over all *selected* buckets in a bucket range -typedef SelectedBucketIterator AllSelectedBucketsIterator; -//typedef boost::filter_iterator AllSelectedBucketsIterator; -typedef std::pair AllSelectedBucketsRange; - -// Iterator for iterating over all entities within each bucket of a bucket range -typedef TwoLevelIterator BucketRangeEntityIterator; -typedef std::pair BucketRangeEntityIteratorRange; - -// Iterator for iterating over all *selected* entities withing a bucket range -typedef TwoLevelIterator SelectedBucketRangeEntityIterator; -typedef std::pair SelectedBucketRangeEntityIteratorRange; - -// -// API - Convert collections into ranges. For internal use only. Clients should use -// GetBuckets.hpp, GetEntities.hpp or their BulkData object. -// - -// Get a range allowing you to iterate over all entities withing a collection of buckets -BucketVectorEntityIteratorRange get_entity_range(const std::vector& buckets); - -// Get a range allowing you to iterate over all *selected* entities withing a collection of buckets -SelectedBucketVectorEntityIteratorRange get_entity_range(const std::vector& buckets, const Selector& selector); - -// Get a range allowing you to iterate over all buckets within a collection of collections of buckets -AllBucketsRange get_bucket_range(const std::vector >& buckets); - -// Get a range allowing you to iterate over a single collection of buckets within a collection of collections of buckets; -// the single collection is specified by the itr argument. -AllBucketsRange get_bucket_range(const std::vector >& buckets, - std::vector >::const_iterator itr); - -// Get a range allowing you to iterate over all *selected* buckets within a collection of collections of buckets -AllSelectedBucketsRange get_selected_bucket_range(const AllBucketsRange& bucket_range, const Selector& selector); - -// Get a range allowing you iterate over selected buckets in a vector -SelectedBucketVectorIteratorRange get_selected_bucket_range(const std::vector& buckets, const Selector& selector); - -// Get a range allowing you to iterate over all *selected* buckets within a collection of collections of buckets -SelectedBucketRangeEntityIteratorRange get_selected_bucket_entity_range(const AllBucketsRange& bucket_range, const Selector& selector); - -} //namespace mesh -} //namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MemoryUsage.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MemoryUsage.cpp deleted file mode 100644 index b7bd13c3e9e4..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MemoryUsage.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -void compute_memory_usage(const BulkData& bulk, MemoryUsage& mem_usage) -{ - mem_usage.entity_rank_names = bulk.mesh_meta_data().entity_rank_names(); - - const FieldVector& fields = bulk.mesh_meta_data().get_fields(); - mem_usage.num_fields = fields.size(); - mem_usage.field_bytes = fields.size()*sizeof(FieldBase); - for(size_t i=0; iname().length(); - mem_usage.field_bytes += sizeof(FieldRestriction)*fields[i]->restrictions().size(); - } - - const PartVector& parts = bulk.mesh_meta_data().get_parts(); - mem_usage.num_parts = parts.size(); - mem_usage.part_bytes = parts.size()*sizeof(Part); - for(size_t i=0; iname().length(); - mem_usage.part_bytes += sizeof(Part*) * parts[i]->supersets().size(); - mem_usage.part_bytes += sizeof(Part*) * parts[i]->subsets().size(); - mem_usage.part_bytes += sizeof(Part*) * parts[i]->intersection_of().size(); - mem_usage.part_bytes += sizeof(PartRelation) * parts[i]->relations().size(); - } - - size_t total_bytes = mem_usage.field_bytes + mem_usage.part_bytes; - - mem_usage.entity_counts.clear(); - mem_usage.downward_relation_counts.clear(); - mem_usage.upward_relation_counts.clear(); - mem_usage.bucket_counts.clear(); - mem_usage.bucket_bytes.clear(); - - Selector all = bulk.mesh_meta_data().universal_part(); - count_entities(all, bulk, mem_usage.entity_counts); - - size_t nranks = mem_usage.entity_counts.size(); - mem_usage.downward_relation_counts.resize(nranks, 0); - mem_usage.upward_relation_counts.resize(nranks, 0); - mem_usage.bucket_counts.resize(nranks, 0); - mem_usage.bucket_bytes.resize(nranks, 0); - - std::vector entities; - for(size_t i=0; i& buckets = bulk.buckets(rank); - mem_usage.bucket_counts[rank] = buckets.size(); - for(size_t b=0; b i) - os << " "< i) - os << " "< i) - os << " "< i) - os << " "< - -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_module - * \{ - */ - -struct MemoryUsage { - unsigned num_fields; - unsigned field_bytes; - unsigned num_parts; - unsigned part_bytes; - std::vector entity_rank_names; - std::vector entity_counts; - unsigned bytes_per_entity; - std::vector downward_relation_counts; - std::vector upward_relation_counts; - unsigned bytes_per_relation; - std::vector bucket_counts; - std::vector bucket_bytes; - size_t total_bytes; -}; - -void compute_memory_usage(const BulkData& bulk, MemoryUsage& mem_usage); - -void print_memory_usage(const MemoryUsage& mem_usage, std::ostream& os); - -//---------------------------------------------------------------------- - - -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Mesh.dox b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Mesh.dox deleted file mode 100644 index bd013183b66c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Mesh.dox +++ /dev/null @@ -1,196 +0,0 @@ - -namespace stk_classic { -namespace mesh { -} // namespace mesh -} // namespace stk_classic - -/** \defgroup stk_mesh_module Sierra Toolkit Mesh - * - * \section stk_mesh_introduction Introduction - * - * The Sierra Toolkit Mesh supports parallel distributed, - * heterogeneous, and dynamically modifiable unstructured meshes - * with computational field data. - * Mesh data is partitioned into - * (1) meta data - * which describes an application's problem domain and - * (2) bulk data - * which implements a discretization of an - * application's problem domain. - * - * - \ref stk_classic::mesh::MetaData "Meta data" - * = { { \ref stk_classic::mesh::Part "Part" } + - * { \ref stk_classic::mesh::Field "Field" } } - * - \ref stk_classic::mesh::BulkData "Bulk data" - * = { { \ref stk_classic::mesh::Entity "Entity" } + - * { \ref stk_classic::mesh::Relation "Relation" } + - * { \ref stk_mesh_field_data "Field data" stored in - * \ref stk_classic::mesh::Bucket "Buckets" } } - * - * A \ref stk_classic::mesh::BulkData "bulk data manager" - * owns and manages an integrated collection of - * \ref stk_classic::mesh::Entity "entities" (e.g. nodes and elements), - * \ref stk_classic::mesh::Relation "relations" between entities (i.e. connectivity), - * and computational - * \ref stk_mesh_field_data "field data" associated with entities of the mesh. - * \ref stk_mesh_field_data "Field data" for homogeneous subsets of entities - * is aggregated into \ref stk_classic::mesh::Bucket "buckets", i.e. - * contiguous blocks of memory. - * A \ref stk_classic::mesh::MetaData "meta data manager" - * owns and manages an integrated collection of - * \ref stk_classic::mesh::Part "parts" and - * \ref stk_classic::mesh::Field "fields". - * A \ref stk_classic::mesh::Part "part" defines an expected - * subset of entities in the problem domain. - * A \ref stk_classic::mesh::Field "field" defines the expected - * computational \ref stk_mesh_field_data "field data" for a - * discretization of the problem domain. - * - * \section stk_mesh_example Simple Example - * - * An application must first create a - * \ref stk_classic::mesh::MetaData "meta data manager". - * An application owns the meta data manager that it creates; - * however, a meta data manager owns its parts and fields. - * \code - * using namespace stk_classic ; - * - * mesh::MetaData meta_mgr ; // Owned by the application - * - * // Declare my element and face parts: - * - * mesh::Part & my_part_a = meta_mgr.declare_part("A",mesh::Element); - * mesh::Part & my_part_b = meta_mgr.declare_part("B",mesh::Element); - * mesh::Part & my_side = meta_mgr.declare_part("S",mesh::Face); - * \endcode - * - * An application defines types for the - * \ref stk_classic::mesh::Field "fields" that it will use. - * The first template parameter of a field type is the numerical - * type of the field. The remaining template parameters (if any) - * define the ranks of the multidimensional array. - * In this example the TensorAtIntegrationField - * defines a rank-two (FORTRAN ordering) - * array where the first array index selects a tensor component and - * the second array index selects an integration point. - * \code - * typedef mesh::Field ScalarField ; - * typedef mesh::Field VectorField ; - * typedef mesh::Field TensorField ; - * typedef mesh::Field TensorAtIntegrationField ; - * // Declare fields of a specified type - * - * ScalarField & my_field_u = meta_mgr.declare_field< ScalarField >("u"); - * VectorField & my_field_v = meta_mgr.declare_field< VectorField >("v"); - * TensorField & my_field_w = meta_mgr.declare_field< TensorField >("w"); - * TensorAtIntegrationField & my_field_x = meta_mgr.declare_field< TensorAtIntegrationField >("x"); - * - * meta_mgr.put_field( my_field_u , mesh::Node , my_part_a ); - * meta_mgr.put_field( my_field_u , mesh::Node , my_part_b ); - * meta_mgr.put_field( my_field_u , mesh::Face , my_part_s ); - * - * meta_mgr.put_field( my_field_w , mesh::Element , my_part_a ); - * meta_mgr.put_field( my_field_x , mesh::Element , my_part_b , 8 ); - * \endcode - * Fields of a given type are declared with a text name. - * This text name is intended to be used exclusively - * by input and output functions, and should be - * immediately forgotten by the application. - * The put_field method is used to associate - * fields with entities on specified parts. - * In this example the nodes of my_part_a and my_part_b , - * and faces of my_side will have a scalar field data for - * my_field_u ; the elements of my_part_a will - * have tensor field data for my_field_w ; and - * each element of my_part_b will have the eight - * tensor values associated with my_field_x . - * - * After populating it parts and fields a meta data manager is committed, - * locking it against further changes. - * A bulk data object is created to manage entities, relations, and - * field data that are (1) conformal to a given meta data objects and - * (2) distributed among the processors of a parallel communicator - * (e.g., MPI_Comm). - * \code - * meta_mgr.commit(); // Finished constructing meta data - * - * mesh::BulkData bulk_mgr( meta_mgr , communicator ); - * \endcode - * Mesh bulk data is created and managed with respect to a committed - * mesh meta data. This separates, and thus simplifies, concerns of - * meta data changes from bulk data changes. - * - * At this point in an application mesh bulk data is typically read - * from a mesh file into the mesh bulk data, bulk_mgr . - * The typical access pattern for bulk data is to (1) iterate mesh - * entities of a given type (e.g., node or element) that belong - * to a given part and (2) operate on computational field data associated - * with the selected entities. - * - * \code - * std::vector< mesh::Bucket *> buckets ; - * // Get buckets for elements in my_part_a - * mesh::get_buckets( BucketSelector( my_part_a ) , - * bulk_mgr.buckets( mesh::Element ), buckets ); - * - * for ( unsigned i = 0 ; i < buckets.size() ; ++i ) { - * mesh::Bucket & k = * buckets[i] ; - * - * // number of elements in this bucket: - * const unsigned n = k.size(); - * - * // Pointer to field data for 'n' elements: - * double * const tensor = mesh::field_data( my_field_w , k ); - * - * // Iterate the elements in the bucketa and the field data - * for ( unsigned j = 0 ; j < n ; ++j ) { - * mesh::Entity & element = * k[j] ; - * double * element_tensor = tensor + size_of_tensor * j ; - * // computations... - * } - * } - * \endcode - * - */ - -//---------------------------------------------------------------------- - -/** \ingroup stk_mesh_module - * \defgroup stk_mesh_relations Mesh Entity Relationships - * \brief An seemingly simple - * \ref stk_classic::mesh::Relation "relationship" between two - * \ref stk_classic::mesh::Entity "mesh entities" - * has consequences for entity membership in - * \ref stk_classic::mesh::Part "parts" - * and derived field relationships. - */ - -/** \ingroup stk_mesh_module - * \defgroup stk_mesh_field_dimension_tags Meta Data Field Dimension Tags - * \brief Mesh specific - * \ref shards::ArrayDimTag "Array dimension tags" for defining - * \ref shards::Array "multi-dimensional array" - * \ref stk_mesh_field_data "field data". - */ - -//---------------------------------------------------------------------- - -/** \ingroup stk_mesh_module - * \defgroup stk_mesh_field_data Mesh Field Bulk Data - * \brief Computational data associated with the - * \ref stk_classic::mesh::Entity "entities" within a mesh. - */ - -/** \ingroup stk_mesh_module - * \defgroup stk_mesh_bulk_data_parallel Bulk Data Parallel Distribution - * \brief Parallel distribution of mesh bulk data. - */ - -/** \ingroup stk_mesh_module - * \defgroup stk_mesh_bulk_data_element Bulk Data Finite Element Entities - * \brief Create \ref stk_classic::mesh::Entity "entities" with common used - * \ref discrete_module "finite element topologies". - */ - -//---------------------------------------------------------------------- - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.cpp deleted file mode 100644 index 5036073c5ace..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - - -#include - -namespace stk_classic { -namespace mesh { - -MetaData & MetaData::get( const BulkData & bulk_data) { - return bulk_data.meta_data(); -} - -MetaData & MetaData::get( const Bucket & bucket) { - return MetaData::get(BulkData::get(bucket)); -} - -MetaData & MetaData::get( const Entity & entity) { - return MetaData::get(BulkData::get(entity)); -} - -MetaData & MetaData::get( const Ghosting & ghost) { - return MetaData::get(BulkData::get(ghost)); -} -//---------------------------------------------------------------------- - -std::ostream & -print_entity_id( std::ostream & os , const MetaData & meta_data , - unsigned type , EntityId id ) -{ - const std::string & name = meta_data.entity_rank_name( type ); - return os << name << "[" << id << "]" ; -} - - -std::ostream & -print_entity_key( std::ostream & os , const MetaData & meta_data , - const EntityKey & key ) -{ - const unsigned type = entity_rank(key); - const EntityId id = entity_id(key); - return print_entity_id( os , meta_data , type , id ); -} - -std::string -print_entity_key( const MetaData & meta_data , const EntityKey & key ) -{ - std::ostringstream out; - print_entity_key(out, meta_data, key); - return out.str(); -} - -//---------------------------------------------------------------------- - -void MetaData::require_not_committed() const -{ - ThrowRequireMsg(!m_commit, "mesh MetaData has been committed."); -} - -void MetaData::require_committed() const -{ - ThrowRequireMsg(m_commit, "mesh MetaData has not been committed."); -} - -void MetaData::require_same_mesh_meta_data( const MetaData & rhs ) const -{ - ThrowRequireMsg(this == &rhs, "Different mesh_meta_data."); -} - -void MetaData::require_valid_entity_rank( EntityRank rank ) const -{ - ThrowRequireMsg(check_rank(rank), - "entity_rank " << rank << " >= " << m_entity_rank_names.size() ); -} - -void MetaData::require_not_relation_target( const Part * const part ) const -{ - std::vector::const_iterator i_end = part->relations().end(); - std::vector::const_iterator i = part->relations().begin(); - for ( ; i != i_end ; ++i ) { - ThrowRequireMsg( part != i->m_target, - "Part[" << part->name() << "] is a PartRelation target"); - } -} - -//---------------------------------------------------------------------- - -MetaData::MetaData(const std::vector& entity_rank_names) - : m_commit( false ), - m_part_repo( this ), - m_attributes(), - m_universal_part( NULL ), - m_owns_part( NULL ), - m_shares_part( NULL ), - m_field_repo(), - m_field_relations( ), - m_properties( ), - m_entity_rank_names( entity_rank_names ), - m_spatial_dimension( 0 /*invalid spatial dimension*/) -{ - ThrowErrorMsgIf( entity_rank_names.empty(), "entity ranks empty" ); - - // Declare the predefined parts - - m_universal_part = m_part_repo.universal_part(); - m_owns_part = & declare_internal_part("OWNS"); - m_shares_part = & declare_internal_part("SHARES"); -} - -MetaData::MetaData() - : m_commit( false ), - m_part_repo( this ), - m_attributes(), - m_universal_part( NULL ), - m_owns_part( NULL ), - m_shares_part( NULL ), - m_field_repo(), - m_field_relations( ), - m_properties( ), - m_entity_rank_names( ), - m_spatial_dimension( 0 /*invalid spatial dimension*/) -{ - // Declare the predefined parts - - m_universal_part = m_part_repo.universal_part(); - m_owns_part = & declare_internal_part("OWNS"); - m_shares_part = & declare_internal_part("SHARES"); -} - -//---------------------------------------------------------------------- - -void MetaData::set_entity_rank_names(const std::vector &entity_rank_names) -{ - ThrowErrorMsgIf( entity_rank_names.empty(), "entity ranks empty" ); - - m_entity_rank_names = entity_rank_names; -} - -const std::string& MetaData::entity_rank_name( EntityRank entity_rank ) const -{ - ThrowErrorMsgIf( entity_rank >= m_entity_rank_names.size(), - "entity-rank " << entity_rank << - " out of range. Must be in range 0.." << m_entity_rank_names.size()); - - return m_entity_rank_names[entity_rank]; -} - -EntityRank MetaData::entity_rank( const std::string &name ) const -{ - EntityRank entity_rank = InvalidEntityRank; - - for (size_t i = 0; i < m_entity_rank_names.size(); ++i) - if (equal_case(name, m_entity_rank_names[i])) { - entity_rank = i; - break; - } - return entity_rank; -} - -//---------------------------------------------------------------------- - -Part * MetaData::get_part( const std::string & p_name , - const char * required_by ) const -{ - const PartVector & all_parts = m_part_repo.get_all_parts(); - - Part * const p = find( all_parts , p_name ); - - ThrowErrorMsgIf( required_by && NULL == p, - "Failed to find part with name " << p_name << - " for method " << required_by ); - - return p ; -} - -Part & MetaData::declare_part( const std::string & p_name ) -{ - require_not_committed(); - - const EntityRank rank = InvalidEntityRank; - - return *m_part_repo.declare_part( p_name, rank ); -} - -Part & MetaData::declare_internal_part( const std::string & p_name ) -{ - std::string internal_name = convert_to_internal_name(p_name); - return declare_part(internal_name); -} - -Part & MetaData::declare_part( const std::string & p_name , EntityRank rank ) -{ - require_not_committed(); - require_valid_entity_rank(rank); - - return *m_part_repo.declare_part( p_name , rank ); -} - -Part & MetaData::declare_internal_part( const std::string & p_name , EntityRank rank ) -{ - std::string internal_name = convert_to_internal_name(p_name); - return declare_part(internal_name, rank); -} - -Part & MetaData::declare_part( const PartVector & part_intersect ) -{ - require_not_committed(); - - for ( PartVector::const_iterator - i = part_intersect.begin() ; i != part_intersect.end() ; ++i ) { - require_not_relation_target(*i); - } - - return *m_part_repo.declare_part( part_intersect ); -} - -void MetaData::declare_part_subset( Part & superset , Part & subset ) -{ - static const char method[] = "stk_classic::mesh::MetaData::declare_part_subset" ; - - require_not_committed(); - require_same_mesh_meta_data( MetaData::get(superset) ); - require_same_mesh_meta_data( MetaData::get(subset) ); - require_not_relation_target( &superset ); - require_not_relation_target( &subset ); - - m_part_repo.declare_subset( superset, subset ); - - // The new superset / subset relationship can cause a - // field restriction to become incompatible or redundant. - m_field_repo.verify_and_clean_restrictions(method, superset, subset, m_part_repo.get_all_parts()); -} - -void MetaData::declare_part_relation( - Part & root_part , - relation_stencil_ptr stencil , - Part & target_part ) -{ - require_not_committed(); - require_not_relation_target( &root_part ); - - ThrowErrorMsgIf( !stencil, "stencil function pointer cannot be NULL" ); - - ThrowErrorMsgIf( 0 != target_part.subsets().size() || - 0 != target_part.intersection_of().size() || - 1 != target_part.supersets().size(), - "target Part[" << target_part.name() << - "] cannot be a superset or subset" ); - - PartRelation tmp ; - tmp.m_root = & root_part ; - tmp.m_target = & target_part ; - tmp.m_function = stencil ; - - m_part_repo.declare_part_relation( root_part, tmp, target_part ); -} - -//---------------------------------------------------------------------- - -FieldBase * -MetaData::declare_field_base( - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states ) -{ - require_not_committed(); - - return m_field_repo.declare_field( - arg_name, - arg_traits, - arg_rank, - arg_dim_tags, - arg_num_states, - this - ); -} - -void MetaData::declare_field_restriction( - FieldBase & arg_field , - EntityRank arg_entity_rank , - const Part & arg_part , - const unsigned * arg_stride , - const void * arg_init_value ) -{ - static const char method[] = - "std::mesh::MetaData::declare_field_restriction" ; - - //require_not_committed(); // Moved to FieldBaseImpl::declare_field_restriction - require_same_mesh_meta_data( MetaData::get(arg_field) ); - require_same_mesh_meta_data( MetaData::get(arg_part) ); - - m_field_repo.declare_field_restriction( - method, - arg_field, - arg_entity_rank, - arg_part, - m_part_repo.get_all_parts(), - arg_stride, - arg_init_value - ); -} - -void MetaData::declare_field_restriction( - FieldBase & arg_field , - EntityRank arg_entity_rank , - const Selector & arg_selector , - const unsigned * arg_stride , - const void * arg_init_value ) -{ - static const char method[] = - "std::mesh::MetaData::declare_field_restriction" ; - - //require_not_committed(); // Moved to FieldBaseImpl::declare_field_restriction - require_same_mesh_meta_data( MetaData::get(arg_field) ); - - m_field_repo.declare_field_restriction( - method, - arg_field, - arg_entity_rank, - arg_selector, - m_part_repo.get_all_parts(), - arg_stride, - arg_init_value - ); -} - - -void MetaData::internal_declare_field_relation( - FieldBase & pointer_field , - relation_stencil_ptr stencil , - FieldBase & referenced_field ) -{ - FieldRelation tmp ; - tmp.m_root = & pointer_field ; - tmp.m_target = & referenced_field ; - tmp.m_function = stencil ; - - m_field_relations.push_back( tmp ); -} - -//---------------------------------------------------------------------- - -void MetaData::commit() -{ - require_not_committed(); - - m_commit = true ; // Cannot add or change parts or fields now -} - -MetaData::~MetaData() -{ - // Destroy the properties, used 'new' to allocate so now use 'delete' - - try { - std::vector::iterator j = m_properties.begin(); - - for ( ; j != m_properties.end() ; ++j ) { delete *j ; } - - m_properties.clear(); - } catch(...) {} - - // PartRepository is member data - // FieldRepository is member data -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Verify parallel consistency of fields and parts - -namespace { - -void pack( CommBuffer & b , const PartVector & pset ) -{ - PartVector::const_iterator i , j ; - for ( i = pset.begin() ; i != pset.end() ; ++i ) { - const Part & p = **i ; - const PartVector & subsets = p.subsets(); - const PartVector & intersect = p.intersection_of(); - - const size_t name_len = p.name().size() + 1 ; - const char * const name_ptr = p.name().c_str(); - - { - const unsigned ord = p.mesh_meta_data_ordinal(); - b.pack( ord ); - } - - b.pack( name_len ); - b.pack( name_ptr , name_len ); - - const unsigned subset_size = static_cast(subsets.size()); - b.pack( subset_size ); - for ( j = subsets.begin() ; j != subsets.end() ; ++j ) { - const Part & s = **j ; - const unsigned ord = s.mesh_meta_data_ordinal(); - b.pack( ord ); - } - const unsigned intersect_size = static_cast(intersect.size()); - b.pack( intersect_size ); - for ( j = intersect.begin() ; j != intersect.end() ; ++j ) { - const Part & s = **j ; - const unsigned ord = s.mesh_meta_data_ordinal(); - b.pack( ord ); - } - } -} - -bool unpack_verify( CommBuffer & b , const PartVector & pset ) -{ - enum { MAX_TEXT_LEN = 4096 }; - char b_text[ MAX_TEXT_LEN ]; - unsigned b_tmp = 0; - - bool ok = true ; - PartVector::const_iterator i , j ; - for ( i = pset.begin() ; ok && i != pset.end() ; ++i ) { - const Part & p = **i ; - const PartVector & subsets = p.subsets(); - const PartVector & intersect = p.intersection_of(); - const unsigned name_len = static_cast(p.name().size()) + 1 ; - const char * const name_ptr = p.name().c_str(); - - if ( ok ) { - b.unpack( b_tmp ); - ok = b_tmp == p.mesh_meta_data_ordinal(); - } - - if ( ok ) { - b.unpack( b_tmp ); - ok = b_tmp == name_len ; - } - if ( ok ) { - b.unpack( b_text , name_len ); - ok = 0 == strcmp( name_ptr , b_text ); - } - - if ( ok ) { - b.unpack( b_tmp ); - ok = b_tmp == subsets.size() ; - } - for ( j = subsets.begin() ; ok && j != subsets.end() ; ++j ) { - const Part & s = **j ; - b.unpack( b_tmp ); - ok = b_tmp == s.mesh_meta_data_ordinal(); - } - - if ( ok ) { - b.unpack( b_tmp ); - ok = b_tmp == intersect.size(); - } - for ( j = intersect.begin() ; ok && j != intersect.end() ; ++j ) { - const Part & s = **j ; - b.unpack( b_tmp ); - ok = b_tmp == s.mesh_meta_data_ordinal(); - } - } - return ok ; -} - -void pack( CommBuffer & , - const std::vector< FieldBase * > & ) -{ -} - -bool unpack_verify( CommBuffer & , - const std::vector< FieldBase * > & ) -{ - bool ok = true ; - return ok ; -} - -} - -//---------------------------------------------------------------------- - -void verify_parallel_consistency( const MetaData & s , ParallelMachine pm ) -{ - const unsigned p_rank = parallel_machine_rank( pm ); - - const bool is_root = 0 == p_rank ; - - CommBroadcast comm( pm , 0 ); - - if ( is_root ) { - pack( comm.send_buffer() , s.get_parts() ); - pack( comm.send_buffer() , s.get_fields() ); - } - - comm.allocate_buffer(); - - if ( is_root ) { - pack( comm.send_buffer() , s.get_parts() ); - pack( comm.send_buffer() , s.get_fields() ); - } - - comm.communicate(); - - int ok[ 2 ]; - - ok[0] = unpack_verify( comm.recv_buffer() , s.get_parts() ); - ok[1] = unpack_verify( comm.recv_buffer() , s.get_fields() ); - - all_reduce( pm , ReduceMin<2>( ok ) ); - - ThrowRequireMsg(ok[0], "P" << p_rank << ": FAILED for Parts"); - ThrowRequireMsg(ok[1], "P" << p_rank << ": FAILED for Fields"); -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.hpp deleted file mode 100644 index 006d053e4101..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/MetaData.hpp +++ /dev/null @@ -1,1026 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_MetaData_hpp -#define stk_mesh_MetaData_hpp - -//---------------------------------------------------------------------- - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -namespace fem { -class FEMMetaData; -} - -/** \addtogroup stk_mesh_module - * \{ - */ - -/** \brief Print an entity key for this meta data */ -std::ostream & -print_entity_key( std::ostream & os, const MetaData & meta_data, const EntityKey & key); - -std::string -print_entity_key( const MetaData & meta_data, const EntityKey & key ); - -//---------------------------------------------------------------------- -/** \brief The manager of an integrated collection of - * \ref stk_classic::mesh::Part "parts" and - * \ref stk_classic::mesh::Field "fields". - * - * Mesh meta data must be identical on all processors. - */ -class MetaData { -public: - - /** \} */ - //------------------------------------ - /** \name Meta data manager construction and destruction - * \{ - */ - - inline static MetaData & get( const Part & part ) { return part.meta_data(); } - inline static MetaData & get( const FieldBase & field ) { return field.meta_data(); } - inline static MetaData & get( const PropertyBase & property ) { return property.meta_data(); } - - static MetaData & get( const BulkData & bulk_data ); - static MetaData & get( const Bucket & bucket ); - static MetaData & get( const Entity & entity ); - static MetaData & get( const Ghosting & ghost ); - - /** \brief Construct a meta data manager to own parts and fields. */ - explicit MetaData( const std::vector& entity_rank_names ); - - /** \brief Construct a meta data manager to own parts and fields. */ - MetaData(); - - //------------------------------------ - /** \name Predefined Parts - * \{ - */ - - /** \brief Universal subset for the problem domain. - * All other parts are a subset of the universal part. - */ - Part & universal_part() const { return *m_universal_part; } - - /** \brief Subset for the problem domain that is owned by the - * local process. Ghost entities are not members of this part. - */ - Part & locally_owned_part() const { return *m_owns_part ; } - - /** \brief Subset for the problem domain that is shared with another - * process. Ghost entities are not members of this part. - */ - Part & globally_shared_part() const { return *m_shares_part ; } - - /** \} */ - //------------------------------------ - /** \name Declare and query parts - * \{ - */ - - /** \brief Get an existing part by its application-defined text name. - * - * Return NULL if not present and required_by == NULL. - * If required and not present then throws an exception - * with the 'required_by' text. - */ - /// \todo REFACTOR remove required_by argument - Part * get_part( const std::string & p_name, - const char * required_by = NULL ) const ; - - /** \brief Get an existing part by its ordinal */ - Part & get_part( unsigned ord ) const ; - - /** \brief Query all parts of the mesh ordered by the parts' ordinal. */ - const PartVector & get_parts() const { return m_part_repo.get_all_parts(); } - - /** \brief Declare a part of the given name and entity rank - * Redeclaration returns the previously declared part. - * - * This part will have member entities that are of equal or lesser rank. - * When an entity of equal rank becomes a member - * then all related entities of lesser rank also become members. - */ - Part & declare_part( const std::string & p_name, EntityRank rank ); - - /** \brief Declare a part of the given name - * Redeclaration returns the previously declared part. - * - * This part does not have an entity type rank. - */ - Part & declare_part( const std::string & p_name); - - /** \brief Declare a part as the defined-intersection - * of the given collection of parts. - * - * The entity type rank will be the smallest entity type rank - * of the parts in the intersection, if any member has an - * entity type rank. - */ - Part & declare_part( const PartVector & p_name); - - /** \brief Declare a superset-subset relationship between parts */ - void declare_part_subset( Part & superset , Part & subset ); - - /** \brief Declare an entity-relationship between parts. - * - * If \ref stk_classic::mesh::Entity "entity" e1 is a member - * of root_part and there exists an - * \ref stk_classic::mesh::Relation "entity relation" - * from e1 to e2 that satisfies the - * \ref stk_mesh_relations "relation stencil" - * then e2 must be a member of the target_part . - */ - void declare_part_relation( Part & root_part , - relation_stencil_ptr stencil , - Part & target_part ); - - /** \brief Declare an attribute on a part. - * Return the attribute of that type, - * which may be an already existing value. - * \todo REFACTOR Should be using a shared pointer in this interface. - * declare_attribute( Part & , shared_ptr & ); - */ - template - const T * declare_attribute_with_delete( Part & part, const T * attribute); - template - const T * declare_attribute_no_delete( Part & part, const T * attribute); - template - bool remove_attribute( Part & part, const T * attribute); - - /** \} */ - //------------------------------------ - /** \name Entity-ranks - * \{ - */ - /** \brief entity-rank names - * - */ - void set_entity_rank_names(const std::vector &entity_rank_names); - - EntityRank entity_rank( const std::string &name ) const; - - const std::vector & entity_rank_names() const - { return m_entity_rank_names ; } - - std::vector::size_type entity_rank_count() const - { return m_entity_rank_names.size(); } - - const std::string & entity_rank_name( EntityRank entity_rank ) const ; - - /** - * Return true if rank is valid. - */ - bool check_rank(EntityRank rank) const; - - /** \} */ - //------------------------------------ - /** \name Declare and query fields - * \{ - */ - - /** \brief Get a field, return NULL if it does not exist. - * - * \exception std::runtime_error - * If the field exits and the - * \ref stk_classic::mesh::Field "field_type" does not match or - * if required_by != NULL and a field of that name is not found. - */ - template< class field_type > - field_type * get_field( const std::string & name ) const ; - - /** \brief Get all defined fields */ - const FieldVector & get_fields() const { - return m_field_repo.get_fields() ; - } - - /** \brief Declare a field of the given - * \ref stk_classic::mesh::Field "field_type", test name, - * and number of states. - * - * A compatible redeclaration returns the previously declared field. - * \exception std::runtime_error If a redeclaration is incompatible - * - * See Field.hpp for a full discussion of Fields. - */ - template< class field_type > - field_type & declare_field( const std::string & name , - unsigned number_of_states = 1 ); - - /** \brief Declare an attribute on a field. - * Return the attribute of that type, - * which may be an already existing value. - * \todo REFACTOR Should be using a shared pointer in this interface. - */ - template - const T * declare_attribute_with_delete( FieldBase & field, const T * attribute); - template - const T * declare_attribute_no_delete( FieldBase & field, const T * attribute); - - /** \brief Declare a field relation. - * - * The pointer_field's scalar type must be a pointer to the - * scalar type of the reference_field. The following - * derived field data relationship maintained. - * - * Let e_root -> Relation( e_target , ord , kind ) - * Let i = stencil( e_root.entity_rank() , - * e_target.entity_rank() , ord , kind ) - * Let Scalar ** ptr = field_data( pointer_field , e_root ) - * then ptr[i] = field_data( referenced_field , e_target ) - * - * This derived field data relationship is typically used - * to support fast access to field data on entities - * related to the root entity; e.g. field data associated with - * the nodes of an element. - * - * See FieldRelation.hpp for a full discussion of field relations. - */ - template< class PointerFieldType , class ReferencedFieldType > - void declare_field_relation( PointerFieldType & pointer_field , - relation_stencil_ptr stencil , - ReferencedFieldType & referenced_field ); - - /** \brief Get all field relations */ - const std::vector & get_field_relations() const - { return m_field_relations ; } - - /** \} */ - //------------------------------------ - - template - const T * get_attribute() const ; - - /** \brief Declare an attribute on the meta data. - * Return the attribute of that type, - * which may be an already existing value. - */ - template - const T * declare_attribute_with_delete( const T * attribute); - - template - const T * declare_attribute_no_delete( const T * attribute); - - template - bool remove_attribute( const T * ); - - //------------------------------------ - /** \} */ - /** \name Declare and query properties associated with parts - * \{ - */ - - /** \brief Get a property, return NULL if it does not exist. - * - * \exception std::runtime_error - * If the property exits and the - * \ref stk_classic::mesh::Property "type" does not match or - */ - template< typename DataType > - Property * get_property( const std::string & name ) const ; - - /** \brief Get all defined properties */ - const std::vector< PropertyBase * > & get_properties() const - { return m_properties ; } - - /** \brief Declare a property of the given - * \ref stk_classic::mesh::Property "type", name, and dimensions. - * - * A compatible redeclaration returns the previously declared property. - * \exception std::runtime_error If a redeclaration is incompatible - */ - template< typename DataType > - Property & declare_property( const std::string & name , - unsigned size = 1 ); - - /** \brief Put a property on the given part */ - void put_property( PropertyBase & property, Part & part); - - /** get the spatial-dimension, which can only be set by using FEMMetaData. */ - unsigned get_spatial_dimension() const { return m_spatial_dimension; } - - /** \brief Commit the part and field declarations so that the - * meta data manager can be used to create - * \ref stk_classic::mesh::BulkData "mesh bulk data". - * - * Verifies consistency of the meta data and clean out redundant - * field data allocation rules. - * Once committed no further part or field declarations can be made. - */ - void commit(); - - /** \brief Query if the meta data manager is committed */ - bool is_commit() const { return m_commit ; } - - /** \brief Destroy the meta data manager and - * all of the parts and fields that it owns. - */ - ~MetaData(); - - /** \} */ - //------------------------------------ - - /** \name Field declaration with weak type information; - * direct use in application code is strongly discouraged. - * \{ - */ - - /** \brief Declare a field via runtime type information */ - FieldBase * declare_field_base( - const std::string & arg_name, - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states ); - - /** \brief Declare a field restriction via runtime type information. - */ - void declare_field_restriction( FieldBase & arg_field , - EntityRank arg_entity_rank , - const Part & arg_part , - const unsigned * arg_stride , - const void* arg_init_value = NULL ); - - /** \brief Declare a field restriction via runtime type information. - */ - void declare_field_restriction( FieldBase & arg_field , - EntityRank arg_entity_rank , - const Selector & arg_selector , - const unsigned * arg_stride , - const void* arg_init_value = NULL ); - /** \} */ -private: - MetaData( const MetaData & ); ///< \brief Not allowed - MetaData & operator = ( const MetaData & ); ///< \brief Not allowed - - Part & declare_internal_part( const std::string & p_name); - - Part & declare_internal_part( const std::string & p_name, EntityRank rank); - - bool m_commit ; - impl::PartRepository m_part_repo ; - CSet m_attributes ; - - Part * m_universal_part ; - Part * m_owns_part ; - Part * m_shares_part ; - - - impl::FieldRepository m_field_repo ; - - std::vector< FieldRelation > m_field_relations ; - std::vector< PropertyBase* > m_properties ; - std::vector< std::string > m_entity_rank_names ; - - unsigned m_spatial_dimension; - friend class fem::FEMMetaData; - - /** \name Invariants/preconditions for MetaData. - * \{ - */ - void require_committed() const ; - - void require_not_committed() const ; - - void require_same_mesh_meta_data( const MetaData & rhs ) const ; - - void require_valid_entity_rank( EntityRank rank) const ; - - void require_not_relation_target( const Part * const part ) const ; - /** \} */ - //------------------------------------ - - Property * get_property_base( const std::string & , - const std::type_info & , - unsigned = 0 ) const ; - - void internal_declare_field_relation( FieldBase & , - relation_stencil_ptr , - FieldBase & ); - - void clean_field_restrictions(); -}; - -/** \brief Verify that the meta data is identical on all processors */ -void verify_parallel_consistency( const MetaData & , ParallelMachine ); - -/** \name Declare field data allocation rules - * \{ - */ - -/** \brief Declare a field to exist for a given entity type and Part. - * - * See Field.hpp for a full discussion of field restrictions. - */ -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Selector & selector , - const void* init_value = NULL); - -/** \brief Declare a field to exist for a given entity type and Part. The - * extra unsigned arguments specify the size of a dimension. So, - * put_field( field, rank, part, 3, 3 ) would create a 3x3 2D field. - * Fields of up to seven dimensions are supported. - */ -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Selector & selector , - unsigned n1 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Selector & selector , - unsigned n1 , - unsigned n2 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Selector & selector , - unsigned n1 , - unsigned n2 , - unsigned n3 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - unsigned n6 , - const void* init_value = NULL); - -template< class field_type > -field_type & put_field( field_type & field , - EntityRank entity_rank , - const Part & part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - unsigned n6 , - unsigned n7 , - const void* init_value = NULL); -/** \} */ -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#ifndef DOXYGEN_COMPILE - -namespace stk_classic { -namespace mesh { - -inline -Part & MetaData::get_part( unsigned ord ) const -{ return * m_part_repo.get_all_parts()[ord] ; } - -template< class field_type > -inline -field_type * MetaData::get_field( const std::string & name ) const -{ - typedef FieldTraits< field_type > Traits ; - - const DataTraits & dt = data_traits< typename Traits::data_type >(); - - const shards::ArrayDimTag * tags[8] ; - - Traits::assign_tags( tags ); - - FieldBase * const field = - m_field_repo.get_field( "stk_classic::mesh::MetaData::get_field" , - name , dt , Traits::Rank , tags , 0 ); - - return static_cast< field_type * >( field ); -} - -template< class field_type > -inline -field_type & MetaData::declare_field( const std::string & name , - unsigned number_of_states ) -{ - typedef FieldTraits< field_type > Traits ; - - const DataTraits & dt = data_traits< typename Traits::data_type >(); - - const shards::ArrayDimTag * tags[8] ; - - Traits::assign_tags( tags ); - - return * static_cast< field_type * >( - declare_field_base( name , dt , Traits::Rank , tags , number_of_states ) ); -} - -template< class field_type > -inline -field_type & put_field( - field_type & field , - EntityRank entity_rank , - const Part & part , - const void* init_value) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( - field_type & field , - EntityRank entity_rank , - const Selector & selector , - const void* init_value) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Selector &selector , - unsigned n1 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Selector &selector , - unsigned n1 , - unsigned n2 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Selector &selector , - unsigned n1 , - unsigned n2 , - unsigned n3 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 , n4 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 , n4, n5 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - unsigned n6 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template< class field_type > -inline -field_type & put_field( field_type &field , - EntityRank entity_rank , - const Part &part , - unsigned n1 , - unsigned n2 , - unsigned n3 , - unsigned n4 , - unsigned n5 , - unsigned n6 , - unsigned n7 , - const void* init_value ) -{ - typedef FieldTraits< field_type > Traits ; - typedef typename Traits::Helper Helper ; - - unsigned stride[8] ; - - Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6, n7 ); - - MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value); - - return field ; -} - -template -inline -const T * -MetaData::declare_attribute_with_delete( const T * a ) -{ - require_not_committed(); - return m_attributes.insert_with_delete( a ); -} - -template -inline -const T * -MetaData::get_attribute() const -{ return m_attributes.get(); } - -template -inline -const T * -MetaData::declare_attribute_no_delete( const T * attribute ) -{ - require_not_committed(); - return m_attributes.insert_no_delete( attribute ); -} - -template -inline -bool -MetaData::remove_attribute( const T * a ) -{ - return m_attributes.remove( a ); -} - -template -inline -const T * -MetaData::declare_attribute_with_delete( Part & part , const T * attribute ) -{ - require_not_committed(); - return m_part_repo.declare_attribute_with_delete( part, attribute ); -} - -template -inline -const T * -MetaData::declare_attribute_no_delete( Part & part , const T * attribute ) -{ - require_not_committed(); - return m_part_repo.declare_attribute_no_delete( part, attribute ); -} - -template -inline -bool -MetaData::remove_attribute( Part & part , const T * attribute ) -{ - return m_part_repo.remove_attribute(part, attribute); -} - -template -inline -const T * -MetaData::declare_attribute_with_delete( FieldBase & field , const T * attribute ) -{ - require_not_committed(); - return m_field_repo.declare_attribute_with_delete(field, attribute); -} - -template -inline -const T * -MetaData::declare_attribute_no_delete( FieldBase & field , const T * attribute ) -{ - require_not_committed(); - return m_field_repo.declare_attribute_no_delete(field, attribute); -} - -//---------------------------------------------------------------------- - -template< class PointerFieldType , class ReferencedFieldType > -inline -void MetaData::declare_field_relation( - PointerFieldType & pointer_field , - relation_stencil_ptr stencil , - ReferencedFieldType & referenced_field ) -{ - typedef typename FieldTraits< PointerFieldType >::data_type pointer_type ; - typedef typename FieldTraits< ReferencedFieldType >::data_type data_type ; - - StaticAssert< SameType< pointer_type , data_type * >::value >::ok(); - StaticAssert< FieldTraits< PointerFieldType >::Rank == 1 >::ok(); - - internal_declare_field_relation( pointer_field , stencil , referenced_field ); -} - -//---------------------------------------------------------------------- - -template< typename DataType > -inline -Property * -MetaData::get_property( const std::string & name ) const -{ - Property * const pv = get_property_base( name, typeid(DataType) ); - return pv ? pv->property() : (Property*) NULL ; -} - -template< typename DataType > -inline -Property & -MetaData::declare_property( const std::string & name , unsigned size ) -{ - Property * pv = get_property_base(name,typeid(DataType),size); - Property * prop = NULL ; - - if ( pv != NULL ) { - prop = pv->property(); - } - else { - if ( 1 == size ) { - pv = prop = new Property( *this , m_properties.size() , name ); - } - else { - pv = prop = new Property< std::vector >( - *this , m_properties.size() , name , size ); - } - m_properties.push_back( pv ); - } - return *prop ; -} - -inline -void MetaData::put_property( PropertyBase & property , Part & part ) -{ - property.add_property( part.mesh_meta_data_ordinal() ); -} - -inline -bool MetaData::check_rank(EntityRank rank) const -{ - return rank < m_entity_rank_names.size(); -} - -inline -bool -is_auto_declared_part(const Part &part) -{ - const std::string &part_name = part.name(); - - return !part_name.empty() && part_name[0] == '{'; -} - -} // namespace mesh -} // namespace stk_classic - -#endif /* DOXYGEN_COMPILE */ - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif /* stk_mesh_MetaData_hpp */ diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.cpp deleted file mode 100644 index 5a46848cd99f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -Part * find( const PartVector & parts , const std::string & name ) -{ - PartVector::const_iterator i = parts.begin(); - - while ( i != parts.end() && not_equal_case((*i)->name(),name) ) { ++i ; } - - return i != parts.end() ? *i : NULL ; -} - -//---------------------------------------------------------------------- - -std::ostream & -print( std::ostream & os , const char * const lead , const Part & p ) -{ - const PartVector & supersets = p.supersets(); - const PartVector & subsets = p.subsets(); - const PartVector & intersection = p.intersection_of(); - - std::vector::const_iterator i ; - - if ( lead != NULL ) { os << lead ; } - os << "Part[ " ; - os << p.name() ; - os << " , " ; - os << p.mesh_meta_data_ordinal() ; - os << " ] {" ; - os << std::endl ; - - if ( lead != NULL ) { os << lead ; } - os << " Supersets {" ; - for ( i = supersets.begin() ; i != supersets.end() ; ++i ) { - const std::string & n = (*i)->name() ; os << " " << n ; - } - os << " }" << std::endl ; - - if ( lead != NULL ) { os << lead ; } - os << " Intersection_Of {" ; - for ( i = intersection.begin() ; i != intersection.end() ; ++i ) { - const std::string & n = (*i)->name() ; os << " " << n ; - } - os << " } }" << std::endl ; - - if ( lead != NULL ) { os << lead ; } - os << " Subsets {" ; - for ( i = subsets.begin() ; i != subsets.end() ; ++i ) { - const std::string & n = (*i)->name() ; os << " " << n ; - } - os << " }" << std::endl ; - - return os ; -} - -//---------------------------------------------------------------------- - -void order( PartVector & v ) -{ - PartVector::iterator ev = v.end(); - PartVector::iterator iv = v.begin(); - std::sort( iv , ev , PartLess() ); - iv = std::unique( iv , ev ); - v.erase( iv , ev ); -} - -bool insert( PartVector & v , Part & part ) -{ - const PartVector::iterator e = v.end(); - PartVector::iterator i = v.begin(); - - i = std::lower_bound( i , e , part , PartLess() ); - - const bool new_member = i == e || *i != & part ; - - if ( new_member ) { v.insert( i , &part ); } - return new_member ; -} - -void remove( PartVector & v , Part & part ) -{ - const PartVector::iterator e = v.end(); - PartVector::iterator i = v.begin(); - - i = std::lower_bound( i , e , part , PartLess() ); - - if ( i != e && *i == & part ) { v.erase( i ); } -} - -bool contain( const PartVector & v , const Part & part ) -{ - const PartVector::const_iterator e = v.end(); - PartVector::const_iterator i = v.begin(); - - i = std::lower_bound( i , e , part , PartLess() ); - - return i != e && *i == & part ; -} - -bool contain( const PartVector & super , const PartVector & sub ) -{ - bool result = ( ! sub.empty() ) && ( sub.size() <= super.size() ); - - if ( result ) { - PartLess comp ; - - const PartVector::const_iterator ev = super.end(); - PartVector::const_iterator iv = super.begin(); - - const PartVector::const_iterator ep = sub.end(); - PartVector::const_iterator ip = sub.begin(); - - while ( result && ip != ep ) { - Part * const q = *ip ; ++ip ; - iv = std::lower_bound( iv , ev , q , comp ); - result = iv != ev && *iv == q ; - } - } - - return result ; -} - -size_t intersect( const PartVector & v , const PartVector & p ) -{ - // Both lists must be sorted, assume v.size() > p.size() - - const PartVector::const_iterator ev = v.end(); - PartVector::const_iterator iv = v.begin(); - - const PartVector::const_iterator ep = p.end(); - PartVector::const_iterator ip = p.begin(); - - size_t count = 0 ; - - for ( ; ip != ep && iv != ev ; ++ip ) { - Part * const q = *ip ; - iv = std::lower_bound( iv , ev , q , PartLess() ); - if ( iv != ev && *iv == q ) { ++count ; } - } - - return count ; -} - -size_t intersect( const PartVector & v , const PartVector & p , PartVector & r ) -{ - // Both lists must be sorted, assume v.size() > p.size() - - const PartVector::const_iterator ev = v.end(); - PartVector::const_iterator iv = v.begin(); - - const PartVector::const_iterator ep = p.end(); - PartVector::const_iterator ip = p.begin(); - - for ( ; ip != ep && iv != ev ; ++ip ) { - Part * const q = *ip ; - iv = std::lower_bound( iv , ev , q , PartLess() ); - if ( iv != ev && *iv == q ) { r.push_back( q ); } - } - - return r.size() ; -} - -bool intersect( const Part & a , const Part & b ) -{ - const PartVector & a_sub = a.subsets(); - const PartVector & b_sub = b.subsets(); - return contain( a_sub , b ) || - contain( b_sub , a ) || - intersect( b_sub , a_sub ); -} - -std::string convert_to_internal_name(const std::string& part_name) -{ - std::ostringstream out; - out << INTERNAL_PART_PREFIX << part_name << INTERNAL_PART_POSTFIX; - std::string out_str = out.str(); - return out_str; -} - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.hpp deleted file mode 100644 index d590fb176544..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Part.hpp +++ /dev/null @@ -1,249 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_Part_hpp -#define stk_mesh_Part_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include -#include - -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -namespace impl { - class PartRepository; -} // namespace impl - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- -/** \brief An application-defined subset of a problem domain. - * - * An application may define parts corresponding to geometric subdomains, - * modeling subdomains, material subdomains, parallel distributed subdomains, - * entities of the same type of discretization - * (e.g., hexahedrons, tetrahedrons, ...), - * or any other application need for subsetting. - * - * A Part is created, owned, and modified by a - * \ref stk_classic::mesh::PartRepository "Part manager". - */ -class Part { -public: - - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns the PartRepository which created this part. - */ - MetaData & mesh_meta_data() const { return m_partImpl.mesh_meta_data(); } - - /** \brief The primary entity type for this part. - * - * For example, the primary purpose of an Element part - * is to define a collection of elements. However, the - * nodes of those elements are also members of an element part. - * Return InvalidEntityRank if no primary entity type. - */ - unsigned primary_entity_rank() const { return m_partImpl.primary_entity_rank(); } - - /** \brief Application-defined text name of this part */ - const std::string & name() const { return m_partImpl.name(); } - - /** \brief Internally generated ordinal of this part that is unique - * within the owning \ref stk_classic::mesh::MetaData "meta data manager". - */ - unsigned mesh_meta_data_ordinal() const { return m_partImpl.mesh_meta_data_ordinal(); } - - /** \brief Parts that are supersets of this part. */ - const PartVector & supersets() const { return m_partImpl.supersets(); } - - /** \brief Parts that are subsets of this part. */ - const PartVector & subsets() const { return m_partImpl.subsets(); } - - /** \brief Parts for which this part is defined as the intersection. */ - const PartVector & intersection_of() const { return m_partImpl.intersection_of(); } - - /** \brief PartRelations for which this part is a member, root or target */ - const std::vector & relations() const { return m_partImpl.relations(); } - - /** \brief Equality comparison */ - bool operator == ( const Part & rhs ) const { return this == & rhs ; } - - /** \brief Inequality comparison */ - bool operator != ( const Part & rhs ) const { return this != & rhs ; } - - /** \brief Query attribute that has been attached to this part */ - template - const A * attribute() const { return m_partImpl.attribute
(); } - -private: - - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns the PartRepository which created this part. - */ - MetaData & meta_data() const { return m_partImpl.mesh_meta_data(); } - - - impl::PartImpl m_partImpl; - - /* \brief A part is owned by a PartRepository, as such only the owning - * PartRepository can create, delete, or modify a part. - * The owner-modifies rule is enforced by the implementation being - * a private data object on the Part and the PartRepository is a - * friend. - */ - friend class ::stk_classic::mesh::impl::PartRepository ; - friend class ::stk_classic::mesh::MetaData ; - -#ifndef DOXYGEN_COMPILE - - /** Construct a subset part within a given mesh. - * Is used internally by the two 'declare_part' methods on PartRepository. - */ - Part( MetaData * arg_meta_data , const std::string & arg_name, EntityRank arg_rank, size_t arg_ordinal) - : m_partImpl(arg_meta_data,arg_name,arg_rank,arg_ordinal) - { } - - ~Part() {} - Part(); - Part( const Part & ); - Part & operator = ( const Part & ); - -#endif /* DOXYGEN_COMPILE */ - -}; - -static const char INTERNAL_PART_PREFIX = '{'; -static const char INTERNAL_PART_POSTFIX = '}'; - -inline -bool is_internal(const std::string& part_name) -{ - return part_name.size() > 2 && *part_name.begin() == INTERNAL_PART_PREFIX && *part_name.rbegin() == INTERNAL_PART_POSTFIX; -} - -inline -bool is_internal(const Part& part) -{ return is_internal(part.name()); } - -std::string convert_to_internal_name(const std::string& part_name); - -//---------------------------------------------------------------------- -/** \brief Ordering operator for parts. */ -struct PartLess { - - inline bool operator()( const Part & lhs , const Part & rhs ) const - { return lhs.mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); } - - inline bool operator()( const Part & lhs , const Part * rhs ) const - { return lhs.mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); } - - inline bool operator()( const Part * lhs , const Part & rhs ) const - { return lhs->mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); } - - inline bool operator()( const Part * lhs , const Part * rhs ) const - { return lhs->mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); } -}; - -/** \brief Order a collection of parts: invoke sort and then unique */ -void order( PartVector & ); - -inline -void order( OrdinalVector & v ) -{ - OrdinalVector::iterator ev = v.end(); - OrdinalVector::iterator iv = v.begin(); - std::sort( iv , ev ); - iv = std::unique( iv , ev ); - v.erase( iv , ev ); -} - -/** \brief Insert a part into a properly ordered collection of parts. - * Returns true if this is a new insertion. - */ -bool insert( PartVector & , Part & ); - -inline -bool insert_ordinal( OrdinalVector & v , unsigned part_ordinal ) -{ - for(OrdinalVector::iterator i=v.begin(), e=v.end(); i!=e; ++i) { - if (*i == part_ordinal) return false; - if (*i > part_ordinal) { - v.insert(i, part_ordinal); - return true; - } - } - - v.push_back(part_ordinal); - return true ; -} - -/** \brief Remove a part from a properly ordered collection of parts. */ -void remove( PartVector & , Part & ); - -/** \brief Find a part by name in a collection of parts. */ -Part * find( const PartVector & , const std::string & ); - -/** \brief Query containment within properly ordered PartVector */ -bool contain( const PartVector & , const Part & ); - -template -inline -bool contains_ordinal( Iterator beg, Iterator end, unsigned part_ordinal ) -{ - for(Iterator i=beg; i!=end; ++i) { - if (*i == part_ordinal) return true; - } - - return false; -} - -/** \brief Query containment for two properly ordered PartVector */ -bool contain( const PartVector & , const PartVector & ); - -/** \brief Query cardinality of intersection of two PartVectors */ -size_t intersect( const PartVector & , const PartVector & ); - -/** \brief Generate the intersection of two PartVectors */ -size_t intersect( const PartVector & , const PartVector & , PartVector & ); - -/** \brief Query if two parts intersect; i.e., - * if one is a subset of the other or they share a common subset - */ -bool intersect( const Part & , const Part & ); - -//---------------------------------------------------------------------- -/** \brief Print a part's information including supersets, subsets, and - * intersection. Each line starts with the given leader string. - */ -std::ostream & print( std::ostream & , const char * const , const Part & ); - - -/** \} */ - - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PartRelation.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PartRelation.hpp deleted file mode 100644 index 4d3c29c12b59..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PartRelation.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef stk_mesh_PartRelation_hpp -#define stk_mesh_PartRelation_hpp - -#include - -namespace stk_classic { -namespace mesh { - -class Part; - -/** \addtogroup stk_mesh_module - * \{ - */ - -//---------------------------------------------------------------------- -/** \ingroup stk_mesh_relations - * \brief A defined entity-relationship between - * \ref stk_classic::mesh::Part "parts". - * An internal class that should never need to be - * directly used within application code. - * - * If an - * \ref stk_classic::mesh::Entity "entity" e1 is a member of - * \ref stk_classic::mesh::Part "part" m_root and - * there exists a - * \ref stk_classic::mesh::Relation "relation" - * from entity e1 to entity e2 that - * is in the domain of the - * \ref stk_mesh_relations "relation stencil" - * m_function - * then entity e2 is a member of part m_target . - */ -struct PartRelation { - /** \brief relation domain part */ - Part * m_root ; - - /** \brief relation range part */ - Part * m_target ; - - /** \brief \ref stk_mesh_relations "relation stencil" */ - relation_stencil_ptr m_function ; - -#ifndef DOXYGEN_COMPILE - - ~PartRelation() {} - - PartRelation() : m_root( NULL ), m_target( NULL ), m_function( NULL ) {} - - PartRelation( const PartRelation & rhs ) - : m_root( rhs.m_root ), - m_target( rhs.m_target ), - m_function( rhs.m_function ) {} - - PartRelation & operator = ( const PartRelation & rhs ) - { - m_root = rhs.m_root ; - m_target = rhs.m_target ; - m_function = rhs.m_function ; - return *this ; - } - -#endif /* DOXYGEN_COMPILE */ - -}; - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_PartRelation_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.cpp deleted file mode 100644 index be97da4695ee..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -Property::~Property() {} - -PropertyBase * -MetaData::get_property_base( const std::string & name , - const std::type_info & type , - unsigned size ) const -{ - PropertyBase * p = NULL ; - { - std::vector< PropertyBase * >::const_iterator i ; - for ( i = m_properties.begin() ; - i != m_properties.end() && not_equal_case( (*i)->name() , name ) ; - ++i ); - - if ( i != m_properties.end() ) { - const bool error_type = ( (*i)->m_type != type ); - const bool error_size = size && ( (*i)->m_size != size ); - - ThrowErrorMsgIf( error_type, - "For property name " << name << ": " << - " actual_type(" << (*i)->m_type.name() << - ") != request_type(" << type.name() << ")"); - - ThrowErrorMsgIf( error_size, - "For property name " << name << ": " << - " actual_size(" << (*i)->m_size << - ") != request_size(" << size << ")") ; - p = *i; - } - } - return p ; -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.hpp deleted file mode 100644 index f094648cf07b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Property.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_Property_hpp -#define stk_mesh_Property_hpp - -//---------------------------------------------------------------------- - -#include -#include - -#include - -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_module - * \{ - */ - -/** \brief Print the text name for a field. */ -std::ostream & operator << ( std::ostream & , const PropertyBase & ); - -/** \brief Print field and field restrictions on new lines. */ -std::ostream & print( std::ostream & , - const char * const , const PropertyBase & ); - -/** \brief Query pointer to property data for a given part */ -template< typename property_type > -inline -const typename property_type::data_type * -property_data( const property_type & prop , const Part & part ) -{ - const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop); - const MetaData * prop_meta_data = & MetaData::get(prop_base); - const MetaData * part_meta_data = & MetaData::get(part); - ThrowRequireMsg( prop_meta_data == part_meta_data, - "MetaData mismatch between property and part" ); - return prop.data( part.mesh_meta_data_ordinal() ); -} - -/** \brief Query pointer to property data for a given part */ -template< typename property_type > -inline -typename property_type::data_type * -property_data( property_type & prop , const Part & part ) -{ - const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop); - const MetaData * prop_meta_data = & MetaData::get(prop_base); - const MetaData * part_meta_data = & MetaData::get(part); - ThrowRequireMsg( prop_meta_data == part_meta_data, - "MetaData mismatch between property and part" ); - return prop.data( part.mesh_meta_data_ordinal() ); -} - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -#endif /* stk_mesh_Property_hpp */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PropertyBase.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PropertyBase.hpp deleted file mode 100644 index 6d63fd514ddb..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/PropertyBase.hpp +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_base_PropertyBase_hpp -#define stk_mesh_base_PropertyBase_hpp - -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { - -/** \ingroup stk_mesh_module - * \brief Property base class with an anonymous data type and - * anonymous multi-dimension. - */ -template<> -class Property< void > { -public: - - MetaData & mesh_meta_data() const { return m_meta_data ; } - - /** \brief Internally generated ordinal of this property that is unique - * within the owning \ref stk_classic::mesh::MetaData "meta data manager". - */ - unsigned mesh_meta_data_ordinal() const { return m_meta_data_ordinal ; } - - /** \brief Application-defined text name of this property */ - const std::string & name() const { return m_name ; } - - /** \brief Query if the scalar type is DataType */ - template bool type_is() const - { return m_type == typeid(DataType); } - - /** \brief Query number of members, if an array */ - unsigned size() const { return m_size ; } - - /** \brief Type-checked cast to property with members of the given type */ - template< typename DataType > - Property< DataType > * property() - { - Property< DataType > * p = NULL ; - if ( m_type == typeid(DataType) ) { - p = static_cast< Property< DataType > * >( this ); - } - return p ; - } - - /** \brief Type-checked cast to property with members of the given type */ - template< typename DataType > - const Property< DataType > * property() const - { - const Property< DataType > * p = NULL ; - if ( m_type == typeid(DataType) ) { - p = static_cast< const Property< DataType > * >( this ); - } - return p ; - } - - //---------------------------------------- - -#ifndef DOXYGEN_COMPILE - -protected: - - Property( MetaData & my_meta_data , - unsigned meta_data_ordinal , - const std::string & input_name , - const std::type_info & type , - unsigned n ) - : m_name( input_name ), - m_meta_data( my_meta_data ), - m_meta_data_ordinal( meta_data_ordinal ), - m_type( type ), m_size( n ) {} - - virtual void add_property( unsigned ) = 0 ; - - virtual ~Property(); - -private: - - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns this property. - */ - MetaData & meta_data() const { return m_meta_data ; } - - const std::string m_name ; ///< Name of the property - MetaData & m_meta_data ; ///< In which this property resides - const unsigned m_meta_data_ordinal ; - const std::type_info & m_type ; ///< Member data type - const unsigned m_size ; ///< Number of items - - Property(); - Property( const Property & ); - Property & operator = ( const Property & ); - - friend class MetaData ; - -#endif /* DOXYGEN_COMPILE */ -}; - -//---------------------------------------------------------------------- - -/** \ingroup stk_mesh_module - * \brief Property with defined data type and multi-dimensions (if any) - */ - -template< typename DataType > -class Property : public PropertyBase { -#ifndef DOXYGEN_COMPILE -private: - friend class MetaData ; - - typedef std::map< unsigned , DataType > map_scalar ; - - map_scalar m_data_scalar ; - -protected: - - Property( MetaData & my_meta_data, unsigned meta_data_ordinal , - const std::string & input_name, unsigned input_size = 1 ) - : PropertyBase( my_meta_data, meta_data_ordinal , - input_name, typeid(DataType), input_size ) {} - - virtual void add_property( unsigned key ) { m_data_scalar[ key ]; } - - virtual ~Property() {} - -#endif /* DOXYGEN_COMPILE */ -public: - - /** \brief Type of the properties' members */ - typedef DataType data_type ; - - /** \brief Access the properties' members */ - virtual data_type * data( unsigned key ) - { - const typename map_scalar::iterator i = m_data_scalar.find( key ); - return i != m_data_scalar.end() ? & (*i).second : (data_type*) NULL ; - } - - /** \brief Access the properties' members */ - virtual const data_type * data( unsigned key ) const - { - const typename map_scalar::const_iterator i = m_data_scalar.find( key ); - return i != m_data_scalar.end() ? & (*i).second : (data_type*) NULL ; - } - -}; - -#ifndef DOXYGEN_COMPILE - -template< typename DataType > -class Property< std::vector< DataType > > : public Property { -private: - friend class MetaData ; - - typedef std::map< unsigned , std::vector< DataType > > map_array ; - - map_array m_data_array ; - - void add_property( unsigned key ) - { m_data_array[ key ].resize( Property::size() ); } - - ~Property() {} - Property(); - Property( const Property & ); - Property & operator = ( const Property & ); - -public: - - Property( MetaData & my_meta_data , - unsigned meta_data_ordinal , - const std::string & name , - unsigned size ) - : Property( my_meta_data, meta_data_ordinal, name, size ) {} - - typedef DataType data_type ; - - data_type * data( unsigned key ) - { - const typename map_array::iterator i = m_data_array.find( key ); - return i != m_data_array.end() ? & (*i).second[0] : (data_type*) NULL ; - } - - const data_type * data( unsigned key ) const - { - const typename map_array::const_iterator i = m_data_array.find( key ); - return i != m_data_array.end() ? & (*i).second[0] : (data_type*) NULL ; - } -}; - -#endif /* DOXYGEN_COMPILE */ - - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_base_PropertyBase_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.cpp deleted file mode 100644 index 30c536890226..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -std::ostream & -operator << ( std::ostream & s , const Relation & rel ) -{ - Entity * const e = rel.entity(); - - if ( e ) { - const MetaData & meta_data = MetaData::get(*e); - s << "[" << rel.identifier() << "]->" ; - print_entity_key( s , meta_data , e->key() ); - } - else { - s << "[" << rel.identifier() << "]->" << rel.entity_rank(); - } - - return s ; -} - -//---------------------------------------------------------------------- - -Relation::Relation( Entity & entity , RelationIdentifier identifier ) - : m_raw_relation( Relation::raw_relation_id( entity.entity_rank() , identifier ) ), - m_target_entity( & entity ) -{ -#ifdef SIERRA_MIGRATION - setRelationType(INVALID); -#endif -} - -bool Relation::operator < ( const Relation & rhs ) const -{ - bool result = false; - -#ifdef SIERRA_MIGRATION - if (entity_rank() != rhs.entity_rank()) { - result = entity_rank() < rhs.entity_rank(); - } - else if (getRelationType() != rhs.getRelationType()) { - result = getRelationType() < rhs.getRelationType(); - } - else if (identifier() != rhs.identifier()) { - result = identifier() < rhs.identifier(); - } -#else - if ( m_raw_relation.value != rhs.m_raw_relation.value ) { - result = m_raw_relation.value < rhs.m_raw_relation.value ; - } -#endif - else { - const EntityKey lhs_key = m_target_entity ? m_target_entity->key() : EntityKey(); - const EntityKey rhs_key = rhs.m_target_entity ? rhs.m_target_entity->key() : EntityKey(); - result = lhs_key < rhs_key ; - } - return result ; -} - -//---------------------------------------------------------------------- - -#ifdef SIERRA_MIGRATION - -Relation::Relation(Entity *obj, const unsigned relation_type, const unsigned ordinal, const unsigned orient) - : - m_raw_relation( Relation::raw_relation_id( obj->entity_rank(), ordinal )), - m_attribute( (relation_type << fmwk_orientation_digits) | orient ), - m_target_entity(obj) -{ - ThrowAssertMsg( orient <= fmwk_orientation_mask, - "orientation " << orient << " exceeds maximum allowed value"); -} - -void Relation::setMeshObj(Entity *object) -{ - if (object != NULL) { - m_raw_relation = Relation::raw_relation_id( object->entity_rank(), identifier() ); - } - m_target_entity = object; -} - -#endif - -namespace { - -void get_entities_through_relations( - PairIterRelation rel , - const std::vector::const_iterator i_beg , - const std::vector::const_iterator i_end , - std::vector & entities_related ) -{ - for ( ; rel.first != rel.second ; ++rel.first ) { - - // Do all input entities have a relation to this entity ? - - Entity * const e = rel.first->entity(); - - std::vector::const_iterator i = i_beg ; - - for ( ; i != i_end ; ++i ) { - PairIterRelation r = (*i)->relations(); - while ( r.first != r.second && e != r.first->entity() ) { - ++r.first ; - } - if ( r.first == r.second ) { break ; } - } - - if ( i == i_end ) { - entities_related.push_back( e ); - } - } -} - -inline -void insert_part_and_supersets(OrdinalVector& induced_parts, - Part& part, - bool include_supersets) -{ - insert_ordinal( induced_parts , part.mesh_meta_data_ordinal() ); - - // In order to preserve superset/subset consistency we should add supersets of - // induced parts to the induced part lists. Unfortunately, this opens up an ambiguity - // where, when a relation is removed, we cannot know if an unranked superset - // part should be removed. - if (include_supersets) { - const PartVector & supersets = part.supersets(); - for (PartVector::const_iterator itr = supersets.begin(), end = supersets.end(); itr != end; ++itr) { - insert_ordinal( induced_parts, (*itr)->mesh_meta_data_ordinal() ); - } - } -} - -} - -void get_entities_through_relations( - const std::vector & entities , - std::vector & entities_related ) -{ - entities_related.clear(); - - if ( ! entities.empty() ) { - std::vector::const_iterator i = entities.begin(); - const std::vector::const_iterator j = entities.end(); - - PairIterRelation rel = (*i)->relations(); ++i ; - - get_entities_through_relations( rel , i , j , entities_related ); - } -} - -void get_entities_through_relations( - const std::vector & entities , - unsigned entities_related_rank , - std::vector & entities_related ) -{ - entities_related.clear(); - - if ( ! entities.empty() ) { - std::vector::const_iterator i = entities.begin(); - const std::vector::const_iterator j = entities.end(); - - PairIterRelation rel = (*i)->relations( entities_related_rank ); ++i ; - - get_entities_through_relations( rel , i , j , entities_related ); - } -} - -//---------------------------------------------------------------------- - -/** \brief Query if a member entity of the given entity type - * has an induced membership. - */ -bool membership_is_induced( const Part & part , unsigned entity_rank ) -{ - const MetaData & meta = MetaData::get(part); - - const bool induced_by_type = - entity_rank < part.primary_entity_rank() && - part.primary_entity_rank() < meta.entity_rank_count() ; - - const bool induced_by_stencil = - ! part.relations().empty() && - part.relations().begin()->m_target == & part ; - - return induced_by_type || induced_by_stencil ; -} - -//---------------------------------------------------------------------- - -void induced_part_membership( Part & part , - unsigned entity_rank_from , - unsigned entity_rank_to , - RelationIdentifier relation_identifier , - OrdinalVector & induced_parts, - bool include_supersets) -{ - if ( entity_rank_to < entity_rank_from && - part.primary_entity_rank() == entity_rank_from ) { - - // Direct relationship: - - insert_part_and_supersets( induced_parts , part, include_supersets ); - - // Stencil relationship where 'part' is the root: - // The 'target' should not have subsets or supersets. - - const std::vector & part_rel = part.relations(); - - for ( std::vector::const_iterator - j = part_rel.begin() ; j != part_rel.end() ; ++j ) { - - if ( & part == j->m_root && - 0 <= (* j->m_function)( entity_rank_from , entity_rank_to , - relation_identifier ) ) { - insert_part_and_supersets( induced_parts , * j->m_target, include_supersets ); - } - } - } -} - -//---------------------------------------------------------------------- -// What are this entity's part memberships that can be deduced from -// this entity's relationship. Can only trust 'entity_from' to be -// accurate if it is owned by the local process. - -void induced_part_membership( const Entity & entity_from , - const OrdinalVector & omit , - unsigned entity_rank_to , - RelationIdentifier relation_identifier , - OrdinalVector & induced_parts, - bool include_supersets) -{ - const Bucket & bucket_from = entity_from.bucket(); - const BulkData & mesh = BulkData::get(bucket_from); - const unsigned local_proc_rank = mesh.parallel_rank(); - const unsigned entity_rank_from = entity_from.entity_rank(); - - // Only induce parts for normal (not back) relations. Can only trust - // 'entity_from' to be accurate if it is owned by the local process. - if ( entity_rank_to < entity_rank_from && - local_proc_rank == entity_from.owner_rank() ) { - const PartVector & all_parts = mesh.mesh_meta_data().get_parts(); - - const std::pair - bucket_superset_ordinals = bucket_from.superset_part_ordinals(); - - OrdinalVector::const_iterator omit_begin = omit.begin(), - omit_end = omit.end(); - - // Contributions of the 'from' entity: - for ( const unsigned * i = bucket_superset_ordinals.first ; - i != bucket_superset_ordinals.second ; ++i ) { - ThrowAssertMsg( *i < all_parts.size(), "Index " << *i << " out of bounds" ); - Part & part = * all_parts[*i] ; - - if ( part.primary_entity_rank() == entity_rank_from && ! contains_ordinal( omit_begin, omit_end , *i )) { - induced_part_membership( part, - entity_rank_from , - entity_rank_to , - relation_identifier , - induced_parts, - include_supersets); - } - } - } -} - -//---------------------------------------------------------------------- - -void induced_part_membership( const Entity & entity , - const OrdinalVector & omit , - OrdinalVector & induced_parts, - bool include_supersets) -{ - for ( PairIterRelation - rel = entity.relations() ; ! rel.empty() ; ++rel ) { - - induced_part_membership( * rel->entity() , omit , - entity.entity_rank() , - rel->identifier() , - induced_parts, - include_supersets); - } -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.dox b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.dox deleted file mode 100644 index 6cbcbd9cf0ab..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.dox +++ /dev/null @@ -1,128 +0,0 @@ -namespace stk_classic { -namespace mesh { -} -} - -/** \addtogroup stk_mesh_relations - * - * \section entity_relation Entity Relation - * - * An \ref stk_classic::mesh::Relation "entity relation" - * defines a directed relationship between two - * \ref stk_classic::mesh::Entity "entities" eA and eB. - * This relationship is directed from the higher ranking - * entity to the lower ranking entity. - * \code - * if ( eA.entity_type() > eB.entity_type() ) { - * // relationship is from eA to eB - * } - * \endcode - * - * Each \ref stk_classic::mesh::Relation "relationship" has two attributes: - * - a local identifier for the relation. - * - the kind of relation and - * - * The identifier is local to the from - * entity of the relationship. For example, a relationship - * from an element entity to a node entity is given local identifier - * according to the element topology's local numbering system - * for nodes. - * - * The kind attribute support and application-defined taxonomy - * of relationships. For example, - * - kind == 0 : simple topological connectivity relationships, - * - kind == 1 : constraint relationships, or - * - kind == 2 : proximity relationships for contact tracking, - * - * - * \section Querying Relations - * - * Each \ref stk_classic::mesh::Entity "entity" has a set of - * \ref stk_classic::mesh::Relation "relations" for which that - * entity is a member. - * Relations for which the entity is a from members - * or a to member are included. - * - * - * \section entity_relation_stencil Relation Stencil - * - * An \ref stk_classic::mesh::relation_stencil_ptr "entity relation stencil" - * is a mapping of a relation type to an integer value. - * \code - * i = stencil( from_entity_type , to_entity_type , identifer , kind ); - * \endcode - * If the returned integer value is non-negative then a relation - * of this type is in the domain of the map. Otherwise it is not. - * - * An \ref stk_classic::mesh::relation_stencil_ptr "entity relation stencil" - * is used to induce - * \ref stk_classic::mesh::Entity "entity" membership in - * \ref stk_classic::mesh::Part "parts" and to induce - * \ref stk_mesh_field_data "field data" pointer values from - * \ref stk_classic::mesh::Relation "entity relations". - * - * - * \section Induced Part Membership - * - * An \ref stk_classic::mesh::Entity "entity" is becomes a member of a - * \ref stk_classic::mesh::Part "mesh part" explicility via the - * \ref stk_classic::mesh::BulkData "mesh bulk data" - * \ref stk_classic::mesh::BulkData::change_entity_part "change entity parts" - * method, and when it membership is induced - * by its relationships. - * - * Induced membership occurs as per the following simple type-based rule. - * - If entity_from is a explicitly a member of part, and - * - if entity_from.entity_type() == part.primary_entity_type(), and - * - if a relation exists from entity_from to entity_to - * - then entity_to is induced to be a member of part. - * - * Induced membership may also occur as per the following stencil-based rule. - * - Let ( part_from , stencil , part_to ) be a - * \ref stk_classic::mesh::PartRelation "part relation". - * - Let ( entity_from , relation , entity_to ) be an - * \ref stk_classic::mesh::Relation "entity relation". - * - If entity_from is a explicitly a member of part_from, - * and - * - if 0 <= stencil( entity_from.entity_type() , entity_to.entity_type() , - * relation.identifier() , relation.kind() ) - * - then entity_to is a member of part_to. - * - * The negation holds for both of these induced membership rules: - * - In the type-based rule the entity_to cannot be a member - * of part unless the conditions of the type-based rule - * are satisfied. - * - In the stencil-based rule the entity_to cannot be a member - * of part_to unless the conditions of the stencil-based rule - * are satisfied. - * - * - * \section Induced Field Relations - * - * A \ref stk_classic::mesh::FieldRelation "field relation" is used to induce - * \ref stk_mesh_field_data "field data" relationships between related - * mesh entities. - * - * If the following field relation conditions are satisfied - * - Let field_from be a pointer-valued field to the - * scalar data type of the field_to non-pointer valued field. - * - Let ( field_from , stencil , field_to ) be a - * \ref stk_classic::mesh::FieldRelation "field relation". - * - Let ( entity_from , relation , entity_to ) be an - * \ref stk_classic::mesh::Relation "entity relation". - * - If entity_from has field data for field_from, and - * if entity_to has field data for field_to, and - * - index = stencil( entity_from.entity_type() , entity_to.entity_type() , - * relation.identifier() , relation.kind() ), and - * - if 0 <= index < n where n is the length - * of the field data on entity_from - * - then following field data relationship is maintained. - * \code - * field_data( field_from , entity_from )[ index ] = - * field_data( field_to , entity_to ) - * \endcode - * - * Note that the non-negative values of the stencil map must - * be unique over the domain of the stencil. - */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.hpp deleted file mode 100644 index a84b1afc460c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Relation.hpp +++ /dev/null @@ -1,387 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_Relation_hpp -#define stk_mesh_Relation_hpp - -#include -#include - -#include - -#include - -#ifdef SIERRA_MIGRATION - -namespace stk_classic { -namespace mesh { -class Entity; -} -} -#endif - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_module - * \{ - */ -//---------------------------------------------------------------------- -/** \brief A relation between two mesh entities with a - * relation identifier and kind . - * - * Each entity owns a collection of relations to other entities. - * Each of these relations has a referenced entity, direction, - * relation identifier, and kind. - * - The direction specifies whether the relation is from the - * entity owning the relation to the referenced entity or - * conversely from the referenced entity to the owning entity. - * - The identifier provides a local numbering convention for relations, - * for example the local numbering convention for the nodes of an element. - * - Relations can be given a kind raw_relation_id to differentiate - * between topological relations (kind = 0) and other kinds of - * relationships such as constraints. - * - * Relations are ordered by their - * - kind of relation, - * - type of the referenced entity, - * - if the relation is forward or converse, - * - local relation identifier, and then - * - referenced entity's identifier. - */ -class Relation { -public: - typedef uint32_t raw_relation_id_type ; - typedef uint32_t attribute_type; - - /** \brief Constructor */ - Relation(); - - /** \brief Construct a relation from a referenced entity and local identifier - */ - Relation( Entity & entity , RelationIdentifier identifier ); - - attribute_type attribute() const { return m_attribute; } - void set_attribute(attribute_type attr) const { m_attribute = attr; } - - /** \brief The encoded relation raw_relation_id */ - static raw_relation_id_type raw_relation_id( unsigned rank , unsigned id ); - - /** \brief The encoded relation raw_relation_id */ - raw_relation_id_type raw_relation_id() const { return m_raw_relation.value ; } - - /** \brief The rank of the referenced entity */ - unsigned entity_rank() const ; - - /** \brief The local relation identifier */ - RelationIdentifier identifier() const ; - - /** \brief The referenced entity */ - Entity * entity() const { return m_target_entity ; } - - /** \brief Equality operator */ - bool operator == ( const Relation & r ) const; - - /** \brief Inequality operator */ - bool operator != ( const Relation & r ) const - { return !(*this == r); } - - /** \brief Ordering operator */ - bool operator < ( const Relation & r ) const ; - -private: - - - enum { - rank_digits = 8 , - id_digits = 24 , - id_mask = ~(0u) >> rank_digits -#ifdef SIERRA_MIGRATION - , - fwmk_relation_type_digits = 8, - fmwk_orientation_digits = 24, - fmwk_orientation_mask = ~(0u) >> fwmk_relation_type_digits -#endif - }; - - BOOST_STATIC_ASSERT(( static_cast(EntityKey::rank_digits) == static_cast(rank_digits) )); - - union RawRelationType { - public: - raw_relation_id_type value ; - - struct { - raw_relation_id_type identifier : id_digits ; - raw_relation_id_type entity_rank : rank_digits ; - } normal_view ; - - struct { - raw_relation_id_type entity_rank : rank_digits ; - raw_relation_id_type identifier : id_digits ; - } reverse_view ; - - RawRelationType( raw_relation_id_type v ) : value(v) {} - RawRelationType() : value(0) {} - RawRelationType( const RawRelationType & rhs ) : value( rhs.value ) {} - RawRelationType & operator = ( const RawRelationType & rhs ) - { value = rhs.value ; return *this ; } - }; - - RawRelationType m_raw_relation ; - mutable attribute_type m_attribute ; - Entity * m_target_entity ; - -// Issue: Framework supports relation types (parent, child, etc) that STK_Mesh -// does not support, so these relations will have to be managed by framework -// until: -// A) STK_Mesh is rewritten to support these extra relation types -// B) An extra data-structure is added to manage these relation types and -// this data structure works together with STK_mesh under the generic API -// to manage all relation-types. -// C) We transition to using a mesh that supports everything framework -// supports and this problem goes away. -// -// The problem is that, with framework managing some relations and STK_Mesh -// managing others, the type of the relation descriptor is different depending -// on what type of relation you're dealing with. This can be addressed with -// templates, but this makes the code very ugly. Instead... -// -// Solution: Have framework and STK_Mesh use the same type as its relation_descriptor. -// The code below is designed to make this class compatible with the fmwk -// Relation class. -#ifdef SIERRA_MIGRATION - public: - /** - * Predefined identifiers for mesh object relationship types. - */ - enum RelationType { - USES = 0 , - USED_BY = 1 , - CHILD = 2 , - PARENT = 3 , - EMBEDDED = 0x00ff , // 4 - CONTACT = 0x00ff , // 5 - AUXILIARY = 0x00ff , - INVALID = 10 - }; - - enum { - POLARITY_MASK = 0x80, - POLARITY_POSITIVE = 0x80, - POLARITY_NEGATIVE = 0x00, - POLARITY_IDENTITY = 0x80 - }; - - static bool polarity(unsigned orient) { - return (orient & POLARITY_MASK) == POLARITY_POSITIVE; - } - - static unsigned permutation(unsigned orient) { - return orient & ~POLARITY_MASK; - } - - /** - * Construct filled-out relation, fmwk-style - */ - Relation(Entity *obj, const unsigned relation_type, const unsigned ordinal, const unsigned orient = 0); - - Entity *getMeshObj() const { - return entity(); - } - - void setMeshObj(Entity *object); - - RelationType getRelationType() const { - return static_cast(attribute() >> fmwk_orientation_digits); - } - - void setRelationType(RelationType relation_type) { - set_attribute( (relation_type << fmwk_orientation_digits) | getOrientation() ); - } - - RelationIdentifier getOrdinal() const { - return identifier(); - } - - void setOrdinal(RelationIdentifier ordinal) { - m_raw_relation = Relation::raw_relation_id( entity_rank(), ordinal ); - } - - attribute_type getOrientation() const { - return attribute() & fmwk_orientation_mask; - } - - void setOrientation(attribute_type orientation) { - set_attribute( (getRelationType() << fmwk_orientation_digits) | orientation ); - } - - /** - * Query polarity of the related mesh object. - * A 'true' polarity indicates that the related mesh object is aligned. - * For element-edge or face-edge a 'true' polarity indicates that the - * nodes of the edge are compatibly ordered with the nodes of the - * element or faces. - * For element-face a 'true' polarity indicates that the ordering - * of face-nodes is compatible with the ordering of element nodes, - * i.e. the face's normal defined by a clockwise ordering is outward. - */ - bool polarity() const { - return (getOrientation() & POLARITY_MASK) == POLARITY_POSITIVE; - } - - unsigned permutation() const { - return getOrientation() & ~POLARITY_MASK; - } - -private: - bool has_fmwk_state() const { return getRelationType() != INVALID; } -#endif // SIERRA_MIGRATION -}; - -//---------------------------------------------------------------------- - -inline -Relation::raw_relation_id_type -Relation::raw_relation_id( unsigned rank , unsigned id ) -{ - ThrowAssertMsg( id <= id_mask, - "For args rank " << rank << ", id " << id << ": " << - "id " << " > id_mask=" << id_mask ); - - return ( raw_relation_id_type(rank) << id_digits ) | id ; -} - -inline -unsigned Relation::entity_rank() const -{ return m_raw_relation.value >> id_digits; } - -inline -RelationIdentifier Relation::identifier() const -{ return unsigned( m_raw_relation.value & id_mask ); } - -struct LessRelation { - bool operator() ( const Relation & lhs , const Relation & rhs ) const - { return lhs < rhs ; } - - bool operator() ( const Relation & lhs , Relation::raw_relation_id_type rhs ) const - { return lhs.raw_relation_id() < rhs ; } -}; - -//---------------------------------------------------------------------- -/** \brief Query which mesh entities have a relation - * to all of the input mesh entities. - */ -void get_entities_through_relations( - const std::vector & entities , - std::vector & entities_related ); - -/** \brief Query which mesh entities have a relation - * to all of the input mesh entities of the given - * mesh rank. - */ -void get_entities_through_relations( - const std::vector & entities , - EntityRank entities_related_rank , - std::vector & entities_related ); - -//---------------------------------------------------------------------- -/** \brief Query if a member entity of the given entity type - * has an induced membership. - */ -bool membership_is_induced( const Part & part , unsigned entity_rank ); - -/** \brief Induce entities' part membership based upon relationships - * between entities. Insert the result into 'induced_parts'. - */ -void induced_part_membership( Part & part , - unsigned entity_rank_from , - unsigned entity_rank_to , - RelationIdentifier relation_identifier , - OrdinalVector & induced_parts, - bool include_supersets=true); - -/** \brief Induce entities' part membership based upon relationships - * between entities. Do not include and parts in the 'omit' list. - */ -void induced_part_membership( const Entity & entity_from , - const OrdinalVector & omit , - unsigned entity_rank_to , - RelationIdentifier relation_identifier , - OrdinalVector & induced_parts, - bool include_supersets=true); - -/** \brief Induce an entity's part membership based upon relationships - * from other entities. Do not include and parts in the 'omit' list. - */ -void induced_part_membership( const Entity & entity , - const OrdinalVector & omit , - OrdinalVector & induced_parts, - bool include_supersets=true); - - -//---------------------------------------------------------------------- - -#if 0 -/** \brief Decode and print the relation raw_relation_id */ -std::ostream & -print_relation( std::ostream & , Relation::raw__attr_type ); - -/** \brief Decode and print the relation raw_relation_id and referenced entity key */ -std::ostream & -print_relation( std::ostream & , const MetaData & , - Relation::raw__attr_type , EntityKey ); -#endif - -/** \brief Print the relation raw_relation_ids and referenced entity's key */ -std::ostream & operator << ( std::ostream & , const Relation & ); - -/** \} */ - -inline -Relation::Relation() : - m_raw_relation(), - m_attribute(), - m_target_entity(NULL) -{ -#ifdef SIERRA_MIGRATION - setRelationType(INVALID); -#endif -} - -inline -bool Relation::operator == ( const Relation & rhs ) const -{ - return m_raw_relation.value == rhs.m_raw_relation.value && m_target_entity == rhs.m_target_entity -#ifdef SIERRA_MIGRATION - // compared fmwk state too - && m_attribute == rhs.m_attribute -#endif - ; -} - -inline -bool same_specification(const Relation& lhs, const Relation& rhs) -{ -#ifdef SIERRA_MIGRATION - return lhs.entity_rank() == rhs.entity_rank() && - lhs.getRelationType() == rhs.getRelationType() && - lhs.getOrdinal() == rhs.getOrdinal(); -#else - return lhs.entity_rank() == rhs.entity_rank(); -#endif -} - -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif /* stk_mesh_Relation_hpp */ - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Selector.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Selector.cpp deleted file mode 100644 index 6049ea16d929..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Selector.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -Selector::Selector( ) - : m_mesh_meta_data(0), m_op() -{ - compoundAll(); -} - - -Selector::Selector( const Part & p ) - : m_mesh_meta_data( & MetaData::get(p) ) , m_op() -{ - m_op.push_back( OpType( p.mesh_meta_data_ordinal() , 0 , 0 ) ); -} - -void Selector::compoundAll() -{ - m_op.insert( m_op.begin(), OpType( 0, 0, m_op.size()+1 ) ); -} - - -Selector & Selector::complement() -{ - bool singlePart = (m_op.size() == 1); - bool fullCompoundPart = (m_op[0].m_count == m_op.size()); - - if ( !(singlePart || fullCompoundPart) ) { - // Turn into a compound - compoundAll(); - } - // Flip the bit - m_op[0].m_unary ^= 1; - return *this; -} - -bool Selector::operator()( const Part & part ) const -{ - unsigned part_ord = part.mesh_meta_data_ordinal(); - std::pair part_ords(&part_ord, &part_ord+1); - return apply(part_ords, PartOrdLess()); -} - -bool Selector::operator()( const Bucket & candidate ) const -{ return apply( m_op.begin() , m_op.end() , candidate.superset_part_ordinals(), PartOrdLess() ); } - -bool Selector::operator()( const Bucket * candidate ) const{ - return operator()(*candidate); -} - -bool Selector::operator()( const Entity & candidate ) const -{ - const Bucket & b = candidate.bucket(); - return this->operator()(b); -} - -Selector & Selector::operator &= ( const Selector & B ) -{ - if (m_mesh_meta_data == 0) { - m_mesh_meta_data = B.m_mesh_meta_data; - } - - m_op.insert( m_op.end() , B.m_op.begin() , B.m_op.end() ); - return *this; -} - - -Selector & Selector::operator |= ( const Selector & B ) -{ - if (m_mesh_meta_data == 0) { - m_mesh_meta_data = B.m_mesh_meta_data; - } - - Selector notB = B; notB.complement(); - - const size_t original_size = m_op.size(); - - if ( 1 == original_size && - m_op.front().m_count == 1 && - m_op.front().m_unary == 0 ) { - // this == empty ; therefore, - // this UNION B == B - m_op = B.m_op ; - } - else if ( m_op.front().m_count == original_size && - m_op.front().m_unary != 0 ) { - // This is a full-compound complement. - // Simply add notB to the end and increase the size of the compound - - // this == ! A ; therefore, - // this UNION B == ! ( ! ( ! A ) & ! B ) - // this UNION B == ! ( A & ! B ) - - m_op.insert( - m_op.end(), - notB.m_op.begin(), - notB.m_op.end() ); - - m_op.front().m_count = m_op.size(); - } - else { - // this UNION B == ! ( ! this & ! B ) - - this->complement(); // ( ! (this) ) - - const unsigned finalSize = 1 + m_op.size() + notB.m_op.size(); - - m_op.insert( - m_op.end(), - notB.m_op.begin(), - notB.m_op.end() ); // ! ( ! (this) & !B ) - m_op.insert( - m_op.begin(), - OpType( 0 , 1 , finalSize ) ); // ! ( ! (this) & ? ) - } - - return *this; -} - -Selector operator & ( const Part & A , const Part & B ) -{ - Selector S( A ); - S &= Selector( B ); - return S; -} - - -Selector operator & ( const Part & A , const Selector & B ) -{ - Selector S( A ); - S &= B; - return S; -} - -Selector operator & ( const Selector & A, const Part & B ) -{ - Selector S( A ); - S &= Selector(B); - return S; -} - -Selector operator & ( const Selector & A, const Selector & B ) -{ - Selector S( A ); - S &= Selector(B); - return S; -} - -Selector operator | ( const Part & A , const Part & B ) -{ - Selector S( A ); - S |= Selector( B ); - return S; -} - - -Selector operator | ( const Part & A , const Selector & B ) -{ - Selector S( A ); - S |= B; - return S; -} - -Selector operator | ( const Selector & A, const Part & B ) -{ - Selector S( A ); - S |= Selector(B); - return S; -} - -Selector operator | ( const Selector & A, const Selector & B ) -{ - Selector S( A ); - S |= Selector(B); - return S; -} - - - - -Selector operator ! ( const Part & A ) -{ - Selector S(A); - return S.complement(); -} - - -std::ostream & operator<<( std::ostream & out, const Selector & selector) -{ - out << selector.printExpression(selector.m_op.begin(),selector.m_op.end()); - return out; -} - -std::string Selector::printExpression( - const std::vector::const_iterator start, - const std::vector::const_iterator finish - ) const -{ - std::ostringstream outS; - - std::vector::const_iterator start_it = start; - std::vector::const_iterator finish_it = finish; - - const OpType & op = *start_it; - if (op.m_count > 0) { // Compound - if (op.m_unary != 0) { // Complement - outS << "!"; - } - outS << "("; - if (op.m_count == 1) { - outS << ")"; - } - else { - finish_it = start_it; - for (int i=0 ; i < op.m_count ; ++i) { - ++finish_it; - } - ++start_it; - outS << printExpression(start_it,finish_it) << ")"; - start_it = finish_it; - --start_it; // back up one - } - } - else { // Part - if (m_mesh_meta_data != NULL) { - Part & part = m_mesh_meta_data->get_part(op.m_part_id); - if (op.m_unary != 0) { // Complement - outS << "!"; - } - outS << part.name(); - } - } - ++start_it; - if (start_it != finish) { - outS << " AND " << printExpression(start_it,finish); - } - return outS.str(); -} - - -Selector selectUnion( const PartVector& union_part_vector ) -{ - Selector selector; - if (union_part_vector.size() > 0) { - selector = *union_part_vector[0]; - for (unsigned i = 1 ; i < union_part_vector.size() ; ++i) { - selector |= *union_part_vector[i]; - } - } - return selector; -} - - -Selector selectIntersection( const PartVector& intersection_part_vector ) -{ - Selector selector; - if (intersection_part_vector.size() > 0) { - selector = *intersection_part_vector[0]; - for (unsigned i = 1 ; i < intersection_part_vector.size() ; ++i) { - selector &= *intersection_part_vector[i]; - } - } - return selector; -} - -Selector selectField( const FieldBase& field ) -{ - Selector selector; - const MetaData& meta = MetaData::get(field); - const FieldRestrictionVector& rvec = field.restrictions(); - - for(size_t i=0; i -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -//An operator to obtain a part-ordinal from a part-iterator. -//This general template handles cases where the part-iterator -//iterates either stk_classic::mesh::Part or Fmwk::MeshPart objects. -//Specializations for part-ordinal-pointers follow below. -template -struct GetPartIterOrdinal { -unsigned operator()(PartIterator p_it) const -{ return (*p_it)->mesh_meta_data_ordinal(); } -}; - -template<> -struct GetPartIterOrdinal { -unsigned operator()(const unsigned* p_it) const -{ return *p_it; } -}; - -template<> -struct GetPartIterOrdinal { -unsigned operator()(unsigned* p_it) const -{ return *p_it; } -}; - - -struct PartOrdLess { - -bool operator()(unsigned lhs, unsigned rhs) const -{ return lhs < rhs; } - -}; - -//Function to determine whether a specified part-ordinal is present -//in a given range of parts. -//Caller-provided comparison-operator compares a part-ordinal with -//one obtained from whatever a PartIterator dereferences to. -template -bool part_is_present(unsigned part_ord, - const std::pair& part_range, - Compare comp) -{ - GetPartIterOrdinal get_part_ordinal; - - // Search for 'part_ord' in the bucket's list of sorted integer part ords - PartIterator p_it = std::lower_bound(part_range.first, part_range.second, part_ord, comp); - return (p_it != part_range.second && get_part_ordinal(p_it) == part_ord); -} - -enum Op{ - INVALID = 0, - COMPOUND = 1, - PART_ID = 2 - }; - -struct OpType { - unsigned m_part_id ; ///< Id of part under consideration - unsigned short m_unary ; ///< Unary NOT operator: m_unary ^ expression - unsigned short m_count ; ///< Compound statement length - Op m_op ; ///< Does the OpType reference a part - - OpType() : m_part_id(0), m_unary(0), m_count(0), m_op(INVALID) {} - OpType( unsigned part_id , unsigned unary , unsigned count, Op op=INVALID ) - : m_part_id( part_id ), m_unary( unary ), m_count( count ), m_op(op) {} - - bool operator == (const OpType & opType ) const - { - return m_part_id == opType.m_part_id && - m_unary == opType.m_unary && - m_count == opType.m_count && - m_op == opType.m_op; - } - bool operator != (const OpType & opType ) const - { return !(*this == opType); } -}; - -/** \addtogroup stk_mesh_module - * \{ - */ - -/** \brief This is a class for selecting \ref stk_classic::mesh::Bucket "buckets" based on a set of - * \ref stk_classic::mesh::Part "meshparts" and set logic. - * - * The selector allows complements, unions and intersections. All of - * this logic is converted to NAND, meaning nots and AND logic. Each - * operation is placed on a stack of operands where each operand is - * either a left parenthesis with a number of operands included in the - * compound object, or an actual meshpart. All operands have a unary - * bit used to complement the operand. - * - * Please see the \ref stk_mesh_selector_unit "unit testing" for additional documentation. - * - * **/ - -class Selector { -public: - /** \brief A default Selector selects nothing */ - Selector(); - - bool operator == (const Selector & rhs) const - { return m_op == rhs.m_op; } - - bool operator != (const Selector & rhs) const - { return m_op != rhs.m_op; } - - /** \brief A part that is required */ - Selector( const Part & part); - - /** \brief Intersection: this = this INTERSECT ( expression ) */ - Selector & operator &= ( const Selector & selector); - - /** \brief Union: this = this UNION ( expression ) */ - Selector & operator |= ( const Selector & selector); - - /** \brief Complement: this = !(this) - * Postcondition: this is a compound expression - * */ - Selector & complement(); - - /** \brief Complement: return !(this) */ - Selector operator ! () const - { Selector S( *this ); return S.complement(); } - - /** \brief Is this part a member of the - * set defined by the selector expression. - */ - bool operator()( const Part & part ) const; - - /** \brief Is this bucket a subset of the - * set defined by the selector expression. - */ - bool operator()( const Bucket & candidate ) const; - - /** \brief Is this bucket a subset of the - * set defined by the selector expression. - */ - bool operator()( const Bucket * candidate ) const; - - /** \brief Is this entity a member of the - * set defined by the selector expression. - */ - bool operator()( const Entity & candidate ) const; - - /** \brief Is the intersection of the 'part_ords' parts a member - * of the set defined by the selector expression. - */ - template - bool apply(const std::pair& part_range, Compare comp) const - { return apply(m_op.begin(), m_op.end(), part_range, comp); } - - /** \brief Pretty print the set-expression with part names */ -#ifndef SWIG - friend std::ostream & operator << ( std::ostream & out, const Selector & selector); -#endif - - const std::vector& get_ops() const { return m_op; } - void set_ops(const std::vector& ops) { m_op = ops; } - - /** \brief Turn the entire expression into a compound */ - void compoundAll(); - -private: - - /** \brief . */ - const MetaData * m_mesh_meta_data ; - - /** \brief . */ - std::vector< OpType > m_op ; - - /** \brief . */ - void verify_compatible( const Selector & B ) const; - - /** \brief . */ - void verify_compatible( const Bucket & B ) const; - - /** \brief . */ - template - bool apply( - std::vector::const_iterator i, - std::vector::const_iterator j, - const std::pair& part_range, - Compare comp) const - { - bool result = i != j ; - while ( result && i != j ) { - const unsigned statement_length = i->m_count; - if ( statement_length > 0 ) { // Check if compound statement - result = i->m_unary ^ apply( i + 1 , i + statement_length , part_range , comp ); - i += statement_length; - } - else { // Test for containment of bucket in this part, or not in - result = i->m_unary ^ part_is_present( i->m_part_id , part_range , comp ); - ++i ; - } - } - return result ; - } - - /** \brief Pretty print the expression */ - std::string printExpression( - const std::vector::const_iterator start, - const std::vector::const_iterator finish - ) const; - -}; - -class Part; - -#ifndef SWIG -std::ostream & operator<<( std::ostream & out, const Selector & selector); -#endif - -/** \brief . - * \relates Selector - * */ -Selector operator & ( const Part & A , const Part & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator & ( const Part & A , const Selector & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator & ( const Selector & A, const Part & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator & ( const Selector & A, const Selector & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator | ( const Part & A , const Part & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator | ( const Part & A , const Selector & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator | ( const Selector & A, const Part & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator | ( const Selector & A , const Selector & B ); - -/** \brief . - * \relates Selector - * */ -Selector operator ! ( const Part & A ); - - -/** \brief . - * \relates Selector - * */ -Selector selectUnion( const PartVector& union_part_vector ); - -/** \brief . - * \relates Selector - * */ -Selector selectIntersection( const PartVector& intersection_part_vector ); - -/** \brief Return a selector for the union of the parts where field exists. - * \relates Selector - * */ -Selector selectField( const FieldBase& field ); - -/** \} */ - -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_Selector_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/SetOwners.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/SetOwners.hpp deleted file mode 100644 index 0b04c23fb66b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/SetOwners.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_SetOwners_hpp -#define stk_mesh_SetOwners_hpp - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -typedef std::less LowestRankSharingProcOwns; -typedef std::greater HighestRankSharingProcOwns; - -/** Sets the owner for shared entities according to the template parameter OwnershipRule. - * OwnershipRule is used as a the comparison operator in a std::set. - * The default behavior of stk_classic::mesh is to give ownership to the highest-rank sharing proc. -*/ -template -void set_owners(BulkData& mesh_bulk_data) -{ - typedef std::set ProcSet ; - - const unsigned local_proc = mesh_bulk_data.parallel_rank(); - - std::vector entity_new_owners; - - const std::vector& entity_comm = mesh_bulk_data.entity_comm(); - - for ( size_t i=0; isharing(); - - if ( ! sharing.empty() && entity->owner_rank() == local_proc ) { - ProcSet proc_set ; - - proc_set.insert( local_proc ); - - for ( size_t j = 0 ; j < sharing.size() ; ++j ) { - proc_set.insert( sharing[j].proc ); - } - - const unsigned new_owner_proc = *proc_set.begin(); - - entity_new_owners.push_back(std::make_pair( entity, new_owner_proc ) ); - } - } - - mesh_bulk_data.modification_begin(); - - mesh_bulk_data.change_entity_owner( entity_new_owners ); - - mesh_bulk_data.modification_end(); -} - -}//namespace mesh -}//namespace stk_classic - -#endif // stk_mesh_SetOwner_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.cpp deleted file mode 100644 index 85948606d1d8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { - -//We used to store a static vector 'watch_vector', but its -//contents (pointers) didn't get deleted which resulted in -//memory leaks. -//Instead, we now wrap the watch_vector in this 'WatchVectorHolder' -//struct, which has a destructor which cleans up the contents -//of watch_vector. This eliminates the memory leaks. -struct WatchVectorHolder { - WatchVectorHolder() : watch_vector() {} - ~WatchVectorHolder() - { - for(std::vector::iterator it=watch_vector.begin(); - it!=watch_vector.end(); ++it) { - delete *it; - } - } - - std::vector watch_vector; -}; - -std::vector& watch_vector() -{ - static WatchVectorHolder watch_vector_holder; - return watch_vector_holder.watch_vector; -} - -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.hpp deleted file mode 100644 index 6220249b7fb3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Trace.hpp +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef stk_mesh_Trace_hpp -#define stk_mesh_Trace_hpp - -/////////////////////////////////////////////////////////////////////////////// -// Macros/functions for tracing. This file contains the "layer" between -// stk_mesh and the stk-util tracing interface; this layer is necessary because -// one of our goal is to ensure that all tracing code will be compiled-out -// unless tracing is enabled. We also wanted to support the ability to watch -// certain objects/values while tracing and this capability is not supported -// natively in the stk_util interface. -// -// No tracing will occur unless STK_MESH_TRACE_ENABLED is defined. You rebuild -// with tracing with: 'bake -c ; bake cxxflags=-DSTK_MESH_TRACE_ENABLED' -// You'll need to be sure you link with stk_util/use_cases. -// -// If a macro is setting up your main function, be sure to use STKUNIT_WITH_TRACING_MAIN. -// If you're setting up the main function yourself, be sure to set up the -// environment with UseCaseEnvironment. -// -// You'll probably want to add the "--pout" argument so that each processor -// produces it's own trace file. -// -// (Diag|Trace)If will produce diag/trace output if the given PrintMask is -// activated. -// -// (Diag|Trace)IfWatching will produce diag/trace output if the given key is in -// the watch list AND the given PrintMask is activated. -// -// A common pattern for code that wants tracing (put this code somewhere before -// the code you want to trace). -// stk_classic::mesh::setStream(use_case::dwout()); -// meshlog.setPrintMask(stk_classic::mesh::LOG_ENTITY | stk_classic::mesh::LOG_TRACE | stk_classic::mesh::LOG_TRACE_SUB_CALLS); -// stk_classic::mesh::watch(stk_classic::mesh::EntityKey(0, 11)); // Node 11 -// stk_classic::diag::Trace::addTraceFunction("stk_classic::mesh::"); -// -// Other common items to watch are Parts, Buckets, and Fields -// -// For unit-testing, all trace-related libraries should be header-only so that -// we can define STK_MESH_TRACE_ENABLED and #include the necessary headers and -// be able to trace. -// -// TODO -// * Describe the tracing/diagnostic command-line interface -// * Describe the PrintMask system. -// * Command-line interface to key watching system? -// * Would like to see a "watch-all" operation based on type -// * What if the id's of two different types of objects are the same? -// * Would be nice if Trace("func") supported printing of arg values too -// * Would be nice to have some automated way of checking that the method names -// are up to date. -/////////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -////////////////////// INTERNAL //////////////////// - -class Watch -{ - public: - virtual ~Watch() {} - virtual const std::type_info& type() const = 0; - virtual bool match(const void* item_) const = 0; - virtual void* item() = 0; -}; - -std::vector& watch_vector(); - -template -bool internal_is_watching(const T& item) -{ - for (std::vector::const_iterator - itr = watch_vector().begin(); itr != watch_vector().end(); ++itr) { - if ((*itr)->type() == typeid(T) && - (*itr)->match(&item)) { - return true; - } - } - return false; -} - -template -class WatchClass : public Watch -{ - public: - WatchClass(const T& watch_item) : m_watch_item(watch_item), - m_type_info(&typeid(T)) { - watch_vector().push_back(this); - } - - virtual const std::type_info& type() const { return *m_type_info; } - - virtual bool match(const void* item_) const { - return *(static_cast(item_)) == m_watch_item; - } - - virtual void* item() { return &m_watch_item; } - - private: - T m_watch_item; - const std::type_info* m_type_info; -}; - -/////////////////// API ///////////////////////// - -template -void watch(const T& watch_item) -{ - // leaks, but who cares - new WatchClass(watch_item); -} - -#ifdef STK_MESH_TRACE_ENABLED - -inline void setStream(std::ostream& stream) -{ - initDiagWriter(stream); -} - -#define Trace_(location) stk_classic::mesh::Trace trace__(location) - -#define TraceIf(location, mask) stk_classic::mesh::Trace trace__(location, mask) - -#define TraceIfWatching(location, mask, item) \ -stk_classic::mesh::Trace trace__(location, mask, stk_classic::mesh::internal_is_watching(item)); \ -DiagIfWatching(mask, item, "Watched item is: " << item << stk_classic::diag::dendl) - -// Useful if you need two traces in the same scope, dec is used to modify the -// name of the trace object to avoid conflicting. -#define TraceIfWatchingDec(location, mask, item, dec) \ -stk_classic::mesh::Trace trace##dec__(location, mask, stk_classic::mesh::internal_is_watching(item)); \ -DiagIfWatching(mask, item, "Watched item is: " << item << stk_classic::diag::dendl) - -#define DiagIfWatching(mask, item, message) \ -meshlog.w(stk_classic::mesh::internal_is_watching(item), mask) << message << stk_classic::diag::dendl - -#define DiagIf(mask, message) \ -meshlog.m(mask) << message << stk_classic::diag::dendl - -///////////////////////////////////////////////// - -#else - -inline void setStream(std::ostream& stream) { } - -#define Trace_(location) ((void) (0)) -#define TraceIf(location, mask) ((void) (0)) -#define TraceIfWatching(location, mask, item) ((void) (0)) -#define TraceIfWatchingDec(location, mask, item, dec) ((void) (0)) -#define DiagIf(mask, message) ((void) (0)) -#define DiagIfWatching(mask, item, message) ((void) (0)) - -#endif - -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Types.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Types.hpp deleted file mode 100644 index b8999b1fce39..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/base/Types.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_Types_hpp -#define stk_mesh_Types_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_module - * \{ - */ - -class MetaData ; // Meta-data description of a mesh -class Part ; // Defined subset of the mesh - -/** \brief Collections of \ref stk_classic::mesh::Part "parts" are frequently - * maintained as a vector of Part pointers. - */ -typedef std::vector< Part * > PartVector ; -typedef std::vector< unsigned > OrdinalVector ; - -class FieldBase; - -template< typename Scalar = void , - class Tag1 = void , class Tag2 = void , - class Tag3 = void , class Tag4 = void , - class Tag5 = void , class Tag6 = void , - class Tag7 = void > - class Field ; - -/** \brief Maximum - * \ref shards::Array "multi-dimenaional array" dimension of a - * \ref stk_classic::mesh::Field "field" - */ -enum { MaximumFieldDimension = 7 }; - -template< typename DataType = void > class Property ; - -typedef Property< void > PropertyBase ; - -/** \} */ - -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_module - * \{ - */ - -class BulkData ; // Bulk-data of a mesh -class Bucket ; // Homogeneous collection of mesh entitities their field data -class Entity ; // Individual entity within the mesh -class Relation ; // Relation pair of local mesh entities -class Ghosting ; - -typedef std::vector BucketVector; -typedef std::vector EntityVector; - -/** Change log to reflect change from before 'modification_begin' - * to the current status. - */ -enum EntityModificationLog { EntityLogNoChange = 0 , - EntityLogCreated = 1 , - EntityLogModified = 2 , - EntityLogDeleted = 3 }; - -template< class FieldType > struct EntityArray ; -template< class FieldType > struct BucketArray ; -template< class FieldType > struct FieldTraits ; - - -typedef unsigned Ordinal; -static const Ordinal InvalidOrdinal = static_cast(-1); // std::numeric_limits::max(); -typedef Ordinal EntityRank ; -typedef Ordinal PartOrdinal; -typedef Ordinal FieldOrdinal; -typedef Ordinal RelationIdentifier; -typedef Ordinal FieldArrayRank; - -typedef uint64_t EntityId ; - -// Base Entity Rank -// Note: This BaseEntityRank can be considered the leaf of a tree and it -// represents the furthest out you can go in downward relations. -static const EntityRank BaseEntityRank = 0; -static const EntityRank InvalidEntityRank = InvalidOrdinal; -static const PartOrdinal InvalidPartOrdinal = InvalidOrdinal; -static const RelationIdentifier InvalidRelationIdentifier = InvalidOrdinal; - -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_bulk_data_parallel - * \{ - */ - -/** \brief Pairing of an entity with a processor rank */ -typedef std::pair EntityProc ; -typedef std::vector EntityProcVec ; - -/** \brief Spans of a vector of entity-processor pairs are common. - * - */ -typedef PairIter< std::vector< EntityProc >::const_iterator > - PairIterEntityProc ; -#ifndef SWIG - //NLM SWIG cannot handle this macro - -NAMED_PAIR( EntityCommInfo , unsigned , ghost_id , unsigned , proc ) - -/** \brief Span of ( communication-subset-ordinal , process-rank ) pairs - * for the communication of an entity. - */ -typedef PairIter< std::vector< EntityCommInfo >::const_iterator > - PairIterEntityComm ; - -typedef std::vector EntityCommInfoVector; -#endif -/** \} */ - -//---------------------------------------------------------------------- -/** \ingroup stk_mesh_relations - * \brief A relation stencil maps entity relationships to ordinals. - * - * A relation stencil function is the inverse mapping of a contiguous - * span of non-negative integers to a template of entity relations. - * For example, a triangle-to-vertex relation stencil would map: - * - 0 = relation_stencil( Element , Node , 0 ) - * - 1 = relation_stencil( Element , Node , 1 ) - * - 2 = relation_stencil( Element , Node , 2 ) - * - * If the input entity relationship is within the stencil then - * a stencil function returns a non-negative integer; - * otherwise a stencil function returns a negative value. - */ -typedef int ( * relation_stencil_ptr )( unsigned from_type , - unsigned to_type , - unsigned identifier ); - -//---------------------------------------------------------------------- -/** \brief Span of a sorted relations for a given domain entity. - * - * The span is sorted by - * -# range entity rank, - * -# relation identifier, and - * -# range entity global identifier. - */ -typedef std::vector RelationVector; -typedef PairIter< RelationVector::const_iterator > PairIterRelation ; - -//---------------------------------------------------------------------- - - -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.cpp deleted file mode 100644 index 35d0bcd16645..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -//---------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace impl { - -//---------------------------------------------------------------------- - -namespace { - -void memory_copy( unsigned char * dst , const unsigned char * src , unsigned n ) -{ std::memcpy( dst , src , n ); } - - -void memory_zero( unsigned char * dst , unsigned n ) -{ std::memset( dst , 0 , n ); } - -} // namespace - -//---------------------------------------------------------------------- - -void BucketImpl::update_state() -{ - const MetaData & meta = MetaData::get(m_mesh); - const std::vector & field_set = meta.get_fields(); - - for ( unsigned i = 0 ; i < field_set.size() ; ) { - - DataMap * const tmp = &m_field_map[0] + i ; - const FieldBase & field = * field_set[i] ; - const unsigned num_state = field.number_of_states(); - i += num_state ; - - if ( 1 < num_state && tmp->m_size ) { - unsigned offset[ MaximumFieldStates ] ; - - offset[0] = tmp[num_state-1].m_base; - for ( unsigned j = 1 ; j < num_state ; ++j ) { - offset[j] = tmp[j-1].m_base ; - } - - for ( unsigned j = 0 ; j < num_state ; ++j ) { - tmp[j].m_base = offset[j] ; - } - } - } -} - -//---------------------------------------------------------------------- -// Every bucket in the family points to the first bucket, -// except the first bucket which points to the last bucket. - -Bucket * BucketImpl::last_bucket_in_family() const -{ - Bucket * last = last_bucket_in_family_impl(); - - ThrowRequireMsg( NULL != last, "Last is NULL"); - ThrowRequireMsg( last->size() != 0, "Last bucket is empty"); - - return last ; -} - -Bucket * BucketImpl::last_bucket_in_family_impl() const -{ - bool this_is_first_bucket_in_family = (bucket_counter() == 0); - - Bucket * last = NULL; - - if (this_is_first_bucket_in_family) { - last = m_bucket; - } else { - last = m_bucket->m_bucketImpl.m_bucket; - } - - return last; -} - -//---------------------------------------------------------------------- - -Bucket * BucketImpl::first_bucket_in_family() const -{ - return last_bucket_in_family_impl()->m_bucketImpl.m_bucket; -} - -//---------------------------------------------------------------------- - -void BucketImpl::set_last_bucket_in_family( Bucket * last_bucket ) -{ - Bucket * last = last_bucket_in_family_impl(); - Bucket * first = last->m_bucketImpl.m_bucket; - first->m_bucketImpl.m_bucket = last_bucket; -} - -//---------------------------------------------------------------------- - -void BucketImpl::set_first_bucket_in_family( Bucket * first_bucket ) -{ - m_bucket = first_bucket; -} - -//---------------------------------------------------------------------- - -BucketImpl::DataMap * BucketImpl::get_field_map() -{ - return &m_field_map[0]; -} - -//---------------------------------------------------------------------- - -void BucketImpl::initialize_fields( unsigned i_dst ) -{ - const std::vector & field_set = - MetaData::get(m_mesh).get_fields(); - - unsigned char * const p = m_field_data; - const DataMap * i = &m_field_map[0]; - const DataMap * const e = i + field_set.size(); - - for (std::vector::const_iterator field_iter=field_set.begin() ; - i != e ; ++i, ++field_iter ) { - - if (i->m_size == 0) { - continue; - } - - const unsigned char* init_val = reinterpret_cast((*field_iter)->get_initial_value()); - if (init_val != NULL) { - memory_copy( p + i->m_base + i->m_size * i_dst , init_val, i->m_size ); - } - else { - memory_zero( p + i->m_base + i->m_size * i_dst , i->m_size ); - } - } -} - -void BucketImpl::replace_fields( unsigned i_dst , Bucket & k_src , unsigned i_src ) -{ - const std::vector & field_set = - MetaData::get(m_mesh).get_fields(); - - unsigned char * const s = k_src.m_bucketImpl.m_field_data; - unsigned char * const d = m_field_data; - const DataMap * j = &(k_src.m_bucketImpl.m_field_map[0]); - const DataMap * i = &m_field_map[0]; - const DataMap * const e = i + field_set.size(); - - for (std::vector::const_iterator field_iter=field_set.begin() ; - i != e ; ++i , ++j, ++field_iter ) { - - if ( i->m_size ) { - if ( j->m_size ) { - ThrowAssertMsg( i->m_size == j->m_size, - "Incompatible field sizes: " << i->m_size << " != " << j->m_size ); - - memory_copy( d + i->m_base + i->m_size * i_dst , - s + j->m_base + j->m_size * i_src , i->m_size ); - } - else { - const unsigned char* init_val = reinterpret_cast((*field_iter)->get_initial_value()); - if (init_val != NULL) { - memory_copy( d + i->m_base + i->m_size * i_dst , - init_val, i->m_size ); - } - else { - memory_zero( d + i->m_base + i->m_size * i_dst , i->m_size ); - } - } - } - } -} - -//---------------------------------------------------------------------- -namespace { -inline unsigned align( size_t nb ) -{ - enum { BYTE_ALIGN = 16 }; - const unsigned gap = nb % BYTE_ALIGN ; - if ( gap ) { nb += BYTE_ALIGN - gap ; } - return nb ; -} -}//namespace anonymous - -//---------------------------------------------------------------------- - -BucketImpl::BucketImpl( BulkData & arg_mesh, - EntityRank arg_entity_rank, - const std::vector & arg_key, - size_t arg_capacity - ) - : m_mesh(arg_mesh) - , m_entity_rank(arg_entity_rank) - , m_key(arg_key) - , m_capacity(arg_capacity) - , m_size(0) - , m_bucket(NULL) - , m_field_map( m_mesh.mesh_meta_data().get_fields().size()+1) - , m_entities(arg_capacity) - , m_field_data(NULL) - , m_field_data_end(NULL) -{ - //calculate the size of the field_data - - const std::vector< FieldBase * > & field_set = - arg_mesh.mesh_meta_data().get_fields(); - - const size_t num_fields = field_set.size(); - - size_t field_data_size = 0; - - if (arg_capacity != 0) { - for ( size_t i = 0; i 0 ) { // Exists - - const unsigned type_stride = field.data_traits().stride_of ; - const unsigned field_rank = field.rank(); - - num_bytes_per_entity = type_stride * - ( field_rank ? restriction.stride( field_rank - 1 ) : 1 ); - } - m_field_map[i].m_base = field_data_size ; - m_field_map[i].m_size = num_bytes_per_entity ; - m_field_map[i].m_stride = &restriction.stride(0); - - field_data_size += align( num_bytes_per_entity * m_capacity ); - } - - m_field_map[ num_fields ].m_base = field_data_size ; - m_field_map[ num_fields ].m_size = 0 ; - m_field_map[ num_fields ].m_stride = NULL ; - } - else { //nil bucket - - FieldBase::Restriction::size_type empty_stride[ MaximumFieldDimension ]; - Copy( empty_stride , FieldBase::Restriction::size_type(0) ); - - for ( size_t i = 0; i 0 ? new unsigned char[field_data_size] : NULL; - - // - //[TODO] ALAN, TODD: to investigate if memory_zero is necessary to fix valgrind - //issues in the following regression test: - //adagio_rtest/presto/super_elem_rigid_body/super_elem_rigid_body.test|np1_explicit_reverseMPC - //memory_zero(m_field_data, field_data_size); - //ABW UPDATE: found and fixed bug in strumento/src/element/SuperElementHandler.C - //which was reading past end of field, so this memory_zero is no longer - //necessary. 8/9/2012 - //std::memset( m_field_data , 0xfff , field_data_size ); - - m_field_data_end = m_field_data + field_data_size; -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.hpp deleted file mode 100644 index c4a5ca69dd56..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketImpl.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_BucketImpl_hpp -#define stk_mesh_BucketImpl_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include - -#include -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace impl { - -class BucketImpl { - public: - - struct DataMap { - typedef FieldBase::Restriction::size_type size_type ; - const size_type * m_stride ; - size_type m_base ; - size_type m_size ; - }; - - BucketImpl( BulkData & arg_mesh , - EntityRank arg_entity_rank, - const std::vector & arg_key, - size_t arg_capacity - ); - - // - // External interface: - // - BulkData & mesh() const { return m_mesh ; } - unsigned entity_rank() const { return m_entity_rank ; } - const unsigned * key() const { return &m_key[0] ; } - const std::vector & key_vector() const { return m_key; } - - std::pair - superset_part_ordinals() const - { - return std::pair - ( key() + 1 , key() + key()[0] ); - } - unsigned allocation_size() const { return 0 ; } - size_t capacity() const { return m_capacity ; } - size_t size() const { return m_size ; } - Entity & operator[] ( size_t i ) const { return *(m_entities[i]) ; } - unsigned field_data_size(const FieldBase & field) const - { - return m_field_map[ field.mesh_meta_data_ordinal() ].m_size; - } - const FieldBase::Restriction::size_type * field_data_stride( const FieldBase & field ) const - { - return m_field_map[ field.mesh_meta_data_ordinal() ].m_stride; - } - unsigned char * field_data_location( const FieldBase & field, const Entity & entity ) const - { - return field_data_location_impl( field.mesh_meta_data_ordinal(), entity.bucket_ordinal() ); - } - - /** Experimental method that skips the if-test for field existence on the bucket. - This method should only be called if the caller is sure that the field exists on the bucket. - */ - unsigned char * fast_field_data_location( const FieldBase & field, unsigned ordinal ) const - { - return fast_field_data_location_impl( field.mesh_meta_data_ordinal(), ordinal ); - } - unsigned char * field_data_location( const FieldBase & field, unsigned ordinal ) const - { - return field_data_location_impl( field.mesh_meta_data_ordinal(), ordinal ); - } - unsigned char * field_data_location( const FieldBase & field ) const - { - unsigned int zero_ordinal = 0; - return field_data_location_impl( field.mesh_meta_data_ordinal(), zero_ordinal ); - } - - // - // Internal interface: - // - void increment_size() { ++m_size ; } - void decrement_size() { --m_size ; } - void replace_entity(unsigned entity_ordinal, Entity * entity ) { m_entities[entity_ordinal] = entity ; } - void update_state(); - - template< class field_type > - typename FieldTraits< field_type >::data_type * - field_data( const field_type & f , const unsigned & entity_ordinal ) const - { - typedef typename FieldTraits< field_type >::data_type * data_p ; - return reinterpret_cast(field_data_location_impl(f.mesh_meta_data_ordinal(),entity_ordinal)); - } - - // BucketKey key = ( part-count , { part-ordinals } , counter ) - // key[ key[0] ] == counter - unsigned bucket_counter() const { return m_key[ m_key[0] ]; } - - Bucket * last_bucket_in_family() const; - Bucket * first_bucket_in_family() const; - void set_last_bucket_in_family( Bucket * last_bucket ); - void set_first_bucket_in_family( Bucket * first_bucket ); - DataMap * get_field_map(); - void initialize_fields( unsigned i_dst ); - void replace_fields( unsigned i_dst , Bucket & k_src , unsigned i_src ); - void set_bucket_family_pointer( Bucket * bucket ) { m_bucket = bucket; } - const Bucket * get_bucket_family_pointer() const { return m_bucket; } - - bool equivalent( const BucketImpl& other_bucket ) const { - return first_bucket_in_family() == other_bucket.first_bucket_in_family(); - } - - Entity*const* begin() const { return &m_entities[0]; } - Entity*const* end() const { return &m_entities[0] + m_size; } - - ~BucketImpl() { delete [] m_field_data; } - - private: - BucketImpl(); - - BulkData & m_mesh ; // Where this bucket resides - const EntityRank m_entity_rank ; // Type of entities for this bucket - std::vector m_key ; - const size_t m_capacity ; // Capacity for entities - size_t m_size ; // Number of entities - Bucket * m_bucket ; // Pointer to head of bucket family, but head points to tail - std::vector m_field_map ; // Field value data map, shared - std::vector m_entities ; // Array of entity pointers, - // beginning of field value memory. - unsigned char* m_field_data; - unsigned char* m_field_data_end; - - unsigned char * field_data_location_impl( const unsigned & field_ordinal, const unsigned & entity_ordinal ) const - { - const DataMap & data_map = m_field_map[ field_ordinal ]; - unsigned char * ptr = NULL; - if ( data_map.m_size ) { - ptr = const_cast(m_field_data) + data_map.m_base + data_map.m_size * entity_ordinal; - ThrowAssert(ptr < m_field_data_end); - } - return ptr ; - } - unsigned char * fast_field_data_location_impl( const unsigned & field_ordinal, const unsigned & entity_ordinal ) const - { - const DataMap & data_map = m_field_map[ field_ordinal ]; - ThrowAssertMsg(data_map.m_size>0,"Field doesn't exist on bucket."); - return const_cast(m_field_data) + data_map.m_base + data_map.m_size * entity_ordinal; - } - Bucket * last_bucket_in_family_impl() const; -}; - - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - - -#endif // stk_mesh_BucketImpl_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.cpp deleted file mode 100644 index 6c6c05233fa9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.cpp +++ /dev/null @@ -1,580 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -//---------------------------------------------------------------------- - - -BucketRepository::BucketRepository( - BulkData & mesh, - unsigned bucket_capacity, - unsigned entity_rank_count, - EntityRepository & entity_repo - ) - :m_mesh(mesh), - m_bucket_capacity(bucket_capacity), - m_buckets(entity_rank_count), - m_nil_bucket(NULL), - m_entity_repo(entity_repo) -{ -} - - -BucketRepository::~BucketRepository() -{ - // Destroy buckets, which were *not* allocated by the set. - - try { - for ( std::vector< std::vector >::iterator - i = m_buckets.end() ; i != m_buckets.begin() ; ) { - try { - std::vector & kset = *--i ; - - while ( ! kset.empty() ) { - try { destroy_bucket( kset.back() ); } catch(...) {} - kset.pop_back(); - } - kset.clear(); - } catch(...) {} - } - m_buckets.clear(); - } catch(...) {} - - try { if ( m_nil_bucket ) destroy_bucket( m_nil_bucket ); } catch(...) {} -} - - -//---------------------------------------------------------------------- -// The current 'last' bucket in a family is to be deleted. -// The previous 'last' bucket becomes the new 'last' bucket in the family. - -void BucketRepository::destroy_bucket( const unsigned & entity_rank , Bucket * bucket_to_be_deleted ) -{ - TraceIfWatching("stk_classic::mesh::impl::BucketRepository::destroy_bucket", LOG_BUCKET, bucket_to_be_deleted); - - ThrowRequireMsg(MetaData::get(m_mesh).check_rank(entity_rank), - "Entity rank " << entity_rank << " is invalid"); - - std::vector & bucket_set = m_buckets[entity_rank]; - - // Get the first bucket in the same family as the bucket being deleted - Bucket * const first = bucket_to_be_deleted->m_bucketImpl.first_bucket_in_family(); - - ThrowRequireMsg( bucket_to_be_deleted->equivalent(*first), "Logic error - bucket_to_be_deleted is not in same family as first_bucket_in_family"); - ThrowRequireMsg( first->equivalent(*bucket_to_be_deleted), "Logic error - first_bucket_in_family is not in same family as bucket_to_be_deleted"); - - ThrowRequireMsg( bucket_to_be_deleted->size() == 0, - "Destroying non-empty bucket " << *(bucket_to_be_deleted->key()) ); - - ThrowRequireMsg( bucket_to_be_deleted == first->m_bucketImpl.get_bucket_family_pointer(), - "Destroying bucket family") ; - - std::vector::iterator ik = lower_bound(bucket_set, bucket_to_be_deleted->key()); - ThrowRequireMsg( ik != bucket_set.end() && bucket_to_be_deleted == *ik, - "Bucket not found in bucket set for entity rank " << entity_rank ); - - ik = bucket_set.erase( ik ); - - if ( first != bucket_to_be_deleted ) { - - ThrowRequireMsg( ik != bucket_set.begin(), - "Where did first bucket go?" ); - - first->m_bucketImpl.set_last_bucket_in_family( *--ik ); - - ThrowRequireMsg ( first->m_bucketImpl.get_bucket_family_pointer()->size() != 0, - "TODO: Explain" ); - } - - destroy_bucket( bucket_to_be_deleted ); -} - -//---------------------------------------------------------------------- -void BucketRepository::destroy_bucket( Bucket * bucket ) -{ - TraceIfWatching("stk_classic::mesh::impl::BucketRepository::destroy_bucket", LOG_BUCKET, bucket); - - delete bucket; -} - -// -//---------------------------------------------------------------------- -// The input part ordinals are complete and contain all supersets. -void -BucketRepository::declare_nil_bucket() -{ - TraceIf("stk_classic::mesh::impl::BucketRepository::declare_nil_bucket", LOG_BUCKET); - - if (m_nil_bucket == NULL) { - // Key layout: - // { part_count + 1 , { part_ordinals } , family_count } - - std::vector new_key(2); - new_key[0] = 1 ; // part_count + 1 - new_key[1] = 0 ; // family_count - - Bucket * bucket = - new Bucket(m_mesh, InvalidEntityRank, new_key, 0); - - bucket->m_bucketImpl.set_bucket_family_pointer( bucket ); - - //---------------------------------- - - m_nil_bucket = bucket; - } -} - - -/** 11/9/10 Discussion between Kendall, Alan, Todd: - * Kendall is confused about why presto would run faster simply by removing - * several fields that are not even used. We considered this and posed the - * following possibility. The current bucket allocation system guarantees - * that all the fields for a bucket are layed out contiguously in memory so - * that they can be accessed in a fast cache-friendly manner. This also - * guarantees means that if a field is allocated but not used, it will still - * be chopped up and carried around in the bucket field data as part of the - * contiguous block of memory and that it will have to be skipped over as the - * computations progress over that block of data. This would result in cache - * misses and reduced performance. When they're removed, it makes sense that - * the performance might get better. - * - * This leads to the idea that maybe we should test this in a use-case or - * performance test case and that we should include this in the performance - * comparison of the up-and-coming pluggable data module for the Bucket memory - * allocation. - * - * It may be that a flat-array style data allocation for field data would - * eliminate this issue. - **/ - -//---------------------------------------------------------------------- -// The input part ordinals are complete and contain all supersets. -Bucket * -BucketRepository::declare_bucket( - const unsigned arg_entity_rank , - const unsigned part_count , - const unsigned part_ord[] , - const std::vector< FieldBase * > & field_set - ) -{ - enum { KEY_TMP_BUFFER_SIZE = 64 }; - - TraceIf("stk_classic::mesh::impl::BucketRepository::declare_bucket", LOG_BUCKET); - - const unsigned max = static_cast(-1); - - ThrowRequireMsg(MetaData::get(m_mesh).check_rank(arg_entity_rank), - "Entity rank " << arg_entity_rank << " is invalid"); - - ThrowRequireMsg( !m_buckets.empty(), - "m_buckets is empty! Did you forget to initialize MetaData before creating BulkData?"); - std::vector & bucket_set = m_buckets[ arg_entity_rank ]; - - - std::vector key(2+part_count) ; - - //---------------------------------- - // Key layout: - // { part_count + 1 , { part_ordinals } , family_count } - // Thus family_count = key[ key[0] ] - // - // for upper bound search use the maximum key. - - key[0] = part_count+1; - key[ key[0] ] = max ; - - { - for ( unsigned i = 0 ; i < part_count ; ++i ) { key[i+1] = part_ord[i] ; } - } - - //---------------------------------- - // Bucket family has all of the same parts. - // Look for the last bucket in this family: - - const std::vector::iterator ik = lower_bound( bucket_set , &key[0] ); - - //---------------------------------- - // If a member of the bucket family has space, it is the last one - // since buckets are kept packed. - const bool bucket_family_exists = - ik != bucket_set.begin() && bucket_part_equal( ik[-1]->key() , &key[0] ); - - Bucket * const last_bucket = bucket_family_exists ? ik[-1] : NULL ; - - Bucket * bucket = NULL ; - - if ( last_bucket == NULL ) { // First bucket in this family - key[ key[0] ] = 0 ; // Set the key's family count to zero - } - else { // Last bucket present, can it hold one more entity? - - ThrowRequireMsg( last_bucket->size() != 0, - "Last bucket should not be empty."); - - //field_map = last_bucket->m_bucketImpl.get_field_map(); - - const unsigned last_count = last_bucket->key()[ key[0] ]; - - const unsigned cap = last_bucket->capacity(); - - if ( last_bucket->size() < cap ) { - bucket = last_bucket ; - } - else if ( last_count < max ) { - key[ key[0] ] = 1 + last_count ; // Increment the key's family count. - } - else { - // ERROR insane number of buckets! - ThrowRequireMsg( false, "Insanely large number of buckets" ); - } - } - - - //---------------------------------- - - //Required bucket does not exist - if ( NULL == bucket ) - { - bucket = new Bucket( m_mesh, arg_entity_rank, key, m_bucket_capacity); - - Bucket * first_bucket = last_bucket ? last_bucket->m_bucketImpl.first_bucket_in_family() : bucket ; - - bucket->m_bucketImpl.set_first_bucket_in_family(first_bucket); // Family members point to first bucket - - first_bucket->m_bucketImpl.set_last_bucket_in_family(bucket); // First bucket points to new last bucket - - bucket_set.insert( ik , bucket ); - } - - //---------------------------------- - - ThrowRequireMsg( bucket->equivalent(*bucket->m_bucketImpl.first_bucket_in_family()), "Logic error - new bucket is not in same family as first_bucket_in_family"); - ThrowRequireMsg( bucket->m_bucketImpl.first_bucket_in_family()->equivalent(*bucket), "Logic error - first_bucket_in_family is not in same family as new bucket"); - - return bucket ; -} - -//---------------------------------------------------------------------- - -void BucketRepository::initialize_fields( Bucket & k_dst , unsigned i_dst ) -{ - TraceIfWatching("stk_classic::mesh::impl::BucketRepository::initialize_fields", LOG_BUCKET, &k_dst); - k_dst.m_bucketImpl.initialize_fields(i_dst); -} - -//---------------------------------------------------------------------- - -void BucketRepository::update_field_data_states() const -{ - TraceIf("stk_classic::mesh::impl::BucketRepository::update_field_data_states", LOG_BUCKET); - - for ( std::vector< std::vector >::const_iterator - i = m_buckets.begin() ; i != m_buckets.end() ; ++i ) { - - const std::vector & kset = *i ; - - for ( std::vector::const_iterator - ik = kset.begin() ; ik != kset.end() ; ++ik ) { - (*ik)->m_bucketImpl.update_state(); - } - } -} - - -//---------------------------------------------------------------------- - - -void BucketRepository::internal_sort_bucket_entities() -{ - TraceIf("stk_classic::mesh::impl::BucketRepository::internal_sort_bucket_entities", LOG_BUCKET); - - for ( EntityRank entity_rank = 0 ; - entity_rank < m_buckets.size() ; ++entity_rank ) { - - std::vector & buckets = m_buckets[ entity_rank ]; - - size_t bk = 0 ; // Offset to first bucket of the family - size_t ek = 0 ; // Offset to end bucket of the family - - for ( ; bk < buckets.size() ; bk = ek ) { - Bucket * b_scratch = NULL ; - Bucket * ik_vacant = buckets[bk]->m_bucketImpl.last_bucket_in_family(); - unsigned ie_vacant = ik_vacant->size(); - - if ( ik_vacant->capacity() <= ie_vacant ) { - // Have to create a bucket just for the scratch space... - const unsigned * const bucket_key = buckets[bk]->key() ; - const unsigned part_count = bucket_key[0] - 1 ; - const unsigned * const part_ord = bucket_key + 1 ; - - b_scratch = declare_bucket( entity_rank , - part_count , part_ord , - MetaData::get(m_mesh).get_fields() ); - - ik_vacant = b_scratch ; - ie_vacant = 0 ; - } - - ik_vacant->m_bucketImpl.replace_entity( ie_vacant , NULL ) ; - - // Determine offset to the end bucket in this family: - while ( ek < buckets.size() && ik_vacant != buckets[ek] ) { ++ek ; } - if (ek < buckets.size()) ++ek ; - - unsigned count = 0 ; - for ( size_t ik = bk ; ik != ek ; ++ik ) { - count += buckets[ik]->size(); - } - - std::vector entities( count ); - - std::vector::iterator j = entities.begin(); - - for ( size_t ik = bk ; ik != ek ; ++ik ) { - Bucket & b = * buckets[ik]; - const unsigned n = b.size(); - for ( unsigned i = 0 ; i < n ; ++i , ++j ) { - *j = & b[i] ; - } - } - - std::sort( entities.begin() , entities.end() , EntityLess() ); - - j = entities.begin(); - - bool change_this_family = false ; - - for ( size_t ik = bk ; ik != ek ; ++ik ) { - Bucket & b = * buckets[ik]; - const unsigned n = b.size(); - for ( unsigned i = 0 ; i < n ; ++i , ++j ) { - Entity * const current = & b[i] ; - - if ( current != *j ) { - - if ( current ) { - // Move current entity to the vacant spot - copy_fields( *ik_vacant , ie_vacant , b, i ); - m_entity_repo.change_entity_bucket(*ik_vacant, *current, ie_vacant); - ik_vacant->m_bucketImpl.replace_entity( ie_vacant , current ) ; - } - - // Set the vacant spot to where the required entity is now. - ik_vacant = & ((*j)->bucket()) ; - ie_vacant = (*j)->bucket_ordinal() ; - ik_vacant->m_bucketImpl.replace_entity( ie_vacant , NULL ) ; - - // Move required entity to the required spot - copy_fields( b, i, *ik_vacant , ie_vacant ); - m_entity_repo.change_entity_bucket( b, **j, i); - b.m_bucketImpl.replace_entity( i, *j ); - - change_this_family = true ; - } - - // Once a change has occured then need to propagate the - // relocation for the remainder of the family. - // This allows the propagation to be performed once per - // entity as opposed to both times the entity is moved. - - if ( change_this_family ) { internal_propagate_relocation( **j ); } - } - } - - if ( b_scratch ) { - // Created a last bucket, now have to destroy it. - destroy_bucket( entity_rank , b_scratch ); - --ek ; - } - } - } -} - -void BucketRepository::optimize_buckets() -{ - TraceIf("stk_classic::mesh::impl::BucketRepository::optimize_buckets", LOG_BUCKET); - - for ( EntityRank entity_rank = 0 ; - entity_rank < m_buckets.size() ; ++entity_rank ) - { - - std::vector & buckets = m_buckets[ entity_rank ]; - - std::vector tmp_buckets; - - size_t begin_family = 0 ; // Offset to first bucket of the family - size_t end_family = 0 ; // Offset to end bucket of the family - - //loop over families - for ( ; begin_family < buckets.size() ; begin_family = end_family ) { - Bucket * last_bucket_in_family = buckets[begin_family]->m_bucketImpl.last_bucket_in_family(); - - // Determine offset to the end bucket in this family: - while ( end_family < buckets.size() && last_bucket_in_family != buckets[end_family] ) { ++end_family ; } - if (end_family < buckets.size()) ++end_family ; //increment past the end - - //if compressed and sorted go to the next family - const bool is_compressed = (end_family-begin_family == 1) - && (buckets[begin_family]->size() == buckets[begin_family]->capacity()); - if (is_compressed) { - const Bucket & b = *buckets[begin_family]; - bool is_sorted = true; - for (size_t i=0, end=b.size()-1; i= b[i+1].key()) is_sorted = false; - } - if (is_sorted) { - tmp_buckets.push_back(buckets[begin_family]); - continue; - } - } - - std::vector new_key = buckets[begin_family]->m_bucketImpl.key_vector(); - //index of bucket in family - new_key[ new_key[0] ] = 0; - - unsigned new_capacity = 0 ; - for ( size_t i = begin_family ; i != end_family ; ++i ) { - new_capacity += buckets[i]->m_bucketImpl.size(); - } - - std::vector entities; - entities.reserve(new_capacity); - - for ( size_t i = begin_family ; i != end_family ; ++i ) { - Bucket& b = *buckets[i]; - for(size_t j=0; jm_bucketImpl.set_first_bucket_in_family(new_bucket); // Family members point to first bucket - new_bucket->m_bucketImpl.set_last_bucket_in_family(new_bucket); // First bucket points to new last bucket - - tmp_buckets.push_back(new_bucket); - - for(size_t new_ordinal=0; new_ordinalm_bucketImpl.increment_size(); - - Entity & entity = *entities[new_ordinal]; - Bucket& old_bucket = entity.bucket(); - unsigned old_ordinal = entity.bucket_ordinal(); - - //copy field data from old to new - copy_fields( *new_bucket, new_ordinal, old_bucket, old_ordinal); - m_entity_repo.change_entity_bucket( *new_bucket, entity, new_ordinal); - new_bucket->m_bucketImpl.replace_entity( new_ordinal , &entity ) ; - internal_propagate_relocation(entity); - } - - for (size_t ik = begin_family; ik != end_family; ++ik) { - delete buckets[ik]; - buckets[ik] = NULL; - } - } - - buckets.swap(tmp_buckets); - } -} -//---------------------------------------------------------------------- - -void BucketRepository::remove_entity( Bucket * k , unsigned i ) -{ - TraceIfWatching("stk_classic::mesh::impl::BucketRepository::remove_entity", LOG_BUCKET, k); - - ThrowRequireMsg( k != m_nil_bucket, "Cannot remove entity from nil_bucket" ); - - const EntityRank entity_rank = k->entity_rank(); - - // Last bucket in the family of buckets with the same parts. - // The last bucket is the only non-full bucket in the family. - - Bucket * const last = k->m_bucketImpl.last_bucket_in_family(); - - ThrowRequireMsg( last->equivalent(*k), "Logic error - last bucket in family not equivalent to bucket"); - ThrowRequireMsg( k->equivalent(*last), "Logic error - bucket not equivalent to last bucket in family"); - - // Fill in the gap if it is not the last entity being removed - - if ( last != k || k->size() != i + 1 ) { - - // Copy last entity in last bucket to bucket *k slot i - - Entity & entity = (*last)[ last->size() - 1 ]; - - copy_fields( *k , i , *last , last->size() - 1 ); - - k->m_bucketImpl.replace_entity(i, & entity ) ; - m_entity_repo.change_entity_bucket( *k, entity, i); - - // Entity field data has relocated - - internal_propagate_relocation( entity ); - } - - last->m_bucketImpl.decrement_size(); - - last->m_bucketImpl.replace_entity( last->size() , NULL ) ; - - if ( 0 == last->size() ) { - destroy_bucket( entity_rank , last ); - } -} - -//---------------------------------------------------------------------- - -void BucketRepository::internal_propagate_relocation( Entity & entity ) -{ - TraceIf("stk_classic::mesh::impl::BucketRepository::internal_propagate_relocation", LOG_BUCKET); - - const EntityRank erank = entity.entity_rank(); - PairIterRelation rel = entity.relations(); - - for ( ; ! rel.empty() ; ++rel ) { - const EntityRank rel_rank = rel->entity_rank(); - if ( rel_rank < erank ) { - Entity & e_to = * rel->entity(); - - set_field_relations( entity, e_to, rel->identifier() ); - } - else if ( erank < rel_rank ) { - Entity & e_from = * rel->entity(); - - set_field_relations( e_from, entity, rel->identifier() ); - } - } -} - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.hpp deleted file mode 100644 index 23552fdacb8e..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/BucketRepository.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_BucketRepository_hpp -#define stk_mesh_BucketRepository_hpp - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -class EntityRepository; - -class BucketRepository { -public: - ~BucketRepository(); - BucketRepository( - BulkData & mesh, - unsigned bucket_capacity, - unsigned entity_rank_count, - EntityRepository & entity_repo - ); - - /** \brief Query all buckets of a given entity rank */ - const std::vector & buckets( EntityRank rank ) const - { - ThrowAssertMsg( rank < m_buckets.size(), "Invalid entity rank " << rank ); - - return m_buckets[ rank ]; - } - - /* Entity modification consequences: - * 1) Change entity relation => update via part relation => change parts - * 2) Change parts => update forward relations via part relation - * => update via field relation - */ - void remove_entity( Bucket * , unsigned ); - - //------------------------------------ - /** \brief Query the upper bound on the number of mesh entities - * that may be associated with a single bucket. - */ - unsigned bucket_capacity() const { return m_bucket_capacity; } - - - //------------------------------------ - - /** \brief Rotate the field data of multistate fields. - * - *
-   *  Rotation of states:
-   *    StateN   <- StateNP1 (StateOld <- StateNew)
-   *    StateNM1 <- StateN   (StateNM1 <- StateOld)
-   *    StateNM2 <- StateNM1
-   *    StateNM3 <- StateNM2
-   *    StateNM3 <- StateNM2
-   *  
- */ - void update_field_data_states() const ; - - // Destroy the last empty bucket in a family: - void destroy_bucket( const unsigned & entity_rank , Bucket * last ); - void destroy_bucket( Bucket * bucket ); - void declare_nil_bucket(); - Bucket * get_nil_bucket() const { return m_nil_bucket; } - Bucket * declare_bucket( - const unsigned entity_rank , - const unsigned part_count , - const unsigned part_ord[] , - const std::vector< FieldBase * > & field_set - ); - void copy_fields( Bucket & k_dst , unsigned i_dst , - Bucket & k_src , unsigned i_src ) - { k_dst.m_bucketImpl.replace_fields(i_dst,k_src,i_src); } - - void initialize_fields( Bucket & k_dst , unsigned i_dst ); - - void internal_sort_bucket_entities(); - - void optimize_buckets(); - void sort_and_optimize_buckets(); - - void add_entity_to_bucket( Entity & entity, Bucket & bucket ) - { - bucket.m_bucketImpl.replace_entity( bucket.size() , & entity ) ; - bucket.m_bucketImpl.increment_size(); - } - - void internal_propagate_relocation( Entity & ); - - AllBucketsRange get_bucket_range() const - { - return stk_classic::mesh::get_bucket_range(m_buckets); - } - - AllBucketsRange get_bucket_range(EntityRank entity_rank) const - { - std::vector< std::vector >::const_iterator itr = m_buckets.begin() + entity_rank; - return stk_classic::mesh::get_bucket_range(m_buckets, itr); - } - -private: - BucketRepository(); - - BulkData & m_mesh ; // Associated Bulk Data Aggregate - unsigned m_bucket_capacity ; // Maximum number of entities per bucket - std::vector< std::vector > m_buckets ; // Vector of bucket pointers by rank - Bucket * m_nil_bucket ; // nil bucket - - EntityRepository & m_entity_repo ; -}; - - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - - -#endif // stk_mesh_BucketRepository_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.cpp deleted file mode 100644 index 471781c5ec14..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - - -PairIterRelation EntityImpl::relations( unsigned rank ) const -{ - RelationVector::const_iterator i = m_relation.begin(); - RelationVector::const_iterator e = m_relation.end(); - - //Nodes - if ( rank != 0 ) { - const Relation::raw_relation_id_type lo_attr = Relation::raw_relation_id( rank , 0 ); - i = std::lower_bound( i , e , lo_attr , LessRelation() ); - } - - const Relation::raw_relation_id_type hi_attr = Relation::raw_relation_id( rank + 1 , 0 ); - e = std::lower_bound( i , e , hi_attr , LessRelation() ); - - return PairIterRelation( i , e ); -} - - -namespace { - -inline bool is_degenerate_relation ( const Relation &r1 , const Relation &r2 ) -{ - return r1.raw_relation_id() == r2.raw_relation_id() && r1.entity() != r2.entity() ; -} - -} - -void EntityImpl::log_resurrect() -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::log_resurrect", LOG_ENTITY, key()); - - ThrowErrorMsgIf( EntityLogDeleted != m_mod_log, - "Trying to resurrect non-deleted entity: " << - print_entity_key( MetaData::get( bucket() ), key() ) ); - - m_mod_log = EntityLogModified; - m_bucket = NULL; -} - -void EntityImpl::log_modified_and_propagate() -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::log_modified_and_propagate", LOG_ENTITY, key()); - - // If already in modified state, return - if (m_mod_log != EntityLogNoChange) { - return; - } - - // mark this entity as modified - m_mod_log = EntityLogModified; - - // recurse on related entities w/ higher rank - EntityRank rank_of_original_entity = entity_rank(); - for ( PairIterRelation irel = relations() ; irel.first != irel.second ; ) { - --irel.second; - Entity & entity = *(irel.second->entity()); - if ( rank_of_original_entity >= entity.entity_rank() ) { - break; //we're done - } - else if ( entity.log_query() == EntityLogNoChange ) { - entity.m_entityImpl.log_modified_and_propagate(); - } - } - -} - -void EntityImpl::compress_relation_capacity() -{ - RelationVector tmp(m_relation); - tmp.swap(m_relation); -} - -void EntityImpl::log_created_parallel_copy() -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::log_created_parallel_copy", LOG_ENTITY, key()); - - if ( EntityLogCreated == m_mod_log ) { - m_mod_log = EntityLogModified ; - } -} - -bool EntityImpl::destroy_relation( Entity& e_to, const RelationIdentifier local_id ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::destroy_relation", LOG_ENTITY, key()); - - bool destroyed_relations = false; - for ( RelationVector::iterator - i = m_relation.begin() ; i != m_relation.end() ; ++i ) { - if ( i->entity() == & e_to && i->identifier() == local_id ) { - i = m_relation.erase( i ); // invalidates iterators, but we're breaking so it's OK - destroyed_relations = true; - break; - } - } - return destroyed_relations; -} - -bool EntityImpl::declare_relation( Entity & e_to, - const RelationIdentifier local_id, - unsigned sync_count, - bool is_back_relation ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::declare_relation", LOG_ENTITY, key()); - - const MetaData & meta_data = MetaData::get( bucket() ); - - Relation new_relation( e_to , local_id ); -#ifdef SIERRA_MIGRATION - new_relation.setRelationType( e_to.entity_rank() > entity_rank() ? Relation::USED_BY : Relation::USES ); - new_relation.setOrientation(0); -#endif - - const RelationVector::iterator rel_end = m_relation.end(); - RelationVector::iterator rel_begin = m_relation.begin(); - RelationVector::iterator lower; - - lower = std::lower_bound( rel_begin , rel_end , new_relation , LessRelation() ); - - // The ordering of the Relations allows for two situations that do - // not arise often in meshes. The first situation is 2 relations between - // e_from and e_to with the same kind but different local_ids. This - // can happen if, for example, a triangle should be used as a quad. In - // this case, one node of the triangle must be two different local nodes of - // the quad. This situation is a valid state of mesh entities. - - // The second situation involves malformed stencils. Given e_from, e_to1, - // and e_to2, e_to1 and eto2 can share a relation with e_from with the same - // kind and local_id. This can arise, for instance, if an edge has three - // nodes. The local_id 1 of the edge may point to two different nodes. - // This situation is disallowed in the mesh. We now check for it. - - // "Degenerate" -> case where we have two relations whose attributes - // (rel id + rel rank) match but point to different entities. It's - // OK for back-relations to be degenerate because there's nothing - // wrong with a node having several back-relations (with similar id) - // to different elements. - - // Check for bad degenerate relations (degenerate forward relations) - // Cannot be degenerate relation if there are no prior relations - if ( !m_relation.empty() && !is_back_relation ) { - // Since LessRelation takes the related entity into account, we must check - // the result of lower_bound AND the iter before to be sure this isn't a - // bad degenerate relation. - RelationVector::iterator start, end; - start = (lower == rel_begin) ? rel_begin : lower - 1; - end = (lower == rel_end) ? rel_end : lower + 1; - - for (RelationVector::iterator itr = start; itr != end; ++itr) { - ThrowErrorMsgIf( is_degenerate_relation ( new_relation , *itr ), - "Could not declare relation from " << - print_entity_key( meta_data, key() ) << " to " << - print_entity_key( meta_data, e_to.key() ) << ", with id " << - local_id << ". Relation already exists to " << - print_entity_key( meta_data, itr->entity()->key() )); - } - } - - bool not_already_exists = (rel_end == lower) || - ( !is_back_relation && new_relation.raw_relation_id() != lower->raw_relation_id() ) || - ( is_back_relation && new_relation != *lower ); - - // If the relation does not already exist, we add it - if (not_already_exists) { - lower = m_relation.insert( lower , new_relation ); - - set_sync_count( sync_count ); - - return true; - } - else { - return false; - } -} - -void EntityImpl::set_key(EntityKey key) -{ - m_key = key; -} - -void EntityImpl::update_key(EntityKey key) -{ - m_key = key; - - std::sort(m_relation.begin(), m_relation.end(), LessRelation()); - log_modified_and_propagate(); - - for ( RelationVector::iterator i = m_relation.begin(), e = m_relation.end(); - i != e; - ++i - ) - { - EntityImpl & entity = i->entity()->m_entityImpl; - std::sort(entity.m_relation.begin(), entity.m_relation.end(), LessRelation()); - entity.log_modified_and_propagate(); - } - -} - -PairIterEntityComm EntityImpl::comm() const -{ - return BulkData::get(bucket()).entity_comm(m_key); -} - -PairIterEntityComm EntityImpl::sharing() const -{ - return BulkData::get(bucket()).entity_comm_sharing(m_key); -} - -PairIterEntityComm EntityImpl::comm( const Ghosting & sub ) const -{ - return BulkData::get(bucket()).entity_comm(m_key,sub); -} - -bool EntityImpl::insert( const EntityCommInfo & val ) -{ - return BulkData::get(bucket()).entity_comm_insert(m_key,val); -} - -bool EntityImpl::erase( const EntityCommInfo & val ) -{ - return BulkData::get(bucket()).entity_comm_erase(m_key,val); -} - -bool EntityImpl::erase( const Ghosting & ghost ) -{ - return BulkData::get(bucket()).entity_comm_erase(m_key,ghost); -} - -void EntityImpl::comm_clear_ghosting() -{ - return BulkData::get(bucket()).entity_comm_clear_ghosting(m_key); -} - -void EntityImpl::comm_clear() -{ - return BulkData::get(bucket()).entity_comm_clear(m_key); -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.hpp deleted file mode 100644 index a0557de865cf..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityImpl.hpp +++ /dev/null @@ -1,231 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_EntityImpl_hpp -#define stk_mesh_EntityImpl_hpp - -#include - -#include - -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -/** \addtogroup stk_mesh_module - * \{ - */ - -class EntityImpl { -public: - - EntityImpl( const EntityKey & arg_key ); - EntityImpl(); - ~EntityImpl(){} - - // Exposed in external interface: - EntityRank entity_rank() const { return stk_classic::mesh::entity_rank( m_key ); } - EntityId identifier() const { return stk_classic::mesh::entity_id( m_key ); } - const EntityKey & key() const { return m_key ; } - PairIterRelation relations() const { return PairIterRelation(m_relation); } - PairIterRelation relations( unsigned rank ) const ; - PairIterRelation node_relations( ) const - { - RelationVector::const_iterator i = m_relation.begin(); - RelationVector::const_iterator e = m_relation.end(); - - const Relation::raw_relation_id_type hi = Relation::raw_relation_id(1, 0); - e = std::lower_bound( i , e , hi , LessRelation() ); - - return PairIterRelation( i , e ); - } - - RelationVector::const_iterator node_relation(unsigned ordinal) const - { return m_relation.begin() + ordinal; } - - PairIterEntityComm comm() const; - PairIterEntityComm sharing() const; - PairIterEntityComm comm( const Ghosting & sub ) const; - - Bucket & bucket() const - { - ThrowAssert(m_bucket); //don't want to return a reference to a null bucket - return *m_bucket ; - } - - Bucket* bucket_ptr() const - { - return m_bucket; // allow for NULL return value - } - - bool is_bucket_valid() const { return m_bucket != NULL; } - unsigned bucket_ordinal() const { return m_bucket_ord ; } - unsigned owner_rank() const { return m_owner_rank ; } - size_t synchronized_count() const { return m_sync_count ; } - - // The two relation methods below need to be called symmetically, ideally - // through EntityRepository which will enforce the symmetry. - - bool destroy_relation( Entity & e_to, const RelationIdentifier local_id); - bool declare_relation( Entity & e_to, - const RelationIdentifier local_id, - unsigned sync_count, - bool is_back_relation = false); - - // Communication info access: - bool insert( const EntityCommInfo & val ); - bool erase( const EntityCommInfo & val ); - bool erase( const Ghosting & ghost ); - void comm_clear_ghosting(); - void comm_clear(); - - void set_bucket_and_ordinal( Bucket * in_bucket, unsigned ordinal ) - { - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::set_bucket_and_ordinal", LOG_ENTITY, key()); - - m_bucket = in_bucket; - m_bucket_ord = ordinal; - } - - // return true if entity was actually modified - bool set_owner_rank( unsigned in_owner_rank ) - { - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::set_owner_rank", LOG_ENTITY, key()); - - if ( in_owner_rank != m_owner_rank ) { - m_owner_rank = in_owner_rank; - return true; - } - return false; - } - - void set_sync_count( size_t sync_count ) - { - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::set_sync_count", LOG_ENTITY, key()); - - m_sync_count = sync_count; - } - - // Change log access: - EntityModificationLog log_query() const { return m_mod_log ; } - - void log_clear() - { - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::log_clear", LOG_ENTITY, key()); - - m_mod_log = EntityLogNoChange; - } - - void log_deleted() - { - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::log_deleted", LOG_ENTITY, key()); - - m_mod_log = EntityLogDeleted; - } - - /** - * Takes an entity that has been marked for deletion and reactivates it. IE - * takes an entity in the deleted state and changes it to modified. - */ - void log_resurrect(); - - /** - * Mark this entity as modified (only changes from EntityLogNoChange - * to EntityLogModified). Propagates the modification to higher-ranking - * entities related to this entity. In other words, based on our - * modification model, all entities that have modified_entity in their - * closure must also be marked as modified. - */ - void log_modified_and_propagate(); - - /** \brief Log that this entity was created as a parallel copy. */ - void log_created_parallel_copy(); - - bool marked_for_destruction() const - { - // The original implementation of this method checked bucket capacity. In - // order to ensure that the addition of EntityLogDeleted does not change - // behavior, we put error check here. - // ThrowErrorMsgIf((bucket().capacity() == 0) != (m_mod_log == EntityLogDeleted), - // "Inconsistent destruction state; " << - // "destroyed entities should be in the nil bucket and vice versa.\n" << - // "Problem is with entity: " << - // print_entity_key( MetaData::get( bucket() ), key() ) << - // "\nWas in nil bucket: " << (bucket().capacity() == 0) << ", " << - // "was in destroyed state: " << (m_mod_log == EntityLogDeleted) ); - - return m_mod_log == EntityLogDeleted; - } - - //set_key is only to be used for setting a key on a newly-constructed entity. - void set_key(EntityKey key); - - //update_key is used to change the key for an entity that has been in use with - //a different key. - void update_key(EntityKey key); - -// RelationVector& rel_vec() {return m_relation;} - void compress_relation_capacity(); - - private: - - EntityKey m_key ; ///< Globally unique key - RelationVector m_relation ; ///< This entity's relationships - Bucket * m_bucket ; ///< Bucket for the entity's field data - unsigned m_bucket_ord ; ///< Ordinal within the bucket - unsigned m_owner_rank ; ///< Owner processors' rank - size_t m_sync_count ; ///< Last membership change - EntityModificationLog m_mod_log ; - -// EntityImpl( const EntityImpl & ); ///< Copy constructor not allowed - EntityImpl & operator = ( const EntityImpl & ); ///< Assignment operator not allowed -}; - -inline -EntityImpl::EntityImpl( const EntityKey & arg_key ) - : m_key(arg_key), - m_relation(), - m_bucket( NULL ), - m_bucket_ord(0), - m_owner_rank(0), - m_sync_count(0), - m_mod_log( EntityLogCreated ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityImpl::EntityImpl", LOG_ENTITY, arg_key); -} - -inline -EntityImpl::EntityImpl() - : m_key(), - m_relation(), - m_bucket( NULL ), - m_bucket_ord(0), - m_owner_rank(0), - m_sync_count(0), - m_mod_log( EntityLogCreated ) -{ -} - -//---------------------------------------------------------------------- - -/** \} */ - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif /* stk_mesh_EntityImpl_hpp */ diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.cpp deleted file mode 100644 index 9cc3a364bda6..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -boost::fast_pool_allocator& entity_allocator() -{ - static boost::fast_pool_allocator entity_pool_allocator; - return entity_pool_allocator; -} - -#ifdef SIERRA_MIGRATION -boost::fast_pool_allocator& fmwk_attr_allocator() -{ - static boost::fast_pool_allocator fmwk_attr_allocator; - return fmwk_attr_allocator; -} -#endif - -Entity* EntityRepository::allocate_entity(bool use_pool) -{ - if (use_pool) { - static Entity tmp_entity; - Entity* new_entity = entity_allocator().allocate(); - entity_allocator().construct(new_entity, tmp_entity); - return new_entity; - } - //else - return new Entity; -} - -#ifdef SIERRA_MIGRATION -fmwk_attributes* allocate_fmwk_attr(bool use_pool) -{ - if (use_pool) { - static fmwk_attributes tmp_attributes; - fmwk_attributes* fmwk_attrs = fmwk_attr_allocator().allocate(); - fmwk_attr_allocator().construct(fmwk_attrs, tmp_attributes); - return fmwk_attrs; - } - //else - return new fmwk_attributes; -} -#endif - -void destroy_entity(Entity* entity, bool use_pool) -{ - if (use_pool) { - entity_allocator().destroy(entity); - entity_allocator().deallocate(entity, 1); - return; - } - //else - delete entity; -} - -#ifdef SIERRA_MIGRATION -void destroy_fmwk_attr(fmwk_attributes* fmwk_attr, bool use_pool) -{ - if (use_pool) { - fmwk_attr_allocator().destroy(fmwk_attr); - fmwk_attr_allocator().deallocate(fmwk_attr, 1); - return; - } - //else - delete fmwk_attr; -} -#endif - -void release_all_entity_memory(bool use_pool) -{ - if (use_pool) { - boost::singleton_pool::release_memory(); - } -} - -#ifdef SIERRA_MIGRATION -void release_all_fmwk_attr_memory(bool use_pool) -{ - if (use_pool) { - boost::singleton_pool::release_memory(); - } -} -#endif - -EntityRepository::~EntityRepository() -{ - try { - while ( ! m_entities.empty() ) { - internal_expunge_entity( m_entities.begin() ); - } - } catch(...){} - - release_all_entity_memory(m_use_pool); -#ifdef SIERRA_MIGRATION - release_all_fmwk_attr_memory(m_use_pool); -#endif -} - -void EntityRepository::internal_expunge_entity( EntityMap::iterator i ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::internal_expunge_entity", LOG_ENTITY, i->first); - - ThrowErrorMsgIf( i->second == NULL, - "For key " << entity_rank(i->first) << " " << - entity_id(i->first) << ", value was NULL"); - - ThrowErrorMsgIf( i->first != i->second->key(), - "Key " << print_entity_key(MetaData::get( *i->second ), i->first) << - " != " << print_entity_key(i->second)); - - Entity* deleted_entity = i->second; - -#ifdef SIERRA_MIGRATION - destroy_fmwk_attr(deleted_entity->m_fmwk_attrs, m_use_pool); -#endif - destroy_entity(deleted_entity, m_use_pool); - i->second = NULL; - m_entities.erase( i ); -} - -Entity* -EntityRepository::internal_allocate_entity(EntityKey entity_key) -{ - Entity* new_entity = allocate_entity(m_use_pool); - new_entity->set_key(entity_key); -#ifdef SIERRA_MIGRATION - fmwk_attributes* fmwk_attrs = allocate_fmwk_attr(m_use_pool); - new_entity->m_fmwk_attrs = fmwk_attrs; -#endif - return new_entity; -} - -std::pair -EntityRepository::internal_create_entity( const EntityKey & key ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::internal_create_entity", LOG_ENTITY, key); - - EntityMap::value_type tmp(key,NULL); - - const std::pair< EntityMap::iterator , bool > - insert_result = m_entities.insert( tmp ); - - std::pair - result( insert_result.first->second , insert_result.second ); - - if ( insert_result.second ) { // A new entity - Entity* new_entity = internal_allocate_entity(key); - insert_result.first->second = result.first = new_entity; - } - else if ( EntityLogDeleted == result.first->log_query() ) { - // resurrection - result.first->m_entityImpl.log_resurrect(); - result.second = true; - } - - return result ; -} - -void EntityRepository::log_created_parallel_copy( Entity & entity ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::log_created_parallel_copy", LOG_ENTITY, entity.key()); - - entity.m_entityImpl.log_created_parallel_copy(); -} - -Entity * EntityRepository::get_entity(const EntityKey &key) const -{ - ThrowErrorMsgIf( ! entity_key_valid( key ), - "Invalid key: " << entity_rank(key) << " " << entity_id(key)); - - const EntityMap::const_iterator i = m_entities.find( key ); - - return i != m_entities.end() ? i->second : NULL ; -} - -void EntityRepository::clean_changes() -{ - TraceIf("stk_classic::mesh::impl::EntityRepository::clean_changes", LOG_ENTITY); - - for ( EntityMap::iterator - i = m_entities.begin() ; i != m_entities.end() ; ) - { - const EntityMap::iterator j = i ; - ++i ; - - if ( j->second->m_entityImpl.marked_for_destruction() ) { - // Clear out the entities destroyed in the previous modification. - // They were retained for change-logging purposes. - internal_expunge_entity( j ); - } - else { - j->second->m_entityImpl.log_clear(); - } - } -} - -bool EntityRepository::erase_ghosting( Entity & e, const Ghosting & ghosts) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::erase_ghosting", LOG_ENTITY, e.key()); - - return e.m_entityImpl.erase( ghosts ); -} - -bool EntityRepository::erase_comm_info( Entity & e, const EntityCommInfo & comm_info) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::erase_comm_info", LOG_ENTITY, e.key()); - - return e.m_entityImpl.erase( comm_info ); -} - -bool EntityRepository::insert_comm_info( Entity & e, const EntityCommInfo & comm_info) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::insert_comm_info", LOG_ENTITY, e.key()); - - return e.m_entityImpl.insert( comm_info ); -} - -void EntityRepository::destroy_later( Entity & e, Bucket* nil_bucket ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::destroy_later", LOG_ENTITY, e.key()); - - ThrowErrorMsgIf( e.log_query() == EntityLogDeleted, - "double deletion of entity: " << print_entity_key( e )); - - change_entity_bucket( *nil_bucket, e, 0); - e.m_entityImpl.log_deleted(); //important that this come last -} - -void EntityRepository::change_entity_bucket( Bucket & b, Entity & e, - unsigned ordinal) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::change_entity_bucket", LOG_ENTITY, e.key()); - DiagIfWatching(LOG_ENTITY, e.key(), "New bucket: " << b << ", ordinal: " << ordinal); - - const bool modified_parts = ! e.m_entityImpl.is_bucket_valid() || - ! b.equivalent( e.bucket() ); - if ( modified_parts ) { - e.m_entityImpl.log_modified_and_propagate(); - } - e.m_entityImpl.set_bucket_and_ordinal( &b, ordinal); -} - -Bucket * EntityRepository::get_entity_bucket( Entity & e ) const -{ - // Note, this allows for returning NULL bucket - return e.m_entityImpl.bucket_ptr(); -} - -bool EntityRepository::destroy_relation( Entity & e_from, - Entity & e_to, - const RelationIdentifier local_id ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::destroy_relation", LOG_ENTITY, e_from.key()); - - bool caused_change_fwd = e_from.m_entityImpl.destroy_relation(e_to, local_id); - - // Relationships should always be symmetrical - if ( caused_change_fwd ) { - bool caused_change_inv = e_to.m_entityImpl.destroy_relation(e_from, local_id); - ThrowErrorMsgIf( !caused_change_inv, - " Internal error - could not destroy inverse relation of " << - print_entity_key( e_from ) << " to " << print_entity_key( e_to ) << - " with local relation id of " << local_id); - } - - // It is critical that the modification be done AFTER the relations are - // changed so that the propagation can happen correctly. - if ( caused_change_fwd ) { - e_to.m_entityImpl.log_modified_and_propagate(); - e_from.m_entityImpl.log_modified_and_propagate(); - } - - return caused_change_fwd; -} - -void EntityRepository::declare_relation( Entity & e_from, - Entity & e_to, - const RelationIdentifier local_id, - unsigned sync_count ) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::declare_relation", LOG_ENTITY, e_from.key()); - - bool caused_change_fwd = - e_from.m_entityImpl.declare_relation( e_to, local_id, sync_count); - - // Relationships should always be symmetrical - if ( caused_change_fwd ) { - - // the setup for the converse relationship works slightly differently - bool is_converse = true; - bool caused_change_inv = - e_to.m_entityImpl.declare_relation( e_from, local_id, sync_count, - is_converse ); - - ThrowErrorMsgIf( !caused_change_inv, - " Internal error - could not create inverse relation of " << - print_entity_key( e_from ) << " to " << print_entity_key( e_to )); - } - - // It is critical that the modification be done AFTER the relations are - // added so that the propagation can happen correctly. - if ( caused_change_fwd ) { - e_to.m_entityImpl.log_modified_and_propagate(); - e_from.m_entityImpl.log_modified_and_propagate(); - } -} - -void EntityRepository::update_entity_key(EntityKey key, Entity & entity) -{ - EntityKey old_key = entity.key(); - - EntityMap::iterator old_itr = m_entities.find( old_key ); - - EntityMap::iterator itr = m_entities.find(key); - if (itr != m_entities.end()) { - Entity* key_entity = itr->second; - ThrowRequireMsg( key_entity->log_query() == EntityLogDeleted, "update_entity_key ERROR: non-deleted entity already present for new key (" << key.rank()<<","<m_entityImpl.update_key(old_key); - //key_entity is already marked for deletion - - old_itr->second->m_entityImpl.update_key(key); - - //We also need to swap the entities on these map iterators so that - //they map to the right keys: - itr->second = old_itr->second; - old_itr->second = key_entity; - } - else { - m_entities.insert(std::make_pair(key,&entity)); - - entity.m_entityImpl.update_key(key); - - old_itr->second = internal_allocate_entity(old_key); - - old_itr->second->m_entityImpl.log_deleted(); - } -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.hpp deleted file mode 100644 index 5d7f5b24c50d..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/EntityRepository.hpp +++ /dev/null @@ -1,174 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_baseImpl_EntityRepository_hpp -#define stk_mesh_baseImpl_EntityRepository_hpp - -#include - -// We will use tr1 if we can (not on PGI or pathscale); otherwise, fall back to std map. -#if defined(__PGI) || defined(__PATHSCALE__) - #define STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 0 -#else - #define STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 0 -#endif - -#if STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 - #include -#else - #include -#endif - -#include - - -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -class EntityRepository { - -#if STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 - struct stk_entity_rep_hash : public std::unary_function< EntityKey, std::size_t > - { - inline std::size_t - operator()(const EntityKey& x) const - { - return (std::size_t)(x.raw_key()); - } - }; - - typedef std::tr1::unordered_map > EntityMap; -#else - typedef std::map EntityMap; -#endif - - public: - - typedef EntityMap::const_iterator iterator; - - EntityRepository(bool use_pool) - : m_entities(), m_use_pool(use_pool) {} - - ~EntityRepository(); - - Entity * get_entity( const EntityKey &key ) const; - - iterator begin() const { return m_entities.begin(); } - iterator end() const { return m_entities.end(); } - - void clean_changes(); - - // Return a pair: the relevant entity, and whether it had to be created - // or not. If there was already an active entity, the second item in the - // will be false; otherwise it will be true (even if the Entity was present - // but marked as destroyed). - std::pair - internal_create_entity( const EntityKey & key ); - - /** \brief Log that this entity was created as a parallel copy - * of an existing entity. - */ - void log_created_parallel_copy( Entity & e ); - - /** - * The client knows that this entity should be marked as modified. In - * general clients shouldn't need to call this because EntityRepository - * knows when it performs operations that modify entities. BulkData should - * be the only caller of this method. - */ - inline void log_modified(Entity & e) const; - - inline void set_entity_owner_rank( Entity & e, unsigned owner_rank); - inline void set_entity_sync_count( Entity & e, size_t count); - - inline void comm_clear( Entity & e) const; - inline void comm_clear_ghosting( Entity & e) const; - - bool erase_ghosting( Entity & e, const Ghosting & ghosts) const; - bool erase_comm_info( Entity & e, const EntityCommInfo & comm_info) const; - - bool insert_comm_info( Entity & e, const EntityCommInfo & comm_info) const; - - void change_entity_bucket( Bucket & b, Entity & e, unsigned ordinal); - Bucket * get_entity_bucket ( Entity & e ) const; - void destroy_later( Entity & e, Bucket* nil_bucket ); - - bool destroy_relation( Entity & e_from, - Entity & e_to, - const RelationIdentifier local_id); - - void declare_relation( Entity & e_from, - Entity & e_to, - const RelationIdentifier local_id, - unsigned sync_count ); - - void update_entity_key(EntityKey key, Entity & entity); - - private: - void internal_expunge_entity( EntityMap::iterator i); - - Entity* internal_allocate_entity(EntityKey entity_key); - Entity* allocate_entity(bool use_pool); - - EntityMap m_entities; - bool m_use_pool; - - //disable copy constructor and assignment operator - EntityRepository(const EntityRepository &); - EntityRepository & operator =(const EntityRepository &); -}; - -/*---------------------------------------------------------------*/ - -void EntityRepository::set_entity_sync_count( Entity & e, size_t count) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::set_entity_sync_count", LOG_ENTITY, e.key()); - - e.m_entityImpl.set_sync_count(count); -} - -void EntityRepository::set_entity_owner_rank( Entity & e, unsigned owner_rank) -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::set_entity_owner_rank", LOG_ENTITY, e.key()); - DiagIfWatching(LOG_ENTITY, e.key(), "new owner: " << owner_rank); - - bool changed = e.m_entityImpl.set_owner_rank(owner_rank); - if ( changed ) { - e.m_entityImpl.log_modified_and_propagate(); - } -} - -void EntityRepository::comm_clear( Entity & e) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::comm_clear", LOG_ENTITY, e.key()); - - e.m_entityImpl.comm_clear(); -} - -void EntityRepository::comm_clear_ghosting( Entity & e) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::comm_clear_ghosting", LOG_ENTITY, e.key()); - - e.m_entityImpl.comm_clear_ghosting(); -} - -void EntityRepository::log_modified( Entity & e ) const -{ - TraceIfWatching("stk_classic::mesh::impl::EntityRepository::log_modified", LOG_ENTITY, e.key()); - - e.m_entityImpl.log_modified_and_propagate(); -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_baseImpl_EntityRepository_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.cpp deleted file mode 100644 index 3811d755acdc..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -//---------------------------------------------------------------------- - -namespace { - -FieldRestrictionVector::const_iterator - find( const FieldRestrictionVector & v , const FieldRestriction & restr ) -{ - FieldRestrictionVector::const_iterator - i = std::lower_bound( v.begin() , v.end() , restr ); - - if ( i != v.end() && !(*i == restr) ) { i = v.end(); } - - return i ; -} - -} - -//---------------------------------------------------------------------- - -FieldBaseImpl::FieldBaseImpl( - MetaData * arg_mesh_meta_data , - unsigned arg_ordinal , - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank, - const shards::ArrayDimTag * const * arg_dim_tags, - unsigned arg_number_of_states , - FieldState arg_this_state - ) -: m_name( arg_name ), - m_attribute(), - m_data_traits( arg_traits ), - m_meta_data( arg_mesh_meta_data ), - m_ordinal( arg_ordinal ), - m_num_states( arg_number_of_states ), - m_this_state( arg_this_state ), - m_field_rank( arg_rank ), - m_dim_map(), - m_selector_restrictions(), - m_initial_value(NULL), - m_initial_value_num_bytes(0) -{ - TraceIfWatching("stk_classic::mesh::impl::FieldBaseImpl::FieldBaseImpl", LOG_FIELD, m_ordinal); - - FieldBase * const pzero = NULL ; - const shards::ArrayDimTag * const dzero = NULL ; - Copy( m_field_states , pzero ); - Copy( m_dim_tags , dzero ); - - for ( unsigned i = 0 ; i < arg_rank ; ++i ) { - m_dim_tags[i] = arg_dim_tags[i]; - } -} - -//---------------------------------------------------------------------- -FieldBaseImpl::~FieldBaseImpl() -{ - if (state() == StateNone) { - void*& init_val = m_initial_value; - - delete [] reinterpret_cast(init_val); - init_val = NULL; - } -} - -//---------------------------------------------------------------------- -const FieldRestrictionVector & FieldBaseImpl::restrictions() const -{ return m_field_states[0]->m_impl.m_dim_map ; } - -const FieldRestrictionVector & FieldBaseImpl::selector_restrictions() const -{ return m_field_states[0]->m_impl.m_selector_restrictions ; } - -FieldRestrictionVector & FieldBaseImpl::restrictions() -{ return m_field_states[0]->m_impl.m_dim_map ; } - -FieldRestrictionVector & FieldBaseImpl::selector_restrictions() -{ return m_field_states[0]->m_impl.m_selector_restrictions ; } - - -//---------------------------------------------------------------------- - -// Setting the dimension for one field sets the dimension -// for the corresponding fields of the FieldState array. -// If subset exists then replace it. -// If exists or superset exists then do nothing. - -void FieldBaseImpl::insert_restriction( - const char * arg_method , - EntityRank arg_entity_rank , - const Part & arg_part , - const unsigned * arg_stride, - const void* arg_init_value ) -{ - TraceIfWatching("stk_classic::mesh::impl::FieldBaseImpl::insert_restriction", LOG_FIELD, m_ordinal); - - FieldRestriction tmp( arg_entity_rank , arg_part.mesh_meta_data_ordinal() ); - - { - unsigned i = 0 ; - if ( m_field_rank ) { - for ( i = 0 ; i < m_field_rank ; ++i ) { tmp.stride(i) = arg_stride[i] ; } - } - else { // Scalar field is 0 == m_field_rank - i = 1 ; - tmp.stride(0) = 1 ; - } - // Remaining dimensions are 1, no change to stride - for ( ; i < MaximumFieldDimension ; ++i ) { - tmp.stride(i) = tmp.stride(i-1) ; - } - - for ( i = 1 ; i < m_field_rank ; ++i ) { - const bool bad_stride = 0 == tmp.stride(i) || - 0 != tmp.stride(i) % tmp.stride(i-1); - ThrowErrorMsgIf( bad_stride, - arg_method << " FAILED for " << *this << - " WITH BAD STRIDE " << - print_restriction( tmp, arg_entity_rank, arg_part, m_field_rank )); - } - } - - if (arg_init_value != NULL) { - //insert_restriction can be called multiple times for the same field, giving - //the field different lengths on different mesh-parts. - //We will only store one initial-value array, we need to store the one with - //maximum length for this field so that it can be used to initialize data - //for all field-restrictions. For the parts on which the field is shorter, - //a subset of the initial-value array will be used. - // - //We want to end up storing the longest arg_init_value array for this field. - // - //Thus, we call set_initial_value only if the current length is longer - //than what's already been stored. - - //length in bytes is num-scalars X sizeof-scalar: - - size_t num_scalars = 1; - //if rank > 0, then field is not a scalar field, so num-scalars is - //obtained from the stride array: - if (m_field_rank > 0) num_scalars = tmp.stride(m_field_rank-1); - - size_t sizeof_scalar = m_data_traits.size_of; - size_t nbytes = sizeof_scalar * num_scalars; - - size_t old_nbytes = 0; - if (get_initial_value() != NULL) { - old_nbytes = get_initial_value_num_bytes(); - } - - if (nbytes > old_nbytes) { - set_initial_value(arg_init_value, num_scalars, nbytes); - } - } - - { - FieldRestrictionVector & restrs = restrictions(); - - FieldRestrictionVector::iterator restr = restrs.begin(); - FieldRestrictionVector::iterator last_restriction = restrs.end(); - - restr = std::lower_bound(restr,last_restriction,tmp); - - const bool new_restriction = ( ( restr == last_restriction ) || !(*restr == tmp) ); - - if ( new_restriction ) { - // New field restriction, verify we are not committed: - ThrowRequireMsg(!m_meta_data->is_commit(), "mesh MetaData has been committed."); - unsigned num_subsets = 0; - for(FieldRestrictionVector::iterator i=restrs.begin(), iend=restrs.end(); i!=iend; ++i) { - if (i->entity_rank() != arg_entity_rank) continue; - - const Part& partI = *m_meta_data->get_parts()[i->part_ordinal()]; - bool found_subset = contain(arg_part.subsets(), partI); - if (found_subset) { - ThrowErrorMsgIf( i->not_equal_stride(tmp), - arg_method << " FAILED for " << *this << " " << - print_restriction( *i, arg_entity_rank, arg_part, m_field_rank ) << - " WITH INCOMPATIBLE REDECLARATION " << - print_restriction( tmp, arg_entity_rank, arg_part, m_field_rank )); - *i = tmp; - ++num_subsets; - } - - bool found_superset = contain(arg_part.supersets(), partI); - if (found_superset) { - ThrowErrorMsgIf( i->not_equal_stride(tmp), - arg_method << " FAILED for " << *this << " " << - print_restriction( *i, arg_entity_rank, arg_part, m_field_rank ) << - " WITH INCOMPATIBLE REDECLARATION " << - print_restriction( tmp, arg_entity_rank, arg_part, m_field_rank )); - //if there's already a restriction for a superset of this part, then - //there's nothing to do and we're out of here.. - return; - } - } - if (num_subsets == 0) { - restrs.insert( restr , tmp ); - } - else { - //if subsets were found, we replaced them with the new restriction. so now we need - //to sort and unique the vector, and trim it to remove any duplicates: - std::sort(restrs.begin(), restrs.end()); - FieldRestrictionVector::iterator it = std::unique(restrs.begin(), restrs.end()); - restrs.resize(it - restrs.begin()); - } - } - else { - ThrowErrorMsgIf( restr->not_equal_stride(tmp), - arg_method << " FAILED for " << *this << " " << - print_restriction( *restr, arg_entity_rank, arg_part, m_field_rank ) << - " WITH INCOMPATIBLE REDECLARATION " << - print_restriction( tmp, arg_entity_rank, arg_part, m_field_rank )); - } - } -} - -void FieldBaseImpl::insert_restriction( - const char * arg_method , - EntityRank arg_entity_rank , - const Selector & arg_selector , - const unsigned * arg_stride, - const void* arg_init_value ) -{ - TraceIfWatching("stk_classic::mesh::impl::FieldBaseImpl::insert_restriction", LOG_FIELD, m_ordinal); - - FieldRestriction tmp( arg_entity_rank , arg_selector ); - - { - unsigned i = 0 ; - if ( m_field_rank ) { - for ( i = 0 ; i < m_field_rank ; ++i ) { tmp.stride(i) = arg_stride[i] ; } - } - else { // Scalar field is 0 == m_field_rank - i = 1 ; - tmp.stride(0) = 1 ; - } - // Remaining dimensions are 1, no change to stride - for ( ; i < MaximumFieldDimension ; ++i ) { - tmp.stride(i) = tmp.stride(i-1) ; - } - - for ( i = 1 ; i < m_field_rank ; ++i ) { - const bool bad_stride = 0 == tmp.stride(i) || - 0 != tmp.stride(i) % tmp.stride(i-1); - ThrowErrorMsgIf( bad_stride, - arg_method << " FAILED for " << *this << - " WITH BAD STRIDE!"); - } - } - - if (arg_init_value != NULL) { - //insert_restriction can be called multiple times for the same field, giving - //the field different lengths on different mesh-parts. - //We will only store one initial-value array, we need to store the one with - //maximum length for this field so that it can be used to initialize data - //for all field-restrictions. For the parts on which the field is shorter, - //a subset of the initial-value array will be used. - // - //We want to end up storing the longest arg_init_value array for this field. - // - //Thus, we call set_initial_value only if the current length is longer - //than what's already been stored. - - //length in bytes is num-scalars X sizeof-scalar: - - size_t num_scalars = 1; - //if rank > 0, then field is not a scalar field, so num-scalars is - //obtained from the stride array: - if (m_field_rank > 0) num_scalars = tmp.stride(m_field_rank-1); - - size_t sizeof_scalar = m_data_traits.size_of; - size_t nbytes = sizeof_scalar * num_scalars; - - size_t old_nbytes = 0; - if (get_initial_value() != NULL) { - old_nbytes = get_initial_value_num_bytes(); - } - - if (nbytes > old_nbytes) { - set_initial_value(arg_init_value, num_scalars, nbytes); - } - } - - { - FieldRestrictionVector & srvec = selector_restrictions(); - - bool restriction_already_exists = false; - for(FieldRestrictionVector::const_iterator it=srvec.begin(), it_end=srvec.end(); - it!=it_end; ++it) { - if (tmp == *it) { - restriction_already_exists = true; - if (tmp.not_equal_stride(*it)) { - ThrowErrorMsg("Incompatible selector field-restrictions!"); - } - } - } - - if ( !restriction_already_exists ) { - // New field restriction, verify we are not committed: - ThrowRequireMsg(!m_meta_data->is_commit(), "mesh MetaData has been committed."); - srvec.push_back( tmp ); - } - } -} - -void FieldBaseImpl::verify_and_clean_restrictions( - const char * arg_method , - const Part& superset, - const Part& subset, - const PartVector & arg_all_parts ) -{ - TraceIfWatching("stk_classic::mesh::impl::FieldBaseImpl::verify_and_clean_restrictions", LOG_FIELD, m_ordinal); - - FieldRestrictionVector & restrs = restrictions(); - - //Check whether both 'superset' and 'subset' are in this field's restrictions. - //If they are, make sure they are compatible and remove the subset restriction. - FieldRestrictionVector::iterator superset_restriction = restrs.end(); - FieldRestrictionVector::iterator subset_restriction = restrs.end(); - for (FieldRestrictionVector::iterator i = restrs.begin() ; i != restrs.end() ; ++i ) { - if (i->part_ordinal() == superset.mesh_meta_data_ordinal()) { - superset_restriction = i; - if (subset_restriction != restrs.end() && subset_restriction->entity_rank() == superset_restriction->entity_rank()) break; - } - if (i->part_ordinal() == subset.mesh_meta_data_ordinal()) { - subset_restriction = i; - if (superset_restriction != restrs.end() && subset_restriction->entity_rank() == superset_restriction->entity_rank()) break; - } - } - - if (superset_restriction != restrs.end() && subset_restriction != restrs.end() && - superset_restriction->entity_rank() == subset_restriction->entity_rank()) { - ThrowErrorMsgIf( superset_restriction->not_equal_stride(*subset_restriction), - "Incompatible field restrictions for parts "<m_impl.m_initial_value; -} - -void* FieldBaseImpl::get_initial_value() { - return m_field_states[0]->m_impl.m_initial_value; -} - -unsigned FieldBaseImpl::get_initial_value_num_bytes() const { - return m_field_states[0]->m_impl.m_initial_value_num_bytes; -} - -void FieldBaseImpl::set_initial_value(const void* new_initial_value, unsigned num_scalars, unsigned num_bytes) { - void*& init_val = m_field_states[0]->m_impl.m_initial_value; - - delete [] reinterpret_cast(init_val); - init_val = new char[num_bytes]; - - m_field_states[0]->m_impl.m_initial_value_num_bytes = num_bytes; - - m_data_traits.copy(init_val, new_initial_value, num_scalars); -} - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// This part or any superset of this part - -const FieldRestriction & -FieldBaseImpl::restriction( unsigned entity_rank , const Part & part ) const -{ - static const FieldRestriction empty ; - - const FieldRestrictionVector & rMap = restrictions(); - const FieldRestrictionVector::const_iterator ie = rMap.end() ; - FieldRestrictionVector::const_iterator i ; - - const PartVector::const_iterator ipe = part.supersets().end(); - PartVector::const_iterator ip = part.supersets().begin() ; - - // Start with this part: - //(putting static here helps performance significantly but is NOT THREAD SAFE !!!) - static FieldRestriction restr; - restr.set_entity_rank( entity_rank ); - restr.set_part_ordinal( part.mesh_meta_data_ordinal() ); - - while ( ie == ( i = find( rMap , restr ) ) && ipe != ip ) { - // Not found try another superset part: - restr.set_entity_rank( entity_rank ); - restr.set_part_ordinal( (*ip)->mesh_meta_data_ordinal() ); - ++ip ; - } - - return ie == i ? empty : *i ; -} - -unsigned FieldBaseImpl::max_size( unsigned entity_rank ) const -{ - unsigned max = 0 ; - - const FieldRestrictionVector & rMap = restrictions(); - const FieldRestrictionVector::const_iterator ie = rMap.end() ; - FieldRestrictionVector::const_iterator i = rMap.begin(); - - for ( ; i != ie ; ++i ) { - if ( i->entity_rank() == entity_rank ) { - const unsigned len = m_field_rank ? i->stride( m_field_rank - 1 ) : 1 ; - if ( max < len ) { max = len ; } - } - } - - return max ; -} - -void FieldBaseImpl::set_field_states( FieldBase ** field_states) -{ - TraceIfWatching("stk_classic::mesh::impl::FieldBaseImpl::set_field_states", LOG_FIELD, m_ordinal); - - for (unsigned i = 0; i < m_num_states; ++i) { - m_field_states[i] = field_states[i]; - } -} - -//---------------------------------------------------------------------- - -//---------------------------------------------------------------------- - -std::ostream & operator << ( std::ostream & s , const FieldBaseImpl & field ) -{ - s << "FieldBaseImpl<" ; - s << field.data_traits().name ; - for ( unsigned i = 0 ; i < field.rank() ; ++i ) { - s << "," << field.dimension_tags()[i]->name(); - } - s << ">" ; - - s << "[ name = \"" ; - s << field.name() ; - s << "\" , #states = " ; - s << field.number_of_states(); - s << " ]" ; - return s ; -} - -std::ostream & print( std::ostream & s , - const char * const b , - const FieldBase & field ) -{ - const PartVector & all_parts = MetaData::get(field).get_parts(); - const std::vector & rMap = field.restrictions(); - s << field.name() ; - s << " {" ; - for ( FieldBase::RestrictionVector::const_iterator - i = rMap.begin() ; i != rMap.end() ; ++i ) { - s << std::endl << b << " " ; - i->print( s, i->entity_rank(), * all_parts[ i->part_ordinal() ], field.rank() ); - s << std::endl; - } - s << std::endl << b << "}" ; - return s ; -} - -//---------------------------------------------------------------------- - - - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.hpp deleted file mode 100644 index d8c1c00eacd5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldBaseImpl.hpp +++ /dev/null @@ -1,174 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#ifndef stk_mesh_baseImpl_FieldBaseImpl_hpp -#define stk_mesh_baseImpl_FieldBaseImpl_hpp - -#include -#include -#include - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -class FieldBase; -class MetaData; - -namespace impl { - -class FieldBaseImpl { -public: - - MetaData & meta_data() const { - return *m_meta_data ; - } - - unsigned ordinal() const { - return m_ordinal ; - } - - const std::string & name() const { - return m_name ; - } - - template - bool type_is() const { - return m_data_traits.type_info == typeid(Type) ; - } - - const DataTraits & data_traits() const { - return m_data_traits ; - } - - unsigned number_of_states() const { - return m_num_states ; - } - - FieldState state() const { - return m_this_state ; - } - - unsigned rank() const { - return m_field_rank ; - } - - const shards::ArrayDimTag * const * dimension_tags() const { - return m_dim_tags ; - } - - //not inline - unsigned max_size( unsigned entity_rank) const ; - - template - const A * attribute() const { - return m_attribute.template get
(); - } - - template - const A * declare_attribute_no_delete(const A * a) { - return m_attribute.template insert_no_delete(a); - } - - template - const A * declare_attribute_with_delete(const A * a) { - return m_attribute.template insert_with_delete(a); - } - - const FieldRestriction & restriction( unsigned entity_rank , const Part & part) const ; - - const FieldRestrictionVector &restrictions() const ; - - const FieldRestrictionVector &selector_restrictions() const ; - - FieldBase * field_state(FieldState fstate) const { - return m_field_states[fstate]; - } - - void insert_restriction( const char * arg_method , - EntityRank arg_entity_rank , - const Part & arg_part , - const unsigned * arg_stride , - const void* arg_init_value = NULL); - - void insert_restriction( const char * arg_method , - EntityRank arg_entity_rank , - const Selector & arg_selector , - const unsigned * arg_stride , - const void* arg_init_value = NULL); - - void verify_and_clean_restrictions( const char * arg_method , - const Part& superset, const Part& subset, - const PartVector & arg_all_parts ); - - const void* get_initial_value() const; - - void* get_initial_value(); - - unsigned get_initial_value_num_bytes() const; - - void set_field_states( FieldBase ** field_states); - - FieldBaseImpl( - MetaData * arg_mesh_meta_data , - unsigned arg_ordinal , - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank, - const shards::ArrayDimTag * const * arg_dim_tags, - unsigned arg_number_of_states , - FieldState arg_this_state - ); - - ~FieldBaseImpl(); - -private: - - void set_initial_value(const void* new_initial_value, unsigned num_scalars, unsigned num_bytes); - - FieldRestrictionVector & restrictions(); - FieldRestrictionVector & selector_restrictions(); - - const std::string m_name ; ///< Name of the field - CSet m_attribute ; ///< User's attributes - const DataTraits & m_data_traits ; ///< Data type traits - MetaData * const m_meta_data ; ///< Owner of this field - const unsigned m_ordinal ; ///< Ordinal in the field set - const unsigned m_num_states ; ///< Number of states - const FieldState m_this_state ; ///< Field state of this field - unsigned m_field_rank ; ///< Number of dimensions - FieldRestrictionVector m_dim_map ; ///< Only valid on StateNone - FieldRestrictionVector m_selector_restrictions ; ///< Only valid on StateNone - FieldBase * m_field_states[ MaximumFieldStates ]; - const shards::ArrayDimTag * m_dim_tags[ MaximumFieldDimension ]; - void* m_initial_value; - unsigned m_initial_value_num_bytes; - - //disallow copy and default constructors - FieldBaseImpl(); - FieldBaseImpl( const FieldBase & ); - FieldBaseImpl & operator = ( const FieldBaseImpl & ); -}; - - -/** \brief Print the field type, text name, and number of states. */ -std::ostream & operator << ( std::ostream & , const FieldBaseImpl & ); - -/** \brief Print field and field restrictions on new lines. */ -std::ostream & print( std::ostream & , - const char * const , const FieldBase & ); - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_baseImpl_FieldBaseIml_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.cpp deleted file mode 100644 index 48eb00f1e400..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -namespace { - -std::string print_field_type(const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_tags ) -{ - std::ostringstream oss; - oss << "FieldBase<" ; - oss << arg_traits.name ; - for ( unsigned i = 0 ; i < arg_rank ; ++i ) { - oss << "," << arg_tags[i]->name(); - } - oss << ">" ; - return oss.str(); -} - -// Check for compatibility: -// 1) Scalar type must match -// 2) Number of states must match -// 3) Dimension must be different by at most one rank, -// where the tags match for the smaller rank. -void verify_field_type( const char * arg_method , - const FieldBase & arg_field , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states ) -{ - - const bool ok_traits = arg_traits.is_void - || & arg_traits == & arg_field.data_traits(); - - const bool ok_number_states = - ! arg_num_states || arg_num_states == arg_field.number_of_states(); - - bool ok_dimension = ! arg_rank || arg_rank == arg_field.rank() || - arg_rank + 1 == arg_field.rank() || - arg_rank - 1 == arg_field.rank() ; - - const unsigned check_rank = arg_rank < arg_field.rank() ? - arg_rank : arg_field.rank() ; - - for ( unsigned i = 0 ; i < check_rank && ok_dimension ; ++i ) { - ok_dimension = arg_dim_tags[i] == arg_field.dimension_tags()[i] ; - } - - ThrowErrorMsgIf( ! ok_traits || ! ok_number_states || ! ok_dimension, - arg_method << " FAILED: Existing field = " << - print_field_type( arg_field.data_traits() , - arg_field.rank() , - arg_field.dimension_tags() ) << - "[ name = \"" << arg_field.name() << - "\" , #states = " << arg_field.number_of_states() << " ]" << - " Expected field info = " << - print_field_type( arg_traits , arg_rank , arg_dim_tags ) << - "[ #states = " << arg_num_states << " ]"); -} - -} //unamed namespace - -//---------------------------------------------------------------------- - -FieldBase * FieldRepository::get_field( - const char * arg_method , - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states ) const -{ - FieldBase * f = NULL ; - - for ( std::vector::const_iterator - j = m_fields.begin() ; - j != m_fields.end() && NULL == f ; ++j ) { - if ( equal_case( (*j)->name() , arg_name ) ) { - - f = *j ; - - verify_field_type( arg_method , *f , arg_traits , - arg_rank , arg_dim_tags , arg_num_states ); - } - } - return f ; -} - -FieldBase * FieldRepository::declare_field( - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states , - MetaData * arg_meta_data ) -{ - TraceIf("stk_classic::mesh::impl::FieldRepository::declare_field", LOG_FIELD); - - static const char* reserved_state_suffix[6] = { - "_STKFS_OLD", - "_STKFS_N", - "_STKFS_NM1", - "_STKFS_NM2", - "_STKFS_NM3", - "_STKFS_NM4" - }; - - // Check that the name does not have a reserved suffix - - for ( unsigned i = 0 ; i < 6 ; ++i ) { - const int len_name = arg_name.size(); - const int len_suffix = std::strlen( reserved_state_suffix[i] ); - const int offset = len_name - len_suffix ; - if ( 0 <= offset ) { - const char * const name_suffix = arg_name.c_str() + offset ; - ThrowErrorMsgIf( equal_case( name_suffix , reserved_state_suffix[i] ), - "For name = \"" << name_suffix << - "\" CANNOT HAVE THE RESERVED STATE SUFFIX \"" << - reserved_state_suffix[i] << "\"" ); - } - } - - // Check that the field of this name has not already been declared - - FieldBase * f[ MaximumFieldStates ] ; - - f[0] = get_field( - "FieldRepository::declare_field" , - arg_name , - arg_traits , - arg_rank , - arg_dim_tags , - arg_num_states - ); - - if ( NULL != f[0] ) { - for ( unsigned i = 1 ; i < arg_num_states ; ++i ) { - f[i] = f[0]->m_impl.field_state(static_cast(i)); - } - } - else { - // Field does not exist then create it - - std::string field_names[ MaximumFieldStates ]; - - field_names[0] = arg_name ; - - if ( 2 == arg_num_states ) { - field_names[1] = arg_name ; - field_names[1].append( reserved_state_suffix[0] ); - } - else { - for ( unsigned i = 1 ; i < arg_num_states ; ++i ) { - field_names[i] = arg_name ; - field_names[i].append( reserved_state_suffix[i] ); - } - } - - for ( unsigned i = 0 ; i < arg_num_states ; ++i ) { - - f[i] = new FieldBase( - arg_meta_data , - m_fields.size() , - field_names[i] , - arg_traits , - arg_rank, - arg_dim_tags, - arg_num_states , - static_cast(i) - ); - - m_fields.push_back( f[i] ); - } - - for ( unsigned i = 0 ; i < arg_num_states ; ++i ) { - f[i]->m_impl.set_field_states( f ); - } - } - - return f[0] ; -} - -void FieldRepository::verify_and_clean_restrictions( - const char * arg_method , - const Part& superset, const Part& subset, - const PartVector & arg_all_parts ) -{ - TraceIf("stk_classic::mesh::impl::FieldRepository::verify_and_clean_restrictions", LOG_FIELD); - - for ( FieldVector::iterator f = m_fields.begin() ; f != m_fields.end() ; ++f ) { - (*f)->m_impl.verify_and_clean_restrictions( arg_method, superset, subset, arg_all_parts ); - } -} - -FieldRepository::~FieldRepository() { - try { - FieldVector::iterator j = m_fields.begin(); - for ( ; j != m_fields.end() ; ++j ) { delete *j ; } - m_fields.clear(); - } catch(...) {} -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.hpp deleted file mode 100644 index 0d6a8af3c2b6..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/FieldRepository.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#ifndef stk_mesh_baseImpl_FieldRepository_hpp -#define stk_mesh_baseImpl_FieldRepository_hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -typedef std::vector FieldVector; - -namespace impl { - -class FieldRepository { - - public: - FieldRepository() {} - ~FieldRepository(); - - FieldBase * get_field( - const char * arg_method , - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states - ) const; - - FieldBase * declare_field( - const std::string & arg_name , - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states , - MetaData * arg_meta_data - ); - - void verify_and_clean_restrictions( - const char * arg_method , - const Part& superset, const Part& subset, - const PartVector & arg_all_parts ); - - const FieldVector & get_fields() const { - return m_fields; - } - - template - const T * - declare_attribute_with_delete( FieldBase & f , const T * a ) - { - return f.m_impl.declare_attribute_with_delete(a); - } - - template - const T * - declare_attribute_no_delete( FieldBase & f , const T * a ) - { - return f.m_impl.declare_attribute_no_delete(a); - } - - void declare_field_restriction( - const char * arg_method, - FieldBase & arg_field , - unsigned arg_entity_rank , - const Part & arg_part , - const PartVector & arg_all_parts, - const unsigned * arg_stride , - const void * arg_init_value = NULL) - { - arg_field.m_impl.insert_restriction( arg_method, arg_entity_rank, arg_part, arg_stride, arg_init_value); - } - - void declare_field_restriction( - const char * arg_method, - FieldBase & arg_field , - unsigned arg_entity_rank , - const Selector & arg_selector , - const PartVector & arg_all_parts, - const unsigned * arg_stride , - const void * arg_init_value = NULL) - { - arg_field.m_impl.insert_restriction( arg_method, arg_entity_rank, arg_selector, arg_stride, arg_init_value); - } - - private: - FieldVector m_fields; - - //disallow copy and assignment - FieldRepository( const FieldRepository &); - FieldRepository & operator = ( const FieldRepository &); -}; - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - -#endif //stk_mesh_baseImpl_FieldRepository_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.cpp deleted file mode 100644 index 6756b697f5bc..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -//---------------------------------------------------------------------- -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -namespace impl { - -void PartImpl::add_part_to_subset( Part & part) -{ - TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_part_to_subset", LOG_PART, m_universe_ordinal); - DiagIfWatching(LOG_PART, m_universe_ordinal, "New subset is: " << part ); - - insert( m_subsets, part ); -} - - -void PartImpl::add_part_to_superset( Part & part ) -{ - TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_part_to_superset", LOG_PART, m_universe_ordinal); - DiagIfWatching(LOG_PART, m_universe_ordinal, "New superset is: " << part ); - - insert( m_supersets, part ); -} - -void PartImpl::add_relation( PartRelation relation ) -{ - TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_relation", LOG_PART, m_universe_ordinal); - DiagIfWatching(LOG_PART, m_universe_ordinal, "New relation from: " << relation.m_root << ", to: " << relation.m_target ); - - m_relations.push_back(relation); -} - -void PartImpl::set_intersection_of( const PartVector & pv ) -{ - TraceIfWatching("stk_classic::mesh::impl::PartImpl::set_intersection_of", LOG_PART, m_universe_ordinal); - DiagIfWatching(LOG_PART, m_universe_ordinal, "Intersection: " << pv ); - - m_intersect = pv ; -} - -// Subset part constructor: -PartImpl::PartImpl( MetaData * arg_meta_data , - const std::string & arg_name , - EntityRank arg_rank , - size_t arg_ordinal ) - : m_name( arg_name ), - m_attribute(), - m_subsets() , m_supersets() , m_intersect() , m_relations() , - m_mesh_meta_data( arg_meta_data ), - m_universe_ordinal( arg_ordinal ), - m_entity_rank( arg_rank ) -{} - -void PartImpl::set_primary_entity_rank( EntityRank entity_rank ) -{ - TraceIfWatching("stk_classic::mesh::impl::PartImpl::set_primary_entity_rank", LOG_PART, m_universe_ordinal); - if ( entity_rank == m_entity_rank ) return; - - const bool rank_already_set = m_entity_rank != InvalidEntityRank && entity_rank != m_entity_rank; - -//const bool has_subsets = m_subsets.size() > 0; -//ThrowErrorMsgIf( has_subsets, " Error: Part '" << m_name << "' has subsets"); - - if ( entity_rank == InvalidEntityRank ) return; - ThrowErrorMsgIf( rank_already_set, " Error: Different entity rank has already been set on Part"); - - m_entity_rank = entity_rank; -} - - -//---------------------------------------------------------------------- - - - -//---------------------------------------------------------------------- - -} // namespace impl - -} // namespace mesh -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.hpp deleted file mode 100644 index 599043c18169..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartImpl.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_PartImpl_hpp -#define stk_mesh_PartImpl_hpp - -//---------------------------------------------------------------------- - -#include -#include -#include - -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace impl { - -class PartImpl { -public: - - /** \brief The \ref stk_classic::mesh::MetaData "meta data manager" - * that owns this part - */ - MetaData & mesh_meta_data() const { return *m_mesh_meta_data ; } - - /** \brief The primary entity type for this part. - * - * For example, the primary purpose of an Element part - * is to define a collection of elements. However, the - * nodes of those elements are also members of an element part. - * Return InvalidEntityRank if no primary entity type. - */ - unsigned primary_entity_rank() const { return m_entity_rank ; } - - /** \brief Application-defined text name of this part */ - const std::string & name() const { return m_name ; } - - /** \brief Internally generated ordinal of this part that is unique - * within the owning \ref stk_classic::mesh::MetaData "meta data manager". - */ - unsigned mesh_meta_data_ordinal() const { return m_universe_ordinal ; } - - /** \brief Parts that are supersets of this part. */ - const PartVector & supersets() const { return m_supersets ; } - - /** \brief Parts that are subsets of this part. */ - const PartVector & subsets() const { return m_subsets ; } - - /** \brief Parts for which this part is defined as the intersection. */ - const PartVector & intersection_of() const { return m_intersect ; } - - /** \brief PartRelations for which this part is a member, root or target */ - const std::vector & relations() const { return m_relations ; } - - /** \brief Equality comparison */ - bool operator == ( const PartImpl & rhs ) const { return this == & rhs ; } - - /** \brief Inequality comparison */ - bool operator != ( const PartImpl & rhs ) const { return this != & rhs ; } - - /** \brief Query attribute that has been attached to this part */ - template - const A * attribute() const { return m_attribute.template get(); } - - explicit PartImpl( MetaData * ); - - void add_part_to_subset( Part & part); - void add_part_to_superset( Part & part ); - void add_relation( PartRelation relation ); - void set_intersection_of( const PartVector & ); - - template - const T * declare_attribute_with_delete( const T *); - template - const T * declare_attribute_no_delete( const T *); - template - bool remove_attribute( const T *); - - /** Construct a subset part within a given mesh. - * Is used internally by the two 'declare_part' methods. - */ - PartImpl( MetaData * meta, const std::string & name, - EntityRank rank, size_t ordinal); - - void set_primary_entity_rank( EntityRank entity_rank ); - -private: - -#ifndef DOXYGEN_COMPILE - - PartImpl(); - PartImpl( const PartImpl & ); - PartImpl & operator = ( const PartImpl & ); - - const std::string m_name ; - CSet m_attribute ; - PartVector m_subsets ; - PartVector m_supersets ; - PartVector m_intersect ; - std::vector m_relations ; - MetaData * const m_mesh_meta_data ; - const unsigned m_universe_ordinal ; - EntityRank m_entity_rank ; - -#endif /* DOXYGEN_COMPILE */ - -}; - -template -inline -const T * -PartImpl::declare_attribute_with_delete( const T * a ) -{ - return m_attribute.template insert_with_delete( a ); -} - -template -inline -const T * -PartImpl::declare_attribute_no_delete( const T * a ) -{ - return m_attribute.template insert_no_delete( a ); -} - -template -inline -bool -PartImpl::remove_attribute( const T * a ) -{ - return m_attribute.template remove( a ); -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.cpp deleted file mode 100644 index eb4abda75bd7..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace impl { - -namespace { - -inline -std::string universal_part_name() -{ - static const std::string name = convert_to_internal_name("UNIVERSAL"); - return name; -} - -void assert_same_universe( const Part & superset , - const Part & subset, - const char * method ) -{ - const PartVector & a = superset.supersets(); - const PartVector & b = subset.supersets(); - - ThrowErrorMsgIf( a.empty() || b.empty() || a[0] != b[0], - method << "(...) FAILED Requirement that " << - "Part[" << superset.name() << "] and " << - "Part[" << subset.name() << "] are in the same " << - universal_part_name() ); -} - -void assert_same( const Part & part1 , - const Part & part2, - const char * method ) -{ - ThrowErrorMsgIf( & part1 != & part2, - method << "(...) FAILED Requirement that " << - "Part[" << part1.name() << "] and " << - "Part[" << part2.name() << "] are the same" ); -} - -void assert_not_same( const Part & part1 , - const Part & part2 , - const char * method ) -{ - ThrowErrorMsgIf( & part1 == & part2, - method << "(...) FAILED Requirement that " << - "Part[" << part1.name() << "] and " << - "Part[" << part2.name() << "] are not the same" ); -} - -void assert_superset( Part & superset , - Part & subset , - const char * method ) -{ - ThrowErrorMsgIf( ! contain( subset.supersets() , superset ), - method << "(...) FAILED Requirement that " << - "Part[" << superset.name() << "] " << - "is a superset of " << - "Part[" << subset.name() << "]" ); -} - -void assert_not_superset( const Part & superset , - const Part & subset , - const char * method ) -{ - ThrowErrorMsgIf( contain( subset.supersets() , superset ), - method << "(...) FAILED Requirement that " << - "Part[" << superset.name() << "] " << - "is not a superset of " << - "Part[" << subset.name() << "]" ); -} - -void assert_rank_ordering( const Part & superset , - const Part & subset , - const char * method ) -{ - ThrowErrorMsgIf( superset.primary_entity_rank() < subset.primary_entity_rank(), - method << "(...) FAILED Requirement that " << - "Part[ " << superset.name() << - " , rank(" << superset.primary_entity_rank() << - ") ] has greater rank than " << - "Part[ " << subset.name() << - " , rank(" << subset.primary_entity_rank() << ") ]"); -} - -} // namespace - - -Part * PartRepository::universal_part() const -{ - return m_universal_part; -} - -const PartVector & PartRepository::get_all_parts() const -{ - return m_all_parts; -} - -Part * PartRepository::declare_part( const std::string & arg_name , EntityRank arg_rank ) -{ - Trace_("stk_classic::mesh::impl::PartRepository::declare_part"); - - const PartVector & all_parts = get_all_parts(); - Part * p = find( all_parts, arg_name ); - - if ( p == NULL ) { - p = declare_part_impl( arg_name, arg_rank ); - } - else { - p->m_partImpl.set_primary_entity_rank(arg_rank); - } - - return p; -} - -Part * PartRepository::declare_part( const PartVector & part_intersect ) -{ - static const char method[] = "stk_classic::mesh::impl::PartRepository::declare_part" ; - Trace_(method); - - PartVector pset_clean ; - - for ( PartVector::const_iterator - i = part_intersect.begin() ; i != part_intersect.end() ; ++i ) { - Part * const p = *i ; - assert_superset( *m_universal_part, *p , method ); - - // If 'p' is a superset of another member - // then it is redundant in this intersection. - // Only keep non-redundant intersections. - - PartVector::const_iterator j = part_intersect.begin(); - for ( ; j != part_intersect.end() && - ! contain( (*j)->supersets() , *p ) ; ++j ); - if ( j == part_intersect.end() ) { - pset_clean.push_back( p ); - } - } - - // Sort and unique the intersection - order( pset_clean ); - - Part * p = NULL ; - if ( 1 == pset_clean.size() ) { - // Only one remaining part, it is the subset. - p = pset_clean[0] ; - } - else { - const char separator[] = "^" ; - // Generate a name and rank reflecting the intersection. - // Rank is the minimum rank of the intersection members. - - std::string p_name ; - EntityRank p_rank = InvalidEntityRank; - - p_name.assign("{"); - for ( PartVector::iterator - i = pset_clean.begin() ; i != pset_clean.end() ; ++i ) { - if ( i != pset_clean.begin() ) { p_name.append( separator ); } - p_name.append( (*i)->name() ); - if ( (*i)->primary_entity_rank() < p_rank ) { - p_rank = (*i)->primary_entity_rank(); - } - } - p_name.append("}"); - - const PartVector & all_parts = get_all_parts(); - p = find( all_parts, p_name ); - if ( p == NULL ) { - // Create the part: - - p = declare_part_impl( p_name , p_rank ); - - // Define the part to be an intersection of the given parts: - - p->m_partImpl.set_intersection_of( pset_clean ); - - for ( PartVector::iterator - i = pset_clean.begin() ; i != pset_clean.end() ; ++i ) { - declare_subset( **i, *p ); - } - } - else { - // This error is "inconceivable" and is - // only possible by heroic malicious abuse. - ThrowInvalidArgMsgIf( pset_clean != p->intersection_of(), - p_name << " FAILED FROM MALICIOUS ABUSE" ); - } - } - - return p ; -} - - -Part * PartRepository::declare_part_impl( const std::string & name, EntityRank rank) -{ - size_t ordinal = get_all_parts().size(); - Part * part = new Part(m_meta_data,name,rank,ordinal); - declare_subset_impl(*m_universal_part, *part); - m_all_parts.push_back(part); - return part; -} - - -void PartRepository::declare_subset_impl( Part & superset_part, Part & subset_part ) -{ - superset_part.m_partImpl.add_part_to_subset( subset_part ); - subset_part.m_partImpl.add_part_to_superset( superset_part ); -} - - -void PartRepository::declare_subset( Part & superset, Part & subset ) -{ - static const char method[] = "stk_classic::mesh::impl::PartRepository::declare_subset" ; - Trace_(method); - - if ( ! contain( subset.supersets() , superset ) ) { - - assert_not_same( superset , subset , method ); - assert_not_superset( superset , subset , method ); - assert_same_universe( superset , subset , method ); - assert_rank_ordering( superset , subset , method ); - - // Insert this symmetric relationship first - // so that it does not get revisited. - - declare_subset_impl( superset, subset ); - - // Transitive: - - const PartVector & subset_subsets = subset.subsets(); - for ( PartVector::const_iterator - i = subset_subsets.begin() ; i != subset_subsets.end() ; ++i ) { - declare_subset( superset, **i ); - } - - const PartVector & superset_supersets = superset.supersets(); - for ( PartVector::const_iterator - i = superset_supersets.begin() ; i != superset_supersets.end() ; ++i ) { - declare_subset( **i, subset ); - } - - // Induced intersection-part membership: - - const PartVector & superset_subsets = superset.subsets(); - for ( PartVector::const_iterator - i = superset_subsets.begin() ; - i != superset_subsets.end() ; ++i ) { - - Part & pint = **i ; - - if ( ! pint.intersection_of().empty() && ( & pint != & subset ) ) { - - // If 'subset' is a subset of every member of 'pint.intersection_of()' - // then it is by definition a subset of 'pint. - if ( contain( subset.supersets() , pint.intersection_of() ) ) { - declare_subset( pint, subset ); - } - } - } - } -} - - -void PartRepository::declare_part_relation( Part & root_part, PartRelation relation, Part & target_part ) -{ - static const char method[] = "stk_classic::mesh::impl::PartRepository::declare_part_relation" ; - Trace_(method); - - assert_not_same( root_part , target_part , method ); - assert_same_universe( root_part , target_part , method ); - assert_same( root_part , *relation.m_root , method ); - assert_same( target_part , *relation.m_target , method ); - - root_part.m_partImpl.add_relation( relation ); - target_part.m_partImpl.add_relation( relation ); -} - - -PartRepository::PartRepository(MetaData * meta) - : m_meta_data(meta), - m_universal_part(NULL), - m_all_parts() -{ - m_universal_part = new Part( m_meta_data, universal_part_name(), ~0u, 0 ); - m_all_parts.push_back(m_universal_part); -} - -PartRepository::~PartRepository() -{ - try { - for ( PartVector::const_iterator i = m_all_parts.begin() ; - i != m_all_parts.end() ; ++i) { - Part * part = *i ; - try { delete part ; } catch(...) {} - } - } catch(...){} -} - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.hpp deleted file mode 100644 index 4be66956b7ff..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/baseImpl/PartRepository.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_PartRepository_hpp -#define stk_mesh_PartRepository_hpp - -#include -#include -#include - - -namespace stk_classic { -namespace mesh { - -class MetaData; - -namespace impl { - - -class PartRepository { -public: - explicit PartRepository(MetaData * meta); - ~PartRepository(); - - Part * universal_part() const; - - const PartVector & get_all_parts() const; - - Part * declare_part( const std::string & arg_name , EntityRank arg_rank ); - Part * declare_part( const PartVector & part_intersect ); - void declare_subset( Part & superset, Part & subset ); - void declare_part_relation( Part & root_part, PartRelation relation, Part & target_part ); - - template - const T * declare_attribute_with_delete( Part & , const T *); - template - const T * declare_attribute_no_delete( Part & , const T *); - template - bool remove_attribute( Part & , const T *); - -private: - PartRepository(); - PartRepository(const PartRepository & ); - PartRepository & operator = ( const PartRepository & ); - - Part * declare_part_impl( const std::string & name, EntityRank rank); - void declare_subset_impl( Part & superset, Part & subset ); - - MetaData * m_meta_data; - Part * m_universal_part; - PartVector m_all_parts; -}; - -template -inline -const T * -PartRepository::declare_attribute_with_delete( Part & p, const T * a ) -{ - return p.m_partImpl.declare_attribute_with_delete( a ); -} - -template -inline -const T * -PartRepository::declare_attribute_no_delete( Part & p, const T * a ) -{ - return p.m_partImpl.declare_attribute_no_delete( a ); -} - -template -inline -bool -PartRepository::remove_attribute( Part & p, const T * a ) -{ - return p.m_partImpl.remove_attribute( a ); -} - - -} // namespace impl -} // namespace mesh -} // namespace stk_classic - - -#endif // stk_mesh_PartRepository_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/diag/EntityKey.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/diag/EntityKey.hpp deleted file mode 100644 index 92e8c5033467..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/diag/EntityKey.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_diag_EntityKey_hpp -#define stk_mesh_diag_EntityKey_hpp - -#include -#include - - -namespace stk_classic { -namespace mesh { - -inline -stk_classic::diag::Writer &operator<<(stk_classic::diag::Writer &dout, const EntityKey &entity_key) { - return dout << entity_rank(entity_key) << ":" << entity_id(entity_key); -} - -} // namespace stk_classic -} // namespace mesh - -#endif // stk_mesh_diag_EntityKey_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.cpp deleted file mode 100644 index 553be321e234..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { - -namespace { - -const EntityRank NODE_RANK = fem::FEMMetaData::NODE_RANK; - -void filter_superimposed_entities(const Entity & entity, EntityVector & entities) -{ - // Get the node entities for the nodes that make up the entity, we'll - // use this to check for superimposed entities - PairIterRelation irel = entity.relations(NODE_RANK); - EntityVector entity_nodes; - entity_nodes.reserve(irel.size()); - for ( ; !irel.empty(); ++irel ) { - entity_nodes.push_back(irel->entity()); - } - std::sort(entity_nodes.begin(), entity_nodes.end()); - - // Make sure to remove the all superimposed entities from the list - unsigned num_nodes_in_orig_entity = entity_nodes.size(); - EntityVector current_nodes; - current_nodes.resize(num_nodes_in_orig_entity); - EntityVector::iterator itr = entities.begin(); - while ( itr != entities.end() ) { - Entity * current_entity = *itr; - PairIterRelation relations = current_entity->relations(NODE_RANK); - - if (current_entity == &entity) { - // Superimposed with self by definition - itr = entities.erase(itr); - } - else if (relations.size() != num_nodes_in_orig_entity) { - // current_entity has a different number of nodes than entity, they - // cannot be superimposed - ++itr; - } - else { - for (unsigned i = 0; relations.first != relations.second; - ++relations.first, ++i ) { - current_nodes[i] = relations.first->entity(); - } - std::sort(current_nodes.begin(), current_nodes.end()); - - bool entities_are_superimposed = entity_nodes == current_nodes; - if (entities_are_superimposed) { - itr = entities.erase(itr); - } - else { - ++itr; - } - } - } -} - -/** \brief Get the entities adjacent to the input entity. - * - * The adjacent entities are of the same rank as the input entity. - * Adjacency is defined by the input entity sharing a common - * sub-cell with the adjacent entities. - * - * subcell_rank defines the rank of the (potentially) common subcell - * subcell_identifier defined the local id of the common subcell - * adjacent_entities is an output parameter that contains pairs that - * have the adjacent entity and the local id of the common subcell - * with respect to the adjacent entity. - */ -void get_adjacent_entities( const Entity & entity , - EntityRank subcell_rank , - unsigned subcell_identifier , - std::vector< EntitySideComponent> & adjacent_entities) -{ - adjacent_entities.clear(); - - // Get nodes that make up the subcell we're looking at - EntityVector subcell_nodes; - const CellTopologyData * subcell_topology = fem::get_subcell_nodes(entity, - subcell_rank, - subcell_identifier, - subcell_nodes); - - - // Given the nodes related to the subcell, find all entities - // with the same rank that have a relation to all of these nodes - EntityVector potentially_adjacent_entities; - - get_entities_through_relations(subcell_nodes, - entity.entity_rank(), - potentially_adjacent_entities); - - // We don't want to include entities that are superimposed with - // the input entity - filter_superimposed_entities(entity, potentially_adjacent_entities); - - // Add the local ids, from the POV of the adj entitiy, to the return value. - // Reverse the nodes so that the adjacent entity has them in the positive - // orientation - std::reverse(subcell_nodes.begin(),subcell_nodes.end()); - - for (EntityVector::const_iterator eitr = potentially_adjacent_entities.begin(); - eitr != potentially_adjacent_entities.end(); ++eitr) { - int local_subcell_num = fem::get_entity_subcell_id(**eitr, - subcell_rank, - subcell_topology, - subcell_nodes); - if ( local_subcell_num != -1) { - adjacent_entities.push_back(EntitySideComponent(*eitr, local_subcell_num)); - } - } -} - -} // unnamed namespace - -void boundary_analysis(const BulkData& bulk_data, - const EntityVector & entities_closure, - EntityRank closure_rank, - EntitySideVector& boundary) -{ - const Selector locally_used = fem::FEMMetaData::get(bulk_data).locally_owned_part() - | fem::FEMMetaData::get(bulk_data).globally_shared_part(); - - // find an iterator that points to the last item in the closure that is of a - // lower-order than the closure_rank - EntityVector::const_iterator itr = - std::lower_bound(entities_closure.begin(), - entities_closure.end(), - EntityKey(closure_rank, 0), - EntityLess()); - - // iterate over all the entities in the closure up to the iterator we computed above - for ( ; itr != entities_closure.end() && (*itr)->entity_rank() == closure_rank; ++itr) { - // some temporaries for clarity - std::vector adjacent_entities; - Entity& curr_entity = **itr; - const CellTopologyData* celltopology = fem::get_cell_topology(curr_entity).getCellTopologyData(); - if (celltopology == NULL) { - continue; - } - - unsigned subcell_rank = closure_rank - 1; - PairIterRelation relations = curr_entity.relations(NODE_RANK); - - // iterate over the subcells of the current entity - for (unsigned nitr = 0; nitr < celltopology->subcell_count[subcell_rank]; ++nitr) { - // find the entities (same rank as subcell) adjacent to this subcell - unsigned subcell_identifier = nitr; - get_adjacent_entities(curr_entity, - closure_rank - 1, - subcell_identifier, - adjacent_entities); - - // try to figure out if we want to keep ((curr_entity, subcell_identifier), - // (adjacent_entity, [k])) - // if so, push into boundary - - // it is a keeper if adjacent entities[k] is not in the entities closure - // AND if either curr_entity OR adjacent entities[k] is a member of the - // bulk_data.locally_used - - if (adjacent_entities.empty()) { - EntitySide keeper; - keeper.inside.entity = &curr_entity; - keeper.inside.side_ordinal = subcell_identifier; - keeper.outside.entity = NULL; - keeper.outside.side_ordinal = 0; - boundary.push_back(keeper); - continue; - } - - // iterate over adjacent entities (our neighbors) - for (std::vector::const_iterator - adj_itr = adjacent_entities.begin(); - adj_itr != adjacent_entities.end(); ++adj_itr) { - // grab a reference to this neighbor for clarity - const Entity& neighbor = *(adj_itr->entity); - - // see if this neighbor is in the closure, if so, not a keeper - bool neighbor_is_in_closure = - std::binary_search(entities_closure.begin(), - entities_closure.end(), - neighbor, - EntityLess()); - - if (neighbor_is_in_closure) { - continue; - } - - // if neighbor or curr_entity is locally-used, add it to keeper - if ( locally_used( neighbor.bucket()) || locally_used( curr_entity.bucket() ) ) { - EntitySide keeper; - keeper.inside.entity = &curr_entity; - keeper.inside.side_ordinal = subcell_identifier; - keeper.outside = *adj_itr; - - boundary.push_back(keeper); - } - } - } - } -} - - -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.hpp deleted file mode 100644 index 8618e5e9cf72..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/BoundaryAnalysis.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_BoundaryAnalysis_hpp -#define stk_mesh_BoundaryAnalysis_hpp - -#include - -#include - -#include - -struct CellTopologyData; - -namespace stk_classic { -namespace mesh { - -class BulkData; -class Entity; - -/** - * A pair of Entity* and a local side id (defined a part of a side) - */ -NAMED_PAIR(EntitySideComponent, Entity *, entity, unsigned, side_ordinal) -/** - * A pair of EntitySideComponents (defines a side of the boundary) - * Most sides will have two EntitySideComponents, but degenerate cases - * ie shells will can have sides with more than two components) - */ -NAMED_PAIR(EntitySide, EntitySideComponent, inside, EntitySideComponent, outside) - -/** - * A vector of EntitySide (defines a boundary) - */ -typedef std::vector EntitySideVector; - -typedef std::vector EntitySideComponentVector; - -/** \brief Given a closure, return a boundary of items of closure_rank-1 - * - * A boundary will contain the entities "touching" the "outside" of the - * closure. - */ -void boundary_analysis(const BulkData & bulk_data, - const EntityVector & entities_closure, - EntityRank closure_rank, - EntitySideVector& boundary); - - -} -} -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CMakeLists.txt deleted file mode 100644 index 54ef03ed5560..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -SET(HEADERS_IMPL "") -SET(SOURCES_IMPL "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_mesh_fem - NOINSTALLHEADERS ${HEADERS} ${HEADERS_IMPL} - DEPLIBS stkclassic_mesh_base - SOURCES ${SOURCES} ${SOURCES_IMPL} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_mesh/fem/) - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CellTopology.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CellTopology.hpp deleted file mode 100644 index a8ef186ae5b1..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CellTopology.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef stk_mesh_fem_CellTopology_hpp -#define stk_mesh_fem_CellTopology_hpp - -#ifdef HAVE_SHARDS_DEBUG -#define STK_MESH_FEM_CHECK_REQUIRE( S ) S -#else -#define STK_MESH_FEM_CHECK_REQUIRE( S ) /* empty */ -#endif - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - -typedef shards::CellTopology CellTopology; - - - -template< typename id_type > -int findPermutation( const CellTopology top , - const id_type * const expected_node , - const id_type * const actual_node ) -{ - return shards::findPermutation( *top.getCellTopologyData() , expected_node , actual_node ); -} - -/** \} */ - -} // namespace fem -} // namespace mesh -} // namespace stk_classic - -#undef STK_MESH_FEM_CHECK_REQUIRE - -#endif // stk_mesh_fem_CellTopology_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.cpp deleted file mode 100644 index e2c810cefcc9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include - -#include -#include - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -//---------------------------------------------------------------------- - -namespace { - -unsigned get_index( const char * const func , - const unsigned number_names , - const char * const * names , - const unsigned size , - const char * const select ) -{ - unsigned index = size <= number_names ? 0 : size ; - - for ( ; index < size && not_equal_case(select,names[index]) ; ++index ); - - ThrowErrorMsgIf( index == size, - func << ", size = " << size << " label = " << select ); - return index ; -} - -const char * get_string( const char * const func , - const unsigned number_names , - const char * const * names , - const unsigned size , - const unsigned index ) -{ - ThrowErrorMsgIf( size < number_names || size <= index, - func << ", size = " << size << " index = " << index ); - - return names[index]; -} - -} - -//---------------------------------------------------------------------- - -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( SimpleArrayTag ) - -//---------------------------------------------------------------------- - -const Cartesian2d & Cartesian2d::tag() -{ static const Cartesian2d self ; return self ; } - -const char * Cartesian2d::name() const -{ static const char n[] = "Cartesian2d" ; return n ; } - -namespace { -const char * const * Cartesian2d_label() { - static const char x[] = "x" ; - static const char y[] = "y" ; - static const char * label[] = { x , y }; - return label; -} -} -std::string Cartesian2d::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( Cartesian2d::tag().name() , - 2 , Cartesian2d_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type Cartesian2d::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( Cartesian2d::tag().name() , - 2 , Cartesian2d_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const Cartesian3d & Cartesian3d::tag() -{ static const Cartesian3d self ; return self ; } - -const char * Cartesian3d::name() const -{ static const char n[] = "Cartesian3d" ; return n ; } - -namespace { -const char * const * Cartesian3d_label() { - static const char x[] = "x" ; - static const char y[] = "y" ; - static const char z[] = "z" ; - static const char * label[] = { x , y , z }; - return label; -} -} -std::string Cartesian3d::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( Cartesian3d::tag().name() , - 3 , Cartesian3d_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type Cartesian::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( Cartesian3d::tag().name() , - 3 , Cartesian3d_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const Cylindrical & Cylindrical::tag() -{ static const Cylindrical self ; return self ; } - -const char * Cylindrical::name() const -{ static const char n[] = "Cylindrical" ; return n ; } - -namespace { -const char * const * Cylindrical_label() { - static const char r[] = "r" ; - static const char a[] = "a" ; - static const char z[] = "z" ; - static const char * label[] = { r , a , z }; - return label; -} -} -std::string Cylindrical::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( Cylindrical::tag().name() , - 3 , Cylindrical_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type Cylindrical::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( Cylindrical::tag().name() , - 3 , Cylindrical_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const FullTensor & FullTensor::tag() -{ static const FullTensor self ; return self ; } - -const char * FullTensor::name() const -{ static const char n[] = "FullTensor" ; return n ; } - -namespace { -const char * const * FullTensor36_label() { - static const char xx[] = "xx" ; - static const char yx[] = "yx" ; - static const char zx[] = "zx" ; - static const char xy[] = "xy" ; - static const char yy[] = "yy" ; - static const char zy[] = "zy" ; - static const char xz[] = "xz" ; - static const char yz[] = "yz" ; - static const char zz[] = "zz" ; - static const char * label[] = { xx , yy , zz , - xy , yz , zx , - yx , zy , xz }; - return label; -} -} -std::string FullTensor36::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( FullTensor36::tag().name() , - 9 , FullTensor36_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type FullTensor::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( FullTensor36::tag().name() , - 9 , FullTensor36_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const FullTensor22 & FullTensor22::tag() -{ static const FullTensor22 self ; return self ; } - -const char * FullTensor22::name() const -{ static const char n[] = "FullTensor22" ; return n ; } - -namespace { -const char * const * FullTensor22_label() { - static const char xx[] = "xx" ; - static const char yy[] = "yy" ; - static const char xy[] = "xy" ; - static const char yx[] = "yx" ; - static const char * label[] = { xx, yy, xy, yx }; - return label; -} -} -std::string FullTensor22::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( FullTensor22::tag().name() , - 4 , FullTensor22_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type FullTensor22::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( FullTensor22::tag().name() , - 4 , FullTensor22_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const SymmetricTensor33 & SymmetricTensor33::tag() -{ static const SymmetricTensor33 self ; return self ; } - -const char * SymmetricTensor::name() const -{ static const char n[] = "SymmetricTensor" ; return n ; } - -namespace { -const char * const * SymmetricTensor33_label() { - static const char xx[] = "xx" ; - static const char yy[] = "yy" ; - static const char zz[] = "zz" ; - static const char xy[] = "xy" ; - static const char yz[] = "yz" ; - static const char xz[] = "xz" ; - static const char * label[] = { xx , yy , zz , xy , yz , xz }; - return label; -} -} -std::string SymmetricTensor33::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( SymmetricTensor33::tag().name() , - 6 , SymmetricTensor33_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type SymmetricTensor33::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( SymmetricTensor33::tag().name() , - 6 , SymmetricTensor33_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const SymmetricTensor31 & SymmetricTensor31::tag() -{ static const SymmetricTensor31 self ; return self ; } - -const char * SymmetricTensor31::name() const -{ static const char n[] = "SymmetricTensor31" ; return n ; } - -namespace { -const char * const * SymmetricTensor31_label() { - static const char rr[] = "rr" ; - static const char zz[] = "zz" ; - static const char rz[] = "rz" ; - static const char zr[] = "zr" ; - static const char * label[] = { rr, zz, rz, zr }; - return label; -} -} -std::string SymmetricTensor31::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( SymmetricTensor31::tag().name() , - 4 , SymmetricTensor31_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type SymmetricTensor31::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( SymmetricTensor31::tag().name() , - 4 , SymmetricTensor31_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const SymmetricTensor21 & SymmetricTensor21::tag() -{ static const SymmetricTensor21 self ; return self ; } - -const char * SymmetricTensor21::name() const -{ static const char n[] = "SymmetricTensor21" ; return n ; } - -namespace { -const char * const * SymmetricTensor21_label() { - static const char xx[] = "xx" ; - static const char yy[] = "yy" ; - static const char xy[] = "xy" ; - static const char * label[] = { xx, yy, xy }; - return label; -} -} -std::string SymmetricTensor21::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( SymmetricTensor21::tag().name() , - 3 , SymmetricTensor21_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type SymmetricTensor21::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( SymmetricTensor21::tag().name() , - 3 , SymmetricTensor21_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const AsymmetricTensor03 & AsymmetricTensor03::tag() -{ static const AsymmetricTensor03 self ; return self ; } - -const char * AsymmetricTensor03::name() const -{ static const char n[] = "AsymmetricTensor03" ; return n ; } - -namespace { -const char * const * AsymmetricTensor03_label() { - static const char yz[] = "yz" ; - static const char xz[] = "xz" ; - static const char xy[] = "xy" ; - static const char * label[] = { xy, yz, xz }; - return label; -} -} -std::string AsymmetricTensor03::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( AsymmetricTensor03::tag().name() , - 3 , AsymmetricTensor03_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type AsymmetricTensor03::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( AsymmetricTensor03::tag().name() , - 3 , AsymmetricTensor03_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const Matrix22 & Matrix22::tag() -{ static const Matrix22 self ; return self ; } - -const char * Matrix22::name() const -{ static const char n[] = "Matrix22" ; return n ; } - -namespace { -const char * const * Matrix22_label() { - static const char xx[] = "xx" ; - static const char yx[] = "yx" ; - static const char xy[] = "xy" ; - static const char yy[] = "yy" ; - static const char * label[] = { xx , yx, xy, yy }; - return label; -} -} -std::string Matrix22::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( Matrix22::tag().name() , - 4 , Matrix22_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type Matrix22::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( Matrix22::tag().name() , - 4 , Matrix22_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -const Matrix33 & Matrix33::tag() -{ static const Matrix33 self ; return self ; } - -const char * Matrix33::name() const -{ static const char n[] = "Matrix33" ; return n ; } - -namespace { -const char * const * Matrix33_label() { - static const char xx[] = "xx" ; - static const char yx[] = "yx" ; - static const char zx[] = "zx" ; - static const char xy[] = "xy" ; - static const char yy[] = "yy" ; - static const char zy[] = "zy" ; - static const char xz[] = "xz" ; - static const char yz[] = "yz" ; - static const char zz[] = "zz" ; - static const char * label[] = { xx , yx , zx , xy , yy , zy , xz , yz , zz }; - return label; -} -} -std::string Matrix33::to_string( shards::ArrayDimTag::size_type size , shards::ArrayDimTag::size_type index ) const -{ - return std::string( get_string( Matrix33::tag().name() , - 9 , Matrix33_label() , size , index ) ); -} - -shards::ArrayDimTag::size_type Matrix33::to_index( shards::ArrayDimTag::size_type size , const std::string & arg ) const -{ - return get_index( Matrix33::tag().name() , - 9 , Matrix33_label() , size , arg.c_str() ); -} - -//---------------------------------------------------------------------- - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.hpp deleted file mode 100644 index 2cda8f3352b3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CoordinateSystems.hpp +++ /dev/null @@ -1,317 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_mesh_fem_CoordinateSystems_hpp -#define stk_mesh_fem_CoordinateSystems_hpp - -//---------------------------------------------------------------------- - -#include - -namespace stk_classic { -namespace mesh { - -/** \addtogroup stk_mesh_field_dimension_tags - * \{ - * - * ArrayDimTags are required for multidimensional Field types; they specify - * the dimensions of the field and the intent of each dimension. Note that - * scalar Field types do not involve ArrayDimTags. This file defines a number - * of ArrayDimTags that we believe will be widely useful for STK users. Clients - * have the freedom to define their own ArrayDimTags as well. - * - * Example use of Cartesian ArrayDimTag to create a field type: - * stk_classic::mesh::Field - */ - -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( SimpleArrayTag ) - -/** - * \brief Implement an shards::ArrayDimTag for Cartesian coordinate dimensions. - * - * A Cartesian coordinate has up to three dimensions in X, Y, Z order. - */ -struct Cartesian3d : public shards::ArrayDimTag { - - enum { Size = 3 }; ///< default size - - enum { X = 0 , Y = 1 , Z = 2 }; ///< Identifiers for each dimension - - const char * name() const ; - std::string to_string( size_type size , size_type index ) const ; - size_type to_index( size_type size , const std::string & ) const ; - static const Cartesian3d & tag(); ///< Singleton - -private: - Cartesian3d() {} - Cartesian3d( const Cartesian3d & ); - Cartesian3d & operator = ( const Cartesian3d & ); -}; - -/** - * \brief Implement an shards::ArrayDimTag for Cartesian 2d coordinate dimensions. - * - * A Cartesian coordinate has up to two dimensions in X, Y order. - */ -struct Cartesian2d: public shards::ArrayDimTag { - - enum { Size = 2 }; ///< default size - - enum { X = 0 , Y = 1 }; ///< Identifiers for each dimension - - const char * name() const ; - std::string to_string( size_type size , size_type index ) const ; - size_type to_index( size_type size , const std::string & ) const ; - static const Cartesian2d & tag(); ///< Singleton - -private: - Cartesian2d() {} - Cartesian2d( const Cartesian2d & ); - Cartesian2d & operator = ( const Cartesian2d & ); -}; - -typedef Cartesian3d Cartesian; -/** - * \brief Implement an shards::ArrayDimTag for Cylindrical coordinate dimensions. - * - * A Cylindral coordinate has up to three dimensions in - * radius, angle, and longitudinal-distance order. - */ -struct Cylindrical : public shards::ArrayDimTag { - - enum { Radius = 0 , R = 0 , ///< Identifiers for each dimension - Angle = 1 , A = 1 , - Z = 2 }; - - const char * name() const ; - std::string to_string( size_type size , size_type index ) const ; - size_type to_index( size_type size , const std::string & ) const ; - static const Cylindrical & tag(); ///< Singleton - -private: - Cylindrical() {} - Cylindrical( const Cylindrical & ); - Cylindrical & operator = ( const Cylindrical & ); -}; - -/** - * \brief Implement an shards::ArrayDimTag for FullTensor. - * - * \todo REFACTOR Where should FullTensor live, in the application, - * in the toolkit or a common application header? - */ -struct FullTensor36 : public shards::ArrayDimTag { - - enum { Size = 9 }; - -/* - * Note on Ordering: This is the ordering as used in the old - * Sierra Framework and is somewhat standard in that a symmetric - * tensor is the first six values of a full tensor and a diagonal - * only tensor is the first three values of that. - * - * I think this is actually in ERROR in that (XZ,YX,ZY) SHOULD - * be (6,7,8) NOT (8,6,7). But backwards compatibility is useful. - * - * \todo Look at the proper ordering of a full second order tensor. - */ - enum { XX = 0 , XY = 3 , XZ = 8 , - YX = 6 , YY = 1 , YZ = 4 , - ZX = 5 , ZY = 7 , ZZ = 2 }; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type, const std::string & ) const ; - static const FullTensor36 & tag(); ///< Singleton - -private: - FullTensor36() {} - FullTensor36( const FullTensor36 & ); - FullTensor36 & operator = ( const FullTensor36 & ); -}; - -typedef FullTensor36 FullTensor; - -/** - * \brief Implement an shards::ArrayDimTag for FullTensor. - */ -struct FullTensor22 : public shards::ArrayDimTag { - - enum { Size = 4 }; - - enum { XX = 0 , XY = 2 , - YX = 3 , YY = 1}; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type, const std::string & ) const ; - static const FullTensor22 & tag(); ///< Singleton - -private: - FullTensor22() {} - FullTensor22( const FullTensor22 & ); - FullTensor22 & operator = ( const FullTensor22 & ); -}; - -//---------------------------------------------------------------------- - -/** - * \brief Implement an shards::ArrayDimTag for SymmetricTensor. - * - * \todo REFACTOR Where should SymmetricTensor live, in the application, - * in the toolkit or a common application header? - */ -struct SymmetricTensor33 : public shards::ArrayDimTag { - - enum { Size = 6 }; - - enum { XX = 0 , XY = 3, XZ = 5, - YX = 3 , YY = 1, YZ = 4, - ZX = 5 , ZY = 4, ZZ = 2}; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const SymmetricTensor33 & tag(); ///< Singleton - -private: - SymmetricTensor33() {} - SymmetricTensor33( const SymmetricTensor33 & ); - SymmetricTensor33 & operator = ( const SymmetricTensor33 & ); -}; - -typedef SymmetricTensor33 SymmetricTensor; - -/** - * \brief Implement an shards::ArrayDimTag for SymmetricTensor. - * - * SymmetricTensor31 is an axisymmetric tensor in 3D. It - * has the radius and height of the cylindrical coordinate - * system but with no theta coordinate. - */ -struct SymmetricTensor31 : public shards::ArrayDimTag { - - enum { Size = 4 }; - - enum { rr = 0 , rz = 2 , - zr = 3 , zz = 1}; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const SymmetricTensor31 & tag(); ///< Singleton - -private: - SymmetricTensor31() {} - SymmetricTensor31( const SymmetricTensor31 & ); - SymmetricTensor31 & operator = ( const SymmetricTensor31 & ); -}; - -/** - * \brief Implement an shards::ArrayDimTag for SymmetricTensor. - */ -struct SymmetricTensor21 : public shards::ArrayDimTag { - - enum { Size = 3 }; - - enum { XX = 0 , XY = 2 , - YX = 2 , YY = 1 }; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const SymmetricTensor21 & tag(); ///< Singleton - -private: - SymmetricTensor21() {} - SymmetricTensor21( const SymmetricTensor21 & ); - SymmetricTensor21 & operator = ( const SymmetricTensor21 & ); -}; - -/** - * \brief Implement an shards::ArrayDimTag for AsymmetricTensor. - * - * Note: I think by Axymmetric is ment Skew-symmetric. - * Asymmetric would be any non-symmetric tensor while skew-symmetric - * means it is equal to the negative of it's transpose. This - * forces the diagonals to be zero and only the three off-diagonal - * elements are useful. - */ -struct AsymmetricTensor03 : public shards::ArrayDimTag { - - enum { Size = 3 }; - - enum { /* XX = 0 */ XY = 0 , XZ = 2 , - YX = 0 ,/* YY = 0 */ YZ = 1 , - ZX = 2 , ZY = 1 /* ZZ=0 */ }; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const AsymmetricTensor03 & tag(); ///< Singleton - -private: - AsymmetricTensor03() {} - AsymmetricTensor03( const AsymmetricTensor03 & ); - AsymmetricTensor03 & operator = ( const AsymmetricTensor03 & ); -}; - -typedef AsymmetricTensor03 AsymmetricTensor; - -/** - * \brief Implement an shards::ArrayDimTag for Matrix. - */ -struct Matrix22 : public shards::ArrayDimTag { - - enum { Size = 4 }; - - enum { XX = 0 , XY = 2 , - YX = 1, YY = 3 }; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const Matrix22 & tag(); ///< Singleton - -private: - Matrix22() {} - Matrix22( const Matrix22 & ); - Matrix22 & operator = ( const Matrix22 & ); -}; - -/** - * \brief Implement an shards::ArrayDimTag for Matrix. - */ -struct Matrix33 : public shards::ArrayDimTag { - - enum { Size = 9 }; - - enum { XX = 0 , XY = 3 , XZ = 6 , - YX = 1 , YY = 4 , YZ = 7 , - ZX = 2 , ZY = 5 , ZZ = 8 }; - - const char * name() const ; - std::string to_string( size_type, size_type) const ; - size_type to_index( size_type , const std::string & ) const ; - static const Matrix33 & tag(); ///< Singleton - -private: - Matrix33() {} - Matrix33( const Matrix33 & ); - Matrix33 & operator = ( const Matrix33 & ); -}; - -//---------------------------------------------------------------------- - -/** \} */ - -} //namespace mesh -} //namespace stk_classic - -#endif //stk_mesh_fem_CoordinateSystems_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.cpp deleted file mode 100644 index a962e7a48947..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.cpp +++ /dev/null @@ -1,494 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -namespace { - - -struct EntitySubcellComponent { - public: - EntitySubcellComponent() - : entity(NULL) - , subcell_rank(0) - , subcell_id(0) - {} - - EntitySubcellComponent( - Entity * arg_entity, - EntityRank arg_subcell_rank, - unsigned arg_subcell_id - ) - : entity(arg_entity) - , subcell_rank(arg_subcell_rank) - , subcell_id(arg_subcell_id) - {} - - Entity * entity; - EntityRank subcell_rank; - unsigned subcell_id; -}; - - - -void get_entities_with_given_subcell( - const CellTopologyData * subcell_topology, - const EntityRank subcell_rank, - const EntityVector & subcell_nodes, - const EntityRank entities_rank, - std::vector< EntitySubcellComponent> & entities_with_subcell - ) -{ - // Get all entities that have relations to all the subcell nodes - EntityVector entities; - get_entities_through_relations(subcell_nodes, - entities_rank, - entities); - - // For all such entities, add id info for the subcell if the subcell - // nodes compose a valid subcell of the entity - for (EntityVector::const_iterator eitr = entities.begin(); - eitr != entities.end(); ++eitr) { - int local_subcell_num = fem::get_entity_subcell_id( - **eitr, - subcell_rank, - subcell_topology, - subcell_nodes); - if ( local_subcell_num != -1) { - entities_with_subcell.push_back(EntitySubcellComponent(*eitr, subcell_rank, local_subcell_num)); - } - } -} - - - -// Check if 3d element topology topo is degenerate -bool is_degenerate( const fem::CellTopology & topo) -{ - return topo.getSideCount() < 3; -} - -// Check if entity has a specific relation to an entity of subcell_rank -bool relation_exist( const Entity & entity, EntityRank subcell_rank, RelationIdentifier subcell_id ) -{ - bool found = false; - PairIterRelation relations = entity.relations(subcell_rank); - - for (; !relations.empty(); ++relations) { - if (relations->identifier() == subcell_id) { - found = true; - break; - } - } - - return found; -} - - - -void internal_count_entities_to_create( BulkData & mesh, std::vector & entities_to_request) { - - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(mesh); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - const EntityRank edge_rank = fem_meta.edge_rank(); - - Selector select_owned = fem::FEMMetaData::get(mesh).locally_owned_part(); - - - BucketVector element_buckets; - - get_buckets( select_owned, mesh.buckets(element_rank), element_buckets); - - - for ( EntityRank subcell_rank = side_rank; subcell_rank >= edge_rank; --subcell_rank) { - for (BucketVector::iterator bitr = element_buckets.begin(); - bitr != element_buckets.end(); - ++bitr) - { - Bucket & b = **bitr; - const fem::CellTopology topo = fem::get_cell_topology(b); - - ThrowErrorMsgIf( is_degenerate(topo), - "stk_classic::mesh::create_adjacent_entities(...) does not yet support degenerate topologies (i.e. shells and beams)"); - - - if ( !is_degenerate(topo) ) { // don't loop over shell elements - - for (size_t i = 0; i adjacent_elements; - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - element_rank, - adjacent_elements - ); - - std::reverse( subcell_nodes.begin(), subcell_nodes.end()); - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - element_rank, - adjacent_elements - ); - - bool current_elem_has_lowest_id = true; - //does this process own the element with the lowest id? - - for (std::vector::iterator adjacent_itr = adjacent_elements.begin(); - adjacent_itr != adjacent_elements.end(); - ++adjacent_itr) - { - if (adjacent_itr->entity->identifier() < elem.identifier()) { - current_elem_has_lowest_id = false; - break; - } - } - - // This process owns the lowest element so - // needs to generate a request to create - // the subcell - if (current_elem_has_lowest_id) { - entities_to_request[subcell_rank]++; - } - } - } - } - } - } - } -} - -void request_entities( - BulkData & mesh, - std::vector & entities_to_request, - std::vector< EntityVector > & requested_entities) -{ - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(mesh); - const size_t num_ranks = fem_meta.entity_rank_count(); - - requested_entities.clear(); - requested_entities.resize(num_ranks); - - EntityVector requested_entities_flat_vector; - mesh.generate_new_entities(entities_to_request, requested_entities_flat_vector); - - EntityVector::iterator b_itr = requested_entities_flat_vector.begin(); - - for (size_t i=0; i & entities_to_request) { - - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(mesh); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - const EntityRank edge_rank = fem_meta.edge_rank(); - - const size_t num_ranks = fem_meta.entity_rank_count(); - - Selector select_owned = fem_meta.locally_owned_part(); - - BucketVector element_buckets; - - get_buckets( select_owned, mesh.buckets(element_rank), element_buckets); - - - mesh.modification_begin(); - - - std::vector< EntityVector > requested_entities; - - request_entities( - mesh, - entities_to_request, - requested_entities - ); - - std::vector entities_used(num_ranks, 0); - - for ( EntityRank subcell_rank = side_rank; subcell_rank >= edge_rank; --subcell_rank) { - for (BucketVector::iterator bitr = element_buckets.begin(); - bitr != element_buckets.end(); - ++bitr) - { - Bucket & b = **bitr; - const fem::CellTopology topo = fem::get_cell_topology(b); - - if ( !is_degenerate(topo) ) { // don't loop over shell elements - - for (size_t i = 0; i adjacent_elements; - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - element_rank, - adjacent_elements - ); - - std::reverse( subcell_nodes.begin(), subcell_nodes.end()); - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - element_rank, - adjacent_elements - ); - - bool current_elem_has_lowest_id = true; - //does this process own the element with the lowest id? - - for (std::vector::iterator adjacent_itr = adjacent_elements.begin(); - adjacent_itr != adjacent_elements.end(); - ++adjacent_itr) - { - if (adjacent_itr->entity->identifier() < elem.identifier()) { - current_elem_has_lowest_id = false; - break; - } - } - - // This process owns the lowest element so - // needs to generate a request to create - // the subcell - if (current_elem_has_lowest_id) { - Entity & subcell = * requested_entities[subcell_rank][entities_used[subcell_rank]++]; - - - //declare the node relations for this subcell - for (size_t n = 0; n= edge_rank; --subcell_rank) { - - mesh.modification_begin(); - for (EntityRank entity_rank = element_rank; entity_rank > subcell_rank; --entity_rank) { - - - BucketVector entity_buckets; - - - get_buckets(select_owned_or_shared, mesh.buckets(entity_rank),entity_buckets); - - for (BucketVector::iterator bitr = entity_buckets.begin(); - bitr != entity_buckets.end(); - ++bitr) - { - Bucket & b = **bitr; - const fem::CellTopology topo = fem::get_cell_topology(b); - - ThrowErrorMsgIf( is_degenerate(topo), - "stk_classic::mesh::create_adjacent_entities(...) does not yet support degenerate topologies (i.e. shells and beams)"); - - { - for (size_t i = 0; i adjacent_entities; - - // add polarity information to newly created relations - // polarity information is required to correctly attached - // degenerate elements to the correct faces and edges - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - subcell_rank, - adjacent_entities - ); - - std::reverse( subcell_nodes.begin(), subcell_nodes.end()); - - get_entities_with_given_subcell( - subcell_topology, - subcell_rank, - subcell_nodes, - subcell_rank, - adjacent_entities - ); - - - if ( !adjacent_entities.empty()) { - - mesh.declare_relation( entity, *adjacent_entities[0].entity, subcell_id); - } - } - } - } - } - } - } - mesh.modification_end(); - } - -} - -} // un-named namespace - -void create_adjacent_entities( BulkData & mesh, PartVector & arg_add_parts) -{ - ThrowErrorMsgIf(mesh.synchronized_state() == BulkData::MODIFIABLE, - "stk_classic::mesh::skin_mesh is not SYNCHRONIZED"); - - // to handle degenerate topologies we anticipate the following order of operations - // - // complete_connectivity - // count degenerate entities to create - // create degenerate entities - // complete_connectivity - // count non degenerate entities to create - // create non degenerate entities - // complete_connectivity - // - // to complete the connectivity (with degenerate elements) we require that - // polarity information to be stored on each relation - - - complete_connectivity(mesh); - - - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(mesh); - const size_t num_ranks = fem_meta.entity_rank_count(); - std::vector entities_to_request(num_ranks, 0); - - internal_count_entities_to_create( mesh, entities_to_request); - - internal_create_adjacent_entities( mesh, arg_add_parts, entities_to_request); - - - complete_connectivity(mesh); - - -} - -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.hpp deleted file mode 100644 index b00e7e2b6354..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/CreateAdjacentEntities.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_CreateAdjacentEntities_hpp -#define stk_mesh_CreateAdjacentEntities_hpp - -#include - -namespace stk_classic { -namespace mesh { - -/** Create all the internal entities and their relations, - * i.e. given a mesh with element and node relations - * * create all the side and edges - * * and setup the relations - * - * Expensive function that should only be called once - * - * This is a parallel collective function (it should be called on all - * processors at the same time - * - * \param mesh A consisent mesh with Element and node relations - * \param add_parts Newly created entities will be added to the add_parts and - * the root part for the given subcell topology. Note, no part in the - * 'add_parts' vector can have a primary_entity_rank - */ -void create_adjacent_entities( - BulkData & mesh, - PartVector & add_parts - ); - -} -} -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.cpp deleted file mode 100644 index a02a0cc8bd10..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.cpp +++ /dev/null @@ -1,446 +0,0 @@ -#include -#include - -#include - -#include -#include - -#include - -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - -namespace { - -void verify_declare_element_side( - const BulkData & mesh, - const Entity & elem, - const unsigned local_side_id - ) -{ - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - const CellTopologyData * const side_top = - ( elem_top && local_side_id < elem_top->side_count ) - ? elem_top->side[ local_side_id ].topology : NULL ; - - ThrowErrorMsgIf( &mesh != & BulkData::get(elem), - "For elem " << print_entity_key(elem) << - ", Bulkdata for 'elem' and mesh are different"); - - ThrowErrorMsgIf( elem_top && local_side_id >= elem_top->side_count, - "For elem " << print_entity_key(elem) << ", local_side_id " << local_side_id << ", " << - "local_side_id exceeds " << elem_top->name << ".side_count = " << elem_top->side_count ); - - ThrowErrorMsgIf( side_top == NULL, - "For elem " << print_entity_key(elem) << ", local_side_id " << local_side_id << ", " << - "No element topology found"); -} - -void verify_declare_element_edge( - const BulkData & mesh, - const Entity & elem, - const unsigned local_edge_id - ) -{ - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - const CellTopologyData * const edge_top = - ( elem_top && local_edge_id < elem_top->edge_count ) - ? elem_top->edge[ local_edge_id ].topology : NULL ; - - ThrowErrorMsgIf( &mesh != & BulkData::get(elem), - "For elem " << print_entity_key(elem) << - ", Bulkdata for 'elem' and mesh are different"); - - ThrowErrorMsgIf( elem_top && local_edge_id >= elem_top->edge_count, - "For elem " << print_entity_key(elem) << ", local_edge_id " << local_edge_id << ", " << - "local_edge_id exceeds " << elem_top->name << ".edge_count = " << elem_top->edge_count ); - - ThrowErrorMsgIf( edge_top == NULL, - "For elem " << print_entity_key(elem) << ", local_edge_id " << local_edge_id << ", " << - "No element topology found"); -} - -} // unnamed namespace - -Entity & declare_element( BulkData & mesh , - Part & part , - const EntityId elem_id , - const EntityId node_id[] ) -{ - FEMMetaData & fem_meta = FEMMetaData::get(mesh); - const CellTopologyData * const top = fem_meta.get_cell_topology( part ).getCellTopologyData(); - - ThrowErrorMsgIf(top == NULL, - "Part " << part.name() << " does not have a local topology"); - - PartVector empty ; - PartVector add( 1 ); add[0] = & part ; - - const EntityRank entity_rank = fem_meta.element_rank(); - - Entity & elem = mesh.declare_entity( entity_rank, elem_id, add ); - - const EntityRank node_rank = fem_meta.node_rank(); - - for ( unsigned i = 0 ; i < top->node_count ; ++i ) { - //declare node if it doesn't already exist - Entity * node = mesh.get_entity( node_rank , node_id[i]); - if ( NULL == node) { - node = & mesh.declare_entity( node_rank , node_id[i], empty ); - } - - mesh.declare_relation( elem , *node , i ); - } - return elem ; -} - -Entity & declare_element_side( - Entity & elem , - Entity & side, - const unsigned local_side_id , - Part * part ) -{ - BulkData & mesh = BulkData::get(side); - - verify_declare_element_side(mesh, elem, local_side_id); - - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - ThrowErrorMsgIf( elem_top == NULL, - "Element[" << elem.identifier() << "] has no defined topology" ); - - const CellTopologyData * const side_top = elem_top->side[ local_side_id ].topology; - - ThrowErrorMsgIf( side_top == NULL, - "Element[" << elem.identifier() << "], local_side_id = " << - local_side_id << ", side has no defined topology" ); - - const unsigned * const side_node_map = elem_top->side[ local_side_id ].node ; - - PartVector add_parts ; - - if ( part ) { add_parts.push_back( part ); } - - mesh.change_entity_parts(side, add_parts); - - mesh.declare_relation( elem , side , local_side_id ); - - PairIterRelation rel = elem.relations( FEMMetaData::NODE_RANK ); - - for ( unsigned i = 0 ; i < side_top->node_count ; ++i ) { - Entity & node = * rel[ side_node_map[i] ].entity(); - mesh.declare_relation( side , node , i ); - } - - return side ; -} - -Entity & declare_element_edge( - Entity & elem , - Entity & edge, - const unsigned local_edge_id , - Part * part ) -{ - BulkData & mesh = BulkData::get(edge); - - // verify_declare_element_edge(mesh, elem, local_edge_id); - - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - ThrowErrorMsgIf( elem_top == NULL, - "Element[" << elem.identifier() << "] has no defined topology" ); - - const CellTopologyData * const edge_top = elem_top->edge[ local_edge_id ].topology; - - ThrowErrorMsgIf( edge_top == NULL, - "Element[" << elem.identifier() << "], local_edge_id = " << - local_edge_id << ", edge has no defined topology" ); - - const unsigned * const edge_node_map = elem_top->edge[ local_edge_id ].node ; - - PartVector add_parts ; - - if ( part ) { add_parts.push_back( part ); } - - mesh.change_entity_parts(edge, add_parts); - - mesh.declare_relation( elem , edge , local_edge_id ); - - PairIterRelation rel = elem.relations( FEMMetaData::NODE_RANK ); - - for ( unsigned i = 0 ; i < edge_top->node_count ; ++i ) { - Entity & node = * rel[ edge_node_map[i] ].entity(); - mesh.declare_relation( edge , node , i ); - } - - return edge ; -} - -Entity & declare_element_side( - BulkData & mesh , - const stk_classic::mesh::EntityId global_side_id , - Entity & elem , - const unsigned local_side_id , - Part * part ) -{ - verify_declare_element_side(mesh, elem, local_side_id); - - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - ThrowErrorMsgIf( elem_top == NULL, - "Element[" << elem.identifier() << "] has no defined topology"); - - const CellTopologyData * const side_top = elem_top->side[ local_side_id ].topology; - - ThrowErrorMsgIf( side_top == NULL, - "Element[" << elem.identifier() << "], local_side_id = " << - local_side_id << ", side has no defined topology" ); - - PartVector empty_parts ; - Entity & side = mesh.declare_entity( side_top->dimension , global_side_id, empty_parts ); - return declare_element_side( elem, side, local_side_id, part); -} - -Entity & declare_element_edge( - BulkData & mesh , - const stk_classic::mesh::EntityId global_edge_id , - Entity & elem , - const unsigned local_edge_id , - Part * part ) -{ - verify_declare_element_edge(mesh, elem, local_edge_id); - - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - ThrowErrorMsgIf( elem_top == NULL, - "Element[" << elem.identifier() << "] has no defined topology"); - - - const CellTopologyData * const edge_top = elem_top->edge[ local_edge_id ].topology; - - ThrowErrorMsgIf( edge_top == NULL, - "Element[" << elem.identifier() << "], local_edge_id = " << - local_edge_id << ", edge has no defined topology" ); - - PartVector empty_parts ; - Entity & edge = mesh.declare_entity( edge_top->dimension , global_edge_id, empty_parts ); - return declare_element_edge( elem, edge, local_edge_id, part); -} - - - -const CellTopologyData * get_subcell_nodes(const Entity & entity , - EntityRank subcell_rank , - unsigned subcell_identifier , - EntityVector & subcell_nodes) -{ - subcell_nodes.clear(); - - // get cell topology - const CellTopologyData* celltopology = get_cell_topology(entity).getCellTopologyData(); - - //error checking - { - //no celltopology defined - if (celltopology == NULL) { - return NULL; - } - - // valid ranks fall within the dimension of the cell topology - const bool bad_rank = subcell_rank >= celltopology->dimension; - ThrowInvalidArgMsgIf( bad_rank, "subcell_rank is >= celltopology dimension\n"); - - // subcell_identifier must be less than the subcell count - const bool bad_id = subcell_identifier >= celltopology->subcell_count[subcell_rank]; - ThrowInvalidArgMsgIf( bad_id, "subcell_id is >= subcell_count\n"); - } - - // Get the cell topology of the subcell - const CellTopologyData * subcell_topology = - celltopology->subcell[subcell_rank][subcell_identifier].topology; - - const int num_nodes_in_subcell = subcell_topology->node_count; - - // For the subcell, get it's local nodes ids - const unsigned* subcell_node_local_ids = - celltopology->subcell[subcell_rank][subcell_identifier].node; - - FEMMetaData & fem_meta = FEMMetaData::get(entity); - const EntityRank node_rank = fem_meta.node_rank(); - PairIterRelation node_relations = entity.relations(node_rank); - - subcell_nodes.reserve(num_nodes_in_subcell); - - for (int i = 0; i < num_nodes_in_subcell; ++i ) { - subcell_nodes.push_back( node_relations[subcell_node_local_ids[i]].entity() ); - } - - return subcell_topology; -} - - -int get_entity_subcell_id( const Entity & entity , - const EntityRank subcell_rank, - const CellTopologyData * subcell_topology, - const std::vector& subcell_nodes ) -{ - const int INVALID_SIDE = -1; - - unsigned num_nodes = subcell_topology->node_count; - - if (num_nodes != subcell_nodes.size()) { - return INVALID_SIDE; - } - - // get topology of elem - const CellTopologyData* entity_topology = get_cell_topology(entity).getCellTopologyData(); - if (entity_topology == NULL) { - return INVALID_SIDE; - } - - // get nodal relations for entity - FEMMetaData & fem_meta = FEMMetaData::get(entity); - const EntityRank node_rank = fem_meta.node_rank(); - PairIterRelation relations = entity.relations(node_rank); - - const int num_permutations = subcell_topology->permutation_count; - - // Iterate over the subcells of entity... - for (unsigned local_subcell_ordinal = 0; - local_subcell_ordinal < entity_topology->subcell_count[subcell_rank]; - ++local_subcell_ordinal) { - - // get topological data for this subcell - const CellTopologyData* curr_subcell_topology = - entity_topology->subcell[subcell_rank][local_subcell_ordinal].topology; - - // If topologies are not the same, there is no way the subcells are the same - if (subcell_topology == curr_subcell_topology) { - - const unsigned* const subcell_node_map = entity_topology->subcell[subcell_rank][local_subcell_ordinal].node; - - // Taking all positive permutations into account, check if this subcell - // has the same nodes as the subcell_nodes argument. Note that this - // implementation preserves the node-order so that we can take - // entity-orientation into account. - for (int p = 0; p < num_permutations; ++p) { - - if (curr_subcell_topology->permutation[p].polarity == - CELL_PERMUTATION_POLARITY_POSITIVE) { - - const unsigned * const perm_node = - curr_subcell_topology->permutation[p].node ; - - bool all_match = true; - for (unsigned j = 0 ; j < num_nodes; ++j ) { - if (subcell_nodes[j] != - relations[subcell_node_map[perm_node[j]]].entity()) { - all_match = false; - break; - } - } - - // all nodes were the same, we have a match - if ( all_match ) { - return local_subcell_ordinal ; - } - } - } - } - } - - return INVALID_SIDE; -} - -bool comm_mesh_counts( BulkData & M , - std::vector & counts , - bool local_flag ) -{ - const size_t zero = 0 ; - - // Count locally owned entities - - const FEMMetaData & S = FEMMetaData::get(M); - const unsigned entity_rank_count = S.entity_rank_count(); - const size_t comm_count = entity_rank_count + 1 ; - - std::vector local( comm_count , zero ); - std::vector global( comm_count , zero ); - - ParallelMachine comm = M.parallel(); - Part & owns = S.locally_owned_part(); - - for ( unsigned i = 0 ; i < entity_rank_count ; ++i ) { - const std::vector & ks = M.buckets( i ); - - std::vector::const_iterator ik ; - - for ( ik = ks.begin() ; ik != ks.end() ; ++ik ) { - if ( has_superset( **ik , owns ) ) { - local[i] += (*ik)->size(); - } - } - } - - local[ entity_rank_count ] = local_flag ; - - stk_classic::all_reduce_sum( comm , & local[0] , & global[0] , comm_count ); - - counts.assign( global.begin() , global.begin() + entity_rank_count ); - - return 0 < global[ entity_rank_count ] ; -} - -bool element_side_polarity( const Entity & elem , - const Entity & side , int local_side_id ) -{ - // 09/14/10: TODO: tscoffe: Will this work in 1D? - FEMMetaData &fem_meta = FEMMetaData::get(elem); - const bool is_side = side.entity_rank() != fem_meta.edge_rank(); - const CellTopologyData * const elem_top = get_cell_topology( elem ).getCellTopologyData(); - - const unsigned side_count = ! elem_top ? 0 : ( - is_side ? elem_top->side_count - : elem_top->edge_count ); - - ThrowErrorMsgIf( elem_top == NULL, - "For Element[" << elem.identifier() << "], element has no defined topology"); - - ThrowErrorMsgIf( local_side_id < 0 || static_cast(side_count) <= local_side_id, - "For Element[" << elem.identifier() << "], " << - "side: " << print_entity_key(side) << ", " << - "local_side_id = " << local_side_id << - " ; unsupported local_side_id"); - - const CellTopologyData * const side_top = - is_side ? elem_top->side[ local_side_id ].topology - : elem_top->edge[ local_side_id ].topology ; - - const unsigned * const side_map = - is_side ? elem_top->side[ local_side_id ].node - : elem_top->edge[ local_side_id ].node ; - - const PairIterRelation elem_nodes = elem.relations( FEMMetaData::NODE_RANK ); - const PairIterRelation side_nodes = side.relations( FEMMetaData::NODE_RANK ); - - const unsigned n = side_top->node_count; - bool good = false ; - for ( unsigned i = 0 ; !good && i < n ; ++i ) { - good = true; - for ( unsigned j = 0; good && j < n ; ++j ) { - good = side_nodes[(j+i)%n].entity() == elem_nodes[ side_map[j] ].entity(); - } - } - return good ; -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.hpp deleted file mode 100644 index 6bda1b984089..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMHelpers.hpp +++ /dev/null @@ -1,242 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_FEMHelpers_hpp -#define stk_mesh_FEMHelpers_hpp - -#include - -#include -#include -// This is needed for ElementNode class -#include - -namespace stk_classic { -namespace mesh { - -class Bucket; -class Entity; - -namespace fem { - -/** \addtogroup stk_mesh_bulk_data_element - * \{ - */ - -//---------------------------------------------------------------------- -/** \brief Declare an element member of a Part with a CellTopology - * and nodes conformal to that topology. - */ -Entity & declare_element( BulkData & mesh , - Part & part , - const EntityId elem_id , - const EntityId node_id[] ); - - -/** \brief Create (or find) an element side. - * - * The element must be a member of a Part with a CellTopology. - */ -Entity & declare_element_side( BulkData & mesh , - const stk_classic::mesh::EntityId global_side_id , - Entity & elem , - const unsigned local_side_id , - Part * part = NULL ); - -/** \brief Create (or find) an element edge. - * - * The element must be a member of a Part with a CellTopology. - */ -Entity & declare_element_edge( BulkData & mesh , - const stk_classic::mesh::EntityId global_side_id , - Entity & elem , - const unsigned local_side_id , - Part * part = NULL ); - -/** \brief Determine the polarity of the local side, - * more efficient if the local_side_id is known. - */ -bool element_side_polarity( const Entity & elem , - const Entity & side , int local_side_id = -1 ); - -/** \brief Create (or find) an element side. - * - * The element must be a member of a Part with a CellTopology. - */ -Entity & declare_element_side( Entity & elem , - Entity & side , - const unsigned local_side_id , - Part * part = NULL ); - - - -/** \brief Create (or find) an element edge. - * - * The element must be a member of a Part with a CellTopology. - */ -Entity & declare_element_edge( Entity & elem , - Entity & edge , - const unsigned local_edge_id , - Part * part = NULL ); - - - -/** \brief Declare a part with a given cell topology. This is just a convenient - function that wraps FEMMetaData's declare_part. - */ -template< class Top > -Part &declare_part(FEMMetaData& meta_data, const std::string &name) { - return meta_data.declare_part(name, shards::getCellTopologyData()); -} - -/** - * Given an entity, subcell_rank, and subcell_id, return the nodes - * that make up the subcell in a correct order for the given polarity. - * - * \param entity - * \param subcell_rank - * \param subcell_indentifier - * \param subcell_nodes EntityVector output of the subcell nodes - * \param use_reverse_polarity - * \return CellTopologyData * of the requested subcell - */ -const CellTopologyData * get_subcell_nodes( - const Entity & entity , - EntityRank subcell_rank , - unsigned subcell_identifier , - EntityVector & subcell_nodes - ); - -/** \brief Given an entity and collection of nodes, return the - * local id of the subcell that contains those nodes in the - * correct orientation. - */ -int get_entity_subcell_id( const Entity & entity , - const EntityRank subcell_rank, - const CellTopologyData * side_topology, - const EntityVector & side_nodes ); - -/** \brief Global counts for a mesh's entities. */ -bool comm_mesh_counts( BulkData & , - std::vector & counts , - bool = false ); - -typedef Field ElementNodePointerField ; - -/** \brief Declare an element-to-node-data pointer field. - */ -template< class NodeField > -inline -ElementNodePointerField & -declare_element_node_pointer_field( - FEMMetaData & fmd , const std::string & s , - NodeField & node_field ) -{ - const unsigned num_states = node_field.number_of_states(); - - ElementNodePointerField & f = - fmd.template declare_field< ElementNodePointerField >( s, num_states ); - - for ( unsigned i = 0 ; i < num_states ; ++i ) { - FieldState state = (FieldState) i; - fmd.declare_field_relation( - f.field_of_state( state ) , - fem::get_element_node_stencil(fmd.spatial_dimension()) , - node_field.field_of_state( state ) ); - } - - return f ; -} - -template< class Traits > -void get_parts_with_topology(stk_classic::mesh::BulkData& mesh, - stk_classic::mesh::PartVector& parts, - bool skip_topology_root_parts=false) -{ - parts.clear(); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(mesh); - - const stk_classic::mesh::PartVector& all_parts = fem_meta.get_parts(); - - stk_classic::mesh::PartVector::const_iterator - iter = all_parts.begin(), - iter_end = all_parts.end(); - - const CellTopologyData* topology = shards::getCellTopologyData(); - - for(; iter!=iter_end; ++iter) { - stk_classic::mesh::Part* part = *iter; - if (fem_meta.get_cell_topology(*part).getCellTopologyData() == topology) { - if (skip_topology_root_parts && stk_classic::mesh::fem::is_cell_topology_root_part(*part)) { - continue; - } - parts.push_back(part); - } - } -} - -inline -unsigned get_spatial_dimension(const Entity& entity) -{ - // expose some dot-chain to ensure everything inlined - return entity.bucket().mesh().mesh_meta_data().get_spatial_dimension(); -} - -/* The Fmwk uses an enum to identify nodes, edges, faces and elements. The - toolkit is similar, but the the toolkit rank depends on the spatial - dimension. For 3D parts they are identical. With 2D, the element rank is - 2 (not 3). etc. -*/ - -#ifdef SIERRA_MIGRATION - -inline -unsigned convert_fmwk_rank_to_stk(unsigned fmwk_rank, unsigned spatial_dim) -{ - ThrowAssert(spatial_dim > 0); - ThrowAssert(spatial_dim < 4); - ThrowAssert(fmwk_rank <= 4); // up to four basic entities types and constraints - static int map2Stk[4][5] = { {-1,-1,-1,-1, 4}, - { 0,-1,-1, 1, 4}, - { 0, 1,-1, 2, 4}, - { 0, 1, 2, 3, 4}}; - int stk_rank = map2Stk[spatial_dim][fmwk_rank]; - - return static_cast(stk_rank); -} - -inline -unsigned convert_stk_rank_to_fmwk(unsigned stk_rank, unsigned spatial_dim) -{ - ThrowAssert(spatial_dim > 0); - ThrowAssert(spatial_dim < 4); - ThrowAssert(stk_rank <= 4); // up to four basic entities types and constraints - static int map2Fmwk[4][5]={ {-1,-1,-1,-1, 4}, - { 0, 3,-1,-1, 4}, - { 0, 1, 3,-1, 4}, - { 0, 1, 2, 3, 4}}; - int fmwk_rank=map2Fmwk[spatial_dim][stk_rank]; - - return static_cast(fmwk_rank); -} - -inline -unsigned get_derived_type(const Entity& entity) -{ - return convert_stk_rank_to_fmwk(entity.entity_rank(), get_spatial_dimension(entity)); -} - -#endif - -/** \} */ - -} //namespace fem -} //namespace mesh -} //namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.cpp deleted file mode 100644 index d06ab49e0a5f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.cpp +++ /dev/null @@ -1,460 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - -namespace { - -void assign_cell_topology( - FEMMetaData::PartCellTopologyVector & part_cell_topology_vector, - size_t part_ordinal, - const fem::CellTopology cell_topology) -{ - if (part_ordinal >= part_cell_topology_vector.size()) - part_cell_topology_vector.resize(part_ordinal + 1); - - part_cell_topology_vector[part_ordinal] = cell_topology; - - if (!cell_topology.getCellTopologyData()) - { - std::cout << "bad topology in FEMMetaData::assign_cell_topology" << std::endl; - } - - ThrowRequireMsg(cell_topology.getCellTopologyData(), "bad topology in FEMMetaData::assign_cell_topology"); -} - -} // namespace - -FEMMetaData::FEMMetaData() -: - m_fem_initialized(false), - m_spatial_dimension(0), - m_side_rank(INVALID_RANK), - m_element_rank(INVALID_RANK) -{ - // Attach FEMMetaData as attribute on MetaData to enable "get accessors" to FEMMetaData - m_meta_data.declare_attribute_no_delete(this); -} - -FEMMetaData::FEMMetaData(size_t spatial_dimension, - const std::vector& in_entity_rank_names) - : - m_fem_initialized(false), - m_spatial_dimension(0), - m_side_rank(INVALID_RANK), - m_element_rank(INVALID_RANK) -{ - // Attach FEMMetaData as attribute on MetaData to enable "get accessors" to FEMMetaData - m_meta_data.declare_attribute_no_delete(this); - - FEM_initialize(spatial_dimension, in_entity_rank_names); -} - -void FEMMetaData::FEM_initialize(size_t spatial_dimension, const std::vector& rank_names) -{ - ThrowRequireMsg(!m_fem_initialized,"FEM functionality in FEMMetaData can only be initialized once."); - if ( rank_names.empty() ) { - m_entity_rank_names = fem::entity_rank_names(spatial_dimension); - } - else { - ThrowRequireMsg(rank_names.size() >= spatial_dimension+1, - "Entity rank name vector must name every rank"); - m_entity_rank_names = rank_names; - } - internal_set_spatial_dimension_and_ranks(spatial_dimension); - m_meta_data.set_entity_rank_names(m_entity_rank_names); - m_fem_initialized = true; - internal_declare_known_cell_topology_parts(); -} - -void FEMMetaData::internal_set_spatial_dimension_and_ranks(size_t spatial_dimension) -{ - ThrowRequireMsg( spatial_dimension != 0, "FEMMetaData::internal_set_spatial_dimension_and_ranks: spatial_dimension == 0!"); - m_spatial_dimension = spatial_dimension; - m_meta_data.m_spatial_dimension = spatial_dimension; - - // TODO: Decide on correct terminology for the FEM Entity Ranks (consider topological vs spatial names and incompatibilities). - // spatial_dimension = 1 - // node = 0, edge = 0, face = 0, side = 0, element = 1 - // spatial_dimension = 2 - // node = 0, edge = 1, face = 1, side = 1, element = 2 - // spatial_dimension = 3 - // node = 0, edge = 1, face = 2, side = 2, element = 3 - // spatial_dimension = 4 - // node = 0, edge = 1, face = 2, side = 3, element = 4 - m_side_rank = m_spatial_dimension - 1; - m_element_rank = m_spatial_dimension; - -} - -void FEMMetaData::internal_declare_known_cell_topology_parts() -{ - // Load up appropriate standard cell topologies. - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Node >()), NODE_RANK); - - if (m_spatial_dimension == 1) { - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Particle >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<2> >()), m_element_rank); // ??? - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<3> >()), m_element_rank); // ??? - - } - - else if (m_spatial_dimension == 2) { - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<2> >()), m_side_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<3> >()), m_side_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Particle >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<3> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<6> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<4> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<4> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<8> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<9> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Beam<2> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Beam<3> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellLine<2> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellLine<3> >()), m_element_rank); - } - - else if (m_spatial_dimension == 3) { - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<2> >()), EDGE_RANK); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Line<3> >()), EDGE_RANK); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<3> >()), m_side_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<6> >()), m_side_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Triangle<4> >()), m_side_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<4> >()), m_side_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<8> >()), m_side_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<9> >()), m_side_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Particle >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Beam<2> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Beam<3> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Tetrahedron<4> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Tetrahedron<10> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Tetrahedron<11> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Tetrahedron<8> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Pyramid<5> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Pyramid<13> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Pyramid<14> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Wedge<6> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Wedge<15> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Wedge<18> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Hexahedron<8> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Hexahedron<20> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::Hexahedron<27> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellTriangle<3> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellTriangle<6> >()), m_element_rank); - - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellQuadrilateral<4> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellQuadrilateral<8> >()), m_element_rank); - register_cell_topology(fem::CellTopology(shards::getCellTopologyData< shards::ShellQuadrilateral<9> >()), m_element_rank); - } -} - -void FEMMetaData::register_cell_topology(const fem::CellTopology cell_topology, EntityRank entity_rank) -{ - ThrowRequireMsg(is_FEM_initialized(),"FEMMetaData::register_cell_topology: FEM_initialize() must be called before this function"); - - CellTopologyPartEntityRankMap::const_iterator it = m_cellTopologyPartEntityRankMap.find(cell_topology); - - const bool duplicate = it != m_cellTopologyPartEntityRankMap.end(); - const EntityRank existing_rank = duplicate ? (*it).second.second : 0; - - ThrowInvalidArgMsgIf(m_spatial_dimension < entity_rank, - "entity_rank " << entity_rank << ", " << - "exceeds maximum spatial_dimension = " << m_spatial_dimension ); - - ThrowErrorMsgIf(duplicate && existing_rank != entity_rank, - "For args: cell_topolgy " << cell_topology.getName() << " and entity_rank " << entity_rank << ", " << - "previously declared rank = " << existing_rank ); - - if (! duplicate) { - std::string part_name = std::string("FEM_ROOT_CELL_TOPOLOGY_PART_") + std::string(cell_topology.getName()); - - ThrowErrorMsgIf(get_part(part_name) != 0, "Cannot register topology with same name as existing part '" << cell_topology.getName() << "'" ); - - Part &part = declare_internal_part(part_name, entity_rank); - m_cellTopologyPartEntityRankMap[cell_topology] = CellTopologyPartEntityRankMap::mapped_type(&part, entity_rank); - - assign_cell_topology(m_partCellTopologyVector, part.mesh_meta_data_ordinal(), cell_topology); - } - //check_topo_db(); -} - - -fem::CellTopology -FEMMetaData::get_cell_topology( - const std::string & topology_name) const -{ - std::string part_name = convert_to_internal_name(std::string("FEM_ROOT_CELL_TOPOLOGY_PART_") + topology_name); - - Part *part = get_part(part_name); - if (part) - return get_cell_topology(*part); - else - return fem::CellTopology(); -} - - -Part &FEMMetaData::get_cell_topology_root_part(const fem::CellTopology cell_topology) const -{ - ThrowRequireMsg(is_FEM_initialized(),"FEMMetaData::get_cell_topology_root_part: FEM_initialize() must be called before this function"); - CellTopologyPartEntityRankMap::const_iterator it = m_cellTopologyPartEntityRankMap.find(cell_topology); - ThrowErrorMsgIf(it == m_cellTopologyPartEntityRankMap.end(), - "Cell topology " << cell_topology.getName() << - " has not been registered"); - - return *(*it).second.first; -} - -/// Note: This function only uses the PartCellTopologyVector to look up the -/// cell topology for a given part. -/// This depends on declare_part_subset to update this vector correctly. If a -/// cell topology is not defined for the given part, then an invalid Cell -/// Topology object will be returned. -fem::CellTopology FEMMetaData::get_cell_topology( const Part & part) const -{ - ThrowRequireMsg(is_FEM_initialized(),"FEMMetaData::get_cell_topology: FEM_initialize() must be called before this function"); - fem::CellTopology cell_topology; - - PartOrdinal part_ordinal = part.mesh_meta_data_ordinal(); - if (part_ordinal < m_partCellTopologyVector.size()) - { - cell_topology = m_partCellTopologyVector[part_ordinal]; - } - - return cell_topology; -} - -#if 0 - void FEMMetaData::check_topo_db() - { - std::cout << "FEMMetaData::check_topo_db... m_partCellTopologyVector.size() = " << m_partCellTopologyVector.size() << std::endl; - - fem::CellTopology cell_topology; - - for (unsigned i = 0; i < m_partCellTopologyVector.size(); i++) - { - cell_topology = m_partCellTopologyVector[i]; - if (!cell_topology.getCellTopologyData()) - { - std::cout << "bad topology in FEMMetaData::check_topo_db" << std::endl; - } - ThrowRequireMsg(cell_topology.getCellTopologyData(), "bad topology in FEMMetaData::check_topo_db"); - - } - std::cout << "FEMMetaData::check_topo_db...done" << std::endl; - - } -#endif - -namespace { - -bool root_part_in_subset(stk_classic::mesh::Part & part) -{ - if (is_cell_topology_root_part(part)) { - return true; - } - const PartVector & subsets = part.subsets(); - for (PartVector::const_iterator it=subsets.begin() ; it != subsets.end() ; ++it) { - if (is_cell_topology_root_part( **it )) { - return true; - } - } - return false; -} - -void find_cell_topologies_in_part_and_subsets_of_same_rank(const Part & part, EntityRank rank, std::set & topologies_found) -{ - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(part); - fem::CellTopology top = fem_meta.get_cell_topology(part); - if ((top.isValid() && (part.primary_entity_rank() == rank))) { - topologies_found.insert(top); - } - const PartVector & subsets = part.subsets(); - for (PartVector::const_iterator it=subsets.begin() ; it != subsets.end() ; ++it) { - top = fem_meta.get_cell_topology(**it); - if (top.isValid() && ( (**it).primary_entity_rank() == rank) ) { - topologies_found.insert(top); - } - } -} - -} // namespace - -void FEMMetaData::declare_part_subset( Part & superset , Part & subset ) -{ - ThrowRequireMsg(is_FEM_initialized(),"FEMMetaData::declare_part_subset: FEM_initialize() must be called before this function"); - fem::CellTopology superset_top = get_cell_topology(superset); - - const bool no_superset_topology = !superset_top.isValid(); - if ( no_superset_topology ) { - m_meta_data.declare_part_subset(superset,subset); - return; - } - // Check for cell topology root parts in subset or subset's subsets - const bool subset_has_root_part = root_part_in_subset(subset); - ThrowErrorMsgIf( subset_has_root_part, "FEMMetaData::declare_part_subset: Error, root cell topology part found in subset or below." ); - - std::set cell_topologies; - find_cell_topologies_in_part_and_subsets_of_same_rank(subset,superset.primary_entity_rank(),cell_topologies); - - ThrowErrorMsgIf( cell_topologies.size() > 1, - "FEMMetaData::declare_part_subset: Error, multiple cell topologies of rank " - << superset.primary_entity_rank() - << " defined below subset" - ); - const bool non_matching_cell_topology = ((cell_topologies.size() == 1) && (*cell_topologies.begin() != superset_top)); - ThrowErrorMsgIf( non_matching_cell_topology, - "FEMMetaData::declare_part_subset: Error, superset topology = " - << superset_top.getName() << " does not match the topology = " - << cell_topologies.begin()->getName() - << " coming from the subset part" - ); - // Everything is Okay! - m_meta_data.declare_part_subset(superset,subset); - // Update PartCellTopologyVector for "subset" and same-rank subsets, ad nauseum - if (subset.primary_entity_rank() == superset.primary_entity_rank()) { - assign_cell_topology(m_partCellTopologyVector, subset.mesh_meta_data_ordinal(), superset_top); - const PartVector & subset_parts = subset.subsets(); - for (PartVector::const_iterator it=subset_parts.begin() ; it != subset_parts.end() ; ++it) { - const Part & it_part = **it; - if (it_part.primary_entity_rank() == superset.primary_entity_rank()) { - assign_cell_topology(m_partCellTopologyVector, it_part.mesh_meta_data_ordinal(), superset_top); - } - } - } -} - -EntityRank FEMMetaData::get_entity_rank( - const fem::CellTopology cell_topology) const -{ - CellTopologyPartEntityRankMap::const_iterator it = m_cellTopologyPartEntityRankMap.find(cell_topology); - if (it == m_cellTopologyPartEntityRankMap.end()) - return INVALID_RANK; - else - return (*it).second.second; -} - -//-------------------------------------------------------------------------------- -// Free Functions -//-------------------------------------------------------------------------------- - -bool is_cell_topology_root_part(const Part & part) { - fem::FEMMetaData & fem_meta = fem::FEMMetaData::get(part); - fem::CellTopology top = fem_meta.get_cell_topology(part); - if (top.isValid()) { - const Part & root_part = fem_meta.get_cell_topology_root_part(top); - return (root_part == part); - } - return false; -} - -/// This is a convenience function to get the root cell topology part and then -/// call declare_part_subset. -/// Note: FEMMetaData::declare_part_subset is the function that actually -/// updates the PartCellTopologyVector in FEMMetaData for fast look-up of the -/// Cell Topology. -void set_cell_topology( - Part & part, - fem::CellTopology cell_topology) -{ - FEMMetaData& fem_meta = FEMMetaData::get(part); - - ThrowRequireMsg(fem_meta.is_FEM_initialized(),"set_cell_topology: FEM_initialize() must be called before this function"); - - Part &root_part = fem_meta.get_cell_topology_root_part(cell_topology); - fem_meta.declare_part_subset(root_part, part); -} - -std::vector -entity_rank_names( size_t spatial_dimension ) -{ - ThrowInvalidArgMsgIf( spatial_dimension < 1 || 3 < spatial_dimension, - "Invalid spatial dimension = " << spatial_dimension ); - - std::vector< std::string > names ; - - names.reserve( spatial_dimension + 1 ); - - names.push_back( std::string( "NODE" ) ); - - if ( 1 < spatial_dimension ) { names.push_back( std::string("EDGE") ); } - if ( 2 < spatial_dimension ) { names.push_back( std::string("FACE") ); } - - names.push_back( std::string("ELEMENT") ); - - return names ; -} - - -CellTopology -get_cell_topology( - const Bucket & bucket) -{ - const BulkData & bulk_data = BulkData::get(bucket); - const MetaData & meta_data = MetaData::get(bulk_data); - const PartVector & all_parts = meta_data.get_parts(); - - FEMMetaData &fem = FEMMetaData::get(meta_data); - - CellTopology cell_topology; - - const std::pair< const unsigned *, const unsigned * > supersets = bucket.superset_part_ordinals(); - - if (supersets.first != supersets.second) { - const Part *first_found_part = 0; - - for ( const unsigned * it = supersets.first ; it != supersets.second ; ++it ) { - - const Part & part = * all_parts[*it] ; - - if ( part.primary_entity_rank() == bucket.entity_rank() ) { - - CellTopology top = fem.get_cell_topology( part ); - - if ( ! cell_topology.getCellTopologyData() ) { - cell_topology = top ; - - if (!first_found_part) - first_found_part = ∂ - } - else { - ThrowErrorMsgIf( top.getCellTopologyData() && top != cell_topology, - "Cell topology is ambiguously defined. It is defined as " << cell_topology.getName() << - " on part " << first_found_part->name() << " and as " << top.getName() << " on its superset part " << part.name() ); - } - } - } - } - - return cell_topology ; -} - -} // namespace fem -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.hpp deleted file mode 100644 index d34795a17618..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/FEMMetaData.hpp +++ /dev/null @@ -1,556 +0,0 @@ -#ifndef stk_mesh_FEMMetaData_hpp -#define stk_mesh_FEMMetaData_hpp - -#include -#include -#include -#include -#include // TODO: Remove! -#include - -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - - -/** \brief FEMMetaData is a class that implements a Finite Element Method skin - * on top of the Sierra Tool Kit Meta Data class. The FEM features include the - * concept of spatial dimension with entity ranks tied to the given spatial - * dimension, cell topology mapping to parts along with induced cell topology - * membership through part subsetting, and many additional invariants that are - * enforced. - * - * Users who are interested in a FEM based mesh database should use FEMMetaData - * rather than MetaData. - * - * Invariants for FEM MetaData: - * 1. Each cell topology has one and only one root cell topology part. The - * root cell topology part for a cell topology is a unique part that can be - * subsetted to induce cell topology on the subset part. - * -> Enforced by register_cell_topology is the only function that modifies - * the PartCellTopologyVector private data on FEMMetaData. - * 2. Root cell topology parts cannot be subsets of parts with cell topologies - * -> Enforced by declare_part_subset - * 3. Incompatible cell topologies are prohibited. I.e. parts with - * different cell topologies of the same rank (as the part) cannot be subsets - * of each other. - * -> Enforced by declare_part_subset - * - */ - -// 02/10/11 FEMMetaData Todo: -// * Implement get_cell_topology for Part. -// * Implement declare_part with cell topology -// Non-critical: -// * Implement stk_classic::mesh::fem::get namespace to include getters for MetaData, -// BulkData, FEMMetaData, FEMBulkData, CellTopology from things like Part, -// Bucket, Entity, etc. -// * Create impl class inside the handle classes to hold their parent pointer -// and a friend to the getter above. - -class FEMMetaData { - public: - - /// CellTopologyPartEntityRankMap maps each Cell Topology to its root cell topology part and its associated rank - typedef std::map > CellTopologyPartEntityRankMap; - /// PartCellTopologyVector is a fast-lookup vector of size equal to the number of parts - typedef std::vector PartCellTopologyVector; - - -#ifdef SWIG //SRK from NLM, this is to avoid pulling in a bunch more headers just to define EntityRank - enum - { - INVALID_RANK = stk_classic::mesh::InvalidEntityRank, - NODE_RANK = 0u, - EDGE_RANK = 1u, - FACE_RANK = 2u, - VOLUME_RANK = 3u - }; -#else - static const EntityRank INVALID_RANK = stk_classic::mesh::InvalidEntityRank; - static const EntityRank NODE_RANK = 0u; - static const EntityRank EDGE_RANK = 1u; - static const EntityRank FACE_RANK = 2u; - static const EntityRank VOLUME_RANK = 3u; -#endif - - FEMMetaData(); - ~FEMMetaData() {} - - /** - * \brief Construct and initialize a FEMMetaData - */ - FEMMetaData(size_t spatial_dimension, - const std::vector& in_entity_rank_names = std::vector()); - - - /// -------------------------------------------------------------------------------- - /// FEMMetaData Specific functions begin: - /// -------------------------------------------------------------------------------- - /** \brief Initialize the spatial dimension and an optional list of entity rank names associated with each rank - * - * This function can only be called once. - * To determine if a FEMMetaData class has been initialized, call the is_FEM_initialized function. - */ - void FEM_initialize( - size_t spatial_dimension, - const std::vector& in_entity_rank_names = std::vector() - ); - - /** \brief This function returns whether this class has been initialized or not. - */ - bool is_FEM_initialized() const - { - return m_fem_initialized; - } - - // NOTE: This is a temporary function that will be removed once a FEMBulkData exists. - /** \brief Getter for MetaData off of a FEMMetaData object. - */ - inline static MetaData & get_meta_data( FEMMetaData & fem_meta ) - { return fem_meta.m_meta_data; } - - /** \brief Returns the spatial dimension that was passed in through FEM_initialize. - */ - size_t spatial_dimension() const - { - return m_spatial_dimension; - } - - /** \brief Returns the node rank, which is always zero. - */ - EntityRank node_rank() const - { - return NODE_RANK; - } - - /** \brief Returns the edge rank which changes depending on spatial dimension - */ - EntityRank edge_rank() const - { - return EDGE_RANK; - } - - /** \brief Returns the face rank which changes depending on spatial dimension - */ - EntityRank face_rank() const - { - return FACE_RANK; - } - - /** \brief Returns the volume rank which changes depending on spatial dimension - */ - EntityRank volume_rank() const - { - return VOLUME_RANK; - } - - /** \brief Returns the side rank which changes depending on spatial dimension - */ - EntityRank side_rank() const - { - return m_side_rank; - } - - /** \brief Returns the element rank which is always equal to spatial dimension - */ - EntityRank element_rank() const - { - return m_element_rank; - } - // void check_topo_db(); - - /** - * Return true if rank is valid. - */ - bool check_rank(EntityRank rank) const; - - /** \brief This function is used to register new cell topologies and their associated ranks with FEMMetaData. - * Currently, several shards Cell Topologies are registered with appropriate ranks at initialization time. - * See: internal_declare_known_cell_topology_parts for the whole list. - * - * Note: This function also creates the root cell topology part which is accessible from get_cell_topology_root_part - */ - void register_cell_topology(const fem::CellTopology cell_topology, EntityRank in_entity_rank); - - /** \brief Return the root cell topology part associated with the given cell topology. - * This Part is created in register_cell_topology - */ - Part &get_cell_topology_root_part(const fem::CellTopology cell_topology) const; - - /** \brief Return the cell topology associated with the given part. - * The cell topology is set on a part through part subsetting with the root - * cell topology part. - */ - fem::CellTopology get_cell_topology( const Part & part) const; - - fem::CellTopology get_cell_topology( const std::string & topology_name) const; - - /** \brief Return the EntityRank that is associated with the given cell - * topology. In several cases, this rank is dependent on spatial - * dimension. - */ - EntityRank get_entity_rank(const fem::CellTopology cell_topology) const; - - /** \brief Getter for FEMMetaData off of a MetaData object. - */ - inline static FEMMetaData & get ( const MetaData & meta ) - { return *const_cast(meta.get_attribute()); } - - /** \brief Getter for FEMMetaData off of a Part object. - */ - inline static FEMMetaData & get( const Part & part ) - { return FEMMetaData::get(MetaData::get(part)); } - - /** \brief Getter for FEMMetaData off of a FieldBase object. - */ - inline static FEMMetaData & get( const FieldBase & field ) - { return FEMMetaData::get(MetaData::get(field)); } - - /** \brief Getter for FEMMetaData off of a PropertyBase object. - */ - inline static FEMMetaData & get( const PropertyBase & property ) - { return FEMMetaData::get(MetaData::get(property)); } - - /** \brief Getter for FEMMetaData off of a BulkData object. - */ - inline static FEMMetaData & get( const BulkData & bulk_data ) - { return FEMMetaData::get(MetaData::get(bulk_data)); } - - /** \brief Getter for FEMMetaData off of a Bucket object. - */ - inline static FEMMetaData & get( const Bucket & bucket ) - { return FEMMetaData::get(MetaData::get(bucket)); } - - /** \brief Getter for FEMMetaData off of a Entity object. - */ - inline static FEMMetaData & get( const Entity & entity ) - { return FEMMetaData::get(MetaData::get(entity)); } - - /** \brief Getter for FEMMetaData off of a Ghosting object. - */ - inline static FEMMetaData & get( const Ghosting & ghost ) - { return FEMMetaData::get(MetaData::get(ghost)); } - - /** \brief Declare a part with a given cell topology - */ - Part &declare_part( const std::string &name, fem::CellTopology cell_topology) - { - ThrowRequireMsg(is_FEM_initialized(),"FEMMetaData::declare_part: FEM_initialize() must be called before this function"); - Part &root_part = get_cell_topology_root_part(cell_topology); - EntityRank primary_entity_rank = root_part.primary_entity_rank(); - Part & part = m_meta_data.declare_part(name, primary_entity_rank); - declare_part_subset(root_part, part); - return part; - } - - /** \brief Declare a part with a given cell topology - */ - template< class Top > - Part &declare_part(const std::string &name) { - return declare_part(name, shards::getCellTopologyData()); - } - - /// -------------------------------------------------------------------------------- - /// FEMMetaData Specific functions end - /// -------------------------------------------------------------------------------- - - /// -------------------------------------------------------------------------------- - /// The following functions are call-throughs to the underlying MetaData class: - /// -------------------------------------------------------------------------------- - - //------------------------------------ - /** \name MetaData predefined parts - */ - - /** \brief Universal subset for the problem domain. - * All other parts are a subset of the universal part. - */ - Part & universal_part() const { return m_meta_data.universal_part(); } - - /** \brief Subset for the problem domain that is owned by the - * local process. Ghost entities are not members of this part. - */ - Part & locally_owned_part() const { return m_meta_data.locally_owned_part(); } - - /** \brief Subset for the problem domain that is shared with another - * process. Ghost entities are not members of this part. - */ - Part & globally_shared_part() const { return m_meta_data.globally_shared_part(); } - - //------------------------------------ - /** \name Declare and query parts - */ - - /** \brief Get an existing part by its application-defined text name. - * - * Return NULL if not present and required_by == NULL. - * If required and not present then throws an exception - * with the 'required_by' text. - */ - /// \todo REFACTOR remove required_by argument - Part * get_part( const std::string & p_name, - const char * required_by = NULL ) const - { return m_meta_data.get_part(p_name,required_by); } - - /** \brief Get an existing part by its ordinal */ - Part & get_part( unsigned ord ) const - { return m_meta_data.get_part(ord); } - - /** \brief Query all parts of the mesh ordered by the parts' ordinal. */ - const PartVector & get_parts() const - { return m_meta_data.get_parts(); } - - /** \brief Declare a part of the given name and entity rank - * Redeclaration returns the previously declared part. - * - * This part will have member entities that are of equal or lesser rank. - * When an entity of equal rank becomes a member - * then all related entities of lesser rank also become members. - */ - Part & declare_part( const std::string & p_name, EntityRank rank ) - { return m_meta_data.declare_part(p_name,rank); } - - /** \brief Declare a part of the given name and entity rank - * Redeclaration returns the previously declared part. - * - * This part does not have an entity type rank. - */ - Part & declare_part( const std::string & p_name) - { return m_meta_data.declare_part(p_name); } - - /** \brief Declare a superset-subset relationship between parts - * Note: Cell Topologies are induced through part subsets. - * See the invariants that are enforced by this function in the documentation for FEMMetaData. - * */ - void declare_part_subset( Part & superset , Part & subset ); - - /** \brief Declare an entity-relationship between parts. - * - * If \ref stk_classic::mesh::Entity "entity" e1 is a member - * of root_part and there exists an - * \ref stk_classic::mesh::Relation "entity relation" - * from e1 to e2 that satisfies the - * \ref stk_mesh_relations "relation stencil" - * then e2 must be a member of the target_part . - */ - void declare_part_relation( Part & root_part , - relation_stencil_ptr stencil , - Part & target_part ) - { m_meta_data.declare_part_relation(root_part, stencil, target_part); } - - /** \brief Set the entity rank names in a vector. - * This also currently sets the maximum entity rank. - */ - void set_entity_rank_names(const std::vector &in_entity_rank_names) - { - m_entity_rank_names = in_entity_rank_names; - m_meta_data.set_entity_rank_names(in_entity_rank_names); - } - - /** \brief Return the rank for the given name that was provided in set_entity_rank_names - */ - EntityRank entity_rank( const std::string &name ) const - { - EntityRank my_entity_rank = InvalidEntityRank; - - for (size_t i = 0; i < m_entity_rank_names.size(); ++i) - if (equal_case(name, m_entity_rank_names[i])) { - my_entity_rank = i; - break; - } - return my_entity_rank; - } - - /** \brief Return the set of entity rank names specified in set_entity_rank_names - */ - const std::vector & entity_rank_names() const - { - return m_entity_rank_names; - } - - /** \brief Return the maximum entity rank - */ - std::vector::size_type entity_rank_count() const - { - return m_entity_rank_names.size(); - } - - /** \brief Return the name for a given entity rank as was specified in set_entity_rank_names - */ - const std::string & entity_rank_name( EntityRank in_entity_rank ) const - { - ThrowErrorMsgIf( in_entity_rank >= m_entity_rank_names.size(), - "entity-rank " << in_entity_rank << - " out of range. Must be in range 0.." << m_entity_rank_names.size()); - return m_entity_rank_names[in_entity_rank]; - } - - /** \brief Return true if the given entity rank is valid. - */ - bool is_valid_entity_rank(EntityRank rank) const - { - return rank < m_entity_rank_names.size(); - } - - //------------------------------------ - /** \name Declare and query fields - */ - - /** \brief Get a field, return NULL if it does not exist. - * - * \exception std::runtime_error - * If the field exits and the - * \ref stk_classic::mesh::Field "field_type" does not match or - * if required_by != NULL and a field of that name is not found. - */ - template< class field_type > - field_type * get_field( const std::string & name ) const - { return m_meta_data.get_field(name); } - - /** \brief Get all defined fields */ - const FieldVector & get_fields() const { - return m_meta_data.get_fields(); - } - - /** \brief Declare a field of the given - * \ref stk_classic::mesh::Field "field_type", test name, - * and number of states. - * - * A compatible redeclaration returns the previously declared field. - * \exception std::runtime_error If a redeclaration is incompatible - */ - template< class field_type > - field_type & declare_field( const std::string & name , - unsigned number_of_states = 1 ) - { return m_meta_data.declare_field( name, number_of_states ); } - - /** \brief Declare a field relation. - * - * The pointer_field's scalar type must be a pointer to the - * scalar type of the reference_field. The following - * derived field data relationship maintained. - * - * Let e_root -> Relation( e_target , ord , kind ) - * Let i = stencil( e_root.entity_rank() , - * e_target.entity_rank() , ord , kind ) - * Let Scalar ** ptr = field_data( pointer_field , e_root ) - * then ptr[i] = field_data( referenced_field , e_target ) - * - * This derived field data relationship is typically used - * to support fast access to field data on entities - * related to the root entity; e.g. field data associated with - * the nodes of an element. - */ - template< class PointerFieldType , class ReferencedFieldType > - void declare_field_relation( PointerFieldType & pointer_field , - relation_stencil_ptr stencil , - ReferencedFieldType & referenced_field ) - { return m_meta_data.declare_field_relation( pointer_field, stencil, referenced_field ); } - - /** \brief Get field relations */ - const std::vector & get_field_relations() const - { return m_meta_data.get_field_relations(); } - - /** \brief Commit the part and field declarations so that the - * meta data manager can be used to create - * \ref stk_classic::mesh::BulkData "mesh bulk data". - * - * Verifies consistency of the meta data and clean out redundant - * field data allocation rules. - * Once committed no further part or field declarations can be made. - */ - void commit() - { m_meta_data.commit(); } - - /** \brief Query if the meta data manager is committed */ - bool is_commit() const - { return m_meta_data.is_commit(); } - - //------------------------------------ - - /** \name Field declaration with weak type information; - * direct use in application code is strongly discouraged. - */ - - /** \brief Declare a field via runtime type information */ - FieldBase * declare_field_base( - const std::string & arg_name, - const DataTraits & arg_traits , - unsigned arg_rank , - const shards::ArrayDimTag * const * arg_dim_tags , - unsigned arg_num_states ) - { return m_meta_data.declare_field_base( arg_name, arg_traits, arg_rank, arg_dim_tags, arg_num_states); } - - /** \brief Declare a field restriction via runtime type information. - */ - void declare_field_restriction( FieldBase & arg_field , - EntityRank arg_entity_rank , - const Part & arg_part , - const unsigned * arg_stride , - const void * arg_init_value = NULL) - { m_meta_data.declare_field_restriction(arg_field, arg_entity_rank, arg_part, arg_stride, arg_init_value); } - - private: // functions - - Part & declare_internal_part( const std::string & p_name, EntityRank rank ) - { return m_meta_data.declare_internal_part(p_name,rank); } - - void internal_set_spatial_dimension_and_ranks(size_t spatial_dimension); - - void internal_declare_known_cell_topology_parts(); - - private: // data - MetaData m_meta_data; - bool m_fem_initialized; - size_t m_spatial_dimension; - EntityRank m_side_rank; - EntityRank m_element_rank; - std::vector< std::string > m_entity_rank_names; - /// Used to store mapping between Cell Topologies and their associated root parts and specified ranks: - CellTopologyPartEntityRankMap m_cellTopologyPartEntityRankMap; - /// Fast-lookup vector that maps part ordinals to Cell Topologies. - PartCellTopologyVector m_partCellTopologyVector; -}; - -/** \brief Determine if the given part is a root part for a cell topology. - */ -bool is_cell_topology_root_part(const Part & part); - -/** set a cell_topology on a part */ -void set_cell_topology( Part &part, const fem::CellTopology cell_topology); - -/** set a cell_topology on a part */ -template -inline void set_cell_topology(Part & part) -{ - stk_classic::mesh::fem::set_cell_topology(part, fem::CellTopology(shards::getCellTopologyData())); -} - - -/** Get the cell_topology off a bucket */ -CellTopology get_cell_topology(const Bucket &bucket); - - -/** Get the cell_topology off an entity */ -inline CellTopology get_cell_topology(const Entity &entity) { - return get_cell_topology(entity.bucket()); -} - -inline -bool FEMMetaData::check_rank(EntityRank rank) const -{ - return m_meta_data.check_rank(rank); -} - - -std::vector entity_rank_names(size_t spatial_dimension); - -} // namespace fem -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_FEMMetaData_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.cpp deleted file mode 100644 index 878881d77b82..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.cpp +++ /dev/null @@ -1,519 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -namespace { - -typedef std::pair< const CellTopologyData *, EntityVector > SideKey; -typedef std::vector< EntitySideComponent > SideVector; -typedef std::map< SideKey, SideVector> BoundaryMap; - -//Comparator class to sort EntitySideComponent -//first by entity identifier and then by side_ordinal -class EntitySideComponentLess { - public: - bool operator () (const EntitySideComponent & lhs, const EntitySideComponent &rhs) - { - const EntityId lhs_elem_id = lhs.entity->identifier(); - const EntityId rhs_elem_id = rhs.entity->identifier(); - - return (lhs_elem_id != rhs_elem_id) ? - (lhs_elem_id < rhs_elem_id) : - (lhs.side_ordinal < rhs.side_ordinal); - } -}; - -//Convience class to help with communication. -//sort first by element identifier and then by side_ordinal -class ElementIdSide { - public: - EntityId elem_id; - RelationIdentifier side_ordinal; - - ElementIdSide() : - elem_id(0), side_ordinal(0) {} - - ElementIdSide( EntityId id, RelationIdentifier ordinal) : - elem_id(id), side_ordinal(ordinal) {} - - ElementIdSide( const EntitySideComponent & esc) : - elem_id(esc.entity->identifier()), side_ordinal(esc.side_ordinal) {} - - ElementIdSide & operator = ( const ElementIdSide & rhs) { - elem_id = rhs.elem_id; - side_ordinal = rhs.side_ordinal; - return *this; - } - - //compare first by elem_id and then by side_ordinal - bool operator < ( const ElementIdSide & rhs) const { - const ElementIdSide & lhs = *this; - - return (lhs.elem_id != rhs.elem_id) ? - (lhs.elem_id < rhs.elem_id) : - (lhs.side_ordinal < rhs.side_ordinal); - } -}; - -//a reverse map used in unpacking to determine what side needs -//to be created -typedef std::map< ElementIdSide, SideKey> ReverseBoundaryMap; - -//a convience class to help with packing the comm buffer -class SideCommHelper { - public: - unsigned proc_to; - ElementIdSide creating_elem_id_side; //used as a look up in the reverse boundary map - EntityId generated_side_id; - - SideCommHelper() : - proc_to(0), creating_elem_id_side(), generated_side_id(0) {}; - - SideCommHelper( unsigned p, const ElementIdSide & creating_eid, const EntityId side_id) : - proc_to(p), creating_elem_id_side(creating_eid), generated_side_id(side_id) {} - - SideCommHelper( const SideCommHelper & sch) : - proc_to(sch.proc_to), - creating_elem_id_side(sch.creating_elem_id_side), - generated_side_id(sch.generated_side_id) - {} - - SideCommHelper & operator = (const SideCommHelper & rhs) { - proc_to = rhs.proc_to; - creating_elem_id_side = rhs.creating_elem_id_side; - generated_side_id = rhs.generated_side_id; - return *this; - } - - //compare first by proc_to, then by creating elem_id - bool operator < ( const SideCommHelper & rhs) const { - const SideCommHelper & lhs = *this; - - return (lhs.proc_to != rhs.proc_to) ? - (lhs.proc_to < rhs.proc_to) : - (lhs.creating_elem_id_side < rhs.creating_elem_id_side); - } -}; - -// Use permutation that starts with lowest entity id -void ensure_consistent_order(EntityVector & side_entities) -{ - ThrowRequire( !side_entities.empty() ); - - EntityId lowest_id = side_entities.front()->identifier(); - unsigned idx_of_lowest_id = 0; - - for (unsigned idx = 1; idx < side_entities.size(); ++idx) { - EntityId curr_id = side_entities[idx]->identifier(); - if (curr_id < lowest_id) { - idx_of_lowest_id = idx; - lowest_id = curr_id; - } - } - - if (idx_of_lowest_id != 0) { - std::rotate(side_entities.begin(), - side_entities.begin() + idx_of_lowest_id, - side_entities.end()); - } -} - -// populate the side_map with 'owned' sides that need to be created -// -// a side needs to be created if the outside is NULL and the element -// does not have a current relation to a side for the side_ordinal -void add_owned_sides_to_map( - const BulkData & mesh, - const EntityRank element_rank, - const EntitySideVector & boundary, - BoundaryMap & side_map) -{ - for (stk_classic::mesh::EntitySideVector::const_iterator itr = boundary.begin(); - itr != boundary.end(); ++itr) { - const EntitySideComponent & inside = itr->inside; - const EntitySideComponent & outside = itr->outside; - const RelationIdentifier side_ordinal = inside.side_ordinal; - const Entity& inside_entity = *(inside.entity); - - if ( inside_entity.owner_rank() == mesh.parallel_rank() && - outside.entity == NULL ) { - // search through existing sides - PairIterRelation existing_sides = inside_entity.relations(element_rank -1); - for (; existing_sides.first != existing_sides.second && - existing_sides.first->identifier() != side_ordinal ; - ++existing_sides.first); - - // a relation the side was not found - if (existing_sides.first == existing_sides.second) { - //create the side_key - //side_key.first := CellTopologyData * of the side topology - //side_key.second := EntityVector * of the side_nodes with the nodes in the correct - // permutation for the side starting with - // the node with the smallest identifier - SideKey side_key; - - side_key.first = fem::get_subcell_nodes( - inside_entity, - element_rank - 1, // subcell rank - side_ordinal, // subcell identifier - side_key.second // subcell nodes - ); - ensure_consistent_order(side_key.second); - - //add this side to the side_map - side_map[side_key].push_back(inside); - } - } - } -} - -// populate the side_map with 'non-owned' sides that need to be created -// who's side_key is already present in the side_map. This process -// may need to communicate with the process which own these elements -// -// a side needs to be created if the outside is NULL and the element -// does not have a current relation to a side for the side_ordinal -void add_non_owned_sides_to_map( - const BulkData & mesh, - const EntityRank element_rank, - const EntitySideVector & boundary, - BoundaryMap & side_map) -{ - for (stk_classic::mesh::EntitySideVector::const_iterator itr = boundary.begin(); - itr != boundary.end(); ++itr) { - const EntitySideComponent & inside = itr->inside; - const EntitySideComponent & outside = itr->outside; - const RelationIdentifier side_ordinal = inside.side_ordinal; - const Entity& inside_entity = *(inside.entity); - - // If this process does NOT own the inside and the outside entity does not exist - if ( inside_entity.owner_rank() != mesh.parallel_rank() && - outside.entity == NULL ) { - // search through existing sides - PairIterRelation existing_sides = inside_entity.relations(element_rank -1); - for (; existing_sides.first != existing_sides.second && - existing_sides.first->identifier() != side_ordinal ; - ++existing_sides.first); - - // a relation to the side was not found - if (existing_sides.first == existing_sides.second) { - // Get the nodes for the inside entity - SideKey side_key; - - side_key.first = fem::get_subcell_nodes( - inside_entity, - element_rank - 1, // subcell rank - side_ordinal, // subcell identifier - side_key.second // subcell nodes - ); - ensure_consistent_order(side_key.second); - - //only add the side if the side_key currently exist in the map - if ( side_map.find(side_key) != side_map.end()) { - side_map[side_key].push_back(inside); - } - } - } - } -} - -//sort the SideVector for each side_key. -//the process who owns the element that appears -//first is responsible for generating the identifier -//for the side and communicating the identifier to the -//remaining process -// -//the ElementIdSide of the first side -//is enough to uniquely identify a side. -//the reverse_map is used to find the side_key -//from this ElementIdSide. -// -//return the number of sides this process -//is responsible for creating -size_t determine_creating_processes( - const BulkData & mesh, - BoundaryMap & side_map, - ReverseBoundaryMap & reverse_side_map) -{ - int num_sides_to_create = 0; - for (BoundaryMap::iterator i = side_map.begin(); - i != side_map.end(); - ++i) - { - const SideKey & side_key = i->first; - SideVector & side_vector = i->second; - - //sort the side vectors base on entity identifier and side ordinal - std::sort( side_vector.begin(), side_vector.end(), EntitySideComponentLess() ); - - const EntitySideComponent & first_side = *side_vector.begin(); - - //does this process create the first side - //if so it needs to create a side_id - if (first_side.entity->owner_rank() == mesh.parallel_rank()) { - ++num_sides_to_create; - } - const ElementIdSide elem_id_side(first_side); - - reverse_side_map[elem_id_side] = side_key; - } - - return num_sides_to_create; -} - -} //end un-named namespace - -void skin_mesh( BulkData & mesh, EntityRank element_rank, Part * skin_part) { - ThrowErrorMsgIf( mesh.synchronized_state() == BulkData::MODIFIABLE, - "mesh is not SYNCHRONIZED" ); - - EntityVector owned_elements; - - // select owned - Selector owned = fem::FEMMetaData::get(mesh).locally_owned_part(); - get_selected_entities( owned, - mesh.buckets(element_rank), - owned_elements); - - reskin_mesh(mesh, element_rank, owned_elements, skin_part); -} - -void reskin_mesh( BulkData & mesh, EntityRank element_rank, EntityVector & owned_elements, Part * skin_part) { - ThrowErrorMsgIf( mesh.synchronized_state() == BulkData::MODIFIABLE, - "mesh is not SYNCHRONIZED" ); - - EntityVector elements_closure; - - // compute owned closure - find_closure( mesh, owned_elements, elements_closure ); - - // compute boundary - EntitySideVector boundary; - boundary_analysis( mesh, elements_closure, element_rank, boundary); - - BoundaryMap side_map; - - add_owned_sides_to_map(mesh, element_rank, boundary, side_map); - - add_non_owned_sides_to_map(mesh, element_rank, boundary, side_map); - - ReverseBoundaryMap reverse_side_map; - - size_t num_sides_to_create = determine_creating_processes(mesh, side_map, reverse_side_map); - - //begin modification - mesh.modification_begin(); - - // formulate request ids for the new sides - std::vector requests(fem::FEMMetaData::get(mesh).entity_rank_count(), 0); - requests[element_rank -1] = num_sides_to_create; - - // create the new sides - EntityVector requested_sides; - mesh.generate_new_entities(requests, requested_sides); - - //set to aid comm packing - std::set side_comm_helper_set; - - - size_t current_side = 0; - for ( BoundaryMap::iterator map_itr = side_map.begin(); - map_itr!= side_map.end(); - ++map_itr) - { - const SideKey & side_key = map_itr->first; - SideVector & side_vector = map_itr->second; - - // Only generated keys for sides in which this process - // owns the first element in the side vector - const EntitySideComponent & first_side = *(side_vector.begin()); - if ( first_side.entity->owner_rank() == mesh.parallel_rank()) { - - //to be used as the key in the reverse boundary map - //a side can be identified in two ways - // 1. vector of nodes in a correct permutation and a side-topology - // 2. element-id side-ordinal for the side - // the reverse boundary map is used to go from (2) to (1). - const ElementIdSide elem_id_side( first_side); - - Entity & side = *(requested_sides[current_side]); - EntityId side_id = side.identifier(); - - - PartVector add_parts ; - { - fem::FEMMetaData &fem_meta_data = fem::FEMMetaData::get(mesh); - Part * topo_part = &fem_meta_data.get_cell_topology_root_part(side_key.first); - add_parts.push_back( topo_part); - if (skin_part) { - add_parts.push_back(skin_part); - fem::CellTopology topo = fem_meta_data.get_cell_topology(*topo_part); - const PartVector topo_parts = skin_part->subsets(); - for (stk_classic::mesh::PartVector::const_iterator i=topo_parts.begin(); i!=topo_parts.end(); ++i) { - // Decode side to element topology. Specific to tri and quad on linear hex and wedges - if (topo == fem_meta_data.get_cell_topology(**i)) { - if (std::string(side_key.first->name) == "Quadrilateral_4") { // A enum would be nice - // Quad could be the face of a hex or wedge. - if (std::string("Hexahedron_8") == stk_classic::mesh::fem::get_cell_topology(*side_vector.front().entity).getName() && - std::string::npos != (*i)->name().find("hex8")) { // Magic string - add_parts.push_back(*i); - } - else if (std::string("Wedge_6") == stk_classic::mesh::fem::get_cell_topology(*side_vector.front().entity).getName() && - std::string::npos != (*i)->name().find("wedge6")) { // Magic string - add_parts.push_back(*i); - } - } - else { - add_parts.push_back(*i); - } - } - } - } - } - mesh.change_entity_parts(side, add_parts); - - - //declare the side->node relations - const EntityVector & nodes = side_key.second; - - for (size_t i = 0; iside relations - for (SideVector::iterator side_itr = side_vector.begin(); - side_itr != side_vector.end(); - ++side_itr) - { - Entity & elem = *(side_itr->entity); - //only declare relations for owned elements - if (elem.owner_rank() == mesh.parallel_rank()) { - const RelationIdentifier elem_side_ordinal = side_itr->side_ordinal; - mesh.declare_relation( elem, side, elem_side_ordinal); - } - else { - //add this side to the communication set - side_comm_helper_set.insert( SideCommHelper( elem.owner_rank(), elem_id_side, side_id)); - } - } - ++current_side; - } - } - - CommAll comm( mesh.parallel() ); - - //pack send buffers - for (int allocation_pass=0; allocation_pass<2; ++allocation_pass) { - if (allocation_pass==1) { - comm.allocate_buffers( mesh.parallel_size() /4, 0); - } - - for (std::set::const_iterator i=side_comm_helper_set.begin(); - i != side_comm_helper_set.end(); - ++i) - { - const SideCommHelper & side_helper = *i; - comm.send_buffer(side_helper.proc_to) - .pack(side_helper.creating_elem_id_side.elem_id) - .pack(side_helper.creating_elem_id_side.side_ordinal) - .pack(side_helper.generated_side_id); - } - } - - comm.communicate(); - - for ( unsigned ip = 0 ; ip < mesh.parallel_size() ; ++ip ) { - CommBuffer & buf = comm.recv_buffer( ip ); - while ( buf.remaining() ) { - ElementIdSide creating_elem_id_side; - EntityId generated_side_id; - - buf.unpack(creating_elem_id_side.elem_id) - .unpack(creating_elem_id_side.side_ordinal) - .unpack(generated_side_id); - - //find the side in the reverse boundary map - const SideKey & side_key = reverse_side_map[creating_elem_id_side]; - - //get the SideVector for the corresponding side_key - SideVector & side_vector = side_map[side_key]; - - PartVector add_parts ; - { - fem::FEMMetaData &fem_meta_data = fem::FEMMetaData::get(mesh); - Part * topo_part = &fem_meta_data.get_cell_topology_root_part(side_key.first); - add_parts.push_back( topo_part); - if (skin_part) { - add_parts.push_back(skin_part); - fem::CellTopology topo = fem_meta_data.get_cell_topology(*topo_part); - PartVector topo_parts = skin_part->subsets(); - for (stk_classic::mesh::PartVector::const_iterator i=topo_parts.begin(); i!=topo_parts.end(); ++i) { - // Decode side to element topology. Specific to tri and quad on linear hex and wedges - if (topo == fem_meta_data.get_cell_topology(**i)) { - if (std::string(side_key.first->name) == "Quadrilateral_4") { // A enum would be nice - // Quad could be the face of a hex or wedge. - if (std::string("Hexahedron_8") == stk_classic::mesh::fem::get_cell_topology(*side_vector.front().entity).getName() && - std::string::npos != (*i)->name().find("hex8")) { // Magic string - add_parts.push_back(*i); - } - else if (std::string("Wedge_6") == stk_classic::mesh::fem::get_cell_topology(*side_vector.front().entity).getName() && - std::string::npos != (*i)->name().find("wedge6")) { // Magic string - add_parts.push_back(*i); - } - } - else { - add_parts.push_back(*i); - } - } - } - } - } - Entity & side = mesh.declare_entity(element_rank-1,generated_side_id,add_parts); - - //declare the side->node relations - const EntityVector & nodes = side_key.second; - - for (size_t i = 0; iside relations - for (SideVector::iterator side_itr = side_vector.begin(); - side_itr != side_vector.end(); - ++side_itr) - { - Entity & elem = *(side_itr->entity); - //only declare relations for owned elements - if (elem.owner_rank() == mesh.parallel_rank()) { - const RelationIdentifier elem_side_ordinal = side_itr->side_ordinal; - mesh.declare_relation( elem, side, elem_side_ordinal); - } - } - } - } - mesh.modification_end(); -} - -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.hpp deleted file mode 100644 index 55293b805d1b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/SkinMesh.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_SkinMesh_hpp -#define stk_mesh_SkinMesh_hpp - -#include - -namespace stk_classic { -namespace mesh { - -class BulkData; -class Part; -class Entity; - -typedef std::vector EntityVector; - -/** - * Skin the entire mesh. - */ -void skin_mesh( BulkData & mesh, - EntityRank entity_rank, - Part * skin_part = NULL ); - -/** - * Given a vector of modified/created elements, update the skin. - */ -void reskin_mesh( BulkData & mesh, - EntityRank entity_rank, - EntityVector & owned_modified_elements, - Part * skin_part = NULL ); - - - -} -} -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.cpp deleted file mode 100644 index 8034514625d8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - -int -element_node_stencil_2d( - EntityRank from_type , - EntityRank to_type , - unsigned identifier ) -{ - static const size_t spatial_dimension = 2; - - int ordinal = -1 ; - - if ( spatial_dimension == from_type && FEMMetaData::NODE_RANK == to_type ) { - ordinal = static_cast(identifier); - } - - return ordinal ; -} - - -int -element_node_stencil_3d( - EntityRank from_type , - EntityRank to_type , - unsigned identifier ) -{ - static const size_t spatial_dimension = 3; - - int ordinal = -1 ; - - if ( spatial_dimension == from_type && FEMMetaData::NODE_RANK == to_type ) { - ordinal = static_cast(identifier); - } - - return ordinal ; -} - - -relation_stencil_ptr -get_element_node_stencil( - size_t spatial_dimension) -{ - ThrowRequire(spatial_dimension == 2 || spatial_dimension == 3); - - if (spatial_dimension == 3) - return & element_node_stencil_3d; - else // if (spatial_dimension == 2) - return & element_node_stencil_2d; -} - -} // namespace fem -} // namespace mesh -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.hpp deleted file mode 100644 index c507cfdac729..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/Stencils.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_Stencils_hpp -#define stk_mesh_Stencils_hpp - -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fem { - -relation_stencil_ptr get_element_node_stencil(size_t spatial_dimension); - -template -int element_node_stencil( EntityRank , EntityRank , unsigned ); - - -template -int element_node_stencil( EntityRank from_type , EntityRank to_type , unsigned identifier ) -{ - enum { number_node = TopologyTraits::node_count }; - - int ordinal = -1 ; - - if ( element_rank == from_type && - FEMMetaData::NODE_RANK == to_type && - identifier < number_node ) { - ordinal = static_cast(identifier); - } - - return ordinal ; -} - -} // namespace fem -} // namespace mesh -} // namespace stk_classic - -#endif // stk_mesh_Stencils_hpp diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.cpp deleted file mode 100644 index db84ab899057..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include - -namespace stk_classic { -namespace mesh { - -const char * ElementNode::name() const -{ static const char n[] = "ElementNode" ; return n ; } - -const ElementNode & ElementNode::tag() -{ static const ElementNode self ; return self ; } - -const char * QuadratureTag::name() const -{ static const char n[] = "Quadrature" ; return n ; } - -const QuadratureTag & QuadratureTag::tag() -{ static const QuadratureTag self ; return self ; } - -const char * BasisTag::name() const -{ static const char n[] = "Basis" ; return n ; } - -const BasisTag & BasisTag::tag() -{ static const BasisTag self ; return self ; } - -} // namespace mesh -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.hpp deleted file mode 100644 index 9fa57cd66017..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fem/TopologyDimensions.hpp +++ /dev/null @@ -1,155 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#ifndef stk_mesh_TopologyDimensions_hpp -#define stk_mesh_TopologyDimensions_hpp - -#include - -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -/** - * The file contains Field typed and ArrayDimTags that are useful for - * setting up various types of field relations. - */ - -//---------------------------------------------------------------------- -/** \ingroup stk_mesh_field_dimension_tags - * \brief Define an array dimension of the number of nodes per element. - */ -class ElementNode : public shards::ArrayDimTag { -public: - const char * name() const ; - static const ElementNode & tag(); ///< \brief Singleton -private: - ElementNode() {} - ElementNode( const ElementNode & ); - ElementNode & operator = ( const ElementNode & ); -}; - -/** \ingroup stk_mesh_relation_stencil - * \brief An element Field defining an array of values, one value per - * node of the element. - */ -typedef Field ElementNodeField ; - -/** \ingroup stk_mesh_relation_stencil - * \brief A Field defining an array of pointers - * to an element's nodal field data. - */ -typedef Field ElementNodePointerField ; -typedef Field ElementNodeLockField ; - -/** \ingroup stk_mesh_relation_stencil - * \brief Declare an element-node field. - */ -inline -ElementNodeField & -declare_element_node_field( MetaData & md , const std::string & s ) -{ - - ElementNodeField & f = - md.declare_field< ElementNodeField >( s, 1 /* 1 state */ ); - - return f ; -} - -/** \ingroup stk_mesh_relation_stencil - * \brief Declare an element-to-node-data pointer field. - */ -template< class NodeField > -inline -ElementNodePointerField & -declare_element_node_pointer_field( - MetaData & md , const std::string & s , - NodeField & node_field ) -{ - const unsigned num_states = node_field.number_of_states(); - - ElementNodePointerField & f = - md.template declare_field< ElementNodePointerField >( s, num_states ); - - for ( unsigned i = 0 ; i < num_states ; ++i ) { - FieldState state = (FieldState) i; - md.declare_field_relation( - f.field_of_state( state ) , - fem::get_element_node_stencil(fem::FEMMetaData::get(md).spatial_dimension()) , - node_field.field_of_state( state ) ); - } - - return f ; -} - -/** \ingroup stk_mesh_relation_stencil - * \brief Declare an element-to-node-data pointer field. - */ -template< class NodeField > -inline -ElementNodeLockField & -declare_element_node_lock_field( - MetaData & md , const std::string & s , - NodeField & node_field ) -{ - const unsigned num_states = node_field.number_of_states(); - - ElementNodeLockField & f = - md.template declare_field< ElementNodeLockField >( s, num_states ); - - for ( unsigned i = 0 ; i < num_states ; ++i ) { - FieldState state = (FieldState) i; - md.declare_field_relation( - f.field_of_state( state ) , - fem::get_element_node_stencil(fem::FEMMetaData::get(md).spatial_dimension()) , - node_field.field_of_state( state ) ); - } - - return f ; -} -//---------------------------------------------------------------------- -/** \addtogroup stk_mesh_field_dimension_tags - * \{ - */ - -struct QuadratureTag : public shards::ArrayDimTag { - const char * name() const ; - static const QuadratureTag & tag(); ///< \brief Singleton -private: - QuadratureTag() {} - QuadratureTag( const QuadratureTag & ); - QuadratureTag & operator = ( const QuadratureTag & ); -}; - -struct BasisTag : public shards::ArrayDimTag { - const char * name() const ; - static const BasisTag & tag(); ///< \brief Singleton -private: - BasisTag() {} - BasisTag( const BasisTag & ); - BasisTag & operator = ( const BasisTag & ); -}; - - -/** \} */ -//---------------------------------------------------------------------- - -}//namespace mesh -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.cpp deleted file mode 100644 index 6a746ea4bdd8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -BoxFixture::BoxFixture( stk_classic::ParallelMachine pm , - unsigned block_size, - const std::vector& entity_names ) - : m_fem_meta ( spatial_dimension, entity_names ), - m_bulk_data ( fem::FEMMetaData::get_meta_data(m_fem_meta) , pm , block_size ), - m_comm_rank( stk_classic::parallel_machine_rank( pm ) ), - m_comm_size( stk_classic::parallel_machine_size( pm ) ), - m_previous_state ( stk_classic::mesh::BulkData::MODIFIABLE ) -{} - -Entity& BoxFixture::get_new_entity ( EntityRank rank , EntityId parallel_dependent_id ) -{ - return m_bulk_data.declare_entity ( rank , parallel_dependent_id*m_comm_size + m_comm_rank + 1 , std::vector () ); -} - -void BoxFixture::generate_boxes( const BOX root_box, - BOX local_box ) -{ - const unsigned p_rank = m_bulk_data.parallel_rank(); - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned ngx = root_box[0][1] - root_box[0][0] ; - const unsigned ngy = root_box[1][1] - root_box[1][0] ; - - BOX * const p_box = new BOX[ p_size ]; - - box_partition( 0 , p_size , 2 , root_box , & p_box[0] ); - - local_box[0][0] = p_box[ p_rank ][0][0] ; - local_box[0][1] = p_box[ p_rank ][0][1] ; - local_box[1][0] = p_box[ p_rank ][1][0] ; - local_box[1][1] = p_box[ p_rank ][1][1] ; - local_box[2][0] = p_box[ p_rank ][2][0] ; - local_box[2][1] = p_box[ p_rank ][2][1] ; - - // Create elements: - - std::vector local_count ; - - const stk_classic::mesh::PartVector no_parts ; - - for ( int k = local_box[2][0] ; k < local_box[2][1] ; ++k ) { - for ( int j = local_box[1][0] ; j < local_box[1][1] ; ++j ) { - for ( int i = local_box[0][0] ; i < local_box[0][1] ; ++i ) { - const EntityId n0= 1 + (i+0) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n1= 1 + (i+1) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n2= 1 + (i+1) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n3= 1 + (i+0) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n4= 1 + (i+0) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n5= 1 + (i+1) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n6= 1 + (i+1) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n7= 1 + (i+0) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - - const EntityId elem_id = 1 + i + j * ngx + k * ngx * ngy; - - Entity & node0 = m_bulk_data.declare_entity( 0 , n0 , no_parts ); - Entity & node1 = m_bulk_data.declare_entity( 0 , n1 , no_parts ); - Entity & node2 = m_bulk_data.declare_entity( 0 , n2 , no_parts ); - Entity & node3 = m_bulk_data.declare_entity( 0 , n3 , no_parts ); - Entity & node4 = m_bulk_data.declare_entity( 0 , n4 , no_parts ); - Entity & node5 = m_bulk_data.declare_entity( 0 , n5 , no_parts ); - Entity & node6 = m_bulk_data.declare_entity( 0 , n6 , no_parts ); - Entity & node7 = m_bulk_data.declare_entity( 0 , n7 , no_parts ); - Entity & elem = m_bulk_data.declare_entity( 3 , elem_id , no_parts ); - - m_bulk_data.declare_relation( elem , node0 , 0 ); - m_bulk_data.declare_relation( elem , node1 , 1 ); - m_bulk_data.declare_relation( elem , node2 , 2 ); - m_bulk_data.declare_relation( elem , node3 , 3 ); - m_bulk_data.declare_relation( elem , node4 , 4 ); - m_bulk_data.declare_relation( elem , node5 , 5 ); - m_bulk_data.declare_relation( elem , node6 , 6 ); - m_bulk_data.declare_relation( elem , node7 , 7 ); - } - } - } - - delete[] p_box ; -} - -void BoxFixture::box_partition( int ip , int up , int axis , - const BOX box , - BOX p_box[] ) -{ - const int np = up - ip ; - if ( 1 == np ) { - p_box[ip][0][0] = box[0][0] ; p_box[ip][0][1] = box[0][1] ; - p_box[ip][1][0] = box[1][0] ; p_box[ip][1][1] = box[1][1] ; - p_box[ip][2][0] = box[2][0] ; p_box[ip][2][1] = box[2][1] ; - } - else { - const int n = box[ axis ][1] - box[ axis ][0] ; - const int np_low = np / 2 ; /* Rounded down */ - const int np_upp = np - np_low ; - - const int n_upp = (int) (((double) n) * ( ((double)np_upp) / ((double)np))); - const int n_low = n - n_upp ; - const int next_axis = ( axis + 2 ) % 3 ; - - if ( np_low ) { /* P = [ip,ip+np_low) */ - BOX dbox ; - dbox[0][0] = box[0][0] ; dbox[0][1] = box[0][1] ; - dbox[1][0] = box[1][0] ; dbox[1][1] = box[1][1] ; - dbox[2][0] = box[2][0] ; dbox[2][1] = box[2][1] ; - - dbox[ axis ][1] = dbox[ axis ][0] + n_low ; - - box_partition( ip, ip + np_low, next_axis, - (const int (*)[2]) dbox, p_box ); - } - - if ( np_upp ) { /* P = [ip+np_low,ip+np_low+np_upp) */ - BOX dbox ; - dbox[0][0] = box[0][0] ; dbox[0][1] = box[0][1] ; - dbox[1][0] = box[1][0] ; dbox[1][1] = box[1][1] ; - dbox[2][0] = box[2][0] ; dbox[2][1] = box[2][1] ; - - ip += np_low ; - dbox[ axis ][0] += n_low ; - dbox[ axis ][1] = dbox[ axis ][0] + n_upp ; - - box_partition( ip, ip + np_upp, next_axis, - (const int (*)[2]) dbox, p_box ); - } - } -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.hpp deleted file mode 100644 index 55073a3c41ac..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/BoxFixture.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Mesh_Fixtures_BoxFixture_hpp -#define Stk_Mesh_Fixtures_BoxFixture_hpp - -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -static const size_t spatial_dimension = 3; -/** - * A fixture that creates a "box" mesh of hexes - */ -class BoxFixture { -public: - BoxFixture(stk_classic::ParallelMachine pm = MPI_COMM_WORLD, - unsigned block_size = 1000, - const std::vector& entity_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - - ~BoxFixture () {} - - fem::FEMMetaData & fem_meta () { return m_fem_meta; } - BulkData & bulk_data () { return m_bulk_data; } - - unsigned comm_size() const { return m_comm_size; } - unsigned comm_rank() const { return m_comm_rank; } - - typedef int BOX[3][2]; - - /** - * Generate a box mesh which is globally ( ngx X ngy X ngz ) - * elements where: - * ngx = root_box[0][1] - root_box[0][0] ; - * ngy = root_box[1][1] - root_box[1][0] ; - * ngz = root_box[2][1] - root_box[2][0] ; - * - * The box is partitioned via recursive coordinate bisection - * and the resulting local box are given in 'local_box'. - */ - void generate_boxes (const BOX root_box, - BOX local_box); - - Entity &get_new_entity ( EntityRank rank , EntityId parallel_dependent_id ); - -protected: - fem::FEMMetaData m_fem_meta; - BulkData m_bulk_data; - - unsigned m_comm_rank; - unsigned m_comm_size; - - BulkData::BulkDataSyncState m_previous_state; - - /** - * Recursively split a box into ( up - ip ) sub-boxes - */ - static void box_partition( int ip , int up , int axis , - const BOX box , - BOX p_box[] ); - -private: - - BoxFixture(); - BoxFixture( const BoxFixture & ); - BoxFixture & operator = ( const BoxFixture & ); -}; - -} // namespace fixtures -} // namespace mesh -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/CMakeLists.txt deleted file mode 100644 index 18e8e081400a..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -#SET(HEADERS_IMPL "") -#SET(SOURCES_IMPL "") - -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../stk_util) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/..) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -#FILE(GLOB HEADERS_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/*.hpp) -#FILE(GLOB SOURCES_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/../baseImpl/*.cpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_mesh_fixtures - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_base stkclassic_mesh_fem - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_mesh/fixtures/) diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.cpp deleted file mode 100644 index 1143ada67eb6..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -} - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -Gear::Gear( - fem::FEMMetaData & meta, - BulkData & bulk, - Part & gear, - Part & arg_cylindrical_coord_part, - Part & hex, - Part & wedge, - CartesianField & arg_cartesian_coord_field, - CartesianField & arg_displacement_field, - CartesianField & arg_translation_field, - CylindricalField & arg_cylindrical_coord_field, - double arg_element_size, - double arg_radius_min, - double arg_radius_max, - double arg_height_min, - double arg_height_max - ) : - element_size(arg_element_size) - , rad_min(arg_radius_min) - , rad_max(arg_radius_max) - , height_min(arg_height_min) - , height_max(arg_height_max) - - , angle_num(static_cast(TWO_PI/element_size)) - , rad_num(static_cast(2 +(rad_max - rad_min)/element_size)) - , height_num(static_cast(2 +(height_max - height_min)/element_size)) - - , angle_increment( TWO_PI / static_cast(angle_num)) - , rad_increment( (rad_max-rad_min) / static_cast(rad_num-1)) - , height_increment( (height_max-height_min) / static_cast(height_num-1)) - - , num_elements( angle_num * (rad_num-1) * (height_num-1) ) - , num_nodes( angle_num * (rad_num) * (height_num) ) - - , meta_data(meta) - , bulk_data(bulk) - - , gear_part(gear) - , cylindrical_coord_part(arg_cylindrical_coord_part) - , hex_part(hex) - , wedge_part(wedge) - - , cartesian_coord_field(arg_cartesian_coord_field) - , displacement_field(arg_displacement_field) - , translation_field(arg_translation_field) - , cylindrical_coord_field(arg_cylindrical_coord_field) -{} - -// -//----------------------------------------------------------------------------- -// - -void Gear::populate_fields(stk_classic::mesh::FieldState state) { - - //setup the cylindrical_coord_field on the hex nodes - for ( size_t ir = 0 ; ir < rad_num-1; ++ir ) { - const double rad = rad_min + rad_increment * ir ; - - for ( size_t ia = 0 ; ia < angle_num; ++ia ) { - const double angle = angle_increment * ia ; - - for ( size_t iz = 0 ; iz < height_num; ++iz ) { - const double height = height_min + height_increment * iz ; - - Entity & node = get_node(iz,ir,ia); - - double * const cylindrical_data = field_data( cylindrical_coord_field , node ); - double * const translation_data = field_data( translation_field , node ); - double * const cartesian_data = field_data( cartesian_coord_field , node ); - double * const displacement_data = field_data( displacement_field.field_of_state(state) , node ); - - cylindrical_data[0] = rad ; - cylindrical_data[1] = angle ; - cylindrical_data[2] = height; - - translation_data[0] = 0; - translation_data[1] = 0; - translation_data[2] = 0; - - displacement_data[0] = 0; - displacement_data[1] = 0; - displacement_data[2] = 0; - - cartesian_data[0] = rad * std::cos(angle); - cartesian_data[1] = rad * std::sin(angle); - cartesian_data[2] = height; - } - } - } - - //setup the cylindrical_coord_field on the wedge nodes - { - size_t ir = rad_num-1; - //const double rad = rad_min + rad_increment * ir ; - const double rad = 1.1*rad_max; - - for ( size_t ia = 0 ; ia < angle_num; ++ia ) { - const double angle = angle_increment * (ia + ia +1.0)/2.0; - - for ( size_t iz = 0 ; iz < height_num; ++iz ) { - const double height = height_min + height_increment * iz ; - - Entity & node = get_node(iz,ir,ia); - - double * const cylindrical_data = field_data( cylindrical_coord_field , node ); - double * const translation_data = field_data( translation_field , node ); - double * const cartesian_data = field_data( cartesian_coord_field , node ); - double * const displacement_data = field_data( displacement_field.field_of_state(state) , node ); - - cylindrical_data[0] = rad ; - cylindrical_data[1] = angle ; - cylindrical_data[2] = height; - - translation_data[0] = 0; - translation_data[1] = 0; - translation_data[2] = 0; - - displacement_data[0] = 0; - displacement_data[1] = 0; - displacement_data[2] = 0; - - cartesian_data[0] = rad * std::cos(angle); - cartesian_data[1] = rad * std::sin(angle); - cartesian_data[2] = height; - } - } - } -} - - -// -//----------------------------------------------------------------------------- -// - -void Gear::generate_gear() -{ - const stk_classic::mesh::EntityRank element_rank = meta_data.element_rank(); - - std::vector requests(meta_data.entity_rank_count(), 0); - requests[NODE_RANK] = num_nodes; - requests[element_rank] = num_elements; - - // Parallel collective call: - bulk_data.generate_new_entities(requests, gear_entities); - - //setup hex elements - { - std::vector add_parts, remove_parts ; - add_parts.push_back( & cylindrical_coord_part ); - add_parts.push_back( & gear_part ); - add_parts.push_back( & hex_part ); - - for ( size_t ir = 0 ; ir < rad_num -2 ; ++ir ) { - for ( size_t ia = 0 ; ia < angle_num; ++ia ) { - for ( size_t iz = 0 ; iz < height_num -1 ; ++iz ) { - - Entity & elem = get_element(iz, ir, ia); - bulk_data.change_entity_parts(elem, add_parts, remove_parts); - - const size_t ia_1 = ( ia + 1 ) % angle_num ; - const size_t ir_1 = ir + 1 ; - const size_t iz_1 = iz + 1 ; - - Entity * node[8] ; - - node[0] = & get_node(iz , ir , ia_1 ); - node[1] = & get_node(iz , ir , ia ); - node[2] = & get_node(iz_1, ir , ia ); - node[3] = & get_node(iz_1, ir , ia_1 ); - node[4] = & get_node(iz , ir_1, ia_1 ); - node[5] = & get_node(iz , ir_1, ia ); - node[6] = & get_node(iz_1, ir_1, ia ); - node[7] = & get_node(iz_1, ir_1, ia_1 ); - - for ( size_t j = 0 ; j < 8 ; ++j ) { - bulk_data.declare_relation( elem , * node[j] , j ); - } - } - } - } - } - - //setup wedges elements - { - std::vector add_parts, remove_parts ; - add_parts.push_back( & cylindrical_coord_part ); - add_parts.push_back( & gear_part ); - add_parts.push_back( & wedge_part ); - - size_t ir = rad_num-2 ; - for ( size_t ia = 0 ; ia < angle_num; ++ia ) { - for ( size_t iz = 0 ; iz < height_num -1 ; ++iz ) { - - Entity & elem = get_element(iz, ir, ia); - bulk_data.change_entity_parts(elem, add_parts, remove_parts); - - const size_t ia_1 = ( ia + 1 ) % angle_num ; - const size_t ir_1 = ir + 1 ; - const size_t iz_1 = iz + 1 ; - - Entity * node[6] ; - - node[0] = & get_node(iz , ir , ia_1 ); - node[1] = & get_node(iz , ir , ia ); - node[2] = & get_node(iz , ir_1, ia ); - node[3] = & get_node(iz_1, ir , ia_1 ); - node[4] = & get_node(iz_1, ir , ia ); - node[5] = & get_node(iz_1, ir_1, ia ); - - for ( size_t j = 0 ; j < 6 ; ++j ) { - bulk_data.declare_relation( elem , * node[j] , j ); - } - } - } - } - - //cylindrical and cartesian coordinates - //are 2 state fields. Need to update - //both states at construction - populate_fields(stk_classic::mesh::StateOld); - populate_fields(stk_classic::mesh::StateNew); - -} - -// -//----------------------------------------------------------------------------- -// - -void Gear::move( const GearMovement & data) { - - enum { Node = 0 }; - - Selector select = gear_part & cylindrical_coord_part & (meta_data.locally_owned_part() | meta_data.globally_shared_part()); - - BucketVector all_node_buckets = bulk_data.buckets(NODE_RANK); - - BucketVector node_buckets; - - get_buckets( - select, - all_node_buckets, - node_buckets - ); - - for (BucketVector::iterator b_itr = node_buckets.begin(); - b_itr != node_buckets.end(); - ++b_itr) - { - Bucket & b = **b_itr; - BucketArray cylindrical_data( cylindrical_coord_field, b); // ONE STATE - BucketArray translation_data( translation_field, b); // ONE STATE - const BucketArray old_coordinate_data( cartesian_coord_field, b); // ONE STATE - BucketArray new_displacement_data( displacement_field.field_of_state(stk_classic::mesh::StateNew), b); // TWO STATE - - double new_coordinate_data[3] = {0,0,0}; - for (size_t i = 0; i < b.size(); ++i) { - int index = i; - - const double radius = cylindrical_data(0,index); - double & angle = cylindrical_data(1,index); - const double height = cylindrical_data(2,index); - - - angle += data.rotation; - - if ( angle < 0.0) { - angle += TWO_PI; - } - else if ( angle > TWO_PI) { - angle -= TWO_PI; - } - - translation_data(0,index) += data.x; - translation_data(1,index) += data.y; - translation_data(2,index) += data.z; - - new_coordinate_data[0] = translation_data(0,index) + radius * std::cos(angle); - new_coordinate_data[1] = translation_data(1,index) + radius * std::sin(angle); - new_coordinate_data[2] = translation_data(2,index) + height; - - new_displacement_data(0,index) = new_coordinate_data[0] - old_coordinate_data(0,index); - new_displacement_data(1,index) = new_coordinate_data[1] - old_coordinate_data(1,index); - new_displacement_data(2,index) = new_coordinate_data[2] - old_coordinate_data(2,index); - - } - } -} - -} // fixtures -} // mesh -} // stk diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.hpp deleted file mode 100644 index e6def3baa8b0..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/Gear.hpp +++ /dev/null @@ -1,164 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_FIXTURES_GEAR_HPP -#define STK_MESH_FIXTURES_GEAR_HPP - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace { - -const double PI = 3.14159265358979; -const double TWO_PI = 2 * PI; - -} // namespace - - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -/** - * Defines a single movement of a gear. This include rotation and movement in - * the x, y, z dimensions. - */ -struct GearMovement -{ - double rotation; - double x; - double y; - double z; - - GearMovement( - double arg_rotation = 0.0, - double arg_x = 0.0, - double arg_y = 0.0, - double arg_z = 0.0 - ) : - rotation(arg_rotation) - , x(arg_x) - , y(arg_y) - , z(arg_z) - {} -}; - -class Gear { - - typedef Field< double ,Cartesian> CartesianField ; - typedef Field< double ,Cylindrical> CylindricalField ; - - enum { SpatialDimension = 3 }; - - public: - Gear( - fem::FEMMetaData & meta, - BulkData & bulk, - Part & gear, - Part & cylindrical_coord, - Part & hex, - Part & wedge, - CartesianField & arg_cartesian_coord_field, - CartesianField & arg_displacement_field, - CartesianField & arg_translation_field, - CylindricalField & arg_cylindrical_coord_field, - double arg_element_size = 0.10, - double arg_radius_min = 0.6, - double arg_radius_max = 1.0 + 0.05, - double arg_height_min = -0.4, - double arg_height_max = 0.4 - ); - - const double element_size; - const double rad_min, rad_max; - const double height_min, height_max; - - const size_t angle_num; - const size_t rad_num; - const size_t height_num; - - const double angle_increment; - const double rad_increment; - const double height_increment; - - const size_t num_elements; - const size_t num_nodes; - - fem::FEMMetaData & meta_data; - BulkData & bulk_data; - - Part & gear_part; - - //must be called between modification_begin / modification_end - void generate_gear(); - - void move( const GearMovement & data ); - - private: - - Entity & get_node ( - size_t iz , // Thickness index - size_t ir , // Radial index - size_t ia ) const // Angle index - { - return * gear_entities[ node_index(iz,ir,ia)]; - } - - Entity & get_element( - size_t iz , // Thickness index - size_t ir , // Radial index - size_t ia ) const // Angle index - { - return * gear_entities[ elem_index(iz,ir,ia)]; - } - - EntityId node_index( - size_t iz , // Thickness index - size_t ir , // Radial index - size_t ia ) const // Angle index - { - return static_cast(iz + height_num * ( ir + rad_num * ia )); - } - - EntityId elem_index( - size_t iz , // Thickness index - size_t ir , // Radial index - size_t ia ) const // Angle index - { - return static_cast(num_nodes + iz + (height_num-1) * ( ir + (rad_num-1) * ia )); - } - - void populate_fields(stk_classic::mesh::FieldState state); - - Part & cylindrical_coord_part; - Part & hex_part; - Part & wedge_part; - - CartesianField & cartesian_coord_field ; - CartesianField & displacement_field ; - CartesianField & translation_field ; - CylindricalField & cylindrical_coord_field ; - - EntityVector gear_entities; - - Gear(const Gear &); - void operator = (const Gear &); -}; - -} // fixtures -} // mesh -} // stk - -#endif // STK_MESH_FIXTURES_GEAR_HPP diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GearsFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GearsFixture.cpp deleted file mode 100644 index 8233fe874e39..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GearsFixture.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -const unsigned ONE_STATE = 1; -const unsigned TWO_STATE = 2; - -typedef shards::Hexahedron<8> Hex8 ; -typedef shards::Wedge<6> Wedge6 ; - -} // namespace - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -GearsFixture::GearsFixture( ParallelMachine pm, size_t num_gears, GearParams gear_params) - : NUM_GEARS(num_gears) - , meta_data( SpatialDimension ) - , bulk_data( fem::FEMMetaData::get_meta_data(meta_data) , pm ) - , element_rank( meta_data.element_rank() ) - , cylindrical_coord_part( meta_data.declare_part("cylindrical_coord_part", element_rank)) - , hex_part( fem::declare_part(meta_data, "hex8_part")) - , wedge_part( fem::declare_part(meta_data, "wedge6_part")) - , cartesian_coord_field( meta_data.declare_field("coordinates", ONE_STATE)) - , displacement_field( meta_data.declare_field("displacement", TWO_STATE)) - , translation_field( meta_data.declare_field("translation", ONE_STATE)) - , cylindrical_coord_field( meta_data.declare_field("cylindrical_coordinates", ONE_STATE)) - , m_gears() - { - - put_field( - cartesian_coord_field, - NODE_RANK, - meta_data.universal_part(), - SpatialDimension - ); - - put_field( - displacement_field, - NODE_RANK, - meta_data.universal_part(), - SpatialDimension - ); - - put_field( - translation_field, - NODE_RANK, - cylindrical_coord_part, - SpatialDimension - ); - - put_field( - cylindrical_coord_field, - NODE_RANK, - cylindrical_coord_part, - SpatialDimension - ); - - m_gears.resize(NUM_GEARS); - - for ( size_t i = 0; i < NUM_GEARS; ++i) { - std::ostringstream oss; - oss << "Gear_" << i ; - m_gears[i] = new Gear ( - meta_data, - bulk_data, - meta_data.declare_part(oss.str(),SpatialDimension), - cylindrical_coord_part, - hex_part, - wedge_part, - cartesian_coord_field, - displacement_field, - translation_field, - cylindrical_coord_field, - gear_params.element_size, - gear_params.radius_min, - gear_params.radius_max, - gear_params.height_min, - gear_params.height_max - ); - } -} - -GearsFixture::~GearsFixture() -{ - for( std::vector::iterator i = m_gears.begin(); - i != m_gears.end(); - ++i ) - { - delete *i; - *i = NULL; - } -} - -void GearsFixture::generate_mesh() { - - // Parallel collective call: - bulk_data.modification_begin(); - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - //create the gears on a line - for( size_t i = 0; i < m_gears.size(); ++i) { - if (( (i*p_size)/m_gears.size()) == p_rank) { - Gear & gear = get_gear(i); - gear.generate_gear(); - } else { - // Parallel synchronization: - std::vector empty_requests(meta_data.entity_rank_count(), 0); - EntityVector empty_entities; - bulk_data.generate_new_entities(empty_requests, empty_entities); - } - } - - // Parallel collective call: - bulk_data.modification_end(); - - // Parallel collective call: - communicate_model_fields(); - - for ( size_t i = 0 ; i < m_gears.size() ; ++i ) { - // Parallel collective call: - distribute_gear_across_processors(get_gear(i),cylindrical_coord_field); - } - -} - -void GearsFixture::communicate_model_fields() -{ - //copy the field data to the aura nodes - - std::vector< const FieldBase *> fields; - - fields.push_back(& cartesian_coord_field); - fields.push_back(& translation_field); - fields.push_back(& cylindrical_coord_field); - fields.push_back(& displacement_field.field_of_state(stk_classic::mesh::StateNew)); - fields.push_back(& displacement_field.field_of_state(stk_classic::mesh::StateOld)); - - // Parallel collective call: - communicate_field_data(bulk_data.shared_aura(), fields); -} - - -double scale_angle_2pi(double angle) { - while ( angle < 0.0 ) { - angle += TWO_PI; - } - while ( angle >= TWO_PI) { - angle -= TWO_PI; - } - return angle; -} - - -void select_nodal_data( - GearsFixture::CylindricalField & cylindrical_coord_field, - Entity & element, - double & radius, - double & angle, - double & height - ) -{ - radius = 0.0; - angle = TWO_PI; - height = 0.0; - PairIterRelation node_relations = element.relations(NODE_RANK); - int numNodes = node_relations.second - node_relations.first; - for ( ; node_relations.first != node_relations.second ; ++(node_relations.first) ) { - Entity * node = node_relations.first->entity(); - EntityArray cylindrical_data( cylindrical_coord_field, *node); - radius += cylindrical_data(0); - angle = std::min(angle,cylindrical_data(1)); - height += cylindrical_data(2); - } - radius /= numNodes; - height /= numNodes; -} - -// Parallel collective call: -void distribute_gear_across_processors(Gear & gear, GearsFixture::CylindricalField & cylindrical_coord_field) -{ - BulkData & bulk_data = gear.bulk_data; - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - EntityProcVec elements_to_change_owner; - - Selector locally_owned = gear.meta_data.locally_owned_part(); - if (p_rank == 0) { - BucketVector all_elements; - stk_classic::mesh::get_buckets(locally_owned,bulk_data.buckets(gear.meta_data.element_rank()),all_elements); - std::set node_set; // First come first serve nodal movement. - for (BucketVector::iterator it = all_elements.begin() ; it != all_elements.end() ; ++it) { - Bucket & b = **it; - for (size_t i=0 ; irelations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for ( ; node_relations.first != node_relations.second ; ++(node_relations.first) ) { - Entity * node = node_relations.first->entity(); - if (node_set.count(node)==0) { - elements_to_change_owner.push_back(EntityProc(node,destination_processor_rank)); - node_set.insert(node); - } - } - } - } - } - - // Parallel collective call: - bulk_data.modification_begin(); - bulk_data.change_entity_owner(elements_to_change_owner); - // Parallel collective call: - bulk_data.modification_end(); - - // Print out how many ended up on each processor: - //{ - // BucketVector local_elements; - // stk_classic::mesh::get_buckets(locally_owned,bulk_data.buckets(Element),local_elements); - // BucketVector local_nodes; - // stk_classic::mesh::get_buckets(locally_owned,bulk_data.buckets(Node),local_nodes); - // size_t element_count = 0; - // for (BucketVector::iterator it = local_elements.begin() ; it != local_elements.end() ; ++it) { - // Bucket & b = **it; - // element_count += b.size(); - // } - // size_t node_count = 0; - // for (BucketVector::iterator it = local_nodes.begin() ; it != local_nodes.end() ; ++it) { - // Bucket & b = **it; - // node_count += b.size(); - // } - // std::cout << "Proc " << p_rank << ": element count = " << element_count << " node count = " << node_count << std::endl; - //} - -} - - -double floor0(double value) -{ - double result = std::floor( std::fabs( value ) ); - return (value < 0.0) ? -result : result; -} - - -void scale_p_rank(unsigned & p_rank, unsigned p_size) -{ - if (p_rank >= p_size) { - p_rank = p_size-1; - } -} - -unsigned destination_processor(const Gear & gear, double rad, double angle, double height, unsigned p_rank, unsigned p_size) -{ - unsigned result = 0; - // Distribute elements across angles: (not working perfectly yet) - angle = scale_angle_2pi(angle); - result = static_cast(floor0((angle/TWO_PI)*p_size)); - - // Distribute elements across radius: - //result = static_cast(floor0((rad-gear.rad_min)/(gear.rad_max-gear.rad_min)*p_size)); - - // Distribute elements across height: - //result = static_cast(floor0((height-gear.height_min)/(gear.height_max-gear.height_min)*p_size)); - - // Distribute elements randomly: - //result = std::rand() % p_size; - - // Distribute in round-robin fashion: - //static unsigned dest_proc = 0; - //result = dest_proc++ % p_size; - - // Distribute all to processor 2: - //result = 1; - - scale_p_rank(result,p_size); - - //std::cout << "P"< all_entities; - - // assign ids, quads, nodes, then shells - // (we need this order to be this way in order for our connectivity setup to work) - std::vector quad_face_ids(num_quad_faces); - std::vector node_ids(num_nodes); - { - unsigned curr_id = 1; - for (unsigned i = 0 ; i < num_quad_faces; ++i, ++curr_id) { - quad_face_ids[i] = curr_id; - } - for (unsigned i = 0 ; i < num_nodes; ++i, ++curr_id) { - node_ids[i] = curr_id; - } - } - - // Note: This block of code would normally be replaced with a call to stk_io - // to generate the mesh. - - // declare entities such that entity_id - 1 is the index of the - // entity in the all_entities vector - { - const PartVector no_parts; - const unsigned first_quad = (p_rank * num_quad_faces) / p_size; - const unsigned end_quad = ((p_rank + 1) * num_quad_faces) / p_size; - - // declare faces - PartVector face_parts; - face_parts.push_back(&m_quad_part); - const unsigned num_nodes_per_quad = 4; - // (right-hand rule) counterclockwise: - const int stencil_for_4x4_quad_mesh[num_nodes_per_quad] = {0, 5, 1, -5}; - for (unsigned i = first_quad; i < end_quad; ++i) { - - unsigned face_id = quad_face_ids[i]; - unsigned row = (face_id - 1) / num_nodes_per_quad; - - Entity& face = m_bulk_data.declare_entity(element_rank, face_id, face_parts); - - unsigned node_id = num_quad_faces + face_id + row; - - for (unsigned chg_itr = 0; chg_itr < num_nodes_per_quad; ++chg_itr) { - node_id += stencil_for_4x4_quad_mesh[chg_itr]; - Entity& node = m_bulk_data.declare_entity(fem::FEMMetaData::NODE_RANK, node_id, no_parts); - m_bulk_data.declare_relation( face , node , chg_itr); - } - } - } -} - -} // fixtures -} // mesh -} // stk - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GridFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GridFixture.hpp deleted file mode 100644 index 874f447ce624..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/GridFixture.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_FIXTURES_GRID_MESH_FIXTURE_HPP -#define STK_MESH_FIXTURES_GRID_MESH_FIXTURE_HPP - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -class GridFixture -{ -public: - GridFixture(stk_classic::ParallelMachine pm); - - ~GridFixture(); - - fem::FEMMetaData& fem_meta() { return m_fem_meta; } - BulkData& bulk_data() { return m_bulk_data; } - - Part* quad_part() const { return & m_quad_part; } - Part* dead_part() const { return & m_dead_part; } - - void generate_grid(); - - const unsigned m_spatial_dimension; - - fem::FEMMetaData m_fem_meta; - BulkData m_bulk_data; - Part & m_quad_part; - Part & m_dead_part; -}; - -} // fixtures -} // mesh -} // stk - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.cpp deleted file mode 100644 index 4318887ed8ca..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -HexFixture::HexFixture(stk_classic::ParallelMachine pm, unsigned nx, unsigned ny, unsigned nz) - : m_spatial_dimension(3), - m_nx(nx), - m_ny(ny), - m_nz(nz), - m_fem_meta( m_spatial_dimension, fem::entity_rank_names(m_spatial_dimension) ), - m_bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_fem_meta) , pm ), - m_hex_part( fem::declare_part >(m_fem_meta, "hex_part") ), - m_node_part( m_fem_meta.declare_part("node_part", m_fem_meta.node_rank() ) ), - m_coord_field( m_fem_meta.declare_field("Coordinates") ), - m_coord_gather_field(m_fem_meta.declare_field("GatherCoordinates")) -{ - typedef shards::Hexahedron<8> Hex8 ; - const unsigned nodes_per_elem = Hex8::node_count; - - //put coord-field on all nodes: - put_field( - m_coord_field, - fem::FEMMetaData::NODE_RANK, - m_fem_meta.universal_part(), - m_spatial_dimension); - - //put coord-gather-field on all elements: - put_field( - m_coord_gather_field, - m_fem_meta.element_rank(), - m_fem_meta.universal_part(), - nodes_per_elem); - - // Field relation so coord-gather-field on elements points - // to coord-field of the element's nodes - m_fem_meta.declare_field_relation( m_coord_gather_field, - fem::element_node_stencil, - m_coord_field); -} - -void HexFixture::generate_mesh() -{ - std::vector element_ids_on_this_processor; - - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned p_rank = m_bulk_data.parallel_rank(); - const unsigned num_elems = m_nx * m_ny * m_nz ; - - const EntityId beg_elem = 1 + ( num_elems * p_rank ) / p_size ; - const EntityId end_elem = 1 + ( num_elems * ( p_rank + 1 ) ) / p_size ; - - for ( EntityId i = beg_elem; i != end_elem; ++i) { - element_ids_on_this_processor.push_back(i); - } - - generate_mesh(element_ids_on_this_processor); -} - -void HexFixture::node_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const -{ - entity_id -= 1; - - x = entity_id % (m_nx+1); - entity_id /= (m_nx+1); - - y = entity_id % (m_ny+1); - entity_id /= (m_ny+1); - - z = entity_id; -} - -void HexFixture::elem_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const -{ - entity_id -= 1; - - x = entity_id % m_nx; - entity_id /= m_nx; - - y = entity_id % m_ny; - entity_id /= m_ny; - - z = entity_id; -} - -void HexFixture::generate_mesh(std::vector & element_ids_on_this_processor) -{ - { - //sort and unique the input elements - std::vector::iterator ib = element_ids_on_this_processor.begin(); - std::vector::iterator ie = element_ids_on_this_processor.end(); - - std::sort( ib, ie); - ib = std::unique( ib, ie); - element_ids_on_this_processor.erase(ib, ie); - } - - m_bulk_data.modification_begin(); - - { - // Declare the elements that belong on this process - - PartVector add_parts; - add_parts.push_back(&m_node_part); - - std::vector::iterator ib = element_ids_on_this_processor.begin(); - const std::vector::iterator ie = element_ids_on_this_processor.end(); - for (; ib != ie; ++ib) { - EntityId entity_id = *ib; - unsigned ix = 0, iy = 0, iz = 0; - elem_x_y_z(entity_id, ix, iy, iz); - - stk_classic::mesh::EntityId elem_node[8] ; - - elem_node[0] = node_id( ix , iy , iz ); - elem_node[1] = node_id( ix+1 , iy , iz ); - elem_node[2] = node_id( ix+1 , iy , iz+1 ); - elem_node[3] = node_id( ix , iy , iz+1 ); - elem_node[4] = node_id( ix , iy+1 , iz ); - elem_node[5] = node_id( ix+1 , iy+1 , iz ); - elem_node[6] = node_id( ix+1 , iy+1 , iz+1 ); - elem_node[7] = node_id( ix , iy+1 , iz+1 ); - - stk_classic::mesh::fem::declare_element( m_bulk_data, m_hex_part, elem_id( ix , iy , iz ) , elem_node); - - for (unsigned i = 0; i<8; ++i) { - stk_classic::mesh::Entity * const node = m_bulk_data.get_entity( fem::FEMMetaData::NODE_RANK , elem_node[i] ); - m_bulk_data.change_entity_parts(*node, add_parts); - - ThrowRequireMsg( node != NULL, - "This process should know about the nodes that make up its element"); - - // Compute and assign coordinates to the node - unsigned nx = 0, ny = 0, nz = 0; - node_x_y_z(elem_node[i], nx, ny, nz); - - Scalar * data = stk_classic::mesh::field_data( m_coord_field , *node ); - - data[0] = nx ; - data[1] = ny ; - data[2] = -(Scalar)nz ; - } - } - } - - m_bulk_data.modification_end(); -} - -} // fixtures -} // mesh -} // stk diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.hpp deleted file mode 100644 index 70509e2ea1c7..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/HexFixture.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_FIXTURES_HEX_MESH_FIXTURE_HPP -#define STK_MESH_FIXTURES_HEX_MESH_FIXTURE_HPP - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -/** - * A 3-dimensional X*Y*Z hex fixture. - * - * A coordinate field will be added to all nodes, a coordinate-gather field - * will be added to all elements. - */ -class HexFixture -{ - public: - typedef double Scalar ; - typedef Field CoordFieldType; - typedef Field CoordGatherFieldType; - - /** - * Set up meta data to support this fixture. Meta data is left uncommitted - * to allow additional modifications by the client. - */ - HexFixture(stk_classic::ParallelMachine pm, unsigned nx, unsigned ny, unsigned nz); - - const int m_spatial_dimension; - const unsigned m_nx; - const unsigned m_ny; - const unsigned m_nz; - fem::FEMMetaData m_fem_meta; - BulkData m_bulk_data; - Part & m_hex_part; - Part & m_node_part; - CoordFieldType & m_coord_field ; - CoordGatherFieldType & m_coord_gather_field ; - - /** - * Thinking in terms of a 3D grid of nodes, get the id of the node in - * the (x, y, z) position. - */ - EntityId node_id( unsigned x , unsigned y , unsigned z ) const { - return 1 + x + ( m_nx + 1 ) * ( y + ( m_ny + 1 ) * z ); - } - - /** - * Thinking in terms of a 3D grid of elements, get the id of the - * element in the (x, y, z) position. - */ - EntityId elem_id( unsigned x , unsigned y , unsigned z ) const { - return 1 + x + m_nx * ( y + m_ny * z ); - } - - /** - * Thinking in terms of a 3D grid of nodes, get the node in the (x, y, z) - * position. Return NULL if this process doesn't know about this node. - */ - Entity * node( unsigned x , unsigned y , unsigned z ) const { - return m_bulk_data.get_entity( fem::FEMMetaData::NODE_RANK , node_id(x, y, z) ); - } - - /** - * Thinking in terms of a 3D grid of elements, get the elements in the - * (x, y, z) position. Return NULL if this process doesn't know about this - * element. - */ - Entity * elem( unsigned x , unsigned y , unsigned z ) const { - return m_bulk_data.get_entity( m_fem_meta.element_rank(), elem_id(x, y, z) ); - } - - /** - * Thinking in terms of a 3D grid of nodes, compute the (x, y, z) position - * of a node given it's id. - */ - void node_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const; - - /** - * Thinking in terms of a 3D grid of elements, compute the (x, y, z) position - * of an element given it's id. - */ - void elem_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const; - - /** - * Create the mesh (into m_bulk_data). - */ - void generate_mesh(); - - void generate_mesh( std::vector & element_ids_on_this_processor ); - - private: - - HexFixture(); - HexFixture( const HexFixture &); - HexFixture & operator = (const HexFixture &); -}; - - -} // fixtures -} // mesh -} // stk -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.cpp deleted file mode 100644 index 39954673e6cb..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -QuadFixture::QuadFixture( stk_classic::ParallelMachine pm , - unsigned nx , unsigned ny ) - : m_spatial_dimension(2), - m_fem_meta( m_spatial_dimension, fem::entity_rank_names(m_spatial_dimension) ), - m_bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_fem_meta) , pm ), - m_quad_part( fem::declare_part >(m_fem_meta, "quad_part" ) ), - m_coord_field( m_fem_meta.declare_field("Coordinates") ), - m_coord_gather_field( m_fem_meta.declare_field("GatherCoordinates") ), - m_nx( nx ), - m_ny( ny ) -{ - typedef shards::Quadrilateral<4> Quad4 ; - const unsigned nodes_per_elem = Quad4::node_count; - - //put coord-field on all nodes: - put_field( - m_coord_field, - fem::FEMMetaData::NODE_RANK, - m_fem_meta.universal_part(), - m_spatial_dimension - ); - - //put coord-gather-field on all elements: - put_field( - m_coord_gather_field, - m_fem_meta.element_rank(), - m_fem_meta.universal_part(), - nodes_per_elem - ); - - // Field relation so coord-gather-field on elements points - // to coord-field of the element's nodes - m_fem_meta.declare_field_relation( - m_coord_gather_field, - fem::element_node_stencil, - m_coord_field - ); -} - -void QuadFixture::node_x_y( EntityId entity_id, unsigned &x , unsigned &y ) const -{ - entity_id -= 1; - - x = entity_id % (m_nx+1); - entity_id /= (m_nx+1); - - y = entity_id; -} - -void QuadFixture::elem_x_y( EntityId entity_id, unsigned &x , unsigned &y ) const -{ - entity_id -= 1; - - x = entity_id % m_nx; - entity_id /= m_nx; - - y = entity_id; -} - - -void QuadFixture::generate_mesh() -{ - std::vector element_ids_on_this_processor; - - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned p_rank = m_bulk_data.parallel_rank(); - const unsigned num_elems = m_nx * m_ny; - - const EntityId beg_elem = 1 + ( num_elems * p_rank ) / p_size ; - const EntityId end_elem = 1 + ( num_elems * ( p_rank + 1 ) ) / p_size ; - - for ( EntityId i = beg_elem; i != end_elem; ++i) { - element_ids_on_this_processor.push_back(i); - } - - generate_mesh(element_ids_on_this_processor); -} - -void QuadFixture::generate_mesh(std::vector & element_ids_on_this_processor) -{ - { - //sort and unique the input elements - std::vector::iterator ib = element_ids_on_this_processor.begin(); - std::vector::iterator ie = element_ids_on_this_processor.end(); - - std::sort( ib, ie); - ib = std::unique( ib, ie); - element_ids_on_this_processor.erase(ib, ie); - } - - m_bulk_data.modification_begin(); - - { - // Declare the elements that belong on this process - - std::vector::const_iterator ib = element_ids_on_this_processor.begin(); - const std::vector::const_iterator ie = element_ids_on_this_processor.end(); - for (; ib != ie; ++ib) { - EntityId entity_id = *ib; - unsigned ix = 0, iy = 0; - elem_x_y(entity_id, ix, iy); - - stk_classic::mesh::EntityId elem_nodes[4] ; - - elem_nodes[0] = node_id( ix , iy ); - elem_nodes[1] = node_id( ix+1 , iy ); - elem_nodes[2] = node_id( ix+1 , iy+1 ); - elem_nodes[3] = node_id( ix , iy+1 ); - - stk_classic::mesh::fem::declare_element( m_bulk_data, m_quad_part, elem_id( ix , iy ) , elem_nodes); - for (unsigned i = 0; i<4; ++i) { - stk_classic::mesh::Entity * const node = m_bulk_data.get_entity( fem::FEMMetaData::NODE_RANK , elem_nodes[i] ); - - ThrowRequireMsg( node != NULL, - "This process should know about the nodes that make up its element"); - - // Compute and assign coordinates to the node - unsigned nx = 0, ny = 0; - node_x_y(elem_nodes[i], nx, ny); - - Scalar * data = stk_classic::mesh::field_data( m_coord_field , *node ); - - data[0] = nx ; - data[1] = ny ; - } - } - } - - m_bulk_data.modification_end(); -} - - -} // fixtures -} // mesh -} // stk diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.hpp deleted file mode 100644 index 505150538cb3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/QuadFixture.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_FIXTURES_QUAD_MESH_FIXTURE_HPP -#define STK_MESH_FIXTURES_QUAD_MESH_FIXTURE_HPP - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -/** - * An 2-dimensional X*Y quad fixture. - * - * A coordinate field will be added to all nodes, a coordinate-gather field - * will be added to all elements. - */ -class QuadFixture -{ - public: - typedef int Scalar ; - typedef Field CoordFieldType; - typedef Field CoordGatherFieldType; - - /** - * Set up meta data to support this fixture. Meta data is left uncommitted - * to allow additional modifications by the client. - */ - QuadFixture( stk_classic::ParallelMachine pm, unsigned nx , unsigned ny ); - - ~QuadFixture() {} - - const unsigned m_spatial_dimension; - fem::FEMMetaData m_fem_meta ; - BulkData m_bulk_data ; - Part & m_quad_part ; - CoordFieldType & m_coord_field ; - CoordGatherFieldType & m_coord_gather_field ; - const unsigned m_nx ; - const unsigned m_ny ; - - /** - * Thinking in terms of rows and columns of nodes, get the id of the node in - * the (x, y) position. - */ - EntityId node_id( unsigned x , unsigned y ) const - { return 1 + x + ( m_nx + 1 ) * y ; } - - /** - * Thinking in terms of rows and columns of elements, get the id of the - * element in the (x, y) position. - */ - EntityId elem_id( unsigned x , unsigned y ) const - { return 1 + x + m_nx * y ; } - - /** - * Thinking in terms of rows and columns of nodes, get the node in - * the (x, y) position. Return NULL if this process doesn't know about - * this node. - */ - Entity * node( unsigned x , unsigned y ) const - { return m_bulk_data.get_entity( fem::FEMMetaData::NODE_RANK , node_id(x, y) ); } - - /** - * Thinking in terms of rows and columns of elements, get the element in - * the (x, y) position. Return NULL if this process doesn't know about - * this element. - */ - Entity * elem( unsigned x , unsigned y ) const - { return m_bulk_data.get_entity( m_fem_meta.element_rank(), elem_id(x, y)); } - - /** - * Thinking in terms of a 2D grid of nodes, compute the (x, y) position - * of a node given it's id. - */ - void node_x_y( EntityId entity_id, unsigned &x , unsigned &y ) const; - - /** - * Thinking in terms of a 2D grid of elements, compute the (x, y) position - * of an element given it's id. - */ - void elem_x_y( EntityId entity_id, unsigned &x , unsigned &y ) const; - - /** - * Create the mesh (into m_bulk_data). - */ - void generate_mesh(); - - private: - void generate_mesh( std::vector & element_ids_on_this_processor ); - - QuadFixture(); - QuadFixture( const QuadFixture & ); - QuadFixture & operator = ( const QuadFixture & ); -}; - -} // fixtures -} // mesh -} // stk -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/README b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/README deleted file mode 100644 index 6fa4914e642f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/README +++ /dev/null @@ -1,49 +0,0 @@ -These fixtures are used in the use cases, unit tests, and performance tests. -They represent some simple flexible ways to generate meshes and distribute them -in parallel. - -GridFixture - Two dimensional - 4x4 faces (shards Quadrilaterals) - 25 nodes - Two parts: quad_part and dead_part - No fields are defined - Parallel distribution is fixed: - processor p_i gets face ids: - p_i*16/p_N .. (p_i+1)*16/p_N - where p_N = number of processors - - -QuadFixture - Two dimensional - NX by NY elements (shards Quadrilaterals) - One part: quad_part - Two fields: Coordinates and GatherCoordinates - Default parallel distrubtion: - processor p_i gets element ids: - 1+NX*NY*p_i/p_N .. 1+NX*NY*(p_i+1)/p_N - where p_N = number of processors - Arbitrary parallel distribution is supported - by specifying which processor creates which elements in a vector. - - -HexFixture - Three dimensional - NX by NY by NZ elements (shards Hexahedrons) - One part: hex_part - Two fields: Coordinates and GatherCoordinates - Default parallel distrubtion: - processor p_i gets element ids: - 1+NX*NY*NZ*p_i/p_N .. 1+NX*NY*NZ*(p_i+1)/p_N - where p_N = number of processors - Arbitrary parallel distribution is supported - by specifying which processor creates which elements in a vector. - -SelectorFixture - Non-dimensional - 5 nodes - Four parts: PartA, PartB, PartC, PartD - Serial only - - - diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.cpp deleted file mode 100644 index 896710b81c77..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -/** - * Creates a ring mesh (circular loop of edges and nodes). Note that we create - * a part for each locally owned edge. Also note that, since we are in 1D, - * the "edges" are actually elements. - */ - -RingFixture::RingFixture( stk_classic::ParallelMachine pm , - unsigned num_edge_per_proc , - bool use_edge_parts ) - : m_spatial_dimension(1), - m_meta_data( m_spatial_dimension ), - m_bulk_data( fem::FEMMetaData::get_meta_data(m_meta_data), pm, 100 ), - m_edge_parts(), - m_edge_part_extra( m_meta_data.declare_part("edge_extra" , m_meta_data.element_rank() ) ), - m_num_edge_per_proc( num_edge_per_proc ), - m_node_ids(), - m_edge_ids() -{ - if ( use_edge_parts ) { - m_edge_parts.resize( num_edge_per_proc ); - for ( unsigned i = 0 ; i < num_edge_per_proc ; ++i ) { - std::ostringstream name ; - name << "EdgePart_" << i ; - m_edge_parts[i] = & m_meta_data.declare_part( name.str() , m_meta_data.element_rank() ); - } - } -} - -void RingFixture::generate_mesh( ) -{ - const unsigned p_rank = m_bulk_data.parallel_rank(); - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned nPerProc = m_num_edge_per_proc ; - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - - m_node_ids.resize( id_total ); - m_edge_ids.resize( id_total ); - std::vector local_count ; - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - m_node_ids[i] = i + 1; - m_edge_ids[i] = i + 1; - } - - // Create a loop of edges: - { - const PartVector no_parts ; - PartVector add_parts ; - - if ( ! m_edge_parts.empty() ) { add_parts.resize(1); } - - for ( unsigned i = id_begin ; i < id_end ; ++i ) { - const unsigned n0 = i ; - const unsigned n1 = ( i + 1 ) % id_total ; - if ( ! m_edge_parts.empty() ) { - add_parts[0] = m_edge_parts[ i % m_edge_parts.size() ]; - } - Entity & e_node_0 = m_bulk_data.declare_entity( 0 , m_node_ids[n0] , no_parts ); - Entity & e_node_1 = m_bulk_data.declare_entity( 0 , m_node_ids[n1] , no_parts ); - Entity & e_edge = m_bulk_data.declare_entity( 1 , m_edge_ids[i] , add_parts ); - m_bulk_data.declare_relation( e_edge , e_node_0 , 0 ); - m_bulk_data.declare_relation( e_edge , e_node_1 , 1 ); - } - } -} - -void RingFixture::fixup_node_ownership() -{ - const unsigned p_rank = m_bulk_data.parallel_rank(); - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned nPerProc = m_num_edge_per_proc ; - const unsigned id_begin = nPerProc * p_rank ; - - // Make sure that edge->owner_rank() == edge->node[1]->owner_rank() - - if ( 1 < p_size ) { - std::vector change ; - Entity * const e_node_0 = m_bulk_data.get_entity( 0 , m_node_ids[id_begin] ); - if ( p_rank == e_node_0->owner_rank() ) { - EntityProc entry ; - entry.first = e_node_0 ; - entry.second = ( p_rank + p_size - 1 ) % p_size ; - change.push_back( entry ); - } - m_bulk_data.change_entity_owner( change ); - } -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.hpp deleted file mode 100644 index 2aecf935b242..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/RingFixture.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_MESH_FIXTURES_RING_FIXTURE_HPP -#define STK_MESH_FIXTURES_RING_FIXTURE_HPP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -/** - * Creates a ring mesh (circular loop of edges and nodes). Note that we create - * a part for each locally owned edge. - */ - -class RingFixture { - public: - const int m_spatial_dimension; - fem::FEMMetaData m_meta_data; - BulkData m_bulk_data; - PartVector m_edge_parts ; - Part & m_edge_part_extra ; - const size_t m_num_edge_per_proc ; - std::vector m_node_ids , m_edge_ids ; - - RingFixture( stk_classic::ParallelMachine pm , - unsigned num_edge_per_proc = 10 , - bool use_edge_parts = false ); - - ~RingFixture() {} - - /** - * Generate a simple loop of mesh entities: - * node[i] : edge[i] : node[ ( i + 1 ) % node.size() ] - */ - void generate_mesh(); - - /** - * Make sure that edge->owner_rank() == edge->node[1]->owner_rank() - */ - void fixup_node_ownership(); - - private: - - RingFixture(); - RingFixture( const RingFixture & ); - RingFixture & operator = ( const RingFixture & ); -}; - -} -} -} - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.cpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.cpp deleted file mode 100644 index 960259e0af1d..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -SelectorFixture::~SelectorFixture() {} - -SelectorFixture::SelectorFixture() - : m_meta_data( std::vector(1, std::string("MyEntityRank")) ) - , m_bulk_data( m_meta_data , MPI_COMM_WORLD ) - , m_partA( m_meta_data.declare_part( "PartA" , 0 ) ) - , m_partB( m_meta_data.declare_part( "PartB" , 0 ) ) - , m_partC( m_meta_data.declare_part( "PartC" , 0 ) ) - , m_partD( m_meta_data.declare_part( "PartD" , 0 ) ) - , m_entity1( NULL ) - , m_entity2( NULL ) - , m_entity3( NULL ) - , m_entity4( NULL ) - , m_entity5( NULL ) - , m_fieldA(m_meta_data.declare_field >("FieldA")) - , m_fieldABC(m_meta_data.declare_field >("FieldABC")) -{ - stk_classic::mesh::EntityRank ent_rank = 0; - - stk_classic::mesh::put_field(m_fieldA, ent_rank, m_partA); - - stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partA); - stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partB); - stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partC); -} - -void SelectorFixture::generate_mesh() -{ - const unsigned entity_count = 5 ; - - stk_classic::mesh::EntityRank ent_type = 0; // rank - - // Create Entities and assign to parts: - stk_classic::mesh::EntityId ent_id = - 1 + entity_count * m_bulk_data.parallel_rank(); // Unique ID - - std::vector partMembership; - - // Entity1 is contained in PartA - partMembership.clear(); - partMembership.push_back( & m_partA ); - m_entity1 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); - ++ent_id; - - // Entity2 is contained in PartA and PartB - partMembership.clear(); - partMembership.push_back( & m_partA ); - partMembership.push_back( & m_partB ); - m_entity2 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); - ++ent_id; - - // Entity3 is contained in PartB and PartC - partMembership.clear(); - partMembership.push_back( & m_partB ); - partMembership.push_back( & m_partC ); - m_entity3 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); - ++ent_id; - - // Entity4 is contained in PartC - partMembership.clear(); - partMembership.push_back( & m_partC ); - m_entity4 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); - ++ent_id; - - // Entity5 is not contained in any Part - partMembership.clear(); - m_entity5 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); -} - -//-------------------------------------------------------------------------- - -VariableSelectorFixture::~VariableSelectorFixture() {} - -VariableSelectorFixture::VariableSelectorFixture(int NumParts) - : m_MetaData( std::vector(1, std::string("MyEntityRank")) ) - , m_BulkData( m_MetaData , MPI_COMM_WORLD ) - , m_declared_part_vector() -{ - // Create Parts and commit: - std::string myPartName; - stk_classic::mesh::EntityRank myRank = 0; - - std::string partName = "Part_"; - for (int part_i=0 ; part_i partMembership; - partMembership.push_back(m_declared_part_vector[part_i]); - stk_classic::mesh::Entity * e = - & m_BulkData.declare_entity(ent_type, ent_id, partMembership); - m_entities.push_back( e ); - ++ent_id; - } - - m_BulkData.modification_end(); -} - -} // fixtures -} // mesh -} // stk diff --git a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.hpp b/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.hpp deleted file mode 100644 index 31ee6440f86d..000000000000 --- a/packages/stk/stk_classic/stk_mesh/stk_mesh/fixtures/SelectorFixture.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_fixture_SelectorFixture_hpp -#define stk_mesh_fixture_SelectorFixture_hpp - -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace fixtures { - -// Example Mesh primarily used for testing Selectors: -// -// PartA, PartB, PartC, PartD -// Entity1, Entity2, Entity3, Entity4 -// All entities are rank 0 -// -// PartA contains Entity1, Entity2 -// PartB contains Entity2, Entity3 -// PartC contains Entity3, Entity4 -// PartD contains no entities -// Entity5 is not contained in any user-defined Part -// -// FieldA is defined on PartA -// FieldABC is defined on Parts A, B, C -// -// |----------|--|-------|--|----------| |-------------| -// |<--PartA---->| |<--PartC---->| | PartD | -// | |<---PartB--->| | | | -// | 1 |2 | |3 | 4 | 5 | | -// | | | | | | | | -// | | | | | | | | -// |----------|--|-------|--|----------| |-------------| -// - -class SelectorFixture { - public: - SelectorFixture(); - ~SelectorFixture(); - - const stk_classic::mesh::MetaData & get_MetaData() const { return m_meta_data ; } - stk_classic::mesh::MetaData & get_NonconstMetaData() { return m_meta_data ; } - - const stk_classic::mesh::BulkData & get_BulkData() const { return m_bulk_data ; } - stk_classic::mesh::BulkData & get_NonconstBulkData() { return m_bulk_data ; } - - stk_classic::mesh::MetaData m_meta_data ; - stk_classic::mesh::BulkData m_bulk_data ; - - stk_classic::mesh::Part & m_partA ; - stk_classic::mesh::Part & m_partB ; - stk_classic::mesh::Part & m_partC ; - stk_classic::mesh::Part & m_partD ; - - stk_classic::mesh::Entity * m_entity1 ; - stk_classic::mesh::Entity * m_entity2 ; - stk_classic::mesh::Entity * m_entity3 ; - stk_classic::mesh::Entity * m_entity4 ; - stk_classic::mesh::Entity * m_entity5 ; - - stk_classic::mesh::Field& m_fieldA; - stk_classic::mesh::Field& m_fieldABC; - - void generate_mesh(); - - private: - SelectorFixture( const SelectorFixture & ); - SelectorFixture & operator = ( const SelectorFixture & ); -}; - -class VariableSelectorFixture { - public: - VariableSelectorFixture(int NumParts); - ~VariableSelectorFixture(); - - stk_classic::mesh::MetaData m_MetaData ; - stk_classic::mesh::BulkData m_BulkData ; - - stk_classic::mesh::PartVector m_declared_part_vector; - std::vector m_entities ; - - private: - VariableSelectorFixture( const VariableSelectorFixture & ); - VariableSelectorFixture & operator = ( const VariableSelectorFixture & ); -}; - -} // fixtures -} // mesh -} // stk - -#endif // stk_mesh_fixture_SelectorFixture_hpp diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/unit_tests/CMakeLists.txt deleted file mode 100644 index 21f122577ac5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util/use_cases) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_mesh_unit_tests - SOURCES ${SOURCES} - DEPLIBS stkclassic_util_use_cases - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1-4 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoundaryAnalysis.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoundaryAnalysis.cpp deleted file mode 100644 index a924e6b9c415..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoundaryAnalysis.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -class UnitTestStkMeshBoundaryAnalysis { -public: - UnitTestStkMeshBoundaryAnalysis(stk_classic::ParallelMachine pm) : m_comm(pm), m_num_procs(0), m_rank(0) - { - m_num_procs = stk_classic::parallel_machine_size( m_comm ); - m_rank = stk_classic::parallel_machine_rank( m_comm ); - } - - void test_boundary_analysis(); - void test_boundary_analysis_null_topology(); - - stk_classic::ParallelMachine m_comm; - int m_num_procs; - int m_rank; -}; - -namespace { - -STKUNIT_UNIT_TEST( UnitTestStkMeshBoundaryAnalysis , testUnit ) -{ - UnitTestStkMeshBoundaryAnalysis unit(MPI_COMM_WORLD); - unit.test_boundary_analysis(); -} - -STKUNIT_UNIT_TEST( UnitTestStkMeshBoundaryAnalysis , testNullTopology ) -{ - UnitTestStkMeshBoundaryAnalysis unit(MPI_COMM_WORLD); - unit.test_boundary_analysis_null_topology(); -} - -} //end namespace - -void UnitTestStkMeshBoundaryAnalysis::test_boundary_analysis() -{ - // Test the boundary_analysis algorithm in stk_mesh/fem/BoundaryAnalysis.hpp - // with a boundary that is both shelled and non-shelled. - // - // We will be testing the algorithm on the following 2D mesh: - // - // 17---18---19---20---21 - // | 1 | 2 | 3 || 4 | - // 22---23---24---25---26 - // | 5 | 6 | 7 || 8 | - // 27---28---29---30---31 - // | 9 | 10 | 11 ||12 | - // 32---33---34---35---36 - // | 13 | 14 | 15 ||16 | - // 37---38---39---40---41 - // - // Note the shells along nodes 20-40. - // - // We will be computing the boundary of the closure of - // elements: 6, 7, 10, 11, 14, 15 - - // This test will only work for np=1 - if (m_num_procs > 1) { - return; - } - - // set up grid_mesh - stk_classic::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD); - - stk_classic::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta(); - stk_classic::mesh::BulkData& bulk_data = grid_mesh.bulk_data(); - - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - // make shell part - stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part& shell_part = fem_meta.declare_part("shell_part", line_top); - - fem_meta.commit(); - - bulk_data.modification_begin(); - grid_mesh.generate_grid(); - - // Add some shells - const unsigned num_shells = 4; - - // get a count of entities that have already been created - std::vector count; - stk_classic::mesh::Selector locally_owned(fem_meta.locally_owned_part()); - stk_classic::mesh::count_entities(locally_owned, bulk_data, count); - const unsigned num_entities = count[NODE_RANK] + count[element_rank]; - - // Declare the shell entities, placing them in the shell part - std::vector shells; - stk_classic::mesh::PartVector shell_parts; - shell_parts.push_back(&shell_part); - for (unsigned i = 1; i <= num_shells; ++i) { - stk_classic::mesh::Entity& new_shell = bulk_data.declare_entity(element_rank, - num_entities + i, - shell_parts); - shells.push_back(&new_shell); - } - - // declare shell relationships - unsigned node_list[5] = {20, 25, 30, 35, 40}; - for (unsigned i = 0; i < num_shells; ++i) { - stk_classic::mesh::Entity& shell = *(shells[i]); - stk_classic::mesh::Entity& node1 = *(bulk_data.get_entity(NODE_RANK, node_list[i])); - stk_classic::mesh::Entity& node2 = *(bulk_data.get_entity(NODE_RANK, node_list[i+1])); - bulk_data.declare_relation(shell, node1, 0); - bulk_data.declare_relation(shell, node2, 1); - } - - bulk_data.modification_end(); - - // create the closure we want to analyze - std::vector closure; - unsigned num_elems_in_closure = 6; - stk_classic::mesh::EntityId ids_of_entities_in_closure[] = - {6, 7, 10, 11, 14, 15, 23, 24, 25, 28, 29, 30, 33, 34, 35, 38, 39, 40}; - for (unsigned i = 0; - i < sizeof(ids_of_entities_in_closure)/sizeof(stk_classic::mesh::EntityId); - ++i) { - stk_classic::mesh::EntityRank rank_of_entity; - if (i < num_elems_in_closure) { - rank_of_entity = element_rank; - } - else { - rank_of_entity = NODE_RANK; - } - stk_classic::mesh::Entity* closure_entity = - bulk_data.get_entity(rank_of_entity, ids_of_entities_in_closure[i]); - closure.push_back(closure_entity); - } - // sort the closure (boundary analysis expects it this way) - std::sort(closure.begin(), closure.end(), stk_classic::mesh::EntityLess()); - - // Run the bounary analysis! - stk_classic::mesh::EntitySideVector boundary; - stk_classic::mesh::boundary_analysis(bulk_data, closure, element_rank, boundary); - STKUNIT_EXPECT_TRUE(!boundary.empty()); - - // Prepare the expected-results as a vector of pairs of pairs representing - // ( inside, outside ) where - // inside is ( element-id, side-ordinal ) of element inside the closure - // outside is ( element-id, side-ordinal ) of element outside the closure - // and inside and outside border each other - - typedef std::pair BoundaryItem; - typedef std::pair BoundaryPair; - - // Note that certain sides of elements 7, 11, 15 have a boundary with - // a shell AND the adjacent element outside the closure. - - BoundaryPair results[] = { - BoundaryPair(BoundaryItem(6, 0), BoundaryItem(5, 2)), - - BoundaryPair(BoundaryItem(6, 3), BoundaryItem(2, 1)), - - BoundaryPair(BoundaryItem(7, 2), BoundaryItem(8, 0)), - BoundaryPair(BoundaryItem(7, 2), BoundaryItem(43, 0)), - - BoundaryPair(BoundaryItem(7, 3), BoundaryItem(3, 1)), - - BoundaryPair(BoundaryItem(10, 0), BoundaryItem(9, 2)), - - BoundaryPair(BoundaryItem(11, 2), BoundaryItem(12, 0)), - BoundaryPair(BoundaryItem(11, 2), BoundaryItem(44, 0)), - - BoundaryPair(BoundaryItem(14, 0), BoundaryItem(13, 2)), - - BoundaryPair(BoundaryItem(14, 1), BoundaryItem(0, 0)), - - BoundaryPair(BoundaryItem(15, 1), BoundaryItem(0, 0)), - - BoundaryPair(BoundaryItem(15, 2), BoundaryItem(16, 0)), - BoundaryPair(BoundaryItem(15, 2), BoundaryItem(45, 0)) - }; - - // Convert the boundary returned by boundary_analysis into a data-structure - // comparable to expected_results - - BoundaryPair expected_results[sizeof(results)/sizeof(BoundaryPair)]; - - unsigned i = 0; - stk_classic::mesh::EntitySideVector::iterator itr = boundary.begin(); - - for (; itr != boundary.end(); ++itr, ++i) - { - stk_classic::mesh::EntitySide& side = *itr; - stk_classic::mesh::EntitySideComponent& inside_closure = side.inside; - stk_classic::mesh::EntityId inside_id = inside_closure.entity != NULL ? inside_closure.entity->identifier() : 0; - stk_classic::mesh::EntityId inside_side = inside_closure.entity != NULL ? inside_closure.side_ordinal : 0; - stk_classic::mesh::EntitySideComponent& outside_closure = side.outside; - stk_classic::mesh::EntityId outside_id = outside_closure.entity != NULL ? outside_closure.entity->identifier() : 0; - stk_classic::mesh::EntityId outside_side = outside_closure.entity != NULL ? outside_closure.side_ordinal : 0; - - expected_results[i] = BoundaryPair(BoundaryItem(inside_id, inside_side), - BoundaryItem(outside_id, outside_side)); - } - - // Check that results match expected results - - STKUNIT_EXPECT_EQ(sizeof(results), sizeof(expected_results)); - - for (i = 0; i < sizeof(results)/sizeof(BoundaryPair); ++i) { - STKUNIT_EXPECT_TRUE(results[i] == expected_results[i]); - } -} - -void UnitTestStkMeshBoundaryAnalysis::test_boundary_analysis_null_topology() -{ - //test on boundary_analysis for closure with a NULL topology - coverage of lines 39-40 of BoundaryAnalysis.cpp - - //create new fem_meta, bulk and boundary for this test - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - - const stk_classic::mesh::EntityRank side_rank = fem_meta.side_rank(); - - //declare part with topology = NULL - stk_classic::mesh::Part & quad_part = fem_meta.declare_part("quad_part", side_rank); - fem_meta.commit(); - - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); - stk_classic::mesh::MetaData & meta = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk ( meta , comm , 100 ); - - stk_classic::mesh::EntitySideVector boundary; - std::vector newclosure; - - stk_classic::mesh::PartVector face_parts; - face_parts.push_back(&quad_part); - - bulk.modification_begin(); - if (m_rank == 0) { - stk_classic::mesh::Entity & new_face = bulk.declare_entity(side_rank, 1, face_parts); - newclosure.push_back(&new_face); - } - - stk_classic::mesh::boundary_analysis(bulk, newclosure, side_rank, boundary); - /* - STKUNIT_EXPECT_TRUE(!boundary.empty()); - */ - - bulk.modification_end(); -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoxFixture.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoxFixture.cpp deleted file mode 100644 index 9ed3649f5430..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBoxFixture.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include -#include -#include -#include -#include - -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Selector; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::fixtures::BoxFixture; - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -class ExposePartition : public BoxFixture -{ - public: - static void expose_box_partition( int ip , int up , int axis , - const BOX box , - BOX p_box[] ) - { - box_partition(ip, up, axis, box, p_box); - } -}; - -} - -STKUNIT_UNIT_TEST( UnitTestBoxFixture, verifyBoxFixture ) -{ - // A unit test to verify the correctness of the BoxFixture fixture. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - // Create the box fixture we'll be testing - - // box specifications - const BoxFixture::BOX root_box = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - BoxFixture::BOX local_box = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - BoxFixture fixture(pm); - FEMMetaData& meta = fixture.fem_meta(); - BulkData& bulk = fixture.bulk_data(); - - const EntityRank element_rank = meta.element_rank(); - - const unsigned p_rank = bulk.parallel_rank(); - const unsigned p_size = bulk.parallel_size(); - - BoxFixture::BOX * const p_box = new BoxFixture::BOX[ p_size ]; - ExposePartition::expose_box_partition( 0, p_size, 2, root_box, &p_box[0] ); - - meta.commit(); - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - - const unsigned nx = local_box[0][1] - local_box[0][0] ; - const unsigned ny = local_box[1][1] - local_box[1][0] ; - const unsigned nz = local_box[2][1] - local_box[2][0] ; - - const unsigned e_local = nx * ny * nz ; - const unsigned n_local = ( nx + 1 ) * ( ny + 1 ) * ( nz + 1 ); - - const unsigned ngx = root_box[0][1] - root_box[0][0] ; - const unsigned ngy = root_box[1][1] - root_box[1][0] ; - - std::vector local_count ; - - // Verify that the correct entities are on this process - - for ( int k = local_box[2][0] ; k < local_box[2][1] ; ++k ) { - for ( int j = local_box[1][0] ; j < local_box[1][1] ; ++j ) { - for ( int i = local_box[0][0] ; i < local_box[0][1] ; ++i ) { - - const EntityId n0= 1 + (i+0) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n1= 1 + (i+1) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n2= 1 + (i+1) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n3= 1 + (i+0) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1); - const EntityId n4= 1 + (i+0) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n5= 1 + (i+1) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n6= 1 + (i+1) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - const EntityId n7= 1 + (i+0) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1); - - const EntityId elem_id = 1 + i + j * ngx + k * ngx * ngy; - - std::vector nodes(8); - nodes[0] = bulk.get_entity( NODE_RANK, n0 ); - nodes[1] = bulk.get_entity( NODE_RANK, n1 ); - nodes[2] = bulk.get_entity( NODE_RANK, n2 ); - nodes[3] = bulk.get_entity( NODE_RANK, n3 ); - nodes[4] = bulk.get_entity( NODE_RANK, n4 ); - nodes[5] = bulk.get_entity( NODE_RANK, n5 ); - nodes[6] = bulk.get_entity( NODE_RANK, n6 ); - nodes[7] = bulk.get_entity( NODE_RANK, n7 ); - - Entity* elem = bulk.get_entity( element_rank, elem_id ); - - std::vector elems ; - stk_classic::mesh::get_entities_through_relations( nodes , elems ); - STKUNIT_ASSERT_EQUAL( elems.size() , size_t(1) ); - STKUNIT_ASSERT_EQUAL( elems[0] , elem ); - - stk_classic::mesh::get_entities_through_relations(nodes, element_rank, elems); - STKUNIT_ASSERT_EQUAL( elems.size() , size_t(1) ); - STKUNIT_ASSERT_EQUAL( elems[0] , elem ); - - } - } - } - - Selector select_owned( meta.locally_owned_part() ); - Selector select_used = select_owned | - meta.globally_shared_part(); - Selector select_all( meta.universal_part() ); - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( e_local , local_count[3] ); - STKUNIT_ASSERT_EQUAL( 0u , local_count[2] ); - STKUNIT_ASSERT_EQUAL( 0u , local_count[1] ); - STKUNIT_ASSERT_EQUAL( n_local , local_count[0] ); - - STKUNIT_ASSERT(bulk.modification_end()); - - // Verify declarations and sharing - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[3] , e_local ); - STKUNIT_ASSERT_EQUAL( local_count[2] , 0u ); - STKUNIT_ASSERT_EQUAL( local_count[1] , 0u ); - STKUNIT_ASSERT_EQUAL( local_count[0] , n_local ); - - for ( int k = local_box[2][0] ; k <= local_box[2][1] ; ++k ) { - for ( int j = local_box[1][0] ; j <= local_box[1][1] ; ++j ) { - for ( int i = local_box[0][0] ; i <= local_box[0][1] ; ++i ) { - EntityRank node_type = 0; - EntityId node_id = 1 + i + j * (ngx+1) + k * (ngx+1) * (ngy+1); - Entity * const node = bulk.get_entity( node_type , node_id ); - STKUNIT_ASSERT( node != NULL ); - // Shared if on a processor boundary. - const bool shared = - ( k == local_box[2][0] && k != root_box[2][0] ) || - ( k == local_box[2][1] && k != root_box[2][1] ) || - ( j == local_box[1][0] && j != root_box[1][0] ) || - ( j == local_box[1][1] && j != root_box[1][1] ) || - ( i == local_box[0][0] && i != root_box[0][0] ) || - ( i == local_box[0][1] && i != root_box[0][1] ); - if (bulk.parallel_size() > 1) { - STKUNIT_ASSERT_EQUAL( shared , ! node->sharing().empty() ); - } - } - } - } - - size_t count_shared_node_pairs = 0 ; - for ( unsigned p = 0 ; p < p_size ; ++p ) if ( p != p_rank ) { - for ( int k = p_box[p][2][0] ; k <= p_box[p][2][1] ; ++k ) - if ( local_box[2][0] <= k && k <= local_box[2][1] ) { - - for ( int j = p_box[p][1][0] ; j <= p_box[p][1][1] ; ++j ) - if ( local_box[1][0] <= j && j <= local_box[1][1] ) { - - for ( int i = p_box[p][0][0] ; i <= p_box[p][0][1] ; ++i ) - if ( local_box[0][0] <= i && i <= local_box[0][1] ) { - - EntityRank node_type = 0; - EntityId node_id = 1 + i + j * (ngx+1) + k * (ngx+1) * (ngy+1); - Entity * const node = bulk.get_entity( node_type , node_id ); - STKUNIT_ASSERT( node != NULL ); - // Must be shared with 'p' - stk_classic::mesh::PairIterEntityComm iter = node->sharing(); - for ( ; ! iter.empty() && iter->proc != p ; ++iter ); - STKUNIT_ASSERT( ! iter.empty() ); - - ++count_shared_node_pairs ; - } - } - } - } - - size_t count_shared_entities = 0 ; - for (std::vector::const_iterator - i = bulk.entity_comm().begin() ; - i != bulk.entity_comm().end() ; - ++i) { - const stk_classic::mesh::PairIterEntityComm ec = (**i).sharing(); - count_shared_entities += ec.size(); - } - STKUNIT_ASSERT_EQUAL( count_shared_entities , count_shared_node_pairs ); - - delete [] p_box; -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBucket.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBucket.cpp deleted file mode 100644 index ab7c26006ce7..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBucket.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* _ Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::PairIterEntityComm; -using stk_classic::mesh::Entity; -using stk_classic::mesh::Bucket; -using stk_classic::mesh::BucketIterator; -using stk_classic::mesh::Selector; -using stk_classic::mesh::Field; -using stk_classic::mesh::FieldBase; -using stk_classic::mesh::put_field; - -typedef Field ScalarFieldType; - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST(UnitTestingOfBucket, testBucket) -{ - // Unit test the Part functionality in isolation: - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - // Create a mesh for testing buckets... - - // Create dummy names for entity ranks to be given to MetaData - std::vector entity_names(10); - for ( size_t i = 0 ; i < 10 ; ++i ) { - std::ostringstream name ; - name << "EntityRank" << i ; - entity_names[i] = name.str(); - } - - // Create MetaData, BulkData - unsigned max_bucket_size = 4; - stk_classic::mesh::fixtures::BoxFixture fixture(pm, max_bucket_size, entity_names); - FEMMetaData& meta = fixture.fem_meta(); - BulkData& bulk = fixture.bulk_data(); - const EntityRank element_rank = meta.element_rank(); - // Create two scalar fields, temperature and volume. Put temperature - // on all the nodes and put volume on all the elements. - unsigned number_of_states = 4; - - ScalarFieldType & temperature = - meta.declare_field < ScalarFieldType > ( "temperature" , number_of_states ); - ScalarFieldType & volume = - - meta.declare_field < ScalarFieldType > ( "volume" , number_of_states ); - Part & universal = meta.universal_part (); - put_field ( temperature , NODE_RANK , universal ); - put_field ( volume , element_rank , universal ); - meta.commit(); - - // Generate the mesh - int root_box[3][2] = { { 0,4 } , { 0,5 } , { 0,6 } }; - int local_box[3][2] = { { 0,0 } , { 0,0 } , { 0,0 } }; - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - // First, test for streaming IO; - { - std::string gold1; - // Parallel and Serial runs have different part intersections for the first - // bucket - if ( bulk.parallel_size() == 1 ) - gold1 = "Bucket( EntityRank0 : {UNIVERSAL} {OWNS} )"; - else - gold1 = "Bucket( EntityRank0 : {UNIVERSAL} )"; - Bucket *b1 = bulk.buckets(0)[0]; - std::stringstream out1_str; - out1_str << (*b1); - bool equal = (gold1 == out1_str.str()); - STKUNIT_ASSERT_EQUAL ( equal, true ); - } - - // Second, update state of bucket until circular cue is filled - { - /* Need to set some data in state, rotate look for it, rotate 3 more times - and look for it again */ - for ( size_t i = 0 ; i != 10 ; ++i ) - bulk.update_field_data_states (); - } - - // Third, checking field_data_valid (...) - { - const std::vector< FieldBase * > &field_bases = meta.get_fields(); - STKUNIT_ASSERT_THROW(field_data_valid ( *field_bases[0] , *bulk.buckets(3)[0] , 1 , "error" ) , std::runtime_error); - STKUNIT_ASSERT_EQUAL(field_data_valid ( *field_bases[0] , *bulk.buckets(0)[0] , 1 , "no_error" ) , true); - STKUNIT_ASSERT_THROW(field_data_valid ( *field_bases[0] , *bulk.buckets(3)[0] , 99 , "error" ) , std::runtime_error); - - // Set up a second mesh - - MetaData meta2 ( entity_names ); - BulkData bulk2( meta2 , pm , max_bucket_size ); - - ScalarFieldType & temperature2 = - meta2.declare_field < ScalarFieldType > ( "temperature2" , number_of_states ); - ScalarFieldType & volume2 = - meta2.declare_field < ScalarFieldType > ( "volume2" , number_of_states ); - Part & universal2 = meta2.universal_part (); - put_field ( temperature2 , NODE_RANK , universal2 ); - put_field ( volume2 , element_rank , universal2 ); - meta2.commit(); - - // Cover line containing messsage for wrong MetaData used - const std::vector< FieldBase * > &field_bases2 = meta2.get_fields(); - STKUNIT_ASSERT_THROW(field_data_valid ( *field_bases2[0] , *bulk.buckets(0)[0] , 1 , "error" ) , std::runtime_error); - } - - // Fourth, check has_superset (...) and membership functions - { - PartVector tmp(2) ; - tmp[0] = & meta.universal_part(); - tmp[1] = & meta.locally_owned_part(); - STKUNIT_ASSERT_EQUAL ( has_superset ( *bulk.buckets(0)[0] , tmp ) , bulk.parallel_size() == 1 ); - STKUNIT_ASSERT ( bulk.buckets(0)[0]->member_any ( tmp ) ); - STKUNIT_ASSERT_EQUAL ( bulk.buckets(0)[0]->member_all ( tmp ) , bulk.parallel_size() == 1 ); - STKUNIT_ASSERT ( bulk.buckets(0)[0]->member ( **meta.get_parts().begin() ) ); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBucket, testGetInvolvedParts) -{ - // Tests to cover get_involved_parts for GetBuckets.cpp - C.Brickley - 12 May 2010 - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const int spatial_dimension = 3; - - FEMMetaData meta( spatial_dimension ); - const EntityRank element_rank = meta.element_rank(); - const EntityRank edge_rank = meta.edge_rank(); - - PartVector involved_parts(2) ; - involved_parts[0] = & meta.universal_part(); - involved_parts[1] = & meta.locally_owned_part(); - - Part & partLeft_1 = stk_classic::mesh::fem::declare_part >( meta, "block_left_1" ); - - Part & partLeft_2 = stk_classic::mesh::fem::declare_part >( meta, "block_left_2" ); - - meta.commit(); - - PartVector union_parts; - union_parts.push_back(&partLeft_1); - union_parts.push_back(&partLeft_2); - - BulkData bulk( FEMMetaData::get_meta_data(meta) , pm , 100 ); - PartVector add_part4, no_part; - add_part4.push_back ( &partLeft_1 ); - - bulk.modification_begin(); - int size , rank; - rank = stk_classic::parallel_machine_rank( pm ); - size = stk_classic::parallel_machine_size( pm ); - - for ( int id_base = 0 ; id_base < 99 ; ++id_base ) - { - int new_id = size * id_base + rank + 1; - bulk.declare_entity( 3 , new_id , add_part4 ); - bulk.declare_entity( NODE_RANK , new_id , no_part ); - } - - bulk.modification_end(); - - const std::vector & buckets = bulk.buckets( element_rank ); - - std::vector::const_iterator k; - - k = buckets.begin(); - - //test 1 covers aecond section of "if" statement in while loop - get_involved_parts( union_parts, **k, involved_parts); - - //test 2 covers union_parts.size() = 0 - PartVector union_parts2(0) ; - get_involved_parts( union_parts2, **k, involved_parts); - - //test 3 covers first section of "if" statement in while loop - const std::vector & buckets2 = bulk.buckets( NODE_RANK ); - std::vector::const_iterator k2; - - k2 = buckets2.begin(); - get_involved_parts( union_parts, **k2, involved_parts); - - // tests on throw_error and BucketIterator in bucket.cpp/hpp - - FEMMetaData meta2 (spatial_dimension); - BulkData bulk2( FEMMetaData::get_meta_data(meta2) , pm , 4 ); - - unsigned number_of_states = 4; - - ScalarFieldType & temperature2 = - meta2.declare_field < ScalarFieldType >("temperature2" , number_of_states); - ScalarFieldType & volume2 = - - meta2.declare_field < ScalarFieldType >("volume2", number_of_states); - Part & universal = meta2.universal_part (); - put_field ( temperature2 , NODE_RANK , universal ); - put_field ( volume2 , element_rank , universal ); - - meta2.commit(); - - bulk2.modification_begin(); - bulk2.declare_entity( edge_rank, rank+1 , no_part ); - bulk2.modification_end(); -} - -STKUNIT_UNIT_TEST(UnitTestingOfBucket, testBucket2) -{ - // Tests to cover print, has_superset and BucketLess::operator() for Buckets.cpp - C.Brickley - 2nd June 2010 - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const int spatial_dimension = 3; - FEMMetaData meta( spatial_dimension ); - const EntityRank element_rank = meta.element_rank(); - - PartVector involved_parts(2) ; - involved_parts[0] = & meta.universal_part(); - involved_parts[1] = & meta.locally_owned_part(); - - Part & partLeft_1 = meta.declare_part("block_left_1", element_rank); - - Part & partLeft_3 = stk_classic::mesh::fem::declare_part >( meta, "block_left_3" ); - - meta.commit(); - - BulkData bulk( FEMMetaData::get_meta_data(meta) , pm , 100 ); - std::vector add_part4; - add_part4.push_back ( &partLeft_1 ); - - bulk.modification_begin(); - int size , rank; - rank = stk_classic::parallel_machine_rank( pm ); - size = stk_classic::parallel_machine_size( pm ); - - for ( int id_base = 0 ; id_base < 99 ; ++id_base ) - { - int new_id = size * id_base + rank; - bulk.declare_entity( 3 , new_id+1 , add_part4 ); - } - - bulk.modification_end(); - - const std::vector & buckets2 = bulk.buckets( element_rank ); - - std::vector::const_iterator k2; - - k2 = buckets2.begin(); - - Bucket& b2 = **k2; - - //define a new meta and bulkdata - std::vector entity_names(10); - - for ( size_t i = 0 ; i < 10 ; ++i ) { - std::ostringstream name ; - name << "EntityRank" << i ; - entity_names[i] = name.str(); - } - - MetaData meta2 ( entity_names ); - BulkData bulk2( meta2 , pm , 4 ); - - unsigned number_of_states = 4; - - ScalarFieldType & temperature2 = - meta2.declare_field < ScalarFieldType >("temperature2" , number_of_states); - ScalarFieldType & volume2 = - meta2.declare_field < ScalarFieldType >("volume2", number_of_states); - Part & universal = meta2.universal_part (); - put_field ( temperature2 , NODE_RANK , universal ); - put_field ( volume2 , element_rank , universal ); - - typedef Field VectorFieldType; - typedef Field ElementNodePointerFieldType; - - meta2.commit(); - - //Test to cover print function in Bucket.cpp - std::ostringstream oss; - print(oss, " ", b2); - - //Test to cover has_superset function in Bucket.cpp - STKUNIT_ASSERT_EQUAL ( has_superset ( b2 , partLeft_3 ) , false ); - - //Test on BucketLess::operator() in Bucket.cpp/hpp - - enum { KEY_TMP_BUFFER_SIZE = 64 }; - - const unsigned max = ~(0u); - - unsigned key_tmp_buffer[ KEY_TMP_BUFFER_SIZE ]; - - std::vector key_tmp_vector ; - - const unsigned key_size = 2 + 3 ; - - unsigned * const key = - ( key_size <= KEY_TMP_BUFFER_SIZE ) - ? key_tmp_buffer - : ( key_tmp_vector.resize( key_size ) , & key_tmp_vector[0] ); - - - key[ key[0] = 3 + 1 ] = max; - - { - unsigned * const k = key + 1 ; - for ( unsigned i = 0 ; i < 3 ; ++i ) { k[i] = 1 ; } - } - - // FIXME: The code below needs to be fixed or removed - /* - impl::BucketImpl::last_bucket_in_family( *k2 ); - - const unsigned * t = key; - const Bucket * u = last_bucket; - - BucketLess Buck; - - bool res = Buck( &t[0], &u[0] ); - - STKUNIT_EXPECT_EQUAL( res, false ); - */ -} - -STKUNIT_UNIT_TEST(UnitTestingOfBucket, testEntityComm) -{ - // FIXME: With so much code commented out, this unit-test does - // not appear to be testing anything. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const int spatial_dimension = 3; - FEMMetaData meta( spatial_dimension ); - - BulkData bulk ( FEMMetaData::get_meta_data(meta) , pm , 100 ); - std::vector add_part4; - - Part & partLeft_1 = stk_classic::mesh::fem::declare_part >( meta, "block_left_1" ); - meta.commit(); - - add_part4.push_back ( &partLeft_1 ); - - //int rank = stk_classic::parallel_machine_rank( pm ); - // int size = stk_classic::parallel_machine_size( pm ); - PartVector tmp(1); - - bulk.modification_begin(); - - //int id_base = 0; - //int new_id = size * id_base + rank; - // for ( id_base = 0 ; id_base < 93 ; ++id_base ) - // { - // int new_id = size * id_base + rank; - // bulk.declare_entity( 0 , new_id+1 , add_part4 ); - // } - - bulk.modification_end(); - - /* cout << endl << "Bucket test line 3" << endl ; - bool result = in_shared(elem); - if( result) { - STKUNIT_ASSERT_EQUAL( result , true ); - } - cout << endl << "Bucket test line 4" << endl ; - - result = in_receive_ghost(elem); - if( result) { - STKUNIT_ASSERT_EQUAL( result , true ); - } - - for ( unsigned p = 0 ; p < p_size ; ++p ) if ( p != p_rank ) { - cout << endl << "in relation h and p =" << p << endl ; - - STKUNIT_ASSERT_EQUAL( in_send_ghost( *elem , p ), false ); - cout << endl << "in relation ii =" << endl - } - - cout << endl << "Bucket test line 5" << endl ; - result = in_send_ghost(elem); - if( result) { - STKUNIT_ASSERT_EQUAL( result , true ); - } - - cout << endl << "Bucket test line 6" << endl ; - - unsigned proc = rank; - unsigned procnew = rank+10; - - result = in_shared(elem, proc); - if( result) { - STKUNIT_ASSERT_EQUAL( result , true ); - } - cout << endl << "Bucket test line 7" << endl ; */ -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData.cpp deleted file mode 100644 index 1f2cb9ea4913..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData.cpp +++ /dev/null @@ -1,1459 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -using stk_classic::mesh::Part; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Selector; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::BaseEntityRank; -using stk_classic::mesh::PairIterRelation; -using stk_classic::mesh::EntityProc; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::EntityKey; -using stk_classic::mesh::EntityVector; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::fixtures::RingFixture; -using stk_classic::mesh::fixtures::BoxFixture; - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -void donate_one_element( BulkData & mesh , bool aura ) -{ - const unsigned p_rank = mesh.parallel_rank(); - - Selector select_owned( MetaData::get(mesh).locally_owned_part() ); - - std::vector before_count ; - std::vector after_count ; - - count_entities( select_owned , mesh , before_count ); - - // Change owner of an element on a process boundary - // from P0 to P1, and then recount to confirm ownership change - - std::vector change ; - - // A shared node: - Entity * node = NULL ; - Entity * elem = NULL ; - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - if ( in_shared( **i ) && (**i).entity_rank() == BaseEntityRank ) { - node = *i ; - break ; - } - } - - STKUNIT_ASSERT( node != NULL ); - - for ( PairIterRelation rel = node->relations( 3 ); - ! rel.empty() && elem == NULL ; ++rel ) { - elem = rel->entity(); - if ( elem->owner_rank() != p_rank ) { elem = NULL ; } - } - - STKUNIT_ASSERT( elem != NULL ); - - unsigned donated_nodes = 0 ; - - // Only process #0 donates an element and its owned nodes: - if ( 0 == p_rank ) { - EntityProc entry ; - entry.first = elem ; - entry.second = node->sharing()[0].proc ; - change.push_back( entry ); - for ( PairIterRelation - rel = elem->relations(0) ; ! rel.empty() ; ++rel ) { - if ( rel->entity()->owner_rank() == p_rank ) { - entry.first = rel->entity(); - change.push_back( entry ); - ++donated_nodes ; - } - } - } - - STKUNIT_ASSERT( mesh.modification_begin() ); - mesh.change_entity_owner( change ); - STKUNIT_ASSERT( stk_classic::unit_test::modification_end_wrapper( mesh , aura ) ); - - count_entities( select_owned , mesh , after_count ); - - if ( 0 == p_rank ) { - STKUNIT_ASSERT_EQUAL( before_count[3] - 1 , after_count[3] ); - STKUNIT_ASSERT_EQUAL( before_count[0] - donated_nodes, after_count[0] ); - } -} - -void donate_all_shared_nodes( BulkData & mesh , bool aura ) -{ - const unsigned p_rank = mesh.parallel_rank(); - - const Selector select_used = MetaData::get(mesh).locally_owned_part() | - MetaData::get(mesh).globally_shared_part() ; - - std::vector before_count ; - std::vector after_count ; - - count_entities( select_used , mesh , before_count ); - - // Donate owned shared nodes to first sharing process. - - const std::vector & entity_comm = mesh.entity_comm(); - - STKUNIT_ASSERT( ! entity_comm.empty() ); - - std::vector change ; - - for ( std::vector::const_iterator - i = entity_comm.begin() ; - i != entity_comm.end() && - (**i).entity_rank() == BaseEntityRank ; ++i ) { - Entity * const node = *i ; - const stk_classic::mesh::PairIterEntityComm ec = node->sharing(); - - if ( node->owner_rank() == p_rank && ! ec.empty() ) { - change.push_back( EntityProc( node , ec->proc ) ); - } - } - - STKUNIT_ASSERT( mesh.modification_begin() ); - mesh.change_entity_owner( change ); - STKUNIT_ASSERT( stk_classic::unit_test::modification_end_wrapper( mesh , aura ) ); - - count_entities( select_used , mesh , after_count ); - - STKUNIT_ASSERT( 3 <= after_count.size() ); - STKUNIT_ASSERT_EQUAL( before_count[0] , after_count[0] ); - STKUNIT_ASSERT_EQUAL( before_count[1] , after_count[1] ); - STKUNIT_ASSERT_EQUAL( before_count[2] , after_count[2] ); - STKUNIT_ASSERT_EQUAL( before_count[3] , after_count[3] ); -} - -} // empty namespace - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testBulkData) -{ - // Unit test the Part functionality in isolation: - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - std::vector entity_names(10); - for ( size_t i = 0 ; i < 10 ; ++i ) { - std::ostringstream name ; - name << "EntityRank" << i ; - entity_names[i] = name.str(); - } - - MetaData meta( entity_names ); - - meta.commit(); - - BulkData bulk( meta , pm , 100 ); - - for ( size_t i = 0 ; i < 4 ; ++i ) { - STKUNIT_ASSERT( bulk.modification_begin() ); - STKUNIT_ASSERT_EQUAL( i , bulk.synchronized_count() ); - STKUNIT_ASSERT( bulk.modification_end() ); - } - - std::vector no_parts ; - - Entity * e[10] ; - - const unsigned id = bulk.parallel_rank() + 1 ; - - STKUNIT_ASSERT( bulk.modification_begin() ); - for ( size_t i = 0 ; i < 10 ; ++i ) { - e[i] = & bulk.declare_entity( i , id , no_parts ); - } - STKUNIT_ASSERT( bulk.modification_end() ); - - for ( size_t i = 0 ; i < 10 ; ++i ) { - STKUNIT_ASSERT( e[i] == bulk.get_entity( i , id ) ); - } - - STKUNIT_ASSERT( bulk.modification_begin() ); - STKUNIT_ASSERT_THROW( bulk.declare_entity( 11 , id , no_parts ), - std::logic_error ); - STKUNIT_ASSERT( bulk.modification_end() ); - - // Catch not-ok-to-modify - STKUNIT_ASSERT_THROW( bulk.declare_entity( 0 , id + 1 , no_parts ), - std::logic_error ); -} - -//---------------------------------------------------------------------- -// Testing for mesh entities without relations - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeOwner_nodes) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - enum { nPerProc = 10 }; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - - const int spatial_dimension = 3; - MetaData meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - BulkData bulk( meta , pm , 100 ); - - const PartVector no_parts ; - - meta.commit(); - bulk.modification_begin(); - - // Ids for all entities (all entities have type 0): - - std::vector ids( id_total ); - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - ids[i] = i + 1; - } - - // Declare just those entities in my range of ids: - - for ( unsigned i = id_begin ; i < id_end ; ++i ) { - bulk.declare_entity( 0 , ids[i] , no_parts ); - } - - STKUNIT_ASSERT( bulk.modification_end() ); - - // Verify that I only have entities in my range: - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - Entity * e = bulk.get_entity( 0 , ids[ i ] ); - if ( id_begin <= i && i < id_end ) { - STKUNIT_ASSERT( NULL != e ); - } - else { - STKUNIT_ASSERT( NULL == e ); - } - } - - // Test change owner no-op first: - - std::vector change ; - - STKUNIT_ASSERT( bulk.modification_begin() ); - bulk.change_entity_owner( change ); - STKUNIT_ASSERT( bulk.modification_end() ); - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - Entity * e = bulk.get_entity( 0 , ids[ i ] ); - if ( id_begin <= i && i < id_end ) { - STKUNIT_ASSERT( NULL != e ); - } - else { - STKUNIT_ASSERT( NULL == e ); - } - } - - // Can only test changing owner in parallel. - - if ( 1 < p_size ) { - // Give my last two ids to the next process - // Get the previous process' last two ids - - const unsigned p_give = ( p_rank + 1 ) % p_size ; - const unsigned id_give = id_end - 2 ; - const unsigned id_get = ( id_begin + id_total - 2 ) % id_total ; - - STKUNIT_ASSERT( NULL != bulk.get_entity( 0 , ids[id_give] ) ); - STKUNIT_ASSERT( NULL != bulk.get_entity( 0 , ids[id_give+1] ) ); - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_get] ) ); - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_get+1] ) ); - - change.resize(2); - change[0].first = bulk.get_entity( 0 , ids[id_give] ); - change[0].second = p_give ; - change[1].first = bulk.get_entity( 0 , ids[id_give+1] ); - change[1].second = p_give ; - - STKUNIT_ASSERT( bulk.modification_begin() ); - bulk.change_entity_owner( change ); - STKUNIT_ASSERT( bulk.modification_end() ); - - STKUNIT_ASSERT( NULL != bulk.get_entity( 0 , ids[id_get] ) ); - STKUNIT_ASSERT( NULL != bulk.get_entity( 0 , ids[id_get+1] ) ); - - // Entities given away are destroyed until the next modification cycle - { - Entity * const e0 = bulk.get_entity( 0 , ids[id_give] ); - Entity * const e1 = bulk.get_entity( 0 , ids[id_give+1] ); - STKUNIT_ASSERT( NULL != e0 && e0->bucket().capacity() == 0 ); - STKUNIT_ASSERT( NULL != e1 && e1->bucket().capacity() == 0 ); - } - - STKUNIT_ASSERT( bulk.modification_begin() ); - STKUNIT_ASSERT( bulk.modification_end() ); - - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_give] ) ); - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_give+1] ) ); - } -} - -//---------------------------------------------------------------------- -// Testing for creating existing mesh entities without relations - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testCreateMore) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - enum { nPerProc = 10 }; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - - if ( 1 < p_size ) { - - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - - const int spatial_dimension = 3; - MetaData meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - - const PartVector no_parts ; - - meta.commit(); - - BulkData bulk( meta , pm , 100 ); - - bulk.modification_begin(); - - // Ids for all entities (all entities have type 0): - - std::vector ids( id_total ); - - for ( unsigned i = 0 ; i < id_total ; ++i ) { ids[i] = i + 1; } - - // Declare just those entities in my range of ids: - - for ( unsigned i = id_begin ; i < id_end ; ++i ) { - bulk.declare_entity( 0 , ids[i] , no_parts ); - } - - STKUNIT_ASSERT( bulk.modification_end() ); - - // Only one process create entities with previous process' last two ids - - const unsigned id_get = ( id_begin + id_total - 2 ) % id_total ; - - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_get] ) ); - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[id_get+1] ) ); - - STKUNIT_ASSERT( bulk.modification_begin() ); - - if ( 1 == p_rank ) { - // These declarations create entities that already exist, - // which will be an error. Must create an owned entity - // to use them, thus they become shared. - - Entity & e0 = bulk.declare_entity( 0 , ids[ id_get ] , no_parts ); - Entity & e1 = bulk.declare_entity( 0 , ids[ id_get + 1 ] , no_parts ); - - Entity & eU = bulk.declare_entity( 1 , 1 , no_parts ); - - bulk.declare_relation( eU , e0 , 0 ); - bulk.declare_relation( eU , e1 , 1 ); - } - - bulk.modification_end(); - - if ( 1 == p_rank ) { - Entity * e0 = bulk.get_entity( 0 , ids[id_get] ); - Entity * e1 = bulk.get_entity( 0 , ids[id_get+1] ); - STKUNIT_ASSERT( NULL != e0 ); - STKUNIT_ASSERT( NULL != e1 ); - STKUNIT_ASSERT( 0 == e0->owner_rank() ); - STKUNIT_ASSERT( 0 == e1->owner_rank() ); - } - - // Now test tripping the error condition - - bulk.modification_begin(); - - if ( 0 == p_rank ) { - bulk.declare_entity( 0 , ids[ id_get ] , no_parts ); - bulk.declare_entity( 0 , ids[ id_get + 1 ] , no_parts ); - } - - STKUNIT_ASSERT_THROW( bulk.modification_end() , std::runtime_error ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeOwner_ring) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - enum { nPerProc = 10 }; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 ); - const unsigned nLocalEdge = nPerProc ; - - std::vector local_count ; - - //------------------------------ - { - bool aura = false; - RingFixture ring_mesh( pm , nPerProc , false /* no edge parts */ ); - BulkData & bulk = ring_mesh.m_bulk_data; - ring_mesh.m_meta_data.commit(); - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, aura)); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, aura)); - - const Selector select_used = ring_mesh.m_meta_data.locally_owned_part() | - ring_mesh.m_meta_data.globally_shared_part() ; - const Selector select_all = ring_mesh.m_meta_data.universal_part() ; - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - if ( 1 < p_size ) { - // Shift ring by two nodes and edges. - - stk_classic::unit_test::test_shift_ring( ring_mesh, false /* no aura */ ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge ); - - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge ); - } - } - - //------------------------------ - // Test shift starting with ghosting but not regenerated ghosting. - { - RingFixture ring_mesh( pm , nPerProc , false /* no edge parts */ ); - BulkData& bulk = ring_mesh.m_bulk_data; - ring_mesh.m_meta_data.commit(); - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(bulk.modification_end()); - - const Selector select_owned( ring_mesh.m_meta_data.locally_owned_part() ); - const Selector select_used = ring_mesh.m_meta_data.locally_owned_part() | - ring_mesh.m_meta_data.globally_shared_part() ; - const Selector select_all( ring_mesh.m_meta_data.universal_part() ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - const unsigned n_extra = 1 < p_size ? 2 : 0 ; - STKUNIT_ASSERT( local_count[0] == nLocalNode + n_extra ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge + n_extra ); - - if ( 1 < p_size ) { - stk_classic::unit_test::test_shift_ring( ring_mesh, false /* no aura */ ); - - count_entities( select_owned , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nPerProc ); - STKUNIT_ASSERT( local_count[1] == nPerProc ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge ); - - // All of my ghosts were disrupted and therefore deleted: - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT_EQUAL( nLocalEdge , local_count[1] ); - STKUNIT_ASSERT_EQUAL( nLocalNode , local_count[0] ); - } - } - //------------------------------ - // Test shift starting with ghosting and regenerating ghosting. - { - RingFixture ring_mesh( pm , nPerProc , false /* no edge parts */ ); - BulkData& bulk = ring_mesh.m_bulk_data; - ring_mesh.m_meta_data.commit(); - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(bulk.modification_end()); - - const Selector select_owned( ring_mesh.m_meta_data.locally_owned_part() ); - const Selector select_used = ring_mesh.m_meta_data.locally_owned_part() | - ring_mesh.m_meta_data.globally_shared_part() ; - const Selector select_all( ring_mesh.m_meta_data.universal_part() ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge ); - - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - const unsigned n_extra = 1 < p_size ? 2 : 0 ; - STKUNIT_ASSERT( local_count[0] == nLocalNode + n_extra ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge + n_extra ); - - if ( 1 < p_size ) { - stk_classic::unit_test::test_shift_ring( ring_mesh, true /* with aura */ ); - - count_entities( select_owned , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nPerProc ); - STKUNIT_ASSERT( local_count[1] == nPerProc ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge ); - - // All of my ghosts were regenerated: - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT( local_count[0] == nLocalNode + n_extra ); - STKUNIT_ASSERT( local_count[1] == nLocalEdge + n_extra ); - } - } - //------------------------------ - // Test bad owner change catching: - if ( 1 < p_size ) { - RingFixture ring_mesh( pm , nPerProc , false /* no edge parts */ ); - BulkData& bulk = ring_mesh.m_bulk_data; - ring_mesh.m_meta_data.commit(); - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(bulk.modification_end()); - - std::vector change ; - - if ( 0 == p_rank ) { - change.resize(4); - // Error to change to bad owner: - change[0].first = ring_mesh.m_bulk_data.get_entity( 0 , ring_mesh.m_node_ids[1] ); - change[0].second = p_size ; - // Error to change a ghost: - for ( std::vector::const_iterator - ec = ring_mesh.m_bulk_data.entity_comm().begin() ; - ec != ring_mesh.m_bulk_data.entity_comm().end() ; ++ec ) { - if ( in_receive_ghost( **ec ) ) { - change[1].first = *ec ; - break ; - } - } - change[1].second = p_rank ; - // Error to change to multiple owners: - change[2].first = ring_mesh.m_bulk_data.get_entity( 0 , ring_mesh.m_node_ids[1] ); - change[2].second = ( p_rank + 1 ) % p_size ; - change[3].first = change[2].first ; - change[3].second = ( p_rank + 2 ) % p_size ; - } - - STKUNIT_ASSERT( ring_mesh.m_bulk_data.modification_begin() ); - - STKUNIT_ASSERT_THROW( ring_mesh.m_bulk_data.change_entity_owner( change ), - std::runtime_error ); - } - //------------------------------ - // Test move one element with initial ghosting but not regenerated ghosting: - // last processor give its shared node to P0 - if ( 1 < p_size ) { - RingFixture ring_mesh( pm , nPerProc , false /* no edge parts */ ); - BulkData& bulk = ring_mesh.m_bulk_data; - ring_mesh.m_meta_data.commit(); - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(bulk.modification_end()); - - const Selector select_owned( ring_mesh.m_meta_data.locally_owned_part() ); - const Selector select_used = ring_mesh.m_meta_data.locally_owned_part() | - ring_mesh.m_meta_data.globally_shared_part() ; - const Selector select_all( ring_mesh.m_meta_data.universal_part() ); - - std::vector change ; - - if ( p_rank + 1 == p_size ) { - EntityProc entry ; - entry.first = ring_mesh.m_bulk_data.get_entity( 0 , ring_mesh.m_node_ids[0] ); - entry.second = 0 ; - STKUNIT_ASSERT_EQUAL( p_rank , entry.first->owner_rank() ); - change.push_back( entry ); - } - - STKUNIT_ASSERT( ring_mesh.m_bulk_data.modification_begin() ); - ring_mesh.m_bulk_data.change_entity_owner( change ); - STKUNIT_ASSERT( stk_classic::unit_test::modification_end_wrapper( ring_mesh.m_bulk_data , false ) ); - - count_entities( select_owned , ring_mesh.m_bulk_data , local_count ); - const unsigned n_node = p_rank == 0 ? nPerProc + 1 : ( - p_rank + 1 == p_size ? nPerProc - 1 : - nPerProc ); - - STKUNIT_ASSERT_EQUAL( n_node , local_count[0] ); - STKUNIT_ASSERT_EQUAL( (unsigned) nPerProc , local_count[1] ); - - count_entities( select_used , ring_mesh.m_bulk_data , local_count ); - STKUNIT_ASSERT_EQUAL( nLocalNode , local_count[0] ); - STKUNIT_ASSERT_EQUAL( nLocalEdge , local_count[1] ); - - // Moving the node disrupted ghosting on first and last process - count_entities( select_all , ring_mesh.m_bulk_data , local_count ); - const unsigned n_extra = p_rank + 1 == p_size || p_rank == 0 ? 1 : 2 ; - STKUNIT_ASSERT_EQUAL( nLocalNode + n_extra , local_count[0] ); - STKUNIT_ASSERT_EQUAL( nLocalEdge + n_extra , local_count[1] ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Testing for collection of boxes - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeOwner_box) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const int spatial_dimension = 3; - MetaData meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - - meta.commit(); - - //------------------------------ - { - bool aura = false; - BoxFixture fixture( pm, 100 ); - fixture.fem_meta().commit(); - BulkData & bulk = fixture.bulk_data(); - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, aura)); - - if ( 1 < p_size ) { - donate_one_element( bulk , aura ); - } - } - - if ( 1 < p_size ) { - bool aura = false; - BoxFixture fixture( pm, 100 ); - fixture.fem_meta().commit(); - BulkData & bulk = fixture.bulk_data(); - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, aura)); - - donate_all_shared_nodes( bulk , aura ); - } - //------------------------------ - if ( 1 < p_size ) { - bool aura = false; - BoxFixture fixture( pm, 100 ); - fixture.fem_meta().commit(); - BulkData & bulk = fixture.bulk_data(); - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, aura)); - - donate_one_element( bulk , false /* no aura */ ); - } - //------------------------------ - // Introduce ghosts: - if ( 1 < p_size ) { - BoxFixture fixture( pm, 100 ); - BulkData & bulk = fixture.bulk_data(); - FEMMetaData & box_meta = fixture.fem_meta(); - box_meta.commit(); - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - std::vector used_count ; - std::vector all_count ; - - const Selector select_owned( box_meta.locally_owned_part() ); - const Selector select_used = box_meta.locally_owned_part() | - box_meta.globally_shared_part() ; - const Selector select_all( box_meta.universal_part() ); - - count_entities( select_all , bulk , all_count ); - count_entities( select_used , bulk , used_count ); - - STKUNIT_ASSERT( used_count[0] < all_count[0] ); - STKUNIT_ASSERT( used_count[3] < all_count[3] ); - - donate_all_shared_nodes( bulk , false /* don't regenerate aura */ ); - - count_entities( select_all , bulk , all_count ); - count_entities( select_used , bulk , used_count ); - - STKUNIT_ASSERT_EQUAL( used_count[0] , all_count[0] ); - STKUNIT_ASSERT_EQUAL( used_count[3] , all_count[3] ); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testModifyPropagation) -{ - // Our new modification model makes it so the modified status - // of an entity is propagated up to higher-ranked entities - // that have relations to the modified entity. We test this - // by grabbing a node off of a ring mesh, modifying it, and - // checking that its edge also gets marked as modified. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const unsigned nPerProc = 2; - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - // this test only needs to be run w/ one processor - if (p_size > 1) return; - - // Make a ring_mesh and add an extra part - RingFixture ring_mesh( pm , nPerProc, false /* don't use edge parts */); - stk_classic::mesh::Part& special_part = - ring_mesh.m_meta_data.declare_part("special_node_part", stk_classic::mesh::BaseEntityRank ); - ring_mesh.m_meta_data.commit(); - BulkData& bulk = ring_mesh.m_bulk_data; - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership( ); - STKUNIT_ASSERT(bulk.modification_end()); - - // grab the first edge - EntityVector edges; - const stk_classic::mesh::EntityRank element_rank = ring_mesh.m_meta_data.element_rank(); - stk_classic::mesh::get_entities( ring_mesh.m_bulk_data, element_rank, edges ); - stk_classic::mesh::Entity& edge = *( edges.front() ); - - // get one of the nodes related to this edge - PairIterRelation node_relations = edge.relations( stk_classic::mesh::BaseEntityRank ); - STKUNIT_ASSERT( !node_relations.empty() ); - stk_classic::mesh::Entity& node = *( node_relations.front().entity()); - STKUNIT_ASSERT_EQUAL( node.entity_rank(), (unsigned) stk_classic::mesh::BaseEntityRank ); - - // make a modification to the node by changing its parts - ring_mesh.m_bulk_data.modification_begin(); - stk_classic::mesh::PartVector parts; - parts.push_back( &special_part ); - ring_mesh.m_bulk_data.change_entity_parts( node, parts ); - - // check that the node AND it's edge are marked as modified - STKUNIT_ASSERT_EQUAL ( node.log_query(), stk_classic::mesh::EntityLogModified ); - STKUNIT_ASSERT_EQUAL ( edge.log_query(), stk_classic::mesh::EntityLogModified ); - - STKUNIT_ASSERT ( ring_mesh.m_bulk_data.modification_end() ); -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeEntityOwnerFromSelfToSelf) -{ - // It should be legal to "change" entity ownership from yourself to yourself. - // - // 1---3---5 - // | 1 | 2 | - // 2---4---6 - // - // To test this, we use the mesh above, with elem 1 going on rank 0 and - // elem 2 going on rank 1. Nodes 3,4 are shared. After the mesh is set up - // we change the ownership of a few nodes to the same proc that already - // owns them. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - // Bail if we only have one proc - if (p_size == 1) { - return; - } - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - EntityVector nodes; - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - - if (p_rank < 2) { - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank elem_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(elem_rank, - p_rank+1, //elem_id - empty_parts); - - // Create nodes - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, - id, - empty_parts)); - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - } - - mesh.modification_end(); - - mesh.modification_begin(); - - std::vector change ; - if (p_rank < 2) { - // Change ownership of some nodes to the same proc that owns them - - // Add a non-shared node to change list - if ( p_rank == 0 ) { - EntityProc entry( nodes.front(), p_rank ) ; - change.push_back( entry ); - } - else { - EntityProc entry( nodes.back(), p_rank ) ; - change.push_back( entry ); - } - - // Add a shared node to change list - Entity* shared_node = nodes[p_rank == 0 ? nodes_per_side : 0]; - EntityId expected_id = 3; - Part& shared_part = meta_data.globally_shared_part(); - STKUNIT_ASSERT( has_superset(shared_node->bucket(), shared_part) ); - STKUNIT_ASSERT_EQUAL(shared_node->identifier(), expected_id); - if (shared_node->owner_rank() == p_rank) { - EntityProc entry( shared_node, p_rank ); - change.push_back( entry ); - } - } - - mesh.change_entity_owner(change); - - mesh.modification_end(); -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeEntityOwnerOfShared) -{ - // This unit-test is designed to test the conditions that results that - // resulted in the difficult-to-fix rebalance use-case bug. Specifically, - // it will test the changing-of-ownership of a shared edge to a proc that - // either ghosted it or did not know about it. - // - // 1---3---5---7 - // | 1 | 2 | 3 | ... - // 2---4---6---8 - // - // To test this, we use the mesh above, with each elem going on a separate - // proc, one elem per proc. We will take the edge shared by the last - // two (rightmost) elements and change the ownership to proc 0. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - const EntityRank edge_rank = meta_data.edge_rank(); - const EntityRank elem_rank = meta_data.element_rank(); - - // Bail if we have fewer than 3 procs - if (p_size < 3) { - return; - } - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - EntityKey elem_key_chg_own(elem_rank, p_size - 1 /*id*/); - EntityKey edge_key_chg_own(edge_rank, 1 /*id*/); - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - Entity & elem = mesh.declare_entity(elem_rank, - p_rank+1, //elem_id - empty_parts); - - // If it is 2nd to last element, it is the one changing - if (p_rank == p_size - 2) { - STKUNIT_ASSERT(elem_key_chg_own == elem.key()); - } - - // Create nodes - EntityVector nodes; - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, - id, - empty_parts)); - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - - // Create edge on last two procs - - if (p_rank >= p_size - 2) { - Entity& edge = mesh.declare_entity(edge_rank, - 1, // id - empty_parts); - STKUNIT_ASSERT(edge.key() == edge_key_chg_own); - - // Add relation from elem to edge - mesh.declare_relation( elem, edge, 1 /*rel-id*/); - - // Add relations from edge to nodes - unsigned start_idx = p_rank == p_size - 1 ? 0 : nodes_per_side; - unsigned end_idx = start_idx + nodes_per_side; - rel_id = 0; - for (unsigned idx = start_idx ; - start_idx < end_idx; - ++start_idx, ++rel_id) { - mesh.declare_relation( edge, *nodes[idx], rel_id ); - } - } - - mesh.modification_end(); - - // Changing elem and edge should be ghosted or unknown on proc 0 - if (p_rank == 0) { - // Get the two entities - Entity* changing_elem = mesh.get_entity(elem_key_chg_own); - Entity* changing_edge = mesh.get_entity(edge_key_chg_own); - if (p_size == 3) { - // Should be ghosted - STKUNIT_ASSERT(changing_elem != NULL); - STKUNIT_ASSERT(changing_edge != NULL); - - // Verify that the entities are ghosted - Part& owned = meta_data.locally_owned_part(); - Part& shared = meta_data.globally_shared_part(); - STKUNIT_ASSERT(!(changing_elem->bucket().member(owned) || - changing_elem->bucket().member(shared))); - STKUNIT_ASSERT(!(changing_edge->bucket().member(owned) || - changing_edge->bucket().member(shared))); - } - else { - // Should be NULL - STKUNIT_ASSERT(changing_elem == NULL); - STKUNIT_ASSERT(changing_edge == NULL); - } - } - - mesh.modification_begin(); - - std::vector change ; - if (p_rank >= p_size - 2) { - // Change ownership of changing elem and all entities in it's closure that - // we own to proc 0. - - Entity* changing_elem = mesh.get_entity(elem_key_chg_own); - if (p_rank == p_size - 2) { - EntityProc eproc(changing_elem, 0 /*new owner*/); - change.push_back(eproc); - } - - for (PairIterRelation i = changing_elem->relations() ; !i.empty() ; ++i) { - if (i->entity()->owner_rank() == p_rank) { - EntityProc eproc(i->entity(), 0 /*new owner*/); - change.push_back(eproc); - } - } - } - - mesh.change_entity_owner(change); - - mesh.modification_end(); - - // Changing elem and edge should now be owned by proc 0 - if (p_rank == 0) { - // Get the two ghosted entities, check that they were found - Entity* changing_elem = mesh.get_entity(elem_key_chg_own); - Entity* changing_edge = mesh.get_entity(edge_key_chg_own); - STKUNIT_ASSERT(changing_elem != NULL); - STKUNIT_ASSERT(changing_edge != NULL); - - // Verify that the entities are ghosted - Part& owned = meta_data.locally_owned_part(); - STKUNIT_ASSERT( changing_elem->bucket().member(owned) ); - STKUNIT_ASSERT( changing_edge->bucket().member(owned) ); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testFamilyTreeGhosting) -{ - // A family tree is a higher-rank entity (rank = element_rank() + 1) that - // has down-relations to elements used, for example, to hold parent/child - // relations in an adapted mesh. - // - // 1---3---5---7 - // | 1 | 2 | 3 | ... - // 2---4---6---8 - // - // To test this, we use the mesh above, with each elem going on a separate - // proc, one elem per proc. - // After the mesh is set up we add rank-3 (family tree) entities and have them point down to - // just the single rank-2 elements. Then we check that they are properly - // ghosted after modification_end. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim); - entity_rank_names.push_back("FAMILY_TREE"); - - FEMMetaData meta_data(spatial_dim, entity_rank_names); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - Part& owned = meta_data.locally_owned_part(); - Part& shared = meta_data.globally_shared_part(); - - // - // Begin modification cycle so we can create the entities and relations - // - - mesh.modification_begin(); - - EntityVector nodes; - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - const EntityRank family_tree_rank = meta_data.element_rank() + 1; - const EntityId my_family_tree_id = p_rank+1; - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank elem_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(elem_rank, - p_rank+1, //elem_id - empty_parts); - - // Create nodes - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, - id, - empty_parts)); - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - - // Create family tree - Entity & family_tree = mesh.declare_entity(family_tree_rank, - my_family_tree_id, - empty_parts); - // Add relation to element - unsigned downward_ordinal = 0; // we only have 1 down relation, it has ordinal 0 - mesh.declare_relation( family_tree, elem, downward_ordinal); - - mesh.modification_end(); - - // - // Test correctness of ghosting: Check that adjacent family-trees are ghosted on this proc - // - - // Compute and store ids of adjacent family-trees - std::vector family_tree_ghost_ids; - if (p_rank > 0) { - family_tree_ghost_ids.push_back(my_family_tree_id - 1); - } - if (p_rank < p_size - 1) { - family_tree_ghost_ids.push_back(my_family_tree_id + 1); - } - - // Check that my_family_tree exists and I own it - Entity *my_family_tree = mesh.get_entity(family_tree_rank, my_family_tree_id); - STKUNIT_ASSERT(my_family_tree); - STKUNIT_ASSERT( (p_rank) == my_family_tree->owner_rank()); - - // Check that adjacent family-trees exist and are ghosted - for (std::vector::const_iterator - itr = family_tree_ghost_ids.begin(); itr != family_tree_ghost_ids.end(); ++itr) { - EntityId expected_ghosted_family_tree_id = *itr; - - Entity *expected_ghosted_family_tree = mesh.get_entity(family_tree_rank, expected_ghosted_family_tree_id); - STKUNIT_ASSERT(expected_ghosted_family_tree); - STKUNIT_ASSERT(expected_ghosted_family_tree_id - 1 == expected_ghosted_family_tree->owner_rank()); - - stk_classic::mesh::Bucket& bucket = expected_ghosted_family_tree->bucket(); - STKUNIT_ASSERT(!bucket.member(owned) && !bucket.member(shared)); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, test_other_ghosting) -{ - // - // 1---3---5---7 - // | 1 | 2 | 3 | ... - // 2---4---6---8 - // - // To test this, we use the mesh above, with each elem going on a separate - // proc, one elem per proc. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim); - //entity_rank_names.push_back("FAMILY_TREE"); - - FEMMetaData meta_data(spatial_dim, entity_rank_names); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - if (p_size != 3) return; - - //Part& owned = meta_data.locally_owned_part(); - //Part& shared = meta_data.globally_shared_part(); - - // - // Begin modification cycle so we can create the entities and relations - // - - mesh.modification_begin(); - - EntityVector nodes; - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank elem_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(elem_rank, - p_rank+1, //elem_id - empty_parts); - - // Create nodes - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, - id, - empty_parts)); - std::cout << "P[" << p_rank << "] node id= " << id << std::endl; - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - - if (1 && p_rank == 2) - { - Entity& node = mesh.declare_entity(NODE_RANK, - 4, - empty_parts); - //Entity* node = mesh.get_entity(NODE_RANK, - //4); - - mesh.declare_relation(elem, node, 4); - } - - mesh.modification_end(); - - if (p_rank == 0) - { - unsigned id=4; - Entity *node = mesh.get_entity(0, id); - std::cout << "P[" << p_rank << "] node " << node << " own= " << node->owner_rank() << std::endl; - - { - PairIterRelation rels = node->relations(); - for (unsigned i = 0; i < rels.size(); i++) - { - std::cout << "P[" << p_rank << "] rel = " << rels[i].entity()->owner_rank() << std::endl; - } - } - } - - mesh.modification_begin(); - if (p_rank == 1) - { - Entity *this_elem = mesh.get_entity(2, 2); - if (!mesh.destroy_entity(this_elem)) exit(2); - } - if (p_rank == 2) - { - Entity *this_elem = mesh.get_entity(2, 3); - if (!mesh.destroy_entity(this_elem)) exit(2); - } - mesh.modification_end(); - - if (1 || p_rank == 2) - { - unsigned id=4; - Entity *node = mesh.get_entity(0, id); - // - - { - PairIterRelation rels = node->relations(); - for (unsigned i = 0; i < rels.size(); i++) - { - std::cout << "P[" << p_rank << "] node " << node << " own= " << node->owner_rank() << " rel = " << rels[i].entity()->owner_rank() << std::endl; - } - } - } - - //exit(123); - -#if 0 - // - // Test correctness of ghosting: Check that adjacent family-trees are ghosted on this proc - // - - // Compute and store ids of adjacent family-trees - std::vector family_tree_ghost_ids; - if (p_rank > 0) { - family_tree_ghost_ids.push_back(my_family_tree_id - 1); - } - if (p_rank < p_size - 1) { - family_tree_ghost_ids.push_back(my_family_tree_id + 1); - } - - // Check that my_family_tree exists and I own it - Entity *my_family_tree = mesh.get_entity(family_tree_rank, my_family_tree_id); - STKUNIT_ASSERT(my_family_tree); - STKUNIT_ASSERT( (p_rank) == my_family_tree->owner_rank()); - - // Check that adjacent family-trees exist and are ghosted - for (std::vector::const_iterator - itr = family_tree_ghost_ids.begin(); itr != family_tree_ghost_ids.end(); ++itr) { - EntityId expected_ghosted_family_tree_id = *itr; - - Entity *expected_ghosted_family_tree = mesh.get_entity(family_tree_rank, expected_ghosted_family_tree_id); - STKUNIT_ASSERT(expected_ghosted_family_tree); - STKUNIT_ASSERT(expected_ghosted_family_tree_id - 1 == expected_ghosted_family_tree->owner_rank()); - - stk_classic::mesh::Bucket& bucket = expected_ghosted_family_tree->bucket(); - STKUNIT_ASSERT(!bucket.member(owned) && !bucket.member(shared)); - } -#endif -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeEntityPartsOfShared) -{ - // - // This unit-test is designed to test what happens when a shared entity - // is moved on one processor during the same modification cycle in which - // it was declared. - // - // 1---3---5 - // | 1 | 2 | - // 2---4---6 - // - // To test this, we use the mesh above, with each elem going on a separate - // proc, one elem per proc. Node 3 is the node we'll be testing. - // - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - const EntityRank node_rank = meta_data.node_rank(); - const EntityRank elem_rank = meta_data.element_rank(); - - stk_classic::mesh::Part& extra_node_part = meta_data.declare_part("extra_node_part", node_rank); - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - // Bail unless in parallel - if (p_size == 1) { - return; - } - - // Begin modification cycle so we can create the entities and relations - if (p_rank < 2) { - mesh.modification_begin(); - - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - EntityKey node_key_to_move(node_rank, 3 /*id*/); - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - Entity & elem = mesh.declare_entity(elem_rank, - p_rank+1, //elem_id - empty_parts); - - // Create nodes - EntityVector nodes; - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, - id, - empty_parts)); - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - - // On the processor that does *not* end up as the owner of the node, change its parts - Entity& changing_node = *mesh.get_entity(node_key_to_move); - if (p_rank == 0) { - PartVector add_parts(1, &extra_node_part); - mesh.change_entity_parts(changing_node, add_parts); - } - - mesh.modification_end(); - - // Expect that this is a shared node - STKUNIT_EXPECT_FALSE(changing_node.sharing().empty()); - - // Expect that part change had no impact since it was on the proc that did not end - // up as the owner - STKUNIT_EXPECT_FALSE(changing_node.bucket().member(extra_node_part)); - - mesh.modification_begin(); - - // On the processor that owns the node, change its parts - if (p_rank == 1) { - PartVector add_parts(1, &extra_node_part); - mesh.change_entity_parts(changing_node, add_parts); - } - - mesh.modification_end(); - - // Expect that the part change *did* have an impact - STKUNIT_EXPECT_TRUE(changing_node.bucket().member(extra_node_part)); - } - else { - // On extra procs, do bare minimum - mesh.modification_begin(); - mesh.modification_end(); - mesh.modification_begin(); - mesh.modification_end(); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, test_final_modification_end) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - - mesh.modification_begin(); - mesh.final_modification_end(); - - STKUNIT_ASSERT_THROW(mesh.modification_begin(), std::logic_error ); - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkDataAdapt.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkDataAdapt.cpp deleted file mode 100644 index d0782634bef7..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkDataAdapt.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -using stk_classic::mesh::Part; -using stk_classic::mesh::Bucket; -using stk_classic::mesh::PairIterRelation; -using stk_classic::mesh::PairIterEntityComm; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Selector; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::BaseEntityRank; -using stk_classic::mesh::PairIterRelation; -using stk_classic::mesh::EntityProc; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::EntityKey; -using stk_classic::mesh::EntityVector; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::fixtures::RingFixture; -using stk_classic::mesh::fixtures::BoxFixture; - -namespace { -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; -} // empty namespace - -void printEntity(std::ostringstream& msg, Entity *entity) -{ - msg << " :: " << print_entity_key(entity) << ":o[" << entity->owner_rank() << "]:l[" << entity->log_query() - << "]:ec["; - for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) { - msg << "(" << ec->ghost_id << "," << ec->proc << ")"; - } - msg << "]"; -} - -void printNode(std::ostringstream& msg, Entity *node) -{ - printEntity(msg, node); - PairIterRelation rels = node->relations(); - for (unsigned i = 0; i < rels.size(); i++) - { - Entity *entity = rels[i].entity(); - if (entity->entity_rank() > node->entity_rank()) - printEntity(msg, entity); - } -} - -void printBuckets(std::ostringstream& msg, BulkData& mesh) -{ - const std::vector & buckets = mesh.buckets(0); - for (unsigned i=0; i < buckets.size(); i++) - { - const Bucket& bucket = *buckets[i]; - msg << " bucket[" << i << "] = "; - size_t bucket_size = bucket.size(); - for (unsigned ie=0; ie < bucket_size; ie++) - { - msg << bucket[ie].identifier() << ", "; - } - } -} - -static void checkBuckets( BulkData& mesh) -{ - const std::vector & buckets = mesh.buckets(0); - for (unsigned i=0; i < buckets.size(); i++) - { - Bucket* bucket = buckets[i]; - STKUNIT_ASSERT(bucket->assert_correct()); - } -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, test_other_ghosting_2) -{ - // - // testing if modification flags propagate properly for ghosted entities - // - // To test this, we focus on a single node shared on 2 procs, ghosted on others - // - - /** - * 1D Mesh (node,owner)--[elem,owner]---(...) - * - * <---(70,0)--[500,0]--(41,1)--[301,1]---(42,2)---[402,2]---(70,0)---> - * - * <---(50,0)--[100,0]--(21,1)--[201,1]---(32,2)---[302,2]---(50,0)---> - * - */ - - // elem, node0, node1, owner - EntityId elems_0[][4] = { {100, 21, 50, 0}, {201, 21, 32, 1}, {302, 32, 50, 2}, - {500, 41, 70, 0}, {301, 41, 42, 1}, {402, 42, 70, 2} }; - // node, owner - EntityId nodes_0[][2] = { {21,1}, {50,0}, {32, 2}, {41, 1}, {42, 1}, {70, 0} }; - - unsigned nelems = sizeof(elems_0)/4/sizeof(EntityId); - unsigned nnodes = sizeof(nodes_0)/2/sizeof(EntityId); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim); - entity_rank_names.push_back("FAMILY_TREE"); - - FEMMetaData meta_data(spatial_dim, entity_rank_names); - //Part & part_tmp = meta_data.declare_part( "temp"); - - meta_data.commit(); - unsigned max_bucket_size = 1; - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm, max_bucket_size); - //BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - if (p_size != 3) return; - - // - // Begin modification cycle so we can create the entities and relations - // - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create elements - const EntityRank elem_rank = meta_data.element_rank(); - Entity * elem = 0; - - mesh.modification_begin(); - - for (unsigned ielem=0; ielem < nelems; ielem++) - { - if (elems_0[ielem][3] == p_rank) - { - elem = &mesh.declare_entity(elem_rank, elems_0[ielem][0], empty_parts); - - EntityVector nodes; - // Create node on all procs - nodes.push_back( &mesh.declare_entity(NODE_RANK, elems_0[ielem][2], empty_parts) ); - nodes.push_back( &mesh.declare_entity(NODE_RANK, elems_0[ielem][1], empty_parts) ); - - // Add relations to nodes - mesh.declare_relation( *elem, *nodes[0], 0 ); - mesh.declare_relation( *elem, *nodes[1], 1 ); - - } - } - - mesh.modification_end(); - - Entity* node1 = 0; - - // change node owners - mesh.modification_begin(); - - std::vector change; - - for (unsigned inode=0; inode < nnodes; inode++) - { - node1 = mesh.get_entity(0, nodes_0[inode][0]); - if (node1 && node1->owner_rank() == p_rank) - { - unsigned dest = nodes_0[inode][1]; - EntityProc eproc(node1, dest); - change.push_back(eproc); - } - } - - mesh.change_entity_owner( change ); - - mesh.modification_end(); - - checkBuckets(mesh); - - MPI_Barrier(MPI_COMM_WORLD); - - - // attempt to delete a node and its elems but on a ghosted proc - mesh.modification_begin(); - - if (p_rank == 2) - { - node1 = mesh.get_entity(0, 21); - Entity *elem1 = mesh.get_entity(2, 201); - Entity *elem2 = mesh.get_entity(2, 100); - - bool did_it_elem = mesh.destroy_entity(elem1); - did_it_elem = did_it_elem & mesh.destroy_entity(elem2); - STKUNIT_ASSERT(did_it_elem); - bool did_it = mesh.destroy_entity(node1); - STKUNIT_ASSERT(did_it); - } - - mesh.modification_end(); - - checkBuckets(mesh); - - // this node should no longer exist anywhere - node1 = mesh.get_entity(0, 21); - - // uncomment to force failure of test - // STKUNIT_ASSERT(node1 == 0); - -} - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_ChangeParts.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_ChangeParts.cpp deleted file mode 100644 index 729852849012..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_ChangeParts.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -#include -#include -#include - -#include - -#include - -using stk_classic::mesh::Part; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Entity; -using stk_classic::mesh::Selector; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::fixtures::RingFixture; - -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeParts) -{ - // This unit test tests part operations and verifies operations - // by looking at bucket supersets. We use contrived entities - // (as opposed to a fixture) for simplicity and clarity. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - - // Single process, no sharing - - // Meta data with entity ranks [0..9] - const unsigned spatial_dimension = 10; - std::vector entity_names(spatial_dimension+1); - for ( size_t i = 0 ; i <= spatial_dimension ; ++i ) { - std::ostringstream name ; - name << "EntityRank_" << i ; - entity_names[i] = name.str(); - } - - // Create a mesh with a bunch of parts - - FEMMetaData meta( spatial_dimension, entity_names ); - BulkData bulk( FEMMetaData::get_meta_data(meta) , pm , 100 ); - - Part & part_univ = meta.universal_part(); - Part & part_owns = meta.locally_owned_part(); - Part & part_shared = meta.globally_shared_part(); - - Part & part_A_0 = meta.declare_part(std::string("A_0"), 0 /*entity_rank*/); - Part & part_A_1 = meta.declare_part(std::string("A_1"), 1 /*entity_rank*/); - Part & part_A_2 = meta.declare_part(std::string("A_2"), 2 /*entity_rank*/); - Part & part_A_3 = meta.declare_part(std::string("A_3"), 3 /*entity_rank*/); - - Part & part_B_0 = meta.declare_part(std::string("B_0"), 0 /*entity_rank*/); - Part & part_B_2 = meta.declare_part(std::string("B_2"), 2 /*entity_rank*/); - - meta.commit(); - bulk.modification_begin(); - - PartVector tmp(1), no_parts; - - // Declare a few entities of various ranks. In order for the sharing - // to work, we need to have all the entities we'll be playing with - // to be in the owned-closure of a high-level non-shared entity, we'll - // call that entity the closure_entity because all the other entities - // will be in it's closure. - - Entity& closure_entity = bulk.declare_entity(4 /*entity rank*/, - p_rank+1 /*id*/, - no_parts); - - tmp[0] = & part_A_0 ; - Entity& entity_0_1 = bulk.declare_entity(0 /*entity rank*/, 1 /*id*/, tmp); - bulk.declare_relation( closure_entity , entity_0_1 , 0 /*local_rel_id*/ ); - - tmp[0] = & part_A_1 ; - Entity& entity_1_1 = bulk.declare_entity(1 /*entity rank*/, 1 /*id*/, tmp); - bulk.declare_relation( closure_entity , entity_1_1 , 1 /*local_rel_id*/ ); - - tmp[0] = & part_A_2 ; - Entity& entity_2_1 = bulk.declare_entity(2 /*entity rank*/, 1 /*id*/, tmp); - bulk.declare_relation( closure_entity , entity_2_1 , 2 /*local_rel_id*/ ); - - tmp[0] = & part_A_3 ; - Entity& entity_3_1 = bulk.declare_entity(3 /*entity rank*/, 1 /*id*/, tmp); - bulk.declare_relation( closure_entity , entity_3_1 , 3 /*local_rel_id*/ ); - - // Ensure that the supersets of the buckets containing the entities we - // just created are correct. - - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - - entity_1_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_1_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_1_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_1_1.bucket().member(part_A_1) ); - - entity_2_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_A_2) ); - - entity_3_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_3_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_3_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_3_1.bucket().member(part_A_3) ); - - // Add entity_0_1 to the part it was already in - { - tmp.resize(1); - tmp[0] = & part_A_0 ; - bulk.change_entity_parts( entity_0_1 , tmp ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - // Add entity_0_1 to part_B_0 - { - tmp.resize(1); - tmp[0] = & part_B_0 ; - bulk.change_entity_parts( entity_0_1 , tmp ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(4) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_B_0) ); - } - - // Remove entity_0_1 from the part it was just added to above - { - tmp.resize(1); - tmp[0] = & part_B_0 ; - bulk.change_entity_parts( entity_0_1 , PartVector() , tmp ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - // Add relation from entity_1_1 (which is in part_A_1) to - // entity_0_1 (which is in part_A_0). After the relation - // is added, there is an induced membership of entity_0_1 - // within part A_1. - stk_classic::mesh::RelationIdentifier test_rel_id = 0; - { - bulk.declare_relation( entity_1_1 , entity_0_1 , test_rel_id ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(4) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_1) ); - } - - // Remove the relationship added in the step above and - // demonstrate that the induced membership of entity_0_1 - // in part_A_1 is gone - { - bulk.destroy_relation( entity_1_1 , entity_0_1, test_rel_id ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - // Add entity_2_1 to part_B_2 - { - tmp.resize(1); - tmp[0] = & part_B_2 ; - bulk.change_entity_parts( entity_2_1 , tmp ); - entity_2_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(4) , tmp.size() ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_A_2) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_B_2) ); - } - - // Add relation from entity_2_1 (which is in part_A_2 and B_2) to - // entity_0_1 (which is in part_A_0). After the relation - // is added, there is an induced membership of entity_0_1 - // within entity_2_1's parts (A_2 and B_2) (and of course entity_0_1 - // is still in the parts it was already in). - { - bulk.declare_relation( entity_2_1 , entity_0_1 , test_rel_id ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(5) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_2) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_B_2) ); - } - - // Remove the relationship added in the step above and - // demonstrate that the induced membership of entity_0_1 - // in parts A_2 and B_2 is gone. - { - bulk.destroy_relation( entity_2_1 , entity_0_1, test_rel_id ); - entity_0_1.bucket().supersets( tmp ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - bulk.modification_end(); - - //------------------------------ - // Now the parallel fun. Existing entities should be shared - // by all processes since they have the same identifiers. - // They should also have the same parts. - - bool parallel = p_size > 1; - - // For parallel runs, the entities should be in the same parts - // as they were before the modification end and they should - // be in the shared part as well. - - entity_0_1.bucket().supersets( tmp ); - if ( entity_0_1.owner_rank() == p_rank ) { - STKUNIT_ASSERT_EQUAL( size_t(parallel ? 4 : 3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - if ( parallel ) - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - else { - STKUNIT_ASSERT( parallel ); - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - entity_2_1.bucket().supersets( tmp ); - if ( entity_2_1.owner_rank() == p_rank ) { - STKUNIT_ASSERT_EQUAL( size_t(parallel ? 5 : 4) , tmp.size() ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_owns) ); - if ( parallel ) - STKUNIT_ASSERT( entity_2_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_A_2) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_B_2) ); - } - else { - STKUNIT_ASSERT_EQUAL( size_t(4) , tmp.size() ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_A_2) ); - STKUNIT_ASSERT( entity_2_1.bucket().member(part_B_2) ); - } - - if ( parallel ) { - // If parallel, check that the entities are shared across all procs. - STKUNIT_ASSERT_EQUAL( size_t(p_size - 1) , entity_0_1.sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(p_size - 1) , entity_1_1.sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(p_size - 1) , entity_2_1.sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(p_size - 1) , entity_3_1.sharing().size() ); - } - - bulk.modification_begin(); - - // Add entity_0_1 to a new part on the owning process - - int ok_to_modify = entity_0_1.owner_rank() == p_rank ; - - try { - tmp.resize(1); - tmp[0] = & part_B_0 ; - bulk.change_entity_parts( entity_0_1 , tmp ); - STKUNIT_ASSERT( ok_to_modify ); - } - catch( const std::exception & x ) { - STKUNIT_ASSERT( ! ok_to_modify ); - } - - // Check that entity_0_1 is in the new part on the owning - // process, but not on other processes. - - entity_0_1.bucket().supersets( tmp ); - if ( entity_0_1.owner_rank() == p_rank ) { - STKUNIT_ASSERT_EQUAL( size_t(parallel ? 5 : 4) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - if ( parallel ) - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_B_0) ); - } - else { - STKUNIT_ASSERT_EQUAL( size_t(3) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - } - - bulk.modification_end(); - - // Now that modification_end has been called, entity_0_1 should - // be in the new part (B_0) on all processes. - - entity_0_1.bucket().supersets( tmp ); - if ( entity_0_1.owner_rank() == p_rank ) { - STKUNIT_ASSERT_EQUAL( size_t(parallel ? 5 : 4) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_owns) ); - if ( parallel ) - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_B_0) ); - } - else { - STKUNIT_ASSERT_EQUAL( size_t(4) , tmp.size() ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_univ) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_shared) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_A_0) ); - STKUNIT_ASSERT( entity_0_1.bucket().member(part_B_0) ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testChangeParts_ringmesh) -{ - // This unit test tests part operations and verifies operations - // by looking at bucket supersets. We use RingMesh for a slightly - // more realistic test than the test above but it's a bit harder - // to read. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const unsigned nPerProc = 10; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 ); - const unsigned nLocalEdge = nPerProc ; - - // Create the ring mesh - - RingFixture ring_mesh( pm , nPerProc , true /* generate parts */ ); - ring_mesh.m_meta_data.commit(); - BulkData& bulk = ring_mesh.m_bulk_data; - - bulk.modification_begin(); - ring_mesh.generate_mesh( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, - false /* no aura */)); - - bulk.modification_begin(); - ring_mesh.fixup_node_ownership(); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, - false /* no aura */)); - - Part & part_owns = ring_mesh.m_meta_data.locally_owned_part(); - Part & part_univ = ring_mesh.m_meta_data.universal_part(); - - // Check that local edges are in the expected parts. Note that the - // RingMesh puts each edge in its own part. - for ( unsigned i = 0 ; i < nLocalEdge ; ++i ) { - const unsigned n = i + nPerProc * p_rank ; - Entity * const edge = bulk.get_entity( 1 /*entity rank*/, - ring_mesh.m_edge_ids[n] ); - STKUNIT_ASSERT( edge != NULL ); - STKUNIT_ASSERT( edge->bucket().member( part_univ ) ); - STKUNIT_ASSERT( edge->bucket().member( part_owns ) ); - STKUNIT_ASSERT( edge->bucket().member( * ring_mesh.m_edge_parts[ n % ring_mesh.m_edge_parts.size() ] ) ); - } - - // Check that local nodes are in the expected parts. Note that the relations - // that nodes have to edges should cause induced membership of the node - // in the parts of both edges it touches. - for ( unsigned i = 0 ; i < nLocalNode ; ++i ) { - const unsigned n = ( i + nPerProc * p_rank ) % ring_mesh.m_node_ids.size(); - const unsigned e0 = n ; - const unsigned e1 = ( n + ring_mesh.m_edge_ids.size() - 1 ) % ring_mesh.m_edge_ids.size(); - const unsigned ns = ring_mesh.m_edge_parts.size(); - const unsigned n0 = e0 % ns ; - const unsigned n1 = e1 % ns ; - Part * const epart_0 = ring_mesh.m_edge_parts[ n0 < n1 ? n0 : n1 ]; - Part * const epart_1 = ring_mesh.m_edge_parts[ n0 < n1 ? n1 : n0 ]; - - Entity * const node = bulk.get_entity( 0 , ring_mesh.m_node_ids[n] ); - STKUNIT_ASSERT( node != NULL ); - if ( node->owner_rank() == p_rank ) { - STKUNIT_ASSERT( node->bucket().member( part_univ ) ); - STKUNIT_ASSERT( node->bucket().member( part_owns ) ); - STKUNIT_ASSERT( node->bucket().member( *epart_0 ) ); - STKUNIT_ASSERT( node->bucket().member( *epart_1 ) ); - } - else { - STKUNIT_ASSERT( node->bucket().member( part_univ ) ); - STKUNIT_ASSERT( ! node->bucket().member( part_owns ) ); - STKUNIT_ASSERT( node->bucket().member( * epart_0 ) ); - STKUNIT_ASSERT( node->bucket().member( * epart_1 ) ); - } - } - - bulk.modification_begin(); - - // On rank 0, change all locally owned edges to the extra-part then check - // for correct part membership - if ( 0 == p_rank ) { - for ( unsigned i = 0 ; i < nLocalEdge ; ++i ) { - const unsigned n = i + nPerProc * p_rank ; - - PartVector add(1); add[0] = & ring_mesh.m_edge_part_extra ; - PartVector rem(1); rem[0] = ring_mesh.m_edge_parts[ n % ring_mesh.m_edge_parts.size() ]; - - Entity * const edge = bulk.get_entity( 1 , ring_mesh.m_edge_ids[n] ); - bulk.change_entity_parts( *edge , add , rem ); - STKUNIT_ASSERT( edge->bucket().member( part_univ ) ); - STKUNIT_ASSERT( edge->bucket().member( part_owns ) ); - STKUNIT_ASSERT( edge->bucket().member(ring_mesh.m_edge_part_extra ) ); - } - } - - bulk.modification_end(); - - // Modification end has been called, check that the part changes made - // in the previous step are reflected across the other procs. - for ( unsigned i = 0 ; i < nLocalNode ; ++i ) { - const unsigned n = ( i + nPerProc * p_rank ) % ring_mesh.m_node_ids.size(); - const unsigned e0 = n ; - const unsigned e1 = ( n + ring_mesh.m_edge_ids.size() - 1 ) % ring_mesh.m_edge_ids.size(); - const unsigned ns = ring_mesh.m_edge_parts.size(); - const unsigned n0 = e0 % ns ; - const unsigned n1 = e1 % ns ; - Part * ep_0 = e0 < nLocalEdge ? & ring_mesh.m_edge_part_extra : ring_mesh.m_edge_parts[n0] ; - Part * ep_1 = e1 < nLocalEdge ? & ring_mesh.m_edge_part_extra : ring_mesh.m_edge_parts[n1] ; - - Part * epart_0 = ep_0->mesh_meta_data_ordinal() < ep_1->mesh_meta_data_ordinal() ? ep_0 : ep_1 ; - Part * epart_1 = ep_0->mesh_meta_data_ordinal() < ep_1->mesh_meta_data_ordinal() ? ep_1 : ep_0 ; - - Entity * const node = bulk.get_entity( 0 , ring_mesh.m_node_ids[n] ); - STKUNIT_ASSERT( node != NULL ); - if ( node->owner_rank() == p_rank ) { - STKUNIT_ASSERT( node->bucket().member( part_owns ) ); - } - else { - STKUNIT_ASSERT( ! node->bucket().member( part_owns ) ); - } - - STKUNIT_ASSERT( node->bucket().member( part_univ ) ); - STKUNIT_ASSERT( node->bucket().member( *epart_0 ) ); - STKUNIT_ASSERT( node->bucket().member( *epart_1 ) ); - } -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_Destroy.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_Destroy.cpp deleted file mode 100644 index b537f548264f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_Destroy.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include -#include -#include - -#include - -#include - -using stk_classic::mesh::Part; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Entity; -using stk_classic::mesh::Selector; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::fixtures::RingFixture; - -//---------------------------------------------------------------------- -// Testing for mesh entities without relations - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testDestroy_nodes) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - enum { nPerProc = 10 }; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - - const int spatial_dimension = 3; - MetaData meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - - const PartVector no_parts ; - - meta.commit(); - - BulkData bulk( meta , pm , 100 ); - - // Ids for all entities (all entities have type 0): - - std::vector ids( id_total ); - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - ids[i] = i + 1; - } - - // Declare just those entities in my range of ids: - - STKUNIT_ASSERT( bulk.modification_begin() ); - for ( unsigned i = id_begin ; i < id_end ; ++i ) { - bulk.declare_entity( 0 , ids[i] , no_parts ); - } - STKUNIT_ASSERT( bulk.modification_end() ); - - // Verify that I only have entities in my range: - - for ( unsigned i = 0 ; i < id_total ; ++i ) { - Entity * e = bulk.get_entity( 0 , ids[ i ] ); - if ( id_begin <= i && i < id_end ) { - STKUNIT_ASSERT( NULL != e ); - STKUNIT_ASSERT( p_rank == e->owner_rank() ); - } - else { - STKUNIT_ASSERT( NULL == e ); - } - } - - // Delete one entity at a time. - - for ( unsigned i = id_begin ; i < id_end ; ++i ) { - Entity * e = bulk.get_entity( 0 , ids[ i ] ); - - STKUNIT_ASSERT( NULL != e ); - - bulk.modification_begin(); - STKUNIT_ASSERT( bulk.destroy_entity( e ) ); - bulk.modification_end(); - - // Due to change logging the previously deleted entity - // should be gone, but the currently deleted entity - // should exist in the 'nil' set. - - if ( id_begin < i ) { - STKUNIT_ASSERT( NULL == bulk.get_entity( 0 , ids[ i - 1 ] ) ); - } - - e = bulk.get_entity( 0 , ids[ i ] ); - STKUNIT_ASSERT( NULL != e ); - STKUNIT_ASSERT( 0 == e->bucket().capacity() ); - } -} - -//---------------------------------------------------------------------- - -void assert_is_destroyed( const Entity * const entity ) -{ - STKUNIT_ASSERT( entity == NULL || entity->bucket().capacity() == 0 ); -} - -STKUNIT_UNIT_TEST(UnitTestingOfBulkData, testDestory_ring) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - enum { nPerProc = 10 }; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - // const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 ); - const unsigned nLocalEdge = nPerProc ; - - const int spatial_dimension = 3; - MetaData meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - - meta.commit(); - - Selector select_owned( meta.locally_owned_part() ); - Selector select_used = meta.locally_owned_part() | meta.globally_shared_part(); - Selector select_all( meta.universal_part() ); - - PartVector no_parts ; - - std::vector local_count ; - - //------------------------------ - { // No ghosting - const bool aura_flag = false ; - - RingFixture mesh( pm , nPerProc , false /* No edge parts */ ); - mesh.m_meta_data.commit(); - BulkData& bulk = mesh.m_bulk_data; - - bulk.modification_begin(); - mesh.generate_mesh( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, - false /*no aura*/)); - - bulk.modification_begin(); - mesh.fixup_node_ownership(); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(bulk, - false /*no aura*/)); - - // This process' first element in the loop - // if a parallel mesh has a shared node - Entity * edge = bulk.get_entity( 1 , mesh.m_edge_ids[ nLocalEdge * p_rank ] ); - Entity * node0 = edge->relations()[0].entity(); - Entity * node1 = edge->relations()[1].entity(); - - const size_t node0_edges = node0->relations().size(); - const size_t node1_edges = node1->relations().size(); - - STKUNIT_ASSERT( 1 <= node0_edges && node0_edges <= 2 ); - STKUNIT_ASSERT( 1 <= node1_edges && node1_edges <= 2 ); - - STKUNIT_ASSERT( node0->relations()[0].entity() == edge || - node0->relations()[1].entity() == edge ); - - STKUNIT_ASSERT( node1->relations()[0].entity() == edge || - node1->relations()[1].entity() == edge ); - - bulk.modification_begin(); - - // Destroy the element: - bool result = bulk.destroy_entity( edge ); - STKUNIT_ASSERT( true == result ); - STKUNIT_ASSERT( NULL == edge ); - - // Destroy orphanned node: - if ( node0->relations().size() == 0 ) { - STKUNIT_ASSERT( bulk.destroy_entity( node0 ) ); - STKUNIT_ASSERT( NULL == node0 ); - } - if ( node1->relations().size() == 0 ) { - STKUNIT_ASSERT( bulk.destroy_entity( node1 ) ); - STKUNIT_ASSERT( NULL == node1 ); - } - STKUNIT_ASSERT( stk_classic::unit_test::modification_end_wrapper(bulk, aura_flag) ); - - if ( NULL != node0 ) { - STKUNIT_ASSERT_EQUAL( node0_edges - 1 , node0->relations().size() ); - } - if ( NULL != node1 ) { - STKUNIT_ASSERT_EQUAL( node1_edges - 1 , node1->relations().size() ); - } - } - //------------------------------ - if ( 1 < p_size ) { // With ghosting - RingFixture mesh( pm , nPerProc , false /* No edge parts */ ); - mesh.m_meta_data.commit(); - BulkData& bulk = mesh.m_bulk_data; - - bulk.modification_begin(); - mesh.generate_mesh( ); - STKUNIT_ASSERT( bulk.modification_end() ); - - bulk.modification_begin(); - mesh.fixup_node_ownership(); - STKUNIT_ASSERT( bulk.modification_end() ); - - const unsigned nNotOwned = nPerProc * p_rank ; - - // The not-owned shared entity: - Entity * node = bulk.get_entity( 0 , mesh.m_node_ids[ nNotOwned ] ); - - STKUNIT_ASSERT( node != NULL ); - STKUNIT_ASSERT_NE( p_rank , node->owner_rank() ); - STKUNIT_ASSERT_EQUAL( size_t(1) , node->sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(2) , node->relations().size() ); - - EntityId node_edge_ids[2] ; - node_edge_ids[0] = node->relations()[0].entity()->identifier(); - node_edge_ids[1] = node->relations()[1].entity()->identifier(); - - bulk.modification_begin(); - - // This process' first node in the loop is shared, destroy it - // First have to destroy attached edges. - // One will be owned and the other ghosted - - while ( node->relations().size() ) { - Entity * e = node->relations().back().entity(); - STKUNIT_ASSERT( bulk.destroy_entity( e ) ); - } - STKUNIT_ASSERT( bulk.destroy_entity( node ) ); - - STKUNIT_ASSERT( bulk.modification_end() ); - - assert_is_destroyed( bulk.get_entity(0, mesh.m_node_ids[nNotOwned] ) ); - assert_is_destroyed( bulk.get_entity(1, node_edge_ids[0] ) ); - assert_is_destroyed( bulk.get_entity(1, node_edge_ids[1] ) ); - - // assert that no entities are shared or ghosted - STKUNIT_ASSERT( bulk.entity_comm().empty() ); - } - //------------------------------ - if ( 1 < p_size ) { // With ghosting - RingFixture mesh( pm , nPerProc , false /* No edge parts */ ); - mesh.m_meta_data.commit(); - BulkData& bulk = mesh.m_bulk_data; - - bulk.modification_begin(); - mesh.generate_mesh( ); - STKUNIT_ASSERT( bulk.modification_end() ); - - bulk.modification_begin(); - mesh.fixup_node_ownership(); - STKUNIT_ASSERT( bulk.modification_end() ); - - // The owned shared entity: - const unsigned nOwned = ( nPerProc * ( p_rank + 1 ) ) % mesh.m_node_ids.size(); - const unsigned nNotOwned = nPerProc * p_rank ; - - Entity * node_owned = bulk.get_entity( 0 , mesh.m_node_ids[ nOwned ] ); - Entity * node_not_owned = bulk.get_entity( 0 , mesh.m_node_ids[ nNotOwned ] ); - - STKUNIT_ASSERT( node_owned != NULL ); - STKUNIT_ASSERT( node_not_owned != NULL ); - STKUNIT_ASSERT_NE( p_rank , node_not_owned->owner_rank() ); - STKUNIT_ASSERT_EQUAL( p_rank , node_owned->owner_rank() ); - STKUNIT_ASSERT_EQUAL( size_t(1) , node_owned->sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(1) , node_not_owned->sharing().size() ); - STKUNIT_ASSERT_EQUAL( size_t(2) , node_owned->relations().size() ); - - EntityId node_edge_ids[2] ; - node_edge_ids[0] = node_owned->relations()[0].entity()->identifier(); - node_edge_ids[1] = node_owned->relations()[1].entity()->identifier(); - - bulk.modification_begin(); - - // This process' first node in the loop is shared, destroy it - // First have to destroy attached edges. - // One will be owned and the other ghosted - - while ( node_owned->relations().size() ) { - Entity * e = node_owned->relations().back().entity(); - STKUNIT_ASSERT( bulk.destroy_entity( e ) ); - } - STKUNIT_ASSERT( bulk.destroy_entity( node_owned ) ); - - STKUNIT_ASSERT( bulk.modification_end() ); - - // Ownership of the other process' owned, shared, and destroyed node - // has been transferred to this process. - - STKUNIT_ASSERT_EQUAL( p_rank , node_not_owned->owner_rank() ); - assert_is_destroyed( bulk.get_entity(0, mesh.m_node_ids[ nOwned ] ) ); - assert_is_destroyed( bulk.get_entity(1, node_edge_ids[0] ) ); - assert_is_destroyed( bulk.get_entity(1, node_edge_ids[1] ) ); - - // assert that no entities are shared or ghosted - STKUNIT_ASSERT( bulk.entity_comm().empty() ); - } -} - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_new.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_new.cpp deleted file mode 100644 index 8811ca1996d3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkData_new.cpp +++ /dev/null @@ -1,1112 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -using stk_classic::mesh::Part; - -// UnitTestBulkData_new is the beginnings of a refactoring of the bulk -// data unit test. It relies on a customized BoxFixture to rapidly -// create a mesh for testing. - -namespace { - -void new_insert_transitive_closure( std::set & , - const stk_classic::mesh::EntityProc & entry ); -void new_comm_sync_send_recv( - stk_classic::mesh::BulkData & mesh , - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send , - std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv ); - -void new_comm_recv_to_send( - stk_classic::mesh::BulkData & mesh , - const std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv , - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send ); - -/** - * The customized box fixture used in this file for testing. This fixture - * is similar to the BoxFixture it inherits from, with the only difference - * being the extra parts that this fixture declares for testing purposes. - */ -class TestBoxFixture : public stk_classic::mesh::fixtures::BoxFixture -{ - public: - TestBoxFixture(stk_classic::ParallelMachine pm = MPI_COMM_WORLD, - unsigned block_size = 1000) : - BoxFixture(pm, block_size), - m_test_part ( m_fem_meta.declare_part ( "Test Part" ) ), - m_cell_part ( m_fem_meta.declare_part ( "Cell list" , 3 /*max rank*/ ) ), - m_part_A_0 ( m_fem_meta.declare_part ( "Part A 0", 0 ) ), - m_part_A_1 ( m_fem_meta.declare_part ( "Part A 1", 1 ) ), - m_part_A_2 ( m_fem_meta.declare_part ( "Part A 2", 2 ) ), - m_part_A_3 ( m_fem_meta.declare_part ( "Part A 3", 3 ) ), - m_part_A_superset ( m_fem_meta.declare_part ( "Part A superset" ) ), - m_part_B_0 ( m_fem_meta.declare_part ( "Part B 0", 0 ) ), - m_part_B_1 ( m_fem_meta.declare_part ( "Part B 1", 1 ) ), - m_part_B_2 ( m_fem_meta.declare_part ( "Part B 2", 2 ) ), - m_part_B_3 ( m_fem_meta.declare_part ( "Part B 3", 3 ) ), - m_part_B_superset ( m_fem_meta.declare_part ( "Part B superset" ) ) - { - m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_0 ); - m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_1 ); - m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_2 ); - m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_3 ); - - m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_0 ); - m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_1 ); - m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_2 ); - m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_3 ); - - // None of the tests currently need to make any addtional changes - // to MetaData; if this changes, the line below will have to be - // removed. - m_fem_meta.commit(); - } - - Part & get_test_part () { return m_test_part; } - Part & get_cell_part () { return m_cell_part; } - - Part & get_part_a_0 () { return m_part_A_0; } - Part & get_part_a_1 () { return m_part_A_1; } - Part & get_part_a_2 () { return m_part_A_2; } - Part & get_part_a_3 () { return m_part_A_3; } - - Part & get_part_a_superset () { return m_part_A_superset; } - - Part & get_part_b_0 () { return m_part_B_0; } - Part & get_part_b_1 () { return m_part_B_1; } - Part & get_part_b_2 () { return m_part_B_2; } - Part & get_part_b_3 () { return m_part_B_3; } - - Part & get_part_b_superset () { return m_part_B_superset; } - - private: - Part & m_test_part; // A simple part - Part & m_cell_part; // A part to put cells in - - Part & m_part_A_0; - Part & m_part_A_1; - Part & m_part_A_2; - Part & m_part_A_3; - - Part & m_part_A_superset; - - Part & m_part_B_0; - Part & m_part_B_1; - Part & m_part_B_2; - Part & m_part_B_3; - - Part & m_part_B_superset; -}; - -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyAssertOwnerDeletedEntity ) -{ - TestBoxFixture fixture; - - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - stk_classic::mesh::Part &new_part = fixture.get_test_part (); - stk_classic::mesh::PartVector add_part; - add_part.push_back ( &new_part ); - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - // Find a cell owned by this process - stk_classic::mesh::Entity *cell_to_delete = NULL; - stk_classic::mesh::Entity *cell_to_delete_copy = NULL; - std::vector::const_iterator cur_bucket = bulk.buckets(3).begin(); - while ( cur_bucket != bulk.buckets(3).end() ) - { - stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin(); - while ( cur_entity != (*cur_bucket)->end() ) - { - if ( cur_entity->owner_rank() == fixture.comm_rank() ) - { - cell_to_delete = &*cur_entity; - break; - } - ++cur_entity; - } - ++cur_bucket; - } - - STKUNIT_ASSERT ( cell_to_delete != NULL ); - cell_to_delete_copy = cell_to_delete; - bulk.modification_begin(); - bulk.destroy_entity ( cell_to_delete ); - // Destroying an already destroyed entity returns false - STKUNIT_ASSERT( false == bulk.destroy_entity( cell_to_delete_copy ) ); - bulk.modification_end(); -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDetectsBadKey ) -{ - TestBoxFixture fixture; - - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - stk_classic::mesh::Part &new_part = fixture.get_test_part (); - stk_classic::mesh::PartVector add_part, empty_vector; - add_part.push_back ( &new_part ); - - stk_classic::mesh::EntityKey bad_key1 ( 45 , 1 ); // Bad entity rank - stk_classic::mesh::EntityKey bad_key2 ( 1 , 0 ); // Bad id - - STKUNIT_ASSERT_THROW ( bulk.declare_entity(bad_key1.rank(), - bad_key1.id(), - empty_vector), - std::logic_error ); - STKUNIT_ASSERT_THROW ( bulk.declare_entity(bad_key2.rank(), - bad_key2.id(), - empty_vector), - std::logic_error ); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDetectsNonOwnerChange ) -{ - // Set up a mesh where there are shared nodes. Take one of the nodes, and - // have the non-owning processes try to make a change to that node; this - // should cause an exception. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - unsigned p_size = stk_classic::parallel_machine_size(pm); - unsigned p_rank = stk_classic::parallel_machine_rank(pm); - - stk_classic::mesh::fixtures::QuadFixture fixture(pm, 1 /*nx*/, p_size /*ny*/); - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - stk_classic::mesh::BulkData & bulk = fixture.m_bulk_data; - - stk_classic::mesh::PartVector empty_vector; - - stk_classic::mesh::Entity* shared_node = fixture.node(1 /*x*/, 1 /*y*/); - // Assert that this node is shared - if ( p_size > 1 && shared_node && (p_rank == 0 || p_rank == 1) ) { - STKUNIT_ASSERT_GE(shared_node->sharing().size(), 1u); - } - - bulk.modification_begin(); - - // Non-owners of shared_node will attempt to make a change to it; this should - // cause an exception - if (shared_node && p_rank != shared_node->owner_rank()) { - STKUNIT_ASSERT_THROW(bulk.change_entity_parts(*shared_node, - empty_vector, //add parts - empty_vector), //rem parts - std::logic_error); - } - - bulk.modification_end(); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyGetEntityGuards ) -{ - TestBoxFixture fixture; - - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - STKUNIT_ASSERT_THROW ( bulk.get_entity ( 1 , 0 ) , std::logic_error ); -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyExplicitAddInducedPart ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - stk_classic::mesh::PartVector empty_vector; - stk_classic::mesh::PartVector cell_part_vector; - - bulk.modification_begin(); - - stk_classic::mesh::Entity &new_cell = bulk.declare_entity ( 3 , fixture.comm_rank()+1 , empty_vector ); - stk_classic::mesh::Entity &new_node = bulk.declare_entity ( 0 , fixture.comm_rank()+1 , empty_vector ); - - bulk.declare_relation ( new_cell , new_node , 1 ); - - cell_part_vector.push_back ( &fixture.get_cell_part () ); - bulk.change_entity_parts ( new_cell , cell_part_vector ); -#ifdef SIERRA_MIGRATION - bulk.change_entity_parts ( new_node , cell_part_vector ); -#else - STKUNIT_ASSERT_THROW ( bulk.change_entity_parts ( new_node , cell_part_vector ) , std::runtime_error ); -#endif -} - -/************************ - * This unit test is not possible currently because of the lack of - * separation between internal part modification routines and public - * part modification routines. -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyCannotRemoveFromSpecialParts ) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - stk_classic::mesh::PartVector test_parts; - stk_classic::mesh::PartVector out_parts; - stk_classic::mesh::PartVector empty_vector; - - stk_classic::mesh::Entity &new_cell = bulk.declare_entity ( 3 , fixture.comm_rank()+1 , empty_vector ); - test_parts.push_back ( &fixture.fem_meta().universal_part() ); - STKUNIT_ASSERT_THROW ( bulk.change_entity_parts ( new_cell , empty_vector , test_parts ) , std::runtime_error ); - test_parts.clear(); - test_parts.push_back ( &fixture.fem_meta().locally_owned_part() ); - STKUNIT_ASSERT_THROW ( bulk.change_entity_parts ( new_cell , empty_vector , test_parts ) , std::runtime_error ); - test_parts.clear(); - test_parts.push_back ( &fixture.fem_meta().globally_shared_part() ); - STKUNIT_ASSERT_THROW ( bulk.change_entity_parts ( new_cell , empty_vector , test_parts ) , std::runtime_error ); -} - */ - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDefaultPartAddition ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - - bulk.modification_begin(); - stk_classic::mesh::Entity &new_cell = fixture.get_new_entity ( 3 , 1 ); - bulk.modification_end(); - - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.fem_meta().universal_part() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.fem_meta().locally_owned_part() ) ); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyChangePartsSerial ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - stk_classic::mesh::PartVector create_parts , remove_parts , add_parts, empty_parts; - - create_parts.push_back ( &fixture.get_test_part() ); - create_parts.push_back ( &fixture.get_part_a_3() ); - remove_parts.push_back ( &fixture.get_part_a_3() ); - add_parts.push_back ( &fixture.get_part_b_superset() ); - add_parts.push_back ( &fixture.get_cell_part() ); - - bulk.modification_begin(); - stk_classic::mesh::Entity &new_cell = fixture.get_new_entity ( 3 , 1 ); - bulk.change_entity_parts ( new_cell , create_parts , empty_parts ); - bulk.modification_end(); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_test_part() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_part_a_3() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_part_a_superset() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_part_b_superset() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_cell_part() ) ); - - bulk.modification_begin(); - bulk.change_entity_parts ( new_cell , add_parts , remove_parts ); - bulk.modification_end(); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_test_part() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_part_a_3() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_part_a_superset() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_part_b_superset() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_cell_part() ) ); - - bulk.modification_begin(); - bulk.change_entity_parts ( new_cell , empty_parts , add_parts ); - bulk.modification_end(); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_test_part() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_part_a_3() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.get_part_a_superset() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_part_b_superset() ) ); - STKUNIT_ASSERT ( !new_cell.bucket().member ( fixture.get_cell_part() ) ); - - //Verify still a member of default parts - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.fem_meta().universal_part() ) ); - STKUNIT_ASSERT ( new_cell.bucket().member ( fixture.fem_meta().locally_owned_part() ) ); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyParallelAddParts ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - stk_classic::mesh::PartVector add_part; - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - add_part.push_back ( &fixture.get_part_a_0() ); - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - - for ( std::vector::const_iterator - cur_entity = bulk.entity_comm().begin(); - cur_entity != bulk.entity_comm().end() ; ++cur_entity ) { - stk_classic::mesh::Entity & entity = **cur_entity ; - if ( entity.entity_rank() == 0 ) { - if ( entity.owner_rank() == fixture.comm_rank() ) { - bulk.change_entity_parts ( entity, add_part, stk_classic::mesh::PartVector() ); - } - } - } - - bulk.modification_end(); - - for ( std::vector::const_iterator - cur_entity = bulk.entity_comm().begin(); - cur_entity != bulk.entity_comm().end() ; ++cur_entity ) { - stk_classic::mesh::Entity & entity = **cur_entity ; - if ( entity.entity_rank() == 0 ) { - STKUNIT_ASSERT ( entity.bucket().member ( fixture.get_part_a_0 () ) ); - } - } -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyInducedMembership ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - stk_classic::mesh::PartVector create_node_parts , create_cell_parts , empty_parts; - - create_node_parts.push_back ( &fixture.get_part_a_0() ); - create_cell_parts.push_back ( &fixture.get_cell_part() ); - - bulk.modification_begin(); - - stk_classic::mesh::Entity &node = fixture.get_new_entity ( 0 , 1 ); - stk_classic::mesh::Entity &cell = fixture.get_new_entity ( 3 , 1 ); - - bulk.modification_begin(); - - bulk.change_entity_parts ( node , create_node_parts , stk_classic::mesh::PartVector () ); - bulk.change_entity_parts ( cell , create_cell_parts , stk_classic::mesh::PartVector () ); - // Add node to cell part - stk_classic::mesh::RelationIdentifier cell_node_rel_id = 0; - bulk.declare_relation ( cell , node , cell_node_rel_id ); - bulk.modification_end(); - - STKUNIT_ASSERT ( node.bucket().member ( fixture.get_cell_part() ) ); - - bulk.modification_begin(); - bulk.destroy_relation ( cell , node, cell_node_rel_id ); - bulk.modification_end(); - - STKUNIT_ASSERT ( !node.bucket().member ( fixture.get_cell_part() ) ); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyCanRemoveFromSetWithDifferentRankSubset ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - stk_classic::mesh::PartVector add_parts , remove_parts, empty_parts; - - add_parts.push_back ( &fixture.get_part_b_3() ); - add_parts.push_back ( &fixture.get_part_a_superset() ); - - remove_parts.push_back ( &fixture.get_part_a_superset() ); - - bulk.modification_begin(); - - stk_classic::mesh::Entity &e = bulk.declare_entity ( 3 , fixture.comm_rank()+1 , add_parts ); - bulk.modification_end(); - - bulk.modification_begin(); - bulk.change_entity_parts ( e , empty_parts , remove_parts ); - bulk.modification_end(); - - STKUNIT_ASSERT ( e.bucket().member ( fixture.get_part_b_3() ) ); - STKUNIT_ASSERT ( !e.bucket().member ( fixture.get_part_a_superset() ) ); -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyCommonGhostingName ) -{ - - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - - bulk.modification_begin(); - - if ( fixture.comm_size() == 1 ) return; - - if ( fixture.comm_rank() == 0 ) - { - STKUNIT_ASSERT_THROW ( bulk.create_ghosting ( "Name 1" ) , std::runtime_error ); - } - else - { - STKUNIT_ASSERT_THROW ( bulk.create_ghosting ( "Name 2" ) , std::runtime_error ); - } -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyTrivialDestroyAllGhostings ) -{ - TestBoxFixture fixture; - - if ( fixture.comm_size() == 1 ) return; - - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - - stk_classic::mesh::Ghosting &ghosting = bulk.create_ghosting ( "Ghost 1" ); - - // Find a cell owned by this process - std::vector::const_iterator cur_bucket = bulk.buckets(3).begin(); - unsigned send_rank = 0; - - std::vector to_send; - std::vector empty_vector; - while ( cur_bucket != bulk.buckets(3).end() ) - { - stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin(); - while ( cur_entity != (*cur_bucket)->end() ) - { - if ( cur_entity->owner_rank() == fixture.comm_rank() ) - { - if ( send_rank == fixture.comm_size() ) send_rank = 0; - if ( send_rank != fixture.comm_rank() ) - to_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) ); - send_rank++; - } - ++cur_entity; - } - ++cur_bucket; - } - bulk.change_ghosting ( ghosting , to_send , empty_vector ); - bulk.modification_end(); - - - { - std::vector send_list ; - std::vector recv_list ; - ghosting.send_list( send_list ); - ghosting.receive_list( recv_list ); - - STKUNIT_ASSERT ( ! send_list.empty() ); - STKUNIT_ASSERT ( ! recv_list.empty() ); - } - - // Usage of operator << in Ghosting.cpp - std::ostringstream oss; - oss << ghosting; - - bulk.modification_begin(); - bulk.destroy_all_ghosting (); - bulk.modification_end(); - - { - std::vector send_list ; - std::vector recv_list ; - ghosting.send_list( send_list ); - ghosting.receive_list( recv_list ); - - STKUNIT_ASSERT ( send_list.empty() ); - STKUNIT_ASSERT ( recv_list.empty() ); - } -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyChangeGhostingGuards ) -{ - TestBoxFixture fixture1, fixture2; - stk_classic::mesh::BulkData & bulk1 = fixture1.bulk_data (); - stk_classic::mesh::BulkData & bulk2 = fixture2.bulk_data (); - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - int local_box1[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - int local_box2[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk1.modification_begin(); - fixture1.generate_boxes( root_box, local_box1 ); - STKUNIT_ASSERT(bulk1.modification_end()); - - bulk2.modification_begin(); - fixture2.generate_boxes( root_box, local_box2 ); - STKUNIT_ASSERT(bulk2.modification_end()); - - bulk1.modification_begin(); - bulk2.modification_begin(); - - std::vector to_send; - std::vector empty_vector; - std::vector::const_iterator cur_bucket = bulk1.buckets(3).begin(); - unsigned send_rank = 0; - while ( cur_bucket != bulk1.buckets(3).end() ) - { - stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin(); - while ( cur_entity != (*cur_bucket)->end() ) - { - if ( cur_entity->owner_rank() == fixture1.comm_rank() ) - { - if ( send_rank == fixture1.comm_size() ) send_rank = 0; - if ( send_rank != fixture1.comm_rank() ) - to_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) ); - ++send_rank; - } - ++cur_entity; - } - ++cur_bucket; - } - - stk_classic::mesh::Ghosting &ghosting = bulk1.create_ghosting ( "Ghost 1" ); - STKUNIT_ASSERT_THROW ( bulk2.change_ghosting ( ghosting , to_send , empty_vector ) , std::runtime_error ); - STKUNIT_ASSERT_THROW ( bulk1.change_ghosting ( bulk1.shared_aura() , to_send , empty_vector ) , std::runtime_error ); - - ghosting.receive_list(empty_vector); - ghosting.send_list(to_send); - - bulk1.modification_end(); - bulk2.modification_end(); -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyOtherGhostingGuards ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data (); - - const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } }; - int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - bulk.modification_begin(); - fixture.generate_boxes( root_box, local_box ); - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - - std::vector to_send_unowned; - std::vector empty_send; - std::vector to_remove_not_ghosted; - std::vector empty_remove; - std::vector::const_iterator cur_bucket = bulk.buckets(3).begin(); - unsigned send_rank = 0; - while ( cur_bucket != bulk.buckets(3).end() ) - { - stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin(); - while ( cur_entity != (*cur_bucket)->end() ) - { - if ( cur_entity->owner_rank() != fixture.comm_rank() ) - { - if ( send_rank == fixture.comm_size() ) send_rank = 0; - if ( send_rank != fixture.comm_rank() ) - to_send_unowned.push_back ( std::make_pair ( &*cur_entity , send_rank ) ); - ++send_rank; - } - else - { - to_remove_not_ghosted.push_back ( &*cur_entity ); - } - ++cur_entity; - } - ++cur_bucket; - } - - stk_classic::mesh::Ghosting &ghosting = bulk.create_ghosting ( "Ghost 1" ); - if ( to_send_unowned.size() > 0 ) - { - STKUNIT_ASSERT_THROW ( bulk.change_ghosting ( ghosting , to_send_unowned , empty_remove ) , std::runtime_error ); - } - else - { - bulk.change_ghosting ( ghosting , to_send_unowned , empty_remove ); - } - - if ( to_remove_not_ghosted.size() > 0 ) - { - STKUNIT_ASSERT_THROW ( bulk.change_ghosting ( ghosting , empty_send , to_remove_not_ghosted ) , std::runtime_error ); - } - else - { - bulk.change_ghosting ( ghosting , empty_send , to_remove_not_ghosted ); - } - bulk.modification_end(); -} - - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyPartsOnCreate ) -{ - TestBoxFixture fixture; - stk_classic::mesh::BulkData & bulk = fixture.bulk_data (); - stk_classic::mesh::Part & part_a = fixture.get_part_a_0 (); - stk_classic::mesh::Part & part_b = fixture.get_part_b_0 (); - - stk_classic::mesh::PartVector create_vector; - create_vector.push_back ( &part_a ); - - bulk.modification_begin(); - - stk_classic::mesh::Entity &node = bulk.declare_entity ( 0 , fixture.comm_rank()+1 ,create_vector ); - bulk.modification_end(); - - STKUNIT_ASSERT ( node.bucket().member ( part_a ) ); - - bulk.modification_begin(); - create_vector.push_back ( &part_b ); - stk_classic::mesh::Entity &node2 = bulk.declare_entity ( 0 , fixture.comm_size() + fixture.comm_rank() + 1 , create_vector ); - bulk.modification_end(); - - STKUNIT_ASSERT ( node2.bucket().member ( part_a ) ); - STKUNIT_ASSERT ( node2.bucket().member ( part_b ) ); -} - -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyBoxGhosting ) -{ - const unsigned p_size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - if ( 8 < p_size ) { return ; } - - stk_classic::mesh::fixtures::HexFixture fixture( MPI_COMM_WORLD, 2, 2, 2 ); - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - for ( size_t iz = 0 ; iz < 3 ; ++iz ) { - for ( size_t iy = 0 ; iy < 3 ; ++iy ) { - for ( size_t ix = 0 ; ix < 3 ; ++ix ) { - stk_classic::mesh::Entity * const node = fixture.node(ix,iy,iz); - STKUNIT_ASSERT( NULL != node ); - - STKUNIT_ASSERT( fixture.node_id(ix,iy,iz) == node->identifier() ); - stk_classic::mesh::fixtures::HexFixture::Scalar * const node_coord = - stk_classic::mesh::field_data( fixture.m_coord_field , *node ); - STKUNIT_ASSERT( node_coord != NULL ); - } - } - } - - for ( size_t iz = 0 ; iz < 2 ; ++iz ) { - for ( size_t iy = 0 ; iy < 2 ; ++iy ) { - for ( size_t ix = 0 ; ix < 2 ; ++ix ) { - stk_classic::mesh::Entity * const elem = fixture.elem(ix,iy,iz); - STKUNIT_ASSERT( NULL != elem ); - - stk_classic::mesh::PairIterRelation elem_nodes = elem->relations(); - STKUNIT_ASSERT_EQUAL( 8u , elem_nodes.size() ); - stk_classic::mesh::fixtures::HexFixture::Scalar ** const elem_node_coord = - stk_classic::mesh::field_data( fixture.m_coord_gather_field , *elem ); - for ( size_t j = 0 ; j < elem_nodes.size() ; ++j ) { - STKUNIT_ASSERT_EQUAL( j , elem_nodes[j].identifier() ); - stk_classic::mesh::fixtures::HexFixture::Scalar * const node_coord = - stk_classic::mesh::field_data( fixture.m_coord_field , *elem_nodes[j].entity() ); - STKUNIT_ASSERT( node_coord == elem_node_coord[ elem_nodes[j].identifier() ] ); - } - if ( 8u == elem_nodes.size() ) { - STKUNIT_ASSERT( elem_nodes[0].entity() == fixture.node(ix,iy,iz)); - STKUNIT_ASSERT( elem_nodes[1].entity() == fixture.node(ix+1,iy,iz)); - STKUNIT_ASSERT( elem_nodes[2].entity() == fixture.node(ix+1,iy,iz+1)); - STKUNIT_ASSERT( elem_nodes[3].entity() == fixture.node(ix,iy,iz+1)); - STKUNIT_ASSERT( elem_nodes[4].entity() == fixture.node(ix,iy+1,iz)); - STKUNIT_ASSERT( elem_nodes[5].entity() == fixture.node(ix+1,iy+1,iz)); - STKUNIT_ASSERT( elem_nodes[6].entity() == fixture.node(ix+1,iy+1,iz+1)); - STKUNIT_ASSERT( elem_nodes[7].entity() == fixture.node(ix,iy+1,iz+1)); - } - - } - } - } -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , testEntityComm ) -{ - //Test on unpack_field_values in EntityComm.cpp - //code based on ../base/BulkDataGhosting.cpp - //Create a simple mesh. Add nodes one element and some parts. - - const int spatial_dimension = 3; - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names ( spatial_dimension )); - - stk_classic::mesh::fem::CellTopology tet_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & part_a = fem_meta.declare_part( "block_a", tet_top ); - stk_classic::mesh::Part & part_b = fem_meta.declare_part( "block_b", tet_top ); - - stk_classic::mesh::fem::CellTopology node_top(shards::getCellTopologyData()); - stk_classic::mesh::Part & part_a_0 = fem_meta.declare_part( "block_a_0", node_top ); - - typedef stk_classic::mesh::Field ScalarFieldType; - - ScalarFieldType & volume = - fem_meta.declare_field < ScalarFieldType > ( "volume" , 4 ); - ScalarFieldType & temperature = - fem_meta.declare_field < ScalarFieldType > ( "temperature" , 4 ); - stk_classic::mesh::Part & universal = fem_meta.universal_part (); - put_field ( volume , 3 , universal ); - put_field ( temperature , 3 , universal ); - - fem_meta.commit(); - - stk_classic::mesh::PartVector create_vector; - stk_classic::mesh::PartVector empty_vector; - create_vector.push_back ( &part_a ); - create_vector.push_back ( &part_b ); - - stk_classic::mesh::MetaData & meta = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk ( meta , MPI_COMM_WORLD , 100 ); - - bulk.modification_begin(); - - stk_classic::mesh::Ghosting &ghosts = bulk.create_ghosting ( "Ghost 1" ); - - unsigned size2 = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - unsigned rank_count2 = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - int new_id2 = size2 + rank_count2; - - stk_classic::mesh::Entity &elem2 = bulk.declare_entity ( 3 , new_id2+1 ,create_vector ); - STKUNIT_ASSERT_EQUAL( elem2.bucket().member ( part_a ), true ); - - unsigned size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - unsigned rank_count = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - - int id_base = 0; - for ( id_base = 0 ; id_base < 99 ; ++id_base ) - { - int new_id = size * id_base + rank_count; - stk_classic::mesh::Entity &new_node = bulk.declare_entity( 0 , new_id+1 , empty_vector ); - STKUNIT_ASSERT_EQUAL( new_node.bucket().member ( part_a_0 ), false ); - } - - //Create a bucket of nodes for sending - - std::vector add_send; - - const std::vector & buckets = bulk.buckets( 0 ); - - std::vector::const_iterator cur_bucket; - - cur_bucket = buckets.begin(); - - unsigned send_rank = 0; - while ( cur_bucket != buckets.end() ) - { - stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin(); - while ( cur_entity != (*cur_bucket)->end() ) - { - if ( cur_entity->owner_rank() == rank_count ) - { - if ( send_rank == size ) send_rank = 0; - if ( send_rank != rank_count ) - add_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) ); - ++send_rank; - } - ++cur_entity; - } - ++cur_bucket; - } - - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > new_send ; - std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > new_recv ; - - // Keep the closure of the remaining received ghosts. - // Working from highest-to-lowest key (rank entity type) - // results in insertion of the transitive closure. - // Insertion will not invalidate the associative container's iterator. - - for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::iterator - i = new_recv.end() ; i != new_recv.begin() ; ) { - --i ; - - const unsigned erank = (*i)->entity_rank(); - - for ( stk_classic::mesh::PairIterRelation - irel = (*i)->relations(); ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < erank && - in_receive_ghost( ghosts , * irel->entity() ) ) { - new_recv.insert( irel->entity() ); - } - } - } - - // Initialize the new_send from the new_recv - new_comm_recv_to_send( bulk , new_recv , new_send ); - - //------------------------------------ - // Add the specified entities and their closure to the send ghosting - - for ( std::vector< stk_classic::mesh::EntityProc >::const_iterator - i = add_send.begin() ; i != add_send.end() ; ++i ) { - new_insert_transitive_closure( new_send , *i ); - } - - // Synchronize the send and receive list. - // If the send list contains a not-owned entity - // inform the owner and receiver to ad that entity - // to their ghost send and receive lists. - - new_comm_sync_send_recv( bulk , new_send , new_recv ); - - //------------------------------------ - // Push newly ghosted entities to the receivers and update the comm list. - // Unpacking must proceed in entity-rank order so that higher ranking - // entities that have relations to lower ranking entities will have - // the lower ranking entities unpacked first. The higher and lower - // ranking entities may be owned by different processes, - // as such unpacking must be performed in rank order. - - //Start of CommAll section: - { - stk_classic::CommAll comm( MPI_COMM_WORLD ); - - for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator - j = new_send.begin(); j != new_send.end() ; ++j ) { - stk_classic::mesh::Entity & entity = * j->first ; - if ( ! in_ghost( ghosts , entity , j->second ) ) { - // Not already being sent , must send it. - stk_classic::CommBuffer & buf = comm.send_buffer( j->second ); - buf.pack( entity.entity_rank() ); - stk_classic::mesh::pack_entity_info( buf , entity ); - stk_classic::mesh::pack_field_values( buf , entity ); - } - } - - comm.allocate_buffers( size / 4 ); - - for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator - j = new_send.begin(); j != new_send.end() ; ++j ) { - stk_classic::mesh::Entity & entity = * j->first ; - if ( ! in_ghost( ghosts , entity , j->second ) ) { - // Not already being sent , must send it. - stk_classic::CommBuffer & buf = comm.send_buffer( j->second ); - buf.pack( entity.entity_rank() ); - stk_classic::mesh::pack_entity_info( buf , entity ); - stk_classic::mesh::pack_field_values( buf , entity ); - - } - } - - comm.communicate(); - - std::ostringstream error_msg ; - - for ( unsigned rank = 0 ; rank < rank_count ; ++rank ) { - - for ( unsigned p = 0 ; p < size ; ++p ) { - - stk_classic::CommBuffer & buf = comm.recv_buffer(p); - - while ( buf.remaining() ) { - - // Only unpack if of the current entity rank. - // If not the current entity rank, break the iteration - // until a subsequent entity rank iteration. - { - unsigned this_rank = ~0u ; - buf.peek( this_rank ); - if ( this_rank != rank ) break ; - - buf.unpack( this_rank ); - } - - // FIXME for Carol; the code below did not work with -np 4 - //STKUNIT_ASSERT_EQUAL( stk_classic::mesh::unpack_field_values( buf , elem2 , error_msg ), false); - //std::cout << "Error message for unpack_field_values = " << error_msg.str() << std::endl ; - - } - } - - } - }//end of CommAll section - - bulk.modification_end (); -} - -STKUNIT_UNIT_TEST ( UnitTestBulkData_new , testUninitializedMetaData ) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - stk_classic::mesh::MetaData meta; // Construct, but do not initialize - stk_classic::mesh::BulkData bulk(meta, pm); - - meta.set_entity_rank_names(stk_classic::mesh::fem::entity_rank_names(2 /*spatial-dim*/)); - - meta.commit(); - - bulk.modification_begin(); - - STKUNIT_ASSERT_THROW( bulk.declare_entity(0, /*rank*/ - 1, /*id*/ - stk_classic::mesh::PartVector() ), - std::logic_error); -} - -namespace { - -void new_insert_transitive_closure( std::set & new_send , - const stk_classic::mesh::EntityProc & entry ) -{ - // Do not insert if I can determine that this entity is already - // owned or shared by the receiving processor. - - if ( entry.second != entry.first->owner_rank() && - ! in_shared( * entry.first , entry.second ) ) { - - std::pair< std::set::iterator , bool > - result = new_send.insert( entry ); - - if ( result.second ) { - // A new insertion, must also insert the closure - - const unsigned etype = entry.first->entity_rank(); - stk_classic::mesh::PairIterRelation irel = entry.first->relations(); - - for ( ; ! irel.empty() ; ++irel ) { - if ( irel->entity_rank() < etype ) { - stk_classic::mesh::EntityProc tmp( irel->entity() , entry.second ); - new_insert_transitive_closure( new_send , tmp ); - } - } - } - } -} - - -// Synchronize the send list to the receive list. - -void new_comm_sync_send_recv( - stk_classic::mesh::BulkData & mesh , - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send , - std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv ) -{ - const unsigned parallel_rank = mesh.parallel_rank(); - const unsigned parallel_size = mesh.parallel_size(); - - stk_classic::CommAll all( mesh.parallel() ); - - // Communication sizing: - - for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator - i = new_send.begin() ; i != new_send.end() ; ++i ) { - const unsigned owner = i->first->owner_rank(); - all.send_buffer( i->second ).skip(2); - if ( owner != parallel_rank ) { - all.send_buffer( owner ).skip(2); - } - } - - all.allocate_buffers( parallel_size / 4 , false /* Not symmetric */ ); - - // Communication packing (with message content comments): - for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator - i = new_send.begin() ; i != new_send.end() ; ) { - const unsigned owner = i->first->owner_rank(); - - // Inform receiver of ghosting, the receiver does not own - // and does not share this entity. - // The ghost either already exists or is a to-be-done new ghost. - // This status will be resolved on the final communication pass - // when new ghosts are packed and sent. - - const stk_classic::mesh::EntityKey &entity_key = i->first->key(); - const uint64_t &proc = i->second; - - all.send_buffer( i->second ).pack(entity_key).pack(proc); - - if ( owner != parallel_rank ) { - // I am not the owner of this entity. - // Inform the owner of this ghosting need. - all.send_buffer( owner ).pack(entity_key).pack(proc); - - // Erase it from my processor's ghosting responsibility: - // The iterator passed to the erase method will be invalidated. - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator jrem = i ; ++i ; - new_send.erase( jrem ); - } - else { - ++i ; - } - } - - all.communicate(); - - // Communication unpacking: - for ( unsigned p = 0 ; p < parallel_size ; ++p ) { - stk_classic::CommBuffer & buf = all.recv_buffer(p); - while ( buf.remaining() ) { - - stk_classic::mesh::EntityKey entity_key; - uint64_t proc(0); - - buf.unpack(entity_key).unpack(proc); - - stk_classic::mesh::Entity * const e = mesh.get_entity( entity_key ); - - if ( parallel_rank != proc ) { - // Receiving a ghosting need for an entity I own. - // Add it to my send list. - STKUNIT_ASSERT( e != NULL ); - stk_classic::mesh::EntityProc tmp( e , proc ); - new_send.insert( tmp ); - } - else if ( e != NULL ) { - // I am the receiver for this ghost. - // If I already have it add it to the receive list, - // otherwise don't worry about it - I will receive - // it in the final new-ghosting communication. - new_recv.insert( e ); - } - } - } -} - -void new_comm_recv_to_send( - stk_classic::mesh::BulkData & mesh , - const std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv , - std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send ) -{ - const unsigned parallel_size = mesh.parallel_size(); - - stk_classic::CommAll all( mesh.parallel() ); - - for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::const_iterator - i = new_recv.begin() ; i != new_recv.end() ; ++i ) { - const unsigned owner = (*i)->owner_rank(); - all.send_buffer( owner ).skip(1); - } - - all.allocate_buffers( parallel_size / 4 , false /* Not symmetric */ ); - - for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::const_iterator - i = new_recv.begin() ; i != new_recv.end() ; ++i ) { - const unsigned owner = (*i)->owner_rank(); - const stk_classic::mesh::EntityKey key = (*i)->key(); - all.send_buffer( owner ).pack( & key , 1 ); - } - - all.communicate(); - - for ( unsigned p = 0 ; p < parallel_size ; ++p ) { - stk_classic::CommBuffer & buf = all.recv_buffer(p); - while ( buf.remaining() ) { - stk_classic::mesh::EntityKey key ; - buf.unpack( & key , 1 ); - stk_classic::mesh::EntityProc tmp( mesh.get_entity( entity_rank(key), entity_id(key) ) , p ); - new_send.insert( tmp ); - } - } -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkModification.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkModification.cpp deleted file mode 100644 index c6d084d15ba8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestBulkModification.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Bucket; -using stk_classic::mesh::BucketIterator; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::fixtures::RingFixture; - -class UnitTestStkMeshBulkModification { - public: - UnitTestStkMeshBulkModification(stk_classic::ParallelMachine pm) : - m_comm(pm), - m_num_procs(stk_classic::parallel_machine_size( m_comm )), - m_rank(stk_classic::parallel_machine_rank( m_comm )), - m_ring_mesh(pm) - { } - - void test_bulkdata_not_syncronized(); - void test_closure_of_non_locally_used_entities(); - void test_all_local_nodes(); - void test_all_local_edges(); - void test_parallel_consistency(); - - BulkData& initialize_ring_fixture() - { - m_ring_mesh.m_meta_data.commit(); - BulkData& bulk_data = m_ring_mesh.m_bulk_data; - - bulk_data.modification_begin(); - m_ring_mesh.generate_mesh( ); - ThrowRequire(bulk_data.modification_end()); - - bulk_data.modification_begin(); - m_ring_mesh.fixup_node_ownership( ); - ThrowRequire(bulk_data.modification_end()); - - return bulk_data; - } - - stk_classic::ParallelMachine m_comm; - int m_num_procs; - int m_rank; - RingFixture m_ring_mesh; -}; - -namespace { - -const EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST( UnitTestBulkDataNotSyrncronized , testUnit ) -{ - UnitTestStkMeshBulkModification unit(MPI_COMM_WORLD); - unit.test_bulkdata_not_syncronized(); -} - -STKUNIT_UNIT_TEST( UnitTestClosureOfNonLocallyUsedEntities , testUnit ) -{ - UnitTestStkMeshBulkModification unit(MPI_COMM_WORLD); - unit.test_closure_of_non_locally_used_entities(); -} - -STKUNIT_UNIT_TEST( UnitTestAllLocalNodes , testUnit ) -{ - UnitTestStkMeshBulkModification unit(MPI_COMM_WORLD); - unit.test_all_local_nodes(); -} - -STKUNIT_UNIT_TEST( UnitTestAllLocalEdges , testUnit ) -{ - UnitTestStkMeshBulkModification unit(MPI_COMM_WORLD); - unit.test_all_local_edges(); -} - -STKUNIT_UNIT_TEST( UnitTestParallelConsistency , testUnit ) -{ - UnitTestStkMeshBulkModification unit(MPI_COMM_WORLD); - unit.test_parallel_consistency(); -} - -} //end namespace - -void UnitTestStkMeshBulkModification::test_bulkdata_not_syncronized() -{ - BulkData& bulk_data = initialize_ring_fixture(); - - bulk_data.modification_begin(); // Intentially make things unsynced - - std::vector< Entity *> entities; - std::vector< Entity *> entities_closure; - STKUNIT_ASSERT_THROW(stk_classic::mesh::find_closure(bulk_data, entities, entities_closure), std::runtime_error); -} - -void UnitTestStkMeshBulkModification::test_closure_of_non_locally_used_entities() -{ - BulkData& bulk_data = initialize_ring_fixture(); - - const stk_classic::mesh::Ghosting & ghost = bulk_data.shared_aura(); - - std::vector< Entity* > ghost_receive ; - - ghost.receive_list( ghost_receive ); - - if (!ghost_receive.empty()) { - std::vector< Entity *> entities; - std::vector< Entity *> entities_closure; - - entities.push_back(ghost_receive.front()); - - STKUNIT_ASSERT_THROW(stk_classic::mesh::find_closure(bulk_data, entities, entities_closure), std::runtime_error); - } -} - -void UnitTestStkMeshBulkModification::test_all_local_nodes() -{ - BulkData& bulk_data = initialize_ring_fixture(); - - { - std::vector< Entity *> entities; - std::vector< Entity *> entities_closure; - find_closure(bulk_data, entities, entities_closure); - - // the closure of the an empty set of entities on all procs should be empty - STKUNIT_EXPECT_TRUE(entities_closure.empty()); - } - - { - // Get a selector for the univeral part (contains local, shared, and ghosted) - const stk_classic::mesh::Part& universal = m_ring_mesh.m_meta_data.universal_part(); - stk_classic::mesh::Selector universal_selector(universal); - - // Get the buckets that will give us the universal nodes - const std::vector& node_buckets = bulk_data.buckets(NODE_RANK); - std::vector buckets; - stk_classic::mesh::get_buckets(universal_selector, node_buckets, buckets); - - // Get the universal nodes - std::vector< Entity *> universal_entities; - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - universal_entities.push_back(&(*bitr)); - } - } - buckets.clear(); - - // sort and unique the universal nodes - std::sort(universal_entities.begin(), universal_entities.end(), stk_classic::mesh::EntityLess()); - std::vector::iterator new_end = std::unique(universal_entities.begin(), universal_entities.end(), stk_classic::mesh::EntityEqual()); - universal_entities.erase(new_end, universal_entities.end()); - - // Get the buckets that will give us the locally used nodes - stk_classic::mesh::Selector locally_used_selector = - m_ring_mesh.m_meta_data.locally_owned_part() | - m_ring_mesh.m_meta_data.globally_shared_part(); - - stk_classic::mesh::get_buckets(locally_used_selector, node_buckets, buckets); - - // Get the locally used nodes - std::vector< Entity *> entities; - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - entities.push_back(&(*bitr)); - } - } - - // Get the closure, passing in the locally used nodes on each proc - std::vector< Entity *> entities_closure; - stk_classic::mesh::find_closure(bulk_data, entities, entities_closure); - - // The ghosted nodes on this part will be locally used on one of the other - // procs, so we expect that they will be part of the closure. In other - // words, the set of nodes returned by find_closure should exactly match - // the set of universal nodes. - STKUNIT_ASSERT_TRUE(universal_entities.size() == entities_closure.size()); - stk_classic::mesh::EntityEqual ee; - for (size_t i = 0; i < entities_closure.size(); ++i) { - STKUNIT_EXPECT_TRUE(ee(universal_entities[i], entities_closure[i])); - } - } -} - -void UnitTestStkMeshBulkModification::test_all_local_edges() -{ - BulkData& bulk_data = initialize_ring_fixture(); - const stk_classic::mesh::EntityRank element_rank = m_ring_mesh.m_meta_data.element_rank(); - - { - const stk_classic::mesh::Part& universal = m_ring_mesh.m_meta_data.universal_part(); - stk_classic::mesh::Selector universal_selector(universal); - - const std::vector& node_buckets = bulk_data.buckets(NODE_RANK); - const std::vector& edge_buckets = bulk_data.buckets(element_rank); - std::vector buckets; - - stk_classic::mesh::get_buckets(universal_selector, node_buckets, buckets); - - // get all the nodes that this process knows about - std::vector< Entity *> universal_entities; - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - universal_entities.push_back(&(*bitr)); - } - } - buckets.clear(); - - stk_classic::mesh::get_buckets(universal_selector, edge_buckets, buckets); - - // get all the edges that this process knows about - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - universal_entities.push_back(&(*bitr)); - } - } - buckets.clear(); - - // universal entities should now have all the universal nodes and edges - // sort and uniq the universal nodes/edges - std::sort(universal_entities.begin(), universal_entities.end(), stk_classic::mesh::EntityLess()); - std::vector::iterator new_end = std::unique(universal_entities.begin(), universal_entities.end(), stk_classic::mesh::EntityEqual()); - universal_entities.erase(new_end, universal_entities.end()); - - // get the buckets that we need to traverse to get the locally used edges - stk_classic::mesh::Selector locally_used_selector = - m_ring_mesh.m_meta_data.locally_owned_part() | - m_ring_mesh.m_meta_data.globally_shared_part(); - - stk_classic::mesh::get_buckets(locally_used_selector, edge_buckets, buckets); - - // get the locally used edges and store them in entities - std::vector< Entity *> entities; - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - entities.push_back(&(*bitr)); - } - } - - // call find_closure, passing in the locally used edges - std::vector< Entity *> entities_closure; - stk_classic::mesh::find_closure(bulk_data, entities, entities_closure); - - // The ghosted entities on this proc (edge or node) should be contained - // in the closure of the locally-used edge on some other proc, so we - // expect that they will be part of the closure. In other - // words, the set of entities returned by find_closure should exactly match - // the set of universal entities (nodes and edges). - STKUNIT_ASSERT_TRUE(universal_entities.size() == entities_closure.size()); - stk_classic::mesh::EntityEqual ee; - for (size_t i = 0; i < entities_closure.size(); ++i) { - STKUNIT_EXPECT_TRUE(ee(universal_entities[i], entities_closure[i])); - } - } -} - -void UnitTestStkMeshBulkModification::test_parallel_consistency() -{ - BulkData& bulk_data = initialize_ring_fixture(); - - stk_classic::CommBroadcast all(bulk_data.parallel(), 0); - - std::vector< Entity *> entities; - std::vector< Entity *> entities_closure; - - // For proc 0 only, add locally used nodes to entities, for all other - // procs, leave entities empty. - if (m_rank == 0) { - const std::vector& node_buckets = bulk_data.buckets(NODE_RANK); - - stk_classic::mesh::Selector locally_used_selector = - m_ring_mesh.m_meta_data.locally_owned_part() | - m_ring_mesh.m_meta_data.globally_shared_part(); - - std::vector buckets; - stk_classic::mesh::get_buckets(locally_used_selector, node_buckets, buckets); - - for (std::vector::iterator itr = buckets.begin(); - itr != buckets.end(); ++itr) { - Bucket& b = **itr; - for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) { - entities.push_back(&(*bitr)); - } - } - } - - // Call find_closure with proc 0 passing in locally-used nodes - stk_classic::mesh::find_closure(bulk_data, entities, entities_closure); - - // Proc 0 will broadcast the global ids of the nodes it passed to - // find_closure - - // pack entities for sizing - for (std::vector::const_iterator - ep = entities.begin() ; ep != entities.end() ; ++ep ) { - all.send_buffer().pack((*ep)->key()); - } - - all.allocate_buffer(); - - // pack for real - for (std::vector::const_iterator - ep = entities.begin() ; ep != entities.end() ; ++ep ) { - all.send_buffer().pack((*ep)->key()); - } - - all.communicate(); - - // clear-out entities and put the nodes that correspond to the keys - // broadcast by proc 0 into entities. - entities.clear(); - stk_classic::CommBuffer& buf = all.recv_buffer(); - stk_classic::mesh::EntityKey k ; - while ( buf.remaining() ) { - buf.unpack(k); - Entity * e = bulk_data.get_entity(k); - // If a proc is not aware of a key, that means it has no relationship - // with that entity, so it can ignore it. - if (e != NULL) { - entities.push_back(e); - } - } - - // sort and unique entities - std::sort(entities.begin(), entities.end(), stk_classic::mesh::EntityLess()); - std::vector::iterator new_end = std::unique(entities.begin(), entities.end(), stk_classic::mesh::EntityEqual()); - entities.erase(new_end, entities.end()); - - // If any processor had ghosted nodes that were local to proc 0, those - // nodes should be in the closure because proc 0 passed them in to - // find_closure. - STKUNIT_ASSERT_TRUE(entities.size() == entities_closure.size()); - stk_classic::mesh::EntityEqual ee; - for (size_t i = 0; i < entities_closure.size(); ++i) { - STKUNIT_EXPECT_TRUE(ee(entities[i], entities_closure[i])); - } -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestChangeEntityId.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestChangeEntityId.cpp deleted file mode 100644 index 9c1e86a4f332..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestChangeEntityId.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#include -#include -#include -#include - -#include - - -STKUNIT_UNIT_TEST( UnitTestChangeEntityId, change_id ) -{ - using namespace stk_classic::mesh; - - const unsigned NX = 50; - const unsigned NY = 50; - const unsigned NZ = 50; - const unsigned num_elems = NX * NY * NZ; - - fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - - Field & simple_nodal_field = hf.m_fem_meta.declare_field >("simple_nodal_field"); - - put_field( simple_nodal_field, - fem::FEMMetaData::NODE_RANK, - hf.m_hex_part); - - - //create nodal field on hex topo - - hf.m_fem_meta.commit(); - - hf.generate_mesh(); - - stk_classic::mesh::BulkData & mesh = hf.m_bulk_data; - - mesh.modification_begin(); - - const BucketVector & nodes = mesh.buckets(fem::FEMMetaData::NODE_RANK); - - BOOST_FOREACH(Bucket * b, nodes) { - BucketArray< Field > nodal_field(simple_nodal_field,*b); - for (int i =0; i old_ids; - old_ids.reserve(num_elems); - BOOST_FOREACH(Bucket * b, elems) { - for (size_t i =0; isize(); ++i) { - Entity & e = (*b)[i]; - old_ids.push_back(e.identifier()); - mesh.change_entity_id( e.identifier()+num_elems, e); - } - } - - mesh.modification_end(); - - mesh.modification_begin(); - mesh.modification_end(); - - std::vector new_ids_minus_num_elems; - new_ids_minus_num_elems.reserve(num_elems); - BOOST_FOREACH(Bucket * b, elems) { - for (size_t i =0; isize(); ++i) { - Entity & e = (*b)[i]; - new_ids_minus_num_elems.push_back(e.identifier()-num_elems); - } - } - - STKUNIT_EXPECT_TRUE(old_ids == new_ids_minus_num_elems); - - BOOST_FOREACH(Bucket * b, nodes) { - BucketArray< Field > nodal_field(simple_nodal_field,*b); - for (int i =0; i - -#include - -#include -#include - -//---------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST ( UnitTestCrackMesh , VerifyDestroy2D ) -{ - // In 2D, build a fresh 3x3 mesh each loop iteration, destroying a different - // single element each time. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - - const unsigned nx = 3 , ny = 3 ; - - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::fixtures::QuadFixture fixture( pm , nx , ny ); - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - fixture.m_bulk_data.modification_begin(); - - stk_classic::mesh::Entity * elem = fixture.elem( ix , iy ); - - if ( elem && p_rank == elem->owner_rank() ) { - stk_classic::mesh::Entity * tmp = elem ; - fixture.m_bulk_data.destroy_entity( tmp ); - } - - fixture.m_bulk_data.modification_end(); - - if ( elem ) { - STKUNIT_EXPECT_TRUE ( elem->log_query() == stk_classic::mesh::EntityLogDeleted ); - } - } - } -} - -STKUNIT_UNIT_TEST ( UnitTestCrackMesh , VerifyDestroy3D ) -{ - // In 3D, build a 3x3x3 mesh each loop iteration, destroying a different - // single element each time. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - - const unsigned nx = 3 , ny = 3 , nz = 3 ; - - for ( unsigned iz = 0 ; iz < nz ; ++iz ) { - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::fixtures::HexFixture fixture( pm , nx , ny , nz ); - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - fixture.m_bulk_data.modification_begin(); - - stk_classic::mesh::Entity * elem = fixture.elem( ix , iy , iz ); - - if ( elem && p_rank == elem->owner_rank() ) { - stk_classic::mesh::Entity * tmp = elem ; - fixture.m_bulk_data.destroy_entity( tmp ); - } - - fixture.m_bulk_data.modification_end(); - - if ( elem ) { - STKUNIT_EXPECT_TRUE ( elem->log_query() == stk_classic::mesh::EntityLogDeleted ); - } - } - } - } -} - -//---------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST ( UnitTestCrackMesh , verifyBoxGhosting ) -{ - // Start with a normal hex fixture, then crack it, and check to see - // if all (incl ghosted) copies get updated. - - // Make the hex fixture - - stk_classic::mesh::fixtures::HexFixture fixture( MPI_COMM_WORLD, 2,2,2 ); - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - stk_classic::mesh::BulkData & mesh = fixture.m_bulk_data; - - // Hardwire which entities are being modified. Note that not every - // process will know about these entities - - stk_classic::mesh::Entity * const old_node = fixture.node(0,1,1); - - stk_classic::mesh::Entity * const right_element = fixture.elem(0,0,1); - - unsigned right_ordinal = 0; - unsigned new_node_id = 28; - - // If this process knows about both entities, compute the ordinal - // of the relation from right_element to old_node - - if ( old_node && right_element ) { - stk_classic::mesh::PairIterRelation rel = old_node->relations(); - - for (; rel.first != rel.second; ++rel) { - if ( (rel.first->entity()) == right_element) { - right_ordinal = rel.first->identifier(); - } - } - } - - // Crack the mesh - - mesh.modification_begin(); - - //only crack the mesh if I own the element - if ( right_element && - right_element->owner_rank() == mesh.parallel_rank() ) { - - const stk_classic::mesh::PartVector no_parts; - - // create a new node - stk_classic::mesh::Entity & new_node = mesh.declare_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, new_node_id, no_parts); - - // destroy right_element's relation to old_node, replace with a - // relation to new node - mesh.destroy_relation(*right_element, *old_node, right_ordinal); - mesh.declare_relation(*right_element, new_node, right_ordinal); - } - - mesh.modification_end(); - - // Now that modification_end has been called, all processes that know - // about right_element should know about the crack. - - if ( right_element ) { - stk_classic::mesh::PairIterRelation rel = right_element->relations(); - stk_classic::mesh::Entity & new_node = * (rel.first[right_ordinal].entity()); - - STKUNIT_EXPECT_TRUE ( new_node.identifier() == new_node_id ); - } -} - -//---------------------------------------------------------------------------- diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestCreateAdjacentEntities.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestCreateAdjacentEntities.cpp deleted file mode 100644 index ae451a338130..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestCreateAdjacentEntities.cpp +++ /dev/null @@ -1,213 +0,0 @@ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include - -STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x1x1 ) -{ - const size_t NX = 3; - const size_t NY = 1; - const size_t NZ = 1; - - stk_classic::mesh::fixtures::HexFixture fixture(MPI_COMM_WORLD, NX, NY, NZ); - - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( counts[0] , 16u ); // nodes - STKUNIT_EXPECT_EQ( counts[1] , 0u ); // edges - STKUNIT_EXPECT_EQ( counts[2] , 0u ); // faces - STKUNIT_EXPECT_EQ( counts[3] , 3u ); // elements - } - - stk_classic::mesh::PartVector empty_add_parts; - - stk_classic::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( counts[0] , 16u ); - STKUNIT_EXPECT_EQ( counts[1] , 28u ); - STKUNIT_EXPECT_EQ( counts[2] , 16u ); - STKUNIT_EXPECT_EQ( counts[3] , 3u ); - } -} - -STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x3x3 ) -{ - const size_t elem_rank = 3; - const size_t face_rank = 2; - const size_t edge_rank = 1; - const size_t node_rank = 0; - - const size_t NX = 3; - const size_t NY = 3; - const size_t NZ = 3; - - stk_classic::mesh::fixtures::HexFixture fixture(MPI_COMM_WORLD, NX, NY, NZ); - - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( counts[node_rank] , 64u ); // nodes - STKUNIT_EXPECT_EQ( counts[edge_rank] , 0u ); // edges - STKUNIT_EXPECT_EQ( counts[face_rank] , 0u ); // faces - STKUNIT_EXPECT_EQ( counts[elem_rank] , 27u ); // elements - } - - stk_classic::mesh::PartVector empty_add_parts; - - stk_classic::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( 64u, counts[node_rank] ); // nodes - STKUNIT_EXPECT_EQ( 144u, counts[edge_rank] ); // edges - STKUNIT_EXPECT_EQ( 108u, counts[face_rank] ); // faces - STKUNIT_EXPECT_EQ( 27u, counts[elem_rank] ); // elements - } - - stk_classic::mesh::BucketVector elem_buckets = fixture.m_bulk_data.buckets(elem_rank); - for ( stk_classic::mesh::BucketVector::iterator b_itr = elem_buckets.begin(); - b_itr != elem_buckets.end(); - ++b_itr - ) - { - stk_classic::mesh::Bucket & b = **b_itr; - for ( size_t i = 0; i< b.size(); ++i) { - stk_classic::mesh::Entity & elem = b[i]; - - STKUNIT_EXPECT_EQ( 6u, elem.relations(face_rank).size() ); - STKUNIT_EXPECT_EQ( 12u, elem.relations(edge_rank).size() ); - STKUNIT_EXPECT_EQ( 8u, elem.relations(node_rank).size() ); - - } - } - - stk_classic::mesh::BucketVector face_buckets = fixture.m_bulk_data.buckets(face_rank); - for ( stk_classic::mesh::BucketVector::iterator b_itr = face_buckets.begin(); - b_itr != face_buckets.end(); - ++b_itr - ) - { - stk_classic::mesh::Bucket & b = **b_itr; - for ( size_t i = 0; i< b.size(); ++i) { - stk_classic::mesh::Entity & face = b[i]; - STKUNIT_EXPECT_EQ( 4u,face.relations(edge_rank).size()); - STKUNIT_EXPECT_EQ( 4u, face.relations(node_rank).size() ); - } - } - - stk_classic::mesh::BucketVector edge_buckets = fixture.m_bulk_data.buckets(edge_rank); - for ( stk_classic::mesh::BucketVector::iterator b_itr = edge_buckets.begin(); - b_itr != edge_buckets.end(); - ++b_itr - ) - { - stk_classic::mesh::Bucket & b = **b_itr; - for ( size_t i = 0; i< b.size(); ++i) { - stk_classic::mesh::Entity & edge = b[i]; - STKUNIT_EXPECT_EQ( 2u, edge.relations(node_rank).size() ); - } - } -} - -STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x3 ) -{ - const size_t elem_rank = 2; - const size_t edge_rank = 1; - const size_t node_rank = 0; - - const size_t NX = 3; - const size_t NY = 3; - - stk_classic::mesh::fixtures::QuadFixture fixture(MPI_COMM_WORLD, NX, NY); - - fixture.m_fem_meta.commit(); - fixture.generate_mesh(); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( counts[node_rank] , 16u ); // nodes - STKUNIT_EXPECT_EQ( counts[edge_rank] , 0u ); // edges - STKUNIT_EXPECT_EQ( counts[elem_rank] , 9u ); // elements - } - - stk_classic::mesh::PartVector empty_add_parts; - - stk_classic::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts); - - { - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts); - - STKUNIT_EXPECT_EQ( 16u, counts[node_rank] ); // nodes - STKUNIT_EXPECT_EQ( 24u, counts[edge_rank] ); // edges - STKUNIT_EXPECT_EQ( 9u, counts[elem_rank] ); // elements - } - - stk_classic::mesh::BucketVector elem_buckets = fixture.m_bulk_data.buckets(elem_rank); - for ( stk_classic::mesh::BucketVector::iterator b_itr = elem_buckets.begin(); - b_itr != elem_buckets.end(); - ++b_itr - ) - { - stk_classic::mesh::Bucket & b = **b_itr; - for ( size_t i = 0; i< b.size(); ++i) { - stk_classic::mesh::Entity & elem = b[i]; - - STKUNIT_EXPECT_EQ( 4u, elem.relations(edge_rank).size() ); - STKUNIT_EXPECT_EQ( 4u, elem.relations(node_rank).size() ); - - } - } - - stk_classic::mesh::BucketVector edge_buckets = fixture.m_bulk_data.buckets(edge_rank); - for ( stk_classic::mesh::BucketVector::iterator b_itr = edge_buckets.begin(); - b_itr != edge_buckets.end(); - ++b_itr - ) - { - stk_classic::mesh::Bucket & b = **b_itr; - for ( size_t i = 0; i< b.size(); ++i) { - stk_classic::mesh::Entity & edge = b[i]; - STKUNIT_EXPECT_EQ( 2u, edge.relations(node_rank).size() ); - } - } -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDataTraits.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDataTraits.cpp deleted file mode 100644 index 8870c887f1bb..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDataTraits.cpp +++ /dev/null @@ -1,581 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -using stk_classic::mesh::DataTraits; -using stk_classic::mesh::data_traits; -using stk_classic::CommAll; - -//---------------------------------------------------------------------- - -namespace { - -STKUNIT_UNIT_TEST(TestDataTraits, testVoid) -{ - // Test the DataTrait for void - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - const DataTraits & traits = data_traits(); - - STKUNIT_ASSERT( traits.type_info == typeid(void) ); - STKUNIT_ASSERT_EQUAL( traits.size_of , size_t(0) ); - STKUNIT_ASSERT_EQUAL( traits.alignment_of , size_t(0) ); - STKUNIT_ASSERT_EQUAL( traits.stride_of , size_t(0) ); - STKUNIT_ASSERT_EQUAL( traits.is_void , true ); - STKUNIT_ASSERT_EQUAL( traits.is_integral , false ); - STKUNIT_ASSERT_EQUAL( traits.is_floating_point , false ); - STKUNIT_ASSERT_EQUAL( traits.is_array , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pointer , false ); - STKUNIT_ASSERT_EQUAL( traits.is_enum , false ); - STKUNIT_ASSERT_EQUAL( traits.is_class , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pod , false ); - STKUNIT_ASSERT_EQUAL( traits.is_signed , false ); - STKUNIT_ASSERT_EQUAL( traits.is_unsigned , false ); - - STKUNIT_ASSERT( ! traits.remove_pointer ); - STKUNIT_ASSERT( traits.enum_info.empty() ); - STKUNIT_ASSERT( traits.class_info.empty() ); - - STKUNIT_ASSERT_THROW( traits.construct( NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.destroy( NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.copy( NULL , NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.sum( NULL , NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.max( NULL , NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.min( NULL , NULL , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.bit_and( NULL, NULL, 0 ), std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.bit_or( NULL , NULL, 0 ), std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.bit_xor( NULL, NULL, 0 ), std::runtime_error ); - STKUNIT_ASSERT_THROW( traits.print( std::cout, NULL, 0), std::runtime_error); - - CommAll comm( pm ); - STKUNIT_ASSERT_THROW( traits.pack( comm.send_buffer(0) , NULL , 0 ), std::runtime_error ); - comm.allocate_buffers( 0 ); - comm.communicate(); - STKUNIT_ASSERT_THROW( traits.unpack( comm.recv_buffer(0) , NULL , 0 ), std::runtime_error ); -} - -//---------------------------------------------------------------------- - -template< typename T , bool is_integral , bool is_signed > -void test_fundamental_type() -{ - // Test DataTrait for fundamental type T - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - int p_rank = stk_classic::parallel_machine_rank( pm ); - int p_size = stk_classic::parallel_machine_size( pm ); - MPI_Barrier( pm ); - - // Test data trait properties of type T - const DataTraits & traits = data_traits(); - STKUNIT_ASSERT( traits.type_info == typeid(T) ); - STKUNIT_ASSERT_EQUAL( traits.size_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.alignment_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.stride_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.is_void , false ); - STKUNIT_ASSERT_EQUAL( traits.is_integral , is_integral ); - STKUNIT_ASSERT_EQUAL( traits.is_floating_point , ! is_integral ); - STKUNIT_ASSERT_EQUAL( traits.is_array , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pointer , false ); - STKUNIT_ASSERT_EQUAL( traits.is_enum , false ); - STKUNIT_ASSERT_EQUAL( traits.is_class , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pod , true ); - STKUNIT_ASSERT_EQUAL( traits.is_signed , is_signed ); - STKUNIT_ASSERT_EQUAL( traits.is_unsigned , is_integral && ! is_signed); - - STKUNIT_ASSERT( ! traits.remove_pointer ); - STKUNIT_ASSERT( traits.enum_info.empty() ); - STKUNIT_ASSERT( traits.class_info.empty() ); - - const unsigned array_size = 3; - const T a[array_size] = { T(1) , T(2) , T(4) }; - T b[array_size] ; - - // Test data trait basic operations on type T - traits.construct( b , array_size ); - STKUNIT_ASSERT_EQUAL( T(0) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(0) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(0) , b[2] ); - - traits.copy( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(1) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(2) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[2] ); - - traits.sum( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(2) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(8) , b[2] ); - - traits.min( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(1) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(2) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[2] ); - - traits.sum( b , a , array_size ); - traits.max( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(2) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(8) , b[2] ); - - if ( is_integral ) { - // Test integral-specific operations - traits.bit_or( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(3) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(6) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(12) , b[2] ); - - traits.bit_and( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(1) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(2) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[2] ); - - traits.bit_xor( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( T(0) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(0) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(0) , b[2] ); - } - else { - // Test unsupported operations - STKUNIT_ASSERT_THROW(traits.bit_or (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_and(b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_xor(b, a, array_size), std::runtime_error); - } - - // Test data trait pack/unpack (communication) of type T - traits.construct( b , array_size ); - CommAll comm( pm ); - traits.pack( comm.send_buffer(0) , a , array_size ); - comm.allocate_buffers( 0 ); - traits.pack( comm.send_buffer(0) , a , array_size ); - comm.communicate(); - if (p_rank == 0) { - for (int proc_id = 0; proc_id < p_size; ++proc_id) { - traits.unpack( comm.recv_buffer(proc_id) , b , array_size ); - STKUNIT_ASSERT_EQUAL( T(1) , b[0] ); - STKUNIT_ASSERT_EQUAL( T(2) , b[1] ); - STKUNIT_ASSERT_EQUAL( T(4) , b[2] ); - } - } - - // Test data trait print of type T - std::ostringstream oss; - oss << traits.name << " " ; - traits.print( oss , a , array_size ); - oss << std::endl ; - - // Test data trait destruction (no-op in this case) - traits.destroy( b , array_size ); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_bool) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedchar) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_short) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedshort) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_int) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedint) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_long) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedlong) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_float) -{ - test_fundamental_type(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_double) -{ - test_fundamental_type(); -} - -//---------------------------------------------------------------------- - -template< typename T > -void test_fundamental_pointer() -{ - // Test DataTrait for fundamenter pointer type T* - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - // Test data trait properties of type T* - const DataTraits & traits = data_traits(); - STKUNIT_ASSERT( traits.type_info == typeid(T*) ); - STKUNIT_ASSERT_EQUAL( traits.size_of , sizeof(T*) ); - STKUNIT_ASSERT_EQUAL( traits.alignment_of , sizeof(T*) ); - STKUNIT_ASSERT_EQUAL( traits.stride_of , sizeof(T*) ); - STKUNIT_ASSERT_EQUAL( traits.is_void , false ); - STKUNIT_ASSERT_EQUAL( traits.is_integral , false ); - STKUNIT_ASSERT_EQUAL( traits.is_floating_point , false ); - STKUNIT_ASSERT_EQUAL( traits.is_array , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pointer , true ); - STKUNIT_ASSERT_EQUAL( traits.is_enum , false ); - STKUNIT_ASSERT_EQUAL( traits.is_class , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pod , false ); - STKUNIT_ASSERT_EQUAL( traits.is_signed , false ); - STKUNIT_ASSERT_EQUAL( traits.is_unsigned , false ); - - STKUNIT_ASSERT( traits.remove_pointer == & data_traits() ); - STKUNIT_ASSERT( traits.enum_info.empty() ); - STKUNIT_ASSERT( traits.class_info.empty() ); - - const unsigned array_size = 3; - T val[array_size] = { T(1) , T(2) , T(4) }; - T * const a[array_size] = { val , val + 1 , val + 2 }; - T * b[array_size] ; - - // Test data trait basic operations on type T* - traits.construct( b , array_size ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[0] ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[1] ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[2] ); - - traits.copy( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( val + 0 , b[0] ); - STKUNIT_ASSERT_EQUAL( val + 1 , b[1] ); - STKUNIT_ASSERT_EQUAL( val + 2 , b[2] ); - - traits.destroy( b , array_size ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[0] ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[1] ); - STKUNIT_ASSERT_EQUAL( static_cast(NULL) , b[2] ); - - // Test unsupported operations - STKUNIT_ASSERT_THROW(traits.sum (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.max (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.min (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_and(b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_or( b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_xor(b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.print (std::cout, NULL, 0), std::runtime_error); - - CommAll comm( pm ); - STKUNIT_ASSERT_THROW( traits.pack( comm.send_buffer(0) , a , array_size ), std::runtime_error ); - comm.allocate_buffers( 0 ); - comm.communicate(); - STKUNIT_ASSERT_THROW( traits.unpack( comm.recv_buffer(0) , b , array_size ), std::runtime_error ); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_char_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedchar_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_short_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedshort_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_int_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedint_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_long_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_unsignedlong_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_float_ptr) -{ - test_fundamental_pointer(); -} - -STKUNIT_UNIT_TEST(TestDataTraits, testFundamental_double_ptr) -{ - test_fundamental_pointer(); -} - -} -//---------------------------------------------------------------------- - -#ifndef __PGI - -enum EType { val_a = 'a' , val_b = 'b' , val_c = 'c' }; - -namespace stk_classic { -namespace mesh { - -// This enum will only work within the stk_classic::mesh namespace -DATA_TRAITS_ENUM_3( EType , val_a , val_b , val_c ) - -} -} - -namespace { - -STKUNIT_UNIT_TEST(TestDataTraits, testEnum) -{ - // Test interaction of DataTraits with enums - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - int p_rank = stk_classic::parallel_machine_rank( pm ); - int p_size = stk_classic::parallel_machine_size( pm ); - MPI_Barrier( pm ); - - typedef EType T ; - const DataTraits & traits = data_traits(); - - // Test data trait properties of enum type - STKUNIT_ASSERT( traits.type_info == typeid(T) ); - STKUNIT_ASSERT_EQUAL( traits.size_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.alignment_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.stride_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.is_integral , false ); - STKUNIT_ASSERT_EQUAL( traits.is_floating_point , false ); - STKUNIT_ASSERT_EQUAL( traits.is_array , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pointer , false ); - STKUNIT_ASSERT_EQUAL( traits.is_enum , true ); - STKUNIT_ASSERT_EQUAL( traits.is_class , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pod , true ); - STKUNIT_ASSERT_EQUAL( traits.is_signed , false ); - STKUNIT_ASSERT_EQUAL( traits.is_unsigned , false ); - - STKUNIT_ASSERT( ! traits.remove_pointer ); - STKUNIT_ASSERT( traits.class_info.empty() ); - - STKUNIT_ASSERT_EQUAL( traits.enum_info.size() , size_t(3) ); - STKUNIT_ASSERT_EQUAL( (traits.enum_info[0].name == "val_a"), true ); - STKUNIT_ASSERT_EQUAL( (traits.enum_info[1].name == "val_b"), true ); - STKUNIT_ASSERT_EQUAL( (traits.enum_info[2].name == "val_c"), true ); - STKUNIT_ASSERT_EQUAL( traits.enum_info[0].value , long(val_a) ); - STKUNIT_ASSERT_EQUAL( traits.enum_info[1].value , long(val_b) ); - STKUNIT_ASSERT_EQUAL( traits.enum_info[2].value , long(val_c) ); - - const unsigned array_size = 3; - EType a[array_size] = { val_a , val_b , val_c }; - EType b[array_size] ; - - // Test data trait basic operations on enum type - traits.construct( b , array_size ); - STKUNIT_ASSERT_EQUAL( val_a , b[0] ); - STKUNIT_ASSERT_EQUAL( val_a , b[1] ); - STKUNIT_ASSERT_EQUAL( val_a , b[2] ); - - traits.copy( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( a[0] , b[0] ); - STKUNIT_ASSERT_EQUAL( a[1] , b[1] ); - STKUNIT_ASSERT_EQUAL( a[2] , b[2] ); - - b[0] = val_b ; b[1] = val_b ; b[2] = val_b ; - - traits.min( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( val_a , b[0] ); - STKUNIT_ASSERT_EQUAL( val_b , b[1] ); - STKUNIT_ASSERT_EQUAL( val_b , b[2] ); - - b[0] = val_b ; b[1] = val_b ; b[2] = val_b ; - - traits.max( b , a , array_size ); - STKUNIT_ASSERT_EQUAL( val_b , b[0] ); - STKUNIT_ASSERT_EQUAL( val_b , b[1] ); - STKUNIT_ASSERT_EQUAL( val_c , b[2] ); - - // Test unsupported operations - STKUNIT_ASSERT_THROW(traits.sum (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_and(b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_or (b, a, array_size), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_xor(b, a, array_size), std::runtime_error); - - // Test pack/unpack (communication) of enum type - traits.construct( b , array_size ); - CommAll comm( pm ); - traits.pack( comm.send_buffer(0) , a , array_size ); - comm.allocate_buffers( 0 ); - traits.pack( comm.send_buffer(0) , a , array_size ); - comm.communicate(); - if (p_rank == 0) { - for (int proc_id = 0; proc_id < p_size; ++proc_id) { - traits.unpack( comm.recv_buffer(proc_id) , b , array_size ); - STKUNIT_ASSERT_EQUAL( a[0] , b[0] ); - STKUNIT_ASSERT_EQUAL( a[1] , b[1] ); - STKUNIT_ASSERT_EQUAL( a[2] , b[2] ); - } - } - - // Test printing of enum type - std::ostringstream oss; - b[2] = static_cast( 'd' ); - oss << traits.name << " " ; - traits.print( oss , b , array_size ); - oss << std::endl ; - - // Test destruction of enum type (no-op in this case) - traits.destroy( b , array_size ); -} - -} - -//---------------------------------------------------------------------- - -struct Vec3 { double x , y , z ; }; - -namespace stk_classic { -namespace mesh { - -// This enum will only work within the stk_classic::mesh namespace -DATA_TRAITS_POD_CLASS_3( Vec3 , x , y , z ) - -} -} - -namespace { - -STKUNIT_UNIT_TEST(TestDataTraits, testClass) -{ - // Test interaction of DataTraits with classes - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - int p_rank = stk_classic::parallel_machine_rank( pm ); - int p_size = stk_classic::parallel_machine_size( pm ); - MPI_Barrier( pm ); - - typedef Vec3 T ; - const DataTraits & traits = data_traits(); - - // Test data trait properties of class type - STKUNIT_ASSERT( traits.type_info == typeid(T) ); - STKUNIT_ASSERT_EQUAL( traits.size_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.alignment_of , sizeof(double) ); - STKUNIT_ASSERT_EQUAL( traits.stride_of , sizeof(T) ); - STKUNIT_ASSERT_EQUAL( traits.is_integral , false ); - STKUNIT_ASSERT_EQUAL( traits.is_floating_point , false ); - STKUNIT_ASSERT_EQUAL( traits.is_array , false ); - STKUNIT_ASSERT_EQUAL( traits.is_pointer , false ); - STKUNIT_ASSERT_EQUAL( traits.is_enum , false ); - STKUNIT_ASSERT_EQUAL( traits.is_class , true ); - STKUNIT_ASSERT_EQUAL( traits.is_pod , true ); - STKUNIT_ASSERT_EQUAL( traits.is_signed , false ); - STKUNIT_ASSERT_EQUAL( traits.is_unsigned , false ); - - STKUNIT_ASSERT( ! traits.remove_pointer ); - STKUNIT_ASSERT( traits.enum_info.empty() ); - - const Vec3 a = { 1.0 , 2.0 , 3.0 }; - const size_t dx = reinterpret_cast( & a.x ) - - reinterpret_cast( & a ); - const size_t dy = reinterpret_cast( & a.y ) - - reinterpret_cast( & a ); - const size_t dz = reinterpret_cast( & a.z ) - - reinterpret_cast( & a ); - - STKUNIT_ASSERT_EQUAL( traits.class_info.size() , size_t(3) ); - STKUNIT_ASSERT_EQUAL( (traits.class_info[0].name == "x"), true ); - STKUNIT_ASSERT_EQUAL( (traits.class_info[1].name == "y"), true ); - STKUNIT_ASSERT_EQUAL( (traits.class_info[2].name == "z"), true ); - STKUNIT_ASSERT_EQUAL( traits.class_info[0].traits, & data_traits() ); - STKUNIT_ASSERT_EQUAL( traits.class_info[1].traits, & data_traits() ); - STKUNIT_ASSERT_EQUAL( traits.class_info[2].traits, & data_traits() ); - STKUNIT_ASSERT_EQUAL( traits.class_info[0].offset, dx ); - STKUNIT_ASSERT_EQUAL( traits.class_info[1].offset, dy ); - STKUNIT_ASSERT_EQUAL( traits.class_info[2].offset, dz ); - - // Test data trait basic operations on class type - const unsigned array_size = 1; - Vec3 b ; - traits.construct( & b , array_size ); - traits.copy( & b , & a , array_size ); - STKUNIT_ASSERT_EQUAL( b.x , a.x ); - STKUNIT_ASSERT_EQUAL( b.y , a.y ); - STKUNIT_ASSERT_EQUAL( b.z , a.z ); - - // Test unsupport operations on class type - STKUNIT_ASSERT_THROW(traits.sum (NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.max (NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.min (NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_and(NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_or (NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.bit_xor(NULL, NULL, 0 ), std::runtime_error); - STKUNIT_ASSERT_THROW(traits.print (std::cout, NULL, 0), std::runtime_error); - - // Test data trait pack/unpack (communication) of class type - traits.construct( & b , array_size ); - CommAll comm( pm ); - traits.pack( comm.send_buffer(0) , & a , array_size ); - comm.allocate_buffers( 0 ); - traits.pack( comm.send_buffer(0) , & a , array_size ); - comm.communicate(); - if (p_rank == 0) { - for (int proc_id = 0; proc_id < p_size; ++proc_id) { - traits.unpack( comm.recv_buffer(proc_id) , & b , array_size ); - STKUNIT_ASSERT_EQUAL( a.x , b.x ); - STKUNIT_ASSERT_EQUAL( a.y , b.y ); - STKUNIT_ASSERT_EQUAL( a.z , b.z ); - } - } - - traits.destroy( & b , array_size ); -} - -} - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDeclareElement.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDeclareElement.cpp deleted file mode 100644 index eb437d6a8dc0..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestDeclareElement.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -STKUNIT_UNIT_TEST( UnitTestDeclareElement , inject_shell ) -{ - // This tests creates a small HexFixture with two hexes then, in a separate - // modification cycle, inserts a shell between the two elements. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - // Create the fixture, adding a part for the shell - - stk_classic::mesh::fixtures::HexFixture fixture( pm , 2 , 1 , 1 ); - - const unsigned p_rank = fixture.m_bulk_data.parallel_rank(); - - stk_classic::mesh::Part & shell_part = stk_classic::mesh::fem::declare_part >( fixture.m_fem_meta, "shell_part"); - - fixture.m_fem_meta.commit(); - - fixture.generate_mesh(); - - stk_classic::mesh::Entity * elem = fixture.elem( 0 , 0 , 0 ); - - fixture.m_bulk_data.modification_begin(); - - bool no_throw = true; - - // Whoever owns the 0,0,0 element create the shell and insert it between - // the two elements. - if ( elem != NULL && p_rank == elem->owner_rank() ) { - stk_classic::mesh::EntityId elem_node[4] ; - elem_node[0] = fixture.node_id( 1, 0, 0 ); - elem_node[1] = fixture.node_id( 1, 1, 0 ); - elem_node[2] = fixture.node_id( 1, 1, 1 ); - elem_node[3] = fixture.node_id( 1, 0, 1 ); - - stk_classic::mesh::EntityId elem_id = 3; - - try { - stk_classic::mesh::fem::declare_element( fixture.m_bulk_data, shell_part, elem_id, elem_node); - } - catch (...) { - no_throw = false; - } - - } - fixture.m_bulk_data.modification_end(); - - STKUNIT_EXPECT_TRUE(no_throw); -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestEntity.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestEntity.cpp deleted file mode 100644 index 2c25dbdf955e..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestEntity.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -using stk_classic::ParallelMachine; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::PartRelation; -using stk_classic::mesh::EntityKey; -using stk_classic::mesh::Entity; -using stk_classic::mesh::Bucket; -using stk_classic::mesh::impl::PartRepository; -using stk_classic::mesh::impl::EntityRepository; - -namespace { - -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST(UnitTestEntity,testEntityKey) -{ - EntityKey key_bad_zero = EntityKey(); - EntityKey key_good_0_1 = EntityKey( 0 , 1 ); - EntityKey key_good_1_1 = EntityKey( 1 , 1 ); - EntityKey key_good_2_10 = EntityKey( 2 , 10); - EntityKey key_order_1_12 = EntityKey( 1 , 12 ); - EntityKey key_order_2_10 = EntityKey( 2 , 10 ); - - STKUNIT_ASSERT( ! entity_key_valid( key_bad_zero ) ); - STKUNIT_ASSERT( entity_key_valid( key_good_0_1 ) ); - STKUNIT_ASSERT( entity_key_valid( key_good_1_1 ) ); - STKUNIT_ASSERT( entity_key_valid( key_good_2_10 ) ); - - STKUNIT_ASSERT( 0 == entity_rank( key_good_0_1)); - STKUNIT_ASSERT( 1 == entity_rank( key_good_1_1) ); - STKUNIT_ASSERT( 2 == entity_rank( key_good_2_10) ); - STKUNIT_ASSERT( 1 == entity_id( key_good_0_1) ); - STKUNIT_ASSERT( 1 == entity_id( key_good_1_1) ); - STKUNIT_ASSERT( 10 == entity_id( key_good_2_10) ); - - STKUNIT_ASSERT( key_order_1_12 < key_order_2_10); - STKUNIT_ASSERT( !( key_order_1_12 > key_order_2_10)); - -#ifndef NDEBUG - STKUNIT_ASSERT_THROW( EntityKey( ~0u , 1 ) , std::logic_error ); - STKUNIT_ASSERT_THROW( EntityKey( 0 , ~stk_classic::mesh::EntityKey::raw_key_type(0) ) , std::logic_error ); -#endif // NDEBUG -} - - -STKUNIT_UNIT_TEST(UnitTestEntity,testEntityRepository) -{ - //Test Entity repository - covering EntityRepository.cpp/hpp - const int spatial_dimension = 3; - MetaData meta(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - Part & part = meta.declare_part( "another part"); - MPI_Barrier( MPI_COMM_WORLD ); - ParallelMachine pm = MPI_COMM_WORLD; - BulkData bulk( meta , pm, 200 ); - const int rank = stk_classic::parallel_machine_rank( pm ); - const int size = stk_classic::parallel_machine_size( pm ); - std::vector add_part; - meta.commit(); - - // Bail if not parallel. This test involves inducing errorneous conditions that - // are only checked-for in parallel. - if (size == 1) { - return; - } - - add_part.push_back ( & part ); - - bulk.modification_begin(); - - int id_base = 0; - for ( id_base = 0 ; id_base < 97 ; ++id_base ) - { - int new_id = size * id_base + rank; - bulk.declare_entity( 0 , new_id+1 , add_part ); - } - - int new_id = size * (++id_base) + rank; - stk_classic::mesh::Entity & elem = bulk.declare_entity( 3 , new_id+1 , add_part ); - - bool use_memory_pool = false; - stk_classic::mesh::impl::EntityRepository e(use_memory_pool); - - e.comm_clear( elem ); - - e.comm_clear_ghosting( elem ); - - const stk_classic::mesh::Ghosting & ghost = bulk.shared_aura(); - - STKUNIT_ASSERT_FALSE(e.erase_ghosting(elem, ghost)); - - const stk_classic::mesh::EntityCommInfo comm_info( ghost.ordinal() , 0 ); - - STKUNIT_ASSERT_FALSE(e.erase_comm_info(elem, comm_info)); - - STKUNIT_ASSERT(e.insert_comm_info(elem, comm_info)); - - //Coverage of verfify_parallel_attributes in BulkDataParallelVerify.cpp - //for owned_closure = 1 AND recv_ghost = 1. - //Also uses pack and unpack in DataTraits.cpp, DataTraitsClass.hpp and DataTraitsEnum.hpp - STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error); - - bulk.modification_begin(); - - - //Checking internal_create_entity - - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 2 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 5 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 7 )); - - //Checking get_entity with invalid key - no rank or id - { - STKUNIT_ASSERT_THROW( - e.get_entity(stk_classic::mesh::EntityKey()), - std::runtime_error - ); - } - - // stk_classic::mesh::impl::EntityRepository::EntityMap eMap; - stk_classic::mesh::Entity & elem2 = bulk.declare_entity( 3 , new_id+8 , add_part ); - stk_classic::mesh::Entity & elem3 = bulk.declare_entity( 3 , new_id+9 , add_part ); - stk_classic::mesh::Entity & elem4 = bulk.declare_entity( 3 , new_id+10 , add_part ); - - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, new_id+8 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, new_id+9 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, new_id+10 )); - - typedef std::map EntityMap; - EntityMap entity_map_array; - - entity_map_array[stk_classic::mesh::EntityKey( 3, new_id+8 )] = &elem2; - entity_map_array[stk_classic::mesh::EntityKey( 3, new_id+9 )] = &elem3; - entity_map_array[stk_classic::mesh::EntityKey( 3, new_id+10 )] = &elem4; - - //Coverage of destroy_later in EntityRepository.cpp - Bucket *nil_bucket = bulk.buckets(3)[0]; - e.destroy_later(elem2, nil_bucket); - //Call a second time for more coverage - STKUNIT_ASSERT_THROW(e.destroy_later(elem2, nil_bucket), std::runtime_error); - - //Coverage of !comm_mesh_verify_parallel_consistency in BulkDataEndSync.cpp - //in internal_modification_end function - Bucket *nil_bucket2 = bulk.buckets(0)[0]; - - STKUNIT_ASSERT ( nil_bucket2 != NULL); - - e.destroy_later(elem3, nil_bucket2); - - STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error); - - bulk.modification_begin(); - - STKUNIT_ASSERT_THROW(e.destroy_later(elem2, nil_bucket), std::runtime_error); - - STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error); - - bulk.modification_begin(); - STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error); -} - -//---------------------------------------------------------------------- -}//namespace - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFEMMetaData.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFEMMetaData.cpp deleted file mode 100644 index 6b7c6d600cd1..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFEMMetaData.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -using stk_classic::mesh::fem::FEMMetaData; - -namespace { - -static const stk_classic::mesh::EntityRank NODE_RANK = FEMMetaData::NODE_RANK; -static const stk_classic::mesh::EntityRank EDGE_RANK = FEMMetaData::EDGE_RANK; -static const stk_classic::mesh::EntityRank FACE_RANK = FEMMetaData::FACE_RANK; -static const stk_classic::mesh::EntityRank VOLUME_RANK = FEMMetaData::VOLUME_RANK; -static const stk_classic::mesh::EntityRank INVALID_RANK = FEMMetaData::INVALID_RANK; - -} - -//---------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST ( UnitTestFEMMetaData, create ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - STKUNIT_EXPECT_TRUE ( true ); - STKUNIT_EXPECT_FALSE( fem_meta.is_FEM_initialized() ); - STKUNIT_EXPECT_EQUAL( fem_meta.spatial_dimension(), 0u ); - STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), INVALID_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), INVALID_RANK ); - - // Verify throws/etc for FEM calls prior to initialization: - stk_classic::mesh::fem::CellTopology invalid_cell_topology( NULL ); - stk_classic::mesh::Part & universal_part = fem_meta.universal_part(); - STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( invalid_cell_topology, INVALID_RANK ), std::logic_error ); - STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part( invalid_cell_topology), std::logic_error ); - STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology( universal_part), std::logic_error ); - STKUNIT_ASSERT_THROW( stk_classic::mesh::fem::set_cell_topology( universal_part, invalid_cell_topology), std::logic_error ); - STKUNIT_EXPECT_EQUAL( fem_meta.get_entity_rank( invalid_cell_topology), INVALID_RANK ); - -} - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, initialize ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - STKUNIT_EXPECT_TRUE( fem_meta.is_FEM_initialized() ); - STKUNIT_EXPECT_EQUAL( fem_meta.spatial_dimension(), spatial_dimension ); -} - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, invalid_initialize ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 0; - STKUNIT_ASSERT_THROW( fem_meta.FEM_initialize(spatial_dimension), std::logic_error ); -} - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, initialize_only_once ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - STKUNIT_ASSERT_THROW( fem_meta.FEM_initialize(2), std::logic_error ); -} - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_1 ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 1; - fem_meta.FEM_initialize(spatial_dimension); - STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), EDGE_RANK ); - -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_2 ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), FACE_RANK ); - -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_3 ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), VOLUME_RANK ); -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_4 ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 4; - std::vector entity_rank_names(spatial_dimension+1); - // When using spatial_dimension > 3, you must pass in names. - entity_rank_names[0] = "node"; - entity_rank_names[1] = "super node"; - entity_rank_names[2] = "super duper node"; - entity_rank_names[3] = "particle"; - entity_rank_names[4] = "thing"; - - fem_meta.FEM_initialize(spatial_dimension,entity_rank_names); - STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), VOLUME_RANK ); - STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), 4u ); -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_trivial ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top); - - STKUNIT_EXPECT_TRUE( stk_classic::mesh::is_auto_declared_part(hex_part) ); - STKUNIT_EXPECT_EQUAL( hex_part.primary_entity_rank(), spatial_dimension ); - stk_classic::mesh::fem::CellTopology topology = fem_meta.get_cell_topology(hex_part); - STKUNIT_EXPECT_EQUAL( (topology == hex_top), true ); -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_simple ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top); - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - STKUNIT_EXPECT_TRUE( stk_classic::mesh::is_auto_declared_part(hex_part) ); - STKUNIT_EXPECT_TRUE( !stk_classic::mesh::is_auto_declared_part(A) ); - fem_meta.declare_part_subset( hex_part, A ); - stk_classic::mesh::fem::CellTopology topology = fem_meta.get_cell_topology(A); - STKUNIT_ASSERT_EQUAL( (topology == hex_top), true ); -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_invalid ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part(hex_top), std::runtime_error ); -} - - -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_subsetting ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - const stk_classic::mesh::EntityRank element_rank = spatial_dimension; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::Part & element_part = fem_meta.declare_part("element part", element_rank ); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( element_part, hex_top ); - - stk_classic::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top); - - const stk_classic::mesh::PartVector & element_part_supersets = element_part.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(element_part_supersets.begin(),element_part_supersets.end(),&hex_part), 1 - ); -} - -// 02/16/11: Cell Topology Induced Membership -// -// Invariants: -// 1. Root cell topology parts cannot be subsets of parts with cell topologies -// 2. Incompatible cell topologies are prohibited. I.e. parts with -// different cell topologies of the same rank (as the part) cannot be subsets -// of each other. -// -// Decision tree for declare_part_subset(superset,subset): -// Q: Does the superset part have a topology? -// A: No -// [ Okay, go forward ] (Test 1) -// A: Yes -// Q: Is the subset part a root cell topology part or are any of the subset's parts subsets a root cell topology part? -// A: Yes -// [ Throw ] (Test 2 a,b) -// A: No -// Q: How many cell topologies of the same rank as the superset are defined for the subset part and the subset's subsets parts? -// A: 0 -// [ Okay, go forward ] (Test 3 a,b,c) -// A: 1+ -// Q: Are all the cell topologies the same? -// A: Yes -// [ Okay, go forward ] (Test 4 a,b) -// A: No -// [ Throw ] (Test 5 a,b,c) -// -// Tests: -// The following parts are necessary for the tests [spatial_dimension = 3]: -// Part A, rank 3, no topology -// Part B, rank 3, no topology -// Part C, rank 2, no topology -// Part D, rank 2, no topolooy -// Part E, rank 3, no topology -// Part F, rank 3, no topolooy -// Part H, rank 3, Hex<8> topology, HR > H (HR = Hex<8> root cell topology part) -// Part Q, rank 2, Quad<4> topology, QR > Q (QR = Quad<4> root cell topology part) -// Part W, rank 3, Wedge<6> topology, WR > W (WR = Wedge<6> root cell topology part) -// 1: Part A > HR -> Okay -// 2a: HR > QR -> Throw -// 2b: HR > A, B > QR, A > B -> Throw -// 3a: Subset has no cell topology and subset's subsets have no cell topology -// HR > A -> Okay -// 3b: Different rank cell topology on subset -// QR > D, HR > A, A > D -> Okay -// 3c: Different rank cell topology on subset's subset -// QR > C, B > C, HR > A, A > B -> Okay -// 4a: Subset has same cell topology -// HR > A, HR > B, A > B -> Okay -// 4b: Subset's subsets have same cell topology -// HR > C, B > C, HR > A, A > B -> Okay -// 5a: Subset has different cell topology -// WR > A, HR > B, A > B -> Throw -// 5b: Subset's subsets have different cell topology -// WR > E, B > E, HR > A, A > B -> Throw -// 5c: Multiple different cell topologies in subset's subsets -// HR > F, WR > E, B > F, B > E, HR > A, A > B -> Throw - -// 1: Part A > HR -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_1 ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - - fem_meta.declare_part_subset(A, HR); - const stk_classic::mesh::PartVector & HR_supersets = HR.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(HR_supersets.begin(),HR_supersets.end(),&A), 1 - ); -} - - -// 2a: HR > QR -> Throw -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_2a ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology QR_top(shards::getCellTopologyData >()); - - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - stk_classic::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top); - - STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(HR, QR), std::runtime_error ); -} - - -// 2b: HR > A, B > QR, A > B -> Throw -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_2b ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology QR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top); - - fem_meta.declare_part_subset( HR, A ); - fem_meta.declare_part_subset( B, QR ); - STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error ); -} - - -// 3a: Subset has no cell topology and subset's subsets have no cell topology -// HR > A -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3a ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - fem_meta.declare_part_subset( HR, A ); - - const stk_classic::mesh::PartVector & A_supersets = A.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(A_supersets.begin(),A_supersets.end(),&HR), 1 - ); -} - - -// 3b: Different rank cell topology on subset -// QR > D, HR > A, A > D -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3b ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & D = fem_meta.declare_part("Part D", fem_meta.side_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology QR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top); - - fem_meta.declare_part_subset( QR, D ); - fem_meta.declare_part_subset( HR, A ); - fem_meta.declare_part_subset( A, D ); - - const stk_classic::mesh::PartVector & D_supersets = D.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(D_supersets.begin(),D_supersets.end(),&A), 1 - ); -} - - -// 3c: Different rank cell topology on subset's subset -// QR > C, B > C, HR > A, A > B -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3c ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - stk_classic::mesh::Part & C = fem_meta.declare_part("Part C", fem_meta.side_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology QR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top); - - fem_meta.declare_part_subset( QR, C ); - fem_meta.declare_part_subset( B, C ); - fem_meta.declare_part_subset( HR, A ); - fem_meta.declare_part_subset( A, B ); - - const stk_classic::mesh::PartVector & B_supersets = B.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(B_supersets.begin(),B_supersets.end(),&A), 1 - ); -} - - -// 4a: Subset has same cell topology -// HR > A, HR > B, A > B -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_4a ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - fem_meta.declare_part_subset( HR, A ); - fem_meta.declare_part_subset( HR, B ); - fem_meta.declare_part_subset( A, B ); - - const stk_classic::mesh::PartVector & B_supersets = B.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(B_supersets.begin(),B_supersets.end(),&A), 1 - ); -} - - -// 4b: Subset's subsets have same cell topology -// HR > C, B > C, HR > A, A > B -> Okay -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_4b ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - stk_classic::mesh::Part & C = fem_meta.declare_part("Part C", fem_meta.side_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - fem_meta.declare_part_subset( HR, C ); - fem_meta.declare_part_subset( B, C ); - fem_meta.declare_part_subset( HR, A ); - fem_meta.declare_part_subset( A, B ); - - const stk_classic::mesh::PartVector & B_supersets = B.supersets(); - STKUNIT_EXPECT_EQUAL( - std::count(B_supersets.begin(),B_supersets.end(),&A), 1 - ); -} - - -// 5a: Subset has different cell topology -// WR > A, HR > B, A > B -> Throw -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5a ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology WR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top); - - fem_meta.declare_part_subset( WR, A ); - fem_meta.declare_part_subset( HR, B ); - STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error ); -} - - -// 5b: Subset's subsets have different cell topology -// WR > E, B > E, HR > A, A > B -> Throw -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5b ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - stk_classic::mesh::Part & E = fem_meta.declare_part("Part E", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology WR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top); - - fem_meta.declare_part_subset( WR, E ); - stk_classic::mesh::fem::CellTopology top = fem_meta.get_cell_topology(E); - STKUNIT_ASSERT_TRUE( top.isValid() ); - fem_meta.declare_part_subset( B, E ); - fem_meta.declare_part_subset( HR, A ); - STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error ); -} - - -// 5c: Multiple different cell topologies in subset's subsets -// HR > F, WR > E, B > F, B > E, HR > A, A > B -> Throw -STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5c ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 3; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() ); - stk_classic::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() ); - stk_classic::mesh::Part & F = fem_meta.declare_part("Part F", fem_meta.element_rank() ); - stk_classic::mesh::Part & E = fem_meta.declare_part("Part E", fem_meta.element_rank() ); - - stk_classic::mesh::fem::CellTopology HR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top); - - stk_classic::mesh::fem::CellTopology WR_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top); - - fem_meta.declare_part_subset( HR, F ); - fem_meta.declare_part_subset( WR, E ); - fem_meta.declare_part_subset( B, F ); - fem_meta.declare_part_subset( B, E ); - fem_meta.declare_part_subset( HR, A ); - STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error ); -} - - - - - -STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - const stk_classic::mesh::EntityRank hex_rank = 2; - - fem_meta.register_cell_topology( shards::getCellTopologyData >(), hex_rank ); - STKUNIT_ASSERT_NO_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData >(), hex_rank ) ); -} - - -STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate_with_different_ranks ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - const stk_classic::mesh::EntityRank hex_rank = 2; - const stk_classic::mesh::EntityRank bad_rank = 1; - - fem_meta.register_cell_topology( shards::getCellTopologyData >(), hex_rank ); - STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData >(), bad_rank ), std::runtime_error ); -} - - -STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate_with_invalid_rank ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - const stk_classic::mesh::EntityRank invalid_rank = 3; - - STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData >(), invalid_rank ), std::logic_error ); -} - - -STKUNIT_UNIT_TEST( FEMMetaData, get_cell_topology_root_part_invalid ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - - STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part( hex_top ), std::runtime_error ); -} - - -STKUNIT_UNIT_TEST( FEMMetaData, get_entity_rank_invalid ) -{ - stk_classic::mesh::fem::FEMMetaData fem_meta; - const size_t spatial_dimension = 2; - fem_meta.FEM_initialize(spatial_dimension); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::EntityRank rank = fem_meta.get_entity_rank(hex_top); - - const stk_classic::mesh::EntityRank invalid_rank = INVALID_RANK; - STKUNIT_ASSERT_EQUAL( rank, invalid_rank ); -} - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestField.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestField.cpp deleted file mode 100644 index 89a46bdc0c90..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestField.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef shards::ArrayDimTag::size_type size_type; - -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( ATAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( BTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( CTAG ) - -template< class FieldType > -void print_bucket_array( const FieldType & f , const stk_classic::mesh::Bucket & k ) -{ - typedef stk_classic::mesh::BucketArray< FieldType > ArrayType ; - std::ostringstream oss; - - ArrayType a( f , k.begin(), k.end() ); - ArrayType b( f , k ); - - oss << " BucketArray[" << f.name() << "](" ; - - if ( a.size() != b.size() ) { - throw std::runtime_error("UnitTestField FAILED BucketArray dimensions not consistant with Bucket::iterator"); - } - - if ( a.size() ) { - for ( unsigned i = 0 ; i < ArrayType::Rank ; ++i ) { - if ( i ) { oss << "," ; } - oss << a.dimension(i); - if (a.dimension(i) != b.dimension(i)) { - throw std::runtime_error("UnitTestField FAILED BucketArray dimensions not consistant with Bucket::iterator"); - } - } - } - oss << ")" << std::endl ; -} - -STKUNIT_UNIT_TEST(UnitTestField, testCartesian) -{ - // Test the Cartesian array dimension tag - - const stk_classic::mesh::Cartesian& cartesian_tag = stk_classic::mesh::Cartesian::tag(); - - std::string to_str = cartesian_tag.to_string(3 /*size*/, 1 /*idx*/); - std::string expected_str("y"); - STKUNIT_ASSERT_EQUAL( (to_str == expected_str), true); - - //should throw if we supply a size < 3: - STKUNIT_ASSERT_THROW( cartesian_tag.to_string(2 /*size*/, 1 /*idx*/), - std::runtime_error ); - - size_type expected_idx = 1; - size_type idx = cartesian_tag.to_index(3 /*size*/, "y" /*dim*/); - STKUNIT_ASSERT_EQUAL( idx, expected_idx ); - - //should throw if we supply a "z" along with size==2: - STKUNIT_ASSERT_THROW( cartesian_tag.to_index(2 /*size*/, "z" /*dim*/), - std::runtime_error ); -} - -STKUNIT_UNIT_TEST(UnitTestField, testCylindrical) -{ - // Test the Cylindrical array dimension tag - - const stk_classic::mesh::Cylindrical& cylindrical_tag =stk_classic::mesh::Cylindrical::tag(); - - std::string to_str = cylindrical_tag.to_string(3 /*size*/, 1 /*idx*/); - std::string expected_str("a"); - STKUNIT_ASSERT_EQUAL( (to_str == expected_str), true ); - - //should throw if we supply a size < 3: - STKUNIT_ASSERT_THROW( cylindrical_tag.to_string(2 /*size*/, 1 /*idx*/), - std::runtime_error ); - - size_type expected_idx = 1; - size_type idx = cylindrical_tag.to_index(3 /*size*/, "a" /*dim*/); - STKUNIT_ASSERT_EQUAL( idx, expected_idx ); - - //should throw if we supply a "z" along with size==2: - STKUNIT_ASSERT_THROW( cylindrical_tag.to_index(2 /*size*/, "z" /*dim*/), - std::runtime_error ); -} - -STKUNIT_UNIT_TEST(UnitTestField, testFullTensor) -{ - // Test the FullTensor array dimension tag - - const stk_classic::mesh::FullTensor& fulltensor_tag = stk_classic::mesh::FullTensor::tag(); - - std::string to_str = fulltensor_tag.to_string(9 /*size*/, 1 /*idx*/); - std::string expected_str("yy"); - STKUNIT_ASSERT_EQUAL( (to_str == expected_str), true ); - - //should throw if we supply a size < 9: - STKUNIT_ASSERT_THROW( fulltensor_tag.to_string(2 /*size*/, 1 /*idx*/), - std::runtime_error ); - - size_type expected_idx = 6; - size_type idx = fulltensor_tag.to_index(9 /*size*/, "yx" /*dim*/); - STKUNIT_ASSERT_EQUAL( idx, expected_idx ); - - //should throw if we supply a "zz" along with size==2: - STKUNIT_ASSERT_THROW( fulltensor_tag.to_index(2 /*size*/, "zz" /*dim*/), - std::runtime_error ); -} - -STKUNIT_UNIT_TEST(UnitTestField, testSymmetricTensor) -{ - // Test the SymmetricTensor array dimension tag - - const stk_classic::mesh::SymmetricTensor& symmetrictensor_tag = - stk_classic::mesh::SymmetricTensor::tag(); - - std::string to_str = symmetrictensor_tag.to_string(9 /*size*/, 1 /*idx*/); - std::string expected_str("yy"); - STKUNIT_ASSERT_EQUAL( (to_str == expected_str), true); - - //should throw if we supply a size < 9: - STKUNIT_ASSERT_THROW( symmetrictensor_tag.to_string(2 /*size*/, 1 /*idx*/), - std::runtime_error ); - - size_type expected_idx = 1; - size_type idx = symmetrictensor_tag.to_index(6 /*size*/, "yy" /*dim*/); - STKUNIT_ASSERT_EQUAL( idx, expected_idx ); - - //should throw if we supply a "xz" along with size==5: - STKUNIT_ASSERT_THROW( symmetrictensor_tag.to_index(5 /*size*/, "xz" /*dim*/), - std::runtime_error ); -} - -STKUNIT_UNIT_TEST(UnitTestField, testFieldDataArray) -{ - stk_classic::ParallelMachine pm = MPI_COMM_SELF ; - std::ostringstream oss; // to test printing of things w/out spamming cout - - // specifications for some test fields - typedef stk_classic::mesh::Field rank_zero_field ; - typedef stk_classic::mesh::Field rank_one_field ; - typedef stk_classic::mesh::Field rank_two_field ; - typedef stk_classic::mesh::Field rank_three_field ; - - const std::string name0("test_field_0"); - const std::string name1("test_field_1"); - const std::string name2("test_field_2"); - const std::string name3("test_field_3"); - - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ); - - rank_zero_field & f0 = meta_data.declare_field< rank_zero_field >( name0 ); - rank_one_field & f1 = meta_data.declare_field< rank_one_field >( name1 ); - rank_three_field & f3 = meta_data.declare_field< rank_three_field >( name3 ); - rank_two_field & f2 = meta_data.declare_field< rank_two_field >( name2 ); - - // confirm that declaring field with erroneous type throws exception - typedef stk_classic::mesh::Field error_type ; - STKUNIT_ASSERT_THROW(meta_data.declare_field< error_type >( name1 ), - std::runtime_error); - - stk_classic::mesh::Part & p0 = meta_data.declare_part("P0", NODE_RANK ); - stk_classic::mesh::Part & p1 = meta_data.declare_part("P1", NODE_RANK ); - stk_classic::mesh::Part & p2 = meta_data.declare_part("P2", NODE_RANK ); - stk_classic::mesh::Part & p3 = meta_data.declare_part("P3", NODE_RANK ); - - stk_classic::mesh::put_field( f0 , NODE_RANK , p0 ); - stk_classic::mesh::put_field( f1 , NODE_RANK , p1 , 10 ); - stk_classic::mesh::put_field( f2 , NODE_RANK , p2 , 10 , 20 ); - stk_classic::mesh::put_field( f3 , NODE_RANK , p3 , 10 , 20 , 30 ); - - stk_classic::mesh::print( oss , " " , f0 ); - - meta_data.commit(); - - bulk_data.modification_begin(); - - // Declare a 10 nodes on each part - - for ( unsigned i = 1 ; i < 11 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p0 ) ); - } - - for ( unsigned i = 11 ; i < 21 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p1 ) ); - } - - for ( unsigned i = 21 ; i < 31 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p2 ) ); - } - - for ( unsigned i = 31 ; i < 41 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p3 ) ); - } - - // Go through node_buckets and print the all the fields on each bucket - const std::vector< stk_classic::mesh::Bucket *> & node_buckets = - bulk_data.buckets( NODE_RANK ); - - for ( std::vector< stk_classic::mesh::Bucket *>::const_iterator - ik = node_buckets.begin() ; ik != node_buckets.end() ; ++ik ) { - stk_classic::mesh::Bucket & k = **ik ; - - std::vector< stk_classic::mesh::Part * > parts ; - k.supersets( parts ); - - for ( std::vector< stk_classic::mesh::Part * >::iterator - ip = parts.begin() ; ip != parts.end() ; ++ip ) { - oss << " " << (*ip)->name(); - } - - print_bucket_array( f0 , k ); - print_bucket_array( f1 , k ); - print_bucket_array( f2 , k ); - print_bucket_array( f3 , k ); - } -} - -STKUNIT_UNIT_TEST(UnitTestField, testFieldWithSelector) -{ - stk_classic::ParallelMachine pm = MPI_COMM_SELF ; - std::ostringstream oss; // to test printing of things w/out spamming cout - - // specifications for test field - typedef stk_classic::mesh::Field rank_zero_field ; - - const std::string name0("test_field_0"); - - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ); - - rank_zero_field & f0 = meta_data.declare_field< rank_zero_field >( name0 ); - - stk_classic::mesh::Part & p0 = meta_data.declare_part("P0", NODE_RANK ); - stk_classic::mesh::Part & p1 = meta_data.declare_part("P1", NODE_RANK ); - - stk_classic::mesh::Selector select_p0 = p0; - std::cout <<"select_p0: "<< select_p0 << std::endl; - - stk_classic::mesh::put_field( f0 , NODE_RANK , select_p0 ); - - stk_classic::mesh::print( oss , " " , f0 ); - - meta_data.commit(); - - bulk_data.modification_begin(); - - // Declare 10 nodes on each part - - for ( unsigned i = 1 ; i < 11 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p0 ) ); - } - - for ( unsigned i = 11 ; i < 21 ; ++i ) { - bulk_data.declare_entity( NODE_RANK , i , - std::vector< stk_classic::mesh::Part * >( 1 , & p1 ) ); - } - - const std::vector< stk_classic::mesh::Bucket *> & node_buckets = - bulk_data.buckets( NODE_RANK ); - - unsigned num = stk_classic::mesh::count_selected_entities(select_p0, node_buckets); - - STKUNIT_ASSERT_EQUAL( 10u, num ); - - stk_classic::mesh::Selector select_f0 = stk_classic::mesh::selectField(f0); - - std::cout <<"select_f0: "<< select_f0 << std::endl; - - unsigned num_f0 = stk_classic::mesh::count_selected_entities(select_f0, node_buckets); - STKUNIT_ASSERT_EQUAL(10u, num_f0); - - std::vector f0_buckets; - stk_classic::mesh::get_buckets(select_p0, bulk_data.buckets(NODE_RANK), f0_buckets); - unsigned num_buckets = f0_buckets.size(); - STKUNIT_ASSERT_EQUAL(1u, num_buckets); - - BOOST_FOREACH(stk_classic::mesh::Bucket* b, f0_buckets) { - unsigned f0_size = b->field_data_size(f0); - STKUNIT_ASSERT_EQUAL(8u, f0_size); - } -} - -STKUNIT_UNIT_TEST(UnitTestField, testFieldWithSelectorAnd) -{ - stk_classic::ParallelMachine pm = MPI_COMM_SELF ; - std::ostringstream oss; // to test printing of things w/out spamming cout - - typedef stk_classic::mesh::Field rank_one_field ; - // specifications for test field - - const std::string name0("test_field_0"); - - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ); - - rank_one_field & f0 = meta_data.declare_field< rank_one_field >( name0 ); - - stk_classic::mesh::EntityRank elem_rank = meta_data.element_rank(); - stk_classic::mesh::Part & elements = meta_data.declare_part("Elements", elem_rank); - stk_classic::mesh::Part & hex8s = meta_data.declare_part("Hex8", elem_rank ); - stk_classic::mesh::Part & tet4s = meta_data.declare_part("Tet4", elem_rank ); - - stk_classic::mesh::Selector elem_hex_selector = elements & hex8s; - stk_classic::mesh::Selector elem_tet_selector = elements & tet4s; - std::cout <<"elem_hex_selector: "<< elem_hex_selector << std::endl; - std::cout <<"elem_tet_selector: "<< elem_tet_selector << std::endl; - - stk_classic::mesh::put_field( f0 , elem_rank , elem_hex_selector, 8u ); - stk_classic::mesh::put_field( f0 , elem_rank , elem_tet_selector, 4u ); - - stk_classic::mesh::print( oss , " " , f0 ); - - meta_data.commit(); - - bulk_data.modification_begin(); - - // Declare 10 elements on each part - - stk_classic::mesh::PartVector parts; - parts.push_back(&elements); - parts.push_back(&hex8s); - - for ( unsigned i = 1 ; i < 11 ; ++i ) { - bulk_data.declare_entity( elem_rank , i , parts ); - } - - parts.clear(); - parts.push_back(&elements); - parts.push_back(&tet4s); - - for ( unsigned i = 11 ; i < 21 ; ++i ) { - bulk_data.declare_entity( elem_rank , i , parts ); - } - - stk_classic::mesh::BucketVector f0_buckets; - stk_classic::mesh::get_buckets(elem_hex_selector, bulk_data.buckets(elem_rank), f0_buckets); - - BOOST_FOREACH(stk_classic::mesh::Bucket* b, f0_buckets) { - unsigned f0_size = b->field_data_size(f0); - STKUNIT_ASSERT_EQUAL(64u, f0_size); - } - - f0_buckets.clear(); - - stk_classic::mesh::get_buckets(elem_tet_selector, bulk_data.buckets(elem_rank), f0_buckets); - - BOOST_FOREACH(stk_classic::mesh::Bucket* b, f0_buckets) { - unsigned f0_size = b->field_data_size(f0); - STKUNIT_ASSERT_EQUAL(32u, f0_size); - } -} - - -STKUNIT_UNIT_TEST(UnitTestField, testFieldWithSelectorInvalid) -{ - stk_classic::ParallelMachine pm = MPI_COMM_SELF ; - std::ostringstream oss; // to test printing of things w/out spamming cout - - typedef stk_classic::mesh::Field rank_one_field ; - // specifications for test field - - const std::string name0("test_field_0"); - - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ); - - rank_one_field & f0 = meta_data.declare_field< rank_one_field >( name0 ); - - stk_classic::mesh::EntityRank elem_rank = meta_data.element_rank(); - stk_classic::mesh::Part & hex8s = meta_data.declare_part("Hex8", elem_rank ); - - stk_classic::mesh::Part & universal_part = meta_data.universal_part(); - stk_classic::mesh::Selector elem_hexA_selector = hex8s; - stk_classic::mesh::Selector elem_hexB_selector = universal_part & hex8s; - - std::cout <<"elem_hexA_selector: "<< elem_hexA_selector << std::endl; - std::cout <<"elem_hexB_selector: "<< elem_hexB_selector << std::endl; - - stk_classic::mesh::put_field( f0 , elem_rank , elem_hexA_selector, 8u ); - STKUNIT_ASSERT_THROW( - stk_classic::mesh::put_field( f0 , elem_rank , elem_hexA_selector, 4u ), - std::runtime_error - ); - stk_classic::mesh::put_field( f0 , elem_rank , elem_hexB_selector, 4u ); - - stk_classic::mesh::print( oss , " " , f0 ); - - meta_data.commit(); - - bulk_data.modification_begin(); - - stk_classic::mesh::PartVector parts; - parts.push_back(&hex8s); - STKUNIT_ASSERT_THROW( - bulk_data.declare_entity( elem_rank , 1 , parts ), - std::runtime_error - ); - -} - -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( ATAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( BTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( CTAG ) - -} //namespace - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldDataInitVal.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldDataInitVal.cpp deleted file mode 100644 index 5d95eee5dd8b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldDataInitVal.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::Part; -using stk_classic::mesh::Field; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::fem::FEMMetaData; - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST(UnitTestFieldDataInitVal, test_scalar_field) -{ - // Test that if an initial-value is set on a scalar field, that value is - // present the first time field-data is referenced for that field. - // - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - - const unsigned num_states = 1; - Field& dfield = meta_data.declare_field >("double_scalar", num_states); - - const double initial_value = 99.9; - - stk_classic::mesh::put_field(dfield, NODE_RANK, meta_data.universal_part(), &initial_value); - - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create stuff - mesh.modification_begin(); - - // Node will be automatically added to the universal part - stk_classic::mesh::PartVector empty_parts; - - EntityId node_id = p_rank+1; - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, node_id, empty_parts); - - mesh.modification_end(); - - //now insist that data for dfield on node is equal to the initial-value specified above: - - double* data_ptr = stk_classic::mesh::field_data( dfield, node); - - STKUNIT_ASSERT_EQUAL( *data_ptr, initial_value ); -} - -STKUNIT_UNIT_TEST(UnitTestFieldDataInitVal, test_vector_field) -{ - // Test that if an initial-value is set on a vector field, that value is - // present the first time field-data is referenced for that field. - // - - typedef stk_classic::mesh::Field VectorField; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - - const unsigned num_states = 1; - VectorField& vfield = meta_data.declare_field("double_vector", num_states); - - const double initial_value[stk_classic::mesh::Cartesian2d::Size] = { 50.0, 99.0 }; - - stk_classic::mesh::put_field(vfield, NODE_RANK, meta_data.universal_part(), stk_classic::mesh::Cartesian2d::Size, initial_value); - - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create stuff - mesh.modification_begin(); - - // Node will be automatically added to the universal part - stk_classic::mesh::PartVector empty_parts; - - EntityId node_id = p_rank+1; - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, node_id, empty_parts); - - mesh.modification_end(); - - //now insist that data for vfield on node is equal to the initial-value specified above: - - double* data_ptr = stk_classic::mesh::field_data( vfield, node); - - STKUNIT_ASSERT_EQUAL( data_ptr[0], initial_value[0] ); - STKUNIT_ASSERT_EQUAL( data_ptr[1], initial_value[1] ); -} - -STKUNIT_UNIT_TEST(UnitTestFieldDataInitVal, test_vector_field_move_bucket) -{ - // Test that if an initial-value is set on a vector field, that value is - // present the first time field-data is referenced for that field, and - // that the value is present for a node that is moved from a bucket without - // the field to a new bucket that does have the field. - // - - typedef stk_classic::mesh::Field VectorField; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - - const unsigned num_states = 1; - VectorField& vfield = meta_data.declare_field("double_vector", num_states); - - const double initial_value[stk_classic::mesh::Cartesian2d::Size] = { 50.0, 99.0 }; - - Part& node_part = meta_data.declare_part("node_part"); - - stk_classic::mesh::put_field(vfield, NODE_RANK, node_part, stk_classic::mesh::Cartesian2d::Size, initial_value); - - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create stuff - mesh.modification_begin(); - - // Node will be automatically added to the universal part - stk_classic::mesh::PartVector empty_parts; - - EntityId node_id = p_rank+1; - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, node_id, empty_parts); - - stk_classic::mesh::Bucket& old_bucket = node.bucket(); - - //Now move the node to the "node_part": - stk_classic::mesh::PartVector node_part_vec; - node_part_vec.push_back(&node_part); - mesh.change_entity_parts(node, node_part_vec); - - mesh.modification_end(); - - //Insist that the node is now in a different bucket: - stk_classic::mesh::Bucket& new_bucket = node.bucket(); - STKUNIT_ASSERT_NE(&old_bucket, &new_bucket); - - //now insist that data for vfield on node is equal to the initial-value specified above: - - double* data_ptr = stk_classic::mesh::field_data( vfield, node); - - STKUNIT_ASSERT_EQUAL( data_ptr[0], initial_value[0] ); - STKUNIT_ASSERT_EQUAL( data_ptr[1], initial_value[1] ); -} - -STKUNIT_UNIT_TEST(UnitTestFieldDataInitVal, test_multi_state_vector_field) -{ - // Test that if an initial-value is set on a multi-state vector field, that value is - // present the first time field-data is referenced for that field. - // - - typedef stk_classic::mesh::Field VectorField; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - - const unsigned num_states = 2; - VectorField& vfield = meta_data.declare_field("double_vector", num_states); - - const double initial_value[stk_classic::mesh::Cartesian2d::Size] = { 50.0, 99.0 }; - - stk_classic::mesh::put_field(vfield, NODE_RANK, meta_data.universal_part(), stk_classic::mesh::Cartesian2d::Size, initial_value); - - meta_data.commit(); - - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create stuff - mesh.modification_begin(); - - // Node will be automatically added to the universal part - stk_classic::mesh::PartVector empty_parts; - - EntityId node_id = p_rank+1; - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, node_id, empty_parts); - - mesh.modification_end(); - - //now insist that data for vfield on node is equal to the initial-value specified above: - - STKUNIT_ASSERT_EQUAL( vfield.number_of_states(), num_states); - - VectorField& vfield_new = vfield.field_of_state(stk_classic::mesh::StateNew); - VectorField& vfield_old = vfield.field_of_state(stk_classic::mesh::StateOld); - - double* data_ptr_new = stk_classic::mesh::field_data( vfield_new, node); - double* data_ptr_old = stk_classic::mesh::field_data( vfield_old, node); - - STKUNIT_ASSERT_EQUAL( data_ptr_new[0], initial_value[0] ); - STKUNIT_ASSERT_EQUAL( data_ptr_new[1], initial_value[1] ); - - STKUNIT_ASSERT_EQUAL( data_ptr_old[0], initial_value[0] ); - STKUNIT_ASSERT_EQUAL( data_ptr_old[1], initial_value[1] ); -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldImpl.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldImpl.cpp deleted file mode 100644 index 384a8975d61f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldImpl.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -class UnitTestFieldImpl { -public: - UnitTestFieldImpl() {} - - void testField(); - void testFieldRestriction(); - void testFieldRelation(); - -}; - -}//namespace mesh -}//namespace stk_classic - -namespace { - -STKUNIT_UNIT_TEST(UnitTestField, testUnit) -{ - stk_classic::mesh::UnitTestFieldImpl ufield; - ufield.testField(); -} - -STKUNIT_UNIT_TEST(UnitTestFieldRestriction, testUnit) -{ - stk_classic::mesh::UnitTestFieldImpl ufield; - ufield.testFieldRestriction(); -} - -STKUNIT_UNIT_TEST(UnitTestFieldRelation, testUnit) -{ - stk_classic::mesh::UnitTestFieldImpl ufield; - ufield.testFieldRelation(); -} - -}//namespace - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { - -namespace { - -// Simple tags for testing field dimensions - -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( ATAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( BTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( CTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( DTAG ) - -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( ATAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( BTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( CTAG ) -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( DTAG ) - -} - -void UnitTestFieldImpl::testField() -{ - MetaData meta_data; - - // Declaration of a field allocates one field object - // per state of the field. These fields are inserted - // into a vector of fields of the base class. - - impl::FieldRepository field_repo; - const FieldVector & allocated_fields = field_repo.get_fields(); - - //------------------------------ - // Declare a double precision scalar field of one state. - // Not an array; therefore, is rank zero. - // Test the query methods for accuracy. - FieldBase * const fA = - field_repo.declare_field( std::string("A"), - data_traits() , - 0 /* # Ranks */ , - NULL /* dimension tags */ , - 1 /* # States */ , - &meta_data ); - - STKUNIT_ASSERT( allocated_fields.size() == 1 ); - STKUNIT_ASSERT( fA != NULL ); - STKUNIT_ASSERT( fA == allocated_fields[0] ); - STKUNIT_ASSERT( fA->name() == std::string("A") ); - STKUNIT_ASSERT( fA->type_is() ); - STKUNIT_ASSERT( fA->state() == StateNone ); - STKUNIT_ASSERT( fA->rank() == 0 ); - - //------------------------------ - // Declare a field with an invalid suffix in its name. - // Suffixes corresponding to "OLD" "N" "NM1" "NM2" "NM3" "NM4" - // are not allowed as these are automatically appended to - // the declared variable name for multistate fields. - { - STKUNIT_ASSERT_THROW( - field_repo.declare_field( "A_STKFS_OLD" , - data_traits() , - 0 /* # Ranks */ , - NULL /* dimension tags */ , - 1 /* # States */ , - &meta_data ), - std::runtime_error); - STKUNIT_ASSERT( allocated_fields.size() == 1 ); - } - - //------------------------------ - // Declare a double precision scalar field of two states. - // Not an array; therefore, is rank zero. - // Test that two fields: "B" and "B_OLD" were created. - // Test the query methods for accuracy. - - FieldBase * const fB = - field_repo.declare_field( std::string("B"), - data_traits(), - 0 /* # Ranks */ , - NULL /* dimension tags */ , - 2 /* # States */ , - &meta_data ); - - STKUNIT_ASSERT( allocated_fields.size() == 3 ); - STKUNIT_ASSERT( fB != NULL ); - STKUNIT_ASSERT( fB == allocated_fields[1] ); - STKUNIT_ASSERT( fB->name() == std::string("B") ); - STKUNIT_ASSERT( fB->type_is() ); - STKUNIT_ASSERT( fB->state() == StateNew ); - STKUNIT_ASSERT( fB->rank() == 0 ); - - const FieldBase * const fB_old = allocated_fields[2] ; - STKUNIT_ASSERT( fB_old->name() == std::string("B_STKFS_OLD") ); - STKUNIT_ASSERT( fB_old->type_is() ); - STKUNIT_ASSERT( fB_old->state() == StateOld ); - STKUNIT_ASSERT( fB_old->rank() == 0 ); - - //------------------------------ - // Redeclare field must give back the previous field: - - FieldBase * const fB_redundant = - field_repo.declare_field( std::string("B"), - data_traits(), - 0 /* # Ranks */ , - NULL /* dimension tags */ , - 2 /* # States */ , - &meta_data ); - - STKUNIT_ASSERT( allocated_fields.size() == 3 ); - STKUNIT_ASSERT( fB == fB_redundant ); - - //------------------------------ - // Declare a double precision array field of four states. - // Test that four fields: were created. - // Test the query methods for accuracy. - - const shards::ArrayDimTag * dim_tags[] = - { & ATAG::tag() , & BTAG::tag() , & CTAG::tag() , & DTAG::tag() }; - - FieldBase * const fC = - field_repo.declare_field( std::string("C"), - data_traits(), - 3 /* # Ranks */ , - dim_tags /* dimension tags */ , - 4 /* # States */ , - &meta_data ); - - STKUNIT_ASSERT( allocated_fields.size() == 7 ); - STKUNIT_ASSERT( fC != NULL ); - STKUNIT_ASSERT( fC == allocated_fields[3] ); - STKUNIT_ASSERT( fC->name() == std::string("C") ); - STKUNIT_ASSERT( fC->type_is() ); - STKUNIT_ASSERT( fC->state() == StateNew ); - STKUNIT_ASSERT( fC->rank() == 3 ); - - const FieldBase * const fC_n = allocated_fields[4] ; - const FieldBase * const fC_nm1 = allocated_fields[5] ; - const FieldBase * const fC_nm2 = allocated_fields[6] ; - - STKUNIT_ASSERT( fC == fC->field_state( StateNP1 ) ); - STKUNIT_ASSERT( fC_n == fC->field_state( StateN ) ); - STKUNIT_ASSERT( fC_nm1 == fC->field_state( StateNM1 ) ); - STKUNIT_ASSERT( fC_nm2 == fC->field_state( StateNM2 ) ); - - STKUNIT_ASSERT( fC == fC_n->field_state( StateNP1 ) ); - STKUNIT_ASSERT( fC_n == fC_n->field_state( StateN ) ); - STKUNIT_ASSERT( fC_nm1 == fC_n->field_state( StateNM1 ) ); - STKUNIT_ASSERT( fC_nm2 == fC_n->field_state( StateNM2 ) ); - - STKUNIT_ASSERT( fC == fC_nm1->field_state( StateNP1 ) ); - STKUNIT_ASSERT( fC_n == fC_nm1->field_state( StateN ) ); - STKUNIT_ASSERT( fC_nm1 == fC_nm1->field_state( StateNM1 ) ); - STKUNIT_ASSERT( fC_nm2 == fC_nm1->field_state( StateNM2 ) ); - - STKUNIT_ASSERT( fC == fC_nm2->field_state( StateNP1 ) ); - STKUNIT_ASSERT( fC_n == fC_nm2->field_state( StateN ) ); - STKUNIT_ASSERT( fC_nm1 == fC_nm2->field_state( StateNM1 ) ); - STKUNIT_ASSERT( fC_nm2 == fC_nm2->field_state( StateNM2 ) ); - - STKUNIT_ASSERT( fC_n->name() == std::string("C_STKFS_N") ); - STKUNIT_ASSERT( fC_n->type_is() ); - STKUNIT_ASSERT( fC_n->state() == StateN ); - STKUNIT_ASSERT( fC_n->rank() == 3 ); - - STKUNIT_ASSERT( fC_nm1->name() == std::string("C_STKFS_NM1") ); - STKUNIT_ASSERT( fC_nm1->type_is() ); - STKUNIT_ASSERT( fC_nm1->state() == StateNM1 ); - STKUNIT_ASSERT( fC_nm1->rank() == 3 ); - - STKUNIT_ASSERT( fC_nm2->name() == std::string("C_STKFS_NM2") ); - STKUNIT_ASSERT( fC_nm2->type_is() ); - STKUNIT_ASSERT( fC_nm2->state() == StateNM2 ); - STKUNIT_ASSERT( fC_nm2->rank() == 3 ); - - //------------------------------ - // Redeclare field must give back the previous field: - //------------------------------ - - for ( unsigned i = 0 ; i < allocated_fields.size() ; ++i ) { - FieldBase * const f = allocated_fields[i] ; - STKUNIT_ASSERT( f->mesh_meta_data_ordinal() == i ); - } - - //Coverage of EntityDimension::name in FieldData.cpp - { - const stk_classic::mesh::EntityDimension& entity_dimension_tag = stk_classic::mesh::EntityDimension::tag(); - // static const char * name(); - - entity_dimension_tag.name(); - } -} - - -//---------------------------------------------------------------------- -// Test field restrictions: the mapping of ( field , part ) -> dimensions - -void UnitTestFieldImpl::testFieldRestriction() -{ - unsigned stride[8] ; - - stride[0] = 10 ; - for ( unsigned i = 1 ; i < 8 ; ++i ) { - stride[i] = ( i + 1 ) * stride[i-1] ; - } - - std::vector< std::string > dummy_names(1); - dummy_names[0].assign("dummy"); - - MetaData meta_data(dummy_names); - - const FieldVector & allocated_fields = meta_data.get_fields(); - - //------------------------------ - - typedef stk_classic::mesh::Field VectorField; - - FieldBase * const f2 = - &meta_data.declare_field( std::string("F2"), 1/* # states */ ); - - //------------------------------ - - FieldBase * const f3 = - &meta_data.declare_field( std::string("F3"), 2/* #states*/); - - FieldBase * const f3_old = f3->field_state( StateOld ) ; - - //------------------------------ - // Test for correctness of vector of declared fields. - STKUNIT_ASSERT( allocated_fields.size() == 3 ); - STKUNIT_ASSERT( f2 == allocated_fields[0] ); - STKUNIT_ASSERT( f3 == allocated_fields[1] ); - - //------------------------------ - // Test for correctness of field internal state access: - - STKUNIT_ASSERT( f2 == f2->field_state( StateNone ) ); - STKUNIT_ASSERT( NULL == f2->field_state( StateOld ) ); - STKUNIT_ASSERT( f3 == f3->field_state( StateNew ) ); - STKUNIT_ASSERT( f3_old == f3->field_state( StateOld ) ); - STKUNIT_ASSERT( NULL == f3->field_state( StateNM1 ) ); - STKUNIT_ASSERT( f3 == f3_old->field_state( StateNew ) ); - STKUNIT_ASSERT( f3_old == f3_old->field_state( StateOld ) ); - STKUNIT_ASSERT( NULL == f3_old->field_state( StateNM1 ) ); - - //------------------------------ - // Declare some parts for restrictions: - - Part & pA = meta_data.declare_part( std::string("A") , 0 ); - Part & pB = meta_data.declare_part( std::string("B") , 0 ); - Part & pC = meta_data.declare_part( std::string("C") , 0 ); - Part & pD = meta_data.declare_part( std::string("D") , 0 ); - - // Declare three restrictions: - - meta_data.declare_field_restriction(*f3, 0 , pA , stride ); - meta_data.declare_field_restriction(*f3, 1 , pB , stride + 1 ); - meta_data.declare_field_restriction(*f3, 2 , pC , stride + 2 ); - - // Check for correctness of restrictions: - - STKUNIT_ASSERT( f3->restrictions().size() == 3 ); - STKUNIT_ASSERT( f3->restrictions()[0] == - FieldRestriction( 0 , pA.mesh_meta_data_ordinal() ) ); - STKUNIT_ASSERT( f3->restrictions()[1] == - FieldRestriction( 1 , pB.mesh_meta_data_ordinal() ) ); - STKUNIT_ASSERT( f3->restrictions()[2] == - FieldRestriction( 2 , pC.mesh_meta_data_ordinal() ) ); - - meta_data.declare_field_restriction(*f3, 0 , pB , stride + 1 ); - - STKUNIT_ASSERT_EQUAL( f3->max_size( 0 ) , 20u ); - - //------------------------------ - // Check for error detection of bad stride: - { - unsigned bad_stride[4] = { 5 , 4 , 6 , 3 }; - STKUNIT_ASSERT_THROW( - meta_data.declare_field_restriction(*f3, 0 , pA , bad_stride ), - std::runtime_error - ); - STKUNIT_ASSERT( f3->restrictions().size() == 4 ); - } - - // Check for error detection in re-declaring an incompatible - // field restriction. - { - STKUNIT_ASSERT_THROW( - meta_data.declare_field_restriction(*f3, 0 , pA , stride + 1 ), - std::runtime_error - ); - STKUNIT_ASSERT( f3->restrictions().size() == 4 ); - } - - // Verify and clean out any redundant restructions: - - STKUNIT_ASSERT( f3->restrictions().size() == 4 ); - - //------------------------------ - // Introduce a redundant restriction, clean it, and - // check that it was cleaned. - -std::cout<<"pA ord: "<restrictions().size() == 1 ); - - { - const FieldBase::Restriction & rA = f2->restriction( 0 , pA ); - const FieldBase::Restriction & rD = f2->restriction( 0 , pD ); - STKUNIT_ASSERT( & rA == & rD ); - STKUNIT_ASSERT( rA.part_ordinal() == pD.mesh_meta_data_ordinal() ); - } - - //------------------------------ - // Introduce a new restriction, then introduce a - // subset-superset relationship that renders the new restriction - // redundant and incompatible. - // Check that the verify_and_clean_restrictions method detects - // this error condition. - { - meta_data.declare_field_restriction(*f2, 0 , pB , stride + 1 ); - STKUNIT_ASSERT_THROW( - meta_data.declare_part_subset( pD, pB ), - std::runtime_error - ); - } - - //Test to cover print function in FieldBaseImpl.cpp and FieldBase.cpp - { - //Create a new field with MetaData m and two restrictions - - FieldBase * const f4 = - &meta_data.declare_field( std::string("F4"), - 2 /* # states */ ); - - meta_data.declare_part_subset( pD, pA ); - meta_data.declare_part_subset( pC, pB ); - - meta_data.declare_field_restriction(*f4, 0 , pA , stride ); - meta_data.declare_field_restriction(*f4, 1 , pB , stride + 1 ); - stk_classic::mesh::impl::print(std::cout, "Field f4", *f4); - - //test stride[i] / stride[i-1] section of else-if - stk_classic::mesh::print(std::cout, "Field f4", *f4); - } - - //Further tests to cover print function in FieldBase.cpp - { - //test stride[i] % stride[i-1] section of else-if - - //Create a new field with MetaData m and two restrictions - - FieldBase * const f5 = - &meta_data.declare_field( std::string("F5"), - 2 /* # states */ ); - - unsigned stride2[8] ; - stride2[0] = 10 ; - for ( unsigned i = 1 ; i < 3 ; ++i ) { - stride2[i] = stride[i-1]; - } - for ( unsigned i = 3 ; i < 8 ; ++i ) { - stride2[i] = 0; - } - meta_data.declare_field_restriction(*f5, 0 , pA, stride2 ); - - stk_classic::mesh::print(std::cout, "Field f5", *f5); - - } - - //Coverage for error from print_restriction in FieldBaseImpl.cpp when there is no stride (!stride[i]) - //Call print_restriction from insert_restriction - { - unsigned arg_no_stride[2]; - - arg_no_stride[0] = 1; - arg_no_stride[1] = 0; - - STKUNIT_ASSERT_THROW( - meta_data.declare_field_restriction(*f2, 0, pA, arg_no_stride), - std::runtime_error - ); - } - - //Coverage of ordinal in FieldRestriction.hpp: - { - const FieldRestrictionVector & rMap = f3->restrictions(); - const FieldRestrictionVector::const_iterator ie = rMap.end() ; - FieldRestrictionVector::const_iterator i = rMap.begin(); - - EntityId entity_id = 0; - unsigned max = 0 ; - - for ( ; i != ie ; ++i ) { - if ( i->part_ordinal() == entity_id ) { - const unsigned len = pA.mesh_meta_data_ordinal() ? i->stride( pA.mesh_meta_data_ordinal() - 1 ) : 1 ; - if ( max < len ) { max = len ; } - } - } - } -} - -// Unit test the FieldRelation copy constructor: -void UnitTestFieldImpl::testFieldRelation() -{ - - FieldRelation rA; - FieldRelation rB(rA); - - rA = rB; - -} - -} -} - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldRestriction.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldRestriction.cpp deleted file mode 100644 index 4d4a11328184..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestFieldRestriction.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include -#include - -namespace { - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, defaultConstruct ) -{ - stk_classic::mesh::FieldRestriction fr; - STKUNIT_EXPECT_EQ( fr.part_ordinal(), stk_classic::mesh::InvalidPartOrdinal ); - for (stk_classic::mesh::Ordinal i = 0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i) { - STKUNIT_EXPECT_EQ( fr.stride(i), 0 ); - } - STKUNIT_EXPECT_EQ( fr.dimension(), 0 ); -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, construct ) -{ - stk_classic::mesh::FieldRestriction fr(1,2); - for (stk_classic::mesh::Ordinal i = 0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i) { - fr.stride(i) = i+1; - } - - STKUNIT_EXPECT_EQ( fr.entity_rank(), 1u ); - STKUNIT_EXPECT_EQ( fr.part_ordinal(), 2u ); - const int max_field_dimension = stk_classic::mesh::MaximumFieldDimension; - for (int i = 0 ; i < max_field_dimension ; ++i) { - STKUNIT_EXPECT_EQ( fr.stride(i), i+1 ); - } - STKUNIT_EXPECT_EQ( fr.dimension(), 1 ); -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, copyConstruct ) -{ - stk_classic::mesh::FieldRestriction fr(1,2); - for (stk_classic::mesh::Ordinal i = 0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i) { - fr.stride(i) = i+1; - } - - stk_classic::mesh::FieldRestriction tmpfr(fr); - STKUNIT_EXPECT_EQ( tmpfr.entity_rank(), 1u ); - STKUNIT_EXPECT_EQ( tmpfr.part_ordinal(), 2u ); - const int max_field_dimension = stk_classic::mesh::MaximumFieldDimension; - for (int i = 0 ; i < max_field_dimension ; ++i) { - STKUNIT_EXPECT_EQ( tmpfr.stride(i), i+1 ); - } - STKUNIT_EXPECT_EQ( tmpfr.dimension(), 1 ); -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, operatorEqual ) -{ - stk_classic::mesh::FieldRestriction fr(1,2); - for (stk_classic::mesh::Ordinal i = 0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i) { - fr.stride(i) = i+1; - } - stk_classic::mesh::FieldRestriction tmpfr(3,4); - for (stk_classic::mesh::Ordinal i = 0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i) { - tmpfr.stride(i) = i+10; - } - - tmpfr = fr; - STKUNIT_EXPECT_EQ( tmpfr.entity_rank(), 1u ); - STKUNIT_EXPECT_EQ( tmpfr.part_ordinal(), 2u ); - const int max_field_dimension = stk_classic::mesh::MaximumFieldDimension; - for (int i = 0 ; i < max_field_dimension ; ++i) { - STKUNIT_EXPECT_EQ( tmpfr.stride(i), i+1 ); - } - STKUNIT_EXPECT_EQ( tmpfr.dimension(), 1 ); -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, operatorLess ) -{ - { - stk_classic::mesh::FieldRestriction frA(1,1); - stk_classic::mesh::FieldRestriction frB(1,2); - STKUNIT_EXPECT_EQ( frA < frB, true ); - STKUNIT_EXPECT_EQ( frB < frA, false ); - } - { - stk_classic::mesh::FieldRestriction frA(1,1); - stk_classic::mesh::FieldRestriction frB(2,1); - STKUNIT_EXPECT_EQ( frA < frB, true ); - STKUNIT_EXPECT_EQ( frB < frA, false ); - } - { - stk_classic::mesh::FieldRestriction frA(0,1); - stk_classic::mesh::FieldRestriction frB(1,2); - STKUNIT_EXPECT_EQ( frA < frB, true ); - STKUNIT_EXPECT_EQ( frB < frA, false ); - } -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, operatorLessInvalid ) -{ - stk_classic::mesh::FieldRestriction frA(1,2); - stk_classic::mesh::FieldRestriction frB; - STKUNIT_EXPECT_EQ( frA < frB, true ); - STKUNIT_EXPECT_EQ( frB < frA, false ); -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, operatorEqualEqual_and_NotEqual ) -{ - { - stk_classic::mesh::FieldRestriction frA(1,2); - frA.stride(0) = 25; - stk_classic::mesh::FieldRestriction frB(1,2); - frB.stride(0) = 10; - STKUNIT_EXPECT_EQ( frA == frB, true ); - STKUNIT_EXPECT_EQ( frA != frB, false ); - } - { - stk_classic::mesh::FieldRestriction frA(1,1); - frA.stride(0) = 3; - stk_classic::mesh::FieldRestriction frB(1,2); - frB.stride(0) = 3; - STKUNIT_EXPECT_EQ( frA == frB, false ); - STKUNIT_EXPECT_EQ( frA != frB, true ); - } - { - stk_classic::mesh::FieldRestriction frA(1,2); - stk_classic::mesh::FieldRestriction frB(2,2); - STKUNIT_EXPECT_EQ( frA == frB, false ); - STKUNIT_EXPECT_EQ( frA != frB, true ); - } - { - stk_classic::mesh::FieldRestriction frA; - stk_classic::mesh::FieldRestriction frB; - STKUNIT_EXPECT_EQ( frA == frB, true ); - STKUNIT_EXPECT_EQ( frA != frB, false ); - } -} - - -STKUNIT_UNIT_TEST( UnitTestFieldRestriction, not_equal_stride ) -{ - { - stk_classic::mesh::FieldRestriction frA(1,2); - frA.stride(0) = 25; - stk_classic::mesh::FieldRestriction frB(1,2); - frB.stride(0) = 10; - STKUNIT_EXPECT_EQ( frA.not_equal_stride(frB), true ); - STKUNIT_EXPECT_EQ( frB.not_equal_stride(frA), true ); - } - { - stk_classic::mesh::FieldRestriction frA(1,2); - for (stk_classic::mesh::Ordinal i=0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i ) { - frA.stride(0) = i+1; - } - stk_classic::mesh::FieldRestriction frB(1,2); - for (stk_classic::mesh::Ordinal i=0 ; i < stk_classic::mesh::MaximumFieldDimension ; ++i ) { - frB.stride(0) = i+1; - } - STKUNIT_EXPECT_EQ( frA.not_equal_stride(frB), false ); - STKUNIT_EXPECT_EQ( frB.not_equal_stride(frA), false ); - frB.stride(stk_classic::mesh::MaximumFieldDimension-1) = 1; - STKUNIT_EXPECT_EQ( frA.not_equal_stride(frB), true ); - STKUNIT_EXPECT_EQ( frB.not_equal_stride(frA), true ); - } -} - - -} //namespace - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGenerateNewEntities.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGenerateNewEntities.cpp deleted file mode 100644 index 28af5d91713b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGenerateNewEntities.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include -#include - -#include - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST( UnitTestStkMeshGenerateNewEntities , testUnit ) -{ - // Test BulkData's generate_new_entities method. - - stk_classic::ParallelMachine pm(MPI_COMM_WORLD); - - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ); - - meta_data.commit(); - - const stk_classic::mesh::PartVector no_parts; - - bulk_data.modification_begin(); - - bulk_data.declare_entity(NODE_RANK, bulk_data.parallel_rank() + 1, no_parts); - - bulk_data.modification_end(); - - // Create a request vector for 2 new nodes on each processor - size_t num_nodes_requested = 2; - std::vector requests(meta_data.entity_rank_count(), 0); - requests[0] = num_nodes_requested; - - bulk_data.modification_begin(); - - // generate_new_entities creates new blank entities of the requested ranks - stk_classic::mesh::EntityVector new_nodes; - bulk_data.generate_new_entities(requests, new_nodes); - STKUNIT_ASSERT_EQ(new_nodes.size(), num_nodes_requested); - - // confirm that the nodes we created earlier are not in the new entities - for (stk_classic::mesh::EntityVector::const_iterator itr = new_nodes.begin(); - itr != new_nodes.end(); ++itr) { - STKUNIT_ASSERT_GT((*itr)->identifier(), bulk_data.parallel_size()); - } - - bulk_data.modification_end(); -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGetBuckets.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGetBuckets.cpp deleted file mode 100644 index c0bc57b03f5d..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGetBuckets.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include - -namespace { - -using stk_classic::mesh::Bucket; -using stk_classic::mesh::Part; -using stk_classic::mesh::Selector; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Entity; - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -// Just make copies so we don't have to worry about constness -template -void sort_and_compare_eq(std::vector results, - std::vector expected_results) -{ - std::sort(expected_results.begin(), expected_results.end()); - std::sort(results.begin(), results.end()); - STKUNIT_ASSERT_EQ(results.size(), expected_results.size()); - for (unsigned i = 0; i < results.size(); ++i) { - STKUNIT_ASSERT(results[i] == expected_results[i]); - } -} - -#if 0 - // the selected bucket itertor is broken - // \TODO fix -void check_selected_buckets(const Selector& selector, - const BulkData& mesh, - const std::vector& node_buckets, - const std::vector& expected_selected_entities) -{ - // - // Check buckets - // - - std::vector get_buckets, get_buckets_range, get_buckets_alt_range, expected_buckets; - std::set selected_bucket_set; - - // Compute vector of buckets that should be selected - BOOST_FOREACH( Entity* entity, expected_selected_entities ) { - selected_bucket_set.insert(&(entity->bucket())); - } - std::copy(selected_bucket_set.begin(), selected_bucket_set.end(), std::back_inserter(expected_buckets)); - - // get buckets selected by selector - stk_classic::mesh::get_buckets(selector, node_buckets, get_buckets); - - // get buckets selected by selector using range API - // all buckets are node buckets, so this should work - stk_classic::mesh::AllSelectedBucketsRange buckets_range = stk_classic::mesh::get_buckets(selector, mesh); - for (stk_classic::mesh::AllSelectedBucketsIterator buckets_itr = boost::begin(buckets_range), buckets_end = boost::end(buckets_range); - buckets_itr != buckets_end; - ++buckets_itr) { - get_buckets_range.push_back(*buckets_itr); - } - //BOOST_FOREACH( Bucket* bucket, stk_classic::mesh::get_buckets(selector, mesh) ) { - // get_buckets_range.push_back(bucket); - //} - - // get buckets selected by selector using alteranate range API - // all buckets are node buckets, so this should work - stk_classic::mesh::AllBucketsRange all_buckets = stk_classic::mesh::get_buckets(mesh); - buckets_range = stk_classic::mesh::get_buckets(selector, all_buckets); - for (stk_classic::mesh::AllSelectedBucketsIterator buckets_itr = boost::begin(buckets_range), buckets_end = boost::end(buckets_range); - buckets_itr != buckets_end; - ++buckets_itr) { - get_buckets_alt_range.push_back(*buckets_itr); - } - //BOOST_FOREACH( Bucket* bucket, stk_classic::mesh::get_buckets(selector, all_buckets) ) { - // get_buckets_alt_range.push_back(bucket); - //} - - sort_and_compare_eq(get_buckets, expected_buckets); - sort_and_compare_eq(get_buckets_range, expected_buckets); - sort_and_compare_eq(get_buckets_alt_range, expected_buckets); - - // - // Check entities - // - - std::vector get_entities_range; - - stk_classic::mesh::SelectedBucketRangeEntityIteratorRange selected_entity_range = stk_classic::mesh::get_selected_entities( selector, all_buckets ); - for (stk_classic::mesh::SelectedBucketRangeEntityIterator selected_entity_itr = boost::begin(selected_entity_range), - selected_entity_end = boost::end(selected_entity_range); - selected_entity_itr != selected_entity_end; - ++selected_entity_itr) { - get_entities_range.push_back(*selected_entity_itr); - } - // TODO: Figure out why BOOST_FOREACH does not work well with selected entity iterators - // BOOST_FOREACH(Entity* entity, stk_classic::mesh::get_selected_entities(selector, all_buckets) ) { - // get_entities_range.push_back(entity); - // } - - sort_and_compare_eq(get_entities_range, expected_selected_entities); -} -#endif - -STKUNIT_UNIT_TEST( UnitTestGetBuckets, ExampleFixture ) -{ - // Using the SelectorFixture, test for correct bucket membership and - // correct results from get_buckets. - - // Generate mesh - - stk_classic::mesh::fixtures::SelectorFixture fix ; - fix.m_meta_data.commit(); - - fix.m_bulk_data.modification_begin(); - fix.generate_mesh(); - STKUNIT_ASSERT(fix.m_bulk_data.modification_end()); - - // Check bucket membership correctness - - { - const Bucket & bucket = fix.m_entity1->bucket(); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partA ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partB ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partC ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partD ) ); - } - - { - const Bucket & bucket = fix.m_entity2->bucket(); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partA ) ); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partB ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partC ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partD ) ); - } - - { - const Bucket & bucket = fix.m_entity3->bucket(); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partA ) ); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partB ) ); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partC ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partD ) ); - } - - { - const Bucket & bucket = fix.m_entity4->bucket(); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partA ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partB ) ); - STKUNIT_ASSERT_TRUE( bucket.member( fix.m_partC ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partD ) ); - } - - { - const Bucket & bucket = fix.m_entity5->bucket(); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partA ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partB ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partC ) ); - STKUNIT_ASSERT_FALSE( bucket.member( fix.m_partD ) ); - } - - // Check get_buckets correctness - - const std::vector & node_buckets = fix.m_bulk_data.buckets(NODE_RANK); - - { - std::vector get_buckets_range; - - // Get all node buckets using range API - - stk_classic::mesh::AllBucketsRange all_node_buckets = stk_classic::mesh::get_buckets(NODE_RANK, fix.m_bulk_data); - for (stk_classic::mesh::AllBucketsIterator buckets_itr = boost::begin(all_node_buckets), buckets_end = boost::end(all_node_buckets); - buckets_itr != buckets_end; - ++buckets_itr) { - get_buckets_range.push_back(*buckets_itr); - } - // BOOST_FOREACH( Bucket* bucket, stk_classic::mesh::get_buckets(NODE_RANK, fix.m_bulk_data) ) { - // get_buckets_range.push_back(bucket); - // } - - sort_and_compare_eq(get_buckets_range, node_buckets); - } - -#if 0 - // the selected bucket itertor is broken - // \TODO fix - { - std::vector expected_selected_entities; - expected_selected_entities.push_back(fix.m_entity1); - expected_selected_entities.push_back(fix.m_entity2); - - check_selected_buckets(Selector(fix.m_partA), fix.m_bulk_data, node_buckets, expected_selected_entities); - } - - { - std::vector expected_selected_entities; - expected_selected_entities.push_back(fix.m_entity2); - expected_selected_entities.push_back(fix.m_entity3); - - check_selected_buckets(Selector(fix.m_partB), fix.m_bulk_data, node_buckets, expected_selected_entities); - } - - { - std::vector expected_selected_entities; - expected_selected_entities.push_back(fix.m_entity3); - expected_selected_entities.push_back(fix.m_entity4); - - check_selected_buckets(Selector(fix.m_partC), fix.m_bulk_data, node_buckets, expected_selected_entities); - } - - // Check get_entities correctness - - { - std::vector all_nodes_expected, all_nodes, all_nodes_range; - - all_nodes_expected.push_back(fix.m_entity1); - all_nodes_expected.push_back(fix.m_entity2); - all_nodes_expected.push_back(fix.m_entity3); - all_nodes_expected.push_back(fix.m_entity4); - all_nodes_expected.push_back(fix.m_entity5); - - stk_classic::mesh::get_entities( fix.m_bulk_data, NODE_RANK, all_nodes ); - sort_and_compare_eq(all_nodes, all_nodes_expected); - - stk_classic::mesh::BucketVectorEntityIteratorRange entity_range = stk_classic::mesh::get_entities(NODE_RANK, fix.m_bulk_data); - for (stk_classic::mesh::BucketVectorEntityIterator entity_itr = boost::begin(entity_range), entity_end = boost::end(entity_range); - entity_itr != entity_end; - ++entity_itr) { - all_nodes_range.push_back(*entity_itr); - } - // BOOST_FOREACH( Entity* const entity, stk_classic::mesh::get_entities( NODE_RANK, fix.m_bulk_data ) ) { - // all_nodes_range.push_back(entity); - // } - sort_and_compare_eq(all_nodes_range, all_nodes_expected); - } -#endif -} - -} // empty namespace diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGridFixture.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGridFixture.cpp deleted file mode 100644 index d53bade9b329..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestGridFixture.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include - -using stk_classic::mesh::MetaData; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::PartRelation; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityVector; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::Selector; -using stk_classic::mesh::BulkData; -using stk_classic::ParallelMachine; -using std::cout; -using std::endl; - -STKUNIT_UNIT_TEST( UnitTestGridFixture, test_gridfixture ) -{ - //Coverage of GridFixture, Hexfixture, BoxFixture,QuadFixture - //and RingFixture in fixture directory for more than one - //processor. - stk_classic::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD); - - stk_classic::mesh::BulkData& bulk_data = grid_mesh.bulk_data(); - stk_classic::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta(); - const stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank(); - - int size , rank; - rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - - // Create a part for the shells - stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part("shell_part", line_top); - - fem_meta.commit(); - - // Generate the plain grid - bulk_data.modification_begin(); - grid_mesh.generate_grid(); - bulk_data.modification_end(); - - // Add the shells - bulk_data.modification_begin(); - - const unsigned num_shell_1_faces = 4*size + rank; - const unsigned num_shell_2_faces = 2*size + rank; - const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces; - - stk_classic::mesh::PartVector shell_parts; - shell_parts.push_back(&shell_part); - - std::vector shell_faces; - - unsigned id_base = 0; - unsigned id_offset = 500; // a safe offset to avoid id overlap - //Start at 1 so as not to have same element on different processors - for (id_base = 1; id_base <= num_shell_faces; ++id_base) { - - int new_id = rank * num_shell_faces + id_base; - stk_classic::mesh::Entity& new_shell = bulk_data.declare_entity(elem_rank, - id_offset + new_id, - shell_parts); - shell_faces.push_back(&new_shell); - } - - bulk_data.modification_end(); -} - - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestHexFixture.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestHexFixture.cpp deleted file mode 100644 index bbb8ae472779..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestHexFixture.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#include -#include -#include - -#include - -namespace { - -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::EntityId; - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_1d_x ) -{ - // Test 3x1x1 HexFixture structure - const unsigned NX = 3; - const unsigned NY = 1; - const unsigned NZ = 1; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(1,0,0), 2u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(2,0,0), 3u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_3d_x ) -{ - // Test 3x3x3 HexFixture structure - const unsigned NX = 3; - const unsigned NY = 3; - const unsigned NZ = 3; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(1,0,0), 2u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(2,0,0), 3u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_1d_y ) -{ - // Test 1x3x1 HexFixture structure - const unsigned NX = 1; - const unsigned NY = 3; - const unsigned NZ = 1; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,1,0), 2u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,2,0), 3u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_3d_y ) -{ - // Test 3x3x3 HexFixture structure - const unsigned NX = 3; - const unsigned NY = 3; - const unsigned NZ = 3; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,1,0), 4u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,2,0), 7u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_1d_z ) -{ - // Test 1x1x3 HexFixture structure - const unsigned NX = 1; - const unsigned NY = 1; - const unsigned NZ = 3; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,1), 2u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,2), 3u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_3d_z ) -{ - // Test 3x3x3 HexFixture structure - const unsigned NX = 3; - const unsigned NY = 3; - const unsigned NZ = 3; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,1), 10u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,2), 19u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, elem_ids_3d_diag ) -{ - // Test 3x3x3 HexFixture structure - const unsigned NX = 3; - const unsigned NY = 3; - const unsigned NZ = 3; - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(); - STKUNIT_EXPECT_EQUAL( hf.elem_id(0,0,0), 1u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(1,1,1), 14u ); - STKUNIT_EXPECT_EQUAL( hf.elem_id(2,2,2), 27u ); -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, trivial_parallel_2 ) -{ - // Test a customized element distribution with one element on proc 0 and 1 - // and none on the other procs - - const unsigned p_rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - - // Skip unless p_size is at least 2 - if (p_size < 2) - return; - - const unsigned NX = 2; - const unsigned NY = 1; - const unsigned NZ = 1; - - // map< processor, vector of element ids >, this is our custom parallel - // distribution. One element will go on rank 0, the other on rank 1, any - // other ranks get nothing. - std::map > parallel_distribution; - { - std::vector< EntityId> element_ids; - element_ids.push_back(1); - parallel_distribution[0] = element_ids; - element_ids[0] = 2; - parallel_distribution[1] = element_ids; - } - - // Create the fixture - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - if (p_rank <= 1) { - hf.generate_mesh(parallel_distribution[p_rank]); - } - else { - std::vector empty_vector; - hf.generate_mesh( empty_vector ) ; - } - - stk_classic::mesh::BulkData & mesh = hf.m_bulk_data; - - // Verify element_id 1 is owned by proc 0 - // Verify element_id 2 is owned by proc 1 - const EntityRank element_rank = hf.m_fem_meta.element_rank(); - Entity * entity_1 = mesh.get_entity(element_rank, 1); - Entity * entity_2 = mesh.get_entity(element_rank ,2); - if (p_rank <= 1) { - STKUNIT_ASSERT_TRUE( entity_1 != NULL ); - STKUNIT_ASSERT_TRUE( entity_2 != NULL ); - STKUNIT_EXPECT_EQUAL( 0u, entity_1->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_2->owner_rank() ); - } - else { - STKUNIT_EXPECT_TRUE( entity_1 == NULL ); - STKUNIT_EXPECT_TRUE( entity_2 == NULL ); - } -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, disjoint_parallel_psizex1x1 ) -{ - // Test a customized element distribution with one element on each proc - - const unsigned p_rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - - const unsigned NX = p_size; - const unsigned NY = 1; - const unsigned NZ = 1; - - // map< processor, vector of element ids >, this is our custom parallel - // distribution. Assign each processor an element such that rank+1 = elem_id - std::map > parallel_distribution; - for (unsigned p=0 ; p < p_size ; ++p) { - std::vector< EntityId> element_ids; - element_ids.push_back(p+1); // element id's start at 1 - parallel_distribution[p] = element_ids; - } - - // Create the fixture - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - hf.generate_mesh(parallel_distribution[p_rank]); - stk_classic::mesh::BulkData & mesh = hf.m_bulk_data; - const EntityRank element_rank = hf.m_fem_meta.element_rank(); - - // We should always know about, and own, the element assigned to us - Entity * my_entity = mesh.get_entity(element_rank, p_rank + 1); - STKUNIT_ASSERT_TRUE( my_entity != NULL ); - STKUNIT_EXPECT_EQUAL( p_rank, my_entity->owner_rank() ); - - // If applicable, we know about the element on adjacent lower rank - if (p_rank > 0) { - Entity * prior_entity = mesh.get_entity(element_rank, p_rank); - STKUNIT_ASSERT_TRUE( prior_entity != NULL ); - STKUNIT_EXPECT_EQUAL( p_rank - 1, prior_entity->owner_rank() ); - } - - // If applicable, we know about the element on adjacent higher rank - if (p_rank < p_size - 1) { - Entity * next_entity = mesh.get_entity(element_rank, p_rank + 2); - STKUNIT_ASSERT_TRUE( next_entity != NULL ); - STKUNIT_EXPECT_EQUAL( p_rank + 1, next_entity->owner_rank() ); - } -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, disjoint_parallel_4x2x1 ) -{ - // layout: 4x2x1 hex mesh - // elements: - // [ e_1, e_2, e_3, e_4 ] - // [ e_5, e_6, e_7, e_8 ] - // processors: - // [ p_0, p_1, p_1, p_1 ] - // [ p_1, p_0, p_1, p_1 ] - // - - const unsigned p_rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - - // Skip unless p_size is at least 2 - if (p_size < 2) - return; - - const unsigned NX = 4; - const unsigned NY = 2; - const unsigned NZ = 1; - - // map< processor, vector of element ids >, this is our custom parallel - // distribution. Assign 1,6 to proc 0, all the rest to proc 1. The other - // procs get nothing. - std::map > parallel_distribution; - { - std::vector< EntityId> element_ids; - element_ids.push_back(1); - element_ids.push_back(6); - parallel_distribution[0] = element_ids; // proc 0 - element_ids.clear(); - element_ids.push_back(2); - element_ids.push_back(3); - element_ids.push_back(4); - element_ids.push_back(5); - element_ids.push_back(7); - element_ids.push_back(8); - parallel_distribution[1] = element_ids; // proc 1 - } - - // Create the fixture - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - if (p_rank <= 1) { - hf.generate_mesh(parallel_distribution[p_rank]); - } - else { - std::vector empty_vector; - hf.generate_mesh( empty_vector ) ; - } - - stk_classic::mesh::BulkData & mesh = hf.m_bulk_data; - - // Verify that the entities and known and owned by the appropriate procs - const EntityRank element_rank = hf.m_fem_meta.element_rank(); - Entity * entity_1 = mesh.get_entity(element_rank, 1); - Entity * entity_2 = mesh.get_entity(element_rank, 2); - Entity * entity_3 = mesh.get_entity(element_rank, 3); - Entity * entity_4 = mesh.get_entity(element_rank, 4); - Entity * entity_5 = mesh.get_entity(element_rank, 5); - Entity * entity_6 = mesh.get_entity(element_rank, 6); - Entity * entity_7 = mesh.get_entity(element_rank, 7); - Entity * entity_8 = mesh.get_entity(element_rank, 8); - if (p_rank == 0) { - STKUNIT_ASSERT_TRUE( entity_1 != NULL ); - STKUNIT_ASSERT_TRUE( entity_2 != NULL ); - STKUNIT_ASSERT_TRUE( entity_3 != NULL ); - STKUNIT_ASSERT_TRUE( entity_4 == NULL ); - STKUNIT_ASSERT_TRUE( entity_5 != NULL ); - STKUNIT_ASSERT_TRUE( entity_6 != NULL ); - STKUNIT_ASSERT_TRUE( entity_7 != NULL ); - STKUNIT_ASSERT_TRUE( entity_8 == NULL ); - STKUNIT_EXPECT_EQUAL( 0u, entity_1->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_2->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_3->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_5->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 0u, entity_6->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_7->owner_rank() ); - } - else if (p_rank == 1) { - STKUNIT_ASSERT_TRUE( entity_1 != NULL ); - STKUNIT_ASSERT_TRUE( entity_2 != NULL ); - STKUNIT_ASSERT_TRUE( entity_3 != NULL ); - STKUNIT_ASSERT_TRUE( entity_4 != NULL ); - STKUNIT_ASSERT_TRUE( entity_5 != NULL ); - STKUNIT_ASSERT_TRUE( entity_6 != NULL ); - STKUNIT_ASSERT_TRUE( entity_7 != NULL ); - STKUNIT_ASSERT_TRUE( entity_8 != NULL ); - STKUNIT_EXPECT_EQUAL( 0u, entity_1->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_2->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_3->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_4->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_5->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 0u, entity_6->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_7->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_8->owner_rank() ); - } - else { - STKUNIT_EXPECT_TRUE( entity_1 == NULL ); - STKUNIT_EXPECT_TRUE( entity_2 == NULL ); - STKUNIT_EXPECT_TRUE( entity_3 == NULL ); - STKUNIT_EXPECT_TRUE( entity_4 == NULL ); - STKUNIT_EXPECT_TRUE( entity_5 == NULL ); - STKUNIT_EXPECT_TRUE( entity_6 == NULL ); - STKUNIT_EXPECT_TRUE( entity_7 == NULL ); - STKUNIT_EXPECT_TRUE( entity_8 == NULL ); - } -} - -STKUNIT_UNIT_TEST( UnitTestHexFixture, disjoint_parallel_5x1x1 ) -{ - // layout: - // [ e_1, e_2, e_3, e_4, e_5 ] elements - // [ p_0, p_1, p_1, p_1, p_0 ] processors - // - const unsigned p_rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - const unsigned p_size = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - - // Skip unless p_size is at least 2 - if (p_size < 2) - return; - - const unsigned NX = 5; - const unsigned NY = 1; - const unsigned NZ = 1; - - // map< processor, vector of element ids >, this is our custom parallel - // distribution. Assign 1,5 to proc 0, all the rest to proc 1. The other - // procs get nothing. - std::map > parallel_distribution; - { - std::vector< EntityId> element_ids; - element_ids.push_back(1); - element_ids.push_back(5); - parallel_distribution[0] = element_ids; - element_ids.clear(); - element_ids.push_back(2); - element_ids.push_back(3); - element_ids.push_back(4); - parallel_distribution[1] = element_ids; - } - - // Create the fixture - stk_classic::mesh::fixtures::HexFixture hf(MPI_COMM_WORLD,NX,NY,NZ); - hf.m_fem_meta.commit(); - if (p_rank <= 1) { - hf.generate_mesh(parallel_distribution[p_rank]); - } - else { - std::vector empty_vector; - hf.generate_mesh( empty_vector ) ; - } - - stk_classic::mesh::BulkData & mesh = hf.m_bulk_data; - - // Verify that the entities and known and owned by the appropriate procs - const EntityRank element_rank = hf.m_fem_meta.element_rank(); - Entity * entity_1 = mesh.get_entity(element_rank, 1); - Entity * entity_2 = mesh.get_entity(element_rank, 2); - Entity * entity_3 = mesh.get_entity(element_rank, 3); - Entity * entity_4 = mesh.get_entity(element_rank, 4); - Entity * entity_5 = mesh.get_entity(element_rank, 5); - if (p_rank == 0) { - STKUNIT_ASSERT_TRUE( entity_1 != NULL ); - STKUNIT_ASSERT_TRUE( entity_2 != NULL ); - STKUNIT_ASSERT_TRUE( entity_3 == NULL ); - STKUNIT_ASSERT_TRUE( entity_4 != NULL ); - STKUNIT_ASSERT_TRUE( entity_5 != NULL ); - STKUNIT_EXPECT_EQUAL( 0u, entity_1->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_2->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_4->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 0u, entity_5->owner_rank() ); - } - else if (p_rank == 1) { - STKUNIT_ASSERT_TRUE( entity_1 != NULL ); - STKUNIT_ASSERT_TRUE( entity_2 != NULL ); - STKUNIT_ASSERT_TRUE( entity_3 != NULL ); - STKUNIT_ASSERT_TRUE( entity_4 != NULL ); - STKUNIT_ASSERT_TRUE( entity_5 != NULL ); - STKUNIT_EXPECT_EQUAL( 0u, entity_1->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_2->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_3->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 1u, entity_4->owner_rank() ); - STKUNIT_EXPECT_EQUAL( 0u, entity_5->owner_rank() ); - } - else { - STKUNIT_EXPECT_TRUE( entity_1 == NULL ); - STKUNIT_EXPECT_TRUE( entity_2 == NULL ); - STKUNIT_EXPECT_TRUE( entity_3 == NULL ); - STKUNIT_EXPECT_TRUE( entity_4 == NULL ); - STKUNIT_EXPECT_TRUE( entity_5 == NULL ); - } -} - -} // end namespace diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestInducedPart.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestInducedPart.cpp deleted file mode 100644 index 7d01556aa5da..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestInducedPart.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include - -#include - -using stk_classic::mesh::Part; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Entity; - -namespace { - -bool has_part(const Entity& entity, const Part& part) -{ - return entity.bucket().member(part); -} - -// Set up a very simple mesh with one element, one side, one node: -// rels: E->(S1,S2)->N -// parts: E in element_rank_part, unranked_part -// S1, S2 in side_rank_part -// element_ranked_part subset of unranked_superset_part -// modification cycle is left uncompleted -#define SETUP_MESH() \ - stk_classic::ParallelMachine pm = MPI_COMM_SELF; \ - \ - const unsigned spatial_dim = 2; \ - \ - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim); \ - FEMMetaData meta_data(spatial_dim, entity_rank_names); \ - Part& unranked_part = meta_data.declare_part("unranked_part"); \ - Part& element_rank_part = meta_data.declare_part("element_rank_part", meta_data.element_rank()); \ - Part& element_rank_superset_part = meta_data.declare_part("element_rank_superset_part", meta_data.element_rank()); \ - Part& side_rank_part = meta_data.declare_part("side_rank_part", meta_data.side_rank()); \ - Part& unranked_superset_part = meta_data.declare_part("unranked_superset_part"); \ - meta_data.declare_part_subset(unranked_superset_part, element_rank_part); \ - meta_data.declare_part_subset(element_rank_superset_part, element_rank_part); \ - \ - meta_data.commit(); \ - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); \ - \ - mesh.modification_begin(); \ - \ - stk_classic::mesh::PartVector parts; \ - parts.push_back(&unranked_part); \ - parts.push_back(&element_rank_part); \ - Entity& elem = mesh.declare_entity(meta_data.element_rank(), 1 /*id*/, parts); \ - \ - parts.clear(); \ - parts.push_back(&side_rank_part); \ - Entity& side1 = mesh.declare_entity(meta_data.side_rank(), 1 /*id*/, parts); \ - Entity& side2 = mesh.declare_entity(meta_data.side_rank(), 2 /*id*/, parts); \ - \ - parts.clear(); \ - Entity& node = mesh.declare_entity(meta_data.node_rank(), 1 /*id*/, parts); \ - \ - mesh.declare_relation(elem, side1, 0 /*rel id*/); \ - mesh.declare_relation(elem, side2, 1 /*rel id*/); \ - mesh.declare_relation(side1, node, 0 /*rel id*/); \ - mesh.declare_relation(side2, node, 0 /*rel id*/); - -STKUNIT_UNIT_TEST ( UnitTestInducedPart , verifyBasicInducedPart ) -{ - SETUP_MESH(); - - // Check that directly-induced parts are induced upon relation creation - // before modification end. - STKUNIT_EXPECT_TRUE(has_part(node, side_rank_part)); - STKUNIT_EXPECT_TRUE(has_part(side1, element_rank_part)); - STKUNIT_EXPECT_TRUE(has_part(side2, element_rank_part)); - - mesh.modification_end(); - - // Modification-end should not have changed induced parts - STKUNIT_EXPECT_TRUE(has_part(node, side_rank_part)); - STKUNIT_EXPECT_TRUE(has_part(side1, element_rank_part)); - STKUNIT_EXPECT_TRUE(has_part(side2, element_rank_part)); -} - -STKUNIT_UNIT_TEST ( UnitTestInducedPart , verifyNotTransitiveInducedPart ) -{ - SETUP_MESH(); - - // Node should not have picked-up the element_rank_part indirectly through - // it's relation to the sides because induced-parts are not supposed to be - // transitive according to the STK_Mesh domain design. - // TODO: Are we sure we don't want induced parts to be transitive?? - STKUNIT_EXPECT_TRUE(!has_part(node, element_rank_part)); -} - -STKUNIT_UNIT_TEST ( UnitTestInducedPart, verifyInducedPartCorrectnessWhenRelationsRemoved ) -{ - SETUP_MESH(); - - // Destroy one relation from element to a side, confirm that the side that lost - // the relation no longer has the element part. - mesh.destroy_relation(elem, side1, 0 /*rel id*/); - STKUNIT_EXPECT_TRUE(!has_part(side1, element_rank_part)); - - // Destroy one of the relations from side to node. Confirm that node still has - // side part due to its remaining relation. - mesh.destroy_relation(side1, node, 0 /*rel id*/); - STKUNIT_EXPECT_TRUE(has_part(node, side_rank_part)); - - // Destroy the other relations from side to node. Confirm that node no longer - // has any induced parts. - mesh.destroy_relation(side2, node, 0 /*rel id*/); - STKUNIT_EXPECT_TRUE(!has_part(node, side_rank_part)); -} - -STKUNIT_UNIT_TEST ( UnitTestInducedPart , verifySupersetsOfInducedPart ) -{ - SETUP_MESH(); - - // Check for superset/subset consistency in induced parts. If an entity is - // induced into a part, it should also be induced into the supersets of - // that part even if the superset parts are unranked. - STKUNIT_EXPECT_TRUE(has_part(side1, element_rank_superset_part)); - STKUNIT_EXPECT_TRUE(has_part(side1, unranked_superset_part)); -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMain.cpp deleted file mode 100644 index b3cf8e41f4de..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMetaData.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMetaData.cpp deleted file mode 100644 index f548dc905fcc..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestMetaData.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -using stk_classic::mesh::MetaData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::PartRelation; -using stk_classic::mesh::EntityRank; -using std::cout; -using std::endl; - -//---------------------------------------------------------------------- - -namespace { -int stencil_test_function( unsigned from_type , - unsigned to_type , - unsigned identifier ) -{ - return 0; -} - - - -STKUNIT_UNIT_TEST( UnitTestMetaData, testMetaData ) -{ - //Test functions in MetaData.cpp - const int spatial_dimension = 3; - const std::vector & rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - MetaData metadata_committed(rank_names); - MetaData metadata_not_committed(rank_names); - MetaData metadata(rank_names); - - Part &pa = metadata.declare_part( std::string("a") , 0 ); - Part &pb = metadata.declare_part( std::string("b") , 0 ); - Part &pc = metadata.declare_part( std::string("c") , 0 ); - Part &pd = metadata.declare_part( std::string("d") , 0 ); - Part &pe = metadata.declare_part( std::string("e") , 0 ); - Part &pf = metadata.declare_part( std::string("f") , 0 ); - Part &pg = metadata.declare_part( std::string("g") , 0 ); - Part &ph = metadata.declare_part( std::string("h") , 0 ); - PartVector part_vector; - metadata_committed.commit(); - - //test get_part with part that does not exist - std::string test_string = "this_part_does_not_exist"; - STKUNIT_ASSERT_THROW( metadata_committed.get_part(test_string,"test_throw"),std::runtime_error); - - //test get_part with valid part - STKUNIT_ASSERT( metadata.get_part(std::string("a"),"do_not_throw")); - - //test declare part - metadata.declare_part_relation( pe,stencil_test_function, pg); - - part_vector.push_back(& pa); - part_vector.push_back(& pb); - part_vector.push_back(& pc); - part_vector.push_back(& pd); - - //Part * const intersection_part = & - metadata.declare_part(part_vector); - - //Test declare_part_subset - STKUNIT_ASSERT_THROW( metadata.declare_part_subset( pe, pe), std::runtime_error); - - //Test declare_part_relation with parts that are not subsets of each other - STKUNIT_ASSERT_THROW( metadata.declare_part_relation( pg,stencil_test_function, ph), std::logic_error); - - //Test declare_part_relation with a NULL stencil function - STKUNIT_ASSERT_THROW( metadata.declare_part_relation( pe,NULL, pe), std::runtime_error); - - //Test declare_part_relation with parts that are subsets of each other - metadata.declare_part_subset( pd, pf); - STKUNIT_ASSERT_THROW( metadata.declare_part_relation( pd,stencil_test_function, pf), std::runtime_error); - - metadata.commit(); -} - -STKUNIT_UNIT_TEST( UnitTestMetaData, rankHigherThanDefined ) -{ - //Test function entity_rank_name in MetaData.cpp - const int spatial_dimension = 3; - const std::vector & rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - MetaData metadata(rank_names); - int i = 2; - - const std::string& i_name2 = metadata.entity_rank_name( i ); - - STKUNIT_ASSERT( i_name2 == rank_names[i] ); - - EntityRank one_rank_higher_than_defined = rank_names.size(); - - STKUNIT_ASSERT_THROW( - metadata.entity_rank_name( one_rank_higher_than_defined ), - std::runtime_error - ); -} - -STKUNIT_UNIT_TEST( UnitTestMetaData, testEntityRepository ) -{ - static const size_t spatial_dimension = 3; - - //Test Entity repository - covering EntityRepository.cpp/hpp - stk_classic::mesh::MetaData meta ( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - stk_classic::mesh::Part & part = meta.declare_part("another part"); - - meta.commit(); - - stk_classic::mesh::BulkData bulk ( meta , MPI_COMM_WORLD , 100 ); - std::vector add_part; - add_part.push_back ( &part ); - - int size , rank; - rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - size = stk_classic::parallel_machine_size( MPI_COMM_WORLD ); - PartVector tmp(1); - - bulk.modification_begin(); - - int id_base = 0; - for ( id_base = 0 ; id_base < 97 ; ++id_base ) - { - int new_id = size * id_base + rank; - bulk.declare_entity( 0 , new_id+1 , add_part ); - } - - int new_id = size * (++id_base) + rank; - stk_classic::mesh::Entity & elem = bulk.declare_entity( 3 , new_id+1 , add_part ); - - //new_id = size * (++id_base) + rank; - // stk_classic::mesh::Entity & elem2 = bulk.declare_entity( 3 , new_id+1 , add_part ); - - bool use_memory_pool = false; - stk_classic::mesh::impl::EntityRepository e(use_memory_pool); - - e.comm_clear( elem ); - - e.comm_clear_ghosting( elem ); - - const stk_classic::mesh::Ghosting & ghost = bulk.shared_aura(); - - bulk.modification_end(); - - STKUNIT_ASSERT_FALSE(e.erase_ghosting(elem, ghost)); - - const stk_classic::mesh::EntityCommInfo comm_info( ghost.ordinal() , 0 ); - - STKUNIT_ASSERT_FALSE(e.erase_comm_info(elem, comm_info)); - - STKUNIT_ASSERT(e.insert_comm_info(elem, comm_info)); - - //Checking internal_create_entity - - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 2 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 5 )); - e.internal_create_entity( stk_classic::mesh::EntityKey( 3, 7 )); - - //Checking get_entity with invalid key - no rank or id - { - int ok = 0 ; - try { - - stk_classic::mesh::Entity * elem3 = e.get_entity(stk_classic::mesh::EntityKey()); - if(elem3){ - // CAROL FIXME - } - - } - catch( const std::exception & x ) { - ok = 1 ; - std::cout << "UnitTestMetaData CORRECTLY caught error for : " - << x.what() - << std::endl ; - } - if ( ! ok ) { - throw std::runtime_error("UnitTestMetaData FAILED to catch error for get_entity - invalid key"); - } - } -} - -STKUNIT_UNIT_TEST( UnitTestMetaData, noEntityTypes ) -{ - //MetaData constructor fails because there are no entity types: - std::vector empty_names; - STKUNIT_ASSERT_THROW( - MetaData metadata(empty_names), - std::runtime_error - ); -} -STKUNIT_UNIT_TEST( UnitTestMetaData, declare_part_with_rank ) -{ - //MetaData constructor fails because there are no entity types: - const int spatial_dimension = 3; - MetaData metadata(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - metadata.declare_part("foo"); - STKUNIT_ASSERT_NO_THROW(metadata.declare_part("foo",1)); - STKUNIT_ASSERT_NO_THROW(metadata.declare_part("foo",1)); - - // Should throw because we're trying to change rank - STKUNIT_ASSERT_THROW(metadata.declare_part("foo",2),std::runtime_error); - - // Should not throw since we did not provide rank - metadata.declare_part("foo"); -} - -STKUNIT_UNIT_TEST( UnitTestMetaData, declare_attribute_no_delete ) -{ - //Coverage of declare_attribute_no_delete in MetaData.hpp - const CellTopologyData * singleton = NULL; - const int spatial_dimension = 3; - MetaData metadata(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - Part &pa = metadata.declare_part( std::string("a") , 0 ); - metadata.declare_attribute_no_delete( pa, singleton); - metadata.commit(); -} - -} -//---------------------------------------------------------------------- - - - - - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.cpp deleted file mode 100644 index 1eba3ca661ec..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -#include - -namespace stk_classic { -namespace mesh { - -bool UnitTestModificationEndWrapper::wrap(stk_classic::mesh::BulkData& mesh, bool generate_aura) -{ - return mesh.internal_modification_end(generate_aura); -} - -} // namespace mesh - -namespace unit_test { - -bool modification_end_wrapper(stk_classic::mesh::BulkData& mesh, bool generate_aura) -{ - return stk_classic::mesh::UnitTestModificationEndWrapper::wrap(mesh, generate_aura); -} - -} // namespace unit_test -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.hpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.hpp deleted file mode 100644 index 6ed5c58deece..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestModificationEndWrapper.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef unit_test_UnitTestModificationEndWrapper_hpp -#define unit_test_UnitTestModificationEndWrapper_hpp - -#include - -// must be in same namespace as BulkData to make friending w/out exposure possible - -namespace stk_classic { -namespace mesh { - -class UnitTestModificationEndWrapper -{ - public: - static bool wrap(stk_classic::mesh::BulkData& mesh, bool generate_aura); -}; - -} // namespace mesh - -namespace unit_test { - -bool modification_end_wrapper(stk_classic::mesh::BulkData& mesh, bool generate_aura); - -} // namespace unit_test - -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPart.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPart.cpp deleted file mode 100644 index 01549b774dec..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPart.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -using stk_classic::mesh::MetaData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::PartRelation; -using stk_classic::mesh::impl::PartRepository; - -namespace { - -STKUNIT_UNIT_TEST(UnitTestPart, testUnit) -{ - const int spatial_dimension = 3; - MetaData m(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - PartRepository partRepo(&m); - PartRepository partRepo2(&m); - PartRepository partRepo3(&m); - PartRepository partRepo4(&m); - Part & universal = *partRepo.universal_part(); - PartVector intersection; - PartVector intersection2; - PartVector intersection4; - PartVector intersection5; - m.commit(); - - STKUNIT_ASSERT( universal.supersets().empty() ); - STKUNIT_ASSERT( 1u == partRepo.get_all_parts().size() ); - - //-------------------------------------------------------------------- - // Test multiple part creation - - enum { NPARTS = 100 }; - - Part * parts[NPARTS]; - - parts[0] = & universal ; - - for ( int i = 1 ; i < NPARTS-1 ; ++i ) { - std::ostringstream name ; - name << "Part_" << i ; - parts[i] = partRepo.declare_part( name.str() , 0 ); - } - parts[99] = partRepo.declare_part( "Part_99" , 1 ); - - STKUNIT_ASSERT( universal.supersets().empty() ); - STKUNIT_ASSERT( NPARTS == partRepo.get_all_parts().size() ); - STKUNIT_ASSERT_EQUAL( partRepo.get_all_parts()[0] , & universal ); - - for ( unsigned i = 1 ; i < NPARTS ; ++i ) { - STKUNIT_ASSERT( parts[i]->subsets().empty() ); - STKUNIT_ASSERT( parts[i]->intersection_of().empty() ); - STKUNIT_ASSERT( parts[i]->mesh_meta_data_ordinal() == i ); - STKUNIT_ASSERT( 1u == parts[i]->supersets().size() ); - STKUNIT_ASSERT( & universal == parts[i]->supersets()[0] ); - STKUNIT_ASSERT_EQUAL( parts[i] , universal.subsets()[i-1] ); - STKUNIT_ASSERT_EQUAL( parts[i] , find( universal.subsets() , parts[i]->name() ) ); - } - - //-------------------------------------------------------------------- - // Test multiple parts and transitive subset declarations: - - partRepo.declare_subset( * parts[3], * parts[4] ); - partRepo.declare_subset( * parts[4], * parts[5] ); - - partRepo.declare_subset( * parts[1], * parts[2] ); - // 1 and 2 pick up 4 and 5 via transitive relationship: - partRepo.declare_subset( * parts[2], * parts[3] ); - - STKUNIT_ASSERT( 4u == parts[1]->subsets().size() ); - STKUNIT_ASSERT( 3u == parts[2]->subsets().size() ); - STKUNIT_ASSERT( 2u == parts[3]->subsets().size() ); - STKUNIT_ASSERT( 1u == parts[4]->subsets().size() ); - STKUNIT_ASSERT( 0u == parts[5]->subsets().size() ); - - STKUNIT_ASSERT( contain( parts[1]->subsets() , * parts[2] ) ); - STKUNIT_ASSERT( contain( parts[1]->subsets() , * parts[3] ) ); - STKUNIT_ASSERT( contain( parts[1]->subsets() , * parts[4] ) ); - STKUNIT_ASSERT( contain( parts[1]->subsets() , * parts[5] ) ); - - STKUNIT_ASSERT( contain( parts[5]->supersets() , * parts[1] ) ); - STKUNIT_ASSERT( contain( parts[5]->supersets() , * parts[2] ) ); - STKUNIT_ASSERT( contain( parts[5]->supersets() , * parts[3] ) ); - STKUNIT_ASSERT( contain( parts[5]->supersets() , * parts[4] ) ); - - //-------------------------------------------------------------------- - // Test declaration of an intersection part - - intersection.push_back( parts[1] ); - intersection.push_back( parts[2] ); - intersection.push_back( parts[3] ); - intersection.push_back( parts[4] ); // Smallest subset of 1..4 - - // Test filtering of trivial intersection - - STKUNIT_ASSERT( parts[4] == partRepo.declare_part( intersection ) ); - - // Test non-trivial intersection: - - intersection.push_back( parts[6] ); - intersection.push_back( parts[7] ); - - Part & pint_4_6_7 = * partRepo.declare_part( intersection ); - - STKUNIT_ASSERT( 3u == pint_4_6_7.intersection_of().size() ); - STKUNIT_ASSERT( contain( pint_4_6_7.intersection_of() , * parts[4] ) ); - STKUNIT_ASSERT( contain( pint_4_6_7.intersection_of() , * parts[6] ) ); - STKUNIT_ASSERT( contain( pint_4_6_7.intersection_of() , * parts[7] ) ); - - STKUNIT_ASSERT( 7u == pint_4_6_7.supersets().size() ); - - // Test redeclaration of intersection, should give the same part back: - - STKUNIT_ASSERT( pint_4_6_7 == * partRepo.declare_part( intersection ) ); - - partRepo.declare_subset( pint_4_6_7, * parts[8] ); - - //-------------------------------------------------------------------- - // Test intersection-induced subset relationship - - partRepo.declare_subset( * parts[7], * parts[10] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[10] ) ); - - partRepo.declare_subset( * parts[6], * parts[10] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[10] ) ); - - partRepo.declare_subset( * parts[3], * parts[10] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[10] ) ); - - partRepo.declare_subset( * parts[4], * parts[10] ); - STKUNIT_ASSERT( contain( pint_4_6_7.subsets() , * parts[10] ) ); - - // Test intersection-induced subset relationship triggered from a subset - - partRepo.declare_subset( * parts[7], * parts[11] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[11] ) ); - - partRepo.declare_subset( * parts[6], * parts[11] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[11] ) ); - - partRepo.declare_subset( * parts[3], * parts[11] ); - STKUNIT_ASSERT( ! contain( pint_4_6_7.subsets() , * parts[11] ) ); - - partRepo.declare_subset( * parts[5], * parts[11] ); - STKUNIT_ASSERT( contain( pint_4_6_7.subsets() , * parts[11] ) ); - - std::cout << std::endl << "Part: test intersection generated" << std::endl ; - print( std::cout , " " , pint_4_6_7 ); - print( std::cout , " " , * parts[10] ); - print( std::cout , " " , * parts[11] ); - - std::cout << std::endl ; - - //Test to cover assert_same_universe in PartRepository - Part is not in the same universe - { - std::vector< std::string > dummy_names(1); - dummy_names[0].assign("dummy"); - - stk_classic::mesh::MetaData meta2( dummy_names ); - - stk_classic::mesh::Part &part_not_in_same_universe = meta2.declare_part ( "part_not_in_same_universe"); - meta2.commit(); - - intersection4.push_back( &part_not_in_same_universe ); - - PartVector::const_iterator i = intersection4.begin() ; - Part * const p = *i ; - STKUNIT_ASSERT_THROW( - partRepo3.declare_subset(*parts[5], *p), - std::runtime_error - ); - } - - //Test to cover assert_not_superset in PartRepository - parts[11] is not a superset of parts[7] - { - STKUNIT_ASSERT_THROW( - partRepo.declare_subset(*parts[11], *parts[7] ), - std::runtime_error - ); - } - - //Test to cover assert_not_superset in PartRepository - parts[99] is not the same rank of parts[11] - { - STKUNIT_ASSERT_THROW( - partRepo.declare_subset(*parts[11], *parts[99] ), - std::runtime_error - ); - } - - //Test to cover declare_part(arg_name, arg_rank) - Part_99 of rank 1 already exists.. - { - STKUNIT_ASSERT_THROW( - partRepo.declare_part("Part_99", 0 ), - std::runtime_error - ); - } - - //Test to cover declare_part(const PartVector & part_intersect) in PartRepository - failed from malicious abuse - { - int ok = 0 ; - try { - //create part with intersection - - // Test declaration of an intersection part - - enum { NPARTS = 100 }; - - Part * parts2[ NPARTS ] ; - - parts2[0] = & universal ; - - for ( int i = 1 ; i < NPARTS-1 ; ++i ) { - std::ostringstream name ; - name << "Part_" << i ; - parts2[i] = partRepo4.declare_part( name.str() , 0 ); - } - - partRepo4.declare_subset( * parts2[3], * parts2[4] ); - partRepo4.declare_subset( * parts2[4], * parts2[5] ); - - partRepo4.declare_subset( * parts2[1], * parts2[2] ); - // 1 and 2 pick up 4 and 5 via transitive relationship: - partRepo4.declare_subset( * parts2[2], * parts2[3] ); - - intersection5.push_back( parts2[1] ); - intersection5.push_back( parts2[2] ); - intersection5.push_back( parts2[3] ); - intersection5.push_back( parts2[4] ); // Smallest subset of 1..4 - intersection5.push_back( parts2[6] ); - intersection5.push_back( parts2[7] ); - - Part & partB = * partRepo2.declare_part("{Part_4^Part_6^Part_7}", 0); - - std::cout << "UnitTestPart name of partB is " << partB.name() << std::endl ; - - Part & pintersect_4_6_7 = * partRepo2.declare_part( intersection5 ); - - std::cout << "UnitTestPart name of intersection part, pintersect_4_6_7 is " << pintersect_4_6_7.name() << std::endl ; - } - catch( const std::exception & x ) { - ok = 1 ; - std::cout << "UnitTestPart CORRECTLY caught error for : " - << x.what() - << std::endl ; - } - - if ( ! ok ) { - throw std::runtime_error("UnitTestPart FAILED to catch error for declare_part in PartRepository"); - } - } -} - -STKUNIT_UNIT_TEST(UnitTestPart, testPartNotaSubset) -{ - //Test to cover assert_contain in PartRepository - Part is not a subset - const int spatial_dimension = 3; - MetaData m(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - PartVector intersection; - PartRepository partRepo(&m); - - stk_classic::mesh::Part &part_not_a_subset = m.declare_part ( "part_not_a_subset"); - m.commit(); - - intersection.push_back( &part_not_a_subset ); - - STKUNIT_ASSERT_THROW( - partRepo.declare_part(intersection), - std::runtime_error - ); -} - -//---------------------------------------------------------------------- - -STKUNIT_UNIT_TEST(UnitTestPart, testPartVector) -{ - const int spatial_dimension = 3; - MetaData m(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - PartRepository partRepo(&m); - - Part * const pa = partRepo.declare_part( std::string("a") , 0 ); - Part * const pb = partRepo.declare_part( std::string("b") , 0 ); - Part * const pc = partRepo.declare_part( std::string("c") , 0 ); - Part * const pd = partRepo.declare_part( std::string("d") , 0 ); - Part * const pe = partRepo.declare_part( std::string("e") , 0 ); - Part * const pf = partRepo.declare_part( std::string("f") , 0 ); - - STKUNIT_ASSERT( ! intersect( *pa , *pb ) ); - STKUNIT_ASSERT( ! intersect( *pb , *pc ) ); - STKUNIT_ASSERT( ! intersect( *pc , *pd ) ); - STKUNIT_ASSERT( ! intersect( *pd , *pe ) ); - STKUNIT_ASSERT( ! intersect( *pe , *pf ) ); - STKUNIT_ASSERT( ! intersect( *pf , *pa ) ); - - PartVector vabc , vbcd , vdef , vresult ; - - vabc.push_back( pa ); - vabc.push_back( pb ); - vabc.push_back( pc ); - - vbcd.push_back( pb ); - vbcd.push_back( pc ); - vbcd.push_back( pd ); - - vdef.push_back( pd ); - vdef.push_back( pe ); - vdef.push_back( pf ); - - order( vabc ); - order( vbcd ); - order( vdef ); - - vresult.clear(); - STKUNIT_ASSERT_EQUAL( size_t(2) , intersect( vabc , vbcd ) ); - size_t intersect_size = intersect( vabc , vbcd , vresult ); - STKUNIT_ASSERT_EQUAL( size_t(2) , intersect_size ); - STKUNIT_ASSERT_EQUAL( pb , vresult[0] ); - STKUNIT_ASSERT_EQUAL( pc , vresult[1] ); - - vresult.clear(); - STKUNIT_ASSERT_EQUAL( size_t(1) , intersect( vdef , vbcd ) ); - intersect_size = intersect( vdef , vbcd , vresult ); - STKUNIT_ASSERT_EQUAL( size_t(1) , intersect_size ); - STKUNIT_ASSERT_EQUAL( pd , vresult[0] ); - - vresult.clear(); - STKUNIT_ASSERT_EQUAL( size_t(0) , intersect( vdef , vabc ) ); - intersect_size = intersect( vdef , vabc , vresult ); - STKUNIT_ASSERT_EQUAL( size_t(0) , intersect_size ); - STKUNIT_ASSERT_EQUAL( size_t(0) , vresult.size() ); - - Part * const pabc = partRepo.declare_part( std::string("abc") , 0 ); - Part * const pbcd = partRepo.declare_part( std::string("bcd") , 0 ); - Part * const pdef = partRepo.declare_part( std::string("def") , 0 ); - - partRepo.declare_subset( * pabc, *pa ); - partRepo.declare_subset( * pabc, *pb ); - partRepo.declare_subset( * pabc, *pc ); - - partRepo.declare_subset( * pbcd, *pb ); - partRepo.declare_subset( * pbcd, *pc ); - partRepo.declare_subset( * pbcd, *pd ); - - partRepo.declare_subset( * pdef, *pd ); - partRepo.declare_subset( * pdef, *pe ); - partRepo.declare_subset( * pdef, *pf ); - - STKUNIT_ASSERT( intersect( *pabc , *pa ) ); - STKUNIT_ASSERT( intersect( *pabc , *pb ) ); - STKUNIT_ASSERT( intersect( *pabc , *pc ) ); - STKUNIT_ASSERT( intersect( *pa , *pabc ) ); - STKUNIT_ASSERT( intersect( *pb , *pabc ) ); - STKUNIT_ASSERT( intersect( *pc , *pabc ) ); - - STKUNIT_ASSERT( intersect( *pabc , *pbcd ) ); - STKUNIT_ASSERT( ! intersect( *pabc , *pdef ) ); -} - -// Unit test the PartRelation copy constructor: -STKUNIT_UNIT_TEST(UnitTestPart, testPartRelation) -{ - PartRelation rA; - PartRelation rB( rA); - - rA = rB; -} - -} // empty namespace diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPartRepository.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPartRepository.cpp deleted file mode 100644 index 553a84ddae6d..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestPartRepository.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include - -#include -#include - -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Part; -using stk_classic::mesh::impl::PartRepository; - -class UnitTestPartRepository -{ -public: - UnitTestPartRepository(); - ~UnitTestPartRepository() {} - - const int spatial_dimension; - MetaData meta; - stk_classic::mesh::impl::PartRepository partRepo; - stk_classic::mesh::impl::PartRepository partRepo_1; - stk_classic::mesh::impl::PartRepository partRepo_2; - - stk_classic::mesh::Part * universal_part; - stk_classic::mesh::Part * part_A; - stk_classic::mesh::Part * part_B; - stk_classic::mesh::Part * part_C; - stk_classic::mesh::Part * part_D; - stk_classic::mesh::Part * part_1_A; - stk_classic::mesh::Part * part_1_B; - stk_classic::mesh::Part * part_2_A; - std::vector intersection; - stk_classic::mesh::PartRelation relation; - const CellTopologyData * singleton; -}; - -UnitTestPartRepository::UnitTestPartRepository() - : spatial_dimension(3) - , meta( stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ) - , partRepo( &meta ) - , partRepo_1( &meta ) - , partRepo_2( &meta ) - , universal_part( partRepo.universal_part() ) - , part_A ( partRepo.declare_part("A",0) ) - , part_B ( partRepo.declare_part("B",0) ) - , part_C ( partRepo.declare_part("C",0) ) - , part_D ( partRepo.declare_part("D",1) ) - , part_1_A ( partRepo_1.declare_part("A",0) ) - , part_1_B ( partRepo_1.declare_part("B",0) ) - , part_2_A ( partRepo_2.declare_part("A",0) ) - , intersection ( ) - , relation ( ) - , singleton ( NULL ) -{ - meta.commit(); -} - -namespace { - -STKUNIT_UNIT_TEST( UnitTestPartRepository, construct ) -{ - UnitTestPartRepository upr; - STKUNIT_EXPECT_TRUE( upr.universal_part != NULL ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, universal_in_subset ) -{ - UnitTestPartRepository upr; - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_subset(*upr.part_A,*upr.universal_part), - std::runtime_error - ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, subset_equal_superset ) -{ - UnitTestPartRepository upr; - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_subset(*upr.part_A,*upr.part_A), - std::runtime_error - ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, universal_in_intersection ) -{ - UnitTestPartRepository upr; - upr.intersection.push_back(upr.universal_part); - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_part(upr.intersection), - std::runtime_error - ); - upr.intersection.push_back(upr.part_A); - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_part(upr.intersection), - std::runtime_error - ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, circular_subset ) -{ - UnitTestPartRepository upr; - upr.partRepo.declare_subset(*upr.part_A,*upr.part_B); - upr.partRepo.declare_subset(*upr.part_B,*upr.part_C); - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_subset(*upr.part_C,*upr.part_A), - std::runtime_error - ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, inconsistent_rank_subset ) -{ - UnitTestPartRepository upr; - // lower rank cannot contain higher rank: - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_subset(*upr.part_A,*upr.part_D), - std::runtime_error - ); - // higher rank can contain lower rank: - STKUNIT_ASSERT_NO_THROW( - upr.partRepo.declare_subset(*upr.part_D,*upr.part_A) - ); -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, two_part_repositories ) -{ - UnitTestPartRepository upr; - // subset/superset parts must come from same part repository - STKUNIT_ASSERT_THROW( - upr.partRepo_1.declare_subset(*upr.part_1_A,*upr.part_2_A), - std::runtime_error - ); - - // intersection contains parts from another part repository - { - upr.intersection.push_back(upr.part_1_A); - upr.intersection.push_back(upr.part_1_B); - STKUNIT_ASSERT_THROW( - upr.partRepo_2.declare_part( upr.intersection ), - std::runtime_error - ); - } - // intersection contains parts from multiple part repositories - { - upr.intersection.push_back(upr.part_1_A); - upr.intersection.push_back(upr.part_2_A); - STKUNIT_ASSERT_THROW( - upr.partRepo_1.declare_part( upr.intersection ), - std::runtime_error - ); - } -} - -STKUNIT_UNIT_TEST( UnitTestPartRepository, invalid_relation ) -{ - UnitTestPartRepository upr; - upr.relation.m_root = upr.part_B; - upr.relation.m_target = upr.part_A; - STKUNIT_ASSERT_THROW( - upr.partRepo.declare_part_relation( *upr.part_A, upr.relation, *upr.part_B ), - std::runtime_error - ); -} - -//Test covers declare_attribute_no_delete in PartRepository.hpp and PartImpl.hpp -STKUNIT_UNIT_TEST( UnitTestPartRepository, declare_attribute_no_delete ) -{ - UnitTestPartRepository upr; - upr.partRepo.declare_attribute_no_delete(*upr.part_A, upr.singleton); - -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestProperty.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestProperty.cpp deleted file mode 100644 index d13e3cb75f87..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestProperty.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -using stk_classic::mesh::MetaData; -using stk_classic::mesh::Part; -using stk_classic::mesh::Property; - -namespace { - -STKUNIT_UNIT_TEST(UnitTestProperty, testProperty) -{ - const int spatial_dimension = 3; - MetaData meta_data(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - MetaData meta_data2(stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - unsigned size = 0; - unsigned EntityRank = 0; - - Property & pi = meta_data.declare_property("my_i"); - Property & pf = meta_data.declare_property("my_d"); - Property & px = meta_data.declare_property("my_x"); - Property & pa = meta_data.declare_property("my_array",5); - - const Property & pi2 = meta_data.declare_property("my_i5"); - Property & pb = meta_data.declare_property("my_y",0); - Property & pi3 = meta_data.declare_property("my_i", pi.size()); - Property & pi_unsigned = meta_data.declare_property("string_unsigned", size); - const Property & pi_unsigned_const = meta_data.declare_property("string_unsigned", size); - Property & pi_unsigned_2 = meta_data.declare_property("string_unsigned_2"); - const Property & pi_unsigned_const_2 = meta_data.declare_property("string_unsigned_2"); - Property & pProp = meta_data.declare_property("string_correct_new_double", pb.size()); - Part & part_not_equal_to_pi2 = meta_data2.declare_part( "part_not_equal_to_pi2" ); - Part & part_not_equal_to_pi = meta_data2.declare_part( "part_not_equal_to_pi"); - Part & part_not_equal_to_pi2_2 = meta_data2.declare_part( "part_not_equal_to_pi2_2", EntityRank ); - Part & part = meta_data.declare_part( "part", EntityRank ); - - meta_data.commit(); - meta_data2.commit(); - - STKUNIT_ASSERT( pi.type_is() ); - STKUNIT_ASSERT( pf.type_is() ); - STKUNIT_ASSERT( px.type_is() ); - STKUNIT_ASSERT( pa.type_is() ); - - STKUNIT_ASSERT( ! pi.type_is() ); - STKUNIT_ASSERT( ! pa.type_is() ); - - STKUNIT_ASSERT_EQUAL( pi.size() , 1u ); - STKUNIT_ASSERT_EQUAL( pf.size() , 1u ); - STKUNIT_ASSERT_EQUAL( px.size() , 1u ); - STKUNIT_ASSERT_EQUAL( pa.size() , 5u ); - - //Covers add_property in Property.hpp and put_property in MetaData.hpp - meta_data.put_property( pi , meta_data.locally_owned_part() ); - //covers property_data in Property.hpp - STKUNIT_ASSERT( stk_classic::mesh::property_data( pi , meta_data.locally_owned_part() ) != NULL); - STKUNIT_ASSERT( !stk_classic::mesh::property_data( px , meta_data.locally_owned_part() ) ); - - //Coverage of virtual const data_type * data( unsigned key ) const in Property.hpp - STKUNIT_ASSERT_FALSE( stk_classic::mesh::property_data( pi2 , meta_data.locally_owned_part() ) != NULL); - - //Cover unsigned data type in Property.hpp - STKUNIT_ASSERT_FALSE( stk_classic::mesh::property_data( pi_unsigned , meta_data.locally_owned_part() ) != NULL); - STKUNIT_ASSERT_FALSE( stk_classic::mesh::property_data( pi_unsigned_2 , meta_data.locally_owned_part() ) != NULL); - STKUNIT_ASSERT( ! pi_unsigned.type_is() ); - - //Cover unsigned const data type in Property.hpp - STKUNIT_ASSERT_FALSE( stk_classic::mesh::property_data( pi_unsigned_const , meta_data.locally_owned_part() ) != NULL); - STKUNIT_ASSERT_FALSE( stk_classic::mesh::property_data( pi_unsigned_const_2 , meta_data.locally_owned_part() ) != NULL); - - //Coverage of Property.hpp to test two unequal parts for const property_type and cover of property_data_throw - STKUNIT_ASSERT_THROW(property_data( pi2 , part_not_equal_to_pi2 ), - std::logic_error); - STKUNIT_ASSERT_THROW(property_data( pi2 , part_not_equal_to_pi2_2 ), - std::logic_error); - - //Test get_property_base with an correct type in Property.cpp - const std::string& string_correct_double = "my_d"; - meta_data.get_property( string_correct_double ); - - //Test get_property_base with an incorrect type and size in Property.cpp - const std::string& string_incorrect_double = "my_i"; - STKUNIT_ASSERT_THROW( - meta_data.get_property( string_incorrect_double ), - std::runtime_error - ); - - //More coverage of Property.hpp to test two parts with different meta data - STKUNIT_ASSERT_THROW(stk_classic::mesh::property_data( pi , part_not_equal_to_pi ), - std::logic_error); - - //Final coverage of MetaData.hpp - declare_property - const std::string& string_correct_new_double = "my_y"; - meta_data.get_property( string_correct_new_double ); - STKUNIT_ASSERT( (pb).type_is() ); - - //Coverage of add_property in Property.hpp - meta_data.put_property( pProp, part); - - //Coverage of declare_property in MetaData.hpp - STKUNIT_ASSERT( pb.type_is() ); - - //Further coverage of declare_property in MetaData.hpp ( pv != NULL) - STKUNIT_ASSERT( pi3.type_is() ); - -} -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRelation.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRelation.cpp deleted file mode 100644 index 80ff5a50b88f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRelation.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::EntityVector; -using stk_classic::mesh::Part; -using stk_classic::mesh::Relation; -using stk_classic::mesh::Selector; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Ghosting; -using stk_classic::mesh::fixtures::BoxFixture; -using stk_classic::mesh::fixtures::RingFixture; - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST(UnitTestingOfRelation, testRelation) -{ - (void)test_info_; - // Unit test the Part functionality in isolation: - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier ( MPI_COMM_WORLD ); - - typedef stk_classic::mesh::Field ScalarFieldType; - // static const char method[] = "stk_classic::mesh::UnitTestRelation" ; - - std::vector entity_names(10); - for ( size_t i = 0 ; i < 10 ; ++i ) { - std::ostringstream name ; - name << "EntityRank" << i ; - entity_names[i] = name.str(); - } - - unsigned max_bucket_size = 4; - - BoxFixture fixture1(pm , max_bucket_size, entity_names), - fixture2(pm , max_bucket_size, entity_names); - - FEMMetaData& meta = fixture1.fem_meta(); - FEMMetaData& meta2 = fixture2.fem_meta(); - const int spatial_dimension = 3; - const EntityRank element_rank = meta.element_rank(); - - BulkData& bulk = fixture1.bulk_data(); - BulkData& bulk2 = fixture2.bulk_data(); - - ScalarFieldType & temperature = - meta.declare_field < ScalarFieldType > ( "temperature" , 4 ); - ScalarFieldType & volume = - meta.declare_field < ScalarFieldType > ( "volume" , 4 ); - ScalarFieldType & temperature2 = - meta2.declare_field < ScalarFieldType > ( "temperature" , 4 ); - ScalarFieldType & volume2 = - meta2.declare_field < ScalarFieldType > ( "volume" , 4 ); - - Part & universal = meta.universal_part (); - Part & universal2 = meta2.universal_part (); - Part & owned = meta.locally_owned_part (); - - stk_classic::mesh::put_field ( temperature , NODE_RANK , universal ); - stk_classic::mesh::put_field ( volume , element_rank , universal ); - meta.commit(); - stk_classic::mesh::put_field ( temperature2 , NODE_RANK , universal2 ); - stk_classic::mesh::put_field ( volume2 , element_rank , universal2 ); - - meta2.commit(); - - bulk.modification_begin(); - bulk2.modification_begin(); - - const int root_box[3][2] = { { 0,4 } , { 0,5 } , { 0,6 } }; - int local_box1[3][2] = { { 0,0 } , { 0,0 } , { 0,0 } }; - int local_box2[3][2] = { { 0,0 } , { 0,0 } , { 0,0 } }; - - { - bulk.modification_begin(); - fixture1.generate_boxes(root_box, local_box1); - - const Ghosting & gg = bulk.create_ghosting( std::string("shared") ); - - // Test for coverage of comm_procs in EntityComm.cpp - EntityVector nodes; - stk_classic::mesh::get_entities(bulk, NODE_RANK, nodes); - std::vector procs ; - STKUNIT_ASSERT(!nodes.empty()); - stk_classic::mesh::comm_procs( gg, *nodes.front() , procs ); - - STKUNIT_ASSERT(bulk.modification_end()); - - bulk.modification_begin(); - bulk.destroy_all_ghosting(); - STKUNIT_ASSERT(bulk.modification_end()); - } - - { - bulk2.modification_begin(); - fixture2.generate_boxes(root_box, local_box2); - - bulk2.create_ghosting( std::string("shared") ); - - STKUNIT_ASSERT(bulk2.modification_end()); - - bulk2.modification_begin(); - bulk2.destroy_all_ghosting(); - STKUNIT_ASSERT(bulk2.modification_end()); - } - - Entity &cell = *(bulk.buckets (3)[0]->begin()); - Entity &node = bulk.buckets (0)[0]-> operator [] ( 0 ); - Entity &nodeb = bulk.buckets (0)[0]-> operator [] ( 2 ); - - std::vector parts; - parts.push_back ( &universal ); - parts.push_back ( &owned ); - bulk.modification_begin(); - stk_classic::mesh::EntityId new_id = bulk.parallel_rank() + 1; - Entity &edge = bulk.declare_entity ( 1 , new_id , parts ); - - Entity &cell2 = *(bulk2.buckets (3)[0]->begin()); - Entity &node2 = *(bulk2.buckets (0)[0]->begin()); - - STKUNIT_ASSERT_THROW ( bulk.declare_relation ( node , cell , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW ( bulk.declare_relation ( cell , node2 , 0 ) , std::runtime_error ); - STKUNIT_ASSERT_THROW ( bulk.declare_relation ( cell2 , node , 0 ) , std::runtime_error ); - - bulk.declare_relation ( edge , node , 1 ); - STKUNIT_ASSERT_THROW ( bulk.declare_relation ( edge , nodeb , 1 ) , std::runtime_error ); - bulk.declare_relation ( edge , nodeb , 2 ); - - std::stringstream s; - s << *edge.relations().first ; - - bulk.modification_end(); - - //Testing on in_send_ghost and in_shared in EntityComm.cpp - enum { nPerProc = 10 }; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned nLocalEdge = nPerProc ; - FEMMetaData meta3( spatial_dimension ); - - meta3.commit(); - - Selector select_owned( meta3.locally_owned_part() ); - Selector select_used = meta3.locally_owned_part() ; - Selector select_all( meta3.universal_part() ); - - stk_classic::mesh::PartVector no_parts ; - - std::vector local_count ; - - //------------------------------ - { // No ghosting - bool aura_flag = false; - RingFixture mesh2( pm , nPerProc , false /* No edge parts */ ); - mesh2.m_meta_data.commit(); - - mesh2.m_bulk_data.modification_begin(); - mesh2.generate_mesh( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(mesh2.m_bulk_data, - aura_flag)); - mesh2.m_bulk_data.modification_begin(); - mesh2.fixup_node_ownership( ); - STKUNIT_ASSERT(stk_classic::unit_test::modification_end_wrapper(mesh2.m_bulk_data, - aura_flag)); - - // This process' first element in the loop - // if a parallel mesh has a shared node - - Entity * edgenew = mesh2.m_bulk_data.get_entity( 1 , mesh2.m_edge_ids[ nLocalEdge * p_rank ] ); - - mesh2.m_bulk_data.modification_begin(); - for ( unsigned p = 0 ; p < p_size ; ++p ) if ( p != p_rank ) { - STKUNIT_ASSERT_EQUAL( in_shared( *edgenew , p ), false ); - STKUNIT_ASSERT_EQUAL( in_send_ghost( *edgenew , p ), false ); - } - - Entity * edgenew2 = mesh2.m_bulk_data.get_entity( 1 , mesh2.m_edge_ids[ nLocalEdge * p_rank ] ); - STKUNIT_ASSERT_EQUAL( in_send_ghost( *edgenew2 , p_rank+100 ), false ); - - Entity * node3 = mesh2.m_bulk_data.get_entity( 0 , mesh2.m_node_ids[ nLocalEdge * p_rank ] ); - STKUNIT_ASSERT_EQUAL( in_shared( *node3 , p_rank+100 ), false ); - } - - { //ghosting - - if ( 1 < p_size ) { // With ghosting - RingFixture mesh3( pm , nPerProc , false /* No edge parts */ ); - mesh3.m_meta_data.commit(); - - mesh3.m_bulk_data.modification_begin(); - mesh3.generate_mesh(); - STKUNIT_ASSERT(mesh3.m_bulk_data.modification_end()); - - mesh3.m_bulk_data.modification_begin(); - mesh3.fixup_node_ownership(); - STKUNIT_ASSERT(mesh3.m_bulk_data.modification_end()); - - const unsigned nNotOwned = nPerProc * p_rank ; - - // The not-owned shared entity: - Entity * node3 = mesh3.m_bulk_data.get_entity( 0 , mesh3.m_node_ids[ nNotOwned ] ); - Entity * node4 = mesh3.m_bulk_data.get_entity( 0 , mesh3.m_node_ids[ nNotOwned ] ); - - //EntityId node_edge_ids[2] ; - //node_edge_ids[0] = node3->relations()[0].entity()->identifier(); - //node_edge_ids[1] = node3->relations()[1].entity()->identifier(); - - mesh3.m_bulk_data.modification_begin(); - - for ( unsigned p = 0 ; p < p_size ; ++p ) if ( p != p_rank ) { - //FIXME for Carol the check below did not pass for -np 3 or 4 - //STKUNIT_ASSERT_EQUAL( in_shared( *node3 , p ), true ); - STKUNIT_ASSERT_EQUAL( in_send_ghost( *node3 , p ), false ); - } - - //not owned and not shared - Entity * node5 = mesh3.m_bulk_data.get_entity( 0 , mesh3.m_node_ids[ nLocalEdge * p_rank ] ); - - //node_edge_ids[0] = node5->relations()[0].entity()->identifier(); - //node_edge_ids[1] = node5->relations()[1].entity()->identifier(); - - STKUNIT_ASSERT_EQUAL( in_shared( *node5 , p_rank+100 ), false ); - STKUNIT_ASSERT_EQUAL( in_send_ghost( *node4 , p_rank+100 ), false ); - } - - } - -} - -STKUNIT_UNIT_TEST(UnitTestingOfRelation, testDegenerateRelation) -{ - (void)test_info_; - // Test that, if you set up degenerate relations, only of the relations - // is deleted when you destroy one of the degenerate relations. - // BulkData::destroy_relation has been changed to take a relation-id so - // that it can work this way. - // - // To test this, we set up an element that has several relations - // to the same node and then delete them one by one. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank entity_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(entity_rank, p_rank+1 /*elem_id*/, empty_parts); - - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, p_rank+1 /*node_id*/, empty_parts); - - // Add degenerate relations - const unsigned nodes_per_elem = 4; - for (unsigned i = 0; i < nodes_per_elem; ++i) { - mesh.declare_relation( elem, node, i ); - } - - // Elem should have nodes-per-elem relations - STKUNIT_ASSERT_EQUAL( nodes_per_elem, elem.relations().size() ); - - // Destroy relation one-by-one, always checking that appropriate number - // of relations remain. - for (unsigned i = 0; i < nodes_per_elem; ++i) { - mesh.destroy_relation( elem, node, i ); - STKUNIT_ASSERT_EQUAL( nodes_per_elem - (i+1), elem.relations().size() ); - } - - mesh.modification_end(); -} - -STKUNIT_UNIT_TEST(UnitTestingOfRelation, testRelationAttribute) -{ - (void)test_info_; - // Test relation attribute - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank entity_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(entity_rank, p_rank+1 /*elem_id*/, empty_parts); - - // Create node - Entity & node = mesh.declare_entity(NODE_RANK, p_rank+1 /*node_id*/, empty_parts); - - mesh.declare_relation( elem, node, 0 ); - - const Relation & my_relation = *(elem.relations(NODE_RANK).begin()); - my_relation.set_attribute(6u); - - STKUNIT_ASSERT_EQUAL( my_relation.attribute(), 6u); - - mesh.modification_end(); -} - -STKUNIT_UNIT_TEST(UnitTestingOfRelation, testDoubleDeclareOfRelation) -{ - (void)test_info_; - // It should be legal to declare the same relation between shared - // entities on two procs. - // - // 1---3---5 - // | 1 | 2 | - // 2---4---6 - // - // To test this, we use the mesh above, with elem 1 going on rank 0 and - // elem 2 going on rank 1. Nodes 3,4 are shared along with the edge between - // nodes 3 and 4. On both procs we declare relations from the shared edge - // to the shared nodes on both procs. - // - // TODO: If we change how declare_relation works, not requiring all - // sharers to declare the same relations, but instead allowing just - // the owner to declare relations, that should be tested here. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( MPI_COMM_WORLD ); - - // Set up meta and bulk data - const unsigned spatial_dim = 2; - FEMMetaData meta_data(spatial_dim); - meta_data.commit(); - BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm); - unsigned p_rank = mesh.parallel_rank(); - unsigned p_size = mesh.parallel_size(); - - // Bail if we only have one proc - if (p_size == 1) { - return; - } - - // Begin modification cycle so we can create the entities and relations - mesh.modification_begin(); - - Entity* elem_ptr = NULL; - Entity* edge_ptr = NULL; - EntityVector nodes; - const unsigned nodes_per_elem = 4, nodes_per_side = 2; - - if (p_rank < 2) { - // We're just going to add everything to the universal part - stk_classic::mesh::PartVector empty_parts; - - // Create element - const EntityRank entity_rank = meta_data.element_rank(); - Entity & elem = mesh.declare_entity(entity_rank, p_rank+1 /*elem_id*/, empty_parts); - elem_ptr = &elem; - - // Create nodes - const unsigned starting_node_id = p_rank * nodes_per_side + 1; - for (unsigned id = starting_node_id; id < starting_node_id + nodes_per_elem; ++id) { - nodes.push_back(&mesh.declare_entity(NODE_RANK, id, empty_parts)); - } - - // Add relations to nodes - unsigned rel_id = 0; - for (EntityVector::iterator itr = nodes.begin(); itr != nodes.end(); ++itr, ++rel_id) { - mesh.declare_relation( elem, **itr, rel_id ); - } - - // Create edge - const EntityRank edge_rank = meta_data.side_rank(); - Entity & edge = mesh.declare_entity(edge_rank, 1 /*id*/, empty_parts); - edge_ptr = &edge; - - // Set up relation from elem to edge - mesh.declare_relation( *elem_ptr, *edge_ptr, 0 /*rel-id*/ ); - } - - mesh.modification_end(); - - mesh.modification_begin(); - - if (p_rank < 2) { - // Set up relations from edge to nodes - unsigned rel_id = 0; - const unsigned starting_node_idx = (1 - p_rank) * nodes_per_side; - for (unsigned node_idx = starting_node_idx; - node_idx < starting_node_idx + nodes_per_side; - ++node_idx, ++rel_id) { - mesh.declare_relation( *edge_ptr, *nodes[node_idx], rel_id ); - } - } - - mesh.modification_end(); -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.cpp deleted file mode 100644 index 5f4e2c771852..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include -#include -#include - -#include - -using stk_classic::mesh::fem::FEMMetaData; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Selector; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityProc; -using stk_classic::mesh::fixtures::RingFixture; - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST( UnitTestBoxFixture, verifyRingFixture ) -{ - // A unit test to verify the correctness of the RingFixture fixture. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - MPI_Barrier( pm ); - - // Create the ring fixture we'll be testing - - RingFixture fixture(pm); - FEMMetaData& meta = fixture.m_meta_data; - BulkData& bulk = fixture.m_bulk_data; - - const stk_classic::mesh::EntityRank element_rank = meta.element_rank(); - - meta.commit(); - - const unsigned p_rank = bulk.parallel_rank(); - const unsigned p_size = bulk.parallel_size(); - const unsigned nPerProc = fixture.m_num_edge_per_proc ; - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 ); - const unsigned nLocalEdge = nPerProc ; - const unsigned n_extra = 1 < p_size ? 2 : 0 ; - - bulk.modification_begin(); - fixture.generate_mesh(); - - Selector select_owned( meta.locally_owned_part() ); - Selector select_used = meta.locally_owned_part() | - meta.globally_shared_part(); - Selector select_all( meta.universal_part() ); - - std::vector local_count; - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[NODE_RANK] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[element_rank] , nLocalEdge ); - - std::vector all_nodes; - get_entities( bulk, NODE_RANK, all_nodes); - - unsigned num_selected_nodes = - count_selected_entities( select_used, bulk.buckets(NODE_RANK) ); - STKUNIT_ASSERT_EQUAL( num_selected_nodes , local_count[NODE_RANK] ); - - std::vector universal_nodes; - get_selected_entities(select_all, bulk.buckets(NODE_RANK), - universal_nodes ); - STKUNIT_ASSERT_EQUAL( universal_nodes.size() , all_nodes.size() ); - - STKUNIT_ASSERT(bulk.modification_end()); - - // Verify declarations and sharing two end nodes: - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - if ( 1 < p_size ) { - const unsigned n0 = id_end < id_total ? id_begin : 0 ; - const unsigned n1 = id_end < id_total ? id_end : id_begin ; - - Entity * const node0 = bulk.get_entity( NODE_RANK , fixture.m_node_ids[n0] ); - Entity * const node1 = bulk.get_entity( NODE_RANK , fixture.m_node_ids[n1] ); - - STKUNIT_ASSERT( node0 != NULL ); - STKUNIT_ASSERT( node1 != NULL ); - - STKUNIT_ASSERT_EQUAL( node0->sharing().size() , size_t(1) ); - STKUNIT_ASSERT_EQUAL( node1->sharing().size() , size_t(1) ); - } - - // Test no-op first: - - std::vector change ; - - STKUNIT_ASSERT( bulk.modification_begin() ); - bulk.change_entity_owner( change ); - STKUNIT_ASSERT( bulk.modification_end()); - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - stk_classic::mesh::count_entities( select_all , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode + n_extra ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge + n_extra ); - - bulk.modification_begin(); - fixture.fixup_node_ownership(); - STKUNIT_ASSERT(bulk.modification_end()); - - // Make sure that edge->owner_rank() == edge->node[1]->owner_rank() - if ( 1 < p_size ) { - stk_classic::mesh::count_entities( select_all , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode + n_extra ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge + n_extra ); - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - stk_classic::mesh::count_entities( select_owned , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nPerProc ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nPerProc ); - } -} - -} - -namespace stk_classic { -namespace unit_test { - -void test_shift_ring( RingFixture& ring, bool generate_aura=true ) -{ - FEMMetaData& meta = ring.m_meta_data; - BulkData& bulk = ring.m_bulk_data; - - const unsigned p_rank = bulk.parallel_rank(); - const unsigned p_size = bulk.parallel_size(); - const unsigned nPerProc = ring.m_num_edge_per_proc ; - const unsigned id_total = nPerProc * p_size ; - const unsigned id_begin = nPerProc * p_rank ; - const unsigned id_end = nPerProc * ( p_rank + 1 ); - const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 ); - const unsigned nLocalEdge = nPerProc ; - - const unsigned p_send = ( p_rank + 1 ) % p_size ; - const unsigned id_send = id_end - 2 ; - const unsigned id_recv = ( id_begin + id_total - 2 ) % id_total ; - - Selector select_used = meta.locally_owned_part() | - meta.globally_shared_part(); - - std::vector local_count ; - std::vector change ; - - Entity * send_edge_1 = bulk.get_entity( 1 , ring.m_edge_ids[ id_send ] ); - Entity * send_edge_2 = bulk.get_entity( 1 , ring.m_edge_ids[ id_send + 1 ] ); - Entity * send_node_1 = send_edge_1->relations()[1].entity(); - Entity * send_node_2 = send_edge_2->relations()[1].entity(); - Entity * recv_edge_1 = bulk.get_entity( 1 , ring.m_edge_ids[ id_recv ] ); - Entity * recv_edge_2 = bulk.get_entity( 1 , ring.m_edge_ids[ id_recv + 1 ] ); - - STKUNIT_ASSERT( NULL != send_edge_1 && p_rank == send_edge_1->owner_rank() ); - STKUNIT_ASSERT( NULL != send_edge_2 && p_rank == send_edge_2->owner_rank() ); - STKUNIT_ASSERT( NULL == recv_edge_1 || p_rank != recv_edge_1->owner_rank() ); - STKUNIT_ASSERT( NULL == recv_edge_2 || p_rank != recv_edge_2->owner_rank() ); - - if ( p_rank == send_node_1->owner_rank() ) { - EntityProc entry( send_node_1 , p_send ); - change.push_back( entry ); - } - if ( p_rank == send_node_2->owner_rank() ) { - EntityProc entry( send_node_2 , p_send ); - change.push_back( entry ); - } - { - EntityProc entry( send_edge_1 , p_send ); - change.push_back( entry ); - } - { - EntityProc entry( send_edge_2 , p_send ); - change.push_back( entry ); - } - - send_edge_1 = NULL ; - send_edge_2 = NULL ; - send_node_1 = NULL ; - send_node_2 = NULL ; - recv_edge_1 = NULL ; - recv_edge_2 = NULL ; - - STKUNIT_ASSERT( bulk.modification_begin() ); - bulk.change_entity_owner( change ); - STKUNIT_ASSERT( stk_classic::unit_test::modification_end_wrapper( bulk , generate_aura ) ); - - send_edge_1 = bulk.get_entity( 1 , ring.m_edge_ids[ id_send ] ); - send_edge_2 = bulk.get_entity( 1 , ring.m_edge_ids[ id_send + 1 ] ); - recv_edge_1 = bulk.get_entity( 1 , ring.m_edge_ids[ id_recv ] ); - recv_edge_2 = bulk.get_entity( 1 , ring.m_edge_ids[ id_recv + 1 ] ); - - STKUNIT_ASSERT( NULL == send_edge_1 || p_rank != send_edge_1->owner_rank() ); - STKUNIT_ASSERT( NULL == send_edge_2 || p_rank != send_edge_2->owner_rank() ); - STKUNIT_ASSERT( NULL != recv_edge_1 && p_rank == recv_edge_1->owner_rank() ); - STKUNIT_ASSERT( NULL != recv_edge_2 && p_rank == recv_edge_2->owner_rank() ); - - stk_classic::mesh::count_entities( select_used , bulk , local_count ); - STKUNIT_ASSERT_EQUAL( local_count[0] , nLocalNode ); - STKUNIT_ASSERT_EQUAL( local_count[1] , nLocalEdge ); - - unsigned count_shared = 0 ; - for ( std::vector::const_iterator - i = bulk.entity_comm().begin() ; - i != bulk.entity_comm().end() ; ++i ) { - if ( in_shared( **i ) ) { ++count_shared ; } - } - STKUNIT_ASSERT_EQUAL( count_shared , 2u ); - - { - Entity * const node_recv = bulk.get_entity( NODE_RANK , ring.m_node_ids[id_recv] ); - Entity * const node_send = bulk.get_entity( NODE_RANK , ring.m_node_ids[id_send] ); - - STKUNIT_ASSERT_EQUAL( node_recv->sharing().size() , 1u ); - STKUNIT_ASSERT_EQUAL( node_send->sharing().size() , 1u ); - } -} - -} -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.hpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.hpp deleted file mode 100644 index eb73da06ec36..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestRingFixture.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef unit_test_UnitTestRingFixture_hpp -#define unit_test_UnitTestRingFixture_hpp - -#include - -// must be in same namespace as BulkData to make friending w/out exposure possible - -namespace stk_classic { -namespace unit_test { - -/** - * TODO - Document what this does - */ -void test_shift_ring( stk_classic::mesh::fixtures::RingFixture& ring, - bool generate_aura=true ); - -} // namespace unit_test -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSelector.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSelector.cpp deleted file mode 100644 index 0d4d99cb243b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSelector.cpp +++ /dev/null @@ -1,973 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -// Unit test the Selector in isolation - -namespace { - -using stk_classic::mesh::fixtures::SelectorFixture ; - -void initialize(SelectorFixture& fixture) -{ - fixture.m_meta_data.commit(); - fixture.m_bulk_data.modification_begin(); - fixture.generate_mesh(); - STKUNIT_ASSERT(fixture.m_bulk_data.modification_end()); -} - -/** \defgroup stk_mesh_selector_unit "stk_classic::mesh::Selector Unit Testing" - * \addtogroup stk_mesh_selector_unit - * \{ - * - * Selector unit testing environment.
- * A special set of mesh parts and entities are set up in the - * following configuration for the Selector unit testing.
- * Parts: PartA, PartB, PartC, PartD, PartU
- * PartU = MetaData.universal_part()
- * Entities: Entity1, Entity2, Entity3, Entity4, Entity5
- * - * PartA contains Entity1, Entity2
- * PartB contains Entity2, Entity3
- * PartC contains Entity3, Entity4
- * PartD contains no entities
- * Entity5 is not contained in any Part
- * - *
-  * |----------|--|-------|--|----------|    |-------------|
-  * |<--PartA---->|       |<--PartC---->|    |   PartD     |
-  * |          |<---PartB--->|          |    |             |
-  * |  1       |2 |       |3 |       4  | 5  |             |
-  * |          |  |       |  |          |    |             |
-  * |          |  |       |  |          |    |             |
-  * |----------|--|-------|--|----------|    |-------------|
-  * 
- * - * Note: The unit test names use the convention of "i" for - * intersection, "u" for union, and "c" for complement. - * - * */ - -/** \brief Verify we can construct the selector unit testing fixture. - * - * */ -STKUNIT_UNIT_TEST( UnitTestSelector, one_SelectorFixture ) -{ - { - SelectorFixture fix; - initialize(fix); - } - STKUNIT_EXPECT_TRUE(true); -} - - -/** \brief Verify we can construct two selector unit testing fixtures one after another. - * - * */ -STKUNIT_UNIT_TEST( UnitTestSelector, two_SelectorFixture ) -{ - { - SelectorFixture fix; - initialize(fix); - } - { - SelectorFixture fix; - initialize(fix); - } - STKUNIT_EXPECT_TRUE(true); -} - - - -/** \brief Test containment directly. - * - * Verify PartA contains Entity1 and Entity2, and does not contain - * Entity3, Entity4, or Entity5. - * */ -STKUNIT_UNIT_TEST( UnitTestSelector, A_12345 ) -{ - SelectorFixture fix; - initialize(fix); - - stk_classic::mesh::Selector selector( fix.m_partA ); - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket() ; - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - -/** \brief Test containment with the complement. - * - * Verify !PartA does not contain Entity1 and Entity2, and does - * contain Entity3, Entity4, and Entity5. - ** */ -STKUNIT_UNIT_TEST( UnitTestSelector, Ac_12345 ) -{ - SelectorFixture fix; - initialize(fix); - - stk_classic::mesh::Selector selector = ! fix.m_partA ; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - -} - -/** \brief Verify PartD does not contain Entity5. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, D_5 ) -{ - SelectorFixture fix; - initialize(fix); - - stk_classic::mesh::Selector selector( fix.m_partD ); - - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); -} - -/** \brief Verify PartA.complement contains Entity1 and Entity5. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, Ac_15 ) -{ - SelectorFixture fix; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - - stk_classic::mesh::Selector selector(partA); - selector.complement(); - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } -} - -/** \brief Verify (PartA AND PartB) does not contain Entity1 and does - * contain Entity2. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AiB_12 ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - - stk_classic::mesh::Selector selector = partA & partB; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } -} - - -/** \brief Verify (PartA OR PartB) contains Entity1 but not Entity4 - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AuB_14 ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - - stk_classic::mesh::Selector selector = partA | partB; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - - -/** \brief Verify !(PartA AND PartB) contains Entity1 but not Entity2. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AiBc_12 ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - - stk_classic::mesh::Selector selector = partA & !partB; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - - -/** \brief Verify !(PartA OR PartB) contains Entity1 but not Entity3. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AuBc_13 ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - - stk_classic::mesh::Selector selector = partA | !partB; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - - -// plus copy constructor -/** \brief Verify (PartA AND !(PartB OR PartC)) contains Entity1 but - * not Entity2. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, Ai_BuC_c_12 ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - - stk_classic::mesh::Selector selector = partA & !(partB | partC); - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - - stk_classic::mesh::Selector newSelector(selector); - // Should be the same: - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = newSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = newSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - -} - - -/** \brief test on Selector operator for Entity - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, entityTest ) -{ - { - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Selector selector = partA & !partB; - - const stk_classic::mesh::Entity & pEntity = *fix.m_entity5; - bool result = selector(pEntity); - STKUNIT_EXPECT_FALSE(result); - } - -} - -/** \brief Verify the default constructor does not contain Entity1. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, defaultConstructor ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Selector selector; - //std::cout << "Selector = " << selector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - - -/** \brief Verify flipping the complement bit on an OR expression - * works correctly. - * Verify !(PartA OR PartB) does not contain Entity1, Entity2, - * or Entity3, and does contain Entity4. Then check that !!(PartA OR - * PartB) does contain Entity1, Entity2, and Entity3, and not Entity4. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, flipComplement_AuB_c ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Selector notOrSelector = partA | partB; - //std::cout << "Or Selector = " << notOrSelector << std::endl; - notOrSelector.complement(); - //std::cout << "Not Or Selector = " << notOrSelector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = notOrSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = notOrSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = notOrSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = notOrSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - - stk_classic::mesh::Selector notNotOrSelector = !notOrSelector; - //std::cout << "Not Not Or Selector = " << notNotOrSelector << std::endl; - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = notNotOrSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = notNotOrSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = notNotOrSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = notNotOrSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - -/** \brief Verify flipping the complement bit on an AND expression - * works correctly. - * Verify !(PartA AND PartB) does not contain Entity2, and does - * contain Entity1, Entity3, and Entity4. - * Then check that !!(PartA AND PartB) does contain Entity2, but not Entity1, Entity3, or Entity4. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, flipComplement_AiB_c ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Selector notAndSelector = partA & partB; - //std::cout << "And Selector = " << notAndSelector << std::endl; - notAndSelector.complement(); - //std::cout << "Not And Selector = " << notAndSelector << std::endl; - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = notAndSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = notAndSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = notAndSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = notAndSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - - stk_classic::mesh::Selector notNotAndSelector = !notAndSelector; - //std::cout << "Not Not And Selector = " << notNotAndSelector << std::endl; - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = notNotAndSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = notNotAndSelector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = notNotAndSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = notNotAndSelector(bucket); - STKUNIT_EXPECT_FALSE(result); - } -} - -/** \brief Verify flipping the complement bit on an empty Selector - * works. - * () does not contain Entity1. - * !() contains Entity1. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, complementEmpty ) { - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Selector selector; - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - selector.complement(); - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } -} - - -/** \brief Verify the fancy output for (PartA OR PartB OR PartC OR - * PartD). - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AuBuCuD ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - stk_classic::mesh::Part & partD = fix.m_partD ; - stk_classic::mesh::Selector selector = partA | partB | partC | partD; - std::cout << "A|B|C|D = " << selector << std::endl; - std::ostringstream msg; - msg << selector; - STKUNIT_EXPECT_EQUAL( "!(!PartA AND !PartB AND !PartC AND !PartD)" , msg.str() ); -} - - -/** \brief Verify the fancy output for (PartA AND PartB AND PartC). - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AiBiC ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - stk_classic::mesh::Selector selector = partA & partB & partC; - std::cout << "A&B&C = " << selector << std::endl; - std::ostringstream msg; - msg << selector; - STKUNIT_EXPECT_TRUE( msg.str() == "PartA AND PartB AND PartC" ); -} - - -/** \brief Verify the fancy output for a complex expression. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, complicated ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - stk_classic::mesh::Part & partD = fix.m_partD ; - stk_classic::mesh::Selector selector = partA | ( !((partA & partB) | partC) & (!partD | partB)); - std::cout << "complicated selector = " << selector << std::endl; - std::ostringstream msg; - msg << selector; - STKUNIT_EXPECT_EQUAL( "!(!PartA AND !((!(PartA AND PartB) AND !PartC) AND !(PartD AND !PartB)))" , msg.str() ); -} - - -/** \brief Verify \ref stk_classic::mesh::selectIntersection - * "selectIntersection" works correctly. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, selectIntersection ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::PartVector parts ; - parts.push_back( & fix.m_partA ); - parts.push_back( & fix.m_partB ); - stk_classic::mesh::Selector selector = selectIntersection(parts); - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_FALSE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_FALSE(result); - } - - std::ostringstream msg; - msg << selector; - STKUNIT_EXPECT_TRUE( msg.str() == "PartA AND PartB"); -} - - -/** \brief Verify \ref stk_classic::mesh::selectUnion "selectUnion" works - * correctly. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, selectUnion ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::PartVector parts ; - parts.push_back( & fix.m_partA ); - parts.push_back( & fix.m_partB ); - parts.push_back( & fix.m_partC ); - stk_classic::mesh::Selector selector = selectUnion(parts); - - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity5->bucket(); - bool result = selector(bucket); - STKUNIT_ASSERT_FALSE(result); - } - - std::ostringstream msg; - msg << selector; - std::cout << "msg.str() = " << msg.str() << std::endl; - STKUNIT_EXPECT_EQUAL( "!(!PartA AND !PartB AND !PartC)", msg.str() ); -} - -// Intersection first then union -// & before | -/** \brief Verify order of operations works correctly. - * (PartA OR PartB AND PartC) = (PartA OR (PartB AND PartC)). - * (PartB AND PartC OR PartA) = ((PartB AND PartC) OR PartA). - * - */ -//STKUNIT_UNIT_TEST( UnitTestSelector, orderOfOperations ) -//{ -// SelectorFixture fix ; -// stk_classic::mesh::Part & partA = fix.m_partA ; -// stk_classic::mesh::Part & partB = fix.m_partB ; -// stk_classic::mesh::Part & partC = fix.m_partC ; -// { -// stk_classic::mesh::Selector selector = partA | partB & partC; -// //std::cout << "A|B&C selector = " << selector << std::endl; -// std::ostringstream msg; -// msg << selector; -// STKUNIT_EXPECT_EQUAL( "!(!PartA AND !(PartB AND PartC))", msg.str() ); -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_FALSE(result); -// } -// } -// { -// stk_classic::mesh::Selector selector = partB & partC | partA; -// //std::cout << "B&C|A selector = " << selector << std::endl; -// std::ostringstream msg; -// msg << selector; -// STKUNIT_EXPECT_EQUAL( "!(!(PartB AND PartC) AND !PartA)", msg.str() ); -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity2->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_TRUE(result); -// } -// { -// const stk_classic::mesh::Bucket & bucket = fix.m_entity4->bucket(); -// bool result = selector(bucket); -// STKUNIT_EXPECT_FALSE(result); -// } -// } -//} - - -/** \brief Verify unions and intersections of default constructors and - * their complements. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, ZeroiuZero ) { - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Selector selectNone; - stk_classic::mesh::Selector selectAll; - selectAll.complement(); - { - stk_classic::mesh::Selector selector = selectNone & selectAll; - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - stk_classic::mesh::Selector selector = selectNone | selectAll; - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selector(bucket); - STKUNIT_EXPECT_TRUE(result); - } - -} - -/** \brief Verify default \ref stk_classic::mesh::Selector "selectors" work - * well with \ref stk_classic::mesh::Part "mesh part" instantiated \ref - * stk_classic::mesh::Selector "selectors". - * - * In particular, check that (() OR - * PartA) contains Entity1 and (!() AND PartA) contains Entity1. - * - */ - -STKUNIT_UNIT_TEST( UnitTestSelector, ZeroiuA ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Selector selectNone; - stk_classic::mesh::Selector selectAll; - selectAll.complement(); - stk_classic::mesh::Selector selectA = partA; - stk_classic::mesh::Selector selectNoneOrA = selectNone | selectA; - stk_classic::mesh::Selector selectAllAndA = selectAll & selectA; - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selectNoneOrA(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selectAllAndA(bucket); - STKUNIT_EXPECT_TRUE(result); - } -} - - -/** \brief Verify copy constructed \ref stk_classic::mesh::Selector "selector" creates same pretty print output. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, copyConstructor ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - stk_classic::mesh::Selector selectA = (partA & partB) | partC; - stk_classic::mesh::Selector anotherSelectA(selectA); - std::ostringstream descriptionA; - descriptionA << selectA; - std::ostringstream descriptionAnotherA; - descriptionAnotherA << anotherSelectA; - STKUNIT_EXPECT_EQUAL( descriptionA.str() == descriptionAnotherA.str(), true ); -} - - -/** \brief Verify pretty printing of default constructors and their - * complements works well. - * In particular !() AND !() and (!() OR !()) == !(() AND ()). - * - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, AlliuAll ) -{ - stk_classic::mesh::Selector selectAll; - selectAll.complement(); - - stk_classic::mesh::Selector anotherSelectAll; - anotherSelectAll.complement(); - - { - stk_classic::mesh::Selector selectAllANDAll = selectAll & anotherSelectAll; - std::ostringstream description; - description << selectAllANDAll; - STKUNIT_EXPECT_EQUAL( "!() AND !()", description.str() ); - } - { - stk_classic::mesh::Selector selectAllORAll = selectAll | anotherSelectAll; - std::ostringstream description; - description << selectAllORAll; - STKUNIT_EXPECT_EQUAL( "!(())", description.str() ); - } -} - -/** \brief Verify that the 'selectField' selector works correctly. - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, selectField ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Selector selectA = stk_classic::mesh::selectField(fix.m_fieldA); - stk_classic::mesh::Selector selectABC = stk_classic::mesh::selectField(fix.m_fieldABC); - { - //entity1 is in partA, so entity1's bucket should be selected by selectA: - const stk_classic::mesh::Bucket & bucket = fix.m_entity1->bucket(); - bool result = selectA(bucket); - STKUNIT_EXPECT_TRUE(result); - } - { - //entity3 is not in partA, so entity3's bucket should not be selected by selectA: - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selectA(bucket); - STKUNIT_EXPECT_FALSE(result); - } - { - //entity3 is in partB, so entity3's bucket should be selected by selectABC: - const stk_classic::mesh::Bucket & bucket = fix.m_entity3->bucket(); - bool result = selectABC(bucket); - STKUNIT_EXPECT_TRUE(result); - } -} - -/** \brief Verify operator()(Part&) works as expected - * - */ -STKUNIT_UNIT_TEST( UnitTestSelector, select_part ) -{ - SelectorFixture fix ; - initialize(fix); - - stk_classic::mesh::Part & partA = fix.m_partA ; - stk_classic::mesh::Part & partB = fix.m_partB ; - stk_classic::mesh::Part & partC = fix.m_partC ; - stk_classic::mesh::Part & partD = fix.m_partD ; - stk_classic::mesh::Selector selector = partA | partB | (!partC) | partD; - std::cout << "select_part selector = " << selector << std::endl; - STKUNIT_EXPECT_TRUE(selector(partA)); - STKUNIT_EXPECT_TRUE(selector(partB)); - STKUNIT_EXPECT_FALSE(selector(partC)); - STKUNIT_EXPECT_TRUE(selector(partD)); - - selector = - partA | - ( !( (partA & partB) | partC) - & - (!partD | partB) - ); - - STKUNIT_EXPECT_TRUE(selector(partA)); - STKUNIT_EXPECT_TRUE(selector(partB)); - STKUNIT_EXPECT_FALSE(selector(partC)); - STKUNIT_EXPECT_FALSE(selector(partD)); - - selector = partC & (!partD); - STKUNIT_EXPECT_FALSE(selector(partA)); - STKUNIT_EXPECT_FALSE(selector(partB)); - STKUNIT_EXPECT_TRUE(selector(partC)); - STKUNIT_EXPECT_FALSE(selector(partD)); - -} - -/** \} */ - - -} // namespace diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinIrregular.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinIrregular.cpp deleted file mode 100644 index 0c09c50d0aa9..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinIrregular.cpp +++ /dev/null @@ -1,670 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -using stk_classic::mesh::EntityId; -using stk_classic::mesh::EntityRank; - -//--------------------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST( UnitTestSkin, SkinPocket) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.declare_part( "hex_part", hex_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - //create and skin a 2 hex-element mesh with a pocket - //in a normal mesh 6 and 13 would be the same node - // - // 8-------7-------12 - // /| /|\ /| - // / | / | \ / | - // 5-------6 | 13-11 | - // | 4----|--3/---|--10 - // | / | // | / - // |/ |// |/ - // 1-------2-------9 - // - - fem_meta.commit(); - - bulk_data.modification_begin(); - - // declare left element on first process - if (p_rank == 0) - { - EntityId element_id = 1; - EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8}; - - stk_classic::mesh::fem::declare_element( bulk_data, hex_part, element_id, node_ids); - - } - - // declare right element on last process - if (p_rank == p_size -1) - { - EntityId element_id = 2; - EntityId node_ids[8] = { 2, 9, 10, 3, 13, 11, 12, 7}; - - stk_classic::mesh::fem::declare_element( bulk_data, hex_part, element_id, node_ids); - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //each element should have 6 faces attached to it - for (EntityId element_id = 1; element_id < 3; ++element_id) { - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, element_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 6); - } - } -} - -STKUNIT_UNIT_TEST( UnitTestSkin, SkinTwoStackedShells) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part( "shell_part", shell_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - fem_meta.commit(); - - //create and skin stacked shells - // 4-------3 - // | | - // | | - // | | - // 1-------2 - // - // create following 8 shells - // shells 1 defined with right hand rule - // shells 2 defined with left hand rule - // - // shell_id: node_list - // 1: (1,2,3,4) - // 2: (1,2,3,4) - - EntityId node_ids[4] = { 1, 2, 3, 4}; - - bulk_data.modification_begin(); - - { - bool create_shell_on_proc = static_cast(p_rank) == 0; - if (create_shell_on_proc) { - EntityId element_id = static_cast(1); - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - } - - { - bool create_shell_on_proc = static_cast(p_rank) == (std::max(0,static_cast(p_size)-1)); - if (create_shell_on_proc) { - EntityId element_id = static_cast(2); - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //count number of sides in mesh - { - stk_classic::mesh::Selector select_sides = meta_data.locally_owned_part() ; - const std::vector& side_buckets = bulk_data.buckets(side_rank); - int num_sides = stk_classic::mesh::count_selected_entities( select_sides, side_buckets); - - - stk_classic::all_reduce(MPI_COMM_WORLD, stk_classic::ReduceSum<1>(&num_sides)); - - // Verify that the correct 2 sides are present. - - STKUNIT_ASSERT_EQUAL( num_sides, 2 ); - } -} - -//--------------------------------------------------------------------------------------- -STKUNIT_UNIT_TEST( UnitTestSkin, SkinStackedShells) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part( "shell_part", shell_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - fem_meta.commit(); - - //create and skin stacked shells - // 4-------3 - // | | - // | | - // | | - // 1-------2 - // - // create following 8 shells - // shells 1-4 defined with right hand rule - // shells 5-6 defined with left hand rule - // - // shell_id: node_list - // 1: (1,2,3,4) - // 2: (2,3,4,1) - // 3: (3,4,1,2) - // 4: (4,1,2,3) - // 5: (4,3,2,1) - // 6: (3,2,1,4) - // 7: (2,1,4,3) - // 8: (1,4,3,2) - - EntityId node_ids[8] = { 1, 2, 3, 4, 1, 2, 3, 4}; - EntityId reverse_node_ids[8] = { 4, 3, 2, 1, 4, 3, 2, 1}; - - bulk_data.modification_begin(); - - //create shells - for ( int i = 0; i<4; i++ ) { - - bool create_shell_on_proc = static_cast(p_rank) == (std::max(0,static_cast(p_size)-1-i)); - if (create_shell_on_proc) { - EntityId element_id = static_cast(i+1); - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids+i); - } - - bool create_reverse_shell_on_proc = static_cast(p_rank) == (std::max(0,static_cast(p_size)-1-4-i)); - if (create_reverse_shell_on_proc) { - EntityId reverse_element_id = static_cast(i+1+4); - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, reverse_element_id, reverse_node_ids+i); - } - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //count number of sides in mesh - { - stk_classic::mesh::Selector select_sides = meta_data.locally_owned_part() ; - const std::vector& side_buckets = bulk_data.buckets( side_rank); - int num_sides = stk_classic::mesh::count_selected_entities( select_sides, side_buckets); - - - stk_classic::all_reduce(MPI_COMM_WORLD, stk_classic::ReduceSum<1>(&num_sides)); - - // Verify that the correct 2 sides are present. - - STKUNIT_ASSERT_EQUAL( num_sides, 2 ); - } - - //check that faces are attached to correct sides - { - EntityId face_1_id = 0; //invalid face id - EntityId face_2_id = 0; //invalid face id - for (EntityId shell_id = 1; shell_id < 5; ++shell_id) { - stk_classic::mesh::Entity * shell = bulk_data.get_entity( element_rank, shell_id); - if ( shell != NULL) { - stk_classic::mesh::PairIterRelation shell_side_relations = shell->relations(side_rank); - - STKUNIT_ASSERT_TRUE( shell_side_relations.size() == 2); - - // verify that only one side has been created - // and that all stacked shells reference this side - if (face_1_id == 0) { - face_1_id = shell_side_relations->entity()->identifier(); - } - else { - STKUNIT_EXPECT_TRUE( face_1_id == shell_side_relations->entity()->identifier()); - } - - //check that the side is one the correct local side of the shell - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0); - - ++shell_side_relations; - - if (face_2_id == 0) { - face_2_id = shell_side_relations->entity()->identifier(); - } - else { - STKUNIT_EXPECT_TRUE( face_2_id == shell_side_relations->entity()->identifier()); - } - - //check that the side is one the correct local side of the shell - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1); - - } - } - - for (EntityId shell_id = 5; shell_id < 9; ++shell_id) { - stk_classic::mesh::Entity * shell = bulk_data.get_entity( element_rank, shell_id); - if ( shell != NULL) { - stk_classic::mesh::PairIterRelation shell_side_relations = shell->relations(side_rank); - - STKUNIT_ASSERT_TRUE( shell_side_relations.size() == 2); - - // verify that only one side has been created - // and that all stacked shells reference this side - if (face_2_id == 0) { - face_2_id = shell_side_relations->entity()->identifier(); - } - else { - STKUNIT_EXPECT_TRUE( face_2_id == shell_side_relations->entity()->identifier()); - } - - //check that the side is one the correct local side of the shell - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0); - - ++shell_side_relations; - - if (face_1_id == 0) { - face_1_id = shell_side_relations->entity()->identifier(); - } - else { - STKUNIT_EXPECT_TRUE( face_1_id == shell_side_relations->entity()->identifier()); - } - - //check that the side is one the correct local side of the shell - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1); - - } - } - } -} - -//--------------------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST( UnitTestSkin, SkinShellOnHex) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.declare_part( "hex_part", hex_top ); - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part( "shell_part", shell_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - //create and skin a hex element mesh with a shell on the first side of the hex - // Using a shell defined by the nodes (1, 2, 6, 5) produces an orientated shell - // - // Therefore the shell will be skinned with 1 side and the hex will have 5. - // - // 8-------7 - // /| /| - // / | / | - // 5=======6 | - // || 4----||-3 - // ||/ ||/ - // |/ |/ - // 1=======2 - // - - fem_meta.commit(); - - bulk_data.modification_begin(); - - // declare hex element on first process - if (p_rank == 0) - { - EntityId element_id = 1; - EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8}; - - stk_classic::mesh::fem::declare_element( bulk_data, hex_part, element_id, node_ids); - - } - - // declare shell element on last process - if (p_rank == p_size -1) - { - EntityId element_id = 2; - EntityId node_ids[8] = { 1, 2, 6, 5}; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //check hex - { - EntityId hex_id = 1; - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, hex_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 5); - for (; !element_side_relations.empty(); ++element_side_relations) { - unsigned local_side_id = element_side_relations->identifier(); - bool correct_side_skinned = local_side_id > 0 && local_side_id < 6; - STKUNIT_EXPECT_TRUE (correct_side_skinned); - std::cout << "Hex local side id: " << local_side_id << std::endl; - } - } - } - - //check shell - { - EntityId shell_id = 2; - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, shell_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 1); - for (; !element_side_relations.empty(); ++element_side_relations) { - unsigned local_side_id = element_side_relations->identifier(); - bool correct_side_skinned = local_side_id == 0; - STKUNIT_EXPECT_TRUE (correct_side_skinned); - std::cout << "Shell local side id: " << local_side_id << std::endl; - } - } - } -} - -//--------------------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST( UnitTestSkin, SkinInvertedShellOnHex) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.declare_part( "hex_part", hex_top ); - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part( "shell_part", shell_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - //create and skin a hex element mesh with an inverted shell - // Using a shell defined by the nodes (1, 2, 5, 6) produces an inverted shell - // with no valid orientation - // - // Therefore the shell will be skinned with 2 sides and the hex will have 6. - // - // 8-------7 - // /| /| - // / | / | - // 5=======6 | - // || 4----||-3 - // ||/ ||/ - // |/ |/ - // 1=======2 - // - - fem_meta.commit(); - - bulk_data.modification_begin(); - - // declare hex element on first process - if (p_rank == 0) - { - EntityId element_id = 1; - EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8}; - - stk_classic::mesh::fem::declare_element( bulk_data, hex_part, element_id, node_ids); - - } - - // declare shell element on last process - if (p_rank == p_size -1) - { - EntityId element_id = 2; - EntityId node_ids[8] = { 1, 2, 5, 6}; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //check hex - { - EntityId hex_id = 1; - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, hex_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 6); - for (; !element_side_relations.empty(); ++element_side_relations) { - unsigned local_side_id = element_side_relations->identifier(); - bool correct_side_skinned = local_side_id < 6; - STKUNIT_EXPECT_TRUE (correct_side_skinned); - std::cout << "Hex local side id: " << local_side_id << std::endl; - } - } - } - - //check shell - { - EntityId shell_id = 2; - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, shell_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 2); - for (; !element_side_relations.empty(); ++element_side_relations) { - unsigned local_side_id = element_side_relations->identifier(); - bool correct_side_skinned = local_side_id < 2; - STKUNIT_EXPECT_TRUE (correct_side_skinned); - std::cout << "Shell local side id: " << element_side_relations->identifier() << std::endl; - } - } - } -} - -//--------------------------------------------------------------------------------------- - -STKUNIT_UNIT_TEST( UnitTestSkin, SkinStackedShellOnHex) -{ - enum { SpatialDim = 3 }; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , pm ); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & hex_part = fem_meta.declare_part( "hex_part", hex_top ); - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part( "shell_part", shell_top ); - const EntityRank element_rank = fem_meta.element_rank(); - const EntityRank side_rank = fem_meta.side_rank(); - - //create and skin a hex element mesh with 3 shells on the first side of the hex - // Using shells defined by the nodes (1, 2, 6, 5), (6, 5, 1, 2), and (1, 5, 6, 2) - // produces an orientated shells. - // - // Therefore the shells will all have a relation to the same side. - // - // 8-------7 - // /| /| - // / | / | - // 5=======6 | - // || 4----||-3 - // ||/ ||/ - // |/ |/ - // 1=======2 - // - - fem_meta.commit(); - - bulk_data.modification_begin(); - - bool create_hex_this_proc = (p_rank == 0); - bool create_shell_1_this_proc = static_cast(p_rank) == (std::max(0,static_cast(p_size)-3)); - bool create_shell_2_this_proc = static_cast(p_rank) == (std::max(0,static_cast(p_size)-2)); - bool create_shell_3_this_proc = (p_rank == p_size -1); - - if (create_hex_this_proc) - { - EntityId element_id = 1; - EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8}; - - stk_classic::mesh::fem::declare_element( bulk_data, hex_part, element_id, node_ids); - - } - - if (create_shell_1_this_proc) - { - EntityId element_id = 2; - EntityId node_ids[8] = { 1, 2, 6, 5}; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - - if (create_shell_2_this_proc) - { - EntityId element_id = 3; - EntityId node_ids[8] = { 6, 5, 1, 2}; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - - if (create_shell_3_this_proc) - { - EntityId element_id = 4; - EntityId node_ids[8] = { 1, 5, 6, 2}; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, element_id, node_ids); - } - - bulk_data.modification_end(); - - //skin the mesh - stk_classic::mesh::skin_mesh(bulk_data, element_rank); - - //check hex - { - EntityId hex_id = 1; - stk_classic::mesh::Entity * element = bulk_data.get_entity( element_rank, hex_id); - if ( element != NULL) { - stk_classic::mesh::PairIterRelation element_side_relations = element->relations(side_rank); - STKUNIT_EXPECT_TRUE( element_side_relations.size() == 5); - for (; !element_side_relations.empty(); ++element_side_relations) { - unsigned local_side_id = element_side_relations->identifier(); - bool correct_side_skinned = local_side_id > 0 && local_side_id < 6; - STKUNIT_EXPECT_TRUE (correct_side_skinned); - std::cout << "Hex local side id: " << local_side_id << std::endl; - } - } - } - - //check shells - { - EntityId face_id = 0; //invalid face id - for (EntityId shell_id = 2; shell_id < 5; ++shell_id) { - stk_classic::mesh::Entity * shell = bulk_data.get_entity( element_rank, shell_id); - if ( shell != NULL) { - stk_classic::mesh::PairIterRelation shell_side_relations = shell->relations(side_rank); - - STKUNIT_EXPECT_TRUE( shell_side_relations.size() == 1); - - // verify that only one side has been created - // and that all stacked shells reference this side - if (face_id == 0) { - face_id = shell_side_relations->entity()->identifier(); - } - else { - STKUNIT_EXPECT_TRUE( face_id == shell_side_relations->entity()->identifier()); - std::cout << "Shell: " << shell_id - << "\tFace_id: " << face_id - << "\tFace_id: " << shell_side_relations->entity()->identifier() - << std::endl; - } - - //check that the side is one the correct local side of the shell - //shells 1 and 2 follow the right hand rule so the side should be on - //local_side_id 0. - //shell 3 should have it's side on local_side_1d 1 - if (shell_id != 4) { - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0); - } - else { - STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1); - } - } - } - } -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinning.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinning.cpp deleted file mode 100644 index e7c4e7158470..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestSkinning.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -class UnitTestStkMeshSkinning { -public: - UnitTestStkMeshSkinning(stk_classic::ParallelMachine pm) : m_comm(pm), m_num_procs(0), m_rank(0) - { - m_num_procs = stk_classic::parallel_machine_size( m_comm ); - m_rank = stk_classic::parallel_machine_rank( m_comm ); - } - - void test_skinning(); - - stk_classic::ParallelMachine m_comm; - int m_num_procs; - int m_rank; -}; - -namespace { - -STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testUnit ) -{ - UnitTestStkMeshSkinning unit(MPI_COMM_WORLD); - unit.test_skinning(); -} - -STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testSingleShell ) -{ - const int spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension)); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data, MPI_COMM_WORLD ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - const unsigned p_rank = bulk_data.parallel_rank(); - - stk_classic::mesh::Part & skin_part = fem_meta.declare_part("skin_part"); - - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part("shell_part", shell_top); - - fem_meta.commit(); - - bulk_data.modification_begin(); - - if ( p_rank == 0 ) { - - stk_classic::mesh::EntityId elem_node[4] ; - - // Query nodes from this simple grid fixture via the (i,j,k) indices. - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - - stk_classic::mesh::EntityId elem_id = 1; - - stk_classic::mesh::fem::declare_element( bulk_data, shell_part, elem_id, elem_node); - - } - bulk_data.modification_end(); - - - stk_classic::mesh::skin_mesh( bulk_data, element_rank, &skin_part); - - { - const unsigned mesh_rank = element_rank; - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(bulk_data); - stk_classic::mesh::Selector select_skin = skin_part & meta.locally_owned_part() ; - const std::vector& buckets = bulk_data.buckets( mesh_rank -1); - int num_skin_entities = stk_classic::mesh::count_selected_entities( select_skin, buckets); - - - stk_classic::all_reduce(MPI_COMM_WORLD, stk_classic::ReduceSum<1>(&num_skin_entities)); - - // Verify that the correct 6 sides are present. - - STKUNIT_ASSERT_EQUAL( num_skin_entities, 2 ); - } -} - -} //end namespace - -void UnitTestStkMeshSkinning::test_skinning() -{ - // This test will only work for np=1 - if (m_num_procs > 1) { - return; - } - - stk_classic::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD); - - stk_classic::mesh::BulkData& bulk_data = grid_mesh.bulk_data(); - stk_classic::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta(); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - // Create a part for the skin and the shells - stk_classic::mesh::Part & skin_part = fem_meta.declare_part("skin_part"); - stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fem_meta.declare_part("shell_part", line_top); - fem_meta.commit(); - - // Begin modification cycle - grid_mesh.bulk_data().modification_begin(); - - // Generate the plain grid - grid_mesh.generate_grid(); - - // Add the shells - std::vector count; - stk_classic::mesh::Selector locally_owned(fem_meta.locally_owned_part()); - stk_classic::mesh::count_entities(locally_owned, bulk_data, count); - const unsigned num_shell_1_faces = 4; - const unsigned num_shell_2_faces = 2; - const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces; - const unsigned num_entities = count[NODE_RANK] + - count[element_rank]; - - stk_classic::mesh::PartVector shell_parts; - shell_parts.push_back(&shell_part); - - std::vector shell_faces; - for (unsigned i = 1; i <= num_shell_faces; ++i) { - stk_classic::mesh::Entity& new_shell = bulk_data.declare_entity(element_rank, - num_entities + i, - shell_parts); - shell_faces.push_back(&new_shell); - } - - // Set up relationships for shells - - // declare shell relationships for first shell - unsigned node_list_1[5] = {21, 26, 31, 36, 41}; - for (unsigned i = 0; i < num_shell_1_faces; ++i) { - stk_classic::mesh::Entity& shell = *(shell_faces[i]); - stk_classic::mesh::Entity& node1 = *(bulk_data.get_entity(NODE_RANK, node_list_1[i])); - stk_classic::mesh::Entity& node2 = *(bulk_data.get_entity(NODE_RANK, node_list_1[i+1])); - bulk_data.declare_relation(shell, node1, 0); - bulk_data.declare_relation(shell, node2, 1); - } - - // declare shell relationships for second shell - unsigned node_list_2[3] = {31, 36, 41}; - for (unsigned i = 0; i < num_shell_2_faces; ++i) { - stk_classic::mesh::Entity& shell = *(shell_faces[i + num_shell_1_faces]); - stk_classic::mesh::Entity& node1 = *(bulk_data.get_entity(NODE_RANK, node_list_2[i])); - stk_classic::mesh::Entity& node2 = *(bulk_data.get_entity(NODE_RANK, node_list_2[i+1])); - bulk_data.declare_relation(shell, node1, 0); - bulk_data.declare_relation(shell, node2, 1); - } - - grid_mesh.bulk_data().modification_end(); - - // skin the boundary - stk_classic::mesh::skin_mesh(bulk_data, element_rank, &skin_part); - - // Grab the skin entities - stk_classic::mesh::Selector skin_selector(skin_part); - const std::vector& edge_buckets = bulk_data.buckets(fem_meta.edge_rank()); - std::vector skin_entities; - stk_classic::mesh::get_selected_entities(skin_selector, edge_buckets, skin_entities); - - unsigned num_expected_skin_entites = 16; - STKUNIT_EXPECT_EQUAL(num_expected_skin_entites, skin_entities.size()); - - // Map the element id to the number of skins associated with that element - - std::map results; - std::map expected_results; - - expected_results[1] = 2; - expected_results[2] = 1; - expected_results[3] = 1; - expected_results[4] = 1; - expected_results[5] = 1; - expected_results[9] = 1; - expected_results[13] = 2; - expected_results[14] = 1; - expected_results[15] = 1; - expected_results[16] = 1; - expected_results[42] = 1; - expected_results[43] = 1; - expected_results[44] = 1; - expected_results[45] = 1; - expected_results[46] = 1; - expected_results[47] = 1; - - // Vector of of vector of entities (shells) that are expected to share a skin - - std::set > sharing; - std::set > expected_sharing; - - std::set temp; - temp.insert(44); - temp.insert(46); - expected_sharing.insert(temp); - - temp.clear(); - temp.insert(45); - temp.insert(47); - expected_sharing.insert(temp); - - // map skin-id to ids of elements it is attached to; we will use this to - // compute sharing - for (std::vector::const_iterator - itr = skin_entities.begin(); itr != skin_entities.end(); ++itr) { - stk_classic::mesh::PairIterRelation upward_relation_itr = - (*itr)->relations(element_rank); - bool has_multiple = upward_relation_itr.size() > 1; - std::set sharing_elements; - for ( ; !upward_relation_itr.empty() ; ++upward_relation_itr ) { - unsigned elem_id = upward_relation_itr->entity()->identifier(); - if (results.find(elem_id) != results.end()) { - ++results[elem_id]; - } - else { - results[elem_id] = 1; - } - - if (has_multiple) { - sharing_elements.insert(elem_id); - } - } - if (has_multiple) { - sharing.insert(sharing_elements); - } - } - - STKUNIT_EXPECT_TRUE(results == expected_results); - STKUNIT_EXPECT_TRUE(sharing == expected_sharing); -} - diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTemplate.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTemplate.cpp deleted file mode 100644 index 6415bddd3e01..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTemplate.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -STKUNIT_UNIT_TEST(UnitTestTemplate, testUnit) -{ - int mpi_rank = 0; - int mpi_size = 1; - -#ifdef STK_HAS_MPI - STKUNIT_ASSERT_EQUAL(MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank), MPI_SUCCESS); - STKUNIT_ASSERT_EQUAL(MPI_Comm_size(MPI_COMM_WORLD, &mpi_size), MPI_SUCCESS); -#endif - - STKUNIT_ASSERT(mpi_rank < mpi_size); -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTopology.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTopology.cpp deleted file mode 100644 index 5eef0a79315f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTopology.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* _ Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -using stk_classic::ParallelMachine; -using stk_classic::mesh::MetaData; -using stk_classic::mesh::BulkData; -using stk_classic::mesh::Part; -using stk_classic::mesh::PartVector; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::EntityId; -using stk_classic::mesh::EntitySideComponent; -using stk_classic::mesh::PairIterRelation; -using stk_classic::mesh::Entity; -using stk_classic::mesh::EntityRank; -using stk_classic::mesh::fem::FEMMetaData; - -class TopologyHelpersTestingFixture -{ - public: - TopologyHelpersTestingFixture(ParallelMachine pm); - ~TopologyHelpersTestingFixture() {} - - const int spatial_dimension; - FEMMetaData meta; - BulkData bulk; - const EntityRank element_rank; - const EntityRank side_rank; - Part & generic_element_part; - Part & element_tet_part; - Part & element_wedge_part; - Part & generic_face_part; - Part & another_generic_face_part; - Part & face_quad_part; - Part & another_generic_element_part; - - EntityId nextEntityId() - { return psize*(++entity_id)+prank; } - - Entity & create_entity( EntityRank rank, Part& part_membership) - { - PartVector part_intersection; - part_intersection.push_back ( &part_membership ); - return bulk.declare_entity(rank, nextEntityId(), part_intersection); - } - - private: - EntityId entity_id; - const int psize; - const int prank; -}; - -TopologyHelpersTestingFixture::TopologyHelpersTestingFixture(ParallelMachine pm) - : spatial_dimension( 3 ) - , meta( spatial_dimension ) - , bulk( FEMMetaData::get_meta_data(meta), pm, 100 ) - , element_rank( meta.element_rank()) - , side_rank( meta.side_rank()) - , generic_element_part( meta.declare_part("another part", element_rank ) ) - , element_tet_part( stk_classic::mesh::fem::declare_part >( meta, "block_left_1" ) ) - , element_wedge_part( stk_classic::mesh::fem::declare_part >(meta, "block_left_2" ) ) - , generic_face_part( stk_classic::mesh::fem::declare_part >(meta, "A_1" ) ) - , another_generic_face_part( meta.declare_part("A_2", side_rank ) ) - , face_quad_part( meta.declare_part("A_3", side_rank ) ) - , another_generic_element_part( meta.declare_part("B_3", element_rank ) ) - , entity_id(0u) - , psize(bulk.parallel_size()) - , prank(bulk.parallel_rank()) -{ - meta.commit(); -} - -namespace { - -const EntityRank NODE_RANK = FEMMetaData::NODE_RANK; - -STKUNIT_UNIT_TEST( testTopologyHelpers, get_cell_topology_based_on_part) -{ - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - fix.bulk.modification_begin(); - Entity & elem1 = fix.create_entity( fix.side_rank, fix.generic_face_part ); - - PartVector tmp(1); - tmp[0] = & fix.face_quad_part; - fix.bulk.change_entity_parts ( elem1 , tmp ); - STKUNIT_ASSERT_EQUAL( stk_classic::mesh::fem::get_cell_topology(elem1).getCellTopologyData(), shards::getCellTopologyData< shards::Quadrilateral<4> >() ); - fix.bulk.change_entity_parts ( elem1 , tmp ); - STKUNIT_ASSERT_EQUAL( stk_classic::mesh::fem::get_cell_topology(elem1).getCellTopologyData(), shards::getCellTopologyData< shards::Quadrilateral<4> >() ); - tmp[0] = & fix.another_generic_face_part; - fix.bulk.change_entity_parts ( elem1 , tmp ); - STKUNIT_ASSERT_EQUAL( stk_classic::mesh::fem::get_cell_topology(elem1).getCellTopologyData(), shards::getCellTopologyData< shards::Quadrilateral<4> >() ); - STKUNIT_ASSERT_NE( stk_classic::mesh::fem::get_cell_topology( elem1).getCellTopologyData() , shards::getCellTopologyData< shards::Wedge<15> >() ); - - fix.bulk.modification_end(); -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, get_cell_topology_multiple_topologies ) -{ - // Coverage for get_cell_topology in TopologyHelpers.cpp; (FAILED WITH MULTIPLE LOCAL TOPOLOGIES) - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - - fix.bulk.modification_begin(); - Entity & elem = fix.create_entity( fix.element_rank, fix.generic_element_part ); - PartVector add_parts; - add_parts.push_back( &fix.element_tet_part ); - add_parts.push_back( &fix.element_wedge_part ); - fix.bulk.change_entity_parts( elem, add_parts ); - fix.bulk.modification_end(); - STKUNIT_ASSERT_THROW( stk_classic::mesh::fem::get_cell_topology( elem ).getCellTopologyData(), std::runtime_error ); -} - -// No longer in the public API -// STKUNIT_UNIT_TEST( testTopologyHelpers, get_adjacent_entities_trivial ) -// { -// // Element, elem2, has NULL topology -// TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); -// -// if ( 1 == fix.bulk.parallel_size() ) { -// -// fix.bulk.modification_begin(); -// Entity & elem2 = fix.create_entity( fix.element_rank, fix.generic_element_part ); -// fix.bulk.modification_end(); -// -// std::vector adjacent_entities; -// const EntityRank subcell_rank = fix.element_rank; -// const EntityId subcell_identifier = 1; -// get_adjacent_entities( elem2 , subcell_rank, subcell_identifier, adjacent_entities); -// STKUNIT_ASSERT_TRUE( true ); -// } -// } -// -// STKUNIT_UNIT_TEST( testTopologyHelpers, get_adjacent_entities_invalid ) -// { -// TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); -// fix.bulk.modification_begin(); -// Entity & elem3 = fix.create_entity( fix.element_rank , fix.generic_element_part ); -// -// PartVector add_parts; -// add_parts.push_back( & fix.element_tet_part ); -// fix.bulk.change_entity_parts ( elem3 , add_parts ); -// fix.bulk.modification_end(); -// std::vector adjacent_entities2; -// { -// const EntityRank invalid_subcell_rank = 4; -// const EntityId valid_subcell_identifier = 0; -// STKUNIT_ASSERT_THROW( -// get_adjacent_entities( elem3 , invalid_subcell_rank, valid_subcell_identifier, adjacent_entities2), -// std::invalid_argument -// ); -// } -// { -// const EntityRank valid_subcell_rank = 1; -// const EntityId invalid_subcell_identifier = 8; -// STKUNIT_ASSERT_THROW( -// get_adjacent_entities( elem3 , valid_subcell_rank, invalid_subcell_identifier, adjacent_entities2), -// std::invalid_argument -// ); -// } -// } - -STKUNIT_UNIT_TEST( testTopologyHelpers, declare_element_side_no_topology ) -{ - // Coverage for declare_element_side - TopologyHelpers.cpp - "Cannot discern element topology" - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - - fix.bulk.modification_begin(); - Entity & elem4 = fix.create_entity( fix.element_rank , fix.generic_element_part ); - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.element_rank, elem4, fix.nextEntityId(), &fix.element_wedge_part ), - std::runtime_error - ); - fix.bulk.modification_end(); - - - { - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - fix.bulk.modification_begin(); - // Cannot declare an element without a topology defined - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::declare_element(fix.bulk, fix.generic_element_part, fix.nextEntityId(), elem_node), - std::runtime_error - ); - fix.bulk.modification_end(); - } -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, declare_element_side_wrong_bulk_data) -{ - // Coverage for verify_declare_element_side - in TopologyHelpers.cpp - "BulkData for 'elem' and 'side' are different" - TopologyHelpersTestingFixture fix1(MPI_COMM_WORLD); - - fix1.bulk.modification_begin(); - - TopologyHelpersTestingFixture fix2(MPI_COMM_WORLD); - fix2.bulk.modification_begin(); - Entity & elem4_2 = fix2.create_entity( fix2.element_rank , fix2.generic_element_part ); - fix2.bulk.modification_end(); - - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::declare_element_side( fix1.bulk, fix1.element_rank, elem4_2, fix1.nextEntityId(), &fix1.element_wedge_part), - std::runtime_error - ); - fix1.bulk.modification_end(); -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, declare_element_side_no_topology_2 ) -{ - // Coverage for verify_declare_element_side - in TopologyHelpers.cpp - "No element topology found and cell side id exceeds..." - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - fix.bulk.modification_begin(); - - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - Entity & element = stk_classic::mesh::fem::declare_element(fix.bulk, fix.element_tet_part, fix.nextEntityId(), elem_node); - const CellTopologyData * const elem_top = stk_classic::mesh::fem::get_cell_topology( element ).getCellTopologyData(); - const EntityId nSideCount = elem_top->side_count + 10 ; - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.nextEntityId(), element, nSideCount, &fix.element_tet_part ), - std::runtime_error - ); - fix.bulk.modification_end(); -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, declare_element_side_full ) -{ - // Go all way the through declare_element_side - use new element - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - - fix.bulk.modification_begin(); - - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - - Entity& element = stk_classic::mesh::fem::declare_element(fix.bulk, fix.element_tet_part, fix.nextEntityId(), elem_node ); - - const EntityId zero_side_count = 0; - Entity& face2 = stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.nextEntityId(), element, zero_side_count); - fix.bulk.modification_end(); - - PairIterRelation rel2 = face2.relations(NODE_RANK); - - STKUNIT_ASSERT_TRUE( true ); -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, element_side_polarity_valid ) -{ - // Coverage of element_side_polarity in TopologyHelpers.cpp 168-181 and 200-215 - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - - fix.bulk.modification_begin(); - Entity & element = stk_classic::mesh::fem::declare_element(fix.bulk, fix.element_tet_part, fix.nextEntityId(), elem_node ); - const EntityId zero_side_count = 0; - Entity& face2 = stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.nextEntityId(), element, zero_side_count); - fix.bulk.modification_end(); - - const int local_side_id = 0; - STKUNIT_ASSERT_TRUE( stk_classic::mesh::fem::element_side_polarity( element, face2, local_side_id) ); - -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, element_side_polarity_invalid_1 ) -{ - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - - // Coverage of element_side_polarity in TopologyHelpers.cpp - { - fix.bulk.modification_begin(); - Entity & element = stk_classic::mesh::fem::declare_element(fix.bulk, fix.element_tet_part, fix.nextEntityId(), elem_node ); - const EntityId zero_side_count = 0; - Entity& face = stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.nextEntityId(), element, zero_side_count); - fix.bulk.modification_end(); - - const int invalid_local_side_id = -1; - // Hits "Unsuported local_side_id" error condition: - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::element_side_polarity( element, face, invalid_local_side_id), - std::runtime_error - ); - } -} - -STKUNIT_UNIT_TEST( testTopologyHelpers, element_side_polarity_invalid_2 ) -{ - TopologyHelpersTestingFixture fix(MPI_COMM_WORLD); - EntityId elem_node[4]; - elem_node[0] = 1; - elem_node[1] = 2; - elem_node[2] = 3; - elem_node[3] = 4; - - // Coverage of element_side_polarity in TopologyHelpers.cpp - NULL = elem_top - fix.bulk.modification_begin(); - - PartVector part_intersection; - part_intersection.push_back ( &fix.generic_element_part); - Entity & element = fix.bulk.declare_entity(fix.element_rank, fix.nextEntityId(), part_intersection); - STKUNIT_ASSERT_TRUE( stk_classic::mesh::fem::get_cell_topology( element ).getCellTopologyData() == NULL ); - - Entity & element_with_top = stk_classic::mesh::fem::declare_element(fix.bulk, fix.element_tet_part, fix.nextEntityId(), elem_node ); - STKUNIT_ASSERT_TRUE( stk_classic::mesh::fem::get_cell_topology( element_with_top ).getCellTopologyData() != NULL ); - - const EntityId zero_side_count = 0; - Entity& face_with_top = stk_classic::mesh::fem::declare_element_side( fix.bulk, fix.nextEntityId(), element_with_top, zero_side_count); - - fix.bulk.modification_end(); - - const int valid_local_side_id = 0; - // Hits "Element has no defined topology" error condition: - STKUNIT_ASSERT_TRUE( stk_classic::mesh::fem::get_cell_topology( element ).getCellTopologyData() == NULL ); - STKUNIT_ASSERT_THROW( - stk_classic::mesh::fem::element_side_polarity( element, face_with_top, valid_local_side_id), - std::runtime_error - ); - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTrace.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTrace.cpp deleted file mode 100644 index f0e41c8b4a55..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTrace.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifdef STK_MESH_TRACE_ENABLED - -#include - -#include -#include - -#include - -using stk_classic::mesh::EntityKey; - -namespace { - -// Test globals -const std::string SHOULD_SEE_STR = "should_see"; -const std::string SHOULD_NOT_SEE_STR = "should_not_see"; -unsigned SHOULD_SEE_COUNTER = 0; - -std::string create_should_see_str(unsigned counter) -{ - std::ostringstream oss; - oss << SHOULD_SEE_STR << counter; - return oss.str(); -} - -const char* create_func(const std::string& func, bool should_see) -{ - std::ostringstream& oss = *(new std::ostringstream()); - if (should_see) { - oss << func << "::" << create_should_see_str(SHOULD_SEE_COUNTER++); - } - else { - oss << func << "::" << SHOULD_NOT_SEE_STR; - } - return oss.str().c_str(); -} - -std::string create_string(bool should_see) -{ - if (should_see) { - return create_should_see_str(SHOULD_SEE_COUNTER++); - } - else { - return SHOULD_NOT_SEE_STR; - } -} - -/////////////////////////////////////////////////////////////////////////////// -STKUNIT_UNIT_TEST(UnitTestTrace, testTrace) -/////////////////////////////////////////////////////////////////////////////// -{ - // A simple unit-test for the stk_mesh's tracing infrastructure. Note that - // none of the Trace macros in the .cpp files in stk_mesh will be active - // because the will have already been compiled without the macros defined. - // This limits this unit test to very basic checks. - - // Local constants - const EntityKey watch_key(0, 1); - const EntityKey not_watch_key(0, 2); - const std::string tracing_func = "stk_classic::mesh::BulkData"; - const std::string not_tracing_func = "stk_classic::mesh::MetaData"; - const stk_classic::mesh::LogMask active_mask = stk_classic::mesh::LOG_ENTITY; - const stk_classic::mesh::LogMask inactive_mask = stk_classic::mesh::LOG_BUCKET; - - // Set up a dummy trace configuration. Here, we're telling the tracing - // system that we want to trace BulkData calls related to entities, - // specifically Node[1]. - std::ostringstream trace_output; - stk_classic::mesh::setStream(trace_output); - meshlog.setPrintMask(active_mask | stk_classic::mesh::LOG_TRACE); - stk_classic::mesh::watch(watch_key); - stk_classic::diag::Trace::addTraceFunction(tracing_func); - - // - // Make calls to Trace API, some of which should generate trace output. We tag - // output that should / should-not be in the trace so we can validate later. - // - - { - bool should_see = false; // not tracing func - Trace_(create_func(not_tracing_func, should_see)); - } - - { - bool should_see = true; - Trace_(create_func(tracing_func, should_see)); - } - - { - bool should_see = false; // not tracing func - TraceIf(create_func(not_tracing_func, should_see), active_mask); - } - - { - bool should_see = false; // inactive mask - TraceIf(create_func(tracing_func, should_see), inactive_mask); - DiagIf(inactive_mask, create_string(should_see)); - } - - { - bool should_see = true; - TraceIf(create_func(tracing_func, should_see), active_mask); - DiagIf(active_mask, create_string(should_see)); - } - - { - bool should_see = false; // not tracing func - TraceIfWatching(create_func(not_tracing_func, should_see), active_mask, watch_key); - } - - { - bool should_see = false; // inactive mask - TraceIfWatching(create_func(tracing_func, should_see), inactive_mask, watch_key); - DiagIfWatching(inactive_mask, watch_key, create_string(should_see)); - } - - { - bool should_see = false; // not watching key - TraceIfWatching(create_func(tracing_func, should_see), active_mask, not_watch_key); - DiagIfWatching(active_mask, not_watch_key, create_string(should_see)); - } - - { - bool should_see = true; - TraceIfWatching(create_func(tracing_func, should_see), active_mask, watch_key); - DiagIfWatching(active_mask, watch_key, create_string(should_see)); - } - - // - // Check validity of output - // - - const std::string trace_output_str = trace_output.str(); - - // The not-trace tagged output should not be in the trace output - STKUNIT_ASSERT_EQUAL(trace_output_str.find(SHOULD_NOT_SEE_STR), std::string::npos); - - // Each occurance of should-see output should be in the trace output - for (unsigned i = 0; i < SHOULD_SEE_COUNTER; ++i) { - STKUNIT_ASSERT_NE(trace_output_str.find(create_should_see_str(i)), std::string::npos); - } -} - - -} // empty namespace - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTransactionLog.cpp b/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTransactionLog.cpp deleted file mode 100644 index 0349332327b2..000000000000 --- a/packages/stk/stk_classic/stk_mesh/unit_tests/UnitTestTransactionLog.cpp +++ /dev/null @@ -1,675 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** \TODO The design of the transaction logging functionality must - * be revisited / revised to clean up entity creation / deletion - * where two or more entities could exist with the same key. - * Such a condition is severely erroneous. Until the design - * revisit / revision is carried out the transaction capability - * is disabled. - */ -#if 0 - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - - -#include - -/** \brief When a mesh bulk data is created, the transaction is placed - * in the bulk transaction state by default. - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyBulkOnCreate) -{ - stk_classic::mesh::MetaData meta ( stk_classic::mesh::fem_entity_rank_names() ); - stk_classic::mesh::Part &new_part = meta.declare_part ( "another part" ); - meta.commit (); - - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); - stk_classic::mesh::BulkData bulk ( meta , comm , 100 ); - std::vector add_part; - add_part.push_back ( &new_part ); - - int size , rank; - rank = stk_classic::parallel_machine_rank( comm ); - size = stk_classic::parallel_machine_size( comm ); - - for ( int i = 0 ; i != 100 ; i++ ) - { - int new_id = size*i+rank; - bulk.declare_entity ( 0 , new_id+1 , add_part ); - } - bulk.modification_end(); - - // If something shows up in the insert incremental log, then - // not in bulk state - STKUNIT_ASSERT ( bulk.get_transaction_log().get_inserted_buckets(0).size() == 0 ); - STKUNIT_ASSERT ( bulk.get_transaction_log().get_modified_buckets(0).size() == 0 ); - STKUNIT_ASSERT ( bulk.get_transaction_log().get_deleted_buckets(0).size() == 0 ); - - // Verify that things are inserted in the bulk transaction - stk_classic::mesh::PartVector inserted_parts; - bulk.get_transaction_log().get_parts_with_inserted_entities ( inserted_parts ); - STKUNIT_ASSERT ( inserted_parts.size() > 0 ); -} - -/** \brief When the transaction log is in bulk transaction mode, - * inserting entities in the mesh will add the parts of that entity to - * the inserted parts set. - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyBulkInsert) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part (); - stk_classic::mesh::PartVector add_part; - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin (); - bulk.declare_entity ( 0 , fixture.comm_size()*1000 + fixture.comm_rank() , add_part ); - bulk.modification_end (); - - // Verify the entity did not go into the log explicitly - STKUNIT_ASSERT ( bulk.get_transaction_log().get_inserted_buckets(0).size() == 0 ); - - // Check to see if the new_part is in the inserted parts; - stk_classic::mesh::PartVector inserted_parts; - bool found = false; - bulk.get_transaction_log().get_parts_with_inserted_entities ( inserted_parts ); - for ( size_t i = 0 ; i != inserted_parts.size() ; i++ ) - { - if ( inserted_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( found ); - - // Verify there is nothing in the modified_parts set - stk_classic::mesh::PartVector modified_parts; - found = false; - bulk.get_transaction_log().get_parts_with_modified_entities ( modified_parts ); - for ( size_t i = 0 ; i != modified_parts.size() ; i++ ) - { - if ( modified_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( !found ); - - // Verify there is nothing in the deleted_parts set - stk_classic::mesh::PartVector deleted_parts; - found = false; - bulk.get_transaction_log().get_parts_with_deleted_entities ( deleted_parts ); - for ( size_t i = 0 ; i != deleted_parts.size() ; i++ ) - { - if ( deleted_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( !found ); -} - - -/** \brief When the transaction log is in bulk transaction mode, - * modifying the state of entities in the mesh will add the parts - * of that entity to the inserted parts set. - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyBulkModify) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin (); - stk_classic::mesh::Entity &new_entity = bulk.declare_entity ( 0 , fixture.comm_size()*1000 + fixture.comm_rank() , add_part ); - bulk.modification_end (); - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin (); - bulk.change_entity_parts ( new_entity , blank_part , add_part ); - bulk.modification_end (); - - STKUNIT_ASSERT ( bulk.get_transaction_log().get_modified_buckets(0).size() == 0 ); - - stk_classic::mesh::PartVector inserted_parts; - bool found = false; - bulk.get_transaction_log().get_parts_with_inserted_entities ( inserted_parts ); - for ( size_t i = 0 ; i != inserted_parts.size() ; i++ ) - { - if ( inserted_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( !found ); - - stk_classic::mesh::PartVector modified_parts; - found = false; - bulk.get_transaction_log().get_parts_with_modified_entities ( modified_parts ); - for ( size_t i = 0 ; i != modified_parts.size() ; i++ ) - { - if ( modified_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( found ); - - stk_classic::mesh::PartVector deleted_parts; - found = false; - bulk.get_transaction_log().get_parts_with_deleted_entities ( deleted_parts ); - for ( size_t i = 0 ; i != deleted_parts.size() ; i++ ) - { - if ( deleted_parts[i] == &new_part ) - found = true; - } - STKUNIT_ASSERT ( !found ); -} - -/** \brief When the transaction log is in bulk transaction mode, - * modifying the relations of entities in the mesh will add the parts - * of that entity to the inserted parts set. - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyBulkAddRelation) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - fixture.generate_boxes(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part, buffer_vec; - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin(); - stk_classic::mesh::Entity &new_node = bulk.declare_entity ( 0 , 123456789 , blank_part ); - stk_classic::mesh::Entity &existing_cell = *bulk.buckets(3)[0]->begin(); - bulk.declare_relation ( existing_cell, new_node , 10 ); - bulk.modification_end(); - - // Verify that nodes were inserted. - log.get_parts_with_inserted_entities ( buffer_vec ); - STKUNIT_ASSERT ( buffer_vec.size() > 0u ); - - // Verify that the element is modified - buffer_vec.clear(); - log.get_parts_with_modified_entities ( buffer_vec ); - STKUNIT_ASSERT ( buffer_vec.size() > 0u ); - -} - - -/** \brief When the transaction log is in bulk transaction mode, - * deleting entities in the mesh will add the parts of that entity to the - * deleted parts set. - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyBulkDelete) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - add_part.push_back ( &new_part ); - - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin (); - stk_classic::mesh::Entity *new_entity = &bulk.declare_entity ( 0 , fixture.comm_size()*1000 + fixture.comm_rank() , add_part ); - bulk.modification_end (); - - bulk.reset_transaction ( stk_classic::mesh::Transaction::BULK ); - bulk.modification_begin (); - bulk.destroy_entity ( new_entity ); - bulk.modification_end (); - - STKUNIT_ASSERT ( bulk.get_transaction_log().get_deleted_buckets(0).size() == 0 ); - - stk_classic::mesh::PartVector inserted_parts; - stk_classic::mesh::PartVector modified_parts; - stk_classic::mesh::PartVector deleted_parts; - bool inserted_found = false; - bulk.get_transaction_log().get_parts_with_inserted_entities ( inserted_parts ); - for ( size_t i = 0 ; i != deleted_parts.size() ; i++ ) - { - if ( inserted_parts[i] == &new_part ) - inserted_found = true; - } - STKUNIT_ASSERT ( !inserted_found ); - - bool modified_found = false; - bulk.get_transaction_log().get_parts_with_modified_entities ( modified_parts ); - for ( size_t i = 0 ; i != deleted_parts.size() ; i++ ) - { - if ( modified_parts[i] == &new_part ) - modified_found = true; - } - STKUNIT_ASSERT ( !modified_found ); - - bool deleted_found = false; - bulk.get_transaction_log().get_parts_with_deleted_entities ( deleted_parts ); - for ( size_t i = 0 ; i != deleted_parts.size() ; i++ ) - { - if ( deleted_parts[i] == &new_part ) - deleted_found = true; - } - STKUNIT_ASSERT ( deleted_found ); -} - -/** \brief It is possible span transactions across modifications. - * reset_transaction must be called to remove entities from a - * transcation, - */ - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyTransactionSpanningModifications) -{ - // HCE 3/4/10: - // For transactions to span multiple modifications destroyed - // mesh entities would have to be retained across multiple - // transactions. This creates a problem where the transaction - // has to take ownership of the mesh entities away from the - // creating bulk data. - // This capability needs to be re-thought. - - return ; - - - stk_classic::mesh::fixtures::BoxFixture fixture; - fixture.generate_boxes(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - - // Here are two modifications. The first adds an edge to the mesh, - // the second changes the state of a node - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin(); - bulk.declare_entity ( 1 , 10001 , blank_part ); - bulk.modification_end(); - - bulk.modification_begin(); - stk_classic::mesh::Entity &n = *(*bulk.buckets(0).begin())->begin(); - bulk.change_entity_parts ( n , add_part ); - bulk.modification_end(); - - - // Verify both changes are logged - STKUNIT_ASSERT ( bulk.get_transaction_log().get_modified_buckets(0).size() == 1 ); - STKUNIT_ASSERT ( bulk.get_transaction_log().get_inserted_buckets(1).size() == 1 ); - - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - // Verify the log is cleared - STKUNIT_ASSERT ( bulk.get_transaction_log().get_inserted_buckets(0).size() == 0 ); - STKUNIT_ASSERT ( bulk.get_transaction_log().get_inserted_buckets(1).size() == 0 ); - - - // Cannot end a transaction while the mesh is modifiable - // Even though the transaction can span modifications, it cannot be - // reset in the middle of a modification - bulk.modification_begin(); - STKUNIT_ASSERT_THROW ( bulk.reset_transaction () , std::runtime_error ); - bulk.modification_end(); - -} - - -/** \brief During an incremental - */ - - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyIncrementalInsert) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin(); - // Add 4 entities to the mesh - stk_classic::mesh::Entity *entities[4]; - entities[0] = &bulk.declare_entity ( 0 , 123456789 , blank_part ); - entities[1] = &bulk.declare_entity ( 1 , 123456789 , blank_part ); - entities[2] = &bulk.declare_entity ( 2 , 123456789 , blank_part ); - entities[3] = &bulk.declare_entity ( 3 , 123456789 , blank_part ); - - // Modify one entity to ensure modification does not appear in log - bulk.change_entity_parts ( *entities[1] , add_part ); - - // Delete one entity to ensure the entity disappears from log - bulk.destroy_entity ( entities[3] ); - bulk.modification_end(); - - // The first three entities should exist in the insert buckets in - // the transaction log - for ( unsigned i = 0 ; i != 3 ; i++ ) - { - // Make sure there is only one bucket - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(i).size() , 1u ); - // Make sure the entity is the only thing in the bucket - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(i)[0]->size() , 1u ); - - stk_classic::mesh::Entity &new_entity = *((*log.get_inserted_buckets(i).begin())->begin()); - // Make sure we find the right entity - STKUNIT_ASSERT_EQUAL ( &new_entity , entities[i] ); - // Verify nothing happend to modified and deleted - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(i).size() , 0u ); - STKUNIT_ASSERT_EQUAL ( log.get_deleted_buckets(i).size() , 0u ); - } - - // Verify entities[3] disappeared from the log - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(3).size() , 0u ); - STKUNIT_ASSERT_EQUAL ( log.get_deleted_buckets(3).size() , 0u ); - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(3).size() , 0u ); -} - - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyIncrementalModify) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - fixture.generate_boxes(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - // Modify the state of a node and entity in the mesh - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin(); - stk_classic::mesh::Entity *entities[2]; - entities[0] = &*bulk.buckets(0)[0]->begin(); - entities[1] = &*bulk.buckets(3)[0]->begin(); - bulk.change_entity_parts ( *entities[0] , add_part ); - bulk.change_entity_parts ( *entities[1] , add_part ); - bulk.modification_end(); - - for ( unsigned i = 0 ; i != 2 ; i++ ) - { - unsigned enttype = i*3; - // Make sure there is only one bucket - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(enttype).size() , 1u ); - // Make sure the entity is the only thing in the bucket - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(enttype)[0]->size() , 1u ); - stk_classic::mesh::Entity &mod_entity = *log.get_modified_buckets(enttype)[0]->begin(); - // Make sure we find the right entity - STKUNIT_ASSERT_EQUAL ( &mod_entity , entities[i] ); - // Verify nothing happend to modified and deleted - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(enttype).size() , 0u ); - STKUNIT_ASSERT_EQUAL ( log.get_deleted_buckets(enttype).size() , 0u ); - - // Verify the transaction recorded the modification accurately - // 1) Make sure the new part is not part of the previous parts - // 2) Make sure the previous parts are in the new parts - STKUNIT_ASSERT ( mod_entity.transaction_bucket() != 0 ); - STKUNIT_ASSERT ( !mod_entity.transaction_bucket()->member ( new_part ) ); - stk_classic::mesh::PartVector modified_bucket_parts; - mod_entity.transaction_bucket()->supersets ( modified_bucket_parts ); - STKUNIT_ASSERT ( mod_entity.bucket().member_all ( modified_bucket_parts )); - } -} - - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyIncrementalAddRelation) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - fixture.generate_boxes(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin(); - stk_classic::mesh::Entity &new_node = bulk.declare_entity ( 0 , 123456789 , blank_part ); - stk_classic::mesh::Entity &existing_cell = *bulk.buckets(3)[0]->begin(); - bulk.declare_relation ( existing_cell, new_node , 10 ); - bulk.modification_end(); - - // Verify that no nodes were modified, only inserted. - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(0).size() , 1u ); - STKUNIT_ASSERT_EQUAL ( log.get_inserted_buckets(0)[0]->size() , 1u ); - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(0).size() , 0u ); - STKUNIT_ASSERT_EQUAL ( &*log.get_inserted_buckets(0)[0]->begin() , &new_node ); - - // Verify that the element is modified - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(3).size() , 1u ); - STKUNIT_ASSERT_EQUAL ( log.get_modified_buckets(3)[0]->size() , 1u ); - STKUNIT_ASSERT_EQUAL ( &*log.get_modified_buckets(3)[0]->begin() , &existing_cell ); - - // Make sure the parts have not changed for the existing cell - stk_classic::mesh::PartVector old_parts , new_parts; - STKUNIT_ASSERT ( existing_cell.transaction_bucket() != 0 ); - existing_cell.transaction_bucket()->supersets ( old_parts ); - STKUNIT_ASSERT ( existing_cell.bucket().member_all ( old_parts ) ); - existing_cell.bucket().supersets ( new_parts ); - STKUNIT_ASSERT ( existing_cell.transaction_bucket()->member_all ( new_parts ) ); - -} - - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyIncrementalDelete) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - fixture.generate_boxes(); - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,old_parts; - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test need only run in serial - if ( fixture.comm_size() > 1 ) return; - - // destroy does not delete. element will not be deleted until next - // transaction reset - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin(); - stk_classic::mesh::Entity *deleted_cell = &*bulk.buckets(3)[0]->begin(); - - // Record the old parts for testing later - deleted_cell->bucket().supersets ( old_parts ); - stk_classic::mesh::EntityId deleted_cell_id = deleted_cell->identifier(); - bulk.destroy_entity ( deleted_cell ); - bulk.modification_end(); - - // Verify that the element is deleted - STKUNIT_ASSERT_EQUAL ( log.get_deleted_buckets(3).size() , 1u ); - STKUNIT_ASSERT_EQUAL ( log.get_deleted_buckets(3)[0]->size() , 1u ); - STKUNIT_ASSERT_EQUAL ( (*log.get_deleted_buckets(3)[0]->begin()).identifier() , deleted_cell_id ); - - // Check for the old parts - deleted_cell = &*log.get_deleted_buckets(3)[0]->begin(); - STKUNIT_ASSERT ( deleted_cell->transaction_bucket() != 0 ); - STKUNIT_ASSERT ( deleted_cell->transaction_bucket()->member_all ( old_parts ) ); - stk_classic::mesh::PartVector old_in_trans; - deleted_cell->transaction_bucket()->supersets ( old_in_trans ); - STKUNIT_ASSERT_EQUAL ( old_in_trans.size() , old_parts.size() ); -} - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyParallelChangeOwnership) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); // Comes out of fixture in MODIFIABLE - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - stk_classic::mesh::PartVector add_part,blank_part; -// const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - add_part.push_back ( &new_part ); - - // This test needs four processes to work - if ( fixture.comm_size() < 4 ) return; - - bulk.modification_begin (); - stk_classic::mesh::Entity *entity = 0; - bulk.declare_entity ( 0 , fixture.comm_rank()+1 , blank_part ); - if ( fixture.comm_rank() < 3 ) - entity = &bulk.declare_entity ( 0 , 1234 , blank_part ); - bulk.modification_end(); - - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - std::vector change_owner; - if ( entity ) - if ( fixture.comm_rank() == entity->owner_rank() ) - { - int other_rank = fixture.comm_rank()==0?1:0; - change_owner.push_back ( std::make_pair ( entity , other_rank ) ); - } - bulk.modification_begin(); - bulk.change_entity_owner ( change_owner ); - bulk.modification_end(); - - /********* This needs to be fixed: we need to know what correct - * behavior should be - if ( entity ) - { - if ( fixture.comm_rank() < 3 ) - { - STKUNIT_ASSERT ( entity->transaction_bucket()->transaction_state() == stk_classic::mesh::Transaction::MODIFIED ); - } - } - ******************/ -} - -STKUNIT_UNIT_TEST(UnitTestTransaction, verifyParallelResolutionModify) -{ - stk_classic::mesh::fixtures::BoxFixture fixture; - stk_classic::mesh::BulkData &bulk = fixture.bulk_data(); - bulk.modification_end(); - - stk_classic::mesh::Part &new_part = fixture.get_test_part(); - const stk_classic::mesh::MetaData &meta = fixture.meta_data(); - const stk_classic::mesh::Transaction &log = bulk.get_transaction_log(); - stk_classic::mesh::PartVector add_part,old_parts; - add_part.push_back ( &new_part ); - - // This test need only run in parallel - if ( fixture.comm_size() == 1 ) return; - fixture.generate_boxes (); - - - // Find a node to alter, preferable one that is shared - const std::vector &shared_entities = bulk.shared_entities(); - stk_classic::mesh::Entity *node_to_modify = 0; - for ( unsigned i = 0 ; i != shared_entities.size() ;i++ ) - { - if ( shared_entities[i].first->entity_rank() == 0 ) - if ( shared_entities[i].first->bucket().member ( meta.locally_owned_part () ) ) - { - node_to_modify = shared_entities[i].first; - break; - } - } - - // Once found, tell all processes which one. If not found, tell - // them that as well - int *found_node_list = new int [ bulk.parallel_size() ]; - stk_classic::mesh::EntityId *found_node_id_list = new stk_classic::mesh::EntityId [ bulk.parallel_size() ]; - -#ifdef STK_HAS_MPI - stk_classic::mesh::EntityId node_id = node_to_modify ? node_to_modify->identifier() : 0; - int found_a_node = node_to_modify ? 1 : 0; - - MPI_Allgather ( &found_a_node , 1 , MPI_INT , found_node_list , 1 , MPI_INT , bulk.parallel() ); - MPI_Allgather ( &node_id , 1 , MPI_INT , found_node_id_list , 1 , MPI_INT , bulk.parallel() ); -#endif - - // Modify the node - bulk.reset_transaction ( stk_classic::mesh::Transaction::INCREMENTAL ); - bulk.modification_begin (); - if ( node_to_modify ) - bulk.change_entity_parts ( *node_to_modify , add_part ); - bulk.modification_end (); - - // Verify parallel consistent modification - // First, loop over everythin in the modified buckets - std::vector::const_iterator cur_modified_node_bucket = log.get_modified_buckets(0).begin(); - while ( cur_modified_node_bucket != log.get_modified_buckets(0).end() ) - { - stk_classic::mesh::BucketIterator cur_modified_node = (*cur_modified_node_bucket)->begin(); - while ( cur_modified_node != (*cur_modified_node_bucket)->begin() ) - { - // For everything located in the buckets, verify it was changed - // by another process - bool valid_change = false; - for ( unsigned i = 0 ; i != bulk.parallel_size() ; i++ ) - if ( found_node_list[i] == 1 ) - if ( cur_modified_node->identifier() == found_node_id_list[i] ) - valid_change = true; - STKUNIT_ASSERT ( valid_change ); - ++cur_modified_node; - } - ++cur_modified_node_bucket; - } - - delete [] found_node_list; - delete [] found_node_id_list; -} - -#endif - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/CMakeLists.txt b/packages/stk/stk_classic/stk_mesh/use_cases/CMakeLists.txt deleted file mode 100644 index b14b09f7a2b3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_mesh_use_cases - SOURCES ${SOURCES} - DEPLIBS stkclassic_util_use_cases - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/README b/packages/stk/stk_classic/stk_mesh/use_cases/README deleted file mode 100644 index 36a812df4cb3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/README +++ /dev/null @@ -1,104 +0,0 @@ - -The use_cases serve as examples of creating and filling simple meshes. -The file UseCaseMain.cpp acts as a driver, running each of the separate use-cases -in succession. -Each use-case mesh is embodied in a struct or class called UseCase__Mesh. -The files for those classes contain the code that populates the MetaData and -BulkData mesh objects with mesh-entities, fields, etc. -UseCaseMain.cpp creates the UseCase__Mesh object, then calls functions -'populate' and 'verifyMesh'. - - -For a completely different example of using stk_classic::mesh, see the -Mantevo 'miniFE' application, which is a miniature finite-element application. -miniFE can be downloaded from http://software.sandia.gov/mantevo. -After unpacking the miniFE source code, see the file stk_mesh_description.hpp. -miniFE builds a mesh representing a brick-shaped domain of hexahedral elements, -defines a coordinate field on the nodes, and assembles a finite-element -problem, solving the steady-state conduction equation. - - -UseCase_2: - 3D, (nLeft+nRight)x1x1 elements - Includes a coordinate field on nodes, a temperature field on nodes, - and a volume field on elements. - This use case sets up the mesh, assigns coordinates, temperature, and volume - data to the fields and then demonstrates how all this data is retrieved from - the mesh by verifying everything is correct through a set of functions on the - class. - - -UseCase_3: - 3D, heterogeneous mesh composed of several different element types. - This is a heterogeneous mesh including: hexahedron, wedge, tetrahedron, - pyramid, quadrilateral shell, and triangle shell. - Includes a coordinate field on nodes, a centroid field on elements, a - temperature field on nodes, and a volume field on hexahedrons, wedges, - tetrahedrons, and pyramids, and an element_node coordinate field on elements - which sets up a set of pointers in the element field which point to the nodal - coordinate field data for the nodes attached to that element. - - -UseCase_4: - 3D, 2x Hex and 3x Wedge mesh with linear and quadratic elements and 66 nodes. - Includes a coordinate field on nodes, a velocity field on nodes, a centroid - field on elements, a temperature field on nodes, a pressure field on vertex - nodes, a boundary field on nodes in the sideset, and an element_node - coordinate field on the quadratic elements. - - This use case demonstrates how to put the vertex nodes from the quadratic hex - and wedge elements into a vertex part through the use of part relations and - stencils. This is used to put the pressure field on the vertex nodes. - - This use case sets up the mesh, assigns the field data, and runs two centroid - algorithms on the quadratic hex and wedge elements, then demonstrates how all - this data is retrieved from the mesh by verifying the data. - -UseCase_ChangeOwner: - 2D, 4x Quadrilateral elements - This use case demonsrates how to move elements from one processor to another. - -UseCase_ElementDeath_1: - "This Use Case demonstrates iteratively removing entities from a mesh and re-skinning." - GridFixture (2D, 4x4 faces, 25 nodes) - Mesh is skinned with sides - Iteratively, faces are removed and the mesh is re-skinned - Faces are removed according to the documentation in UseCase_ElementDeath_1_validation_helpers.cpp - - -UseCase_Skinning_1: - First example: - "This Use Case demonstrates removing an interior entity from a mesh and re-skinning" - HexFixture (3D, 3x3x3 hex elements, standard parallel distribution) - Mesh is skinned with faces - Element in middle of mesh (entirely on the inside), is separated out - Mesh is re-skinned and faces are added around interior element and around interior of mesh. - Second example: - "This Use Case demonstrates removing an interior layer from a mesh and re-skinning" - HexFixture (3D, 3x3x3 hex elements, standard parallel distribution) - Mesh is skinned with faces - Entire middle level (x=1) is separated out - Mesh is re-skinned and faces are added to middle layer and to remaining mesh - -UseCase_Skinning_1b: - "This Use Case demonstrates converting an entity into a set of particles" - HexFixture (3D, 3x3x3 hex elements, standard parallel distribution) - Iteratively do the following (for every element in a mesh of size 3x3x3): - create the fixture with a skin_part and a coordinate field on particles - generate the mesh - skin the mesh - Select one of the elements and destroy the element and create particles in its place - re-skin the mesh - -UseCase_Skinning_2: - "This Use Case demonstrates skinning and element death involving shells" - HexFixture (3D, 2x1x1 hex elements, standard parallel distribution) - create skin_part and shell_part - Attach shards ShellQuadrilateral to the shell_part - generate the mesh - Select the element at position (0,0,0) to add a shell between it and the other element - Skin the mesh and verify the correct number of skin faces - Destroy the element at position (0,0,0) - Re-skin the mesh and verify the correct number of skin faces - - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCaseMain.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCaseMain.cpp deleted file mode 100644 index 2bbd4d1414b3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCaseMain.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -void printStatus(bool status) -{ - if (status) { - std::cout << "passed" << std::endl; - } - else { - std::cout << "FAILED" << std::endl; - } -} - -int main ( int argc, char * argv[] ) -{ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - stk_classic::ParallelMachine parallel_machine = use_case_environment.m_comm; - - const bool single_process = - stk_classic::parallel_machine_size( parallel_machine ) <= 1 ; - - bool status = true; - - if ( single_process ) { - std::cout << "Use Case 1 ... "; - bool local_status = true ; - try { - stk_classic::mesh::use_cases::UseCase_1_Mesh mesh(parallel_machine); - printStatus(local_status); - } - catch ( const std::exception & x ) { - local_status = false ; - printStatus(local_status); - std::cout << x.what(); - } - status = status && local_status; - } - - if ( single_process ) { - std::cout << "Use Case 2 ... "; - bool local_status = true ; - try { - stk_classic::mesh::use_cases::UseCase_2_Mesh mesh(parallel_machine); - mesh.populate(1,3); - local_status = stk_classic::mesh::use_cases::verifyMesh(mesh,1,3); - printStatus(local_status); - } - catch ( const std::exception & x ) { - local_status = false ; - printStatus(local_status); - std::cout << x.what(); - } - status = status && local_status; - } - - if ( single_process ) { - std::cout << "Use Case 3 ... "; - bool local_status = true ; - try { - stk_classic::mesh::use_cases::UseCase_3_Mesh mesh(parallel_machine); - mesh.populate(); - local_status = stk_classic::mesh::use_cases::verifyMesh(mesh); - printStatus(local_status); - } - catch ( const std::exception & x ) { - local_status = false ; - printStatus(local_status); - std::cout << x.what(); - } - status = status && local_status; - } - - if ( single_process ) { - std::cout << "Use Case 4 ... "; - stk_classic::mesh::use_cases::UseCase_4_Mesh mesh(parallel_machine); - mesh.populate(); - stk_classic::mesh::use_cases::runAlgorithms(mesh); - const bool local_status = stk_classic::mesh::use_cases::verifyMesh(mesh); - printStatus(local_status); - status = status && local_status; - } - - { - std::cout << "Use Case Change Owner ... "; - Grid2D_Fixture test( parallel_machine ); - const bool local_status = test.test_change_owner(); - printStatus(local_status); - status = status && local_status; - } - - { - std::cout << "Use Case Change Owner with constraint ... "; - const bool local_status = test_change_owner_with_constraint( parallel_machine ); - printStatus(local_status); - status = status && local_status; - } - - { - std::cout << "Use Case Change Owner #2 ... "; - const bool local_status = test_change_owner_2( parallel_machine ); - printStatus(local_status); - status = status && local_status; - } - - { - std::cout << "Use Case Change Owner #3 ... "; - const bool result = test_change_owner_3( parallel_machine ); - printStatus(result); - } - - { - std::cout << "Use Case Element Death 1 ... "; - bool local_status = element_death_use_case_1(parallel_machine); - printStatus(local_status); - status = status && local_status; - } - { - std::cout << "Use Case Skinning 1 ... "; - bool local_status = skinning_use_case_1(parallel_machine); - printStatus(local_status); - status = status && local_status; - } - { - std::cout << "Use Case Skinning 1b ... "; - bool local_status = skinning_use_case_1b(parallel_machine); - printStatus(local_status); - status = status && local_status; - } - { - std::cout << "Use Case Skinning 2 ... "; - bool local_status = skinning_use_case_2(parallel_machine); - printStatus(local_status); - status = status && local_status; - } - - bool collective_result = use_case::print_status(parallel_machine, status); - int return_code = collective_result ? 0 : -1; - - return return_code; -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.cpp deleted file mode 100644 index 2cf8bd125293..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/// doxygen tutorial start #includes -#include - -#include - -#include -/// end code snippet - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -/// doxygen tutorial start source -enum { field_data_chunk_size = 10 }; - -UseCase_1_Mesh::UseCase_1_Mesh( stk_classic::ParallelMachine comm ) - : m_metaData( stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) - , m_bulkData( m_metaData , comm , field_data_chunk_size ) -{ - /// Done populating the mesh meta data. - /// Commit the meta data: this locks out changes, - /// verifies consistency of potentially complex meta data relationships, - /// and allows the internal data structures to be optimized - /// for subsquent use by mesh bulk data. - m_metaData.commit(); -} - -UseCase_1_Mesh::~UseCase_1_Mesh() -{ } -/// end code snippet - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.hpp deleted file mode 100644 index 2c6cf354ec2b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_1.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Mesh_Use_Cases_UseCase_1_hpp -#define Stk_Mesh_Use_Cases_UseCase_1_hpp - -/// doxygen tutorial start #includes -#include -#include -/// end code snippet - -/** stk_mesh Use Case 1 - * This is basically hello world for STK Mesh - * - */ - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -class UseCase_1_Mesh -{ -public: - ~UseCase_1_Mesh(); - - UseCase_1_Mesh( stk_classic::ParallelMachine comm ); - - enum { SpatialDim = 1}; - - stk_classic::mesh::MetaData m_metaData; - stk_classic::mesh::BulkData m_bulkData; -}; - - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_1_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_2.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_2.cpp deleted file mode 100644 index df3d7f438f3b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_2.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic{ -namespace mesh { -namespace use_cases { - -// Functions to generate the use case mesh information: -namespace { -void usecase_2_elem_node_ids( stk_classic::mesh::EntityId elem_id , - stk_classic::mesh::EntityId node_ids[] ); -void usecase_2_node_coordinates( stk_classic::mesh::EntityId node_id , - double coord[] ); - -const double TEMPERATURE_VALUE_GOLD = 98.6; -const double VOLUME_VAL = 1.0; // A known value. -} - -//---------------------------------------------------------------------- - -enum { field_data_chunk_size = 10 }; -enum { SpatialDim = 3 }; - -typedef shards::Hexahedron<8> ElementTraits ; - -//---------------------------------------------------------------------- -// Populate the mesh meta data. -// We have chosen to do it in the use case constructor; -// however, it could be done incrementally outside of -// the constructor. - -UseCase_2_Mesh::UseCase_2_Mesh( stk_classic::ParallelMachine comm ) : - m_fem_metaData( SpatialDim ) - , m_bulkData( fem::FEMMetaData::get_meta_data(m_fem_metaData) , comm , field_data_chunk_size ) - , m_partLeft( fem::declare_part( m_fem_metaData, "block_left")) - , m_partRight( fem::declare_part( m_fem_metaData, "block_right")) - , m_coordinates_field( m_fem_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_temperature_field( m_fem_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_volume_field( m_fem_metaData.declare_field< ScalarFieldType >( "volume" )) - , m_elem_rank( m_fem_metaData.element_rank() ) - , m_side_rank( m_fem_metaData.side_rank() ) - , m_edge_rank( m_fem_metaData.edge_rank() ) - , m_node_rank( m_fem_metaData.node_rank() ) -{ - // Put the coordinates and temperature field on all nodes - - stk_classic::mesh::Part & universal = m_fem_metaData.universal_part(); - stk_classic::mesh::put_field( m_coordinates_field , m_node_rank , universal , SpatialDim ); - stk_classic::mesh::put_field( m_temperature_field, m_node_rank, universal ); - - // Put the volume field on all elements: - stk_classic::mesh::put_field( m_volume_field , m_elem_rank , universal ); - - // Done populating the mesh meta data. - // Commit the meta data: this locks out changes, - // verifies consistency of potentially complex meta data relationships, - // and allows the internal data structures to be optimized - // for subsquent use by mesh bulk data. - - m_fem_metaData.commit(); -} - -UseCase_2_Mesh::~UseCase_2_Mesh() -{ } - -//---------------------------------------------------------------------- -// Populate the mesh bulk data. -// The mesh meta data must be complete and commited before -// the mesh bulk data can be modified. - -void UseCase_2_Mesh::populate( unsigned nleft , unsigned nright ) -{ - //------------------------------ - { // Generate the elements and nodes - - m_bulkData.modification_begin(); // Begin modifying the mesh - - stk_classic::mesh::EntityId curr_elem_id = 1 ; - stk_classic::mesh::EntityId node_ids[ shards::Hexahedron<8> ::node_count ]; - - // Note declare_element expects a cell topology - // to have been attached to m_partLeft. - - // Declare nleft elements - for ( unsigned j = 0 ; j < nleft ; ++j , ++curr_elem_id ) { - usecase_2_elem_node_ids( curr_elem_id , node_ids ); - stk_classic::mesh::fem::declare_element( m_bulkData, m_partLeft, curr_elem_id, node_ids ); - } - - // Note declare_element expects a cell topology - // to have been attached to m_partRight. - - // Declare nright elements - for ( unsigned j = 0 ; j < nright ; ++j , ++curr_elem_id ) { - usecase_2_elem_node_ids( curr_elem_id , node_ids ); - stk_classic::mesh::fem::declare_element( m_bulkData, m_partRight, curr_elem_id, node_ids ); - } - - // Done modifying the mesh. - // Modifications on the local parallel process are communicated - // among processes, verified for consistency, and changes to - // parallel shared/ghosted mesh entities are synchronized. - m_bulkData.modification_end(); - } - //------------------------------ - { // Assign Nodal Field Data - // The following operations are entirely parallel local - // and can be parallel inconsistent. A user may communicate - // field data as needed to force consistency. - - - // Iterate over all nodes by getting all node buckets and iterating over each bucket. - const std::vector & node_buckets = - m_bulkData.buckets( m_node_rank ); - - for ( std::vector::const_iterator - node_bucket_it = node_buckets.begin() ; - node_bucket_it != node_buckets.end() ; ++node_bucket_it ) { - - const stk_classic::mesh::Bucket & bucket = **node_bucket_it; - - // Fill the nodal coordinates. - // Create a multidimensional array view of the - // nodal coordinates field data for this bucket of nodes. - // The array is two dimensional ( Cartesian X NumberNodes ) - // and indexed by ( 0..2 , 0..NumberNodes-1 ) - - stk_classic::mesh::BucketArray - coordinates_array( m_coordinates_field, bucket ); - - const int num_nodes_in_bucket = coordinates_array.dimension(1); - - ThrowRequireMsg( coordinates_array.dimension(0) == SpatialDim , "Expected coordinates_array.dimension(0) " - << coordinates_array.dimension(0) << " to equal SpatialDim " << SpatialDim ); - - // For each node in the bucket populate its nodal coordinates. - for ( int i=0 ; i < num_nodes_in_bucket ; ++i ) { - const unsigned node_id = bucket[i].identifier(); - usecase_2_node_coordinates( node_id, & coordinates_array(0,i) ); - } - - // Fill the nodal temperature field. - // Create a multidimensional array view of the - // nodal temperature field data for this bucket of nodes. - // The array is one dimensional ( NumberNodes ) - // and indexed by ( 0..NumberNodes-1 ) - - stk_classic::mesh::BucketArray - temperature_array( m_temperature_field, bucket ); - - const int num_temps = temperature_array.dimension(0); - - ThrowRequireMsg( num_nodes_in_bucket == num_temps , "Expected num_temps " - << num_temps << " to equal num_nodes_in_bucket " << num_nodes_in_bucket ); - - // For each node in the bucket assign the temperature field to a constant. - for ( int i=0 ; i < num_nodes_in_bucket ; ++i) { - temperature_array(i) = TEMPERATURE_VALUE_GOLD ; - } - } - } - //------------------------------ - { // Assign Element Field Data - // The following operations are entirely parallel local - // and can be parallel inconsistent. A user may communicate - // field data as needed to force consistency. - - const std::vector & elem_buckets = - m_bulkData.buckets( m_elem_rank ); - - // Volume field: - - // Iterate over all element buckets and populate volume field. - for ( std::vector::const_iterator - element_bucket_it = elem_buckets.begin(); - element_bucket_it != elem_buckets.end() ; ++element_bucket_it ) { - - Bucket & element_bucket = **element_bucket_it; - - // Fill the element volume field. - // Create a multidimensional array view of the - // element volume field data for this bucket of elements. - // The array is one dimensional ( NumberElements ) - // and indexed by ( 0..NumberElements-1 ) - - stk_classic::mesh::BucketArray - volume_array( m_volume_field, element_bucket ); - - const unsigned num_elements = volume_array.dimension(0); - - ThrowRequireMsg( element_bucket.size() == num_elements , "Expected element_bucket.size() " - << element_bucket.size() << " to equal num_elements " << num_elements ); - - // Populate volume field - for ( unsigned volume_index=0 ; volume_index < num_elements ; ++volume_index) { - volume_array(volume_index) = VOLUME_VAL; - } - } - } -} - -//------------------------------------------------------------------------------ - -bool verifyMesh( const UseCase_2_Mesh & mesh, unsigned nleft, unsigned nright ) -{ - bool result = false; - result = verifyCellTopology(mesh); - result = result && verifyEntityCounts(mesh,nleft,nright); - result = result && verifyRelations(mesh,nleft,nright); - result = result && verifyFields(mesh); - return result; -} - - -bool verifyCellTopology( const UseCase_2_Mesh & mesh ) -{ - // Verify that cell topology for left and right parts is a hex - - stk_classic::mesh::Part & partLeft = mesh.m_partLeft ; - stk_classic::mesh::Part & partRight = mesh.m_partRight ; - - bool result = true; - const CellTopologyData * left_cell_topology = mesh.m_fem_metaData.get_cell_topology( partLeft ).getCellTopologyData(); - if (left_cell_topology != shards::getCellTopologyData< shards::Hexahedron<8> >()) { - std::cerr << "Error, the left cell topology is not what we asked for!" << std::endl; - std::cerr << "It is " << left_cell_topology->name<< " rather than a hex" << std::endl; - result = false; - } - - const CellTopologyData * right_cell_topology = mesh.m_fem_metaData.get_cell_topology( partRight ).getCellTopologyData(); - if (right_cell_topology != shards::getCellTopologyData< shards::Hexahedron<8> >()) { - std::cerr << "Error, the right cell topology is not what we asked for!" << std::endl; - std::cerr << "It is " << right_cell_topology->name<< " rather than a hex" << std::endl; - result = false; - } - return result; -} - -bool verifyEntityCounts( const UseCase_2_Mesh & mesh, - unsigned nleft, unsigned nright ) -{ - // Verify that we have the expected numbers of entities in each part - - const stk_classic::mesh::BulkData & bulkData = mesh.m_bulkData ; - stk_classic::mesh::Part & partLeft = mesh.m_partLeft ; - stk_classic::mesh::Part & partRight = mesh.m_partRight ; - - // Compute expected number of entities for each entity rank - const unsigned expected_num_left_nodes = (nleft+1)*4; - const unsigned expected_num_right_nodes = (nright+1)*4; - const unsigned expected_num_edges = 0; - const unsigned expected_num_faces = 0; - - bool result = true; - std::vector entity_counts; - - // Create a 'Selector' to select mesh entities - // (nodes, edges, faces, elements) - // that are members of the left element block.. - // Use the selector to count those entities. - stk_classic::mesh::Selector selector_left(partLeft); - stk_classic::mesh::count_entities( selector_left, bulkData , entity_counts ); - - // Verify expected number of entities for left part - if ( entity_counts[mesh.m_node_rank] != expected_num_left_nodes || - entity_counts[mesh.m_edge_rank] != expected_num_edges || - entity_counts[mesh.m_side_rank] != expected_num_faces || - entity_counts[mesh.m_elem_rank] != nleft ) { - std::cerr<< "Error, the left entity counts are incorrect!" << std::endl; - result = false; - } - - // Create a 'Selector' to select mesh entities - // (nodes, edges, faces, elements) - // that are members of the right element block.. - // Use the selector to count those entities. - stk_classic::mesh::Selector selector_right(partRight); - stk_classic::mesh::count_entities( selector_right, bulkData , entity_counts ); - - // Verify expected number of entities for right part - if ( entity_counts[mesh.m_node_rank] != expected_num_right_nodes || - entity_counts[mesh.m_edge_rank] != expected_num_edges || - entity_counts[mesh.m_side_rank] != expected_num_faces || - entity_counts[mesh.m_elem_rank] != nright ) { - std::cerr<< "Error, the right counts are incorrect!" << std::endl; - result = false; - } - return result; -} - -bool verifyRelations( const UseCase_2_Mesh & mesh, - unsigned nleft, unsigned nright ) -{ - const stk_classic::mesh::BulkData & bulkData = mesh.m_bulkData ; - stk_classic::mesh::Part & partLeft = mesh.m_partLeft ; - stk_classic::mesh::Part & partRight = mesh.m_partRight ; - std::vector both_parts; - both_parts.push_back(&partLeft); - both_parts.push_back(&partRight); - - bool result = true; - - const std::vector & all_elem_buckets = bulkData.buckets( mesh.m_elem_rank ); - - // For both left and right parts - // Verify the element-node relationships for each part: - for( std::vector::const_iterator iter_part = both_parts.begin(); iter_part < both_parts.end(); iter_part++) - { - std::vector selected_elem_buckets ; - - // From all element buckets select part buckets - stk_classic::mesh::Selector selector(**iter_part); - stk_classic::mesh::get_buckets( selector , all_elem_buckets , - selected_elem_buckets ); - - // Iterate over part buckets - for ( size_t j = 0 ; j < selected_elem_buckets.size() ; ++j ) { - - const stk_classic::mesh::Bucket & elem_bucket = *selected_elem_buckets[j] ; - - // Iterate over all elements in this bucket - for ( size_t i = 0 ; i < elem_bucket.size() ; ++i ) { - stk_classic::mesh::Entity & elem = elem_bucket[i] ; - - // Query the node ids for this element. - stk_classic::mesh::EntityId node_ids[ shards::Hexahedron<8> ::node_count ]; - usecase_2_elem_node_ids( elem.identifier() , node_ids ); - - // Pair of iterators for all of the element's relations. - // This class has convenience functions for size and indexing. - // rel.size() == std::distance( rel.first , rel.second ); - // rel[i] == *( rel.first + i ); - stk_classic::mesh::PairIterRelation rel = elem.relations(); - - // Verify that the number of nodes in this element is correct. - if( shards::Hexahedron<8> ::node_count != rel.size() ) { - std::cerr << "Error, number of relations is incorrect! It is " << rel.size() - << std::endl; - result = false; - } - - // Verify the nodes of this element - // have the correct relation-identifiers and - // are members of the block. - for ( unsigned k = 0 ; k < shards::Hexahedron<8> ::node_count ; ++k ) { - stk_classic::mesh::Entity & rel_node = * rel[k].entity(); - if ( node_ids[k] != rel_node.identifier() || - ! rel_node.bucket().member(**iter_part) ) { - std::cerr << "Error, an element's node is just plain wrong!" - << std::endl; - result = false; - } - } - } - } - } - - return result; -} - -//------------------------------------------------------------------------------ -// An example of a template function for gathering (copying) -// field data from the nodes of an element. -template< class field_type > -bool gather_field_data( unsigned expected_num_rel, const field_type & field , - const stk_classic::mesh::Entity & entity , - typename stk_classic::mesh::FieldTraits< field_type >::data_type * dst, - stk_classic::mesh::EntityRank entity_rank ) -{ - typedef typename stk_classic::mesh::FieldTraits< field_type >::data_type T ; - - stk_classic::mesh::PairIterRelation rel = entity.relations( entity_rank ); - - bool result = expected_num_rel == (unsigned) rel.size(); - - if ( result ) { - // Iterate over field data for each related entity and copy data - // into src for one entity at a time - T * const dst_end = dst + SpatialDim * expected_num_rel ; - for ( ; dst < dst_end ; ++rel , dst += SpatialDim ) { - const T* src = field_data( field , * rel->entity() ); - if (!src) { - break; - } - stk_classic::Copy( dst , src ); - } - result = dst == dst_end ; - } - return result ; -} - -namespace { -// This is based on the local node numbering mapping to relative coordinates. -// See header file for local node numbering. -const double ELEMENT_LOCAL_COORDINATES_GOLD[ ElementTraits::node_count ][ SpatialDim ] = - { { 0, 0, 0 } , - { 1, 0, 0 } , - { 1, 1, 0 } , - { 0, 1, 0 } , - { 0, 0, 1 } , - { 1, 0, 1 } , - { 1, 1, 1 } , - { 0, 1, 1 } }; - -} - -bool verifyFields( const UseCase_2_Mesh & mesh ) -{ - bool result = true; - - const VectorFieldType & coordinates_field = mesh.m_coordinates_field ; - const ScalarFieldType & volume_field = mesh.m_volume_field ; - const stk_classic::mesh::BulkData & bulkData = mesh.m_bulkData ; - - // All element buckets: - const std::vector & elem_buckets = - bulkData.buckets( mesh.m_elem_rank ); - - // Verify coordinates_field by gathering the nodal coordinates - // from each element's nodes. - - // Iterate over all element buckets - for ( std::vector::const_iterator - element_bucket_it = elem_buckets.begin(); - element_bucket_it != elem_buckets.end() ; ++element_bucket_it ) { - - const stk_classic::mesh::Bucket& bucket = **element_bucket_it; - const size_t num_elements_in_bucket = bucket.size(); - - // Iterate over all elements in bucket - for( size_t bucket_index = 0; bucket_index < num_elements_in_bucket; ++bucket_index) { - const stk_classic::mesh::Entity & elem = bucket[bucket_index] ; - - // Gather nodal coordinates of this element - double elem_coord[ ElementTraits::node_count ][ SpatialDim ]; - const bool gather_result = - gather_field_data - ( ElementTraits::node_count, coordinates_field , elem , & elem_coord[0][0], mesh.m_node_rank ); - - if ( gather_result == false ) { - std::cerr << "Error!" << std::endl; - result = false; - } - - // Take the global nodal coordinates of the nodes in this element and - // and convert them to local relative coordinates - - // Compute nodal coordinates of first node in element - double base[3] ; - base[0] = elem_coord[0][0] ; - base[1] = elem_coord[0][1] ; - base[2] = elem_coord[0][2] ; - - // Convert the global coordinates for each node by subtracting the - // coordinates of the base node - for ( unsigned j = 0 ; j < ElementTraits::node_count ; ++j ) { - elem_coord[j][0] -= base[0] ; - elem_coord[j][1] -= base[1] ; - elem_coord[j][2] -= base[2] ; - } - - // Check that computed local nodal coordinates match gold local - // coordinates. - for (int node_index=0 ; node_index volume_array( - volume_field, - **element_bucket_it - ); - - // For all elements volume field should be VOLUME_VAL - for ( unsigned volume_index=0 ; volume_index < num_elements_in_bucket ; ++volume_index) { - if ( volume_array(volume_index) != VOLUME_VAL ) { - std::cerr << "Error! volume_array(" << volume_index << ") == " - << volume_array(volume_index) << " != " << VOLUME_VAL - << " == VOLUME_VAL " << std::endl; - result = false; - } - } - } - - { - // Verify temperature_field on the nodes - - const ScalarFieldType & temperature_field = mesh.m_temperature_field ; - - // Get all node buckets - const std::vector & node_buckets = - bulkData.buckets( mesh.m_node_rank ); - - // Iterate over all node buckets - for ( std::vector::const_iterator - node_bucket_it = node_buckets.begin(); - node_bucket_it != node_buckets.end() ; ++node_bucket_it ) { - const stk_classic::mesh::Bucket & bucket = **node_bucket_it; - stk_classic::mesh::BucketArray temperature_array( - temperature_field, - bucket - ); - - // For all nodes in bucket temperature field should be - // TEMPERATURE_VALUE_GOLD - int num_nodes_in_bucket = temperature_array.dimension(0); - for ( int i=0 ; i < num_nodes_in_bucket ; ++i) { - if (temperature_array(i) != TEMPERATURE_VALUE_GOLD) { - std::cerr << "Error! temperature_array("< - -#include -#include -#include -#include - -#include -#include - -/** stk_mesh Use Case 2 - * - * This use case creates a mesh containing a chain of elements.It'll - * split them between left and righte parts with left coming first.The - * point of this use case is to demonstrate construction of a very simple mesh. - * - * Assume the following mesh of 4 hex8 elements. - * - * Global node and element numbering - *
- *      3       7      11      15      19
- *      +-------+-------+-------+-------+
- *     /       /       /       /       /|
- *   4/      8/     12/     16/     20/ |
- *   +-------+-------+-------+-------+  |
- *   |       |       |       |       |  +18        Z  Y
- *   |  e1   |  e2   |  e3   |  e4   | /           | /
- *   |       |       |       |       |/            |/
- *   +-------+-------+-------+-------+             *--X
- *   1       5      9       13      17
- * 
- * - * Local node numbering - *
- *      8       7
- *      +-------+
- *     /       /|
- *   5/      6/ |
- *   +-------+  |
- *   |       |  +3
- *   |  e1   | /
- *   |       |/
- *   +-------+
- *   1       2
- * 
- */ - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -// Two part MetaData with four entity types: -// Node, Edge, Face, Element -// and two parts (partLeft and partRight) -// and three fields (coordinates, temperature, and volume) -class UseCase_2_Mesh -{ -public: - ~UseCase_2_Mesh(); - - UseCase_2_Mesh( stk_classic::ParallelMachine comm ); - - void populate( unsigned nleft , unsigned nright ); - - stk_classic::mesh::fem::FEMMetaData m_fem_metaData; - stk_classic::mesh::BulkData m_bulkData; - stk_classic::mesh::Part & m_partLeft; - stk_classic::mesh::Part & m_partRight; - VectorFieldType & m_coordinates_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_volume_field; - const stk_classic::mesh::EntityRank m_elem_rank; - const stk_classic::mesh::EntityRank m_side_rank; - const stk_classic::mesh::EntityRank m_edge_rank; - const stk_classic::mesh::EntityRank m_node_rank; -}; - -/** - * Verify correctness of mesh - */ -bool verifyMesh( const UseCase_2_Mesh & mesh, unsigned nleft, unsigned nright ); - -// Helper functions for verifyMesh -bool verifyCellTopology( const UseCase_2_Mesh & mesh ); -bool verifyEntityCounts( const UseCase_2_Mesh & mesh, unsigned nleft, unsigned nright ); -bool verifyRelations( const UseCase_2_Mesh & mesh, unsigned nleft, unsigned nright ); -bool verifyFields( const UseCase_2_Mesh & mesh ); - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_2_hpp - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.cpp deleted file mode 100644 index 479f841f187c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -typedef shards::Hexahedron<8> Hex8; -typedef shards::Wedge<6> Wedge6; -typedef shards::Tetrahedron<4> Tet4; -typedef shards::Pyramid<5> Pyramid4; -typedef shards::ShellQuadrilateral<4> ShellQuad4; -typedef shards::ShellTriangle<3> ShellTriangle3; - -UseCase_3_Mesh::UseCase_3_Mesh( stk_classic::ParallelMachine comm, bool doCommit ) : - m_spatial_dimension(3) - , m_fem_metaData( m_spatial_dimension ) - , m_bulkData( fem::FEMMetaData::get_meta_data(m_fem_metaData) , comm ) - , m_block_hex( fem::declare_part( m_fem_metaData, "block_1")) - , m_block_wedge( fem::declare_part( m_fem_metaData, "block_2")) - , m_block_tet( fem::declare_part( m_fem_metaData,"block_3")) - , m_block_pyramid( fem::declare_part( m_fem_metaData, "block_4")) - , m_block_quad_shell( fem::declare_part( m_fem_metaData, "block_5")) - , m_block_tri_shell( fem::declare_part( m_fem_metaData, "block_6")) - , m_elem_rank( m_fem_metaData.element_rank() ) - , m_node_rank( m_fem_metaData.node_rank() ) - , m_coordinates_field( m_fem_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_centroid_field( m_fem_metaData.declare_field< VectorFieldType >( "centroid" )) - , m_temperature_field( m_fem_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_volume_field( m_fem_metaData.declare_field< ScalarFieldType >( "volume" )) - , m_element_node_coordinates_field( m_fem_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" )) -{ - // Define where fields exist on the mesh: - Part & universal = m_fem_metaData.universal_part(); - - put_field( m_coordinates_field , m_node_rank , universal ); - put_field( m_centroid_field , m_elem_rank , universal ); - put_field( m_temperature_field, m_node_rank, universal ); - put_field( m_volume_field, m_elem_rank, m_block_hex ); - put_field( m_volume_field, m_elem_rank, m_block_wedge ); - put_field( m_volume_field, m_elem_rank, m_block_tet ); - put_field( m_volume_field, m_elem_rank, m_block_pyramid ); - - // Define the field-relation such that the values of the - // 'element_node_coordinates_field' are pointers to the - // element's nodal 'coordinates_field'. - // I.e., let: - // double *const* elem_node_coord = - // field_data( m_element_node_coordinates_field , element ); - // then - // elem_node_coord[n][0..2] is the coordinates of element node 'n' - // that are attached to that node. - - m_fem_metaData.declare_field_relation( - m_element_node_coordinates_field , - fem::get_element_node_stencil(3) , - m_coordinates_field - ); - - // Define element node coordinate field for all element parts - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_hex, Hex8::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_wedge, Wedge6::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_tet, Tet4::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_pyramid, Pyramid4::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_quad_shell, ShellQuad4::node_count); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_tri_shell, ShellTriangle3::node_count ); - - if (doCommit) - m_fem_metaData.commit(); -} - -UseCase_3_Mesh::~UseCase_3_Mesh() -{ } - -//------------------------------------------------------------------------------ -// Use case specific mesh generation data: - -enum { SpatialDim = 3 }; -enum { node_count = 21 }; -enum { number_hex = 3 }; -enum { number_wedge = 3 }; -enum { number_tetra = 3 }; -enum { number_pyramid = 2 }; -enum { number_shell_quad = 3 }; -enum { number_shell_tri = 3 }; - -namespace { - -// Hard coded node coordinate data for all the nodes in the entire mesh -static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 2 , 0 , 0 } , { 3 , 0 , 0 } , - { 0 , 1 , 0 } , { 1 , 1 , 0 } , { 2 , 1 , 0 } , { 3 , 1 , 0 } , - { 0 , 2 , 0 } , { 1 , 2 , 0 } , - { 0 , 0 , -1 } , { 1 , 0 , -1 } , { 2 , 0 , -1 } , { 3 , 0 , -1 } , - { 0 , 1 , -1 } , { 1 , 1 , -1 } , { 2 , 1 , -1 } , { 3 , 1 , -1 } , - { 0 , 2 , -1 } , { 1 , 2 , -1 } , - { 1 , 1 , -2 } }; - -// Hard coded hex node ids for all the hex nodes in the entire mesh -static const EntityId hex_node_ids[number_hex][ Hex8::node_count ] = { - { 1 , 2 , 12 , 11 , 5 , 6 , 16 , 15 } , - { 2 , 3 , 13 , 12 , 6 , 7 , 17 , 16 } , - { 3 , 4 , 14 , 13 , 7 , 8 , 18 , 17 } }; - -// Hard coded wedge node ids for all the wedge nodes in the entire mesh -static const EntityId wedge_node_ids[number_wedge][ Wedge6::node_count ] = { - { 15 , 16 , 19 , 5 , 6 , 9 } , - { 10 , 9 , 6 , 20 , 19 , 16 } , - { 16 , 17 , 20 , 6 , 7 , 10 } }; - -// Hard coded tetra node ids for all the tetra nodes in the entire mesh -static const EntityId tetra_node_ids[number_tetra][ Tet4::node_count ] = { - { 15 , 19 , 16 , 21 } , - { 19 , 20 , 16 , 21 } , - { 16 , 20 , 17 , 21 } }; - -// Hard coded pyramid node ids for all the pyramid nodes in the entire mesh -static const EntityId pyramid_node_ids[number_pyramid][ Pyramid4::node_count ] = { - { 11 , 15 , 16 , 12 , 21 } , - { 12 , 16 , 17 , 13 , 21 } }; - -// Hard coded shell quad node ids for all the shell quad nodes in the entire mesh -static const EntityId shell_quad_node_ids[number_shell_quad][ ShellQuad4::node_count ]={ - { 9 , 6 , 16 , 19 } , - { 6 , 7 , 17 , 16 } , - { 7 , 8 , 18 , 17 } }; - -// Hard coded shell tri node ids for all the shell tri nodes in the entire mesh -static const EntityId shell_tri_node_ids[number_shell_tri][ ShellTriangle3::node_count ] ={ - { 19 , 16 , 21 } , - { 16 , 17 , 21 } , - { 17 , 13 , 21 } }; - -} - -//------------------------------------------------------------------------------ - -void UseCase_3_Mesh::populate() -{ - // Populate mesh with all node types - - m_bulkData.modification_begin(); - - EntityId curr_elem_id = 1; - - // For each element topology declare elements - - for ( unsigned i = 0 ; i < number_hex ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_hex, curr_elem_id, hex_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_wedge ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_wedge, curr_elem_id, wedge_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_tetra ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_tet, curr_elem_id, tetra_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_pyramid ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_pyramid, curr_elem_id, pyramid_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_shell_quad ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_quad_shell, curr_elem_id, shell_quad_node_ids[i]); - } - - for ( unsigned i = 0 ; i < number_shell_tri ; ++i , ++curr_elem_id ) { - fem::declare_element( m_bulkData, m_block_tri_shell, curr_elem_id, shell_tri_node_ids[i] ); - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < node_count ; ++i ) { - Entity * const node = m_bulkData.get_entity( m_node_rank , i + 1 ); - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - m_bulkData.modification_end(); - // No parallel stuff for now -} - -// Verify mesh for 6 different parts -bool verifyMesh( const UseCase_3_Mesh & mesh ) -{ - bool result = true; - - const BulkData & bulkData = mesh.m_bulkData ; - const VectorFieldType & node_coord = mesh.m_coordinates_field ; - const ElementNodePointerFieldType & elem_node_coord = - mesh.m_element_node_coordinates_field ; - - std::vector element_buckets = bulkData.buckets( mesh.m_elem_rank ); - - // Create a pair containing Part and matching node_count - typedef std::pair PartNodeCountPair; - std::vector part_and_node_counts; - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_hex, Hex8::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_wedge, Wedge6::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_tet, Tet4::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_pyramid, Pyramid4::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_quad_shell, ShellQuad4::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_tri_shell, ShellTriangle3::node_count)); - - // Verify that entities in each part are set up correctly. - // Use a PartVector iterator for parts_to_check and call - // verify_elem_node_coord_by_part in UseCase_Common.cpp for - // each part in turn. - for( std::vector::const_iterator i = part_and_node_counts.begin() ; i != part_and_node_counts.end() ; ++i ) - { - result = result && - verify_elem_node_coord_by_part( - *(i->first), - element_buckets, - elem_node_coord, - node_coord, - i->second - ); - } - - // Check that all the nodes were allocated. - for ( unsigned i = 0 ; i < node_count ; ++i ) { - Entity * const node = bulkData.get_entity( mesh.m_node_rank , i + 1 ); - if ( node == NULL ) { - std::cerr << "Error! Invalid null pointer for node returned from " - << "bulkData.get_entity( m_node_rank, " << i+1 << " ) " << std::endl; - result = false; - } - } - - return result; -} - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.hpp deleted file mode 100644 index 09837fbec19c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_3.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Mesh_Use_Cases_UseCase_3_hpp -#define Stk_Mesh_Use_Cases_UseCase_3_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -/** stk_mesh Use Case 3 */ - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -/** Use case with mixed element topologies and - * field relations to provide fast access to node field data - * from an element. - */ - -class UseCase_3_Mesh { -public: - - ~UseCase_3_Mesh(); - - UseCase_3_Mesh( stk_classic::ParallelMachine comm, bool doCommit = true); - - void populate(); - - const int m_spatial_dimension; - fem::FEMMetaData m_fem_metaData; - BulkData m_bulkData; - - Part & m_block_hex; - Part & m_block_wedge; - Part & m_block_tet; - Part & m_block_pyramid; - Part & m_block_quad_shell; - Part & m_block_tri_shell; - - const EntityRank m_elem_rank; - const EntityRank m_node_rank; - - VectorFieldType & m_coordinates_field; - VectorFieldType & m_centroid_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_volume_field; - ElementNodePointerFieldType & m_element_node_coordinates_field; -}; - -bool verifyMesh( const UseCase_3_Mesh & mesh ); - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_3_hpp diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.cpp deleted file mode 100644 index d5e3c564efe2..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - -enum { SpatialDim = 3 }; - -namespace stk_classic{ -namespace mesh { -namespace use_cases { - -typedef shards::Hexahedron<8> Hex8; -typedef shards::Hexahedron<27> Hex27; -typedef shards::Wedge<6> Wedge6; -typedef shards::Wedge<18> Wedge18; - -UseCase_4_Mesh::UseCase_4_Mesh( stk_classic::ParallelMachine comm, bool doCommit ) : - m_fem_metaData( SpatialDim ) - , m_bulkData( fem::FEMMetaData::get_meta_data(m_fem_metaData) , comm ) - , m_elem_rank( m_fem_metaData.element_rank() ) - , m_side_rank( m_fem_metaData.side_rank() ) - , m_node_rank( m_fem_metaData.node_rank() ) - , m_block_hex27( stk_classic::mesh::fem::declare_part( m_fem_metaData, "block_1")) - , m_block_wedge18( stk_classic::mesh::fem::declare_part( m_fem_metaData, "block_2")) - , m_part_vertex_nodes( m_fem_metaData.declare_part("vertex_nodes", m_node_rank )) - , m_side_part( m_fem_metaData.declare_part("sideset_1", m_side_rank )) - , m_coordinates_field(m_fem_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_velocity_field(m_fem_metaData.declare_field< VectorFieldType >( "velocity" )) - , m_centroid_field(m_fem_metaData.declare_field< VectorFieldType >( "centroid" )) - , m_temperature_field(m_fem_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_pressure_field(m_fem_metaData.declare_field< ScalarFieldType >( "pressure" )) - , m_boundary_field(m_fem_metaData.declare_field< VectorFieldType >( "boundary" )) - , m_element_node_coordinates_field(m_fem_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" ) ) -{ - //-------------------------------- - // The vertex nodes of the hex and wedge elements are members - // of the vertex part; however, the mid-edge nodes are not. - // - // Use an element-node stencil to define this relationship. - - // Declare that the Hexahedron<> nodes of an element in the - // hex27 element block are members of the linear part. - - m_fem_metaData.declare_part_relation( - m_block_hex27 , - & fem::element_node_stencil< Hex8, SpatialDim > , - m_part_vertex_nodes ); - - // Declare that the Wedge<> nodes of an element in the - // wedge18 element block are members of the vertex part. - - m_fem_metaData.declare_part_relation( - m_block_wedge18 , - & fem::element_node_stencil< Wedge6, SpatialDim > , - m_part_vertex_nodes ); - - // Where fields exist on the mesh: - Part & universal = m_fem_metaData.universal_part(); - - put_field( m_coordinates_field , m_node_rank , universal ); - put_field( m_velocity_field , m_node_rank , universal ); - put_field( m_centroid_field , m_elem_rank , universal ); - put_field( m_temperature_field, m_node_rank, universal ); - - // The pressure field only exists on the vertex nodes: - put_field( m_pressure_field, m_node_rank, m_part_vertex_nodes ); - - // The boundary field only exists on nodes in the sideset part - put_field( m_boundary_field, m_node_rank, m_side_part ); - - // Set up the relationship between nodal coord field and elem node coord field - m_fem_metaData.declare_field_relation( - m_element_node_coordinates_field , - fem::get_element_node_stencil(SpatialDim) , - m_coordinates_field - ); - - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_hex27, Hex27::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_wedge18, Wedge18::node_count ); - - if (doCommit) - m_fem_metaData.commit(); -} - -UseCase_4_Mesh::~UseCase_4_Mesh() -{ } - -//------------------------------------------------------------------------------ -// Use-case specific mesh data: - -enum { node_count = 66 }; -enum { number_hex = 2 }; -enum { number_wedge = 3 }; - -namespace { - -// Hard coded node coordinate data for all the nodes in the entire mesh -static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 0 , 0 , 0 } , { 0 , 0 , -1 } , { 0 , 0 , -2 } , - { 1 , 0 , 0 } , { 1 , 0 , -1 } , { 1 , 0 , -2 } , - { 2 , 0 , 0 } , { 2 , 0 , -1 } , { 2 , 0 , -2 } , - { 3 , 0 , 0 } , { 3 , 0 , -1 } , { 3 , 0 , -2 } , - { 4 , 0 , 0 } , { 4 , 0 , -1 } , { 4 , 0 , -2 } , - - { 0 , 1 , 0 } , { 0 , 1 , -1 } , { 0 , 1 , -2 } , - { 1 , 1 , 0 } , { 1 , 1 , -1 } , { 1 , 1 , -2 } , - { 2 , 1 , 0 } , { 2 , 1 , -1 } , { 2 , 1 , -2 } , - { 3 , 1 , 0 } , { 3 , 1 , -1 } , { 3 , 1 , -2 } , - { 4 , 1 , 0 } , { 4 , 1 , -1 } , { 4 , 1 , -2 } , - - { 0 , 2 , 0 } , { 0 , 2 , -1 } , { 0 , 2 , -2 } , - { 1 , 2 , 0 } , { 1 , 2 , -1 } , { 1 , 2 , -2 } , - { 2 , 2 , 0 } , { 2 , 2 , -1 } , { 2 , 2 , -2 } , - { 3 , 2 , 0 } , { 3 , 2 , -1 } , { 3 , 2 , -2 } , - { 4 , 2 , 0 } , { 4 , 2 , -1 } , { 4 , 2 , -2 } , - - { 0.5 , 3 , 0 } , { 0.5 , 3 , -1 } , { 0.5 , 3 , -2 } , - { 1.5 , 3 , 0 } , { 1.5 , 3 , -1 } , { 1.5 , 3 , -2 } , - { 2.5 , 3 , 0 } , { 2.5 , 3 , -1 } , { 2.5 , 3 , -2 } , - { 3.5 , 3 , 0 } , { 3.5 , 3 , -1 } , { 3.5 , 3 , -2 } , - - { 1 , 4 , 0 } , { 1 , 4 , -1 } , { 1 , 4 , -2 } , - { 2 , 4 , 0 } , { 2 , 4 , -1 } , { 2 , 4 , -2 } , - { 3 , 4 , 0 } , { 3 , 4 , -1 } , { 3 , 4 , -2 } -}; - -// Hard coded wedge node ids for all the wedge nodes in the entire mesh -static const EntityId wedge_node_ids[3][ Wedge18::node_count ] = { - { 33 , 39 , 60 , 31 , 37 , 58 , // vertices - 36 , 51 , 48 , 32 , 38 , 59 , 34 , 49 , 46 , // mid edge nodes - 35 , 50 , 47 }, // mid side nodes - { 39 , 45 , 66 , 37 , 43 , 64 , // vertices - 42 , 57 , 54 , 38 , 44 , 65 , 40 , 55 , 52 , // mid edge nodes - 41 , 56 , 53 }, // mid side nodes - { 66 , 60 , 39 , 64 , 58 , 37 , // vertices - 63 , 51 , 54 , 65 , 59 , 38 , 61 , 49 , 52 , // mid edge nodes - 62 , 50 , 53 } // mid side nodes - - }; - -// Hard coded hex node ids for all the hex nodes in the entire mesh -static const EntityId hex_node_ids[2][ Hex27::node_count ] = { - { 1 , 7 , 9 , 3 , 31 , 37 , 39 , 33 , // vertices - 4 , 8 , 6 , 2 , 16 , 22 , 24 , 18 , 34 , 38 , 36 , 32 , // mid edge nodes - 20 , 5 , 35 , 17 , 23 , 19 , 21 } , // mid side nodes - { 7 , 13 , 15 , 9 , 37 , 43 , 45 , 39 , // vertices - 10 , 14 , 12 , 8 , 22 , 28 , 30 , 24 , 40 , 44 , 42 , 38 , // mid edge nodes - 26 , 11 , 41 , 23 , 29 , 25 , 27 } // mid side nodes - -}; - -} - -//------------------------------------------------------------------------------ - -void UseCase_4_Mesh::populate() -{ - m_bulkData.modification_begin(); - - EntityId elem_id = 1; - EntityId face_id = 1; - - // Declare element with its nodes. - // Declare a side on an element. This utility function creates the - // side, element-side relations, and side-node relations. - // It will NOT check if the side sandwiched between two elements. - - // Iterate over the number of desired hexs here and declares them - for ( unsigned i = 0 ; i < number_hex ; ++i , ++elem_id , ++face_id ) { - Entity & elem = - fem::declare_element( m_bulkData, m_block_hex27, elem_id, hex_node_ids[i] ); - - fem::declare_element_side( m_bulkData, face_id, elem, 0 /*local side id*/, &m_side_part); - } - - // Iterate over the number of desired wedges here and declares the - for ( unsigned i = 0 ; i < number_wedge ; ++i , ++elem_id , ++face_id ) { - Entity & elem = - fem::declare_element( m_bulkData, m_block_wedge18, elem_id, wedge_node_ids[i] ); - - fem::declare_element_side( m_bulkData, face_id , elem , 4 /*local side id*/, &m_side_part); - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < node_count ; ++i ) { - Entity * const node = m_bulkData.get_entity( m_node_rank, i + 1 ); - ThrowRequireMsg( node != NULL, i+1 ); - - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - m_bulkData.modification_end(); -} - -//------------------------------------------------------------------------------ - -void runAlgorithms( const UseCase_4_Mesh & mesh ) -{ - const BulkData & bulkData = mesh.m_bulkData ; - VectorFieldType & centroid_field = mesh.m_centroid_field ; - ElementNodePointerFieldType & elem_node_coord = mesh.m_element_node_coordinates_field ; - Part & block_hex27 = mesh.m_block_hex27 ; - Part & block_wedge18 = mesh.m_block_wedge18 ; - - // Run the centroid algorithm on the hexes: - centroid_algorithm< Hex27 >( bulkData , - centroid_field , - elem_node_coord , - block_hex27, - mesh.m_elem_rank ); - - // Run the centroid algorithm on the wedges: - centroid_algorithm< Wedge18 >( bulkData , - centroid_field , - elem_node_coord , - block_wedge18, - mesh.m_elem_rank ); - -} - -//------------------------------------------------------------------------------ - -namespace { - -template< class CellTopology > -bool verify_elem_side_node( const EntityId * const elem_nodes , - const unsigned local_side , - const mesh::Entity & side ) -{ - bool result = true; - const CellTopologyData * const elem_top = shards::getCellTopologyData< CellTopology >(); - - const CellTopologyData * const side_top = elem_top->side[ local_side ].topology ; - const unsigned * const side_node_map = elem_top->side[ local_side ].node ; - - const mesh::PairIterRelation rel = side.relations( fem::FEMMetaData::NODE_RANK ); - - // Verify that the node relations are compatible with the cell topology data - for ( unsigned i = 0 ; i < side_top->node_count ; ++i ) { - - if ( elem_nodes[ side_node_map[i] ] != rel[i].entity()->identifier() ) { - std::cerr << "Error!" << std::endl; - result = false; - } - } - return result; -} - -bool verify_boundary_field_data( const BulkData & mesh , - Part & side_part , - const VectorFieldType & boundary_field ) -{ - bool result = true; - - unsigned num_nodes_on_side_of_mesh = 0 ; - - const std::vector & buckets = mesh.buckets( fem::FEMMetaData::NODE_RANK ); - - // Iterate over each bucket and sum the number of nodes - // into num_nodes_on_side_of_mesh for each bucket which is a subset of side_part. - // this should give the number of nodes on the front face of the mesh (see .hpp file). - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - Bucket & bucket = **k ; - - void * data = field_data( boundary_field , bucket.begin() ); - - if ( has_superset( bucket, side_part ) ) { - // Since this node is in the side part it should have a - // boundary field. - if ( data == NULL ) { - std::cerr << "Error! data == NULL" << std::endl; - result = false; - } - num_nodes_on_side_of_mesh += bucket.size(); - } - else { - // Since this node is not in the side part it should not have a - // boundary field. - if ( data != NULL ) { - std::cerr << "Error! data != NULL" << std::endl; - result = false; - } - } - } - - // There should be 22 nodes on the front face of the mesh. This is checking to verify that. - if ( num_nodes_on_side_of_mesh != 22u ) { - std::cerr << "Error! num_nodes_on_side_of_mesh == " << num_nodes_on_side_of_mesh << " != 22!" << std::endl; - result = false; - } - return result; -} - -// xCheck on pressure and velocity on each node -template< class ElementTopology , - class StencilTopology , - class PressureField , - class VelocityField > -bool verify_pressure_velocity_stencil( - const BulkData & M , - const Part & element_part , - const Part & linear_node_part , - const PressureField & pressure , - const VelocityField & velocity, - EntityRank element_rank ) -{ - typedef typename FieldTraits< PressureField >::data_type scalar_type ; - typedef typename FieldTraits< VelocityField >::data_type scalar_type_2 ; - - bool result = true; - - StaticAssert< SameType< scalar_type , scalar_type_2 >::value >::ok(); - - // Verify element topoloy and stencil topology are compatible - if ( (int) ElementTopology::dimension != StencilTopology::dimension ) { - std::cerr << "Error! ElementTopology::dimension != StencilTopology::dimension!" << std::endl; - result = false; - } - if ( (int) ElementTopology::vertex_count != StencilTopology::vertex_count ) { - std::cerr << "Error! ElementTopology::vertex_nodes != StencilTopology::vertex_count!" << std::endl; - result = false; - } - if ( (int) ElementTopology::edge_count != StencilTopology::edge_count ) { - std::cerr << "Error! ElementTopology::edge_count != StencilTopology::edge_count!" << std::endl; - result = false; - } - if ( (int) ElementTopology::face_count != StencilTopology::face_count ) { - std::cerr << "Error! ElementTopology::face_count != StencilTopology::face_count!" << std::endl; - result = false; - } - - const std::vector & buckets = M.buckets( element_rank ); - - // Iterate over all element buckets - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - Bucket & bucket = **k ; - - // Ignoring buckets which do not contain element part. - if ( has_superset( bucket, element_part ) ) { - - // Iterate over all entities in bucket - for ( Bucket::iterator - i = bucket.begin() ; i != bucket.end() ; ++i ) { - Entity & elem = *i ; - - PairIterRelation rel = elem.relations( fem::FEMMetaData::NODE_RANK ); - - // Check that the nodal relation size is the same as the element topology - // node count. - if ( (unsigned) rel.size() != (unsigned) ElementTopology::node_count ) { - std::cerr << "Error!" << std::endl; - result = false; - } - - // Iterate over every node and check pressure and velocity at each node. - for ( unsigned j = 0 ; j < ElementTopology::node_count ; ++j ) { - Entity & node = * rel[j].entity(); - - // Get the parts that this node belongs to. - const Bucket & node_bucket = node.bucket(); - PartVector node_parts ; - node_bucket.supersets( node_parts ); - - scalar_type * const p = field_data( pressure , node ); - scalar_type * const v = field_data( velocity , node ); - - // Check if this node is within StencilTopology::node_count, (Hex - 8 and Wedge - 6) - // that the node_parts contains the linear_node_part and that - // the pressure is not NULL. This code relies on the fact that the vertex nodes come first - // in the relation PairIter. - if ( j < StencilTopology::node_count ) { - - if ( !contain( node_parts , linear_node_part ) ) { - std::cerr << "Error! PartVector node_parts does not contain linear_node_part" - << std::endl; - result = false; - } - // Pressure should not be NULL on the vertices. - if ( p == NULL ) { - std::cerr << "Error! Pressure is NULL" << std::endl; - result = false; - } - } - // If this node is NOT within StencilTopology::node_count, - // check that node_parts does NOT contain the linear_node_part and that - // the pressure IS NULL. - else { - if ( contain( node_parts , linear_node_part ) ) { - std::cerr << "Error! PartVector node_parts contains linear_node_part" - << std::endl; - result = false; - } - if ( p != NULL ) { - std::cerr << "Error! Pressure is not NULL" << std::endl; - result = false; - } - } - - // Check velocity is not NULL. This should be present on every node. - if ( v == NULL ) { - std::cerr << "Error! Velocity is NULL" << std::endl; - result = false; - } - } - } - } - } - return result; -} - -} - -//------------------------------------------------------------------------------ - -bool verifyMesh( const UseCase_4_Mesh & mesh ) -{ - bool result = true; - const BulkData& bulk_data = mesh.m_bulkData ; - - std::vector element_buckets = bulk_data.buckets( mesh.m_elem_rank ); - - // Verify the element node coordinates and side nodes: - // block_hex27: - Part & block_hex27 = mesh.m_block_hex27 ; - const ElementNodePointerFieldType & elem_node_coord = mesh.m_element_node_coordinates_field ; - const VectorFieldType & node_coord = mesh.m_coordinates_field ; - result = result && - verify_elem_node_coord_by_part( - block_hex27, - element_buckets, - elem_node_coord, - node_coord, - 27 - ); - - // Verify element side node: - const std::vector face_buckets = bulk_data.buckets( mesh.m_side_rank ); - Part & side_part = mesh.m_side_part ; - { - Selector selector = block_hex27 & side_part; - std::vector entities; - get_selected_entities( selector, face_buckets, entities); - for (unsigned i=0 ; i < entities.size() ; ++i) { - result = result && - verify_elem_side_node< shards::Hexahedron<27> >( - hex_node_ids[i], 0, *entities[i] - ); - } - } - - // block_wedge18: - Part & block_wedge18 = mesh.m_block_wedge18 ; - result = result && - verify_elem_node_coord_by_part( - block_wedge18, - element_buckets, - elem_node_coord, - node_coord, - 18 - ); - - // Verify element side node: - { - Selector selector = block_wedge18 & side_part; - std::vector entities; - get_selected_entities( selector, face_buckets, entities); - for (unsigned i=0 ; i < entities.size() ; ++i) { - result = result && - verify_elem_side_node< shards::Wedge<18> >( - wedge_node_ids[i], 4, *entities[i] - ); - } - } - - // Verify centroid dimensions - const VectorFieldType & centroid_field = mesh.m_centroid_field ; - result = result && - centroid_algorithm_unit_test_dimensions< shards::Hexahedron<27> >( - bulk_data , centroid_field , elem_node_coord , block_hex27, mesh.m_elem_rank ); - - result = result && - centroid_algorithm_unit_test_dimensions< shards::Wedge<18> >( - bulk_data , centroid_field , elem_node_coord , block_wedge18, mesh.m_elem_rank ); - - // Verify boundary field data - const VectorFieldType & boundary_field = mesh.m_boundary_field ; - result = result && - verify_boundary_field_data( bulk_data , - side_part , - boundary_field ); - - // Verify pressure velocity stencil for block_hex27 - Part & part_vertex_nodes = mesh.m_part_vertex_nodes ; - const ScalarFieldType & pressure_field = mesh.m_pressure_field ; - const VectorFieldType & velocity_field = mesh.m_velocity_field ; - result = result && - verify_pressure_velocity_stencil - < shards::Hexahedron<27> , shards::Hexahedron<8> > - ( bulk_data , block_hex27 , part_vertex_nodes , - pressure_field , velocity_field, mesh.m_elem_rank ); - - // Verify pressure velocity stencil for block_wedge18 - result = result && - verify_pressure_velocity_stencil - < shards::Wedge<18> , shards::Wedge<6> > - ( bulk_data , block_wedge18 , part_vertex_nodes , - pressure_field , velocity_field, mesh.m_elem_rank ); - - return result; -} - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.hpp deleted file mode 100644 index 94551198773b..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_4.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Mesh_Use_Cases_UseCase_4_hpp -#define Stk_Mesh_Use_Cases_UseCase_4_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -/** stk_mesh Use Case 4 - * - * This use case creates the mesh below. We have only labelled the - * node ids of the vertices visible from the front. Sides are - * created for the side of the elements that are facing us in this diagram. - * - * This mesh consists of two Hex27 elements side by side with three Wedge18 on top. - * - *
- *         +60-----66+
- *        /         /\
- *       /         /  \
- *      +58-----64+    \
- *     /  \     /  \    +45
- *    /    \   /    \  /|
- *   /      \ /      \/ |
- *   +31-----+37---43+  |     Z  Y
- *   |       |       |  +15   | /
- *   |       |       | /      |/
- *   |       |       |/       *--X
- *   +-------+-------+
- *   1       7      13
- * 
- * - * There are 22 nodes on this front face including mid-edge and - * mid-side nodes in addition to the labelled vertices. - * - */ - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -/** Use case for quadratic element with a mix of linear and quadratic nodes. */ - -class UseCase_4_Mesh { -public: - - ~UseCase_4_Mesh(); - - UseCase_4_Mesh( stk_classic::ParallelMachine comm, bool doCommit=true ); - - void populate(); - - fem::FEMMetaData m_fem_metaData; - BulkData m_bulkData; - - const EntityRank m_elem_rank; - const EntityRank m_side_rank; - const EntityRank m_node_rank; - - Part & m_block_hex27; - Part & m_block_wedge18; - Part & m_part_vertex_nodes; - Part & m_side_part; - - VectorFieldType & m_coordinates_field; - VectorFieldType & m_velocity_field; - VectorFieldType & m_centroid_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_pressure_field; - VectorFieldType & m_boundary_field; - ElementNodePointerFieldType & m_element_node_coordinates_field; - -}; - -void runAlgorithms( const UseCase_4_Mesh & mesh ); - -bool verifyMesh( const UseCase_4_Mesh & mesh ); - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_4_hpp diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.cpp deleted file mode 100644 index 6f8a10b3a233..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.cpp +++ /dev/null @@ -1,605 +0,0 @@ -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "UseCase_ChangeOwner.hpp" - -namespace { - -typedef shards::Quadrilateral<4> Quad4; - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -const unsigned spatial_dimension = 2; - -} - -Grid2D_Fixture::Grid2D_Fixture( stk_classic::ParallelMachine comm ) - : m_fem_meta_data( spatial_dimension ), - m_bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_fem_meta_data) , comm , 100 ), - m_quad_part( stk_classic::mesh::fem::declare_part( m_fem_meta_data, "quad")), - m_coord_field( m_fem_meta_data.declare_field< VectorField >( "coordinates" ) ), - m_elem_rank( m_fem_meta_data.element_rank() ), - m_node_rank( m_fem_meta_data.node_rank() ) -{ - stk_classic::mesh::put_field( m_coord_field , m_node_rank , m_fem_meta_data.universal_part() ); - - m_fem_meta_data.commit(); -} - -bool Grid2D_Fixture::test_change_owner( unsigned nx , unsigned ny ) -{ - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned p_rank = m_bulk_data.parallel_rank(); - - int result = 1 ; - - m_bulk_data.modification_begin(); - - // First of all work out the node ids and declare element elem - if ( p_rank == 0 ) { - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::fem::declare_element( m_bulk_data , m_quad_part , elem , nodes ); - } - } - } - - // Only P0 has any nodes or elements - if ( p_rank == 0 ) { - result = ! m_bulk_data.buckets( m_node_rank ).empty() && - ! m_bulk_data.buckets( m_elem_rank ).empty(); - } - else { - result = m_bulk_data.buckets( m_node_rank ).empty() && - m_bulk_data.buckets( m_elem_rank ).empty(); - } - - m_bulk_data.modification_end(); - - if ( 1 < p_size ) { - std::vector< stk_classic::mesh::EntityProc > change ; - - if ( p_rank == 0 ) { - if ( p_size == 3 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - unsigned proc = ix < nx/2 ? 1 : 2; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_node_rank , id ) , proc ); - change.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - unsigned proc = ix < nx/2 ? 1 : 2; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_elem_rank , id ) , proc ); - change.push_back( tmp ); - } - } - } - else - { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_node_rank , id ) , 1 ); - change.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_elem_rank , id ) , 1 ); - change.push_back( tmp ); - } - } - } - } - - m_bulk_data.modification_begin(); - m_bulk_data.change_entity_owner( change ); - m_bulk_data.modification_end(); - - change.clear(); - - if ( p_rank == 0 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = 0 ; iy < nny / 2 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_node_rank , id ) , 1 ); - change.push_back( tmp ); - } - } - for ( unsigned iy = 0 ; iy < ny / 2 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_elem_rank , id ) , 1 ); - change.push_back( tmp ); - } - } - } - - m_bulk_data.modification_begin(); - m_bulk_data.change_entity_owner( change ); - m_bulk_data.modification_end(); - - if ( p_size == 3 ) { - change.clear(); - - if ( p_rank == 2 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = nx / 2 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - unsigned proc = 1; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_node_rank , id ) , proc ); - change.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = nx / 2 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - unsigned proc = 1; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( m_elem_rank , id ) , proc ); - change.push_back( tmp ); - } - } - } - - m_bulk_data.modification_begin(); - m_bulk_data.change_entity_owner( change ); - m_bulk_data.modification_end(); - } - - // Only P1 has any nodes or elements - if ( p_rank == 1 ) { - result = ! m_bulk_data.buckets( m_node_rank ).empty() && - ! m_bulk_data.buckets( m_elem_rank ).empty(); - } - else { - result = m_bulk_data.buckets( m_node_rank ).empty() && - m_bulk_data.buckets( m_elem_rank ).empty(); - } - } - - stk_classic::all_reduce( m_bulk_data.parallel() , stk_classic::ReduceMin<1>( & result ) ); - - return result ; -} - -//---------------------------------------------------------------------------- - -bool test_change_owner_with_constraint( stk_classic::ParallelMachine pm ) -{ - bool success = true ; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - if ( p_size != 2 ) { return success ; } - - std::vector rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - const stk_classic::mesh::EntityRank constraint_rank = rank_names.size(); - rank_names.push_back("Constraint"); - stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension, rank_names ); - const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank(); - - VectorField * coordinates_field = - & put_field( - fem_meta_data.declare_field("coordinates"), - NODE_RANK, - fem_meta_data.universal_part() , - 3 - ); - - stk_classic::mesh::Part & owned_part = fem_meta_data.locally_owned_part(); - stk_classic::mesh::Part & quad_part = stk_classic::mesh::fem::declare_part( fem_meta_data, "quad"); - - fem_meta_data.commit(); - - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta_data), - pm, - 100 ); - bulk_data.modification_begin(); - - unsigned nx = 3; - unsigned ny = 3; - - if ( p_rank==0 ) - { - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - } - } - - for ( unsigned iy = 0 ; iy < ny+1 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx+1 ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid ); - double * const coord = stk_classic::mesh::field_data( *coordinates_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - } - - bulk_data.modification_end(); - - if ( p_size>1 ) - { - std::vector ep; - - if ( p_rank==0 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 3 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 4 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 7 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 8 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 1 ) ); - } - - bulk_data.modification_begin(); - bulk_data.change_entity_owner( ep ); - bulk_data.modification_end(); - - bulk_data.modification_begin(); - - if ( p_rank==1 ) - { - // create constraint - - stk_classic::mesh::Entity * n10 = bulk_data.get_entity( NODE_RANK, 10 ); - stk_classic::mesh::Entity * n11 = bulk_data.get_entity( NODE_RANK, 11 ); - stk_classic::mesh::Entity * n12 = bulk_data.get_entity( NODE_RANK, 12 ); - - stk_classic::mesh::PartVector add; - add.push_back( &owned_part ); - const stk_classic::mesh::EntityId c_entity_id = 1; - stk_classic::mesh::Entity & c = bulk_data.declare_entity( constraint_rank, c_entity_id, add ); - bulk_data.declare_relation( c , *n10 , 0 ); - bulk_data.declare_relation( c , *n11 , 1 ); - bulk_data.declare_relation( c , *n12 , 2 ); - } - - bulk_data.modification_end(); - - stk_classic::mesh::Entity * n10 = bulk_data.get_entity( NODE_RANK, 10 ); - - if ( p_rank==0 or p_rank==1 ) - { - ThrowErrorMsgIf( !stk_classic::mesh::in_shared( *n10 ), "NODE[10] not shared" ); - } - - bulk_data.modification_begin(); - - if ( p_rank==1 ) - { - // destroy constraint - - stk_classic::mesh::Entity * c1 = bulk_data.get_entity( constraint_rank, 1 ); - - ThrowErrorMsgIf( !bulk_data.destroy_entity( c1 ), - "failed to destroy constraint" ); - } - - bulk_data.modification_end(); - - if ( p_rank==0 or p_rank==1 ) - { - ThrowErrorMsgIf( stk_classic::mesh::in_shared( *n10 ), "NODE[10] shared" ); - } - } - - return success ; -} - -//---------------------------------------------------------------------------- - -bool test_change_owner_2( stk_classic::ParallelMachine pm ) -{ - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - if ( p_size != 3 ) { return true ; } - - stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension ); - const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank(); - - VectorField * coordinates_field = - & put_field( - fem_meta_data.declare_field("coordinates"), - NODE_RANK, - fem_meta_data.universal_part() , - 3 - ); - - stk_classic::mesh::Part & quad_part = stk_classic::mesh::fem::declare_part( fem_meta_data, "quad"); - - fem_meta_data.commit(); - - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta_data), - pm, - 100 ); - bulk_data.modification_begin(); - - unsigned nx = 3; - unsigned ny = 3; - - if ( p_rank==0 ) - { - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - } - } - - for ( unsigned iy = 0 ; iy < ny+1 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx+1 ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid ); - double * const coord = stk_classic::mesh::field_data( *coordinates_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - } - - bulk_data.modification_end(); - - if ( p_size==3 ) - { - std::vector ep; - - if ( p_rank==0 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 9 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 13 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 7 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 3 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 4 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 7 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 8 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 2 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 2 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 2 ) ); - } - - bulk_data.modification_begin(); - bulk_data.change_entity_owner( ep ); - bulk_data.modification_end(); - - ep.clear(); - - if ( p_rank==1 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 9 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 13 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 0 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 7 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 0 ) ); - } - - if ( p_rank==2 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 3 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 4 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 7 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 8 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 0 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 0 ) ); - } - - bulk_data.modification_begin(); - bulk_data.change_entity_owner( ep ); - bulk_data.modification_end(); - } - - return true ; -} - -//---------------------------------------------------------------------------- - -bool test_change_owner_3( stk_classic::ParallelMachine pm ) -{ - const int p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension ); - const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank(); - - VectorField * coordinates_field = - & put_field( - fem_meta_data.declare_field("coordinates"), - NODE_RANK, - fem_meta_data.universal_part() , - 3 - ); - - stk_classic::mesh::Part & quad_part = stk_classic::mesh::fem::declare_part( fem_meta_data, "quad"); - - fem_meta_data.commit(); - - stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta_data), - pm, - 100 ); - bulk_data.modification_begin(); - - unsigned nx = 3; - unsigned ny = 3; - - if ( p_rank==0 ) - { - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - } - } - - for ( unsigned iy = 0 ; iy < ny+1 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx+1 ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid ); - double * const coord = stk_classic::mesh::field_data( *coordinates_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - } - - bulk_data.modification_end(); - - if ( p_size>1 ) { - - std::vector ep; - - if ( p_rank==0 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 2 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 3 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 4 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 6 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 7 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 8 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 10 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 2 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 5 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 1 ) ); - } - - bulk_data.modification_begin(); - bulk_data.change_entity_owner( ep ); - bulk_data.modification_end(); - - // output to debug - - ep.clear(); - - if ( p_rank==0 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 1 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 5 ), 1 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 1 ), 1 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 4 ), 1 ) ); - } - else if ( p_rank==1 ) - { - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 10 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 0 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 0 ) ); - - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 0 ) ); - ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 0 ) ); - } - - bulk_data.modification_begin(); - bulk_data.change_entity_owner( ep ); - bulk_data.modification_end(); - } - - return true ; -} - - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.hpp deleted file mode 100644 index d07932cfe0d5..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ChangeOwner.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef TEST_CHANGE_OWNER_HPP -#define TEST_CHANGE_OWNER_HPP - -#include - -#include -#include -#include - -#include -#include - -/*---------------------------------------------------------------------------- - -A. Generate entire mesh on process #0: - - 7-----8-----9 - | | | - | 3 | 4 | - | | | - 4-----5-----6 - | | | - | 1 | 2 | - | | | - 1-----2-----3 ---> X - -B. Move Elements { 3 , 4 } and Nodes { 4 , 5 , 6 , 7 , 8 , 9 } to process #1 - -C. Move Elements { 1 , 2 } and Nodes { 1 , 2 , 3 } to process #1 - -----------------------------------------------------------------------------*/ - -typedef stk_classic::mesh::Field VectorField ; - -class Grid2D_Fixture { -public: - - Grid2D_Fixture( stk_classic::ParallelMachine ); - - unsigned m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData m_fem_meta_data; - stk_classic::mesh::BulkData m_bulk_data; - stk_classic::mesh::Part & m_quad_part; - VectorField & m_coord_field; - const stk_classic::mesh::EntityRank m_elem_rank; - const stk_classic::mesh::EntityRank m_node_rank; - - bool test_change_owner( unsigned nx , unsigned ny ); - - bool test_change_owner() { return test_change_owner(2,2); } -}; - -bool test_change_owner_with_constraint( stk_classic::ParallelMachine pm ); -bool test_change_owner_2( stk_classic::ParallelMachine pm ); -bool test_change_owner_3( stk_classic::ParallelMachine pm ); - -#endif // TEST_CHANGE_OWNER_HPP - diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.cpp deleted file mode 100644 index e30872abf5c3..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -namespace { - -const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; -enum { SpatialDim = 3 }; - -} - -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -bool verify_elem_node_coord( - mesh::Entity & elem , - const ElementNodePointerFieldType & elem_node_coord , - const VectorFieldType & node_coord , - const unsigned node_count ) -{ - bool result = true; - mesh::PairIterRelation rel = elem.relations( NODE_RANK ); - - if( (unsigned) rel.size() != node_count ) { - std::cerr << "Error! relation size == " << rel.size() << " != " - << node_count << " == node count" << std::endl; - result = false; - } - - // Field data for the elem_node_coord for elem - mesh::EntityArray< ElementNodePointerFieldType > - elem_node_array( elem_node_coord , elem ); - - // Checking the size and dimensionality of elem_node_array - { - const unsigned n1 = elem_node_array.dimension<0>(); - if( n1 != node_count ) { - std::cerr << "Error! element node array dimension<0> == " << n1 << " != " - << node_count << " == node count" << std::endl; - result = false; - } - if ( (unsigned) elem_node_array.size() != node_count ) { - std::cerr << "Error! element node array size == " - << elem_node_array.size() << " != " << node_count << " == node count" - << std::endl; - result = false; - } - } - - // Get the raw memory for the entity field array - double * const * const elem_data = elem_node_array.contiguous_data(); - - // Iterating over the nodes in element - for ( unsigned j = 0 ; j < node_count ; ++j ) { - mesh::Entity & node = * rel[j].entity(); - - // Field data for the nodal coordinate field for node - mesh::EntityArray< VectorFieldType > node_coord_array( node_coord , node ); - - // Checking the size and dimensionality of node_coord_array - { - const unsigned n1 = node_coord_array.dimension<0>(); - if( n1 != (unsigned) SpatialDim ) { - std::cerr << "Error! node coord array dimension<0> == " << n1 << " != " - << SpatialDim << " == SpatialDim" << std::endl; - result = false; - } - if( node_coord_array.size() != SpatialDim ) { - std::cerr << "Error! node coord array size == " - << node_coord_array.size() << " != " << SpatialDim - << " == SpatialDim" << std::endl; - result = false; - } - } - - // Confirming that element data points to nodal coordinate data for - // this node - double * const node_data = node_coord_array.contiguous_data(); - if( elem_data[j] != node_data ) { - std::cerr << "Error! elem_data[" << j << "] == " << elem_data[j] - << " != " << node_data << " node_data" << std::endl; - result = false; - } - } - return result; -} - -bool verify_elem_node_coord_by_part( - stk_classic::mesh::Part & part, - const std::vector & bucket_vector, - const ElementNodePointerFieldType & elem_node_coord, - const VectorFieldType & node_coord, - const unsigned node_count ) -{ - Selector selector(part); - std::vector entities; - get_selected_entities( selector, bucket_vector, entities); - std::vector::iterator entity_it = entities.begin(); - bool result = true; - for ( ; entity_it != entities.end() ; ++entity_it ) { - result = result && - verify_elem_node_coord( - **entity_it , elem_node_coord , node_coord , node_count - ); - } - return result; -} - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.hpp deleted file mode 100644 index b5edff742b41..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Common.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Mesh_Use_Cases_UseCase_Common_hpp -#define Stk_Mesh_Use_Cases_UseCase_Common_hpp - -#include -#include -#include - -#include - -namespace stk_classic { -namespace mesh { - -class Entity; -class Part; -class ElementNode; - -namespace use_cases { - -typedef Field VectorFieldType ; -typedef Field ScalarFieldType ; -typedef Field ElementNodePointerFieldType ; - -/** - * For elem with element node pointer field, verify that the - * element node pointer field correctly refers to the vector field - * of its nodes. - */ -bool verify_elem_node_coord( - Entity & elem , - const ElementNodePointerFieldType & elem_node_coord , - const VectorFieldType & node_coord , - const unsigned node_count ); - -/** - * For every element in part and bucket vector verify - * elem node coord. - */ -bool verify_elem_node_coord_by_part( - Part & part, - const std::vector & bucket_vector, - const ElementNodePointerFieldType & elem_node_coord, - const VectorFieldType & node_coord, - const unsigned node_count ); - - -} //namespace use_cases -} //namespace mesh -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_Common_hpp diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath.hpp deleted file mode 100644 index 25cdb34bb64c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef UseCase_ElementDeath_hpp -#define UseCase_ElementDeath_hpp - -#include - -bool element_death_use_case_1(stk_classic::ParallelMachine pm); - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1.cpp deleted file mode 100644 index 51a6ac94dd50..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -/* -The grid fixture creates the mesh below and skins it -1-16 Quadrilateral<4> -17-41 Nodes -skin ids are generated by the distributed index - -Note: "=" and "||" represent side entities. - -17===18===19===20===21 -|| 1 | 2 | 3 | 4 || -22---23---24---25---26 -|| 5 | 6 | 7 | 8 || -27---28---29---30---31 -|| 9 | 10 | 11 | 12 || -32---33---34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -This use case will iteratively erode the mesh. - -Each iteration will move a selection of faces to the 'dead_part" -Create boundaries between live and dead faces -Destroy nodes and sides that are no longer attached to a live face - -0: Init the mesh - -17===18===19===20===21 -|| 1 | 2 | 3 | 4 || -22---23---24---25---26 -|| 5 | 6 | 7 | 8 || -27---28---29---30---31 -|| 9 | 10 | 11 | 12 || -32---33---34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -1: Move 4, 9 and 10 to the dead part - - -17===18===19===20 -|| 1 | 2 | 3 || -22---23---24---25===26 -|| 5 | 6 | 7 | 8 || -27===28===29---30---31 - || 11| 12 || -32===33===34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - - -2: Move faces 2 and 3 to the dead part - -17===18 -|| 1 || -22---23===24===25===26 -|| 5 | 6 | 7 | 8 || -27===28===29---30---31 - || 11| 12 || -32===33===34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -3: Move faces 1 and 11 to the dead part - -22===23===24===25===26 -|| 5 | 6 | 7 | 8 || -27===28===29===30---31 - || 12|| -32===33===34===35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -4: Move faces 6 and 7 to the dead part - -22===23 25===26 -|| 5 || || 8|| -27===28 30---31 - || 12|| -32===33===34===35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -5: Move faces 5 and 16 to the dead part - - 25===26 - || 8|| - 30---31 - || 12|| -32===33===34===35===36 -|| 13| 14 | 15 || -37===38===39===40 - -6: Move the remaining faces to the dead part - - -(this space intentionally left blank) - (nothing to see here) - -*/ - -const int NUM_ITERATIONS = 7; -const int NUM_RANK = 3; - -namespace { - -//Finds the sides that need to be created between the live and dead entities -void find_sides_to_be_created( - const stk_classic::mesh::EntitySideVector & boundary, - const stk_classic::mesh::Selector & select, - std::vector & sides - ); - -//Finds entities from the closure of the entities_to_be_killed -//that only have relations with dead entities -void find_lower_rank_entities_to_kill( - const stk_classic::mesh::EntityVector & entities_closure, - unsigned closure_rank, - unsigned entity_rank, - const stk_classic::mesh::Selector & select_owned, - const stk_classic::mesh::Selector & select_live, - stk_classic::mesh::EntityVector & kill_list - ); - -} - -bool element_death_use_case_1(stk_classic::ParallelMachine pm) -{ - //set up the mesh - stk_classic::mesh::fixtures::GridFixture fixture(pm); - - stk_classic::mesh::BulkData& mesh = fixture.bulk_data(); - stk_classic::mesh::fem::FEMMetaData& fem_meta = fixture.fem_meta(); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - fem_meta.commit(); - - mesh.modification_begin(); - fixture.generate_grid(); - mesh.modification_end(); - - stk_classic::mesh::skin_mesh(mesh, element_rank); - - // Nothing happens on iteration #0, - // so the initial mesh should pass this validation. - - if ( ! validate_iteration( pm, fixture, 0) ) { return false ; } - - stk_classic::mesh::Part & dead_part = *fixture.dead_part(); - - stk_classic::mesh::PartVector dead_parts; - dead_parts.push_back( & dead_part); - - bool passed = true; - - unsigned mesh_rank = element_rank; - - for (int iteration = 0; iteration skin; - find_sides_to_be_created( boundary, select_live_and_owned, skin); - - - mesh.modification_begin(); - - // Kill entities by moving them to the dead part. - for (stk_classic::mesh::EntityVector::iterator itr = entities_to_kill.begin(); - itr != entities_to_kill.end(); ++itr) { - mesh.change_entity_parts(**itr, dead_parts); - } - - - // Ask for new entities to represent the sides between the live and dead entities - // - std::vector requests(fem_meta.entity_rank_count(), 0); - requests[mesh_rank-1] = skin.size(); - - // generate_new_entities creates new blank entities of the requested ranks - stk_classic::mesh::EntityVector requested_entities; - mesh.generate_new_entities(requests, requested_entities); - - // Create boundaries between live and dead entities - // by creating a relation between the new entities and the live entities - for ( size_t i = 0; i < skin.size(); ++i) { - stk_classic::mesh::Entity & entity = *(skin[i].entity); - const unsigned side_ordinal = skin[i].side_ordinal; - stk_classic::mesh::Entity & side = * (requested_entities[i]); - - stk_classic::mesh::fem::declare_element_side(entity, side, side_ordinal); - } - - mesh.modification_end(); - //the modification_end() will communicate which entities have been changed - //to other processes. - - //find lower ranked entity that are only related to the dead entities - //and kill them - for (int rank = mesh_rank -1; rank >= 0; --rank) { - stk_classic::mesh::EntityVector kill_list; - find_lower_rank_entities_to_kill( - entities_closure, - mesh_rank, - rank, - select_owned, - select_live, - kill_list - ); - - //need to communicate killing the higher ranking entities among - //processors before killing the lower. - mesh.modification_begin(); - for (stk_classic::mesh::EntityVector::iterator itr = kill_list.begin(); - itr != kill_list.end(); ++itr) { - mesh.change_entity_parts(**itr, dead_parts); - } - mesh.modification_end(); - } - - - passed &= validate_iteration( pm, fixture, iteration); - } - - return passed; -} - -//---------------------------------------------------------------------------------- -namespace { - -//---------------------------------------------------------------------------------- -void find_sides_to_be_created( - const stk_classic::mesh::EntitySideVector & boundary, - const stk_classic::mesh::Selector & select, - std::vector & sides - ) -{ - //look at the outside of the boundary since the inside will be kill this - //iteration - - for (stk_classic::mesh::EntitySideVector::const_iterator itr = boundary.begin(); - itr != boundary.end(); ++itr) { - - const stk_classic::mesh::EntitySideComponent & outside = itr->outside; - - - // examine the boundary of the outside of the closure. - if ( outside.entity != NULL && select(*(outside.entity)) ) { - - //make sure the side does not already exist - const unsigned side_ordinal = outside.side_ordinal; - const stk_classic::mesh::Entity & entity = * outside.entity; - stk_classic::mesh::PairIterRelation existing_sides = entity.relations(entity.entity_rank()-1); - - for (; existing_sides.first != existing_sides.second && - existing_sides.first->identifier() != side_ordinal ; - ++existing_sides.first); - - //reached the end -- a new side needs to be created - if (existing_sides.first == existing_sides.second) { - sides.push_back(outside); - } - } - } -} - -//---------------------------------------------------------------------------------- -void find_lower_rank_entities_to_kill( - const stk_classic::mesh::EntityVector & entities_closure, - unsigned mesh_rank, - unsigned entity_rank, - const stk_classic::mesh::Selector & select_owned, - const stk_classic::mesh::Selector & select_live, - stk_classic::mesh::EntityVector & kill_list - ) -{ - - kill_list.clear(); - - //find the first entity in the closure - stk_classic::mesh::EntityVector::const_iterator itr = std::lower_bound(entities_closure.begin(), - entities_closure.end(), - stk_classic::mesh::EntityKey(entity_rank, 0), - stk_classic::mesh::EntityLess()); - - const stk_classic::mesh::EntityVector::const_iterator end = std::lower_bound(entities_closure.begin(), - entities_closure.end(), - stk_classic::mesh::EntityKey(entity_rank+1, 0), - stk_classic::mesh::EntityLess()); - - for (; itr != end; ++itr) { - stk_classic::mesh::Entity & entity = **itr; - - if (select_owned(entity.bucket())) { - bool found_live = false; - - for(unsigned rank = entity_rank + 1; rank<=mesh_rank && !found_live; ++rank) { - - stk_classic::mesh::PairIterRelation relations_pair = entity.relations(rank); - - for (; relations_pair.first != relations_pair.second && !found_live; ++relations_pair.first) { - - if( select_live(*relations_pair.first->entity())) { - found_live = true; - } - } - } - - if (!found_live) { - kill_list.push_back(&entity); - } - } - } - -} - -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1_validation_helpers.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1_validation_helpers.cpp deleted file mode 100644 index fa3455f33cc8..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_ElementDeath_1_validation_helpers.cpp +++ /dev/null @@ -1,637 +0,0 @@ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* -The grid fixture creates the mesh below and skins it -1-16 Quadrilateral<4> -17-41 Nodes -skin ids are generated by the distributed index - -Note: "=" and "||" represent side entities. - -17===18===19===20===21 -|| 1 | 2 | 3 | 4 || -22---23---24---25---26 -|| 5 | 6 | 7 | 8 || -27---28---29---30---31 -|| 9 | 10 | 11 | 12 || -32---33---34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -This use case will iteratively erode the mesh. - -Each iteration will move a selection of faces to the 'dead_part" -Create boundaries between live and dead faces -Destroy nodes and sides that are no longer attached to a live face - -0: Init the mesh - -17===18===19===20===21 -|| 1 | 2 | 3 | 4 || -22---23---24---25---26 -|| 5 | 6 | 7 | 8 || -27---28---29---30---31 -|| 9 | 10 | 11 | 12 || -32---33---34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -1: Move 4, 9 and 10 to the dead part - - -17===18===19===20 -|| 1 | 2 | 3 || -22---23---24---25===26 -|| 5 | 6 | 7 | 8 || -27===28===29---30---31 - || 11| 12 || -32===33===34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - - -2: Move faces 2 and 3 to the dead part - -17===18 -|| 1 || -22---23===24===25===26 -|| 5 | 6 | 7 | 8 || -27===28===29---30---31 - || 11| 12 || -32===33===34---35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -3: Move faces 1 and 11 to the dead part - -22===23===24===25===26 -|| 5 | 6 | 7 | 8 || -27===28===29===30---31 - || 12|| -32===33===34===35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -4: Move faces 6 and 7 to the dead part - -22===23 25===26 -|| 5 || || 8|| -27===28 30---31 - || 12|| -32===33===34===35---36 -|| 13| 14 | 15 | 16 || -37===38===39===40===41 - -5: Move faces 5 and 16 to the dead part - - 25===26 - || 8|| - 30---31 - || 12|| -32===33===34===35===36 -|| 13| 14 | 15 || -37===38===39===40 - -6: Move the remaining faces to the dead part - - -(this space intentionally left blank) - (nothing to see here) - -*/ - -const int NUM_ITERATIONS = 7; -const int NUM_RANK = 3; - -typedef std::vector EntityVector; - -// Validation constants: -const int global_num_dead[NUM_ITERATIONS][NUM_RANK] = -{ //nodes edges faces - {0, 0, 0 }, //0 - {1, 3, 3 }, //1 - {3, 6, 5 }, //2 - {5, 10, 7 }, //3 - {7, 14, 9 }, //4 - {12, 20, 11}, //5 - {25, 34, 16} //6 -}; - -// Validation constants: -const int global_num_live[NUM_ITERATIONS][NUM_RANK] = -{ //nodes edges faces - {25, 16, 16}, //0 - {24, 20, 13}, //1 - {22, 20, 11}, //2 - {20, 20, 9 }, //3 - {18, 18, 7 }, //4 - {13, 14, 5 }, //5 - {0, 0, 0 } //6 -}; - -//---------------------------------------------------------------------------------- - -//Generates a vector of entities to be killed in this iteration -EntityVector entities_to_be_killed( - const stk_classic::mesh::BulkData & mesh, - int iteration, - stk_classic::mesh::EntityRank entity_rank - ) { - - std::vector entity_ids_to_kill; - switch(iteration) { - case 0: - break; - case 1: - entity_ids_to_kill.push_back(4); - entity_ids_to_kill.push_back(9); - entity_ids_to_kill.push_back(10); - break; - case 2: - entity_ids_to_kill.push_back(2); - entity_ids_to_kill.push_back(3); - break; - case 3: - entity_ids_to_kill.push_back(1); - entity_ids_to_kill.push_back(11); - break; - case 4: - entity_ids_to_kill.push_back(6); - entity_ids_to_kill.push_back(7); - break; - case 5: - entity_ids_to_kill.push_back(5); - entity_ids_to_kill.push_back(16); - break; - case 6: - entity_ids_to_kill.push_back(8); - entity_ids_to_kill.push_back(12); - entity_ids_to_kill.push_back(13); - entity_ids_to_kill.push_back(14); - entity_ids_to_kill.push_back(15); - break; - default: - break; - } - - EntityVector entities_to_kill; - for (std::vector::const_iterator itr = entity_ids_to_kill.begin(); - itr != entity_ids_to_kill.end(); ++itr) { - stk_classic::mesh::Entity * temp = mesh.get_entity(entity_rank, *itr); - //select the entity only if the current process in the owner - if (temp != NULL && temp->owner_rank() == mesh.parallel_rank()) { - entities_to_kill.push_back(temp); - } - } - return entities_to_kill; -} - - -//---------------------------------------------------------------------------------- -namespace { - struct entity_side{ - - unsigned entity_id; - unsigned side_ordinal; - - entity_side( unsigned e, unsigned s) - : entity_id(e), side_ordinal(s) {} - }; -} - -bool validate_sides( stk_classic::mesh::fixtures::GridFixture & fixture, int iteration) -{ - enum { - LEFT = 0, - BOTTOM = 1, - RIGHT = 2, - TOP = 3 - }; - - std::vector live_sides, dead_sides; - switch(iteration) - { - case 0: - { - /* - 17===18===19===20===21 - || 1 | 2 | 3 | 4 || - 22---23---24---25---26 - || 5 | 6 | 7 | 8 || - 27---28---29---30---31 - || 9 | 10 | 11 | 12 || - 32---33---34---35---36 - || 13| 14 | 15 | 16 || - 37===38===39===40===41 - */ - live_sides.push_back(entity_side(1,TOP)); - live_sides.push_back(entity_side(2,TOP)); - live_sides.push_back(entity_side(3,TOP)); - live_sides.push_back(entity_side(4,TOP)); - live_sides.push_back(entity_side(4,RIGHT)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(16,RIGHT)); - live_sides.push_back(entity_side(16,BOTTOM)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(9,LEFT)); - live_sides.push_back(entity_side(5,LEFT)); - live_sides.push_back(entity_side(1,LEFT)); - } - break; - - case 1: - { - /* - 17===18===19===20 - || 1 | 2 | 3 || - 22---23---24---25===26 - || 5 | 6 | 7 | 8 || - 27===28===29---30---31 - || 11| 12 || - 32===33===34---35---36 - || 13| 14 | 15 | 16 || - 37===38===39===40===41 - */ - live_sides.push_back(entity_side(1,TOP)); - live_sides.push_back(entity_side(2,TOP)); - live_sides.push_back(entity_side(3,TOP)); - live_sides.push_back(entity_side(3,RIGHT)); - live_sides.push_back(entity_side(8,TOP)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(16,RIGHT)); - live_sides.push_back(entity_side(16,BOTTOM)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(13,TOP)); - live_sides.push_back(entity_side(14,TOP)); - live_sides.push_back(entity_side(11,LEFT)); - live_sides.push_back(entity_side(6,BOTTOM)); - live_sides.push_back(entity_side(5,BOTTOM)); - live_sides.push_back(entity_side(5,LEFT)); - live_sides.push_back(entity_side(1,LEFT)); - - - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(9,LEFT)); - } - break; - - case 2: - { - /* - 17===18 - || 1 || - 22---23===24===25===26 - || 5 | 6 | 7 | 8 || - 27===28===29---30---31 - || 11| 12 || - 32===33===34---35---36 - || 13| 14 | 15 | 16 || - 37===38===39===40===41 - */ - live_sides.push_back(entity_side(1,TOP)); - live_sides.push_back(entity_side(1,RIGHT)); - live_sides.push_back(entity_side(6,TOP)); - live_sides.push_back(entity_side(7,TOP)); - live_sides.push_back(entity_side(8,TOP)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(16,RIGHT)); - live_sides.push_back(entity_side(16,BOTTOM)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(13,TOP)); - live_sides.push_back(entity_side(14,TOP)); - live_sides.push_back(entity_side(11,LEFT)); - live_sides.push_back(entity_side(6,BOTTOM)); - live_sides.push_back(entity_side(5,BOTTOM)); - live_sides.push_back(entity_side(5,LEFT)); - live_sides.push_back(entity_side(1,LEFT)); - - - dead_sides.push_back(entity_side(2,TOP)); - dead_sides.push_back(entity_side(3,TOP)); - dead_sides.push_back(entity_side(3,RIGHT)); - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(9,LEFT)); - } - break; - - case 3: - { - /* - 22===23===24===25===26 - || 5 | 6 | 7 | 8 || - 27===28===29===30---31 - || 12|| - 32===33===34===35---36 - || 13| 14 | 15 | 16 || - 37===38===39===40===41 - */ - live_sides.push_back(entity_side(5,TOP)); - live_sides.push_back(entity_side(6,TOP)); - live_sides.push_back(entity_side(7,TOP)); - live_sides.push_back(entity_side(8,TOP)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(16,RIGHT)); - live_sides.push_back(entity_side(16,BOTTOM)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(13,TOP)); - live_sides.push_back(entity_side(14,TOP)); - live_sides.push_back(entity_side(15,TOP)); - live_sides.push_back(entity_side(12,LEFT)); - live_sides.push_back(entity_side(7,BOTTOM)); - live_sides.push_back(entity_side(6,BOTTOM)); - live_sides.push_back(entity_side(5,BOTTOM)); - live_sides.push_back(entity_side(5,LEFT)); - - - dead_sides.push_back(entity_side(1,LEFT)); - dead_sides.push_back(entity_side(1,TOP)); - dead_sides.push_back(entity_side(1,RIGHT)); - dead_sides.push_back(entity_side(2,TOP)); - dead_sides.push_back(entity_side(3,TOP)); - dead_sides.push_back(entity_side(3,RIGHT)); - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(9,LEFT)); - dead_sides.push_back(entity_side(11,LEFT)); - - } - break; - - case 4: - { - /* - 22===23 25===26 - || 5 || || 8|| - 27===28 30---31 - || 12|| - 32===33===34===35---36 - || 13| 14 | 15 | 16 || - 37===38===39===40===41 - */ - live_sides.push_back(entity_side(5,LEFT)); - live_sides.push_back(entity_side(5,BOTTOM)); - live_sides.push_back(entity_side(5,RIGHT)); - live_sides.push_back(entity_side(5,TOP)); - - live_sides.push_back(entity_side(8,TOP)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(16,RIGHT)); - live_sides.push_back(entity_side(16,BOTTOM)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(13,TOP)); - live_sides.push_back(entity_side(14,TOP)); - live_sides.push_back(entity_side(15,TOP)); - live_sides.push_back(entity_side(12,LEFT)); - live_sides.push_back(entity_side(8,LEFT)); - - - dead_sides.push_back(entity_side(1,LEFT)); - dead_sides.push_back(entity_side(1,RIGHT)); - dead_sides.push_back(entity_side(1,TOP)); - dead_sides.push_back(entity_side(2,TOP)); - dead_sides.push_back(entity_side(3,RIGHT)); - dead_sides.push_back(entity_side(3,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(6,BOTTOM)); - dead_sides.push_back(entity_side(6,TOP)); - dead_sides.push_back(entity_side(7,BOTTOM)); - dead_sides.push_back(entity_side(7,TOP)); - dead_sides.push_back(entity_side(9,LEFT)); - dead_sides.push_back(entity_side(11,LEFT)); - } - break; - - case 5: - { - /* - 25===26 - || 8|| - 30---31 - || 12|| - 32===33===34===35===36 - || 13| 14 | 15 || - 37===38===39===40 - */ - live_sides.push_back(entity_side(8,TOP)); - live_sides.push_back(entity_side(8,RIGHT)); - live_sides.push_back(entity_side(12,RIGHT)); - live_sides.push_back(entity_side(12,BOTTOM)); - live_sides.push_back(entity_side(15,RIGHT)); - live_sides.push_back(entity_side(15,BOTTOM)); - live_sides.push_back(entity_side(14,BOTTOM)); - live_sides.push_back(entity_side(13,BOTTOM)); - live_sides.push_back(entity_side(13,LEFT)); - live_sides.push_back(entity_side(13,TOP)); - live_sides.push_back(entity_side(14,TOP)); - live_sides.push_back(entity_side(15,TOP)); - live_sides.push_back(entity_side(12,LEFT)); - live_sides.push_back(entity_side(8,LEFT)); - - - dead_sides.push_back(entity_side(1,LEFT)); - dead_sides.push_back(entity_side(1,RIGHT)); - dead_sides.push_back(entity_side(1,TOP)); - dead_sides.push_back(entity_side(2,TOP)); - dead_sides.push_back(entity_side(3,RIGHT)); - dead_sides.push_back(entity_side(3,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(5,LEFT)); - dead_sides.push_back(entity_side(5,BOTTOM)); - dead_sides.push_back(entity_side(5,RIGHT)); - dead_sides.push_back(entity_side(5,TOP)); - dead_sides.push_back(entity_side(6,BOTTOM)); - dead_sides.push_back(entity_side(6,TOP)); - dead_sides.push_back(entity_side(7,BOTTOM)); - dead_sides.push_back(entity_side(7,TOP)); - dead_sides.push_back(entity_side(9,LEFT)); - dead_sides.push_back(entity_side(11,LEFT)); - dead_sides.push_back(entity_side(16,RIGHT)); - dead_sides.push_back(entity_side(16,BOTTOM)); - } - break; - - case 6: - { - /* (All dead) */ - dead_sides.push_back(entity_side(1,LEFT)); - dead_sides.push_back(entity_side(1,RIGHT)); - dead_sides.push_back(entity_side(1,TOP)); - dead_sides.push_back(entity_side(2,TOP)); - dead_sides.push_back(entity_side(3,RIGHT)); - dead_sides.push_back(entity_side(3,TOP)); - dead_sides.push_back(entity_side(4,RIGHT)); - dead_sides.push_back(entity_side(4,TOP)); - dead_sides.push_back(entity_side(5,LEFT)); - dead_sides.push_back(entity_side(5,BOTTOM)); - dead_sides.push_back(entity_side(5,RIGHT)); - dead_sides.push_back(entity_side(5,TOP)); - dead_sides.push_back(entity_side(6,BOTTOM)); - dead_sides.push_back(entity_side(6,TOP)); - dead_sides.push_back(entity_side(7,BOTTOM)); - dead_sides.push_back(entity_side(7,TOP)); - dead_sides.push_back(entity_side(8,LEFT)); - dead_sides.push_back(entity_side(8,TOP)); - dead_sides.push_back(entity_side(8,RIGHT)); - dead_sides.push_back(entity_side(9,LEFT)); - dead_sides.push_back(entity_side(11,LEFT)); - dead_sides.push_back(entity_side(12,RIGHT)); - dead_sides.push_back(entity_side(12,BOTTOM)); - dead_sides.push_back(entity_side(12,LEFT)); - dead_sides.push_back(entity_side(13,BOTTOM)); - dead_sides.push_back(entity_side(13,LEFT)); - dead_sides.push_back(entity_side(13,TOP)); - dead_sides.push_back(entity_side(14,BOTTOM)); - dead_sides.push_back(entity_side(14,TOP)); - dead_sides.push_back(entity_side(15,RIGHT)); - dead_sides.push_back(entity_side(15,BOTTOM)); - dead_sides.push_back(entity_side(15,TOP)); - dead_sides.push_back(entity_side(16,RIGHT)); - dead_sides.push_back(entity_side(16,BOTTOM)); - } - break; - - default: - break; - } - - stk_classic::mesh::BulkData& mesh = fixture.bulk_data(); - stk_classic::mesh::Part & dead_part = *fixture.dead_part(); - const stk_classic::mesh::EntityRank element_rank = fixture.fem_meta().element_rank(); - - // Select live or dead from owned, shared, and ghosted - stk_classic::mesh::Selector select_dead = dead_part ; - stk_classic::mesh::Selector select_live = !dead_part ; - - //check live sides - for (std::vector::const_iterator itr = live_sides.begin(); - itr != live_sides.end(); ++itr) { - stk_classic::mesh::Entity * entity = mesh.get_entity(element_rank, itr->entity_id); - if (entity != NULL) { - //make sure the side exist - const unsigned side_ordinal = itr->side_ordinal; - stk_classic::mesh::PairIterRelation existing_sides = entity->relations(entity->entity_rank()-1); - - for (; existing_sides.first != existing_sides.second && - existing_sides.first->identifier() != side_ordinal ; - ++existing_sides.first); - - //reached the end or side is not live - if (existing_sides.first == existing_sides.second || !select_live( *(existing_sides.first->entity())) ) - { - return false; - } - } - } - - //check dead sides - for (std::vector::const_iterator itr = dead_sides.begin(); - itr != dead_sides.end(); ++itr) { - stk_classic::mesh::Entity * entity = mesh.get_entity(element_rank, itr->entity_id); - //select the entity only if the current process in the owner - // TODO fix the aura to correctly ghost the sides - if (entity != NULL && entity->owner_rank() == mesh.parallel_rank()) { - //if (entity != NULL) { - //make sure the side exist - const unsigned side_ordinal = itr->side_ordinal; - stk_classic::mesh::PairIterRelation existing_sides = entity->relations(entity->entity_rank()-1); - - for (; existing_sides.first != existing_sides.second && - existing_sides.first->identifier() != side_ordinal ; - ++existing_sides.first); - - //reached the end or side is not dead - if (existing_sides.first == existing_sides.second || !select_dead( *(existing_sides.first->entity())) ) - { - return false; - } - } - } - - - return true; -} - - - - -//---------------------------------------------------------------------------------- - - -//Validates that the correct entites were killed in this iteration -bool validate_iteration( stk_classic::ParallelMachine pm, stk_classic::mesh::fixtures::GridFixture & fixture, int iteration) { - - if (iteration >= NUM_ITERATIONS || iteration < 0) { - return false; - } - - stk_classic::mesh::BulkData& mesh = fixture.bulk_data(); - stk_classic::mesh::fem::FEMMetaData& fem_meta = fixture.fem_meta(); - - stk_classic::mesh::Part & dead_part = *fixture.dead_part(); - - stk_classic::mesh::Selector select_dead = dead_part & fem_meta.locally_owned_part(); - stk_classic::mesh::Selector select_live = !dead_part & fem_meta.locally_owned_part(); - - int num_dead[NUM_RANK] = {0, 0, 0}; - int num_live[NUM_RANK] = {0, 0, 0}; - - for ( int i = 0; i < NUM_RANK ; ++i) { - const std::vector& buckets = mesh.buckets( stk_classic::mesh::EntityRank(i) ); - num_dead[i] = count_selected_entities( select_dead, buckets); - num_live[i] = count_selected_entities( select_live, buckets); - } - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<3>(num_dead) & stk_classic::ReduceSum<3>(num_live)); - - bool correct_dead = true; - bool correct_live = true; - - for (int i=0; i - - -namespace stk_classic { -namespace mesh { - -class Entity; -class BulkData; - -namespace fixtures { - -class GridFixture; - -} - -} -} - -//Generates a vector of entities to be killed in this iteration -std::vector entities_to_be_killed( - const stk_classic::mesh::BulkData & mesh, - int iteration, - stk_classic::mesh::EntityRank entity_rank - ); - -//Validates that the correct entites were killed in this iteration -bool validate_iteration( - stk_classic::ParallelMachine pm, - stk_classic::mesh::fixtures::GridFixture & fixture, - int iteration - ); - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.cpp deleted file mode 100644 index d5314e30173c..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -namespace { - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -void find_owned_nodes_with_relations_outside_closure( - stk_classic::mesh::EntityVector & closure, - stk_classic::mesh::Selector select_owned, - stk_classic::mesh::EntityVector & nodes) -{ - nodes.clear(); - - //the closure is a sorted unique vector - const stk_classic::mesh::EntityRank upward_rank = NODE_RANK + 1; - const stk_classic::mesh::EntityId base_id = 0; - stk_classic::mesh::EntityVector::iterator node_end = std::lower_bound(closure.begin(), - closure.end(), - stk_classic::mesh::EntityKey(upward_rank, base_id), - stk_classic::mesh::EntityLess()); - - for (stk_classic::mesh::EntityVector::iterator itr = closure.begin(); itr != node_end; ++itr) { - stk_classic::mesh::Entity & node = **itr; - - if (select_owned(node)) { - stk_classic::mesh::PairIterRelation relations_pair = node.relations(); - - //loop over the relations and check to see if they are in the closure - for (; relations_pair.first != relations_pair.second; ++relations_pair.first) { - stk_classic::mesh::Entity * current_entity = (relations_pair.first->entity()); - - //has relation outside of closure - if ( !std::binary_search(node_end, - closure.end(), - current_entity, - stk_classic::mesh::EntityLess()) ) - { - nodes.push_back(&node); - break; - } - } - } - } -} - -void copy_nodes_and_break_relations( stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::EntityVector & closure, - stk_classic::mesh::EntityVector & nodes, - stk_classic::mesh::EntityVector & new_nodes) -{ - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity * entity = nodes[i]; - stk_classic::mesh::Entity * new_entity = new_nodes[i]; - - stk_classic::mesh::PairIterRelation relations_pair = entity->relations(); - - std::vector sides; - - //loop over the relations and check to see if they are in the closure - for (; relations_pair.first != relations_pair.second;) { - --relations_pair.second; - stk_classic::mesh::Entity * current_entity = (relations_pair.second->entity()); - unsigned side_ordinal = relations_pair.second->identifier(); - - if (stk_classic::mesh::in_receive_ghost(*current_entity)) { - // TODO deleteing the ghost triggers a logic error at the - // end of the NEXT modification cycle. We need to fix this! - //mesh.destroy_entity(current_entity); - continue; - } - // check if has relation in closure - else if ( std::binary_search(closure.begin(), - closure.end(), - current_entity, - stk_classic::mesh::EntityLess()) ) - { - sides.push_back(stk_classic::mesh::EntitySideComponent(current_entity,side_ordinal)); - } - } - - //loop over the sides and break the relations between the old nodes - //and set up the relations with the new - for ( std::vector::iterator - itr = sides.begin(); itr != sides.end(); ++itr) { - mesh.destroy_relation(*(itr->entity), *entity, itr->side_ordinal); - mesh.declare_relation(*(itr->entity), *new_entity, itr->side_ordinal); - } - - //copy non-induced part membership from nodes[i] to new_nodes[i] - //there are NO non-induced parts for this example - - //copy field data from nodes[i] to new_nodes[i] - mesh.copy_entity_fields( *entity, *new_entity); - - if (entity->relations().empty()) { - mesh.destroy_entity(entity); - } - - if (new_entity->relations().empty()) { - mesh.destroy_entity(new_entity); - } - - - } - -} - -void communicate_and_create_shared_nodes( stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::EntityVector & nodes, - stk_classic::mesh::EntityVector & new_nodes) -{ - - - stk_classic::CommAll comm(mesh.parallel()); - - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity & node = *nodes[i]; - stk_classic::mesh::Entity & new_node = *new_nodes[i]; - - stk_classic::mesh::PairIterEntityComm entity_comm = node.sharing(); - - for (; entity_comm.first != entity_comm.second; ++entity_comm.first) { - - unsigned proc = entity_comm.first->proc; - comm.send_buffer(proc).pack(node.key()) - .pack(new_node.key()); - - } - } - - comm.allocate_buffers( mesh.parallel_size()/4 ); - - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity & node = *nodes[i]; - stk_classic::mesh::Entity & new_node = *new_nodes[i]; - - stk_classic::mesh::PairIterEntityComm entity_comm = node.sharing(); - - for (; entity_comm.first != entity_comm.second; ++entity_comm.first) { - - unsigned proc = entity_comm.first->proc; - comm.send_buffer(proc).pack(node.key()) - .pack(new_node.key()); - - } - } - - comm.communicate(); - - const stk_classic::mesh::PartVector no_parts; - - for (size_t process = 0; process < mesh.parallel_size(); ++process) { - stk_classic::mesh::EntityKey old_key; - stk_classic::mesh::EntityKey new_key; - - while ( comm.recv_buffer(process).remaining()) { - - comm.recv_buffer(process).unpack(old_key) - .unpack(new_key); - - stk_classic::mesh::Entity * old_entity = mesh.get_entity(old_key); - stk_classic::mesh::Entity * new_entity = & mesh.declare_entity(new_key.rank(), new_key.id(), no_parts); - - nodes.push_back(old_entity); - new_nodes.push_back(new_entity); - - } - } -} - -} // empty namespace - -void separate_and_skin_mesh( - stk_classic::mesh::fem::FEMMetaData & fem_meta, - stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::Part & skin_part, - std::vector< stk_classic::mesh::EntityId > elements_to_separate, - const stk_classic::mesh::EntityRank rank_of_element - ) -{ - stk_classic::mesh::EntityVector entities_to_separate; - - //select the entity only if the current process in the owner - for (std::vector< stk_classic::mesh::EntityId>::const_iterator itr = elements_to_separate.begin(); - itr != elements_to_separate.end(); ++itr) - { - stk_classic::mesh::Entity * element = mesh.get_entity(rank_of_element, *itr); - if (element != NULL && element->owner_rank() == mesh.parallel_rank()) { - entities_to_separate.push_back(element); - } - } - - stk_classic::mesh::EntityVector entities_closure; - stk_classic::mesh::find_closure(mesh, - entities_to_separate, - entities_closure); - - stk_classic::mesh::Selector select_owned = fem_meta.locally_owned_part(); - - stk_classic::mesh::EntityVector nodes; - find_owned_nodes_with_relations_outside_closure( entities_closure, select_owned, nodes); - - //ask for new nodes to represent the copies - std::vector requests(fem_meta.entity_rank_count(), 0); - requests[NODE_RANK] = nodes.size(); - - mesh.modification_begin(); - - // generate_new_entities creates new blank entities of the requested ranks - stk_classic::mesh::EntityVector new_nodes; - mesh.generate_new_entities(requests, new_nodes); - - //communicate and create new nodes everywhere the old node is shared - communicate_and_create_shared_nodes(mesh, nodes, new_nodes); - - copy_nodes_and_break_relations(mesh, entities_closure, nodes, new_nodes); - - mesh.modification_end(); - - skin_mesh( mesh, rank_of_element, &skin_part); - - return; -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.hpp deleted file mode 100644 index ebab3a6d895f..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_UseCase_Skinning_hpp -#define stk_mesh_UseCase_Skinning_hpp - -#include - -#include - -#include -#include - - -bool skinning_use_case_1(stk_classic::ParallelMachine pm); -bool skinning_use_case_1b(stk_classic::ParallelMachine pm); -bool skinning_use_case_2(stk_classic::ParallelMachine pm); - - -void separate_and_skin_mesh( - stk_classic::mesh::fem::FEMMetaData & fem_meta, - stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::Part & skin_part, - std::vector< stk_classic::mesh::EntityId > elements_to_separate, - const stk_classic::mesh::EntityRank rank_of_element - ); - -#endif diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1.cpp deleted file mode 100644 index ae6cd50a63e7..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -namespace { - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -unsigned count_skin_entities( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Part & skin_part, stk_classic::mesh::EntityRank skin_rank ) -{ - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(mesh); - - stk_classic::mesh::Selector select_skin = skin_part & meta.locally_owned_part() ; - - const std::vector& buckets = mesh.buckets( skin_rank ); - - return count_selected_entities( select_skin, buckets); -} - -} // empty namespace - -bool skinning_use_case_1(stk_classic::ParallelMachine pm) -{ - bool passed = true; - { - //setup the mesh - stk_classic::mesh::fixtures::HexFixture fixture(pm,3,3,3); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = fixture.m_fem_meta; - stk_classic::mesh::BulkData & mesh = fixture.m_bulk_data; - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank side_rank = fem_meta.side_rank(); - - stk_classic::mesh::Part & skin_part = fem_meta.declare_part("skin_part"); - fem_meta.commit(); - - fixture.generate_mesh(); - - skin_mesh(mesh, element_rank, &skin_part); - - std::vector< stk_classic::mesh::EntityId > elements_to_separate; - - //separate out the middle element - elements_to_separate.push_back(fixture.elem_id(1,1,1)); - - separate_and_skin_mesh( - fem_meta, - mesh, - skin_part, - elements_to_separate, - element_rank - ); - - // pointer to middle_element after mesh modification. - stk_classic::mesh::Entity * middle_element = mesh.get_entity(element_rank, fixture.elem_id(1,1,1)); - - unsigned num_skin_entities = count_skin_entities(mesh, skin_part, side_rank); - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<1>(&num_skin_entities)); - - //there should be 66 faces in the skin part - //54 on the outside - //6 on the inside attached to the entire mesh - //6 on the inside attected to the element that was detached - bool correct_skin = ( num_skin_entities == 66 ); - bool correct_relations = true; - bool correct_comm = true; - - //all nodes connected to the single element that has been broken off - //should have relations.size() == 4 and comm.size() == 0 - if (middle_element != NULL && middle_element->owner_rank() == mesh.parallel_rank()) { - - stk_classic::mesh::PairIterRelation relations = middle_element->relations(NODE_RANK); - - for (; relations.first != relations.second; ++relations.first) { - stk_classic::mesh::Entity * current_node = (relations.first->entity()); - //each node should be attached to only 1 element and 3 faces - correct_relations &= ( current_node->relations().size() == 4 ); - //the entire closure of the element should exist on a single process - correct_comm &= ( current_node->comm().size() == 0 ); - } - } - passed &= (correct_skin && correct_relations && correct_comm); - } - - //seperate the entire middle layer of the mesh - { - //setup the mesh - stk_classic::mesh::fixtures::HexFixture fixture(pm,3,3,3); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = fixture.m_fem_meta; - stk_classic::mesh::BulkData & mesh = fixture.m_bulk_data; - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank side_rank = fem_meta.side_rank(); - - stk_classic::mesh::Part & skin_part = fem_meta.declare_part("skin_part"); - fem_meta.commit(); - - fixture.generate_mesh(); - - skin_mesh(mesh, element_rank, &skin_part); - - std::vector< stk_classic::mesh::EntityId > elements_to_separate; - - //separate out the middle level - elements_to_separate.push_back(fixture.elem_id(1,0,0)); - elements_to_separate.push_back(fixture.elem_id(1,0,1)); - elements_to_separate.push_back(fixture.elem_id(1,0,2)); - elements_to_separate.push_back(fixture.elem_id(1,1,0)); - elements_to_separate.push_back(fixture.elem_id(1,1,1)); - elements_to_separate.push_back(fixture.elem_id(1,1,2)); - elements_to_separate.push_back(fixture.elem_id(1,2,0)); - elements_to_separate.push_back(fixture.elem_id(1,2,1)); - elements_to_separate.push_back(fixture.elem_id(1,2,2)); - - separate_and_skin_mesh( - fem_meta, - mesh, - skin_part, - elements_to_separate, - element_rank - ); - - // pointer to middle_element after mesh modification. - unsigned num_skin_entities = count_skin_entities(mesh, skin_part, side_rank); - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<1>(&num_skin_entities)); - - //there should be 90 faces in the skin part - //30 attached to each level of the mesh - bool correct_skin = ( num_skin_entities == 90 ); - - passed &= correct_skin; - } - - return passed; -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1b.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1b.cpp deleted file mode 100644 index d86a021274ff..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_1b.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -namespace { - -void destroy_entity_and_create_particles( - stk_classic::mesh::fixtures::HexFixture & fixture, - stk_classic::mesh::Part & skin_part, - stk_classic::mesh::Entity * elem - ) -{ - stk_classic::mesh::fem::FEMMetaData &fem_meta = fixture.m_fem_meta; - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - const unsigned p_rank = fixture.m_bulk_data.parallel_rank(); - - fixture.m_bulk_data.modification_begin(); - const stk_classic::mesh::EntityRank particle_rank = element_rank; - - // forumlate request for 8 particles on owning process - std::vector requests(fixture.m_fem_meta.entity_rank_count(), 0); - if ( elem != NULL && p_rank == elem->owner_rank() ) { - requests[particle_rank] = 8; - } - - // create the particles - stk_classic::mesh::EntityVector new_particles; - fixture.m_bulk_data.generate_new_entities(requests, new_particles); - - if ( ! new_particles.empty() ) { - // Get node relations - stk_classic::mesh::PairIterRelation relations = elem->relations(); - - std::vector add_parts; - add_parts.push_back(&skin_part); - - // iterate over the new particles - for (unsigned i = 0; i != 8; ++i) { - // add the particles to the skin_part - fixture.m_bulk_data.change_entity_parts( *new_particles[i], - add_parts ); - // copy fields from nodes to particles - fixture.m_bulk_data.copy_entity_fields( *(relations[i].entity()), - *new_particles[i] ); - } - } - - // delete element and entities in closure that have been orphaned - if ( elem != NULL ) { - stk_classic::mesh::PairIterRelation relations = elem->relations(); - stk_classic::mesh::EntityVector downward_relations; - - for (; relations.first != relations.second;) { - --relations.second; - stk_classic::mesh::Entity * current_entity = (relations.second->entity()); - - downward_relations.push_back(current_entity); - } - - fixture.m_bulk_data.destroy_entity( elem ); - - // destroy the related entities if they are not connected to any - // higher order entities - for (stk_classic::mesh::EntityVector::iterator itr = downward_relations.begin(); - itr != downward_relations.end(); ++itr) { - stk_classic::mesh::Entity * current_entity = *itr; - - if (current_entity->relations(element_rank).empty()) { - fixture.m_bulk_data.destroy_entity( current_entity ); - } - } - } - - fixture.m_bulk_data.modification_end(); - - stk_classic::mesh::skin_mesh( fixture.m_bulk_data, element_rank, &skin_part); -} - -} - -bool skinning_use_case_1b(stk_classic::ParallelMachine pm) -{ - const unsigned nx = 3 , ny = 3 , nz = 3 ; - - bool result = true; - - //TODO check the skin after each update to ensure that the appropriate - //number of faces and particles exist. - try { - for ( unsigned iz = 0 ; iz < nz ; ++iz ) { - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::fixtures::HexFixture fixture( pm , nx , ny , nz ); - const stk_classic::mesh::EntityRank element_rank = fixture.m_fem_meta.element_rank(); - - const stk_classic::mesh::EntityRank particle_rank = element_rank; - - stk_classic::mesh::Part & skin_part = - fixture.m_fem_meta.declare_part("skin_part"); - - stk_classic::mesh::put_field( fixture.m_coord_field, - particle_rank, - fixture.m_fem_meta.universal_part(), - 3 ); - - fixture.m_fem_meta.commit(); - - fixture.generate_mesh(); - - stk_classic::mesh::skin_mesh(fixture.m_bulk_data, element_rank, &skin_part); - - stk_classic::mesh::Entity * elem = fixture.elem(ix , iy , iz); - - destroy_entity_and_create_particles(fixture, skin_part, elem); - } - } - } - } - catch(std::exception& e) { - std::cerr << "Caught exception: " << e.what() << std::endl; - result = false; - } - - return result; -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_2.cpp b/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_2.cpp deleted file mode 100644 index 8f33068164aa..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/UseCase_Skinning_2.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace { - -unsigned count_skin_entities( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Part & skin_part, stk_classic::mesh::EntityRank skin_rank) -{ - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(mesh); - - stk_classic::mesh::Selector select_skin = skin_part & meta.locally_owned_part() ; - - const std::vector& buckets = mesh.buckets( skin_rank ); - - return count_selected_entities( select_skin, buckets); -} - -// \TODO This function is a general utility, to be moved into stk_mesh and unit tested. - -// Destroy this entity and any lower ranking entities in this entity's closure that no longer -// have any upward relations. -void destroy_entity_closure( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Entity * entity) -{ - stk_classic::mesh::PairIterRelation relations = entity->relations(); - stk_classic::mesh::EntityRank entity_rank = entity->entity_rank(); - - ThrowErrorMsgIf( !relations.empty() && - relations.back().entity()->entity_rank() > entity_rank, - "Unable to destroy and entity with upward relations" ); - - for (; !entity->relations().empty();) { - stk_classic::mesh::Entity * related_entity = (entity->relations().back().entity()); - stk_classic::mesh::RelationIdentifier rel_id = entity->relations().back().identifier(); - stk_classic::mesh::EntityRank related_entity_rank = related_entity->entity_rank(); - - mesh.destroy_relation( *entity, *related_entity, rel_id ); - - stk_classic::mesh::PairIterRelation related_entity_relations = related_entity->relations(); - - // Only destroy if there are no upward relations - if ( related_entity_relations.empty() || - related_entity_relations.back().entity()->entity_rank() < related_entity_rank ) - { - destroy_entity_closure(mesh,related_entity); - } - } - - mesh.destroy_entity(entity); -} - -} - -// \TODO ASCII art to illustrate the whole use case geometry -// both before and after. - -bool skinning_use_case_2(stk_classic::ParallelMachine pm) -{ - const unsigned nx = 2 , ny = 1 , nz = 1 ; - - bool result = true; - - //TODO check the skin after each update to ensure that the appropriate - //number of faces and particles exist. - try { - stk_classic::mesh::fixtures::HexFixture fixture( pm , nx , ny , nz ); - const stk_classic::mesh::EntityRank element_rank = fixture.m_fem_meta.element_rank(); - const stk_classic::mesh::EntityRank side_rank = fixture.m_fem_meta.side_rank(); - - const unsigned p_rank = fixture.m_bulk_data.parallel_rank(); - const unsigned p_size = fixture.m_bulk_data.parallel_size(); - - stk_classic::mesh::Part & skin_part = fixture.m_fem_meta.declare_part("skin_part"); - - stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & shell_part = fixture.m_fem_meta.declare_part("shell_part", shell_top); - - fixture.m_fem_meta.commit(); - - fixture.generate_mesh(); - - fixture.m_bulk_data.modification_begin(); - - if ( p_rank + 1 == p_size ) { - // Verifies when all three elements on different processes, for p_size > 2 - //add shell between the two elements - - stk_classic::mesh::EntityId elem_node[4] ; - - // Query nodes from this simple grid fixture via the (i,j,k) indices. - elem_node[0] = fixture.node_id( 1, 0, 0 ); - elem_node[1] = fixture.node_id( 1, 1, 0 ); - elem_node[2] = fixture.node_id( 1, 1, 1 ); - elem_node[3] = fixture.node_id( 1, 0, 1 ); - - stk_classic::mesh::EntityId elem_id = 3; - - stk_classic::mesh::fem::declare_element( fixture.m_bulk_data, shell_part, elem_id, elem_node); - } - fixture.m_bulk_data.modification_end(); - - stk_classic::mesh::skin_mesh(fixture.m_bulk_data, element_rank, &skin_part); - - //---------------------------------------------------------------------- - //Actual usecase - //---------------------------------------------------------------------- - - { - int num_skin_entities = count_skin_entities( fixture.m_bulk_data, skin_part, side_rank); - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<1>(&num_skin_entities)); - - if ( num_skin_entities != 10 ) { - result = false; - std::cerr << std::endl << "incorrect number of entities in skin. Expected 10, Found " - << num_skin_entities << std::endl; - } - } - - // Kill element on the "left" of the shell: - fixture.m_bulk_data.modification_begin(); - stk_classic::mesh::Entity * elem_to_kill = fixture.elem( 0 , 0 , 0 ); // (i,j,k) indices - if ( elem_to_kill != NULL && p_rank == elem_to_kill->owner_rank() ) { - // Destroy element and its sides and nodes - // that are not in the closure of another element. - destroy_entity_closure( fixture.m_bulk_data, elem_to_kill); - } - - fixture.m_bulk_data.modification_end(); - - stk_classic::mesh::skin_mesh( fixture.m_bulk_data, element_rank, &skin_part); - - { - int num_skin_entities = count_skin_entities( fixture.m_bulk_data, skin_part, side_rank); - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<1>(&num_skin_entities)); - - // Verify that the correct 6 sides are present. - - if ( num_skin_entities != 6 ) { - result = false; - std::cerr << std::endl << "incorrect number of entities in skin. Expected 6, Found " - << num_skin_entities << std::endl; - } - } - } - catch(std::exception & e) { - std::cerr << std::endl << e.what() << std::endl; - result = false; - } - - return result; -} diff --git a/packages/stk/stk_classic/stk_mesh/use_cases/centroid_algorithm.hpp b/packages/stk/stk_classic/stk_mesh/use_cases/centroid_algorithm.hpp deleted file mode 100644 index 62fa766b5784..000000000000 --- a/packages/stk/stk_classic/stk_mesh/use_cases/centroid_algorithm.hpp +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------*/ -/** - * @author H. Carter Edwards - */ - -#ifndef centroid_algorithm_hpp -#define centroid_algorithm_hpp - -#include -#include -#include -#include - -namespace stk_classic { -namespace mesh { -namespace use_cases { - -enum {SpatialDim = 3}; - -//---------------------------------------------------------------------- -// An example of a trivial element-block algorithm -// that just works on element field data -// written with a "generic programming" flavor. - -template< class ElementTraits > -void centroid( unsigned number_elements , - double * elem_centroid , - double ** elem_node_coordinates ) -{ - enum { vertices_per_element = ElementTraits::vertex_count }; - enum { nodes_per_element = ElementTraits::node_count }; - - for ( unsigned j = 0 ; j < number_elements ; ++j ) { - - // Array is 'double * elem_node[ nodes_per_element * number_elements ] - // so get the node coordinate pointer for this element. - - double ** node_coordinates = elem_node_coordinates + j * nodes_per_element ; - - double tmp[SpatialDim] = { 0 , 0 , 0 }; - - for ( unsigned i = 0 ; i < vertices_per_element ; ++i ) { - // Pointer to this node's coordinates, - // accessing this field data in-place - // as opposed to copying (a.k.a. gathering) - // it into a local temporary array. - - double * coord = node_coordinates[i] ; - - // Sum for the mean. - tmp[0] += coord[0] ; - tmp[1] += coord[1] ; - tmp[2] += coord[2] ; - } - - tmp[0] /= vertices_per_element ; - tmp[1] /= vertices_per_element ; - tmp[2] /= vertices_per_element ; - - // The centroid field data for this element. - - double * centroid = elem_centroid + j * SpatialDim ; - - centroid[0] = tmp[0] ; - centroid[1] = tmp[1] ; - centroid[2] = tmp[2] ; - } -} - -//---------------------------------------------------------------------- -// An example of a trivial element-loop algorithm -// written with a "generic programming" flavor. -// -// Loop over all elements in the given 'elem_part'. -// Access the element-node coordinates. - -template< class ElementTraits > -void centroid_algorithm( - const BulkData & bulkData , - const VectorFieldType & elem_centroid , - const ElementNodePointerFieldType & elem_node_coord , - Part & elem_part, - EntityRank element_rank ) -{ - // Use the "homogeneous subset" concept (see the Domain Model document) - // for field data storage. A "homogeneous subset" is called - // a 'Bucket'. - - // Iterate the set of element buckets: - - const std::vector & buckets = bulkData.buckets( element_rank ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - Bucket & bucket = **k ; - - // If this bucket is a subset of the given elem_part - // then want to compute on it. - - if ( has_superset( bucket, elem_part ) ) { - - // Number of elements in the bucket: - - const unsigned size = bucket.size(); - - // Aggressive "gather" field data for the elements - // in the bucket. - // double * node_ptr[ nodes_per_element * number_of_elements ] - - double ** node_ptr = field_data( elem_node_coord , bucket.begin() ); - - // Element centroid field data - // double elem_ptr[ SpatialDim * number_of_elements ] - - double * elem_ptr = field_data( elem_centroid , bucket.begin() ); - - // Call an element function to calculate centroid for - // contiguous arrays of element field data. - - centroid< ElementTraits >( size , elem_ptr , node_ptr ); - } - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template< class ElementTraits > -bool centroid_algorithm_unit_test_dimensions( - const BulkData & bulkData , - const VectorFieldType & elem_centroid , - const ElementNodePointerFieldType & elem_node_coord , - Part & elem_part, - EntityRank element_rank ) -{ - bool result = true; - // Use the "homogeneous subset" concept (see the Domain Model document) - // for field data storage. A "homogeneous subset" is called - // a 'Bucket'. - - // Iterate the set of element buckets: - - const std::vector & buckets = bulkData.buckets( element_rank ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - Bucket & bucket = **k ; - - // If this bucket is a subset of the given elem_part - // then want to compute on it. - - if ( has_superset( bucket, elem_part ) ) { - - // Number of elements in the bucket: - - const unsigned size = bucket.size(); - - // Unit testing the dimension feature - { - BucketArray< ElementNodePointerFieldType > - array( elem_node_coord, bucket.begin(), bucket.end() ); - const unsigned n1 = array.template dimension<0>(); - const unsigned n2 = array.template dimension<1>(); - if ( n1 != ElementTraits::node_count ) { - std::cerr << "Error! n1 == " << n1 << " != " << ElementTraits::node_count << " == ElementTraits::node_count" << std::endl; - result = false; - } - if ( n2 != size ) { - std::cerr << "Error! n2 == " << n2 << " != " << size << " == size" << std::endl; - result = false; - } - if ( (unsigned) array.size() != n1 * n2 ) { - std::cerr << "Error! array.size() == " << array.size() << " != " << n1*n2 << " == n1*n2" << std::endl; - result = false; - } - } - - { - BucketArray< VectorFieldType > array( elem_centroid , bucket.begin(), bucket.end() ); - const unsigned n1 = array.template dimension<0>(); - const unsigned n2 = array.template dimension<1>(); - if ( n1 != (unsigned) SpatialDim ) { - std::cerr << "Error! n1 == " << n1 << " != " << SpatialDim << " == SpatialDim" << std::endl; - result = false; - } - if ( n2 != size ) { - std::cerr << "Error! n2 == " << n2 << " != " << size << " == size" << std::endl; - result = false; - } - if ( (unsigned) array.size() != n1 * n2 ) { - std::cerr << "Error! array.size() == " << array.size() << " != " << n1*n2 << " == n1*n2" << std::endl; - result = false; - } - } - } - } - return result; -} - -} // namespace use_cases -} // namespace mesh -} // namespace stk_classic - -#endif // centroid_algorithm_hpp diff --git a/packages/stk/stk_classic/stk_percept/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/CMakeLists.txt deleted file mode 100644 index f664f3a896aa..000000000000 --- a/packages/stk/stk_classic/stk_percept/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ - -ADD_SUBDIRECTORY(stk_percept) - -IF( TPL_ENABLE_Netcdf) -# IF (NOT CMAKE_BUILD_TYPE STREQUAL DEBUG) - IF (NOT ${PARENT_PACKAGE_NAME}_ENABLE_DEBUG) - TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) -# TRIBITS_ADD_TEST_DIRECTORIES(regression_tests) - ENDIF() -ENDIF() diff --git a/packages/stk/stk_classic/stk_percept/build/.gitignore b/packages/stk/stk_classic/stk_percept/build/.gitignore deleted file mode 100644 index d55b72e034aa..000000000000 --- a/packages/stk/stk_classic/stk_percept/build/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build.dir \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/build/README b/packages/stk/stk_classic/stk_percept/build/README deleted file mode 100644 index cb4799293ae0..000000000000 --- a/packages/stk/stk_classic/stk_percept/build/README +++ /dev/null @@ -1,24 +0,0 @@ -Build PyPercept Interface. -------------------------- - -To configure, copy the sample-Trilinos-configure-script and edit to -your needs, let's call this new file my-configure-script. Then, do -"mkdir build.dir", cd into build.dir, execute ../my-configure-script. -Next, execute make, etc. as you would for a Trilinos build. - -Docs ----- - -To build the docs, cd into build.dir and run ../build-pydoc.sh. This -builds the Doxygen-based comments from the C++ code into an xml file -which is processed by a doxy2py script to create python docstrings in -Percept_dox.i which are then %include'd in PerceptMesh.i. This script -also must perform a make and follows it with a pydoc command to build -the PerceptMesh.html doc file. - -Sierra users note: ------------------- - -Avoid the links used in Sierra for stk. Instead, cd into - /Trilinos/packages/stk/stk_percept/build -to build PyPercept. diff --git a/packages/stk/stk_classic/stk_percept/build/build-pydoc.sh b/packages/stk/stk_classic/stk_percept/build/build-pydoc.sh deleted file mode 100755 index 309c9877e1aa..000000000000 --- a/packages/stk/stk_classic/stk_percept/build/build-pydoc.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -# run this from you Trilinos build directory - -# relative to Trilinos/packages/stk/stk_percept/build/build.dir - -BASE_PATH=../../../../.. -echo "BASE_PATH= " , `cd $BASE_PATH; pwd` - -# Location of Trilinos source, where we build from - -TRILINOS_CODE=$BASE_PATH - -if [[ "$1" != "" ]] ; then - TRILINOS_CODE=$1 -fi -curwd=`pwd` - -cd $TRILINOS_CODE/packages/PyTrilinos/doc/Doxygen/ -make depend -make Percept_dox.i - -cd $curwd -touch $TRILINOS_CODE/packages/PyTrilinos/src/stk/PerceptMesh.i -make -j8 - -pydoc -w ./packages/PyTrilinos/src/stk/PyPercept/PerceptMesh.py - -cp PerceptMesh.html $TRILINOS_CODE/packages/stk/stk_percept/doc/ - - - diff --git a/packages/stk/stk_classic/stk_percept/build/install-pydoc.sh b/packages/stk/stk_classic/stk_percept/build/install-pydoc.sh deleted file mode 100755 index 142a146cb448..000000000000 --- a/packages/stk/stk_classic/stk_percept/build/install-pydoc.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# run this from you Trilinos build directory after running build-pydoc.sh - -cp PerceptMesh.html /projects/percept/doc - - - diff --git a/packages/stk/stk_classic/stk_percept/build/sample-Trilinos-configure-script b/packages/stk/stk_classic/stk_percept/build/sample-Trilinos-configure-script deleted file mode 100755 index 6772bd0db0a9..000000000000 --- a/packages/stk/stk_classic/stk_percept/build/sample-Trilinos-configure-script +++ /dev/null @@ -1,95 +0,0 @@ -# this is a sample configure script used on a sierra-like platform - -# The locations of various libraries (like boost, netcdf, mpi4py, -# etc.) will have to be set for your environment. - -EXTRA_ARGS=$@ - -# relative to Trilinos/packages/stk/stk_percept/build/build.dir - -BASE_PATH=../../../../.. - -# make it an absolute path -BASE_PATH=`cd $BASE_PATH; pwd` -echo "BASE_PATH= $BASE_PATH" - -# Location of Trilinos source, where we build from - -TRILINOS_CODE=$BASE_PATH - -# Location of install -#INSTALL_PATH=/usr/local/ -#INSTALL_PATH=./usr/local -INSTALL_PATH=/projects/percept - -# Python installation and related shared library dependencies -PYTHON_EXECUTABLE=/usr/netpub/python-2.7/bin/python -PYTHON_INSTALL_DIR=/usr/netpub/python-2.7 -MPI4PY_INSTALL_DIR=$PYTHON_INSTALL_DIR/lib/python2.7/site-packages/mpi4py - -# Location of Swig for building the Python/C++ interfaces -SWIG_INSTALL_DIR=/usr/netpub/swig-2.0.4 - -# Location of other third party library dependencies of Percept -BOOST_INCLUDE_DIR=$TRILINOS_CODE/../boost -# make it an absolute path -BOOST_INCLUDE_DIR=`cd $BOOST_INCLUDE_DIR; pwd` -echo "abs BOOST_INCLUDE_DIR= $BOOST_INCLUDE_DIR" - -NETCDF_INSTALL_DIR=/projects/seacas/linux_rhel5/current - -#debug: -# -# -D CMAKE_BUILD_TYPE:STRING=DEBUG \ - -# -# build docs -# -#./build-pydoc.sh $TRILINOS_CODE - -# not used in this version, can be set to null -#OPENNURBS_PATH=$BASE_PATH/../opennurbs - -# how to enable OpenNURBS -# -D STK_ADAPT_HAS_GEOMETRY -# -D TPL_OpenNURBS_INCLUDE_DIRS:PATH=$OPENNURBS_PATH \ -# -D TPL_OpenNURBS_LIBRARIES:PATH=$OPENNURBS_PATH/libopenNURBS.a \ -# -D TPL_ENABLE_OpenNURBS:BOOL=ON \ - -cmake \ - -D MPI4PY_INCLUDE_DIR:FILEPATH=$MPI4PY_INSTALL_DIR/include \ - -D SWIG_EXECUTABLE:FILEPATH=$SWIG_INSTALL_DIR/bin/swig \ - -D Trilinos_ENABLE_PyTrilinos:BOOL=ON \ - -D BUILD_SHARED_LIBS:BOOL=ON \ - -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON \ -\ - -D STK_ENABLE_SEACASIoss:BOOL=ON \ - -D STK_ENABLE_Intrepid:BOOL=ON \ - \ - -D CMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH \ - -D CMAKE_BUILD_TYPE:STRING=RELEASE \ - -D Trilinos_ENABLE_SECONDARY_STABLE_CODE:BOOL=ON \ - -D Trilinos_ENABLE_STK:BOOL=ON \ -\ - -D Trilinos_ENABLE_SEACASIoss:BOOL=ON \ - -D CMAKE_CXX_FLAGS:STRING="-DNO_PARAVIEWMESH_SUPPORT" \ -\ - -D Trilinos_ENABLE_Intrepid:BOOL=ON \ - -D Trilinos_ENABLE_ThreadPool:BOOL=ON \ -\ - -D Trilinos_ENABLE_Zoltan:BOOL=OFF \ - -D Trilinos_ENABLE_TESTS:BOOL=OFF \ - -D STK_ENABLE_TESTS:BOOL=ON \ -\ - -D TPL_ENABLE_BoostLib:BOOL=OFF \ -\ - -D TPL_ENABLE_MPI:BOOL=ON \ - -D TPL_ENABLE_Boost:BOOL=ON \ - -D TPL_ENABLE_Netcdf:BOOL=ON \ -\ - -D TPL_Boost_INCLUDE_DIRS:PATH=$BOOST_INCLUDE_DIR \ - -D TPL_BoostLib_INCLUDE_DIRS:PATH=$BOOST_INCLUDE_DIR \ -\ - -D TPL_Netcdf_LIBRARIES=$NETCDF_INSTALL_DIR/lib/shared/libnetcdf.so \ - -D TPL_Netcdf_INCLUDE_DIRS=$NETCDF_INSTALL_DIR/include \ -\ - $TRILINOS_CODE diff --git a/packages/stk/stk_classic/stk_percept/doc/Doxyfile b/packages/stk/stk_classic/stk_percept/doc/Doxyfile deleted file mode 100644 index e188a13f73ae..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/Doxyfile +++ /dev/null @@ -1,39 +0,0 @@ -@INCLUDE = Doxyfile.options -# -# Package options -# -PROJECT_NAME = "STK Percept" -#OUTPUT_DIRECTORY = ../.. -OUTPUT_DIRECTORY = . - -# -# What and how documentation is extracted -# -@INCLUDE = Doxyfile.input - -FILE_PATTERNS = *.dox *.hpp *.h - -IMAGE_PATH = -EXAMPLE_PATH = ../unit_tests -EXCLUDE = -EXAMPLE_PATTERNS = -INPUT_FILTER = -ALPHABETICAL_INDEX = YES -IGNORE_PREFIX = -RECURSIVE = YES -# -# Links to other packages -# -ALLEXTERNALS = YES -EXTERNAL_GROUPS = YES - -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 - -GENERATE_TAGFILE = ./tags - - -# see http://stackoverflow.com/questions/1579007/how-can-i-include-a-subset-of-a-cpp-file-in-a-doxygen-comment -ALIASES += clip{2}="\dontinclude \1 \n \skipline \2 \n \until end_demo" - -# use: \clip{Time_Limiter_example.cpp,tl_demo} diff --git a/packages/stk/stk_classic/stk_percept/doc/Doxyfile.input b/packages/stk/stk_classic/stk_percept/doc/Doxyfile.input deleted file mode 100644 index 0cc9a8fbefa0..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/Doxyfile.input +++ /dev/null @@ -1,12 +0,0 @@ -#BANNER @copydoc stk_percept_banner -#HOWTO @copydoc stk_percept_howto - -INPUT += ../../stk_percept/doc/index.dox \ - ../../stk_percept/stk_percept \ - ../../stk_percept/unit_tests - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES diff --git a/packages/stk/stk_classic/stk_percept/doc/Doxyfile.options b/packages/stk/stk_classic/stk_percept/doc/Doxyfile.options deleted file mode 100755 index 6d07ba28cdfd..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/Doxyfile.options +++ /dev/null @@ -1,96 +0,0 @@ -# -# Package options -# -OUTPUT_LANGUAGE = English -PROJECT_NUMBER = "Version of the Day" - -# -HAVE_DOT = YES - -# -# What and how documentation is extracted -# -SUBGROUPING = YES -## EXTRACT_ALL = NO -EXTRACT_ALL = YES -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = NO -HIDE_UNDOC_MEMBERS = NO -## HIDE_UNDOC_CLASSES = YES -HIDE_UNDOC_CLASSES = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -DETAILS_AT_TOP = YES -#DETAILS_AT_TOP = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -SHOW_DIRECTORIES = YES -## INTERNAL_DOCS = NO -INTERNAL_DOCS = YES -CLASS_DIAGRAMS = YES -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = YES -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = NO -TAB_SIZE = 2 -ENABLED_SECTIONS = -ENUM_VALUES_PER_LINE = 1 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = "$file:$line: $text" -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 4 -# -# What diagrams are created -# -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -UML_LOOK = YES -TEMPLATE_RELATIONS = YES -#TEMPLATE_RELATIONS = NO - -#MAX_DOT_GRAPH_WIDTH = 500 -MAX_DOT_GRAPH_DEPTH = 3 -#DOT_PATH = ~/mydot -#DOT_PATH = /scratch/srkenno/code/stk_encore/dox/dot -#DOT_GRAPH_MAX_NODES = 10 - -## HIDE_UNDOC_RELATIONS = YES -HIDE_UNDOC_RELATIONS = NO -# -# Preprocessing -# -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -## EXPAND_ONLY_PREDEF = NO -EXPAND_ONLY_PREDEF = YES -SEARCH_INCLUDES = YES -INCLUDE_FILE_PATTERNS = -PREDEFINED += DOXYGEN_COMPILE STK_HAS_MPI -# -# What kind of documentation is generated -# -GENERATE_HTMLHELP = NO -DISABLE_INDEX = NO -GENERATE_LATEX = NO -GENERATE_RTF = NO -GENERATE_MAN = NO -GENERATE_XML = NO -SEARCHENGINE = YES diff --git a/packages/stk/stk_classic/stk_percept/doc/PerceptMesh.html b/packages/stk/stk_classic/stk_percept/doc/PerceptMesh.html deleted file mode 100644 index 00ee1a12f66b..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/PerceptMesh.html +++ /dev/null @@ -1,5999 +0,0 @@ - - -Python: module PerceptMesh - - - - -
 
- 
PerceptMesh
index
/scratch/srkenno/code/TPLs_src/Trilinos/packages/stk/stk_percept/build/build.dir/packages/PyTrilinos/src/stk/PyPercept/PerceptMesh.py
-

PyPercept is the Python interface for the Trilinos STK Percept package.

-The following are examples of the actual PyPercept Python interface:

-##################################################################################################################

-Case 1: Norm of the difference of an Exact Solution and a Mesh Field

-pMesh = 
PerceptMesh() #Create a PerceptMesh database
-#Specify the geometric hex mesh to be a 3x3x3 box between 0,0,0 and 2,2,2
-pMesh.new_mesh(GMeshSpec('3x3x3|bbox:0,0,0,2,2,2')) 
-field = pMesh.add_field('coordinates', 1) #Add a coordinates field
-pMesh.commit() #Commits the mesh to the mesh database

-input_array = numpy.array([1.0, 0.5, 0.5]) #Create numpy arrays to be evaluated 
-input_array_2 = numpy.array([1.0, 1.5, 1.5])
-'
-#Create a field function with a name, field base, and the mesh and the domain and co-domain dimensions
-ff = FieldFunction('ff', field, pMesh, 3, 3) 
-ff.addAlias('myalias') #Define another name for the field function
-ff_output = ff.evaluate(input_array) #Evaluate the field function with the given array

-f2 = FieldFunction('f2', field, pMesh, 3, 3)
-f2_output = f2.evaluate(input_array_2)

-#Create a function from a string 'x+y+z', with a name, the domain and co-domain dimensions
-sf = StringFunction('x+y+z', 'myname', 3, 1) 
-sf_output = sf.evaluate(input_array) #Evaluate the function with the given array

-sf_diff = StringFunction('ff-f2', 'myname') #Create a function of the difference of the field functions

-norm = L1Norm(pMesh.getBulkData()) #Create a norm object to evaluate the norm of the mesh field
-value = norm.evaluate(ff) #Evaluate the norm
-diffnorm = norm.evaluate(sf_diff) #Evaluate the norm of the difference of the exact solution and the mesh field

-#Now use a helper function to evaluate the norm: eval_norm(bulkData, Function, int) 
-value1 = eval_norm(pMesh.getBulkData(), ff, 1) 
-diffnorm1 = eval_norm(pMesh.getBulkData(), sf_diff, 1)

-#################################################################################################################

-Case 2: Refine a mesh uniformly

-pMesh = PerceptMesh()
-pMesh.open('tet-mesh-brick-no-block.e') #Read an existing exodus file

-uniform_refiner = Refiner(pMesh, TET4_TET4_8) #Create a refiner on the specified mesh of the specified pattern.
-pMesh.commit()

-i = 0
-while i < 3:
-  uniform_refiner.doBreak() #Call the doBreak() method to refine the mesh
-  i = i + 1

-pMesh.saveAs('tet-mesh-refined-3-times.e') #Save out the refined mesh

-#################################################################################################################

-Case 3: Norm of the difference of results from two separate simulations

-subprocess.call('sierra aria -i tet_mesh.e -o result_0.e') #Run an external program from Python

-pMesh = PerceptMesh()
-pMesh.open('tet-mesh.e')
-uniform_refiner = Refiner(pMesh, TET4_TET4_8)
-pMesh.commit()

-uniform_refiner.doBreak()
-pMesh.saveAs('tet-mesh_refined.e')

-subprocess.call('sierra aria -i tet_mesh_refined.e -o result_1.e')

-pMesh_0 = PerceptMesh()
-pMesh_1 = PerceptMesh()
-pMesh_0.openReadOnly('result_0.e')
-pMesh_1.openReadOnly('result_1.e')

-ff_0 = Field_Function(pMesh_0)
-ff_1 = Field_Function(pMesh_1)
-diff = StringFunction('ff_0 - ff_1')

-diffnorm = eval_norm(pMesh.getBulkData, diff, 2)
-print 'diffnorm = ', diffnorm

-#################################################################################################################

-

- - - - - -
 
-Modules
       
_PerceptMesh
-

- - - - - -
 
-Classes
       
-
__builtin__.object -
-
-
BeamFixture -
Bucket -
BucketLess -
BulkData -
FEMMetaData -
FieldBase -
FieldCreateOrder -
FieldRepository -
GenericFunction -
-
-
Function -
-
-
ConstantFunction -
ConstantFunctionVec -
FieldFunction -
MaxOfNodeValues -
StringFunction -
-
-
-
-
Gmesh_STKmesh_Fixture -
HeterogeneousFixture -
L1Norm -
L2Norm -
LInfNorm -
MDArray -
MDArrayString -
MeshTransformer -
Name -
-
-
GMeshSpec -
-
-
OpType -
Part -
PartLess -
PartOrdLess -
PerceptMesh -
QuadFixture_3 -
QuadFixture_4 -
RCPComp -
RCPConstComp -
RCPFunction -
Refiner -
STK_Adapt_Auto_Part -
Selector -
SierraPort -
SwigPyIterator -
To_Ptr -
UniformRefinerPatternBase -
WedgeFixture -
Writer -
WriterThrowSafe -
vectord -
vectorfieldbase -
vectori -
-
-
Dimensions -
-
-
vectorparts -
vectors -
vectorvs -
-
-
-

- - - - - - - -
 
-class BeamFixture(__builtin__.object)
   Use case with mixed element topologies and field relations to provide
-fast access to node field data from an element.

-copied from stk_mesh and modified

-C++ includes: BeamFixture.hpp
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ParallelMachine comm, bool doCommit = True) -> BeamFixture
-__init__(self, ParallelMachine comm) -> BeamFixture

-stk_classic::percept::BeamFixture::BeamFixture(stk_classic::ParallelMachine comm, bool
-doCommit=true)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
populate(self)
populate(self)

-void
-stk_classic::percept::BeamFixture::populate()
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
m_block_beam
-
BeamFixture_m_block_beam_get(BeamFixture self) -> Part
-
-
m_bulkData
-
BeamFixture_m_bulkData_get(BeamFixture self) -> BulkData
-
-
m_centroid_field
-
BeamFixture_m_centroid_field_get(BeamFixture self) -> VectorFieldType
-
-
m_coordinates_field
-
BeamFixture_m_coordinates_field_get(BeamFixture self) -> VectorFieldType
-
-
m_elem_rank
-
BeamFixture_m_elem_rank_get(BeamFixture self) -> EntityRank
-
-
m_element_node_coordinates_field
-
BeamFixture_m_element_node_coordinates_field_get(BeamFixture self) -> ElementNodePointerFieldType
-
-
m_metaData
-
BeamFixture_m_metaData_get(BeamFixture self) -> FEMMetaData
-
-
m_spatial_dimension
-
BeamFixture_m_spatial_dimension_get(BeamFixture self) -> int
-
-
m_temperature_field
-
BeamFixture_m_temperature_field_get(BeamFixture self) -> ScalarFieldType
-
-
m_volume_field
-
BeamFixture_m_volume_field_get(BeamFixture self) -> ScalarFieldType
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_BeamFixture>
delete_BeamFixture(BeamFixture self)

-stk_classic::percept::BeamFixture::~BeamFixture()
- -
__swig_getmethods__ = {'m_block_beam': <built-in function BeamFixture_m_block_beam_get>, 'm_bulkData': <built-in function BeamFixture_m_bulkData_get>, 'm_centroid_field': <built-in function BeamFixture_m_centroid_field_get>, 'm_coordinates_field': <built-in function BeamFixture_m_coordinates_field_get>, 'm_elem_rank': <built-in function BeamFixture_m_elem_rank_get>, 'm_element_node_coordinates_field': <built-in function BeamFixture_m_element_node_coordinates_field_get>, 'm_metaData': <built-in function BeamFixture_m_metaData_get>, 'm_spatial_dimension': <built-in function BeamFixture_m_spatial_dimension_get>, 'm_temperature_field': <built-in function BeamFixture_m_temperature_field_get>, 'm_volume_field': <built-in function BeamFixture_m_volume_field_get>}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Bucket(__builtin__.object)
   Proxy of C++ stk_classic::mesh::Bucket class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
allocation_size(self)
allocation_size(self) -> unsigned int
- -
assert_correct(self)
assert_correct(self) -> bool
- -
begin(self)
begin(self) -> iterator
- -
capacity(self)
capacity(self) -> size_t
- -
end(self)
end(self) -> iterator
- -
entity_rank(self)
entity_rank(self) -> unsigned int
- -
equivalent(self, *args)
equivalent(self, Bucket b) -> bool
- -
fast_field_data_location(self, *args)
fast_field_data_location(self, FieldBase field, unsigned int ordinal) -> unsigned char
- -
field_data_location(self, *args)
field_data_location(self, FieldBase field, Entity entity) -> unsigned char
-field_data_location(self, FieldBase field, unsigned int ordinal) -> unsigned char
-field_data_location(self, FieldBase field) -> unsigned char
- -
field_data_size(self, *args)
field_data_size(self, FieldBase field) -> unsigned int
- -
field_data_stride(self, *args)
field_data_stride(self, FieldBase field) -> stk_classic::mesh::FieldBase::Restriction::size_type
- -
key(self)
key(self) -> unsigned int
- -
member(self, *args)
member(self, Part arg0) -> bool
- -
member_all(self, *args)
member_all(self, PartVector arg0) -> bool
-member_all(self, OrdinalVector arg0) -> bool
- -
member_any(self, *args)
member_any(self, PartVector arg0) -> bool
-member_any(self, OrdinalVector arg0) -> bool
- -
mesh(self)
mesh(self) -> BulkData
- -
size(self)
size(self) -> size_t
- -
superset_part_ordinals(self)
superset_part_ordinals(self) -> std::pair<(p.q(const).unsigned int,p.q(const).unsigned int)>
- -
supersets(self, *args)
supersets(self, PartVector arg0)
-supersets(self, OrdinalVector arg0)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class BucketLess(__builtin__.object)
   Proxy of C++ stk_classic::mesh::BucketLess class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> BucketLess
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_BucketLess>
delete_BucketLess(BucketLess self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class BulkData(__builtin__.object)
   Proxy of C++ stk_classic::mesh::BulkData class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, MetaData mesh_meta_data, ParallelMachine parallel, 
-    unsigned int bucket_max_size = 1000, bool use_memory_pool = True) -> BulkData
-__init__(self, MetaData mesh_meta_data, ParallelMachine parallel, 
-    unsigned int bucket_max_size = 1000) -> BulkData
-__init__(self, MetaData mesh_meta_data, ParallelMachine parallel) -> BulkData
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
buckets(self, *args)
buckets(self, EntityRank rank) -> std::vector<(p.stk_classic::mesh::Bucket,std::allocator<(p.stk_classic::mesh::Bucket)>)>
- -
change_entity_id(self, *args)
change_entity_id(self, EntityId id, Entity entity)
- -
change_entity_owner(self, *args)
change_entity_owner(self, std::vector<(stk_classic::mesh::EntityProc,std::allocator<(stk_classic::mesh::EntityProc)>)> arg_change)
- -
change_entity_parts(self, *args)
change_entity_parts(self, Entity entity, PartVector add_parts, PartVector remove_parts = stk_classic::mesh::PartVector())
-change_entity_parts(self, Entity entity, PartVector add_parts)
- -
change_ghosting(self, *args)
change_ghosting(self, Ghosting ghosts, std::vector<(stk_classic::mesh::EntityProc,std::allocator<(stk_classic::mesh::EntityProc)>)> add_send, 
-    std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)> remove_receive)
- -
copy_entity_fields(self, *args)
copy_entity_fields(self, Entity src, Entity dest)
- -
create_ghosting(self, *args)
create_ghosting(self, string name) -> Ghosting
- -
declare_entity(self, *args)
declare_entity(self, EntityRank ent_rank, EntityId ent_id, PartVector parts) -> Entity
- -
declare_relation(self, *args)
declare_relation(self, Entity e_from, Entity e_to, RelationIdentifier local_id)
-declare_relation(self, Entity entity, std::vector<(stk_classic::mesh::Relation,std::allocator<(stk_classic::mesh::Relation)>)> rel)
- -
destroy_all_ghosting(self)
destroy_all_ghosting(self)
- -
destroy_entity(self, *args)
destroy_entity(self, Entity entity) -> bool
- -
destroy_relation(self, *args)
destroy_relation(self, Entity e_from, Entity e_to, RelationIdentifier local_id) -> bool
- -
entity_comm(self, *args)
entity_comm(self) -> std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)>
-entity_comm(self, EntityKey key) -> PairIterEntityComm
-entity_comm(self, EntityKey key, Ghosting sub) -> PairIterEntityComm
- -
entity_comm_clear(self, *args)
entity_comm_clear(self, EntityKey key)
- -
entity_comm_clear_ghosting(self, *args)
entity_comm_clear_ghosting(self, EntityKey key)
- -
entity_comm_erase(self, *args)
entity_comm_erase(self, EntityKey key, EntityCommInfo val) -> bool
-entity_comm_erase(self, EntityKey key, Ghosting ghost) -> bool
- -
entity_comm_insert(self, *args)
entity_comm_insert(self, EntityKey key, EntityCommInfo val) -> bool
- -
entity_comm_sharing(self, *args)
entity_comm_sharing(self, EntityKey key) -> PairIterEntityComm
- -
entity_comm_swap(self, *args)
entity_comm_swap(self, EntityKey key1, EntityKey key2)
- -
final_modification_end(self)
final_modification_end(self) -> bool
- -
generate_new_entities(self, *args)
generate_new_entities(self, std::vector<(size_t,std::allocator<(size_t)>)> requests, 
-    std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)> requested_entities)
- -
get_entity(self, *args)
get_entity(self, EntityRank entity_rank, EntityId entity_id) -> Entity
-get_entity(self, EntityKey key) -> Entity
- -
ghostings(self)
ghostings(self) -> std::vector<(p.stk_classic::mesh::Ghosting,std::allocator<(p.stk_classic::mesh::Ghosting)>)>
- -
mesh_meta_data(self)
mesh_meta_data(self) -> MetaData
- -
modification_begin(self)
modification_begin(self) -> bool
- -
modification_end(self)
modification_end(self) -> bool
- -
optimize_buckets_at_modification_end(self, *args)
optimize_buckets_at_modification_end(self, bool b)
- -
parallel(self)
parallel(self) -> ParallelMachine
- -
parallel_rank(self)
parallel_rank(self) -> unsigned int
- -
parallel_size(self)
parallel_size(self) -> unsigned int
- -
shared_aura(self)
shared_aura(self) -> Ghosting
- -
synchronized_count(self)
synchronized_count(self) -> size_t
- -
synchronized_state(self)
synchronized_state(self) -> BulkDataSyncState
- -
update_field_data_states(self)
update_field_data_states(self)
- -
-Static methods defined here:
-
get(*args)
get(Bucket bucket) -> BulkData
-get(Entity entity) -> BulkData
-get(Ghosting ghost) -> BulkData
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
MODIFIABLE = 1
- -
SYNCHRONIZED = 2
- -
__swig_destroy__ = <built-in function delete_BulkData>
delete_BulkData(BulkData self)
- -
__swig_getmethods__ = {'get': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class ConstantFunction(Function)
   Proxy of C++ stk_classic::percept::ConstantFunction class
 
 
Method resolution order:
-
ConstantFunction
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, double value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions(), 
-    unsigned int integration_order = 0) -> ConstantFunction
-__init__(self, double value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions()) -> ConstantFunction
-__init__(self, double value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions()) -> ConstantFunction
-__init__(self, double value, char name) -> ConstantFunction

-stk_classic::percept::ConstantFunction::ConstantFunction(double value, const
-char *name, Dimensions domain_dimensions=Dimensions(), Dimensions
-codomain_dimensions=Dimensions(), unsigned integration_order=0)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
getValue(self)
getValue(self) -> double

-double& stk_classic::percept::ConstantFunction::getValue()
- -
setValue(self, *args)
setValue(self, double v)

-void
-stk_classic::percept::ConstantFunction::setValue(double &v)
- -
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_ConstantFunction>
delete_ConstantFunction(ConstantFunction self)
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from Function:
-
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual
-Teuchos::RCP<Function >
-stk_classic::percept::Function::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::Function::gradient(int
-spatialDim=3)
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods inherited from Function:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes inherited from Function:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class ConstantFunctionVec(Function)
   Proxy of C++ stk_classic::percept::ConstantFunctionVec class
 
 
Method resolution order:
-
ConstantFunctionVec
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, vectord value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions(), 
-    unsigned int integration_order = 0) -> ConstantFunctionVec
-__init__(self, vectord value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions()) -> ConstantFunctionVec
-__init__(self, vectord value, char name, Dimensions domain_dimensions = stk_classic::percept::Dimensions()) -> ConstantFunctionVec
-__init__(self, vectord value, char name) -> ConstantFunctionVec

-stk_classic::percept::ConstantFunctionVec::ConstantFunctionVec(std::vector<
-double > &value, const char *name, Dimensions
-domain_dimensions=Dimensions(), Dimensions
-codomain_dimensions=Dimensions(), unsigned integration_order=0)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
getValue(self)
getValue(self) -> vectord

-std::vector<double>& stk_classic::percept::ConstantFunctionVec::getValue()
- -
setValue(self, *args)
setValue(self, vectord v)

-void stk_classic::percept::ConstantFunctionVec::setValue(std::vector< double >
-&v)
- -
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_ConstantFunctionVec>
delete_ConstantFunctionVec(ConstantFunctionVec self)
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from Function:
-
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual
-Teuchos::RCP<Function >
-stk_classic::percept::Function::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::Function::gradient(int
-spatialDim=3)
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods inherited from Function:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes inherited from Function:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class Dimensions(vectori)
   Proxy of C++ stk_classic::percept::Dimensions class
 
 
Method resolution order:
-
Dimensions
-
vectori
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> Dimensions
-__init__(self, int i0) -> Dimensions
-__init__(self, int i0, int i1) -> Dimensions
-__init__(self, int i0, int i1, int i2) -> Dimensions

-stk_classic::percept::Dimensions::Dimensions(int i0, int i1, int i2)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_Dimensions>
delete_Dimensions(Dimensions self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from vectori:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors inherited from vectori:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class FEMMetaData(__builtin__.object)
   Proxy of C++ stk_classic::mesh::fem::FEMMetaData class
 
 Methods defined here:
-
FEM_initialize(self, *args)
FEM_initialize(self, size_t spatial_dimension, vectors in_entity_rank_names = std::vector< std::string >())
-FEM_initialize(self, size_t spatial_dimension)
- -
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> FEMMetaData
-__init__(self, size_t spatial_dimension, vectors in_entity_rank_names = std::vector< std::string >()) -> FEMMetaData
-__init__(self, size_t spatial_dimension) -> FEMMetaData
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
check_rank(self, *args)
check_rank(self, EntityRank rank) -> bool
- -
commit(self)
commit(self)
- -
declare_field_base(self, *args)
declare_field_base(self, string arg_name, DataTraits arg_traits, unsigned int arg_rank, 
-    shards::ArrayDimTag arg_dim_tags, 
-    unsigned int arg_num_states) -> FieldBase
- -
declare_field_restriction(self, *args)
declare_field_restriction(self, FieldBase arg_field, EntityRank arg_entity_rank, Part arg_part, 
-    unsigned int arg_stride, void arg_init_value = None)
-declare_field_restriction(self, FieldBase arg_field, EntityRank arg_entity_rank, Part arg_part, 
-    unsigned int arg_stride)
- -
declare_part(self, *args)
declare_part(self, string name, CellTopology cell_topology) -> Part
-declare_part(self, string p_name, EntityRank rank) -> Part
-declare_part(self, string p_name) -> Part
- -
declare_part_relation(self, *args)
declare_part_relation(self, Part root_part, relation_stencil_ptr stencil, Part target_part)
- -
declare_part_subset(self, *args)
declare_part_subset(self, Part superset, Part subset)
- -
edge_rank(self)
edge_rank(self) -> EntityRank
- -
element_rank(self)
element_rank(self) -> EntityRank
- -
entity_rank(self, *args)
entity_rank(self, string name) -> EntityRank
- -
entity_rank_count(self)
entity_rank_count(self) -> std::vector<(std::string,std::allocator<(std::string)>)>::size_type
- -
entity_rank_name(self, *args)
entity_rank_name(self, EntityRank in_entity_rank) -> string
- -
entity_rank_names(self)
entity_rank_names(self) -> vectors
- -
face_rank(self)
face_rank(self) -> EntityRank
- -
get_cell_topology(self, *args)
get_cell_topology(self, Part part) -> CellTopology
-get_cell_topology(self, string topology_name) -> CellTopology
- -
get_cell_topology_root_part(self, *args)
get_cell_topology_root_part(self, CellTopology cell_topology) -> Part
- -
get_entity_rank(self, *args)
get_entity_rank(self, CellTopology cell_topology) -> EntityRank
- -
get_field(self, *args)
get_field(self, string name) -> FieldBase
- -
get_field_relations(self)
get_field_relations(self) -> std::vector<(FieldRelation,std::allocator<(FieldRelation)>)>
- -
get_fields(self)
get_fields(self) -> FieldVector
- -
get_part(self, *args)
get_part(self, string p_name, char required_by = None) -> Part
-get_part(self, string p_name) -> Part
-get_part(self, unsigned int ord) -> Part
- -
get_parts(self)
get_parts(self) -> PartVector
- -
globally_shared_part(self)
globally_shared_part(self) -> Part
- -
is_FEM_initialized(self)
is_FEM_initialized(self) -> bool
- -
is_commit(self)
is_commit(self) -> bool
- -
is_valid_entity_rank(self, *args)
is_valid_entity_rank(self, EntityRank rank) -> bool
- -
locally_owned_part(self)
locally_owned_part(self) -> Part
- -
node_rank(self)
node_rank(self) -> EntityRank
- -
register_cell_topology(self, *args)
register_cell_topology(self, CellTopology cell_topology, EntityRank in_entity_rank)
- -
set_entity_rank_names(self, *args)
set_entity_rank_names(self, vectors in_entity_rank_names)
- -
side_rank(self)
side_rank(self) -> EntityRank
- -
spatial_dimension(self)
spatial_dimension(self) -> size_t
- -
universal_part(self)
universal_part(self) -> Part
- -
volume_rank(self)
volume_rank(self) -> EntityRank
- -
-Static methods defined here:
-
get(*args)
get(MetaData meta) -> FEMMetaData
-get(Part part) -> FEMMetaData
-get(FieldBase field) -> FEMMetaData
-get(PropertyBase property) -> FEMMetaData
-get(BulkData bulk_data) -> FEMMetaData
-get(Bucket bucket) -> FEMMetaData
-get(Entity entity) -> FEMMetaData
-get(Ghosting ghost) -> FEMMetaData
- -
get_meta_data(*args)
get_meta_data(FEMMetaData fem_meta) -> MetaData
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
EDGE_RANK = 1
- -
FACE_RANK = 2
- -
INVALID_RANK = -1
- -
NODE_RANK = 0
- -
VOLUME_RANK = 3
- -
__swig_destroy__ = <built-in function delete_FEMMetaData>
delete_FEMMetaData(FEMMetaData self)
- -
__swig_getmethods__ = {'get': <function <lambda>>, 'get_meta_data': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class FieldBase(__builtin__.object)
   Proxy of C++ stk_classic::mesh::FieldBase class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
data_traits(self)
data_traits(self) -> DataTraits
- -
dimension_tags(self)
dimension_tags(self) -> shards::ArrayDimTag
- -
field_state(self, *args)
field_state(self, FieldState fstate) -> FieldBase
- -
get_initial_value(self, *args)
get_initial_value(self) -> void
-get_initial_value(self) -> void
- -
get_initial_value_num_bytes(self)
get_initial_value_num_bytes(self) -> unsigned int
- -
max_size(self, *args)
max_size(self, EntityRank entity_rank) -> unsigned int
- -
mesh_meta_data(self)
mesh_meta_data(self) -> MetaData
- -
mesh_meta_data_ordinal(self)
mesh_meta_data_ordinal(self) -> unsigned int
- -
name(self)
name(self) -> string
- -
number_of_states(self)
number_of_states(self) -> unsigned int
- -
rank(self)
rank(self) -> unsigned int
- -
restriction(self, *args)
restriction(self, unsigned int entity_rank, Part part) -> Restriction
- -
restrictions(self)
restrictions(self) -> RestrictionVector
- -
selector_restrictions(self)
selector_restrictions(self) -> RestrictionVector
- -
state(self)
state(self) -> FieldState
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_FieldBase>
delete_FieldBase(FieldBase self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class FieldCreateOrder(__builtin__.object)
   Proxy of C++ stk_classic::percept::FieldCreateOrder class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> FieldCreateOrder
-__init__(self, string name, unsigned int entity_rank, vectori dimensions, 
-    Part part) -> FieldCreateOrder

-stk_classic::percept::FieldCreateOrder::FieldCreateOrder(const std::string
-name, const unsigned entity_rank, const std::vector< int > dimensions,
-const mesh::Part *part)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
m_dimensions
-
FieldCreateOrder_m_dimensions_get(FieldCreateOrder self) -> vectori
-
-
m_entity_rank
-
FieldCreateOrder_m_entity_rank_get(FieldCreateOrder self) -> unsigned int
-
-
m_name
-
FieldCreateOrder_m_name_get(FieldCreateOrder self) -> string
-
-
m_part
-
FieldCreateOrder_m_part_get(FieldCreateOrder self) -> Part
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_FieldCreateOrder>
delete_FieldCreateOrder(FieldCreateOrder self)
- -
__swig_getmethods__ = {'m_dimensions': <built-in function FieldCreateOrder_m_dimensions_get>, 'm_entity_rank': <built-in function FieldCreateOrder_m_entity_rank_get>, 'm_name': <built-in function FieldCreateOrder_m_name_get>, 'm_part': <built-in function FieldCreateOrder_m_part_get>}
- -
__swig_setmethods__ = {'m_part': <built-in function FieldCreateOrder_m_part_set>}
- -

- - - - - - - -
 
-class FieldFunction(Function)
   Evaluate the function at this input point (or points) returning
-value(s) in output_field_values

-In the following, the arrays are dimensioned using the notation (from
-Intrepid's doc):

-[C] - num. integration domains (cells/elements) [F] - num. Intrepid
-"fields" (number of bases within an element == num. nodes typically)
-[P] - num. integration (or interpolation) points within the element
-[D] - spatial dimension [D1], [D2] - spatial dimension

-Locally, we introduce this notation:

-[DOF] - number of degrees-of-freedom per node of the interpolated stk
-Field. For example, a vector field in 3D has [DOF] = 3

-C++ includes: FieldFunction.hpp
 
 
Method resolution order:
-
FieldFunction
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, char name, FieldBase field, PerceptMesh mesh, int domain_dimension = 3, 
-    int codomain_dimension = 1, 
-    SearchType searchType = SIMPLE_SEARCH, unsigned int integration_order = 0) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh mesh, int domain_dimension = 3, 
-    int codomain_dimension = 1, 
-    SearchType searchType = SIMPLE_SEARCH) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh mesh, int domain_dimension = 3, 
-    int codomain_dimension = 1) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh mesh, int domain_dimension = 3) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh mesh) -> FieldFunction
-__init__(self, char name, FieldBase field, BulkData bulk, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions(), 
-    SearchType searchType = SIMPLE_SEARCH, 
-    unsigned int integration_order = 0) -> FieldFunction
-__init__(self, char name, FieldBase field, BulkData bulk, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions(), 
-    SearchType searchType = SIMPLE_SEARCH) -> FieldFunction
-__init__(self, char name, FieldBase field, BulkData bulk, Dimensions domain_dimensions = stk_classic::percept::Dimensions(), 
-    Dimensions codomain_dimensions = stk_classic::percept::Dimensions()) -> FieldFunction
-__init__(self, char name, FieldBase field, BulkData bulk, Dimensions domain_dimensions = stk_classic::percept::Dimensions()) -> FieldFunction
-__init__(self, char name, FieldBase field, BulkData bulk) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh eMesh, Dimensions domain_dimensions, 
-    Dimensions codomain_dimensions, 
-    SearchType searchType = SIMPLE_SEARCH, 
-    unsigned int integration_order = 0) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh eMesh, Dimensions domain_dimensions, 
-    Dimensions codomain_dimensions, 
-    SearchType searchType = SIMPLE_SEARCH) -> FieldFunction
-__init__(self, char name, FieldBase field, PerceptMesh eMesh, Dimensions domain_dimensions, 
-    Dimensions codomain_dimensions) -> FieldFunction

-stk_classic::percept::FieldFunction::FieldFunction(const char *name,
-mesh::FieldBase *field, PerceptMesh &eMesh, Dimensions
-domain_dimensions, Dimensions codomain_dimensions, SearchType
-searchType=SIMPLE_SEARCH, unsigned integration_order=0)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual Teuchos::RCP<Function >
-stk_classic::percept::FieldFunction::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
getFoundOnLocalOwnedPart(self)
getFoundOnLocalOwnedPart(self) -> bool

-bool
-stk_classic::percept::FieldFunction::getFoundOnLocalOwnedPart()
- -
get_bulk_data(self)
get_bulk_data(self) -> BulkData

-mesh::BulkData * stk_classic::percept::FieldFunction::get_bulk_data()
- -
get_field(self)
get_field(self) -> FieldBase

-mesh::FieldBase * stk_classic::percept::FieldFunction::get_field()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::FieldFunction::gradient(int
-spatialDim=3)
- -
interpolateFrom(self, *args)
interpolateFrom(self, Function function)

-void stk_classic::percept::FieldFunction::interpolateFrom(Function &function)

-for each node in the codomain, evaluate the function_to_interpolate's
-function, assign to the codomain field
- -
localEvaluation(self, *args)
localEvaluation(self, MDArray _in, double time_value_optional = 0.0)
-localEvaluation(self, MDArray _in)

-void stk_classic::percept::FieldFunction::localEvaluation(MDArray &in, MDArray
-&out, double time_value_optional=0.0)
- -
setup_searcher(self, *args)
setup_searcher(self, int D_)

-void stk_classic::percept::FieldFunction::setup_searcher(int D_)
- -
-Data descriptors defined here:
-
m_parallelEval
-
-
-Data and other attributes defined here:
-
SIMPLE_SEARCH = 0
- -
STK_SEARCH = 1
- -
__swig_destroy__ = <built-in function delete_FieldFunction>
delete_FieldFunction(FieldFunction self)

-stk_classic::percept::FieldFunction::~FieldFunction()
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'm_parallelEval': <built-in function FieldFunction_m_parallelEval_get>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {'m_parallelEval': <built-in function FieldFunction_m_parallelEval_set>}
- -
-Methods inherited from Function:
-
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods inherited from Function:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes inherited from Function:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class FieldRepository(__builtin__.object)
   Proxy of C++ stk_classic::mesh::impl::FieldRepository class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> FieldRepository
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
declare_field(self, *args)
declare_field(self, string arg_name, DataTraits arg_traits, unsigned int arg_rank, 
-    shards::ArrayDimTag arg_dim_tags, 
-    unsigned int arg_num_states, MetaData arg_meta_data) -> FieldBase
- -
declare_field_restriction(self, *args)
declare_field_restriction(self, char arg_method, FieldBase arg_field, unsigned int arg_entity_rank, 
-    Part arg_part, PartVector arg_all_parts, 
-    unsigned int arg_stride, void arg_init_value = None)
-declare_field_restriction(self, char arg_method, FieldBase arg_field, unsigned int arg_entity_rank, 
-    Part arg_part, PartVector arg_all_parts, 
-    unsigned int arg_stride)
-declare_field_restriction(self, char arg_method, FieldBase arg_field, unsigned int arg_entity_rank, 
-    Selector arg_selector, PartVector arg_all_parts, 
-    unsigned int arg_stride, 
-    void arg_init_value = None)
-declare_field_restriction(self, char arg_method, FieldBase arg_field, unsigned int arg_entity_rank, 
-    Selector arg_selector, PartVector arg_all_parts, 
-    unsigned int arg_stride)
- -
get_field(self, *args)
get_field(self, char arg_method, string arg_name, DataTraits arg_traits, 
-    unsigned int arg_rank, shards::ArrayDimTag arg_dim_tags, 
-    unsigned int arg_num_states) -> FieldBase
- -
get_fields(self)
get_fields(self) -> FieldVector
- -
verify_and_clean_restrictions(self, *args)
verify_and_clean_restrictions(self, char arg_method, Part superset, Part subset, PartVector arg_all_parts)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_FieldRepository>
delete_FieldRepository(FieldRepository self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Function(GenericFunction)
   Proxy of C++ stk_classic::percept::Function class
 
 
Method resolution order:
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual
-Teuchos::RCP<Function >
-stk_classic::percept::Function::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::Function::gradient(int
-spatialDim=3)
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods defined here:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes defined here:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
__swig_destroy__ = <built-in function delete_Function>
delete_Function(Function self)
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class GMeshSpec(Name)
   Proxy of C++ stk_classic::percept::GMeshSpec class
 
 
Method resolution order:
-
GMeshSpec
-
Name
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, string name) -> GMeshSpec

-stk_classic::percept::GMeshSpec::GMeshSpec(const std::string &name)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_GMeshSpec>
delete_GMeshSpec(GMeshSpec self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from Name:
-
getName(self)
getName(self) -> string

-const
-std::string& stk_classic::percept::Name::getName() const
- -
-Data descriptors inherited from Name:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class GenericFunction(__builtin__.object)
   Proxy of C++ stk_classic::percept::GenericFunction class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods defined here:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_GenericFunction>
delete_GenericFunction(GenericFunction self)

-virtual stk_classic::percept::GenericFunction::~GenericFunction()
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Gmesh_STKmesh_Fixture(__builtin__.object)
   Proxy of C++ stk_classic::io::util::Gmesh_STKmesh_Fixture class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ParallelMachine comm, string gmesh_spec) -> Gmesh_STKmesh_Fixture
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
commit(self)
commit(self)
- -
getBulkData(self)
getBulkData(self) -> BulkData
- -
getElemCount(self)
getElemCount(self) -> size_t
- -
getFEMMetaData(self)
getFEMMetaData(self) -> FEMMetaData
- -
getMetaData(self)
getMetaData(self) -> MetaData
- -
getNodeCount(self)
getNodeCount(self) -> size_t
- -
getSideCount(self)
getSideCount(self) -> size_t
- -
getSideParts(self)
getSideParts(self) -> PartVector
- -
getSidesetNames(self)
getSidesetNames(self) -> vectors
- -
getSurfCoordInfo(self, *args)
getSurfCoordInfo(self, size_t surf_id) -> std::pair<(int,double)>
- -
getSurfElemCount(self, *args)
getSurfElemCount(self, size_t surf_id) -> size_t
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_Gmesh_STKmesh_Fixture>
delete_Gmesh_STKmesh_Fixture(Gmesh_STKmesh_Fixture self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class HeterogeneousFixture(__builtin__.object)
   Use case with mixed element topologies and field relations to provide
-fast access to node field data from an element.

-copied from stk_mesh and modified

-C++ includes: HeterogeneousFixture.hpp
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ParallelMachine comm, bool doCommit = True, bool do_sidesets = False) -> HeterogeneousFixture
-__init__(self, ParallelMachine comm, bool doCommit = True) -> HeterogeneousFixture
-__init__(self, ParallelMachine comm) -> HeterogeneousFixture

-stk_classic::percept::HeterogeneousFixture::HeterogeneousFixture(stk_classic::ParallelMachine
-comm, bool doCommit=true, bool do_sidesets=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
populate(self)
populate(self)

-void stk_classic::percept::HeterogeneousFixture::populate()
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
m_block_hex
-
HeterogeneousFixture_m_block_hex_get(HeterogeneousFixture self) -> Part
-
-
m_block_pyramid
-
HeterogeneousFixture_m_block_pyramid_get(HeterogeneousFixture self) -> Part
-
-
m_block_tet
-
HeterogeneousFixture_m_block_tet_get(HeterogeneousFixture self) -> Part
-
-
m_block_wedge
-
HeterogeneousFixture_m_block_wedge_get(HeterogeneousFixture self) -> Part
-
-
m_bulkData
-
HeterogeneousFixture_m_bulkData_get(HeterogeneousFixture self) -> BulkData
-
-
m_centroid_field
-
HeterogeneousFixture_m_centroid_field_get(HeterogeneousFixture self) -> VectorFieldType
-
-
m_coordinates_field
-
HeterogeneousFixture_m_coordinates_field_get(HeterogeneousFixture self) -> VectorFieldType
-
-
m_elem_rank
-
HeterogeneousFixture_m_elem_rank_get(HeterogeneousFixture self) -> EntityRank
-
-
m_element_node_coordinates_field
-
HeterogeneousFixture_m_element_node_coordinates_field_get(HeterogeneousFixture self) -> ElementNodePointerFieldType
-
-
m_metaData
-
HeterogeneousFixture_m_metaData_get(HeterogeneousFixture self) -> FEMMetaData
-
-
m_sideset_quad
-
HeterogeneousFixture_m_sideset_quad_get(HeterogeneousFixture self) -> Part
-
-
m_sideset_quad_subset
-
HeterogeneousFixture_m_sideset_quad_subset_get(HeterogeneousFixture self) -> Part
-
-
m_sideset_tri
-
HeterogeneousFixture_m_sideset_tri_get(HeterogeneousFixture self) -> Part
-
-
m_sideset_tri_subset
-
HeterogeneousFixture_m_sideset_tri_subset_get(HeterogeneousFixture self) -> Part
-
-
m_spatial_dimension
-
HeterogeneousFixture_m_spatial_dimension_get(HeterogeneousFixture self) -> int
-
-
m_temperature_field
-
HeterogeneousFixture_m_temperature_field_get(HeterogeneousFixture self) -> ScalarFieldType
-
-
m_volume_field
-
HeterogeneousFixture_m_volume_field_get(HeterogeneousFixture self) -> ScalarFieldType
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_HeterogeneousFixture>
delete_HeterogeneousFixture(HeterogeneousFixture self)

-stk_classic::percept::HeterogeneousFixture::~HeterogeneousFixture()
- -
__swig_getmethods__ = {'m_block_hex': <built-in function HeterogeneousFixture_m_block_hex_get>, 'm_block_pyramid': <built-in function HeterogeneousFixture_m_block_pyramid_get>, 'm_block_tet': <built-in function HeterogeneousFixture_m_block_tet_get>, 'm_block_wedge': <built-in function HeterogeneousFixture_m_block_wedge_get>, 'm_bulkData': <built-in function HeterogeneousFixture_m_bulkData_get>, 'm_centroid_field': <built-in function HeterogeneousFixture_m_centroid_field_get>, 'm_coordinates_field': <built-in function HeterogeneousFixture_m_coordinates_field_get>, 'm_elem_rank': <built-in function HeterogeneousFixture_m_elem_rank_get>, 'm_element_node_coordinates_field': <built-in function HeterogeneousFixture_m_element_node_coordinates_field_get>, 'm_metaData': <built-in function HeterogeneousFixture_m_metaData_get>, ...}
- -
__swig_setmethods__ = {'m_sideset_quad': <built-in function HeterogeneousFixture_m_sideset_quad_set>, 'm_sideset_quad_subset': <built-in function HeterogeneousFixture_m_sideset_quad_subset_set>, 'm_sideset_tri': <built-in function HeterogeneousFixture_m_sideset_tri_set>, 'm_sideset_tri_subset': <built-in function HeterogeneousFixture_m_sideset_tri_subset_set>}
- -

- - - - - - - -
 
-class L1Norm(__builtin__.object)
   This class will evaluate the L1 norm of a function.
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L1Norm
-__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE) -> L1Norm
-__init__(self, BulkData bulkData, string partName) -> L1Norm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L1Norm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE) -> L1Norm
-__init__(self, BulkData bulkData, MDArrayString partNames) -> L1Norm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L1Norm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE) -> L1Norm
-__init__(self, BulkData bulkData, Part part = None) -> L1Norm
-__init__(self, BulkData bulkData) -> L1Norm

-stk_classic::percept::Norm<
-Power >::Norm(mesh::BulkData &bulkData, mesh::Selector *selector,
-TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
error_check_is_surface_norm(self)
error_check_is_surface_norm(self)

-void stk_classic::percept::Norm< Power >::error_check_is_surface_norm()

-if a Selector is specified with part(s) that are not auto-declared,
-make sure all parts are of the same rank, and that m_is_surface_norm
-is set correctly (if not, warn...)
- -
evaluate(self, *args)
evaluate(self, Function integrand) -> double

-double
-stk_classic::percept::Norm< Power >::evaluate(Function &integrand)
- -
getCubDegree(self)
getCubDegree(self) -> unsigned int

-unsigned
-stk_classic::percept::Norm< Power >::getCubDegree()
- -
get_is_surface_norm(self)
get_is_surface_norm(self) -> bool

-bool
-stk_classic::percept::Norm< Power >::get_is_surface_norm()
- -
setCubDegree(self, *args)
setCubDegree(self, unsigned int cubDegree)

-void
-stk_classic::percept::Norm< Power >::setCubDegree(unsigned cubDegree)
- -
set_is_surface_norm(self, *args)
set_is_surface_norm(self, bool is_surface_norm)

-void
-stk_classic::percept::Norm< Power >::set_is_surface_norm(bool is_surface_norm)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_L1Norm>
delete_L1Norm(L1Norm self)

-virtual
-stk_classic::percept::Norm< Power >::~Norm()
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class L2Norm(__builtin__.object)
   This class will evaluate the L2 norm of a function.
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L2Norm
-__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE) -> L2Norm
-__init__(self, BulkData bulkData, string partName) -> L2Norm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L2Norm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE) -> L2Norm
-__init__(self, BulkData bulkData, MDArrayString partNames) -> L2Norm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> L2Norm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE) -> L2Norm
-__init__(self, BulkData bulkData, Part part = None) -> L2Norm
-__init__(self, BulkData bulkData) -> L2Norm

-stk_classic::percept::Norm<
-Power >::Norm(mesh::BulkData &bulkData, mesh::Selector *selector,
-TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
error_check_is_surface_norm(self)
error_check_is_surface_norm(self)

-void stk_classic::percept::Norm< Power >::error_check_is_surface_norm()

-if a Selector is specified with part(s) that are not auto-declared,
-make sure all parts are of the same rank, and that m_is_surface_norm
-is set correctly (if not, warn...)
- -
evaluate(self, *args)
evaluate(self, Function integrand) -> double

-double
-stk_classic::percept::Norm< Power >::evaluate(Function &integrand)
- -
getCubDegree(self)
getCubDegree(self) -> unsigned int

-unsigned
-stk_classic::percept::Norm< Power >::getCubDegree()
- -
get_is_surface_norm(self)
get_is_surface_norm(self) -> bool

-bool
-stk_classic::percept::Norm< Power >::get_is_surface_norm()
- -
setCubDegree(self, *args)
setCubDegree(self, unsigned int cubDegree)

-void
-stk_classic::percept::Norm< Power >::setCubDegree(unsigned cubDegree)
- -
set_is_surface_norm(self, *args)
set_is_surface_norm(self, bool is_surface_norm)

-void
-stk_classic::percept::Norm< Power >::set_is_surface_norm(bool is_surface_norm)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_L2Norm>
delete_L2Norm(L2Norm self)

-virtual
-stk_classic::percept::Norm< Power >::~Norm()
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class LInfNorm(__builtin__.object)
   This class will evaluate the L-inf norm of a function.
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> LInfNorm
-__init__(self, BulkData bulkData, string partName, TurboOption turboOpt = TURBO_NONE) -> LInfNorm
-__init__(self, BulkData bulkData, string partName) -> LInfNorm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> LInfNorm
-__init__(self, BulkData bulkData, MDArrayString partNames, TurboOption turboOpt = TURBO_NONE) -> LInfNorm
-__init__(self, BulkData bulkData, MDArrayString partNames) -> LInfNorm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE, 
-    bool is_surface_norm = False) -> LInfNorm
-__init__(self, BulkData bulkData, Part part = None, TurboOption turboOpt = TURBO_NONE) -> LInfNorm
-__init__(self, BulkData bulkData, Part part = None) -> LInfNorm
-__init__(self, BulkData bulkData) -> LInfNorm

-stk_classic::percept::Norm<
-Power >::Norm(mesh::BulkData &bulkData, mesh::Selector *selector,
-TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
error_check_is_surface_norm(self)
error_check_is_surface_norm(self)

-void stk_classic::percept::Norm< Power >::error_check_is_surface_norm()

-if a Selector is specified with part(s) that are not auto-declared,
-make sure all parts are of the same rank, and that m_is_surface_norm
-is set correctly (if not, warn...)
- -
evaluate(self, *args)
evaluate(self, Function integrand) -> double

-double
-stk_classic::percept::Norm< Power >::evaluate(Function &integrand)
- -
getCubDegree(self)
getCubDegree(self) -> unsigned int

-unsigned
-stk_classic::percept::Norm< Power >::getCubDegree()
- -
get_is_surface_norm(self)
get_is_surface_norm(self) -> bool

-bool
-stk_classic::percept::Norm< Power >::get_is_surface_norm()
- -
setCubDegree(self, *args)
setCubDegree(self, unsigned int cubDegree)

-void
-stk_classic::percept::Norm< Power >::setCubDegree(unsigned cubDegree)
- -
set_is_surface_norm(self, *args)
set_is_surface_norm(self, bool is_surface_norm)

-void
-stk_classic::percept::Norm< Power >::set_is_surface_norm(bool is_surface_norm)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_LInfNorm>
delete_LInfNorm(LInfNorm self)

-virtual
-stk_classic::percept::Norm< Power >::~Norm()
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class MDArray(__builtin__.object)
   Proxy of C++ Intrepid::FieldContainer<(double)> class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> MDArray
-__init__(self, MDArray right) -> MDArray
-__init__(self, int dim0) -> MDArray
-__init__(self, int dim0, int dim1) -> MDArray
-__init__(self, int dim0, int dim1, int dim2) -> MDArray
-__init__(self, int dim0, int dim1, int dim2, int dim3) -> MDArray
-__init__(self, int dim0, int dim1, int dim2, int dim3, int dim4) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions, Teuchos::ArrayView<(double)> data) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions, Teuchos::ArrayRCP<(double)> data) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions, double data, bool deep_copy = False, 
-    bool owns_mem = False) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions, double data, bool deep_copy = False) -> MDArray
-__init__(self, Teuchos::Array<(int)> dimensions, double data) -> MDArray
-__init__(self, shards::Array<(double,shards::NaturalOrder)> data, 
-    bool deep_copy = False, bool owns_mem = False) -> MDArray
-__init__(self, shards::Array<(double,shards::NaturalOrder)> data, 
-    bool deep_copy = False) -> MDArray
-__init__(self, shards::Array<(double,shards::NaturalOrder)> data) -> MDArray
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
clear(self)
clear(self)
- -
dimension(self, *args)
dimension(self, int whichDim) -> int
- -
getData(self)
getData(self) -> Teuchos::ArrayRCP<(double)>
- -
getEnumeration(self, *args)
getEnumeration(self, int i0) -> int
-getEnumeration(self, int i0, int i1) -> int
-getEnumeration(self, int i0, int i1, int i2) -> int
-getEnumeration(self, int i0, int i1, int i2, int i3) -> int
-getEnumeration(self, int i0, int i1, int i2, int i3, int i4) -> int
-getEnumeration(self, Teuchos::Array<(int)> multiIndex) -> int
- -
getMultiIndex(self, *args)
getMultiIndex(self, int i0, int valueEnum)
-getMultiIndex(self, int i0, int i1, int valueEnum)
-getMultiIndex(self, int i0, int i1, int i2, int valueEnum)
-getMultiIndex(self, int i0, int i1, int i2, int i3, int valueEnum)
-getMultiIndex(self, int i0, int i1, int i2, int i3, int i4, int valueEnum)
- -
getValue(self, *args)
getValue(self, Teuchos::Array<(int)> multiIndex) -> double
- -
initialize(self, value=0)
initialize(self, double value = 0)
-initialize(self)
- -
rank(self)
rank(self) -> int
- -
resize(self, *args)
resize(self, int dim0)
-resize(self, int dim0, int dim1)
-resize(self, int dim0, int dim1, int dim2)
-resize(self, int dim0, int dim1, int dim2, int dim3)
-resize(self, int dim0, int dim1, int dim2, int dim3, int dim4)
-resize(self, Teuchos::Array<(int)> newDimensions)
-resize(self, MDArray anotherContainer)
-resize(self, int numPoints, int numFields, EFunctionSpace spaceType, 
-    EOperator operatorType, int spaceDim)
- -
setValue(self, *args)
setValue(self, double dataValue, Teuchos::Array<(int)> multiIndex)
-setValue(self, double dataValue, int order)
- -
setValues(self, *args)
setValues(self, Teuchos::ArrayView<(double)> dataArray)
-setValues(self, double dataPtr, int numData)
- -
size(self)
size(self) -> int
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_MDArray>
delete_MDArray(MDArray self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class MDArrayString(__builtin__.object)
   Proxy of C++ stk_classic::percept::MDArrayString class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> MDArrayString
-__init__(self, int dim) -> MDArrayString
-__init__(self, int dim0, int dim1) -> MDArrayString
-__init__(self, MDArrayString mda) -> MDArrayString

-stk_classic::percept::MDArrayString::MDArrayString(const MDArrayString &mda)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
dimension(self, *args)
dimension(self, int i1) -> int

-int
-stk_classic::percept::MDArrayString::dimension(int i1) const
- -
rank(self)
rank(self) -> int

-const int
-stk_classic::percept::MDArrayString::rank() const
- -
resize(self, *args)
resize(self, int dim)
-resize(self, int dim0, int dim1)

-void
-stk_classic::percept::MDArrayString::resize(int dim0, int dim1)
- -
setValues(self, *args)
setValues(self, string data)

-void
-stk_classic::percept::MDArrayString::setValues(std::string *data)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_MDArrayString>
delete_MDArrayString(MDArrayString self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class MaxOfNodeValues(Function)
   Proxy of C++ stk_classic::percept::MaxOfNodeValues class
 
 
Method resolution order:
-
MaxOfNodeValues
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
m_integrand
-
MaxOfNodeValues_m_integrand_get(MaxOfNodeValues self) -> Function
-
-
maxVal
-
MaxOfNodeValues_maxVal_get(MaxOfNodeValues self) -> vectord
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_MaxOfNodeValues>
delete_MaxOfNodeValues(MaxOfNodeValues self)
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'm_integrand': <built-in function MaxOfNodeValues_m_integrand_get>, 'maxVal': <built-in function MaxOfNodeValues_maxVal_get>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {'m_integrand': <built-in function MaxOfNodeValues_m_integrand_set>, 'maxVal': <built-in function MaxOfNodeValues_maxVal_set>}
- -
-Methods inherited from Function:
-
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual
-Teuchos::RCP<Function >
-stk_classic::percept::Function::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::Function::gradient(int
-spatialDim=3)
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods inherited from Function:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes inherited from Function:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - - - -
 
-class MeshTransformer(__builtin__.object)
   Proxy of C++ stk_classic::percept::MeshTransformer class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> MeshTransformer
-__init__(self, Math::Matrix m) -> MeshTransformer

-stk_classic::percept::MeshTransformer::MeshTransformer(Math::Matrix &m)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_MeshTransformer>
delete_MeshTransformer(MeshTransformer self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Name(__builtin__.object)
   Useful in other places where two strings are passed into a function or
-constructor.

-this is to avoid a common bug where the name of the String Function is
-given instead of function_string, ie., first two args are accidentally
-reversed - this is essentially a model of a "named argument", as
-opposed to a positional one; of course, it is still only a hint
-(though a strong one) to the user

-C++ includes: Name.hpp
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, string name) -> Name

-stk_classic::percept::Name::Name(const std::string name)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
getName(self)
getName(self) -> string

-const
-std::string& stk_classic::percept::Name::getName() const
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_Name>
delete_Name(Name self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class OpType(__builtin__.object)
   Proxy of C++ stk_classic::mesh::OpType class
 
 Methods defined here:
-
__eq__(self, *args)
__eq__(self, OpType opType) -> bool
- -
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self) -> OpType
-__init__(self, unsigned int part_id, unsigned int unary, unsigned int count, 
-    Op op = INVALID) -> OpType
-__init__(self, unsigned int part_id, unsigned int unary, unsigned int count) -> OpType
- -
__ne__(self, *args)
__ne__(self, OpType opType) -> bool
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
m_count
-
OpType_m_count_get(OpType self) -> unsigned short
-
-
m_op
-
OpType_m_op_get(OpType self) -> Op
-
-
m_part_id
-
OpType_m_part_id_get(OpType self) -> unsigned int
-
-
m_unary
-
OpType_m_unary_get(OpType self) -> unsigned short
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_OpType>
delete_OpType(OpType self)
- -
__swig_getmethods__ = {'m_count': <built-in function OpType_m_count_get>, 'm_op': <built-in function OpType_m_op_get>, 'm_part_id': <built-in function OpType_m_part_id_get>, 'm_unary': <built-in function OpType_m_unary_get>}
- -
__swig_setmethods__ = {'m_count': <built-in function OpType_m_count_set>, 'm_op': <built-in function OpType_m_op_set>, 'm_part_id': <built-in function OpType_m_part_id_set>, 'm_unary': <built-in function OpType_m_unary_set>}
- -

- - - - - - - -
 
-class Part(__builtin__.object)
   Proxy of C++ stk_classic::mesh::Part class
 
 Methods defined here:
-
__eq__(self, *args)
__eq__(self, Part rhs) -> bool
- -
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__ne__(self, *args)
__ne__(self, Part rhs) -> bool
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
intersection_of(self)
intersection_of(self) -> PartVector
- -
mesh_meta_data(self)
mesh_meta_data(self) -> MetaData
- -
mesh_meta_data_ordinal(self)
mesh_meta_data_ordinal(self) -> unsigned int
- -
name(self)
name(self) -> string
- -
primary_entity_rank(self)
primary_entity_rank(self) -> unsigned int
- -
relations(self)
relations(self) -> std::vector<(PartRelation,std::allocator<(PartRelation)>)>
- -
subsets(self)
subsets(self) -> PartVector
- -
supersets(self)
supersets(self) -> PartVector
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class PartLess(__builtin__.object)
   Proxy of C++ stk_classic::mesh::PartLess class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> PartLess
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_PartLess>
delete_PartLess(PartLess self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class PartOrdLess(__builtin__.object)
   Proxy of C++ stk_classic::mesh::PartOrdLess class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> PartOrdLess
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_PartOrdLess>
delete_PartOrdLess(PartOrdLess self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class PerceptMesh(__builtin__.object)
   Proxy of C++ stk_classic::percept::PerceptMesh class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, size_t spatialDimension = 3u, ParallelMachine comm = MPI_COMM_WORLD) -> PerceptMesh
-__init__(self, size_t spatialDimension = 3u) -> PerceptMesh
-__init__(self) -> PerceptMesh
-__init__(self, FEMMetaData metaData, BulkData bulkData, bool isCommitted = True) -> PerceptMesh
-__init__(self, FEMMetaData metaData, BulkData bulkData) -> PerceptMesh

-stk_classic::percept::PerceptMesh::PerceptMesh(const
-stk_classic::mesh::fem::FEMMetaData *metaData, stk_classic::mesh::BulkData *bulkData,
-bool isCommitted=true)

-Create a Mesh object that doesn't own its constituent FEMMetaData and
-BulkData, pointers to which are adopted by this constructor.
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
add_coordinate_state_fields(self)
add_coordinate_state_fields(self)

-void
-stk_classic::percept::PerceptMesh::add_coordinate_state_fields()

-add coordinate-like fields needed, for example, to use smoothing of
-geometry-projected refined meshes Must be called before commit()
- -
add_field(self, *args)
add_field(self, string name, unsigned int entity_rank, int vectorDimension = 0, 
-    string part_name = "universal_part") -> FieldBase
-add_field(self, string name, unsigned int entity_rank, int vectorDimension = 0) -> FieldBase
-add_field(self, string name, unsigned int entity_rank) -> FieldBase

-stk_classic::mesh::FieldBase* stk_classic::percept::PerceptMesh::add_field(const
-std::string &name, const unsigned entity_rank, int vectorDimension=0,
-const std::string part_name="universal_part")

-add a field to the mesh
- -
add_spacing_fields(self)
add_spacing_fields(self)

-void stk_classic::percept::PerceptMesh::add_spacing_fields()

-add spacing fields for having refinement obey the spacing (i.e.
-putting new nodes not at midpoint)
- -
close(self)
close(self)

-void
-stk_classic::percept::PerceptMesh::close()

-closes this mesh, deleting its data

-closes this mesh to further changes
- -
commit(self)
commit(self)

-void
-stk_classic::percept::PerceptMesh::commit()

-commits mesh - any operations done on a non-committed mesh, except to
-add fields will throw an exception
- -
copy_field(self, *args)
copy_field(self, FieldBase field_dest, FieldBase field_src)

-void
-stk_classic::percept::PerceptMesh::copy_field(stk_classic::mesh::FieldBase
-*field_dest, stk_classic::mesh::FieldBase *field_src)

-copy field data from one field (field_src) to another (field_dest)
- -
copy_field_state(self, *args)
copy_field_state(self, FieldBase field, unsigned int dest_state, unsigned int src_state)

-void stk_classic::percept::PerceptMesh::copy_field_state(stk_classic::mesh::FieldBase
-*field, unsigned dest_state, unsigned src_state)

-copy field state data from one state (src_state) to another
-(dest_state)
- -
dump_elements(self, partName='')
dump_elements(self, string partName = "")
-dump_elements(self)

-void
-stk_classic::percept::PerceptMesh::dump_elements(const std::string
-&partName="")

-print elements on the given part
- -
dump_elements_compact(self, partName='')
dump_elements_compact(self, string partName = "")
-dump_elements_compact(self)

-void
-stk_classic::percept::PerceptMesh::dump_elements_compact(const std::string
-&partName="")

-compact print of elements on the given part
- -
edge_rank(self)
edge_rank(self) -> EntityRank

-stk_classic::mesh::EntityRank stk_classic::percept::PerceptMesh::edge_rank() const

-Returns the edge rank which changes depending on spatial dimension.
- -
element_rank(self)
element_rank(self) -> EntityRank

-stk_classic::mesh::EntityRank stk_classic::percept::PerceptMesh::element_rank() const

-Returns the element rank which is always equal to spatial dimension.
- -
face_rank(self)
face_rank(self) -> EntityRank

-stk_classic::mesh::EntityRank stk_classic::percept::PerceptMesh::face_rank() const

-Returns the face rank which changes depending on spatial dimension.
- -
get_bulk_data(self)
get_bulk_data(self) -> BulkData

-stk_classic::mesh::BulkData * stk_classic::percept::PerceptMesh::get_bulk_data()

-get the low-level bulk data pointer from stk_mesh
- -
get_coordinates_field(self)
get_coordinates_field(self) -> VectorFieldType

-VectorFieldType*
-stk_classic::percept::PerceptMesh::get_coordinates_field()

-return a pointer to the field containing node coordinates
- -
get_current_database_step(self)
get_current_database_step(self) -> int

-int
-stk_classic::percept::PerceptMesh::get_current_database_step()

-return the current state of the Exodus database, 0 if not loaded yet
-(steps are 1-based in Exodus)
- -
get_current_database_time(self)
get_current_database_time(self) -> double

-double
-stk_classic::percept::PerceptMesh::get_current_database_time()

-return the current state of the Exodus database (time associated with
-current step)
- -
get_database_step_at_time(self, *args)
get_database_step_at_time(self, double time) -> int

-int
-stk_classic::percept::PerceptMesh::get_database_step_at_time(double time)

-return the step number closest to specified time, thus
-read_database_at_time(time) is equivalent to
-read_database_at_step(get_database_step_at_time(time))
- -
get_database_time_at_step(self, *args)
get_database_time_at_step(self, int step) -> double

-double
-stk_classic::percept::PerceptMesh::get_database_time_at_step(int step)

-return the state time associated with given step
- -
get_database_time_step_count(self)
get_database_time_step_count(self) -> int

-int
-stk_classic::percept::PerceptMesh::get_database_time_step_count()

-return the number of steps in the database
- -
get_element(self, *args)
get_element(self, EntityId element_id) -> Entity
-get_element(self, double x, double y, double z = 0, double t = 0) -> Entity
-get_element(self, double x, double y, double z = 0) -> Entity
-get_element(self, double x, double y) -> Entity

-stk_classic::mesh::Entity * stk_classic::percept::PerceptMesh::get_element(double x,
-double y, double z=0, double t=0)

-find and return pointer to element that contains given point - in
-parallel, check return for null (if null, element containing point is
-on another proc)

-find element that contains or is closest to given point
- -
get_entity(self, *args)
get_entity(self, EntityRank rank, EntityId id) -> Entity

-stk_classic::mesh::Entity*
-stk_classic::percept::PerceptMesh::get_entity(mesh::EntityRank rank, const
-mesh::EntityId id)

-get a pointer to an entity with given id
- -
get_fem_meta_data(self)
get_fem_meta_data(self) -> FEMMetaData

-stk_classic::mesh::fem::FEMMetaData *
-stk_classic::percept::PerceptMesh::get_fem_meta_data()

-get the low-level meta data pointer from stk_mesh
- -
get_field(self, *args)
get_field(self, string name) -> FieldBase

-stk_classic::mesh::FieldBase * stk_classic::percept::PerceptMesh::get_field(const
-std::string &name)
- -
get_field_data(self, *args)
get_field_data(self, FieldBase field, Entity entity, unsigned int ordinal = 0) -> double
-get_field_data(self, FieldBase field, Entity entity) -> double

-double stk_classic::percept::PerceptMesh::get_field_data(const
-stk_classic::mesh::FieldBase *field, const mesh::Entity *entity, unsigned
-ordinal=0)

-get the value of a field on the given entity; if a vector field, pass
-in the index of the vector required (ordinal)
- -
get_node(self, *args)
get_node(self, EntityId node_id) -> Entity
-get_node(self, double x, double y, double z = 0, double t = 0) -> Entity
-get_node(self, double x, double y, double z = 0) -> Entity
-get_node(self, double x, double y) -> Entity

-stk_classic::mesh::Entity * stk_classic::percept::PerceptMesh::get_node(double x,
-double y, double z=0, double t=0)

-find and return pointer to node closest to given point - in parallel,
-check return for null (if null, closest node is on another proc)
- -
get_node_field_data(self, *args)
get_node_field_data(self, FieldBase field, EntityId node_id, unsigned int ordinal = 0) -> double
-get_node_field_data(self, FieldBase field, EntityId node_id) -> double

-double
-stk_classic::percept::PerceptMesh::get_node_field_data(stk_classic::mesh::FieldBase
-*field, const mesh::EntityId node_id, unsigned ordinal=0)

-get the value of a field on the given node; if a vector field, pass in
-the index of the vector required (ordinal)
- -
get_number_edges(self)
get_number_edges(self) -> int

-int stk_classic::percept::PerceptMesh::get_number_edges()
- -
get_number_elements(self)
get_number_elements(self) -> int

-int stk_classic::percept::PerceptMesh::get_number_elements()
- -
get_number_elements_locally_owned(self)
get_number_elements_locally_owned(self) -> int

-int
-stk_classic::percept::PerceptMesh::get_number_elements_locally_owned()
- -
get_number_nodes(self)
get_number_nodes(self) -> int

-int stk_classic::percept::PerceptMesh::get_number_nodes()
- -
get_parallel_rank(self)
get_parallel_rank(self) -> unsigned int

-unsigned stk_classic::percept::PerceptMesh::get_parallel_rank()
- -
get_parallel_size(self)
get_parallel_size(self) -> unsigned int

-unsigned stk_classic::percept::PerceptMesh::get_parallel_size()
- -
get_part(self, *args)
get_part(self, string part_name) -> Part

-mesh::Part* stk_classic::percept::PerceptMesh::get_part(const std::string
-&part_name)

-get a pointer to a stk_mesh Part with the given name
- -
get_rank(self)
get_rank(self) -> unsigned int

-unsigned
-stk_classic::percept::PerceptMesh::get_rank()

-parallel rank
- -
get_spatial_dim(self)
get_spatial_dim(self) -> int

-int stk_classic::percept::PerceptMesh::get_spatial_dim()
- -
has_coordinate_state_fields(self)
has_coordinate_state_fields(self) -> bool

-bool
-stk_classic::percept::PerceptMesh::has_coordinate_state_fields()

-get number of coordinate field states needed
- -
new_mesh(self, *args)
new_mesh(self, GMeshSpec gmesh_spec)

-void
-stk_classic::percept::PerceptMesh::new_mesh(const GMeshSpec gmesh_spec)

-creates a new mesh using the GeneratedMesh fixture with spec

-Parameters:
------------

-gmesh_spec:
- -
new_mesh_read_only(self, *args)
new_mesh_read_only(self, GMeshSpec gmesh_spec)

-void stk_classic::percept::PerceptMesh::new_mesh_read_only(const GMeshSpec
-gmesh_spec)

-creates a new mesh using the GeneratedMesh fixture with spec

-Parameters:
------------

-gmesh_spec:  Read:  Only mode, no edits allowed
- -
nodal_field_axpby(self, *args)
nodal_field_axpby(self, double alpha, FieldBase field_x, double beta, FieldBase field_y)

-void stk_classic::percept::PerceptMesh::nodal_field_axpby(double alpha,
-stk_classic::mesh::FieldBase *field_x, double beta, stk_classic::mesh::FieldBase
-*field_y)

-axpby calculates: y = alpha*x + beta*y
- -
nodal_field_axpbypgz(self, *args)
nodal_field_axpbypgz(self, double alpha, FieldBase field_x, double beta, FieldBase field_y, 
-    double gamma, FieldBase field_z)

-void stk_classic::percept::PerceptMesh::nodal_field_axpbypgz(double alpha,
-stk_classic::mesh::FieldBase *field_x, double beta, stk_classic::mesh::FieldBase
-*field_y, double gamma, stk_classic::mesh::FieldBase *field_z)

-axpbypgz calculates: z = alpha*x + beta*y + gamma*z
- -
nodal_field_dot(self, *args)
nodal_field_dot(self, FieldBase field_x, FieldBase field_y) -> double

-double stk_classic::percept::PerceptMesh::nodal_field_dot(stk_classic::mesh::FieldBase
-*field_x, stk_classic::mesh::FieldBase *field_y)

-dot calculates: x.y
- -
nodal_field_set_value(self, *args)
nodal_field_set_value(self, FieldBase field_x, double value = 0.0)
-nodal_field_set_value(self, FieldBase field_x)

-void
-stk_classic::percept::PerceptMesh::nodal_field_set_value(stk_classic::mesh::FieldBase
-*field_x, double value=0.0)

-set field to constant value
- -
nodal_field_state_axpby(self, *args)
nodal_field_state_axpby(self, FieldBase field, double alpha, unsigned int x_state, 
-    double beta, unsigned int y_state)

-void
-stk_classic::percept::PerceptMesh::nodal_field_state_axpby(stk_classic::mesh::FieldBase
-*field, double alpha, unsigned x_state, double beta, unsigned y_state)

-axpby calculates: y = alpha*x + beta*y
- -
nodal_field_state_axpbypgz(self, *args)
nodal_field_state_axpbypgz(self, FieldBase field, double alpha, unsigned int x_state, 
-    double beta, unsigned int y_state, double gamma, 
-    unsigned int z_state)

-void
-stk_classic::percept::PerceptMesh::nodal_field_state_axpbypgz(stk_classic::mesh::FieldBase
-*field, double alpha, unsigned x_state, double beta, unsigned y_state,
-double gamma, unsigned z_state)

-axpbypgz calculates: z = alpha*x + beta*y + gamma*z
- -
node_rank(self)
node_rank(self) -> EntityRank

-stk_classic::mesh::EntityRank stk_classic::percept::PerceptMesh::node_rank() const

-return the rank of a node
- -
open(self, *args)
open(self, string in_filename)

-void
-stk_classic::percept::PerceptMesh::open(const std::string &in_filename)

-reads but doesn't commit mesh, enabling edit
- -
open_read_only(self, *args)
open_read_only(self, string in_filename)

-void stk_classic::percept::PerceptMesh::open_read_only(const std::string
-&in_filename)

-reads and commits mesh, editing disabled
- -
print_entity(self, *args)
print_entity(self, Entity entity, FieldBase field = None)
-print_entity(self, Entity entity)

-void
-stk_classic::percept::PerceptMesh::print_entity(std::ostream &out, const
-stk_classic::mesh::Entity &entity, stk_classic::mesh::FieldBase *field=0)
- -
print_entity_compact(self, *args)
print_entity_compact(self, Entity entity, FieldBase field = None) -> string
-print_entity_compact(self, Entity entity) -> string

-std::string stk_classic::percept::PerceptMesh::print_entity_compact(const
-stk_classic::mesh::Entity &entity, stk_classic::mesh::FieldBase *field=0)

-shorter output for print_entity
- -
print_fields(self, header='')
print_fields(self, string header = "")
-print_fields(self)

-void
-stk_classic::percept::PerceptMesh::print_fields(std::string header="")

-print the fields defined on the mesh
- -
print_info(self, *args)
print_info(self, std::ostream stream, string header = "", int print_level = 0, 
-    bool do_endl = True)
-print_info(self, std::ostream stream, string header = "", int print_level = 0)
-print_info(self, std::ostream stream, string header = "")
-print_info(self, std::ostream stream)
-print_info(self, string header = "", int print_level = 0, bool do_endl = True)
-print_info(self, string header = "", int print_level = 0)
-print_info(self, string header = "")
-print_info(self)

-void
-stk_classic::percept::PerceptMesh::print_info(std::string header="", int
-print_level=0, bool do_endl=true)

-print number of parts and fields, and info on each
- -
read_database_at_step(self, *args)
read_database_at_step(self, int step)

-void
-stk_classic::percept::PerceptMesh::read_database_at_step(int step)

-set the current data in fields to the given Exodus step by reading
-from the database
- -
read_database_at_time(self, *args)
read_database_at_time(self, double time)

-void
-stk_classic::percept::PerceptMesh::read_database_at_time(double time)

-set the current data in fields to the given Exodus time by reading
-from the database (finds the closest step to the given time (no
-interpolation yet))
- -
remove_geometry_blocks_on_output(self, *args)
remove_geometry_blocks_on_output(self, string geometry_file_name)

-void
-stk_classic::percept::PerceptMesh::remove_geometry_blocks_on_output(std::string
-geometry_file_name)

-remove blocks in the mesh used solely for geometry association, during
-output of the mesh to Exodus.

-Parameters:
------------

-geometry_file_name:  = name of the OpenNURBS file (*.3dm) containing
-the geometry info

-Only available when Percept is configured with
-STK_PERCEPT_HAS_GEOMETRY
- -
reopen(self, temp_file_name='percept_tmp.e')
reopen(self, string temp_file_name = "percept_tmp.e")
-reopen(self)

-void
-stk_classic::percept::PerceptMesh::reopen(const std::string
-temp_file_name="percept_tmp.e")

-reopens the mesh for editing - warning, this operation writes the mesh
-to a temp file then re-reads it and thus recreates the internal
-FEMMetaData and BulkData
- -
save_as(self, *args)
save_as(self, string out_filename)

-void
-stk_classic::percept::PerceptMesh::save_as(const std::string &out_filename)

-commits mesh if not committed and saves it in new file
- -
set_field_data(self, *args)
set_field_data(self, double value, FieldBase field, Entity entity, unsigned int ordinal = 0)
-set_field_data(self, double value, FieldBase field, Entity entity)

-void stk_classic::percept::PerceptMesh::set_field_data(double value, const
-stk_classic::mesh::FieldBase *field, const mesh::Entity *entity, unsigned
-ordinal=0)

-set the value of a field on the given entity; if a vector field, pass
-in the index of the vector required (ordinal)
- -
set_node_field_data(self, *args)
set_node_field_data(self, double value, FieldBase field, EntityId node_id, unsigned int ordinal = 0)
-set_node_field_data(self, double value, FieldBase field, EntityId node_id)

-void stk_classic::percept::PerceptMesh::set_node_field_data(double value,
-stk_classic::mesh::FieldBase *field, const mesh::EntityId node_id, unsigned
-ordinal=0)

-set the value of a field on the given node; if a vector field, pass in
-the index of the vector required (ordinal)
- -
set_proc_rank_field(self, proc_rank_field=None)
set_proc_rank_field(self, FieldBase proc_rank_field = None)
-set_proc_rank_field(self)

-void
-stk_classic::percept::PerceptMesh::set_proc_rank_field(stk_classic::mesh::FieldBase
-*proc_rank_field=0)

-set proc_rank on each element
- -
side_rank(self)
side_rank(self) -> EntityRank

-stk_classic::mesh::EntityRank stk_classic::percept::PerceptMesh::side_rank() const

-Returns the side rank which changes depending on spatial dimension.
- -
transform_mesh(self, *args)
transform_mesh(self, MDArray matrix)

-void stk_classic::percept::PerceptMesh::transform_mesh(Math::Matrix &matrix)

-transform mesh by a given 3x3 matrix
- -
-Static methods defined here:
-
mesh_difference(*args)
mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg, bool _print = True, 
-    bool print_all_field_diffs = False) -> bool
-mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg, bool _print = True) -> bool
-mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg) -> bool
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
s_omit_part
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_PerceptMesh>
delete_PerceptMesh(PerceptMesh self)

-stk_classic::percept::PerceptMesh::~PerceptMesh()
- -
__swig_getmethods__ = {'mesh_difference': <function <lambda>>, 's_omit_part': <built-in function PerceptMesh_s_omit_part_get>}
- -
__swig_setmethods__ = {'s_omit_part': <built-in function PerceptMesh_s_omit_part_set>}
- -

- - - - - - - -
 
-class QuadFixture_3(__builtin__.object)
   This class creates a tri mesh.
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ParallelMachine pm, unsigned int nx, unsigned int ny, 
-    bool generate_sidesets_in, bool debug_geom_side_sets_as_blocks_in = False) -> QuadFixture_3
-__init__(self, ParallelMachine pm, unsigned int nx, unsigned int ny, 
-    bool generate_sidesets_in) -> QuadFixture_3

-stk_classic::percept::QuadFixture< Scalar, Topology
->::QuadFixture(stk_classic::ParallelMachine pm, unsigned nx, unsigned ny, bool
-generate_sidesets_in, bool debug_geom_side_sets_as_blocks_in=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
elem(self, *args)
elem(self, unsigned int ix, unsigned int iy) -> Entity

-stk_classic::mesh::Entity* stk_classic::percept::QuadFixture< Scalar, Topology
->::elem(unsigned ix, unsigned iy) const
- -
elem_id(self, *args)
elem_id(self, unsigned int ix, unsigned int iy) -> EntityId

-stk_classic::mesh::EntityId stk_classic::percept::QuadFixture< Scalar, Topology
->::elem_id(unsigned ix, unsigned iy) const
- -
elem_ix_iy(self, *args)
elem_ix_iy(self, EntityId entity_id, unsigned int ix, unsigned int iy)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::elem_ix_iy(stk_classic::mesh::EntityId entity_id, unsigned &ix, unsigned
-&iy) const
- -
generate_mesh(self, *args)
generate_mesh(self)
-generate_mesh(self, std::vector<(stk_classic::mesh::EntityId,std::allocator<(stk_classic::mesh::EntityId)>)> element_ids_on_this_processor)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_mesh(std::vector< stk_classic::mesh::EntityId >
-&element_ids_on_this_processor)
- -
generate_sides_bulk(self, *args)
generate_sides_bulk(self, std::vector<(stk_classic::mesh::EntityId,std::allocator<(stk_classic::mesh::EntityId)>)> element_ids_on_this_processor)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_sides_bulk(std::vector< stk_classic::mesh::EntityId >
-&element_ids_on_this_processor)
- -
generate_sides_meta(self)
generate_sides_meta(self)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_sides_meta()
- -
node(self, *args)
node(self, unsigned int ix, unsigned int iy) -> Entity

-stk_classic::mesh::Entity* stk_classic::percept::QuadFixture< Scalar, Topology
->::node(unsigned ix, unsigned iy) const
- -
node_id(self, *args)
node_id(self, unsigned int ix, unsigned int iy) -> EntityId

-stk_classic::mesh::EntityId stk_classic::percept::QuadFixture< Scalar, Topology
->::node_id(unsigned ix, unsigned iy) const
- -
node_ix_iy(self, *args)
node_ix_iy(self, EntityId entity_id, unsigned int ix, unsigned int iy)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::node_ix_iy(stk_classic::mesh::EntityId entity_id, unsigned &ix, unsigned
-&iy) const
- -
set_bounding_box(self, *args)
set_bounding_box(self, double xmin, double xmax, double ymin, double ymax)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::set_bounding_box(double xmin, double xmax, double ymin, double
-ymax)
- -
-Static methods defined here:
-
get_entity_rank_names(*args)
get_entity_rank_names(unsigned int dim) -> vectors
- -
-Data descriptors defined here:
-
NX
-
QuadFixture_3_NX_get(QuadFixture_3 self) -> unsigned int
-
-
NY
-
QuadFixture_3_NY_get(QuadFixture_3 self) -> unsigned int
-
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
bulk_data
-
QuadFixture_3_bulk_data_get(QuadFixture_3 self) -> BulkData
-
-
coord_field
-
QuadFixture_3_coord_field_get(QuadFixture_3 self) -> CoordFieldType
-
-
debug_geom_side_sets_as_blocks
-
QuadFixture_3_debug_geom_side_sets_as_blocks_get(QuadFixture_3 self) -> bool
-
-
generate_sidesets
-
QuadFixture_3_generate_sidesets_get(QuadFixture_3 self) -> bool
-
-
meta_data
-
QuadFixture_3_meta_data_get(QuadFixture_3 self) -> FEMMetaData
-
-
quad_part
-
QuadFixture_3_quad_part_get(QuadFixture_3 self) -> Part
-
-
side_parts
-
QuadFixture_3_side_parts_get(QuadFixture_3 self) -> Part
-
-
-Data and other attributes defined here:
-
NodesPerElem = 3
- -
__swig_destroy__ = <built-in function delete_QuadFixture_3>
delete_QuadFixture_3(QuadFixture_3 self)

-stk_classic::percept::QuadFixture< Scalar, Topology >::~QuadFixture()
- -
__swig_getmethods__ = {'NX': <built-in function QuadFixture_3_NX_get>, 'NY': <built-in function QuadFixture_3_NY_get>, 'bulk_data': <built-in function QuadFixture_3_bulk_data_get>, 'coord_field': <built-in function QuadFixture_3_coord_field_get>, 'debug_geom_side_sets_as_blocks': <built-in function QuadFixture_3_debug_geom_side_sets_as_blocks_get>, 'generate_sidesets': <built-in function QuadFixture_3_generate_sidesets_get>, 'get_entity_rank_names': <function <lambda>>, 'meta_data': <built-in function QuadFixture_3_meta_data_get>, 'quad_part': <built-in function QuadFixture_3_quad_part_get>, 'side_parts': <built-in function QuadFixture_3_side_parts_get>}
- -
__swig_setmethods__ = {'debug_geom_side_sets_as_blocks': <built-in function QuadFixture_3_debug_geom_side_sets_as_blocks_set>, 'generate_sidesets': <built-in function QuadFixture_3_generate_sidesets_set>, 'side_parts': <built-in function QuadFixture_3_side_parts_set>}
- -

- - - - - - - -
 
-class QuadFixture_4(__builtin__.object)
   This class creates a quad mesh.
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ParallelMachine pm, unsigned int nx, unsigned int ny, 
-    bool generate_sidesets_in, bool debug_geom_side_sets_as_blocks_in = False) -> QuadFixture_4
-__init__(self, ParallelMachine pm, unsigned int nx, unsigned int ny, 
-    bool generate_sidesets_in) -> QuadFixture_4

-stk_classic::percept::QuadFixture< Scalar, Topology
->::QuadFixture(stk_classic::ParallelMachine pm, unsigned nx, unsigned ny, bool
-generate_sidesets_in, bool debug_geom_side_sets_as_blocks_in=false)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
elem(self, *args)
elem(self, unsigned int ix, unsigned int iy) -> Entity

-stk_classic::mesh::Entity* stk_classic::percept::QuadFixture< Scalar, Topology
->::elem(unsigned ix, unsigned iy) const
- -
elem_id(self, *args)
elem_id(self, unsigned int ix, unsigned int iy) -> EntityId

-stk_classic::mesh::EntityId stk_classic::percept::QuadFixture< Scalar, Topology
->::elem_id(unsigned ix, unsigned iy) const
- -
elem_ix_iy(self, *args)
elem_ix_iy(self, EntityId entity_id, unsigned int ix, unsigned int iy)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::elem_ix_iy(stk_classic::mesh::EntityId entity_id, unsigned &ix, unsigned
-&iy) const
- -
generate_mesh(self, *args)
generate_mesh(self)
-generate_mesh(self, std::vector<(stk_classic::mesh::EntityId,std::allocator<(stk_classic::mesh::EntityId)>)> element_ids_on_this_processor)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_mesh(std::vector< stk_classic::mesh::EntityId >
-&element_ids_on_this_processor)
- -
generate_sides_bulk(self, *args)
generate_sides_bulk(self, std::vector<(stk_classic::mesh::EntityId,std::allocator<(stk_classic::mesh::EntityId)>)> element_ids_on_this_processor)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_sides_bulk(std::vector< stk_classic::mesh::EntityId >
-&element_ids_on_this_processor)
- -
generate_sides_meta(self)
generate_sides_meta(self)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::generate_sides_meta()
- -
node(self, *args)
node(self, unsigned int ix, unsigned int iy) -> Entity

-stk_classic::mesh::Entity* stk_classic::percept::QuadFixture< Scalar, Topology
->::node(unsigned ix, unsigned iy) const
- -
node_id(self, *args)
node_id(self, unsigned int ix, unsigned int iy) -> EntityId

-stk_classic::mesh::EntityId stk_classic::percept::QuadFixture< Scalar, Topology
->::node_id(unsigned ix, unsigned iy) const
- -
node_ix_iy(self, *args)
node_ix_iy(self, EntityId entity_id, unsigned int ix, unsigned int iy)

-void
-stk_classic::percept::QuadFixture< Scalar, Topology
->::node_ix_iy(stk_classic::mesh::EntityId entity_id, unsigned &ix, unsigned
-&iy) const
- -
set_bounding_box(self, *args)
set_bounding_box(self, double xmin, double xmax, double ymin, double ymax)

-void stk_classic::percept::QuadFixture< Scalar, Topology
->::set_bounding_box(double xmin, double xmax, double ymin, double
-ymax)
- -
-Static methods defined here:
-
get_entity_rank_names(*args)
get_entity_rank_names(unsigned int dim) -> vectors
- -
-Data descriptors defined here:
-
NX
-
QuadFixture_4_NX_get(QuadFixture_4 self) -> unsigned int
-
-
NY
-
QuadFixture_4_NY_get(QuadFixture_4 self) -> unsigned int
-
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
bulk_data
-
QuadFixture_4_bulk_data_get(QuadFixture_4 self) -> BulkData
-
-
coord_field
-
QuadFixture_4_coord_field_get(QuadFixture_4 self) -> CoordFieldType
-
-
debug_geom_side_sets_as_blocks
-
QuadFixture_4_debug_geom_side_sets_as_blocks_get(QuadFixture_4 self) -> bool
-
-
generate_sidesets
-
QuadFixture_4_generate_sidesets_get(QuadFixture_4 self) -> bool
-
-
meta_data
-
QuadFixture_4_meta_data_get(QuadFixture_4 self) -> FEMMetaData
-
-
quad_part
-
QuadFixture_4_quad_part_get(QuadFixture_4 self) -> Part
-
-
side_parts
-
QuadFixture_4_side_parts_get(QuadFixture_4 self) -> Part
-
-
-Data and other attributes defined here:
-
NodesPerElem = 4
- -
__swig_destroy__ = <built-in function delete_QuadFixture_4>
delete_QuadFixture_4(QuadFixture_4 self)

-stk_classic::percept::QuadFixture< Scalar, Topology >::~QuadFixture()
- -
__swig_getmethods__ = {'NX': <built-in function QuadFixture_4_NX_get>, 'NY': <built-in function QuadFixture_4_NY_get>, 'bulk_data': <built-in function QuadFixture_4_bulk_data_get>, 'coord_field': <built-in function QuadFixture_4_coord_field_get>, 'debug_geom_side_sets_as_blocks': <built-in function QuadFixture_4_debug_geom_side_sets_as_blocks_get>, 'generate_sidesets': <built-in function QuadFixture_4_generate_sidesets_get>, 'get_entity_rank_names': <function <lambda>>, 'meta_data': <built-in function QuadFixture_4_meta_data_get>, 'quad_part': <built-in function QuadFixture_4_quad_part_get>, 'side_parts': <built-in function QuadFixture_4_side_parts_get>}
- -
__swig_setmethods__ = {'debug_geom_side_sets_as_blocks': <built-in function QuadFixture_4_debug_geom_side_sets_as_blocks_set>, 'generate_sidesets': <built-in function QuadFixture_4_generate_sidesets_set>, 'side_parts': <built-in function QuadFixture_4_side_parts_set>}
- -

- - - - - - - -
 
-class RCPComp(__builtin__.object)
   Proxy of C++ Teuchos::RCPComp class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> RCPComp
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_RCPComp>
delete_RCPComp(RCPComp self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class RCPConstComp(__builtin__.object)
   Proxy of C++ Teuchos::RCPConstComp class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> RCPConstComp
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_RCPConstComp>
delete_RCPConstComp(RCPConstComp self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class RCPFunction(__builtin__.object)
   Proxy of C++ Teuchos::RCP<(stk_classic::percept::Function)> class
 
 Methods defined here:
-
__deref__(self)
__deref__(self) -> Function
- -
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, ENull null_arg = null) -> RCPFunction
-__init__(self) -> RCPFunction
-__init__(self, Function p, bool has_ownership = True) -> RCPFunction
-__init__(self, Function p) -> RCPFunction
-__init__(self, RCPFunction r_ptr) -> RCPFunction
-__init__(self, Function p, ERCPWeakNoDealloc arg1) -> RCPFunction
-__init__(self, Function p, ERCPUndefinedWeakNoDealloc arg1) -> RCPFunction
-__init__(self, Function p, RCPNodeHandle node) -> RCPFunction
- -
__ref__(self)
__ref__(self) -> Function
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
access_private_node(self)
access_private_node(self) -> RCPNodeHandle
- -
access_private_ptr(self)
access_private_ptr(self) -> Function
- -
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in, MDArray out) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
assert_not_null(self)
assert_not_null(self) -> RCPFunction
- -
assert_valid_ptr(self)
assert_valid_ptr(self) -> RCPFunction
- -
count(self)
count(self) -> int
- -
create_strong(self)
create_strong(self) -> RCPFunction
- -
create_weak(self)
create_weak(self) -> RCPFunction
- -
debug_assert_not_null(self)
debug_assert_not_null(self) -> RCPFunction
- -
debug_assert_valid_ptr(self)
debug_assert_valid_ptr(self) -> RCPFunction
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-virtual
-Teuchos::RCP<Function >
-stk_classic::percept::Function::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
get(self)
get(self) -> Function
- -
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getConst(self)
getConst(self) -> Teuchos::RCP<(q(const).stk_classic::percept::Function)>
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
getNewMDArray(self, *args)
getNewMDArray(self, Dimensions dims) -> MDArray
- -
getRawPtr(self)
getRawPtr(self) -> Function
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-virtual
-Teuchos::RCP<Function > stk_classic::percept::Function::gradient(int
-spatialDim=3)
- -
has_ownership(self)
has_ownership(self) -> bool
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
is_null(self)
is_null(self) -> bool
- -
is_valid_ptr(self)
is_valid_ptr(self) -> bool
- -
nonconst_access_private_node(self)
nonconst_access_private_node(self) -> RCPNodeHandle
- -
ptr(self)
ptr(self) -> Teuchos::Ptr<(stk_classic::percept::Function)>
- -
release(self)
release(self) -> Teuchos::Ptr<(stk_classic::percept::Function)>
- -
reset(self)
reset(self)
- -
setCodomainDimDefault(self, *args)
setCodomainDimDefault(self, unsigned int codomainDim)
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
setIntegrationOrderDefault(self, *args)
setIntegrationOrderDefault(self, unsigned int integration_order)
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
setSpatialDimDefault(self, *args)
setSpatialDimDefault(self, unsigned int spatialDim)
- -
set_has_ownership(self)
set_has_ownership(self)
- -
strength(self)
strength(self) -> ERCPStrength
- -
strong_count(self)
strong_count(self) -> int
- -
swap(self, *args)
swap(self, RCPFunction r_ptr)
- -
total_count(self)
total_count(self) -> int
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
weak_count(self)
weak_count(self) -> int
- -
-Data descriptors defined here:
-
Identity
-
RCPFunction_Identity_get(RCPFunction self) -> Function
-
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_RCPFunction>
delete_RCPFunction(RCPFunction self)
- -
__swig_getmethods__ = {'Identity': <built-in function RCPFunction_Identity_get>}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Refiner(__builtin__.object)
   e.g. UniformRefiner<shards::Hex<8>, shards::Tet<4> >

-C++ includes: Refiner.hpp
 
 Methods defined here:
-
__basePatterns__(self)
__basePatterns__(self)

-The following is a list of patterns that may be used to create a Refiner object:
-BEAM2_BEAM2_2    
-BEAM2_BEAM3_1    
-BEAM3_BEAM3_2
-HEX20_HEX20_8   
-HEX27_HEX27_8   
-HEX8_HEX20_1
-HEX8_HEX27_1   
-HEX8_HEX8_8      
-HEX8_TET4_24
-HEX8_TET4_6_12    
-LINE2_LINE2_2     
-LINE3_LINE3_2
-QUAD4_QUAD4_4   
-QUAD4_QUAD4_4_OLD   
-QUAD4_QUAD4_4_SIERRA
-QUAD4_QUAD8_1   
-QUAD4_QUAD9_1      
-QUAD4_TRI3_2
-QUAD4_TRI3_4    
-QUAD4_TRI3_6        
-QUAD8_QUAD8_4
-QUAD9_QUAD9_4
-SHELLLINE2_SHELLLINE2_2            
-SHELLLINE3_SHELLLINE3_2
-SHELLLINE3_SHELLLINE3_2            
-SHELLQUAD4_SHELLQUAD8_1
-SHELLQUAD8_SHELLQUAD8_4            
-SHELLTRI3_SHELLTRI3_4
-SHELLTRI6_SHELLTRI6_4
-TET10_TET10_8    
-TET4_TET10_1    
-TET4_TET4_8
-TRI3_TRI3_4      
-TRI3_TRI6_1     
-TRI6_TRI6_4
-WEDGE15_WEDGE15_8    
-WEDGE18_WEDGE18_8
-WEDGE6_WEDGE15_1     
-WEDGE6_WEDGE18_1
-WEDGE6_WEDGE6_8
- -
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, PerceptMesh eMesh, UniformRefinerPatternBase bp, FieldBase proc_rank_field = None) -> Refiner
-__init__(self, PerceptMesh eMesh, UniformRefinerPatternBase bp) -> Refiner
-__init__(self, PerceptMesh eMesh, Pattern refine_type, FieldBase proc_rank_field = None) -> Refiner
-__init__(self, PerceptMesh eMesh, Pattern refine_type) -> Refiner

-stk_classic::adapt::Refiner::Refiner(percept::PerceptMesh &eMesh, Pattern
-refine_type, stk_classic::mesh::FieldBase *proc_rank_field=0)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
check_db(self, msg='')
check_db(self, string msg = "")
-check_db(self)

-void
-stk_classic::adapt::Refiner::check_db(std::string msg="")
- -
check_sidesets(self, msg='')
check_sidesets(self, string msg = "")
-check_sidesets(self)

-void
-stk_classic::adapt::Refiner::check_sidesets(std::string msg="")
- -
check_sidesets_1(self, *args)
check_sidesets_1(self, string msg)

-void
-stk_classic::adapt::Refiner::check_sidesets_1(std::string msg)
- -
check_sidesets_2(self, *args)
check_sidesets_2(self, string msg)

-void
-stk_classic::adapt::Refiner::check_sidesets_2(std::string msg)
- -
connectSides(self, *args)
connectSides(self, Entity element, Entity side_elem, SidePartMap side_part_map = None) -> bool
-connectSides(self, Entity element, Entity side_elem) -> bool

-bool
-stk_classic::adapt::Refiner::connectSides(stk_classic::mesh::Entity *element,
-stk_classic::mesh::Entity *side_elem, SidePartMap *side_part_map=0)
- -
deleteParentElements(self)
deleteParentElements(self)

-void stk_classic::adapt::Refiner::deleteParentElements()

-Delete all elements that aren't child elements.
- -
doBreak(self)
doBreak(self)

-void
-stk_classic::adapt::Refiner::doBreak()

-FIXME add part info

-communicate all-to-all the new node creation information which also
-updates the node registry so it can be queried locally now for any
-ghost or non-ghost element

-Global element ops: here's where we e.g. connect the new elements by
-declaring new relations
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

-Global node loop operations: this is where we perform ops like adding
-new nodes to the right parts, interpolating fields, etc.
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- -
fixElementSides2(self)
fixElementSides2(self)

-void
-stk_classic::adapt::Refiner::fixElementSides2()
- -
fixSides(self, *args)
fixSides(self, Entity parent)

-void
-stk_classic::adapt::Refiner::fixSides(stk_classic::mesh::Entity *parent)
- -
fix_side_sets_1(self)
fix_side_sets_1(self)

-void
-stk_classic::adapt::Refiner::fix_side_sets_1()
- -
fix_side_sets_2(self)
fix_side_sets_2(self)

-void
-stk_classic::adapt::Refiner::fix_side_sets_2()
- -
fix_side_sets_3(self, *args)
fix_side_sets_3(self, bool checkParentChild, SidePartMap side_part_map)

-void
-stk_classic::adapt::Refiner::fix_side_sets_3(bool checkParentChild,
-SidePartMap &side_part_map)
- -
getAlwaysInitializeNodeRegistry(self)
getAlwaysInitializeNodeRegistry(self) -> bool

-bool
-stk_classic::adapt::Refiner::getAlwaysInitializeNodeRegistry()
- -
getDoProgressMeter(self)
getDoProgressMeter(self) -> bool

-bool
-stk_classic::adapt::Refiner::getDoProgressMeter()
- -
getIgnoreSideSets(self)
getIgnoreSideSets(self) -> bool

-bool
-stk_classic::adapt::Refiner::getIgnoreSideSets()
- -
getMesh(self)
getMesh(self) -> PerceptMesh

-percept::PerceptMesh& stk_classic::adapt::Refiner::getMesh()
- -
getNodeRegistry(self)
getNodeRegistry(self) -> NodeRegistry

-NodeRegistry& stk_classic::adapt::Refiner::getNodeRegistry()
- -
getRefinementInfoByType(self)
getRefinementInfoByType(self) -> std::vector<(RefinementInfoByType,std::allocator<(RefinementInfoByType)>)>

-std::vector< RefinementInfoByType > &
-stk_classic::adapt::Refiner::getRefinementInfoByType()
- -
getRemoveGeometryBlocks(self)
getRemoveGeometryBlocks(self) -> bool

-bool stk_classic::adapt::Refiner::getRemoveGeometryBlocks()
- -
getRemoveOldElements(self)
getRemoveOldElements(self) -> bool

-bool stk_classic::adapt::Refiner::getRemoveOldElements()
- -
getSmoothGeometry(self)
getSmoothGeometry(self) -> bool

-bool
-stk_classic::adapt::Refiner::getSmoothGeometry()
- -
get_side_part_relations(self, *args)
get_side_part_relations(self, bool checkParentChild, SidePartMap side_part_map)

-void stk_classic::adapt::Refiner::get_side_part_relations(bool
-checkParentChild, SidePartMap &side_part_map)

-determine side part to elem part relations
- -
setAlwaysInitializeNodeRegistry(self, *args)
setAlwaysInitializeNodeRegistry(self, bool do_init)

-void
-stk_classic::adapt::Refiner::setAlwaysInitializeNodeRegistry(bool do_init)
- -
setDoProgressMeter(self, *args)
setDoProgressMeter(self, bool do_progress)

-void
-stk_classic::adapt::Refiner::setDoProgressMeter(bool do_progress)
- -
setGeometryFile(self, *args)
setGeometryFile(self, string file_name)

-void
-stk_classic::adapt::Refiner::setGeometryFile(std::string file_name)
- -
setIgnoreSideSets(self, *args)
setIgnoreSideSets(self, bool ignore_sidesets)

-void
-stk_classic::adapt::Refiner::setIgnoreSideSets(bool ignore_sidesets)
- -
setQueryPassOnly(self, *args)
setQueryPassOnly(self, bool doQueryOnly)

-void
-stk_classic::adapt::Refiner::setQueryPassOnly(bool doQueryOnly)
- -
setRemoveGeometryBlocks(self, *args)
setRemoveGeometryBlocks(self, bool do_remove)

-void stk_classic::adapt::Refiner::setRemoveGeometryBlocks(bool do_remove)
- -
setRemoveOldElements(self, *args)
setRemoveOldElements(self, bool do_remove)

-void stk_classic::adapt::Refiner::setRemoveOldElements(bool do_remove)
- -
setSmoothGeometry(self, *args)
setSmoothGeometry(self, bool do_smooth)

-void
-stk_classic::adapt::Refiner::setSmoothGeometry(bool do_smooth)
- -
unrefineAll(self)
unrefineAll(self)

-void
-stk_classic::adapt::Refiner::unrefineAll()
- -
unrefineTheseElements(self, *args)
unrefineTheseElements(self, ElementUnrefineCollection elements_to_unref)

-void
-stk_classic::adapt::Refiner::unrefineTheseElements(ElementUnrefineCollection
-&elements_to_unref)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_Refiner>
delete_Refiner(Refiner self)

-stk_classic::adapt::Refiner::~Refiner()
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class STK_Adapt_Auto_Part(__builtin__.object)
   signifies a part that has been defined automatically during adaptivity

-C++ includes: UniformRefinerPattern.hpp
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> STK_Adapt_Auto_Part
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_STK_Adapt_Auto_Part>
delete_STK_Adapt_Auto_Part(STK_Adapt_Auto_Part self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Selector(__builtin__.object)
   Proxy of C++ stk_classic::mesh::Selector class
 
 Methods defined here:
-
__eq__(self, *args)
__eq__(self, Selector rhs) -> bool
- -
__getattr__ lambda self, name
- -
__iand__(self, *args)
__iand__(self, Selector selector) -> Selector
- -
__init__(self, *args)
__init__(self) -> Selector
-__init__(self, Part part) -> Selector
- -
__ior__(self, *args)
__ior__(self, Selector selector) -> Selector
- -
__ne__(self, *args)
__ne__(self, Selector rhs) -> bool
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
complement(self)
complement(self) -> Selector
- -
compoundAll(self)
compoundAll(self)
- -
get_ops(self)
get_ops(self) -> std::vector<(stk_classic::mesh::OpType,std::allocator<(stk_classic::mesh::OpType)>)>
- -
set_ops(self, *args)
set_ops(self, std::vector<(stk_classic::mesh::OpType,std::allocator<(stk_classic::mesh::OpType)>)> ops)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_Selector>
delete_Selector(Selector self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class SierraPort(__builtin__.object)
   Proxy of C++ stk_classic::adapt::SierraPort class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> SierraPort
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_SierraPort>
delete_SierraPort(SierraPort self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class StringFunction(Function)
   Proxy of C++ stk_classic::percept::StringFunction class
 
 
Method resolution order:
-
StringFunction
-
Function
-
GenericFunction
-
__builtin__.object
-
-
-Methods defined here:
-
__add__(self, *args)
__add__(self, StringFunction rhs) -> StringFunction
- -
__div__(self, *args)
__div__(self, StringFunction rhs) -> StringFunction
- -
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, char function_string, Name name = stk_classic::percept::Name("noname"), 
-    int domain_dimension = 3, int codomain_dimension = 1, 
-    unsigned int integration_order = 0) -> StringFunction
-__init__(self, char function_string, Name name = stk_classic::percept::Name("noname"), 
-    int domain_dimension = 3, int codomain_dimension = 1) -> StringFunction
-__init__(self, char function_string, Name name = stk_classic::percept::Name("noname"), 
-    int domain_dimension = 3) -> StringFunction
-__init__(self, char function_string, Name name = stk_classic::percept::Name("noname")) -> StringFunction
-__init__(self, char function_string) -> StringFunction
-__init__(self, char function_string, Name name, Dimensions domain_dimensions, 
-    Dimensions codomain_dimensions, unsigned int integration_order = 0) -> StringFunction
-__init__(self, char function_string, Name name, Dimensions domain_dimensions, 
-    Dimensions codomain_dimensions) -> StringFunction
-__init__(self, StringFunction s) -> StringFunction

-stk_classic::percept::StringFunction::StringFunction(const StringFunction &s)
- -
__mul__(self, *args)
__mul__(self, StringFunction rhs) -> StringFunction
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__sub__(self, *args)
__sub__(self, StringFunction rhs) -> StringFunction
- -
derivative(self, *args)
derivative(self, MDArrayString deriv_spec) -> RCPFunction

-Teuchos::RCP< Function >
-stk_classic::percept::StringFunction::derivative(MDArrayString &deriv_spec)

-Return a function that is the derivative of this function. The
-derivative is specified as a rank-2 array of strings that specify what
-derivative to take and how many derivatives. For example,
- -
derivative_test(self, *args)
derivative_test(self, MDArrayString deriv_spec) -> RCPFunction

-Teuchos::RCP< Function >
-stk_classic::percept::StringFunction::derivative_test(MDArrayString
-&deriv_spec)
- -
derivative_test_fd(self, *args)
derivative_test_fd(self, MDArrayString deriv_spec, double eps = 1.e-6) -> RCPFunction
-derivative_test_fd(self, MDArrayString deriv_spec) -> RCPFunction

-Teuchos::RCP<
-Function >
-stk_classic::percept::StringFunction::derivative_test_fd(MDArrayString
-&deriv_spec, double eps=1.e-6)
- -
getFunctionString(self)
getFunctionString(self) -> string

-std::string stk_classic::percept::StringFunction::getFunctionString()
- -
gradient(self, spatialDim=3)
gradient(self, int spatialDim = 3) -> RCPFunction
-gradient(self) -> RCPFunction

-Teuchos::RCP< Function > stk_classic::percept::StringFunction::gradient(int
-spatialDim=3)
- -
resolve(self, *args)
resolve(self, stk_classic::expreval::VariableMap::iterator var_it)

-void
-stk_classic::percept::StringFunction::resolve(stk_classic::expreval::VariableMap::iterator
-&var_it)
- -
set_gradient_strings(self, *args)
set_gradient_strings(self, string gstring, int len)
-set_gradient_strings(self, MDArrayString gstring)

-void
-stk_classic::percept::StringFunction::set_gradient_strings(MDArrayString
-&gstring)
- -
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_StringFunction>
delete_StringFunction(StringFunction self)
- -
__swig_getmethods__ = {'getNewMDArray': <function <lambda>>, 'setCodomainDimDefault': <function <lambda>>, 'setIntegrationOrderDefault': <function <lambda>>, 'setSpatialDimDefault': <function <lambda>>}
- -
__swig_setmethods__ = {}
- -
-Methods inherited from Function:
-
add_alias(self, *args)
add_alias(self, char alias) -> Function

-Function *
-stk_classic::percept::Function::add_alias(const char *alias)

-allow this function to have one or more aliases
- -
argsAreValid(self, *args)
argsAreValid(self, MDArray _in) -> bool

-bool
-stk_classic::percept::Function::argsAreValid(const MDArray &in, const MDArray
-&out)

-Verify that the last dimensions of

-Parameters:
------------

-in:  and

-out:  are the same; this allows Functions to be invoked at multiple
-points where the first M indices represent an M-d array of points to
-evaluate the function, while the last N indices should match the
-Functions domain and codomain dimensions.
- -
derivativeAtPoint(self, *args)
derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain, 
-    double time = 0.0)
-derivativeAtPoint(self, MDArrayString deriv_spec, MDArray domain, MDArray codomain)

-void stk_classic::percept::Function::derivativeAtPoint(MDArrayString
-&deriv_spec, MDArray &domain, MDArray &codomain, double time=0.0)
- -
getIntegrationOrder(self)
getIntegrationOrder(self) -> unsigned int

-unsigned stk_classic::percept::Function::getIntegrationOrder(void)
- -
getName(self)
getName(self) -> string

-std::string&
-stk_classic::percept::Function::getName()
- -
setCodomainDimensions(self, *args)
setCodomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setCodomainDimensions(const Dimensions
-dims)
- -
setDomainDimensions(self, *args)
setDomainDimensions(self, Dimensions dims)

-void stk_classic::percept::Function::setDomainDimensions(const Dimensions
-dims)
- -
setIntegrationOrder(self, *args)
setIntegrationOrder(self, unsigned int iord)

-void stk_classic::percept::Function::setIntegrationOrder(unsigned iord)
- -
value(self, *args)
value(self, MDArray domain, MDArray MDOutVal, double time_value_optional = 0.0)
-value(self, MDArray domain, MDArray MDOutVal)
-value(self, MDArray domain, double time_value_optional = 0.0) -> MDArray
-value(self, MDArray domain) -> MDArray

-MDArray
-stk_classic::percept::Function::value(MDArray &domain, double
-time_value_optional=0.0)

-this version creates a dummy output and returns it based on the
-codomain-dimensions specified at construction
- -
-Static methods inherited from Function:
-
setCodomainDimDefault(*args)
setCodomainDimDefault(unsigned int codomainDim)
- -
setIntegrationOrderDefault(*args)
setIntegrationOrderDefault(unsigned int integration_order)
- -
setSpatialDimDefault(*args)
setSpatialDimDefault(unsigned int spatialDim)
- -
-Data and other attributes inherited from Function:
-
Identity = <PerceptMesh.Function; proxy of <Swig Object of type 'stk_classic::percept::Function *' at 0x18870480> >
- -
-Methods inherited from GenericFunction:
-
getCodomainDimensions(self)
getCodomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getCodomainDimensions()
- -
getDomainDimensions(self)
getDomainDimensions(self) -> Dimensions

-Dimensions
-stk_classic::percept::GenericFunction::getDomainDimensions()
- -
getNewCodomain(self)
getNewCodomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewCodomain() const
- -
getNewDomain(self)
getNewDomain(self) -> MDArray

-MDArray stk_classic::percept::GenericFunction::getNewDomain()
- -
isSpatialOperator(self)
isSpatialOperator(self) -> bool

-bool
-stk_classic::percept::GenericFunction::isSpatialOperator()
- -
setIsSpatialOperator(self, *args)
setIsSpatialOperator(self, bool so)

-void
-stk_classic::percept::GenericFunction::setIsSpatialOperator(bool so)
- -
-Static methods inherited from GenericFunction:
-
getNewMDArray(*args)
getNewMDArray(Dimensions dims) -> MDArray
- -
-Data descriptors inherited from GenericFunction:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-

- - - - - -
 
-class SwigPyIterator(__builtin__.object)
    Methods defined here:
-
__add__(self, *args)
- -
__eq__(self, *args)
- -
__getattr__ lambda self, name
- -
__iadd__(self, *args)
- -
__init__(self, *args, **kwargs)
- -
__isub__(self, *args)
- -
__iter__(self)
- -
__ne__(self, *args)
- -
__next__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__sub__(self, *args)
- -
advance(self, *args)
- -
copy(self)
- -
decr(self, n=1)
- -
distance(self, *args)
- -
equal(self, *args)
- -
incr(self, n=1)
- -
next(self)
- -
previous(self)
- -
value(self)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_SwigPyIterator>
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class To_Ptr(__builtin__.object)
   Proxy of C++ stk_classic::mesh::To_Ptr class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> To_Ptr
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_To_Ptr>
delete_To_Ptr(To_Ptr self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class UniformRefinerPatternBase(__builtin__.object)
   The base class for all refinement patterns
-------------------------------------------------------------------------------------------------------------------------

-C++ includes: UniformRefinerPattern.hpp
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args, **kwargs)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
connectSides(self, *args)
connectSides(self, PerceptMesh eMesh, Entity element, Entity side_elem) -> bool

-bool
-stk_classic::adapt::UniformRefinerPatternBase::connectSides(percept::PerceptMesh
-&eMesh, stk_classic::mesh::Entity *element, stk_classic::mesh::Entity *side_elem)
- -
createNewElements(self, *args)
createNewElements(self, PerceptMesh eMesh, NodeRegistry nodeRegistry, Entity element, 
-    NewSubEntityNodesType new_sub_entity_nodes, 
-    vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)>::iterator element_pool, 
-    FieldBase proc_rank_field = None)
-createNewElements(self, PerceptMesh eMesh, NodeRegistry nodeRegistry, Entity element, 
-    NewSubEntityNodesType new_sub_entity_nodes, 
-    vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)>::iterator element_pool)

-virtual
-void
-stk_classic::adapt::UniformRefinerPatternBase::createNewElements(percept::PerceptMesh
-&eMesh, NodeRegistry &nodeRegistry, stk_classic::mesh::Entity &element,
-NewSubEntityNodesType &new_sub_entity_nodes, vector< stk_classic::mesh::Entity
-* >::iterator &element_pool, stk_classic::mesh::FieldBase
-*proc_rank_field=0)=0

-given the node database ( NodeRegistry), and the newly created nodes,
-and an iterator for the elements in the element pool, create all new
-sub-elements of the refined element
- -
doBreak(self)
doBreak(self)

-virtual void stk_classic::adapt::UniformRefinerPatternBase::doBreak()=0
- -
fillNeededEntities(self, *args)
fillNeededEntities(self, std::vector<(NeededEntityType,std::allocator<(NeededEntityType)>)> needed_entities)

-virtual
-void
-stk_classic::adapt::UniformRefinerPatternBase::fillNeededEntities(std::vector<
-NeededEntityType > &needed_entities)=0

-must be provided by derived classes
-------------------------------------------------------------------------------------------------------------------------
-supplies the ranks of the sub entities needed during refinement (eg.
-m_eMesh.face_rank(), m_eMesh.edge_rank(),..) 10/02/10 and the number
-of nodes needed for each sub entity
- -
findSideRelations(self, *args)
findSideRelations(self, PerceptMesh eMesh, Entity parent, Entity child) -> bool

-bool
-stk_classic::adapt::UniformRefinerPatternBase::findSideRelations(percept::PerceptMesh
-&eMesh, stk_classic::mesh::Entity *parent, stk_classic::mesh::Entity *child)

-given a new element (child) that is a child of an original element
-(parent), look at parent's side to elem relations and from the
-children of the element, choose an element to connect the new side to
-(using connectSides)
- -
fixSurfaceAndEdgeSetNamesMap(self)
fixSurfaceAndEdgeSetNamesMap(self) -> StringStringMap

-virtual StringStringMap
-stk_classic::adapt::UniformRefinerPatternBase::fixSurfaceAndEdgeSetNamesMap()

-for i/o to work properly, supply string replacements such as for
-hex-->tet breaking, you would supply "quad"-->"tri" etc. string
-maps
- -
getAppendConvertString(self)
getAppendConvertString(self) -> string

-const
-std::string&
-stk_classic::adapt::UniformRefinerPatternBase::getAppendConvertString()
- -
getAppendOriginalString(self)
getAppendOriginalString(self) -> string

-const
-std::string&
-stk_classic::adapt::UniformRefinerPatternBase::getAppendOriginalString()
- -
getCentroid(self, *args)
getCentroid(self, double pts, int len, int spatialDim, double x) -> double

-double*
-stk_classic::adapt::UniformRefinerPatternBase::getCentroid(double *pts[], int
-len, int spatialDim, double *x)
- -
getFromParts(self)
getFromParts(self) -> PartVector

-stk_classic::mesh::PartVector&
-stk_classic::adapt::UniformRefinerPatternBase::getFromParts()
- -
getFromTopoPartName(self)
getFromTopoPartName(self) -> string

-virtual
-std::string
-stk_classic::adapt::UniformRefinerPatternBase::getFromTopoPartName()=0

-provided by this class
-------------------------------------------------------------------------------------------------------------------------
- -
getFromTopology(self)
getFromTopology(self) -> CellTopologyData

-virtual const
-CellTopologyData*
-stk_classic::adapt::UniformRefinerPatternBase::getFromTopology()=0
- -
getFromTypeKey(self)
getFromTypeKey(self) -> unsigned int

-virtual
-unsigned stk_classic::adapt::UniformRefinerPatternBase::getFromTypeKey()=0
- -
getName(self)
getName(self) -> string

-virtual std::string stk_classic::adapt::UniformRefinerPatternBase::getName()
- -
getNumNewElemPerElem(self)
getNumNewElemPerElem(self) -> unsigned int

-virtual
-unsigned
-stk_classic::adapt::UniformRefinerPatternBase::getNumNewElemPerElem()=0

-supply the number of new elements per element during refinement
- -
getPrimaryEntityRank(self)
getPrimaryEntityRank(self) -> EntityRank

-stk_classic::mesh::EntityRank
-stk_classic::adapt::UniformRefinerPatternBase::getPrimaryEntityRank()
- -
getToParts(self)
getToParts(self) -> PartVector

-stk_classic::mesh::PartVector&
-stk_classic::adapt::UniformRefinerPatternBase::getToParts()
- -
getToTopoPartName(self)
getToTopoPartName(self) -> string

-virtual
-std::string
-stk_classic::adapt::UniformRefinerPatternBase::getToTopoPartName()=0
- -
getToTopology(self)
getToTopology(self) -> CellTopologyData

-virtual const
-CellTopologyData*
-stk_classic::adapt::UniformRefinerPatternBase::getToTopology()=0
- -
interpolateElementFields(self, *args)
interpolateElementFields(self, PerceptMesh eMesh, Entity old_owning_elem, Entity newElement)

-void
-stk_classic::adapt::UniformRefinerPatternBase::interpolateElementFields(percept::PerceptMesh
-&eMesh, stk_classic::mesh::Entity &old_owning_elem, stk_classic::mesh::Entity
-&newElement)
- -
midPoint(self, *args)
midPoint(self, double p1, double p2, int spatialDim, double x) -> double

-double* stk_classic::adapt::UniformRefinerPatternBase::midPoint(const double
-*p1, const double *p2, int spatialDim, double *x)
- -
setNeededParts(self, *args)
setNeededParts(self, PerceptMesh eMesh, BlockNamesType block_names_ranks, 
-    bool sameTopology = True)
-setNeededParts(self, PerceptMesh eMesh, BlockNamesType block_names_ranks)

-virtual void
-stk_classic::adapt::UniformRefinerPatternBase::setNeededParts(percept::PerceptMesh
-&eMesh, BlockNamesType block_names_ranks, bool sameTopology=true)
- -
setSubPatterns(self, *args)
setSubPatterns(self, std::vector<(p.stk_classic::adapt::UniformRefinerPatternBase,std::allocator<(p.stk_classic::adapt::UniformRefinerPatternBase)>)> bp, 
-    PerceptMesh eMesh)

-virtual void
-stk_classic::adapt::UniformRefinerPatternBase::setSubPatterns(std::vector<
-UniformRefinerPatternBase * > &bp, percept::PerceptMesh &eMesh)

-optionally overridden (must be overridden if sidesets are to work
-properly) to provide info on which sub pattern should be used to
-refine side sets (and edge sets)

-default is only this pattern
- -
setToOne(self, *args)
setToOne(self, std::vector<(NeededEntityType,std::allocator<(NeededEntityType)>)> needed_entities)

-void stk_classic::adapt::UniformRefinerPatternBase::setToOne(std::vector<
-NeededEntityType > &needed_entities)

-utilities --------- sets the needed number of nodes on each sub-entity
-to 1 - this is just a helper - in general, edges and faces have 1 new
-node for linear elements, and multiple new nodes in the case of
-quadratic elements
- -
set_parent_child_relations(self, *args)
set_parent_child_relations(self, PerceptMesh eMesh, Entity old_owning_elem, Entity newElement, 
-    unsigned int ordinal, unsigned int numChild = None)
-set_parent_child_relations(self, PerceptMesh eMesh, Entity old_owning_elem, Entity newElement, 
-    unsigned int ordinal)

-void
-stk_classic::adapt::UniformRefinerPatternBase::set_parent_child_relations(percept::PerceptMesh
-&eMesh, stk_classic::mesh::Entity &old_owning_elem, stk_classic::mesh::Entity
-&newElement, unsigned ordinal, unsigned *numChild=0)

-if numChild is passed in as non-null, use that value, else use
-getNumNewElemPerElem() as size of child vector
- -
-Static methods defined here:
-
createPattern(*args)
createPattern(string refine, string enrich, string convert, PerceptMesh eMesh, 
-    BlockNamesType block_names) -> Teuchos::RCP<(stk_classic::adapt::UniformRefinerPatternBase)>
- -
getOldElementsPartName()
getOldElementsPartName() -> string
- -
getTopoDim(*args)
getTopoDim(shards::CellTopology cell_topo) -> int
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
s_convert_options
-
-
s_enrich_options
-
-
s_refine_options
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_UniformRefinerPatternBase>
delete_UniformRefinerPatternBase(UniformRefinerPatternBase self)

-virtual
-stk_classic::adapt::UniformRefinerPatternBase::~UniformRefinerPatternBase()
- -
__swig_getmethods__ = {'createPattern': <function <lambda>>, 'getOldElementsPartName': <function <lambda>>, 'getTopoDim': <function <lambda>>, 's_convert_options': <built-in function UniformRefinerPatternBase_s_convert_options_get>, 's_enrich_options': <built-in function UniformRefinerPatternBase_s_enrich_options_get>, 's_refine_options': <built-in function UniformRefinerPatternBase_s_refine_options_get>}
- -
__swig_setmethods__ = {'s_convert_options': <built-in function UniformRefinerPatternBase_s_convert_options_set>, 's_enrich_options': <built-in function UniformRefinerPatternBase_s_enrich_options_set>, 's_refine_options': <built-in function UniformRefinerPatternBase_s_refine_options_set>}
- -

- - - - - - - -
 
-class WedgeFixture(__builtin__.object)
   Proxy of C++ stk_classic::percept::WedgeFixture class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self)
__init__(self) -> WedgeFixture
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
createBulkAfterMetaCommit(self, *args)
createBulkAfterMetaCommit(self, ParallelMachine parallel_machine)

-void
-stk_classic::percept::WedgeFixture::createBulkAfterMetaCommit(stk_classic::ParallelMachine
-parallel_machine)
- -
createFixedSizeMesh(self, *args)
createFixedSizeMesh(self, ParallelMachine parallel_machine, string output_filename)

-void
-stk_classic::percept::WedgeFixture::createFixedSizeMesh(stk_classic::ParallelMachine
-parallel_machine, std::string output_filename)
- -
createMesh(self, *args)
createMesh(self, ParallelMachine parallel_machine, unsigned int n_nodes_x, 
-    unsigned int n_nodes_y, unsigned int n_nodes_z, 
-    double xmin, double xmax, double ymin, 
-    double ymax, double zmin, double zmax, string output_filename) -> BulkData

-mesh::BulkData*
-stk_classic::percept::WedgeFixture::createMesh(stk_classic::ParallelMachine
-parallel_machine, unsigned n_nodes_x, unsigned n_nodes_y, unsigned
-n_nodes_z, double xmin, double xmax, double ymin, double ymax, double
-zmin, double zmax, std::string output_filename)
- -
getMetaData(self)
getMetaData(self) -> FEMMetaData

-mesh::fem::FEMMetaData* stk_classic::percept::WedgeFixture::getMetaData()
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_WedgeFixture>
delete_WedgeFixture(WedgeFixture self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class Writer(__builtin__.object)
   Proxy of C++ stk_classic::diag::Writer class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, std::streambuf streambuf, PrintMask print_mask = static_cast< PrintMask >(LOG_MEMBERS), 
-    Flags flags = static_cast< stk_classic::diag::Writer::Flags >(ENABLED)) -> Writer
-__init__(self, std::streambuf streambuf, PrintMask print_mask = static_cast< PrintMask >(LOG_MEMBERS)) -> Writer
-__init__(self, std::streambuf streambuf) -> Writer
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
decTraceDepth(self)
decTraceDepth(self) -> int
- -
dendl(self)
dendl(self) -> Writer
- -
dflush(self)
dflush(self) -> Writer
- -
getDepth(self)
getDepth(self) -> int
- -
getFlags(self)
getFlags(self) -> int
- -
getPrintMask(self)
getPrintMask(self) -> PrintMask
- -
getStream(self)
getStream(self) -> std::ostream
- -
incTraceDepth(self)
incTraceDepth(self) -> int
- -
isEnabled(self)
isEnabled(self) -> bool
- -
isLoggable(self, *args)
isLoggable(self, PrintMask line_mask) -> bool
- -
isTraceable(self)
isTraceable(self) -> bool
- -
isTracing(self)
isTracing(self) -> bool
- -
m(self, *args)
m(self, PrintMask line_mask) -> Writer
- -
pop(self)
pop(self) -> Writer
- -
push(self)
push(self) -> Writer
- -
resetLineMask(self)
resetLineMask(self) -> Writer
- -
restoreDepth(self, *args)
restoreDepth(self, int depth) -> Writer
- -
setFlags(self, *args)
setFlags(self, int flags) -> Writer
- -
setLineMask(self, *args)
setLineMask(self, PrintMask line_mask) -> Writer
- -
setPrintMask(self, mask=0)
setPrintMask(self, PrintMask mask = 0) -> Writer
-setPrintMask(self) -> Writer
- -
shouldPrint(self, *args)
shouldPrint(self) -> bool
-shouldPrint(self, PrintMask line_mask) -> bool
- -
shouldTrace(self, *args)
shouldTrace(self, int line_mask) -> bool
- -
t(self, line_mask=0)
t(self, PrintMask line_mask = 0) -> Writer
-t(self) -> Writer
- -
w(self, *args)
w(self, bool on, PrintMask line_mask) -> Writer
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
DISABLED = 0
- -
ENABLED = 1
- -
__swig_destroy__ = <built-in function delete_Writer>
delete_Writer(Writer self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - - - -
 
-class WriterThrowSafe(__builtin__.object)
   Proxy of C++ stk_classic::diag::WriterThrowSafe class
 
 Methods defined here:
-
__getattr__ lambda self, name
- -
__init__(self, *args)
__init__(self, Writer writer) -> WriterThrowSafe
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_WriterThrowSafe>
delete_WriterThrowSafe(WriterThrowSafe self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectord(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectord>
delete_vectord(vectord self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectorfieldbase(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectorfieldbase>
delete_vectorfieldbase(vectorfieldbase self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectori(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectori>
delete_vectori(vectori self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectorparts(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectorparts>
delete_vectorparts(vectorparts self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectors(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectors>
delete_vectors(vectors self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-class vectorvs(__builtin__.object)
    Methods defined here:
-
__bool__(self)
- -
__delitem__(self, *args)
- -
__delslice__(self, *args)
- -
__getattr__ lambda self, name
- -
__getitem__(self, *args)
- -
__getslice__(self, *args)
- -
__init__(self, *args)
- -
__iter__(self)
- -
__len__(self)
- -
__nonzero__(self)
- -
__repr__ = _swig_repr(self)
- -
__setattr__ lambda self, name, value
- -
__setitem__(self, *args)
- -
__setslice__(self, *args)
- -
append(self, *args)
- -
assign(self, *args)
- -
back(self)
- -
begin(self)
- -
capacity(self)
- -
clear(self)
- -
empty(self)
- -
end(self)
- -
erase(self, *args)
- -
front(self)
- -
get_allocator(self)
- -
insert(self, *args)
- -
iterator(self)
- -
pop(self)
- -
pop_back(self)
- -
push_back(self, *args)
- -
rbegin(self)
- -
rend(self)
- -
reserve(self, *args)
- -
resize(self, *args)
- -
size(self)
- -
swap(self, *args)
- -
-Data descriptors defined here:
-
__dict__
-
dictionary for instance variables (if defined)
-
-
__weakref__
-
list of weak references to the object (if defined)
-
-
-Data and other attributes defined here:
-
__swig_destroy__ = <built-in function delete_vectorvs>
delete_vectorvs(vectorvs self)
- -
__swig_getmethods__ = {}
- -
__swig_setmethods__ = {}
- -

- - - - - -
 
-Functions
       
BeamFixture_swigregister(...)
-
BucketLess_swigregister(...)
-
Bucket_swigregister(...)
-
BulkData_get(*args)
get(Bucket bucket) -> BulkData
-get(Entity entity) -> BulkData
-BulkData_get(Ghosting ghost) -> BulkData
-
BulkData_swigregister(...)
-
ConstantFunctionVec_swigregister(...)
-
ConstantFunction_swigregister(...)
-
Dimensions_swigregister(...)
-
FEMMetaData_get(*args)
get(MetaData meta) -> FEMMetaData
-get(Part part) -> FEMMetaData
-get(FieldBase field) -> FEMMetaData
-get(PropertyBase property) -> FEMMetaData
-get(BulkData bulk_data) -> FEMMetaData
-get(Bucket bucket) -> FEMMetaData
-get(Entity entity) -> FEMMetaData
-FEMMetaData_get(Ghosting ghost) -> FEMMetaData
-
FEMMetaData_get_meta_data(*args)
FEMMetaData_get_meta_data(FEMMetaData fem_meta) -> MetaData
-
FEMMetaData_swigregister(...)
-
FieldBase_swigregister(...)
-
FieldCreateOrder_swigregister(...)
-
FieldFunction_swigregister(...)
-
FieldRepository_swigregister(...)
-
Function_setCodomainDimDefault(*args)
Function_setCodomainDimDefault(unsigned int codomainDim)
-
Function_setIntegrationOrderDefault(*args)
Function_setIntegrationOrderDefault(unsigned int integration_order)
-
Function_setSpatialDimDefault(*args)
Function_setSpatialDimDefault(unsigned int spatialDim)
-
Function_swigregister(...)
-
GMeshSpec_swigregister(...)
-
GenericFunction_getNewMDArray(*args)
GenericFunction_getNewMDArray(Dimensions dims) -> MDArray
-
GenericFunction_swigregister(...)
-
Gmesh_STKmesh_Fixture_swigregister(...)
-
HeterogeneousFixture_swigregister(...)
-
L1Norm_swigregister(...)
-
L2Norm_swigregister(...)
-
LInfNorm_swigregister(...)
-
MDArrayString_swigregister(...)
-
MDArray_swigregister(...)
-
MaxOfNodeValues_swigregister(...)
-
MeshTransformer_swigregister(...)
-
Name_swigregister(...)
-
OpType_swigregister(...)
-
PartLess_swigregister(...)
-
PartOrdLess_swigregister(...)
-
Part_swigregister(...)
-
PerceptMesh_mesh_difference(*args)
mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg, bool _print = True, 
-    bool print_all_field_diffs = False) -> bool
-mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg, bool _print = True) -> bool
-PerceptMesh_mesh_difference(PerceptMesh mesh1, PerceptMesh mesh2, string msg) -> bool
-
PerceptMesh_swigregister(...)
-
QuadFixture_3_get_entity_rank_names(*args)
QuadFixture_3_get_entity_rank_names(unsigned int dim) -> vectors
-
QuadFixture_3_swigregister(...)
-
QuadFixture_4_get_entity_rank_names(*args)
QuadFixture_4_get_entity_rank_names(unsigned int dim) -> vectors
-
QuadFixture_4_swigregister(...)
-
RCPComp_swigregister(...)
-
RCPConstComp_swigregister(...)
-
RCPFunction_swigregister(...)
-
Refiner_swigregister(...)
-
STK_Adapt_Auto_Part_swigregister(...)
-
Selector_swigregister(...)
-
SierraPort_swigregister(...)
-
StringFunction_swigregister(...)
-
SwigPyIterator_swigregister(...)
-
To_Ptr_swigregister(...)
-
UniformRefinerPatternBase_createPattern(*args)
UniformRefinerPatternBase_createPattern(string refine, string enrich, string convert, PerceptMesh eMesh, 
-    BlockNamesType block_names) -> Teuchos::RCP<(stk_classic::adapt::UniformRefinerPatternBase)>
-
UniformRefinerPatternBase_getOldElementsPartName()
UniformRefinerPatternBase_getOldElementsPartName() -> string
-
UniformRefinerPatternBase_getTopoDim(*args)
UniformRefinerPatternBase_getTopoDim(shards::CellTopology cell_topo) -> int
-
UniformRefinerPatternBase_swigregister(...)
-
WedgeFixture_swigregister(...)
-
WriterThrowSafe_swigregister(...)
-
Writer_swigregister(...)
-
__add__(*args)
__add__(StringFunction lhs, StringFunction rhs) -> StringFunction
-
__and__(*args)
__and__(Part A, Part B) -> Selector
-__and__(Part A, Selector B) -> Selector
-__and__(Selector A, Part B) -> Selector
-__and__(Selector A, Selector B) -> Selector
-
__div__(*args)
__div__(StringFunction lhs, StringFunction rhs) -> StringFunction
-
__mul__(*args)
__mul__(StringFunction lhs, StringFunction rhs) -> StringFunction
-
__or__(*args)
__or__(Part A, Part B) -> Selector
-__or__(Part A, Selector B) -> Selector
-__or__(Selector A, Part B) -> Selector
-__or__(Selector A, Selector B) -> Selector
-
__sub__(*args)
__sub__(StringFunction lhs, StringFunction rhs) -> StringFunction
-__sub__(StringFunction lhs) -> StringFunction
-
bucket_part_equal(*args)
bucket_part_equal(unsigned int lhs, unsigned int rhs) -> bool
-
contain(*args)
contain(PartVector arg0, Part arg1) -> bool
-contain(PartVector arg0, PartVector arg1) -> bool
-
convert_to_internal_name(*args)
convert_to_internal_name(string part_name) -> string
-
db_api_int_size(*args)
db_api_int_size(GroupingEntity entity) -> size_t
-
define_io_fields(*args)
define_io_fields(GroupingEntity entity, Ioss::Field::RoleType role, 
-    Part part, EntityRank part_type)
-
define_output_db(*args)
define_output_db(Region io_region, mesh::BulkData bulk_data, Region input_region = None, 
-    Selector anded_selector = None, 
-    bool sort_stk_parts = False)
-define_output_db(Region io_region, mesh::BulkData bulk_data, Region input_region = None, 
-    Selector anded_selector = None)
-define_output_db(Region io_region, mesh::BulkData bulk_data, Region input_region = None)
-define_output_db(Region io_region, mesh::BulkData bulk_data)
-
dendl(*args)
dendl(Writer dout) -> Writer
-
dflush(*args)
dflush(Writer dout) -> Writer
-
edge_rank(*args)
edge_rank(mesh::MetaData meta) -> mesh::EntityRank
-
element_rank(*args)
element_rank(mesh::MetaData meta) -> mesh::EntityRank
-
entity_rank_names(*args)
entity_rank_names(size_t spatial_dimension) -> vectors
-
eval_func(*args)
eval_func(double x, double y, double z, double t, Function func) -> double
-eval_func(double x, double y, double z, double t, RCPFunction func) -> double
-
eval_func2(*args)
eval_func2(double x, double y, double t, Function func) -> double
-eval_func2(double x, double y, double t, RCPFunction func) -> double
-
eval_print(*args)
eval_print(double x, double y, double z, double t, Function func)
-eval_print(double x, double y, double z, double t, RCPFunction func)
-
eval_print2(*args)
eval_print2(double x, double y, double t, Function func)
-eval_print2(double x, double y, double t, RCPFunction func)
-
eval_vec3(*args)
eval_vec3(double x, double y, double z, double t, Function func) -> MDArray
-eval_vec3(double x, double y, double z, double t, RCPFunction func) -> MDArray
-
eval_vec3_print(*args)
eval_vec3_print(double x, double y, double z, double t, Function func)
-eval_vec3_print(double x, double y, double z, double t, RCPFunction func)
-
face_rank(*args)
face_rank(mesh::MetaData meta) -> mesh::EntityRank
-
field_data_from_ioss(*args)
field_data_from_ioss(FieldBase field, std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)> entities, 
-    GroupingEntity io_entity, 
-    string io_fld_name)
-
field_data_to_ioss(*args)
field_data_to_ioss(FieldBase field, std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)> entities, 
-    GroupingEntity io_entity, 
-    string io_fld_name, 
-    Ioss::Field::RoleType filter_role)
-
find(*args)
find(PartVector arg0, string arg1) -> Part
-
get_associated_ioss_entity(*args)
get_associated_ioss_entity(mesh::Part part) -> GroupingEntity
-
get_cell_topology(*args)
get_cell_topology(Bucket bucket) -> CellTopology
-get_cell_topology(Entity entity) -> CellTopology
-
get_distribution_factor_field(*args)
get_distribution_factor_field(mesh::Part p) -> mesh::Field<(double,mesh::ElementNode,void,void,void,void,void,void)>
-
get_entity_list(*args)
get_entity_list(GroupingEntity io_entity, EntityRank part_type, BulkData bulk, 
-    std::vector<(p.stk_classic::mesh::Entity,std::allocator<(p.stk_classic::mesh::Entity)>)> entities)
-
get_field_role(*args)
get_field_role(mesh::FieldBase f) -> Ioss::Field::RoleType
-
get_io_field_type(*args)
get_io_field_type(FieldBase field, stk_classic::mesh::FieldRestriction res, std::pair<(std::string,Ioss::Field::BasicType)> result)
-
has_superset(*args)
has_superset(Bucket arg0, Part p) -> bool
-has_superset(Bucket arg0, unsigned int ordinal) -> bool
-has_superset(Bucket arg0, PartVector arg1) -> bool
-
include_entity(*args)
include_entity(GroupingEntity entity) -> bool
-
initialize_spatial_dimension(*args)
initialize_spatial_dimension(mesh::fem::FEMMetaData fem_meta, size_t spatial_dimension, 
-    vectors entity_rank_names)
-initialize_spatial_dimension(mesh::MetaData meta, size_t spatial_dimension, vectors entity_rank_names)
-
insert(*args)
insert(PartVector arg0, Part arg1) -> bool
-
insert_ordinal(*args)
insert_ordinal(OrdinalVector v, unsigned int part_ordinal) -> bool
-
internal_part_processing(*args)
internal_part_processing(GroupingEntity entity, FEMMetaData meta)
-internal_part_processing(EntityBlock entity, FEMMetaData meta)
-internal_part_processing(GroupingEntity entity, MetaData meta)
-internal_part_processing(EntityBlock entity, MetaData meta)
-
intersect(*args)
intersect(PartVector arg0, PartVector arg1) -> size_t
-intersect(PartVector arg0, PartVector arg1, PartVector arg2) -> size_t
-intersect(Part arg0, Part arg1) -> bool
-
invalid_rank(*args)
invalid_rank(mesh::EntityRank rank) -> bool
-
ioss_add_fields(*args)
ioss_add_fields(Part part, EntityRank part_type, GroupingEntity entity, 
-    Ioss::Field::RoleType filter_role, bool add_all = False)
-ioss_add_fields(Part part, EntityRank part_type, GroupingEntity entity, 
-    Ioss::Field::RoleType filter_role)
-
is_cell_topology_root_part(*args)
is_cell_topology_root_part(Part part) -> bool
-
is_internal(*args)
is_internal(string part_name) -> bool
-is_internal(Part part) -> bool
-
is_part_io_part(*args)
is_part_io_part(mesh::Part part) -> bool
-
is_valid_part_field(*args)
is_valid_part_field(FieldBase field, EntityRank part_type, Part part, Part universal, 
-    Ioss::Field::RoleType filter_role, 
-    bool add_all = False) -> bool
-is_valid_part_field(FieldBase field, EntityRank part_type, Part part, Part universal, 
-    Ioss::Field::RoleType filter_role) -> bool
-
lower_bound(*args)
lower_bound(std::vector<(p.stk_classic::mesh::Bucket,std::allocator<(p.stk_classic::mesh::Bucket)>)> v, 
-    unsigned int key) -> std::vector<(p.stk_classic::mesh::Bucket,std::allocator<(p.stk_classic::mesh::Bucket)>)>::iterator
-
map_topology_cell_to_ioss(*args)
map_topology_cell_to_ioss(CellTopologyData cell_top, int spatial_dimension) -> string
-
map_topology_ioss_to_cell(*args)
map_topology_ioss_to_cell(ElementTopology topology) -> CellTopologyData
-
node_rank(*args)
node_rank(mesh::MetaData meta) -> mesh::EntityRank
-
order(*args)
order(PartVector arg0)
-order(OrdinalVector v)
-
parallel_machine_barrier(*args)
parallel_machine_barrier(ParallelMachine parallel_machine)
-
parallel_machine_finalize()
parallel_machine_finalize()
-
parallel_machine_init(*args)
parallel_machine_init(int argc, char argv) -> ParallelMachine
-
parallel_machine_null()
parallel_machine_null() -> ParallelMachine
-
parallel_machine_rank(*args)
parallel_machine_rank(ParallelMachine parallel_machine) -> unsigned int
-
parallel_machine_size(*args)
parallel_machine_size(ParallelMachine parallel_machine) -> unsigned int
-
part_primary_entity_rank(*args)
part_primary_entity_rank(mesh::Part part) -> mesh::EntityRank
-
pop(*args)
pop(Writer dout) -> Writer
-
push(*args)
push(Writer dout) -> Writer
-
put_io_part_attribute(*args)
put_io_part_attribute(mesh::Part part, GroupingEntity entity = None)
-put_io_part_attribute(mesh::Part part)
-
remove(*args)
remove(PartVector arg0, Part arg1)
-
remove_io_part_attribute(*args)
remove_io_part_attribute(mesh::Part part)
-
resetlinemask(*args)
resetlinemask(Writer dout) -> Writer
-
selectField(*args)
selectField(FieldBase field) -> Selector
-
selectIntersection(*args)
selectIntersection(PartVector intersection_part_vector) -> Selector
-
selectUnion(*args)
selectUnion(PartVector union_part_vector) -> Selector
-
set_cell_topology(*args)
set_cell_topology(Part part, CellTopology cell_topology)
-
set_distribution_factor_field(*args)
set_distribution_factor_field(mesh::Part p, mesh::Field<(double,mesh::ElementNode,void,void,void,void,void,void)> df_field)
-
set_field_relations(*args)
set_field_relations(Entity e_from, Entity e_to, unsigned int ident)
-
set_field_role(*args)
set_field_role(mesh::FieldBase f, Ioss::Field::RoleType role)
-
setlinemask(*args)
setlinemask(PrintMask line_mask) -> _setlinemask
-
side_rank(*args)
side_rank(mesh::MetaData meta) -> mesh::EntityRank
-
square(*args)
square(double x) -> double
-
vectord_swigregister(...)
-
vectorfieldbase_swigregister(...)
-
vectori_swigregister(...)
-
vectorparts_swigregister(...)
-
vectors_swigregister(...)
-
vectorvs_swigregister(...)
-
verifyMesh(*args)
verifyMesh(BeamFixture mesh) -> bool
-verifyMesh(HeterogeneousFixture mesh) -> bool
-
write_output_db(*args)
write_output_db(Region io_region, mesh::BulkData bulk, Selector anded_selector = None)
-write_output_db(Region io_region, mesh::BulkData bulk)
-

- - - - - -
 
-Data
       BEAM2_BEAM2_2 = 1
-BEAM2_BEAM3_1 = 29
-BEAM3_BEAM3_2 = 17
-BaseEntityRank = 0
-COMPOUND = 1
-DEBUG_URP_HPP = 0
-EXTRA_PRINT_FF_HELPER = 0
-EntityLogCreated = 1
-EntityLogDeleted = 3
-EntityLogModified = 2
-EntityLogNoChange = 0
-EntityRankEnd = 6
-FAMILY_TREE_CHILD_START_INDEX = 1
-FAMILY_TREE_LEVEL_0 = 0
-FAMILY_TREE_LEVEL_1 = 1
-FAMILY_TREE_PARENT = 0
-FORCE_TRACE_PRINT_ONLY = 0
-HET_FIX_INCLUDE_EXTRA_ELEM_TYPES = 0
-HEX20_HEX20_8 = 22
-HEX27_HEX27_8 = 21
-HEX8_HEX20_1 = 34
-HEX8_HEX27_1 = 33
-HEX8_HEX8_8 = 13
-HEX8_TET4_24 = 41
-HEX8_TET4_6_12 = 42
-INTERNAL_PART_POSTFIX = '}'
-INTERNAL_PART_PREFIX = '{'
-INVALID = 0
-InvalidEntityRank = 4294967295
-InvalidOrdinal = 4294967295
-InvalidPartOrdinal = 4294967295
-InvalidRelationIdentifier = 4294967295
-LINE2_LINE2_2 = 0
-LINE3_LINE3_2 = 16
-MaximumFieldDimension = 7
-NEW_FIX_ELEMENT_SIDES = 1
-PART_ID = 2
-PERCEPT_QF_USE_COORD_GATHER_FIELD = 0
-PERCEPT_USE_FAMILY_TREE = 1
-PERCEPT_USE_PSEUDO_ELEMENTS = 0
-PYRAMID13_PYRAMID13_10 = 26
-PYRAMID5_PYRAMID13_1 = 37
-PYRAMID5_PYRAMID5_10 = 15
-QUAD4_QUAD4_4 = 5
-QUAD4_QUAD4_4_OLD = 4
-QUAD4_QUAD4_4_SIERRA = 6
-QUAD4_QUAD8_1 = 28
-QUAD4_QUAD9_1 = 27
-QUAD4_TRI3_2 = 38
-QUAD4_TRI3_4 = 39
-QUAD4_TRI3_6 = 40
-QUAD8_QUAD8_4 = 20
-QUAD9_QUAD9_4 = 19
-RCP_UNDEFINED_WEAK_NO_DEALLOC = 0
-RCP_UNDEFINED_WITH_DEALLOC = 0
-RCP_WEAK_NO_DEALLOC = 0
-SHELLLINE2_SHELLLINE2_2 = 2
-SHELLLINE3_SHELLLINE3_2 = 3
-SHELLQUAD4_SHELLQUAD4_4 = 10
-SHELLQUAD4_SHELLQUAD8_1 = 30
-SHELLQUAD8_SHELLQUAD8_4 = 11
-SHELLTRI3_SHELLTRI3_4 = 8
-SHELLTRI6_SHELLTRI6_4 = 9
-STK_ADAPT_URP_LOCAL_NODE_COMPS = 0
-TET10_TET10_8 = 23
-TET4_TET10_1 = 32
-TET4_TET4_8 = 12
-TRACE_STAGE_PRINT_ON = 0
-TRI3_TRI3_4 = 7
-TRI3_TRI6_1 = 31
-TRI6_TRI6_4 = 18
-UNIFORM_REF_REMOVE_OLD_BOOST_SET = 0
-UNIFORM_REF_REMOVE_OLD_STD_SET = 1
-UNIFORM_REF_REMOVE_OLD_STD_VECTOR = 0
-WEDGE15_WEDGE15_8 = 24
-WEDGE18_WEDGE18_8 = 25
-WEDGE6_WEDGE15_1 = 35
-WEDGE6_WEDGE18_1 = 36
-WEDGE6_WEDGE6_8 = 14
-cvar = <Swig global variables>
- \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/dg.dot b/packages/stk/stk_classic/stk_percept/doc/dot/dg.dot deleted file mode 100644 index eced0412f9b3..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/dg.dot +++ /dev/null @@ -1,15 +0,0 @@ -graph a { - - graph [bb="0,0,100,100"]; - -node [color=Green, fontcolor=Blue, font=Courier] -object [pos="10,10"]; -B [pos="20,30"]; -C [pos="10,40"]; -B -- D -C -- D - -A -- B -A -- C -object -- A -} \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/dot.old b/packages/stk/stk_classic/stk_percept/doc/dot/dot.old deleted file mode 100755 index a90cd5b3122f..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/dot.old +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -#/usr/netpub/graphviz-2.26.3/bin/dot -Knop $* -dot -Knop $* \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/hex.1.dot b/packages/stk/stk_classic/stk_percept/doc/dot/hex.1.dot deleted file mode 100644 index 2772cf227c9f..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/hex.1.dot +++ /dev/null @@ -1,33 +0,0 @@ -graph Hexahedron_8 { -# name= Hexahedron_8 -# n_vert = 8 -# n_node = 8 -# n_edge = 12 -# n_face = 6 -# n_side = 6 - ratio=1; - layout=nop; - size="5,5"; - bb="0,0,100,100"; - node [color=Green, fontcolor=Blue, font=Courier, width="0.1", height="0.1", shape=circle, fontsize=6, fixedsize=true]; - 0 [ pos="0,0"]; - 1 [ pos="30.6186,36.9599"]; - 2 [ pos="12.941,65.6211"]; - 3 [ pos="-17.6777,28.6612"]; - 4 [ pos="35.3553,-17.6777"]; - 5 [ pos="65.974,19.2823"]; - 6 [ pos="48.2963,47.9434"]; - 7 [ pos="17.6777,10.9835"]; - 0 -- 1 ; - 1 -- 2 ; - 2 -- 3 ; - 3 -- 0 ; - 4 -- 5 ; - 5 -- 6 ; - 6 -- 7 ; - 7 -- 4 ; - 0 -- 4 ; - 1 -- 5 ; - 2 -- 6 ; - 3 -- 7 ; -} diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/hex.2.dot b/packages/stk/stk_classic/stk_percept/doc/dot/hex.2.dot deleted file mode 100644 index d038a2598a78..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/hex.2.dot +++ /dev/null @@ -1,33 +0,0 @@ -graph Hexahedron_8 { - # name= Hexahedron_8 - # n_vert = 8 - # n_node = 8 - # n_edge = 12 - # n_face = 6 - # n_side = 6 - ratio=1; - layout=nop; - size="5,5"; - bb="0,0,150,150"; - node [color=Green, fontcolor=Blue, font=Courier, width="0.14", height="0.14", shape=circle, fontsize=6, fixedsize=true, penwidth=0.1]; - 0 [ pos="3.77778,4.04242"]; - 1 [ pos="49.7057,59.4823"]; - 2 [ pos="23.1892,102.474"]; - 3 [ pos="-22.7387,47.0342"]; - 4 [ pos="56.8108,-22.4741"]; - 5 [ pos="102.739,32.9658"]; - 6 [ pos="76.2222,75.9576"]; - 7 [ pos="30.2943,20.5177"]; - 0 -- 1 ; - 1 -- 2 ; - 2 -- 3 ; - 3 -- 0 ; - 4 -- 5 ; - 5 -- 6 ; - 6 -- 7 ; - 7 -- 4 ; - 0 -- 4 ; - 1 -- 5 ; - 2 -- 6 ; - 3 -- 7 ; -} diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/hex.dot b/packages/stk/stk_classic/stk_percept/doc/dot/hex.dot deleted file mode 100644 index 0f75ffd4264f..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/hex.dot +++ /dev/null @@ -1,33 +0,0 @@ -graph Hexahedron_8 { -# name= Hexahedron_8 -# n_vert = 8 -# n_node = 8 -# n_edge = 12 -# n_face = 6 -# n_side = 6 - ratio=1; - layout=nop; - size="5,5"; - bb="-30,-30,100,100"; - node [color=Green, fontcolor=Blue, font=Courier, width=0.125, height=0.125, shape=circle, fontsize=6, fixedsize=true, penwidth=0.2]; - 0 [ pos="1.02223,1.23393"]; - 1 [ pos="37.7646,45.5859"]; - 2 [ pos="16.5514,79.9793"]; - 3 [ pos="-20.191,35.6273"]; - 4 [ pos="43.4486,-19.9793"]; - 5 [ pos="80.191,24.3727"]; - 6 [ pos="58.9778,58.7661"]; - 7 [ pos="22.2354,14.4141"]; - 0 -- 1 ; - 1 -- 2 ; - 2 -- 3 ; - 3 -- 0 ; - 4 -- 5 ; - 5 -- 6 ; - 6 -- 7 ; - 7 -- 4 ; - 0 -- 4 ; - 1 -- 5 ; - 2 -- 6 ; - 3 -- 7 ; -} diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/hex.pdf b/packages/stk/stk_classic/stk_percept/doc/dot/hex.pdf deleted file mode 100644 index b148d315cdf840cec7750b704cbcca15dbb16149..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14575 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 jV`2*?#RTY+yyDZ5(Ffp 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 N2{W^_sth^Fe*sj>{H6c^ diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/run-quad b/packages/stk/stk_classic/stk_percept/doc/dot/run-quad deleted file mode 100644 index c3d3e8e1727f..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/run-quad +++ /dev/null @@ -1,2 +0,0 @@ -dot -Tpdf quad.dot > quad.pdf -kpdf quad.pdf diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/tet.dot b/packages/stk/stk_classic/stk_percept/doc/dot/tet.dot deleted file mode 100644 index 4c19e698c61c..000000000000 --- a/packages/stk/stk_classic/stk_percept/doc/dot/tet.dot +++ /dev/null @@ -1,23 +0,0 @@ -graph Tetrahedron_4 { -# name= Tetrahedron_4 -# n_vert = 4 -# n_node = 4 -# n_edge = 6 -# n_face = 4 -# n_side = 4 - ratio=1; - layout=nop; - size="5,5"; - bb="-30,-30,100,100"; - node [color=Green, fontcolor=Blue, font=Courier, width=0.125, height=0.125, shape=circle, fontsize=6, fixedsize=true, penwidth=0.2]; - 0 [ pos="1.02223,1.23393"]; - 1 [ pos="37.7646,45.5859"]; - 2 [ pos="-20.191,35.6273"]; - 3 [ pos="43.4486,-19.9793"]; - 0 -- 1 ; - 1 -- 2 ; - 2 -- 0 ; - 0 -- 3 ; - 1 -- 3 ; - 2 -- 3 ; -} diff --git a/packages/stk/stk_classic/stk_percept/doc/dot/tet.pdf b/packages/stk/stk_classic/stk_percept/doc/dot/tet.pdf deleted file mode 100644 index be900b539f7256bca4fcc5b09a1acf02782cf9b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11249 zcmcI~1z1#F_pgY8B47~Gj!23#Ob1;eAl;1vjP!tX3MwHYAWBL}DkvbGA_7XNpp=wK zDj_XM>OBVx{_pj^_j$g1zv1DWeSUlGb=F?7_dd^Byy|lDPy`H3N5fk>lfOYngM`2# zj^?&>G-6^9VPz88%GDZz0x(TF8VCd;tnKAQf(YxYncI>qTz4QXH*?o*RNm3qVF!|t zarA^30i)m$Bx2{^gpNi+f{w<;)tN*Ds1VzoQ1Av)SOCx^2nq{9;4lz}?JL-_-);f0 zJ=nK>x2B`{O{NDSgPg!W&2!r~1jN}2B20ustXy`{{Td6h+-3qccKGjRck$ntAs`-f zG;oL#cmcFyWCDT1;1Ek-2ppmUfubRx+`tWrK%qgoQJCFLa4Nv7ev(}RWCeADfS`d3 zZfE*h5Dkzw*aJ*vr?G1?a2WDmB|u?da3m6mLPDS@1PqBn5rC!x+w_p~aHg=Q$?s0(pn|468Y-?9z^mHXV(yEYZf< zQQnd43WY<#er>>@SU{7&0~8Cv5`N7Nfri5nSS%cegJ?TI#NcoVh&Eu-vjC4Bwf`sj zNB(9H1?GhZ^p8XV`o|$)I4l|qM?s)C3=D(E5a77~6Kubm8W8szy7%)OnXc!K7B?hz!;1zf{4vWA6VT^*o(HH`f0Kwp4!1{zj z17U?l!{8Vs0T2&p5eOJG5&&^X7!r*_A|Mw3>bL)CRO4_kG#YRkzD}bNd;WXQg8;U!9sMA% z2p9@SKmn1q9n{GGckclL;g{+VXc!g=#}Yt40epsl!eOuo2owlP$)bo60k4=>&~{Mfb#;U3ZUcw}x&a=EL7>2Ghk(L@`w|q1gyG-_B#r<9>;Ol=5oiDeSiwQUf8Te210{)U z`Rm9HG`A1-;Awul0i5TN1SEW$Xd6KP>H*LGJ12d0q7`Z9Os`IKCXrot&Zj$w3dz!j z_}7y@_@y8V9K?VDF2HvH_)Vb+`S}I#OAO5Jm&x1MyONwC!t(Y+SCSmb!qM{QTYr9m zV1Yew=cPLUaO5Z8P{{xJP2rg|BYMbFyF1}?nJtce*FP+t$vAw4pxeKG0v< z-BZ?8Ws+O{)^tVkbBbuB<@Fl54Zp;e!L>QUkF}4VC4X$8P98g%8EC8$@Mw5$IqKb^YB%NHh9209uxf8YNX-YrADp#e60nev#M_MKnzshfHOkWLb_Eh7dv9XFVnM7B_e%1ll3W9rD&4&|GZ=0!eV;uFrsNL^Iojfm5oNgguWz;nMddp!H5 zcrHzD){|h6`8UmtAgog!Ix_t}imUbCI<}X>{rK3Z>1s&$qe4 zX`z(@7Lke&_+^ibHjyc@5S}T!=FHI6l|oc`XJ|El%q*9WkH$FJd*jQ%4RVU>$HA5u zhJ)J5d18qor_;W#gFYb*L$;#OCB-`X0yAU(c zvDKMG`tPTOo;uZPOJeb|$vGWEXG9HzU*F=>>9x{H_G?RL?WnJM9@ZwgA!ZYG@Kyfl z)26P7h<<(@#%H|c@2xhQJx52|9p?Ro*T-BU{U?Xd&DDIat@c&pTb?V}$V1N-tBWu7 z8TqfpO-)%bchSvO%(hXlGpxrJw|zJ_8F^xDOjfyFx@20ZtN8YpN0L@k37r>|ND21* zq#}Dqr$Hn4bCa_-2EJI9hvOL&GqqEO1JWmzpDA9>9wWuZ)|L8BzR^-klc=8!seB*C zxtMxmTrzET;>vmzY{S;eZQbMOhYKV`$=CGX8;(B4o;-E1^=wy`Ef?6A)lIYUL} z5rLDEcO1qZkMVEZdJ&`<CHbbl;@QYDJDTiEdHL|6;lvfb4bMd({2rg?>E`|4gcp0IXZelPV`&6c^NSn` zy)KOr*7o#;7U0`X+?tItm7Ay+ac6A-uNP0GkKHaqaPI*h|P`OEv*Tu9v>T!R1 z8_v3A(NHq~qO{`4;2ALv*~ut9+*8#MuSMza-eJZ;Nn2yz)3?qtJui+rRNPD1f$B(0 zA7~*javRg@)wgFktn{r=&j>ZsckXrC-*=_NqX=_WykpN)o2e0to6*xP8k@swPquE1 zkTbV9vyUzgS}mo^i^oHK6#Szo-KrG&sc`o)?cGHP>NOpvVbf7E3%Xr*Z{g2yvmfb~ z;o^(D)hb#NO^_W$~UUq!{$g7Q5-ld`Z?RMLfEK1iOQKypa5VzmW#0Y(pS&o0QGSyeW z<*?Z8)uxkdH~HadW#T@aZ%iuqPex&o>INc*2X2Az!nMFS{Ar5NN{7_-4-*xaRyx=@ z`#Zb>n;tt%eKz_0eWP3gLF_YYd4&*rkea{I;6A;S9QVWB-NyNqil=Dsk)z9=&b5FzbKm7>ZNjy!^zX;SoR4cZ$w^PK z9^c>*6Mb=n`Tlu(QB=v??J49Yzk)yG*!}2l28s$psrvbc3_dedeWhax4z;6|iaEE$T zIbMEXdaV3Hc#hfWsGwPGWW%xhYZer!yIjD3;{KZ9SukWKByGc@`VPRNaOxPQH^m|DFA{FW%)DRG-`0~X;eQt}`yyNiB z1ro(TOXK(Tvfo?~NeW-K(u*9J#vW1DFwy(k8nStd;=C==|pfcc~BF~Iy82b%U9%e9p_FwC=P zk~Z!JoNv|~nBEJ^Go^_;;3;;{1RaAmk5ITpahr$OabAY!tU$^)idR(8T~TYRhS$|` z=IR{*c)?dk1RHy%^jY-AVAo5^(3+`i4OghN&!}R#k3>3h)cUR>U0N23^j|-@moYOkSmZVl zwtvE;$ngBsu;(Ew*OTFF#_Ub)JXMCHUvG;E*xt$ywo?#@Q96^CN5}oP)-{|cOyE9 z+!j?w!!2~{9Qio5X|LAkvpnMU=ZcaeMd}h5idKQrp;voG0#{q%ZM+qxg0-yi-M4-B z4@lg!{Rlr#|L#;ZMW+}0ymi08>gmjCR@&1tmAdQ+G>phO9@ADtR-9I97tMy~Ll+h+ zM*6JP17Y<7<;(IMVHwmP)R?mk`0pPd?KEsT)jz3WO2#xV!Sw{F?28@9ASMDpFa&K|asZ#PVl7PxOeOMS;( zUmx>vBg4+Ype-636*|EfC&cb%5WZe1p5D~>te;L?>|s-2upxaDiLJGv* zq?AyLwaDj}5je-$&f zE3kydCQ>@T)5tGw<<;{fw?$$)**+PhM~t-NCHLpd`$hX-Txu#@<$kWl?Ov2ClW|w< ze0W)GpQTh1l+WYh5*N%uT~0Hw$p(osS8BCqd$r(2?lRzi(5lu5Z)ZJv`MxEZ##u4p zsX3u%;{084xNp!^mmV9V z7zWa(6dO+WTGyp5uJ$Mlbma;YzaO3*b^#G?KjIz{nw(S@=jELvmSLN~RCyUkDwB`C zD$3i45*tsgx}`B19~xQlFRTNvu$LjJ*Xi4|tXzQM2c7T#A-5#rxGG1d8_Hh{*n=^m5#;=AJgrgs~);v zH>O*Gsj9dPBZttprCk|C2qAsSE^@aej>gE7g+Jl=ycj-@jW91Tbv35PPAAK}O|!(8 zIBg9MYUXhagt)t&s^v$SzsLxg?ia9k=s=HtxEb2RF^zTROt2C@n@>Kf1tVAcLgQ0= zoYsmBQM@M1erG7)Bx_p}5Cm1fpj^caLoz}6L%{!vy zwy$(ED&6j*_}_if-FuOlJY4aX=-H>SWYZ#6T+}X7S!$HVZ$CZR`)E8b7iZ)bUpe5* z*P7>jtwsW8Cnc^G)9A&?(yq<7<%{*n=9in}N%@x4gnzjC#p9xXg^h7GpFMSy6XdjM#pd5eM=E}<#xWhhdW$Tis{G<-8*L7s6kKeNU!Sl^S zM(li0Wsrfm!Kn$p&}HM;(u2hTeI8--OWxRZmeMRsPrWOB_i*PHA?2kquei8IbLM?X z%M}uv`JFjrTmR^FX(dxhYtQlJXUo^3uWmuS?`}x9B9^Z$3av>+DEFC$1bNwWcFAxu zkIPOAy*=v3JN{!siQt!IA2K{wT#z}I{P={anWEr)$%@8=kl_9eC4+EPH8VxlEHfwX zbtM|Yhg!{*0@eFP1<~&v*Zi_Fl55Y+!4ld(U*uiTn1%`RJgwHQsJ`S~b-q=gCyT(m zY3-4~$YpWrVM6CelBPtx2_H#6PH^Lqk4Uw0>xO&6gv~Tku<0!+{e*s;;xJY}TwBlC zM#Zk$>HF8^i0G>lKOTFZYrX#A=++zHuHkd8kLwNfM^Vj)3=cHh`@>}(mZYAHRDn~X z60HYaeVwb(_lrg|lC+zw#!v&HZobh;5$)D~AzE+K6vOYCsTCzt1uYRhFoEbLVe7)V zqC&?8Qmxdv&l7j$t4kGX{K<6U!H%`vZ(^IJxHCJQ&_~s>OCU3fFEYAfy4D-x>dtU& zCc4`!CAwGIGxEOlD~;985j6ZX?cG|V;U67k_C@s5+`bNCQbSdGhqfl2tp=tt>V;3R zmPWKHl$CCJbHIg|99)taT;qMmmR83jef9w}Og4fHu`#r<8!=MX*@Dd2S|Y2uR< z52xkruOV7#o+3f@at&9Hj^0A6gj#lrjG)|-(7A{_CN79~b3#Kyi)YV^JKFEw9KOye zuMxD~ppP29Wq*}bBr869^ya!Oi~cEQIPPoa9fakBg`j8n?orj;`_(w>D~#;K_2tG> zEcVK2Qew=sDDkgZH%87m+j`Wfjk3jSH12QSCw(SG1~>6ZU`dIao#GQmx2!Esx~pBi ztpL^RF^pQfC+#S=V#Y$IuDZirHU(?()5u&zP-|*vy$TGVW!E_*fXIIf z^etMVvVupRb5o*|7(UTx@#hr&SR1LJeUor9!R*mY8u68lV(kOT6xykh)5V7$vN+nw zxP7zC2hoR6`}>aJ=`&?JB$6q6C@Z5*o=zmlq)KyDtij>>p^v!{cU)o?P#Fm#|+W(=7O)QV=hsgboFAL?TR2bXN zo0N2pFZ-}n8=9E*_l?hdnXinJXSnU~tpw*26;}N^TnUo)BBIUBRP80rQ-OU;XyXj-XFbVyorm^t zEyY!CrbM{+56SBo)8&!1u-aLL-QzYc9ejF;4})?n5Jc;25d#+id+D(1_cLy#A~^+} z?O>*7j zH1(H{#&D$$D4Li?MtWuT4O|&P`n#i-4ot}SAU~HL@=A#8?QNcrI#XsS&^zW{$}N3@ zfs#5}%=jkkTXsOKLSZj+;(&6vSoqz_&X$ZG<-IKRP{d%xCl=}j{rcqRYMiKQ(qVgd z4$;?LFFUE_aVc^ar|4E};wju>l|~eK+iolR>wgyIjI6UB6kB?bFMo?Q-@N*|1u?#%Z`RPeVnfB&#YBnP$s&?#}S*5f;@O7B}pqirL_>zOf6fsa;?9rDzUI zK#}U#DiqygFDcd+rg$PxYk&T9C^ObDOXkLk^T;z#rBHq!y9ep>H>NYs-?!LGy{@H2 zEqIYrPA!vOv&ij;_%jg&Rs-r#o)bgSuG6ms)bCw9#5`_k%WK=M)Os#MS5sNi_d@Ay zb8_#U+?Z%BeIda zOgzU~v4tT{5|=V{TQT(cq+*b9bwKJx9TU;^V)JGX&W zdcHEd=LdDpDd{fV$%$ZmD3Z>v#VJ_XeN;ScNIZGlV(oi*-*<~23~v3!sx-ogGXZ)XY_m+h z=Vb5?6V%((QKCWdo&H@CwqRNp&-ldlwH>SS&8=Wd zkt61w*dNqhbQaI#CFO8(n-pjUiFRy=J)WxrAhWR=P)pYF@ z{%(19Go3;*fl3lPbdGBCO@KdYs18yyze&5cpE4ztLh`}2IrjPY4x~j7p<&TG!v>To zh@k;0F^4)WD&Lm@{B)~&l(jZ>3{<`uv|Jxep_1gf?@cMUzOm2uW=xMar35tPmr1TK z+pfJ`UOqSU)_ddKLt-k$59EPJmicz7FPI@aDlv{gf40MBeh&=4+aBTS*MdoE)A_Ux z3kiJH3m%fDthKMBr1H(-n8gj%3P;4vJ-j9y5#n?0F}sHQ;d)6nr}q3yi{eyY*r+}H ziMhTWM`|B;p7bZ4{^DBqnW^GsKs#M*Ybxr(W5(IWvmW&IoaK>mbMchrksE$&{7Sbm)G;d`HL#q)qf$J{7K>`*pa#nJAXxBGFv*>bgM zdnL5?z8kGumhO#+?KhMSJ?u^i6emy@-W#4Z#qG0W(nopa)@0M`vcCyR zs%EQ`Jm`B{c14B4aldhubGmO1MKbRjqLfdfEE#w2HANoPqxu9Lsz+b(V=)ZRP*1d1 z@E6Vsmax1LJ1{G4jlB03t48Ly8q8l;N;5@Q(HIaG7x(hGUfm*zVQhT-@t1T>FN3Y9 zgH9TPXD~xDlrVkGlV%drjmm6z|MdYUsfLoxrw{yI%rwh6>#agI2jquau0vu5rxGOhnp17 znbaBgiK_M^_VQ6gT&2L)l)t8Ip=jJ=^OSMWJ92`9 zu$E~%PxmK12Ua`Dkz6dCZJb;kop&;1Af`%m0Lt`mawJ=#uAA~XSuG+ND2M~oazKX7 z$^`<{`)xk}q(5u*uqZT;HpQaxKt3600_kT29tY;^KsrTNqP>lUG}+3Y1Of7eASCT# zv7HViz!5tDCra_?8V5cl`V@4V=D38J>M8wpHY?!Yoc7ZS)6BK$W+*f_hm%32ehf6Yjl`15&} za{lNR0&4$f5u~1trK>fV*hGNkCjYqnBh3j`{`|veU{3X?HO|{uf_%Wl>vn<^)U2$d z8<=O^nSv(C#nH{#g5&}b6Wc~WinE@s=d@gbOzAEV#DTg;&^2VGfh?`C1rfM{C6_=C z@cYve-d4#Uc0lJpO6Ndb?@aa2KyW$-3m2H9 zvz6e^G}N6PE!`}D4DVklcJn3d=DU-FmL&r2=V9pHt&zM1eQlk2#sU@zq7OdH)c@K z4JvX7NS#ms)-g2)LBJ4@9k2uf(gKM|f(UX0l^7HvNst=?|Gi021^CpjX&!*AN45b; z0_p=VL4AFY9)UMu1W@L<@tZObFzjC?kOY>vf(WGxP$CGT92EfbBe4(wRg6#&2!JTZ z^Z!i}f(S>F5E{QpqF_KpF0N>e#=5JxyLpO1#0cXCfbkFjZ=eHwMM4@-3ksG%0*@rf zz!fA5fyjXj0J|vzi;s2tUz8Ms0lI(@5a2-o+9HmXII3I-Jp>4jI4%fU0&PGRfP7s3 zQvBDV|4*7D|5J15@0t_b{>!M4-;Mh3;RToeo8FRO2`C&QDGl%f_6i&i+K`Cx$oqP zSp9F3{a->*3JeEH|2+m_|94M_!2q^mh~I(`jsQzZNkS!%ATbFr30iOXKAdC<|k8u10TMQ0^K_rp?DhF^{q1^2LIM0FR(XBy< z!lMRoSwJPFq>d&X5eQ#7Y7j1#<7-6M+5vTZVdz?8QEr~chu<+p3uTA4{;$^v;Tlo| zP99(Z4!C3p5?=-Vx?cVegAnw8eoO`J;)%k7#8q6ZJyA+1TX(x(U;TBxArNrr@kfsd zP!Qk)B<$}OmQUuU426%`wKRv7oQ!$_Eg3R28f~JjPpn*c<%&@FD;xe^-YkT;JwIB+ zuqCY}Db3q{3vxGK2!C4svIQgK9U~!AdYap1#!U(glc(p%%{g^Dyu7USjP%NCTd#Q& z&u-lsym*77S8`AJ$u?edW$@O};m}XHpNHEyWHmGj!abi(^~B^(Ir{uuNWf#3oWrIp zs9uaOacA;A`{CP`Nq2s*dgU;|eg6Ar%HPZCXNcCx zjN;oX->CRn`0|OD^|_yEyCJ`5bc2_#(SLBMtzRy$Z6CMWE^jT{ zPQ6s;J!n&$)r#r(c;~6=Sxco%adza!x9{YpS?zts?X@M3`p}miM;jn}M=k_5%mvP6 zUp#1a7+P;kd*NL5*saYzqhybT^iI+4%~y@ImP~lVE%?ZbmoLOr-gpm+oswasHTK6VzQ? zDCCLEx!7hCdTVs$0{#aQ(rrCg>vtu&wlokmp4g&6iT7KiLu`^ZesY&>9!jvdVKwtC z_h#5fHpReoy;YOi*5z-fS4G1P8?MEK8VJSYjUQefR~7j@F}(@$-+Xpu6Jg@tNY}@R zoSTBkNmW}1Sj?AFEy9D#bQz_;JS)g}{ApuBAiKDgbJ3`H%)SR>yq~$(rMXG9v~pT16Zf=>&54trTD<&? zLgQE-c^R0itg5==(Lq~*7izhzvbw?rJ5V7cBF@ujx~bDK9Ij$k;(cp>g<7`mW_MkN zMa{TRrHR$~*G=woQJY&U2i@&FwiT{AmScN;QnR1ambe$2WVLnuX~gXqg?Q?ox0|;` zyD}gzXLn5|*>ScE?Vpe=!Grak)AL-H=` zz3S)rmWpDs&expo3C#CMt9apU?8~x-U!2Wv$3WKa8ibrsKN{MlR!orFsXY+P24I!qU<9#`p<(qL#daLG*GMl%!NprKzE_cPvA8hW?OGwHAUa~`Fa#w;#cX`4gJY~>X7~HVsnxCfJfn?`o$l9RU8ga&a}St#gDAu zGfh5XxoxI8=IN;0F^Y$zE9Hkg$Qu!7)&w#Fadn>#-{5Y^Rl(qk-fda(QL%n)_q*>X zhZ+2M+psztb-i%O=LhM%x?Zt^K$T z0rVF>%B2msWeSAGP#Q+lj$*b7Ei2J z5S|2tu3Y3iwb7}unSOx`=i5cwnDhb8nFxtrgIB3d$vaK@@s@+KNO{dvN-L}LQe5NG zia(Gqc$~%e*x>bn$t;bNe3W+CS?W{rjCeNQ^7zC3&l=6KnYNFwbV;aXeZNgx33|Do z!e?eYN4cG_<3igKK!koe9nYJ`tNhR|N=YpOQX6{;N&y*BGMsnjQwWWEq9*dz4kBT9 z&Xh+unvN;X@5;$twsY7d<__lFWygZ&SrIv`l`Jou&p_XMVA^@R;X#=Z2~0yaWY1Qx z#my_vq#Jqa878UbeV@ncpR(50q7yO5rBM_nYvZSJIQL$K=I(+YdrO&39PLP1Bz((eR;fC;#TL4^Zi?YJ&hs?Z4<*Tk6T)4d#svJ{MY zZ$|rm&BZnl9!y+OoT}Z(^>Q(=R*{39nu$W#r&Dhrpj?RJhS zVVs$5F0ja(ar6}lTt*gXXR;_~Mj5d@Z^?fp!h;}gGEpy|$4Bb3XWRAm`YlOWH98V= zXt2dpU44}C#VV?#+vP~vjY&cp6x3+-E1MK-tF2K6#?PxeL8aD;nUue(YY=8?{7 zGFBSrJYZrP`+ye~wu^~EYOTR}n|bpm%}2Hin>5|*W7BrGXtD3RzLM3*2{l#r%Bz;L zu-NLcoGyJ}ZIZ5@&cgM4$%mX=mLrni>-NcR1WL-*n9hGTw*66vUR=^TBT z7+OIgG&ZV1KJ#UiaS~}(M5xBr3P}AvgMns7Y!q`;RQbJx`_Z>+6z+(!Uscvat7kAE zJQ;i>hAGaHhPMd12bZLQf)7|)*hZ9_CoFnR%ORxnm9`2F*VMF?-N141 zQPvgXhuVue=9wXyU*y1Y9}gFO0upEhXf7FFE74O-C@3`TcZCTLF(%10`5N^wCnnI- zd8GH$aNn zV@l4+}wx#7>zN{$S)>+9;7kzUAlfvN}64q1&}r}gZ&(kid4_CJ`~_6sgIZlNxh zW_j`2k?c0wuC*Gcu(ib7F)*sZz;dm>LU6BDs1B~6v2`!1XGb%jupl-)D&O{bbn?3T z@>aYw8Ew~g_`Wdenu%450%!Jyh1TtIbk_LcjQu9B1@alTK~=p{urQULrk$!vam04T zw1Bd`zJDkMNHc#?RX{<q}=k|hZ}5)^mXU4`qp;>b8}3ma<5|?8GNQ=rnAjk zqCPVC6lhJ|{(47a7A)NouKbM;UQ^8AS7hM%>U^YjZjP!^sfN|p;W&GsnZ(BW%VGl*QC&l|}-<2<%~VlLOqPk$a&;kso(F-q*_>nc)hJp1+HNb7xB zq9;h*E@8Ik7JFwzn|2y5HK|^B_G9yY;^$Rv(H!D0sDS+yUXjMChP$F|i@ogpVz+P9 zkm8kPy{?dbM>?l6d$K;V-}*4$!bm@aOf#DW%e7FHy$FDt7~Ob8j&-%>v$9{%4ra>< zOW}m)+#iq-`B|=S)SB$q)tDXk(qy*O@8fu6TI)-Phh3#oylc2R63x|8TJy1Bze*Sj zP2HiyMInCyzhNB5YI#iET=F6+OWD`N-n=BnDHx}bQoT~6BY0uC7a}z1pVS`}BvA`n z_=4gCbIw8Eqo>w>YJMUTc~7j7ay3~o_q%@A+?7L71_s8JPj;dC8Qc>%<5~XcllF6B za=q(^?-s|>dzUItHa*b|UgENLRv+NtSiPd$QR`>serxi*r&Pn-mG2;vG3sW1q&`>^eP z+=q(~nmTSM={&e0$v)H6c*71gVVfhUFC(|ddqFPTJbm=_Zf?=oZrYatZ!9~f$*bM8 z%5BVr3zBIRuao-vv7~YVe1}3^zkYC-E(vG{poY{B6f=C?5{!hucir^Y_0ow9@by- zTx0qg_f;m?g?803y;L;ms-lURmaDCw4~#+mYrTPNI^$gS?LuQE4RnvQU;)3b7t>mt z(*msC$Vm-X6FWHeOi;tAL=yapRKl@FF#R%0o<5!1p8uh-H#x~CAKGE00)NQZaGweH zory9!{*u-c(c!7-+Urk>W4<}6QQI$?aOc@K%Pu%lX4S{)(^I5cQah-;`sT%S=E_wQ zSV3g1yjDD!vR=(QD@2|Li{tP~rbkHT{)lE?o?%U;A$#3a9|PFi^H&Rn5?l~>4$Rn@ zZabSf3!mg=_h8t;cx2!4iz$Hb5!`}R+9N!~kDGqkFF!+w3WW61<(vp3v8N{^!pg_L zl6V(UkL+tt98e8Hc8}1&8S_HZ>se!hTb0B{^mVMv@{P=N(0t?eX~X%9h6#G1LI%4o zX6(;rLi!blG51K*S^KTtaRn)j>#8}rrN_DJ!o#sBTc;ST3YQo=yZRYu#6Ww@ZJ)4G zdEUeo5mDcfB&0_oJ)wl>r0Vln&`YY`?>4T~ zRJPh0(aJo2!uRaGT5cM3`Mj3S+{t#;kV`H5iApV$S3uiEYna; zEq)LGl2GU!ozzD>sI#xy^tqiPl*c5mj?pS37W7i?Zk_ArSGYRgR%~#_!AUyn`lw&* zw$lP)i#PeX&wgjS4Hy6TJi_Y?!_%9ouY{<_=_pFM4O6RimBbiV6e>Pe$IWJ+`1slT z6yniMj+IY!a+cdcO*5l|Ytw;kRk)fvvz?D-f1FUH%xM*)Y6`MwXAOswTJPSvS=hyYZt7ir{QFYT@9p zH-29cU)!?QPlCNB)(sTyWv%1=-$b> z<2yZbKE<@CuBZvGDC76l|IG}MyF0b>rw77Y6X3f-Y^5U;%lqD~My;**ncnf5RE(s4 zRvS{#^40tIy9d+e;Fax<^}fg;@4YXwu0+Anjj9@+WFB}w|8LnMUp-FjiZX&9d1R?p zUp_s3fam9>Tl@UrQKt5TNv59Y+Tr!j&8hg+Pq@3D2Yz~HTSK#FX^6f%>TI=f2#J5D z;mlxVk9vMx<23%_7MSyQ@Dn|@}!q}jkcRXi2ls2)zqM*B?BFJi4E zmqewcxLLc!^TO=UXz7by=iuugZ670KN_m{Fscrz3i4l8EQfZuH?^;xry4SPN2FJW5 za!$X2uE?y*3yMYJ0aG6Iat8Er&l{d*FiEmdJXWTsswcX{s=a)RgiU$Qjje-Cd0UkC zN9iQ!M@RaznzxS`wSRI(+~FB^9eyFmU$#lrt5&OLui2&Xu+#Bsx1Rt@G>LI!p?$4U z-)^OeuHo61_s+G_!6K5*qUW_pc^uofW)xHPdGL@>XR?t5t&PrPJ;o??Q6=G;IM-2H zBboVRPvuD7xsr2(PW%Rtu_roQU<;zLbl@M5)Uhl5B6OD{Z8<1)%93OIoLs%Q^UJ8QXaJ@-vYVnZvy@Il<+D{9+YtAzwpd&@ zRXWL#pcv!KqY6y$T~c=;{s3;RZ>$p}(TV4!Px@9dQf$uS#qTRR-Yr#p>mzQh8DY_| z(r}*tMWC}VTP#L)^!bFQs8qj&=T=c=}WFiL>oa(d!*m;yC7= zxlcQmbqkle=g0jHp1Qg%QS`qT6934xFK^s_&|zJh;p6bIAAj!w2TJ zuqg4vg_OsR27yST$BtpZDR6_>!ZBpkd4BH2{3^+}a@HSS0^jyL4w#6u757%XyK)_5 zk`-kZUTgcT2v8(DP#*Lu9Mlk9g3U*ge5)fO?Vf*M#3-V}wlijPAWs)C7qmTXP!LeW z*m04%1Jx--br3+79E)wSfI$oYhu z<9$4zs;gM#A{B1Ao#a5w*OAEDbvl$T$P>$bFL~WplrgVgw-9`8L-}62?M@TP^kawn z*vCZv_D^o+m_3+g3enl}7S1s{(VDeGM*f*~XSYUud66XcT30t_xckL?-sb^Bxkr>+ zX;il)h;Gb%YQ{DZ-PnBdaQc(nBgSui91gC$KiZgu*hUiff@R;<>@`vSEHK-ew6RL6;g=UF!rHD>+Ra8 z@5b}y1|>dO)s?gtsNOLX4>8xXy|TBgtk=4{zBoU7LX4!XJ4j^0P~`ep=NmZgUc-3x z$_I6nR{t;(hDjqzsjSokX9bO?NGFfOF}l1$WPIJW_tZuld^h7g><0NE24Vqu4u`odJH;Zt=h^5H~dWD-=V z!HyD?f>pt_=cF+s!88yi3_WG_V*5?xROV&MYWC`Iw@0Ji3zl8fzOAQI_Z^0R5>;$i zg8wVfMF6}1M3|1@ECL*^gu>Zk(HKv6>@lK5plMsX0yz^>N+>65LoZELMSW{GAUlBo zV*!Yi0}ccvUmSISslO5@5E7D-1mv0k3j$3T2nLmwB4AvEc~?BGUC_4jZVoOe5agI7 zkF!03&j4uem_QJNKtaGEaEW7*qBTYhg?4cC1i>M{mg#$=6V9fHM>f zNNfNAwqr2t4|q-Lzbk+Ip+ECM46t4(f@O}$3f4FjfhkD*zZn9J#d#_^T4VpvNYnaP z|CjWCw=ID2AIU^8$91%wry~Ifgi1gpek=Zg2ogZsh9jl>>b+_}f1;Eh%I^%b~$lv)M$G4(25P9wnzc>+$_XlA6`$8Wq3djWk zkb5Ak2#FfU4-kn2u$wS)^hhHm0PP45A&2Lv0Tj^xpg|E(z}JN5uX#`eup|CSlY#>t z{`)*>Ao%}-1|aPJq#>bj0Ji@7S|k9<|3&k}S_4}F*wO^I>ZAQoN7@k_cGcb86GX7p mv7f}RxY@gd2tN6>V{o3 $1.pdf -kpdf $1.pdf diff --git a/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestMain.cpp b/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestMain.cpp deleted file mode 100644 index 3a20b41267fb..000000000000 --- a/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestMain.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include - -#if !PY_PERCEPT -STKUNIT_MAIN(argc, argv) -#else - int main() {return 0;} -#endif diff --git a/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestPerceptMeshFieldFunction.cpp b/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestPerceptMeshFieldFunction.cpp deleted file mode 100644 index e132b73b2361..000000000000 --- a/packages/stk/stk_classic/stk_percept/regression_tests/RegressionTestPerceptMeshFieldFunction.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - namespace regression_tests - { - -#define EXTRA_PRINT 0 - - /// configuration: you can choose where to put the generated Exodus files (see variables input_files_loc, output_files_loc) - /// The following defines where to put the input and output files created by this set of functions - -#if 1 - const std::string path_sep = "._."; - const std::string input_files_loc="./input_files"+path_sep; - const std::string output_files_loc="./output_files"+path_sep; -#else - const std::string input_files_loc="./input_files/"; - const std::string output_files_loc="./output_files/"; -#endif - - static double pressure_value = 123.4; - -#if 1 - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(perceptMesh, open_new_close_PerceptMesh) - { - EXCEPTWATCH; - - // start_demo_open_new_close_PerceptMesh - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - int scalarDimension = 0; // a scalar - int vectorDimension = 3; - - mesh::FieldBase* pressure_field = eMesh.add_field("pressure", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, scalarDimension); - eMesh.add_field("velocity", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - // create a field function from the new pressure field - FieldFunction ff_pressure("ff_pressure", pressure_field, eMesh, 3, 1); - - // set the value of the pressure field to a constant everywhere - ConstantFunction initPressureValues(pressure_value, "initPVal"); - ff_pressure.interpolateFrom(initPressureValues); - - //if (eMesh.get_rank()== 0) eMesh.print_fields("Pressure"); - //exit(1); - - // here we could evaluate this field function - double x=0.123, y=0.234, z=0.345, time=0.0; - std::cout << "P[" << eMesh.get_rank() << "] " - << "before write ff_pressure = " << eval(x,y,z,time, ff_pressure) << std::endl; - - //eval_print(x, y, z, time, ff_pressure); - - double pval = eval(x, y, z, time, ff_pressure); - EXPECT_DOUBLE_EQ(pval, pressure_value); - - eMesh.save_as(output_files_loc+"cube_with_pressure.e"); - eMesh.close(); - - // end_demo - - // start_demo_open_new_close_PerceptMesh_1 - // open the file we previously saved with the new fields - eMesh.open_read_only(input_files_loc+"cube_with_pressure.e"); - - // get the pressure field - pressure_field = eMesh.get_field("pressure"); - - // FIXME - std::vector< const mesh::FieldBase * > sync_fields( 1 , pressure_field ); - mesh::communicate_field_data( eMesh.get_bulk_data()->shared_aura() , sync_fields ); - // FIXME - - //if (1 || eMesh.get_rank()== 0) eMesh.print_fields("Pressure"); - - FieldFunction ff_pressure_1("ff_pressure", pressure_field, eMesh, 3, 1); - ff_pressure_1.add_alias("P"); - StringFunction sf_pressure("P"); - std::cout << "P[" << eMesh.get_rank() << "] " - << "after read ff_pressure = " << eval(x,y,z,time, ff_pressure_1) << std::endl; - - // a point-source at the origin -#define EXACT_SOL log(sqrt( x*x + y*y + z*z) + 1.e-10) - - StringFunction sf_exact_solution(EXPAND_AND_QUOTE(EXACT_SOL), Name("sf_exact_solution"), 3, 1); - StringFunction sf_error = sf_exact_solution - sf_pressure; - - std::cout << "P[" << eMesh.get_rank() << "] " - << "sf_pressure = " << eval(x,y,z,time, sf_pressure) << std::endl; - //!eval_print(x,y,z,time, sf_error); - std::cout << "P[" << eMesh.get_rank() << "] " - << "sf_error = " << eval(x,y,z,time, sf_error) << std::endl; - double val_cpp = EXACT_SOL - pressure_value; - double val_sf = eval(x,y,z,time, sf_error); - EXPECT_DOUBLE_EQ(val_sf, val_cpp); - // end_demo - - } - -#endif - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(perceptMesh, open_new_close_PerceptMesh_2) - { - EXCEPTWATCH; - - double x=0.123, y=0.234, z=0.345, time=0.0; - - // start_demo_open_new_close_PerceptMesh_2 - PerceptMesh eMesh(3u); - // open the file we previously saved with the new fields - eMesh.open_read_only(input_files_loc+"cube_with_pressure.e"); - - eMesh.print_info("Info after reading mesh"); - - //eMesh.print_fields(); - mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - // create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, 3, 3); - - // here we could evaluate this field function - eval_vec3_print(x, y, z, time, ff_coords); - - // get the pressure field - mesh::FieldBase* pressure_field = eMesh.get_field("pressure"); - - // FIXME - std::vector< const mesh::FieldBase * > sync_fields( 1 , pressure_field ); - mesh::communicate_field_data( eMesh.get_bulk_data()->shared_aura() , sync_fields ); - // FIXME - - //double * pdata = eMesh.node_field_data(pressure_field, 1); - - FieldFunction ff_pressure("ff_pressure", pressure_field, eMesh, 3, 1); - ff_pressure.add_alias("P"); - StringFunction sf_pressure("P"); - - // a point-source at the origin -#define EXACT_SOL log(sqrt( x*x + y*y + z*z) + 1.e-10) - - StringFunction sf_exact_solution(EXPAND_AND_QUOTE(EXACT_SOL), Name("sf_exact_solution"), 3, 1); - StringFunction sf_error = sf_exact_solution - sf_pressure; - - eval_print(x,y,z,time, sf_error); - double val_cpp = EXACT_SOL - pressure_value; - double val_sf = eval(x,y,z,time, sf_error); - EXPECT_DOUBLE_EQ(val_sf, val_cpp); - // end_demo - - } - -#define EXPECT_CATCH(expression, name) \ - { \ - bool didCatch_ ## name = false; \ - try { \ - expression ; \ - } \ - catch ( const std::exception & X ) { \ - std::cout << # name << " expected to catch this exception: " << X.what() << std::endl; \ - didCatch_ ## name = true; \ - } \ - catch( ... ) { \ - std::cout << " Caught unknown exception" \ - << std::endl ; \ - std::cout.flush(); \ - didCatch_ ## name = false; \ - } \ - EXPECT_TRUE(didCatch_ ## name); \ - } - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(perceptMesh, open_new_close_PerceptMesh_3) - { - EXCEPTWATCH; - - // start_demo_open_new_close_PerceptMesh_3 - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - int scalarDimension = 0; // a scalar - int vectorDimension = 3; - - mesh::FieldBase* pressure_field = eMesh.add_field("pressure", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, scalarDimension); - eMesh.add_field("velocity", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - EXPECT_CATCH( eMesh.commit() , commit_again); - - // create a field function from the new pressure field - FieldFunction ff_pressure("ff_pressure", pressure_field, eMesh, 3, 1); - - // set the value of the pressure field to a constant everywhere - ConstantFunction initPressureValues(pressure_value, "initPVal"); - ff_pressure.interpolateFrom(initPressureValues); - - // save - eMesh.save_as(output_files_loc+"cube_with_pressure_3.e"); - eMesh.close(); - - EXPECT_CATCH( eMesh.print_info("bad", 1) , mesh_closed_try_print); - - // end_demo - - } - - - //====================================================================================================================== - //====================================================================================================================== - //====================================================================================================================== - STKUNIT_UNIT_TEST(perceptMesh, open_new_reopen_PerceptMesh) - { - EXCEPTWATCH; - - // start_demo_open_new_reopen_PerceptMesh - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - int scalarDimension = 0; // a scalar - int vectorDimension = 3; - - eMesh.add_field("pressure", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, scalarDimension); - eMesh.add_field("velocity", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.add_field("element_volume", eMesh.element_rank(), scalarDimension); - - eMesh.commit(); - - /// reopen the mesh to allow for more fields to be added - note that this involves a db write/read operation - eMesh.reopen(output_files_loc+"optional_temp_filename.e"); - mesh::FieldBase* momentum_field = eMesh.add_field("momentum", stk_classic::mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - - // create a field function from the new pressure field - mesh::FieldBase *pressure_field = eMesh.get_field("pressure"); - FieldFunction ff_pressure("ff_pressure", pressure_field, eMesh, 3, 1); - - // set the value of the pressure field to a constant everywhere - ConstantFunction initPressureValues(pressure_value, "initPVal"); - ff_pressure.interpolateFrom(initPressureValues); - - // set the momentum field - std::vector momentum_values(3); - momentum_values[0] = 2034.5; - momentum_values[1] = 2134.5; - momentum_values[2] = 2234.5; - ConstantFunctionVec initMomentumValues(momentum_values, "initMomVal"); - - // create a field function from the new momentum field - FieldFunction ff_momentum("ff_momentum", momentum_field, eMesh, 3, 3); - ff_momentum.interpolateFrom(initMomentumValues); - - // save - eMesh.save_as(output_files_loc+"cube_with_pressure_and_momentum.e"); - eMesh.close(); - - - // end_demo - - } - - - }// namespace unit_tests - }// namespace percept -}// namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/CMakeLists.txt deleted file mode 100644 index 854268de49ae..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ - -INCLUDE(TribitsLibraryMacros) - -ADD_SUBDIRECTORY(function) -ADD_SUBDIRECTORY(fixtures) -ADD_SUBDIRECTORY(math) -ADD_SUBDIRECTORY(mesh) -ADD_SUBDIRECTORY(norm) -ADD_SUBDIRECTORY(util) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_search) - -SET(HEADERS "") -SET(SOURCES "") - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/fixtures) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/function) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/function/internal) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/math) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/mesh/gen) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/norm) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/util) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) - -#SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/verifier/mesh) -#APPEND_GLOB(HEADERS ${DIR}/*.hpp) -#APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -# Must glob the binary dir last to get all of the auto-generated headers -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_SET(HEADERS ${DIR}/${PACKAGE_NAME}_config.h ) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk_util/stk_util/unit_test_support/) -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) - -SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) - -TRIBITS_ADD_LIBRARY( - stkclassic_percept - HEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_fem stkclassic_io_util stkclassic_util_diag stkclassic_search stkclassic_expreval - SOURCES ${SOURCES} -) - -INSTALL(FILES ${HEADERS} DESTINATION -${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Edge.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Edge.hpp deleted file mode 100644 index 16de29a2aca2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Edge.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef stk_percept_Edge_hpp -#define stk_percept_Edge_hpp - -namespace stk_classic -{ - namespace percept - { - - template - class MyEdge - { - public: - MyEdge(IdType i0, IdType i1) : m_i0(i0 -#include - -/** This little jewel is a poor man's stack trace. To use, insert EXCEPTWATCH at the beginning of each function you want to trace: - * - * void func() { - * EXCEPTWATCH - * //... - * } - * see: http://www.velocityreviews.com/forums/t284190-exception-stack-trace.html - */ - -namespace stk_classic { - namespace percept { - - class ExceptionWatch { - int line_; - char const* pfname_; - public: - ExceptionWatch(int line, char const* pfname) : line_(line), - pfname_(pfname) {} - ~ExceptionWatch() { - if(std::uncaught_exception()) { - //on purpose - printf("STACKTRACE::ExceptionWatch: line:\t%d\tfile name:\t%s\n", line_, pfname_); - } - } - }; - } -} - -#define TOKENPASTE_LOC(x,y) x ## y -#define TOKENPASTE2_LOC(x,y) TOKENPASTE_LOC(x,y) - -#ifndef NDEBUG -#define EXCEPTWATCH stk_classic::percept::ExceptionWatch TOKENPASTE2_LOC(exception_watch_, __COUNTER__ ) (__LINE__, __FILE__) -#else -#define EXCEPTWATCH ((void)0) -#endif - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.cpp deleted file mode 100644 index c00a2830b71d..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.cpp +++ /dev/null @@ -1,511 +0,0 @@ -#include -#include -#include - -#include -#include - -#include - -#include -#include "PerceptMesh.hpp" - -#include -#include -#include -#include - -#include "Intrepid_FieldContainer.hpp" - -#include "Intrepid_CellTools.hpp" -#include "Intrepid_RealSpaceTools.hpp" -#include "Intrepid_FunctionSpaceTools.hpp" -#include "Intrepid_DefaultCubatureFactory.hpp" - -#include "GeometryVerifier.hpp" - -// FIXME -#include - -using namespace Intrepid; -using namespace shards; - -namespace stk_classic -{ - namespace percept - { - using namespace interface_table; - - struct ltstr - { - bool operator()(const char* s1, const char* s2) const - { - return strcmp(s1, s2) < 0; - } - }; - - - struct minMaxAve - { - double min; - double max; - double ave; - double sum; - double numAve; - unsigned min_i; - unsigned max_i; - unsigned n_histogram_ranges; - std::vector histogram_ranges; - bool notInitialized; - - minMaxAve() : min(std::numeric_limits::max()), max(std::numeric_limits::min()), ave(0), sum(0), numAve(0), - min_i(0), max_i(0), - n_histogram_ranges(10), - histogram_ranges(n_histogram_ranges), - notInitialized(true) {}; - - void registerValue(unsigned id, double val) - { - sum += val; - ave += val; - numAve += 1.0; - - if (val < min) - { - min = val; - min_i = id; - } - - if (val > max) - { - max = val; - max_i = id; - } - } - void finish(stk_classic::mesh::BulkData& mesh) - { - //double parallel_max = max; - - //std::cout << "rank= " << mesh.parallel_rank() << " max before= " << max << std::endl; - double min_local = min; - double max_local = max; - // double ave_local = ave; - // double sum_local = sum; - // double numAve_local = numAve; - // unsigned min_i_local = min_i; - // unsigned max_i_local = max_i; - - all_reduce( mesh.parallel() , ReduceMax<1>( & max ) ); - all_reduce( mesh.parallel() , ReduceMin<1>( & min ) ); - all_reduce( mesh.parallel() , ReduceSum<1>( & numAve ) ); - all_reduce( mesh.parallel() , ReduceSum<1>( & ave ) ); - all_reduce( mesh.parallel() , ReduceSum<1>( & sum ) ); - - // if this proc doesn't have the max then reset the local max_i to 0, do ReduceMax, thereby picking up - // the value from the proc that does own the actual max_i - if (std::fabs(max-max_local) > 1.e-10) - { - max_i = std::numeric_limits::min(); - } - if (std::fabs(min-min_local) > 1.e-10) - { - min_i = std::numeric_limits::max(); - } - - //std::cout << "P[" << mesh.parallel_rank() << "] max_i before= " << max_i << " max= " << max << " max_local= " << max_local << std::endl; - //std::cout << "P[" << mesh.parallel_rank() << "] min_i before= " << min_i << " min= " << min << " min_local= " << min_local << std::endl; - all_reduce( mesh.parallel() , ReduceMax<1>( & max_i ) ); - all_reduce( mesh.parallel() , ReduceMin<1>( & min_i ) ); - //std::cout << "P[" << mesh.parallel_rank() << "] max_i after = " << max_i << " max= " << max << " max_local= " << max_local << std::endl; - - //std::cout << "rank= " << mesh.parallel_rank() << " max after= " << max << std::endl; - - ave /= std::max(numAve,1.e-20); - } - - // for future expansion to compute and print histograms - void setStandardRanges() - { - histogram_ranges = std::vector(n_histogram_ranges); - for (unsigned i = 0; i < n_histogram_ranges; i++) - { - histogram_ranges[i] = (double(i)/double(n_histogram_ranges-1))*(max-min); - } - } - - - }; - - - struct jacData - { - //jacData(double mn, double mx, double av) : min(mn), max(mx), ave(av), numAve(0),notInitialized(true) {} - jacData() : jac(), QM_1(), QM_2(), numEle(0), - n_histogram_ranges(10), - notInitialized(true) {} - - minMaxAve jac; - minMaxAve QM_1; - minMaxAve QM_2; - unsigned numEle; - - //std::vector histogram_ranges; - unsigned n_histogram_ranges; - bool notInitialized; - }; - - typedef std::map jac_data_map; - - GeometryVerifier::GeometryVerifier(bool dump, double badJac) : m_dump(dump), m_badJacobian(badJac) {} - - double GeometryVerifier::getEquiVol(CellTopology& cell_topo) - { - double volEqui = 1.0; - switch(cell_topo.getKey() ) - { - - // Tet cells - case shards::Tetrahedron<4>::key: - case shards::Tetrahedron<8>::key: - case shards::Tetrahedron<10>::key: - volEqui = std::sqrt(2.)/12.; - break; - - // Hex cells - case shards::Hexahedron<8>::key: - case shards::Hexahedron<20>::key: - case shards::Hexahedron<27>::key: - volEqui = 1.0; - break; - - // Pyramid cells - case shards::Pyramid<5>::key: - case shards::Pyramid<13>::key: - case shards::Pyramid<14>::key: - volEqui = std::sqrt(2.)/6.; - break; - - // Wedge cells - case shards::Wedge<6>::key: - case shards::Wedge<15>::key: - case shards::Wedge<18>::key: - volEqui = std::sqrt(3.)/4.; - break; - - case shards::Triangle<3>::key: - case shards::Triangle<4>::key: - case shards::Triangle<6>::key: - volEqui = std::sqrt(3.)/4.; - break; - - case shards::Quadrilateral<4>::key: - case shards::Quadrilateral<8>::key: - case shards::Quadrilateral<9>::key: - volEqui = 1.0; - break; - - case shards::ShellTriangle<3>::key: - case shards::ShellTriangle<6>::key: - volEqui = std::sqrt(3.)/4.; - break; - - case shards::ShellQuadrilateral<4>::key: - case shards::ShellQuadrilateral<8>::key: - case shards::ShellQuadrilateral<9>::key: - volEqui = 1.0; - break; - - case shards::ShellLine<2>::key: - case shards::ShellLine<3>::key: - case shards::Beam<2>::key: - case shards::Beam<3>::key: - volEqui = 1.0; - break; - - default: - break; - }//cell key - return volEqui; - } - - /** - * Check for nonpositive Jacobian - */ - bool GeometryVerifier::isGeometryBad(stk_classic::mesh::BulkData& bulk, bool printTable) //, stk_classic::mesh::Part& mesh_part ) - { - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - const unsigned p_rank = bulk.parallel_rank(); - - unsigned foundBad=0; - jac_data_map jac_data; - - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - mesh::Selector select_owned( meta.locally_owned_part() ); - const std::vector & buckets = bulk.buckets( meta.element_rank() ); - - //for ( std::vector::const_iterator ik = buckets.begin() ; ik != buckets.end() ; ++ik ) - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); ip != all_parts.end(); ++ip ) - { - stk_classic::mesh::Part * part = *ip; - - if ( stk_classic::mesh::is_auto_declared_part(*part) ) - continue; - - const CellTopologyData * const part_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(*part); - //std::cout << "P[" << p_rank << "] part = " << part->name() << " part_cell_topo_data= " << part_cell_topo_data << " topo-name= " - // << (part_cell_topo_data ? part_cell_topo_data->name : "null") << std::endl; - - if (part_cell_topo_data) - jac_data[part_cell_topo_data->name] = jacData(); - } - - for (unsigned ipass = 0; ipass < 1; ipass++) - { - for ( std::vector::const_iterator ik = buckets.begin() ; ik != buckets.end() ; ++ik ) - { - if ( select_owned( **ik ) ) { - - const mesh::Bucket & bucket = **ik ; - - // Number of elems in this bucket of elems and elem field data - const unsigned number_elems = bucket.size(); - - double * elem_node_data = field_data( *coord_field , bucket.begin() ); - //double * elem_centroid_data = field_data( elem_centroid_field , bucket.begin() ); - //double * const coord = field_data( m_coordinates_field , *node ); - - // FIXME - if (0) { elem_node_data[0]++;} - -#if 1 - const CellTopologyData * const bucket_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - int bucket_shardsId = ShardsInterfaceTable::s_singleton.lookupShardsId(bucket_cell_topo_data->name); -#endif - - //if (0) { std::cout << bucket_cell_topo_data->name; } - if (0) { std::cout << "bucket_shardsId= " << bucket_shardsId << " name= " << bucket_cell_topo_data->name << std::endl; } - - if (0) { std::cout << "number_elems= " << number_elems << std::endl;} - - CellTopology cell_topo(bucket_cell_topo_data); - double volEqui = getEquiVol(cell_topo); - unsigned numCells = number_elems; - unsigned numNodes = cell_topo.getNodeCount(); - unsigned spaceDim = cell_topo.getDimension(); - //unsigned spatialDimMeta = stk_classic::mesh::fem::FEMMetaData::get(bulk).spatial_dimension(); - - // Rank-3 array with dimensions (C,N,D) for the node coordinates of 3 traingle cells - FieldContainer cellNodes(numCells, numNodes, spaceDim); - PerceptMesh::fillCellNodes(bucket, coord_field, cellNodes, spaceDim); - - FieldContainer volume(numCells); - - // get min/max edge length - FieldContainer elem_min_edge_length(number_elems); - FieldContainer elem_max_edge_length(number_elems); - PerceptMesh::findMinMaxEdgeLength(bucket, *coord_field, elem_min_edge_length, elem_max_edge_length); - - /// note: we're using cubature here instead of explicitly specifying some reference points - /// the idea is that we'll get a good estimate of the Jacobian's sign by testing it at all the - /// cubature points - - DefaultCubatureFactory cubFactory; // create cubature factory - unsigned cubDegree = 2; // set cubature degree, e.g. 2 - Teuchos::RCP > myCub; - bool hasGoodTopo = true; - try { - myCub = cubFactory.create(cell_topo, cubDegree); // create default cubature - } - catch(...) - { - if (!p_rank) - std::cout << "WARNING: mesh contains elements that Intrepid doesn't support for quadrature, cell_topo= " << cell_topo.getName() << std::endl; - //continue; - hasGoodTopo = false; - } - - FieldContainer jacobian_det(numCells, 1); - unsigned numCubPoints = 1; - FieldContainer jacobian(numCells, numCubPoints, spaceDim, spaceDim); - - if (hasGoodTopo) - { - numCubPoints = myCub->getNumPoints(); // retrieve number of cubature points - - FieldContainer cub_points(numCubPoints, spaceDim); - FieldContainer cub_weights(numCubPoints); - - // Rank-4 array (C,P,D,D) for the Jacobian and its inverse and Rank-2 array (C,P) for its determinant - //FieldContainer jacobian(numCells, numCubPoints, spaceDim, spaceDim); - jacobian.resize(numCells, numCubPoints, spaceDim, spaceDim); - FieldContainer jacobian_inv(numCells, numCubPoints, spaceDim, spaceDim); - //FieldContainer jacobian_det(numCells, numCubPoints); - jacobian_det.resize(numCells, numCubPoints); - - myCub->getCubature(cub_points, cub_weights); // retrieve cubature points and weights - - // Methods to compute cell Jacobians, their inverses and their determinants - - CellTools::setJacobian(jacobian, cub_points, cellNodes, cell_topo); // compute cell Jacobians - CellTools::setJacobianInv(jacobian_inv, jacobian); // compute inverses of cell Jacobians - CellTools::setJacobianDet(jacobian_det, jacobian); // compute determinants of cell Jacobians - - FieldContainer weightedMeasure(numCells, numCubPoints); - - FieldContainer onesLeft(numCells, numCubPoints); - onesLeft.initialize(1.0); - - // compute weighted measure - FunctionSpaceTools::computeCellMeasure(weightedMeasure, jacobian_det, cub_weights); - - // integrate to get volume - FunctionSpaceTools::integrate(volume, onesLeft, weightedMeasure, COMP_BLAS); - } - - jacData& jdata = jac_data[cell_topo.getName()]; - jdata.numEle += numCells; - - for (unsigned iCell = 0; iCell < numCells; iCell++) - { - mesh::Entity & elem = bucket[iCell]; - double min_edge_length = elem_min_edge_length[iCell]; - double max_edge_length = elem_max_edge_length[iCell]; - double max_edge_lengthNotZero = (fabs(max_edge_length) < 1.e-20? 1.e-20 : max_edge_length); - - double cellVolActual = volume(iCell); - double cellVol = cellVolActual/volEqui; // scaled so that equilateral cell has vol=1.0 - - for (unsigned iCubPt = 0; iCubPt < numCubPoints; iCubPt++) - { - double jacDet = jacobian_det(iCell, iCubPt); - if (hasGoodTopo && jacDet < m_badJacobian) - { - ++foundBad; - } - - double cellVolNotZero = fabs(cellVol) < 1.e-20? 1.e-20 : cellVol; - double quality_measure_1 = (cellVolNotZero < 0? -1.0 : 1.0) * min_edge_length / pow(fabs(cellVolNotZero), 1./(double(spaceDim))); - if (0 && iCubPt==0) - { - std::cout << "quality_measure_1= " << quality_measure_1 << " cellVolNotZero= " << cellVolNotZero << " cellVolActual= " - << cellVolActual << " volEqui= " << volEqui << " min_edge_length= " << min_edge_length - << " max_edge_length= " << max_edge_length << std::endl; - } - - double quality_measure_2 = min_edge_length / max_edge_lengthNotZero; - - if (ipass == 0) - { - jdata.jac.registerValue(elem.identifier(), jacDet); - jdata.QM_1.registerValue(elem.identifier(), quality_measure_1); - jdata.QM_2.registerValue(elem.identifier(), quality_measure_2); - } - } - } - - if (m_dump) - { - for (unsigned iCell = 0; iCell < numCells; iCell++) - { - for (unsigned iCubPt = 0; iCubPt < numCubPoints; iCubPt++) - { - stk_classic::PrintTable table; - std::ostringstream msg; msg << "Jacobian"<<" iCell= "<second.jac.finish(bulk); - itMap->second.QM_1.finish(bulk); - itMap->second.QM_2.finish(bulk); - } - - // all_reduce( mesh.parallel() , ReduceMax<1>( & error_flag ) ); - - stk_classic::PrintTable table; - if (0) - { - const unsigned rank = bulk.parallel_rank(); - std::string title = "Jacobian and Quality Table P["+toString(rank)+"]\n"; - table.setTitle(title.c_str()); - } - table.setTitle("Jacobian and Quality Table\n"); - - table << "|" << "Element Type" << "|" - << "Min JacDet" << "|" << "Id" << "|" - << "Max JacDet" << "|" << "Id" << "|" - << "Ave JacDet" << "|" - << "Sum JacDet" << "|" - << "Min QM1" << "|" << "Id" << "|" - << "Max QM1" << "|" << "Id" << "|" - << "Ave QM1" << "|" - << "Min QM2" << "|" << "Id" << "|" - << "Max QM2" << "|" << "Id" << "|" - << "Ave QM2" << "|" - << stk_classic::end_header; - - for (jac_data_map::iterator itMap = jac_data.begin(); itMap != jac_data.end(); itMap++) - { - if (1) - { - std::cout << "P[" << p_rank << "] nele = " << itMap->second.numEle << std::endl; - } - - table << "|" << itMap->first << "|" - << itMap->second.jac.min << "|" - << itMap->second.jac.min_i << "|" - << itMap->second.jac.max << "|" - << itMap->second.jac.max_i << "|" - << itMap->second.jac.ave << "|" - << itMap->second.jac.sum << "|" - << itMap->second.QM_1.min << "|" - << itMap->second.QM_1.min_i << "|" - << itMap->second.QM_1.max << "|" - << itMap->second.QM_1.max_i << "|" - << itMap->second.QM_1.ave << "|" - << itMap->second.QM_2.min << "|" - << itMap->second.QM_2.min_i << "|" - << itMap->second.QM_2.max << "|" - << itMap->second.QM_2.max_i << "|" - << itMap->second.QM_2.ave << "|" - << stk_classic::end_row; - } - - if (!p_rank && printTable) - //if (printTable) - { - std::cout << "P[" << p_rank << "] Explanation: JacDet=det(element jacobian), QM1=min(element edge length)/(elemement vol)^(1/dim), QM2=min(element edge length)/max(element edge length)\n" - << " NOTE: QM1 is normalized to 1 for ideally shaped elements, < 1 or > 1 values signify badly shaped elements\n" - << " NOTE: QM2 is small for badly shaped elements, normalized to 1 for ideally shaped elements\n" - << std::endl; - std::cout << table; - } - - return (foundBad > 0); - } - - }//namespace percept -}//namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.hpp deleted file mode 100644 index aa6b3832b465..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/GeometryVerifier.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef GeometryVerifier_hpp -#define GeometryVerifier_hpp - -#include - - -#include "Shards_CellTopology.hpp" -//#include "Teuchos_GlobalMPISession.hpp" - -#include -#include -#include -#include -#include -#include - -#include -#include - -//using namespace Intrepid; - - -namespace stk_classic -{ - namespace percept - { - - - class GeometryVerifier - { - //typedef std::set invalid_edge_set_type; - bool m_dump; - double m_badJacobian; // default and settable value for bad jacobian - double getEquiVol(shards::CellTopology& cell_topo); - - public: - GeometryVerifier(bool dump=false, double badJac=1.e-10); - bool isGeometryBad(stk_classic::mesh::BulkData& bulk, bool printTable=false); - }; - - }//namespace percept -}//namespace stk_classic - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp deleted file mode 100644 index e2041821b981..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp +++ /dev/null @@ -1,157 +0,0 @@ -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_HGRAD_HEX_C2_Serendipity_FEM.hpp - \brief Header file for the Intrepid::HGRAD_HEX_C2_Serendipity_FEM class. - \author Created by P. Bochev and D. Ridzal. - */ - -#ifndef INTREPID_HGRAD_HEX_C2_Serendipity_FEM_HPP -#define INTREPID_HGRAD_HEX_C2_Serendipity_FEM_HPP -#include "Intrepid_Basis.hpp" - -namespace Intrepid { - -/** \class Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM - \brief Implementation of the default H(grad)-compatible FEM basis of INCOMPLETE degree 2 on Hexahedron cell - - Implements Lagrangian basis of incomplete degree 2 on the reference Hexahedron cell. The basis has - cardinality 20 and spans an INCOMPLETE tri-quadratic polynomial space. Basis functions are dual - to a unisolvent set of degrees-of-freedom (DoF) defined and enumerated as follows: - - \verbatim - ================================================================================================= - | | degree-of-freedom-tag table | | - | DoF |----------------------------------------------------------| DoF definition | - | ordinal | subc dim | subc ordinal | subc DoF ord |subc num DoF | | - |=========|==============|==============|==============|=============|===========================| - | 0 | 0 | 0 | 0 | 1 | L_0(u) = u(-1,-1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 1 | 0 | 1 | 0 | 1 | L_1(u) = u( 1,-1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 2 | 0 | 2 | 0 | 1 | L_2(u) = u( 1, 1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 3 | 0 | 3 | 0 | 1 | L_3(u) = u(-1, 1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 4 | 0 | 4 | 0 | 1 | L_4(u) = u(-1,-1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 5 | 0 | 5 | 0 | 1 | L_5(u) = u( 1,-1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 6 | 0 | 6 | 0 | 1 | L_6(u) = u( 1, 1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 7 | 0 | 7 | 0 | 1 | L_7(u) = u(-1, 1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 8 | 1 | 0 | 0 | 1 | L_8(u) = u( 0,-1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 9 | 1 | 1 | 0 | 1 | L_9(u) = u( 1, 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 10 | 1 | 2 | 0 | 1 | L_10(u) = u( 0, 1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 11 | 1 | 3 | 0 | 1 | L_11(u) = u(-1, 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 12 | 1 | 8 | 0 | 1 | L_12(u) = u(-1,-1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 13 | 1 | 9 | 0 | 1 | L_13(u) = u( 1,-1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 14 | 1 | 10 | 0 | 1 | L_14(u) = u( 1, 1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 15 | 1 | 11 | 0 | 1 | L_15(u) = u(-1, 1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 16 | 1 | 4 | 0 | 1 | L_16(u) = u( 0,-1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 17 | 1 | 5 | 0 | 1 | L_17(u) = u( 1, 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 18 | 1 | 6 | 0 | 1 | L_18(u) = u( 0, 1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 19 | 1 | 7 | 0 | 1 | L_19(u) = u(-1, 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - |=========|==============|==============|==============|=============|===========================| - | MAX | maxScDim=2 | maxScOrd=12 | maxDfOrd=0 | - | | - |=========|==============|==============|==============|=============|===========================| - \endverbatim - - \remark Ordering of DoFs follows the node order in Hexahedron<20> topology. Note that node - order in this topology does not follow the natural oder of k-subcells where the nodes - are located, except for nodes 0 to 7 which coincide with the vertices of the base - Hexahedrn <8> topology. As a result, L_0 to L_7 are associated with nodes 0 to 7, but - L_8 to L_19 are not associated with edges 0 to 12 in that order. - - */ - -template -class Basis_HGRAD_HEX_C2_Serendipity_FEM : public Basis, public DofCoordsInterface { -private: - - /** \brief Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays. - */ - void initializeTags(); - -public: - - /** \brief Constructor. - */ - Basis_HGRAD_HEX_C2_Serendipity_FEM(); - - - /** \brief Evaluation of a FEM basis on a reference Hexahedron cell. - - Returns values of operatorType acting on FEM basis functions for a set of - points in the reference Hexahedron cell. For rank and dimensions of - I/O array arguments see Section \ref basis_md_array_sec. - - \param outputValues [out] - rank-2 or 3 array with the computed basis values - \param inputPoints [in] - rank-2 array with dimensions (P,D) containing reference points - \param operatorType [in] - operator applied to basis functions - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const; - - - /** \brief FVD basis evaluation: invocation of this method throws an exception. - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType = OPERATOR_VALUE) const; - - /** \brief Returns spatial locations (coordinates) of degrees of freedom on a - reference Quadrilateral. - - \param DofCoords [out] - array with the coordinates of degrees of freedom, - dimensioned (F,D) - */ - void getDofCoords(ArrayScalar & DofCoords) const; -}; -}// namespace Intrepid - -#include "Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp" - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp deleted file mode 100644 index 44bd5e2c75f6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp +++ /dev/null @@ -1,434 +0,0 @@ -#ifndef INTREPID_HGRAD_HEX_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_HEX_C2_SERENDIPITY_FEMDEF_HPP -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_HGRAD_HEX_C2_Serendipity_FEMDef.hpp - \brief Definition file for bi-linear FEM basis functions for H(grad) functions on Hexahedron cells. - \author Created by P. Bochev and D. Ridzal. (serendipity version by S. R. Kennon, srkenno@sandia.gov) -*/ - -namespace Intrepid { - - - template - Basis_HGRAD_HEX_C2_Serendipity_FEM::Basis_HGRAD_HEX_C2_Serendipity_FEM() - { - this -> basisCardinality_ = 20; - this -> basisDegree_ = 2; - this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData >() ); - this -> basisType_ = BASIS_FEM_DEFAULT; - this -> basisCoordinates_ = COORDINATES_CARTESIAN; - this -> basisTagsAreSet_ = false; - } - - - - template - void Basis_HGRAD_HEX_C2_Serendipity_FEM::initializeTags() { - - // Basis-dependent intializations - int tagSize = 4; // size of DoF tag, i.e., number of fields in the tag - int posScDim = 0; // position in the tag, counting from 0, of the subcell dim - int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal - int posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell - - // An array with local DoF tags assigned to basis functions, in the order of their local enumeration - int tags[] = { 0, 0, 0, 1, // Nodes 0 to 7 follow vertex order of the topology - 0, 1, 0, 1, - 0, 2, 0, 1, - 0, 3, 0, 1, - 0, 4, 0, 1, - 0, 5, 0, 1, - 0, 6, 0, 1, - 0, 7, 0, 1, - 1, 0, 0, 1, // Node 8 -> edge 0 - 1, 1, 0, 1, // Node 9 -> edge 1 - 1, 2, 0, 1, // Node 10 -> edge 2 - 1, 3, 0, 1, // Node 11 -> edge 3 - 1, 8, 0, 1, // Node 12 -> edge 8 - 1, 9, 0, 1, // Node 13 -> edge 9 - 1,10, 0, 1, // Node 14 -> edge 10 - 1,11, 0, 1, // Node 15 -> edge 11 - 1, 4, 0, 1, // Node 16 -> edge 4 - 1, 5, 0, 1, // Node 17 -> edge 5 - 1, 6, 0, 1, // Node 18 -> edge 6 - 1, 7, 0, 1 // Node 19 -> edge 7 - - // ,3, 0, 0, 1, // Node 20 -> Hexahedron - // 2, 4, 0, 1, // Node 21 -> face 4 - // 2, 5, 0, 1, // Node 22 -> face 5 - // 2, 3, 0, 1, // Node 23 -> face 3 - // 2, 1, 0, 1, // Node 24 -> face 1 - // 2, 0, 0, 1, // Node 25 -> face 0 - // 2, 2, 0, 1, // Node 26 -> face 2 - - }; - - // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays: - Intrepid::setOrdinalTagData(this -> tagToOrdinal_, - this -> ordinalToTag_, - tags, - this -> basisCardinality_, - tagSize, - posScDim, - posScOrd, - posDfOrd); - } - - - template - void Basis_HGRAD_HEX_C2_Serendipity_FEM::getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const { - - // Verify arguments -#ifdef HAVE_INTREPID_DEBUG - Intrepid::getValues_HGRAD_Args(outputValues, - inputPoints, - operatorType, - this -> getBaseCellTopology(), - this -> getCardinality() ); -#endif - - // Number of evaluation points = dim 0 of inputPoints - int dim0 = inputPoints.dimension(0); - - // Temporaries: (x,y,z) coordinates of the evaluation point - Scalar x = 0.0; - Scalar y = 0.0; - Scalar z = 0.0; - Scalar one = 1.0; - Scalar two = 2.0; - - Scalar one8th = 1./8.; - Scalar one4th = 1./4.; - Scalar half = 1./2.; - - switch (operatorType) { - - case OPERATOR_VALUE: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0, 0); - y = inputPoints(i0, 1); - z = inputPoints(i0, 2); - Scalar s = x; - Scalar t = y; - Scalar u = z; - - //Scalar stu = s * t * u; - //Scalar st = s * t; - //Scalar su = s * u; - //Scalar tu = t * u; - - Scalar one_m_s = one - s; - Scalar one_p_s = one + s; - Scalar one_m_t = one - t; - Scalar one_p_t = one + t; - Scalar one_m_u = one - u; - Scalar one_p_u = one + u; - - Scalar um2 = u - two; - Scalar up2 = u + two; - - Scalar one_m_ss = one - s * s; - Scalar one_m_tt = one - t * t; - Scalar one_m_uu = one - u * u; - - - // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0) - outputValues( 0, i0)= one8th * one_m_s * one_m_t * one_m_u * (-s-t-up2); - outputValues( 1, i0)= one8th * one_p_s * one_m_t * one_m_u * ( s-t-up2); - outputValues( 2, i0)= one8th * one_p_s * one_p_t * one_m_u * ( s+t-up2); - outputValues( 3, i0)= one8th * one_m_s * one_p_t * one_m_u * (-s+t-up2); - outputValues( 4, i0)= one8th * one_m_s * one_m_t * one_p_u * (-s-t+um2); - outputValues( 5, i0)= one8th * one_p_s * one_m_t * one_p_u * ( s-t+um2); - outputValues( 6, i0)= one8th * one_p_s * one_p_t * one_p_u * ( s+t+um2); - outputValues( 7, i0)= one8th * one_m_s * one_p_t * one_p_u * (-s+t+um2); - outputValues( 8, i0)= one4th * one_m_ss * one_m_t * one_m_u ; - outputValues( 9, i0)= one4th * one_p_s * one_m_tt * one_m_u ; - outputValues(10, i0)= one4th * one_m_ss * one_p_t * one_m_u ; - outputValues(11, i0)= one4th * one_m_s * one_m_tt * one_m_u ; - outputValues(12, i0)= one4th * one_m_s * one_m_t * one_m_uu ; - outputValues(13, i0)= one4th * one_p_s * one_m_t * one_m_uu ; - outputValues(14, i0)= one4th * one_p_s * one_p_t * one_m_uu ; - outputValues(15, i0)= one4th * one_m_s * one_p_t * one_m_uu ; - outputValues(16, i0)= one4th * one_m_ss * one_m_t * one_p_u ; - outputValues(17, i0)= one4th * one_p_s * one_m_tt * one_p_u ; - outputValues(18, i0)= one4th * one_m_ss * one_p_t * one_p_u ; - outputValues(19, i0)= one4th * one_m_s * one_m_tt * one_p_u ; - - } - break; - - case OPERATOR_GRAD: - case OPERATOR_D1: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - Scalar s = x; - Scalar t = y; - Scalar u = z; - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) - - - double one_m_s = one - s ; - double one_p_s = one + s ; - double one_m_t = one - t ; - double one_p_t = one + t ; - double one_m_u = one - u ; - double one_p_u = one + u; - - double s2_m1 = two * s - 1; - double t2_m1 = two * t - 1; - double u2_m1 = two * u - 1; - - double s2_p1 = two * s + 1; - double t2_p1 = two * t + 1; - double u2_p1 = two * u + 1 ; - - double one_m_ss = one - s * s ; - double one_m_tt = one - t * t ; - double one_m_uu = one - u * u ; - - //double one_m_2s = one - two * s ; - //double one_m_2t = one - two * t ; - //double one_m_2u = one - two * u ; - - // shape function derivative in the s direction - - outputValues( 0, i0, 0)= -one8th * one_m_t * one_m_u * (-s2_p1-t-u); - outputValues( 1, i0, 0)= one8th * one_m_t * one_m_u * ( s2_m1-t-u); - outputValues( 2, i0, 0)= one8th * one_p_t * one_m_u * ( s2_m1+t-u); - outputValues( 3, i0, 0)= -one8th * one_p_t * one_m_u * (-s2_p1+t-u); - outputValues( 4, i0, 0)= -one8th * one_m_t * one_p_u * (-s2_p1-t+u); - outputValues( 5, i0, 0)= one8th * one_m_t * one_p_u * ( s2_m1-t+u); - outputValues( 6, i0, 0)= one8th * one_p_t * one_p_u * ( s2_m1+t+u); - outputValues( 7, i0, 0)= -one8th * one_p_t * one_p_u * (-s2_p1+t+u); - outputValues( 8, i0, 0)= -half * one_m_t * one_m_u * s; - outputValues( 9, i0, 0)= one4th * one_m_tt * one_m_u; - outputValues(10, i0, 0)= -half * one_p_t * one_m_u * s; - outputValues(11, i0, 0)= -one4th * one_m_tt * one_m_u; - outputValues(12, i0, 0)= -one4th * one_m_t * one_m_uu; - outputValues(13, i0, 0)= one4th * one_m_t * one_m_uu; - outputValues(14, i0, 0)= one4th * one_p_t * one_m_uu; - outputValues(15, i0, 0)= -one4th * one_p_t * one_m_uu; - outputValues(16, i0, 0)= -half * one_m_t * one_p_u * s; - outputValues(17, i0, 0)= one4th * one_m_tt * one_p_u; - outputValues(18, i0, 0)= -half * one_p_t * one_p_u * s; - outputValues(19, i0, 0)= -one4th * one_m_tt * one_p_u; - - // shape function derivative in the t direction - - outputValues( 0, i0, 1)= -one8th * one_m_s * one_m_u * (-s-t2_p1-u); - outputValues( 1, i0, 1)= -one8th * one_p_s * one_m_u * ( s-t2_p1-u); - outputValues( 2, i0, 1)= one8th * one_p_s * one_m_u * ( s+t2_m1-u); - outputValues( 3, i0, 1)= one8th * one_m_s * one_m_u * (-s+t2_m1-u); - outputValues( 4, i0, 1)= -one8th * one_m_s * one_p_u * (-s-t2_p1+u); - outputValues( 5, i0, 1)= -one8th * one_p_s * one_p_u * ( s-t2_p1+u); - outputValues( 6, i0, 1)= one8th * one_p_s * one_p_u * ( s+t2_m1+u); - outputValues( 7, i0, 1)= one8th * one_m_s * one_p_u * (-s+t2_m1+u); - outputValues( 8, i0, 1)= -one4th * one_m_ss * one_m_u; - outputValues( 9, i0, 1)= -half * one_p_s * one_m_u * t; - outputValues(10, i0, 1)= one4th * one_m_ss * one_m_u; - outputValues(11, i0, 1)= -half * one_m_s * one_m_u * t; - outputValues(12, i0, 1)= -one4th * one_m_s * one_m_uu; - outputValues(13, i0, 1)= -one4th * one_p_s * one_m_uu; - outputValues(14, i0, 1)= one4th * one_p_s * one_m_uu; - outputValues(15, i0, 1)= one4th * one_m_s * one_m_uu; - outputValues(16, i0, 1)= -one4th * one_m_ss * one_p_u; - outputValues(17, i0, 1)= -half * one_p_s * one_p_u * t; - outputValues(18, i0, 1)= one4th * one_m_ss * one_p_u; - outputValues(19, i0, 1)= -half * one_m_s * one_p_u * t; - - // shape function derivative in the u direction - - outputValues( 0, i0, 2)= -one8th * one_m_s * one_m_t * (-s-t-u2_p1); - outputValues( 1, i0, 2)= -one8th * one_p_s * one_m_t * ( s-t-u2_p1); - outputValues( 2, i0, 2)= -one8th * one_p_s * one_p_t * ( s+t-u2_p1); - outputValues( 3, i0, 2)= -one8th * one_m_s * one_p_t * (-s+t-u2_p1); - outputValues( 4, i0, 2)= one8th * one_m_s * one_m_t * (-s-t+u2_m1); - outputValues( 5, i0, 2)= one8th * one_p_s * one_m_t * ( s-t+u2_m1); - outputValues( 6, i0, 2)= one8th * one_p_s * one_p_t * ( s+t+u2_m1); - outputValues( 7, i0, 2)= one8th * one_m_s * one_p_t * (-s+t+u2_m1); - outputValues( 8, i0, 2)= -one4th * one_m_ss * one_m_t; - outputValues( 9, i0, 2)= -one4th * one_p_s * one_m_tt; - outputValues(10, i0, 2)= -one4th * one_m_ss * one_p_t; - outputValues(11, i0, 2)= -one4th * one_m_s * one_m_tt; - outputValues(12, i0, 2)= -half * one_m_s * one_m_t * u; - outputValues(13, i0, 2)= -half * one_p_s * one_m_t * u; - outputValues(14, i0, 2)= -half * one_p_s * one_p_t * u; - outputValues(15, i0, 2)= -half * one_m_s * one_p_t * u; - outputValues(16, i0, 2)= one4th * one_m_ss * one_m_t; - outputValues(17, i0, 2)= one4th * one_p_s * one_m_tt; - outputValues(18, i0, 2)= one4th * one_m_ss * one_p_t; - outputValues(19, i0, 2)= one4th * one_m_s * one_m_tt; - - - } - break; - - case OPERATOR_CURL: - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D"); - break; - - case OPERATOR_DIV: - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D"); - break; - - case OPERATOR_D2: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D2Cardinality = 6) - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_D2), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): OPERATOR_D2 not yet coded"); - - } - break; - - case OPERATOR_D3: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_D3), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): OPERATOR_D3 not yet coded"); - - } - break; - - case OPERATOR_D4: - { - // Non-zero entries have Dk (derivative cardinality) indices {3,4,5,7,8,12}, all other entries are 0. - // Intitialize array by zero and then fill only non-zero entries. - - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_D4), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): OPERATOR_D4 not yet coded"); - - } - break; - - case OPERATOR_D5: - case OPERATOR_D6: - TEUCHOS_TEST_FOR_EXCEPTION( true, std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): operator not supported"); - break; - - case OPERATOR_D7: - case OPERATOR_D8: - case OPERATOR_D9: - case OPERATOR_D10: - { - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality) - int DkCardinality = Intrepid::getDkCardinality(operatorType, - this -> basisCellTopology_.getDimension() ); - for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) { - for (int i0 = 0; i0 < dim0; i0++) { - for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){ - outputValues(dofOrd, i0, dkOrd) = 0.0; - } - } - } - } - break; - - default: - TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): Invalid operator type"); - } - } - - - - template - void Basis_HGRAD_HEX_C2_Serendipity_FEM::getValues(ArrayScalar& outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType) const { - TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error, - ">>> ERROR (Basis_HGRAD_HEX_C2_Serendipity_FEM): FEM Basis calling an FVD member function"); - } - - template - void Basis_HGRAD_HEX_C2_Serendipity_FEM::getDofCoords(ArrayScalar & DofCoords) const { -#ifdef HAVE_INTREPID_DEBUG - // Verify rank of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM::getDofCoords) rank = 2 required for DofCoords array"); - // Verify 0th dimension of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array"); - // Verify 1st dimension of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array"); -#endif - - DofCoords(0,0) = -1.0; DofCoords(0,1) = -1.0; DofCoords(0,2) = -1.0; - DofCoords(1,0) = 1.0; DofCoords(1,1) = -1.0; DofCoords(1,2) = -1.0; - DofCoords(2,0) = 1.0; DofCoords(2,1) = 1.0; DofCoords(2,2) = -1.0; - DofCoords(3,0) = -1.0; DofCoords(3,1) = 1.0; DofCoords(3,2) = -1.0; - DofCoords(4,0) = -1.0; DofCoords(4,1) = -1.0; DofCoords(4,2) = 1.0; - DofCoords(5,0) = 1.0; DofCoords(5,1) = -1.0; DofCoords(5,2) = 1.0; - DofCoords(6,0) = 1.0; DofCoords(6,1) = 1.0; DofCoords(6,2) = 1.0; - DofCoords(7,0) = -1.0; DofCoords(7,1) = 1.0; DofCoords(7,2) = 1.0; - - DofCoords(8,0) = 0.0; DofCoords(8,1) = -1.0; DofCoords(8,2) = -1.0; - DofCoords(9,0) = 1.0; DofCoords(9,1) = 0.0; DofCoords(9,2) = -1.0; - DofCoords(10,0) = 0.0; DofCoords(10,1) = 1.0; DofCoords(10,2) = -1.0; - DofCoords(11,0) = -1.0; DofCoords(11,1) = 0.0; DofCoords(11,2) = -1.0; - DofCoords(12,0) = -1.0; DofCoords(12,1) = -1.0; DofCoords(12,2) = 0.0; - DofCoords(13,0) = 1.0; DofCoords(13,1) = -1.0; DofCoords(13,2) = 0.0; - DofCoords(14,0) = 1.0; DofCoords(14,1) = 1.0; DofCoords(14,2) = 0.0; - DofCoords(15,0) = -1.0; DofCoords(15,1) = 1.0; DofCoords(15,2) = 0.0; - DofCoords(16,0) = 0.0; DofCoords(16,1) = -1.0; DofCoords(16,2) = 1.0; - DofCoords(17,0) = 1.0; DofCoords(17,1) = 0.0; DofCoords(17,2) = 1.0; - DofCoords(18,0) = 0.0; DofCoords(18,1) = 1.0; DofCoords(18,2) = 1.0; - DofCoords(19,0) = -1.0; DofCoords(19,1) = 0.0; DofCoords(19,2) = 1.0; - - // DofCoords(20,0) = 0.0; DofCoords(20,1) = 0.0; DofCoords(20,2) = 0.0; - - // DofCoords(21,0) = 0.0; DofCoords(21,1) = 0.0; DofCoords(21,2) = -1.0; - // DofCoords(22,0) = 0.0; DofCoords(22,1) = 0.0; DofCoords(22,2) = 1.0; - // DofCoords(23,0) = -1.0; DofCoords(23,1) = 0.0; DofCoords(23,2) = 0.0; - // DofCoords(24,0) = 1.0; DofCoords(24,1) = 0.0; DofCoords(24,2) = 0.0; - // DofCoords(25,0) = 0.0; DofCoords(25,1) = -1.0; DofCoords(25,2) = 0.0; - // DofCoords(26,0) = 0.0; DofCoords(26,1) = 1.0; DofCoords(26,2) = 0.0; - } - -}// namespace Intrepid -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEM.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEM.hpp deleted file mode 100644 index 6d3fb7ccee5e..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEM.hpp +++ /dev/null @@ -1,124 +0,0 @@ -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_G_QUAD_C2_Serendipity_FEM.hpp - \brief Header file for the Intrepid::G_QUAD_C2_Serendipity_FEM class. - \author Created by P. Bochev and D. Ridzal. - */ - -#ifndef INTREPID_HGRAD_QUAD_C2_Serendipity_FEM_HPP -#define INTREPID_HGRAD_QUAD_C2_Serendipity_FEM_HPP -#include "Intrepid_Basis.hpp" - -namespace Intrepid { - -/** \class Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM - \brief Implementation of the default H(grad)-compatible FEM serendipity basis of incomplete degree 2 on Quadrilateral cell - - Implements Lagrangian serendipity basis of degree 2 on the reference Quadrilateral cell. The basis has - cardinality 8 and spans an INCOMPLETE bi-quadratic polynomial space. Basis functions are dual - to a unisolvent set of degrees-of-freedom (DoF) defined and enumerated as follows: - - \verbatim - ================================================================================================= - | | degree-of-freedom-tag table | | - | DoF |----------------------------------------------------------| DoF definition | - | ordinal | subc dim | subc ordinal | subc DoF ord |subc num DoF | | - |=========|==============|==============|==============|=============|===========================| - | 0 | 0 | 0 | 0 | 1 | L_0(u) = u(-1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 1 | 0 | 1 | 0 | 1 | L_1(u) = u( 1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 2 | 0 | 2 | 0 | 1 | L_2(u) = u( 1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 3 | 0 | 3 | 0 | 1 | L_3(u) = u(-1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 4 | 1 | 0 | 0 | 1 | L_4(u) = u( 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 5 | 1 | 1 | 0 | 1 | L_5(u) = u( 1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 6 | 1 | 2 | 0 | 1 | L_6(u) = u( 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 7 | 1 | 3 | 0 | 1 | L_7(u) = u(-1, 0) | - |=========|==============|==============|==============|=============|===========================| - | MAX | maxScDim=2 | maxScOrd=3 | maxDfOrd=0 | - | | - |=========|==============|==============|==============|=============|===========================| - \endverbatim -*/ -template -class Basis_HGRAD_QUAD_C2_Serendipity_FEM : public Basis, public DofCoordsInterface { -private: - - /** \brief Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays. - */ - void initializeTags(); - -public: - - /** \brief Constructor. - */ - Basis_HGRAD_QUAD_C2_Serendipity_FEM(); - - - /** \brief FEM basis evaluation on a reference Quadrilateral cell. - - Returns values of operatorType acting on FEM basis functions for a set of - points in the reference Quadrilateral cell. For rank and dimensions of - I/O array arguments see Section \ref basis_md_array_sec . - - \param outputValues [out] - rank-2 or 3 array with the computed basis values - \param inputPoints [in] - rank-2 array with dimensions (P,D) containing reference points - \param operatorType [in] - operator applied to basis functions - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const; - - - /** \brief FVD basis evaluation: invocation of this method throws an exception. - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType = OPERATOR_VALUE) const; - - /** \brief Returns spatial locations (coordinates) of degrees of freedom on a - reference Quadrilateral. - - \param DofCoords [out] - array with the coordinates of degrees of freedom, - dimensioned (F,D) - */ - void getDofCoords(ArrayScalar & DofCoords) const; - -}; -}// namespace Intrepid - -#include "Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp" - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp deleted file mode 100644 index c95d0ddbe8e3..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp +++ /dev/null @@ -1,390 +0,0 @@ -#ifndef INTREPID_HGRAD_QUAD_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_QUAD_C2_SERENDIPITY_FEMDEF_HPP - -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_HGRAD_QUAD_C2_Serendipity_FEMDef.hpp - \brief Definition file for bi-linear FEM basis functions for H(grad) functions on QUAD cells. - \author Created by P. Bochev and D. Ridzal. (serendipity version by S. R. Kennon, srkenno@sandia.gov) -*/ - -namespace Intrepid { - - template - Basis_HGRAD_QUAD_C2_Serendipity_FEM::Basis_HGRAD_QUAD_C2_Serendipity_FEM() - { - this -> basisCardinality_ = 8; - this -> basisDegree_ = 2; - this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData >() ); - this -> basisType_ = BASIS_FEM_DEFAULT; - this -> basisCoordinates_ = COORDINATES_CARTESIAN; - this -> basisTagsAreSet_ = false; - } - - - template - void Basis_HGRAD_QUAD_C2_Serendipity_FEM::initializeTags() { - - // Basis-dependent intializations - int tagSize = 4; // size of DoF tag, i.e., number of fields in the tag - int posScDim = 0; // position in the tag, counting from 0, of the subcell dim - int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal - int posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell - - // An array with local DoF tags assigned to basis functions, in the order of their local enumeration - int tags[] = { 0, 0, 0, 1, - 0, 1, 0, 1, - 0, 2, 0, 1, - 0, 3, 0, 1, - // edge midpoints - 1, 0, 0, 1, - 1, 1, 0, 1, - 1, 2, 0, 1, - 1, 3, 0, 1 - - //// quad center - // ,2, 0, 0, 1 - }; - - // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays: - Intrepid::setOrdinalTagData(this -> tagToOrdinal_, - this -> ordinalToTag_, - tags, - this -> basisCardinality_, - tagSize, - posScDim, - posScOrd, - posDfOrd); - } - - - - template - void Basis_HGRAD_QUAD_C2_Serendipity_FEM::getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const { - - // Verify arguments -#ifdef HAVE_INTREPID_DEBUG - Intrepid::getValues_HGRAD_Args(outputValues, - inputPoints, - operatorType, - this -> getBaseCellTopology(), - this -> getCardinality() ); -#endif - - static double xc[] = {-1, 1, 1, -1}; - static double yc[] = {-1, -1, 1, 1}; - static double xm[] = {0, 1, 0, -1}; - static double ym[] = {-1, 0, 1, 0}; - - // Number of evaluation points = dim 0 of inputPoints - int dim0 = inputPoints.dimension(0); - - // Temporaries: (x,y) coordinates of the evaluation point - Scalar x = 0.0; - Scalar y = 0.0; - - switch (operatorType) { - - case OPERATOR_VALUE: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0, 0); - y = inputPoints(i0, 1); - - // corner nodes - // 1/4 (1 + x x_i) (1 + y y_i) ( x x_i + y y_i - 1.0) - // mid nodes on x - // 1/2 (1 - x^2)(1 + y y_i) - // mid nodes on y - // 1/2 (1 - y^2)(1 + x x_i) - - // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0) - - for (int ic=0; ic < 4; ic++) - { - outputValues(ic, i0) = (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0; - } - - for (int im=0; im < 3; im += 2) - { - outputValues(im+4, i0) = (1.0 - x*x)*(1.0 + y * ym[im]) / 2.0; // 4,6 = 0, 2 - outputValues(im+4+1, i0) = (1.0 - y*y)*(1.0 + x * xm[im+1]) / 2.0; // 5,7 = 1, 3 - } - } - break; - - case OPERATOR_GRAD: - case OPERATOR_D1: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) - for (int ic=0; ic < 4; ic++) - { - //outputValues(ic, i0) = (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0; - outputValues(ic, i0, 0) = - ( xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0 + - (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( xc[ic] ) / 4.0; - outputValues(ic, i0, 1) = - (1.0 + x * xc[ic]) * ( yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0 + - (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( yc[ic] ) / 4.0; - } - - for (int im=0; im < 3; im += 2) - { - //outputValues(im+4, i0) = (1.0 - x*x)*(1.0 + y * ym[im]) / 2.0; // 4,6 = 0, 2 - outputValues(im+4, i0, 0) = ( - 2.0*x)*(1.0 + y * ym[im]) / 2.0; - outputValues(im+4, i0, 1) = (1.0 - x*x)*( ym[im]) / 2.0; - - //outputValues(im+4+1, i0) = (1.0 - y*y)*(1.0 + x * xm[im+1]) / 2.0; // 5,7 = 1, 3 - outputValues(im+4+1, i0, 0) = (1.0 - y*y)*( xm[im+1]) / 2.0; - outputValues(im+4+1, i0, 1) = ( - 2.0*y)*(1.0 + x * xm[im+1]) / 2.0; - } - - - } - break; - - case OPERATOR_CURL: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) - // CURL(u) = (u_y, -u_x), is rotated GRAD - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) - for (int ic=0; ic < 4; ic++) - { - //outputValues(ic, i0) = (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0; - outputValues(ic, i0, 1) = -( - ( xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0 + - (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( xc[ic] ) / 4.0); - outputValues(ic, i0, 0) = - (1.0 + x * xc[ic]) * ( yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0 + - (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( yc[ic] ) / 4.0; - } - - for (int im=0; im < 3; im += 2) - { - //outputValues(im+4, i0) = (1.0 - x*x)*(1.0 + y * ym[im]) / 2.0; // 4,6 = 0, 2 - outputValues(im+4, i0, 1) = - ( - 2.0*x)*(1.0 + y * ym[im]) / 2.0; - outputValues(im+4, i0, 0) = (1.0 - x*x)*( ym[im]) / 2.0; - - //outputValues(im+4+1, i0) = (1.0 - y*y)*(1.0 + x * xm[im+1]) / 2.0; // 5,7 = 1, 3 - outputValues(im+4+1, i0, 1) = - (1.0 - y*y)*( xm[im+1]) / 2.0; - outputValues(im+4+1, i0, 0) = ( - 2.0*y)*(1.0 + x * xm[im+1]) / 2.0; - } - - } - break; - - case OPERATOR_DIV: - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_QUAD_C2_Serendipity_FEM): DIV is invalid operator for rank-0 (scalar) functions in 2D"); - break; - - case OPERATOR_D2: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D2Cardinality=3) - for (int ic=0; ic < 4; ic++) - { - //outputValues(ic, i0) = (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0; - outputValues(ic, i0, 0) = - ( xc[ic]) * (1.0 + y * yc[ic]) * ( xc[ic] ) / 4.0 + - ( xc[ic]) * (1.0 + y * yc[ic]) * ( xc[ic] ) / 4.0; - outputValues(ic, i0, 1) = - ( xc[ic]) * ( yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0 + - ( xc[ic]) * (1.0 + y * yc[ic]) * ( yc[ic] ) / 4.0 + - (1.0 + x * xc[ic]) * ( yc[ic]) * ( xc[ic] ) / 4.0; - - outputValues(ic, i0, 2) = - (1.0 + x * xc[ic]) * ( yc[ic]) * ( yc[ic] ) / 4.0 + - (1.0 + x * xc[ic]) * ( yc[ic]) * ( yc[ic] ) / 4.0; - } - - for (int im=0; im < 3; im += 2) - { - //outputValues(im+4, i0) = (1.0 - x*x)*(1.0 + y * ym[im]) / 2.0; // 4,6 = 0, 2 - outputValues(im+4, i0, 0) = ( - 2.0 )*(1.0 + y * ym[im]) / 2.0; - outputValues(im+4, i0, 1) = ( - 2.0*x)*( ym[im]) / 2.0; - - outputValues(im+4, i0, 2) = 0.0; - - //outputValues(im+4+1, i0) = (1.0 - y*y)*(1.0 + x * xm[im+1]) / 2.0; // 5,7 = 1, 3 - outputValues(im+4+1, i0, 0) = 0.0; - outputValues(im+4+1, i0, 1) = ( - 2.0*y)*( xm[im+1]) / 2.0; - - outputValues(im+4+1, i0, 2) = ( - 2.0 )*(1.0 + x * xm[im+1]) / 2.0; - } - } - break; - - case OPERATOR_D3: - // x - // y - - // xx, xy - // yy - - // xxx, xxy - // xyy - // yyy - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D3Cardinality=4) - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - - for (int ic=0; ic < 4; ic++) - { - //outputValues(ic, i0) = (1.0 + x * xc[ic]) * (1.0 + y * yc[ic]) * ( x * xc[ic] + y * yc[ic] - 1.0) / 4.0; - outputValues(ic, i0, 0) = 0.0; - - outputValues(ic, i0, 1) = - ( xc[ic]) * ( yc[ic]) * ( xc[ic] ) / 4.0 + - ( xc[ic]) * ( yc[ic]) * ( xc[ic] ) / 4.0; - - outputValues(ic, i0, 2) = - ( xc[ic]) * ( yc[ic]) * ( yc[ic] ) / 4.0 + - ( xc[ic]) * ( yc[ic]) * ( yc[ic] ) / 4.0; - - - outputValues(ic, i0, 3) = 0.0; - } - - for (int im=0; im < 3; im += 2) - { - //outputValues(im+4, i0) = (1.0 - x*x)*(1.0 + y * ym[im]) / 2.0; // 4,6 = 0, 2 - outputValues(im+4, i0, 0) = 0.0; - outputValues(im+4, i0, 1) = ( - 2.0 )*( ym[im]) / 2.0; - - outputValues(im+4, i0, 2) = 0.0; - - outputValues(im+4, i0, 3) = 0.0; - - //outputValues(im+4+1, i0) = (1.0 - y*y)*(1.0 + x * xm[im+1]) / 2.0; // 5,7 = 1, 3 - outputValues(im+4+1, i0, 0) = 0.0; - outputValues(im+4+1, i0, 1) = 0.0; - - outputValues(im+4+1, i0, 2) = ( - 2.0 )*( xm[im+1]) / 2.0; - - outputValues(im+4+1, i0, 3) = 0.0; - } - } - break; - - case OPERATOR_D4: - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D4Cardinality=5) - for (int i0 = 0; i0 < dim0; i0++) { - - for (int ib = 0; ib < 8; ib++) - { - for (int dc = 0; dc < 5; dc++) - { - outputValues(ib, i0, dc) = 0.0; - } - } - } - break; - - case OPERATOR_D5: - case OPERATOR_D6: - case OPERATOR_D7: - case OPERATOR_D8: - case OPERATOR_D9: - case OPERATOR_D10: - { - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality) - int DkCardinality = Intrepid::getDkCardinality(operatorType, - this -> basisCellTopology_.getDimension() ); - for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) { - for (int i0 = 0; i0 < dim0; i0++) { - for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){ - outputValues(dofOrd, i0, dkOrd) = 0.0; - } - } - } - } - break; - - default: - TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_QUAD_C2_Serendipity_FEM): Invalid operator type"); - } - } - - - - template - void Basis_HGRAD_QUAD_C2_Serendipity_FEM::getValues(ArrayScalar& outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType) const { - TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error, - ">>> ERROR (Basis_HGRAD_QUAD_C2_Serendipity_FEM): FEM Basis calling an FVD member function"); - } - - - - template - void Basis_HGRAD_QUAD_C2_Serendipity_FEM::getDofCoords(ArrayScalar & DofCoords) const { -#ifdef HAVE_INTREPID_DEBUG - // Verify rank of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM::getDofCoords) rank = 2 required for DofCoords array"); - // Verify 0th dimension of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array"); - // Verify 1st dimension of output array. - TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument, - ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array"); -#endif - - DofCoords(0,0) = -1.0; DofCoords(0,1) = -1.0; - DofCoords(1,0) = 1.0; DofCoords(1,1) = -1.0; - DofCoords(2,0) = 1.0; DofCoords(2,1) = 1.0; - DofCoords(3,0) = -1.0; DofCoords(3,1) = 1.0; - - DofCoords(4,0) = 0.0; DofCoords(4,1) = -1.0; - DofCoords(5,0) = 1.0; DofCoords(5,1) = 0.0; - DofCoords(6,0) = 0.0; DofCoords(6,1) = 1.0; - DofCoords(7,0) = -1.0; DofCoords(7,1) = 0.0; - - //DofCoords(8,0) = 0.0; DofCoords(8,1) = 0.0; - - } - -}// namespace Intrepid -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp deleted file mode 100644 index d6ab80edeaeb..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_HGRAD_WEDGE_C2_Serendipity_FEM.hpp - \brief Header file for the Intrepid::G_WEDGE_C2_FEM class. - \author Created by P. Bochev and D. Ridzal. -*/ - -#ifndef INTREPID_HGRAD_WEDGE_C2_SERENDIPITY_FEM_HPP -#define INTREPID_HGRAD_WEDGE_C2_SERENDIPITY_FEM_HPP -#include "Intrepid_Basis.hpp" - -namespace Intrepid { - -/** \class Intrepid::Basis_HGRAD_WEDGE_C2_Serendipity_FEM - \brief Implementation of the default H(grad)-compatible FEM basis of incomplete degree 2 on Wedge cell - - Implements Lagrangian basis of degree 2 on the reference Wedge cell. The basis has - cardinality 15 and spans a INCOMPLETE bi-quadratic polynomial space. Basis functions are dual - to a unisolvent set of degrees-of-freedom (DoF) defined and enumerated as follows: - - \verbatim - ================================================================================================= - | | degree-of-freedom-tag table | | - | DoF |----------------------------------------------------------| DoF definition | - | ordinal | subc dim | subc ordinal | subc DoF ord |subc num DoF | | - |=========|==============|==============|==============|=============|===========================| - | 0 | 0 | 0 | 0 | 1 | L_0(u) = u( 0, 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 1 | 0 | 1 | 0 | 1 | L_1(u) = u( 1, 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 2 | 0 | 2 | 0 | 1 | L_2(u) = u( 0, 1,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 3 | 0 | 3 | 0 | 1 | L_3(u) = u( 0, 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 4 | 0 | 4 | 0 | 1 | L_4(u) = u( 1, 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 5 | 0 | 5 | 0 | 1 | L_5(u) = u( 0, 1, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 6 | 1 | 0 | 0 | 1 | L_6(u) = u(1/2, 0,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 7 | 1 | 1 | 0 | 1 | L_7(u) = u(1/2,1/2,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 8 | 1 | 2 | 0 | 1 | L_8(u) = u( 0,1/2,-1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 9 | 1 | 6 | 0 | 1 | L_9(u) = u( 0, 0, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 10 | 1 | 7 | 0 | 1 | L_10(u)= u( 1, 0, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 11 | 1 | 8 | 0 | 1 | L_11(u)= u( 0, 1, 0) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 12 | 1 | 3 | 0 | 1 | L_12(u)= u(1/2, 0, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 13 | 1 | 4 | 0 | 1 | L_13(u)= u(1/2,1/2, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - | 14 | 1 | 5 | 0 | 1 | L_14(u)= u( 0,1/2, 1) | - |---------|--------------|--------------|--------------|-------------|---------------------------| - |=========|==============|==============|==============|=============|===========================| - | MAX | maxScDim=2 | maxScOrd=8 | maxDfOrd=0 | - | | - |=========|==============|==============|==============|=============|===========================| - \endverbatim - - \remark Ordering of DoFs follows the node order in Wedge<15> topology. Note that node - order in this topology does not follow the natural oder of k-subcells where the nodes - are located, except for nodes 0 to 5 which coincide with the vertices of the base - Wedge<6> topology. As a result, L_0 to L_5 are associated with nodes 0 to 5, but - L_6 to L_14 are not associated with edges 0 to 9 in that order. - */ -template -class Basis_HGRAD_WEDGE_C2_Serendipity_FEM : public Basis { -private: - - /** \brief Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays. - */ - void initializeTags(); - -public: - - /** \brief Constructor. - */ - Basis_HGRAD_WEDGE_C2_Serendipity_FEM(); - - - /** \brief FEM basis evaluation on a reference Wedge cell. - - Returns values of operatorType acting on FEM basis functions for a set of - points in the reference Wedge cell. For rank and dimensions of - I/O array arguments see Section \ref basis_md_array_sec . - - \param outputValues [out] - rank-2 or 3 array with the computed basis values - \param inputPoints [in] - rank-2 array with dimensions (P,D) containing reference points - \param operatorType [in] - operator applied to basis functions - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const; - - - /** \brief FVD basis evaluation: invocation of this method throws an exception. - */ - void getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType = OPERATOR_VALUE) const; -}; -}// namespace Intrepid - -#include "Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp" - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp deleted file mode 100644 index d78a3d422c24..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp +++ /dev/null @@ -1,1230 +0,0 @@ -#ifndef INTREPID_HGRAD_WEDGE_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_WEDGE_C2_SERENDIPITY_FEMDEF_HPP -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov) or -// Denis Ridzal (dridzal@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file Intrepid_HGRAD_WEDGE_C2_Serendipity_FEMDef.hpp - \brief Definition file for incomplete bi-quadratic FEM basis functions for H(grad) functions on WEDGE cells. - \author Created by P. Bochev and D. Ridzal. (serendipity version by S. R. Kennon, srkenno@sandia.gov) -*/ - -namespace Intrepid { - - template - Basis_HGRAD_WEDGE_C2_Serendipity_FEM::Basis_HGRAD_WEDGE_C2_Serendipity_FEM() - { - this -> basisCardinality_ = 15; - this -> basisDegree_ = 2; - this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData >() ); - this -> basisType_ = BASIS_FEM_DEFAULT; - this -> basisCoordinates_ = COORDINATES_CARTESIAN; - this -> basisTagsAreSet_ = false; - } - - - template - void Basis_HGRAD_WEDGE_C2_Serendipity_FEM::initializeTags() { - - // Basis-dependent intializations - int tagSize = 4; // size of DoF tag - int posScDim = 0; // position in the tag, counting from 0, of the subcell dim - int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal - int posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell - - // An array with local DoF tags assigned to basis functions, in the order of their local enumeration - int tags[] = { 0, 0, 0, 1, - 0, 1, 0, 1, - 0, 2, 0, 1, - 0, 3, 0, 1, - 0, 4, 0, 1, - 0, 5, 0, 1, - 1, 0, 0, 1, - 1, 1, 0, 1, - 1, 2, 0, 1, - 1, 6, 0, 1, - 1, 7, 0, 1, - 1, 8, 0, 1, - 1, 3, 0, 1, - 1, 4, 0, 1, - 1, 5, 0, 1 - // ,2, 0, 0, 1, - // 2, 1, 0, 1, - // 2, 2, 0, 1 - }; - - // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays: - Intrepid::setOrdinalTagData(this -> tagToOrdinal_, - this -> ordinalToTag_, - tags, - this -> basisCardinality_, - tagSize, - posScDim, - posScOrd, - posDfOrd); - } - - - - template - void Basis_HGRAD_WEDGE_C2_Serendipity_FEM::getValues(ArrayScalar & outputValues, - const ArrayScalar & inputPoints, - const EOperator operatorType) const { - - // Verify arguments - //#ifdef HAVE_INTREPID_DEBUG - Intrepid::getValues_HGRAD_Args(outputValues, - inputPoints, - operatorType, - this -> getBaseCellTopology(), - this -> getCardinality() ); - //#endif - - // Number of evaluation points = dim 0 of inputPoints - int dim0 = inputPoints.dimension(0); - - // Temporaries: (x,y,z) coordinates of the evaluation point - Scalar x = 0.0; - Scalar y = 0.0; - Scalar z = 0.0; - - switch (operatorType) { - - case OPERATOR_VALUE: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0, 0); - y = inputPoints(i0, 1); - z = inputPoints(i0, 2); - - // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0) - // - // triangle C2 - // outputValues(0, i0) = (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(1, i0) = x*(2.0*x - 1.0); - // outputValues(2, i0) = y*(2.0*y - 1.0); - - // outputValues(3, i0) = -4.0*x*(x + y - 1.0); - // outputValues(4, i0) = 4.0*x*y; - // outputValues(5, i0) = -4.0*y*(x + y - 1.0); - - double z0 = (1.0 - z)/2.0; - double z1 = (1.0 + z)/2.0; - double zq0 = (-z)*z0; - double zq1 = ( z)*z1; - double zqh = 4.0*z0*z1; - - //--- 0,1,2 - outputValues(0, i0) = zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(1, i0) = zq0* x*(2.0*x - 1.0); - outputValues(2, i0) = zq0* y*(2.0*y - 1.0); - - //--- 3,4,5 - // same as 0,1,2 with zq1 for zq0 - outputValues(3, i0) = zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(4, i0) = zq1* x*(2.0*x - 1.0); - outputValues(5, i0) = zq1* y*(2.0*y - 1.0); - - //--- 6,7,8 - outputValues(6, i0) = z0* (-4.0*x*(x + y - 1.0)); - outputValues(7, i0) = z0* ( 4.0*x*y); - outputValues(8, i0) = z0* (-4.0*y*(x + y - 1.0)); - - - //--- 9,10,11 - // same as 0,1,2 with zqh for zq0 - outputValues(9, i0) = zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(10, i0) = zqh* x*(2.0*x - 1.0); - outputValues(11, i0) = zqh* y*(2.0*y - 1.0); - - //--- 12,13,14 - // same as 6,7,8 with z1 for z0 - outputValues(12, i0) = z1* (-4.0*x*(x + y - 1.0)); - outputValues(13, i0) = z1* ( 4.0*x*y); - outputValues(14, i0) = z1* (-4.0*y*(x + y - 1.0)); - - } - break; - - case OPERATOR_GRAD: - case OPERATOR_D1: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) - double z0 = (1.0 - z)/2.0; - double z1 = (1.0 + z)/2.0; - double zq0 = (-z)*z0; - double zq1 = ( z)*z1; - double zqh = 4.0*z0*z1; - - double dz0 = -0.5; - double dz1 = 0.5; - double dzq0 = (-1.0)*z0 + (-z)*dz0; - double dzq1 = ( 1.0)*z1 + ( z)*dz1; - double dzqh = 4.0*(dz0*z1 + z0*dz1); - - //outputValues(0, i0) = zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(0, i0, 0) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(0, i0, 1) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(0, i0, 2) = dzq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(1, i0) = zq0* x*(2.0*x - 1.0); - outputValues(1, i0, 0) = zq0* ( 4.0*x - 1.0 ); - outputValues(1, i0, 1) = 0.0; - outputValues(1, i0, 2) = dzq0* x*(2.0*x - 1.0); - - //outputValues(2, i0) = zq0* y*(2.0*y - 1.0); - outputValues(2, i0, 0) = 0.0; - outputValues(2, i0, 1) = zq0* (4.0*y - 1.0); - outputValues(2, i0, 2) = dzq0* y*(2.0*y - 1.0); - - //outputValues(3, i0) = zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(3, i0, 0) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(3, i0, 1) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(3, i0, 2) = dzq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(4, i0) = zq1* x*(2.0*x - 1.0); - outputValues(4, i0, 0) = zq1* ( 4.0*x - 1.0); - outputValues(4, i0, 1) = 0.0; - outputValues(4, i0, 2) = dzq1* x*(2.0*x - 1.0); - - //outputValues(5, i0) = zq1* y*(2.0*y - 1.0); - outputValues(5, i0, 0) = 0.0; - outputValues(5, i0, 1) = zq1* (4.0*y - 1.0); - outputValues(5, i0, 2) = dzq1* y*(2.0*y - 1.0); - - //outputValues(6, i0) = z0* (-4.0*x*(x + y - 1.0)); - outputValues(6, i0, 0) = z0* (-4.0*(2.0*x + y - 1.0) ); - outputValues(6, i0, 1) = z0* (-4.0*x*(1.0)); - outputValues(6, i0, 2) = dz0* (-4.0*x*(x + y - 1.0)); - - //outputValues(7, i0) = z0* ( 4.0*x*y); - outputValues(7, i0, 0) = z0* ( 4.0*y); - outputValues(7, i0, 1) = z0* ( 4.0*x); - outputValues(7, i0, 2) = dz0* ( 4.0*x*y); - - //outputValues(8, i0) = z0* (-4.0*y*(x + y - 1.0)); - outputValues(8, i0, 0) = z0* (-4.0*y*(1.0)); - outputValues(8, i0, 1) = z0* (-4.0*(x + 2.0*y - 1.0)); - outputValues(8, i0, 2) = dz0* (-4.0*y*(x + y - 1.0)); - - //outputValues(9, i0) = zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(9, i0, 0) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(9, i0, 1) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - outputValues(9, i0, 2) = dzqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(10, i0) = zqh* x*(2.0*x - 1.0); - outputValues(10, i0, 0) = zqh* ( 1.0*(2.0*x - 1.0) + x*(2.0) ); - outputValues(10, i0, 1) = 0.0; - outputValues(10, i0, 2) = dzqh* x*(2.0*x - 1.0); - - //outputValues(11, i0) = zqh* y*(2.0*y - 1.0); - outputValues(11, i0, 0) = 0.0; - outputValues(11, i0, 1) = zqh* (4.0*y - 1.0); - outputValues(11, i0, 2) = dzqh* y*(2.0*y - 1.0); - - //outputValues(12, i0) = z1* (-4.0*x*(x + y - 1.0)); - outputValues(12, i0, 0) = z1* (-4.0*(2.0*x + y - 1.0)); - outputValues(12, i0, 1) = z1* (-4.0*x*(1.0)); - outputValues(12, i0, 2) = dz1* (-4.0*x*(x + y - 1.0)); - - //outputValues(13, i0) = z1* ( 4.0*x*y); - outputValues(13, i0, 0) = z1* ( 4.0*y); - outputValues(13, i0, 1) = z1* ( 4.0*x); - outputValues(13, i0, 2) = dz1* ( 4.0*x*y); - - //outputValues(14, i0) = z1* (-4.0*y*(x + y - 1.0)); - outputValues(14, i0, 0) = z1* (-4.0*y*(1.0)); - outputValues(14, i0, 1) = z1* (-4.0*(x + 2.0*y - 1.0)); - outputValues(14, i0, 2) = dz1* (-4.0*y*(x + y - 1.0)); - - } - break; - - case OPERATOR_CURL: - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_WEDGE_C2_Serendipity_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D"); - break; - - case OPERATOR_DIV: - TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_WEDGE_C2_Serendipity_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D"); - break; - - case OPERATOR_D2: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - double z0 = (1.0 - z)/2.0; - double z1 = (1.0 + z)/2.0; - double zq0 = (-z)*z0; - double zq1 = ( z)*z1; - double zqh = 4.0*z0*z1; - - double dz0 = -0.5; - double dz1 = 0.5; - double dzq0 = (-1.0)*z0 + (-z)*dz0; - double dzq1 = ( 1.0)*z1 + ( z)*dz1; - double dzqh = 4.0*(dz0*z1 + z0*dz1); - - double d2z0 = 0.0; - double d2z1 = 0.0; - double d2zq0 = (-1.0)*dz0 + (-1.0)*dz0; - double d2zq1 = ( 1.0)*dz1 + ( 1.0)*dz1; - double d2zqh = 8.0*( dz0*dz1); - - //---- 0,1,2 - //outputValues(0, i0) = zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(0, i0, 0) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(0, i0, 1) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(0, i0, 2) = dzq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(0, i0, 0) = zq0* ( 4.0 ); - outputValues(0, i0, 1) = zq0* ( 4.0 ); - outputValues(0, i0, 2) = dzq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(0, i0, 3) = zq0* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - outputValues(0, i0, 4) = dzq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(0, i0, 5) = d2zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(1, i0) = zq0* x*(2.0*x - 1.0); - // outputValues(1, i0, 0) = zq0* ( 4.0*x - 1.0 ); - // outputValues(1, i0, 1) = 0.0; - // outputValues(1, i0, 2) = dzq0* x*(2.0*x - 1.0); - outputValues(1, i0, 0) = zq0* ( 4.0 ); - outputValues(1, i0, 1) = 0.0; - outputValues(1, i0, 2) = dzq0* ( 4.0*x - 1.0 ); - - outputValues(1, i0, 3) = 0.0; - outputValues(1, i0, 4) = 0.0; - - outputValues(1, i0, 5) = d2zq0* x*(2.0*x - 1.0); - - //outputValues(2, i0) = zq0* y*(2.0*y - 1.0); - // outputValues(2, i0, 0) = 0.0; - // outputValues(2, i0, 1) = zq0* (4.0*y - 1.0); - // outputValues(2, i0, 2) = dzq0* y*(2.0*y - 1.0); - - outputValues(2, i0, 0) = 0.0; - outputValues(2, i0, 1) = 0.0; - outputValues(2, i0, 2) = 0.0; - - outputValues(2, i0, 3) = zq0* (4.0); - outputValues(2, i0, 4) = dzq0* (4.0*y - 1.0); - - outputValues(2, i0, 5) = d2zq0* y*(2.0*y - 1.0); - - //---- 3,4,5 - // same as 0,1,2 with zq1 for zq0 - //outputValues(3, i0) = zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(3, i0, 0) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(3, i0, 1) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(3, i0, 2) = dzq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(3, i0, 0) = zq1* ( 4.0 ); - outputValues(3, i0, 1) = zq1* ( 4.0 ); - outputValues(3, i0, 2) = dzq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(3, i0, 3) = zq1* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - outputValues(3, i0, 4) = dzq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(3, i0, 5) = d2zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(4, i0) = zq1* x*(2.0*x - 1.0); - // outputValues(4, i0, 0) = zq1* ( 4.0*x - 1.0 ); - // outputValues(4, i0, 1) = 0.0; - // outputValues(4, i0, 2) = dzq1* x*(2.0*x - 1.0); - outputValues(4, i0, 0) = zq1* ( 4.0 ); - outputValues(4, i0, 1) = 0.0; - outputValues(4, i0, 2) = dzq1* ( 4.0*x - 1.0 ); - - outputValues(4, i0, 3) = 0.0; - outputValues(4, i0, 4) = 0.0; - - outputValues(4, i0, 5) = d2zq1* x*(2.0*x - 1.0); - - //outputValues(5, i0) = zq1* y*(2.0*y - 1.0); - // outputValues(5, i0, 0) = 0.0; - // outputValues(5, i0, 1) = zq1* (4.0*y - 1.0); - // outputValues(5, i0, 2) = dzq1* y*(2.0*y - 1.0); - - outputValues(5, i0, 0) = 0.0; - outputValues(5, i0, 1) = 0.0; - outputValues(5, i0, 2) = 0.0; - - outputValues(5, i0, 3) = zq1* (4.0); - outputValues(5, i0, 4) = dzq1* (4.0*y - 1.0); - - outputValues(5, i0, 5) = d2zq1* y*(2.0*y - 1.0); - - - //--- 6,7,8 - //outputValues(6, i0) = z0* (-4.0*x*(x + y - 1.0)); - // outputValues(6, i0, 0) = z0* (-4.0*(2.0*x + y - 1.0) ); - // outputValues(6, i0, 1) = z0* (-4.0*x*(1.0)); - // outputValues(6, i0, 2) = dz0* (-4.0*x*(x + y - 1.0)); - - outputValues(6, i0, 0) = z0* (-8.0); - outputValues(6, i0, 1) = z0* (-4.0); - outputValues(6, i0, 2) = dz0* (-4.0*(2.0*x + y - 1.0) ); - - outputValues(6, i0, 3) = 0.0; - outputValues(6, i0, 4) = dz0* (-4.0*x*(1.0)); - - outputValues(6, i0, 5) = d2z0* (-4.0*x*(x + y - 1.0)); - - //outputValues(7, i0) = z0* ( 4.0*x*y); - // outputValues(7, i0, 0) = z0* ( 4.0*y); - // outputValues(7, i0, 1) = z0* ( 4.0*x); - // outputValues(7, i0, 2) = dz0* ( 4.0*x*y); - - outputValues(7, i0, 0) = 0.0; - outputValues(7, i0, 1) = z0* ( 4.0 ); - outputValues(7, i0, 2) = dz0* ( 4.0*y); - - outputValues(7, i0, 3) = 0.0; - outputValues(7, i0, 4) = dz0* ( 4.0*x); - - outputValues(7, i0, 5) = d2z0* ( 4.0*x*y); - - //outputValues(8, i0) = z0* (-4.0*y*(x + y - 1.0)); - // outputValues(8, i0, 0) = z0* (-4.0*y*(1.0)); - // outputValues(8, i0, 1) = z0* (-4.0*(x + 2.0*y - 1.0)); - // outputValues(8, i0, 2) = dz0* (-4.0*y*(x + y - 1.0)); - - outputValues(8, i0, 0) = 0.0; - outputValues(8, i0, 1) = z0* (-4.0); - outputValues(8, i0, 2) = dz0* (-4.0*y*(1.0)); - - outputValues(8, i0, 3) = z0* (-8.0); - outputValues(8, i0, 4) = dz0* (-4.0*(x + 2.0*y - 1.0)); - - outputValues(8, i0, 5) = d2z0* (-4.0*y*(x + y - 1.0)); - - //---- 9,10,11 - // same as 0,1,2 with zqh for zq0 - - //outputValues(9, i0) = zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(9, i0, 0) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(9, i0, 1) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(9, i0, 2) = dzqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - outputValues(9, i0, 0) = zqh* ( 4.0 ); - outputValues(9, i0, 1) = zqh* ( 4.0 ); - outputValues(9, i0, 2) = dzqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(9, i0, 3) = zqh* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - outputValues(9, i0, 4) = dzqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(9, i0, 5) = d2zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - //outputValues(10, i0) = zqh* x*(2.0*x - 1.0); - // outputValues(10, i0, 0) = zqh* ( 4.0*x - 1.0 ); - // outputValues(10, i0, 1) = 0.0; - // outputValues(10, i0, 2) = dzqh* x*(2.0*x - 1.0); - outputValues(10, i0, 0) = zqh* ( 4.0 ); - outputValues(10, i0, 1) = 0.0; - outputValues(10, i0, 2) = dzqh* ( 4.0*x - 1.0 ); - - outputValues(10, i0, 3) = 0.0; - outputValues(10, i0, 4) = 0.0; - - outputValues(10, i0, 5) = d2zqh* x*(2.0*x - 1.0); - - //outputValues(11, i0) = zqh* y*(2.0*y - 1.0); - // outputValues(11, i0, 0) = 0.0; - // outputValues(11, i0, 1) = zqh* (4.0*y - 1.0); - // outputValues(11, i0, 2) = dzqh* y*(2.0*y - 1.0); - - outputValues(11, i0, 0) = 0.0; - outputValues(11, i0, 1) = 0.0; - outputValues(11, i0, 2) = 0.0; - - outputValues(11, i0, 3) = zqh* (4.0); - outputValues(11, i0, 4) = dzqh* (4.0*y - 1.0); - - outputValues(11, i0, 5) = d2zqh* y*(2.0*y - 1.0); - - //--- 12,13,14 - // same as 6,7,8 with z1 for z0 - //outputValues(12, i0) = z1* (-4.0*x*(x + y - 1.0)); - // outputValues(12, i0, 0) = z1* (-4.0*(2.0*x + y - 1.0) ); - // outputValues(12, i0, 1) = z1* (-4.0*x*(1.0)); - // outputValues(12, i0, 2) = dz1* (-4.0*x*(x + y - 1.0)); - - outputValues(12, i0, 0) = z1* (-8.0); - outputValues(12, i0, 1) = z1* (-4.0); - outputValues(12, i0, 2) = dz1* (-4.0*(2.0*x + y - 1.0) ); - - outputValues(12, i0, 3) = 0.0; - outputValues(12, i0, 4) = dz1* (-4.0*x*(1.0)); - - outputValues(12, i0, 5) = d2z1* (-4.0*x*(x + y - 1.0)); - - //outputValues(13, i0) = z1* ( 4.0*x*y); - // outputValues(13, i0, 0) = z1* ( 4.0*y); - // outputValues(13, i0, 1) = z1* ( 4.0*x); - // outputValues(13, i0, 2) = dz1* ( 4.0*x*y); - - outputValues(13, i0, 0) = 0.0; - outputValues(13, i0, 1) = z1* ( 4.0 ); - outputValues(13, i0, 2) = dz1* ( 4.0*y); - - outputValues(13, i0, 3) = 0.0; - outputValues(13, i0, 4) = dz1* ( 4.0*x); - - outputValues(13, i0, 5) = d2z1* ( 4.0*x*y); - - //outputValues(14, i0) = z1* (-4.0*y*(x + y - 1.0)); - // outputValues(14, i0, 0) = z1* (-4.0*y*(1.0)); - // outputValues(14, i0, 1) = z1* (-4.0*(x + 2.0*y - 1.0)); - // outputValues(14, i0, 2) = dz1* (-4.0*y*(x + y - 1.0)); - - outputValues(14, i0, 0) = 0.0; - outputValues(14, i0, 1) = z1* (-4.0); - outputValues(14, i0, 2) = dz1* (-4.0*y*(1.0)); - - outputValues(14, i0, 3) = z1* (-8.0); - outputValues(14, i0, 4) = dz1* (-4.0*(x + 2.0*y - 1.0)); - - outputValues(14, i0, 5) = d2z1* (-4.0*y*(x + y - 1.0)); - - - } - break; - - case OPERATOR_D3: - for (int i0 = 0; i0 < dim0; i0++) { - x = inputPoints(i0,0); - y = inputPoints(i0,1); - z = inputPoints(i0,2); - - // 1st - // x - // y - // z - - // 2nd - // xx, xy, xz - // yy, yz - // zz - - // 3rd - // xxx, xxy, [xxz],z, (2) - // xyy, [xyz],z, (4) - // xzz - - // yyy, [yyz],z (7) - // yzz - - // zzz - - - // 4th - // xxxx, xxxy, xxxz - // xxyy, xxyz - // xxzz, (5) - - // xyyy, xyyz, - // xyzz, (8) - - // xzzz - - // yyyy, yyyz, - // yyzz, (12) - - // yzzz - - // zzzz - - double z0 = (1.0 - z)/2.0; - double z1 = (1.0 + z)/2.0; - //double zq0 = (-z)*z0; - //double zq1 = ( z)*z1; - //double zqh = 4.0*z0*z1; - - double dz0 = -0.5; - double dz1 = 0.5; - double dzq0 = (-1.0)*z0 + (-z)*dz0; - double dzq1 = ( 1.0)*z1 + ( z)*dz1; - double dzqh = 4.0*(dz0*z1 + z0*dz1); - - double d2z0 = 0.0; - double d2z1 = 0.0; - double d2zq0 = (-1.0)*dz0 + (-1.0)*dz0; - double d2zq1 = ( 1.0)*dz1 + ( 1.0)*dz1; - double d2zqh = 8.0*( dz0*dz1); - - double d3z0 = 0.0; - double d3z1 = 0.0; - double d3zq0 = 0.0; - double d3zq1 = 0.0; - double d3zqh = 0.0; - - //---- 0,1,2 - //outputValues(0, i0) = zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(0, i0, 0) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(0, i0, 1) = zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(0, i0, 2) = dzq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(0, i0, 0) = zq0* ( 4.0 ); - // outputValues(0, i0, 1) = zq0* ( 4.0 ); - // outputValues(0, i0, 2) = dzq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(0, i0, 3) = zq0* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - // outputValues(0, i0, 4) = dzq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(0, i0, 5) = d2zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(0, i0, 0) = 0.0; - outputValues(0, i0, 1) = 0.0; - outputValues(0, i0, 2) = dzq0* ( 4.0 ); - - outputValues(0, i0, 3) = 0.0; - outputValues(0, i0, 4) = dzq0* ( 4.0 ); - - outputValues(0, i0, 5) = d2zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(0, i0, 6) = 0.0; - outputValues(0, i0, 7) = dzq0* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - outputValues(0, i0, 8) = d2zq0* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(0, i0, 9) = d3zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - - //outputValues(1, i0) = zq0* x*(2.0*x - 1.0); - // outputValues(1, i0, 0) = zq0* ( 4.0*x - 1.0 ); - // outputValues(1, i0, 1) = 0.0; - // outputValues(1, i0, 2) = dzq0* x*(2.0*x - 1.0); - // outputValues(1, i0, 0) = zq0* ( 4.0 ); - // outputValues(1, i0, 1) = 0.0; - // outputValues(1, i0, 2) = dzq0* ( 4.0*x - 1.0 ); - - // outputValues(1, i0, 3) = 0.0; - // outputValues(1, i0, 4) = 0.0; - - // outputValues(1, i0, 5) = d2zq0* x*(2.0*x - 1.0); - - outputValues(1, i0, 0) = 0.0; - outputValues(1, i0, 1) = 0.0; - outputValues(1, i0, 2) = dzq0* ( 4.0 ); - - outputValues(1, i0, 3) = 0.0; - outputValues(1, i0, 4) = 0.0; - - outputValues(1, i0, 5) = d2zq0* ( 4.0*x - 1.0 ); - - - outputValues(1, i0, 6) = 0.0; - outputValues(1, i0, 7) = 0.0; - - outputValues(1, i0, 8) = 0.0; - - outputValues(1, i0, 9) = d3zq0* x*(2.0*x - 1.0); - - //outputValues(2, i0) = zq0* y*(2.0*y - 1.0); - // outputValues(2, i0, 0) = 0.0; - // outputValues(2, i0, 1) = zq0* (4.0*y - 1.0); - // outputValues(2, i0, 2) = dzq0* y*(2.0*y - 1.0); - - // outputValues(2, i0, 0) = 0.0; - // outputValues(2, i0, 1) = 0.0; - // outputValues(2, i0, 2) = 0.0; - - // outputValues(2, i0, 3) = zq0* (4.0); - // outputValues(2, i0, 4) = dzq0* (4.0*y - 1.0); - - // outputValues(2, i0, 5) = d2zq0* y*(2.0*y - 1.0); - - outputValues(2, i0, 0) = 0.0; - outputValues(2, i0, 1) = 0.0; - outputValues(2, i0, 2) = 0.0; - - outputValues(2, i0, 3) = 0.0; - outputValues(2, i0, 4) = 0.0; - - outputValues(2, i0, 5) = 0.0; - - - outputValues(2, i0, 6) = 0.0; - outputValues(2, i0, 7) = dzq0* (4.0); - - outputValues(2, i0, 8) = d2zq0* (4.0*y - 1.0); - - outputValues(2, i0, 9) = d3zq0* y*(2.0*y - 1.0); - - //---- 3,4,5 - // same as 0,1,2 with zq1 for zq0 - //outputValues(3, i0) = zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(3, i0, 0) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(3, i0, 1) = zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(3, i0, 2) = dzq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(3, i0, 0) = zq1* ( 4.0 ); - // outputValues(3, i0, 1) = zq1* ( 4.0 ); - // outputValues(3, i0, 2) = dzq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(3, i0, 3) = zq1* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - // outputValues(3, i0, 4) = dzq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(3, i0, 5) = d2zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(3, i0, 0) = 0.0; - outputValues(3, i0, 1) = 0.0; - outputValues(3, i0, 2) = dzq1* ( 4.0 ); - - outputValues(3, i0, 3) = 0.0; - outputValues(3, i0, 4) = dzq1* ( 4.0 ); - - outputValues(3, i0, 5) = d2zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(3, i0, 6) = 0.0; - outputValues(3, i0, 7) = dzq1* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - outputValues(3, i0, 8) = d2zq1* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(3, i0, 9) = d3zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - - //outputValues(4, i0) = zq1* x*(2.0*x - 1.0); - // outputValues(4, i0, 0) = zq1* ( 4.0*x - 1.0 ); - // outputValues(4, i0, 1) = 0.0; - // outputValues(4, i0, 2) = dzq1* x*(2.0*x - 1.0); - // outputValues(4, i0, 0) = zq1* ( 4.0 ); - // outputValues(4, i0, 1) = 0.0; - // outputValues(4, i0, 2) = dzq1* ( 4.0*x - 1.0 ); - - // outputValues(4, i0, 3) = 0.0; - // outputValues(4, i0, 4) = 0.0; - - // outputValues(4, i0, 5) = d2zq1* x*(2.0*x - 1.0); - - outputValues(4, i0, 0) = 0.0; - outputValues(4, i0, 1) = 0.0; - outputValues(4, i0, 2) = dzq1* ( 4.0 ); - - outputValues(4, i0, 3) = 0.0; - outputValues(4, i0, 4) = 0.0; - - outputValues(4, i0, 5) = d2zq1* ( 4.0*x - 1.0 ); - - - outputValues(4, i0, 6) = 0.0; - outputValues(4, i0, 7) = 0.0; - - outputValues(4, i0, 8) = 0.0; - - outputValues(4, i0, 9) = d3zq1* x*(2.0*x - 1.0); - - //outputValues(5, i0) = zq1* y*(2.0*y - 1.0); - // outputValues(5, i0, 0) = 0.0; - // outputValues(5, i0, 1) = zq1* (4.0*y - 1.0); - // outputValues(5, i0, 2) = dzq1* y*(2.0*y - 1.0); - - // outputValues(5, i0, 0) = 0.0; - // outputValues(5, i0, 1) = 0.0; - // outputValues(5, i0, 2) = 0.0; - - // outputValues(5, i0, 3) = zq1* (4.0); - // outputValues(5, i0, 4) = dzq1* (4.0*y - 1.0); - - // outputValues(5, i0, 5) = d2zq1* y*(2.0*y - 1.0); - - outputValues(5, i0, 0) = 0.0; - outputValues(5, i0, 1) = 0.0; - outputValues(5, i0, 2) = 0.0; - - outputValues(5, i0, 3) = 0.0; - outputValues(5, i0, 4) = 0.0; - - outputValues(5, i0, 5) = 0.0; - - - outputValues(5, i0, 6) = 0.0; - outputValues(5, i0, 7) = dzq1* (4.0); - - outputValues(5, i0, 8) = d2zq1* (4.0*y - 1.0); - - outputValues(5, i0, 9) = d3zq1* y*(2.0*y - 1.0); - - - - //--- 6,7,8 - //outputValues(6, i0) = z0* (-4.0*x*(x + y - 1.0)); - // outputValues(6, i0, 0) = z0* (-4.0*(2.0*x + y - 1.0) ); - // outputValues(6, i0, 1) = z0* (-4.0*x*(1.0)); - // outputValues(6, i0, 2) = dz0* (-4.0*x*(x + y - 1.0)); - - // outputValues(6, i0, 0) = z0* (-8.0); - // outputValues(6, i0, 1) = z0* (-4.0); - // outputValues(6, i0, 2) = dz0* (-4.0*(2.0*x + y - 1.0) ); - - // outputValues(6, i0, 3) = 0.0; - // outputValues(6, i0, 4) = dz0* (-4.0*x*(1.0)); - - // outputValues(6, i0, 5) = d2z0* (-4.0*x*(x + y - 1.0)); - - outputValues(6, i0, 0) = 0.0; - outputValues(6, i0, 1) = 0.0; - outputValues(6, i0, 2) = dz0* (-8.0); - - outputValues(6, i0, 3) = 0.0; - outputValues(6, i0, 4) = dz0* (-4.0); - - outputValues(6, i0, 5) = d2z0* (-4.0*(2.0*x + y - 1.0) ); - - - outputValues(6, i0, 6) = 0.0; - outputValues(6, i0, 7) = 0.0; - - outputValues(6, i0, 8) = d2z0* (-4.0*x*(1.0)); - - outputValues(6, i0, 9) = d3z0* (-4.0*x*(x + y - 1.0)); - - //outputValues(7, i0) = z0* ( 4.0*x*y); - // outputValues(7, i0, 0) = z0* ( 4.0*y); - // outputValues(7, i0, 1) = z0* ( 4.0*x); - // outputValues(7, i0, 2) = dz0* ( 4.0*x*y); - - // outputValues(7, i0, 0) = 0.0; - // outputValues(7, i0, 1) = z0* ( 4.0 ); - // outputValues(7, i0, 2) = dz0* ( 4.0*y); - - // outputValues(7, i0, 3) = 0.0; - // outputValues(7, i0, 4) = dz0* ( 4.0*x); - - // outputValues(7, i0, 5) = d2z0* ( 4.0*x*y); - - outputValues(7, i0, 0) = 0.0; - outputValues(7, i0, 1) = 0.0; - outputValues(7, i0, 2) = 0.0; - - outputValues(7, i0, 3) = 0.0; - outputValues(7, i0, 4) = dz0* ( 4.0 ); - - outputValues(7, i0, 5) = d2z0* ( 4.0*y); - - - outputValues(7, i0, 6) = 0.0; - outputValues(7, i0, 7) = 0.0; - - outputValues(7, i0, 8) = d2z0* ( 4.0*x); - - outputValues(7, i0, 9) = d3z0* ( 4.0*x*y); - - //outputValues(8, i0) = z0* (-4.0*y*(x + y - 1.0)); - // outputValues(8, i0, 0) = z0* (-4.0*y*(1.0)); - // outputValues(8, i0, 1) = z0* (-4.0*(x + 2.0*y - 1.0)); - // outputValues(8, i0, 2) = dz0* (-4.0*y*(x + y - 1.0)); - - // outputValues(8, i0, 0) = 0.0; - // outputValues(8, i0, 1) = z0* (-4.0); - // outputValues(8, i0, 2) = dz0* (-4.0*y*(1.0)); - - // outputValues(8, i0, 3) = z0* (-8.0); - // outputValues(8, i0, 4) = dz0* (-4.0*(x + 2.0*y - 1.0)); - - // outputValues(8, i0, 5) = d2z0* (-4.0*y*(x + y - 1.0)); - - outputValues(8, i0, 0) = 0.0; - outputValues(8, i0, 1) = 0.0; - outputValues(8, i0, 2) = 0.0; - - outputValues(8, i0, 3) = 0.0; - outputValues(8, i0, 4) = dz0* (-4.0); - - outputValues(8, i0, 5) = d2z0* (-4.0*y*(1.0)); - - - outputValues(8, i0, 6) = 0.0; - outputValues(8, i0, 7) = dz0* (-8.0); - - outputValues(8, i0, 8) = d2z0* (-4.0*(x + 2.0*y - 1.0)); - - outputValues(8, i0, 9) = d3z0* (-4.0*y*(x + y - 1.0)); - - //---- 9,10,11 - // same as 0,1,2 with zqh for zq0 - - //outputValues(9, i0) = zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(9, i0, 0) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(9, i0, 1) = zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - // outputValues(9, i0, 2) = dzqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - // outputValues(9, i0, 0) = zqh* ( 4.0 ); - // outputValues(9, i0, 1) = zqh* ( 4.0 ); - // outputValues(9, i0, 2) = dzqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(9, i0, 3) = zqh* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - // outputValues(9, i0, 4) = dzqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - // outputValues(9, i0, 5) = d2zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(9, i0, 0) = 0.0; - outputValues(9, i0, 1) = 0.0; - outputValues(9, i0, 2) = dzqh* ( 4.0 ); - - outputValues(9, i0, 3) = 0.0; - outputValues(9, i0, 4) = dzqh* ( 4.0 ); - - outputValues(9, i0, 5) = d2zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(9, i0, 6) = 0.0; - outputValues(9, i0, 7) = dzqh* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - outputValues(9, i0, 8) = d2zqh* ( (1.0)*(2.0*x + 2.0*y - 1.0) + (x + y - 1.0)*(2.0) ); - - outputValues(9, i0, 9) = d3zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - - - //outputValues(10, i0) = zqh* x*(2.0*x - 1.0); - // outputValues(10, i0, 0) = zqh* ( 4.0*x - 1.0 ); - // outputValues(10, i0, 1) = 0.0; - // outputValues(10, i0, 2) = dzqh* x*(2.0*x - 1.0); - // outputValues(10, i0, 0) = zqh* ( 4.0 ); - // outputValues(10, i0, 1) = 0.0; - // outputValues(10, i0, 2) = dzqh* ( 4.0*x - 1.0 ); - - // outputValues(10, i0, 3) = 0.0; - // outputValues(10, i0, 4) = 0.0; - - // outputValues(10, i0, 5) = d2zqh* x*(2.0*x - 1.0); - - outputValues(10, i0, 0) = 0.0; - outputValues(10, i0, 1) = 0.0; - outputValues(10, i0, 2) = dzqh* ( 4.0 ); - - outputValues(10, i0, 3) = 0.0; - outputValues(10, i0, 4) = 0.0; - - outputValues(10, i0, 5) = d2zqh* ( 4.0*x - 1.0 ); - - - outputValues(10, i0, 6) = 0.0; - outputValues(10, i0, 7) = 0.0; - - outputValues(10, i0, 8) = 0.0; - - outputValues(10, i0, 9) = d3zqh* x*(2.0*x - 1.0); - - //outputValues(11, i0) = zqh* y*(2.0*y - 1.0); - // outputValues(11, i0, 0) = 0.0; - // outputValues(11, i0, 1) = zqh* (4.0*y - 1.0); - // outputValues(11, i0, 2) = dzqh* y*(2.0*y - 1.0); - - // outputValues(11, i0, 0) = 0.0; - // outputValues(11, i0, 1) = 0.0; - // outputValues(11, i0, 2) = 0.0; - - // outputValues(11, i0, 3) = zqh* (4.0); - // outputValues(11, i0, 4) = dzqh* (4.0*y - 1.0); - - // outputValues(11, i0, 5) = d2zqh* y*(2.0*y - 1.0); - - outputValues(11, i0, 0) = 0.0; - outputValues(11, i0, 1) = 0.0; - outputValues(11, i0, 2) = 0.0; - - outputValues(11, i0, 3) = 0.0; - outputValues(11, i0, 4) = 0.0; - - outputValues(11, i0, 5) = 0.0; - - - outputValues(11, i0, 6) = 0.0; - outputValues(11, i0, 7) = dzqh* (4.0); - - outputValues(11, i0, 8) = d2zqh* (4.0*y - 1.0); - - outputValues(11, i0, 9) = d3zqh* y*(2.0*y - 1.0); - - - //--- 12,13,14 - // same as 6,7,8 with z1 for z0 - - //outputValues(12, i0) = z1* (-4.0*x*(x + y - 1.0)); - // outputValues(12, i0, 0) = z1* (-4.0*(2.0*x + y - 1.0) ); - // outputValues(12, i0, 1) = z1* (-4.0*x*(1.0)); - // outputValues(12, i0, 2) = dz1* (-4.0*x*(x + y - 1.0)); - - // outputValues(12, i0, 0) = z1* (-8.0); - // outputValues(12, i0, 1) = z1* (-4.0); - // outputValues(12, i0, 2) = dz1* (-4.0*(2.0*x + y - 1.0) ); - - // outputValues(12, i0, 3) = 0.0; - // outputValues(12, i0, 4) = dz1* (-4.0*x*(1.0)); - - // outputValues(12, i0, 5) = d2z1* (-4.0*x*(x + y - 1.0)); - - outputValues(12, i0, 0) = 0.0; - outputValues(12, i0, 1) = 0.0; - outputValues(12, i0, 2) = dz1* (-8.0); - - outputValues(12, i0, 3) = 0.0; - outputValues(12, i0, 4) = dz1* (-4.0); - - outputValues(12, i0, 5) = d2z1* (-4.0*(2.0*x + y - 1.0) ); - - - outputValues(12, i0, 6) = 0.0; - outputValues(12, i0, 7) = 0.0; - - outputValues(12, i0, 8) = d2z1* (-4.0*x*(1.0)); - - outputValues(12, i0, 9) = d3z1* (-4.0*x*(x + y - 1.0)); - - //outputValues(13, i0) = z1* ( 4.0*x*y); - // outputValues(13, i0, 0) = z1* ( 4.0*y); - // outputValues(13, i0, 1) = z1* ( 4.0*x); - // outputValues(13, i0, 2) = dz1* ( 4.0*x*y); - - // outputValues(13, i0, 0) = 0.0; - // outputValues(13, i0, 1) = z1* ( 4.0 ); - // outputValues(13, i0, 2) = dz1* ( 4.0*y); - - // outputValues(13, i0, 3) = 0.0; - // outputValues(13, i0, 4) = dz1* ( 4.0*x); - - // outputValues(13, i0, 5) = d2z1* ( 4.0*x*y); - - outputValues(13, i0, 0) = 0.0; - outputValues(13, i0, 1) = 0.0; - outputValues(13, i0, 2) = 0.0; - - outputValues(13, i0, 3) = 0.0; - outputValues(13, i0, 4) = dz1* ( 4.0 ); - - outputValues(13, i0, 5) = d2z1* ( 4.0*y); - - - outputValues(13, i0, 6) = 0.0; - outputValues(13, i0, 7) = 0.0; - - outputValues(13, i0, 8) = d2z1* ( 4.0*x); - - outputValues(13, i0, 9) = d3z1* ( 4.0*x*y); - - //outputValues(14, i0) = z1* (-4.0*y*(x + y - 1.0)); - // outputValues(14, i0, 0) = z1* (-4.0*y*(1.0)); - // outputValues(14, i0, 1) = z1* (-4.0*(x + 2.0*y - 1.0)); - // outputValues(14, i0, 2) = dz1* (-4.0*y*(x + y - 1.0)); - - // outputValues(14, i0, 0) = 0.0; - // outputValues(14, i0, 1) = z1* (-4.0); - // outputValues(14, i0, 2) = dz1* (-4.0*y*(1.0)); - - // outputValues(14, i0, 3) = z1* (-8.0); - // outputValues(14, i0, 4) = dz1* (-4.0*(x + 2.0*y - 1.0)); - - // outputValues(14, i0, 5) = d2z1* (-4.0*y*(x + y - 1.0)); - - outputValues(14, i0, 0) = 0.0; - outputValues(14, i0, 1) = 0.0; - outputValues(14, i0, 2) = 0.0; - - outputValues(14, i0, 3) = 0.0; - outputValues(14, i0, 4) = dz1* (-4.0); - - outputValues(14, i0, 5) = d2z1* (-4.0*y*(1.0)); - - - outputValues(14, i0, 6) = 0.0; - outputValues(14, i0, 7) = dz1* (-8.0); - - outputValues(14, i0, 8) = d2z1* (-4.0*(x + 2.0*y - 1.0)); - - outputValues(14, i0, 9) = d3z1* (-4.0*y*(x + y - 1.0)); - - - } - break; - - case OPERATOR_D4: - { - // There are only few constant non-zero entries. Initialize by zero and then assign non-zero entries. - int DkCardinality = Intrepid::getDkCardinality(operatorType, this -> basisCellTopology_.getDimension() ); - for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) { - for (int i0 = 0; i0 < dim0; i0++) { - for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){ - outputValues(dofOrd, i0, dkOrd) = 0.0; - } - } - } - - for (int i0 = 0; i0 < dim0; i0++) { - - //double z0 = (1.0 - z)/2.0; - //double z1 = (1.0 + z)/2.0; - //double zq0 = (-z)*z0; - //double zq1 = ( z)*z1; - //double zqh = 4.0*z0*z1; - - double dz0 = -0.5; - double dz1 = 0.5; - //double dzq0 = (-1.0)*z0 + (-z)*dz0; - //double dzq1 = ( 1.0)*z1 + ( z)*dz1; - //double dzqh = 4.0*(dz0*z1 + z0*dz1); - - double d2z0 = 0.0; - double d2z1 = 0.0; - double d2zq0 = (-1.0)*dz0 + (-1.0)*dz0; - double d2zq1 = ( 1.0)*dz1 + ( 1.0)*dz1; - double d2zqh = 8.0*( dz0*dz1); - - // double d3z0 = 0.0; - // double d3z1 = 0.0; - // double d3zq0 = 0.0; - // double d3zq1 = 0.0; - // double d3zqh = 0.0; - - // (2,4,7)-->(5,8,12) - - //---- 0,1,2 - //outputValues(0, i0) = zq0* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(0, i0, 5) = d2zq0* ( 4.0 ); - outputValues(0, i0, 8) = d2zq0* ( 4.0 ); - outputValues(0, i0, 12) = d2zq0* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - //outputValues(1, i0) = zq0* x*(2.0*x - 1.0); - outputValues(1, i0, 5) = d2zq0* ( 4.0 ); - outputValues(1, i0, 8) = 0.0; - outputValues(1, i0, 12) = 0.0; - - //outputValues(2, i0) = zq0* y*(2.0*y - 1.0); - outputValues(2, i0, 5) = 0.0; - outputValues(2, i0, 8) = 0.0; - outputValues(2, i0, 12) = d2zq0* (4.0); - - //---- 3,4,5 - // same as 0,1,2 with zq1 for zq0 - //outputValues(3, i0) = zq1* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(3, i0, 5) = d2zq1* ( 4.0 ); - outputValues(3, i0, 8) = d2zq1* ( 4.0 ); - outputValues(3, i0, 12) = d2zq1* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - //outputValues(4, i0) = zq1* x*(2.0*x - 1.0); - outputValues(4, i0, 5) = d2zq1* ( 4.0 ); - outputValues(4, i0, 8) = 0.0; - outputValues(4, i0, 12) = 0.0; - - //outputValues(5, i0) = zq1* y*(2.0*y - 1.0); - outputValues(5, i0, 5) = 0.0; - outputValues(5, i0, 8) = 0.0; - outputValues(5, i0, 12) = d2zq1* (4.0); - - //--- 6,7,8 - //outputValues(6, i0) = z0* (-4.0*x*(x + y - 1.0)); - outputValues(6, i0, 5) = d2z0* (-8.0); - outputValues(6, i0, 8) = d2z0* (-4.0); - outputValues(6, i0, 12) = 0.0; - - //outputValues(7, i0) = z0* ( 4.0*x*y); - outputValues(7, i0, 5) = 0.0; - outputValues(7, i0, 8) = d2z0* ( 4.0 ); - outputValues(7, i0, 12) = 0.0; - - //outputValues(8, i0) = z0* (-4.0*y*(x + y - 1.0)); - outputValues(8, i0, 5) = 0.0; - outputValues(8, i0, 8) = d2z0* (-4.0); - outputValues(8, i0, 12) = d2z0* (-8.0); - - //---- 9,10,11 - // same as 0,1,2 with zqh for zq0 - //outputValues(9, i0) = zqh* (x + y - 1.0)*(2.0*x + 2.0*y - 1.0); - outputValues(9, i0, 5) = d2zqh* ( 4.0 ); - outputValues(9, i0, 8) = d2zqh* ( 4.0 ); - outputValues(9, i0, 12) = d2zqh* ( (1.0)*( 2.0) + (1.0)*(2.0) ); - - //outputValues(10, i0) = zqh* x*(2.0*x - 1.0); - outputValues(10, i0, 5) = d2zqh* ( 4.0 ); - outputValues(10, i0, 8) = 0.0; - outputValues(10, i0, 12) = 0.0; - - //outputValues(11, i0) = zqh* y*(2.0*y - 1.0); - outputValues(11, i0, 5) = 0.0; - outputValues(11, i0, 8) = 0.0; - outputValues(11, i0, 12) = d2zqh* (4.0); - - //--- 12,13,14 - // same as 6,7,8 with z1 for z0 - - //outputValues(12, i0) = z1* (-4.0*x*(x + y - 1.0)); - outputValues(12, i0, 5) = d2z1* (-8.0); - outputValues(12, i0, 8) = d2z1* (-4.0); - outputValues(12, i0, 12) = 0.0; - - //outputValues(13, i0) = z1* ( 4.0*x*y); - outputValues(13, i0, 5) = 0.0; - outputValues(13, i0, 8) = d2z1* ( 4.0 ); - outputValues(13, i0, 12) = 0.0; - - //outputValues(14, i0) = z1* (-4.0*y*(x + y - 1.0)); - outputValues(14, i0, 5) = 0.0; - outputValues(14, i0, 8) = d2z1* (-4.0); - outputValues(14, i0, 12) = d2z1* (-8.0); - - } - } - break; - - case OPERATOR_D5: - case OPERATOR_D6: - case OPERATOR_D7: - case OPERATOR_D8: - case OPERATOR_D9: - case OPERATOR_D10: - { - // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality) - int DkCardinality = Intrepid::getDkCardinality(operatorType, - this -> basisCellTopology_.getDimension() ); - for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) { - for (int i0 = 0; i0 < dim0; i0++) { - for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){ - outputValues(dofOrd, i0, dkOrd) = 0.0; - } - } - } - } - break; - - default: - TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument, - ">>> ERROR (Basis_HGRAD_WEDGE_C2_Serendipity_FEM): Invalid operator type"); - } - } - - - - template - void Basis_HGRAD_WEDGE_C2_Serendipity_FEM::getValues(ArrayScalar& outputValues, - const ArrayScalar & inputPoints, - const ArrayScalar & cellVertices, - const EOperator operatorType) const { - TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error, - ">>> ERROR (Basis_HGRAD_WEDGE_C2_Serendipity_FEM): FEM Basis calling an FVD member function"); - } -}// namespace Intrepid -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.cpp deleted file mode 100644 index a1040a1e86ae..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#include - -namespace stk_classic { - namespace percept { - using shards::CellTopology; - - bool MeshUtil::m_debug = false; - - // ================================================================================================================================================================ - // ================================================================================================================================================================ - // ================================================================================================================================================================ - - void MeshUtil::fillSideNodes(stk_classic::mesh::Entity& element, unsigned iside, std::vector& side_nodes) - { - CellTopology cell_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - int nfn = cell_topo.getCellTopologyData()->side[iside].topology->vertex_count; - side_nodes.resize(nfn); - for (int inode = 0; inode < nfn; inode++) - { - int jnode = cell_topo.getCellTopologyData()->side[iside].node[inode]; - side_nodes[inode] = elem_nodes[jnode].entity()->identifier(); - } - } - - void MeshUtil::fillSideNodes(stk_classic::mesh::Entity& element, unsigned iside, std::vector& side_nodes) - { - CellTopology cell_topo(stk_classic::percept::PerceptMesh::get_cell_topology(element)); - const mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - int nfn = cell_topo.getCellTopologyData()->side[iside].topology->vertex_count; - side_nodes.resize(nfn); - for (int inode = 0; inode < nfn; inode++) - { - int jnode = cell_topo.getCellTopologyData()->side[iside].node[inode]; - side_nodes[inode] = elem_nodes[jnode].entity(); - } - } - - double MeshUtil::triFaceArea(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element, unsigned iside) - { - std::vector side_nodes; - fillSideNodes(element, iside, side_nodes); - - //int spatialDim = eMesh.get_spatial_dim(); - double a[3]={0,0,0}; - double b[3]={0,0,0}; - double c[3]={0,0,0}; - - double *fdata0 = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *side_nodes[0]); - double *fdata1 = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *side_nodes[1]); - double *fdata2 = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *side_nodes[2]); - for (int idim=0; idim < 3; idim++) - { - a[idim] = fdata1[idim] - fdata0[idim]; - b[idim] = fdata2[idim] - fdata0[idim]; - } - c[0] = a[1]*b[2] - a[2]*b[1]; - c[1] = -(a[0]*b[2] - a[2]*b[0]); - c[2] = a[0]*b[1] - a[1]*b[0]; - - return 0.5*std::sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]); - } - - bool MeshUtil::nodesMatch( std::vector& side1, std::vector& side2, bool reverse) - { - if (side1.size() != side2.size()) return false; - //std::cout << "tmp side1= " << side1 << " side2= " << side2 << std::endl; - int nfn = side1.size(); - for (int i = 0; i < nfn; i++) - { - bool found = true; - if (reverse) - { - int k=0; - for (int j = nfn-1; j >= 0; --j) - { - if (side1[k++] != side2[(i+j) % nfn]) - { - found = false; - break; - } - } - } - else - { - for (int j = 0; j < nfn; j++) - { - if (side1[j] != side2[(i+j) % nfn]) - { - found = false; - break; - } - } - } - - if (found) - { - return true; - } - } - return false; - } - - bool MeshUtil::sharesFace(stk_classic::mesh::Entity& element1, stk_classic::mesh::Entity& element2, unsigned& iside1, unsigned& iside2) - { - CellTopology cell_topo1(stk_classic::percept::PerceptMesh::get_cell_topology(element1)); - CellTopology cell_topo2(stk_classic::percept::PerceptMesh::get_cell_topology(element2)); - if (cell_topo1.getKey() != cell_topo2.getKey()) - return false; - - std::vector side1; - std::vector side2; - unsigned nsides = (unsigned)cell_topo1.getSideCount(); - for (iside1 = 0; iside1 < nsides; iside1++) - { - fillSideNodes(element1, iside1, side1); - for (iside2 = 0; iside2 < nsides; iside2++) - { - fillSideNodes(element2, iside2, side2); - - // true = reverse the nodes since we are looking at a face from two sides - if (nodesMatch(side1, side2, true)) - { - return true; - } - - } - } - return false; - } - - bool MeshUtil::facesConsistent1(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element1, stk_classic::mesh::Entity& element2) - { - //int spatialDim = eMesh.get_spatial_dim(); - //unsigned side_rank = (spatialDim == 3 ? m_eMesh.face_rank() : m_eMesh.edge_rank()); - double tol = 1.e-5; - - CellTopology cell_topo1(stk_classic::percept::PerceptMesh::get_cell_topology(element1)); - CellTopology cell_topo2(stk_classic::percept::PerceptMesh::get_cell_topology(element2)); - - if (cell_topo1.getKey() != cell_topo2.getKey()) - return false; - - unsigned ichild_side1=0, ichild_side2=0; - unsigned iside1=0, iside2=0; - if (eMesh.isParentElement(element1, false) && eMesh.isParentElement(element2, false)) - { - if (sharesFace(element1, element2, iside1, iside2)) - { - double ptriFaceArea1 = triFaceArea(eMesh, element1, iside1); - double ptriFaceArea2 = triFaceArea(eMesh, element2, iside2); - if (std::abs(ptriFaceArea1 - ptriFaceArea2) > tol*(ptriFaceArea1 + ptriFaceArea2)/2.) - { - throw std::runtime_error("triFaceArea inconsistent parent"); - } - std::vector children1, children2; - bool hasChildren1 = eMesh.getChildren(element1, children1, true, true); // check_for_family_tree, only_if_element_is_parent_leaf - bool hasChildren2 = eMesh.getChildren(element2, children2, true, true); - VERIFY_OP_ON(hasChildren1, &&, hasChildren2, "no children"); - double cfaceTot=0.0; - - for (unsigned ichild1 = 0; ichild1 < children1.size(); ichild1++) - { - for (unsigned ichild2 = 0; ichild2 < children2.size(); ichild2++) - { - stk_classic::mesh::Entity& child1 = *children1[ichild1]; - stk_classic::mesh::Entity& child2 = *children2[ichild2]; - if (sharesFace(child1, child2, ichild_side1, ichild_side2)) - { - double ctriFaceArea1 = triFaceArea(eMesh, child1, ichild_side1); - double ctriFaceArea2 = triFaceArea(eMesh, child2, ichild_side2); - if (std::abs(ctriFaceArea1 - ctriFaceArea2) > tol*(ctriFaceArea1 + ctriFaceArea2)/2.) - { - throw std::runtime_error("triFaceArea inconsistent child"); - } - cfaceTot += ctriFaceArea1; - } - } - } - if (m_debug) - { - std::cout << "E1= " << element1.identifier() << " E2= " << element2.identifier() << " cfaceTot= " << cfaceTot - << " ptriFaceArea1= " << ptriFaceArea1 << std::endl; - } - if (std::abs(cfaceTot - ptriFaceArea1) > tol*(cfaceTot+ptriFaceArea1)/2.) - { - throw std::runtime_error("triFaceArea inconsistent child/parent"); - } - } - } - return true; - } - - - bool MeshUtil::facesConsistent(percept::PerceptMesh& eMesh) - { - const std::vector & buckets = eMesh.get_bulk_data()->buckets( eMesh.element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - for ( std::vector::const_iterator k1 = buckets.begin() ; k1 != buckets.end() ; ++k1 ) - { - stk_classic::mesh::Bucket & bucket1 = **k1 ; - - const unsigned num_elements_in_bucket1 = bucket1.size(); - for (unsigned iElement1 = 0; iElement1 < num_elements_in_bucket1; iElement1++) - { - stk_classic::mesh::Entity& element1 = bucket1[iElement1]; - if (&element1 != &element) - { - bool isConsistent = facesConsistent1(eMesh, element, element1); - if (!isConsistent) - return false; - } - } - } - } - } - return true; - } - - void MeshUtil::checkTopology(percept::PerceptMesh& eMesh) - { - const std::vector & buckets = eMesh.get_bulk_data()->buckets( eMesh.element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - if (!stk_classic::percept::PerceptMesh::get_cell_topology(element)) - { - // an empty element - if (element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK).size() == 0) - continue; - - std::cout << "Error MeshUtil::checkTopology null" << std::endl; - eMesh.print_entity(std::cout, element); - throw std::logic_error("Error MeshUtil::checkTopology null" ); - } - } - } - } - } -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.hpp deleted file mode 100644 index 7ca2ec765c24..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/MeshUtil.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef stk_percept_MeshUtil_hpp -#define stk_percept_MeshUtil_hpp - -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -namespace stk_classic { - namespace percept { - - class MeshUtil - { - public: - static bool m_debug; - - // high level methods - static bool facesConsistent(PerceptMesh& eMesh); - - static void checkTopology(percept::PerceptMesh& eMesh); - - // low-level support methods - - static void fillSideNodes(stk_classic::mesh::Entity& element, unsigned iside, std::vector& side_nodes); - - static void fillSideNodes(stk_classic::mesh::Entity& element, unsigned iside, std::vector& side_nodes); - - static double triFaceArea(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element, unsigned iside); - - static bool nodesMatch( std::vector& side1, std::vector& side2, bool reverse=false); - - static bool sharesFace(stk_classic::mesh::Entity& element1, stk_classic::mesh::Entity& element2, unsigned& iside1, unsigned& iside2); - - static bool facesConsistent1(percept::PerceptMesh& eMesh, stk_classic::mesh::Entity& element1, stk_classic::mesh::Entity& element2); - - }; - } -} - -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Name.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Name.hpp deleted file mode 100644 index 99a2530408e0..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Name.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef stk_percept_Name_hpp -#define stk_percept_Name_hpp - -#include - -namespace stk_classic -{ - namespace percept - { - - /// this is to avoid a common bug where the name of the String Function is given instead of function_string, - /// ie., first two args are accidentally reversed - this is essentially a model of a "named argument", - /// as opposed to a positional one; of course, it is still only a hint (though a strong one) to the user - - /// Useful in other places where two strings are passed into a function or constructor - class Name - { - const std::string m_name; - public: - explicit - Name(const std::string name) : m_name(name) {} - const std::string& getName() const { return m_name; } - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/NoMallocArray.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/NoMallocArray.hpp deleted file mode 100644 index e7d99fdeccde..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/NoMallocArray.hpp +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef stk_percept_NoMallocArray_hpp -#define stk_percept_NoMallocArray_hpp - -#include -#include - -namespace stk_classic { - namespace percept { - - // patterned after boost::array - - template - class NoMallocArray { - - public: - //enum { MAX_CAPACITY = N }; - - // type definitions - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - public: - size_type m_size; // 0...N-1 - T m_data[N]; // fixed-size array of elements of type T - - public: - - explicit NoMallocArray() : m_size(0u) {} - - NoMallocArray(size_type sz, const T& val) : m_size(sz) - { -#ifdef NOMALLOC_ARRAY_CHECK_SIZES -#endif -#if 1 - if (sz > N) throw std::runtime_error("error n > N"); - for (size_type i = 0; i < sz; i++) - { - m_data[i] = val; - } -#endif - } - - void clear() { m_size=0; } - - // iterator support - iterator begin() { return m_data; } - const_iterator begin() const { return m_data; } - iterator end() { return m_data+m_size; } - const_iterator end() const { return m_data+m_size; } - - void resize(size_type n) { - if (n > N) throw std::runtime_error("error n > N"); - m_size=n; - } - // reverse iterator support - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - // operator[] - reference operator[](size_type i) - { - VERIFY_OP( i, <, N, "out of range" ); - return m_data[i]; - } - - const_reference operator[](size_type i) const - { - VERIFY_OP( i, <, N, "out of range" ); - return m_data[i]; - } - - // at() with range check - reference at(size_type i) { rangecheck(i); return m_data[i]; } - const_reference at(size_type i) const { return m_data[i]; } - - // front() and back() - reference front() - { - return m_data[0]; - } - - const_reference front() const - { - return m_data[0]; - } - - reference back() - { - return m_data[m_size-1]; - } - - const_reference back() const - { - return m_data[m_size-1]; - } - - inline size_type size() const { return m_size;} - - void insert(T val) - { - VERIFY_OP(m_size, < , N, "out of bounds"); - (*this)[m_size] = val; - m_size++; - //if (m_size > m_capacity) throw std::runtime_error("m_size"); - //std::sort( begin(), end() ); - } - - bool empty() { return m_size == 0; } - size_type max_size() { return N; } - size_type max_capacity() { return N; } - - - bool contains(T val) - { - for (size_type i = 0; i < m_size; i++) - { - if (val == (*this)[i]) - { - return true; - } - } - return false; - } - - // swap (note: linear complexity) - void swap (NoMallocArray& y) { - std::swap_ranges(begin(),end(),y.begin()); - } - - // direct access to data (read-only) - const T* data() const { return m_data; } - T* data() { return m_data; } - - // use array as C array (direct read/write access to data) - T* c_array() { return m_data; } - - // assignment with type conversion - template - NoMallocArray& operator= (const NoMallocArray& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); - return *this; - } - -#if 0 - bool operator== (const NoMallocArray& rhs) const { - for (size_type i = 0; i < size(); i++) - { - if (m_data[i] != rhs.m_data[i]) - return false; - } - return true; - } -#endif - - // assign one value to all elements - void assign (const T& value) - { - std::fill_n(begin(),size(),value); - } - - // check range (may be private because it is static) - void rangecheck (size_type i) { - if (i >= size()) { - throw std::out_of_range("NoMallocArray<>: index out of range"); - } - } - }; - - template - inline std::ostream &operator<<(std::ostream& out, const NoMallocArray& arr) - { - out << arr[0]; - return out; - } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Observable.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Observable.hpp deleted file mode 100644 index e6263e2ce1d8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Observable.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef stk_percept_Observable_hpp -#define stk_percept_Observable_hpp - -#include -#include -#include - -namespace stk_classic -{ -namespace percept -{ - -template -class Observable; - -template -class Observer -{ -public: - - Observer( Observable& observable) : m_observable(observable) - { - observable.addObserver(*this); - } - - ~Observer() - { - m_observable.removeObserver(*this); - } - - virtual void notify(DATA_TYPE *data) = 0; - -private: - Observable& m_observable; -}; - -template -class Observable -{ -public: - typedef std::vector *> Observers; - - Observable(){} - - void addObserver(Observer& observer) - { - m_observers.push_back(&observer); - } - - void removeObserver(Observer& observer) - { -#if 0 - std::vector::iterator found; - found = std::find(m_observers.begin(), m_observers().end(), &observer); - if (found != m_observers().end()) - { - m_observers.erase(found); - } -#endif - } - - Observers& getObservers() - { - return m_observers; - } - - void notifyObservers(DATA_TYPE *data) - { - for (unsigned i = 0; i < m_observers.size(); i++) - { - m_observers[i]->notify(data); - } - } - -private: - Observers m_observers; -}; - - - - -} -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/OptionMask.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/OptionMask.hpp deleted file mode 100644 index 32dc81cc164b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/OptionMask.hpp +++ /dev/null @@ -1,215 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -#ifndef stk_percept_OptionMask_hpp -#define stk_percept_OptionMask_hpp - -#include -#include -#include - -#include -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include -#include - - -/// copied and edited from stk_util/use_cases/UseCaseEnvironment - -namespace { - - // Parse command line bit masks and produce -h documentation. (Probably moved to Util at some point) - typedef unsigned long OptionMask; - - struct OptionMaskName - { - OptionMaskName() - : m_name(""), - m_mask(0), - m_description("") - {} - - OptionMaskName(const std::string &name, const OptionMask &mask, const std::string &description = "No description available") - : m_name(name), - m_mask(mask), - m_description(description) - {} - - virtual ~OptionMaskName() - {} - - std::string m_name; - OptionMask m_mask; - std::string m_description; - }; - - - class OptionMaskNameMap: public std::map - { - public: - void mask(const std::string &name, const OptionMask mask, const std::string &description) { - iterator it = find(name); - if (it == end()) - insert(std::make_pair(name, OptionMaskName(name, mask, description))); - else { - (*it).second.m_mask = mask; - (*it).second.m_description = description; - } - } - }; - - class OptionMaskParser - { - public: - typedef OptionMask Mask; ///< Mask for this option - - public: - /** - * Creates a new OptionMaskParser instance. - * - */ - OptionMaskParser(const std::string &description) - : m_optionMaskNameMap(), - m_description(description), - m_optionMask(0), - m_status(true) - {} - - virtual ~OptionMaskParser() - {} - - Mask parse(const char *mask) const; - - virtual void parseArg(const std::string &name) const; - - std::string describe() const { - std::ostringstream strout; - strout << m_description << std::endl; - for (OptionMaskNameMap::const_iterator it = m_optionMaskNameMap.begin(); it != m_optionMaskNameMap.end(); ++it) - strout << " " << (*it).first << std::setw(14 - (*it).first.size()) << " " << (*it).second.m_description << std::endl; - return strout.str(); - } - - void mask(const std::string &name, const Mask mask, const std::string &description) { - m_optionMaskNameMap.mask(name, mask, description); - } - - protected: - OptionMaskNameMap m_optionMaskNameMap; ///< Mask name vector - std::string m_description; ///< Help description - mutable OptionMask m_optionMask; ///< Most recently parsed mask - mutable bool m_status; ///< Result of most recent parse - }; - - - OptionMaskParser::Mask - OptionMaskParser::parse( - const char * mask) const - { - if (mask) { - const std::string mask_string(mask); - - m_status = true; - - std::string::const_iterator it0 = mask_string.begin(); - std::string::const_iterator it1; - std::string::const_iterator it2; - std::string::const_iterator it3; - do { - // Trim preceeding spaces - while (it0 != mask_string.end() && *it0 == ' ') - it0++; - - if (it0 == mask_string.end()) - break; - - for (it1 = it0; it1 != mask_string.end(); ++it1) { - if (*it1 == '(' || *it1 == ':' || *it1 == ',') - break; - } - - // Trim trailing spaces - it2 = it1; - while (it2 != it0 && *(it2 - 1) == ' ') - --it2; - - std::string name(it0, it2); - - // Get argument list - if (*it1 == '(') { - it2 = it1 + 1; - - // Trim preceeding spaces - while (it2 != mask_string.end() && *it2 == ' ') - ++it2; - - int paren_count = 0; - - for (; it1 != mask_string.end(); ++it1) { - if (*it1 == '(') - ++paren_count; - else if (*it1 == ')') { - --paren_count; - if (paren_count == 0) - break; - } - } - it3 = it1; - - // Trim trailing spaces - while (it3 != it2 && *(it3 - 1) == ' ') - --it3; - - // Find next argument start - for (; it1 != mask_string.end(); ++it1) - if (*it1 == ':' || *it1 == ',') - break; - } - else - it2 = it3 = it1; - - const std::string arg(it2, it3); - - parseArg(name); - - it0 = it1 + 1; - } while (it1 != mask_string.end()); - } - - return m_optionMask; - } - - - void - OptionMaskParser::parseArg( - const std::string & name) const - { - OptionMaskNameMap::const_iterator mask_entry = m_optionMaskNameMap.find(name); - - if (mask_entry != m_optionMaskNameMap.end()) m_optionMask |= (*mask_entry).second.m_mask; - else { - Mask mask_hex = 0; - std::istringstream mask_hex_stream(name.c_str()); - if (mask_hex_stream >> std::resetiosflags(std::ios::basefield) >> mask_hex) - m_optionMask |= mask_hex; - else - m_status = false; - } - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtil.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtil.hpp deleted file mode 100644 index c886882f7010..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtil.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef stk_percept_ParallelUtil_hpp -#define stk_percept_ParallelUtil_hpp - -#include - -#include - -#if defined( STK_HAS_MPI ) -#include -#endif - - -namespace stk_classic { - namespace percept { - - - /** Copied/Modeled after MPIX.[hc]pp in ~/code/stk/src/rsmesh and is an extension to the Sierra framework's - * Fmwk_global_min capability. - */ - - //======================================================================================================================== - // external interface - namespace { - - template - inline - void stk_percept_global_lex_min(stk_classic::ParallelMachine comm, int n , T local_min[] , T global_min[] ); - } - - } // percept -}// stk - -//======================================================================================================================== -// implementation - -#include - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtilDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtilDef.hpp deleted file mode 100644 index 741b0751ca01..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ParallelUtilDef.hpp +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef stk_percept_ParallelUtilDef_hpp -#define stk_percept_ParallelUtilDef_hpp - - -namespace stk_classic { - namespace percept { - - - //======================================================================================================================== - // implementation - namespace { - -#if defined( STK_HAS_MPI ) - - template - struct stk_percept_Datatype; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_CHAR; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_CHAR; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_BYTE; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_INT; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_UNSIGNED; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_SHORT; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_UNSIGNED_SHORT; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_LONG; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_UNSIGNED_LONG; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_FLOAT; - } - }; - - template <> - struct stk_percept_Datatype - { - static MPI_Datatype type() { - return MPI_DOUBLE; - } - }; - - - //======================================================================================================================== - extern "C" { - typedef void (*stk_percept_ParallelReduceOp) - (void * inv, void * outv, int *, MPI_Datatype *); - } - - template < typename T > - struct stk_percept_reduce_min_lex - { - static void void_op(void * inv, void * outv, int *len, MPI_Datatype *) - { - T* inv_T = reinterpret_cast(inv); - T* outv_T = reinterpret_cast(outv); - - bool is_less = false; - for (int iv = 0; iv < *len; iv++) - { - if (inv_T[iv] < outv_T[iv]) - { - is_less = true; - break; - } - else if (inv_T[iv] == outv_T[iv]) - { - // continue - } - else - { - is_less = false; - break; - } - } - if (is_less) - { - std::copy(inv_T, inv_T+(*len), outv_T); - } - } - }; - -#endif - - template - inline - void stk_percept_global_lex_min(stk_classic::ParallelMachine comm, int n , T local_min[] , T global_min[] ) - { -#if defined( STK_HAS_MPI ) - ParallelReduceOp p_op = reinterpret_cast(& stk_percept_reduce_min_lex::void_op ); - - if ( n < 1 ) return; - MPI_Op mpi_op = MPI_OP_NULL ; - - MPI_Op_create(p_op, 0, & mpi_op); - - if ( MPI_SUCCESS != MPI_Allreduce( local_min, global_min, (int) n, - stk_percept_Datatype::type(), - mpi_op, - comm ) ) - { - throw std::runtime_error("MPI_Allreduce failed"); - } - - MPI_Op_free(& mpi_op); - -#else - for ( register int i = 0 ; i < n ; ++i ) - global_min[i] = local_min[i] ; -#endif - } - - - } // empty namespace - - - } // percept -}// stk - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Percept.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Percept.hpp deleted file mode 100644 index f21477ba53d2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Percept.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef stk_percept_Percept_hpp -#define stk_percept_Percept_hpp - -//#define HAVE_INTREPID_DEBUG 0 - -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ -//----- PGI Compiler bug workaround (switch statements in template code) -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ - -#define USE_PGI_7_1_COMPILER_BUG_WORKAROUND - -#if !defined(PGI_INSTANTIATION_FILE) && defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND) -// ensure bases get included only once -#define INTREPID_HGRAD_HEX_C1_FEMDEF_HPP -#define INTREPID_HGRAD_HEX_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_LINE_C1_FEMDEF_HPP - -#define INTREPID_HGRAD_TRI_C1_FEMDEF_HPP -#define INTREPID_HGRAD_TRI_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_QUAD_C1_FEMDEF_HPP -#define INTREPID_HGRAD_QUAD_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_HEX_C1_FEMDEF_HPP -#define INTREPID_HGRAD_HEX_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_TET_C1_FEMDEF_HPP -#define INTREPID_HGRAD_TET_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_WEDGE_C1_FEMDEF_HPP - -#define INTREPID_HGRAD_QUAD_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_HEX_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_WEDGE_C2_SERENDIPITY_FEMDEF_HPP -#define INTREPID_HGRAD_QUAD_C2_SERENDIPITY_FEMDEF_HPP - - // Shells -#define INTREPID_HGRAD_TRI_C1_FEMDEF_HPP -#define INTREPID_HGRAD_TRI_C2_FEMDEF_HPP - -#define INTREPID_HGRAD_QUAD_C1_FEMDEF_HPP - - -#define INTREPID_CELLTOOLSDEF_HPP - -#endif - - -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ -//----- PGI Compiler old-ness problem - unsupported on boost::ublas -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ - -/* The following is to avoid the following error from boost::ublas libraries: - -"/scratch/srkenno/code/TPLs_src/boost/boost/numeric/ublas/detail/config.hpp", line 170: catastrophic error: - #error directive: Your compiler and/or configuration is unsupported - by this verions of uBLAS. Define BOOST_UBLAS_UNSUPPORTED_COMPILER=0 - to override this message. Boost 1.32.0 includes uBLAS with support - for many older compilers. - #error Your compiler and/or configuration is unsupported by this verions of uBLAS. Define BOOST_UBLAS_UNSUPPORTED_COMPILER=0 to - override this message. Boost 1.32.0 includes uBLAS with support for many older compilers. -*/ - -#if defined(__PGI) -#define BOOST_UBLAS_UNSUPPORTED_COMPILER 0 -#endif - - -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ -//----- Geometry and Mesquite configuration -//------------------------------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------------------------------ - -#if defined(STK_BUILT_IN_SIERRA) && !defined(STK_PERCEPT_HAS_GEOMETRY) -#define STK_PERCEPT_HAS_GEOMETRY -#endif - -#if defined(STK_BUILT_IN_SIERRA) && !defined(STK_PERCEPT_HAS_MESQUITE) -#define STK_PERCEPT_HAS_MESQUITE -#endif - -#if defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) -#undef STK_PERCEPT_HAS_MESQUITE -#endif - -#if defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_GEOMETRY) -#undef STK_PERCEPT_HAS_GEOMETRY -#endif - -#include - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptBoostArray.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/PerceptBoostArray.hpp deleted file mode 100644 index 6dac9cecf00e..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptBoostArray.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 1210) -#pragma warning disable 2196 2536 279 -#endif - -#include -#include - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.cpp deleted file mode 100644 index 70eb6514c85a..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.cpp +++ /dev/null @@ -1,4471 +0,0 @@ -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include "Intrepid_HGRAD_HEX_C1_FEM.hpp" -//#include "Intrepid_Basis.hpp" - - -#include - -//#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#if defined( STK_PERCEPT_HAS_GEOMETRY ) - -#include -#include -#include - -#endif - -// FIXME - -#include -#include -#include - -#include - -namespace stk_classic { - namespace percept { - - //std::string PerceptMesh::s_omit_part = "_urp_original"; - //std::string PerceptMesh::s_omit_part = "_urporig"; - std::string PerceptMesh::s_omit_part = "_uo"; // stk_io now lowercases everything - - FieldCreateOrder::FieldCreateOrder() : m_name(), m_entity_rank(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), m_dimensions(), m_part(0) {} - FieldCreateOrder::FieldCreateOrder(const std::string name, const unsigned entity_rank, - const std::vector dimensions, const stk_classic::mesh::Part* part) - : m_name(name), m_entity_rank(entity_rank), m_dimensions(dimensions), m_part(part) {} - - - // ctor constructor - //======================================================================================================================== - /// high-level interface - -#if 0 - PerceptMesh::PerceptMesh( stk_classic::ParallelMachine comm) : - m_metaData(NULL), - m_bulkData(NULL), - m_fixture(NULL), - m_iossRegion(NULL), - m_iossMeshData_created(false), - m_sync_io_regions(true), - m_coordinatesField(NULL), - m_spatialDim(0), - m_ownData(false), - m_isCommitted(false), - m_isOpen(false), - m_isInitialized(false), - m_isAdopted(false), - m_dontCheckState(false), - m_filename(), - m_comm(comm) - { - init( m_comm); - } -#endif - - PerceptMesh::PerceptMesh(size_t spatialDimension, stk_classic::ParallelMachine comm) : - m_metaData(NULL), - m_bulkData(NULL), - m_fixture(NULL), - m_iossRegion(NULL), - m_iossMeshData_created(false), - m_sync_io_regions(true), - m_coordinatesField(NULL), - m_spatialDim(spatialDimension), - m_ownData(false), - m_isCommitted(false), - m_isOpen(false), - m_isInitialized(false), - m_isAdopted(false), - m_dontCheckState(false), - m_filename(), - m_comm(comm), - m_streaming_size(0), - m_searcher(0) - ,m_num_coordinate_field_states(1) - { - init( m_comm); - } - - /// reads and commits mesh, editing disabled - void PerceptMesh:: - open_read_only(const std::string& in_filename) - { - open(in_filename); - commit(); - } - - /// opens an empty mesh, with a commit - void PerceptMesh:: - openEmpty() - { - if (m_isOpen) - { - throw std::runtime_error("stk_classic::percept::Mesh::openEmpty: mesh is already opened. Please close() before trying open, or use reopen()."); - } - if (m_isCommitted) - { - throw std::runtime_error("stk_classic::percept::Mesh::openEmpty: mesh is already committed. Internal code error"); - } - if (!m_isInitialized) - { - init( m_comm); - } - - //const unsigned p_rank = parallel_machine_rank( get_bulk_data()->parallel() ); - const unsigned p_rank = parallel_machine_rank( m_comm ); - - if (p_rank == 0) std::cout << "PerceptMesh:: opening empty mesh" << std::endl; - //read_metaDataNoCommit(in_filename); - m_metaData->commit(); - m_isCommitted = true; - m_isAdopted = false; - m_isOpen = true; - m_filename = ""; - } - - /// reads but doesn't commit mesh, enabling edit - void PerceptMesh:: - open(const std::string& in_filename) - { - if (m_isOpen) - { - throw std::runtime_error("stk_classic::percept::Mesh::open: mesh is already opened. Please close() before trying open, or use reopen()."); - } - if (m_isCommitted) - { - throw std::runtime_error("stk_classic::percept::Mesh::open: mesh is already committed. Internal code error"); - } - if (!m_isInitialized) - { - init( m_comm); - } - - //const unsigned p_rank = parallel_machine_rank( get_bulk_data()->parallel() ); - const unsigned p_rank = parallel_machine_rank( m_comm ); - - if (p_rank == 0) std::cout << "PerceptMesh:: opening "<< in_filename << std::endl; - read_metaDataNoCommit(in_filename); - m_isCommitted = false; - m_isAdopted = false; - m_isOpen = true; - m_filename = in_filename; - } - - /// creates a new mesh using the GeneratedMesh fixture with spec @param gmesh_spec - void PerceptMesh:: - new_mesh(const GMeshSpec gmesh_spec) - { - if (m_isOpen) - { - throw std::runtime_error("stk_classic::percept::Mesh::new_mesh: mesh is already opened. Please close() before trying to create a new mesh, or use reopen()."); - } - if (m_isCommitted) - { - throw std::runtime_error("stk_classic::percept::Mesh::new_mesh: mesh is already committed. Internal code error"); - } - m_ownData = false; - if (!m_isInitialized) - { - init( m_comm, true); - } - create_metaDataNoCommit( gmesh_spec.getName() ); - m_isOpen = true; - m_isCommitted = false; - m_isAdopted = false; - -#if PERCEPT_USE_FAMILY_TREE - // FIXME - // do a "reopen" operation to allow FAMILY_TREE type ranks (family_tree search term) - if (1) - { - commit(); - reopen(); - } -#endif - } - - /// creates a new mesh using the GeneratedMesh fixture with spec @param gmesh_spec, Read Only mode, no edits allowed - void PerceptMesh:: - new_mesh_read_only(const GMeshSpec gmesh_spec) - { - new_mesh(gmesh_spec); - commit(); - } - - /// add a field to the mesh - stk_classic::mesh::FieldBase * PerceptMesh:: - add_field(const std::string& name, unsigned int entity_rank, int vectorDimension, const std::string part_name) - { - if (m_isCommitted) - { - throw std::runtime_error("stk_classic::percept::Mesh::add_field: mesh is already committed, can't add fields. Use reopen()"); - } - if (!m_isOpen) - { - throw std::runtime_error("stk_classic::percept::Mesh::add_field: mesh is not open. Use open or new_mesh first."); - } - const stk_classic::mesh::Part* arg_part = getPart(part_name); - - //std::cout << "add_field : " << name << std::endl; - std::vector vdim(0); - if (vectorDimension) - { - vdim = std::vector(1); - vdim[0] = vectorDimension; - } - return createField(name, entity_rank, vdim, arg_part); - } - - stk_classic::mesh::FieldBase * PerceptMesh:: - get_field(const std::string& name) - { - stk_classic::mesh::FieldBase *field = m_metaData->get_field(name); - return field; - } - - /// commits mesh - any operations done on a non-committed mesh, except to add fields will throw an exception - void PerceptMesh::commit() - { - commit_metaData(); - // no op if mesh created by new_mesh - readBulkData(); - setCoordinatesField(); - m_isCommitted = true; - } - - /// reopens the mesh for editing - warning, this operation writes the mesh to a temp file then re-reads it and - /// thus recreates the internal FEMMetaData and BulkData - void PerceptMesh:: - reopen(const std::string temp_file_name) - { - if (!m_isCommitted) - { - throw std::runtime_error("stk_classic::percept::Mesh::reopen: mesh is not committed, can't reopen. Commit first."); - } - if (!m_isOpen) - { - throw std::runtime_error("stk_classic::percept::Mesh::reopen: mesh is not open. Use open or new_mesh first."); - } - writeModel(temp_file_name); - // std::cout << "reopen: after writeModel" << std::endl; - close(); - // std::cout << "reopen: after close, m_fixture = " << m_fixture << std::endl; - open(temp_file_name); - // std::cout << "reopen: after open, m_fixture = " << m_fixture << std::endl; - } - - /// commits mesh if not committed and saves it in new file - void PerceptMesh:: - save_as(const std::string& out_filename ) - { - writeModel(out_filename); - } - - /// closes this mesh to further changes - void PerceptMesh:: - close() - { - EXCEPTWATCH; - m_isInitialized = false; - m_isOpen = false; - m_isCommitted = false; - m_isAdopted = false; - destroy(); - } - - - std::ostream& noendl(std::ostream& os) {return os;} - - void PerceptMesh:: - print_info(std::ostream& stream, std::string header, int print_level, bool do_endl) - { - EXCEPTWATCH; - if (print_level < 1) return; - - typedef std::ostream& endl_type(std::ostream& os); - endl_type * m_endl = &std::endl; - endl_type * m_noendl = &noendl; - endl_type& mendl = (do_endl ? *m_endl : *m_noendl ); - const char *NL = (do_endl ? "\n" : ""); - - checkStateSpec("print_info", m_isOpen, m_isInitialized); - PerceptMesh& eMesh = *this; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( eMesh.get_bulk_data()->parallel() ); - const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - - stream - << ""< count ; - stk_classic::mesh::Selector selector(metaData.universal_part()); - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::print_info"); - } - stream << "P[" << p_rank << "] Uses {" ; - stream << " Node = " << count[ 0 ] ; - stream << " Edge = " << count[ 1 ] ; - stream << " Face = " << count[ 2 ] ; - if (count.size() >= 4) stream << " Elem = " << count[ 3 ] ; - if (count.size() >= 5) stream << " FamilyTree = " << count[ 4 ] ; - stream << " }" << mendl ; - } - - // Parts information - const std::vector< stk_classic::mesh::Part * > & parts = metaData.get_parts(); - unsigned nparts = parts.size(); - if (print_info) - { - stream << "P[" << p_rank << "] info> Number of parts = " << nparts << mendl; - stream << ""< Part subset info: "< 0) { - for (size_t j = 0; j < part_subsets.size(); j++) - { - stk_classic::mesh::Part & efb_part = *part_subsets[j]; - subsets += efb_part.name()+(j != part_subsets.size()-1?" , ":""); - } - } - subsets += "}"; - stream << "P[" << p_rank << "] info> Part[" << ipart << "]= " << part.name() - << " topology = " << (topology?shards::CellTopology(topology).getName():"null") - << " primary_entity_rank = " << part.primary_entity_rank() - << " subsets = " << subsets - << mendl; - } - - stream << ""< Part Uses information: "< count ; - stk_classic::mesh::Selector selector(part); - stk_classic::mesh::count_entities( selector, *eMesh.get_bulk_data(), count ); - - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::print_info"); - } - - stream << "P[" << p_rank << "] info> Part[" << ipart << "]= " << part.name() ; - stream << " : Uses {" ; - stream << " Node = " << count[ 0 ] ; - stream << " Edge = " << count[ 1 ] ; - stream << " Face = " << count[ 2 ] ; - if (count.size() >= 4) stream << " Elem = " << count[ 3 ] ; - if (count.size() >= 5) stream << " FamilyTree = " << count[ 4 ] ; - stream << " }" << mendl ; - - if (0) - { - dump_elements(part.name()); - } - } - } - } - - const stk_classic::mesh::FieldVector & fields = metaData.get_fields(); - unsigned nfields = fields.size(); - if (print_info) - { - stream << "P[" << p_rank << "] info> Number of fields = " << fields.size() << mendl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - if (print_info) stream << "P[" << p_rank << "] info> Field[" << ifld << "]= " << field->name() << " rank= " << field->rank() << mendl; - //if (print_info) stream << "P[" << p_rank << "] info> " << *field << mendl; - unsigned nfr = field->restrictions().size(); - if (print_info) stream << "P[" << p_rank << "] info> number of field restrictions= " << nfr << mendl; - unsigned stride = 0; - stk_classic::mesh::EntityRank field_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - stk_classic::mesh::Part& frpart = metaData.get_part(fr.part_ordinal()); - stride = fr.dimension(); - field_rank = fr.entity_rank(); - if (print_info) stream << "P[" << p_rank << "] info> field restriction " << ifr << " stride[0] = " << fr.dimension() << - " type= " << fr.entity_rank() << " ord= " << fr.part_ordinal() << - " which corresponds to Part= " << frpart.name() << mendl; - } - - if (print_level > 4) - { - stk_classic::mesh::Selector on_locally_owned_part = ( get_fem_meta_data()->locally_owned_part() ); - //EntityRank rank = field->rank(); - stk_classic::mesh::EntityRank rank = field_rank; - const std::vector & buckets = get_bulk_data()->buckets( rank ); - stream << "P[" << p_rank << "] info> num buckets = " << buckets.size() << " for rank= " << rank << mendl; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) // this is where we do part selection - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - //dw().m(LOG_APPLICATION) << "num_elements_in_bucket = " << num_elements_in_bucket<< " element ids = " << stk_classic::diag::dendl; - //dw() << "num_elements_in_bucket = " << num_elements_in_bucket<< " element ids = " << stk_classic::diag::dendl; - - std::ostringstream outstr; - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - double *fdata = stk_classic::mesh::field_data( *static_cast(field) , element ); - if (fdata) - { - for (unsigned istride = 0; istride < stride; istride++) - { - outstr << "P[" << p_rank << "] info> field data[" << istride << "]= " << fdata[istride] << " "< 5) - { - using std::vector; - const vector & buckets = get_bulk_data()->buckets( element_rank() ); - stream << "P[" << p_rank << "] info> num buckets = " << buckets.size() << mendl; - - int ibucket = 0; - for ( vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (select_owned(**k)) // this is where we do part selection - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - //dw().m(LOG_APPLICATION) << "num_elements_in_bucket = " << num_elements_in_bucket<< " element ids = " << stk_classic::diag::dendl; - //dw() << "num_elements_in_bucket = " << num_elements_in_bucket<< " element ids = " << stk_classic::diag::dendl; - - std::ostringstream outstr; - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - //stream << "element id = " << element.identifier() << mendl; - if (1) - { - //stream << " " << element.identifier(); - outstr << " " << element.identifier(); - if ((iElement+1) % 20 == 0) - outstr << mendl; - } - else - { - stream << "P[" << p_rank << "] info> " << " " << element << mendl; - } - } - stream << "P[" << p_rank << "] info> bucket # " << ibucket - << " num_elements_in_bucket = " << num_elements_in_bucket<< " element ids = " << outstr.str() << mendl; - ++ibucket; - } - } - } - - stream - << ""< pt(&domain[0], &domain[0]+domain.size()); - std::vector field(&codomain[0], &codomain[0]+codomain.size()); - std::cout << "P["<< m_eMesh.get_rank() << "] " << m_name << " field = " << field << " point = " << pt << std::endl; - } - - }; - - void PerceptMesh:: - print_fields(std::string header) - { - EXCEPTWATCH; - checkStateSpec("print_fields", m_isOpen, m_isInitialized); - - PerceptMesh& eMesh = *this; - - const unsigned p_rank = parallel_machine_rank( eMesh.get_bulk_data()->parallel() ); - - std::cout << "P[" << p_rank << "] PerceptMesh::print_fields: " << header << std::endl; - bool print_info = true; - - stk_classic::mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - - const stk_classic::mesh::FieldVector & fields = metaData.get_fields(); - unsigned nfields = fields.size(); - if (print_info) - { - std::cout << "P[" << p_rank << "] info> Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - if (print_info) std::cout << "P[" << p_rank << "] info> Field[" << ifld << "]= " << field->name() << " rank= " << field->rank() << std::endl; - if (print_info) std::cout << "P[" << p_rank << "] info> " << *field << std::endl; - - unsigned nfr = field->restrictions().size(); - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //std::cout << fr.key.rank(); - if (fr.entity_rank() == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - - if (print_info) std::cout << "P[" << p_rank << "] info> stride = "<< fr.dimension() << std::endl; - PrintFieldOp pfop(field->name(), *this, 3, fr.dimension()); - nodalOpLoop(pfop, field); - } - } - - } - } - } - - int PerceptMesh:: - get_spatial_dim() - { - // #ifndef NDEBUG - // const stk_classic::mesh::FieldBase::Restriction & r = get_coordinates_field()->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, get_fem_meta_data()->universal_part()); - // unsigned dataStride = r.dimension() ; - // VERIFY_OP((int)dataStride, ==, m_spatialDim, "PerceptMesh::get_spatial_dim() bad spatial dim"); - // #endif - return m_spatialDim; - } - - int PerceptMesh:: - get_number_elements() - { - std::vector count ; - stk_classic::mesh::Selector selector(get_fem_meta_data()->universal_part()); - stk_classic::mesh::count_entities( selector, *get_bulk_data(), count ); - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::get_number_elements"); - } - - return count[ element_rank() ]; - // std::cout << " Node = " << count[ 0 ] ; - // std::cout << " Edge = " << count[ 1 ] ; - // std::cout << " Face = " << count[ 2 ] ; - // std::cout << " Elem = " << count[ 3 ] ; - // std::cout << " }" << std::endl ; - // std::cout.flush(); - } - - int PerceptMesh:: - get_number_edges() - { - std::vector count ; - stk_classic::mesh::Selector selector(get_fem_meta_data()->universal_part()); - stk_classic::mesh::count_entities( selector, *get_bulk_data(), count ); - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::get_number_elements"); - } - - return count[ edge_rank() ]; - // std::cout << " Node = " << count[ 0 ] ; - // std::cout << " Edge = " << count[ 1 ] ; - // std::cout << " Face = " << count[ 2 ] ; - // std::cout << " Elem = " << count[ 3 ] ; - // std::cout << " }" << std::endl ; - // std::cout.flush(); - } - - int PerceptMesh:: - get_number_nodes() - { - std::vector count ; - stk_classic::mesh::Selector selector(get_fem_meta_data()->universal_part()); - stk_classic::mesh::count_entities( selector, *get_bulk_data(), count ); - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::get_number_elements"); - } - - return count[ node_rank() ]; - } - - int PerceptMesh:: - get_number_elements_locally_owned() - { - std::vector count ; - stk_classic::mesh::Selector selector(get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::count_entities( selector, *get_bulk_data(), count ); - if (count.size() < 3) - { - throw std::logic_error("logic error in PerceptMesh::get_number_elements"); - } - - return count[ element_rank() ]; - // std::cout << " Node = " << count[ 0 ] ; - // std::cout << " Edge = " << count[ 1 ] ; - // std::cout << " Face = " << count[ 2 ] ; - // std::cout << " Elem = " << count[ 3 ] ; - // std::cout << " }" << std::endl ; - // std::cout.flush(); - } - - void PerceptMesh::print_entity(std::ostream& out1, const stk_classic::mesh::Entity& entity, stk_classic::mesh::FieldBase* field) - { - if (!field) field = get_coordinates_field(); - - std::ostringstream out; - int fieldStride = 3; - { - unsigned nfr = field->restrictions().size(); - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //mesh::Part& frpart = eMesh.get_fem_meta_data()->get_part(fr.ordinal()); - fieldStride = fr.dimension() ; - } - } - - if (entity.entity_rank() == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - out << "Node: " << entity.identifier() << " rank= " << entity.entity_rank() << " nodes: \n"; - - double *f_data = PerceptMesh::field_data(field, entity); - out << " data = " ; - for (int ifd=0; ifd < fieldStride; ifd++) - { - out << f_data[ifd] << " "; - } - out << "\n"; - } - else - { - out << "Elem: " << entity.identifier() << " rank= " << entity.entity_rank() << " nodes: \n"; - - const mesh::PairIterRelation elem_nodes = entity.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - std::vector min(fieldStride, 1e+30); - std::vector max(fieldStride, -1e+30); - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - out << "inode= " << inode << " id= " << node.identifier() << " "; - double *f_data = PerceptMesh::field_data(field, node); - out << " data = " ; - for (int ifd=0; ifd < fieldStride; ifd++) - { - min[ifd] = std::min(f_data[ifd], min[ifd]); - max[ifd] = std::max(f_data[ifd], max[ifd]); - out << f_data[ifd] << " "; - } - out << "\n"; - } - out << " min= " << min << "\n"; - out << " max= " << max << "\n"; - for (int ifd=0; ifd < fieldStride; ifd++) - { - max[ifd] = max[ifd] - min[ifd]; - } - out << " max-min= " << max << "\n"; - } - out1 << out.str() << std::endl; - - } - - std::string PerceptMesh::print_entity_compact(const stk_classic::mesh::Entity& entity, stk_classic::mesh::FieldBase* field) - { - if (!field) field = get_coordinates_field(); - std::ostringstream out; - - if (entity.entity_rank() == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - out << "NODE: " << entity.identifier() << "\n"; - } - else - { - int fieldStride = 3; - { - unsigned nfr = field->restrictions().size(); - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //mesh::Part& frpart = eMesh.get_fem_meta_data()->get_part(fr.ordinal()); - fieldStride = fr.dimension() ; - } - } - - out << "E= " << entity.identifier() << " R= " << entity.entity_rank(); - - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - - std::string ghost_or_not = "N"; - if (isGhostElement(entity)) - ghost_or_not = "G"; - out << " GN= " << ghost_or_not << " "; - if (entity.entity_rank() == FAMILY_TREE_RANK) - { - out << " FT= "; - for (int rank = (int)element_rank(); rank >= 0; --rank) - { - const mesh::PairIterRelation family_tree_relations = entity.relations( (unsigned)rank ); - unsigned num_node = family_tree_relations.size(); - if (num_node) out << " |" << rank << "| "; - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * family_tree_relations[ inode ].entity(); - out << node.identifier() << " "; - } - } - } - else - { - std::string parent_or_child_or_none = "N"; - if (entity.relations(FAMILY_TREE_RANK).size()) - { - parent_or_child_or_none = (isChildElement(entity) ? "C" : "P"); - } - out << " PCN= " << parent_or_child_or_none << " "; - out << " N= "; - const mesh::PairIterRelation elem_nodes = entity.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - std::vector min(fieldStride, 1e+30); - std::vector max(fieldStride, -1e+30); - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - out << node.identifier() << " "; - } - out << " D= "; - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - out << "{ "; - double *f_data = PerceptMesh::field_data(field, node); - for (int ifd=0; ifd < fieldStride; ifd++) - { - min[ifd] = std::min(f_data[ifd], min[ifd]); - max[ifd] = std::max(f_data[ifd], max[ifd]); - out << f_data[ifd] << ", "; - } - out << "}"; - } - /* - out << " min= " << min << "\n"; - out << " max= " << max << "\n"; - for (int ifd=0; ifd < fieldStride; ifd++) - { - max[ifd] = max[ifd] - min[ifd]; - } - out << " max-min= " << max << "\n"; - */ - //out << "\n"; - } - - } - - return out.str(); - } - - //======================================================================================================================== - /// low-level interfaces - - void PerceptMesh:: - checkStateSpec(const std::string& function, bool cond1, bool cond2, bool cond3) - { - if (!m_dontCheckState && !(cond1 && cond2 && cond3)) - { - std::string str= "PerceptMesh::"+function+": mesh state error - check code for use of a closed PerceptMesh"; - throw std::runtime_error(str.c_str()); - } - } - - // ctor constructor - PerceptMesh::PerceptMesh(const stk_classic::mesh::fem::FEMMetaData* metaData, stk_classic::mesh::BulkData* bulkData, bool isCommitted) : - m_metaData(const_cast(metaData)), - m_bulkData(bulkData), - m_fixture(NULL), - m_iossRegion(NULL), - m_iossMeshData_created(false), - m_sync_io_regions(true), - m_coordinatesField(NULL), - m_spatialDim(metaData->spatial_dimension()), - m_ownData(false), - m_isCommitted(isCommitted), - m_isOpen(true), - m_isInitialized(true), - m_isAdopted(true), - m_dontCheckState(false), - m_filename(), - m_comm(), - m_streaming_size(0), - m_searcher(0) - ,m_num_coordinate_field_states(1) - { - if (!bulkData) - throw std::runtime_error("PerceptMesh::PerceptMesh: must pass in non-null bulkData"); - m_comm = bulkData->parallel(); - - setCoordinatesField(); - } - - void PerceptMesh:: - setSpatialDim( int sd ) - { - m_spatialDim = sd; - } - - void PerceptMesh:: - init( stk_classic::ParallelMachine comm, bool no_alloc) - { - if (m_isInitialized) return; - - m_isInitialized = true; - m_comm = comm; - m_ownData = true; - - if (!no_alloc) - { - if (m_spatialDim) - { - //m_metaData = new stk_classic::mesh::fem::FEMMetaData( m_spatialDim, stk_classic::mesh::fem::entity_rank_names(m_spatialDim) ); - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(m_spatialDim); -#if PERCEPT_USE_FAMILY_TREE - entity_rank_names.push_back("FAMILY_TREE"); -#endif -#if PERCEPT_USE_PSEUDO_ELEMENTS - entity_rank_names.push_back("PSEUDO_ELEMENT"); -#endif - m_metaData = new stk_classic::mesh::fem::FEMMetaData( m_spatialDim, entity_rank_names); - m_bulkData = new stk_classic::mesh::BulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(*m_metaData) , comm ); - } - else - { - m_metaData = new stk_classic::mesh::fem::FEMMetaData( ); - } - } - - m_fixture = 0; - m_isCommitted = false; - m_isAdopted = false; - m_isOpen = false; - m_filename = ""; - m_coordinatesField = NULL; - } - - void PerceptMesh::destroy() - { - //EXCEPTWATCH; - if (m_ownData) - { - delete m_metaData; - delete m_bulkData; - m_metaData = 0; - m_bulkData = 0; - } - if (m_fixture) - { - delete m_fixture; - m_fixture = 0; - } - //m_spatialDim = 0; - m_coordinatesField = NULL; - } - - PerceptMesh::~PerceptMesh() - { - destroy(); - } - - stk_classic::mesh::BulkData * PerceptMesh::get_bulk_data() - { - //checkState("get_bulk_data"); - return m_bulkData; - } - stk_classic::mesh::fem::FEMMetaData * PerceptMesh::get_fem_meta_data() - { - //checkState("get_fem_meta_data"); - return m_metaData; - } - - void PerceptMesh::setCoordinatesField() { - if (m_bulkData == NULL || m_metaData == NULL) { - throw std::runtime_error("PerceptMesh::setCoordinatesField() requires metadata and bulkdata"); - } - m_coordinatesField = m_metaData->get_field("coordinates"); - if (m_coordinatesField == NULL) { - throw std::runtime_error("PerceptMesh::setCoordinatesField() could not obtain the field from meta data"); - } - } - - stk_classic::mesh::Part* PerceptMesh:: - get_non_const_part(const std::string& part_name) - { - const stk_classic::mesh::Part* part = getPart(part_name); - return const_cast(part); - } - - const stk_classic::mesh::Part* PerceptMesh:: - getPart(const std::string& part_name) - { -#if 1 - const stk_classic::mesh::Part* part = get_fem_meta_data()->get_part(part_name); - return part; -#else - EXCEPTWATCH; - checkStateSpec("getPart", m_isInitialized, m_isOpen); - const stk_classic::mesh::Part* arg_part = 0; - if (part_name == "universal_part") - { - arg_part = &m_metaData->universal_part(); - } - else - { - const stk_classic::mesh::PartVector & parts = get_fem_meta_data()->get_parts(); - unsigned nparts = parts.size(); - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - if (part.name() == part_name) - { - arg_part = ∂ - } - } - } - if (!arg_part) - { - std::ostringstream msg; - msg << "stk_classic::percept::Mesh::getPart() couldn't find part with name = " << part_name; - throw std::runtime_error(msg.str()); - } - return arg_part; -#endif - } - - stk_classic::mesh::FieldBase* PerceptMesh::createField(const std::string& name, const unsigned entity_rank, - const std::vector& dimensions, const stk_classic::mesh::Part* arg_part) - { - EXCEPTWATCH; - checkStateSpec("createField", m_isOpen); - stk_classic::mesh::FieldBase *field=0; - const stk_classic::mesh::Part* part = (arg_part ? arg_part : &m_metaData->universal_part()); - - switch(dimensions.size()) - { - case 0: - // scalar - { - //std::cout << "createField scalar: " << name << std::endl; - ScalarFieldType & sfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( sfield , entity_rank , *part ); - field = &sfield; - } - break; - case 1: - // vector - { - //std::cout << "createField vector: " << name << std::endl; - VectorFieldType & vfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( vfield , entity_rank , *part, dimensions[0] ); - field = &vfield; - } - break; - case 2: - // Tensor - { - TensorFieldType & tfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( tfield , entity_rank , *part, dimensions[1], dimensions[0] ); - field = &tfield; - } - break; - case 3: - // Quad Point Tensor - { - QPTensorFieldType & qptfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( qptfield , entity_rank , *part, dimensions[2], dimensions[1], dimensions[0] ); - field = &qptfield; - } - break; - default: - // error FIXME - { - std::ostringstream msg; - msg << "PerceptMesh::createField unknown field dimensions = " << dimensions.size() << "\n"; - throw new std::runtime_error(msg.str()); - } - break; - } - - // set this field to have an Ioss role of transient - stk_classic::io::set_field_role(*field, Ioss::Field::TRANSIENT); - - return field; - } - - // modeled after Kuettler's code - stk_classic::mesh::Entity & PerceptMesh::createOrGetNode(stk_classic::mesh::EntityId node_id, double* coord_in) - { - EXCEPTWATCH; - if (!node_id) { - std::cout << "P[" << get_rank() << "] node_id = 0 " << std::endl; - exit(1); - } - - stk_classic::mesh::Entity * node = get_bulk_data()->get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, node_id ); - if (node) - { - double * const coord = stk_classic::mesh::field_data( *get_coordinates_field() , *node ); - - if (coord_in) - { - coord[0] = coord_in[0]; - coord[1] = coord_in[1]; - if (get_spatial_dim() == 3) - { - coord[2] = coord_in[2]; - } - } - - return *node; - } - else - { - static stk_classic::mesh::PartVector empty ; - stk_classic::mesh::Entity & node_0 = get_bulk_data()->declare_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, node_id, empty ); - - double * const coord = stk_classic::mesh::field_data( *get_coordinates_field() , node_0 ); - - if (!coord_in) - { - std::cout << "PerceptMesh::createOrGetNode coord_in is null and node doesn't exist, node_id= " << node_id << std::endl; - throw std::runtime_error("PerceptMesh::createOrGetNode coord_in is null and node doesn't exist"); - } - - if (coord_in) - { - coord[0] = coord_in[0]; - coord[1] = coord_in[1]; - if (get_spatial_dim() == 3) - { - coord[2] = coord_in[2]; - } - } - else - { - coord[0] = 0.0; - coord[1] = 0.0; - if (get_spatial_dim() == 3) - { - coord[2] = 0.0; - } - } - - return node_0; - } - } - - void PerceptMesh:: - createEntities(stk_classic::mesh::EntityRank entityRank, int count, std::vector& requested_entities) - { - std::vector requests( m_metaData->entity_rank_count() , 0 ); - requests[entityRank] = count; - get_bulk_data()->generate_new_entities( requests, requested_entities ); - } - - // static - double * PerceptMesh:: - field_data(const stk_classic::mesh::FieldBase *field, const stk_classic::mesh::Entity& node, unsigned *stride) - { - EXCEPTWATCH; - unsigned rank = field->rank(); - double * fdata = 0; - - if(stride) { - const stk_classic::mesh::FieldBase::Restriction & r = - field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, stk_classic::mesh::fem::FEMMetaData::get(*field).universal_part()); - if(rank == 0) - *stride = r.dimension() ; - else - *stride = r.stride(rank - 1); - } - - switch(rank) - { - case 0: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , node ); - } - break; - case 1: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , node ); - } - break; - case 2: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , node ); - } - break; - case 3: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , node ); - } - break; - default: - { - // error - std::ostringstream msg; - msg << "PerceptMesh::field_data unknown field rank = " << rank << "\n"; - throw new std::runtime_error(msg.str()); - } - } - return fdata; - } - - // static - double * PerceptMesh:: - field_data_entity(const stk_classic::mesh::FieldBase *field, const stk_classic::mesh::Entity& entity, unsigned *stride) - { - EXCEPTWATCH; - // this "rank" is not the same as the entity_rank, it is the "rank" of the data in the field, 0 for scalar, 1 for vector, 2 for tensor, etc - unsigned rank = field->rank(); - double * fdata = 0; - - if(stride) { - const stk_classic::mesh::FieldBase::Restriction & r = - field->restriction(entity.entity_rank(), stk_classic::mesh::fem::FEMMetaData::get(*field).universal_part()); - static const stk_classic::mesh::FieldBase::Restriction empty ; - - if (r == empty) - { - unsigned nfr = field->restrictions().size(); - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - //unsigned field_rank = fr.entity_rank(); - unsigned field_dimension = fr.dimension() ; - if (field_dimension > 0) - { - *stride = field_dimension; - } - if(rank <= 1){ - if (field_dimension > 0) - { - *stride = field_dimension; - } - } - else - *stride = fr.stride(rank - 1); - } - } - else - { - if(rank == 0) - *stride = r.dimension() ; - else - *stride = r.stride(rank - 1); - } - } - - switch(rank) - { - case 0: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , entity ); - } - break; - case 1: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , entity ); - } - break; - case 2: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , entity ); - } - break; - case 3: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , entity ); - } - break; - default: - { - // error - std::ostringstream msg; - msg << "PerceptMesh::field_data unknown field rank = " << rank << "\n"; - throw new std::runtime_error(msg.str()); - } - } - return fdata; - } - - - // static - double * PerceptMesh:: - field_data(const stk_classic::mesh::FieldBase *field, const stk_classic::mesh::Bucket & bucket, unsigned *stride) - { - EXCEPTWATCH; - unsigned rank = field->rank(); - double * fdata = 0; - - - if(stride) { - const stk_classic::mesh::FieldBase::Restriction & r = - field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, stk_classic::mesh::fem::FEMMetaData::get(*field).universal_part()); - if(rank == 0) - *stride = r.dimension() ; - else - *stride = r.stride(rank - 1); - } - - switch(rank) - { - case 0: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - } - break; - case 1: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - } - break; - case 2: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - } - break; - case 3: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - } - break; - default: - { - // error - std::ostringstream msg; - msg << "PerceptMesh::field_data unknown field rank = " << rank << "\n"; - throw new std::runtime_error(msg.str()); - } - } - return fdata; - } - - double * PerceptMesh:: - node_field_data(stk_classic::mesh::FieldBase *field, const stk_classic::mesh::EntityId node_id) - { - EXCEPTWATCH; - checkState("node_field_data"); - //field_data( const_cast(field), get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, node_id); - return field_data( field, *(get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, node_id) ) ); - } - -#if 0 - stk_classic::mesh::FieldBase* PerceptMesh::get_field(const std::string& name, const unsigned entity_rank, - const std::vector& dimensions, const stk_classic::mesh::Part* arg_part) - { - stk_classic::mesh::FieldBase *field=0; - const stk_classic::mesh::Part* part = (arg_part ? arg_part : &m_metaData->universal_part()); - - switch(dimensions.size()) - { - case 0: - // scalar - { - ScalarFieldType & sfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( sfield , entity_rank , *part ); - field = &sfield; - } - break; - case 1: - // vector - { - VectorFieldType & vfield = m_metaData->declare_field(name); - stk_classic::mesh::put_field( vfield , entity_rank , *part, dimensions[0] ); - field = &vfield; - } - break; - default: - // error FIXME - { - std::ostringstream msg; - msg << "PerceptMesh::createField unknown field dimensions = " << dimensions.size() << "\n"; - throw new std::runtime_error(msg.str()); - } - break; - } - - // set this field to have an Ioss role of transient - stk_classic::io::set_field_role(*field, Ioss::Field::TRANSIENT); - - return field; - } -#endif -#if 0 - /// A "safe" array is returned (it's only safe if you compile Intrepid with HAVE_INTREPID_DEBUG) - /// where "safe" means that indices are checked for being in bounds. - void PerceptMesh::field_data_safe(stk_classic::mesh::FieldBase *field, stk_classic::mesh::Bucket & bucket, unsigned *stride, MDArray& mda) - { - unsigned rank = field->rank(); - double * fdata = 0; - - if(stride) { - const stk_classic::mesh::FieldBase::Restriction & r = field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, stk_classic::mesh::fem::FEMMetaData::get(*field).universal_part()); - *stride = r.dimension() ; - } - - switch(rank) - { - case 0: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - Teuchos::Array dims(1); - dims(0) = bucket.size(); - MDArray md(dims, fdata); - return md; - } - break; - case 1: - { - fdata = stk_classic::mesh::field_data( *static_cast(field) , bucket.begin() ); - } - break; - default: - { - // error - std::ostringstream msg; - msg << "PerceptMesh::field_data unknown field rank = " << rank << "\n"; - throw new std::runtime_error(msg.str()); - } - } - return fdata; - } -#endif - - - void PerceptMesh::readModel( const std::string& in_filename ) - { - EXCEPTWATCH; - //checkState("readModel"); - read_metaDataNoCommit(in_filename); - commit_metaData(); - readBulkData(); - } - - - stk_classic::mesh::Entity *PerceptMesh::get_node(double x, double y, double z, double t) - { - double sum_min_local = 0.0; - stk_classic::mesh::Entity *node = get_closest_node(x,y,z,t, &sum_min_local); - if (get_parallel_size() == 1) return node; - - double sum_min_global = sum_min_local; - stk_classic::all_reduce( get_bulk_data()->parallel() , ReduceMin<1>( & sum_min_global ) ); - if (sum_min_local == sum_min_global) - return node; - else - return 0; - } - - /// find node closest to given point - stk_classic::mesh::Entity *PerceptMesh::get_closest_node(double x, double y, double z, double t, double *sum_min_ret) - { - stk_classic::mesh::FieldBase &coord_field = *get_coordinates_field(); - double sum_min = std::numeric_limits::max(); - stk_classic::mesh::Entity *node_min = 0; - - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& node = bucket[iElement]; - double * node_coord_data = (double*)stk_classic::mesh::field_data( coord_field , node); - //for (int ii=0; ii < get_spatial_dim(); ii++) - double sum=0.0; - sum += square(node_coord_data[0] - x); - sum += square(node_coord_data[1] - y); - if(get_spatial_dim() == 3) - { - sum += square(node_coord_data[2] - z); - } - if (sum < sum_min) - { - sum_min = sum; - node_min = &node; - } - } - } - } - if (sum_min_ret) *sum_min_ret = std::sqrt(sum_min); - return node_min; - } - - /// find element that contains or is closest to given point - stk_classic::mesh::Entity *PerceptMesh::get_element(double x, double y, double z, double t) - { - if (!m_searcher) - { - FieldFunction::SearchType m_searchType = FieldFunction::SIMPLE_SEARCH; - switch (m_searchType) - { - case FieldFunction::SIMPLE_SEARCH: - m_searcher = new SimpleSearcher(m_bulkData); - break; - case FieldFunction::STK_SEARCH: - { - //int spDim = last_dimension(input_phy_points); - if (get_spatial_dim() == 3) - m_searcher = new STKSearcher<3>(m_bulkData); - else - { - //m_searcher = new STKSearcher<2>(this); - throw std::runtime_error("STK_SEARCH not ready for 2D, use SIMPLE_SEARCH"); - } - } - break; - default: - throw std::runtime_error("FieldFunction::operator() unknown search type"); - break; - } - //std::cout << "setupSearch..." << std::endl; - m_searcher->setupSearch(); - //std::cout << "setupSearch...done" << std::endl; - } - - static MDArray input_phy_points_one(1,get_spatial_dim()); - static MDArray output_field_values_one(1,get_spatial_dim()); - static MDArray found_parametric_coordinates_one(1, get_spatial_dim()); - input_phy_points_one(0,0) = x; - input_phy_points_one(0,1) = y; - if (get_spatial_dim()==3) input_phy_points_one(0,2) = z; - - unsigned found_it = 0; - const stk_classic::mesh::Entity *found_element = 0; - stk_classic::mesh::Entity *m_cachedElement = 0; - { - EXCEPTWATCH; - //if (m_searchType==STK_SEARCH) std::cout << "find" << std::endl; - found_element = m_searcher->findElement(input_phy_points_one, found_parametric_coordinates_one, found_it, m_cachedElement); - //if (m_searchType==STK_SEARCH) std::cout << "find..done found_it=" << found_it << std::endl; - } - - // if found element on the local owned part, evaluate - if (found_it) - { - return const_cast(found_element); - } - - return 0; - } - - template - static void checkOmit(const std::vector& collection, std::string omit_part) - { - //typedef const typename std::vector Collection; - typename std::vector::const_iterator iter; - for (iter = collection.begin(); iter != collection.end(); iter++) - { - Ioss::GroupingEntity *entity = *iter; - if (entity != NULL && entity->name().find(omit_part) != std::string::npos) - { - std::cout << "tmp srk checkOmit found for entity = " << entity->name() << std::endl; - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - } - } - } - - static void checkForPartsToAvoidReading(Ioss::Region& in_region, std::string omit_part) - { - checkOmit(in_region.get_node_blocks(), omit_part ) ; /*const NodeBlockContainer& */ - checkOmit(in_region.get_edge_blocks(), omit_part ) ; /*const EdgeBlockContainer& */ - checkOmit(in_region.get_face_blocks(), omit_part ) ; /*const FaceBlockContainer& */ - checkOmit(in_region.get_element_blocks(), omit_part ) ; /*const ElementBlockContainer& g*/ - checkOmit(in_region.get_sidesets(), omit_part ) ; /*const SideSetContainer& */ - checkOmit(in_region.get_nodesets(), omit_part ) ; /*const NodeSetContainer& */ - checkOmit(in_region.get_edgesets(), omit_part ) ; /*const EdgeSetContainer& */ - checkOmit(in_region.get_facesets(), omit_part ) ; /*const FaceSetContainer& */ - checkOmit(in_region.get_elementsets(), omit_part ) ; /*const ElementSetContainer& */ - //checkOmit(in_region. get_commsets(), omit_part ) ; /*const CommSetContainer& */ - } - - // ======================================================================== - static void setup_spatialDim_metaData(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta, int& spatial_dim) - { - size_t spatial_dimension = region.get_property("spatial_dimension").get_int(); - spatial_dim = spatial_dimension; - - if (!meta.is_FEM_initialized()) - { - std::vector entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim); -#if PERCEPT_USE_FAMILY_TREE - entity_rank_names.push_back("FAMILY_TREE"); -#endif -#if PERCEPT_USE_PSEUDO_ELEMENTS - entity_rank_names.push_back("PSEUDO_ELEMENT"); -#endif - meta.FEM_initialize(spatial_dim, entity_rank_names); - } - - //s_spatial_dim = spatial_dim; - //std::cout << "PerceptMesh::setup_spatialDim_metaData: spatial_dim= " << spatial_dim << std::endl; - -#if 0 - stk_classic::mesh::Field & coord_field = - meta.declare_field >("coordinates"); - - stk_classic::mesh::put_field( coord_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta.universal_part(), - spatial_dim); - - /** \todo IMPLEMENT truly handle fields... For this case we are - * just defining a field for each transient field that is present - * in the mesh... - */ - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK); -#endif - } - - void PerceptMesh::read_metaDataNoCommit( const std::string& in_filename) - { - EXCEPTWATCH; - //checkState("read_metaDataNoCommit"); - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - // std::cout << "========================================================================\n" - // << " Use Case: Subsetting with df and attribute field input/output \n" - // << "========================================================================\n"; - - //const stk_classic::ParallelMachine& comm = m_bulkData->parallel(); - const stk_classic::ParallelMachine& comm = m_comm; - - std::string dbtype("exodusII"); - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(dbtype, in_filename, Ioss::READ_MODEL, comm); - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << in_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - //m_iossRegion = Teuchos::rcp( new Ioss::Region(dbi, "input_model") ); - m_iossRegion = new Ioss::Region(dbi, "input_model"); - Ioss::Region& in_region = *m_iossRegion; - - checkForPartsToAvoidReading(in_region, s_omit_part); - - //---------------------------------- - // Process Entity Types. Subsetting is possible. - //stk_classic::mesh::fem::FEMMetaData meta_data( stk_classic::percept::PerceptMesh::fem_entity_rank_names() ); - //stk_classic::mesh::fem::FEMMetaData& meta_data = *m_metaData; - //std::cout << "tmp1.0 m_fem_meta_data = " << m_fem_meta_data << std::endl; - - stk_classic::mesh::fem::FEMMetaData& meta_data = *m_metaData; - // std::cout << "tmp1 m_metaData->is_commit() = " << m_metaData->is_commit() << std::endl; - - bool meta_is_init = meta_data.is_FEM_initialized(); - setup_spatialDim_metaData(in_region, meta_data, m_spatialDim); - if (!meta_is_init) - { - m_bulkData = new stk_classic::mesh::BulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(*m_metaData) , m_comm ); - } - if (0) - { - const size_t ntype = stk_classic::mesh::MetaData::get(*m_bulkData).entity_rank_count(); - const size_t ntype1 = stk_classic::mesh::fem::FEMMetaData::get(*m_bulkData).entity_rank_count(); - std::cout << "tmp SRK m_spatialDim= " << m_spatialDim << " ntype= " << ntype << " ntype1= " << ntype1 << std::endl; - } - - // Open, read, filter meta data from the input mesh file: - // The coordinates field will be set to the correct dimension. - - m_iossMeshData = Teuchos::rcp( new stk_classic::io::MeshData() ); - m_iossMeshData_created = true; - stk_classic::io::MeshData& mesh_data = *m_iossMeshData; - mesh_data.m_input_region = m_iossRegion; - stk_classic::io::create_input_mesh(dbtype, in_filename, comm, meta_data, mesh_data); - - stk_classic::io::define_input_fields(mesh_data, meta_data); - - - } - - void PerceptMesh::create_metaDataNoCommit( const std::string& gmesh_spec) - { - EXCEPTWATCH; - m_fixture = new stk_classic::io::util::Gmesh_STKmesh_Fixture(MPI_COMM_WORLD, gmesh_spec); - - if (m_metaData) - delete m_metaData; - if (m_bulkData) - delete m_bulkData; - - m_metaData = &m_fixture->getFEMMetaData(); - m_bulkData = &m_fixture->getBulkData(); - m_ownData = false; - } - - void PerceptMesh::commit_metaData() - { - if (m_fixture) - m_fixture->commit(); - else - m_metaData->commit(); - } - - void PerceptMesh::readBulkData() - { -#if 1 - //std::cout << "PerceptMesh::readBulkData() " << std::endl; - if (m_fixture || m_isAdopted) - { - //std::cout << "PerceptMesh::readBulkData() m_fixture " << std::endl; - return; - } - - int step = 1; - - if (get_database_time_step_count() == 0) - step = 0; - - read_database_at_step(step); -#else - //std::cout << "PerceptMesh::readBulkData() " << std::endl; - if (m_fixture || m_isAdopted) - { - //std::cout << "PerceptMesh::readBulkData() m_fixture " << std::endl; - return; - } - - Ioss::Region& in_region = *m_iossRegion; - //---------------------------------- - // Process Bulkdata for all Entity Types. Subsetting is possible. - //stk_classic::mesh::BulkData bulk_data(meta_data, comm); - stk_classic::mesh::BulkData& bulk_data = *m_bulkData; - - // Read the model (topology, coordinates, attributes, etc) - // from the mesh-file into the mesh bulk data. - stk_classic::io::MeshData& mesh_data = *m_iossMeshData; - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - int timestep_count = in_region.get_property("state_count").get_int(); - ///std::cout << "tmp timestep_count= " << timestep_count << std::endl; - //Util::pause(true, "tmp timestep_count"); - - // FIXME - if (timestep_count == 0) - stk_classic::io::process_input_request(mesh_data, bulk_data, 0); - else - stk_classic::io::process_input_request(mesh_data, bulk_data, 1); - -#endif - } - - int PerceptMesh::get_current_database_step() - { - return m_exodusStep; - } - double PerceptMesh::get_current_database_time() - { - return m_exodusTime; - } - - int PerceptMesh::get_database_time_step_count() - { - Ioss::Region * region = m_iossRegion; - int timestep_count = region->get_property("state_count").get_int(); - return timestep_count; - } - - double PerceptMesh::get_database_time_at_step(int step) - { - Ioss::Region * region = m_iossRegion; - int timestep_count = region->get_property("state_count").get_int(); - //std::cout << "tmp timestep_count= " << timestep_count << std::endl; - //Util::pause(true, "tmp timestep_count"); - - if ((timestep_count > 0 && step <= 0) || (step > timestep_count)) - { - throw std::runtime_error("step is out of range for PerceptMesh::get_database_time_at_step, step="+toString(step)+" timestep_count= "+toString(timestep_count)); - } - - double state_time = timestep_count > 0 ? region->get_state_time(step) : 0.0; - return state_time; - } - - int PerceptMesh::get_database_step_at_time(double time) - { - Ioss::Region * region = m_iossRegion; - int step_count = region->get_property("state_count").get_int(); - double delta_min = 1.0e30; - int step_min = 0; - for (int istep = 0; istep < step_count; istep++) { - double state_time = region->get_state_time(istep+1); - double delta = state_time - time; - if (delta < 0.0) delta = -delta; - if (delta < delta_min) { - delta_min = delta; - step_min = istep; - if (delta == 0.0) break; - } - } - return step_min+1; - } - - void PerceptMesh::read_database_at_step(int step) - { - EXCEPTWATCH; - std::cout << "PerceptMesh::read_database_at_step() " << std::endl; - if (m_fixture || m_isAdopted) - { - std::cout << "PerceptMesh::read_database_at_step() m_fixture " << std::endl; - return; - } - - Ioss::Region& in_region = *m_iossRegion; - //---------------------------------- - // Process Bulkdata for all Entity Types. Subsetting is possible. - //stk_classic::mesh::BulkData bulk_data(meta_data, comm); - stk_classic::mesh::BulkData& bulk_data = *m_bulkData; - - // Read the model (topology, coordinates, attributes, etc) - // from the mesh-file into the mesh bulk data. - stk_classic::io::MeshData& mesh_data = *m_iossMeshData; - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - int timestep_count = in_region.get_property("state_count").get_int(); - //std::cout << "tmp timestep_count= " << timestep_count << std::endl; - //Util::pause(true, "tmp timestep_count"); - - if ((timestep_count > 0 && step <= 0) || (step > timestep_count)) - { - std::cout << "step is out of range for PerceptMesh::read_database_at_step, step="+toString(step)+" timestep_count= "+toString(timestep_count) << std::endl; - throw std::runtime_error("step is out of range for PerceptMesh::read_database_at_step, step="+toString(step)+" timestep_count= "+toString(timestep_count)); - } - // FIXME - m_exodusStep = step; - m_exodusTime = get_database_time_at_step(step); - stk_classic::io::process_input_request(mesh_data, bulk_data, step); - } - - void PerceptMesh::read_database_at_time(double time) - { - std::cout << "PerceptMesh::read_database_at_time() " << std::endl; - if (m_fixture || m_isAdopted) - { - std::cout << "PerceptMesh::read_database_at_time() m_fixture " << std::endl; - return; - } - - int step = get_database_step_at_time(time); - - // Exodus steps are 1-based; - read_database_at_step(step); - } - - /// transform mesh by a given 3x3 matrix - void PerceptMesh::transform_mesh(MDArray& matrix) - { - if (matrix.rank() != 2) throw std::runtime_error("pass in a 3x3 matrix"); - if (matrix.dimension(0) != 3 || matrix.dimension(1) != 3) throw std::runtime_error("pass in a 3x3 matrix"); - Math::Matrix mat; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - { - mat(i,j) = matrix(i,j); - } - transform_mesh(mat); - } - - //======================================================================================================================== - /// transform mesh by a given 3x3 matrix - void PerceptMesh::transform_mesh(Math::Matrix& matrix) - { - MeshTransformer xform(matrix); - nodalOpLoop(xform, get_coordinates_field()); - } - - /// Convenience method to read a model's meta data, create some new fields, commit meta data then read the bulk data - void PerceptMesh::readModelAndCreateOptionalFields(const std::string file, bool print, FieldCreateOrderVec create_field) - { - /// read a mesh file's meta data but don't commit the meta data - if (print) std::cout << "PerceptMesh::readModelCreateOptionalFields reading file = " << file << std::endl; - read_metaDataNoCommit(file); - - createFields(print, create_field); - - commit_metaData(); - readBulkData(); - } - - //// after the meta data is read or created, create some fields using this method - void PerceptMesh::createFields(bool print, FieldCreateOrderVec create_field) - { - checkStateSpec("createFields", m_isOpen); - - /// create a meta data/bulk data empty pair - stk_classic::mesh::fem::FEMMetaData& metaData = *get_fem_meta_data(); - - /// access to the parts existing in the mesh - if (print) - { - const stk_classic::mesh::PartVector & parts = metaData.get_parts(); - unsigned nparts = parts.size(); - if (print) std::cout << "PerceptMesh::readModelCreateOptionalFields: Number of metaData parts = " << nparts << std::endl; - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - if (print) std::cout << "PerceptMesh::readModelCreateOptionalFields: part = " << part.name() - << " primary_entity_rank= " << part.primary_entity_rank() - << " mesh_meta_data_ordinal= " << part.mesh_meta_data_ordinal() << " supersets= " << part.supersets().size() - << " subsets= " << part.subsets().size() << std::endl; - } - } - /// here's where we can add parts, fields, etc., before commit - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field if needed - //stk_classic::mesh::FieldBase *f_coords = metaData.get_field("coordinates"); - //if (print) std::cout << "coordinates field name = "<< f_coords->name() << std::endl; - - /// create a new field to contain the magnitude of the coordinates field - - /// it is a scalar field, so we pass in dimensions of length 0 - if (create_field.size()) - { - for (unsigned icf = 0; icf < create_field.size(); icf++) - { - createField(create_field[icf].m_name, create_field[icf].m_entity_rank, create_field[icf].m_dimensions, - create_field[icf].m_part); - } - } - } - -#if 0 - /// now we have created all fields we need, we can commit the meta data and actually read the bulk data - - commit_metaData(); - readBulkData(); - - if (print) - { - const stk_classic::mesh::FieldVector & fields = metaData.get_fields(); - unsigned nfields = fields.size(); - if (print) std::cout << "PerceptMesh::readModelCreateOptionalFields:: nfields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - if (print) std::cout << "PerceptMesh::readModelCreateOptionalFields:: Field[" << ifld << "]= " << field->name() - << " rank= " << field->rank() << std::endl; - } - } -#endif - - -#if 0 - return NULL != part.attribute(); - - void PerceptMesh::setOmitted(Ioss::Region& out_region) - { - - // Filter out all non-hex8 element blocks... - if (hex_only) { - const Ioss::ElementBlockContainer& elem_blocks = in_region->get_element_blocks(); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - std::string name = entity->topology()->name(); - if (name != "hex8") { - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - } - } - } - - } -#endif - -#if DEPRECATED - static void omit_entity(Ioss::GroupingEntity *entity) - { - //std::string topo_name = entity->topology()->name(); - std::string name = entity->name(); - // if (topo_name == "hex8") { - // entity->property_add(Ioss::Property(std::string("omitted"), 1)); - // } - // FIXME - this is a bit of a hack until we can have a design review with Greg Sjaardema - if (name.find(PerceptMesh::s_omit_part) != std::string::npos) - { - std::cout << "tmp srk omit_entity found it " << name << std::endl; - exit(1); - if ( entity->property_exists(std::string("omitted") ) ) - { - entity->property_erase(std::string("omitted")); - } - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - } - else - { - } - if (0 && entity->property_exists(std::string("omitted") ) ) - { - int iprop = entity->get_property(std::string("omitted")).get_int(); - std::cout << "tmp iprop= " << iprop << std::endl; - } - } - - void omitted_output_db_processing(Ioss::Region& out_region) - { - // FIXME - //if (1) return; - - const Ioss::ElementBlockContainer& elem_blocks = out_region.get_element_blocks(); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - omit_entity(entity); - } - - const Ioss::NodeSetContainer& node_sets = out_region.get_nodesets(); - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - omit_entity(*it); - } - - //---------------------------------- - { - const Ioss::SideSetContainer& side_sets = out_region.get_sidesets(); - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - - Ioss::SideSet* ef_set = *it; - - size_t block_count = ef_set->block_count(); - for (size_t i=0; i < block_count; i++) { - Ioss::EntityBlock *block = ef_set->get_block(i); - omit_entity(block); - } - - omit_entity(*it); - } - } - - } -#endif - - void PerceptMesh::checkForPartsToAvoidWriting() - { - const stk_classic::mesh::PartVector * parts = &get_fem_meta_data()->get_parts(); - unsigned nparts = parts->size(); - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *((*parts)[ipart]); - std::string name = part.name(); - //std::cout << "tmp srk checkForPartsToAvoidWriting found part= " << name << " s_omit_part= " << s_omit_part << std::endl; - if (name.find(PerceptMesh::s_omit_part) != std::string::npos) - { - //if (!get_rank()) std::cout << "tmp srk checkForPartsToAvoidWriting found omitted part= " << name << std::endl; - const Ioss::GroupingEntity *entity = part.attribute(); - if (entity) - stk_classic::io::remove_io_part_attribute(part); - else if (!get_rank()) - { - //std::cout << "tmp srk checkForPartsToAvoidWriting found part to omit but it's not a real part, part= " << name << std::endl; - } - - } - } - - parts = &get_io_omitted_parts(); - nparts = parts->size(); - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *((*parts)[ipart]); - std::string name = part.name(); - //std::cout << "tmp srk checkForPartsToAvoidWriting found part from get_io_omitted_parts() = " << name << " s_omit_part= " << s_omit_part << std::endl; - { - //std::cout << "tmp srk checkForPartsToAvoidWriting found part from get_io_omitted_parts() omitted part= " << name << std::endl; - const Ioss::GroupingEntity *entity = part.attribute(); - if (entity) - stk_classic::io::remove_io_part_attribute(part); - else if (!get_rank()) - { - //std::cout << "tmp srk checkForPartsToAvoidWriting found part to omit from get_io_omitted_parts() but it's not a real part, part= " << name << std::endl; - } - - } - } - } - - - static bool decipher_filename(std::string filename_in, int& my_processor, int& processor_count) - { - const bool debug=false; - std::string filename = filename_in; - std::cout << "tmp srk PerceptMesh::decipher_filename in: filename= " << filename - << " processor_count= " << processor_count << " my_processor= " << my_processor << std::endl; - - size_t found_dot = filename.find_last_of("."); - if (found_dot == std::string::npos) - { - std::cout << "warning: filename has no .procs.myproc extensions: " << std::endl; - return false; - } - std::string my_proc = filename.substr(found_dot+1); - if (debug) std::cout << "tmp srk PerceptMesh::decipher_filename: my_proc extension before zero strip= " << my_proc << std::endl; - // strip leading 0's - if (my_proc.length() > 1) - { - size_t found_z = my_proc.find_last_of("0"); - if (found_z != std::string::npos && found_z < my_proc.length()-1) - my_proc = my_proc.substr(found_z+1); - } - if (debug) std::cout << "tmp srk PerceptMesh::decipher_filename: my_proc extension= " << my_proc << std::endl; - my_processor = boost::lexical_cast(my_proc); - filename = filename.substr(0,found_dot); - found_dot = filename.find_last_of("."); - processor_count = boost::lexical_cast(filename.substr(found_dot+1)); - if (debug) - std::cout << "tmp srk PerceptMesh::decipher_filename: filename= " << filename_in - << " processor_count= " << processor_count << " my_processor= " << my_processor << std::endl; - return true; - } - - static void percept_create_output_mesh(const std::string &filename, - stk_classic::ParallelMachine comm, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::io::MeshData &mesh_data) - { - Ioss::Region *out_region = NULL; - - std::string out_filename = filename; - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create("exodusII", out_filename, - Ioss::WRITE_RESULTS, - comm); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type 'exodusII'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - out_region = new Ioss::Region(dbo, "results_output"); - - int my_processor = 0; - int processor_count = 0; - - if (!decipher_filename(filename, my_processor, processor_count)) - { - throw std::runtime_error("bad filename passed to percept_create_output_mesh= "+filename); - } - std::cout << "tmp srk PerceptMesh::percept_create_output_mesh: filename= " << filename - << " processor_count= " << processor_count << " my_processor= " << my_processor << std::endl; - - out_region->property_add(Ioss::Property("processor_count", processor_count)); - out_region->property_add(Ioss::Property("my_processor", my_processor)); - - bool sort_stk_parts = true; - stk_classic::io::define_output_db(*out_region, bulk_data, mesh_data.m_input_region, mesh_data.m_anded_selector, sort_stk_parts); - stk_classic::io::write_output_db(*out_region, bulk_data, mesh_data.m_anded_selector); - mesh_data.m_output_region = out_region; - } - - void PerceptMesh::writeModel( const std::string& out_filename) - { - const unsigned p_rank = parallel_machine_rank( get_bulk_data()->parallel() ); - const unsigned p_size = parallel_machine_size( get_bulk_data()->parallel() ); - - if (p_rank == 0) std::cout << "PerceptMesh:: saving "<< out_filename << std::endl; - - //std::cout << "tmp dump_elements PerceptMesh::writeModel: " << out_filename << std::endl; - //dump_elements(); - - checkForPartsToAvoidWriting(); - - //checkState("writeModel" ); - stk_classic::mesh::fem::FEMMetaData& meta_data = *m_metaData; - stk_classic::mesh::BulkData& bulk_data = *m_bulkData; - - //---------------------------------- - // OUTPUT...Create the output "mesh" portion - Ioss::Init::Initializer init_db; - - std::string dbtype("exodusII"); - - const stk_classic::ParallelMachine& comm = m_bulkData->parallel(); - stk_classic::io::MeshData mesh_data_0; - stk_classic::io::MeshData& mesh_data = (m_iossMeshData_created && m_sync_io_regions ) ? *m_iossMeshData : mesh_data_0; - - //std::cout << "tmp srk out_filename= " << out_filename << " m_streaming_size= " << m_streaming_size << std::endl; - if (p_size == 1 && m_streaming_size) - percept_create_output_mesh(out_filename, comm, bulk_data, mesh_data); - else - stk_classic::io::create_output_mesh(out_filename, comm, bulk_data, mesh_data); - - stk_classic::io::define_output_fields(mesh_data, meta_data, false); - - //deprecated omitted_output_db_processing(out_region); - - // Read and Write transient fields... - double time = 0.0; - stk_classic::io::process_output_request(mesh_data, bulk_data, time); - - if (mesh_data.m_input_region) mesh_data.m_input_region->get_database()->closeDatabase(); - if (mesh_data.m_output_region) mesh_data.m_output_region->get_database()->closeDatabase(); - if (p_rank == 0) std::cout << "PerceptMesh:: saving "<< out_filename << " ... done" << std::endl; - } - - - /** \brief Read in the model given by \param file and print some info about the file to stdout */ - void PerceptMesh::dump(const std::string& file) - { - //checkState("dump"); - - std::cout << "PerceptMesh::dump: for file = " << file << std::endl; - - PerceptMesh eMeshS(3); // FIXME - //PerceptMesh *eMesh = & eMeshS; - PerceptMesh *eMesh = file.length() > 0 ? &eMeshS : this; - if (file.length() > 0) - eMesh->readModel(file); - - stk_classic::mesh::fem::FEMMetaData& metaData = *eMesh->get_fem_meta_data(); - //BulkData& bulkData = *eMesh.get_bulk_data(); - - const stk_classic::mesh::PartVector & parts = metaData.get_parts(); - - unsigned nparts = parts.size(); - std::cout << "PerceptMesh::dump: Number of parts = " << nparts << std::endl; - - const stk_classic::mesh::FieldVector & fields = metaData.get_fields(); - unsigned nfields = fields.size(); - std::cout << "PerceptMesh::dump: Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - std::cout << "PerceptMesh::dump: Field[" << ifld << "]= " << field->name() << " rank= " << field->rank() << std::endl; - //std::cout << *field << std::endl; - unsigned nfr = field->restrictions().size(); - std::cout << "PerceptMesh::dump: number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - stk_classic::mesh::Part& frpart = metaData.get_part(fr.part_ordinal()); - std::cout << "PerceptMesh::dump: field restriction " << ifr << " stride[0] = " << fr.dimension() << " type= " << fr.entity_rank() << " ord= " << fr.part_ordinal() << - " which corresponds to Part= " << frpart.name() << std::endl; - } - } - - } - - void PerceptMesh:: - dump_elements(const std::string& partName) - { - const stk_classic::mesh::PartVector & parts = get_fem_meta_data()->get_parts(); - unsigned nparts = parts.size(); - - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - stk_classic::mesh::Selector selector(part); - - // is_auto_declared_part - //if (part.name()[0] == '{' || (part.name().find("oldElem") != std::string::npos) ) - if (stk_classic::mesh::is_auto_declared_part(part) || (part.name().find("oldElem") != std::string::npos) ) - continue; - - if (partName.size() > 0 && part.name() != partName) - continue; - - for (unsigned irank=1; irank < element_rank(); irank++) - { - std::cout << "tmp PerceptMesh::dump_elements: part = " << part.name() << " rank= " << irank << std::endl; - - const std::vector & buckets = get_bulk_data()->buckets( irank ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - std::cout << "tmp element: " << element << std::endl; - print_entity(std::cout, element, get_coordinates_field() ); - } - } - } - } - } - } - - void PerceptMesh:: - dump_elements_compact(const std::string& partName) - { - MPI_Barrier( get_bulk_data()->parallel() ); - stk_classic::mesh::Selector selector; - if (partName.size() > 0) - { - stk_classic::mesh::Part *part = get_non_const_part(partName); - if (part) - selector = stk_classic::mesh::Selector(*part); - } - - for (unsigned irank = 0u; irank < get_parallel_size(); irank++) - { - if (get_rank() == irank) - { - std::ostringstream out; - out << "\nP[" << get_rank() << "]= \n"; - - for (unsigned jrank = 0; jrank < 2u; jrank++) - { - const std::vector & buckets = get_bulk_data()->buckets( element_rank() + jrank ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - stk_classic::mesh::Bucket & bucket = **k ; - if (selector(bucket)) - { - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - out << print_entity_compact( element ) << "\n"; - } - } - } - } - std::cout << out.str() << std::endl; - } - MPI_Barrier( get_bulk_data()->parallel() ); - } - } - - /** \brief Loop over all buckets and apply \param bucketOp passing in the argument \param field to \param bucketOp */ - void PerceptMesh::bucketOpLoop(BucketOp& bucketOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Part *part) - { - EXCEPTWATCH; - - if (part) - { - stk_classic::mesh::Selector selector(*part); - bucketOpLoop(bucketOp, field, &selector); - } - else - { - bucketOpLoop(bucketOp, field, (stk_classic::mesh::Selector *)0); - } - } - - void PerceptMesh::bucketOpLoop(BucketOp& bucketOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Selector *selector, bool is_surface_norm) - { - EXCEPTWATCH; - //checkState("bucketOpLoop"); - - //mesh::fem::FEMMetaData& metaData = *m_metaData; - stk_classic::mesh::BulkData& bulkData = *m_bulkData; - - // FIXME consider caching the coords_field in FieldFunction - //VectorFieldType *coords_field = metaData.get_field("coordinates"); - - stk_classic::mesh::EntityRank rank= element_rank(); - if (is_surface_norm) rank = rank - 1; - const std::vector & buckets = bulkData.buckets( rank ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (!selector || (*selector)(**k)) // this is where we do part selection - { - const stk_classic::mesh::Bucket & bucket = **k ; - bool breakLoop = bucketOp(bucket, field, bulkData); - - if (breakLoop) - { - return; - } - } - } - } - - /** \brief Loop over all elements and apply \param elementOp passing in the argument \param field to \param elementOp */ - void PerceptMesh::elementOpLoop(ElementOp& elementOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Part *part) - { - EXCEPTWATCH; - - if (part) - { - stk_classic::mesh::Selector selector(*part); - elementOpLoop(elementOp, field, &selector); - } - else - { - elementOpLoop(elementOp, field, (stk_classic::mesh::Selector *)0); - } - } - - /** \brief Loop over all elements and apply \param elementOp passing in the argument \param field to \param elementOp */ - void PerceptMesh::elementOpLoop(ElementOp& elementOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Selector *selector, bool is_surface_norm) - { - EXCEPTWATCH; - //checkState("elementOpLoop"); - elementOp.init_elementOp(); - - //mesh::fem::FEMMetaData& metaData = *m_metaData; - stk_classic::mesh::BulkData& bulkData = *m_bulkData; - - // FIXME consider caching the coords_field in FieldFunction - //VectorFieldType *coords_field = metaData.get_field("coordinates"); - stk_classic::mesh::EntityRank rank = element_rank(); - if (is_surface_norm) rank = rank - 1; - - const std::vector & buckets = bulkData.buckets( rank ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (!selector || (*selector)(**k)) // this is where we do part selection - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - // FIXME for multiple points - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - bool breakLoop = elementOp(element, field, bulkData); - //std::cout << "PerceptMesh::elementOpLoop breakLoop= " << breakLoop << std::endl; - if (breakLoop) - { - elementOp.fini_elementOp(); - return; - } - - } - - } - } - elementOp.fini_elementOp(); - } - - void PerceptMesh::nodalOpLoop(GenericFunction& nodalOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Selector* selector) - { - EXCEPTWATCH; - //checkState("nodalOpLoop"); - - stk_classic::mesh::BulkData& bulkData = *m_bulkData; - - VectorFieldType *coords_field = get_coordinates_field(); - - // for each node in the codomain, evaluate the function_to_interpolate's function, assign to the codomain field - - const std::vector & buckets = bulkData.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - int num_nodes = 0; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (!selector || (*selector)(**k)) // this is where we do part selection - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - unsigned spatialDim = 0; - //double * coord = stk_classic::mesh::field_data( *coords_field , bucket.begin() ); - double * coord = PerceptMesh::field_data( coords_field , bucket, &spatialDim ); - //if (Util::getFlag(9829)) std::cout << "spatialDim= " << spatialDim << std::endl; - - unsigned stride = 0; - double * output_nodal_field = (field ? PerceptMesh::field_data( field , bucket, &stride) : 0); - if (!field) stride = (nodalOp.getCodomainDimensions().size() ? nodalOp.getCodomainDimensions()[0] : 0); - - //int inDim = nodalOp.getDomainDimensions()[0]; - //int outDim = nodalOp.getCodomainDimensions()[0]; - int inDim = m_metaData->spatial_dimension(); - - num_nodes += num_nodes_in_bucket; - // FIXME for multiple points - for (unsigned inode = 0; inode < num_nodes_in_bucket; inode++) - { - MDArray pt(inDim); // FIXME for spatialDim - for (int iSpace = 0; iSpace < inDim; iSpace++) - { - pt(iSpace) = coord[iSpace]; - } - MDArray out(stride); - - // an optional setting of the codomain from existing values (allows for +=, etc.) - // if(set_output) { - if (field) - { - for (unsigned jout = 0; jout < stride; jout++) - { - out(jout) = output_nodal_field[jout]; - //if (Util::getFlag(9829)) std::cout << "bef jout= " << jout << " val= " << out(jout) << std::endl; - } - } - - //if (Util::getFlag(9829)) std::cout << "nodalOp= " << nodalOp << std::endl; - { - FieldFunction::m_parallelEval=false; - nodalOp(pt, out); - FieldFunction::m_parallelEval=true; - } - - if (field) - { - for (unsigned jout = 0; jout < stride; jout++) - { - //if (Util::getFlag(9829)) std::cout << "aft jout= " << jout << " val= " << out(jout) << std::endl; - output_nodal_field[jout] = out(jout); - } - } - - if (field) output_nodal_field += stride; // FIXME - coord += inDim; // FIXME - } - - } - } - - if (1) std::cout << "P[" << get_rank() << "] num_nodes= "<< num_nodes << std::endl; - - } - - PerceptMesh::BasisTableMap PerceptMesh::m_basisTable; - void PerceptMesh::setupBasisTable() - { - /// from the Intrepid documentation, these are the only cell topologies currently supported for inverse mappings - /// see Intrepid::CellTools::mapToReferenceFrame documentation - /** - std::vector supportedTopologies; - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - supportedTopologies.push_back(shards::getCellTopologyData >() ); - */ - - - - - // FIXME - //#if !(defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND)) - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_LINE_C1_FEM() ); - //m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_LINE_C1_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C1_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C2_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C1_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C1_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C2_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TET_C1_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TET_C2_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_WEDGE_C1_FEM() ); - - // Intrepid doesn't support wedge 15 - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_WEDGE_C2_Serendipity_FEM() ); - - - // Shells - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C1_FEM() ); - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C2_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C1_FEM() ); - - m_basisTable[shards::getCellTopologyData >()-> key] = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM() ); - - //#endif - - // etc.... - - // FIXME - } - - // static - PerceptMesh::BasisTypeRCP PerceptMesh:: - getBasis(shards::CellTopology& topo) - { - unsigned key = topo.getKey(); - if (m_basisTable.size() == 0) - { - setupBasisTable(); - } - PerceptMesh::BasisTypeRCP basis = m_basisTable[key]; - - return basis; - } - - - - double PerceptMesh::edge_length_ave(const stk_classic::mesh::Entity &entity, mesh::FieldBase* coord_field_in ) - { - stk_classic::mesh::FieldBase &coord_field = (coord_field_in ? *coord_field_in : *get_coordinates_field()); - const CellTopologyData * const cell_topo_data = PerceptMesh::get_cell_topology(entity); - - shards::CellTopology cell_topo(cell_topo_data); - - unsigned spaceDim = cell_topo.getDimension(); - - const stk_classic::mesh::Entity & elem = entity; - const stk_classic::mesh::PairIterRelation elem_nodes = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - double edge_length_ave=0.0; - double min_edge_length = -1.0; - double max_edge_length = -1.0; - for (unsigned iedgeOrd = 0; iedgeOrd < cell_topo_data->edge_count; iedgeOrd++) - { - unsigned in0 = cell_topo_data->edge[iedgeOrd].node[0]; - unsigned in1 = cell_topo_data->edge[iedgeOrd].node[1]; - double * node_coord_data_0 = (double*)stk_classic::mesh::field_data( coord_field , *elem_nodes[in0].entity()); - double * node_coord_data_1 = (double*)stk_classic::mesh::field_data( coord_field , *elem_nodes[in1].entity()); - - double edge_length = 0.0; - for (unsigned iSpaceDimOrd = 0; iSpaceDimOrd < spaceDim; iSpaceDimOrd++) - { - edge_length += - (node_coord_data_0[iSpaceDimOrd]-node_coord_data_1[iSpaceDimOrd])* - (node_coord_data_0[iSpaceDimOrd]-node_coord_data_1[iSpaceDimOrd]); - } - edge_length = std::sqrt(edge_length); - edge_length_ave += edge_length / ((double)cell_topo_data->edge_count); - if(iedgeOrd == 0) - { - min_edge_length = edge_length; - max_edge_length = edge_length; - } - else - { - min_edge_length = std::min(min_edge_length, edge_length); - max_edge_length = std::max(max_edge_length, edge_length); - } - } - return edge_length_ave; - } - - // static - void PerceptMesh:: - findMinMaxEdgeLength(const stk_classic::mesh::Bucket &bucket, stk_classic::mesh::Field& coord_field, - Intrepid::FieldContainer& elem_min_edge_length, Intrepid::FieldContainer& elem_max_edge_length) - { - const CellTopologyData * const bucket_cell_topo_data = PerceptMesh::get_cell_topology(bucket); - - shards::CellTopology cell_topo(bucket_cell_topo_data); - unsigned number_elems = bucket.size(); - //unsigned numCells = number_elems; - //unsigned numNodes = cell_topo.getNodeCount(); - unsigned spaceDim = cell_topo.getDimension(); - - for ( unsigned iElemInBucketOrd = 0 ; iElemInBucketOrd < number_elems ; ++iElemInBucketOrd) - { - stk_classic::mesh::Entity & elem = bucket[iElemInBucketOrd] ; - if (0) std::cout << "elemOfBucket= " << elem << std::endl; - const stk_classic::mesh::PairIterRelation elem_nodes = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - //int shardsId = ShardsInterfaceTable::s_singleton.lookupShardsId(cell_topo->name); - - double min_edge_length = -1.0; - double max_edge_length = -1.0; - for (unsigned iedgeOrd = 0; iedgeOrd < bucket_cell_topo_data->edge_count; iedgeOrd++) - { - //const CellTopologyData_Subcell& edge = - - unsigned in0 = bucket_cell_topo_data->edge[iedgeOrd].node[0]; - unsigned in1 = bucket_cell_topo_data->edge[iedgeOrd].node[1]; - double * node_coord_data_0 = stk_classic::mesh::field_data( coord_field , *elem_nodes[in0].entity()); - double * node_coord_data_1 = stk_classic::mesh::field_data( coord_field , *elem_nodes[in1].entity()); - - //elem_nodes[in0].entity()->identifier(), elem_nodes[in1].entity()->identifier()); - double edge_length = 0.0; - for (unsigned iSpaceDimOrd = 0; iSpaceDimOrd < spaceDim; iSpaceDimOrd++) - { - edge_length += - (node_coord_data_0[iSpaceDimOrd]-node_coord_data_1[iSpaceDimOrd])* - (node_coord_data_0[iSpaceDimOrd]-node_coord_data_1[iSpaceDimOrd]); - } - edge_length = std::sqrt(edge_length); - //if(min_edge_length < 0) - if(iedgeOrd == 0) - { - min_edge_length = edge_length; - max_edge_length = edge_length; - } - else - { - min_edge_length = std::min(min_edge_length, edge_length); - max_edge_length = std::max(max_edge_length, edge_length); - } - } - elem_min_edge_length[iElemInBucketOrd] = min_edge_length; - elem_max_edge_length[iElemInBucketOrd] = max_edge_length; - } - } - - // copied and modified from TopologyHelpers element_side_polarity - void PerceptMesh:: - element_side_nodes( const stk_classic::mesh::Entity & elem , int local_side_id, stk_classic::mesh::EntityRank side_entity_rank, std::vector& side_node_entities ) - { - static const char method[] = "stk_classic::percept::PerceptMesh::element_side_nodes"; - - // 09/14/10: TODO: tscoffe: Will this work in 1D? - // 09/14/10: TODO: tscoffe: We need an exception here if we don't get a FEMInterface off of old_metaData or we need to take one on input. - - stk_classic::mesh::fem::FEMMetaData& femMeta = stk_classic::mesh::fem::FEMMetaData::get(elem); - const bool is_side = side_entity_rank != femMeta.edge_rank(); - //const CellTopologyData * const elem_top = fem::get_cell_topology( elem ).getCellTopologyData(); - const CellTopologyData * const elem_top = PerceptMesh::get_cell_topology(elem); - - const unsigned side_count = ! elem_top ? 0 : ( - is_side ? elem_top->side_count - : elem_top->edge_count ); - - if ( NULL == elem_top || - local_side_id < 0 || - static_cast(side_count) <= local_side_id ) { - const stk_classic::mesh::fem::FEMMetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get(elem); - std::ostringstream msg ; - msg << method ; - msg << " ( Element[" << elem.identifier() << "]" ; - msg << " , " << meta_data.entity_rank_names()[ side_entity_rank ]; - msg << " , local_side_id = " << local_side_id << " ) FAILED: " ; - if ( NULL == elem_top ) { - msg << " Element has no defined topology" ; - } - else { - msg << " Unsupported local_side_id" ; - } - throw std::runtime_error( msg.str() ); - } - - const CellTopologyData * const side_top = - is_side ? elem_top->side[ local_side_id ].topology - : elem_top->edge[ local_side_id ].topology ; - - const unsigned * const side_map = - is_side ? elem_top->side[ local_side_id ].node - : elem_top->edge[ local_side_id ].node ; - - const stk_classic::mesh::PairIterRelation elem_nodes = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - //const PairIterRelation side_nodes = side.relations( FEMMetaData::NODE_RANK ); - - //if (side_node_ids.size() != - side_node_entities.resize(side_top->node_count); - for ( unsigned j = 0 ; j < side_top->node_count ; ++j ) { - side_node_entities[j] = elem_nodes[ side_map[j] ].entity(); - } - } - - /** In @param returnedIndex, return the index of the nodes in @param side that is the start of the matching nodes in element.side[iSubDimOrd].nodes - * If the side/element face don't match, return -1. - * If the side/element face pair match, but with opposite polarity, return -1 in returnedPolarity, else 1. - * - */ - void PerceptMesh:: - element_side_permutation(const stk_classic::mesh::Entity& element, const stk_classic::mesh::Entity& side, unsigned iSubDimOrd, int& returnedIndex, int& returnedPolarity) - { - returnedPolarity = 1; - returnedIndex = -1; - - stk_classic::mesh::EntityRank needed_entity_rank = side.entity_rank(); - - //const CellTopologyData * const cell_topo_data = fem::get_cell_topology(element).getCellTopologyData(); - const CellTopologyData * const cell_topo_data = PerceptMesh::get_cell_topology(element); - - shards::CellTopology cell_topo(cell_topo_data); - const stk_classic::mesh::PairIterRelation elem_nodes = element.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - const stk_classic::mesh::PairIterRelation side_nodes = side.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - shards::CellTopology cell_topo_side(PerceptMesh::get_cell_topology(side)); - - const unsigned * inodes = 0; - unsigned nSubDimNodes = 0; - static const unsigned edge_nodes_2[2] = {0,1}; - static const unsigned face_nodes_3[3] = {0,1,2}; - static const unsigned face_nodes_4[4] = {0,1,2,3}; - - stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(element); - // special case for faces in 3D - if (needed_entity_rank == meta.face_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - if (nSubDimNodes ==3 ) - inodes = face_nodes_3; - else - inodes = face_nodes_4; - } - // special case for edges in 2D - else if (needed_entity_rank == meta.edge_rank() && needed_entity_rank == element.entity_rank()) - { - nSubDimNodes = cell_topo_data->vertex_count; - - if (nSubDimNodes == 2 ) - { - inodes = edge_nodes_2; - } - else - { - throw std::runtime_error("NodeRegistry bad for edges"); - } - } - else if (needed_entity_rank == meta.edge_rank()) - { - VERIFY_OP_ON(iSubDimOrd, <, cell_topo_data->edge_count, "err 1001"); - inodes = cell_topo_data->edge[iSubDimOrd].node; - nSubDimNodes = 2; - } - else if (needed_entity_rank == meta.face_rank() ) - { - VERIFY_OP_ON(iSubDimOrd, <, cell_topo_data->side_count, "err 1002"); - nSubDimNodes = cell_topo_data->side[iSubDimOrd].topology->vertex_count; - // note, some cells have sides with both 3 and 4 nodes (pyramid, prism) - inodes = cell_topo_data->side[iSubDimOrd].node; - } - - // if number of nodes on each side doesn't match, return (this can happen with wedge and pyramid) - if (nSubDimNodes > side_nodes.size()) - { - returnedIndex = -1; - returnedPolarity = 1; - return; - } - - int found_node_offset = -1; - for (unsigned jnode = 0; jnode < nSubDimNodes; jnode++) - { - for (unsigned node_offset = 0; node_offset < nSubDimNodes; node_offset++) - { - unsigned knode = (jnode + node_offset) % nSubDimNodes; - if (1) - { - VERIFY_OP_ON(inodes[jnode], <, elem_nodes.size(), "err 1003"); - VERIFY_OP_ON(knode, < , side_nodes.size(), "err 1005"); - if (knode >= side_nodes.size()) - { - std::cout << "err 1005\n"; - exit(1); - } - stk_classic::mesh::Entity *elem_nodes_jnode = elem_nodes[inodes[jnode]].entity(); - stk_classic::mesh::Entity *side_nodes_knode = side_nodes[ knode ].entity(); - VERIFY_OP_ON(elem_nodes_jnode, !=, 0, "err 1006"); - VERIFY_OP_ON(side_nodes_knode, !=, 0, "err 1007"); - if (!elem_nodes_jnode || !side_nodes_knode) - { - std::cout << "elem_nodes_jnode= " << elem_nodes_jnode << std::endl; - std::cout << "side_nodes_knode= " << side_nodes_knode << std::endl; - } - } - - if (elem_nodes[inodes[jnode]].entity()->identifier() == side_nodes[ knode ].entity()->identifier() ) - { - found_node_offset = (int)node_offset; - } - } - } - - if (found_node_offset >= 0) - { - bool matched = true; - for (unsigned jnode = 0; jnode < nSubDimNodes; jnode++) - { - unsigned knode = (jnode + found_node_offset) % nSubDimNodes; - VERIFY_OP_ON(inodes[jnode], <, elem_nodes.size(), "err 2003"); - VERIFY_OP_ON(knode, < , side_nodes.size(), "err 2005"); - if (elem_nodes[inodes[jnode]].entity()->identifier() != side_nodes[ knode ].entity()->identifier() ) - { - matched = false; - break; - } - } - - if (matched) - { - returnedPolarity = 1; - returnedIndex = found_node_offset; - return; - } - else - { - // try reverse ordering - matched = true; - - for (unsigned jnode = 0; jnode < nSubDimNodes; jnode++) - { - int knode = ( found_node_offset + (int)nSubDimNodes - (int)jnode) % ((int)nSubDimNodes); - - VERIFY_OP_ON(inodes[jnode], <, elem_nodes.size(), "err 2003"); - VERIFY_OP_ON(knode, < , (int)side_nodes.size(), "err 2005"); - if (elem_nodes[inodes[jnode]].entity()->identifier() != side_nodes[ knode ].entity()->identifier() ) - { - matched = false; - break; - } - } - if (matched) - { - returnedPolarity = -1; - returnedIndex = found_node_offset; - return; - } - else - { - returnedPolarity = 1; - returnedIndex = -1; - return; - } - } - } - else - { - returnedIndex = -1; - returnedPolarity = 1; - return; - } - } - - bool PerceptMesh:: - isBoundarySurface(mesh::Part& block, stk_classic::mesh::Part& surface) - { - stk_classic::mesh::EntityRank block_rank = block.primary_entity_rank(); - stk_classic::mesh::EntityRank surface_rank = surface.primary_entity_rank(); - // assert block_rank > surface_rank - - stk_classic::mesh::Selector block_selector(block); - stk_classic::mesh::Selector surface_selector(surface); - - const std::vector & buckets_1 = get_bulk_data()->buckets( block_rank ); - const std::vector & buckets_2 = get_bulk_data()->buckets( surface_rank ); - - static std::vector element_side(27); - static std::vector surface_node_ids(27); - - for ( std::vector::const_iterator k = buckets_1.begin() ; k != buckets_1.end() ; ++k ) - { - if (block_selector(**k)) // and locally_owned_part FIXME - { - stk_classic::mesh::Bucket & bucket = **k ; - - const CellTopologyData * const cell_topo_data = PerceptMesh::get_cell_topology(bucket); - shards::CellTopology cell_topo(cell_topo_data); - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - const stk_classic::mesh::PairIterRelation& elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - bool isCandidate = false; - unsigned num_node = elem_nodes.size(); - for (unsigned inode=0; inode < num_node; inode++) - { - stk_classic::mesh::Entity & node = *elem_nodes[ inode ].entity(); - //stk_classic::mesh::EntityId nid = node.identifier(); - - // this element is a candidate for sharing a face with surface - if (node.bucket().member(surface)) - { - isCandidate = true; - // FIXME at this point we know block shares at least one node with surface, which may be enough to return true here? - break; - } - } - // now check if the higher-rank part shares a face with the elements of surface - if (isCandidate) - { - for (unsigned iface = 0; iface < cell_topo_data->side_count; iface++) - { - unsigned num_nodes_on_face = cell_topo_data->side[iface].topology->vertex_count; - element_side.resize(num_nodes_on_face); - for (unsigned jnode = 0; jnode < num_nodes_on_face; jnode++) - { - element_side[jnode] = elem_nodes[ cell_topo_data->side[iface].node[jnode] ].entity()->identifier(); - } - - // second bucket loop over part2 - bool break_bucket_loop = false; - for ( std::vector::const_iterator k_2 = buckets_2.begin() ; k_2 != buckets_2.end() ; ++k_2 ) - { - if (break_bucket_loop) - break; - - if (surface_selector(**k_2)) // and locally_owned_part FIXME - { - stk_classic::mesh::Bucket & bucket_2 = **k_2 ; - - const CellTopologyData * const cell_topo_data_2 = PerceptMesh::get_cell_topology(bucket_2); - shards::CellTopology cell_topo_2(cell_topo_data_2); - - const unsigned num_elements_in_bucket_2 = bucket_2.size(); - - for (unsigned iElement_2 = 0; iElement_2 < num_elements_in_bucket_2; iElement_2++) - { - stk_classic::mesh::Entity& element_2 = bucket_2[iElement_2]; - - const stk_classic::mesh::PairIterRelation& elem_nodes_2 = element_2.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - surface_node_ids.resize(elem_nodes_2.size()); - for (unsigned jnode = 0; jnode < elem_nodes_2.size(); jnode++) - { - surface_node_ids[jnode] = elem_nodes_2[jnode].entity()->identifier(); - } - - int perm = shards::findPermutation(cell_topo.getCellTopologyData()->subcell[surface_rank][iface].topology, - &element_side[0], &surface_node_ids[0]); - if (perm < 0) - { - break_bucket_loop = true; - break; - } - else - { - //std::cout << "tmp block and surface share: " << block.name() << " " << surface.name() << std::endl; - return true; - } - } - } - } - } - } - } - } - } - return false; - } - - - template<> - const CellTopologyData * - PerceptMesh::get_cell_topology(const stk_classic::mesh::Part& part) - { - const stk_classic::mesh::fem::FEMMetaData & fem_meta = get_fem_meta_data(part); - - const CellTopologyData * cell_topo_data = fem_meta.get_cell_topology(part).getCellTopologyData(); - return cell_topo_data; - } - - - bool PerceptMesh:: - mesh_difference(stk_classic::mesh::fem::FEMMetaData& metaData_1, - stk_classic::mesh::fem::FEMMetaData& metaData_2, - stk_classic::mesh::BulkData& bulkData_1, - stk_classic::mesh::BulkData& bulkData_2, - std::string msg, - bool print, bool print_all_field_diffs) - { - EXCEPTWATCH; - - bool diff = false; - - const unsigned p_rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD ); - - if (print) - { - std::cout - << "\n\nP[" << p_rank << "] ========================================================\n" - << "P[" << p_rank << "] ====== mesh diff start... ==============================\n" - << "P[" << p_rank << "] ========================================================\n\n\n" - << std::endl; - } - - if (print) std::cout << "P[" << p_rank << "] PerceptMesh::difference: " << std::endl; - - - // mesh counts - { - std::vector count_1, count_2 ; - stk_classic::mesh::Selector selector_1(metaData_1.universal_part()); - stk_classic::mesh::Selector selector_2(metaData_2.universal_part()); - stk_classic::mesh::count_entities( selector_1, bulkData_1, count_1 ); - stk_classic::mesh::count_entities( selector_2, bulkData_2, count_2 ); - - if (print) - { - std::cout << "mesh_1:2 P[" << p_rank << "] Uses {" ; - std::cout << "\n Node = " << count_1[ 0 ] << " " << count_2[ 0 ] ; - std::cout << "\n Edge = " << count_1[ 1 ] << " " << count_2[ 1 ] ; - std::cout << "\n Face = " << count_1[ 2 ] << " " << count_2[ 2 ] ; - if (count_1.size() >= 4) std::cout << "\n Elem = " << count_1[ 3 ] << " " << count_2[ 3 ] ; - if (count_1.size() >= 5) std::cout << "\n FamilyTree = " << count_1[ 4 ] << " " << count_2[ 4 ] ; - std::cout << " }" << std::endl ; - } - for (unsigned i = 0; i < std::min(count_1.size(), count_2.size()); i++) - { - if (count_1[i] != count_2[i]) - { - msg += "| A. counts are different "+toString(count_1[i])+" "+toString(count_2[i])+" |\n"; - diff = true; - } - } - } - - // Parts information - const std::vector< stk_classic::mesh::Part * > & parts_1 = metaData_1.get_parts(); - const std::vector< stk_classic::mesh::Part * > & parts_2 = metaData_2.get_parts(); - if (parts_1.size() != parts_2.size()) - { - msg += "| parts size diff "+toString((unsigned)parts_1.size()) + " " +toString((unsigned)parts_2.size()) +"|\n"; - diff = true; - } - else - { - unsigned nparts = parts_1.size(); - if (print) - { - std::cout << "P[" << p_rank << "] info> Number of parts = " << nparts << std::endl; - std::cout << "\nP[" << p_rank << "] info> Part subset info: \n" << std::endl; - } - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part_1 = *parts_1[ipart]; - stk_classic::mesh::Part& part_2 = *parts_2[ipart]; - const CellTopologyData *const topology_1 = stk_classic::percept::PerceptMesh::get_cell_topology(part_1); - const CellTopologyData *const topology_2 = stk_classic::percept::PerceptMesh::get_cell_topology(part_2); - if (part_1.subsets().size() != part_2.subsets().size()) - { - msg += std::string("| parts subsets size diff ")+part_1.name()+" "+part_2.name()+" | "; - diff = true; - } - - if (part_1.name() != part_2.name()) { msg += "|part names diff "+part_1.name()+" "+part_2.name()+" | "; diff = true; } - if ((topology_1 != topology_2) || - ((std::string(topology_1?shards::CellTopology(topology_1).getName():"null") != - std::string(topology_2?shards::CellTopology(topology_2).getName():"null") )) - ) - { - msg += "| part topology diff "+ - std::string(topology_1?shards::CellTopology(topology_1).getName():"null")+" "+ - std::string(topology_2?shards::CellTopology(topology_2).getName():"null"); - diff = true; - } - - if ( part_1.primary_entity_rank() != part_2.primary_entity_rank() ) - { msg += "| primary_entity_rank diff "+ - toString(part_1.primary_entity_rank())+" "+ - toString(part_2.primary_entity_rank())+" |\n"; diff = true; } - } - - if (print) std::cout << "\nP[" << p_rank << "] info> Part Uses information: \n" << std::endl; - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part_1 = *parts_1[ipart]; - stk_classic::mesh::Part& part_2 = *parts_2[ipart]; - { - std::vector count_1, count_2 ; - stk_classic::mesh::Selector selector_1(part_1); - stk_classic::mesh::Selector selector_2(part_2); - stk_classic::mesh::count_entities( selector_1, bulkData_1, count_1 ); - stk_classic::mesh::count_entities( selector_2, bulkData_2, count_2 ); - - bool loc_diff = false; - for (unsigned i = 0; i < std::min(count_1.size(), count_2.size()); i++) - { - if (count_1[i] != count_2[i]) - { - msg += "| B. counts are different "+toString(count_1[i])+" "+toString(count_2[i])+" |\n"; - //msg += "| counts are different |\n"; - diff = true; - loc_diff = true; - break; - } - } - if (loc_diff && print) - { - std::cout << "part_1,2= " << part_1.name() << " " << part_2.name() << " P[" << p_rank << "] Uses {" ; - std::cout << "\n Node = " << count_1[ 0 ] << " " << count_2[ 0 ] ; - std::cout << "\n Edge = " << count_1[ 1 ] << " " << count_2[ 1 ] ; - std::cout << "\n Face = " << count_1[ 2 ] << " " << count_2[ 2 ] ; - if (count_1.size() >= 4) std::cout << "\n Elem = " << count_1[ 3 ] << " " << count_2[ 3 ] ; - if (count_1.size() >= 5) std::cout << "\n FamilyTree = " << count_1[ 4 ] << " " << count_2[ 4 ] ; - std::cout << " }" << std::endl ; - - } - } - - } - } - - // check mesh connectivity - { - stk_classic::mesh::Selector on_locally_owned_part_1 = ( metaData_1.locally_owned_part() ); - stk_classic::mesh::Selector on_locally_owned_part_2 = ( metaData_2.locally_owned_part() ); - for (unsigned rank = 1; rank <= metaData_1.element_rank(); rank++) - { - const std::vector & buckets_1 = bulkData_1.buckets( rank ); - const std::vector & buckets_2 = bulkData_2.buckets( rank ); - if (buckets_1.size() != buckets_2.size()) - { - if (print) - { - std::cout << "P[" << p_rank << "] info> num buckets_1 = " << buckets_1.size() << " for rank= " << rank << std::endl; - std::cout << "P[" << p_rank << "] info> num buckets_2 = " << buckets_2.size() << " for rank= " << rank << std::endl; - } - msg += "[ buckets size diff ]"; - diff = true; - } - else - { - for (unsigned k = 0; k < buckets_1.size(); k++) - { - stk_classic::mesh::Bucket& bucket_1 = *buckets_1[k]; - stk_classic::mesh::Bucket& bucket_2 = *buckets_2[k]; - if (on_locally_owned_part_1(bucket_1) != on_locally_owned_part_2(bucket_2)) - { - msg += "| on_locally_owned_part for buckets diff |\n"; - diff = true; - } - else - { - if (on_locally_owned_part_1(bucket_1)) // this is where we do part selection - { - const unsigned num_entities_in_bucket_1 = bucket_1.size(); - const unsigned num_entities_in_bucket_2 = bucket_2.size(); - if (num_entities_in_bucket_1 != num_entities_in_bucket_2) - { - msg += "| num_entities_in_bucket diff |\n"; - diff = true; - } - - //dw().m(LOG_APPLICATION) << "num_entities_in_bucket = " << num_entities_in_bucket<< " element ids = " << stk_classic::diag::dendl; - //dw() << "num_entities_in_bucket = " << num_entities_in_bucket<< " element ids = " << stk_classic::diag::dendl; - - //bool local_diff = false; - for (unsigned iEntity = 0; iEntity < num_entities_in_bucket_1; iEntity++) - { - stk_classic::mesh::Entity& entity_1 = bucket_1[iEntity]; - stk_classic::mesh::Entity& entity_2 = bucket_2[iEntity]; - - stk_classic::mesh::PairIterRelation elem_nodes_1 = entity_1.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - stk_classic::mesh::PairIterRelation elem_nodes_2 = entity_2.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - if (elem_nodes_1.size() != elem_nodes_2.size()) - { - msg += "| entity relations size diff |\n"; - diff = true; - break; - } - for (unsigned i = 0; i < elem_nodes_1.size(); i++) - { - stk_classic::mesh::Entity& node_1 = *elem_nodes_1[i].entity(); - stk_classic::mesh::Entity& node_2 = *elem_nodes_2[i].entity(); - if (elem_nodes_1[i].identifier() != elem_nodes_2[i].identifier()) - { - msg += "| entity relations identifier diff |\n"; - diff = true; - break; - } - if (node_1.identifier() != node_2.identifier()) - { - msg += "| node ids diff |\n"; - diff = true; - } - } - } - } - } - } - } - } - } - - // Fields - { - const stk_classic::mesh::FieldVector & fields_1 = metaData_1.get_fields(); - const stk_classic::mesh::FieldVector & fields_2 = metaData_2.get_fields(); - if (fields_1.size() != fields_2.size()) - { - msg += "| fields size diff |\n"; - diff = true; - } - else - { - unsigned nfields = fields_1.size(); - - if (print) std::cout << "P[" << p_rank << "] info> Number of fields = " << fields_1.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field_1 = fields_1[ifld]; - stk_classic::mesh::FieldBase *field_2 = fields_2[ifld]; - - if (0) - { - if (print) std::cout << "P[" << p_rank << "] info> Field[" << ifld << "]= " << field_1->name() << " rank= " << field_1->rank() << std::endl; - if (print) std::cout << "P[" << p_rank << "] info> " << *field_1 << std::endl; - if (print) std::cout << "P[" << p_rank << "] info> Field[" << ifld << "]= " << field_2->name() << " rank= " << field_2->rank() << std::endl; - if (print) std::cout << "P[" << p_rank << "] info> " << *field_2 << std::endl; - } - - unsigned nfr_1 = field_1->restrictions().size(); - if (field_1->restrictions().size() != field_2->restrictions().size()) - { - msg += "| field restrictions size diff |\n"; - diff=true; - continue; - } - //if (print_info) std::cout << "P[" << p_rank << "] info> number of field restrictions= " << nfr << std::endl; - unsigned stride_1 = 0; - unsigned stride_2 = 0; - stk_classic::mesh::EntityRank field_rank = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - bool local_diff = false; - for (unsigned ifr = 0; ifr < nfr_1; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr_1 = field_1->restrictions()[ifr]; - stk_classic::mesh::Part& frpart_1 = metaData_1.get_part(fr_1.part_ordinal()); - stride_1 = fr_1.dimension(); - field_rank = fr_1.entity_rank(); - const stk_classic::mesh::FieldRestriction& fr_2 = field_2->restrictions()[ifr]; - stk_classic::mesh::Part& frpart_2 = metaData_2.get_part(fr_2.part_ordinal()); - stride_2 = fr_2.dimension(); - - if (stride_1 != stride_2 || fr_1.entity_rank() != fr_2.entity_rank()) - { - if (print) - { - std::cout << "P[" << p_rank << "] info> field restriction " << ifr << " stride[0] = " << fr_1.dimension() << - " type= " << fr_1.entity_rank() << " ord= " << fr_1.part_ordinal() << - " which corresponds to Part= " << frpart_1.name() << std::endl; - std::cout << "P[" << p_rank << "] info> field restriction " << ifr << " stride[0] = " << fr_2.dimension() << - " type= " << fr_2.entity_rank() << " ord= " << fr_2.part_ordinal() << - " which corresponds to Part= " << frpart_2.name() << std::endl; - } - msg += "| field stride or rank diff |\n"; - diff = true; - local_diff = true; - } - } - - bool compare_detailed = true; - //int print_field_width = 15; - //int print_percent_width = 5; - if (compare_detailed && !local_diff) - { - bool printed_header=false; - double max_diff = 0.0; - double min_diff = 1.e+30; - - stk_classic::mesh::EntityRank rank = field_rank; - stk_classic::mesh::Selector on_locally_owned_part_1 = ( metaData_1.locally_owned_part() ); - stk_classic::mesh::Selector on_locally_owned_part_2 = ( metaData_2.locally_owned_part() ); - const std::vector & buckets_1 = bulkData_1.buckets( rank ); - const std::vector & buckets_2 = bulkData_2.buckets( rank ); - for (unsigned k = 0; k < buckets_1.size(); k++) - { - stk_classic::mesh::Bucket& bucket_1 = *buckets_1[k]; - stk_classic::mesh::Bucket& bucket_2 = *buckets_2[k]; - if (on_locally_owned_part_1(bucket_1)) // this is where we do part selection - { - const unsigned num_entities_in_bucket_1 = bucket_1.size(); - //const unsigned num_entities_in_bucket_2 = bucket_2.size(); - - bool local_local_diff = false; - for (unsigned iEntity = 0; iEntity < num_entities_in_bucket_1; iEntity++) - { - stk_classic::mesh::Entity& entity_1 = bucket_1[iEntity]; - stk_classic::mesh::Entity& entity_2 = bucket_2[iEntity]; - - unsigned loc_stride_1 = 0; - unsigned loc_stride_2 = 0; - double * fdata_1 = PerceptMesh::field_data( field_1 , entity_1, &loc_stride_1); - double * fdata_2 = PerceptMesh::field_data( field_2 , entity_2, &loc_stride_2); - - if ((fdata_1 == 0) != (fdata_2 == 0) || (loc_stride_1 != loc_stride_2)) - { - msg += "| (fdata_1 == 0) != (fdata_2 == 0)) |\n"; - diff = true; - } - - if (fdata_1) - { - bool is_same=true; - double tol = 1.e-5; - for (unsigned istride = 0; istride < loc_stride_1; istride++) - { - double fd1 = fdata_1[istride]; - double fd2 = fdata_2[istride]; - if (!Util::approx_equal_relative(fd1, fd2, tol)) - { - is_same=false; - break; - } - } - - if (!is_same) - { - if (!printed_header) - { - msg += std::string("\n| field data not equal field_1= ") +field_1->name()+" field_2= "+field_2->name()+" |"; - printed_header = true; - } - msg += "\n|{"; - for (unsigned istride = 0; istride < loc_stride_1; istride++) - { - double fd1 = fdata_1[istride]; - double fd2 = fdata_2[istride]; - // msg += "\n| "+toString(fd1).substr(0,print_field_width)+" - "+toString(fd2).substr(0,print_field_width)+" = " - // +toString(fd1-fd2).substr(0,print_field_width)+ - // " [ "+toString(100.0*(fd1-fd2)/(std::abs(fd1)+std::abs(fd2)+1.e-20)).substr(0,print_percent_width)+" % ] |"; - //std::ostringstream ostr; - // ostr << "\n| " << std::setw(print_field_width) << fd1 << " - " << fd2 << " = " - // << (fd1-fd2) - // << std::setw(print_percent_width) << " [ " << (100.0*(fd1-fd2)/(std::abs(fd1)+std::abs(fd2)+1.e-20)) << " % ] |"; - //msg += ostr.str(); - char buf[1024]; - sprintf(buf, ", | %12.3g - %12.3g = %12.3g [ %10.3g %% ] |", fd1, fd2, (fd1-fd2), (100.0*(fd1-fd2)/(std::abs(fd1)+std::abs(fd2)+1.e-20))); - // << (fd1-fd2) - // << std::setw(print_percent_width) << " [ " << (100.0*(fd1-fd2)/(std::abs(fd1)+std::abs(fd2)+1.e-20)) << " % ] |"; - msg += buf; - diff = true; - local_local_diff = true; - max_diff = std::max(max_diff, std::abs(fd1-fd2)); - min_diff = std::min(min_diff, std::abs(fd1-fd2)); - } - msg += "}|"; - } - } - - if (!print_all_field_diffs && local_local_diff) break; - } - } - } - msg += "\n| for field: "+field_1->name()+", max diff = "+toString(max_diff)+ " | "; - } - } - } - } - - if (diff && print) - { - std::cout << " results = \n " << msg << std::endl; - std::cout - << "\n\nP[" << p_rank << "] ========================================================\n" - << "P[" << p_rank << "] =============== meshes are different ===================\n" - << "P[" << p_rank << "] ========================================================\n" - << std::endl; - } - if (!diff && print) - { - std::cout - << "\n\nP[" << p_rank << "] ========================================================\n" - << "P[" << p_rank << "] =============== meshes are the same ===================\n" - << "P[" << p_rank << "] ========================================================\n" - << std::endl; - //std::cout << " results = \n " << msg << std::endl; - } - return diff; - } - - bool PerceptMesh:: - mesh_difference(PerceptMesh& eMesh_1, PerceptMesh& eMesh_2, std::string msg, bool print, bool print_all_field_diffs) - { - stk_classic::mesh::fem::FEMMetaData& metaData_1 = *eMesh_1.get_fem_meta_data(); - stk_classic::mesh::fem::FEMMetaData& metaData_2 = *eMesh_2.get_fem_meta_data(); - stk_classic::mesh::BulkData& bulkData_1 = *eMesh_1.get_bulk_data(); - stk_classic::mesh::BulkData& bulkData_2 = *eMesh_2.get_bulk_data(); - return mesh_difference(metaData_1, metaData_2, bulkData_1, bulkData_2, msg, print, print_all_field_diffs); - } - - // checks if this entity has a duplicate (ie all nodes are the same) - bool PerceptMesh:: - check_entity_duplicate(stk_classic::mesh::Entity& entity) - { - PerceptMesh& eMesh = *this; - - stk_classic::mesh::EntityRank node_rank = eMesh.node_rank(); - stk_classic::mesh::EntityRank entity_rank = entity.entity_rank(); - - typedef std::set SetOfIds; - SetOfIds entity_ids; - stk_classic::mesh::PairIterRelation entity_nodes = entity.relations(node_rank); - - for (unsigned is=0; is < entity_nodes.size(); is++) - { - entity_ids.insert(entity_nodes[is].entity()->identifier()); - } - - for (unsigned isnode=0; isnode < entity_nodes.size(); isnode++) - { - stk_classic::mesh::PairIterRelation node_entitys = entity_nodes[isnode].entity()->relations(entity_rank); - for (unsigned ienode=0; ienode < node_entitys.size(); ienode++) - { - stk_classic::mesh::Entity& entity2 = *node_entitys[ienode].entity(); - if (entity2.identifier() == entity.identifier()) - continue; - - SetOfIds entity2_ids; - - if (entity2.relations(node_rank).size() == 0) - continue; - - if (eMesh.isGhostElement(entity2)) - continue; - - stk_classic::mesh::PairIterRelation entity2_nodes = entity2.relations(node_rank); - for (unsigned is2=0; is2 < entity2_nodes.size(); is2++) - { - entity2_ids.insert(entity2_nodes[is2].entity()->identifier()); - } - SetOfIds::iterator it=entity_ids.begin(); - SetOfIds::iterator it2=entity2_ids.begin(); - bool found = true; - for (; it != entity_ids.end(); ++it, ++it2) - { - if (*it != *it2) - { - found = false; - break; - } - } - if (found) - { - std::cout << "tmp check_entity_duplicate bad entitys " << entity << " " << entity2 << std::endl; - - std::cout << "tmp check_entity_duplicate bad entity2= " ; - for (unsigned is2=0; is2 < entity2_nodes.size(); is2++) - { - std::cout << " " << entity2_nodes[is2].entity(); - } - std::cout << std::endl; - - std::cout << "tmp check_entity_duplicate bad entity= " ; - for (unsigned is=0; is < entity_nodes.size(); is++) - { - std::cout << " " << entity_nodes[is].entity(); - } - std::cout << std::endl; - - for (it=entity_ids.begin(); it != entity_ids.end(); ++it) - { - std::cout << " " << *it; - } - std::cout << std::endl; - return true; - } - } - } - return false; - } - - void PerceptMesh::delete_side_sets() - { - const std::vector & buckets = get_bulk_data()->buckets( side_rank() ); - - typedef std::set SetOfEntities; - - SetOfEntities elem_set; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - elem_set.insert(&element); - } - } - } - std::cout << "delete_side_sets: elem_set.size= " << elem_set.size() << std::endl; - - get_bulk_data()->modification_begin(); - for(SetOfEntities::iterator elem_it = elem_set.begin(); - elem_it != elem_set.end(); ++elem_it) - { - stk_classic::mesh::Entity *elem = *elem_it; - stk_classic::mesh::PairIterRelation rels = elem->relations(element_rank()); - for (unsigned irels = 0; irels < rels.size(); irels++) - { - stk_classic::mesh::Entity *vol_elem = rels[irels].entity(); - if ( ! get_bulk_data()->destroy_relation(*vol_elem, *elem, rels[irels].identifier())) - { - throw std::logic_error("PerceptMesh::delete_side_sets couldn't remove element, destroy_relation returned false for elem."); - } - } - - if ( ! get_bulk_data()->destroy_entity( elem ) ) - { - throw std::logic_error("PerceptMesh::delete_side_sets couldn't remove element, destroy_entity returned false for elem."); - } - } - get_bulk_data()->modification_end(); - - } - - void PerceptMesh::addParallelInfoFields(bool elemental, bool nodal, - std::string elemental_proc_rank_name, - std::string nodal_fixed_flag, // boundary flag for telling Mesquite these nodes shouldn't be moved - std::string nodal_global_id_name, - std::string nodal_proc_id_name, - std::string nodal_local_id_name) - { - if (elemental) - { - int scalarDimension = 0; // a scalar - add_field(elemental_proc_rank_name, element_rank(), scalarDimension); - } - if (nodal) - { - int scalarDimension = 0; // a scalar - add_field(nodal_global_id_name, node_rank(), scalarDimension); - add_field(nodal_proc_id_name, node_rank(), scalarDimension); - add_field(nodal_local_id_name, node_rank(), scalarDimension); - add_field(nodal_fixed_flag, node_rank(), scalarDimension); - } - } - - void PerceptMesh::populateParallelInfoFields(bool elemental, bool nodal, - stk_classic::mesh::Selector* fixed_node_selector, - std::string elemental_proc_rank_name, - std::string nodal_fixed_flag, - std::string nodal_global_id_name, - std::string nodal_proc_id_name, - std::string nodal_local_id_name) - { - if (elemental) - { - stk_classic::mesh::FieldBase * field = get_field(elemental_proc_rank_name); - const std::vector & buckets = get_bulk_data()->buckets( element_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - double *fdata = PerceptMesh::field_data( field , element ); - if (fdata) fdata[0] = element.owner_rank(); - } - } - } - } - if (nodal) - { - stk_classic::mesh::FieldBase * field_gid = get_field(nodal_global_id_name); - stk_classic::mesh::FieldBase * field_pid = get_field(nodal_proc_id_name); - stk_classic::mesh::FieldBase * field_lid = get_field(nodal_local_id_name); - stk_classic::mesh::FieldBase * field_fix = get_field(nodal_fixed_flag); - unsigned lid=0; - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& node = bucket[ientity]; - double *fdata_gid = PerceptMesh::field_data( field_gid , node ); - double *fdata_pid = PerceptMesh::field_data( field_pid , node ); - double *fdata_lid = PerceptMesh::field_data( field_lid , node ); - double *fdata_fix = PerceptMesh::field_data( field_fix , node ); - if (fdata_gid) fdata_gid[0] = node.identifier(); - if (fdata_pid) fdata_pid[0] = node.owner_rank(); - if (fdata_lid) fdata_lid[0] = lid++; - if (fdata_fix) - { - if (fixed_node_selector) - fdata_fix[0] = (*fixed_node_selector)(node) ? 1 : 0; - else - fdata_fix[0] = 0; - } - } - } - } - } - } - - void PerceptMesh::add_coordinate_state_fields() - { - m_num_coordinate_field_states = 3; - int scalarDimension = get_spatial_dim(); // a scalar - add_field("coordinates_N", node_rank(), scalarDimension); - add_field("coordinates_NM1", node_rank(), scalarDimension); - add_field("coordinates_lagged", node_rank(), scalarDimension); - - add_field("cg_g", node_rank(), scalarDimension); - add_field("cg_r", node_rank(), scalarDimension); - add_field("cg_d", node_rank(), scalarDimension); - add_field("cg_s", node_rank(), scalarDimension); - - // hessian - add_field("cg_h", node_rank(), scalarDimension*scalarDimension); - } - - void PerceptMesh::add_spacing_fields() - { - int scalarDimension = get_spatial_dim(); // a scalar - add_field("ref_spacing_field", node_rank(), scalarDimension); - add_field("ref_spacing_field_counter", node_rank(), 1); - } - - void PerceptMesh::set_proc_rank_field(stk_classic::mesh::FieldBase *proc_rank_field) - { - std::cout << "P["<< get_rank() << "] " << " proc_rank_field= " << proc_rank_field << std::endl; - - if (!proc_rank_field) proc_rank_field=get_field("proc_rank"); - if (!proc_rank_field) return; - const std::vector & buckets = get_bulk_data()->buckets( element_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - double *fdata = field_data(proc_rank_field, element); - fdata[0] = double(element.owner_rank()); - } - } - } - } - - /// copy field state data from one state (src_state) to another (dest_state) - void PerceptMesh::copy_field_state(stk_classic::mesh::FieldBase* field, unsigned dest_state, unsigned src_state) - { - stk_classic::mesh::FieldBase* field_dest = field->field_state((stk_classic::mesh::FieldState)dest_state); - VERIFY_OP_ON(field_dest, !=, 0, "copy_field_state dest null"); - stk_classic::mesh::FieldBase* field_src = field->field_state((stk_classic::mesh::FieldState)src_state); - VERIFY_OP_ON(field_src, !=, 0, "copy_field_state src null"); - copy_field(field_dest, field_src); - } - - /// copy field data from one field (field_src) to another (field_dest) - void PerceptMesh::copy_field(stk_classic::mesh::FieldBase* field_dest, stk_classic::mesh::FieldBase* field_src) - { - stk_classic::mesh::Selector not_aura = get_fem_meta_data()->locally_owned_part() | get_fem_meta_data()->globally_shared_part() ; - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (not_aura(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - unsigned fd_size = bucket.field_data_size(*field_dest); - unsigned stride = fd_size/sizeof(double); - // FIXME - //VERIFY_OP_ON((int)stride, ==, get_spatial_dim(), "stride..."); - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - unsigned stride0=0; - double *fdata_dest = PerceptMesh::field_data( field_dest , node, &stride0 ); - VERIFY_OP_ON(stride, ==, stride0,"strides..."); - double *fdata_src = PerceptMesh::field_data( field_src , node ); - if (fdata_dest && fdata_src) - { - for (unsigned istride = 0; istride < stride; istride++) - { - fdata_dest[istride] = fdata_src[istride]; - } - } - } - } - } - std::vector< const stk_classic::mesh::FieldBase *> fields; - fields.push_back(field_dest); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(get_bulk_data()->shared_aura(), fields); - - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*get_bulk_data()->ghostings()[0], fields); - - } - - /// axpby calculates: y = alpha*x + beta*y - void PerceptMesh::nodal_field_state_axpby(stk_classic::mesh::FieldBase* field, double alpha, unsigned x_state, double beta, unsigned y_state) - { - stk_classic::mesh::FieldBase* field_x = field->field_state((stk_classic::mesh::FieldState)x_state); - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_axpby x null"); - stk_classic::mesh::FieldBase* field_y = field->field_state((stk_classic::mesh::FieldState)y_state); - VERIFY_OP_ON(field_y, !=, 0, "nodal_field_axpby y null"); - nodal_field_axpby(alpha, field_x, beta, field_y); - } - - /// axpby calculates: y = alpha*x + beta*y - void PerceptMesh::nodal_field_axpby(double alpha, stk_classic::mesh::FieldBase* field_x, double beta, stk_classic::mesh::FieldBase* field_y) - { - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_axpby x null"); - VERIFY_OP_ON(field_y, !=, 0, "nodal_field_axpby y null"); - stk_classic::mesh::Selector not_aura = get_fem_meta_data()->locally_owned_part() | get_fem_meta_data()->globally_shared_part() ; - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (not_aura(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - unsigned fd_size = bucket.field_data_size(*field_y); - unsigned stride = fd_size/sizeof(double); - // FIXME - //VERIFY_OP_ON((int)stride, ==, get_spatial_dim(), "stride..."); - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - unsigned stride0=0; - double *fdata_y = PerceptMesh::field_data( field_y , node, &stride0 ); - VERIFY_OP_ON(stride, ==, stride0,"strides..."); - double *fdata_x = PerceptMesh::field_data( field_x , node ); - if (fdata_y && fdata_x) - { - for (unsigned istride = 0; istride < stride; istride++) - { - fdata_y[istride] = alpha*fdata_x[istride] + beta*fdata_y[istride]; - } - } - } - } - } - std::vector< const stk_classic::mesh::FieldBase *> fields; - //fields.push_back(field_x); - fields.push_back(field_y); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(get_bulk_data()->shared_aura(), fields); - - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*get_bulk_data()->ghostings()[0], fields); - } - - double PerceptMesh::nodal_field_dot(stk_classic::mesh::FieldBase* field_x, stk_classic::mesh::FieldBase* field_y) - { - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_dot x null"); - VERIFY_OP_ON(field_y, !=, 0, "nodal_field_dot y null"); - //stk_classic::mesh::Selector not_aura = get_fem_meta_data()->locally_owned_part() | get_fem_meta_data()->globally_shared_part() ; - stk_classic::mesh::Selector on_locally_owned_part = get_fem_meta_data()->locally_owned_part(); - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - double sum=0.0; - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - unsigned fd_size = bucket.field_data_size(*field_y); - unsigned stride = fd_size/sizeof(double); - // FIXME - //VERIFY_OP_ON((int)stride, ==, get_spatial_dim(), "stride..."); - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - unsigned stride0=0; - double *fdata_y = PerceptMesh::field_data( field_y , node, &stride0 ); - VERIFY_OP_ON(stride, ==, stride0,"strides..."); - double *fdata_x = PerceptMesh::field_data( field_x , node ); - if (fdata_y && fdata_x) - { - for (unsigned istride = 0; istride < stride; istride++) - { - sum += fdata_x[istride]*fdata_y[istride]; - } - } - } - } - } - - stk_classic::all_reduce( get_bulk_data()->parallel() , ReduceSum<1>( & sum ) ); - return sum; - } - void PerceptMesh::nodal_field_set_value(stk_classic::mesh::FieldBase* field_x, double value) - { - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_dot x null"); - stk_classic::mesh::Selector not_aura = get_fem_meta_data()->locally_owned_part() | get_fem_meta_data()->globally_shared_part() ; - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // do it for all nodes - //if (not_aura(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - unsigned fd_size = bucket.field_data_size(*field_x); - unsigned stride = fd_size/sizeof(double); - // FIXME - //VERIFY_OP_ON((int)stride, ==, get_spatial_dim(), "stride..."); - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - unsigned stride0=0; - double *fdata_x = PerceptMesh::field_data( field_x , node, &stride0 ); - VERIFY_OP_ON(stride, ==, stride0,"strides..."); - if (fdata_x) - { - for (unsigned istride = 0; istride < stride; istride++) - { - fdata_x[istride] = value; - } - } - } - } - } - - } - - /// axpbypgz calculates: z = alpha*x + beta*y + gamma*z - void PerceptMesh::nodal_field_state_axpbypgz(stk_classic::mesh::FieldBase* field, double alpha, unsigned x_state, double beta, unsigned y_state, double gamma, unsigned z_state) - { - stk_classic::mesh::FieldBase* field_x = field->field_state((stk_classic::mesh::FieldState)x_state); - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_axpbypgz x null"); - stk_classic::mesh::FieldBase* field_y = field->field_state((stk_classic::mesh::FieldState)y_state); - VERIFY_OP_ON(field_y, !=, 0, "nodal_field_axpbypgz y null"); - stk_classic::mesh::FieldBase* field_z = field->field_state((stk_classic::mesh::FieldState)z_state); - VERIFY_OP_ON(field_z, !=, 0, "nodal_field_axpbypgz z null"); - nodal_field_axpbypgz(alpha, field_x, beta, field_y, gamma, field_z); - } - - /// axpbypgz calculates: z = alpha*x + beta*y + gamma*z - void PerceptMesh::nodal_field_axpbypgz(double alpha, stk_classic::mesh::FieldBase* field_x, - double beta, stk_classic::mesh::FieldBase* field_y, - double gamma, stk_classic::mesh::FieldBase* field_z) - { - EXCEPTWATCH; - VERIFY_OP_ON(field_x, !=, 0, "nodal_field_axpbypgz x null"); - VERIFY_OP_ON(field_y, !=, 0, "nodal_field_axpbypgz y null"); - VERIFY_OP_ON(field_z, !=, 0, "nodal_field_axpbypgz z null"); - stk_classic::mesh::Selector not_aura = get_fem_meta_data()->locally_owned_part() | get_fem_meta_data()->globally_shared_part() ; - const std::vector & buckets = get_bulk_data()->buckets( node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (not_aura(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - unsigned fd_size = bucket.field_data_size(*field_y); - unsigned stride = fd_size/sizeof(double); - // FIXME - //VERIFY_OP_ON((int)stride, ==, get_spatial_dim(), "stride..."); - const unsigned num_nodes_in_bucket = bucket.size(); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - unsigned stride0=0; - double *fdata_y = PerceptMesh::field_data( field_y , node, &stride0 ); - double *fdata_z = PerceptMesh::field_data( field_z , node, &stride0 ); - VERIFY_OP_ON(stride, ==, stride0,"strides..."); - double *fdata_x = PerceptMesh::field_data( field_x , node ); - if (fdata_y && fdata_x && fdata_z) - { - for (unsigned istride = 0; istride < stride; istride++) - { - fdata_z[istride] = alpha*fdata_x[istride] + beta*fdata_y[istride] + gamma*fdata_z[istride]; - } - } - } - } - } - std::vector< const stk_classic::mesh::FieldBase *> fields; - //fields.push_back(field_x); - //fields.push_back(field_y); - fields.push_back(field_z); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(get_bulk_data()->shared_aura(), fields); - - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*get_bulk_data()->ghostings()[0], fields); - } - - void PerceptMesh::remove_geometry_blocks_on_output(std::string geometry_file_name) - { -#if defined(STK_PERCEPT_HAS_GEOMETRY) - GeometryKernelOpenNURBS gk; - // set to 0.0 for no checks, > 0.0 for a fixed check delta, < 0.0 (e.g. -0.5) to check against local edge length average times this |value| - double doCheckMovement = 0.0; - - // anything exceeding a value > 0.0 will be printed - double doCheckCPUTime = 0.0; - //double doCheckCPUTime = 0.1; - - MeshGeometry mesh_geometry(&gk, doCheckMovement, doCheckCPUTime); - GeometryFactory factory(&gk, &mesh_geometry); - factory.read_file(geometry_file_name, this); - - const stk_classic::mesh::PartVector& eMeshOmittedParts = get_io_omitted_parts(); - stk_classic::mesh::PartVector newOmittedParts = eMeshOmittedParts; - const std::vector& geomEvals = mesh_geometry.getGeomEvaluators(); - for (unsigned i = 0; i < geomEvals.size(); i++) - { - //if (!m_eMesh.get_rank()) std::cout << " tmp srk adding geomEvals[i]->mPart->name()..." << geomEvals[i]->mPart->name() << std::endl; - newOmittedParts.push_back(geomEvals[i]->mPart); - } - set_io_omitted_parts(newOmittedParts); -#else - throw std::runtime_error("no geometry available, set STK_PERCEPT_HAS_GEOMETRY flag: not implemented"); -#endif - } - - //==================================================================================================================================== - /** - * A family tree relation holds the parent/child relations for a refined mesh. - * - * Case 0: a single refinement of a parent P_0 and its children C_0_0, C_0_1,...,C_0_N leads to a new - * family tree entity FT_0 that has down relations to {P_0, C_0_0, C_0_1,...,C_0_N} - * The back pointers from P_0, C_0_0, ... are initially stored as the 0'th index of their relations, - * i.e.: P_0.relations(FAMILY_TREE_RANK)[0] --> FT_0, - * C_0_0.relations(FAMILY_TREE_RANK)[0] --> FT_0, etc. - * Case 1: a previously refined child, say C_0_1, renamed to P_0_1, gets further refined leading to - * a new family tree entity, FT_1 - * pointing to: {P_0_1, C_0_1_0, C_0_1_1,... } - * but, now the relations indexing changes (actually, we can't predict what it will be, thus the - * need for this function getFamilyTreeRelationIndex): - * P_0_1.relations(FAMILY_TREE_RANK)[0] --> FT_1 - * P_0_1.relations(FAMILY_TREE_RANK)[1] --> FT_0 - * etc. - * So, we use this function to look for the family tree corresponding to if we are looking for the first - * level (if there's only one level, or we are looking for the family tree associated with the element - * when it was a child for the first time), orthe "level 1" family tree (corresponding to Case 1 - * where we are looking for the family tree of the element associated with it being a parent). - * - */ - unsigned PerceptMesh::getFamilyTreeRelationIndex(FamiltyTreeLevel level, const stk_classic::mesh::Entity& element) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (level == FAMILY_TREE_LEVEL_0) - { - // only one level, so we return 0 as the index - if (element_to_family_tree_relations.size() <= 1) return 0; - - // check both family trees to see if element is parent or not - stk_classic::mesh::Entity *family_tree_0 = element_to_family_tree_relations[0].entity(); - stk_classic::mesh::Entity *family_tree_1 = element_to_family_tree_relations[1].entity(); - - // NOTE: reversed index - when looking for FAMILY_TREE_LEVEL_0, we are looking for the family tree associated - // with this element when viewed as a child, not a parent. - if ( (family_tree_0->relations(element.entity_rank())[FAMILY_TREE_PARENT]).entity() == &element) return 1; - else if ( (family_tree_1->relations(element.entity_rank())[FAMILY_TREE_PARENT]).entity() == &element) return 0; - else - { - std::cout << "element_to_family_tree_relations[0].entity()->identifier() = " << element_to_family_tree_relations[0].entity()->identifier() - << "element_to_family_tree_relations[1].entity()->identifier() = " << element_to_family_tree_relations[1].entity()->identifier() << std::endl; - std::cout << "element_to_family_tree_relations.size() = " << element_to_family_tree_relations.size() << std::endl; - throw std::logic_error("PerceptMesh:: getFamilyTreeRelationIndex logic error 1"); - } - } - else if (level == FAMILY_TREE_LEVEL_1) - { - if (element_to_family_tree_relations.size() <= 1) - { - throw std::logic_error("PerceptMesh:: getFamilyTreeRelationIndex logic error 2"); - } - // check both family trees to see if element is parent or not - stk_classic::mesh::Entity *family_tree_0 = element_to_family_tree_relations[0].entity(); - stk_classic::mesh::Entity *family_tree_1 = element_to_family_tree_relations[1].entity(); - - if ( (family_tree_0->relations(element.entity_rank())[FAMILY_TREE_PARENT]).entity() == &element) return 0; - else if ( (family_tree_1->relations(element.entity_rank())[FAMILY_TREE_PARENT]).entity() == &element) return 1; - else - { - std::cout << "element_to_family_tree_relations[0].entity()->identifier() = " << element_to_family_tree_relations[0].entity()->identifier() - << "element_to_family_tree_relations[1].entity()->identifier() = " << element_to_family_tree_relations[1].entity()->identifier() << std::endl; - std::cout << "element_to_family_tree_relations.size() = " << element_to_family_tree_relations.size() << std::endl; - throw std::logic_error("PerceptMesh:: getFamilyTreeRelationIndex logic error 3"); - } - } - return 0; - } - - /// the element is not a parent of the 0'th family_tree relation - - bool PerceptMesh::isChildElement( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isChildElement:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isChildElement:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - // in this case, we specifically look at only the 0'th familty tree relation - unsigned element_ft_level_0 = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - if (&element == parent) - { - if (element_to_family_tree_relations[FAMILY_TREE_PARENT].identifier() != 0) - { - throw std::runtime_error("isChildElement:: bad identifier in isChildElement"); - } - return false; - } - else - return true; - } - - // either has no family tree or is a child - bool PerceptMesh::isLeafElement( const stk_classic::mesh::Entity& element) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - return true; - } - else - { - return isChildElement(element, true); - } - } - - /// the element is not a parent of any family tree relation - bool PerceptMesh::isChildElementLeaf( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isChildElementLeaf:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isChildElementLeaf:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("isChildElementLeaf:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - if (element_to_family_tree_relations.size() == 1) - return isChildElement(element, check_for_family_tree); - else - { - unsigned element_ft_level_1 = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_1, element); - - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level_1].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error(std::string("isChildElementLeaf:: family_tree_relations size=0 = ")); - } - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - if (&element == parent) - { - if (element_to_family_tree_relations[FAMILY_TREE_PARENT].identifier() != 0) - { - throw std::runtime_error("isChildElementLeaf:: bad identifier "); - } - return false; - } - return true; - } - } - - bool PerceptMesh::hasFamilyTree(const stk_classic::mesh::Entity& element) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - return false; - } - return true; - } - - /// if the element is a parent at any level, return true - bool PerceptMesh::isParentElement( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isParentElement:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isParentElement:: no FAMILY_TREE_RANK relations: element"); - } - else - { - // has no family tree, can't be a parent - return false; - } - } - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("isParentElement:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - bool isParent = false; - for (unsigned i_ft_rel = 0; i_ft_rel < element_to_family_tree_relations.size(); i_ft_rel++) - { - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[i_ft_rel].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - std::cout << "isParentElement:: family_tree_relations size=0, i_ft_rel= " << i_ft_rel - << " family_tree_relations.size() = " << family_tree_relations.size() - << std::endl; - throw std::logic_error(std::string("isParentElement:: family_tree_relations size=0 = ")); - } - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - if (&element == parent) - { - if (element_to_family_tree_relations[FAMILY_TREE_PARENT].identifier() != 0) - { - throw std::runtime_error("isParentElement:: bad identifier "); - } - isParent = true; - break; - } - } - return isParent; - } - - /// is element a parent at the leaf level (either there is only one level, and it's a parent, or - /// if more than one, the element is a child and a parent and its children have no children) - bool PerceptMesh::isParentElementLeaf( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isParentElementLeaf:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isParentElementLeaf:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("isParentElementLeaf:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - if (!isParentElement(element, check_for_family_tree)) - return false; - - unsigned element_ft_level = 0; - if (element_to_family_tree_relations.size() == 1) - { - //return isParentElement(element, check_for_family_tree); - element_ft_level = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - } - else - { - element_ft_level = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_1, element); - } - - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error(std::string("isParentElementLeaf:: family_tree_relations size=0 = ")); - } - for (unsigned ichild = 1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - if (isParentElement(*child, check_for_family_tree)) - { - // means this element is a grandparent - return false; - } - } - return true; - } - - /// is element a parent at level 2 (meaning that it is both a child and a parent) - bool PerceptMesh::isParentElementLevel2( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isParentElementLevel2:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isParentElementLevel2:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("isParentElementLevel2:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - if (element_to_family_tree_relations.size() == 1) - return false; - - unsigned element_ft_level_1 = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_1, element); - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level_1].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error(std::string("isParentElementLevel2:: family_tree_relations size=0 = ")); - } - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - if (parent == &element) - return true; - return false; - - } - - /// is element a child with siblings with no nieces or nephews (siblings with children) - /// (alternative would be "is child and is parent not a grandparent") - bool PerceptMesh::isChildWithoutNieces( const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "isChildWithoutNieces:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("isChildWithoutNieces:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("isChildWithoutNieces:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - if (!isChildElement(element, check_for_family_tree)) - return false; - - if (element_to_family_tree_relations.size() == 2) - return false; - - unsigned element_ft_level_0 = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error(std::string("isChildWithoutNieces:: family_tree_relations size=0 = ")); - } - //stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - for (unsigned ichild = 1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - if (isParentElement(*child, check_for_family_tree)) - { - return false; - } - } - return true; - } - - // return false if we couldn't get the children - bool PerceptMesh::getChildren( const stk_classic::mesh::Entity& element, std::vector& children, bool check_for_family_tree, bool only_if_element_is_parent_leaf) - { - children.resize(0); - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - if (element_to_family_tree_relations.size()==0 ) - { - if (check_for_family_tree) - { - std::cout << "PerceptMesh::getChildren:: no FAMILY_TREE_RANK relations: element= " << element << std::endl; - print_entity(std::cout, element); - throw std::runtime_error("PerceptMesh::getChildren:: no FAMILY_TREE_RANK relations: element"); - } - else - { - return false; - } - } - - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("PerceptMesh::getChildren:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - if (!isParentElement(element, check_for_family_tree)) - return false; - - if (only_if_element_is_parent_leaf && !isParentElementLeaf(element, check_for_family_tree)) - return false; - - unsigned element_ft_level_0 = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[element_ft_level_0].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - throw std::logic_error(std::string("getChildren:: family_tree_relations size=0 = ")); - } - - for (unsigned ichild = 1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - children.push_back(child); - } - return true; - } - - void PerceptMesh::printParentChildInfo(const stk_classic::mesh::Entity& element, bool check_for_family_tree) - { - const unsigned FAMILY_TREE_RANK = element_rank() + 1u; - stk_classic::mesh::PairIterRelation element_to_family_tree_relations = element.relations(FAMILY_TREE_RANK); - std::cout << "printParentChildInfo:: element_to_family_tree_relations.size() = " << element_to_family_tree_relations.size() << std::endl; - if (element_to_family_tree_relations.size() == 0) - { - return; - } - - if (element_to_family_tree_relations.size() > 2) - throw std::logic_error(std::string("printParentChildInfo:: too many relations = ")+toString(element_to_family_tree_relations.size())); - - bool b_isChildElement = isChildElement(element, check_for_family_tree); - bool b_isParentElement = isParentElement(element, check_for_family_tree); - bool b_isChildWithoutNieces = isChildWithoutNieces(element, check_for_family_tree); - bool b_isParentElementLeaf = isParentElementLeaf(element, check_for_family_tree); - - for (unsigned i_ft_rel = 0; i_ft_rel < element_to_family_tree_relations.size(); i_ft_rel++) - { - stk_classic::mesh::Entity *family_tree = element_to_family_tree_relations[i_ft_rel].entity(); - stk_classic::mesh::PairIterRelation family_tree_relations = family_tree->relations(element.entity_rank()); - if (family_tree_relations.size() == 0) - { - std::cout << "printParentChildInfo:: family_tree_relations size=0, i_ft_rel= " << i_ft_rel - << " family_tree_relations.size() = " << family_tree_relations.size() - << std::endl; - throw std::logic_error(std::string("printParentChildInfo:: family_tree_relations size=0 = ")); - } - //unsigned ft_index = 0; - //if (i_ft_rel==0) - // ft_index = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_0, element); - //else - // ft_index = getFamilyTreeRelationIndex(FAMILY_TREE_LEVEL_1, element); - - stk_classic::mesh::Entity *parent = family_tree_relations[FAMILY_TREE_PARENT].entity(); - std::cout << "printParentChildInfo: tree level {0,1} = " << i_ft_rel << " parent= " << parent->identifier() << " children= "; - for (unsigned ichild = 1; ichild < family_tree_relations.size(); ichild++) - { - stk_classic::mesh::Entity *child = family_tree_relations[ichild].entity(); - std::cout << child->identifier() << " "; - } - std::cout << std::endl; - } - std::cout << "printParentChildInfo: " - << " b_isChildElement= " << b_isChildElement - << " b_isParentElement= " << b_isParentElement - << " b_isChildWithoutNieces= " << b_isChildWithoutNieces - << " b_isParentElementLeaf= " << b_isParentElementLeaf; - std::cout << std::endl; - - } - - } // percept -} // stk diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.hpp deleted file mode 100644 index fc99d733eb49..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMesh.hpp +++ /dev/null @@ -1,831 +0,0 @@ -#ifndef stk_percept_PerceptMesh_hpp -#define stk_percept_PerceptMesh_hpp - -#include -#include -#include -#include - - -#include -#include -#include - -#include "ShardsInterfaceTable.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - - -#include -#include -#include - -#include "Teuchos_RCP.hpp" - -//#include "PerceptMeshReadWrite.hpp" -#include -#include - -#include - -#include - -#include - -// if this is set, use stk_mesh relations to hold parent/child information, else use special data structures for this -#define PERCEPT_USE_FAMILY_TREE 1 - -// if this is set, extra high-rank entities are allowed to be created for use in generating shared nodes (see stk_adapt/NodeRegistry) -#define PERCEPT_USE_PSEUDO_ELEMENTS 0 - -//using namespace shards; - -namespace Intrepid { - template - class Basis; -} - -namespace stk_classic { - namespace percept { - - typedef mesh::Field ScalarFieldType ; - typedef mesh::Field VectorFieldType ; - typedef mesh::Field TensorFieldType ; - typedef mesh::Field QPTensorFieldType ; - - - static const unsigned EntityRankEnd = 6; - - enum FamiltyTreeLevel { - FAMILY_TREE_LEVEL_0 = 0, - FAMILY_TREE_LEVEL_1 = 1 - }; - - enum FamiltyTreeParentIndex { - FAMILY_TREE_PARENT = 0, - FAMILY_TREE_CHILD_START_INDEX = 1 - }; - - //using namespace interface_table; - - class GMeshSpec : public Name - { - public: - explicit GMeshSpec(const std::string& name) : Name(name) {} - }; - - - struct FieldCreateOrder - { - const std::string m_name; - const unsigned m_entity_rank; - const std::vector m_dimensions; - const mesh::Part* m_part; - FieldCreateOrder(); - FieldCreateOrder(const std::string name, const unsigned entity_rank, - const std::vector dimensions, const mesh::Part* part); - }; - typedef std::vector FieldCreateOrderVec; - - class PerceptMesh - { - public: - typedef Intrepid::Basis BasisType; - typedef Teuchos::RCP BasisTypeRCP; - typedef std::map BasisTableMap; - - static std::string s_omit_part; - - public: - - //======================================================================================================================== - /// high-level interface - - // ctor constructor - /// Create a Mesh object that owns its constituent FEMMetaData and BulkData (which are created by this object) - //PerceptMesh( stk_classic::ParallelMachine comm = MPI_COMM_WORLD ); - PerceptMesh(size_t spatialDimension = 3u, stk_classic::ParallelMachine comm = MPI_COMM_WORLD ); - - /// Create a Mesh object that doesn't own its constituent FEMMetaData and BulkData, pointers to which are adopted - /// by this constructor. - PerceptMesh(const stk_classic::mesh::fem::FEMMetaData* metaData, stk_classic::mesh::BulkData* bulkData, bool isCommitted=true); - - /// reads and commits mesh, editing disabled - void - open_read_only(const std::string& in_filename); - - /// reads but doesn't commit mesh, enabling edit - void - open(const std::string& in_filename); - - /// creates a new mesh using the GeneratedMesh fixture with spec @param gmesh_spec, Read Only mode, no edits allowed - void - new_mesh_read_only(const GMeshSpec gmesh_spec); - - /// creates a new mesh using the GeneratedMesh fixture with spec @param gmesh_spec - void - new_mesh(const GMeshSpec gmesh_spec); - - /// add a field to the mesh - stk_classic::mesh::FieldBase * - add_field(const std::string& name, const unsigned entity_rank, int vectorDimension=0, const std::string part_name="universal_part"); - - stk_classic::mesh::FieldBase * - get_field(const std::string& name); - - /// commits mesh - any operations done on a non-committed mesh, except to add fields will throw an exception - void - commit(); - - /// reopens the mesh for editing - warning, this operation writes the mesh to a temp file then re-reads it and - /// thus recreates the internal FEMMetaData and BulkData - void - reopen(const std::string temp_file_name="percept_tmp.e"); - - /// commits mesh if not committed and saves it in new file - void - save_as(const std::string& out_filename); - - /// closes this mesh, deleting its data - void - close(); - - /// print number of parts and fields, and info on each - void - print_info(std::ostream& stream, std::string header="", int print_level=0, bool do_endl=true); - - /// print number of parts and fields, and info on each - void - print_info(std::string header="", int print_level = 0, bool do_endl=true); - - /// print the fields defined on the mesh - void - print_fields(std::string header=""); - - int - get_spatial_dim(); - - int - get_number_elements(); - - int - get_number_nodes(); - - int - get_number_edges(); - - int - get_number_elements_locally_owned(); - - /// parallel rank - unsigned get_rank() { return get_bulk_data()->parallel_rank(); } - unsigned get_parallel_rank() { return get_bulk_data()->parallel_rank(); } - unsigned get_parallel_size() { return get_bulk_data()->parallel_size(); } - - /// print a node, edge, element, etc; optionally pass in a field to dump data associated with the entity - void print_entity(const stk_classic::mesh::Entity& entity, stk_classic::mesh::FieldBase* field=0) { print_entity(std::cout, entity, field); }; - /// shorter output for print_entity - std::string print_entity_compact(const stk_classic::mesh::Entity& entity, stk_classic::mesh::FieldBase* field=0); - - /// print elements on the given part - void dump_elements(const std::string& partName = ""); - /// compact print of elements on the given part - void dump_elements_compact(const std::string& partName = ""); - - /// get the low-level bulk data pointer from stk_mesh - stk_classic::mesh::BulkData * get_bulk_data(); - /// get the low-level meta data pointer from stk_mesh - stk_classic::mesh::fem::FEMMetaData * get_fem_meta_data(); - - /// get a pointer to a stk_mesh Part with the given name - mesh::Part* get_part(const std::string& part_name) { return get_non_const_part(part_name); } - - // entity data setter/getters - /// get the value of a field on the given entity; if a vector field, pass in the index of the vector required (ordinal) - double get_field_data(const stk_classic::mesh::FieldBase *field, const mesh::Entity* entity, unsigned ordinal=0) - { - double *val= field_data_entity(field,*entity); - return val ? val[ordinal] : 0.0; - } - /// set the value of a field on the given entity; if a vector field, pass in the index of the vector required (ordinal) - void set_field_data(double value, const stk_classic::mesh::FieldBase *field, const mesh::Entity* entity, unsigned ordinal=0 ) - { - double *val= field_data_entity(field,*entity); - if( val) val[ordinal] = value; - } - - /// get the value of a field on the given node; if a vector field, pass in the index of the vector required (ordinal) - double get_node_field_data(stk_classic::mesh::FieldBase *field, const mesh::EntityId node_id, unsigned ordinal=0) - { - double *val = node_field_data(field, node_id); - return val ? val[ordinal] : 0.0; - } - /// set the value of a field on the given node; if a vector field, pass in the index of the vector required (ordinal) - void set_node_field_data(double value, stk_classic::mesh::FieldBase *field, const mesh::EntityId node_id, unsigned ordinal=0) - { - double *val = node_field_data(field, node_id); - if( val) val[ordinal] = value; - } - - /// get a pointer to a node with given id - stk_classic::mesh::Entity *get_node(const mesh::EntityId node_id) - { - return get_bulk_data()->get_entity(node_rank(), node_id); - } - - /// get a pointer to an element with given id - stk_classic::mesh::Entity *get_element(const mesh::EntityId element_id) - { - return get_bulk_data()->get_entity(element_rank(), element_id); - } - - /// get a pointer to an entity with given id - stk_classic::mesh::Entity *get_entity( mesh::EntityRank rank, const mesh::EntityId id) - { - return get_bulk_data()->get_entity(rank, id); - } - - /// find and return pointer to node closest to given point - in parallel, check return for null (if null, closest node is on another proc) - stk_classic::mesh::Entity *get_node(double x, double y, double z=0, double t=0) ; - - /// find and return pointer to element that contains given point - in parallel, check return for null (if null, element containing point is on another proc) - stk_classic::mesh::Entity *get_element(double x, double y, double z=0, double t=0) ; - - /// return true if the two meshes are different; if @param print is true, print diffs; set print_all_field_diffs to get more output - static bool mesh_difference(PerceptMesh& mesh1, PerceptMesh& mesh2, - std::string msg, - bool print=true, bool print_all_field_diffs=false); - - /// return a pointer to the field containing node coordinates - VectorFieldType* get_coordinates_field() { - // this should have been set by a previous internal call to setCoordinatesField - return m_coordinatesField; - } - - /// return the rank of a node - stk_classic::mesh::EntityRank node_rank() const - { - return m_metaData->node_rank(); - } - - /** \brief Returns the edge rank which changes depending on spatial dimension - */ - stk_classic::mesh::EntityRank edge_rank() const - { - return m_metaData->edge_rank(); - } - - /** \brief Returns the face rank which changes depending on spatial dimension - */ - stk_classic::mesh::EntityRank face_rank() const - { - return m_metaData->face_rank(); - } - - /** \brief Returns the side rank which changes depending on spatial dimension - */ - stk_classic::mesh::EntityRank side_rank() const - { - return m_metaData->side_rank(); - } - - /** \brief Returns the element rank which is always equal to spatial dimension - */ - stk_classic::mesh::EntityRank element_rank() const - { - return m_metaData->element_rank(); - } - - /// set the current data in fields to the given Exodus step by reading from the database - void read_database_at_step(int step); - - /// set the current data in fields to the given Exodus time by reading from the database - /// (finds the closest step to the given time (no interpolation yet)) - void read_database_at_time(double time); - - /// return the current state of the Exodus database, 0 if not loaded yet (steps are 1-based in Exodus) - int get_current_database_step(); - /// return the current state of the Exodus database (time associated with current step) - double get_current_database_time(); - - /// return the step number closest to specified time, thus read_database_at_time(time) is equivalent to - /// read_database_at_step(get_database_step_at_time(time)) - int get_database_step_at_time(double time); - /// return the state time associated with given step - double get_database_time_at_step(int step); - /// return the number of steps in the database - int get_database_time_step_count(); - - /// transform mesh by a given 3x3 matrix - void transform_mesh(MDArray& matrix); - - /// add coordinate-like fields needed, for example, to use smoothing of geometry-projected refined meshes - /// Must be called before commit() - void add_coordinate_state_fields(); - - /// add spacing fields for having refinement obey the spacing (i.e. putting new nodes not at midpoint) - void add_spacing_fields(); - - /// set proc_rank on each element - void set_proc_rank_field(stk_classic::mesh::FieldBase *proc_rank_field=0); - - /// get number of coordinate field states needed - bool has_coordinate_state_fields() { return m_num_coordinate_field_states != 1; } - - /// copy field state data from one state (src_state) to another (dest_state) - void copy_field_state(stk_classic::mesh::FieldBase* field, unsigned dest_state, unsigned src_state); - - /// copy field data from one field (field_src) to another (field_dest) - void copy_field(stk_classic::mesh::FieldBase* field_dest, stk_classic::mesh::FieldBase* field_src); - - /// axpby calculates: y = alpha*x + beta*y - void nodal_field_state_axpby(stk_classic::mesh::FieldBase* field, double alpha, unsigned x_state, double beta, unsigned y_state); - - /// axpby calculates: y = alpha*x + beta*y - void nodal_field_axpby(double alpha, stk_classic::mesh::FieldBase* field_x, double beta, stk_classic::mesh::FieldBase* field_y); - - /// axpbypgz calculates: z = alpha*x + beta*y + gamma*z - void nodal_field_state_axpbypgz(stk_classic::mesh::FieldBase* field, double alpha, unsigned x_state, double beta, unsigned y_state, double gamma, unsigned z_state); - - /// axpbypgz calculates: z = alpha*x + beta*y + gamma*z - void nodal_field_axpbypgz(double alpha, stk_classic::mesh::FieldBase* field_x, - double beta, stk_classic::mesh::FieldBase* field_y, - double gamma, stk_classic::mesh::FieldBase* field_z); - - /// dot calculates: x.y - double nodal_field_dot(stk_classic::mesh::FieldBase* field_x, stk_classic::mesh::FieldBase* field_y); - - /// set field to constant value - void nodal_field_set_value(stk_classic::mesh::FieldBase* field_x, double value=0.0); - - /// remove blocks in the mesh used solely for geometry association, during output of the mesh to Exodus. - /// @param geometry_file_name = name of the OpenNURBS file (*.3dm) containing the geometry info - /// @note Only available when Percept is configured with STK_PERCEPT_HAS_GEOMETRY - void remove_geometry_blocks_on_output(std::string geometry_file_name); - - -#ifndef SWIG - //======================================================================================================================== - // low-level interfaces - - void set_sync_io_regions(bool val) { m_sync_io_regions = val; } - - - /// transform mesh by a given 3x3 matrix - void transform_mesh(Math::Matrix& matrix); - - /// return true if the two meshes are different; if @param print is true, print diffs; set print_all_field_diffs to get more output - static bool mesh_difference(stk_classic::mesh::fem::FEMMetaData& metaData_1, - stk_classic::mesh::fem::FEMMetaData& metaData_2, - stk_classic::mesh::BulkData& bulkData_1, - stk_classic::mesh::BulkData& bulkData_2, - std::string msg, - bool print=true, bool print_all_field_diffs=false); - - - mesh::Part* get_non_const_part(const std::string& part_name); - - /// opens an empty mesh, with a commit - void - openEmpty(); - - stk_classic::mesh::Entity *get_closest_node(double x, double y, double z=0, double t=0, double *sum_min_ret=0) ; - - //PerceptMesh(const stk_classic::mesh::MetaData* metaData, stk_classic::mesh::BulkData* bulkData, bool isCommitted=true); - - ~PerceptMesh() ; - void init( stk_classic::ParallelMachine comm = MPI_COMM_WORLD, bool no_alloc=false ); // FIXME - make private - void destroy(); // FIXME - make private - - const mesh::Part* - getPart(const std::string& part_name) ; - - void print_entity(std::ostream& out, const stk_classic::mesh::Entity& entity, stk_classic::mesh::FieldBase* field=0); - - // allow setting spatial dim after creation (for compatability with new FEMMetaData) - void setSpatialDim(int sd); - - // streaming refine mesh - void setStreamingSize(int streaming_size) { m_streaming_size= streaming_size; } - int getStreamingSize() { return m_streaming_size; } - - /// reads the given file into a temporary model and prints info about it - void dump(const std::string& file=""); - - bool isGhostElement(const stk_classic::mesh::Entity& element) - { - //throw std::runtime_error("not impl"); // FIXME - bool isGhost = element.owner_rank() != get_rank(); - return isGhost; - } - - // checks if this entity has a duplicate (ie all nodes are the same) - bool - check_entity_duplicate(stk_classic::mesh::Entity& entity); - - void delete_side_sets(); - - /// add some fields that are useful for debugging or for exporting meshes to Mesquite - must be - /// done before commit() - void addParallelInfoFields(bool elemental, bool nodal, - std::string elemental_proc_rank_name = "proc_rank", - std::string nodal_fixed_flag="fixed", // boundary flag for telling Mesquite these nodes shouldn't be moved - std::string nodal_global_id_name="GLOBAL_ID", - std::string nodal_proc_id_name="PROCESSOR_ID", - std::string nodal_local_id_name="LOCAL_ID"); - - /// fill the fields from addParallelInfoFields with data from stk_mesh database - void populateParallelInfoFields(bool elemental, bool nodal, - stk_classic::mesh::Selector* fixed_node_selector=0, - std::string elemental_proc_rank_name = "proc_rank", - std::string nodal_fixed_flag="fixed", // boundary flag for telling Mesquite these nodes shouldn't be moved - std::string nodal_global_id_name="GLOBAL_ID", - std::string nodal_proc_id_name="PROCESSOR_ID", - std::string nodal_local_id_name="LOCAL_ID"); - - /** - * A family tree relation holds the parent/child relations for a refined mesh. - * - * Case 0: a single refinement of a parent P_0 and its children C_0_0, C_0_1,...,C_0_N leads to a new - * family tree entity FT_0 that has down relations to {P_0, C_0_0, C_0_1,...,C_0_N} - * The back pointers from P_0, C_0_0, ... are initially stored as the 0'th index of their relations, - * i.e.: P_0.relations(FAMILY_TREE_RANK)[0] --> FT_0, - * C_0_0.relations(FAMILY_TREE_RANK)[0] --> FT_0, etc. - * Case 1: a previously refined child, say C_0_1, renamed to P_0_1, gets further refined leading to - * a new family tree entity, FT_1 - * pointing to: {P_0_1, C_0_1_0, C_0_1_1,... } - * but, now the relations indexing changes (actually, we can't predict what it will be, thus the - * need for this function getFamilyTreeRelationIndex): - * P_0_1.relations(FAMILY_TREE_RANK)[0] --> FT_1 - * P_0_1.relations(FAMILY_TREE_RANK)[1] --> FT_0 - * etc. - * So, we use this function to look for the family tree corresponding to if we are looking for the first - * level (if there's only one level, or we are looking for the family tree associated with the element - * when it was a child for the first time), orthe "level 1" family tree (corresponding to Case 1 - * where we are looking for the family tree of the element associated with it being a parent). - * - */ - unsigned getFamilyTreeRelationIndex(FamiltyTreeLevel level, const stk_classic::mesh::Entity& element); - - /// the element is not a parent of the 0'th family_tree relation - bool isChildElement( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - // either has no family tree or is a child - bool isLeafElement( const stk_classic::mesh::Entity& element); - - /// the element is not a parent of any family tree relation - bool isChildElementLeaf( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - bool hasFamilyTree(const stk_classic::mesh::Entity& element); - - /// if the element is a parent at any level, return true - bool isParentElement( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - /// is element a parent at the leaf level (either there is only one level, and it's a parent, or - /// if more than one, the element is a child and a parent and its children have no children) - bool isParentElementLeaf( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - /// is element a parent at level 2 (meaning that it is both a child and a parent) - bool isParentElementLevel2( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - /// is element a child with siblings with no nieces or nephews (siblings with children) - /// (alternative would be "is child and is parent not a grandparent") - bool isChildWithoutNieces( const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - // return false if we couldn't get the children - bool getChildren( const stk_classic::mesh::Entity& element, std::vector& children, bool check_for_family_tree=true, bool only_if_element_is_parent_leaf=false); - - void printParentChildInfo(const stk_classic::mesh::Entity& element, bool check_for_family_tree=true); - - static inline - stk_classic::mesh::EntityRank fem_entity_rank( unsigned int t ) { - return t < EntityRankEnd ? stk_classic::mesh::EntityRank(t) : stk_classic::mesh::InvalidEntityRank ; - } - - - stk_classic::mesh::Entity & createOrGetNode(stk_classic::mesh::EntityId nid, double* x=0); - - void createEntities(stk_classic::mesh::EntityRank entityRank, int count, std::vector& requested_entities); - - - static double * field_data(const stk_classic::mesh::FieldBase *field, const stk_classic::mesh::Bucket & bucket, unsigned *stride=0); - static double * field_data(const stk_classic::mesh::FieldBase *field, const mesh::Entity& node, unsigned *stride=0); - static double * field_data_entity(const stk_classic::mesh::FieldBase *field, const mesh::Entity& entity, unsigned *stride=0); - - static inline double * - field_data_inlined(const mesh::FieldBase *field, const mesh::Entity& node) - { - return field_data(field, node); -// return -// field->rank() == 0 ? -// stk_classic::mesh::field_data( *static_cast(field) , node ) -// : -// stk_classic::mesh::field_data( *static_cast(field) , node ); - } - - - double * node_field_data(stk_classic::mesh::FieldBase *field, const mesh::EntityId node_id); - - static BasisTypeRCP getBasis(shards::CellTopology& topo); - static void setupBasisTable(); - - void nodalOpLoop(GenericFunction& nodalOp, stk_classic::mesh::FieldBase *field=0, stk_classic::mesh::Selector* selector=0); - void elementOpLoop(ElementOp& elementOp, stk_classic::mesh::FieldBase *field=0, stk_classic::mesh::Part *part = 0); - void bucketOpLoop(BucketOp& bucketOp, stk_classic::mesh::FieldBase *field=0, stk_classic::mesh::Part *part = 0); - void elementOpLoop(ElementOp& elementOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Selector* selector, bool is_surface_norm=false ); - void bucketOpLoop(BucketOp& bucketOp, stk_classic::mesh::FieldBase *field, stk_classic::mesh::Selector* selector, bool is_surface_norm=false ); - - static unsigned size1(const stk_classic::mesh::Bucket& bucket) { return bucket.size(); } - static unsigned size1(const stk_classic::mesh::Entity& element) { return 1; } - - /// \brief Fill the array cellNodes(numCells, numNodesPerCell, nDof) with DOF values from the given Field - /// The stride of the data (last dimension in cellNodes) is taken to be that of the field's stride; however, - /// in some cases you may want to pass in an array where nDof is less than the stride (e.g., pull out 2 - /// coordinates from a 3D coordinate field). In that case, the dataStride argument can be set (to e.g. "2"). - template - static void fillCellNodes( const stk_classic::mesh::Bucket &bucket, - //stk_classic::mesh::Field& coord_field, - //VectorFieldType& coord_field, - mesh::FieldBase* field, - ArrayType& cellNodes, unsigned dataStride=0 ); - - /// \brief see comment for fillCellNodes(Bucket& ...) - template - static void fillCellNodes( const stk_classic::mesh::Entity &element, - //stk_classic::mesh::Field& coord_field, - //VectorFieldType& coord_field, - mesh::FieldBase* field, - ArrayType& cellNodes, unsigned dataStride=0 ); - - double edge_length_ave(const stk_classic::mesh::Entity &entity, mesh::FieldBase* coord_field = 0); - - static void findMinMaxEdgeLength(const mesh::Bucket &bucket, stk_classic::mesh::Field& coord_field, - Intrepid::FieldContainer& elem_min_edge_length, Intrepid::FieldContainer& elem_max_edge_length); - - static void - element_side_nodes( const mesh::Entity & elem , int local_side_id, stk_classic::mesh::EntityRank side_entity_rank, std::vector& side_node_entities ); - - static void - element_side_permutation(const mesh::Entity& element, const mesh::Entity& side, unsigned iSubDimOrd, int& returnedIndex, int& returnedPolarity); - - // FIXME - SameRankRelation& adapt_parent_to_child_relations() { return m_adapt_parent_to_child_relations; } - - bool - isBoundarySurface(mesh::Part& block, mesh::Part& surface); - - /// here @param thing is a Part, Bucket, Entity, or Field or BulkData - template - static - const stk_classic::mesh::fem::FEMMetaData& get_fem_meta_data(const T& thing) - { - //const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(thing); - const stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get ( thing ); - return fem_meta; - } - - /// here @param thing is a Part, Bucket, Entity - template - static - const CellTopologyData * get_cell_topology(const T& thing) - { - const CellTopologyData * cell_topo_data = mesh::fem::get_cell_topology(thing).getCellTopologyData(); - return cell_topo_data; - } - - const stk_classic::mesh::PartVector& get_io_omitted_parts() { return m_io_omitted_parts; } - void set_io_omitted_parts(stk_classic::mesh::PartVector& io_omitted_parts) { m_io_omitted_parts = io_omitted_parts; } - - - private: - - /// reads meta data, commits it, reads bulk data - void readModel( const std::string& in_filename ); - - /// read with no commit - void read_metaDataNoCommit( const std::string& in_filename ); - - /// create with no commit - void create_metaDataNoCommit( const std::string& gmesh_spec); - - void commit_metaData(); - - /// read the bulk data (no op in create mode) - void readBulkData(); - - /// Convenience method to read a model's meta data, create some new fields, commit meta data then read the bulk data - /// deprecated - void readModelAndCreateOptionalFields(const std::string file, bool print, FieldCreateOrderVec create_field); - - /// after the meta data is read or created, create some fields using this method, then you can commit and read bulk data(if in - /// reading mode, else no need to read bulk data in create mode) - // deprecated - void createFields(bool print, FieldCreateOrderVec create_field = FieldCreateOrderVec()); - - /// Cache internal pointer to coordinate field - void setCoordinatesField(); - - // look for omitted parts - void checkForPartsToAvoidWriting(); - - // write in exodus format to given file - void writeModel( const std::string& out_filename ); - - stk_classic::mesh::FieldBase * createField(const std::string& name, const unsigned entity_rank, const std::vector& dimensions, - const stk_classic::mesh::Part* arg_part=0); - - //static void transformMesh(GenericFunction& coordinate_transform); - -#endif // SWIG - - private: - //stk_classic::mesh::fem::FEMMetaData * m_fem_meta_data; - stk_classic::mesh::fem::FEMMetaData * m_metaData; - stk_classic::mesh::BulkData * m_bulkData; - stk_classic::io::util::Gmesh_STKmesh_Fixture* m_fixture; - //Teuchos::RCP m_iossRegion; - Ioss::Region* m_iossRegion; // the input region - Teuchos::RCP m_iossMeshData; - bool m_iossMeshData_created; - bool m_sync_io_regions; - VectorFieldType* m_coordinatesField; - int m_spatialDim; - bool m_ownData; - bool m_isCommitted; - bool m_isOpen; - bool m_isInitialized; - bool m_isAdopted; - bool m_dontCheckState; - std::string m_filename; - stk_classic::ParallelMachine m_comm; - - //static std::map m_basisTable; - static BasisTableMap m_basisTable; - - SameRankRelation m_adapt_parent_to_child_relations; - - stk_classic::mesh::PartVector m_io_omitted_parts; - - // normally 0, unless using streaming refine - int m_streaming_size; - - Searcher * m_searcher; - - int m_exodusStep; - double m_exodusTime; - - // state manipulation - set to 3 to enable smoothing for example - unsigned m_num_coordinate_field_states; - - private: - void checkStateSpec(const std::string& function, bool cond1=true, bool cond2=true, bool cond3=true); - - void checkState(const std::string& function) { - return checkStateSpec(function, m_isOpen, m_isInitialized, m_isCommitted); - } - - }; // class PerceptMesh - - - - class MeshTransformer : public GenericFunction - { - Math::Matrix m_rotMat; - public: - - MeshTransformer(){} - MeshTransformer(Math::Matrix& m) : m_rotMat(m) {} - virtual void operator()(MDArray& domain, MDArray& codomain, double time_value_optional=0.0) - { - double x = domain(0); - double y = domain(1); - double z = domain(2); - Math::Vector v; - v(0)=x; - v(1)=y; - v(2)=z; - v = m_rotMat * v; - codomain(0)=v(0); - codomain(1)=v(1); - codomain(2)=v(2); - } - - }; - - template<> - const CellTopologyData * - PerceptMesh::get_cell_topology(const mesh::Part& part) ; - - - -#if 0 - inline - std::string &operator<<(std::string& out, const char *str) - { - return out.append(str); - } -#endif - - // static - template - void PerceptMesh::fillCellNodes( const mesh::Bucket &bucket, - //stk_classic::mesh::Cartesian>& coord_field, - //VectorFieldType& coord_field, - mesh::FieldBase* field, - ArrayType& cellNodes, unsigned dataStrideArg) - { - unsigned number_elems = bucket.size(); - //const CellTopologyData * const bucket_cell_topo_data = stk_classic::mesh::fem::get_cell_topology(bucket).getCellTopologyData(); - const CellTopologyData * const bucket_cell_topo_data = get_cell_topology(bucket); - - shards::CellTopology cell_topo(bucket_cell_topo_data); - //unsigned numCells = number_elems; - unsigned numNodes = cell_topo.getNodeCount(); - //unsigned spaceDim = cell_topo.getDimension(); - - unsigned dataStride = dataStrideArg; - if (!dataStrideArg) - { - const stk_classic::mesh::FieldBase::Restriction & r = field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, mesh::fem::FEMMetaData::get(*field).universal_part()); - dataStride = r.dimension() ; - } - //std::cout << "bucket dataStride= " << dataStride << std::endl; - - for ( unsigned iElemInBucketOrd = 0 ; iElemInBucketOrd < number_elems ; ++iElemInBucketOrd) - { - mesh::Entity & elem = bucket[iElemInBucketOrd] ; - - if (0) std::cout << "elemOfBucket= " << elem << std::endl; - const mesh::PairIterRelation elem_nodes = elem.relations( mesh::fem::FEMMetaData::NODE_RANK ); - - // FIXME: fill field data (node coordinates) - for (unsigned iNodeOrd = 0; iNodeOrd < numNodes; iNodeOrd++) - { - mesh::Entity& node = *elem_nodes[iNodeOrd].entity(); - double * node_coord_data = PerceptMesh::field_data( field , node); - - for (unsigned iDOFOrd = 0; iDOFOrd < dataStride; iDOFOrd++) - { - cellNodes(iElemInBucketOrd, iNodeOrd, iDOFOrd) = node_coord_data[iDOFOrd]; - } - } - - - } - - } - - // static - template - void PerceptMesh::fillCellNodes( const stk_classic::mesh::Entity &element, - //stk_classic::mesh::Field& coord_field, - //VectorFieldType& coord_field, - mesh::FieldBase* field, - ArrayType& cellNodes, - unsigned dataStrideArg ) - { - unsigned dataStride = dataStrideArg; - if (!dataStrideArg) - { - const stk_classic::mesh::FieldBase::Restriction & r = field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, mesh::fem::FEMMetaData::get(*field).universal_part()); - dataStride = r.dimension() ; - } - //std::cout << "element dataStride= " << dataStride << std::endl; - const mesh::PairIterRelation element_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned numNodes = element_nodes.size(); - - unsigned iCell = 0; - for (unsigned iNodeOrd = 0; iNodeOrd < numNodes; iNodeOrd++) - { - mesh::Entity& node = *element_nodes[iNodeOrd].entity(); - double * node_coord_data = PerceptMesh::field_data( field , node); - - for (unsigned iDOFOrd = 0; iDOFOrd < dataStride; iDOFOrd++) - { - cellNodes(iCell, iNodeOrd, iDOFOrd) = node_coord_data[iDOFOrd]; - } - } - } - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMeshReadWrite.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMeshReadWrite.hpp deleted file mode 100644 index e65f124fab7e..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/PerceptMeshReadWrite.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -/** \addtogroup stk_io_module - * \{ - */ - -/** - * Example code showing a basic, but complete, mesh to results output - * coding including subsetting and periodic field input and output. - * Includes handling of nodeblocks, element blocks, nodesets, - * and sidesets. Attribute fields and distribution factor - * fields are also supported. - * - * This example can serve as the basis for adding binary IO support to - * an application. The code here uses the Ioss to/from stk_classic::mesh - * bridge functions in the stk_classic::io namespace defined in IossBridge.hpp - * include file. - */ -namespace stk_classic { - namespace percept { - namespace io_util { - - /// Declare "coordinates" field and put it on the universal part. This - /// example also defines all Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::Nodeblock as fields on the universal part. - void process_read_nodeblocks_meta (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta, int& spatial_dim); - - /// Declare a part for each element block on the Ioss::Region - /// 'region' unless the element block has the "omitted" property set - /// to the value 1. The example then iterates each element block and - /// defines any Ioss::Field::ATTRIBUTE and Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::ElementBlock as fields on the corresponding part. - void process_read_elementblocks_meta (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - - /// Declare a part for each Ioss::NodeSet on the Ioss::Region - /// 'region' unless the nodeset has the "omitted" property set - /// to the value 1. The example then iterates each nodeset and - /// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that - /// exist on the Ioss::NodeSet as fields on the corresponding - /// part. - void process_read_nodesets_meta (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - - /// Declare a part for each Ioss::SideSet on the Ioss::Region - /// 'region' unless the sideset has the "omitted" property set - /// to the value 1. The example then iterates each sideset and - /// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that - /// exist on the Ioss::SideSet as fields on the corresponding - /// part. - /// - /// Each sideblock in the active sidesets is then processed by - /// defining a part for each Ioss::SideBlock on the Ioss::SideSet - /// unless the sideblock has the "omitted" property set to the value - /// 1. The example then iterates each sideblock and defines any - /// "distribution factor" and Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::SideBlock as fields on the corresponding part. - void process_read_sidesets_meta (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - - /// NOTE: This must be called after the process_read_elementblocks() call - /// since there may be nodes that exist in the database that are - /// not part of the analysis mesh due to subsetting of the element - /// blocks. - /// - /// Populates the "coordinates" field for all active nodes in the model. - void process_read_nodeblocks_bulk (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// NOTE: This should be the first function called of any of the - /// "process_read_X" type functions that take an stk_classic::mesh::BulkData - /// argument, especially if the input Ioss::Region mesh is going to - /// be subsetted (have element blocks omitted). - /// - /// This function iterates all non-omitted element blocks and - /// declares each element (and the corresponding nodes) in the - /// element block. If there are any Ioss::Field::ATTRIBUTE fields on the element - /// block (for example, shell thickness or particle radius), then - /// that field data is alse read and the corresponding - /// stk_classic::mesh::Field populated. - void process_read_elementblocks_bulk (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// Iterates each non-omitted Ioss::NodeSet and then iterates each - /// node in the Ioss::NodeSet. If the node exists (that is, it is - /// connected to a non-omitted Ioss::ElementBlock), then that node - /// is associated with the part corresponding to this - /// Ioss::NodeSet. If the "distribution_factor" field exists, then - /// that data is also associated with the field. - void process_read_nodesets_bulk (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// Process each non-omitted Ioss::SideSet and the contained - /// non-omitted Ioss::SideBlock and associate each element-side pair with - /// the corresponding part if the underlying element is active. If - /// the "distribution_factor" field exists, then that data is also - /// associated with the corresponding field. - void process_read_sidesets_bulk (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// A minimal example function showing how field data on the - /// Ioss::Region entities can be periodically transferred to the - /// corresponding field(s) on the stk_classic::mesh entities. This would be - /// used to bring in initial condition data or interpolation data or - /// any other scenario in which data on the mesh file needs to be - /// transferred to the stk_classic::mesh fields. - void process_read_input_request (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - - /// A minimal example function showing how stk_classic::mesh field data can - /// periodically be output to a results, history, heartbeat, or - /// restart database. The scheduling would be done either in this - /// function or at a higher level and is not shown here. The - /// function iterates all parts and if there is a corresponding Ioss - /// part on the Ioss::Region, all fields defined to be output are - /// iterated and their data output to the corresponding - /// Ioss::Field. The function calls the - /// stk_classic::io::is_valid_part_field() function to determine whether the - /// field should be output and then calls the - /// stk_classic::io::field_data_to_ioss() function to do the actual output - /// of the field. - void process_output_request(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - - /// This function shows the basic calls needed to perform definition - /// and input of the mesh model and definition and periodic output - /// of a results database. The function is given the mesh filename - /// and the output filename and goes through all steps of - /// associating the filename with an Ioss::DatabaseIO object of the - /// correct type ("exodusII" in this example); creating an - /// Ioss::Region and then defining an stk_classic::mesh corresponding to - /// this mesh. The function also provides an example of how - /// specific element blocks existing in the mesh database could be - /// omitted from the analysis model. - /// - /// The example then shows how to define a results database - /// corresponding to the analysis model and periodically output the - /// results in an execute loop. - /// - /// A true application would have to provide additional - /// functionality and robustness, but the example shows how the - /// basic functionality can be provided by an application. - /// - /// Note that the paradigm illustrated here is different than the - /// mesh input and output paradigm provided in the current - /// framework. In this case, the application is responsible for the - /// majority of the IO behavior and the toolkit only provides some - /// helper functions to bridge between the Ioss and the stk_classic::mesh. - /// It is hoped that this paradigm will result in more functionality - /// for the application with less complication and overhead. - } - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.cpp deleted file mode 100644 index 4187a7efaad9..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -namespace stk_classic -{ -namespace percept -{ - -const char* ProgressMeterData::m_stateStrings[3] = {"INIT", "RUNNING", "FINI"}; - -ProgressMeter::ProgressMeter(Observable& observable) : Observer(observable) { } - -void ProgressMeter::notify(ProgressMeterData *data) -{ - // 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1 - static std::string meter = "[===================================================================================================]"; // length 101 - static std::string blanks = "[ ]"; - - int percent_done = (int)data->m_data; - - if (data->m_state == ProgressMeterData::INIT) - { - percent_done = 0; - } - else if (data->m_state == ProgressMeterData::RUNNING) - { - } - else if (data->m_state == ProgressMeterData::FINI) - { - percent_done = 100; - } - if (percent_done < 0) { std::cout << "percent_done= " << percent_done << " data= " << data->m_data << std::endl; percent_done = 0; } - if (percent_done > 100) { std::cout << "percent_done= " << percent_done << " data= " << data->m_data << std::endl; percent_done = 100; } - //std::cout << "\r" << meter.substr(0,1+percent_done) << blanks.substr(1+percent_done,100-percent_done) << " " << percent_done << " [%] " << data->m_stage; - // size_t meter_end = std::min(1+percent_done, meter.size()); - // size_t blanks_start = std::min(1+percent_done, blanks.size()-1); - // size_t blanks_end = std::min(100-percent_done, blanks.size()-blansk_start); - - std::cout << "\r" << meter.substr(0,1+percent_done) << blanks.substr(1+percent_done,100-percent_done) << " " << percent_done << " [%] " << data->m_stage; - if (data->m_state == ProgressMeterData::FINI) - { - std::cout << std::endl; - } - - std::cout << std::flush; - //sleep(1); - -} - -} -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.hpp deleted file mode 100644 index 98c39bf2a02f..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ProgressMeter.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef PROGRESS_METER_HPP -#define PROGRESS_METER_HPP - -#include -#include - -#include - -namespace stk_classic -{ -namespace percept -{ - -struct ProgressMeterData -{ - enum STATE - { - INIT, - RUNNING, - FINI - }; - - ProgressMeterData(STATE state, double data, std::string stage="") : m_state(state), m_data(data), m_stage(stage) {} - - //static std::string *m_stateStrings; - static const char* m_stateStrings[3]; - STATE m_state; - double m_data; - std::string m_stage; -}; - - - -class ProgressMeter : public Observer -{ -public: - ProgressMeter(Observable& observable); - - virtual void notify(ProgressMeterData *data) ; - -}; - - -} -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.cpp deleted file mode 100644 index a0c2c5293c85..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.cpp +++ /dev/null @@ -1,830 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include - -#define USE_GETCWD 1 -#if USE_GETCWD -#include -#include -#include -#endif - -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include "Teuchos_CommandLineProcessor.hpp" -#include "Teuchos_GlobalMPISession.hpp" -#include "Teuchos_oblackholestream.hpp" -#include "Teuchos_StandardCatchMacros.hpp" -#include "Teuchos_Version.hpp" - -#define STK_PERCEPT_DEBUG_INPUT_ARGS 0 - -/// copied and edited from stk_util/use_cases/UseCaseEnvironment - -namespace { - - OptionMaskParser dw_option_mask("stk_percept diagnostic writer"); - OptionMaskParser timer_option_mask("stk_percept timers"); - - //!stk_classic::Bootstrap x(bootstrap); - -} // namespace - -namespace stk_classic { - namespace percept { - - // Output streams - std::ostream & - out() { - static std::ostream s_out(std::cout.rdbuf()); - - return s_out; - } - - std::ostream & - pout() { - static std::ostream s_pout(std::cout.rdbuf()); - - return s_pout; - } - - std::ostream & - dout() { - static std::ostream s_dout(std::cout.rdbuf()); - - return s_dout; - } - - std::ostream & - tout() { - static std::ostream s_tout(std::cout.rdbuf()); - - return s_tout; - } - - std::ostream & - dwout() { - static stk_classic::indent_streambuf s_dwoutStreambuf(std::cout.rdbuf()); - static std::ostream s_dwout(&s_dwoutStreambuf); - - return s_dwout; - } - - // Diagnostic writer - stk_classic::diag::Writer & - dw() - { - static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - - return s_diagWriter; - } - - // Message reporting - std::ostream & - operator<<( - std::ostream & os, - message_type type) - { - switch (type & stk_classic::MSG_TYPE_MASK) { - case MSG_WARNING: - os << "Warning"; - break; - case MSG_FATAL: - os << "Fatal error"; - break; - case MSG_INFORMATION: - os << "Information"; - break; - case MSG_EXCEPTION: - os << "Exception"; - break; - case MSG_PARALLEL_EXCEPTION: - os << "Parallel exception"; - break; - } - return os; - } - - void - report_handler( - const char * message, - int type) - { - if (type & stk_classic::MSG_DEFERRED) - pout() << "Deferred " << (message_type) type << ": " << message << std::endl; - - else - out() << (message_type) type << ": " << message << std::endl; - } - - - // Timers - stk_classic::diag::TimerSet & - timerSet() - { - static stk_classic::diag::TimerSet s_timerSet(TIMER_ALL); - - return s_timerSet; - } - - stk_classic::diag::Timer &timer() { - static stk_classic::diag::Timer s_timer = stk_classic::diag::createRootTimer("root timer", timerSet()); - - return s_timer; - } - - std::string RunEnvironment::m_workingDirectory = ""; - - RunEnvironment::RunEnvironment( - int * argc, - char *** argv, bool debug) - : ParallelMachineFinalize(false), - m_comm( stk_classic::parallel_machine_init(argc, argv)), - m_need_to_finalize(true), m_debug(debug), m_processCommandLine_invoked(false), m_argv_new(0),m_argc(0),m_argv(0) - //,m_par_finalize(false) - { - internal_initialize(*argc, *argv); - } - - RunEnvironment::RunEnvironment( - int * argc, - char *** argv, - stk_classic::ParallelMachine comm, bool debug) - : ParallelMachineFinalize(false), - m_comm(comm), - m_need_to_finalize(false), m_debug(debug), m_processCommandLine_invoked(false), m_argv_new(0),m_argc(0),m_argv(0) - //,m_par_finalize(false) - - { - internal_initialize(*argc, *argv); - } - - void RunEnvironment::internal_initialize(int argc, char** argv) - { - // Broadcast argc and argv to all processors. - int parallel_rank = stk_classic::parallel_machine_rank(m_comm); - //int parallel_size = stk_classic::parallel_machine_size(m_comm); - - if (m_debug && !parallel_rank) - { - for (int i = 0; i < argc; ++i) { - const std::string s((argv)[i]); - std::cout << "tmp 1 argv["<(m_argv_new[i].c_str()); - if (m_debug && !parallel_rank) std::cout << "modified argv["<(dwout().rdbuf())->redirect(dout().rdbuf()); - - stk_classic::set_report_handler(report_handler); - - stk_classic::Bootstrap::bootstrap(); - - if (0) - for (int i = 0; i < m_argc; ++i) { - const std::string s((m_argv)[i]); - if ( s == "-h" || s == "-help" || s == "--help") { - //std::cout << "Found Help:: Usage: " << (*argv)[0] << " [options...]" << std::endl; - printHelp(); - std::exit(0); - return; - } - } - - Util::setRank(parallel_rank); - stk_classic::BroadcastArg b_arg(m_comm, argc, argv); - - bootstrap(); - - setSierraOpts(parallel_rank, argc, argv); - - } - - int RunEnvironment::processCommandLine(int argc, char** argv) - { - int parallel_rank = stk_classic::parallel_machine_rank(m_comm); - int parallel_size = stk_classic::parallel_machine_size(m_comm); - - unsigned failed = 0; - - int success = processCLP(parallel_rank, argc, argv); - failed = success == 0 ? 0u : 1u; - - if (failed) - { - std::cerr << std::endl; - std::cout << std::endl; - if ( !parallel_rank) - { - std::cout << "Command Line error: echo of args:" << std::endl; - for (int ii=0; ii < argc; ii++) - { - std::cout << "failed = 1, arg[" << ii << "] = " << (argv)[ii] << std::endl; - } - //printHelp(); - } -#if defined( STK_HAS_MPI ) - MPI_Barrier( m_comm ); - MPI_Finalize(); -#endif - //stk_classic::RuntimeDoomedSymmetric() << "parse_command_line"; - exit(1); - } - - // Parse diagnostic messages to display - dw().setPrintMask(dw_option_mask.parse(dw_opt.c_str())); - - // Parse timer metrics and classes to display - stk_classic::diag::setEnabledTimerMetricsMask(stk_classic::diag::METRICS_CPU_TIME | stk_classic::diag::METRICS_WALL_TIME); - timerSet().setEnabledTimerMask(timer_option_mask.parse(timer_opt.c_str())); - - // Set working directory - m_workingDirectory = "./"; - m_workingDirectory = directory_opt; - - if (m_workingDirectory.length() && m_workingDirectory[m_workingDirectory.length() - 1] != '/') - m_workingDirectory += "/"; - - std::string output_description = build_log_description( m_workingDirectory, parallel_rank, parallel_size); - - stk_classic::bind_output_streams(output_description); - - dout() << "Output log binding: " << output_description << std::endl; - - // Start stk_percept root timer - timer().start(); - //std::cout << "RunEnvironment::initialize done, m_workingDirectory= " << m_workingDirectory << std::endl; - m_processCommandLine_invoked = true; - - return 0; - } - - RunEnvironment::~RunEnvironment() - { - if (!m_processCommandLine_invoked) - { - throw std::runtime_error("RunEnvironment:: you must now invoke processCommandLine after constructing a RunEnvironment"); - } - stk_classic::report_deferred_messages(m_comm); - - // Stop stk_percept root timer - timer().stop(); - - stk_classic::diag::printTimersTable(out(), timer(), stk_classic::diag::METRICS_CPU_TIME | stk_classic::diag::METRICS_WALL_TIME, false, m_comm); - - stk_classic::diag::deleteRootTimer(timer()); - - static_cast(dwout().rdbuf())->redirect(std::cout.rdbuf()); - - stk_classic::unregister_ostream(tout()); - stk_classic::unregister_ostream(dout()); - stk_classic::unregister_ostream(pout()); - stk_classic::unregister_ostream(out()); - - stk_classic::unregister_log_ostream(std::cerr); - stk_classic::unregister_log_ostream(std::cout); - - if (m_argv_new) delete[] m_argv_new; - if (m_argv) delete[] m_argv; - - if (m_need_to_finalize) { - //stk_classic::parallel_machine_finalize(); - } - } - - void RunEnvironment::printHelp() - { - std::cout << "Usage: stk_adapt_exe [options...]" << std::endl; - clp.printHelpMessage("RunEnvironment",std::cout); - } - - void - RunEnvironment::bootstrap() - { - /// \todo REFACTOR Put these program options in a function - /// that can be called without the bootstrapping. - //* dw_option_mask.mask("search", stk_classic::percept::LOG_SEARCH, "log search diagnostics"); - //* dw_option_mask.mask("transfer", stk_classic::percept::LOG_TRANSFER, "log transfer diagnostics"); - //* dw_option_mask.mask("timer", stk_classic::percept::LOG_TIMER, "log timer diagnostics"); - dw_option_mask.mask("all", stk_classic::percept::LOG_ALWAYS, "log all"); - - timer_option_mask.mask("mesh", stk_classic::percept::TIMER_MESH, "mesh operations timers"); - //* timer_option_mask.mask("meshio", stk_classic::percept::TIMER_MESH_IO, "mesh I/O timers"); - //* timer_option_mask.mask("transfer", stk_classic::percept::TIMER_TRANSFER, "transfer timers"); - //* timer_option_mask.mask("search", stk_classic::percept::TIMER_SEARCH, "search timers"); - - - //!stk_classic::get_options_description().add(desc); - - } - - void RunEnvironment:: - setSierraOpts(int procRank, int argc, char* argv[]) - { - Teuchos::oblackholestream blackhole; - std::ostream &out = ( procRank == 0 ? std::cout : blackhole ); - - if (m_debug) - out << Teuchos::Teuchos_Version() << std::endl << std::endl; - - clp.setDocString("Run environment options" ); - clp.setOption("help", &help_opt, "help flag"); - clp.setOption("directory", &directory_opt, "working directory"); - clp.setOption("d", &directory_opt, "working directory"); - clp.setOption("output-log", &output_log_opt, "output log path"); - clp.setOption("o", &output_log_opt, "output log path"); - clp.setOption("pout", &pout_opt, "per-processor log file path"); - clp.setOption("dout", &dout_opt, "diagnostic output stream one of: 'cout', 'cerr', 'out' or a file path"); - clp.setOption("dw", &dw_opt, dw_option_mask.describe().c_str()); - clp.setOption("timer", &timer_opt, timer_option_mask.describe().c_str()); - clp.setOption("runtest", &runtest_opt, "runtest pid file"); - //("exit", "do nothing and then exit"); - - } - - int RunEnvironment:: - processCLP(int procRank, int argc, char* argv[]) - { - Teuchos::oblackholestream blackhole; - std::ostream &out = ( procRank == 0 ? std::cout : blackhole ); - - bool success = true; - - try { - - /* There are also two methods that control the behavior of the - command line processor. First, for the command line processor to - allow an unrecognized a command line option to be ignored (and - only have a warning printed), use: - */ - - clp.recogniseAllOptions(true); - - /* Second, by default, if the parser finds a command line option it - doesn't recognize or finds the --help option, it will throw an - std::exception. If you want prevent a command line processor from - throwing an std::exception (which is important in this program since - we don't have an try/catch around this) when it encounters a - unrecognized option or help is printed, use: - */ - clp.throwExceptions(false); - - /* We now parse the command line where argc and argv are passed to - the parse method. Note that since we have turned off std::exception - throwing above we had better grab the return argument so that - we can see what happened and act accordingly. - */ - Teuchos::CommandLineProcessor::EParseCommandLineReturn parseReturn= Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ; - try { - parseReturn = clp.parse( argc, argv ); - //std::cout << "tmp srk parseReturn = " << parseReturn << std::endl; - } - catch (std::exception exc) - { - out << "RunEnvironment::processCLP error, exc= " << exc.what() << std::endl; - return 1; - } - - if( parseReturn == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED ) { - - //std::cout << "tmp srk parseReturn = PARSE_HELP_PRINTED " << parseReturn << std::endl; - - return 1; - } - - if( parseReturn == Teuchos::CommandLineProcessor::PARSE_UNRECOGNIZED_OPTION ) { - - // std::cout << "tmp srk parseReturn = PARSE_UNRECOGNIZED_OPTION " << parseReturn << std::endl; - - if (m_debug) - out << "RunEnvironment::processCLP error, unrecognized option" << std::endl; - return 1; // Error! - } - - if( parseReturn == Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) { - if (m_debug) - out << "RunEnvironment::processCLP success" << std::endl; - } - - // Here is where you would use these command line arguments but for this example program - // we will just print the help message with the new values of the command-line arguments. - if (procRank == 0 && m_debug) - { - out << "\nPrinting help message with new values of command-line arguments ...\n\n"; - - clp.throwExceptions(false); - - clp.printHelpMessage(argv[0],out); - - clp.throwExceptions(true); - } - - // Now we will print the option values - if (procRank == 0 && m_debug) { - out << "\nPrinting user options after parsing ...\n\n"; - out << " output_log_opt= " << output_log_opt << std::endl; - out << " dw_opt= " << dw_opt << std::endl; - out << " timer_opt= " << timer_opt << std::endl; - out << " directory_opt= " << directory_opt << std::endl; - out << " help_opt= " << help_opt << std::endl; - } - - } // try - TEUCHOS_STANDARD_CATCH_STATEMENTS(true,std::cerr,success); - - if(success && m_debug) - out << "\nEnd Result: TEST PASSED" << std::endl; - - return ( success ? 0 : 1 ); - } - - // Build output logging description for binding output streams - std::string - RunEnvironment::build_log_description( - const std::string & working_directory, - int parallel_rank, - int parallel_size) - { - std::ostringstream output_description; - - // On processor 0: - // [outfile=path] [poutfile=path.n.r] [doutfile=path.n.r] out>{-|cout|cerr|outfile}+pout pout>{null|poutfile} dout>{out|doutfile} - - // On processor 1..n: - // [poutfile=path.n.r] [doutfile=path.n.r] out>pout pout>{null|poutfile} dout>{out|doutfile} - - std::string out_path = "-"; - out_path = output_log_opt; - if (out_path == "-") - out_path = "cout"; - - std::string out_ostream; - - if (!stk_classic::get_log_ostream(out_path)) - if (out_path.size() && out_path[0] != '/') - out_path = working_directory + out_path; - - if (parallel_rank == 0) { - if (!stk_classic::get_log_ostream(out_path)) { - output_description << "outfile=\"" << out_path << "\""; - out_ostream = "outfile"; - } - else - out_ostream = out_path; - } - else - out_ostream = "null"; - - std::string pout_ostream = "null"; - if (true) { - std::string pout_path = pout_opt; - if (pout_path == "-") { - std::ostringstream s; - - if (stk_classic::get_log_ostream(out_path)) - s << working_directory << "sierra.log." << parallel_size << "." << parallel_rank; - else - s << out_path << "." << parallel_size << "." << parallel_rank; - pout_path = s.str(); - } - else if (pout_path.find("/") == std::string::npos && !stk_classic::get_log_ostream(pout_path)) { - std::ostringstream s; - - s << working_directory << pout_path << "." << parallel_size << "." << parallel_rank; - pout_path = s.str(); - } - - if (!stk_classic::get_log_ostream(pout_path)) { - output_description << " poutfile=\"" << pout_path << "\""; - pout_ostream = "poutfile"; - } - else - pout_ostream = pout_path; - } - - std::string dout_ostream; - if (true) { - std::string dout_path = dout_opt; - if (!dout_path.empty() && stk_classic::is_registered_ostream(dout_path)) - dout_ostream = dout_path; - else { - std::ostringstream s; - if (dout_path.size() && dout_path[0] != '/') - s << working_directory << dout_path << "." << parallel_size << "." << parallel_rank; - else - s << dout_path << parallel_size << "." << parallel_rank; - dout_path = s.str(); - output_description << " doutfile=\"" << dout_path << "\""; - dout_ostream = "doutfile"; - } - } - else - dout_ostream = "out"; - - if (parallel_rank == 0) - output_description << " out>" << out_ostream << "+pout"; - else - output_description << " out>pout"; - - output_description << " pout>" << pout_ostream << " dout>" << dout_ostream; - - return output_description.str(); - } - - // broken - do not use - for reference purposes only - void RunEnvironment:: - doSierraLoadBalance(stk_classic::ParallelMachine comm, std::string meshFileName) - { - unsigned p_size = stk_classic::parallel_machine_size(comm); - unsigned p_rank = stk_classic::parallel_machine_rank(comm); - if (!p_rank) - { - FILE *fpipe; - std::string tmp_file = "stk_percept_tmp_loadbal.i"; - std::string command="sierra -i "+tmp_file; - command += " -j "+toString(p_size); - command += +" stk_percept_verifier_mesh -O\"--exit\""; - //const char *command="sierra -i stk_percept_tmp_loadbal.i"; - char line[256]; - - std::ofstream fout((std::string("./"+tmp_file)).c_str()); - fout << "Begin Sierra Percept\n" - << " Title None\n" - << " Begin Finite Element Model 3d_model\n" - << " Database Name = " << meshFileName << "\n" - << " End\n" - << "End\n" << std::endl; - fout.close(); - - std::cout << "command= " << command << std::endl; - if ( !(fpipe = (FILE*)popen(command.c_str(),"r")) ) - { // If fpipe is NULL - perror("Problems with pipe"); - exit(1); - } - - while ( fgets( line, sizeof line, fpipe)) - { - //printf("%s", line); - std::cout << line << std::endl; - } - pclose(fpipe); - } -#if defined(STK_HAS_MPI) - MPI_Barrier( comm ); -#endif - } - -#if USE_GETCWD - static void panic() - { - (void)perror("Unexpected library error"); - std::abort(); - } - -#define MAX_PATH 256 - //: Returns the name of the current working directory - std::string RunEnvironment:: - get_working_directory() - { - int size = MAX_PATH; - - while(true) { - char *ptr = new char[size]; - if (getcwd(ptr, size-1) != 0) { - std::string ret_str(ptr); - ret_str = ret_str +"/"; - delete [] ptr; - return ret_str; - } - if (errno != ERANGE) - panic(); - - // Need larger char* to store current working directory name. - delete [] ptr; - size += MAX_PATH; - } - } -#else - std::string RunEnvironment::get_working_directory() - { - return m_workingDirectory; - } - -#endif - - - static void runCommand(std::string command) - { - char line[256]; - - FILE *fpipe; - if ( !(fpipe = (FILE*)popen(command.c_str(),"r")) ) - { // If fpipe is NULL - perror("Problems with pipe"); - exit(1); - } - - while ( fgets( line, sizeof line, fpipe)) - { - //printf("%s", line); - std::cout << line; // << std::endl; - } - pclose(fpipe); - } - - /** - * - * input fullpath=meshFilename = some file name with a path... - * - * output: fullpath = /some/file/path/ending/with/slash/ - * output: meshFileName = ./filename.ext - * - */ - - int RunEnvironment:: - setFileNames(std::string& fullpath, std::string& meshFileName, std::string& errString) - { - int err=0; - fullpath = get_working_directory() + meshFileName; - if (meshFileName[0] == '/') - { - // already absolute - fullpath = meshFileName; - } - else if (meshFileName.length() >= 3 && (meshFileName[0] != '.' && meshFileName[1] != '/')) - { - // make it a relative path - fullpath = get_working_directory() + meshFileName; - meshFileName = "./"+meshFileName; - //fullpath = get_working_directory() + meshFileName.substr(2,meshFileName.length()-2); - } - else if (meshFileName.length() >= 3 && (meshFileName[0] == '.' && meshFileName[1] == '/')) - { - fullpath = get_working_directory() + meshFileName.substr(2,meshFileName.length()-2); - } - else - { - err = 1; - errString = "RunEnvironment::setFileNames: bad format for input file name, name= "+meshFileName; - return err; - } - - size_t found = 0; - // strip off the basename + extension - found = fullpath.find_last_of("/"); - if (found != std::string::npos) - { - fullpath = fullpath.substr(0,found); - } - if(fullpath == ".") - fullpath = "./"; - else - fullpath += "/"; - - return err; - } - - void RunEnvironment:: - doLoadBalance(stk_classic::ParallelMachine comm, std::string meshFileName) - { - - if (meshFileName.length() == 0) return; - - unsigned p_size = stk_classic::parallel_machine_size(comm); - unsigned p_rank = stk_classic::parallel_machine_rank(comm); - int err=0; - std::string errString; - - if (p_size > 1 && !p_rank) - { - std::string fullpath = meshFileName; - - std::cout << "tmp get_working_directory= " << get_working_directory() << std::endl; - std::cout << "tmp fullpath before= " << fullpath << std::endl; - - err = setFileNames(fullpath, meshFileName, errString); - - if (!err) - { - std::cout << "tmp fullpath= " << fullpath << std::endl; - std::cout << "tmp meshFileName= " << meshFileName << std::endl; - - //std::string fullpath = meshFileName; - - // - // file.exo - // file.e - unsigned extension_length = 1; - - size_t found = meshFileName.find_last_of("."); - if (found == std::string::npos) { - //throw std::runtime_error("RunEnvironment::doLoadBalance input file name must have an extension"); - err = 2; - errString = "RunEnvironment::doLoadBalance input file name must have an extension"; - } - extension_length = meshFileName.length() - found - 1; - std::string base_name = meshFileName.substr(0, meshFileName.length()-(extension_length+1)); - - std::string extension = meshFileName.substr(meshFileName.length()-extension_length, meshFileName.length()); - - std::cout << "tmp: extension= " << extension << " meshFileName= " << meshFileName << " fullpath= " << fullpath << " base_name= " << base_name << std::endl; - - std::string command="loadbal -No_subdirectory -spread -suffix_mesh " + extension+" -suffix_spread "+extension+" -p "+toString(p_size)+ " "; - command += "-R " +fullpath+" " + base_name; - //command += "-R ./ " + base_name; - - command="decomp -p "+toString(p_size)+ " -R " +fullpath+" " + meshFileName; - - std::cout << "RunEnvironment::doLoadBalance: command= " << command << std::endl; - - runCommand(command); - } - } - - stk_classic::all_reduce( comm, stk_classic::ReduceSum<1>( &err ) ); - - if (err && !p_rank) - { - std::cout << "ERROR in RunEnvironment::doLoadBalance: " << errString << std::endl; - } - if (err) - throw std::runtime_error("ERROR in RunEnvironment::doLoadBalance: " + errString ); - -#if defined(STK_HAS_MPI) - MPI_Barrier( comm ); -#endif - } - } // namespace percept -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.hpp deleted file mode 100644 index 22cce803b10e..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/RunEnvironment.hpp +++ /dev/null @@ -1,192 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_RunEnvironment_hpp -#define stk_percept_RunEnvironment_hpp - -/// copied and edited from stk_util/use_cases/UseCaseEnvironment - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "Teuchos_CommandLineProcessor.hpp" -#include "Teuchos_GlobalMPISession.hpp" -#include "Teuchos_oblackholestream.hpp" -#include "Teuchos_StandardCatchMacros.hpp" - -namespace stk_classic { - namespace percept { - - - enum LogMask { - LOG_ALWAYS = stk_classic::LOG_ALWAYS, - LOG_TRACE = stk_classic::LOG_TRACE, - LOG_TRACE_STATS = stk_classic::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = stk_classic::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = stk_classic::LOG_MEMBERS, - - LOG_APPLICATION = 0x0000010 // use this as the base for additional masks - //LOG_SEARCH = 0x0000010, - //LOG_TRANSFER = 0x0000020, - //LOG_TIMER = 0x0000040 - - }; - - /** - * @brief Class message_type ... - * - */ - enum message_type { - MSG_WARNING = stk_classic::MSG_WARNING, - MSG_FATAL = stk_classic::MSG_DOOMED, - MSG_INFORMATION, - MSG_EXCEPTION, - MSG_PARALLEL_EXCEPTION - }; - - - /** - * @brief Class type ... - * - */ - enum message_throttle_type { - MSG_APPLICATION = stk_classic::MSG_APPLICATION, - MSG_TIME_STEP - }; - - enum TimerSetMask { - TIMER_MESH = 0x00000001, ///< Enable mesh timers - // TIMER_MESH_IO = 0x00000002, ///< Enable mesh I/O timers - // TIMER_SEARCH = 0x00000004, ///< Enable search timers - // TIMER_TRANSFER = 0x00000008, ///< Enable transfer timers - TIMER_ALL = 0xFFFFFFFF, ///< Force timer to be active - - TIMER_FORCE = 0x00000000 ///< Force timer to be active - }; - - std::ostream &out(); ///< Normal output stream - std::ostream &dout(); ///< Diagnostic output stream - std::ostream &pout(); ///< Per-processor output stream (See RuntimeDeferredx) - std::ostream &tout(); ///< Regression test textual output stream - - std::ostream &dwout(); ///< Diagnostic writer stream - - // dw() definition - stk_classic::diag::Writer &dw(); -#define DWENDL stk_classic::diag::dendl - - stk_classic::diag::TimerSet &timerSet(); - - stk_classic::diag::Timer &timer(); - - void my_report_handler(const char *message, int type); - - // this little class is simply here to force an ordering in the ~RunEnvironment() dtor, so that - // parallel_machine_finalize gets called after m_comm is destroyed; but, it still only works - // if this is invoked after returning from an enclosing block of RunEnvironment. why? - class ParallelMachineFinalize - { - bool m_need_to_finalize; - public: - ParallelMachineFinalize(bool need_to_finalize=false) : m_need_to_finalize(need_to_finalize) {} - ~ParallelMachineFinalize() - { - if (m_need_to_finalize) - { - stk_classic::parallel_machine_finalize(); - } - } - }; - - class RunEnvironment : public ParallelMachineFinalize - { - - public: - // Will initialize a comm - RunEnvironment(int *argc, char ***argv, bool debug=false); - - // Assumes already-initialized comm - RunEnvironment(int *argc, char ***argv, stk_classic::ParallelMachine comm, bool debug=false); - - int processCommandLine(int argc, char **argv); - int processCommandLine() { return processCommandLine(m_argc, m_argv); } - - ~RunEnvironment(); - - void printHelp(); - - static void - doSierraLoadBalance(stk_classic::ParallelMachine comm, std::string meshFileName); - - static void - doLoadBalance(stk_classic::ParallelMachine comm, std::string meshFileName); - - std::string - build_log_description(const std::string & working_directory, - int parallel_rank, - int parallel_size); - - int get_argc() { return m_argc; } - char **get_argv() { return m_argv; } - - static std::string - get_working_directory(); - - - // command line options - Teuchos::CommandLineProcessor clp; - - std::string output_log_opt; - std::string dw_opt; - std::string timer_opt; - std::string directory_opt; - - std::string pout_opt; - std::string dout_opt; - std::string runtest_opt; - - int help_opt; - - // data - const stk_classic::ParallelMachine m_comm; - static std::string m_workingDirectory; - - private: - - static int setFileNames(std::string& fullmesh, std::string& meshFileName, std::string& errString); - - bool m_need_to_finalize; - bool m_debug; - bool m_processCommandLine_invoked; - std::string *m_argv_new; - int m_argc; - char **m_argv; - - //ParallelMachineFinalize m_par_finalize; - - int processCLP(int procRank, int argc, char* argv[]); - // shared constructor implementation; do not call directly - void internal_initialize(int argc, char **argv); - void bootstrap(); - - void setSierraOpts(int procRank, int argc, char* argv[]); - }; - - } // namespace percept -} // namespace stk_classic - -#endif // stk_percept_RunEnvironment_hpp diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/SameRankRelation.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/SameRankRelation.hpp deleted file mode 100644 index f8c3ead9cb2b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/SameRankRelation.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef stk_percept_SameRankRelation_hpp -#define stk_percept_SameRankRelation_hpp - -//#include - -#include -//#include -//#include - -/// define only one of these to be 1 -#define SAME_RANK_RELATION_MAP_TYPE_BOOST 1 -#define SAME_RANK_RELATION_MAP_TYPE_TR1 0 -#define SAME_RANK_RELATION_MAP_TYPE_STD 0 - -#if SAME_RANK_RELATION_MAP_TYPE_BOOST -#include -#endif - -#if SAME_RANK_RELATION_MAP_TYPE_STD -#include -#endif - -#if SAME_RANK_RELATION_MAP_TYPE_TR1 -#include -#endif - -namespace stk_classic { - namespace percept { - - - typedef std::vector PerceptEntityVector; - typedef stk_classic::mesh::Entity *SameRankRelationKey; - typedef PerceptEntityVector SameRankRelationValue; - typedef boost::unordered_map SameRankRelation; - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.cpp deleted file mode 100644 index 8b7c4a72bf42..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "ShardsInterfaceTable.hpp" -#include -#include - -using namespace shards; - -namespace stk_classic { - namespace percept { - - - static interface_table::elemInfoType elemInfo[NUM_ELEM_TYPES] = { - { shards_Node , getCellTopologyData< shards::Node >(), 0, shards::Node::vertex_count, shards::Node::node_count , shards_Line_2 , 0}, - { shards_Particle , getCellTopologyData< shards::Particle >(), 0, shards::Particle::vertex_count, shards::Particle::node_count , -1 , 0}, - - { shards_Line_2 , getCellTopologyData< shards::Line<2> >(), 0, shards::Line<2>::vertex_count, shards::Line<2>::node_count , shards_Quadrilateral_4 , - stk_classic::mesh::fem::set_cell_topology< shards::Line<2> > }, - - { shards_ShellLine_2 , getCellTopologyData< shards::ShellLine<2> >(), 0, shards::ShellLine<2>::vertex_count, shards::ShellLine<2>::node_count , -1 , 0}, - { shards_ShellLine_3 , getCellTopologyData< shards::ShellLine<3> >(), 0, shards::ShellLine<3>::vertex_count, shards::ShellLine<3>::node_count , -1 , 0}, - { shards_Beam_2 , getCellTopologyData< shards::Beam<2> >(), 0, shards::Beam<2>::vertex_count, shards::Beam<2>::node_count , -1 , 0}, - { shards_Beam_3 , getCellTopologyData< shards::Beam<3> >(), 0, shards::Beam<3>::vertex_count, shards::Beam<3>::node_count , -1 , 0}, - - { shards_Triangle_3 , getCellTopologyData< shards::Triangle<3> >(), 0, shards::Triangle<3>::vertex_count, shards::Triangle<3>::node_count , shards_Wedge_6 , - stk_classic::mesh::fem::set_cell_topology< shards::Triangle<3> > }, - { shards_Triangle_6 , getCellTopologyData< shards::Triangle<6> >(), 0, shards::Triangle<6>::vertex_count, shards::Triangle<6>::node_count , -1 , 0}, - { shards_ShellTriangle_3 , getCellTopologyData< shards::ShellTriangle<3> >(), 0, shards::ShellTriangle<3>::vertex_count, shards::ShellTriangle<3>::node_count , -1 , 0}, - { shards_ShellTriangle_6 , getCellTopologyData< shards::ShellTriangle<6> >(), 0, shards::ShellTriangle<6>::vertex_count, shards::ShellTriangle<6>::node_count , -1 , 0}, - - { shards_Quadrilateral_4 , getCellTopologyData< shards::Quadrilateral<4> >(), 0, shards::Quadrilateral<4>::vertex_count, shards::Quadrilateral<4>::node_count , shards_Hexahedron_8 , - stk_classic::mesh::fem::set_cell_topology< shards::Quadrilateral<4> > }, - { shards_Quadrilateral_8 , getCellTopologyData< shards::Quadrilateral<8> >(), 0, shards::Quadrilateral<8>::vertex_count, shards::Quadrilateral<8>::node_count , -1 , 0}, - { shards_Quadrilateral_9 , getCellTopologyData< shards::Quadrilateral<9> >(), 0, shards::Quadrilateral<9>::vertex_count, shards::Quadrilateral<9>::node_count , -1 , 0}, - { shards_ShellQuadrilateral_4 , getCellTopologyData< shards::ShellQuadrilateral<4> >(), 0, shards::ShellQuadrilateral<4>::vertex_count, shards::ShellQuadrilateral<4>::node_count , -1 , 0}, - { shards_ShellQuadrilateral_8 , getCellTopologyData< shards::ShellQuadrilateral<8> >(), 0, shards::ShellQuadrilateral<8>::vertex_count, shards::ShellQuadrilateral<8>::node_count , -1 , 0}, - { shards_ShellQuadrilateral_9 , getCellTopologyData< shards::ShellQuadrilateral<9> >(), 0, shards::ShellQuadrilateral<9>::vertex_count, shards::ShellQuadrilateral<9>::node_count , -1 , 0}, - - { shards_Pentagon_5 , getCellTopologyData< shards::Pentagon<5> >(), 0, shards::Pentagon<5>::vertex_count, shards::Pentagon<5>::node_count , -1 , 0}, - { shards_Hexagon_6 , getCellTopologyData< shards::Hexagon<6> >(), 0, shards::Hexagon<6>::vertex_count, shards::Hexagon<6>::node_count , -1 , 0}, - - { shards_Tetrahedron_4 , getCellTopologyData< shards::Tetrahedron<4> >(), 0, shards::Tetrahedron<4>::vertex_count, shards::Tetrahedron<4>::node_count , -1 , - stk_classic::mesh::fem::set_cell_topology< shards::Tetrahedron<4> >}, - { shards_Tetrahedron_10 , getCellTopologyData< shards::Tetrahedron<10> >(), 0, shards::Tetrahedron<10>::vertex_count, shards::Tetrahedron<10>::node_count , -1 , 0}, - - { shards_Pyramid_5 , getCellTopologyData< shards::Pyramid<5> >(), 0, shards::Pyramid<5>::vertex_count, shards::Pyramid<5>::node_count , -1 , 0}, - { shards_Pyramid_13 , getCellTopologyData< shards::Pyramid<13> >(), 0, shards::Pyramid<13>::vertex_count, shards::Pyramid<13>::node_count , -1 , 0}, - { shards_Pyramid_14 , getCellTopologyData< shards::Pyramid<14> >(), 0, shards::Pyramid<14>::vertex_count, shards::Pyramid<14>::node_count , -1 , 0}, - - { shards_Wedge_6 , getCellTopologyData< shards::Wedge<6> >(), 0, shards::Wedge<6>::vertex_count, shards::Wedge<6>::node_count , -1 , - stk_classic::mesh::fem::set_cell_topology< shards::Wedge<6> >}, - { shards_Wedge_15 , getCellTopologyData< shards::Wedge<15> >(), 0, shards::Wedge<15>::vertex_count, shards::Wedge<15>::node_count , -1 , 0}, - { shards_Wedge_18 , getCellTopologyData< shards::Wedge<18> >(), 0, shards::Wedge<18>::vertex_count, shards::Wedge<18>::node_count , -1 , 0}, - - { shards_Hexahedron_8 , getCellTopologyData< shards::Hexahedron<8> >(), 0, shards::Hexahedron<8>::vertex_count, shards::Hexahedron<8>::node_count , -1 , - stk_classic::mesh::fem::set_cell_topology< shards::Hexahedron<8> > }, - { shards_Hexahedron_20 , getCellTopologyData< shards::Hexahedron<20> >(), 0, shards::Hexahedron<20>::vertex_count, shards::Hexahedron<20>::node_count , -1 , 0}, - { shards_Hexahedron_27 , getCellTopologyData< shards::Hexahedron<27> >(), 0, shards::Hexahedron<27>::vertex_count, shards::Hexahedron<27>::node_count , -1 , 0} - - }; - - // ShardsInterfaceTable::s_elemInfo = elemInfo; - interface_table::elemInfoType *ShardsInterfaceTable::s_elemInfo = elemInfo; - - std::map ShardsInterfaceTable::s_nameToIdMap; - - ShardsInterfaceTable ShardsInterfaceTable::s_singleton; - - void ShardsInterfaceTable::buildMaps() - { - //static std::map nameToIdMap; - for (int i = 0; i < NUM_ELEM_TYPES; i++) - { - s_elemInfo[i].name = s_elemInfo[i].cellTopoData->name; - } - for (int i = 0; i < NUM_ELEM_TYPES; i++) - { - s_nameToIdMap[s_elemInfo[i].name] = i; - } - //s_nameToIdMap = nameToIdMap; - } - - int ShardsInterfaceTable::lookupShardsId(const char *name) - { - return s_nameToIdMap[name]; - } - - void ShardsInterfaceTable::checkTable() - { - for (int i = 0; i < NUM_ELEM_TYPES; i++) - { - //s_elemInfo[i] - if (s_elemInfo[i].elemEnumType != i) - { - std::ostringstream msg; - msg << "ShardsInterfaceTable error - check table's code\n"; - throw std::runtime_error( msg.str() ); - } - } - } - - } // namespace percept -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.hpp deleted file mode 100644 index 6c024752f785..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/ShardsInterfaceTable.hpp +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef stk_percept_ShardsInterfaceTable_hpp -#define stk_percept_ShardsInterfaceTable_hpp - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -namespace stk_classic { - namespace percept { - namespace interface_table { - - typedef void (*stk_set_cell_topology_fptr)(stk_classic::mesh::Part & ); - - - enum ElemTypes { - shards_Node , - shards_Particle , - - shards_Line_2 , - shards_ShellLine_2 , - shards_ShellLine_3 , - shards_Beam_2 , - shards_Beam_3 , - - shards_Triangle_3 , - shards_Triangle_6 , - shards_ShellTriangle_3 , - shards_ShellTriangle_6 , - - shards_Quadrilateral_4 , - shards_Quadrilateral_8 , - shards_Quadrilateral_9 , - shards_ShellQuadrilateral_4 , - shards_ShellQuadrilateral_8 , - shards_ShellQuadrilateral_9 , - - shards_Pentagon_5 , - shards_Hexagon_6 , - - shards_Tetrahedron_4 , - shards_Tetrahedron_10 , - - shards_Pyramid_5 , - shards_Pyramid_13 , - shards_Pyramid_14 , - - shards_Wedge_6 , - shards_Wedge_15 , - shards_Wedge_18 , - - shards_Hexahedron_8 , - shards_Hexahedron_20 , - shards_Hexahedron_27 , - - - NUM_ELEM_TYPES }; - - typedef struct - { - //unsigned elemEnumType; - ElemTypes elemEnumType; - const CellTopologyData *cellTopoData; - const char *name; - unsigned vertex_count; - unsigned node_count; - int sweptElemType; - stk_set_cell_topology_fptr setCellTopoFptr; - } elemInfoType; - - - } // namespace interface_table - - using namespace interface_table; - - struct lstr { - bool operator()(const char *a, const char *b) const { return strcmp(a,b)<0; } - }; - - class ShardsInterfaceTable - { - ShardsInterfaceTable() { - checkTable(); - buildMaps(); - } - void checkTable(); - void buildMaps(); - static std::map s_nameToIdMap; - - public: - static ShardsInterfaceTable s_singleton; - static elemInfoType *s_elemInfo; - int lookupShardsId(const char *); - - }; //class ShardsInterfaceTable - - } // namespace percept -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.cpp deleted file mode 100644 index f45a1a709ec4..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "TopologyVerifier.hpp" -#include -#include "PerceptMesh.hpp" - -namespace stk_classic -{ - namespace percept - { - using namespace interface_table; - - TopologyVerifier::TopologyVerifier() - { - build_invalid_edge_sets(); - } - - void TopologyVerifier::build_invalid_edge_sets() - { - // build tables for edge checking - const CellTopologyData *topos[NELT]; - - m_invalid_edge_set = std::vector(NELT); - - for (unsigned i = 0; i < NELT; i++) - { - topos[i] = ShardsInterfaceTable::s_elemInfo[i].cellTopoData; - } - //topos[interface_table::shards_Wedge_6] = shards::getCellTopologyData >(); - // etc. FIXME - - for (unsigned ielt = 0; ielt < NELT; ielt++) - { - if (topos[ielt]) - { - // generate all possible edges in the element, including diagonals, etc. - unsigned vertex_count = topos[ielt]->vertex_count; - if (vertex_count > 1) - { - for (unsigned iv = 0; iv < vertex_count-1; iv++) - { - for (unsigned jv = iv+1; jv < vertex_count; jv++) - { - MyEdge edge(iv, jv); - m_invalid_edge_set[ielt].insert(edge); - } - } - - // remove the actual valid edges so only invalid remain - unsigned edge_count = topos[ielt]->edge_count; - for (unsigned ie = 0; ie < edge_count; ie++) - { - MyEdge edge(topos[ielt]->edge[ie].node[0], topos[ielt]->edge[ie].node[1]); - m_invalid_edge_set[ielt].erase(edge); - } - } - } - } - - } - - /// return true if topology is bad - bool TopologyVerifier::isTopologyBad( mesh::Entity &elem) - { - const CellTopologyData * const top = stk_classic::percept::PerceptMesh::get_cell_topology(elem); - - const mesh::PairIterRelation elem_nodes = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - -#if 0 - std::cout << "top->node_count = " << top->node_count << "\n"; - std::cout << "elem_nodes.size() = " << elem_nodes.size() << "\n"; - std::cout.flush(); -#endif - - for (unsigned j = 0; j < elem_nodes.size()-1; j++) - { - mesh::Entity & node = * elem_nodes[ j ].entity(); - - for ( unsigned i = j+1 ; i < top->node_count ; ++i ) { - { - mesh::Entity & nodei = * elem_nodes[ i ].entity(); - if (node.identifier() == nodei.identifier()) - { - return true; - } - } - } - } - return false; - } - - - - /** - * Algorithm: - * 1. for each element, loop over its edges, for each edge's node, loop over elements attached to node - * 1a. for each neighboring element, check if current edge is invalid - */ - bool TopologyVerifier::isTopologyBad(stk_classic::mesh::BulkData& bulk) //, stk_classic::mesh::Part& mesh_part ) - { - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - //mesh::Selector select_owned( meta_data.locally_owned_part() ); - - const std::vector & buckets = bulk.buckets(meta.element_rank() ); - - for ( std::vector::const_iterator ik = buckets.begin() ; ik != buckets.end() ; ++ik ) - { - // if ( select_owned( **ik ) ) {... - - const mesh::Bucket & bucket = **ik ; - - // Number of elems in this bucket of elems and elem field data - const unsigned number_elems = bucket.size(); - - double * elem_node_data = field_data( *coord_field , bucket.begin() ); - //double * elem_centroid_data = field_data( elem_centroid_field , bucket.begin() ); - - // FIXME - if (0) { elem_node_data[0]++;} - -#if 1 - const CellTopologyData * const bucket_cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - int bucket_shardsId = ShardsInterfaceTable::s_singleton.lookupShardsId(bucket_cell_topo->name); -#endif - - //if (0) { std::cout << bucket_cell_topo->name; } - if (0) { std::cout << "bucket_shardsId= " << bucket_shardsId << " name= " << bucket_cell_topo->name << std::endl; } - - if (0) { std::cout << "number_elems= " << number_elems << std::endl;} - - for ( unsigned i = 0 ; i < number_elems ; ++i) - { - mesh::Entity & elem = bucket[i] ; - bool isDuplicateNode = isTopologyBad(elem); - if (isDuplicateNode) - { - std::cout << "duplicate node found: elem = " << elem << std::endl; - return true; - } - if (0) std::cout << "elemOfBucket= " << elem << std::endl; - const mesh::PairIterRelation elem_nodes = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - //const CellTopologyData * const cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(elem); - const CellTopologyData * const cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(elem); - int shardsId = ShardsInterfaceTable::s_singleton.lookupShardsId(cell_topo->name); - if (0) { std::cout << "shardsId= " << shardsId << " name= " << cell_topo->name << std::endl; } - - for (unsigned iedgeOrd = 0; iedgeOrd < cell_topo->edge_count; iedgeOrd++) - { - //const CellTopologyData_Subcell& edge = - - unsigned in0 = cell_topo->edge[iedgeOrd].node[0]; - unsigned in1 = cell_topo->edge[iedgeOrd].node[1]; - - MyEdge potential_bad_edge(elem_nodes[in0].entity()->identifier(), elem_nodes[in1].entity()->identifier()); - //if (potential_bad_edge.getId0() == 3 && potential_bad_edge.getId1() == 6) - if (0) std::cout << "potential_bad_edge: " << potential_bad_edge.getId0() << " " << potential_bad_edge.getId1() << std::endl; - } - for (unsigned iedgeOrd = 0; iedgeOrd < cell_topo->edge_count; iedgeOrd++) - { - //const CellTopologyData_Subcell& edge = - - unsigned in0 = cell_topo->edge[iedgeOrd].node[0]; - unsigned in1 = cell_topo->edge[iedgeOrd].node[1]; - - MyEdge potential_bad_edge(elem_nodes[in0].entity()->identifier(), elem_nodes[in1].entity()->identifier()); - //if (potential_bad_edge.getId0() == 3 && potential_bad_edge.getId1() == 6) - if (0) std::cout << "potential_bad_edge: " << potential_bad_edge.getId0() << " " << potential_bad_edge.getId1() << std::endl; - - if (0 && MyEdge(3,6) == potential_bad_edge) - { - std::cout << "bad edge" << std::endl; - } - - for (unsigned inodeOnPotBadEdge = 0; inodeOnPotBadEdge < 2; inodeOnPotBadEdge++) - { - unsigned inodeOnPotBadEdgeInElem = cell_topo->edge[iedgeOrd].node[inodeOnPotBadEdge]; - - const mesh::PairIterRelation node_elems = elem_nodes[inodeOnPotBadEdgeInElem].entity()->relations( meta.element_rank() ); - unsigned num_elems_on_node = node_elems.size(); - - for (unsigned iele = 0; iele < num_elems_on_node; iele++) - { - mesh::Entity & elemOnNode = *node_elems[iele].entity(); - const mesh::PairIterRelation elemOnNode_nodes = elemOnNode.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - const CellTopologyData * const local_cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(elemOnNode); - int local_shardsId = ShardsInterfaceTable::s_singleton.lookupShardsId(local_cell_topo->name); - //if (1) { std::cout << "shardsId= " << shardsId << " name= " << cell_topo->name << std::endl; } - - if (0) std::cout << "elemOnNode= " << elemOnNode << std::endl; - unsigned num_invalid_edges = m_invalid_edge_set[local_shardsId].size(); - if (0) { std::cout << num_invalid_edges; } - for (invalid_edge_set_type::iterator inv_edge = m_invalid_edge_set[local_shardsId].begin(); - inv_edge != m_invalid_edge_set[local_shardsId].end(); inv_edge++) - { - MyEdge globalIdInvEdge( elemOnNode_nodes[ (*inv_edge).getId0()].entity()->identifier(), - elemOnNode_nodes[ (*inv_edge).getId1()].entity()->identifier() ); - - if (0) std::cout << "globalIdInvEdge: " << globalIdInvEdge.getId0() << " " << globalIdInvEdge.getId1() << std::endl; - if(potential_bad_edge == globalIdInvEdge) - { - return true; - } - } - } - } - } - - - } - } - return false; - } - - - }//namespace percept -}//namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.hpp deleted file mode 100644 index 255b8f7ecf31..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/TopologyVerifier.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef stk_encr_TopologyVerifier_hpp -#define stk_encr_TopologyVerifier_hpp - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Edge.hpp" -#include "ShardsInterfaceTable.hpp" - - -namespace stk_classic -{ - namespace percept - { - - class TopologyVerifier // consider: : MeshVerifier, MeshVerifier : Verifier - { - typedef std::set > invalid_edge_set_type; - std::vector m_invalid_edge_set; - //std::vector m_valid_edge_set; - enum { NELT = interface_table::NUM_ELEM_TYPES }; - void build_invalid_edge_sets(); - public: - TopologyVerifier(); - bool isTopologyBad( mesh::Entity &elem); - bool isTopologyBad( mesh::BulkData& mesh_bulk_data); - }; - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Util.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/Util.cpp deleted file mode 100644 index 0d6ba846bb6a..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Util.cpp +++ /dev/null @@ -1,452 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if !defined(__APPLE__) -#include -#endif -#include - -#include -#include -#include - -// FIXME - double s_timers[10] = {0,0,0,0,0,0,0,0,0,0}; - - - - -namespace shards { - - std::ostream& operator<<(std::ostream& os, const shards::Array& container) - { - // Save the format state of the original ostream os. - Teuchos::oblackholestream oldFormatState; - oldFormatState.copyfmt(os); - - os.setf(std::ios_base::scientific, std::ios_base::floatfield); - os.setf(std::ios_base::right); - int myprec = os.precision(); - - int size = container.size(); - int rank = container.rank(); - Teuchos::Array multiIndex(rank); - //Teuchos::Array dimensions(rank); - std::vector dimensions(rank); - //container.dimensions(dimensions); - for (int irank = 0; irank < rank; irank++) - { - dimensions[irank] = container.dimension(irank); - } - - os<< "===============================================================================\n"\ - << "\t Container size = " << size << "\n" - << "\t Container rank = " << rank << "\n" ; - - if( (rank == 0 ) && (size == 0) ) { - os<< "====================================================================================\n"\ - << "| *** This is an empty container **** |\n"; - } - else { - os<< "\t Dimensions = "; - - for(int r = 0; r < rank; r++){ - os << " (" << dimensions[r] <<") "; - } - os << "\n"; - - os<< "====================================================================================\n"\ - << "| Multi-index Enumeration Value |\n"\ - << "====================================================================================\n"; - } - - int address=0; - - std::vector dims = dimensions; - dims.resize(8,1); - std::vector idim(8); - for (idim[0] = 0; idim[0] < dims[0]; idim[0]++) - { - for (idim[1] = 0; idim[1] < dims[1]; idim[1]++) - { - for (idim[2] = 0; idim[2] < dims[2]; idim[2]++) - { - for (idim[3] = 0; idim[3] < dims[3]; idim[3]++) - { - for (idim[4] = 0; idim[4] < dims[4]; idim[4]++) - { - for (idim[5] = 0; idim[5] < dims[5]; idim[5]++) - { - for (idim[6] = 0; idim[6] < dims[6]; idim[6]++) - { - std::ostringstream mistring; - for (int jr = 0; jr < rank; jr++) - { - mistring << idim[jr] << std::dec << " " ; - } - os.setf(std::ios::right, std::ios::adjustfield); - os << std::setw(27) << mistring.str(); - os << std::setw(20) << address; - os << " "; - os.setf(std::ios::left, std::ios::adjustfield); - os << std::setw(myprec+8) - << container[address] - << "\n"; - ++address; - } - } - } - } - } - } - } -#if 0 - for(int address = 0; address < size; address++){ - container.getMultiIndex(multiIndex,address); - std::ostringstream mistring; - for(int r = 0; r < rank; r++){ - mistring << multiIndex[r] << std::dec << " "; - } - os.setf(std::ios::right, std::ios::adjustfield); - os << std::setw(27) << mistring.str(); - os << std::setw(20) << address; - os << " "; - os.setf(std::ios::left, std::ios::adjustfield); - os << std::setw(myprec+8) << container[address] << "\n"; - } -#endif - - os<< "====================================================================================\n\n"; - - // reset format state of os - os.copyfmt(oldFormatState); - - return os; - } - -} - -namespace stk_classic { - - namespace mesh { - - std::ostream &operator<<(std::ostream& out, const stk_classic::mesh::Entity& entity) - { - if (entity.entity_rank() != stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - out << "Elem: " << entity.identifier() << " rank= " << entity.entity_rank() << " nodes: "; - - const mesh::PairIterRelation elem_nodes = entity.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - out << node.identifier() << " "; - } - //out << std::endl; - - } - - else if (entity.entity_rank() == stk_classic::mesh::fem::FEMMetaData::NODE_RANK) - { - out << "Node: " << entity.identifier(); - - } - else - { - out << "rank unknown: " << entity.entity_rank(); - } - - return out; - } - - } - - namespace percept { - -#define ENABLE_PAUSE 1 - //#define ENABLE_PAUSE (1 && NDEBUG) - - double Util::s_timers[10] = {0,0,0,0,0,0,0,0,0,0}; - -#if ENABLE_PAUSE - static bool s_doPause = true; - static bool s_doPauseNeverAgain = false; // set to false to enable pausing -#else - static bool s_doPause = false; - static bool s_doPauseNeverAgain = true; // set to false to enable pausing -#endif - static std::map s_flag; - static int s_p_rank=0; - void Util::setFlag(int which_flag, bool val) { s_flag[which_flag]=val; } - bool Util::getFlag(int which_flag) { return s_flag[which_flag]; } - void Util::setRank(int rank){ s_p_rank=rank; } - int Util::get_rank() { return s_p_rank; } - - void Util::setDoPause(bool enableOrDisablePause) - { - s_doPause = enableOrDisablePause; - } - void Util::pause(bool doPause, const char *msg) - { - if (s_doPause && doPause && !s_doPauseNeverAgain) - { - if (msg) - { - std::cout << msg << std::endl; - } - - std::cout << "pause...:: c or to continue, q to quit, C to continue without further pauses: " << std::endl; - char buf[100]; - std::cin >> buf; - std::string buf_s(buf); - if (buf_s == "q") - { - std::exit(1); - } - // else if (buf_s == "c") - // { - // } - else if (buf_s == "C") - { - s_doPauseNeverAgain = true; - } - - } - - } - void Util::debug_stop() - { - std::cout << "in debug_stop" << std::endl; - } - - static unsigned s_trace_mem_0[] = {0u,0u,0u,0u,0u,0u,0u,0u,0u,0u}; - static unsigned s_trace_mem_1[] = {0u,0u,0u,0u,0u,0u,0u,0u,0u,0u}; - static double s_trace_time_0[] = {0,0,0,0,0,0,0,0,0,0}; - static double s_trace_time_1[] = {0,0,0,0,0,0,0,0,0,0}; - - void - Util:: - trace_cpu_time_and_mem_0(unsigned index) - { - { - size_t heap_in_bytes = 0; - size_t memory_in_bytes = Util::memory(heap_in_bytes); - - double cpu_in_min = Util::cpu_time()/60.0; - - s_trace_mem_0[index] = memory_in_bytes; - s_trace_time_0[index] = cpu_in_min; - } - } - - void - Util:: - trace_cpu_time_and_mem_1(unsigned index) - { - { - size_t heap_in_bytes = 0; - size_t memory_in_bytes = Util::memory(heap_in_bytes); - - double cpu_in_min = Util::cpu_time()/60.0; - - s_trace_mem_1[index] += memory_in_bytes - s_trace_mem_0[index]; - s_trace_time_1[index] += cpu_in_min - s_trace_time_0[index]; - } - } - - - void Util::trace_cpu_time_and_mem_print(int index, std::string msg) - { - std::cout << "tmp trace_cpu_time_and_mem_print " - << msg << " = " << ((double)s_trace_mem_1[index])/(1024.0*1024.0) << " [Mb] " - << s_trace_time_1[index] << " [min] " << std::endl ; - } - - void Util::replace(std::string &str, const std::string &find_what, const std::string &replace_with) - { - std::string::size_type pos = 0; - while((pos = str.find(find_what, pos)) != std::string::npos) - { - str.erase(pos, find_what.length()); - str.insert(pos, replace_with); - pos += replace_with.length(); - } - } - - - -static void -get_memory_info( - size_t & memory_usage, - size_t & faults) -{ - memory_usage = 0; - faults = 0; - - std::ifstream proc("/proc/self/stat", std::ios_base::in|std::ios_base::binary); - if (proc) { - - std::string s; - int i; - for (i = 0; i < 11; ++i) - proc >> s; - - proc >> faults; - ++i; - - for (; i < 22; ++i) - proc >> s; - - proc >> memory_usage; - ++i; - } -} - -static void -get_heap_info( - size_t & heap_size, - size_t & largest_free) -{ - heap_size = 0; - largest_free = 0; - -#if defined(SIERRA_HEAP_INFO) -# if 0 // if defined(REDS) // Redstorm now links in gnu's malloc - static size_t reds_fragments; - static unsigned long reds_total_free; - static unsigned long reds_heap_size; - static unsigned long reds_largest_free; - - ::heap_info(&reds_fragments, &reds_total_free, &reds_largest_free, &reds_heap_size); - - heap_size = reds_heap_size; - largest_free = reds_largest_free; - - slibout.m(Slib::LOG_MEMORY) <<"reds_fragments " << reds_fragments - << ", reds_total_free " << reds_total_free - << ", reds_largest_free " << reds_largest_free - << ", reds_heap_size " << reds_heap_size << Diag::dendl; - -// # elif defined(__linux__) -# elif defined(__linux__) || defined(REDS) && ! defined(__IBMCPP__) - static struct mallinfo minfo; - minfo = mallinfo(); - heap_size = (unsigned int) minfo.uordblks + (unsigned int) minfo.hblkhd; - largest_free = (unsigned int) minfo.fordblks; - - -# elif defined(__sun) - pstatus_t proc_status; - - std::ifstream proc("/proc/self/status", std::ios_base::in|std::ios_base::binary); - if (proc) { - proc.read((char *)&proc_status, sizeof(proc_status)); - heap_size = proc_status.pr_brksize; - slibout.m(Slib::LOG_MEMORY) <<"pr_brksize " << proc_status.pr_brksize - << ", pr_stksize " << proc_status.pr_stksize << Diag::dendl; - } -# endif -#endif // defined(SIERRA_HEAP_INFO) -} - - - - double - Util::cpu_time() - { -#if defined(REDS) - struct rusage my_rusage; - - ::getrusage(RUSAGE_SELF, &my_rusage); - - double seconds = my_rusage.ru_utime.tv_sec; - double micro_seconds = my_rusage.ru_utime.tv_usec; - - return seconds + micro_seconds*1.0e-6; - -#else - static struct rusage my_rusage; - - ::getrusage(RUSAGE_SELF, &my_rusage); - - double seconds = (double)(my_rusage.ru_utime.tv_sec + my_rusage.ru_stime.tv_sec); - double micro_seconds = (double)(my_rusage.ru_utime.tv_usec + my_rusage.ru_stime.tv_usec); - return seconds + micro_seconds*1.0e-6; - -#endif - } - - size_t - Util::memory(size_t& heap) - { -#if defined(REDS) - struct rusage my_rusage; - - ::getrusage(RUSAGE_SELF, &my_rusage); - - double seconds = my_rusage.ru_utime.tv_sec; - double micro_seconds = my_rusage.ru_utime.tv_usec; - - return seconds + micro_seconds*1.0e-6; - -#else - - /* Maximum resident set size (in kilobytes). */ - size_t largest_free = 0; - size_t faults = 0; - size_t memory_in_bytes = 0; - get_heap_info(heap, largest_free); - get_memory_info(memory_in_bytes, faults); - return memory_in_bytes; - -#endif - } - - //======================================================================================================================== - - // FIXME - bool Util::isLinearElement(shards::CellTopology& cell_topo) - { - if (cell_topo.getVertexCount() == cell_topo.getNodeCount()) - return true; - else - return false; - } - - - - //======================================================================================================================== - stk_classic::diag::TimerSet& perceptTimerSet() - { - static stk_classic::diag::TimerSet s_perceptTimerSet(PERCEPT_TIMER_ROOT); - - return s_perceptTimerSet; - } - - stk_classic::diag::Timer& perceptTimer() { - const std::string name("PerceptTimer"); - static stk_classic::diag::Timer s_perceptTimer (stk_classic::diag::createRootTimer(name, perceptTimerSet())); - - return s_perceptTimer; - } - - LapTimeType getLapTime(stk_classic::diag::Timer& lap_timer) { return lap_timer.getMetric().getLap(); } - LapCountType getAccumulatedLap(stk_classic::diag::Timer& timer, bool option) { return timer.getMetric().getAccumulatedLap(option); } - - - - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/Util.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/Util.hpp deleted file mode 100644 index b33670367a09..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/Util.hpp +++ /dev/null @@ -1,319 +0,0 @@ -#ifndef stk_percept_Util_hpp -#define stk_percept_Util_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "Shards_Array.hpp" -#include "Shards_CellTopology.hpp" - -#include "Teuchos_Array.hpp" -#include "Teuchos_ArrayRCP.hpp" -#include "Teuchos_ArrayView.hpp" -// #include "Shards_Array.hpp" -#include "Teuchos_RCP.hpp" -// #include "Teuchos_BLAS.hpp" -#include "Teuchos_oblackholestream.hpp" -//#include "Teuchos_Assert.hpp" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -// output operators -// bcarnes: needed to put these in the namespace matching the second -// arg to operator << in order to get compiler (gcc 4.4.4) to work - -namespace std { - - template - std::ostream& operator<<(std::ostream& out, const std::set& val) - { - copy(val.begin(), val.end(), std::ostream_iterator(out, " ")); - return out; - } - - template - std::ostream& operator<<(std::ostream& out, const std::vector& val) - { - copy(val.begin(), val.end(), std::ostream_iterator(out, " ")); - return out; - } - - template - std::ostream& operator<<(std::ostream& out, std::map& val) - { - typename std::map::iterator it; - for (it = val.begin(); - it != val.end(); - it++) - { - out << "map[ " << (*it).first << "]= " << (*it).second << " \n"; - } - - return out; - } - - template - std::ostream& operator<<(std::ostream& os, const std::vector& vec) - { - os << "vector size()= " << vec.size() << " entries= [ \n"; - for (unsigned i = 0; i < vec.size(); i++) - os << " " << vec[i] << " , "; // << "\n"; - os << " ]\n"; - return os; - } - -} - -namespace shards { - std::ostream& operator<<(std::ostream& os, const shards::Array& container) ; -} - -namespace stk_classic { - - namespace mesh { - std::ostream &operator<<(std::ostream& out, const stk_classic::mesh::Entity& entity); - } - - namespace percept { - - enum TraceTypes { - CONNECT_LOCAL, - CONNECT_LOCAL_createNewNeededNodes, - CONNECT_LOCAL_createNewElements, - CONNECT_LOCAL_URP_createOrGetNode, - CONNECT_LOCAL_URP_declare_relation - }; - - //======================================================================================================================== - enum TurboOption { - TURBO_ELEMENT, - TURBO_BUCKET, - TURBO_NONE - }; - - //======================================================================================================================== - class Util - { - public: - static double s_timers[10]; - - static bool isLinearElement(shards::CellTopology& cell_topo); - static double cpu_time(); - static size_t memory(size_t& heap); - static void pause(bool doPause=true, const char *msg=0); - static void setDoPause(bool enableOrDisablePause); - static void setFlag(int which_flag, bool val); - static bool getFlag(int which_flag); - static void setRank(int rank); - static int get_rank(); - static void debug_stop(); - static void replace(std::string &str, const std::string &find_what, const std::string &replace_with); - - static void trace_cpu_time_and_mem_0(unsigned index); - static void trace_cpu_time_and_mem_1(unsigned index); - static void trace_cpu_time_and_mem_print(int index, std::string msg); - - static std::vector split(std::string str, std::string separators, bool remove_spaces=true) - { - if (remove_spaces) - { - replace(str, " ", ""); - } - std::vector tokens; - stk_classic::util::tokenize(str, separators, tokens); - return tokens; - } - static std::string join(std::vector tokens, std::string separator, bool add_spaces=true) - { - if (add_spaces) - { - separator += " "; - } - std::string ret; - for (unsigned i = 0; i < tokens.size(); i++) - { - ret += tokens[i]; - if (i != tokens.size() - 1) - ret += separator; - } - return ret; - } - - static bool approx_equal_relative(double a, double b, double tol) - { - if (fabs(a-b) <= tol*(fabs(a)+fabs(b))*0.5) - return true; - else - return false; - } - static bool approx_equal_absolute(double a, double b, double tol) - { - if (fabs(a-b) < tol) - return true; - else - return false; - } - - static bool file_exists(std::string filename) - { - std::fstream fin; - fin.open(filename.c_str(), std::ios::in); - if( fin.is_open() ) - { - fin.close(); - return true; - } - fin.close(); - return false; - } - - }; - - //======================================================================================================================== - template - class GenericVectorOfObjectPointers : public std::vector - { - public: - GenericVectorOfObjectPointers(int n) : std::vector(n) {} - GenericVectorOfObjectPointers(VecType *vt1=0, - VecType *vt2=0, - VecType *vt3=0, - VecType *vt4=0, - VecType *vt5=0, - VecType *vt6=0, - VecType *vt7=0, - VecType *vt8=0) - { - if (vt1) push_back(vt1); - if (vt2) push_back(vt2); - if (vt3) push_back(vt3); - if (vt4) push_back(vt4); - if (vt5) push_back(vt5); - if (vt6) push_back(vt6); - if (vt7) push_back(vt7); - if (vt8) push_back(vt8); - } - }; - - - //======================================================================================================================== - enum { - PERCEPT_TIMER_ROOT = 0x00001000 ///< Enable root timer - }; - stk_classic::diag::TimerSet& perceptTimerSet(); - stk_classic::diag::Timer& perceptTimer() ; - typedef stk_classic::diag::MetricTraits::Type LapTimeType; - LapTimeType getLapTime(stk_classic::diag::Timer& lap_timer); - typedef stk_classic::diag::MetricTraits::Type LapCountType; - LapCountType getAccumulatedLap(stk_classic::diag::Timer& timer, bool option=false); - - //======================================================================================================================== - - template - std::string toString(T t) { return boost::lexical_cast(t); } - - template - inline - T square(T t) { return t*t; } - - template - inline - T SQR(T t) { return t*t; } - - inline int toInt(std::string t) { return boost::lexical_cast(t); } - - //======================================================================================================================== - -#define QUOTE(A) #A -#define EXPAND_AND_QUOTE(A) QUOTE(A) - -#define PERCEPT_OUT(a) " " << QUOTE(a) << " = " << a - -#define TOKENPASTE2(x,y) x ## y -#define TOKENPASTE(x,y) TOKENPASTE2(x,y) - -#define VERIFY_OP_ON( val1, op, val2, message) do { if (1) { if (!(val1 op val2)) { std::ostringstream msg_loc; \ - msg_loc << "\n\n ERROR: " << __FILE__ << " line: " << __LINE__; \ - msg_loc << "\n " << message << "\n" \ - << " { " #val1 << " = " << val1 << " } \n" \ - << " { " #val2 << " = " << val2 << " } \n"; \ - msg_loc << " ERROR condition is: \n " << #val1 " " #op " " #val2 << "\n"; \ - std::cout << msg_loc.str() << std::endl; \ - Util::debug_stop(); \ - throw std::runtime_error(msg_loc.str()); } } } while (0) - - -#ifdef NDEBUG - -#define VERIFY_1(message) do {} while(0) -#define VERIFY(expr, val1, val2, message) do {} while(0) -#define VERIFY_OP( val1, op, val2, message) do {} while(0) -#define VERIFY_EQ1( val1, val2, message) do {} while(0) -#define VERIFY_NE( val1, val2, message) do {} while(0) - -#else - -#define VERIFY_ON 1 - -#define VERIFY_1(message) do { if(VERIFY_ON) { std::ostringstream msg_loc; msg_loc << message; \ - std::cout << msg_loc.str() << std::endl; \ - throw std::runtime_error(msg_loc.str()); } } while (0) - - -#define VERIFY(expr, val1, val2, message) do { if (VERIFY_ON) { if (!(expr)) { std::ostringstream msg_loc; msg_loc << message << " " << val1 << " " << val2; \ - std::cout << msg_loc.str() << std::endl; \ - Util::debug_stop(); \ - throw std::runtime_error(msg_loc.str()); } } } while (0) - -#define VERIFY_OP( val1, op, val2, message) do { if (VERIFY_ON) { if (!(val1 op val2)) { std::ostringstream msg_loc; \ - msg_loc << "\n\n ERROR: " << __FILE__ << " line: " << __LINE__; \ - msg_loc << "\n " << message << "\n" \ - << " { " #val1 << " = " << val1 << " } \n" \ - << " { " #val2 << " = " << val2 << " } \n"; \ - msg_loc << " ERROR condition is: \n " << #val1 " " #op " " #val2 << "\n"; \ - std::cout << msg_loc.str() << std::endl; \ - Util::debug_stop(); \ - throw std::runtime_error(msg_loc.str()); } } } while (0) - - - -#define VERIFY_EQ1( val1, val2, message) do { if (VERIFY_ON) { if (!(val1==val2)) { std::ostringstream msg_loc; msg_loc << message << " " << val1 << " " << val2; \ - std::cout << msg_loc.str() << std::endl; \ - Util::debug_stop(); \ - throw std::runtime_error(msg_loc.str()); } } } while (0) - -#define VERIFY_NE( val1, val2, message) do { if (VERIFY_ON) { if (!(val1 != val2)) { std::ostringstream msg_loc; msg_loc << message << " " << val1 << " " << val2; \ - std::cout << msg_loc.str() << std::endl; \ - Util::debug_stop(); \ - throw std::runtime_error(msg_loc.str()); } } } while (0) - -#endif - -#define VERIFY_EQ( val1, val2, message) VERIFY_OP(val1, ==, val2, message) -#define VERIFY_EQ_ON( val1, val2, message) VERIFY_OP_ON(val1, ==, val2, message) - -#define VERIFY_TRUE( val1) VERIFY_OP( (val1), ==, true, EXPAND_AND_QUOTE(val1)) -#define VERIFY_TRUE_ON( val1) VERIFY_OP_ON( (val1), ==, true, EXPAND_AND_QUOTE(val1)) - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.cpp deleted file mode 100644 index e3415991d777..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include - -#include - -#include - -//---------------------------------------------------------------------- - -namespace stk_classic{ - namespace percept { - - typedef shards::Beam<2> Beam2; - - BeamFixture::BeamFixture( stk_classic::ParallelMachine comm, bool doCommit ) : - m_spatial_dimension(3) - , m_metaData(m_spatial_dimension, stk_classic::mesh::fem::entity_rank_names(m_spatial_dimension) ) - , m_bulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_metaData) , comm ) - , m_block_beam( m_metaData.declare_part< Beam2 >( "block_2" ) ) - , m_elem_rank( m_metaData.element_rank() ) - , m_coordinates_field( m_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_centroid_field( m_metaData.declare_field< VectorFieldType >( "centroid" )) - , m_temperature_field( m_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_volume_field( m_metaData.declare_field< ScalarFieldType >( "volume" )) - , m_element_node_coordinates_field( m_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" )) - { - // Define where fields exist on the mesh: - stk_classic::mesh::Part & universal = m_metaData.universal_part(); - - put_field( m_coordinates_field , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal ); - put_field( m_centroid_field , m_elem_rank , universal ); - put_field( m_temperature_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, universal ); - put_field( m_volume_field, m_elem_rank, m_block_beam ); - - // Define the field-relation such that the values of the - // 'element_node_coordinates_field' are pointers to the - // element's nodal 'coordinates_field'. - // I.e., let: - // double *const* elem_node_coord = - // field_data( m_element_node_coordinates_field , element ); - // then - // elem_node_coord[n][0..2] is the coordinates of element node 'n' - // that are attached to that node. - - m_metaData.declare_field_relation( - m_element_node_coordinates_field , - stk_classic::mesh::fem::get_element_node_stencil(3) , - m_coordinates_field - ); - - // Define element node coordinate field for all element parts - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_beam, Beam2::node_count ); - - if (doCommit) - m_metaData.commit(); - } - - BeamFixture::~BeamFixture() - { } - - //------------------------------------------------------------------------------ - // Use case specific mesh generation data: - - enum { SpatialDim = 3 }; - enum { node_count = 4 }; - enum { number_beam = 2 }; - - namespace { - - // Hard coded node coordinate data for all the nodes in the entire mesh - static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 10 , 10 , 10 } , { 11 , 12 , 13 } , { 24 , 24 , 24 } , { 28 , 29 , 30 } - }; - - // Hard coded beam node ids for all the beam nodes in the entire mesh - static const stk_classic::mesh::EntityId beam_node_ids[number_beam][ Beam2::node_count ] = { - { 1,2 } , - { 3,4 } - }; - - } - - //------------------------------------------------------------------------------ - - void BeamFixture::populate() - { - // Populate mesh with all node types - - m_bulkData.modification_begin(); - - if (m_bulkData.parallel_rank() == 0) - { - stk_classic::mesh::EntityId curr_elem_id = 1; - - // For each element topology declare elements - for ( unsigned i = 0 ; i < number_beam ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_beam, curr_elem_id, beam_node_ids[i] ); - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < node_count ; ++i ) { - stk_classic::mesh::Entity * const node = m_bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - } - m_bulkData.modification_end(); - - } - - // Verify mesh for 6 different parts - bool verifyMesh( const BeamFixture & mesh ) - { - bool result = true; - - return result; - } - - } //namespace percept -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.hpp deleted file mode 100644 index 73feeb861013..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/BeamFixture.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_BeamFixture_hpp -#define stk_percept_BeamFixture_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include - -#include - -/** stk_mesh Use Case 3 - copied and modified here */ - -#define HET_FIX_INCLUDE_EXTRA_ELEM_TYPES 0 - -namespace stk_classic { - namespace percept { - - - typedef stk_classic::mesh::Field VectorFieldType ; - typedef stk_classic::mesh::Field ScalarFieldType ; - typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - - /** Use case with mixed element topologies and - * field relations to provide fast access to node field data - * from an element. - * - * copied from stk_mesh and modified - */ - - class BeamFixture { - public: - - - ~BeamFixture(); - - BeamFixture( stk_classic::ParallelMachine comm, bool doCommit = true); - - void populate(); - - const int m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData m_metaData; - stk_classic::mesh::BulkData m_bulkData; - - stk_classic::mesh::Part & m_block_beam; - const stk_classic::mesh::EntityRank m_elem_rank; - - VectorFieldType & m_coordinates_field; - VectorFieldType & m_centroid_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_volume_field; - ElementNodePointerFieldType & m_element_node_coordinates_field; - }; - - bool verifyMesh( const BeamFixture & mesh ); - - } //namespace percept -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_3_hpp diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/CMakeLists.txt deleted file mode 100644 index 10868c309778..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/fixtures/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.cpp deleted file mode 100644 index 79bbeae5c010..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -#include "Fixture.hpp" - -namespace stk_classic { - namespace percept { - -#if 0 - void Fixture::setup_read_mesh_create_coordsMag_field(PerceptMesh& meshUtil, bool create_field, const std::string file, bool print) - { - std::vector create_field_vec; - meshUtil.readModelCreateOptionalFields(create_field_vec, file, print); - } -#endif - - } -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.hpp deleted file mode 100644 index 2979277db862..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/Fixture.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef stk_percept_UnitTestFixture_hpp -#define stk_percept_UnitTestFixture_hpp - -#include -#include -#include - -#include - - -#include -#include -#include - -#include -#include -#include - - -namespace stk_classic { - namespace percept { - -#define STKUNIT_EXPECT_DOUBLE_EQ_APPROX_TOL(expected, actual, tol) \ - { \ - if (std::fabs(expected-actual) > 0.5*(std::fabs(expected)+std::fabs(actual))*tol) \ - { \ - std::cout << "std::fabs(expected-actual) = " \ - << std::fabs(expected-actual) \ - << " 0.5*(std::fabs(expected)+std::fabs(actual))*tol = " \ - << 0.5*(std::fabs(expected)+std::fabs(actual))*tol \ - << " tol= " << tol << std::endl; \ - STKUNIT_EXPECT_DOUBLE_EQ(expected, actual); \ - } \ - } - -#define STKUNIT_EXPECT_DOUBLE_EQ_APPROX(expected, actual) STKUNIT_EXPECT_DOUBLE_EQ_APPROX_TOL(expected, actual, 1.e-6) - - -#define TIME_IT(expr,total_time) \ - { \ - double tstart = stk_classic::wall_time(); \ - { \ - expr \ - } \ - total_time = stk_classic::wall_dtime(tstart); \ - } - - - //using namespace use_case; - enum { - LOG_NORM = 2*LOG_APPLICATION, - LOG_GEOMETRY_VERIFIER = 2*LOG_NORM, - LOG_MESH_COLORER = 2*LOG_GEOMETRY_VERIFIER - - }; - - -#if 0 - class Fixture : public RunEnvironment - { - public: - static void setup_read_mesh_create_coordsMag_field(PerceptMesh& meshUtil, bool create_field, - const std::string file="./cube_hex8.e", bool print=false); - - }; -#endif - typedef RunEnvironment Fixture; - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.cpp deleted file mode 100644 index 1728d9639cc2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include - -#include - -//---------------------------------------------------------------------- - -namespace stk_classic{ - namespace percept { - - typedef shards::Hexahedron<8> Hex8; - typedef shards::Wedge<6> Wedge6; - typedef shards::Tetrahedron<4> Tet4; - typedef shards::Pyramid<5> Pyramid4; - - typedef shards::ShellQuadrilateral<4> ShellQuad4; - typedef shards::ShellTriangle<3> ShellTriangle3; - - typedef shards::Quadrilateral<4> Quad4; - typedef shards::Triangle<3> Triangle3; - - HeterogeneousFixture::HeterogeneousFixture( stk_classic::ParallelMachine comm, bool doCommit, bool do_sidesets ) : - m_spatial_dimension(3) - , m_metaData(m_spatial_dimension, stk_classic::mesh::fem::entity_rank_names(m_spatial_dimension) ) - , m_bulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_metaData) , comm ) - , m_block_hex( m_metaData.declare_part< Hex8 >( "block_1" )) - , m_block_wedge( m_metaData.declare_part< Wedge6 >( "block_2" )) - , m_block_tet( m_metaData.declare_part< Tet4 >( "block_3" )) - , m_block_pyramid( m_metaData.declare_part< Pyramid4 >( "block_4" )) - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - , m_block_quad_shell( m_metaData.declare_part< ShellQuad4 >( "block_5" )) - , m_block_tri_shell( m_metaData.declare_part< ShellTriangle3 >( "block_6" )) -#endif - , m_sideset_quad(0), m_sideset_quad_subset(0) - , m_sideset_tri(0), m_sideset_tri_subset(0) - - , m_elem_rank( m_metaData.element_rank() ) - , m_coordinates_field( m_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_centroid_field( m_metaData.declare_field< VectorFieldType >( "centroid" )) - , m_temperature_field( m_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_volume_field( m_metaData.declare_field< ScalarFieldType >( "volume" )) - , m_element_node_coordinates_field( m_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" )) - { - // Define where fields exist on the mesh: - stk_classic::mesh::Part & universal = m_metaData.universal_part(); - - put_field( m_coordinates_field , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal ); - put_field( m_centroid_field , m_elem_rank , universal ); - put_field( m_temperature_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, universal ); - put_field( m_volume_field, m_elem_rank, m_block_hex ); - put_field( m_volume_field, m_elem_rank, m_block_wedge ); - put_field( m_volume_field, m_elem_rank, m_block_tet ); - put_field( m_volume_field, m_elem_rank, m_block_pyramid ); - - // Define the field-relation such that the values of the - // 'element_node_coordinates_field' are pointers to the - // element's nodal 'coordinates_field'. - // I.e., let: - // double *const* elem_node_coord = - // field_data( m_element_node_coordinates_field , element ); - // then - // elem_node_coord[n][0..2] is the coordinates of element node 'n' - // that are attached to that node. - - m_metaData.declare_field_relation( - m_element_node_coordinates_field , - stk_classic::mesh::fem::get_element_node_stencil(3) , - m_coordinates_field - ); - - // Define element node coordinate field for all element parts - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_hex, Hex8::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_wedge, Wedge6::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_tet, Tet4::node_count ); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_pyramid, Pyramid4::node_count ); - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_quad_shell, ShellQuad4::node_count); - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_tri_shell, ShellTriangle3::node_count ); -#endif - - stk_classic::io::put_io_part_attribute( m_block_hex ); - stk_classic::io::put_io_part_attribute( m_block_wedge ); - stk_classic::io::put_io_part_attribute( m_block_tet ); - stk_classic::io::put_io_part_attribute( m_block_pyramid ); - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - stk_classic::io::put_io_part_attribute( m_block_quad_shell ); - stk_classic::io::put_io_part_attribute( m_block_tri_shell ); -#endif - - if (do_sidesets) - { - m_sideset_quad_subset = &m_metaData.declare_part(std::string("surface_wedge5_quad2d2_1"), m_metaData.face_rank()); - m_sideset_quad = &m_metaData.declare_part(std::string("surface_1"), m_metaData.face_rank()); - stk_classic::mesh::fem::set_cell_topology< Quad4 >(*m_sideset_quad_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_quad_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_quad); - m_metaData.declare_part_subset(*m_sideset_quad, *m_sideset_quad_subset); - - m_sideset_tri_subset = &m_metaData.declare_part(std::string("surface_wedge5_tri2d2_1"), m_metaData.face_rank()); - m_sideset_tri = &m_metaData.declare_part(std::string("surface_2"), m_metaData.face_rank()); - stk_classic::mesh::fem::set_cell_topology< Triangle3 >(*m_sideset_tri_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_tri_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_tri); - m_metaData.declare_part_subset(*m_sideset_tri, *m_sideset_tri_subset); - } - - if (doCommit) - m_metaData.commit(); - } - - HeterogeneousFixture::~HeterogeneousFixture() - { } - - //------------------------------------------------------------------------------ - // Use case specific mesh generation data: - - enum { SpatialDim = 3 }; - enum { node_count = 21 }; - enum { number_hex = 3 }; - enum { number_wedge = 3 }; - enum { number_tetra = 3 }; - enum { number_pyramid = 2 }; - enum { number_shell_quad = 3 }; - enum { number_shell_tri = 3 }; - enum { number_quad = 3 }; - enum { number_tri = 2 }; - - namespace { - - // Hard coded node coordinate data for all the nodes in the entire mesh - static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 2 , 0 , 0 } , { 3 , 0 , 0 } , - { 0 , 1 , 0 } , { 1 , 1 , 0 } , { 2 , 1 , 0 } , { 3 , 1 , 0 } , - { 0 , 2 , 0 } , { 1 , 2 , 0 } , - { 0 , 0 , -1 } , { 1 , 0 , -1 } , { 2 , 0 , -1 } , { 3 , 0 , -1 } , - { 0 , 1 , -1 } , { 1 , 1 , -1 } , { 2 , 1 , -1 } , { 3 , 1 , -1 } , - { 0 , 2 , -1 } , { 1 , 2 , -1 } , - { 1 , 1 , -2 } }; - - // Hard coded hex node ids for all the hex nodes in the entire mesh - static const stk_classic::mesh::EntityId hex_node_ids[number_hex][ Hex8::node_count ] = { - { 1 , 2 , 12 , 11 , 5 , 6 , 16 , 15 } , - { 2 , 3 , 13 , 12 , 6 , 7 , 17 , 16 } , - { 3 , 4 , 14 , 13 , 7 , 8 , 18 , 17 } }; - - // Hard coded wedge node ids for all the wedge nodes in the entire mesh - static const stk_classic::mesh::EntityId wedge_node_ids[number_wedge][ Wedge6::node_count ] = { - { 15 , 16 , 19 , 5 , 6 , 9 } , - { 10 , 9 , 6 , 20 , 19 , 16 } , - { 16 , 17 , 20 , 6 , 7 , 10 } }; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static const stk_classic::mesh::EntityId tetra_node_ids[number_tetra][ Tet4::node_count ] = { - { 15 , 19 , 16 , 21 } , - { 19 , 20 , 16 , 21 } , - { 16 , 20 , 17 , 21 } }; - - // Hard coded pyramid node ids for all the pyramid nodes in the entire mesh - static const stk_classic::mesh::EntityId pyramid_node_ids[number_pyramid][ Pyramid4::node_count ] = { - { 11 , 15 , 16 , 12 , 21 } , - { 12 , 16 , 17 , 13 , 21 } }; - - // Hard coded shell quad node ids for all the shell quad nodes in the entire mesh - static const stk_classic::mesh::EntityId shell_quad_node_ids[number_shell_quad][ ShellQuad4::node_count ]={ - { 9 , 6 , 16 , 19 } , - { 6 , 7 , 17 , 16 } , - { 7 , 8 , 18 , 17 } }; - - // Hard coded shell tri node ids for all the shell tri nodes in the entire mesh - static const stk_classic::mesh::EntityId shell_tri_node_ids[number_shell_tri][ ShellTriangle3::node_count ] ={ - { 19 , 16 , 21 } , - { 16 , 17 , 21 } , - { 17 , 13 , 21 } }; - - // NOTE: some quad, tri's for wedge sideset testing - // Hard coded quad node ids for all the quad nodes in the entire mesh - static const stk_classic::mesh::EntityId quad_node_ids[number_quad][ Quad4::node_count ] = { - { 5, 9, 19, 15}, - { 7, 17, 20, 10 }, - { 10, 20, 19, 9} - }; - - // wedge element id, side id - static const stk_classic::mesh::EntityId quad_node_side_ids[number_quad][ 2 ] = { - {4, 2}, - {6, 1}, - {5, 0} - }; - - // Hard coded tri node ids for all the tri nodes in the entire mesh - static const stk_classic::mesh::EntityId tri_node_ids[number_tri][ Triangle3::node_count ] = { - { 5, 6, 9}, - { 6, 10, 9} - }; - - // wedge element id, side id - static const stk_classic::mesh::EntityId tri_node_side_ids[number_quad][ 2 ] = { - {4, 4}, - {5, 3} - }; - - } - - //------------------------------------------------------------------------------ - - void HeterogeneousFixture::populate() - { - // Populate mesh with all node types - - m_bulkData.modification_begin(); - - if (m_bulkData.parallel_rank() == 0) - { - stk_classic::mesh::EntityId curr_elem_id = 1; - - // For each element topology declare elements - - stk_classic::mesh::Entity *wedges[number_wedge]; - - for ( unsigned i = 0 ; i < number_hex ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_hex, curr_elem_id, hex_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_wedge ; ++i , ++curr_elem_id ) { - wedges[i] = &stk_classic::mesh::fem::declare_element( m_bulkData, m_block_wedge, curr_elem_id, wedge_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_tetra ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_tet, curr_elem_id, tetra_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_pyramid ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_pyramid, curr_elem_id, pyramid_node_ids[i] ); - } - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - for ( unsigned i = 0 ; i < number_shell_quad ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_quad_shell, curr_elem_id, shell_quad_node_ids[i]); - } - - for ( unsigned i = 0 ; i < number_shell_tri ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_tri_shell, curr_elem_id, shell_tri_node_ids[i] ); - } -#endif - - if (m_sideset_quad) - { - for ( unsigned i = 0 ; i < number_quad ; ++i , ++curr_elem_id ) { - std::cout << "quad i= " << i << std::endl; - stk_classic::mesh::fem::declare_element_side( m_bulkData, - curr_elem_id, //side_id, - *wedges[quad_node_side_ids[i][0] - 4], // element, - quad_node_side_ids[i][1], //j_side, // local_side_ord, - m_sideset_quad_subset); - } - } - - if (m_sideset_tri) - { - for ( unsigned i = 0 ; i < number_tri ; ++i , ++curr_elem_id ) { - std::cout << "tri i= " << i << std::endl; - stk_classic::mesh::fem::declare_element_side( m_bulkData, - curr_elem_id, //side_id, - *wedges[tri_node_side_ids[i][0] - 4], // element, - tri_node_side_ids[i][1], //j_side, // local_side_ord, - m_sideset_tri_subset); - } - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < node_count ; ++i ) { - stk_classic::mesh::Entity * const node = m_bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - } - m_bulkData.modification_end(); - - } - - // Verify mesh for 6 different parts - bool verifyMesh( const HeterogeneousFixture & mesh ) - { - bool result = true; - - const stk_classic::mesh::BulkData & bulkData = mesh.m_bulkData ; - //const VectorFieldType & node_coord = mesh.m_coordinates_field ; - //const ElementNodePointerFieldType & elem_node_coord = mesh.m_element_node_coordinates_field ; - - std::vector element_buckets = bulkData.buckets( mesh.m_elem_rank ); - - // Create a pair containing Part and matching node_count - - typedef std::pair PartNodeCountPair; - std::vector part_and_node_counts; - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_hex, Hex8::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_wedge, Wedge6::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_tet, Tet4::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_pyramid, Pyramid4::node_count)); - -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_quad_shell, ShellQuad4::node_count)); - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_tri_shell, ShellTriangle3::node_count)); -#endif - - // Verify that entities in each part are set up correctly. - // Use a PartVector iterator for parts_to_check and call - // verify_elem_node_coord_by_part in UseCase_Common.cpp for - // each part in turn. -#if 0 - for( std::vector::const_iterator i = part_and_node_counts.begin() ; i != part_and_node_counts.end() ; ++i ) - { - result = result && - verify_elem_node_coord_by_part( - *(i->first), - element_buckets, - elem_node_coord, - node_coord, - i->second - ); - } -#endif - - // Check that all the nodes were allocated. - for ( unsigned i = 0 ; i < node_count ; ++i ) { - stk_classic::mesh::Entity * const node = bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - if ( node == NULL ) { - std::cerr << "Error! Invalid null pointer for node returned from " - << "bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, " << i+1 << " ) " << std::endl; - result = false; - } - } - - return result; - } - - } //namespace percept -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.hpp deleted file mode 100644 index d709bb3a5aa3..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/HeterogeneousFixture.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_HeterogeneousFixture_hpp -#define stk_percept_HeterogeneousFixture_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include - -/** stk_mesh Use Case 3 - copied and modified here */ - -#define HET_FIX_INCLUDE_EXTRA_ELEM_TYPES 0 - -namespace stk_classic { - namespace percept { - - typedef stk_classic::mesh::Field VectorFieldType ; - typedef stk_classic::mesh::Field ScalarFieldType ; - typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - - /** Use case with mixed element topologies and - * field relations to provide fast access to node field data - * from an element. - * - * copied from stk_mesh and modified - */ - - class HeterogeneousFixture { - public: - - - ~HeterogeneousFixture(); - - HeterogeneousFixture( stk_classic::ParallelMachine comm, bool doCommit = true, bool do_sidesets=false); - - void populate(); - - const int m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData m_metaData; - stk_classic::mesh::BulkData m_bulkData; - - stk_classic::mesh::Part & m_block_hex; - stk_classic::mesh::Part & m_block_wedge; - stk_classic::mesh::Part & m_block_tet; - stk_classic::mesh::Part & m_block_pyramid; -#if HET_FIX_INCLUDE_EXTRA_ELEM_TYPES - stk_classic::mesh::Part & m_block_quad_shell; - stk_classic::mesh::Part & m_block_tri_shell; -#endif - stk_classic::mesh::Part * m_sideset_quad; - stk_classic::mesh::Part * m_sideset_quad_subset; - stk_classic::mesh::Part * m_sideset_tri; - stk_classic::mesh::Part * m_sideset_tri_subset; - - const stk_classic::mesh::EntityRank m_elem_rank; - - VectorFieldType & m_coordinates_field; - VectorFieldType & m_centroid_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_volume_field; - ElementNodePointerFieldType & m_element_node_coordinates_field; - }; - - bool verifyMesh( const HeterogeneousFixture & mesh ); - - } //namespace percept -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_3_hpp diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.cpp deleted file mode 100644 index 9d3c1fec0ede..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include - -#include - -//---------------------------------------------------------------------- - -namespace stk_classic{ - namespace percept { - - typedef shards::Hexahedron<8> Hex8; - typedef shards::Wedge<6> Wedge6; - typedef shards::Tetrahedron<4> Tet4; - typedef shards::Pyramid<5> Pyramid5; - - typedef shards::ShellQuadrilateral<4> ShellQuad4; - typedef shards::ShellTriangle<3> ShellTriangle3; - - typedef shards::Quadrilateral<4> Quad4; - typedef shards::Triangle<3> Triangle3; - - PyramidFixture::PyramidFixture( stk_classic::ParallelMachine comm, bool doCommit, bool do_sidesets ) : - m_spatial_dimension(3) - , m_metaData(m_spatial_dimension, stk_classic::mesh::fem::entity_rank_names(m_spatial_dimension) ) - , m_bulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_metaData) , comm ) - , m_block_pyramid( m_metaData.declare_part< Pyramid5 >( "block_4" )) - , m_sideset_quad(0), m_sideset_quad_subset(0) - , m_sideset_tri(0), m_sideset_tri_subset(0) - , m_elem_rank( m_metaData.element_rank() ) - , m_coordinates_field( m_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_centroid_field( m_metaData.declare_field< VectorFieldType >( "centroid" )) - , m_temperature_field( m_metaData.declare_field< ScalarFieldType >( "temperature" )) - , m_volume_field( m_metaData.declare_field< ScalarFieldType >( "volume" )) - , m_element_node_coordinates_field( m_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" )) - { - // Define where fields exist on the mesh: - stk_classic::mesh::Part & universal = m_metaData.universal_part(); - - if (do_sidesets) - { - m_sideset_quad_subset = &m_metaData.declare_part(std::string("surface_pyramid5_quad2d2_1"), m_metaData.face_rank()); - m_sideset_quad = &m_metaData.declare_part(std::string("surface_1"), m_metaData.face_rank()); - stk_classic::mesh::fem::set_cell_topology< Quad4 >(*m_sideset_quad_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_quad_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_quad); - m_metaData.declare_part_subset(*m_sideset_quad, *m_sideset_quad_subset); - - m_sideset_tri_subset = &m_metaData.declare_part(std::string("surface_pyramid5_tri2d2_1"), m_metaData.face_rank()); - m_sideset_tri = &m_metaData.declare_part(std::string("surface_2"), m_metaData.face_rank()); - stk_classic::mesh::fem::set_cell_topology< Triangle3 >(*m_sideset_tri_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_tri_subset); - stk_classic::io::put_io_part_attribute(*m_sideset_tri); - m_metaData.declare_part_subset(*m_sideset_tri, *m_sideset_tri_subset); - } - put_field( m_coordinates_field , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal ); - put_field( m_centroid_field , m_elem_rank , universal ); - put_field( m_temperature_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, universal ); - - put_field( m_volume_field, m_elem_rank, m_block_pyramid ); - - // Define the field-relation such that the values of the - // 'element_node_coordinates_field' are pointers to the - // element's nodal 'coordinates_field'. - // I.e., let: - // double *const* elem_node_coord = - // field_data( m_element_node_coordinates_field , element ); - // then - // elem_node_coord[n][0..2] is the coordinates of element node 'n' - // that are attached to that node. - - m_metaData.declare_field_relation( - m_element_node_coordinates_field , - stk_classic::mesh::fem::get_element_node_stencil(3) , - m_coordinates_field - ); - - // Define element node coordinate field for all element parts - put_field( m_element_node_coordinates_field, m_elem_rank, m_block_pyramid, Pyramid5::node_count ); - stk_classic::io::put_io_part_attribute( m_block_pyramid ); - - if (doCommit) - m_metaData.commit(); - } - - PyramidFixture::~PyramidFixture() - { } - - //------------------------------------------------------------------------------ - // Use case specific mesh generation data: - - enum { SpatialDim = 3 }; - enum { node_count = 7 }; - enum { number_pyramid = 2 }; - enum { number_quad = 2 }; - enum { number_tri = 6 }; - - namespace { - - // Hard coded node coordinate data for all the nodes in the entire mesh - static const double node_coord_data[ node_count ][ SpatialDim ] = { - - { 0 , 0 , -1 } , { 1 , 0 , -1 } , { 2 , 0 , -1 } , - - { 0 , 1 , -1 } , { 1 , 1 , -1 } , { 2 , 1 , -1 } , - - { 1 , 1 , -2 } - }; - - // Hard coded pyramid node ids for all the pyramid nodes in the entire mesh - static const stk_classic::mesh::EntityId pyramid_node_ids[number_pyramid][ Pyramid5::node_count ] = { - { 1 , 4 , 5 , 2 , 7 } , - { 2 , 5 , 6 , 3 , 7 } }; - - // Hard coded quad node ids for all the quad nodes in the entire mesh - static const stk_classic::mesh::EntityId quad_node_ids[number_quad][ Quad4::node_count ] = { - { 1 , 4 , 5 , 2 } , - { 2 , 5 , 6 , 3 } }; - - // Hard coded tri node ids for all the tri nodes in the entire mesh - static const stk_classic::mesh::EntityId tri_node_ids[number_tri][ Triangle3::node_count ] = { - { 1 , 7 , 2 }, - { 4, 7, 1 }, - { 5, 7, 4 }, - { 6, 7, 5 }, - { 3, 7, 6 }, - { 2, 7, 3 } - }; - - } - - //------------------------------------------------------------------------------ - - void PyramidFixture::populate() - { - // Populate mesh with all node types - - m_bulkData.modification_begin(); - - if (m_bulkData.parallel_rank() == 0) - { - stk_classic::mesh::EntityId curr_elem_id = 1; - - // For each element topology declare elements - - stk_classic::mesh::Entity *pyramids[2]; - for ( unsigned i = 0 ; i < number_pyramid ; ++i , ++curr_elem_id ) { - pyramids[i] = &stk_classic::mesh::fem::declare_element( m_bulkData, m_block_pyramid, curr_elem_id, pyramid_node_ids[i] ); - } - - if (m_sideset_quad) - { - for ( unsigned i = 0 ; i < number_quad ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element_side( m_bulkData, - curr_elem_id, //side_id, - *pyramids[i], // element, - 4, //j_side, // local_side_ord, - m_sideset_quad_subset); - } - } - - if (m_sideset_tri) - { - unsigned j_side=0; - for ( unsigned i = 0 ; i < 3 ; ++i , ++curr_elem_id ) { - if (i == 2) ++j_side; - stk_classic::mesh::fem::declare_element_side( m_bulkData, - curr_elem_id, //side_id, - *pyramids[0], // element, - j_side, //j_side, // local_side_ord, - m_sideset_tri_subset); - ++j_side; - } - j_side=1; - for ( unsigned i = 0 ; i < 3 ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element_side( m_bulkData, - curr_elem_id, //side_id, - *pyramids[1], // element, - j_side, //j_side, // local_side_ord, - m_sideset_tri_subset); - ++j_side; - } - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < node_count ; ++i ) { - stk_classic::mesh::Entity * const node = m_bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - } - m_bulkData.modification_end(); - - } - - // Verify mesh for 6 different parts - bool verifyMesh( const PyramidFixture & mesh ) - { - bool result = true; - - const stk_classic::mesh::BulkData & bulkData = mesh.m_bulkData ; - //const VectorFieldType & node_coord = mesh.m_coordinates_field ; - //const ElementNodePointerFieldType & elem_node_coord = mesh.m_element_node_coordinates_field ; - - std::vector element_buckets = bulkData.buckets( mesh.m_elem_rank ); - - // Create a pair containing Part and matching node_count - - typedef std::pair PartNodeCountPair; - std::vector part_and_node_counts; - part_and_node_counts.push_back(PartNodeCountPair(&mesh.m_block_pyramid, Pyramid5::node_count)); - - // Verify that entities in each part are set up correctly. - // Use a PartVector iterator for parts_to_check and call - // verify_elem_node_coord_by_part in UseCase_Common.cpp for - // each part in turn. -#if 0 - for( std::vector::const_iterator i = part_and_node_counts.begin() ; i != part_and_node_counts.end() ; ++i ) - { - result = result && - verify_elem_node_coord_by_part( - *(i->first), - element_buckets, - elem_node_coord, - node_coord, - i->second - ); - } -#endif - - // Check that all the nodes were allocated. - for ( unsigned i = 0 ; i < node_count ; ++i ) { - stk_classic::mesh::Entity * const node = bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - if ( node == NULL ) { - std::cerr << "Error! Invalid null pointer for node returned from " - << "bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK, " << i+1 << " ) " << std::endl; - result = false; - } - } - - return result; - } - - } //namespace percept -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.hpp deleted file mode 100644 index 435cf95ab97b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/PyramidFixture.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_PyramidFixture_hpp -#define stk_percept_PyramidFixture_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include - -/** stk_mesh Use Case 3 - copied and modified here */ - -#define HET_FIX_INCLUDE_EXTRA_ELEM_TYPES 0 - -namespace stk_classic { - namespace percept { - - typedef stk_classic::mesh::Field VectorFieldType ; - typedef stk_classic::mesh::Field ScalarFieldType ; - typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - - /** Use case with mixed element topologies and - * field relations to provide fast access to node field data - * from an element. - * - * copied from stk_mesh and modified - */ - - class PyramidFixture { - public: - - - ~PyramidFixture(); - - PyramidFixture( stk_classic::ParallelMachine comm, bool doCommit = true, bool do_sidesets = false); - - void populate(); - - const int m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData m_metaData; - stk_classic::mesh::BulkData m_bulkData; - - stk_classic::mesh::Part & m_block_pyramid; - stk_classic::mesh::Part * m_sideset_quad; - stk_classic::mesh::Part * m_sideset_quad_subset; - stk_classic::mesh::Part * m_sideset_tri; - stk_classic::mesh::Part * m_sideset_tri_subset; - - const stk_classic::mesh::EntityRank m_elem_rank; - - VectorFieldType & m_coordinates_field; - VectorFieldType & m_centroid_field; - ScalarFieldType & m_temperature_field; - ScalarFieldType & m_volume_field; - ElementNodePointerFieldType & m_element_node_coordinates_field; - }; - - bool verifyMesh( const PyramidFixture & mesh ); - - } //namespace percept -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_3_hpp diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/QuadFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/QuadFixture.hpp deleted file mode 100644 index b89f9e2b1764..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/QuadFixture.hpp +++ /dev/null @@ -1,473 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_UnitTestQuadFixture_hpp -#define stk_percept_UnitTestQuadFixture_hpp - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#ifdef PERCEPT_QF_USE_COORD_GATHER_FIELD -#undef PERCEPT_QF_USE_COORD_GATHER_FIELD -#endif - -#define PERCEPT_QF_USE_COORD_GATHER_FIELD 0 - -namespace stk_classic { - namespace percept { - - - // copied from stk_mesh/fixtures - had to copy because stk_mesh couldn't depend on stk_io, for example, so the changes I required - // had to be done on a copy - - // QuadFixture now allows Scalar to be a double (which is required by I/O for example, also named parts are conforming to I/O) - - /// Topology can also be Triangle<3> - - template > - class QuadFixture { - - public: - // typedef int Scalar ; - //typedef double Scalar ; - typedef Topology QuadOrTriTopo ; - enum { NodesPerElem = QuadOrTriTopo::node_count }; - - typedef stk_classic::mesh::Field CoordFieldType; - typedef stk_classic::mesh::Field CoordGatherFieldType; - - static std::vector get_entity_rank_names(unsigned dim) - { - std::vector names = stk_classic::mesh::fem::entity_rank_names(dim); -#if PERCEPT_USE_FAMILY_TREE - names.push_back("FAMILY_TREE"); -#endif -#if PERCEPT_USE_PSEUDO_ELEMENTS - names.push_back("PSEUDO_ELEMENT"); -#endif - return names; - } - - ~QuadFixture() - {} - - QuadFixture( stk_classic::ParallelMachine pm , - unsigned nx , unsigned ny, bool generate_sidesets_in, bool debug_geom_side_sets_as_blocks_in=false ) - : meta_data(2, get_entity_rank_names(2) ), - bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm ), - quad_part( meta_data.declare_part("block_1", meta_data.element_rank() ) ), - coord_field( meta_data.declare_field("coordinates") ), -#if PERCEPT_QF_USE_COORD_GATHER_FIELD - coord_gather_field( meta_data.declare_field("GatherCoordinates") ), -#endif - NX( nx ), - NY( ny ), - generate_sidesets(generate_sidesets_in), - debug_geom_side_sets_as_blocks(debug_geom_side_sets_as_blocks_in) - { - enum { SpatialDim = 2 }; - - set_bounding_box(0,(double)NX,0,(double)NY); - - // Set topology of the element block part - //stk_classic::mesh::fem::set_cell_topology(meta_data, quad_part, fem::CellTopology(shards::getCellTopologyData()) ); - stk_classic::mesh::fem::set_cell_topology(quad_part); - stk_classic::io::put_io_part_attribute(quad_part); - - //put coord-field on all nodes: - put_field( - coord_field, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - meta_data.universal_part(), - SpatialDim - ); - -#if PERCEPT_QF_USE_COORD_GATHER_FIELD - //put coord-gather-field on all elements: - put_field( - coord_gather_field, - meta_data.element_rank(), - meta_data.universal_part(), - NodesPerElem - ); - // Field relation so coord-gather-field on elements points - // to coord-field of the element's nodes - - const stk_classic::mesh::EntityRank element_rank = 2; - meta_data.declare_field_relation( coord_gather_field, stk_classic::mesh::fem::element_node_stencil, coord_field); -#endif - - - if (generate_sidesets) - generate_sides_meta( ); - - } - void set_bounding_box(double xmin, double xmax, double ymin, double ymax) - { - m_xmin=xmin; - m_xmax=xmax; - m_ymin=ymin; - m_ymax=ymax; - } - - void generate_mesh() { - std::vector element_ids_on_this_processor; - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - const unsigned num_elems = NX * NY; - - const stk_classic::mesh::EntityId beg_elem = 1 + ( num_elems * p_rank ) / p_size ; - const stk_classic::mesh::EntityId end_elem = 1 + ( num_elems * ( p_rank + 1 ) ) / p_size ; - - for ( stk_classic::mesh::EntityId i = beg_elem; i != end_elem; ++i) { - element_ids_on_this_processor.push_back(i); - } - - generate_mesh(element_ids_on_this_processor); - } - - void generate_mesh(std::vector & element_ids_on_this_processor) { - - { - //sort and unique the input elements - std::vector::iterator ib = element_ids_on_this_processor.begin(); - std::vector::iterator ie = element_ids_on_this_processor.end(); - - std::sort( ib, ie); - ib = std::unique( ib, ie); - element_ids_on_this_processor.erase(ib, ie); - } - - bulk_data.modification_begin(); - - { - std::vector::iterator ib = element_ids_on_this_processor.begin(); - const std::vector::iterator ie = element_ids_on_this_processor.end(); - for (; ib != ie; ++ib) { - stk_classic::mesh::EntityId entity_id = *ib; - unsigned ix = 0, iy = 0; - elem_ix_iy(entity_id, ix, iy); - - stk_classic::mesh::EntityId elem_node[4] ; - - elem_node[0] = node_id( ix , iy ); - elem_node[1] = node_id( ix+1 , iy ); - elem_node[2] = node_id( ix+1 , iy+1 ); - elem_node[3] = node_id( ix , iy+1 ); - - /* - * 3 2 PARENT Linear 4-Node Quadrilateral Element Nodes - * o---------o (SPACE_DIM = 2!) - * | /| - * | / | Triangles: [0] = {0,1,2} [1] = {0,2,3} - * | [1] / | Global sides: quad = {0,1,2,3}, triangles = { {[0], 0}, {[0], 1}, {[1], 1}, {[1], 2} } - * | / | - * | / | (PARENT) Linear 4-Node Quadrilateral - * | / | Element Edge Node Map: - * | / | { {0, 1}, {1, 2}, {2, 3} {3, 0} }; - * | / [0] | - * |/ | Triangle edge node map: { {0, 1}, {1, 2}, {2, 3} } - * o---------o - * 0 1 - */ - - if (NodesPerElem == 4) - { - stk_classic::mesh::fem::declare_element( bulk_data, quad_part, elem_id( ix , iy ) , elem_node); - } - else - { - stk_classic::mesh::fem::declare_element( bulk_data, quad_part, elem_id( ix , iy ) , elem_node); - - elem_node[0] = node_id( ix , iy ); - elem_node[1] = node_id( ix+1 , iy+1 ); - elem_node[2] = node_id( ix , iy+1 ); - stk_classic::mesh::fem::declare_element( bulk_data, quad_part, (NX*NY+1)+elem_id( ix , iy ) , elem_node); - } - elem_node[0] = node_id( ix , iy ); - elem_node[1] = node_id( ix+1 , iy ); - elem_node[2] = node_id( ix+1 , iy+1 ); - elem_node[3] = node_id( ix , iy+1 ); - - for (unsigned i = 0; i<4; ++i) { - stk_classic::mesh::Entity * const node = - bulk_data.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , elem_node[i] ); - - if ( node != NULL) { - - unsigned nx = 0, ny = 0; - node_ix_iy(elem_node[i], nx, ny); - - Scalar * data = stk_classic::mesh::field_data( coord_field , *node ); - - //data[0] = nx ; - // data[1] = ny ; - data[0] = m_xmin + (m_xmax-m_xmin)*((double)nx) / ((double)NX) ; - data[1] = m_ymin + (m_ymax-m_ymin)*((double)ny) / ((double)NY) ; - - } - } - } - } - - bulk_data.modification_end(); - - if (generate_sidesets) - generate_sides_bulk(element_ids_on_this_processor ); - - } - - stk_classic::mesh::fem::FEMMetaData meta_data ; - stk_classic::mesh::BulkData bulk_data ; - stk_classic::mesh::Part & quad_part ; - CoordFieldType & coord_field ; -#if PERCEPT_QF_USE_COORD_GATHER_FIELD - CoordGatherFieldType & coord_gather_field ; -#endif - const unsigned NX ; - const unsigned NY ; - stk_classic::mesh::Part *side_parts[4]; - bool generate_sidesets; - bool debug_geom_side_sets_as_blocks; - - - stk_classic::mesh::EntityId node_id( unsigned ix , unsigned iy ) const - { return 1 + ix + ( NX + 1 ) * iy ; } - - stk_classic::mesh::EntityId elem_id( unsigned ix , unsigned iy ) const - { return 1 + ix + NX * iy ; } - - stk_classic::mesh::Entity * node( unsigned ix , unsigned iy ) const - { return bulk_data.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_id(ix,iy) ); } - - void node_ix_iy( stk_classic::mesh::EntityId entity_id, unsigned &ix , unsigned &iy ) const { - entity_id -= 1; - - ix = entity_id % (NX+1); - entity_id /= (NX+1); - - iy = entity_id; - } - - void elem_ix_iy( stk_classic::mesh::EntityId entity_id, unsigned &ix , unsigned &iy ) const { - entity_id -= 1; - - ix = entity_id % NX; - entity_id /= NX; - - iy = entity_id; - } - - stk_classic::mesh::Entity * elem( unsigned ix , unsigned iy ) const - { return bulk_data.get_entity( meta_data.element_rank() , elem_id(ix,iy) ); } - - - void generate_sides_meta() - { - for (unsigned i_side = 0; i_side < 4; i_side++) - { - if (!debug_geom_side_sets_as_blocks) - { - side_parts[i_side] = &meta_data.declare_part(std::string("surface_quad4_edge2_")+boost::lexical_cast(i_side+1), meta_data.edge_rank()); - mesh::Part& side_part = meta_data.declare_part(std::string("surface_")+boost::lexical_cast(i_side+1), meta_data.edge_rank()); - //void set_cell_topology(FEMMetaData & fem_meta, Part &part, fem::CellTopology cell_topology); - - //stk_classic::mesh::fem::set_cell_topology< shards::Line<2> >(*side_parts[i_side]); - //stk_classic::mesh::fem::set_cell_topology(meta_data, *side_parts[i_side], fem::CellTopology(shards::getCellTopologyData()) ); - stk_classic::mesh::fem::set_cell_topology< shards::Line<2> >(*side_parts[i_side]); - stk_classic::io::put_io_part_attribute(*side_parts[i_side]); - stk_classic::io::put_io_part_attribute(side_part); - - meta_data.declare_part_subset(side_part, *side_parts[i_side]); - } - else - { - //side_parts[i_side] = &meta_data.declare_part(std::string("block_1000")+boost::lexical_cast(i_side+1), meta_data.edge_rank()); - side_parts[i_side] = &meta_data.declare_part >(std::string("block_1000")+boost::lexical_cast(i_side+1)); - //, m_block_beam( m_metaData.declare_part< Beam2 >( "block_2" ) ) - //stk_classic::mesh::fem::set_cell_topology< shards::Beam<2> >(*side_parts[i_side]); - stk_classic::io::put_io_part_attribute(*side_parts[i_side]); - - } - } - } - - void generate_sides_bulk( std::vector & element_ids_on_this_processor ) - { - bulk_data.modification_begin(); - - std::vector::iterator ibegin = element_ids_on_this_processor.begin(); - std::vector::iterator end = element_ids_on_this_processor.end(); - - // FIXME - a simple side_id server - unsigned side_id = 0 + bulk_data.parallel_rank() * (NX+1) * (NY+1); - - for (unsigned i_side = 0; i_side < 4; i_side++) - { - unsigned j_side = i_side; - if (NodesPerElem == 3) - { - if (i_side==2) j_side = 1; - if (i_side==3) j_side = 2; - } - - unsigned ix0 = 0; - unsigned ix1 = NX; - unsigned iy0 = 0; - unsigned iy1 = NY; - //unsigned ixp = 0; - //unsigned iyp = 0; - switch(i_side) - { - case 0: - iy0 = 0; - iy1 = 1; - //ixp = 1; - break; - case 1: - ix0 = NX-1; - ix1 = ix0+1; - //iyp = 1; - break; - case 2: - iy0 = NY-1; - iy1 = iy0+1; - //ixp = 1; - break; - case 3: - ix0 = 0; - ix1 = 1; - //iyp = 1; - break; - } - for (unsigned ix = ix0; ix < ix1; ix++) - { - for (unsigned iy = iy0; iy < iy1; iy++) - { - if (elem(ix,iy) && - (NodesPerElem == 4 || i_side <= 1)) - { - mesh::Entity& element = *elem(ix, iy); - - if (end != std::find(ibegin, end, element.identifier())) - { - ++side_id; - - if (0) - { - std::cout << "P[" << bulk_data.parallel_rank() << "] name= " << side_parts[i_side]->name() - << " ix= " << ix - << " iy= " << iy - << " i_side= " << i_side - << " element= " << element - << std::endl; - } - if (!debug_geom_side_sets_as_blocks) - { - stk_classic::mesh::fem::declare_element_side(bulk_data, - side_id, - element, - j_side, // local_side_ord, - side_parts[i_side]); - } - else - { - stk_classic::mesh::EntityId elem_node[2]; - elem_node[0] = (element.relations(0)[j_side]).entity()->identifier(); - elem_node[1] = (element.relations(0)[(j_side+1)%4]).entity()->identifier(); - stk_classic::mesh::fem::declare_element( bulk_data, *side_parts[i_side], side_id + (2*NX*NY+2) , elem_node); - - } - - } - - } - if (NodesPerElem == 3 && elem(ix,iy) && i_side >=2 ) - { - mesh::Entity& element = *bulk_data.get_entity(meta_data.element_rank(), (NX*NY+1)+elem_id(ix, iy)); - - if (end != std::find(ibegin, end, elem_id(ix,iy)) ) - { - ++side_id; - - if (0) - { - std::cout << "P[" << bulk_data.parallel_rank() << "] name= " << side_parts[i_side]->name() - << " ix= " << ix - << " iy= " << iy - << " i_side= " << i_side - << " element= " << element - << std::endl; - } - if (!debug_geom_side_sets_as_blocks) - { - stk_classic::mesh::fem::declare_element_side(bulk_data, - side_id, - element, - j_side, // local_side_ord, - side_parts[i_side]); - } - - } - - } - - } - } - - - } - - bulk_data.modification_end(); - } - - private: - - QuadFixture(); - QuadFixture( const QuadFixture & ); - QuadFixture & operator = ( const QuadFixture & ); - - double m_xmin; - double m_xmax; - double m_ymin; - double m_ymax; - - }; - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - } // percept -} // stk -#undef PERCEPT_QF_USE_COORD_GATHER_FIELD - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.cpp deleted file mode 100644 index 3df6142e01ef..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -// -//---------------------------------------------------------------------- - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include - -//---------------------------------------------------------------------- - -namespace stk_classic{ - namespace percept { - - typedef shards::Tetrahedron<4> Tet4; - - SingleTetFixture::SingleTetFixture( stk_classic::ParallelMachine comm, bool doCommit, unsigned npts, Point *points, unsigned ntets, TetIds *tetIds, - stk_classic::mesh::EntityId elem_id_start - ) : - m_spatial_dimension(3) - , m_metaData(m_spatial_dimension, stk_classic::mesh::fem::entity_rank_names(m_spatial_dimension) ) - , m_bulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_metaData) , comm ) - , m_block_tet( m_metaData.declare_part< Tet4 >( "block_1" )) - , m_elem_rank( m_metaData.element_rank() ) - , m_coordinates_field( m_metaData.declare_field< VectorFieldType >( "coordinates" )) - , m_npts(npts), m_points(points) - , m_ntets(ntets), m_tetIds(tetIds) - , m_elem_id_start(elem_id_start) - { - // Define where fields exist on the mesh: - stk_classic::mesh::Part & universal = m_metaData.universal_part(); - - put_field( m_coordinates_field , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal ); - - if (doCommit) - m_metaData.commit(); - } - - SingleTetFixture::~SingleTetFixture() - { } - - //------------------------------------------------------------------------------ - // Use case specific mesh generation data: - - enum { SpatialDim = 3 }; - enum { node_count = 4 }; - - namespace { - - // Hard coded node coordinate data for all the nodes in the entire mesh - static SingleTetFixture::Point node_coord_data[ node_count ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 1 } }; - - // Hard coded tetra node ids for all the tetra nodes in the entire mesh - static SingleTetFixture::TetIds tetra_node_ids[] = { - { 1, 2, 3, 4} }; - - } - - //------------------------------------------------------------------------------ - - void SingleTetFixture::populate() - { - // Populate mesh with all node types - - m_bulkData.modification_begin(); - - if (m_bulkData.parallel_rank() == 0) - { - stk_classic::mesh::EntityId curr_elem_id = (m_elem_id_start ? m_elem_id_start : 1); - - // For each element topology declare elements - unsigned ntets = 1; - unsigned npts = 4; - Point *pts = node_coord_data; - TetIds *tets = tetra_node_ids; - - if (m_ntets && m_npts) - { - ntets = m_ntets; - npts = m_npts; - pts = m_points; - tets = m_tetIds; - } - for ( unsigned i = 0 ; i < ntets ; ++i , ++curr_elem_id ) { - stk_classic::mesh::fem::declare_element( m_bulkData, m_block_tet, curr_elem_id, tets[i] ); - //std::cout << "tmp SingleTetFixture::populate tets[i]= " << i << " " << tets[i][0] << " " << tets[i][1] << " " << tets[i][2] << " " << tets[i][3] << std::endl; - } - - // For all nodes assign nodal coordinates - for ( unsigned i = 0 ; i < npts ; ++i ) { - stk_classic::mesh::Entity * const node = m_bulkData.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - double * const coord = field_data( m_coordinates_field , *node ); - coord[0] = pts[i][0] ; - coord[1] = pts[i][1] ; - coord[2] = pts[i][2] ; - //std::cout << "tmp SingleTetFixture::populate coords= " << i << " " << coord[0] << " " << coord[1] << " " << coord[2] << std::endl; - } - - } - m_bulkData.modification_end(); - - } - - } //namespace percept -} //namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.hpp deleted file mode 100644 index a4f80404a8e5..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/SingleTetFixture.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_SingleTetFixture_hpp -#define stk_percept_SingleTetFixture_hpp - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include - -/** stk_mesh Use Case 3 - copied and modified here */ - -#define HET_FIX_INCLUDE_EXTRA_ELEM_TYPES 0 - -namespace stk_classic { - namespace percept { - - typedef stk_classic::mesh::Field VectorFieldType ; - typedef stk_classic::mesh::Field ScalarFieldType ; - typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - - /** Use case with mixed element topologies and - * field relations to provide fast access to node field data - * from an element. - * - * copied from stk_mesh and modified - */ - - class SingleTetFixture { - public: - - typedef double Point[3]; - typedef stk_classic::mesh::EntityId TetIds[4]; - - - ~SingleTetFixture(); - - SingleTetFixture( stk_classic::ParallelMachine comm, bool doCommit = true, unsigned npts=0, Point *points=0, unsigned ntets=0, TetIds *tetIds=0, - stk_classic::mesh::EntityId elem_id_start=0); - - void populate(); - - int m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData m_metaData; - stk_classic::mesh::BulkData m_bulkData; - - stk_classic::mesh::Part & m_block_tet; - - const stk_classic::mesh::EntityRank m_elem_rank; - - VectorFieldType & m_coordinates_field; - - unsigned m_npts; - Point *m_points; - unsigned m_ntets; - TetIds *m_tetIds; - - stk_classic::mesh::EntityId m_elem_id_start; - - }; - - //bool verifyMesh( const SingleTetFixture & mesh ); - - } //namespace percept -} //namespace stk_classic - -#endif // Stk_Mesh_Use_Cases_UseCase_3_hpp diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/WedgeFixture.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/WedgeFixture.hpp deleted file mode 100644 index b77a9ac745df..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/fixtures/WedgeFixture.hpp +++ /dev/null @@ -1,219 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_percept_UnitTestWedgeFixture_hpp -#define stk_percept_UnitTestWedgeFixture_hpp - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include - -namespace stk_classic { - namespace percept { - - class WedgeFixture - { - SweepMesher m_sweepMesher; - - public: - - mesh::BulkData * createMesh(stk_classic::ParallelMachine parallel_machine, - unsigned n_nodes_x, unsigned n_nodes_y, unsigned n_nodes_z, - double xmin, double xmax, - double ymin, double ymax, - double zmin, double zmax, - std::string output_filename - ) - { - bool verbose = true; - - std::vector > coordsLine(n_nodes_x); - for (unsigned ix = 0; ix < n_nodes_x; ix++) - { - double dx = double(ix)/double(n_nodes_x - 1); - coordsLine[ix][0] = xmin + dx*(xmax - xmin); - coordsLine[ix][1] = ymin; - coordsLine[ix][2] = zmin; - } - std::vector line2Elems(2*(n_nodes_x - 1)); - for (unsigned ix = 0; ix < n_nodes_x - 1; ix++) - { - line2Elems[2*ix] = ix; - line2Elems[2*ix+1] = ix+1; - } - - // line2 mesh - SweepMesher& tp2 = m_sweepMesher; - //tp2 = SweepMesher(); - - //tp2.initNodes(coordsLine.begin(), n_nodes_x); - tp2.initNodes(&coordsLine[0], n_nodes_x); - tp2.initElems(shards_Line_2, &line2Elems[0], n_nodes_x - 1); - if(verbose) std::cout << "line2 mesh\n"; - tp2.dump(); - - // sweep to make a quad mesh from line mesh - boost::array dir = {{0, (ymax-ymin)/double(n_nodes_y - 1),0}}; - - TransformDir xf0 ( dir ); - Transform* xf = &xf0; - - std::vector xforms(n_nodes_y - 1, xf); - - tp2.sweep(shards_Line_2, shards_Quadrilateral_4, xforms); - if(verbose) std::cout << "after line to quad sweep\n"; - tp2.dump(); - - SweepMesher quadMeshCopy; - quadMeshCopy.CopyFromBasicMesh(tp2); - //tp2.stkMeshCreate(parallel_machine); - //tp2.writeSTKMesh("wedge-quad-0.e"); - - // break all of the quads into tris - tp2.breakAllElements(); - if(verbose) std::cout << "after break quad to tri\n"; - tp2.dump(true); - //tp2.stkMeshCreate(parallel_machine); - //tp2.writeSTKMesh("tp2-quad-tri.e"); - - // sweep again to make a wedge mesh - boost::array dir1 = {{0,0,(zmax-zmin)/double(n_nodes_z - 1)}}; - TransformDir xf01(dir1); - Transform* xf01t = &xf01; - std::vector xforms0(n_nodes_z - 1, xf01t); - tp2.sweep(xforms0); - - if(verbose) std::cout << "after sweep for wedge \n"; - tp2.dump(); - if (output_filename.length()) - { - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh(output_filename.c_str()); - } - else - { - tp2.stkMeshCreateMetaNoCommit(parallel_machine); - } - - return tp2.get_bulk_data(); - - } - - mesh::fem::FEMMetaData *getMetaData() { return m_sweepMesher.getMetaData() ; } - - //stk_classic::mesh::BulkData* - void - createBulkAfterMetaCommit(stk_classic::ParallelMachine parallel_machine) - { - m_sweepMesher.stkMeshCreateBulkAfterMetaCommit(parallel_machine); - //return m_sweepMesher.get_bulk_data(); - } - - void createFixedSizeMesh(stk_classic::ParallelMachine parallel_machine, std::string output_filename) - { - bool verbose = true; - - boost::array coordsLine[] = { - {{0,0,0}}, {{1,0,0}}, {{2,0,0}}, {{3,0,0}}, {{4,0,0}} - }; - - // double coordsCPP[][3] = { - // {0,0,0}, {1,0,0}, {2,2,0}, {0,3,0}, - // {0,0,1}, {1,0,1}, {2,2,1}, {0,3,1} - // }; - unsigned numNodesLine = sizeof(coordsLine)/sizeof(coordsLine[0]); - - unsigned line2Elems[] = { - 0,1, - 1,2, - 2,3, - 3,4, - 0,0 // sentinel - }; - enum { - numElemsL2 = sizeof(line2Elems)/(2*sizeof(line2Elems[0])) - 1 // drop sentinel - }; - if(verbose) std::cout << "numElemsL2= " << numElemsL2 << std::endl; - - - // line2 mesh - SweepMesher tp2; - - tp2.initNodes(coordsLine, numNodesLine); - tp2.initElems(shards_Line_2, line2Elems, numElemsL2); - if(verbose) std::cout << "line2 mesh\n"; - tp2.dump(); - - // sweep to make a quad mesh from line mesh - boost::array dir = {{0,1.234,0}}; - - TransformDir xf0 ( dir ); - Transform* xf = &xf0; - - std::vector xforms(3, xf); - - tp2.sweep(shards_Line_2, shards_Quadrilateral_4, xforms); - if(verbose) std::cout << "after line to quad sweep\n"; - tp2.dump(); - - SweepMesher quadMeshCopy; - quadMeshCopy.CopyFromBasicMesh(tp2); - //tp2.stkMeshCreate(parallel_machine); - //tp2.writeSTKMesh("wedge-quad-0.e"); - - // break all of the quads into tris - tp2.breakAllElements(); - //verbose=true; - if(verbose) std::cout << "after break quad to tri\n"; - tp2.dump(verbose); - tp2.dump(); - //tp2.stkMeshCreate(parallel_machine); - //tp2.writeSTKMesh("tp2-quad-tri.e"); - - // sweep again to make a wedge mesh - boost::array dir1 = {{0,0,2.345}}; - std::vector xforms0(1); - TransformDir xf01(dir1); - xforms0[0] = &xf01; - tp2.sweep(xforms0); - - if(verbose) std::cout << "after sweep for wedge \n"; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - - tp2.writeSTKMesh(output_filename.c_str()); - } - - }; - - - } // percept -} // stk -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/foo.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/foo.cpp deleted file mode 100644 index 2e9a3d1d08f4..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/foo.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -int foo() -{ - return 0; -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/BucketOp.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/BucketOp.hpp deleted file mode 100644 index c0aff73b060c..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/BucketOp.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef stk_percept_BucketOp_hpp -#define stk_percept_BucketOp_hpp - -#include -#include -#include -#include - - -namespace stk_classic -{ - namespace percept - { - - class BucketOp - { - public: - /// innermost operation of an bucket-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - virtual bool operator()(const stk_classic::mesh::Bucket& bucket, - stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData)=0; - virtual ~BucketOp() {} - }; - - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/function/CMakeLists.txt deleted file mode 100644 index a60a1a8a429a..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - -ADD_SUBDIRECTORY(internal) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/function/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/CompositeFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/CompositeFunction.hpp deleted file mode 100644 index 49bf3eb6a1b2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/CompositeFunction.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef stk_encr_CompositeFunction_hpp -#define stk_encr_CompositeFunction_hpp - -#include -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - //typedef GenericVector GenericFunctionVector; - - //typedef std::vector GenericFunctionVector; - - class CompositeFunction : public Function - { - public: - /// compose two functions to be able to apply in turn as in func_2(func_1(x)), or more specifically as: - /// func_1(domain, codomain_temp); - // func_2(codomain_temp, codomain); - - /// Note that since this is a Function also, one can make multiple compositions e.g. h(g(f(x))) by - /// CompositeFunction g_of_f (f, g) - /// CompositeFunction h_of_g_of_f (g_of_f, h); - /// The first function in the list is always applied first. - CompositeFunction(const char *name, Function& func_1, Function& func_2, - Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions(), - unsigned integration_order = 0) : Function(name, domain_dimensions, codomain_dimensions, integration_order), - m_func1(func_1), m_func2(func_2) - { - EXCEPTWATCH; -// std::cout << "func_1 = " << func_1 << std::endl; -// std::cout << "func_2 = " << func_2 << std::endl; -// std::cout << "domain_dimensions= " << domain_dimensions << std::endl; -// std::cout << "codomain_dimensions= " << codomain_dimensions << std::endl; - setDomainDimensions(func_1.getDomainDimensions()); - setCodomainDimensions(func_2.getCodomainDimensions()); - } - - virtual void operator()(MDArray& domain, MDArray& codomain, double time_value_optional=0.0) - { - EXCEPTWATCH; - m_func1(domain, codomain, time_value_optional); - MDArray input = codomain; - m_func2(input, codomain, time_value_optional); - } - - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - EXCEPTWATCH; - m_func1(domain, codomain, element, parametric_coords, time_value_optional); - MDArray input = codomain; - m_func2( input, codomain, element, parametric_coords, time_value_optional); - } - - - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coords, double time_value_optional=0.0) - { - EXCEPTWATCH; - m_func1(domain, codomain, bucket, parametric_coords, time_value_optional); - MDArray input = codomain; - m_func2( input, codomain, bucket, parametric_coords, time_value_optional); - } - - protected: - - Function& m_func1; - Function& m_func2; - - }; - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/ConstantFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/ConstantFunction.hpp deleted file mode 100644 index c4dc9f54c1fb..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/ConstantFunction.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef stk_encr_ConstantFunction_hpp -#define stk_encr_ConstantFunction_hpp - -#include -#include - -namespace stk_classic -{ - namespace percept - { - class ConstantFunction : public Function, public HasValue - { - double m_value; - public: - ConstantFunction(double value, - const char *name, - Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions(), - unsigned integration_order = 0) : Function(name, domain_dimensions, codomain_dimensions, integration_order), m_value(value) {} - - using Function::operator(); - virtual void operator()(MDArray& domain, MDArray& codomain, double time_value_optional=0.0) - { - // set all values (regardless of rank of codomain) to m_value - codomain.initialize(m_value); - } - - double& getValue() { return m_value; } - void setValue(double& v) { m_value = v; } - - }; - - class ConstantFunctionVec : public Function, public HasValue > - { - std::vector m_value; - public: - ConstantFunctionVec(std::vector& value, - const char *name, - Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions(), - unsigned integration_order = 0) : Function(name, domain_dimensions, codomain_dimensions, integration_order), m_value(value) {} - - using Function::operator(); - virtual void operator()(MDArray& domain, MDArray& codomain, double time_value_optional=0.0) - { - if (codomain.rank() <= 0) - { - throw std::runtime_error("ConstantFunctionVec::operator() codomain rank is <= 0"); - } - int stride = codomain.dimension(codomain.rank()-1); - if (stride <= 0) - { - throw std::runtime_error("ConstantFunctionVec::operator() codomain stride is <= 0"); - } - if (stride != (int)m_value.size()) - { - throw std::runtime_error("ConstantFunctionVec::operator() codomain stride is not same as value"); - } - int sz = codomain.size(); - int k = 0; - for (int i = 0; i < sz/stride; i++) - { - for (int j = 0; j < stride; j++) - { - codomain[k+j] = m_value[j]; - } - k += stride; - } - } - - std::vector& getValue() { return m_value; } - void setValue(std::vector& v) { m_value = v; } - - }; - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/ElementOp.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/ElementOp.hpp deleted file mode 100644 index 321c25dbc61b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/ElementOp.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef stk_percept_ElementOp_hpp -#define stk_percept_ElementOp_hpp - -#include -#include -#include -#include - - -namespace stk_classic -{ - namespace percept - { - - class ElementOp - { - public: - /// innermost operation of an element-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData)=0; - virtual void init_elementOp()=0; - virtual void fini_elementOp()=0; - virtual ~ElementOp() {} - }; - - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.cpp deleted file mode 100644 index d25f9ac0359c..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.cpp +++ /dev/null @@ -1,293 +0,0 @@ - -#include - -#include -#include -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - //======================================================================================================================== - // high-level interface - FieldFunction::FieldFunction(const char *name, mesh::FieldBase *field, PerceptMesh& mesh, - int domain_dimension, - int codomain_dimension, - SearchType searchType, - unsigned integration_order) : - - Function(name, Dimensions(domain_dimension), Dimensions(codomain_dimension), integration_order), - m_my_field(field), m_bulkData(mesh.get_bulk_data()), - m_cachedElement(0), m_searcher(0), - m_cached_topo_key(0), m_cached_basis(0), m_searchType(searchType), m_get_derivative(false) - //, m_parallelEval(true) - { - } - - bool FieldFunction::m_parallelEval=true; - - mesh::FieldBase *FieldFunction::get_field() {return m_my_field; } - - void FieldFunction::interpolateFrom(Function& function) - { - EXCEPTWATCH; - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*m_my_field); - mesh::BulkData& bulkData = *m_bulkData; - - PerceptMesh meshUtil(&metaData, &bulkData); - - /// for each node in the codomain, evaluate the function_to_interpolate's function, assign to the codomain field - meshUtil.nodalOpLoop(function, m_my_field); - - }//interpolateFrom - - - //======================================================================================================================== - // low-level interface - - typedef mesh::Field ScalarFieldType ; - typedef mesh::Field VectorFieldType ; - - - FieldFunction::FieldFunction(const char *name, mesh::FieldBase *field, mesh::BulkData *bulk, - Dimensions domain_dimensions, - Dimensions codomain_dimensions, - SearchType searchType, - unsigned integration_order) : - Function(name, domain_dimensions, codomain_dimensions, integration_order), - m_my_field(field), m_bulkData(bulk), m_cachedElement(0), m_searcher(0), - m_cached_topo_key(0), m_cached_basis(0), m_searchType(searchType), m_get_derivative(false) - //, m_parallelEval(true) - { - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*bulk); - m_coordinatesField = metaData.get_field("coordinates"); - } - - FieldFunction::FieldFunction(const char *name, mesh::FieldBase *field, PerceptMesh& eMesh, - Dimensions domain_dimensions, - Dimensions codomain_dimensions, - SearchType searchType, - unsigned integration_order) : - Function(name, domain_dimensions, codomain_dimensions, integration_order), - m_my_field(field), m_bulkData(eMesh.get_bulk_data()), m_cachedElement(0), m_searcher(0), - m_cached_topo_key(0), m_cached_basis(0), m_searchType(searchType), m_get_derivative(false) - { - - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*m_bulkData); - m_coordinatesField = metaData.get_field("coordinates"); - - } - - FieldFunction::~FieldFunction() - { - if (m_searcher) - delete m_searcher; - } - - mesh::BulkData *FieldFunction::get_bulk_data() {return m_bulkData; } - - - void FieldFunction::localEvaluation(MDArray& input_phy_points, MDArray& output_field_values, double time) - { - m_parallelEval = false; - (*this)(input_phy_points, output_field_values, time); - m_parallelEval = true; - } - - void FieldFunction::setup_searcher(int D_) - { - if (!m_searcher) - { - switch (m_searchType) - { - case SIMPLE_SEARCH: - m_searcher = new SimpleSearcher(m_bulkData); - break; - case STK_SEARCH: - { - //int spDim = last_dimension(input_phy_points); - if (D_ == 3) - m_searcher = new STKSearcher<3>(m_bulkData); - else - { - //m_searcher = new STKSearcher<2>(this); - throw std::runtime_error("STK_SEARCH not ready for 2D, use SIMPLE_SEARCH"); - } - } - break; - default: - throw std::runtime_error("FieldFunction::operator() unknown search type"); - break; - } - //std::cout << "setupSearch..." << std::endl; - m_searcher->setupSearch(); - //std::cout << "setupSearch...done" << std::endl; - } - } - - /** Evaluate the function at this input point (or points) returning value(s) in output_field_values - * - * In the following, the arrays are dimensioned using the notation (from Intrepid's doc): - * - * [C] - num. integration domains (cells/elements) - * [F] - num. Intrepid "fields" (number of bases within an element == num. nodes typically) - * [P] - num. integration (or interpolation) points within the element - * [D] - spatial dimension - * [D1], [D2] - spatial dimension - * - * Locally, we introduce this notation: - * - * [DOF] - number of degrees-of-freedom per node of the interpolated stk Field. For example, a vector field in 3D has [DOF] = 3 - * - * Dimensions of input_phy_points are required to be either ([D]) or ([P],[D]) - * Dimensions of output_field_values are required to be ([DOF]) or ([P],[DOF]) respectively - * - * [R] is used for the rank of MDArray's - */ - void FieldFunction::operator()(MDArray& input_phy_points, MDArray& output_field_values, double time) - { - EXCEPTWATCH; - argsAreValid(input_phy_points, output_field_values); - - m_found_on_local_owned_part = false; - - //// single point only (for now) - unsigned found_it = 0; - - int D_ = last_dimension(input_phy_points); - MDArray found_parametric_coordinates_one(1, D_); - setup_searcher(D_); - - MDArray output_field_values_local = output_field_values; - int R_output = output_field_values.rank(); - - int R_input = input_phy_points.rank(); - int P_ = (R_input == 1 ? 1 : input_phy_points.dimension(R_input-2)); - - // FIXME for tensor valued fields - int DOF_ = last_dimension(output_field_values_local); - - MDArray input_phy_points_one(1,D_); - MDArray output_field_values_one(1,DOF_); - - int C_ = 1; - if (R_input == 3) - { - C_ = input_phy_points.dimension(0); - } - for (int iC = 0; iC < C_; iC++) - { - for (int iP = 0; iP < P_; iP++) - { - for (int iD = 0; iD < D_; iD++) - { - switch(R_input) - { - case 1: input_phy_points_one(0, iD) = input_phy_points(iD); break; - case 2: input_phy_points_one(0, iD) = input_phy_points(iP, iD); break; - case 3: input_phy_points_one(0, iD) = input_phy_points(iC, iP, iD); break; - default: VERIFY_1("bad rank"); - } - } - - const stk_classic::mesh::Entity *found_element = 0; - { - EXCEPTWATCH; - //if (m_searchType==STK_SEARCH) std::cout << "find" << std::endl; - found_element = m_searcher->findElement(input_phy_points_one, found_parametric_coordinates_one, found_it, m_cachedElement); - //if (m_searchType==STK_SEARCH) std::cout << "find..done found_it=" << found_it << std::endl; - } - - // if found element on the local owned part, evaluate - if (found_it) - { - m_found_on_local_owned_part = true; - if (( EXTRA_PRINT) && m_searchType==STK_SEARCH) - std::cout << "FieldFunction::operator() found element # = " << found_element->identifier() << std::endl; - - (*this)(input_phy_points_one, output_field_values_one, *found_element, found_parametric_coordinates_one); - - for (int iDOF = 0; iDOF < DOF_; iDOF++) - { - switch (R_output) - { - case 1: output_field_values_local( iDOF) = output_field_values_one(0, iDOF); break; - case 2: output_field_values_local(iP, iDOF) = output_field_values_one(0, iDOF); break; - case 3: output_field_values_local(iC, iP, iDOF) = output_field_values_one(0, iDOF); break; - default: VERIFY_1("bad rank"); - } - } - } - else - { - if (!m_parallelEval) - { - std::cout << "P[" << Util::get_rank() << "] FieldFunction::operator() found_it = " << found_it << " points= " - << input_phy_points_one - << std::endl; - - throw std::runtime_error("FieldFunction::operator() in local eval mode and didn't find element - logic error"); - } - double max_val = std::numeric_limits::max(); - output_field_values_local.initialize(max_val); - } - - // make sure it is found somewhere - if (m_parallelEval) - { - all_reduce( m_bulkData->parallel() , ReduceMax<1>( & found_it ) ); - } - - if (EXTRA_PRINT) std::cout << "FieldFunction::operator() global found_it = " << found_it << std::endl; - - if (!found_it) - { - throw std::runtime_error("FieldFunction::operator() couldn't find element"); - } - - if (m_parallelEval) - { - stk_percept_global_lex_min( m_bulkData->parallel(), output_field_values.size(), &output_field_values_local[0], &output_field_values[0]); - } - else - { - output_field_values = output_field_values_local; - } - m_cachedElement = found_element; - } - } - - } - - /** Evaluate the function on this element at the parametric coordinates and return in output_field_values. - * - * Dimensions of parametric_coordinates are required to be ([P],[D]) - * Dimensions of output_field_values are required to be ([P],[DOF]), (or in future, ([C],[P],[DOF]) ) - * - */ - - void FieldFunction::operator()(MDArray& input_phy_points, MDArray& output_field_values, - const stk_classic::mesh::Entity& element, const MDArray& parametric_coordinates, double time_value_optional) - { - EXCEPTWATCH; - helper(input_phy_points, output_field_values, element, parametric_coordinates, time_value_optional); - } - - void FieldFunction::operator()(MDArray& input_phy_points, MDArray& output_field_values, - const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coordinates, double time_value_optional) - { - EXCEPTWATCH; -#ifndef NDEBUG - int num_elements_in_bucket = bucket.size(); - VERIFY_OP(input_phy_points.dimension(0), ==, num_elements_in_bucket, "FieldFunction::operator() mismatch in input_phy_points and num_elements_in_bucket"); - VERIFY_OP(output_field_values.dimension(0), ==, num_elements_in_bucket, "FieldFunction::operator() mismatch in input_phy_points and num_elements_in_bucket"); -#endif - helper(input_phy_points, output_field_values, bucket, parametric_coordinates, time_value_optional); - } - - - }//namespace percept -}//namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.hpp deleted file mode 100644 index 7262e99e58b1..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/FieldFunction.hpp +++ /dev/null @@ -1,358 +0,0 @@ -#ifndef stk_encr_FieldFunction_hpp -#define stk_encr_FieldFunction_hpp - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include "Teuchos_RCP.hpp" - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -//using namespace sierra; - -namespace stk_classic -{ - namespace percept - { - - //class Helper; - /** Evaluate the function at this input point (or points) returning value(s) in output_field_values - * - * In the following, the arrays are dimensioned using the notation (from Intrepid's doc): - * - * [C] - num. integration domains (cells/elements) - * [F] - num. Intrepid "fields" (number of bases within an element == num. nodes typically) - * [P] - num. integration (or interpolation) points within the element - * [D] - spatial dimension - * [D1], [D2] - spatial dimension - * - * Locally, we introduce this notation: - * - * [DOF] - number of degrees-of-freedom per node of the interpolated stk Field. For example, a vector field in 3D has [DOF] = 3 - * - */ - class FieldFunction : public Function - { - public: - static bool m_parallelEval; - - enum SearchType { SIMPLE_SEARCH, STK_SEARCH }; - - //======================================================================================================================== - // high-level interface - FieldFunction(const char *name, mesh::FieldBase *field, PerceptMesh& mesh, - int domain_dimension=3, - int codomain_dimension=1, - SearchType searchType = SIMPLE_SEARCH, - unsigned integration_order = 0); - - mesh::FieldBase *get_field(); - void interpolateFrom(Function& function); - - //virtual void value(MDArray& in, MDArray& out, double time_value_optional=0.0); - - //======================================================================================================================== - // low-level interface - FieldFunction(const char *name, mesh::FieldBase *field, mesh::BulkData *bulk, - Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions(), - SearchType searchType = SIMPLE_SEARCH, - unsigned integration_order = 0); - - FieldFunction(const char *name, mesh::FieldBase *field, PerceptMesh& eMesh, - Dimensions domain_dimensions, // = Dimensions(), - Dimensions codomain_dimensions, // = Dimensions(), - SearchType searchType = SIMPLE_SEARCH, - unsigned integration_order = 0); - - virtual ~FieldFunction(); - - virtual Teuchos::RCP derivative(MDArrayString& deriv_spec) - { - m_deriv_spec = deriv_spec; - Dimensions domain_dimensions = getDomainDimensions(); - Dimensions codomain_dimensions = getCodomainDimensions(); - //int meta_dimension = mesh::fem::FEMMetaData::get_meta_data(mesh::fem::FEMMetaData::get(*m_bulkData)).get_spatial_dimension(); - int num_grad = deriv_spec.dimension(0); - //domain_dimensions.push_back(num_grad); - codomain_dimensions.back() = num_grad; - - FieldFunction *deriv = new FieldFunction(this->getName().c_str(), - this->m_my_field, - this->get_bulk_data(), - domain_dimensions, codomain_dimensions, - this->m_searchType, - this->getIntegrationOrder()); - deriv->m_deriv_spec = deriv_spec; - deriv->m_get_derivative = true; - Teuchos::RCP deriv_rcp = Teuchos::rcp(deriv); - return deriv_rcp; - } - - virtual Teuchos::RCP gradient(int spatialDim=3) - { - int meta_dimension = mesh::fem::FEMMetaData::get_meta_data(mesh::fem::FEMMetaData::get(*m_bulkData)).get_spatial_dimension(); - VERIFY_OP_ON(meta_dimension, ==, spatialDim, "gradient: mismatch in spatial dimensions"); - std::string xyz[] = {"x", "y", "z"}; - MDArrayString mda(meta_dimension); - for (int i = 0; i < meta_dimension; i++) - { - mda(i) = xyz[i]; - } - return derivative(mda); - } - - virtual void operator()(MDArray& in, MDArray& out, double time_value_optional=0.0); - virtual void localEvaluation(MDArray& in, MDArray& out, double time_value_optional=0.0); - - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0); - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coords, double time_value_optional=0.0); - - void setup_searcher(int D_); - - template - void helper(MDArray& input_phy_points, MDArray& output_field_values, - const BucketOrEntity& bucket_or_element, const MDArray& parametric_coordinates, double time_value_optional); - - mesh::BulkData *get_bulk_data(); - - //void setBulkData(mesh::BulkData *bulk) { m_bulkData = bulk; } - bool getFoundOnLocalOwnedPart() { return m_found_on_local_owned_part; } - - private: - mesh::FieldBase *m_my_field; - mesh::BulkData *m_bulkData; - const mesh::Entity *m_cachedElement; - Searcher* m_searcher; - //const CellTopologyData * m_cached_topo; - - //typedef Intrepid::Basis IntrepidBasisType; - typedef Intrepid::Basis BasisType; - typedef Teuchos::RCP BasisTypeRCP; - - unsigned m_cached_topo_key; - BasisTypeRCP m_cached_basis; - - SearchType m_searchType; - bool m_found_on_local_owned_part; - - bool m_get_derivative; - MDArrayString m_deriv_spec; - mesh::FieldBase *m_coordinatesField; - }; - - /** Evaluate the function on this element at the parametric coordinates and return in output_field_values. - * - * Dimensions of parametric_coordinates are required to be ([P],[D]) - * Dimensions of output_field_values are required to be ([P],[DOF]), (or in future, ([C],[P],[DOF]) ) - * - */ -#define EXTRA_PRINT_FF_HELPER 0 - template - void FieldFunction::helper(MDArray& input_phy_points, MDArray& output_field_values, - const BucketOrEntity& bucket_or_element, const MDArray& parametric_coordinates, double time_value_optional) - { - VERIFY_OP(parametric_coordinates.rank(), ==, 2, "FieldFunction::operator() parametric_coordinates bad rank"); - VERIFY_OP(output_field_values.rank(), ==, 2, "FieldFunction::operator() output_field_values bad rank"); - - int numInterpPoints = parametric_coordinates.dimension(0); - int spatialDim = mesh::fem::FEMMetaData::get_meta_data(mesh::fem::FEMMetaData::get(*m_bulkData)).get_spatial_dimension(); - int num_grad = getCodomainDimensions().back(); - - VERIFY_OP(output_field_values.dimension(0), ==, numInterpPoints, "FieldFunction::operator() output_field_values bad dim(0)"); - - const CellTopologyData * const cell_topo_data = PerceptMesh::get_cell_topology(bucket_or_element); - - unsigned stride = 0; - PerceptMesh::field_data( m_my_field , bucket_or_element, &stride); - - unsigned nDOF = stride; -#ifndef NDEBUG - int nOutDim = m_codomain_dimensions.back(); // FIXME for tensor - - VERIFY_OP((int)(nDOF * (m_get_derivative? spatialDim : 1)), == , nOutDim, - "FieldFunction::operator(): invalid dimensions nDOF, m_codomain_dimensions[0]= "); -#endif - - int numCells = PerceptMesh::size1(bucket_or_element); // FIXME for multiple cells - - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) 1" << std::endl; - - shards::CellTopology topo(cell_topo_data); - int numNodes = topo.getNodeCount(); - //int cellDim = topo.getDimension(); - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) 2" << std::endl; - - // map cell topology to a basis - PerceptMesh::BasisTypeRCP basis; - if (m_cached_topo_key != cell_topo_data->key) - { - basis = PerceptMesh::getBasis(topo); - m_cached_basis = basis; - m_cached_topo_key = cell_topo_data->key; - } - else - { - basis = m_cached_basis; - } - - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) 3" << std::endl; - VERIFY_OP(basis.get(), != , 0, "FieldFunction::operator() basis is null"); - - int numBases = basis->getCardinality(); - if (numBases != numNodes) - { - throw std::runtime_error(" (numBases != numNodes) "); - } - - // [P] = 1 - //int numInterpPoints = 1; // FIXME - this is now set based on parametric_coordinates dimensioning - - // ([F],[P]), or ([F],[P],[D]) for GRAD - MDArray basis_values(numBases, numInterpPoints); - // ([C],[F],[P]), or ([C],[F],[P],[D]) for GRAD - MDArray transformed_basis_values(numCells, numBases, numInterpPoints); - - MDArray Jac; - MDArray JacInverse; - if (m_get_derivative) - { - basis_values.resize(numBases, numInterpPoints, spatialDim); - transformed_basis_values.resize(numCells, numBases, numInterpPoints, spatialDim); - MDArray cellWorkset(numCells, numNodes, spatialDim); - PerceptMesh::fillCellNodes(bucket_or_element, m_coordinatesField, cellWorkset, spatialDim); - Jac.resize(numCells, numInterpPoints, spatialDim, spatialDim); - JacInverse.resize(numCells, numInterpPoints, spatialDim, spatialDim); - Intrepid::CellTools::setJacobian(Jac, parametric_coordinates, cellWorkset, topo); - Intrepid::CellTools::setJacobianInv(JacInverse, Jac); - } - - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) 4" << std::endl; - - // FIXME - it appears that Intrepid only supports the evaluation of scalar-valued fields, so we have - // to copy the field one DOF at a time into a local array, evaluate, then copy back - // ([C],[F]) - MDArray field_data_values(numCells, numBases); - MDArray field_data_values_dof(numCells, numBases, nDOF); - - // ([P],[D]) [P] points in [D] dimensions - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) parametric_coordinates = \n " << parametric_coordinates << std::endl; - - { - EXCEPTWATCH; - basis->getValues(basis_values, parametric_coordinates, m_get_derivative ? Intrepid::OPERATOR_GRAD : Intrepid::OPERATOR_VALUE ); - } - - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) basis_values = \n " << basis_values << std::endl; - - // this function just spreads (copies) the values of the basis to all elements in the workset (numCells) - if (m_get_derivative) - { - Intrepid::FunctionSpaceTools::HGRADtransformGRAD(transformed_basis_values, JacInverse, basis_values); - } - else - { - Intrepid::FunctionSpaceTools::HGRADtransformVALUE(transformed_basis_values, basis_values); - } - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) transformed_basis_values = " << transformed_basis_values << std::endl; - - // ([C],[P]) - place for results of evaluation - MDArray loc_output_field_values(numCells, numInterpPoints); - if (m_get_derivative) - { - loc_output_field_values.resize(numCells, numInterpPoints, spatialDim); - } - - PerceptMesh::fillCellNodes(bucket_or_element, m_my_field, field_data_values_dof); - - // gather - for (unsigned iDOF = 0; iDOF < nDOF; iDOF++) - { - for (int iCell = 0; iCell < numCells; iCell++) - { - for (int iNode = 0; iNode < numNodes; iNode++) - { - field_data_values(iCell, iNode) = field_data_values_dof(iCell, iNode, iDOF); - if (EXTRA_PRINT_FF_HELPER) std::cout << "tmp iNode= " << iNode << "iDOF= " << iDOF << " fd= " << field_data_values(iCell, iNode) << std::endl; - } - } - - /// NOTE: this is needed since FunctionSpaceTools::evaluate method assumes the output array is initialized to 0 - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) evaluate ... " << std::endl; - loc_output_field_values.initialize(0.0); - Intrepid::FunctionSpaceTools::evaluate(loc_output_field_values, field_data_values, transformed_basis_values); - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) evaluate done " << std::endl; - - VERIFY_OP_ON(numCells, ==, 1, "numCells..."); - - if (m_get_derivative) - { - for (int iDim = 0; iDim < num_grad; iDim++) - { - int jDim = -1; - if (m_deriv_spec(iDim) == "x") jDim = 0; - else if (m_deriv_spec(iDim) == "y") jDim = 1; - else if (m_deriv_spec(iDim) == "z") jDim = 2; - - for (int iCell = 0; iCell < numCells; iCell++) - { - for (int iPoint = 0; iPoint < numInterpPoints; iPoint++) - { - // FIXME - // output_field_values(iPoint, iDOF, iDim) = loc_output_field_values(iCell, iPoint, jDim); - output_field_values(iPoint, iDOF*num_grad+ iDim) = loc_output_field_values(iCell, iPoint, jDim); - if (EXTRA_PRINT_FF_HELPER) std::cout << "tmp iDOF= " << iDOF << " iDim= " << iDim << - " ofd= " << output_field_values(iPoint, iDOF, iDim) << std::endl; - } - } - } - } - else - { - for (int iCell = 0; iCell < numCells; iCell++) - { - for (int iPoint = 0; iPoint < numInterpPoints; iPoint++) - { - output_field_values(iPoint, iDOF) = loc_output_field_values(iCell, iPoint); - if (EXTRA_PRINT_FF_HELPER) std::cout << "tmp iDOF= " << iDOF << " ofd= " << output_field_values(iPoint, iDOF) << std::endl; - } - } - } - - if (EXTRA_PRINT_FF_HELPER) std::cout << "FieldFunction::operator()(elem,...) scatter done " << std::endl; - } - } - - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.cpp deleted file mode 100644 index 4f9a1a589c1c..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include - -#include -#include - - -namespace stk_classic -{ - namespace percept - { - - Function::NameToFunctionMap Function::s_nameToFunctionMap; - unsigned Function::s_integration_order_default = 1; - unsigned Function::s_spatialDimDefault = 3; // 3 space, 1 for time - unsigned Function::s_codomainDimDefault = 1; - - class IdentityFunction : public Function - { - public: - IdentityFunction() : Function("Identity") {} - using Function::operator(); - virtual void operator()(MDArray& domain, MDArray& codomain, double time ) - { - codomain.initialize(1.0); - } - }; - - static IdentityFunction id = IdentityFunction(); - const Function& Function::Identity = id; - - Function::Function(const char *name, - Dimensions domain_dimensions, - Dimensions codomain_dimensions, - unsigned integration_order) : m_name( (name ? name : "null") ), m_integration_order(integration_order) - { - if (domain_dimensions.size() == 0) - { - m_domain_dimensions.resize(1); // assume we have input points of dimension 2 or 3 - m_domain_dimensions[0] = s_spatialDimDefault; - } - else if (domain_dimensions.size() <= 2) - { - m_domain_dimensions = domain_dimensions; - for (unsigned ii = 0; ii < domain_dimensions.size(); ii++) - { - if (domain_dimensions[ii] <= 0) - { - throw new std::runtime_error("Function::Function: domain_dimensions error"); - } - } - } - else - { - throw new std::runtime_error("Function::Function: domain_dimensions error"); - } - if (codomain_dimensions.size() == 0) - { - m_codomain_dimensions.resize(1); - m_codomain_dimensions[0] = s_codomainDimDefault; - } - else if (codomain_dimensions.size() <= 2) - { - m_codomain_dimensions = codomain_dimensions; - for (unsigned ii = 0; ii < codomain_dimensions.size(); ii++) - { - if (codomain_dimensions[ii] <= 0) - { - throw new std::runtime_error("Function::Function: codomain_dimensions error"); - } - } - } - else - { - throw new std::runtime_error("Function::Function: codomain_dimensions error"); - } - - getNameToFunctionMap()[m_name] = this; - } - - Function * Function::add_alias(const char *alias) - { - const std::string str_alias(alias); - getNameToFunctionMap()[str_alias] = this; - return this; - } - - Function::NameToFunctionMap& Function::getNameToFunctionMap() - { - return s_nameToFunctionMap; - } - - std::string join(std::string str1, std::string str2) - { - return str1+str2; - } - - bool Function::argsAreValid(const MDArray& inp, const MDArray& out) - { - EXCEPTWATCH; - VERIFY_OP_ON((unsigned)inp.rank() , >= , m_domain_dimensions.size(), - join("Function::argsAreValid inp.rank,dom.size: the input MDArray's rank must be >= to the Function's domain rank.\n Function.name= ",getName()) ); - VERIFY_OP_ON((unsigned)out.rank(), >= , m_codomain_dimensions.size(), - join("Function::argsAreValid out.rank,codom.size: the output MDArray's rank must be >= to the Function's codomain rank.\n Function.name= ",getName()) ); - - int domain_rank = m_domain_dimensions.size(); - int codomain_rank = m_codomain_dimensions.size(); - int inp_rank = inp.rank(); - int out_rank = out.rank(); - int inp_offset = inp_rank - domain_rank; - int out_offset = out_rank - codomain_rank; - - // the last dimensions must match - for (int idomain = 0; idomain < domain_rank; idomain++) - { - VERIFY_OP_ON(inp.dimension(idomain+inp_offset), ==, m_domain_dimensions[idomain], - join("Function::argsAreValid: inp dimensions are inconsistent with function's domain dimensions. \nFunction.name= ",getName()) ); - } - for (int icodomain = 0; icodomain < codomain_rank; icodomain++) - { - if(out.dimension(icodomain+out_offset) != m_codomain_dimensions[icodomain]) - { - std::cout << "out= " << out << "\n" << " m_codomain_dimensions= " << m_codomain_dimensions << std::endl; - } - VERIFY_OP_ON(out.dimension(icodomain+out_offset), ==, m_codomain_dimensions[icodomain], - join("Function::argsAreValid: in dimensions are inconsistent with function's codomain dimensions. \nFunction.name= ", getName()) ); - } - return true; - } - - void Function::setDomainDimensions(const Dimensions dims) - { - VERIFY_OP(dims.size(), >, 0, "Function::setDomainDimensions: dims.size() > 0= " ); - VERIFY_OP(dims.size(), <, 3, "Function::setDomainDimensions: dims.size() < 3= " ); - for (unsigned idomain = 0; idomain < dims.size(); idomain++) - { - VERIFY_OP(dims[idomain], >=, 1, "Function::setDomainDimensions: dims[idomain] "); - } - m_domain_dimensions = dims; - } - - void Function::setCodomainDimensions(const Dimensions dims) - { - VERIFY_OP(dims.size(), >, 0, "Function::setCodomainDimensions: dims.size() > 0= " ); - VERIFY_OP(dims.size(), <, 3, "Function::setCodomainDimensions: dims.size() < 3= " ); - for (unsigned icodomain = 0; icodomain < dims.size(); icodomain++) - { - VERIFY_OP(dims[icodomain], >=, 1, "Function::setCodomainDimensions: dims[icodomain] "); - } - m_codomain_dimensions = dims; - } - - std::ostream &operator<<(std::ostream& out, Function& func) - { - out << "Function: " << func.getName() << " domain dims: " << func.getDomainDimensions() << " codomain dims: " << func.getCodomainDimensions(); - return out; - } - - double eval(double x, double y, double z, double t, Teuchos::RCP& func) - { - return eval(x,y,z,t,*func.access_private_ptr()); - } - void eval_print(double x, double y, double z, double t, Teuchos::RCP& func) - { - eval_print(x,y,z,t,*func.access_private_ptr()); - } - void eval_print2(double x, double y, double t, Teuchos::RCP& func) - { - eval_print2(x,y,t,*func.access_private_ptr()); - } - MDArray eval_vec3(double x, double y, double z, double t, Teuchos::RCP& func) - { - return eval_vec3(x,y,z,t,*func.access_private_ptr()); - } - void eval_vec3_print(double x, double y, double z, double t, Teuchos::RCP& func) - { - eval_vec3_print(x,y,z,t,*func.access_private_ptr()); - } - - double eval(double x, double y, double z, double t, Function& func) - { - MDArray val(1); - MDArray pt(3); - pt(0)=x; - pt(1)=y; - pt(2)=z; - - func(pt, val, t); - return val(0); - } - - double eval2(double x, double y, double t, Teuchos::RCP& func) - { - return eval2(x,y,t,*func.access_private_ptr()); - } - double eval2(double x, double y, double t, Function& func) - { - MDArray val(1); - MDArray pt(2); - pt(0)=x; - pt(1)=y; - - func(pt, val, t); - return val(0); - } - - void eval_print(double x, double y, double z, double t, Function& func) - { - MDArray pt(3); - pt(0)=x; - pt(1)=y; - pt(2)=z; - std::cout << "eval_print:: pt=\n" << pt << " val= " << eval(x,y,z,t,func) << std::endl; - } - - void eval_print2(double x, double y, double t, Function& func) - { - MDArray pt(2); - pt(0)=x; - pt(1)=y; - //std::cout << "eval_print:: pt=\n" << pt << " val= " << eval2(x,y,t,func) << std::endl; - std::cout << eval2(x,y,t,func); - } - - MDArray eval_vec3(double x, double y, double z, double t, Function& func) - { - MDArray pt(3); - MDArray val(3); - pt(0)=x; - pt(1)=y; - pt(2)=z; - func(pt, val, t); - return val; - } - - void eval_vec3_print(double x, double y, double z, double t, Function& func) - { - MDArray pt(3); - pt(0)=x; - pt(1)=y; - pt(2)=z; - std::cout << "eval_vec3_print:: pt= \n" << pt << " val= \n" << eval_vec3(x,y,z,t,func) << std::endl; - } - - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.hpp deleted file mode 100644 index b82814c92ef3..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/Function.hpp +++ /dev/null @@ -1,245 +0,0 @@ -#ifndef stk_encr_Function_hpp -#define stk_encr_Function_hpp - - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - class Function : public GenericFunction // , HasGradient - { - public: - typedef std::map NameToFunctionMap; - - /** - * Create a function with the given name, domain dimensions and codomain dimensions, and integration order. - * If domain_dimensions and codomain_dimensions are defaulted, then they are dimensioned using the - * defaults of domain_dimensions = {s_spatialDimDefault} and - * codomain_dimensions = {s_codomainDimDefault} - * If integration_order is not specified, it defaults to s_integration_order_default. - * The defaults of the defaults is s_spatialDimDefault=3, s_codomainDimDefault=1, and s_integration_order_default=1 - * - * [DEPRECATED START] NOTE: we assume that input arrays have either {x,y,t} 2D+time or {x,y,z,t} for 3D+time. There is no separate - * argument for time. This means arrays should be dimensioned with length 3 (2D+time), or 4 (3D+time) respectively. - * [DEPRECATED END]: now we have time in the operator() arg list - * - * A Function has a {\em core} dimensioning of its domain and codamain, as specified in its constructor (or by - * setting with accessors setDomainDimensions() and setCodomainDimensions(). This means that all Function's - * implementations of operator()(MDArray& input, MDArray& output) expect the rightmost dimensions of input - * to be equal to the rightmost dimensions of its domain dimensions, and similar for output and codomain_dimensions - * - * Conventions: - * 1. core dimensions given by getDomainDimensions() and getCodomainDimensions() properties - * 2. rightmost dimensions of input array must match rightmost dimensions of Function's domain - * 3. rightmost dimensions of output array must match rightmost dimensions of Function's codomain - * 4. domain and codomain can have different ranks and dimensions - * 5. usage of conventions 1-4 are in scenarios where the input and output arrays contain multiple points - * that the client is requesting the Function to evaluate. For example: - * - * int numElements = bucket.size(); - * int numQuadPoints = quadratureFactory.getNumPoints(); - * int spaceDim = 3; - * int numValuesAtQP = 1; - * - * MDArray quadrature_points(numElements, numQuadPoints, spaceDim); - * MDArray function_value_at_quadrature_points(numElements, numQuadPoints, numValuesAtQP); - * - * StringFunction sf("<... some definition ...>", "<... some name ...>", Dimensions(spaceDim), Dimensions(numValuesAtQP) ); - * - * MDArray single_point(spaceDim); - * MDArray value_at_single_point(numValuesAtQP); - * - * // note that this same sf can be evaluated on either of these pairs of in/out arrays - * string_function(quadrature_points, function_value_at_quadrature_points); - * string_function(single_point, value_at_single_point); - * - */ - Function() {throw new std::runtime_error("shouldn't be invoked"); } - Function(const char *name, - Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions(), - unsigned integration_order = 0); - - /// this version uses the MDOutVal argument as a predefined array to ensure the python returned value is properly sized - void value(MDArray& domain, MDArray& MDOutVal, double time_value_optional=0.0) - { - this->operator()(domain, MDOutVal, time_value_optional); - } - - /// this version creates a dummy output and returns it based on the codomain-dimensions specified at construction - MDArray value(MDArray& domain, double time_value_optional=0.0) - { - MDArray output = getNewCodomain(); - this->operator()(domain, output, time_value_optional); - return output; - } - - virtual void operator()(MDArray& domain, MDArray& codomain, double time = 0.0)=0; - //using GenericFunction::operator(); - - // FIXME make protected - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - EXCEPTWATCH; - throw std::runtime_error("Not implemented"); - } - - // FIXME make protected - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coords, double time_value_optional=0.0) - { - EXCEPTWATCH; - throw std::runtime_error("Not implemented"); - } - - - /*! - * Return a function that is the derivative of this function. The derivative is specified as a rank-2 array - * of strings that specify what derivative to take and how many derivatives. - * For example, - * - * \code - * Function func(....); - * MDArray point(3); - * - * MDArray value(1); - * MDArrayString spec_x(1,1); - * spec_x(0,0) = "x"; - * Function deriv = func.derivative(spec_x); - * deriv(point, value); - * - * // mixed derivative d^2/dx dy - * MDArray value(1); - * MDArrayString spec_xy(1,2); - * spec_xy(0,0) = "x"; - * spec_xy(0,1) = "y"; - * deriv = func.derivative(spec_xy); - * deriv(point, value); - * - * // gradient (returns a 3-vector) - * MDArray gradient_value(3); - * MDArrayString spec_grad(3,1); - * spec_grad(0,0) = "x"; - * spec_grad(1,0) = "y"; - * spec_grad(2,0) = "z"; - * deriv = func.derivative(spec_grad); - * deriv(point, gradient_value); - * - * // time deriv - * MDArrayString spec_t(1,1); - * spec_t(0,0) = "t"; - * deriv = func.derivative(spec_t); - * deriv(point, value); - * - * // Derivative w.r.t. a parameter - * ValueFunction vf_A ( "A", 1.234); // setup a "function" with parameter name "A" with current value 1.234 - * StringFunction sf_param("A * sin(2.0 * x)"); - * MDArrayString spec_param(1,1); - * spec_param(0,0) = "A"; - * deriv = func.derivative(spec_param); - * deriv(point, value); - * // now change A and recompute - * vf_A.setValue(2.456); - * deriv(point, value); - * - * \endcode - * - */ - - virtual Teuchos::RCP derivative(MDArrayString& deriv_spec) - //virtual Function& derivative(MDArrayString& deriv_spec) - { - throw std::runtime_error("not implemented"); - } - - virtual Teuchos::RCP gradient(int spatialDim=3) - { - throw std::runtime_error("not implemented"); - } - - void derivativeAtPoint(MDArrayString& deriv_spec, MDArray& domain, MDArray& codomain, double time = 0.0) - { - derivative(deriv_spec)->operator()(domain, codomain, time); - } - - - static void setIntegrationOrderDefault(unsigned integration_order) { s_integration_order_default = integration_order; } - static void setSpatialDimDefault(unsigned spatialDim) { s_spatialDimDefault = spatialDim; } - static void setCodomainDimDefault(unsigned codomainDim) { s_codomainDimDefault = codomainDim; } - - /// allow this function to have one or more aliases - // FIXME add ability to delete an alias - Function * add_alias(const char *alias); - - std::string& getName() { return m_name; } - - void setIntegrationOrder(unsigned iord) { m_integration_order=iord; } - unsigned getIntegrationOrder(void) { return m_integration_order; } - - void setDomainDimensions(const Dimensions dims); - void setCodomainDimensions(const Dimensions dims); - - static const Function& Identity; - //static Function Zero; - - /// Verify that the last dimensions of @param in and @param out are the same; this allows Functions - /// to be invoked at multiple points where the first M indices represent an M-d array of points - /// to evaluate the function, while the last N indices should match the Functions domain and - /// codomain dimensions. - bool argsAreValid(const MDArray& in, const MDArray& out); - - protected: - - static int last_dimension(MDArray& arr) { return arr.dimension(arr.rank()-1); } - static NameToFunctionMap& getNameToFunctionMap(); - - std::string m_name; - unsigned m_integration_order; - - private: - - static NameToFunctionMap s_nameToFunctionMap; - static unsigned s_integration_order_default; - static unsigned s_spatialDimDefault; - static unsigned s_codomainDimDefault; - - }; - -#ifndef SWIG - std::ostream &operator<<(std::ostream& out, Function& func); -#endif - - double eval(double x, double y, double z, double t, Function& func); - double eval(double x, double y, double z, double t, Teuchos::RCP& func); - - double eval2(double x, double y, double t, Function& func); - double eval2(double x, double y, double t, Teuchos::RCP& func); - - void eval_print(double x, double y, double z, double t, Function& func); - void eval_print(double x, double y, double z, double t, Teuchos::RCP& func); - - void eval_print2(double x, double y, double t, Function& func); - void eval_print2(double x, double y, double t, Teuchos::RCP& func); - - MDArray eval_vec3(double x, double y, double z, double t, Function& func); - MDArray eval_vec3(double x, double y, double z, double t, Teuchos::RCP& func); - - void eval_vec3_print(double x, double y, double z, double t, Function& func); - void eval_vec3_print(double x, double y, double z, double t, Teuchos::RCP& func); - - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.cpp deleted file mode 100644 index fb5b03d8f5ca..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - -#if 0 - void FunctionOperator::integrate( Function& integrand, Function& result) - { - std::cout << "type= " << typeid(integrand).name() << " " << typeid(FieldFunction).name() << std::endl; - if (typeid(integrand) == typeid(FieldFunction) || - typeid(integrand) == typeid(StringFunction)) - { - const FieldFunction *field_function_const = dynamic_cast(&integrand); - FieldFunction *field_function = const_cast(field_function_const); - PerceptMesh meshUtil(const_cast(&MetaData::get(field_function->get_bulk_data())), field_function->get_bulk_data()); -#if 0 - NoOpScalar no_op(integrand, field_function->get_field()); - meshUtil.elementOpLoop(no_op , field_function->get_field()); -#endif - } - } -#endif - -#if 0 - void FunctionOperator::integrate(FunctionWithIntrepidRequest& integrand, Function& result) - { - const FieldFunction *field_function_const = dynamic_cast(&integrand); - FieldFunction *field_function = const_cast(field_function_const); - PerceptMesh meshUtil(const_cast(&MetaData::get(field_function->get_bulk_data())), field_function->get_bulk_data()); - IntegratedOp general_integrand(integrand, TURBO_NONE); - meshUtil.elementOpLoop(general_integrand , field_function->get_field()); - } -#endif - - - }//namespace percept -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.hpp deleted file mode 100644 index f5db6cbfc1aa..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/FunctionOperator.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef stk_encr_FunctionOperator_hpp -#define stk_encr_FunctionOperator_hpp - -//#define HAVE_INTREPID_DEBUG 1 - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - //class FunctionWithIntrepidRequest; - - /** - */ - class FunctionOperator - { - protected: - mesh::BulkData& m_bulkData; - stk_classic::mesh::Selector *m_selector; - //mesh::Part *m_part; - bool m_own_selector; - public: - - FunctionOperator(mesh::BulkData& bulkData, mesh::Part *part = 0) : m_bulkData(bulkData), m_selector(0), m_own_selector(false) - { - init(part); - } - - FunctionOperator(mesh::BulkData& bulkData, mesh::Selector *selector) : m_bulkData(bulkData), m_selector(selector), m_own_selector(false) - { - init(selector); - } - - void init(mesh::Part *part) - { - if (m_own_selector) - { - VERIFY_OP_ON(m_selector, !=, 0, "FunctionOperator::init"); - delete m_selector; - } - if (!part) - { - m_selector = new stk_classic::mesh::Selector(stk_classic::mesh::fem::FEMMetaData::get(m_bulkData).universal_part()); - } - else - { - m_selector = new stk_classic::mesh::Selector(*part); - } - m_own_selector = true; - } - - void init(mesh::Selector *selector) - { - if (!selector) - { - if (m_own_selector) - { - VERIFY_OP_ON(m_selector, !=, 0, "FunctionOperator::init"); - delete m_selector; - } - m_selector = new stk_classic::mesh::Selector(stk_classic::mesh::fem::FEMMetaData::get(m_bulkData).universal_part()); - m_own_selector = true; - } - } - - virtual ~FunctionOperator() { - if (m_own_selector) - delete m_selector; - } - - //stk_classic::mesh::Selector *get_selector() { return m_selector; } - - virtual void operator()(Function& integrand, Function& result) = 0; - -#if 0 - void norm_l2( Function& integrand, Function& result); - void integrate( Function& integrand, Function& result); - - - void integrate(FunctionWithIntrepidRequest& integrand, Function& result); -#endif - - }; - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/MDArray.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/MDArray.hpp deleted file mode 100644 index 10192a55c5fd..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/MDArray.hpp +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef stk_encr_MDArray_hpp -#define stk_encr_MDArray_hpp - -#include -#include -#include -#include "Intrepid_FieldContainer.hpp" - -namespace stk_classic -{ - namespace percept - { - - // class MDArray : public FieldContainer - // { - // public: - // typedef FieldContainer base; - // MDArray(std::vector dimensions) : FieldContainer( Teuchos::Array(dimensions.begin(), dimensions.end()) ) {} - // }; - - typedef Intrepid::FieldContainer MDArray; - typedef Intrepid::FieldContainer MDArrayInt; - typedef Intrepid::FieldContainer MDArrayUInt; - - //typedef Intrepid::FieldContainer MDArrayString; - class MDArrayString - { - typedef std::vector VecOfString; - int m_rank; - VecOfString m_array_1; // rank one - std::vector m_array_2; // rank two - //... - - void clone(const MDArrayString& mda) - { - this->m_rank = mda.m_rank; - if (this->m_rank == 1) - { - this->m_array_1 = mda.m_array_1; - } - else - { - int dim0 = mda.dimension(0); - this->m_array_2.resize(dim0); - for (int j = 0; j < dim0; j++) - { - this->m_array_2[j] = mda.m_array_2[j]; - } - } - } - - public: - MDArrayString() : m_rank(1) { m_array_1.resize(0); } - MDArrayString(int dim) : m_rank(1) { m_array_1.resize(dim); } - MDArrayString(int dim0, int dim1) : m_rank(2) - { - m_array_2.resize(dim0); - for (int j = 0; j < dim0; j++) - { - m_array_2[j].resize(dim1); - } - } - - MDArrayString(const MDArrayString& mda) - { - clone(mda); - } - MDArrayString& operator=(const MDArrayString& mda) - { - clone(mda); - return *this; - } - - void resize(int dim) - { - m_rank = 1; - m_array_1.resize(dim); - } - void resize(int dim0, int dim1) - { - m_rank = 2; - m_array_2.resize(dim0); - for (int j = 0; j < dim0; j++) - { - m_array_2[j].resize(dim1); - } - - } - const int rank() const { return m_rank; } - - void setValues(std::string *data) - { - if (m_rank == 1) - { - for (unsigned j = 0; j < m_array_1.size(); j++) - m_array_1[j] = data[j]; - } - else if (m_rank == 2) - { - unsigned k = 0; - for (unsigned i = 0; i < m_array_2.size(); i++) - for (unsigned j = 0; j < m_array_2[0].size(); j++) - { - m_array_2[i][j] = data[k++]; - } - } - } - - //MDArrayString(std::string array[][]) : m_rank(2) - std::string& operator()(int i1) { - if (m_rank==2) throw std::runtime_error("MDArrayString:: rank 2 but asking for 1 dim"); - return m_array_1[i1]; - } - std::string& operator()(int i1, int i2) { - if (m_rank==1) throw std::runtime_error("MDArrayString:: rank 1 but asking for 2 dim"); - return m_array_2[i1][i2]; - } - - int dimension(int i1) const { - if (m_rank==1 && i1 > 0) throw std::runtime_error("MDArrayString:: rank 1 but asking for 2nd dim"); - if (m_rank == 1) - { - return m_array_1.size(); - } - else if (m_rank ==2) - { - if (i1 == 0) - { - return m_array_2.size(); - } - else if (i1 == 1) - { - return m_array_2[0].size(); - } - else - { - throw std::runtime_error("MDArrayString:: asking for dimension greater than max rank of 2"); - } - } - return 0; - } - - }; - - } -} - -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/MultipleFieldFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/MultipleFieldFunction.hpp deleted file mode 100644 index cd1b62b5ddab..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/MultipleFieldFunction.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef stk_percept_MultipleFieldFunction_hpp -#define stk_percept_MultipleFieldFunction_hpp - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - /** This class compbines several Fields into a single function, e.g., density_field*temperature_field/pressure_field - * It uses Intrepid to compute basis functions then evaluates all the required fields and stores them in MDArray's - * ready for the operator() to compute the actual function. - */ - class MultipleFieldFunction : public FieldFunction - { - public: -// MultipleFieldFunction(const char *name, mesh::FieldBase *field, mesh::BulkData *bulk, SearchType searchType = SIMPLE_SEARCH, -// Dimensions domain_dimensions = Dimensions(), -// Dimensions codomain_dimensions = Dimensions(), -// unsigned integration_order = 0) : FieldFunction(name, field, bulk, searchType, domain_dimensions, codomain_dimensions) -// { -// } - //MultipleFieldFunction() : FieldFunction() {} - - // add_fields(std::vector ffs) ... - -#if 0 - computeAllFieldValues() - { - // loop over field functions - // evaluate each to get the field values and store - } - - operator() (in, out) = 0; - - // derived class can then use whatever field values it needs - Derived::operator() (in, out) - { - // invoke helper: - computeAllFieldValues(); - - - - } - - // for l2 norm, can compose two functions - // for StringFunction, can use these helpers also in evalFunctions - -#endif - - }; - - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/PartOp.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/PartOp.hpp deleted file mode 100644 index 168f5dc1f336..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/PartOp.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef stk_percept_PartOp_hpp -#define stk_percept_PartOp_hpp - -#include -#include -#include -#include - - -namespace stk_classic -{ - namespace percept - { - - class PartOp - { - public: - /// innermost operation of an part-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - virtual bool operator()(const stk_classic::mesh::Part& part, - mesh::Selector& select_owned, // select which buckets to use - stk_classic::mesh::FieldBase *field, - const mesh::BulkData& bulkData)=0; - }; - - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.cpp deleted file mode 100644 index 240d2e9f1f8b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.cpp +++ /dev/null @@ -1,533 +0,0 @@ -#define DOPRINT 0 - -#if DOPRINT -#define PRINTQ(a) do { std::cout << QUOTE(a) << a << std::endl; } while(0) -#define PRINT(a) do { std::cout << a << std::endl; } while(0) -#else -#define PRINTQ(a) do { } while(0) -#define PRINT(a) do { } while(0) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - StringFunction::StringFunction(const char *function_string, - Name name, - int domain_dimension, - int codomain_dimension, - unsigned integration_order) : - Function(name.getName().c_str(), Dimensions(domain_dimension), Dimensions(codomain_dimension), integration_order), - m_func_string(function_string), m_functionExpr(*this), m_gradient_string(""), m_spatialDim(0) - { - init(); - } - - StringFunction::StringFunction(const char *function_string, - Name name, - Dimensions domain_dimensions, - Dimensions codomain_dimensions, - unsigned integration_order) : - Function(name.getName().c_str(), domain_dimensions, codomain_dimensions, integration_order), - m_func_string(function_string), m_functionExpr(*this), m_gradient_string("") , m_spatialDim(0) - { - init(); - } - - StringFunction::StringFunction(const StringFunction& s) : - Function(s.m_name.c_str(), s.m_domain_dimensions, s.m_codomain_dimensions, s.m_integration_order), - m_func_string(s.m_func_string), m_functionExpr(*this), m_gradient_string(s.m_gradient_string), m_spatialDim(s.m_spatialDim) - { - init(); - } - - void StringFunction::init() - { - // FIXME for tensor-valued - int nOutDim = m_codomain_dimensions.back(); - m_v.resize(nOutDim); - //m_g.resize(nOutDim); - m_functionExpr.setExpression(m_func_string.c_str()).parse(); - m_element=0; - m_bucket=0; - m_parametric_coordinates = MDArray(1,3); - m_have_element = false; - m_have_bucket = false; - } - - void StringFunction::set_gradient_strings(std::string gstring[3], int len) - { - m_gradient_string = ""; - m_spatialDim = len; - for (int i = 0; i < len; i++) - m_gradient_string += "v["+boost::lexical_cast(i)+"]= "+gstring[i]+";"; - } - - void - StringFunction::set_gradient_strings(MDArrayString& gstring) - { - if (gstring.rank() != 1) throw std::runtime_error("set_gradient_strings takes a rank 1 matrix (i.e. a vector) of strings (MDArrayString)"); - int len = gstring.dimension(0); - m_gradient_string = ""; - m_spatialDim = len; - for (int i = 0; i < len; i++) - m_gradient_string += "v["+boost::lexical_cast(i)+"]= "+gstring(i)+";"; - } - - // new StringFunction = lhs OP rhs - StringFunction operator-(StringFunction& lhs, StringFunction& rhs) - { - std::string newFuncString = "(" + lhs.getFunctionString() + ") - (" + rhs.getFunctionString() + ")"; - return StringFunction(newFuncString.c_str()); - } - - StringFunction operator+(StringFunction& lhs, StringFunction& rhs) - { - std::string newFuncString = "(" + lhs.getFunctionString() + ") + (" + rhs.getFunctionString() + ")"; - return StringFunction(newFuncString.c_str()); - } - - StringFunction operator*(StringFunction& lhs, StringFunction& rhs) - { - std::string newFuncString = "(" + lhs.getFunctionString() + ") * (" + rhs.getFunctionString() + ")"; - return StringFunction(newFuncString.c_str()); - } - - StringFunction operator/(StringFunction& lhs, StringFunction& rhs) - { - std::string newFuncString = "(" + lhs.getFunctionString() + ") / (" + rhs.getFunctionString() + ")"; - return StringFunction(newFuncString.c_str()); - } - - // unary minus - StringFunction operator-(StringFunction& lhs) - { - std::string newFuncString = "-(" + lhs.getFunctionString() + ")"; - return StringFunction(newFuncString.c_str()); - } - - void StringFunction::evalFunctions(MDArray& inp, double time_value_optional) - { - EXCEPTWATCH; - std::map >::iterator it = m_func_to_value.begin(); - const std::map >::iterator it_end = m_func_to_value.end(); - - //Evaluate the function and store the answer in its bound location - for(; it != it_end; ++it) - { - Function& func = *it->first; - - PRINTQ(func.getName()); - - // check to avoid infinite recursion - if (&func == this) - { - std::ostringstream msg; - msg << "StringFunction::evalFunctions: infinite recursion by self-referential string function, name= " << m_name; - VERIFY_1(msg.str()); - } - - VERIFY_OP(func.getNewDomain().rank(), ==, 1, "StringFunction::evalFunctions: functions must be defined with domain/codomain of rank 1 for now"); - VERIFY_OP(func.getNewCodomain().rank(), ==, 1, "StringFunction::evalFunctions: functions must be defined with domain/codomain of rank 1 for now"); - int numCells = 1; - - MDArray f_inp = MDArray(numCells, func.getNewDomain().dimension(0)); - MDArray f_out = MDArray(numCells, func.getNewCodomain().dimension(0)); - - int nInDim = last_dimension(f_inp); - // FIXME - do we really need the extra array? - for (int iDim = 0; iDim < nInDim; iDim++) - { - f_inp(0, iDim) = inp( iDim); - } - - if (m_have_element) - { - func(f_inp, f_out, *m_element, m_parametric_coordinates, time_value_optional); - } - else - { - func(f_inp, f_out); - } - - int nOutDim = last_dimension(f_out); - - for (int iDim = 0; iDim < nOutDim; iDim++) - { - (it->second)[iDim] = f_out(0, iDim); - } - - } - } - - static inline void first_dimensions(MDArray& arr, int arr_offset, int *n_points, int max_rank=3) - { - for (int ii = 0; ii < max_rank; ii++) - { - n_points[ii] = 1; - } - for (int ii = 0; ii < arr_offset; ii++) - { - n_points[ii] = arr.dimension(ii); - } - } - - // replace all occurrences of input_string with output_string in source_string - - Teuchos::RCP StringFunction::derivative_test(MDArrayString& deriv_spec) - { - bool debug=true; - std::string fstr = m_func_string; - // FIXME this is just for a simple test and only works for linear functions - int outputDim = deriv_spec.dimension(0); - static std::string s_xyzt[] = {"x", "y", "z", "t"}; - std::string out_str; - //if (debug) std::cout << "deriv_spec= " << deriv_spec << std::endl; - for (int iresult = 0; iresult < deriv_spec.dimension(0); iresult++) - { - fstr = m_func_string; - for (int jderiv = 0; jderiv < deriv_spec.dimension(1); jderiv++) - { - if (debug) std::cout << "deriv_spec= " << deriv_spec(iresult, jderiv) << " fstr= " << fstr << std::endl; - char xyzt = deriv_spec(iresult, jderiv)[0]; - std::replace( fstr.begin(), fstr.end(), xyzt, '1' ); - if (debug) std::cout << "xyzt= " << xyzt << " fstr= " << fstr << std::endl; - } - for (int jderiv = 0; jderiv < 4; jderiv++) - { - char xyzt = s_xyzt[jderiv][0]; - std::replace( fstr.begin(), fstr.end(), xyzt, '0' ); - if (debug) std::cout << "xyzt= " << xyzt << " fstr= " << fstr << std::endl; - } - if (deriv_spec.dimension(0) > 1) - { - out_str += "v["+boost::lexical_cast(iresult)+"]= " + fstr+";"; - } - else - { - out_str = fstr; - } - } - std::string fname = getName(); - std::string new_name = "deriv_"+fname; - if (debug) std::cout << "fname= " << fname << " new_name= " << new_name << " out_str= " << out_str << std::endl; - //Util::pause(true, "tmp:: StringFunction::derivative"); - return Teuchos::rcp(new StringFunction(out_str.c_str(), Name(new_name), Dimensions(3), Dimensions(outputDim) )); - } - - - Teuchos::RCP StringFunction::derivative_test_fd(MDArrayString& deriv_spec, double eps) - { - std::string eps_string = boost::lexical_cast(eps); - std::string fstr = m_func_string; - std::string fstr_p = m_func_string; - std::string fstr_m = m_func_string; - // FIXME this is just for a simple test and only works for linear functions - int outputDim = deriv_spec.dimension(0); - static std::string s_xyzt[] = {"x", "y", "z", "t"}; - std::string out_str; - for (int iresult = 0; iresult < deriv_spec.dimension(0); iresult++) - { - fstr = m_func_string; - fstr_p = m_func_string; - fstr_m = m_func_string; - for (int jderiv = 0; jderiv < deriv_spec.dimension(1); jderiv++) - { - //std::cout << "deriv_spec= " << deriv_spec(iresult, jderiv) << " fstr= " << fstr << std::endl; - std::string rep = "("+deriv_spec(iresult, jderiv)+"+"+eps_string+")"; - Util::replace(fstr_p, deriv_spec(iresult, jderiv), rep); - rep = "("+deriv_spec(iresult, jderiv)+"-"+eps_string+")"; - Util::replace(fstr_m, deriv_spec(iresult, jderiv), rep); - fstr = "(("+fstr_p+")-("+fstr_m+"))/(2.0*"+eps_string+")"; - //std::cout << "xyzt= " << xyzt << " fstr= " << fstr << std::endl; - } - if (deriv_spec.dimension(0) > 1) - { - out_str += "v["+boost::lexical_cast(iresult)+"]= " + fstr+";"; - } - else - { - out_str = fstr; - } - } - std::string fname = getName(); - std::string new_name = "deriv_"+fname; - //std::cout << "fname= " << fname << " new_name= " << new_name << " out_str= " << out_str << std::endl; - //Util::pause(true, "tmp:: StringFunction::derivative"); - return Teuchos::rcp(new StringFunction(out_str.c_str(), Name(new_name), Dimensions(3), Dimensions(outputDim) )); - } - - Teuchos::RCP StringFunction::derivative(MDArrayString& deriv_spec) - { - if (m_gradient_string.length() == 0) - { - throw std::runtime_error("StringFunction::derivative: must set gradient strings first"); - } - std::string fname = getName(); - std::string new_name = "deriv_"+fname; - //std::cout << "fname= " << fname << " new_name= " << new_name << std::endl; - //Util::pause(true, "tmp:: StringFunction::derivative"); - - return Teuchos::rcp(new StringFunction(m_gradient_string.c_str(), Name(new_name), Dimensions(3), Dimensions(3) )); - } - - Teuchos::RCP StringFunction::gradient(int spatialDim) - { - if (m_gradient_string.length() == 0) - { - throw std::runtime_error("StringFunction::gradient: must set gradient strings first"); - } - std::string xyz[] = {"x", "y", "z"}; - MDArrayString mda(spatialDim); - for (int i = 0; i < spatialDim; i++) - { - mda(i) = xyz[i]; - } - return derivative(mda); - - } - - void StringFunction::operator()(MDArray& inp, MDArray& out, double time_value_optional) - { - EXCEPTWATCH; - argsAreValid(inp, out); - PRINT("tmp srk StringFunction::operator() getName()= " << getName() << " inp= " << inp << " out= " << out); - - int domain_rank = m_domain_dimensions.size(); - int codomain_rank = m_codomain_dimensions.size(); - - // FIXME move to argsAreValid - VERIFY_OP(domain_rank, ==, 1, "StringFunction::operator(): must specify domain Dimensions as rank 1 (for now)"); - VERIFY_OP(codomain_rank, ==, 1, "StringFunction::operator(): must specify codomain Dimensions as rank 1 (for now)"); - - int inp_rank = inp.rank(); - int out_rank = out.rank(); - int inp_offset = inp_rank - domain_rank; - int out_offset = out_rank - codomain_rank; - - // returns 1,1,1,... etc. if that dimension doesn't exist - enum { maxRank = 3}; - VERIFY_OP_ON(inp_rank, <=, maxRank, "StringFunction::operator() input array rank too large"); - VERIFY_OP_ON(out_rank, <=, maxRank, "StringFunction::operator() output array rank too large"); - int n_inp_points[maxRank] = {1,1,1}; - int n_out_points[maxRank] = {1,1,1}; - first_dimensions(inp, inp_offset, n_inp_points, maxRank); - first_dimensions(out, out_offset, n_out_points, maxRank); - - int nInDim = m_domain_dimensions[0]; - int nOutDim = m_codomain_dimensions[0]; - - MDArray inp_loc(nInDim); - MDArray out_loc(nOutDim); - - int iDim[maxRank-1] = {0,0}; - double *xyzt[] = {&m_x, &m_y, &m_z, &m_t}; - - PRINT("getName()= " << getName() << " n_inp_points= " << n_inp_points[0] << " " << n_inp_points[1] << " " << n_inp_points[2] << " nInDim= " << nInDim); - - m_t = time_value_optional; - for (iDim[0] = 0; iDim[0] < n_inp_points[0]; iDim[0]++) - { - for (iDim[1] = 0; iDim[1] < n_inp_points[1]; iDim[1]++) - { - for (int id = 0; id < nInDim; id++) - { - switch (inp_rank) - { - case 3: - inp_loc(id) = inp(iDim[0], iDim[1], id); - *xyzt[id] = inp(iDim[0], iDim[1], id); - break; - case 2: - inp_loc(id) = inp(iDim[0], id); - *xyzt[id] = inp(iDim[0], id); - break; - case 1: - inp_loc(id) = inp( id); - *xyzt[id] = inp( id); - break; - } - } - - if (m_func_to_value.size()) - { - evalFunctions(inp_loc, time_value_optional); - } - - //Save the evaluations slightly differently whether it's a scalar or vector valued function - if ((int)m_v.size() != nOutDim) - { - m_v.resize(nOutDim); - } - - PRINT("getName()= " << getName() << " about to evaluate m_functionExpr... iDim[0] = " << iDim[0] << " iDim[1]= " << iDim[1]); - if(nOutDim == 1) - m_v[0] = m_functionExpr.evaluate(); - else - m_functionExpr.evaluate(); - PRINT("getName()= " << getName() << " done to evaluate m_functionExpr... iDim[0] = " << iDim[0] << " iDim[1]= " << iDim[1]); - - for (int iOutDim = 0; iOutDim < nOutDim; iOutDim++) - { - switch (out_rank) - { - case 1: out(iOutDim) = m_v[iOutDim]; break; - case 2: out(iDim[0], iOutDim) = m_v[iOutDim]; break; - case 3: out(iDim[0], iDim[1], iOutDim) = m_v[iOutDim]; break; - default: - VERIFY_1("StringFunction::operator() bad output rank"); - } - } - } - } - PRINT("getName()= " << getName() << " done in operator()"); - } - - /// Dimensions of parametric_coordinates and input_phy_points are required to be ([P],[D]) - /// output_values: ([P], [DOF]) - void StringFunction::operator()(MDArray& input_phy_points, MDArray& output_values, - const stk_classic::mesh::Entity& element, const MDArray& parametric_coordinates, double time_value_optional) - { - PRINT("tmp srk StringFunction::operator(element) getName()= " << getName() << " input_phy_points= " << input_phy_points << " output_values= " << output_values); - - argsAreValid(input_phy_points, output_values); - argsAreValid(parametric_coordinates, output_values); - - m_element = &element; - m_have_element = true; - VERIFY_OP(parametric_coordinates.rank(), ==, 2, "StringFunction::operator() parametric_coordinates rank bad"); - m_parametric_coordinates = MDArray(1, parametric_coordinates.dimension(1)); - int nPoints=parametric_coordinates.dimension(0); - int spaceDim = parametric_coordinates.dimension(1); - for (int iPoint = 0; iPoint < nPoints; iPoint++) - { - for (int iSpace=0; iSpace < spaceDim; iSpace++) - m_parametric_coordinates(0, iSpace)=parametric_coordinates(iPoint, iSpace); - (*this)(input_phy_points, output_values, time_value_optional); - } - - // reset this else we won't be able to reuse this object correctly - m_have_element = false; - m_element = 0; - - // * Dimensions of parametric_coordinates are required to be ([P],[D]) - //FieldFunction:: void operator()(const stk_classic::mesh::Entity *element, const MDArray& parametric_coordinates, MDArray& out); - - } - - void StringFunction::operator()(MDArray& input_phy_points, MDArray& output_values, - const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coordinates, double time_value_optional) - { - PRINT("tmp srk StringFunction::operator(bucket) getName()= " << getName() << " input_phy_points= " << input_phy_points << " output_values= " << output_values); - - VERIFY_OP(input_phy_points.rank(), ==, 3, "StringFunction::operator() must pass in input_phy_points(numCells, numPointsPerCell, spaceDim)"); - int nPoints = input_phy_points.dimension(1); - int nSpaceDim = input_phy_points.dimension(2); - int nOutDim = output_values.dimension(2); - MDArray input_phy_points_one(1, nPoints, nSpaceDim); - MDArray output_values_one (1, nPoints, nOutDim); - const unsigned num_elements_in_bucket = bucket.size(); - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - for (int iPoint = 0; iPointparameters().get_nested(FUNCTION_ROOT)->get_nested(GLOBAL_FUNCTION_PARAMETERS); - // const Fmwk::Parameters * use_funcs = parameters->get_nested(USE_FUNCTIONS); - - std::string name = (*var_it).first; - - bool use_funcs = true; - //Not a parameter... so see if it matches the normal stuff - if (DOPRINT) std::cout << " resolve: name= " << name << " " ; - if (!(name).compare("x")) - { - if (DOPRINT) std::cout << " bind to x = " << name; - (*var_it).second->bind(m_x); - } - else if (!(name).compare("y")) - { - if (DOPRINT) std::cout << " bind to y = " << name; - (*var_it).second->bind(m_y); - } - else if (!(name).compare("z")) - { - if (DOPRINT) std::cout << " bind to z = " << name; - - (*var_it).second->bind(m_z); - } - else if (!(name).compare("t")) - { - if (DOPRINT) std::cout << " bind to t = " << name; - - (*var_it).second->bind(m_t); - } - else if (!(name).compare("v")) - { - if (DOPRINT) std::cout << "bind to v = " << name << std::endl; - (*var_it).second->bind(m_v[0]); - } - else if(use_funcs) - { - if (DOPRINT) std::cout << "bind to function= " << name << std::endl; - Function * func = Function::getNameToFunctionMap()[name]; - if (DOPRINT) std::cout << "bind to function= " << func << std::endl; - int func_rank = func->getCodomainDimensions().size(); - int func_dim = func->getCodomainDimensions()[func_rank-1]; - if (func) - { - //m_func_to_value[func] = std::vector(func->getDomainDimensions()[0], 0.0); // FIXME for multi points - m_func_to_value[func] = std::vector(func_dim, 0.0); // FIXME for multi points - } - else - { - std::ostringstream msg; - msg << "StringFunction::resolve: unknown function name = " << name; - throw new std::runtime_error(msg.str()); - } - - //Bind that solution in - (*var_it).second->bind(m_func_to_value[func][0]); - } - - else - { - std::ostringstream msg; - msg << "Unable to resolve symbols in expression: " << name; - throw new std::runtime_error(msg.str()); - } - if (DOPRINT) std::cout << " end resolve: "< - -#include -#include -#include - -#include -#include - -namespace stk_classic -{ - namespace percept - { - - class StringFunction : public Function, public stk_classic::expreval::VariableMap::Resolver - { - public: - - - //======================================================================================================================== - // high-level interface - - StringFunction(const char *function_string, - Name name = Name("noname"), - int domain_dimension = 3, - int codomain_dimension = 1, - unsigned integration_order = 0); - - - std::string - getFunctionString() { return m_func_string; } - - void - set_gradient_strings(std::string gstring[3], int len); - - void - set_gradient_strings(MDArrayString& gstring); - - virtual Teuchos::RCP - derivative(MDArrayString& deriv_spec); - - Teuchos::RCP gradient(int spatialDim=3); - - //======================================================================================================================== - // low-level interface - StringFunction(const char *function_string, - Name name, - Dimensions domain_dimensions, - Dimensions codomain_dimensions, - unsigned integration_order = 0); - - StringFunction(const StringFunction& s); - - void resolve(stk_classic::expreval::VariableMap::iterator & var_it); - - Teuchos::RCP derivative_test(MDArrayString& deriv_spec); - Teuchos::RCP derivative_test_fd(MDArrayString& deriv_spec, double eps=1.e-6); - - virtual void operator()(MDArray& in, MDArray& out, double time_value_optional=0.0); - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0); - virtual void operator()(MDArray& in, MDArray& out, const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coords, double time_value_optional=0.0); - - private: - void evalFunctions(MDArray& in, double time_value_optional=0.0); - - std::string m_func_string; - stk_classic::expreval::Eval m_functionExpr; - //std::vector m_gradient_string; - std::string m_gradient_string; - //Expr::Eval gradientExpr; - //Expr::Eval dotExpr; - - //Local variables - double m_x,m_y,m_z,m_t; - std::vector m_v; - - //Map of function names to their evalutation values - std::map > m_func_to_value; - - const stk_classic::mesh::Entity * m_element; - const stk_classic::mesh::Bucket * m_bucket; - MDArray m_parametric_coordinates; - bool m_have_element; - bool m_have_bucket; - - int m_spatialDim; - - void init(); - - - - }; -#if 1 - - // new StringFunction = lhs OP rhs - StringFunction operator-(StringFunction& lhs, StringFunction& rhs); - StringFunction operator+(StringFunction& lhs, StringFunction& rhs); - StringFunction operator/(StringFunction& lhs, StringFunction& rhs); - StringFunction operator*(StringFunction& lhs, StringFunction& rhs); - - // unary ops - StringFunction operator-(StringFunction& lhs); - - -#endif - - }//namespace percept -}//namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.i b/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.i deleted file mode 100644 index 41dabefa618f..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.i +++ /dev/null @@ -1,10 +0,0 @@ -/* File : StringFunction.i */ -%module StringFunction - -%{ -#include "StringFunction.hpp" -%} - -/* Let's just grab the original header file here */ -%include "StringFunction.hpp" - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.py b/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.py deleted file mode 100644 index a1181e67c481..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction.py +++ /dev/null @@ -1,69 +0,0 @@ -# This file was created automatically by SWIG 1.3.29. -# Don't modify this file, modify the SWIG interface instead. -# This file is compatible with both classic and new-style classes. - -import _StringFunction -import new -new_instancemethod = new.instancemethod -def _swig_setattr_nondynamic(self,class_type,name,value,static=1): - if (name == "thisown"): return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'PySwigObject': - self.__dict__[name] = value - return - method = class_type.__swig_setmethods__.get(name,None) - if method: return method(self,value) - if (not static) or hasattr(self,name): - self.__dict__[name] = value - else: - raise AttributeError("You cannot add attributes to %s" % self) - -def _swig_setattr(self,class_type,name,value): - return _swig_setattr_nondynamic(self,class_type,name,value,0) - -def _swig_getattr(self,class_type,name): - if (name == "thisown"): return self.this.own() - method = class_type.__swig_getmethods__.get(name,None) - if method: return method(self) - raise AttributeError,name - -def _swig_repr(self): - try: strthis = "proxy of " + self.this.__repr__() - except: strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - -import types -try: - _object = types.ObjectType - _newclass = 1 -except AttributeError: - class _object : pass - _newclass = 0 -del types - - -class StringFunction(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, StringFunction, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, StringFunction, name) - __repr__ = _swig_repr - def __init__(self, *args): - this = _StringFunction.new_StringFunction(*args) - try: self.this.append(this) - except: self.this = this - def resolve(*args): return _StringFunction.StringFunction_resolve(*args) - def getFunctionString(*args): return _StringFunction.StringFunction_getFunctionString(*args) - def derivative(*args): return _StringFunction.StringFunction_derivative(*args) - def __call__(*args): return _StringFunction.StringFunction___call__(*args) - __swig_destroy__ = _StringFunction.delete_StringFunction - __del__ = lambda self : None; -StringFunction_swigregister = _StringFunction.StringFunction_swigregister -StringFunction_swigregister(StringFunction) - -__add__ = _StringFunction.__add__ -__div__ = _StringFunction.__div__ -__mul__ = _StringFunction.__mul__ - -__sub__ = _StringFunction.__sub__ - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction_wrap.cxx b/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction_wrap.cxx deleted file mode 100644 index cf1e05b520d9..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/StringFunction_wrap.cxx +++ /dev/null @@ -1,4760 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.29 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -#define SWIGPYTHON -#define SWIG_PYTHON_DIRECTOR_NO_VTABLE - -#ifdef __cplusplus -template class SwigValueWrapper { - T *tt; -public: - SwigValueWrapper() : tt(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } - SwigValueWrapper(const T& t) : tt(new T(t)) { } - ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } - operator T&() const { return *tt; } - T *operator&() { return tt; } -private: - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); -}; -#endif - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) -# if (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -# define _CRT_SECURE_NO_DEPRECATE -#endif - - -/* Python.h has to appear first */ -#include - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The swig conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old swig versions, you usually write code as: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit as: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - that seems to be the same, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() - - - */ -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store inforomation on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (l1 - f1) - (l2 - f2); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); -} - -/* Same as previous function, except strcmp is replaced with a pointer comparison */ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -/* Python.h has to appear first */ -#include - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - - -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_Format(PyExc_RuntimeError, mesg); - } -} - - - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif - -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register int l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), min, l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), max, l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue(""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* PySwigClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} PySwigClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - PySwigClientData *data = (PySwigClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME PySwigClientData * -PySwigClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -PySwigClientData_Del(PySwigClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== PySwigObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} PySwigObject; - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); - if (ofmt) { - res = PyString_Format(ofmt,args); - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - return PySwigObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - return PySwigObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -PySwigObject_repr(PySwigObject *v) -#else -PySwigObject_repr(PySwigObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); - Py_DECREF(hex); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); -#else - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); -#endif - PyString_ConcatAndDel(&repr,nrep); - } - return repr; -} - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ -#ifdef METH_NOARGS - PyObject *repr = PySwigObject_repr(v); -#else - PyObject *repr = PySwigObject_repr(v, NULL); -#endif - if (repr) { - fputs(PyString_AsString(repr), fp); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -PySwigObject_dealloc(PyObject *v) -{ - PySwigObject *sobj = (PySwigObject *) v; - PyObject *next = sobj->next; - if (sobj->own) { - swig_type_info *ty = sobj->ty; - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); -#endif - } - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -PySwigObject_append(PyObject* v, PyObject* next) -{ - PySwigObject *sobj = (PySwigObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!PySwigObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -PySwigObject_next(PyObject* v) -#else -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_disown(PyObject *v) -#else -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_acquire(PyObject *v) -#else -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -PySwigObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v); - } else { - PySwigObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v,args); - } else { - PySwigObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -PySwigObject_getattr(PySwigObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject pyswigobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigObject", /* tp_name */ - sizeof(PySwigObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigObject_dealloc, /* tp_dealloc */ - (printfunc)PySwigObject_print, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)PySwigObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigObject_compare, /* tp_compare */ - (reprfunc)PySwigObject_repr, /* tp_repr */ - &PySwigObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigobject_type = tmp; - pyswigobject_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigobject_type; -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own) -{ - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); - } else { - return PyString_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); - } else { - return PyString_FromString(v->ty->name); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PyObject *v) -{ - if (PySwigPacked_Check(v)) { - PySwigPacked *sobj = (PySwigPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigPacked", /* tp_name */ - sizeof(PySwigPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ - (printfunc)PySwigPacked_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigPacked_compare, /* tp_compare */ - (reprfunc)PySwigPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigpacked_type = tmp; - pyswigpacked_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigpacked_type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (PySwigPacked_Check(obj)) { - PySwigPacked *sobj = (PySwigPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return PyString_FromString("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -SWIGRUNTIME PySwigObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (PySwigObject_Check(pyobj)) { - return (PySwigObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !PySwigObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - PySwigObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (PySwigObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (PySwigObject *)sobj->next; - } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) *own = sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, whitout calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, "__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - PySwigObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = PySwigObject_New(ptr, type, own); - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - PySwigClientData *data = (PySwigClientData *) ty->clientdata; - if (data) PySwigClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache() { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); - } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) -{ - PySwigObject *v = (PySwigObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - - - -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) - -#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else - - - -/* -------- TYPES TABLE (BEGIN) -------- */ - -#define SWIGTYPE_p_Dimensions swig_types[0] -#define SWIGTYPE_p_MDArray swig_types[1] -#define SWIGTYPE_p_MDArrayString swig_types[2] -#define SWIGTYPE_p_Name swig_types[3] -#define SWIGTYPE_p_Teuchos__RCPTFunction_t swig_types[4] -#define SWIGTYPE_p_char swig_types[5] -#define SWIGTYPE_p_std__string swig_types[6] -#define SWIGTYPE_p_stk__encore__StringFunction swig_types[7] -#define SWIGTYPE_p_stk__expreval__VariableMap__iterator swig_types[8] -#define SWIGTYPE_p_stk__mesh__Bucket swig_types[9] -#define SWIGTYPE_p_stk__mesh__Entity swig_types[10] -static swig_type_info *swig_types[12]; -static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; -#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) -#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) - -/* -------- TYPES TABLE (END) -------- */ - -#if (PY_VERSION_HEX <= 0x02000000) -# if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires to use swig with the '-classic' option" -# endif -#endif - -/*----------------------------------------------- - @(target):= _StringFunction.so - ------------------------------------------------*/ -#define SWIG_init init_StringFunction - -#define SWIG_name "_StringFunction" - -#define SWIGVERSION 0x010329 - - -#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) - - -#include - - -namespace swig { - class PyObject_ptr { - protected: - PyObject *_obj; - - public: - PyObject_ptr() :_obj(0) - { - } - - PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj) - { - Py_XINCREF(_obj); - } - - PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj) - { - if (initial_ref) Py_XINCREF(_obj); - } - - PyObject_ptr & operator=(const PyObject_ptr& item) - { - Py_XINCREF(item._obj); - Py_XDECREF(_obj); - _obj = item._obj; - return *this; - } - - ~PyObject_ptr() - { - Py_XDECREF(_obj); - } - - operator PyObject *() const - { - return _obj; - } - - PyObject *operator->() const - { - return _obj; - } - }; -} - - -namespace swig { - struct PyObject_var : PyObject_ptr { - PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { } - - PyObject_var & operator = (PyObject* obj) - { - Py_XDECREF(_obj); - _obj = obj; - return *this; - } - }; -} - - -#include "StringFunction.hpp" - - -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor() -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - -SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -{ - if (PyString_Check(obj)) { - char *cstr; int len; - PyString_AsStringAndSize(obj, &cstr, &len); - if (cptr) { - if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. - - The default behavior is just to return the pointer value, - so, be careful. - */ -#if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) -#else - if (*alloc == SWIG_NEWOBJ) -#endif - { - *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); - *alloc = SWIG_NEWOBJ; - } - else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } - } else { - *cptr = PyString_AsString(obj); - } - } - if (psize) *psize = len + 1; - return SWIG_OK; - } else { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} - - - - - -#include -#ifndef LLONG_MIN -# define LLONG_MIN LONG_LONG_MIN -#endif -#ifndef LLONG_MAX -# define LLONG_MAX LONG_LONG_MAX -#endif -#ifndef ULLONG_MAX -# define ULLONG_MAX ULONG_LONG_MAX -#endif - - -SWIGINTERN int -SWIG_AsVal_double (PyObject *obj, double *val) -{ - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; - } else if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } - } -#endif - return res; -} - - -#include - - -#include - - -SWIGINTERNINLINE int -SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ - if ((errno == EDOM) || (errno == ERANGE)) { - errno = 0; - } else { - double summ, reps, diff; - if (rd < x) { - diff = x - rd; - } else if (rd > x) { - diff = rd - x; - } else { - return 1; - } - summ = rd + x; - reps = diff/summ; - if (reps < 8*DBL_EPSILON) { - *d = rd; - return 1; - } - } - } - return 0; -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) -{ - if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< unsigned int >(v); - } - } - return res; -} - -#ifdef __cplusplus -extern "C" { -#endif -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - Name arg2 ; - Dimensions arg3 ; - Dimensions arg4 ; - unsigned int arg5 ; - stk_classic::encore::StringFunction *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - void *argp2 ; - int res2 = 0 ; - void *argp3 ; - int res3 = 0 ; - void *argp4 ; - int res4 = 0 ; - unsigned int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:new_StringFunction",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = buf1; - { - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Name, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } else { - Name * temp = reinterpret_cast< Name * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - { - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Dimensions, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } else { - Dimensions * temp = reinterpret_cast< Dimensions * >(argp3); - arg3 = *temp; - if (SWIG_IsNewObj(res3)) delete temp; - } - } - { - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Dimensions, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_StringFunction" "', argument " "4"" of type '" "Dimensions""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "4"" of type '" "Dimensions""'"); - } else { - Dimensions * temp = reinterpret_cast< Dimensions * >(argp4); - arg4 = *temp; - if (SWIG_IsNewObj(res4)) delete temp; - } - } - ecode5 = SWIG_AsVal_unsigned_SS_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_StringFunction" "', argument " "5"" of type '" "unsigned int""'"); - } - arg5 = static_cast< unsigned int >(val5); - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((char const *)arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - Name arg2 ; - Dimensions arg3 ; - Dimensions arg4 ; - stk_classic::encore::StringFunction *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - void *argp2 ; - int res2 = 0 ; - void *argp3 ; - int res3 = 0 ; - void *argp4 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:new_StringFunction",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = buf1; - { - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Name, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } else { - Name * temp = reinterpret_cast< Name * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - { - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Dimensions, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } else { - Dimensions * temp = reinterpret_cast< Dimensions * >(argp3); - arg3 = *temp; - if (SWIG_IsNewObj(res3)) delete temp; - } - } - { - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Dimensions, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_StringFunction" "', argument " "4"" of type '" "Dimensions""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "4"" of type '" "Dimensions""'"); - } else { - Dimensions * temp = reinterpret_cast< Dimensions * >(argp4); - arg4 = *temp; - if (SWIG_IsNewObj(res4)) delete temp; - } - } - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((char const *)arg1,arg2,arg3,arg4); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - Name arg2 ; - Dimensions arg3 ; - stk_classic::encore::StringFunction *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - void *argp2 ; - int res2 = 0 ; - void *argp3 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:new_StringFunction",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = buf1; - { - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Name, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } else { - Name * temp = reinterpret_cast< Name * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - { - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Dimensions, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "3"" of type '" "Dimensions""'"); - } else { - Dimensions * temp = reinterpret_cast< Dimensions * >(argp3); - arg3 = *temp; - if (SWIG_IsNewObj(res3)) delete temp; - } - } - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((char const *)arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - Name arg2 ; - stk_classic::encore::StringFunction *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - void *argp2 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:new_StringFunction",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = buf1; - { - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Name, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "2"" of type '" "Name""'"); - } else { - Name * temp = reinterpret_cast< Name * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((char const *)arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - stk_classic::encore::StringFunction *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_StringFunction",&obj0)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = buf1; - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((char const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - stk_classic::encore::StringFunction *result = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_StringFunction",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringFunction" "', argument " "1"" of type '" "stk_classic::encore::StringFunction const &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringFunction" "', argument " "1"" of type '" "stk_classic::encore::StringFunction const &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - result = (stk_classic::encore::StringFunction *)new stk_classic::encore::StringFunction((stk_classic::encore::StringFunction const &)*arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_StringFunction(PyObject *self, PyObject *args) { - int argc; - PyObject *argv[6]; - int ii; - - if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 5); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } - if (argc == 1) { - int _v; - int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_StringFunction__SWIG_5(self, args); - } - } - if (argc == 1) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_StringFunction__SWIG_4(self, args); - } - } - if (argc == 2) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Name, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_StringFunction__SWIG_3(self, args); - } - } - } - if (argc == 3) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Name, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_Dimensions, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_StringFunction__SWIG_2(self, args); - } - } - } - } - if (argc == 4) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Name, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_Dimensions, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Dimensions, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_StringFunction__SWIG_1(self, args); - } - } - } - } - } - if (argc == 5) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Name, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_Dimensions, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Dimensions, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_unsigned_SS_int(argv[4], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_new_StringFunction__SWIG_0(self, args); - } - } - } - } - } - } - -fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'new_StringFunction'"); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction_resolve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - stk_classic::expreval::VariableMap::iterator *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:StringFunction_resolve",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction_resolve" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_stk__expreval__VariableMap__iterator, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction_resolve" "', argument " "2"" of type '" "stk_classic::expreval::VariableMap::iterator &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction_resolve" "', argument " "2"" of type '" "stk_classic::expreval::VariableMap::iterator &""'"); - } - arg2 = reinterpret_cast< stk_classic::expreval::VariableMap::iterator * >(argp2); - (arg1)->resolve(*arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction_getFunctionString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - std::string result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:StringFunction_getFunctionString",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction_getFunctionString" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - result = (arg1)->getFunctionString(); - resultobj = SWIG_NewPointerObj((new std::string(static_cast< const std::string& >(result))), SWIGTYPE_p_std__string, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction_derivative(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArrayString *arg2 = 0 ; - Teuchos::RCP result; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:StringFunction_derivative",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction_derivative" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArrayString, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction_derivative" "', argument " "2"" of type '" "MDArrayString &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction_derivative" "', argument " "2"" of type '" "MDArrayString &""'"); - } - arg2 = reinterpret_cast< MDArrayString * >(argp2); - result = (arg1)->derivative(*arg2); - resultobj = SWIG_NewPointerObj((new Teuchos::RCP(static_cast< const Teuchos::RCP& >(result))), SWIGTYPE_p_Teuchos__RCPTFunction_t, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - double arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - double val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:StringFunction___call__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - ecode4 = SWIG_AsVal_double(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "StringFunction___call__" "', argument " "4"" of type '" "double""'"); - } - arg4 = static_cast< double >(val4); - (arg1)->operator ()(*arg2,*arg3,arg4); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:StringFunction___call__",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - (arg1)->operator ()(*arg2,*arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - stk_classic::mesh::Entity *arg4 = 0 ; - MDArray *arg5 = 0 ; - double arg6 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - double val6 ; - int ecode6 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:StringFunction___call__",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_stk__mesh__Entity, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Entity const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Entity const &""'"); - } - arg4 = reinterpret_cast< stk_classic::mesh::Entity * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_MDArray, 0 | 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - if (!argp5) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - arg5 = reinterpret_cast< MDArray * >(argp5); - ecode6 = SWIG_AsVal_double(obj5, &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "StringFunction___call__" "', argument " "6"" of type '" "double""'"); - } - arg6 = static_cast< double >(val6); - (arg1)->operator ()(*arg2,*arg3,(stk_classic::mesh::Entity const &)*arg4,(MDArray const &)*arg5,arg6); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - stk_classic::mesh::Entity *arg4 = 0 ; - MDArray *arg5 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:StringFunction___call__",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_stk__mesh__Entity, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Entity const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Entity const &""'"); - } - arg4 = reinterpret_cast< stk_classic::mesh::Entity * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_MDArray, 0 | 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - if (!argp5) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - arg5 = reinterpret_cast< MDArray * >(argp5); - (arg1)->operator ()(*arg2,*arg3,(stk_classic::mesh::Entity const &)*arg4,(MDArray const &)*arg5); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - stk_classic::mesh::Bucket *arg4 = 0 ; - MDArray *arg5 = 0 ; - double arg6 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - double val6 ; - int ecode6 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:StringFunction___call__",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_stk__mesh__Bucket, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Bucket const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Bucket const &""'"); - } - arg4 = reinterpret_cast< stk_classic::mesh::Bucket * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_MDArray, 0 | 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - if (!argp5) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - arg5 = reinterpret_cast< MDArray * >(argp5); - ecode6 = SWIG_AsVal_double(obj5, &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "StringFunction___call__" "', argument " "6"" of type '" "double""'"); - } - arg6 = static_cast< double >(val6); - (arg1)->operator ()(*arg2,*arg3,(stk_classic::mesh::Bucket const &)*arg4,(MDArray const &)*arg5,arg6); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call____SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - MDArray *arg2 = 0 ; - MDArray *arg3 = 0 ; - stk_classic::mesh::Bucket *arg4 = 0 ; - MDArray *arg5 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:StringFunction___call__",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringFunction___call__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "2"" of type '" "MDArray &""'"); - } - arg2 = reinterpret_cast< MDArray * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_MDArray, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "3"" of type '" "MDArray &""'"); - } - arg3 = reinterpret_cast< MDArray * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_stk__mesh__Bucket, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Bucket const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "4"" of type '" "stk_classic::mesh::Bucket const &""'"); - } - arg4 = reinterpret_cast< stk_classic::mesh::Bucket * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_MDArray, 0 | 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - if (!argp5) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringFunction___call__" "', argument " "5"" of type '" "MDArray const &""'"); - } - arg5 = reinterpret_cast< MDArray * >(argp5); - (arg1)->operator ()(*arg2,*arg3,(stk_classic::mesh::Bucket const &)*arg4,(MDArray const &)*arg5); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_StringFunction___call__(PyObject *self, PyObject *args) { - int argc; - PyObject *argv[7]; - int ii; - - if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 6); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } - if (argc == 3) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_StringFunction___call____SWIG_1(self, args); - } - } - } - } - if (argc == 4) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_double(argv[3], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_StringFunction___call____SWIG_0(self, args); - } - } - } - } - } - if (argc == 5) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_stk__mesh__Entity, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_StringFunction___call____SWIG_3(self, args); - } - } - } - } - } - } - if (argc == 5) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_stk__mesh__Bucket, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_StringFunction___call____SWIG_5(self, args); - } - } - } - } - } - } - if (argc == 6) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_stk__mesh__Bucket, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_double(argv[5], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_StringFunction___call____SWIG_4(self, args); - } - } - } - } - } - } - } - if (argc == 6) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_stk__mesh__Entity, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_MDArray, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_double(argv[5], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_StringFunction___call____SWIG_2(self, args); - } - } - } - } - } - } - } - -fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'StringFunction___call__'"); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_StringFunction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = (stk_classic::encore::StringFunction *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_StringFunction",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_StringFunction" "', argument " "1"" of type '" "stk_classic::encore::StringFunction *""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - delete arg1; - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *StringFunction_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_stk__encore__StringFunction, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - stk_classic::encore::StringFunction *arg2 = 0 ; - SwigValueWrapper result; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:__sub__",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "__sub__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__sub__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "__sub__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__sub__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg2 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp2); - result = stk_classic::encore::operator -(*arg1,*arg2); - resultobj = SWIG_NewPointerObj((new stk_classic::encore::StringFunction(static_cast< const stk_classic::encore::StringFunction& >(result))), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - stk_classic::encore::StringFunction *arg2 = 0 ; - SwigValueWrapper result; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:__add__",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "__add__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__add__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "__add__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__add__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg2 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp2); - result = stk_classic::encore::operator +(*arg1,*arg2); - resultobj = SWIG_NewPointerObj((new stk_classic::encore::StringFunction(static_cast< const stk_classic::encore::StringFunction& >(result))), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap___div__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - stk_classic::encore::StringFunction *arg2 = 0 ; - SwigValueWrapper result; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:__div__",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "__div__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__div__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "__div__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__div__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg2 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp2); - result = stk_classic::encore::operator /(*arg1,*arg2); - resultobj = SWIG_NewPointerObj((new stk_classic::encore::StringFunction(static_cast< const stk_classic::encore::StringFunction& >(result))), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap___mul__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - stk_classic::encore::StringFunction *arg2 = 0 ; - SwigValueWrapper result; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:__mul__",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "__mul__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__mul__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "__mul__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__mul__" "', argument " "2"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg2 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp2); - result = stk_classic::encore::operator *(*arg1,*arg2); - resultobj = SWIG_NewPointerObj((new stk_classic::encore::StringFunction(static_cast< const stk_classic::encore::StringFunction& >(result))), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - stk_classic::encore::StringFunction *arg1 = 0 ; - SwigValueWrapper result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:__sub__",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_stk__encore__StringFunction, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "__sub__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "__sub__" "', argument " "1"" of type '" "stk_classic::encore::StringFunction &""'"); - } - arg1 = reinterpret_cast< stk_classic::encore::StringFunction * >(argp1); - result = stk_classic::encore::operator -(*arg1); - resultobj = SWIG_NewPointerObj((new stk_classic::encore::StringFunction(static_cast< const stk_classic::encore::StringFunction& >(result))), SWIGTYPE_p_stk__encore__StringFunction, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap___sub__(PyObject *self, PyObject *args) { - int argc; - PyObject *argv[3]; - int ii; - - if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 2); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } - if (argc == 1) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap___sub____SWIG_1(self, args); - } - } - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_stk__encore__StringFunction, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap___sub____SWIG_0(self, args); - } - } - } - -fail: - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - - - - -#include - -#ifdef __cplusplus -extern "C" -#endif -void SWIG_init(); /* Forward reference */ - -#define _PyImport_Inittab swig_inittab - -/* Grab Python's inittab[] structure */ - -#ifdef __cplusplus -extern "C" { -#endif -#include - -#undef _PyImport_Inittab - -/* Now define our own version of it. - Hopefully someone does not have more than 1000 built-in modules */ - -struct _inittab SWIG_Import_Inittab[1000]; - -static int swig_num_modules = 0; - -/* Function for adding modules to Python */ - -static void swig_add_module(char *name, void (*initfunc)()) { - SWIG_Import_Inittab[swig_num_modules].name = name; - SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; - swig_num_modules++; - SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; - SWIG_Import_Inittab[swig_num_modules].initfunc = 0; -} - -/* Function to add all of Python's build in modules to our interpreter */ - -static void swig_add_builtin() { - int i = 0; - while (swig_inittab[i].name) { - swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); - i++; - } -#ifdef SWIGMODINIT - SWIGMODINIT -#endif - /* Add SWIG builtin function */ - swig_add_module(SWIG_name, SWIG_init); -} - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern int Py_Main(int, char **); - -#ifdef __cplusplus -} -#endif - -extern struct _inittab *PyImport_Inittab; - -int -main(int argc, char **argv) { - swig_add_builtin(); - PyImport_Inittab = SWIG_Import_Inittab; - return Py_Main(argc,argv); -} - - -static PyMethodDef SwigMethods[] = { - { (char *)"new_StringFunction", _wrap_new_StringFunction, METH_VARARGS, NULL}, - { (char *)"StringFunction_resolve", _wrap_StringFunction_resolve, METH_VARARGS, NULL}, - { (char *)"StringFunction_getFunctionString", _wrap_StringFunction_getFunctionString, METH_VARARGS, NULL}, - { (char *)"StringFunction_derivative", _wrap_StringFunction_derivative, METH_VARARGS, NULL}, - { (char *)"StringFunction___call__", _wrap_StringFunction___call__, METH_VARARGS, NULL}, - { (char *)"delete_StringFunction", _wrap_delete_StringFunction, METH_VARARGS, NULL}, - { (char *)"StringFunction_swigregister", StringFunction_swigregister, METH_VARARGS, NULL}, - { (char *)"__add__", _wrap___add__, METH_VARARGS, NULL}, - { (char *)"__div__", _wrap___div__, METH_VARARGS, NULL}, - { (char *)"__mul__", _wrap___mul__, METH_VARARGS, NULL}, - { (char *)"__sub__", _wrap___sub__, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ - -static swig_type_info _swigt__p_Dimensions = {"_p_Dimensions", "Dimensions *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_MDArray = {"_p_MDArray", "MDArray *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_MDArrayString = {"_p_MDArrayString", "MDArrayString *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_Name = {"_p_Name", "Name *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_Teuchos__RCPTFunction_t = {"_p_Teuchos__RCPTFunction_t", "Teuchos::RCP *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stk__encore__StringFunction = {"_p_stk__encore__StringFunction", "stk_classic::encore::StringFunction *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stk__expreval__VariableMap__iterator = {"_p_stk__expreval__VariableMap__iterator", "stk_classic::expreval::VariableMap::iterator *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stk__mesh__Bucket = {"_p_stk__mesh__Bucket", "stk_classic::mesh::Bucket *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stk__mesh__Entity = {"_p_stk__mesh__Entity", "stk_classic::mesh::Entity *", 0, 0, (void*)0, 0}; - -static swig_type_info *swig_type_initial[] = { - &_swigt__p_Dimensions, - &_swigt__p_MDArray, - &_swigt__p_MDArrayString, - &_swigt__p_Name, - &_swigt__p_Teuchos__RCPTFunction_t, - &_swigt__p_char, - &_swigt__p_std__string, - &_swigt__p_stk__encore__StringFunction, - &_swigt__p_stk__expreval__VariableMap__iterator, - &_swigt__p_stk__mesh__Bucket, - &_swigt__p_stk__mesh__Entity, -}; - -static swig_cast_info _swigc__p_Dimensions[] = { {&_swigt__p_Dimensions, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_MDArray[] = { {&_swigt__p_MDArray, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_MDArrayString[] = { {&_swigt__p_MDArrayString, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_Name[] = { {&_swigt__p_Name, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_Teuchos__RCPTFunction_t[] = { {&_swigt__p_Teuchos__RCPTFunction_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stk__encore__StringFunction[] = { {&_swigt__p_stk__encore__StringFunction, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stk__expreval__VariableMap__iterator[] = { {&_swigt__p_stk__expreval__VariableMap__iterator, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stk__mesh__Bucket[] = { {&_swigt__p_stk__mesh__Bucket, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stk__mesh__Entity[] = { {&_swigt__p_stk__mesh__Entity, 0, 0, 0},{0, 0, 0, 0}}; - -static swig_cast_info *swig_cast_initial[] = { - _swigc__p_Dimensions, - _swigc__p_MDArray, - _swigc__p_MDArrayString, - _swigc__p_Name, - _swigc__p_Teuchos__RCPTFunction_t, - _swigc__p_char, - _swigc__p_std__string, - _swigc__p_stk__encore__StringFunction, - _swigc__p_stk__expreval__VariableMap__iterator, - _swigc__p_stk__mesh__Bucket, - _swigc__p_stk__mesh__Entity, -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ - -static swig_const_info swig_const_table[] = { -{0, 0, 0, 0.0, 0, 0}}; - -#ifdef __cplusplus -} -#endif -/* ----------------------------------------------------------------------------- - * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to - * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of - * swig_module, and does all the lookup, filling in the swig_module.types - * array with the correct data and linking the correct swig_cast_info - * structures together. - * - * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop though that array, and handle each type individually. - * First we lookup if this type has been already loaded, and if so, use the - * loaded structure instead of the generated one. Then we have to fill in the - * cast linked list. The cast data is initially stored in something like a - * two-dimensional array. Each row corresponds to a type (there are the same - * number of rows as there are in the swig_type_initial array). Each entry in - * a column is one of the swig_cast_info structures for that type. - * The cast_initial array is actually an array of arrays, because each row has - * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it - * adding the casts to the list. The one last trick we need to do is making - * sure the type pointer in the swig_cast_info struct is correct. - * - * First off, we lookup the cast->type name to see if it is already loaded. - * There are three cases to handle: - * 1) If the cast->type has already been loaded AND the type we are adding - * casting info to has not been loaded (it is in this module), THEN we - * replace the cast->type pointer with the type pointer that has already - * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the - * cast->type) are loaded, THEN the cast info has already been loaded by - * the previous module so we just ignore it. - * 3) Finally, if cast->type has not already been loaded, then we add that - * swig_cast_info to the linked list (because the cast->type) pointer will - * be correct. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* c-mode */ -#endif -#endif - -#if 0 -#define SWIGRUNTIME_DEBUG -#endif - -SWIGRUNTIME void -SWIG_InitializeModule(void *clientdata) { - size_t i; - swig_module_info *module_head; - static int init_run = 0; - - clientdata = clientdata; - - if (init_run) return; - init_run = 1; - - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (module_head) { - swig_module.next = module_head->next; - module_head->next = &swig_module; - } else { - /* This is the first module loaded */ - swig_module.next = &swig_module; - SWIG_SetModule(clientdata, &swig_module); - } - - /* Now work on filling in swig_module.types */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); -#endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); -#endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); -#endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); -#endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); -#endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); -#ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); -#endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); -#endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); -#ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); -#endif - if (!ocast) ret = 0; - } - } - - if (!ret) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); -#endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; - } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; - } - swig_module.types[i] = 0; - -#ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n",j); - } - printf("**** SWIG_InitializeModule: Cast List ******\n"); -#endif -} - -/* This function will propagate the clientdata field of type to -* any new swig_type_info structures that have been added into the list -* of equivalent types. It is like calling -* SWIG_TypeClientData(type, clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } - } - } -} - -#ifdef __cplusplus -#if 0 -{ - /* c-mode */ -#endif -} -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - /* Python-specific SWIG API */ -#define SWIG_newvarlink() SWIG_Python_newvarlink() -#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) -#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - - /* ----------------------------------------------------------------------------- - * global variable support code. - * ----------------------------------------------------------------------------- */ - - typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; - } swig_globalvar; - - typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; - } swig_varlinkobject; - - SWIGINTERN PyObject * - swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { - return PyString_FromString(""); - } - - SWIGINTERN PyObject * - swig_varlink_str(swig_varlinkobject *v) { - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - PyString_ConcatAndDel(&str,PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str,PyString_FromString(")")); - return str; - } - - SWIGINTERN int - swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - PyObject *str = swig_varlink_str(v); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", PyString_AsString(str)); - Py_DECREF(str); - return 0; - } - - SWIGINTERN void - swig_varlink_dealloc(swig_varlinkobject *v) { - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } - } - - SWIGINTERN PyObject * - swig_varlink_getattr(swig_varlinkobject *v, char *n) { - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; - } - if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); - } - return res; - } - - SWIGINTERN int - swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); - } - return res; - } - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { - static char varlink__doc__[] = "Swig var link object"; - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* Number of items in variable part (ob_size) */ - (char *)"swigvarlink", /* Type name (tp_name) */ - sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ - 0, /* Itemsize (tp_itemsize) */ - (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ - (printfunc) swig_varlink_print, /* Print (tp_print) */ - (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ - (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ - 0, /* tp_compare */ - (reprfunc) swig_varlink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)swig_varlink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - varlink__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - varlink_type = tmp; - varlink_type.ob_type = &PyType_Type; - type_init = 1; - } - return &varlink_type; - } - - /* Create a variable linking object for use later */ - SWIGINTERN PyObject * - SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject*) result); - } - - SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name)+1; - gv->name = (char *)malloc(size); - if (gv->name) { - strncpy(gv->name,name,size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } - } - v->vars = gv; - } - - SWIGINTERN PyObject * - SWIG_globals() { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; - } - - /* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - - /* Install Constants */ - SWIGINTERN void - SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { - PyObject *obj = 0; - size_t i; - for (i = 0; constants[i].type; ++i) { - switch(constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - Py_DECREF(obj); - } - } - } - - /* -----------------------------------------------------------------------------*/ - /* Fix SwigMethods to carry the callback ptrs when needed */ - /* -----------------------------------------------------------------------------*/ - - SWIGINTERN void - SWIG_Python_FixMethods(PyMethodDef *methods, - swig_const_info *const_table, - swig_type_info **types, - swig_type_info **types_initial) { - size_t i; - for (i = 0; methods[i].ml_name; ++i) { - char *c = methods[i].ml_doc; - if (c && (c = strstr(c, "swig_ptr: "))) { - int j; - swig_const_info *ci = 0; - char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - strncpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - strncpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } - } - } - } - } - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" -#endif -SWIGEXPORT void SWIG_init(void) { - PyObject *m, *d; - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - - m = Py_InitModule((char *) SWIG_name, SwigMethods); - d = PyModule_GetDict(m); - - SWIG_InitializeModule(0); - SWIG_InstallConstants(d,swig_const_table); - - -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxes.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxes.hpp deleted file mode 100644 index 6d1b74f9fd08..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxes.hpp +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef stk_percept_BuildBoundingBoxes_hpp -#define stk_percept_BuildBoundingBoxes_hpp - -#include -#include -#include -#include - -#include -#include - -#include - -#define EXTRA_PRINT 0 - -namespace stk_classic -{ - namespace percept - { - - typedef mesh::Field ScalarFieldType ; - typedef mesh::Field VectorFieldType ; - - template - class BuildBoundingBoxes : public ElementOp - { - - public: - typedef stk_classic::search::ident::IdentProc IdentProc; - typedef stk_classic::search::box::PointBoundingBox BoundingPoint; - typedef stk_classic::search::box::AxisAlignedBoundingBox AABoundingBox; - - std::vector& m_boxes; - VectorFieldType *m_coords_field; - bool m_notInitialized; - public: - BuildBoundingBoxes(std::vector& boxes, VectorFieldType *coords_field) : m_boxes(boxes), m_coords_field(coords_field), - m_notInitialized(false) - { - } - - void init_elementOp() - { - } - void fini_elementOp() - { - m_notInitialized=true; // force this object to be used only once - } - bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData); - - AABoundingBox getBoundingBox(const stk_classic::mesh::Entity& element, const mesh::BulkData& bulkData) - { - double bbox[2*SpatialDim]; - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned numNodes = elem_nodes.size(); - for (unsigned iNode = 0; iNode < numNodes; iNode++) - { - mesh::Entity& node = *elem_nodes[iNode].entity(); - double * coord_data = mesh::field_data( *m_coords_field, node); - if (iNode == 0) - { - for (unsigned iDim = 0; iDim < SpatialDim; iDim++) - { - bbox[iDim] = coord_data[iDim]; - bbox[iDim + SpatialDim] = coord_data[iDim]; - } - } - else - { - for (unsigned iDim = 0; iDim < SpatialDim; iDim++) - { - bbox[iDim] = std::min(bbox[iDim], coord_data[iDim]); - bbox[iDim + SpatialDim] = std::max(bbox[iDim + SpatialDim], coord_data[iDim]); - } - } - } - - AABoundingBox bb; - bb.key.ident = element.identifier(); - bb.set_box(bbox); - - return bb; - } - }; - - - // FIXME - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<3>::AABoundingBox &bbox); - - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<3>::BoundingPoint &bbox); - - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<2>::AABoundingBox &bbox); - - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<2>::BoundingPoint &bbox); - -#if 0 - template - std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::AABoundingBox &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } -#endif - -#if 0 - template - std::ostream &operator<<(std::ostream &out, const BBox_loc &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } -#endif - - template - bool BuildBoundingBoxes::operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - if (m_notInitialized) - throw std::runtime_error("BuildBoundingBoxes::operator(): you must re-construct this object before reusing it"); - - AABoundingBox bb = getBoundingBox(element, bulkData); - if (0 || EXTRA_PRINT) std::cout << "bb = " << bb << std::endl; - m_boxes.push_back(bb); - return false; // never break out of the enclosing loop - } - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxesDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxesDef.hpp deleted file mode 100644 index 79cb830b8d58..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/BuildBoundingBoxesDef.hpp +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef stk_percept_BuildBoundingBoxesDef_hpp -#define stk_percept_BuildBoundingBoxesDef_hpp - -#include - -namespace stk_classic -{ - namespace percept - { - - // FIXME - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<3>::AABoundingBox &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } - - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<3>::BoundingPoint &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } - - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<2>::AABoundingBox &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << "} "; - return out; - } - - //template - //std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::BoundingBox &bbox) - std::ostream &operator<<(std::ostream &out, const BuildBoundingBoxes<2>::BoundingPoint &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << "} "; - return out; - } - - -#if 0 - template - std::ostream &operator<<(std::ostream &out, const typename BuildBoundingBoxes::AABoundingBox &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } -#endif - -#if 0 - template - std::ostream &operator<<(std::ostream &out, const BBox_loc &bbox) - { - out << "bbox_min = { " - << bbox.lower(0) << ", " - << bbox.lower(1) << ", " - << bbox.lower(2) << "} " - << "bbox_max = { " - << bbox.upper(0) << ", " - << bbox.upper(1) << ", " - << bbox.upper(2) << "} "; - return out; - } -#endif - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/CMakeLists.txt deleted file mode 100644 index ebea648727d7..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/function/internal/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeBases.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeBases.hpp deleted file mode 100644 index bfa7d9ac4811..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeBases.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef stk_percept_ComputeBases_hpp -#define stk_percept_ComputeBases_hpp - -#include -#include - -#include - -#include "Intrepid_FunctionSpaceTools.hpp" -#include "Intrepid_FieldContainer.hpp" - -#include - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - class ComputeBases - { - //typedef Intrepid::Basis IntrepidBasisType; - unsigned m_cached_topo_key; - //IntrepidBasisType *m_cached_basis; - //PerceptMesh::BasisTypeRCP m_cached_basis; - PerceptMesh::BasisType* m_cached_basis; - public: - ComputeBases() : m_cached_topo_key(0), m_cached_basis(0) {} - - // [P] = 1 (or numInterpPoints) - // [C] = numCells - // [B] = numBases - // [D] = spatialDim - - /// ([P],[D]) - // parametric_coordinates: ([P],[D]) - // transformed_basis_values: ([C],[B],[P]), or ([C],[B],[P],[D]) for GRAD - void getBases(const stk_classic::mesh::Bucket &bucket, const MDArray& parametric_coordinates, MDArray& transformed_basis_values, int which_cell = -1) - { - VERIFY_OP(parametric_coordinates.rank(), ==, 2, "ComputeBases::operator() parametric_coordinates bad rank"); - VERIFY_OP(transformed_basis_values.rank(), ==, 3, "ComputeBases::operator() transformed_basis_values bad rank"); - VERIFY_OP(transformed_basis_values.dimension(2), ==, parametric_coordinates.dimension(0), - "ComputeBases::operator() transformed_basis_values.dim(2) != parametric_coordinates.dim(0)"); - //VERIFY_OP(output_field_values.rank(), ==, 2, "FieldFunction::operator() output_field_values bad rank"); - - // [P] = number of integration points - int numInterpPoints = parametric_coordinates.dimension(0); - - //const mesh::Bucket & bucket = element->bucket(); - const CellTopologyData * const bucket_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - - //unsigned stride = 0; - //double * fdata_bucket = PerceptMesh::field_data( m_my_field , bucket, &stride); - // intentionally ignoring return value to get around compiler warning - //PerceptMesh::field_data( m_my_field , bucket, &stride); - //unsigned nDOF = stride; - //int nOutDim = m_codomain_dimensions.back(); // FIXME for tensor - // FIXME - //VERIFY_OP((int)nDOF, == , nOutDim, - //"FieldFunction::operator(): invalid dimensions nDof, m_codomain_dimensions[0]= "); - - int numCells = bucket.size(); // FIXME for multiple cells - if (which_cell >= 0) - numCells = 1; - - shards::CellTopology topo(bucket_cell_topo_data); - int numNodes = topo.getNodeCount(); - int cellDim = topo.getDimension(); - if (0) - { - MDArray cellWorkset(numCells, numNodes, cellDim); - if (0) cellWorkset(0,0,0) = 0.0; - } - - // map cell topology to a basis - PerceptMesh::BasisType *basis; - //PerceptMesh::BasisTypeRCP basis; - if (m_cached_topo_key != bucket_cell_topo_data->key) - { - PerceptMesh::BasisTypeRCP basisRCP = PerceptMesh::getBasis(topo); - basis = basisRCP.get(); - m_cached_basis = basis; - m_cached_topo_key = bucket_cell_topo_data->key; - } - else - { - basis = m_cached_basis; - } - - int numBases = basis->getCardinality(); - if (numBases != numNodes) - { - throw std::runtime_error(" (numBases != numNodes) "); - } - - // ([B],[P]), or ([B],[P],[D]) for GRAD - MDArray basis_values(numBases, numInterpPoints); - - // ([C],[B],[P]), or ([C],[B],[P],[D]) for GRAD - //MDArray transformed_basis_values(numCells, numBases, numInterpPoints); - - basis->getValues(basis_values, parametric_coordinates, Intrepid::OPERATOR_VALUE); - - // this function just spreads (copies) the values of the basis to all elements in the workset (numCells) - Intrepid::FunctionSpaceTools::HGRADtransformVALUE(transformed_basis_values, basis_values); - } - - void getBases(const stk_classic::mesh::Entity &element, const MDArray& parametric_coordinates, MDArray& transformed_basis_values) - { - // FIXME this will need to be changed when the bases have gradients and thus depend on which element they're assoc with - const mesh::Bucket & bucket = element.bucket(); - getBases(bucket, parametric_coordinates, transformed_basis_values, 0); - } - - }; - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeFieldValues.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeFieldValues.hpp deleted file mode 100644 index 8e1b03e104c3..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/ComputeFieldValues.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef stk_percept_ComputeFieldValues_hpp -#define stk_percept_ComputeFieldValues_hpp - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - class ComputeFieldValues - { - public: - - // FIXME input_field_data_values: ([C],[F],[DOF]) - - // transformed_basis_values: ([C],[F],[P]), or ([C],[F],[P],[D]) for GRAD - // output_field_values: ([C],[P],[DOF]) - void get_fieldValues(const stk_classic::mesh::Entity& element, MDArray& transformed_basis_values, mesh::FieldBase* field, MDArray& output_field_values) - { - VERIFY_OP(output_field_values.rank(), ==, 3, "FieldValuesComputer::get_fieldValues output_field_values bad rank"); - VERIFY_OP(transformed_basis_values.rank(), ==, 3, "FieldValuesComputer::get_fieldValues transformed_basis_values bad rank"); - VERIFY_OP(output_field_values.dimension(0), ==, transformed_basis_values.dimension(0), - "FieldValuesComputer::get_fieldValues output_field_values.dim(0) doesn't match transformed_basis_values.dim(0)"); - VERIFY_OP(output_field_values.dimension(1), ==, transformed_basis_values.dimension(1), - "FieldValuesComputer::get_fieldValues output_field_values.dim(1) doesn't match transformed_basis_values.dim(1)"); - - // [P] = num integration points - int numInterpPoints = transformed_basis_values.dimension(2); - - unsigned stride = 0; - //double * fdata_bucket = PerceptMesh::field_data( m_my_field , bucket, &stride); - // intentionally ignoring return value to get around compiler warning - //PerceptMesh::field_data( field , bucket, &stride); - unsigned nDOF = stride; - -#ifndef NDEBUG - int nOutDim = output_field_values.dimension(2); // FIXME for tensor - VERIFY_OP((int)nDOF, == , nOutDim, - "FieldValuesComputer::get_fieldValues: invalid dimensions nDof, m_codomain_dimensions[0]= "); -#endif - - int numCells = transformed_basis_values.dimension(0); // FIXME for multiple cells - -// shards::CellTopology topo(bucket_cell_topo_data); -// int numNodes = topo.getNodeCount(); -// int cellDim = topo.getDimension(); - -// if (0) -// { -// MDArray cellWorkset(numCells, numNodes, cellDim); -// if (0) cellWorkset(0,0,0) = 0.0; -// } - - int numBases = transformed_basis_values.dimension(1); - int numNodes = numBases; // FIXME - - // ([C],[F],[P]), or ([C],[F],[P],[D]) for GRAD - //MDArray transformed_basis_values(numCells, numBases, numInterpPoints); - - // FIXME - it appears that Intrepid only supports the evaluation of scalar-valued fields, so we have - // to copy the field one DOF at a time into a local array, evaluate, then copy back - // ([C],[F]) - MDArray field_data_values(numCells, numBases); - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - // ([P],[D]) [P] points in [D] dimensions - - // ([C],[P]) - place for results of evaluation - MDArray loc_output_field_values(numCells, numInterpPoints); - - unsigned stride_node = 0; - - // gather - for (unsigned iDOF = 0; iDOF < nDOF; iDOF++) - { - for (int iCell = 0; iCell < numCells; iCell++) - { - for (int iNode = 0; iNode < numNodes; iNode++) - { - mesh::Entity& node = *elem_nodes[iNode].entity(); - double * fdata = PerceptMesh::field_data( field , node, &stride_node); - field_data_values(iCell, iNode) = fdata[iDOF]; - } - } - - /// NOTE: this is needed since Intrepid::FunctionSpaceTools::evaluate method assumes the output array is initialized to 0 - loc_output_field_values.initialize(0.0); - Intrepid::FunctionSpaceTools::evaluate(loc_output_field_values, field_data_values, transformed_basis_values); - - for (int iCell = 0; iCell < numCells; iCell++) - { - for (int iPoint = 0; iPoint < numInterpPoints; iPoint++) - { - output_field_values(iCell, iPoint, iDOF) = loc_output_field_values(iCell, iPoint); - } - } - } - } - }; - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.cpp deleted file mode 100644 index 17cfbae337b8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -namespace stk_classic -{ - namespace percept - { - - std::ostream &operator<<(std::ostream& out, const Dimensions& dim) - { - //out << "Dimensions: "; - out << "[ "; - for (unsigned int i = 0; i < dim.size(); i++) - { - out << " " << dim[i]; - } - out << "] "; - return out; - } - - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.hpp deleted file mode 100644 index 5fda7e9b23ee..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Dimensions.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef stk_encr_Dimensions_hpp -#define stk_encr_Dimensions_hpp - -#include -#include - -namespace stk_classic -{ - namespace percept - { - class Dimensions : public std::vector - { - public: - typedef std::vector base_type; - //Dimensions() : base_type(1, 0) {} - Dimensions() : base_type( 0) {} - Dimensions(int i0) : base_type(1) { (*this)[0] = i0; } - Dimensions(int i0, int i1) : base_type(2) - { - (*this)[0] = i0; - (*this)[1] = i1; - } - Dimensions(int i0, int i1, int i2) : base_type(3) - { - (*this)[0] = i0; - (*this)[1] = i1; - (*this)[2] = i2; - } - }; - -#ifndef SWIG - std::ostream &operator<<(std::ostream& out, const Dimensions& dim); -#endif - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/FunctionWithIntrepidRequest.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/FunctionWithIntrepidRequest.hpp deleted file mode 100644 index 4b0b7be009cb..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/FunctionWithIntrepidRequest.hpp +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef stk_percept_FunctionWithIntrepidRequest_hpp -#define stk_percept_FunctionWithIntrepidRequest_hpp - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - class FunctionWithIntrepidRequest : public Function - { - Function *m_function; - public: - Function *getFunction() { return m_function; } - typedef FieldBase *FieldType; - typedef MDArray *ContainerType; - typedef std::map Request; - typedef Request::iterator RequestIterator; - Request m_order_values; - Request m_order_gradient; - Request m_order_higherDerivs; - - FunctionWithIntrepidRequest() : Function("noname") {} - FunctionWithIntrepidRequest(Function *func, - Request values = Request(), - Request gradient = Request(), - Request higherDerivs = Request()) : Function(*func), - m_function(func), m_order_values(values), m_order_gradient(gradient), m_order_higherDerivs(higherDerivs) {} - }; - - class ExampleFunctionWithIntrepidRequest : public FunctionWithIntrepidRequest - { - MDArray m_pressure_array; - MDArray m_pressure_grad_array; - public: - - ExampleFunctionWithIntrepidRequest(BulkData& bulkData) : FunctionWithIntrepidRequest() - { - mesh::fem::FEMMetaData& metaData = mesh::fem::FEMMetaData::get(bulkData); - FieldBase *pressure = metaData.get_field("pressure"); - m_pressure_array.resize(10, 1); - m_pressure_grad_array.resize(10, 1, 3); - m_order_values[pressure] = &m_pressure_array; - m_order_gradient[pressure] = &m_pressure_grad_array; - } - - /// input_phy_points: ([C], [P], [D]) - /// output_integrand_values: ([C], [P], [DOF]) - virtual void operator()(MDArray& input_phy_points, MDArray& output_integrand_values, double time_value_optional=0.0) - { - // FIXME check args - int nCells = input_phy_points.dimension(0); - int nPoints = input_phy_points.dimension(1); - int nDof = output_integrand_values.dimension(2); - int start = 0; -// if (which_cell >= 0) -// { -// nCells = 1; -// start = which_cell; -// } - int end = start+nCells; - - for (int iCell = start; iCell < end; iCell++) - { - for (int iPoints = 0; iPoints < nPoints; iPoints++) - { - for (int iDof = 0; iDof < nDof; iDof++) - { - output_integrand_values(iCell, iPoints, iDof) = std::sin(m_pressure_array(iCell, iPoints, iDof)); - // or - output_integrand_values(iCell, iPoints, iDof) = square(m_pressure_array(iCell, iPoints, iDof)); - } - } - } - } - }; - - // This one uses the basis functions passed in from Intrepid - class Example2FunctionWithIntrepidRequest : public FunctionWithIntrepidRequest - { - MDArray m_pressure_array; - MDArray m_pressure_grad_array; - public: - - Example2FunctionWithIntrepidRequest(BulkData& bulkData) : FunctionWithIntrepidRequest() - { - mesh::fem::FEMMetaData& metaData = mesh::fem::FEMMetaData::get(bulkData); - FieldBase *pressure = metaData.get_field("pressure"); - m_pressure_array.resize(10, 1); - m_pressure_grad_array.resize(10, 1, 3); - m_order_values[pressure] = &m_pressure_array; - m_order_gradient[pressure] = &m_pressure_grad_array; - } - - virtual void operator()(MDArray& input_phy_points, MDArray& output_integrand_values, double time_value_optional=0.0) - { - int npts = input_phy_points.dimension(0); - int start = 0; -// if (which_point >= 0) -// { -// npts = 1; -// start = which_point; -// } - int end = start+npts; - - //MDArray& basis_values = *m_order_values[0]; // yes, "0" - by convention, the basis functions are associated with a null FieldBase - MDArray& basis_gradients = *m_order_gradient[0]; // yes, "0" - by convention, the basis functions are associated with a null FieldBase - - int nBasis = 0; // FIXME - int nSpaceDim = 0; // FIXME - for (int iBasis = 0; iBasis < nBasis; iBasis++) - { - for (int ipts = start; ipts < end; ipts++) - { - double sum=0; - // compute grad_N_{iBasis}.grad(pressure) - for (int iSpaceDim = 0; iSpaceDim < nSpaceDim; iSpaceDim++) - { - sum += basis_gradients(ipts, iBasis, iSpaceDim) * m_pressure_grad_array(ipts, 0, iSpaceDim); - } - output_integrand_values(ipts, iBasis) = sum; - } - } - } - }; - - - class l2NormOpScalar : public FunctionWithIntrepidRequest - { - MDArray m_field_array; - //MDArray m_field_grad_array; - public: - - l2NormOpScalar( FieldBase *field) : FunctionWithIntrepidRequest() - { - //FEMMetaData& metaData = FEMMetaData::get(BulkData); - -#if 0 - int npts=0; // FIXME - m_field_array.resize(npts, 1); - - m_order_values[field] = &m_field_array; // if null, calling code will supply this array (temp only - don't hold on to it) -#else - m_order_values[field] = 0; // if null, calling code will supply this array (temp only - don't hold on to it) -#endif - //m_order_gradient[field] = &m_field_grad_array; - } - - /// input_phy_points: ([C], [P], [D]) - /// output_integrand_values: ([C], [P], [DOF]) - virtual void operator()(MDArray& input_phy_points, MDArray& output_integrand_values, double time_value_optional=0.0) - { - // FIXME check args - int nCells = input_phy_points.dimension(0); - int nPoints = input_phy_points.dimension(1); - int nDof = output_integrand_values.dimension(2); - int start = 0; -// if (which_cell >= 0) -// { -// nCells = 1; -// start = which_cell; -// } - int end = start+nCells; - - for (int iCell = start; iCell < end; iCell++) - { - for (int iPoints = 0; iPoints < nPoints; iPoints++) - { - for (int iDof = 0; iDof < nDof; iDof++) - { - output_integrand_values(iCell, iPoints, iDof) = square(m_field_array(iCell, iPoints, iDof)); - } - } - } - } - - }; - - class l2NormOpScalarFunction : public FunctionWithIntrepidRequest - { - Function& m_f; - public: - - l2NormOpScalarFunction(Function& f ) : FunctionWithIntrepidRequest(), m_f(f) - { - // request nothing to be computed by Intrepid, just integrate this function - m_order_values.clear(); - //m_order_gradient.resize(0); - } - - /// input_phy_points: ([C], [P], [D]) - /// output_integrand_values: ([C], [P], [DOF]) - virtual void operator()(MDArray& input_phy_points, MDArray& output_integrand_values, double time_value_optional=0.0) - { - m_f(input_phy_points, output_integrand_values, time); - - // FIXME check args - int nCells = input_phy_points.dimension(0); - int nPoints = input_phy_points.dimension(1); - int nDof = output_integrand_values.dimension(2); - int start = 0; -// if (which_cell >= 0) -// { -// nCells = 1; -// start = which_cell; -// } - int end = start+nCells; - - for (int iCell = start; iCell < end; iCell++) - { - for (int iPoints = 0; iPoints < nPoints; iPoints++) - { - for (int iDof = 0; iDof < nDof; iDof++) - { - output_integrand_values(iCell, iPoints, iDof) = square(output_integrand_values(iCell, iPoints, iDof)); - } - } - } - } - - }; - - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.cpp deleted file mode 100644 index cde41c0e027f..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -#include - -namespace stk_classic -{ - namespace percept - { - std::ostream &operator<<(std::ostream& out, GenericFunction& func) - { - out << "GenericFunction:: domain dims: " << func.getDomainDimensions() << " codomain dims: " << func.getCodomainDimensions(); - return out; - } - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.hpp deleted file mode 100644 index 913072dbe9cc..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef stk_encr_GenericFunction_hpp -#define stk_encr_GenericFunction_hpp - -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - - class GenericFunction - { - public: - GenericFunction(Dimensions domain_dimensions = Dimensions(), - Dimensions codomain_dimensions = Dimensions()) : - m_domain_dimensions(domain_dimensions), - m_codomain_dimensions(codomain_dimensions), m_spatialOperator(false) - { - } - virtual ~GenericFunction() {} - - /** Evaluate the function on it's domain returning result in codomain. - */ - virtual void operator()(MDArray& domain, MDArray& codomain, double time = 0.0)=0; - - bool isSpatialOperator() { return m_spatialOperator; } - void setIsSpatialOperator(bool so) { m_spatialOperator=so; } - - Dimensions getDomainDimensions() {return m_domain_dimensions; } - Dimensions getCodomainDimensions() { return m_codomain_dimensions; } - MDArray getNewDomain() - { - return Intrepid::FieldContainer( Teuchos::Array(m_domain_dimensions.begin(), m_domain_dimensions.end())); - } - - MDArray getNewCodomain() - { - return Intrepid::FieldContainer( Teuchos::Array(m_codomain_dimensions.begin(), m_codomain_dimensions.end())); - } - MDArray getNewCodomain() const - { - return Intrepid::FieldContainer( Teuchos::Array(m_codomain_dimensions.begin(), m_codomain_dimensions.end())); - } - - static MDArray getNewMDArray(const Dimensions dims) - { - return Intrepid::FieldContainer( Teuchos::Array(dims.begin(), dims.end())); - } - protected: - Dimensions m_domain_dimensions; // size() gives rank, each entry gives dimension, e.g. {3,3} for a rank-2 3D tensor - Dimensions m_codomain_dimensions; - bool m_spatialOperator; - }; - -#ifndef SWIG - std::ostream &operator<<(std::ostream& out, GenericFunction& func); -#endif - //class NodalOp : public GenericFunction {}; - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.i b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.i deleted file mode 100644 index 9d0db11fbc32..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/GenericFunction.i +++ /dev/null @@ -1,10 +0,0 @@ -/* File : GenericFunction.i */ -%module GenericFunction - -%{ -#include "GenericFunction.hpp" -%} - -/* Let's just grab the original header file here */ -%include "GenericFunction.hpp" - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/HasValue.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/HasValue.hpp deleted file mode 100644 index ddc607706281..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/HasValue.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef stk_percept_function_HasValue_hpp -#define stk_percept_function_HasValue_hpp - -namespace stk_classic -{ - namespace percept - { - template - class HasValue - { - public: - virtual ValueType& getValue() = 0; - virtual void setValue(ValueType& ) = 0; - virtual ~HasValue() {} - }; - - template - class HasConstValue - { - public: - virtual ValueType& getValue() = 0; - virtual ~HasConstValue() {} - }; - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IntegratedOp.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IntegratedOp.hpp deleted file mode 100644 index 74a541ae89d8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IntegratedOp.hpp +++ /dev/null @@ -1,530 +0,0 @@ -#ifndef stk_percept_IntegratedOp_hpp -#define stk_percept_IntegratedOp_hpp - -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - class IntegratedOp : public ElementOp, public BucketOp, public HasConstValue > - { - public: - - enum AccumulationType { - ACCUMULATE_SUM, - ACCUMULATE_MAX - }; - - IntegratedOp(Function& integrand, TurboOption turboOpt=TURBO_NONE, mesh::FieldBase *field=0) : - m_nDOFs(1), m_accumulation_buffer(), m_count_elems(0), m_is_field(false), m_integrand(integrand), m_turboOpt(turboOpt), - m_cubDegree(2), m_accumulation_type(ACCUMULATE_SUM) - { - if (typeid(integrand) == typeid(FieldFunction)) - { - m_is_field = true; - } - if (field) - { - const stk_classic::mesh::FieldBase::Restriction & r = field->restriction(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, mesh::fem::FEMMetaData::get(*field).universal_part()); - unsigned stride = r.dimension() ; - m_nDOFs = stride; - } - else - { - unsigned sz = integrand.getCodomainDimensions().size(); - if (sz >= 1) - { - m_nDOFs = integrand.getCodomainDimensions()[ sz -1 ]; - } - } - - m_accumulation_buffer.resize(m_nDOFs); - init(); - } - - void setAccumulationType(AccumulationType type) { m_accumulation_type = type; } - AccumulationType getAccumulationType() { return m_accumulation_type; } - - void setCubDegree(unsigned cubDegree) { m_cubDegree= cubDegree; } - unsigned getCubDegree() { return m_cubDegree; } - - void init() - { - m_count_elems=0; - m_accumulation_buffer.assign(m_nDOFs, 0.0); - } - - std::vector& getValue(void) { return m_accumulation_buffer; } - unsigned getElementCount() { return m_count_elems; } - - /// innermost operation of an bucket-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - virtual bool operator()(const stk_classic::mesh::Bucket& bucket, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData); - - /// innermost operation of an element-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - virtual bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData); - void init_elementOp() { init(); } - void fini_elementOp() {} - - private: - - - template - bool helper(const BucketOrEntity& bucket_or_element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - EXCEPTWATCH; - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket_or_element); - CellTopology cell_topo(cell_topo_data); - - int cell_dimension = cell_topo.getDimension(); - int meta_dimension = mesh::fem::FEMMetaData::get_meta_data(mesh::fem::FEMMetaData::get(bulkData)).get_spatial_dimension(); - - if (cell_dimension == meta_dimension - 1) - { - return helperSubDim(bucket_or_element, field, bulkData); - } - - VERIFY_OP_ON(cell_dimension, ==, meta_dimension, "Dimensions don't match"); - - VectorFieldType& coord_field = *(mesh::fem::FEMMetaData::get(bulkData)).get_field("coordinates"); - - // FIXME for fields not on a Node - unsigned nDOF = m_nDOFs; - - unsigned nCells = PerceptMesh::size1(bucket_or_element); - m_count_elems += nCells; - - typedef IntrepidManager IM; - unsigned cubDegree = m_cubDegree; - IM im(Elements_Tag(nCells), cell_topo, cubDegree); - if (0) - { - unsigned numCubPoints = im.m_cub->getNumPoints(); - std::cout << "numCubPoints= " << numCubPoints << std::endl; - } - - - // FIXME - im.m_DOFs_Tag.num = m_nDOFs; - // FIXME - - IM::Jacobian J (im); - IM::JacobianDet dJ (im); - IM::CubaturePoints xi (im); - IM::CellWorkSet cn (im); - IM::CubatureWeights wt (im); - IM::PhysicalCoords pc (im); - IM::IntegrandValues iv (im); - IM::IntegrandValuesDOF ivD (im); - IM::Integral Io (im); - IM::Bases Nb (im); - - IM::WeightedMeasure wXdJ (im); - IM::FieldValues fv (im); - - im.m_cub->getCubature(xi, wt); - - unsigned spaceDim = im.m_Spatial_Dim_Tag.num; - - PerceptMesh::fillCellNodes(bucket_or_element, &coord_field, cn, spaceDim); - - // get jacobian - J(xi, cn, cell_topo); - dJ(J); - wXdJ(wt, dJ); - - if (0) - { - using namespace shards; - - std::cout << "dJ= \n" << dJ << std::endl; - std::cout << "wXdJ= \n" << wXdJ << std::endl; - std::cout << "xi= \n" << xi << std::endl; - std::cout << "wt= \n" << wt << std::endl; - std::cout << "cn= \n" << cn << std::endl; - Util::setDoPause(true); - Util::pause(true); - } - - // get physical coordinates at integration points - pc(cn, xi); - - // get bases -#if 1 - // FIXME - MDArray xi_mda; - xi.copyTo(xi_mda); - Nb(bucket_or_element, xi_mda); -#else - Nb(bucket_or_element, xi); -#endif - - // apply integrand (right now we have MDArray hard-coded... FIXME - templatize on its type) - // it should look like this (one instead of multiple lines): -#if 0 - m_integrand(pc, v); -#else - MDArray pc_mda; - pc.copyTo(pc_mda); - std::vector ivDims; - ivD.dimensions( ivDims); - - - /// NOTE: m_integrand requires the ranks of in/out MDArrays to be such that out_rank >= in_rank - /// Thus, we use IntegrandValuesDOF with [DOF] = 1, and then copy the result to IntegrandValues - /// which does not have the additional rightmost DOF index (Intrepid doesn't have the concept of - /// DOF's, it works on scalars only for the integration routines, or at least that's how I understand - /// it currently. - - // create an array that stk_classic::percept::Function will like to hold the results - ivDims[ivDims.size()-1] = m_nDOFs; - - MDArray iv_mda ( Teuchos::Array(ivDims.begin(), ivDims.end())); - - if (m_turboOpt == TURBO_ELEMENT || m_turboOpt == TURBO_BUCKET) - { - m_integrand(pc_mda, iv_mda, bucket_or_element, xi_mda); - } - else - { - m_integrand(pc_mda, iv_mda); - } - - // now, copy from the results to an array that Intrepid::integrate will like - -#endif - - for (unsigned iDof = 0; iDof < nDOF; iDof++) - { - iv.copyFrom(im, iv_mda, iDof); - - // get the integral - if (m_accumulation_type == ACCUMULATE_SUM) - { - Io(iv, wXdJ, Intrepid::COMP_BLAS); - } - - //optional design: - // - // Io(integrand(pc_mda, v), wXdJ(w, dJ(J(xi, c, cell_topo)), Intrepid::COMP_BLAS); - - for (unsigned iCell = 0; iCell < nCells; iCell++) - { - // if (Util::getFlag(0)) - // { - // std::cout << "tmp Io(iCell)= " << Io(iCell) << std::endl; - // Util::pause(true, "Io(iCell)"); - // } - if (m_accumulation_type == ACCUMULATE_SUM) - { - m_accumulation_buffer[iDof] += Io(iCell); - } - else if (m_accumulation_type == ACCUMULATE_MAX) - { - double valIo = 0.0; - for (int ivpts = 0; ivpts < iv.dimension(1); ivpts++) - { - valIo = std::max(valIo, iv((int)iCell, ivpts)); - } - //std::cout << "m_accumulation_buffer[iDof] = " << m_accumulation_buffer[iDof] << " valIO= " << valIo << std::endl; - m_accumulation_buffer[iDof] = std::max(m_accumulation_buffer[iDof], valIo); - } - } - } - return false; - } - - /** for sub-dim elements embedded in higher dim (e.g. quad face of hex elements), we need to: - * 1. get parent element through side relations - * 2. get integration points and weights on quad ref element - * 3. get integration points and weights on hex ref element - * 4. get face normals (from Intrepid they are non-normalized normals, i.e. they are surface area vectors) - * 5. get norm of face normals - * 6. get products with cubature weights - */ - - bool helperSubDim(const stk_classic::mesh::Bucket& bucket, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - helperSubDim(element, field, bulkData); - } - return false; - } - - bool helperSubDim(const stk_classic::mesh::Entity& child_element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - EXCEPTWATCH; - - const CellTopologyData * const child_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(child_element); - CellTopology child_cell_topo(child_cell_topo_data); - int child_cell_dimension = child_cell_topo.getDimension(); - int meta_dimension = mesh::fem::FEMMetaData::get_meta_data(mesh::fem::FEMMetaData::get(bulkData)).get_spatial_dimension(); - - // for now, only allow face (or edge) - VERIFY_OP_ON(child_cell_dimension, ==, meta_dimension - 1, "Dimensions don't match"); - - VectorFieldType& coord_field = *(mesh::fem::FEMMetaData::get(bulkData)).get_field("coordinates"); - - // FIXME for fields not on a Node - unsigned nDOF = m_nDOFs; - - unsigned nCells = PerceptMesh::size1(child_element); - m_count_elems += nCells; - - typedef IntrepidManager IM; - unsigned cubDegree = m_cubDegree; - const stk_classic::mesh::PairIterRelation parent_elements = child_element.relations(child_element.entity_rank() + 1); - VERIFY_OP_ON(parent_elements.size(), ==, 1, "cant find parent"); - const stk_classic::mesh::Entity& element = *parent_elements[0].entity(); - unsigned i_face = parent_elements[0].identifier(); - - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - CellTopology cell_topo(cell_topo_data); - int cell_dimension = cell_topo.getDimension(); - VERIFY_OP_ON(cell_dimension, ==, meta_dimension , "Dimensions don't match"); - - IM im(Elements_Tag(nCells), cell_topo, cubDegree); - IM imChild(Elements_Tag(nCells), child_cell_topo, cubDegree); - unsigned numCubPoints_child = imChild.m_cub->getNumPoints(); - im.m_Cub_Points_Tag = Cub_Points_Tag(numCubPoints_child); - - if (0) - { - std::cout << "numCubPoints_child= " << numCubPoints_child - << " parent rank= " << element.entity_rank() - << " parent topo= " << cell_topo.getName() - << std::endl; - } - - // FIXME - im.m_DOFs_Tag.num = m_nDOFs; - // FIXME - - // _c suffix is for the child (face) element - IM::Jacobian J (im); - IM::FaceNormal fn (im); - //IM::JacobianDet dJ (im); - IM::CubaturePoints xi (im); - IM::CubaturePoints xi_c (imChild); - IM::CellWorkSet cn (im); - IM::CubatureWeights wt (im); - IM::CubatureWeights wt_c (imChild); - IM::PhysicalCoords pc (im); - IM::IntegrandValues iv (im); - IM::IntegrandValuesDOF ivD (im); - IM::Integral Io (im); - IM::Bases Nb (im); - - IM::WeightedMeasure wXfn (im); - IM::FieldValues fv (im); - - imChild.m_cub->getCubature(xi_c, wt_c); - - unsigned spaceDim = im.m_Spatial_Dim_Tag.num; - - PerceptMesh::fillCellNodes(element, &coord_field, cn, spaceDim); - - // get parent cell integration points - // Map Gauss points on quad to reference face: paramGaussPoints -> refGaussPoints - Intrepid::CellTools::mapToReferenceSubcell(xi, - xi_c, - 2, i_face, cell_topo); // FIXME magic - - // get jacobian - J(xi, cn, cell_topo); - //dJ(J); - - //shards::ArrayVector fn_Norm; - - // FIXME - //fn(J, i_face, cell_topo); - MDArray J_mda; - J.copyTo(J_mda); - MDArray fn_mda(im.m_Elements_Tag.num, numCubPoints_child, spaceDim); - Intrepid::CellTools::getPhysicalFaceNormals(fn_mda, J_mda, i_face, cell_topo); - - /// get norm of fn - for (int icell = 0; icell < im.m_Elements_Tag.num; icell++) - { - for (int ipt = 0; ipt < (int)numCubPoints_child; ipt++) - { - double sum = 0.0; - for (int i = 0; i < (int)spaceDim; i++) - { - sum += square(fn_mda(icell, ipt, i)); - } - wXfn(icell, ipt) = std::sqrt(sum) * wt_c(ipt); - } - } - - if (0) - { - using namespace shards; - - //std::cout << "dJ= \n" << dJ << std::endl; - std::cout << "wXfn= \n" << wXfn << std::endl; - std::cout << "xi= \n" << xi << std::endl; - std::cout << "wt= \n" << wt << std::endl; - std::cout << "cn= \n" << cn << std::endl; - Util::setDoPause(true); - Util::pause(true); - } - - // get physical coordinates at integration points - pc(cn, xi); - - // get bases -#if 1 - // FIXME - MDArray xi_mda; - xi.copyTo(xi_mda); - Nb(element, xi_mda); -#else - Nb(element, xi); -#endif - - // apply integrand (right now we have MDArray hard-coded... FIXME - templatize on its type) - // it should look like this (one instead of multiple lines): -#if 0 - m_integrand(pc, v); -#else - MDArray pc_mda; - pc.copyTo(pc_mda); - std::vector ivDims; - ivD.dimensions( ivDims); - - - /// NOTE: m_integrand requires the ranks of in/out MDArrays to be such that out_rank >= in_rank - /// Thus, we use IntegrandValuesDOF with [DOF] = 1, and then copy the result to IntegrandValues - /// which does not have the additional rightmost DOF index (Intrepid doesn't have the concept of - /// DOF's, it works on scalars only for the integration routines, or at least that's how I understand - /// it currently. - - // create an array that stk_classic::percept::Function will like to hold the results - - ivDims[ivDims.size()-1] = m_nDOFs; - - MDArray iv_mda ( Teuchos::Array(ivDims.begin(), ivDims.end())); - - if (m_turboOpt == TURBO_ELEMENT || m_turboOpt == TURBO_BUCKET) - { - m_integrand(pc_mda, iv_mda, element, xi_mda); - } - else - { - m_integrand(pc_mda, iv_mda); - } - - // now, copy from the results to an array that Intrepid::integrate will like - -#endif - - for (unsigned iDof = 0; iDof < nDOF; iDof++) - { - iv.copyFrom(im, iv_mda, iDof); - - // get the integral - if (m_accumulation_type == ACCUMULATE_SUM) - { - Io(iv, wXfn, Intrepid::COMP_BLAS); - } - - //optional design: - // - // Io(integrand(pc_mda, v), wXdJ(w, dJ(J(xi, c, cell_topo)), Intrepid::COMP_BLAS); - - for (unsigned iCell = 0; iCell < nCells; iCell++) - { - // if (Util::getFlag(0)) - // { - // std::cout << "tmp Io(iCell)= " << Io(iCell) << std::endl; - // Util::pause(true, "Io(iCell)"); - // } - if (m_accumulation_type == ACCUMULATE_SUM) - { - m_accumulation_buffer[iDof] += Io(iCell); - } - else if (m_accumulation_type == ACCUMULATE_MAX) - { - double valIo = 0.0; - for (int ivpts = 0; ivpts < iv.dimension(1); ivpts++) - { - valIo = std::max(valIo, iv((int)iCell, ivpts)); - } - //std::cout << "m_accumulation_buffer[iDof] = " << m_accumulation_buffer[iDof] << " valIO= " << valIo << std::endl; - m_accumulation_buffer[iDof] = std::max(m_accumulation_buffer[iDof], valIo); - } - } - } - return false; - } - - - - - private: - unsigned m_nDOFs; - std::vector m_accumulation_buffer; - unsigned m_count_elems; - bool m_is_field; - Function& m_integrand; - TurboOption m_turboOpt; - unsigned m_cubDegree; - AccumulationType m_accumulation_type; - }; - - //template<> - - - bool IntegratedOp::operator()(const stk_classic::mesh::Bucket& bucket, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - EXCEPTWATCH; - helper(bucket, field, bulkData); - return false; - } - - /// innermost operation of an element-based loop; return value of true forces the enclosing loop to terminate and this class' - /// derived classes can return info back to the loop invoker - bool IntegratedOp::operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *field, const mesh::BulkData& bulkData) - { - EXCEPTWATCH; - helper(element, field, bulkData); - return false; - } - - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.cpp deleted file mode 100644 index b30a19c34585..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include - -#include - - -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - IsInElement::IsInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates) : - m_found_it(false), m_input_phy_points(input_phy_points), m_found_parametric_coordinates(found_parametric_coordinates), - m_foundElement(0) - {} - - void IsInElement::init_elementOp() - { - m_found_it=false; - } - void IsInElement::fini_elementOp() - { - } - - bool IsInElement::operator()(const stk_classic::mesh::Entity& element, const mesh::BulkData& bulkData) - { - - unsigned found_it; - isInElement(m_input_phy_points, m_found_parametric_coordinates, found_it, element, bulkData); - //if (EXTRA_PRINT) std::cout << "IsInElement::operator() found_it = " << found_it << std::endl; - // break out of enclosing element loop - if (found_it) - { - m_found_it = true; - m_foundElement = &element; - return true; - } - else - return false; - } - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - void IsInElement::isInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, unsigned& found_it, const mesh::Entity& element, - const mesh::BulkData& bulkData) - { - IntrepidManager::isInElement(input_phy_points, found_parametric_coordinates, found_it, element, bulkData); -#if 0 - found_it = 0; - - // FIXME consider caching the coords_field in FieldFunction - const mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(bulkData); - VectorFieldType *coords_field = metaData.get_field("coordinates"); - - const mesh::Bucket & bucket = element.bucket(); - const CellTopologyData * const bucket_cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - - unsigned numCells = 1; // FIXME - - shards::CellTopology topo(bucket_cell_topo_data); - unsigned numNodes = topo.getNodeCount(); - unsigned cellDim = topo.getDimension(); - MDArray cellWorkset(numCells, numNodes, cellDim); - - /// FIXME -- fill cellWorkset - const mesh::PairIterRelation elem_nodes = element.relations( mesh::Node ); - - for (unsigned iCell = 0; iCell < numCells; iCell++) - { - for (unsigned iNode = 0; iNode < numNodes; iNode++) - { - mesh::Entity& node = *elem_nodes[iNode].entity(); - double * node_coord_data = stk_classic::mesh::field_data( *coords_field , node); - for (unsigned iDim=0; iDim < cellDim; iDim++) - { - cellWorkset(iCell, iNode, iDim) = node_coord_data[iDim]; - } - } - } - - // FIXME for multiple points - if (input_phy_points.rank() == 1) - { - VERIFY_1("IsInElement::isInElement bad rank of input_phy_points"); - } - VERIFY_OP(input_phy_points.dimension(0), == , 1, "IsInElement::isInElement bad input_phy_points 1st dim"); - VERIFY_OP(input_phy_points.dimension(1), >= , (int)cellDim, "IsInElement::isInElement bad input_phy_points 2nd dim"); - - if (found_parametric_coordinates.rank() == 1) - { - VERIFY_1("IsInElement::isInElement bad rank of found_parametric_coordinates"); - } - VERIFY_OP(found_parametric_coordinates.dimension(0), == , 1, "IsInElement::isInElement bad found_parametric_coordinates 1st dim"); - VERIFY_OP(found_parametric_coordinates.dimension(1), == , (int)cellDim, - "IsInElement::isInElement bad found_parametric_coordinates 2nd dim"); - - unsigned cellOrd = 0; // FIXME - Intrepid::CellTools::mapToReferenceFrame(found_parametric_coordinates, input_phy_points, cellWorkset, topo, cellOrd); - MDArrayUInt inclusion_results(1); // FIXME - Intrepid::CellTools::checkPointwiseInclusion(inclusion_results, found_parametric_coordinates, topo); - found_it = inclusion_results(0); - if (found_it) - { - // for testing only - if (0) - { - FieldContainer images(1, cellDim ); - //Intrepid::CellTools::mapToPhysicalFrame(images, preImages, triNodes, triangle_3, whichCell); - Intrepid::CellTools::mapToPhysicalFrame(images, found_parametric_coordinates, cellWorkset, topo, cellOrd); - } - } -#endif - } - - - } -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.hpp deleted file mode 100644 index 6f358d9598f6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/IsInElement.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef stk_encr_IsInElement_hpp -#define stk_encr_IsInElement_hpp - -#include -#include -#include -#include - - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - - class IsInElement : public ElementOp - { - - public: - bool m_found_it; - MDArray& m_input_phy_points; - MDArray& m_found_parametric_coordinates; - const stk_classic::mesh::Entity *m_foundElement; - public: - IsInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates); - - bool operator()(const stk_classic::mesh::Entity& element, const mesh::BulkData& bulkData); - bool operator()(const stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase* field, const mesh::BulkData& bulkData) - { - return (*this)(element, bulkData); - } - void init_elementOp(); - void fini_elementOp(); - - private: - - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - void isInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, unsigned& found_it, const mesh::Entity& element, - const mesh::BulkData& bulkData); - - }; - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcher.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcher.hpp deleted file mode 100644 index 6a0f6383d330..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcher.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef stk_percept_STKSearcher_hpp -#define stk_percept_STKSearcher_hpp - -#include - -#include -#include -#include -#include - -#include - - -#include - -#include -#include - -#include - -#include -#include - -#define EXTRA_PRINT 0 - -namespace stk_classic -{ - namespace percept - { - typedef mesh::Field ScalarFieldType ; - typedef mesh::Field VectorFieldType ; - - template - class STKSearcher : public Searcher - { - typedef BuildBoundingBoxes BBB; - typedef typename BBB ::AABoundingBox BBox; - typedef typename BBB ::BoundingPoint BPoint; - typedef typename BBB ::IdentProc IdProc; - typedef std::vector > IdentProcRelation; - - stk_classic::mesh::BulkData *m_bulk; - //std::vector< template<> BuildBoundingBoxes::BoundingBox > m_boxes; - std::vector< BBox > m_boxes; - - public: - - STKSearcher(stk_classic::mesh::BulkData *bulk); - - virtual ~STKSearcher(); - - void setupSearch(); - - void tearDownSearch(); - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - - virtual const stk_classic::mesh::Entity *findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, - unsigned& found_it, const mesh::Entity *hint_element ); - - private: - - - }; - - } -} - -#include "STKSearcherDef.hpp" - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcherDef.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcherDef.hpp deleted file mode 100644 index 96a9506af88a..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/STKSearcherDef.hpp +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef stk_percept_STKSearcherDef_hpp -#define stk_percept_STKSearcherDef_hpp - -#include - -#include -#include "STKSearcher.hpp" - -namespace stk_classic -{ - namespace percept - { - - template - STKSearcher::STKSearcher(stk_classic::mesh::BulkData *bulk) : m_bulk(bulk), m_boxes() - { - } - - template - STKSearcher::~STKSearcher() {} - - template - void - STKSearcher::setupSearch() - { - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*m_bulk); - mesh::BulkData& bulkData = *m_bulk; - VectorFieldType *coords_field = metaData.get_field("coordinates"); - PerceptMesh meshUtil(&metaData, &bulkData); - - BBB buildBoundingBoxes(m_boxes, coords_field); - meshUtil.elementOpLoop(buildBoundingBoxes, coords_field); - } - - template - void - STKSearcher::tearDownSearch() - { - m_boxes.clear(); - } - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - - template - const stk_classic::mesh::Entity * - STKSearcher::findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, - unsigned& found_it, const mesh::Entity *hint_element ) - { - //return 0; - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*m_bulk); - mesh::BulkData& bulkData = *m_bulk; - - //VectorFieldType *coords_field = metaData.get_field("coordinates"); - - PerceptMesh meshUtil(&metaData, &bulkData); - - double pts[SpatialDim]; - for (unsigned iDim = 0; iDim < SpatialDim; iDim++) - { - pts[iDim] = input_phy_points(0, iDim); - } - BPoint pointBoundingBox; - pointBoundingBox.key.ident = 123; // FIXME for multiple points - pointBoundingBox.set_center(pts); - std::vector points(1, pointBoundingBox); - - stk_classic::search::FactoryOrder order; - order.m_communicator = bulkData.parallel(); - order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE; - - if (0 || EXTRA_PRINT) - { - bool box_p = m_boxes[0].intersect(pointBoundingBox); - bool p_box = pointBoundingBox.intersect(m_boxes[0]); - - std::cout << "STKSearcher::findElement: m_boxes[0]= " << m_boxes[0] << std::endl; - std::cout << "STKSearcher::findElement: pointBoundingBox= " << pointBoundingBox << std::endl; - std::cout << "STKSearcher::findElement: box_p= " << box_p << std::endl; - std::cout << "STKSearcher::findElement: p_box= " << p_box << std::endl; - } - - if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: nboxes= " << m_boxes.size() << std::endl; - - IdentProcRelation relation; - stk_classic::search::coarse_search(relation, m_boxes, points, order); - //stk_classic::search::coarse_search(relation, points, m_boxes, order); - - if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: found " << relation.size() << " containing bboxes" << std::endl; - - if (relation.size()) - { - IsInElement isIn(input_phy_points, found_parametric_coordinates); - - for (unsigned i = 0; i < relation.size(); i++) - { - if (0 || EXTRA_PRINT) - std::cout << "relation[ " << i << "]= {" << relation[i].first << "} --> { " << relation[i].second << "}" << std::endl; - mesh::Entity *element = bulkData.get_entity(metaData.element_rank(), relation[i].second.ident); - //bool loop_break = ... intentionally ignoring return value - isIn(*element, bulkData); - if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: found it= " << isIn.m_found_it << std::endl; - if (isIn.m_found_it) - { - found_it = 1; - return isIn.m_foundElement; - } - else - { - found_it = 0; - return 0; - } - } - } - - return 0; - } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Searcher.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Searcher.hpp deleted file mode 100644 index 5711540746b8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/Searcher.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef stk_encr_Searcher_hpp -#define stk_encr_Searcher_hpp - -#include -#include -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - class Searcher - { - public: - - /** Find the element containing this physical point and return if found (also set the found_it flag to 1, else 0). - * If hint_element is non-null, use it to check first if it contains the point to potentially avoid a more costly search. - * - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - virtual const stk_classic::mesh::Entity *findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, - unsigned& found_it, const mesh::Entity *hint_element )=0; - virtual void setupSearch() {} - virtual void tearDownSearch() {} - virtual ~Searcher() {} - }; - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.cpp deleted file mode 100644 index ce5bbce40935..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -#include - - -#include -#include - -#include -#include - -namespace stk_classic -{ - namespace percept - { - - SimpleSearcher::SimpleSearcher(stk_classic::mesh::BulkData *bulk) : m_bulk(bulk) {} - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - - const stk_classic::mesh::Entity *SimpleSearcher::findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, - unsigned& found_it, const mesh::Entity *hint_element ) - { - VERIFY_OP(input_phy_points.rank(), ==, found_parametric_coordinates.rank(), "SimpleSearcher::findElement bad dims"); - VERIFY_OP(input_phy_points.rank(), ==, 2, "SimpleSearcher::findElement bad rank"); - - mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get( *m_bulk ); - mesh::BulkData& bulkData = *m_bulk; - - // FIXME consider caching the coords_field - VectorFieldType *coords_field = metaData.get_field("coordinates"); - - PerceptMesh meshUtil(&metaData, &bulkData); - - IsInElement isIn(input_phy_points, found_parametric_coordinates); - - // check first using the hint - if (hint_element) - { - IsInElement isIn_hint(input_phy_points, found_parametric_coordinates); - isIn_hint(*hint_element, bulkData); - - //if (EXTRA_PRINT) std::cout << "SimpleSearcher::findElement: hint found it= " << isIn_hint.m_found_it << std::endl; - if (isIn_hint.m_found_it) - { - found_it = 1; - return isIn_hint.m_foundElement; - } - } - - meshUtil.elementOpLoop(isIn, coords_field); - //if (EXTRA_PRINT) std::cout << "SimpleSearcher::findElement: found it= " << isIn.m_found_it << std::endl; - - if (isIn.m_found_it) - { - found_it = 1; - return isIn.m_foundElement; - } - else - { - found_it = 0; - } - return 0; - } - - - } -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.hpp deleted file mode 100644 index 2145046a58eb..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/SimpleSearcher.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef stk_encr_SimpleSearcher_hpp -#define stk_encr_SimpleSearcher_hpp - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -namespace stk_classic -{ - namespace percept - { - typedef mesh::Field ScalarFieldType ; - typedef mesh::Field VectorFieldType ; - - class FieldFunction; - - class SimpleSearcher : public Searcher - { - stk_classic::mesh::BulkData *m_bulk; - public: - SimpleSearcher(stk_classic::mesh::BulkData *bulk); - - virtual ~SimpleSearcher() {} - - /** - * Dimensions of input_phy_points = ([P]=1, [D]) - * Dimensions of found_parametric_coordinates = ([P]=1, [D]) - */ - - virtual const stk_classic::mesh::Entity *findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, - unsigned& found_it, const mesh::Entity *hint_element ); - }; - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/swig.make b/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/swig.make deleted file mode 100644 index cacd8b873127..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/internal/swig.make +++ /dev/null @@ -1 +0,0 @@ -swig -python -c++ -I/scratch/srkenno/code/stk_encore -includeall -lembed.i GenericFunction.i \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/function/jj.swig.make b/packages/stk/stk_classic/stk_percept/stk_percept/function/jj.swig.make deleted file mode 100644 index 691d05c8afde..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/function/jj.swig.make +++ /dev/null @@ -1 +0,0 @@ -swig -python -c++ -I/scratch/srkenno/code/stk_encore -includeall -lembed.i StringFunction.i \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/math/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/math/CMakeLists.txt deleted file mode 100644 index 2b256f171b66..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/math/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/math/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/math/Math.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/math/Math.hpp deleted file mode 100644 index 7d63949b54b0..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/math/Math.hpp +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef stk_percept_math_TransformationMatrix_hpp -#define stk_percept_math_TransformationMatrix_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -namespace stk_classic { - namespace percept { - - namespace ublas = boost::numeric::ublas; - - class Math - { - public: - - typedef ublas::c_matrix Matrix; - - typedef ublas::c_vector Vector; - - typedef ublas::c_vector ubvec; - - class MyVector : public ubvec - { - public: - - MyVector(double x=0.0) : ubvec() - { - (*this)(0) = x; - (*this)(1) = x; - (*this)(2) = x; - } - - MyVector(double *x) : ubvec() - { - (*this)(0) = x[0]; - (*this)(1) = x[1]; - (*this)(2) = x[2]; - } - //Vector(const ubvec& v) : ubvec(v) {} - - MyVector& operator=(const ubvec& v) - { - //ubvec& v0 = ubvec::operator=(v); - (*this)(0) = v(0); - (*this)(1) = v(1); - (*this)(2) = v(2); - return *this; - } - - //v = ublas::prod(m_rotMat, v); - - }; - - static double my_abs_hi(double x, double eps=1.e-6) { return std::sqrt(x*x + eps*eps); } - static double my_min_hi(double x, double y, double eps=1.e-6) { return 0.5*(x+y - my_abs_hi(x-y,eps)); } - static double my_max_hi(double x, double y, double eps=1.e-6) { return 0.5*(x+y + my_abs_hi(x-y,eps)); } - // heavyside - static double heavy_smooth(double x, double x0, double eps=1.e-6) { return 1./(1.+std::exp(-2.0*(x-x0)/eps)); } - - static double random01() - { - double rnd = Teuchos::ScalarTraits::random(); - return (rnd+1.0)/2.0; - } - - static Matrix rotationMatrix(int axis, double angle_degrees) - { - Matrix rm; - rm.clear(); - double theta = M_PI * angle_degrees / 180.0; - double cost = std::cos(theta); - double sint = std::sin(theta); - if (axis == 2) - { - rm(0,0) = cost; rm(0,1) = -sint; - rm(1,0) = sint; rm(1,1) = cost; - rm(2,2) = 1.0; - } - else if (axis == 1) - { - rm(0,0) = cost; rm(0,2) = -sint; - rm(2,0) = sint; rm(2,2) = cost; - rm(1,1) = 1.0; - } - else if (axis == 0) - { - rm(1,1) = cost; rm(1,2) = -sint; - rm(2,1) = sint; rm(2,2) = cost; - rm(0,0) = 1.0; - } - return rm; - } - - static Matrix scalingMatrix(int axis, double scale) - { - Matrix sm; - sm.clear(); - sm(0,0)=1.0; - sm(1,1)=1.0; - sm(2,2)=1.0; - sm(axis,axis)=scale; - return sm; - } - - static Matrix scalingMatrix( double scale) - { - Matrix sm; - sm.clear(); - sm(0,0)=scale; - sm(1,1)=scale; - sm(2,2)=scale; - return sm; - } - - }; - - inline Math::Vector operator*(Math::Matrix& mat, Math::Vector& vec) { return ublas::prod(mat, vec); } - inline Math::Matrix operator*(Math::Matrix& mat, Math::Matrix& mat2) { return ublas::prod(mat, mat2); } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/CMakeLists.txt deleted file mode 100644 index f4a9f4f7d0bc..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - -ADD_SUBDIRECTORY(gen) diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.cpp deleted file mode 100644 index a4ea6e31a256..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -#include "MeshDifference.hpp" - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - void MeshDifference::process_options(RunEnvironment& re) - { - re.clp.setDocString("MeshDifference options"); - - re.clp.setOption("mesh1", &mesh_opt_1, "mesh file #1." ); - re.clp.setOption("mesh2", &mesh_opt_2, "mesh file #2." ); - - } - - void MeshDifference::run(int argc, char** argv) - { - //stk_classic::ParallelMachine parallel_machine = stk_classic::parallel_machine_init(&argc, &argv); - - std::string file_name1, file_name2; - - bool debug_re=true; - ParallelMachineFinalize pmf(true); - RunEnvironment run_environment(&argc, &argv, debug_re); - process_options(run_environment); - run_environment.processCommandLine(); - - { - if (run_environment.help_opt) { - run_environment.printHelp(); - std::exit(EXIT_SUCCESS); - } - - std::string working_directory = ""; - std::string in_filename1 = ""; - std::string in_filename2 = ""; - - if (true) - { - - working_directory = run_environment.directory_opt; - - in_filename1 = mesh_opt_1; - file_name1 = in_filename1; - if (in_filename1[0] != '/' && !working_directory.empty() > 0) { - file_name1 = working_directory + in_filename1; - } - - in_filename2 = mesh_opt_2; - file_name2 = in_filename2; - if (in_filename2[0] != '/' && !working_directory.empty() > 0) { - file_name2 = working_directory + in_filename2; - } - - } - - if (file_name1.length() == 0 || file_name2.length() == 0) - { - std::cout << "OPTION ERROR: The '--mesh1 --mesh2 ' option is required.\n"; - std::exit(EXIT_FAILURE); - } - - } - - //RunEnvironment::doLoadBalance(run_environment.m_comm, file_name); - - PerceptMesh mesh1(3, run_environment.m_comm); - PerceptMesh mesh2(3, run_environment.m_comm); - mesh1.open_read_only(file_name1); - std::cout << "read in file1: " << file_name1 << std::endl; - mesh2.open_read_only(file_name2); - std::cout << "read in file2: " << file_name2 << std::endl; - - PerceptMesh::mesh_difference(mesh1, mesh2, "diff", true, true); - } - - - }//namespace percept -}//namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.hpp deleted file mode 100644 index 74a81f1ceabc..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifference.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef stk_percept_MeshDifference_hpp -#define stk_percept_MeshDifference_hpp - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - - -namespace stk_classic -{ - namespace percept - { - - class MeshDifference - { - public: - MeshDifference() {} - void run(int argc, char** argv); - - void process_options(RunEnvironment& re); - // command line - std::string mesh_opt_1, mesh_opt_2; - }; - - - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifferenceMain.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifferenceMain.cpp deleted file mode 100644 index 3f50965b1ada..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/diff/MeshDifferenceMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -#include "MeshDifference.hpp" - - -using namespace stk_classic; -using namespace percept; - -int main(int argc, char **argv) -{ - - MeshDifference md; - md.run(argc, argv); - - - return 0; -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/CMakeLists.txt deleted file mode 100644 index 2acb307f091d..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/mesh/gen/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.cpp deleted file mode 100644 index cecdb011ef3b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.cpp +++ /dev/null @@ -1,647 +0,0 @@ -#include -#include -#include -#include - -#undef NDEBUG -//#define NDEBUG -#include - -#include "SweepMesher.hpp" -#include "TransformPath.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - - -// template -// void clone(const VectorOfInt& oldElems, VectorOfInt& newElems, VectorOfCoord& nodePool, VectorOfCoord& newNodes, Transform& xform) -// { - -// } -using namespace shards ; - -SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Tag1 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Tag2 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Tag3 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_IMPLEMENTATION( Tag4 ) - - -namespace stk_classic -{ - namespace percept - { - using namespace util; - - enum { SpatialDim = 3 }; - enum { node_count = 21 }; - enum { number_hex = 3 }; - enum { number_wedge = 3 }; - enum { number_tetra = 3 }; - enum { number_pyramid = 2 }; - enum { number_shell_quad = 3 }; - enum { number_shell_tri = 3 }; - - - - static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 2 , 0 , 0 } , { 3 , 0 , 0 } , - { 0 , 1 , 0 } , { 1 , 1 , 0 } , { 2 , 1 , 0 } , { 3 , 1 , 0 } , - { 0 , 2 , 0 } , { 1 , 2 , 0 } , - { 0 , 0 , -1 } , { 1 , 0 , -1 } , { 2 , 0 , -1 } , { 3 , 0 , -1 } , - { 0 , 1 , -1 } , { 1 , 1 , -1 } , { 2 , 1 , -1 } , { 3 , 1 , -1 } , - { 0 , 2 , -1 } , { 1 , 2 , -1 } , - { 1 , 1 , -2 } }; - - static const stk_classic::mesh::EntityId hex_node_ids[3][ shards::Hexahedron<> ::node_count ] = { - { 1 , 2 , 12 , 11 , 5 , 6 , 16 , 15 } , - { 2 , 3 , 13 , 12 , 6 , 7 , 17 , 16 } , - { 3 , 4 , 14 , 13 , 7 , 8 , 18 , 17 } }; - - static const stk_classic::mesh::EntityId wedge_node_ids[3][ shards::Wedge<> ::node_count ] = { - { 15 , 16 , 19 , 5 , 6 , 9 } , - { 10 , 9 , 6 , 20 , 19 , 16 } , - { 16 , 17 , 20 , 6 , 7 , 10 } }; - - static const stk_classic::mesh::EntityId tetra_node_ids[3][ shards::Tetrahedron<> ::node_count ] = { - { 15 , 19 , 16 , 21 } , - { 19 , 20 , 16 , 21 } , - { 16 , 20 , 17 , 21 } }; - - static const stk_classic::mesh::EntityId pyramid_node_ids[2][ shards::Pyramid<> ::node_count ] = { - { 11 , 15 , 16 , 12 , 21 } , - { 12 , 16 , 17 , 13 , 21 } }; - - static const stk_classic::mesh::EntityId shell_quad_node_ids[3][ shards::ShellQuadrilateral<> ::node_count ]={ - { 9 , 6 , 16 , 19 } , - { 6 , 7 , 17 , 16 } , - { 7 , 8 , 18 , 17 } }; - - static const stk_classic::mesh::EntityId shell_tri_node_ids[3][ shards::ShellTriangle<> ::node_count ] ={ - { 19 , 16 , 21 } , - { 16 , 17 , 21 } , - { 17 , 13 , 21 } }; - - - - - - template<> void SweepMesher::breakElement(unsigned elemIndex) - { - unsigned* elem = &m_elems[shards_Quadrilateral_4][elemIndex*m_elemInfo[shards_Quadrilateral_4].vertex_count]; - VectorOfInt newElem = VectorOfInt(3); - newElem[0] = elem[0]; - newElem[1] = elem[1]; - newElem[2] = elem[2]; - push_back(m_elems[shards_Triangle_3], newElem); - newElem[0] = elem[0]; - newElem[1] = elem[2]; - newElem[2] = elem[3]; - push_back(m_elems[shards_Triangle_3], newElem); - if (m_deleteAfterBreak) - { - VectorOfInt::iterator pos = m_elems[shards_Quadrilateral_4].begin()+(elemIndex*m_elemInfo[shards_Quadrilateral_4].vertex_count); - m_elems[shards_Quadrilateral_4].erase(pos, pos + m_elemInfo[shards_Quadrilateral_4].vertex_count); - } - } - - -#if 0 - template<> void SweepMesher::breakAllElements() - { - unsigned numElems = m_elems[shards_Quadrilateral_4].size(); - for (unsigned elemIndex = 0; elemIndex < numElems; elemIndex++) - { - breakElement ( elemIndex); - } - } -#endif - - - /// Break a wedge element into 3 (common case) or 8 (rare case) tets using a constructive algorithm. - template<> void SweepMesher::breakElement(unsigned elemIndex) - { - static unsigned loc_trifaces[4][2][3]; // iPseudoQuadFace, kTriOnQuadFace, jTriNodeIndex - static unsigned loc_qfaces[3][4]; // iWedgeFaceOrd, iFaceNodeOrd - unsigned* elem = &m_elems[shards_Wedge_6][elemIndex * m_elemInfo[shards_Wedge_6].vertex_count]; - - // build quad face break patterns - use simple smallest node index as first node - //shards::CellTopology wedge_topo(shards::getCellTopologyData >() ); - const CellTopologyData *wedge_topo = shards::getCellTopologyData >(); - unsigned numFaces = wedge_topo->side_count; // should be 5 - if (numFaces != 5) - { - assert(5 == numFaces); - } - - // quad faces are first in the face list - unsigned valences[6]={0,0,0,0,0,0}; - for (unsigned iWedgeFaceOrd = 0; iWedgeFaceOrd < 3; iWedgeFaceOrd++) - { - const CellTopologyData_Subcell& face = wedge_topo->side[iWedgeFaceOrd]; - unsigned iqf = face.node[0]; - unsigned globalIqf = elem[iqf]; - unsigned minVal = globalIqf; - unsigned indxMinVal = 0; - for (unsigned iFaceNodeOrd=1; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - //qfaces[iWedgeFaceOrd][iFaceNodeOrd] = elem[face.node[iFaceNodeOrd]]; - iqf = face.node[iFaceNodeOrd]; - globalIqf = elem[iqf]; - if (globalIqf < minVal) - { - minVal = globalIqf; - indxMinVal = iFaceNodeOrd; - } - } - // permute to make min node index come first - for (unsigned iFaceNodeOrd=0; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - unsigned jFaceNodeOrd = (iFaceNodeOrd + indxMinVal) % 4; - //qfaces[iWedgeFaceOrd][iFaceNodeOrd] = elem[face.node[jFaceNodeOrd]]; - loc_qfaces[iWedgeFaceOrd][iFaceNodeOrd] = face.node[jFaceNodeOrd]; - } - // each quad face is now broken into tri faces as {0,1,2}, {0,2,3} - loc_trifaces[iWedgeFaceOrd][0][0] = loc_qfaces[iWedgeFaceOrd][0]; - loc_trifaces[iWedgeFaceOrd][0][1] = loc_qfaces[iWedgeFaceOrd][1]; - loc_trifaces[iWedgeFaceOrd][0][2] = loc_qfaces[iWedgeFaceOrd][2]; - loc_trifaces[iWedgeFaceOrd][1][0] = loc_qfaces[iWedgeFaceOrd][0]; - loc_trifaces[iWedgeFaceOrd][1][1] = loc_qfaces[iWedgeFaceOrd][2]; - loc_trifaces[iWedgeFaceOrd][1][2] = loc_qfaces[iWedgeFaceOrd][3]; - - valences[loc_trifaces[iWedgeFaceOrd][0][0]]++; - valences[loc_trifaces[iWedgeFaceOrd][0][1]]++; - valences[loc_trifaces[iWedgeFaceOrd][0][2]]++; - valences[loc_trifaces[iWedgeFaceOrd][1][0]]++; - valences[loc_trifaces[iWedgeFaceOrd][1][1]]++; - valences[loc_trifaces[iWedgeFaceOrd][1][2]]++; - } - // add in the top and bottom face as a new pseudo quad face - loc_trifaces[3][0][0] = wedge_topo->side[3].node[0]; - loc_trifaces[3][0][1] = wedge_topo->side[3].node[1]; - loc_trifaces[3][0][2] = wedge_topo->side[3].node[2]; - loc_trifaces[3][1][0] = wedge_topo->side[4].node[0]; - loc_trifaces[3][1][1] = wedge_topo->side[4].node[1]; - loc_trifaces[3][1][2] = wedge_topo->side[4].node[2]; - - // find max valence - unsigned vmaxIndx = 0; - unsigned vmax = valences[0]; - bool all3 = true; - for (unsigned iv = 1; iv < 6; iv++) - { - if (valences[iv] > vmax) - { - if (valences[iv] != 3) - all3 = false; - vmax = valences[iv]; - vmaxIndx = iv; - } - } - - if (vmax == 3) - { - /// Rare case where all valences are 3 (each face is broken in same twisting direction - this is the classic - /// "un-tetrahedralizable" configuration, the Schonhardt prism) - in this case, we have to add a Steiner point. - /// The point can be added along one face's diagonal midpoint, but this introduces a need to investigate neighbors, - /// so, we simply choose to create more tets by using the centroid as the Steiner point. - /// (cf. http://www.ams.org/journals/spmj/2005-16-04/S1061-0022-05-00872-1/S1061-0022-05-00872-1.pdf - /// St. Petersburg Math. J. Tom. 16 (2004), vyp. 4 Vol. 16 (2005), No. 4, Pages 673–690 S 1061-0022(05)00872-1 - /// Article electronically published on June 24, 2005 - /// REGULAR TRIANGULATIONS AND STEINER POINTS - /// M. YU. ZVAGELSKI I, A. V. PROSKURNIKOV, AND YU. R. ROMANOVSKI I - /// ) - - //assert(0); - assert(all3); - if (1) - { - std::ostringstream msg; - msg << "shouldn't get here, but if we do, let's exit for now " << 1 << " " << 1.e-10 << "\n"; - throw std::runtime_error( msg.str() ); - } - - //exit(1); - boost::array centroid = {{0,0,0}}; - for (unsigned iv = 0; iv < 6; iv++) - { - centroid[0] += m_node_coords[elem[iv]][0]/6.0; - centroid[1] += m_node_coords[elem[iv]][0]/6.0; - centroid[2] += m_node_coords[elem[iv]][0]/6.0; - } - m_node_coords.push_back(centroid); - unsigned newNodeIndex = m_node_coords.size() - 1; - - for (unsigned iPseudoQuadFace = 0; iPseudoQuadFace < 4; iPseudoQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - m_elems[shards_Tetrahedron_4].push_back(newNodeIndex); - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - m_elems[shards_Tetrahedron_4].push_back(elem[loc_trifaces[iPseudoQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - } - } - } - } - else - { - /// normal case - connect max valence node to other faces without that node (should be 3 tets always) - unsigned count=0; - for (unsigned iPseudoQuadFace = 0; iPseudoQuadFace < 4; iPseudoQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - bool isEqual = false; - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - if (vmaxIndx == loc_trifaces[iPseudoQuadFace][kTriOnQuadFace][jTriNodeIndex]) - { - isEqual = true; - break; - } - } - if (not isEqual) - { - ++count; - m_elems[shards_Tetrahedron_4].push_back(elem[vmaxIndx]); - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - m_elems[shards_Tetrahedron_4].push_back(elem[loc_trifaces[iPseudoQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - } - } - } - } - assert(count == 3); - - } - if (m_deleteAfterBreak) - { - VectorOfInt::iterator pos = m_elems[shards_Wedge_6].begin()+(elemIndex * m_elemInfo[shards_Wedge_6].vertex_count); - m_elems[shards_Wedge_6].erase(pos, pos + m_elemInfo[shards_Wedge_6].vertex_count); - } - - } - - /// Break a hex element into 6 (common case) or 12 (rare case) tets using a constructive algorithm. - /// Note: the 5-tet case cannot be constructed with this algorithm - a table lookup scheme would be more efficient - /// and allow for the 5-tet case - template<> void SweepMesher::breakElement(unsigned elemIndex) - { - static unsigned loc_trifaces[6][2][3]; // iQuadFace, kTriOnQuadFace, jTriNodeIndex - static unsigned loc_qfaces[6][4]; // iHexFaceOrd, iFaceNodeOrd - unsigned* elem = &m_elems[shards_Hexahedron_8][elemIndex * m_elemInfo[shards_Hexahedron_8].vertex_count]; - - // build quad face break patterns - use simple min node index as first node - const CellTopologyData *hex_topo = shards::getCellTopologyData >(); - unsigned numFaces = hex_topo->side_count; // should be 6 - assert(6 == numFaces); - - // node valences - unsigned valences[8]={0,0,0,0,0,0,0,0}; - for (unsigned iHexFaceOrd = 0; iHexFaceOrd < 6; iHexFaceOrd++) - { - const CellTopologyData_Subcell& face = hex_topo->side[iHexFaceOrd]; - unsigned iqf = face.node[0]; - unsigned globalIqf = elem[iqf]; - unsigned minVal = globalIqf; - unsigned indxMinVal = 0; - for (unsigned iFaceNodeOrd=1; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - iqf = face.node[iFaceNodeOrd]; - globalIqf = elem[iqf]; - if (globalIqf < minVal) - { - minVal = globalIqf; - indxMinVal = iFaceNodeOrd; - } - } - // permute to make min node index come first - for (unsigned iFaceNodeOrd=0; iFaceNodeOrd < 4; iFaceNodeOrd++) - { - unsigned jFaceNodeOrd = (iFaceNodeOrd + indxMinVal) % 4; - //qfaces[iHexFaceOrd][iFaceNodeOrd] = elem[face.node[jFaceNodeOrd]]; - loc_qfaces[iHexFaceOrd][iFaceNodeOrd] = face.node[jFaceNodeOrd]; - } - // each quad face is now broken into tri faces as {0,1,2}, {0,2,3} - loc_trifaces[iHexFaceOrd][0][0] = loc_qfaces[iHexFaceOrd][0]; - loc_trifaces[iHexFaceOrd][0][1] = loc_qfaces[iHexFaceOrd][1]; - loc_trifaces[iHexFaceOrd][0][2] = loc_qfaces[iHexFaceOrd][2]; - loc_trifaces[iHexFaceOrd][1][0] = loc_qfaces[iHexFaceOrd][0]; - loc_trifaces[iHexFaceOrd][1][1] = loc_qfaces[iHexFaceOrd][2]; - loc_trifaces[iHexFaceOrd][1][2] = loc_qfaces[iHexFaceOrd][3]; - - valences[loc_trifaces[iHexFaceOrd][0][0]]++; - valences[loc_trifaces[iHexFaceOrd][0][1]]++; - valences[loc_trifaces[iHexFaceOrd][0][2]]++; - valences[loc_trifaces[iHexFaceOrd][1][0]]++; - valences[loc_trifaces[iHexFaceOrd][1][1]]++; - valences[loc_trifaces[iHexFaceOrd][1][2]]++; - } - - // find max valence - unsigned vmaxIndx = 0; - unsigned vmax = valences[0]; - for (unsigned iv = 1; iv < 8; iv++) - { - if (valences[iv] > vmax) - { - vmax = valences[iv]; - vmaxIndx = iv; - } - } - - if (vmax != 6) - { - /// Rare case - create tets by joining centroid to each face - for now, just throw an exception to see how often this - /// case occurs - FIXME - take this exception out later - if (1) - { - std::ostringstream msg; - msg << "shouldn't get here, but if we do, let's exit for now \n"; - throw std::runtime_error( msg.str() ); - } - - //exit(1); - boost::array centroid = {{0,0,0}}; - for (unsigned iv = 0; iv < 8; iv++) - { - centroid[0] += m_node_coords[elem[iv]][0]/8.0; - centroid[1] += m_node_coords[elem[iv]][0]/8.0; - centroid[2] += m_node_coords[elem[iv]][0]/8.0; - } - m_node_coords.push_back(centroid); - unsigned newNodeIndex = m_node_coords.size() - 1; - - for (unsigned iQuadFace = 0; iQuadFace < 6; iQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - m_elems[shards_Tetrahedron_4].push_back(newNodeIndex); - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - m_elems[shards_Tetrahedron_4].push_back(elem[loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - } - } - } - } - else - { - /// normal case - connect max valence node to other faces without that node (should be 6 tets always) - /// Note: there is a 5-tet configuration that exists for some face diagonal configurations - FIXME - could add this case later - /// The 5-tet case consists of an interior tet with no boundary faces, and 4 corner tets; the boundary faces have - /// to each have alternating diagonals along the 3 axis directions for this configuration to exist - unsigned count=0; - for (unsigned iQuadFace = 0; iQuadFace < 6; iQuadFace++) - { - for (unsigned kTriOnQuadFace = 0; kTriOnQuadFace < 2; kTriOnQuadFace++) - { - bool isEqual = false; - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - if (vmaxIndx == loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]) - { - isEqual = true; - break; - } - } - if (not isEqual) - { - ++count; - m_elems[shards_Tetrahedron_4].push_back(elem[vmaxIndx]); - for (unsigned jTriNodeIndex = 0; jTriNodeIndex < 3; jTriNodeIndex++) - { - m_elems[shards_Tetrahedron_4].push_back(elem[loc_trifaces[iQuadFace][kTriOnQuadFace][jTriNodeIndex]]); - } - } - } - } - assert(count == 6); - - } - if (m_deleteAfterBreak) - { - VectorOfInt::iterator pos = m_elems[shards_Hexahedron_8].begin()+(elemIndex * m_elemInfo[shards_Hexahedron_8].vertex_count); - m_elems[shards_Hexahedron_8].erase(pos, pos + m_elemInfo[shards_Hexahedron_8].vertex_count); - } - } - - /// based on UseCase_3 in stk_mesh/use_cases - creates nodes and elements in stk_classic::mesh database - void SweepMesher::stkMeshCreate(stk_classic::ParallelMachine& comm) - { - stkMeshCreateMetaNoCommit(comm); - m_metaData->commit(); - stkMeshCreateBulkAfterMetaCommit(comm); - } - - static std::vector get_entity_rank_names(unsigned dim) - { - std::vector names = stk_classic::mesh::fem::entity_rank_names(dim); -#if PERCEPT_USE_FAMILY_TREE - names.push_back("FAMILY_TREE"); -#endif -#if PERCEPT_USE_PSEUDO_ELEMENTS - names.push_back("PSEUDO_ELEMENT"); -#endif - return names; - } - - void SweepMesher::stkMeshCreateMetaNoCommit(stk_classic::ParallelMachine& comm) - { - //m_metaData = new stk_classic::mesh::fem::FEMMetaData(3); // stk_classic::mesh::fem::fem_entity_rank_names() ); // FAMILY_TREE search - m_metaData = new stk_classic::mesh::fem::FEMMetaData(3, get_entity_rank_names(3u) ); // stk_classic::mesh::fem::fem_entity_rank_names() ); - //m_metaData = & stk_classic::mesh::fem::FEMMetaData::get_meta_data(*m_metaData); - m_bulkData = new stk_classic::mesh::BulkData( stk_classic::mesh::fem::FEMMetaData::get_meta_data(*m_metaData) , comm ); - m_parts.resize(NUM_ELEM_TYPES); - - for (unsigned ieletype = 0; ieletype < NUM_ELEM_TYPES; ieletype++) - { - if (m_elems[ieletype].size() > 0) - { - m_parts[ieletype] = &(m_metaData->declare_part( std::string("block_").append(std::string(m_elemInfo[ieletype].name)) , m_metaData->element_rank() )); - } - } - m_coordinates_field = &m_metaData->declare_field< VectorFieldType >( "coordinates" ); - - m_element_node_coordinates_field = &m_metaData->declare_field< ElementNodePointerFieldType >( "elem_node_coord" ); - - // set cell topology - for (unsigned ieletype = 0; ieletype < NUM_ELEM_TYPES; ieletype++) - { - if (m_elems[ieletype].size() > 0) - { - m_elemInfo[ieletype].setCellTopoFptr(*m_parts[ieletype]); - stk_classic::io::put_io_part_attribute(*m_parts[ieletype]); - } - } - - // Field restrictions: - stk_classic::mesh::Part & universal = m_metaData->universal_part(); - - put_field( *m_coordinates_field , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal ); - - m_metaData->declare_field_relation( - *m_element_node_coordinates_field , - stk_classic::mesh::fem::get_element_node_stencil(3) , - *m_coordinates_field - ); - - for (unsigned ieletype = 0; ieletype < NUM_ELEM_TYPES; ieletype++) - { - if (m_elems[ieletype].size() > 0) - { -#if 0 - std::cout << "shards::Hexahedron<> ::node_count = " << shards::Hexahedron<> ::node_count - << " " << m_elemInfo[ieletype].node_count << std::endl; - std::cout << "shards::Wedge<> ::node_count = " << shards::Wedge<> ::node_count - << " " << m_elemInfo[ieletype].node_count << std::endl; -#endif - put_field( *m_element_node_coordinates_field, m_metaData->element_rank(), *m_parts[ieletype], m_elemInfo[ieletype].node_count); - } - } - } - - void SweepMesher::stkMeshCreateBulkAfterMetaCommit(stk_classic::ParallelMachine& comm) - { - - //stk_classic::mesh::BulkData & bulkData = modifiableBulkData(); - stk_classic::mesh::BulkData & bulkData = *m_bulkData; - bulkData.modification_begin(); - - stk_classic::mesh::EntityId elem_id = 1 ; - - for (unsigned ieletype = 0; ieletype < NUM_ELEM_TYPES; ieletype++) - { - if (m_elems[ieletype].size() > 0) - { - static stk_classic::mesh::EntityId node_ids[27]; // FIXME - do we have more than 27 nodes? - stk_classic::mesh::Part & part = *m_parts[ieletype]; - unsigned nodes_per_elem = m_elemInfo[ieletype].vertex_count; - unsigned numElems = m_elems[ieletype].size()/nodes_per_elem; - - //std::cout << " elems[" << m_elemInfo[ieletype].name << "] = " << numElems << std::endl; - - for (unsigned jelem = 0; jelem < numElems; jelem++, ++elem_id) - { - for (unsigned inode = 0; inode < m_elemInfo[ieletype].vertex_count; inode++) - { - node_ids[inode] = 1+m_elems[ieletype][jelem*m_elemInfo[ieletype].vertex_count + inode]; - } - - //std::cout << "elem_id = " << elem_id << std::endl; - stk_classic::mesh::fem::declare_element( bulkData , part , elem_id , node_ids ); - } - } - } - - unsigned node_count_1 = m_node_coords.size(); - for ( unsigned i = 0 ; i < node_count_1 ; ++i ) { - stk_classic::mesh::Entity * const node = m_bulkData->get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - double * const coord = field_data( *m_coordinates_field , *node ); - - coord[0] = m_node_coords[i][0]; - coord[1] = m_node_coords[i][1]; - coord[2] = m_node_coords[i][2]; - } - - bulkData.modification_end(); - } - - - void SweepMesher::dumpSTK() - { - const stk_classic::mesh::BulkData & bulkData = *m_bulkData; - - for (unsigned ieletype = 0; ieletype < NUM_ELEM_TYPES; ieletype++) - { - unsigned nodes_per_elem = m_elemInfo[ieletype].vertex_count; - if (m_elems[ieletype].size() > 0 && nodes_per_elem > 0) - { - //std::cout << nodes_per_elem << std::endl; - unsigned numElems = m_elems[ieletype].size()/nodes_per_elem; - - //std::cout << " elems[" << m_elemInfo[ieletype].name << "] = " << numElems << std::endl; - - stk_classic::mesh::Part & part = *m_parts[ieletype]; - - const unsigned expected_num_nodes = m_node_coords.size(); - const unsigned expected_num_elems = numElems; - //const unsigned expected_num_edges = 0; - // const unsigned expected_num_faces = 0; - - //bool result = true; - std::vector entity_counts; - stk_classic::mesh::Selector selector(part); - stk_classic::mesh::count_entities( selector, bulkData , entity_counts ); - if (0) std::cout << "num_nodes = " << entity_counts[0] << " " << expected_num_nodes << std::endl; - if (0) std::cout << "num_elems = " << entity_counts[m_metaData->element_rank()] << " " << expected_num_elems << std::endl; - - - if ( - //(entity_counts[stk_classic::mesh::fem::FEMMetaData::NODE_RANK] != expected_num_nodes) || - //(entity_counts[Edge] != expected_num_edges) || - //(entity_counts[Face] != expected_num_faces) || - (entity_counts[m_metaData->element_rank()] != expected_num_elems) - ) { - std::cerr<< "Error, the entity counts are incorrect!" << std::endl; - //result = false; - - } - } - } - - } - - void SweepMesher::writeSTKMesh(const char *filename) - { - //const std::string out_filename("tp2.e"); - const std::string out_filename(filename); - - std::vector< stk_classic::mesh::Part * > parts; - for (unsigned ielemType = 0; ielemType < NUM_ELEM_TYPES; ielemType++) - { - if (m_elems[ielemType].size()) - { - parts.push_back(m_parts[ielemType]); - } - } - - const stk_classic::ParallelMachine& comm = m_bulkData->parallel(); - - Ioss::Init::Initializer init_db; - stk_classic::io::MeshData mesh; - stk_classic::io::create_output_mesh(out_filename, comm, *m_bulkData, mesh); - } - - void SweepMesher::sweep(const VectorOfCoord& path, const VectorOfCoord& dir) - { - unsigned npoints = path.size(); - std::vector xforms(npoints-1); - for (unsigned i = 0; i < npoints-1; i++) - { - xforms[i] = new TransformPath(path[i], dir[i], path[i+1], dir[i+1]); - } - sweep(xforms); - for (unsigned i = 0; i < npoints-1; i++) - { - delete xforms[i]; - } - } - - - }//namespace percept -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.hpp deleted file mode 100644 index 1ab0cb1b6c03..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/SweepMesher.hpp +++ /dev/null @@ -1,600 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef stk_percept_mesh_gen_SweepMesher_hpp -#define stk_percept_mesh_gen_SweepMesher_hpp - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Tag1 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Tag2 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Tag3 ) - SHARDS_ARRAY_DIM_TAG_SIMPLE_DECLARATION( Tag4 ) - - -namespace stk_classic -{ - namespace percept - { - using namespace interface_table; - - using namespace util; - - - typedef stk_classic::mesh::Field VectorFieldType ; - typedef stk_classic::mesh::Field ScalarFieldType ; - typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - - template void push_back( std::vector& dst, const std::vector& src) - { - dst.insert(dst.end(), src.begin(), src.end()); - } - - typedef boost::array Coord; - typedef GeneralFunction< Coord, Coord > VectorFieldGeneralFunction; - class Transform : public VectorFieldGeneralFunction - { - public: - Transform() {}; - virtual Coord operator()(const Coord& x) - { - Coord y; - operator()(x, y); - return y; - } - - using VectorFieldGeneralFunction::operator(); - - virtual void operator()(const Coord& x, Coord& y) =0; - - }; - - class TransformDir : public Transform - { - Coord m_dir; - public: - TransformDir(Coord dir) : m_dir(dir) {} - using Transform::operator(); - - virtual Coord operator()(const Coord& x) - { - Coord y; - operator()(x, y); - return y; - } - virtual void operator()(const Coord& x, Coord& y) - { - y[0] = x[0] + m_dir[0]; - y[1] = x[1] + m_dir[1]; - y[2] = x[2] + m_dir[2]; - } - }; - - - // FIXME - use shards::Array - typedef std::vector< Coord > VectorOfCoord; - typedef std::vector VectorOfInt; - - //using namespace shards ; - - //typedef ArrayVector ArrayInt2 ; - - /** \class stk_classic::utils::SweepMesher - * \brief A simple utility to product tensor product (line, quad, hex) meshes by sweeping - * as well as non-tensor product mesh by breaking into sub-elements (tri, tet, wedge, pyramid) - * - * \author Steve Kennon, Brian Carnes, Kevin Copps - * - * Usage: initialize with a simple pair of node, element arrays, such as - * - * double coords[][3] = { - * {0,0,0}, {1,0,0}, {2,2,0}, {0,3,0}, - * {0,0,1}, {1,0,1}, {2,2,1}, {0,3,1} - * }; - * - * unsigned quad4Elems[] = { - * 0,1,2,3, - * 4,5,6,7 - * }; - * - * SweepMesher tp; - * tp.initNodes(coords, 8); - * tp.initElems(elemType, // one of enum's defined below - * quad4Elems, 2); - * - * Then use sweep to create a hex mesh (this example breaks a quad to create two Tri's, then creates a mixed hex/wedge mesh) - * - * boost::array< double, 3> dir = {0,0,1}; - * std::vector xforms(1, &TransformDir( dir ) ); - * - * // break one of the quads into tris - * unsigned quadElemIndex = 1; - * tp2.breakElem(quadElemIndex); - * std::cout << "after break\n"; - * tp2.dump(); - * - * // sweep to make a hex mesh - * boost::array< double, 3> dir1 = {0,0,2.345}; - * xforms[0] = &TransformDir(dir1); - * tp2.sweep( SweepMesher::ET_Quad4, SweepMesher::ET_Hex8, xforms); - * - * - */ - - class SweepMesher - { - //ATest m_atest; - const interface_table::elemInfoType *m_elemInfo; - - public: - - bool m_deleteAfterSweep; - bool m_deleteAfterBreak; - - /// only a few sweep types allowed so far; later could add quadratic sweeping - SweepMesher(unsigned spatialDim=3) : m_spatial_dimension(spatialDim) - //: m_deleteAfterSweep(1), m_deleteAfterBreak(1), m_metaData(0), m_bulkData(0) - { - //m_dump = false; - //m_elemInfo = ShardsInterfaceTable::s_elemInfo; - initialize(); - //m_atest.doIt(); - } - - ~SweepMesher() - { - delete m_metaData; - delete m_bulkData; - } - - void initialize() - { - m_deleteAfterSweep = 1; - m_deleteAfterBreak = 1; - m_metaData = 0; - m_bulkData = 0; - m_dump = false; - m_elemInfo = ShardsInterfaceTable::s_elemInfo; - } - - // allow public access for simplicity - FIXME - VectorOfCoord m_node_coords; // node pool - VectorOfInt m_elems[NUM_ELEM_TYPES]; - - void CopyFromBasicMesh(SweepMesher& source) - { - m_node_coords = source.m_node_coords; - for (unsigned i = 0; i < NUM_ELEM_TYPES; i++) - m_elems[i] = source.m_elems[i]; - } - - stk_classic::mesh::BulkData * get_bulk_data() { return m_bulkData;} - stk_classic::mesh::fem::FEMMetaData * getMetaData() { return m_metaData; } - - private: - bool m_dump; - unsigned m_spatial_dimension; - stk_classic::mesh::fem::FEMMetaData * m_metaData; - stk_classic::mesh::BulkData * m_bulkData; - std::vector m_parts; - stk_classic::mesh::Part *m_block_hex; - stk_classic::mesh::Part *m_block_wedge; - - VectorFieldType * m_coordinates_field; - // VectorFieldType & m_centroid_field; - // ScalarFieldType & m_temperature_field; - // ScalarFieldType & m_volume_field; - ElementNodePointerFieldType * m_element_node_coordinates_field; - - public: - - void initNodes(double coords[][3], unsigned numNodes) - { - //std::cout << "h1" << std::endl; - m_node_coords.clear(); - //m_node_coords.assign(coords, coords+numNodes); - for (unsigned i = 0; i < numNodes; i++) - { - Coord x; - x[0] = coords[i][0]; - x[1] = coords[i][1]; - x[2] = coords[i][2]; - m_node_coords.push_back(x); - } - } - - void initNodes(Coord coords[], unsigned numNodes) - { - //std::cout << "h2" << std::endl; - m_node_coords.clear(); - m_node_coords.assign(coords, coords+numNodes); - } - - void initElems(unsigned elemType, unsigned indices[], unsigned numElem) - { - //std::cout << "h3" << std::endl; - m_elems[elemType].clear(); - m_elems[elemType].assign(indices, indices+numElem*m_elemInfo[elemType].vertex_count); - } - - - - private: - void transform(VectorOfCoord& oldNodes, VectorOfCoord& newNodes, Transform& xform) - { - // xform.do( on each node) - for(unsigned i = 0; i < oldNodes.size(); i++) - { -#if defined(__IBMCPP__) - xform.operator()(oldNodes[i], newNodes[i]); -#else - xform(oldNodes[i], newNodes[i]); -#endif - } - } - - void cloneNodes(VectorOfCoord& oldNodes, VectorOfCoord& newNodes, Transform& xform) - { - //unsigned nnodes = oldNodes.size(); - newNodes = oldNodes; // deep copy - transform(oldNodes, newNodes, xform); - } - - void cloneElems(VectorOfCoord& oldNodes, VectorOfInt& oldElems, VectorOfInt& newElems) - { - unsigned nnodes = oldNodes.size(); - newElems = oldElems; - for (unsigned i = 0; i < oldElems.size(); i++) - { - newElems[i] += nnodes; - } - } - - void sweep(unsigned elemType, unsigned sweptElemType, - VectorOfCoord& oldNodes, VectorOfInt& oldElems, VectorOfCoord& newNodes, VectorOfInt& newElems, VectorOfInt& newSweptElems) - { - // for now we assume all elems are "vertex only", i.e. only linears, so we can just double the nodes and tack on the end - // special cases: line to quad: have to reverse the nodes - newSweptElems.clear(); - // this would be a lot easier with a multi-d array - FIXME - unsigned nodes_per_elem = m_elemInfo[elemType].vertex_count; - unsigned numElems = oldElems.size()/nodes_per_elem; - //unsigned numSweptElems = numElems; - - for (unsigned iel = 0; iel < numElems; iel++) - { - unsigned *newElemI = &newElems[iel*nodes_per_elem]; - unsigned *oldElemI = &oldElems[iel*nodes_per_elem]; - VectorOfInt newElem(newElemI, newElemI+nodes_per_elem); - VectorOfInt oldElem(oldElemI, oldElemI+nodes_per_elem); - if (elemType == shards_Line_2) - { - newElem = VectorOfInt(newElem.rbegin(), newElem.rend()); - } - push_back(newSweptElems, oldElem); - push_back(newSweptElems, newElem); - } - } - - public: - - // for a single element type - void sweep(unsigned elemType, unsigned sweptElemType, std::vector xforms) - { - //void sweep(std::vector elemTypes, std::vector sweptElemTypes, std::vector xforms) - sweep(VectorOfInt(1, elemType), VectorOfInt(1, sweptElemType), xforms); - } - - - /// for a specified group of element types in the mesh at once - void sweep(VectorOfInt elemTypes, VectorOfInt sweptElemTypes, std::vector xforms) - { - unsigned nlevels = xforms.size(); - - //assert(2*m_elemInfo[elemType].vertex_count == m_elemInfo[sweptElemType].vertex_count); - - // setup arrays - unsigned neleType = elemTypes.size(); - std::vector voldElems(neleType); - std::vector vnewElems(neleType); - - // a bit of overkill here, but leaving open the possibility of more complex heterogeneous meshes with e.g. linear and quadratics - for (unsigned ieleType = 0; ieleType < elemTypes.size(); ieleType++) - { - unsigned elemType = elemTypes[ieleType]; - //unsigned sweptElemType = sweptElemTypes[ieleType]; - - voldElems[ieleType] = m_elems[elemType]; - vnewElems[ieleType] = m_elems[elemType]; - } - - VectorOfCoord oldNodes = m_node_coords; - VectorOfCoord newNodes = oldNodes; - VectorOfInt newSweptElems; - - for (unsigned ilev = 0; ilev < nlevels; ilev++) - { - //clone(oldNodes, oldElems, newNodes, newElems, *xforms[ilev]); - cloneNodes(oldNodes, newNodes, *xforms[ilev]); - - for (unsigned ieleType = 0; ieleType < elemTypes.size(); ieleType++) - { - unsigned elemType = elemTypes[ieleType]; - unsigned sweptElemType = sweptElemTypes[ieleType]; - - cloneElems(oldNodes, voldElems[ieleType], vnewElems[ieleType]); - sweep(elemType, sweptElemType, oldNodes, voldElems[ieleType], newNodes, vnewElems[ieleType], newSweptElems); - push_back(m_elems[sweptElemType], newSweptElems); - voldElems[ieleType] = vnewElems[ieleType]; - } - - oldNodes = newNodes; - push_back(m_node_coords, newNodes); - } - if (m_deleteAfterSweep) - { - for (unsigned ieleType = 0; ieleType < elemTypes.size(); ieleType++) - { - unsigned elemType = elemTypes[ieleType]; - m_elems[elemType].clear(); - } - } - }; - - /// for all element types in the mesh at once - void sweep( std::vector xforms) - { - VectorOfInt elemTypes; - VectorOfInt sweptElemTypes; - for (unsigned i = 0; i < NUM_ELEM_TYPES; i++) - { - if (m_elems[i].size() > 0) - { - elemTypes.push_back(m_elemInfo[i].elemEnumType); - sweptElemTypes.push_back(m_elemInfo[i].sweptElemType); - } - } - sweep(elemTypes, sweptElemTypes, xforms); - } - - /// for all element types in the mesh at once - path following - void sweep(const double path[][3], unsigned npts) - { - VectorOfCoord vpath; - for (unsigned i = 0; i < npts; i++) - { - const Coord &pt = *reinterpret_cast(path[i]); - vpath.push_back(pt); - } - sweep(vpath); - } - - void sweep(const VectorOfCoord& path) - { - unsigned npoints = path.size(); - std::vector xforms(npoints-1); - for (unsigned i = 0; i < npoints-1; i++) - { - boost::array< double, 3> dir; - dir[0] = path[i+1][0]-path[i][0]; - dir[1] = path[i+1][1]-path[i][1]; - dir[2] = path[i+1][2]-path[i][2]; - - xforms[i] = new TransformDir(dir); - } - sweep(xforms); - - for (unsigned i = 0; i < npoints-1; i++) - { - delete xforms[i]; - } - } - - void sweep(const VectorOfCoord& path, const VectorOfCoord& dir); - - /// apply a single transformation to all nodes' coordinates - void transform(Transform& xform) - { - for (unsigned i = 0; i < m_node_coords.size(); i++) - { - Coord y; - xform.operator()(m_node_coords[i], y); - m_node_coords[i] = y; - } - } - - void squareMesh(unsigned nx, unsigned ny, double xlength, double ylength, double xorigin=0.0, double yorigin=0.0) - { - for (unsigned iy = 0; iy < ny; iy++) - { - double y = yorigin + ylength*((double)iy)/((double)(ny-1)); - for (unsigned ix = 0; ix < nx; ix++) - { - double x = xorigin + xlength*((double)ix)/((double)(nx-1)); - Coord pt = {{x, y, 0}}; - m_node_coords.push_back(pt); - } - } - for (unsigned iye = 0; iye < ny-1; iye++) - { - for (unsigned ixe = 0; ixe < nx-1; ixe++) - { - unsigned nodexy = ixe + iye*nx; - unsigned nodexpy = ixe+1 + iye*nx; - unsigned nodexpyp = ixe+1 + (iye+1)*nx; - unsigned nodexyp = ixe + (iye+1)*nx; - - m_elems[shards_Quadrilateral_4].push_back(nodexy); - m_elems[shards_Quadrilateral_4].push_back(nodexpy); - m_elems[shards_Quadrilateral_4].push_back(nodexpyp); - m_elems[shards_Quadrilateral_4].push_back(nodexyp); - - } - } - } - - void cubeMesh(unsigned nx, unsigned ny, unsigned nz, double xlength, double ylength, double zlength, - double xorigin=0.0, double yorigin=0.0, double zorigin=0.0) - { - for (unsigned iz = 0; iz < nz; iz++) - { - double z = zorigin + zlength*((double)iz)/((double)(nz-1)); - - for (unsigned iy = 0; iy < ny; iy++) - { - double y = yorigin + ylength*((double)iy)/((double)(ny-1)); - for (unsigned ix = 0; ix < nx; ix++) - { - double x = xorigin + xlength*((double)ix)/((double)(nx-1)); - Coord pt = {{x, y, z}}; - m_node_coords.push_back(pt); - } - } - } - for (unsigned ize = 0; ize < nz-1; ize++) - { - for (unsigned iye = 0; iye < ny-1; iye++) - { - for (unsigned ixe = 0; ixe < nx-1; ixe++) - { - unsigned nodexy = ixe + iye*nx + ize*nx*ny; - unsigned nodexpy = ixe+1 + iye*nx + ize*nx*ny; - unsigned nodexpyp = ixe+1 + (iye+1)*nx + ize*nx*ny; - unsigned nodexyp = ixe + (iye+1)*nx + ize*nx*ny; - unsigned nodexyzp = ixe + iye*nx + (ize+1)*nx*ny; - unsigned nodexpyzp = ixe+1 + iye*nx + (ize+1)*nx*ny; - unsigned nodexpypzp = ixe+1 + (iye+1)*nx + (ize+1)*nx*ny; - unsigned nodexypzp = ixe + (iye+1)*nx + (ize+1)*nx*ny; - - m_elems[shards_Hexahedron_8].push_back(nodexy); - m_elems[shards_Hexahedron_8].push_back(nodexpy); - m_elems[shards_Hexahedron_8].push_back(nodexpyp); - m_elems[shards_Hexahedron_8].push_back(nodexyp); - m_elems[shards_Hexahedron_8].push_back(nodexyzp); - m_elems[shards_Hexahedron_8].push_back(nodexpyzp); - m_elems[shards_Hexahedron_8].push_back(nodexpypzp); - m_elems[shards_Hexahedron_8].push_back(nodexypzp); - } - } - } - } - - void debug(const char* str) - { - std::cout << " debug: " << str << std::endl; - std::cout.flush(); - } - void debug(const char* str, const int i) - { - std::cout << " debug: " << str << " " << i << std::endl; - std::cout.flush(); - } - - template void breakElement(unsigned elemIndex); - - template void breakAllElements() - { - //debug("breakAllElements"); - unsigned numElems = m_elems[fromType].size()/m_elemInfo[fromType].vertex_count; - if (0) debug("numElems: ", numElems); - unsigned numElemsTo = m_elems[toType].size()/m_elemInfo[toType].vertex_count; - if (0) debug("numElemsTo: ", numElemsTo); - bool deleteAfterBreak = m_deleteAfterBreak; - m_deleteAfterBreak = false; - for (unsigned elemIndex = 0; elemIndex < numElems; elemIndex++) - { - breakElement ( elemIndex); - } - m_deleteAfterBreak = deleteAfterBreak; - if (m_deleteAfterBreak) - { - m_elems[fromType].clear(); - } - } - - - void dumpSTK(); - - void dump(bool onOff) { m_dump= onOff; } - void dump() - { - if (!m_dump) return; - std::cout << "\ndump::\n"; - - for (unsigned i = 0; i < m_node_coords.size(); i++) - { - std::cout << "node: " << i << " = {" << m_node_coords[i][0] << " " << m_node_coords[i][1] << " " << m_node_coords[i][2] << "}" << std::endl; - } - for (unsigned i = 0; i < NUM_ELEM_TYPES; i++) - { - if (m_elems[i].size() > 0) - { - //std::cout << "h4 " << i << std::endl; - std::cout.flush(); - unsigned nodes_per_elem = m_elemInfo[i].vertex_count; - unsigned numElems = m_elems[i].size()/nodes_per_elem; - std::cout << "elem[" << m_elemInfo[i].name << "]: num= " << numElems << std::endl; - unsigned counter=0; - for (unsigned iel = 0; iel < numElems; iel++) - { - std::cout << " { "; - for (unsigned j = 0; j < nodes_per_elem; j++) - { - std::cout << m_elems[i][counter++] << " "; - std::cout.flush(); - } - std::cout << " }\n"; - } - std::cout.flush(); - } - } - } - - - /// create a std::mesh representation of this - void stkMeshCreate(stk_classic::ParallelMachine& ); - - void stkMeshCreateMetaNoCommit(stk_classic::ParallelMachine& ); - void stkMeshCreateBulkAfterMetaCommit(stk_classic::ParallelMachine& ); - - void writeSTKMesh(const char* filename); - - - }; - - - }//namespace percept -}//namespace stk_classic - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/TransformPath.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/TransformPath.hpp deleted file mode 100644 index 8832b3f50754..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/gen/TransformPath.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef stk_percept_mesh_gen_TransformPath_hpp -#define stk_percept_mesh_gen_TransformPath_hpp - -#include "SweepMesher.hpp" -#include - -namespace stk_classic -{ - namespace percept - { - namespace util - { - - class TransformPath : public Transform - { - typedef boost::array Coord; - Coord m_from; - Coord m_from_dir; - Coord m_to; - Coord m_to_dir; - Coord m_rotation_axis; - Coord m_rotation_origin; - double m_theta; - Coord m_diff; - - void normalize(Coord& vec) - { - double norm = std::sqrt(vec[0]*vec[0]+ - vec[1]*vec[1]+ - vec[2]*vec[2]); - vec[0] /= norm; - vec[1] /= norm; - vec[2] /= norm; - } - void cross(const Coord& a, const Coord& b, Coord& axb) - { - axb[0] = (a[1]*b[2]-a[2]*b[1]); - axb[1] = -(a[0]*b[2]-a[2]*b[0]); - axb[2] = (a[0]*b[1]-a[1]*b[0]); - } - - // from http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/ArbitraryAxisRotation.html - void rotatePointAboutAxis(const Coord& rotation_axis, const Coord& rotation_origin, const Coord& point_to_rotate, const double angleInRadians, - Coord& rotated_point) - { - double a = rotation_origin[0], b= rotation_origin[1], c= rotation_origin[2]; - double u = rotation_axis[0], v= rotation_axis[1], w= rotation_axis[2]; - double x = point_to_rotate[0], y = point_to_rotate[1], z = point_to_rotate[2]; - double cosAngle = std::cos(angleInRadians); - double sinAngle = std::sin(angleInRadians); - double u2 = u*u; - double v2 = v*v; - double w2 = w*w; - double l2 = u2 + v2 + w2; - double l = sqrt(l2); - rotated_point[0] = (a*(v2 + w2) + u*(-b*v - c*w + u*x + v*y + w*z) - + (-a*(v2 + w2) + u*(b*v + c*w - v*y - w*z) + (v2 + w2)*x)*cosAngle - + l*(-c*v + b*w - w*y + v*z)*sinAngle)/l2; - rotated_point[1] = (b*(u2 + w2) + v*(-a*u - c*w + u*x + v*y + w*z) - + (-b*(u2 + w2) + v*(a*u + c*w - u*x - w*z) + (u2 + w2)*y)*cosAngle - + l*(c*u - a*w + w*x - u*z)*sinAngle)/l2; - rotated_point[2] = (c*(u2 + v2) + w*(-a*u - b*v + u*x + v*y + w*z) - + (-c*(u2 + v2) + w*(a*u + b*v - u*x - v*y) + (u2 + v2)*z)*cosAngle - + l*(-b*u + a*v - v*x + u*y)*sinAngle)/l2; - - } - void rotatePointAboutAxis(const Coord& point_to_rotate, Coord& rotated_point) - { - rotatePointAboutAxis(m_rotation_axis, m_rotation_origin, point_to_rotate, m_theta, rotated_point); - } - - - public: - - /// Given some points on a plane ("from"), we want to move them to a new plane by rotation and translation - /// The initial plane is defined by an origin ([in] from), and it's normal ([in] from_dir). - /// The final plane is defined by origin/normal: [in] to, to_dir - /// The translation delta is just the vector {to - from}. - /// The algorithm rotates the points in the initial plane to the new plane's direction, then does the translate. - /// Note that the points on the initial plane don't have to lie in a plane, just easier to visualize that way. - TransformPath(const Coord& from, const Coord& from_dir, - const Coord& to, const Coord& to_dir) : m_from(from), m_from_dir(from_dir), - m_to(to) , m_to_dir(to_dir) - { - m_diff[0] = m_to[0]-m_from[0]; - m_diff[1] = m_to[1]-m_from[1]; - m_diff[2] = m_to[2]-m_from[2]; - - // normalize - normalize(m_from_dir); - normalize(m_to_dir); - // angle between the two direction vectors - m_theta = acos(m_from_dir[0]*m_to_dir[0]+ - m_from_dir[1]*m_to_dir[1]+ - m_from_dir[2]*m_to_dir[2]); - //std::cout<< "m_theta= " << m_theta << std::endl; - - cross(m_from_dir, m_to_dir, m_rotation_axis); - m_rotation_origin = m_from; - } - - using Transform::operator(); - virtual Coord operator()(const Coord& x) - { - Coord y; - operator()(x, y); - return y; - } - virtual void operator()(const Coord& x, Coord& y) - { - rotatePointAboutAxis(x, y); - y[0] += m_diff[0]; - y[1] += m_diff[1]; - y[2] += m_diff[2]; - } - }; - - }//namespace utils - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.cpp deleted file mode 100644 index b5e21ca1dd02..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "GeometryFactory.hpp" -#include -#include - -using namespace stk_classic; -using namespace mesh; -using namespace percept; - -GeometryFactory::GeometryFactory(GeometryKernel* kernel, MeshGeometry* geometry) -{ - geomKernel = kernel; - geomDatabase = geometry; -} - -GeometryFactory::~GeometryFactory() -{ -#if 1 - const std::vector& evaluators = geomDatabase->getGeomEvaluators(); - for (unsigned i = 0; i < evaluators.size(); i++) - { - delete evaluators[i]; - } -#endif -} - -bool GeometryFactory::read_file(const std::string& filename, PerceptMesh* mesh_data) -{ - std::vector geometry_entities; - if (!geomKernel->read_file(filename, geometry_entities)) - return false; - for (size_t i=0; iget_attribute(geometry_entities[i]); - Part* part = mesh_data->get_non_const_part(str); -#if DEBUG_GEOM_SNAP - std::cout << "tmp geom part = " << str << " lookup= " << part << std::endl; -#endif - if (part) - { - GeometryEvaluator* eval = new GeometryEvaluator(part); - eval->mGeometry = geometry_entities[i]; - //eval->mGeometry = i; - geomDatabase->add_evaluator(eval); - } - } - return true; -} diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.hpp deleted file mode 100644 index 4a1bb44ae8bb..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryFactory.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GEOMETRYFACTORY_HPP -#define GEOMETRYFACTORY_HPP - -#include -#include "GeometryKernel.hpp" -#include "MeshGeometry.hpp" -#include -using namespace stk_classic; -using namespace mesh; -using namespace percept; - -class GeometryFactory -{ -public: - GeometryFactory(GeometryKernel* kernel, MeshGeometry* geometry); - ~GeometryFactory(); - - bool read_file(const std::string& filename, PerceptMesh* mesh); - -protected: - GeometryKernel* geomKernel; - MeshGeometry* geomDatabase; -}; - -#endif // GEOMETRYFACTORY_HPP diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernel.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernel.hpp deleted file mode 100644 index 775ea0d72372..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernel.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef GEOMETRYKERNEL_HPP -#define GEOMETRYKERNEL_HPP - -#include -#include - -typedef double* KernelPoint; -typedef int GeometryHandle; - -class GeometryKernel -{ -public: - GeometryKernel() {} - virtual ~GeometryKernel() {}; - - virtual bool read_file(const std::string& file_name, - std::vector& geometry_entities ) = 0; - - virtual std::string get_attribute(GeometryHandle geom) = 0; - - virtual void snap_to(KernelPoint& point, GeometryHandle geom, - double *converged_tolerance = NULL, - double *uvw_computed = NULL, - double *uvw_hint = NULL) = 0; - - virtual void normal_at(KernelPoint& point, GeometryHandle geom, std::vector& normal) = 0; - - virtual bool is_curve(GeometryHandle geom) const = 0; - - virtual bool is_surface(GeometryHandle geom) const = 0; - -}; - -#endif // GEOMETRYKERNEL_HPP diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.cpp deleted file mode 100644 index b4d1eb7e3f54..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include -#include - -#include "GeometryKernelOpenNURBS.hpp" -#include - -#define DEBUG_GEOM_ON 0 - -GeometryKernelOpenNURBS::GeometryKernelOpenNURBS() -{ - ON::Begin(); -} - -GeometryKernelOpenNURBS::~GeometryKernelOpenNURBS() -{ - ON::End(); -} - -bool GeometryKernelOpenNURBS::read_file -( - const std::string& file_name, - std::vector& geometry_entities -) -{ - FILE* archive_fp = ON::OpenFile( file_name.c_str(), "rb"); - if ( !archive_fp ) - { - return false; - } - - ON_BinaryFile archive( ON::read3dm, archive_fp ); - - // read the contents of the file into "model" - bool rc = onModel.Read( archive ); - - // close the file - ON::CloseFile( archive_fp ); - - if ( !onModel.IsValid() ) - return false; - -#if DEBUG_GEOM_ON - std::cout << "tmp geom onModel.m_object_table.Count() = " << onModel.m_object_table.Count() << std::endl; - for (int i=0; i(onModel.m_object_table[geom].m_object); - const ON_Curve* curve = dynamic_cast(onModel.m_object_table[geom].m_object); - if (surface) - { - ON_3dPoint p(point); - double u, v; - - surface->GetClosestPoint(p, &u, &v, 0.0, NULL, NULL, converged_tolerance, uvw_computed); - if(uvw_computed) - { - uvw_computed[0] = u; - uvw_computed[1] = v; - } - surface->EvPoint(u, v, p); - point[0] = p.x; - point[1] = p.y; - point[2] = p.z; - } - else if (curve) - { - ON_3dPoint p(point); - double u; - - curve->GetClosestPoint(p, &u); - curve->EvPoint(u, p); - point[0] = p.x; - point[1] = p.y; - point[2] = p.z; - } -} - -void GeometryKernelOpenNURBS::normal_at(KernelPoint& point, GeometryHandle geom, std::vector& normal) -{ - const ON_Surface* surface = dynamic_cast(onModel.m_object_table[geom].m_object); - const ON_Curve* curve = dynamic_cast(onModel.m_object_table[geom].m_object); - if (surface) - { - ON_3dPoint p(point); - double u, v; - - surface->GetClosestPoint(p, &u, &v); - //surface->EvPoint(u, v, p); - ON_3dVector norm; - surface->EvNormal(u, v, norm); - normal[0] = norm[0]; - normal[1] = norm[1]; - normal[2] = norm[2]; - } - else if (curve) - { - ON_3dPoint p(point); - double u; - - curve->GetClosestPoint(p, &u); - //curve->EvPoint(u, p); - ON_3dVector tangent; - ON_3dVector kappa; - //curve->EvTangent(u, p, tangent); - curve->EvCurvature(u, p, tangent, kappa); - - // FIXME - normal[0] = kappa[0]; - normal[1] = kappa[1]; - normal[2] = kappa[2]; - } -} - -bool GeometryKernelOpenNURBS::is_curve -( - GeometryHandle geom -) const -{ - const ON_Curve* curve = dynamic_cast(onModel.m_object_table[geom].m_object); - return curve ? true : false; -} - -bool GeometryKernelOpenNURBS::is_surface -( - GeometryHandle geom -) const -{ - const ON_Surface* surface = dynamic_cast(onModel.m_object_table[geom].m_object); - return surface ? true : false; -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.hpp deleted file mode 100644 index 546bebcb1b10..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelOpenNURBS.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef GEOMETRYKERNEL_OPENNURBS_HPP -#define GEOMETRYKERNEL_OPENNURBS_HPP - -//#include -#include -#include "GeometryKernel.hpp" - -class GeometryKernelOpenNURBS : public GeometryKernel -{ -public: - GeometryKernelOpenNURBS(); - virtual ~GeometryKernelOpenNURBS(); - - virtual bool read_file(const std::string& file_name, - std::vector& geometry_entities); - - virtual std::string get_attribute(GeometryHandle geom); - - virtual void snap_to(KernelPoint& point, GeometryHandle geom, - double *converged_tolerance = NULL, - double *uvw_computed = NULL, - double *uvw_hint = NULL); - virtual void normal_at(KernelPoint& point, GeometryHandle geom, std::vector& normal); - - virtual bool is_curve(GeometryHandle geom) const; - - virtual bool is_surface(GeometryHandle geom) const; - -private: - ONX_Model onModel; -}; - -#endif // GEOMETRYKERNEL_OPENNURBS_HPP diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelStupid.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelStupid.hpp deleted file mode 100644 index 5a19a8a5ab47..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/GeometryKernelStupid.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef GEOMETRYKERNELSTUPID_HPP -#define GEOMETRYKERNELSTUPID_HPP - -#include "GeometryKernel.hpp" -#include -#include - -class GeometryKernelStupid : public GeometryKernel -{ -public: - GeometryKernelStupid() : GeometryKernel() {} - virtual ~GeometryKernelStupid() {} - - virtual bool read_file(const std::string& file_name, - std::vector& geometry_entities) - { - std::ifstream file (file_name.c_str()); - if (!file.is_open()) - return false; - int i=1; - while (!file.eof()) - { - geometry_entities.push_back(i); - char string[256]; - file.getline(string, 255); - geometryAttribute[i]=string; - i++; - } - return true; - } - - virtual std::string get_attribute(GeometryHandle geom) - { - return geometryAttribute[geom]; - } - - virtual void snap_to(KernelPoint& point, GeometryHandle geom) - { } - - virtual void normal_at(KernelPoint& point, GeometryHandle geom, std::vector& normal) {} - - virtual bool is_curve(GeometryHandle geom) const - { - return true; - } - - virtual bool is_surface(GeometryHandle geom) const - { - return true; - } - -private: - std::map geometryAttribute; -}; - -#endif // GEOMETRYKERNELSTUPID_HPP diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.cpp deleted file mode 100644 index 92fa241b226b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.cpp +++ /dev/null @@ -1,602 +0,0 @@ -#include "MeshGeometry.hpp" -#include - -MeshGeometry::MeshGeometry(GeometryKernel* geom, double doCheckMovement, double doCheckCPUTime, bool cache_classify_bucket_is_active, bool doPrint) - : m_doCheckMovement(doCheckMovement), m_checkCPUTime(doCheckCPUTime), m_cache_classify_bucket_is_active(cache_classify_bucket_is_active), m_doPrint(doPrint), - m_type(-1) -{ - geomKernel = geom; - mDbgNodeCoords[0] = -0.00477133907617983; - mDbgNodeCoords[1] = -0.00477133907617983; - mDbgNodeCoords[2] = 0.260484055257467; - - mDbgNodeCoords[0] = 183.049; - mDbgNodeCoords[1] = 174.609; - mDbgNodeCoords[2] = 27.2434; - //big cpu = 0.462929 coords_0 = 5.60577 1.48796 19.3677 delta= -0.0963596 -0.0259963 0.00280205 coords_1= 5.50941 1.46197 19.3705 deltaMag= 0.099844 block= TOPOLOGY_SURFACE_BLOCK_20387 - - mDbgNodeCoords[0] = 5.60577; - mDbgNodeCoords[1] = 1.48796; - mDbgNodeCoords[2] = 19.3677; - -} - -MeshGeometry::~MeshGeometry() -{ - -} - -void MeshGeometry::add_evaluator(GeometryEvaluator* evaluator) -{ - geomEvaluators.push_back(evaluator); -} - -void MeshGeometry::add_evaluators(std::vector evaluators) -{ - geomEvaluators.insert(geomEvaluators.end(), evaluators.begin(), evaluators.end()); - // std::for_each( evaluators.begin(), - // evaluators.end(), - // std::mem_fun( &MeshGeometry::add_evaluator ) ); -} - -const std::vector& MeshGeometry::getGeomEvaluators() -{ - return geomEvaluators; -} - -/** - * Return 0,1,2,3 if the node is on a geometry vertex, curve, surface or domain. - */ -int MeshGeometry::classify_node(const stk_classic::mesh::Entity& node, size_t& curveOrSurfaceEvaluator) -{ - const stk_classic::mesh::Bucket& bucket = node.bucket(); - return classify_bucket(bucket, curveOrSurfaceEvaluator); -} - -/** - * Return 0,1,2,3 if the bucket is on a geometry vertex, curve, surface or domain. - */ -int MeshGeometry::classify_bucket(const stk_classic::mesh::Bucket& bucket, size_t& curveOrSurfaceEvaluator) -{ - int classify_value = 0; - if (m_cache_classify_bucket_is_active) - { - CacheBucketClassifyType::iterator iter = m_cache_bucket_classify.find(&bucket); - if (iter == m_cache_bucket_classify.end()) - { - classify_value = classify_bucket_internal(bucket, curveOrSurfaceEvaluator); - m_cache_bucket_classify[&bucket] = CacheBucketClassifyValueType(classify_value, curveOrSurfaceEvaluator); - } - else - { - CacheBucketClassifyValueType& val = iter->second; - classify_value = val.first; - curveOrSurfaceEvaluator = val.second; - bool debug=false; - if (debug) - { - size_t t; - int cv=classify_bucket_internal(bucket, t); - if (cv != classify_value || t != curveOrSurfaceEvaluator) - { - std::cout << "cv = " << cv << " classify_value= " << classify_value << " t= " << t << " curveOrSurfaceEvaluator= " << curveOrSurfaceEvaluator << std::endl; - exit(123); - } - } - } - } - else - { - classify_value = classify_bucket_internal(bucket, curveOrSurfaceEvaluator); - } - m_type = classify_value; - return classify_value; -} - -/** - * Return 0,1,2,3 if the bucket is on a geometry vertex, curve, surface or domain. - */ -int MeshGeometry::classify_bucket_internal(const stk_classic::mesh::Bucket& bucket, size_t& curveOrSurfaceEvaluator) -{ - // Each bucket contains the set of nodes with unique part intersections. - // This means that every nodes will be in exactly one bucket. But, the - // nodes on curves are also in the part for the adjacent surfaces which - // means more than one evaluator will be selected for those buckets which - // are on the boundary of an entity (i.e. buckets representing curves - // and vertices). We first create a list of all the evaluators that - // might be relevant. - - static std::vector curveEvaluators(0); - static std::vector surfEvaluators(0); - curveEvaluators.resize(0); - surfEvaluators.resize(0); - - size_t s; - for (s=0; smMesh(bucket); - if (selector_has_bucket) - { - //if (geomKernel->is_curve(s)) - if (geomKernel->is_curve(geomEvaluators[s]->mGeometry)) - { - curveEvaluators.push_back(s); - } - //else if (geomKernel->is_surface(s)) - else if (geomKernel->is_surface(geomEvaluators[s]->mGeometry)) - { - surfEvaluators.push_back(s); - } - } - } - - curveOrSurfaceEvaluator = 0; - if ( curveEvaluators.size() > 1 ) - { - // This is a bucket representing a vertex. No need to do anything - // since the node will already be on the vertex, and no new nodes - // ever get created assigned to vertices during refinement. - //std::cout << "Vertex node encountered" << std::endl; - curveOrSurfaceEvaluator = 0; - return 0; - } - if ( curveEvaluators.size() == 1 ) - { - // This bucket represents a geometric curve. Snap to it. - //std::cout << "Snapping to curve" << curveEvaluators[0] << std::endl; - //snap_nodes( eMesh, bucket, curveEvaluators[0] ); - curveOrSurfaceEvaluator = curveEvaluators[0]; - return 1; - } - - if ( surfEvaluators.size() == 1 ) - { - //std::cout << "Snapping to surface" << surfEvaluators[0] << std::endl; - // This bucket represents a geometric surface. Snap to it. - //snap_nodes( eMesh, bucket, surfEvaluators[0] ); - curveOrSurfaceEvaluator = surfEvaluators[0]; - return 2; - } - return -1; // error condition, or it is an interior node -} - -void MeshGeometry::snap_points_to_geometry(PerceptMesh* eMesh) -{ - BulkData& bulkData = *eMesh->get_bulk_data(); - - // Get all of the nodes. - std::vector nodes; - stk_classic::mesh::get_entities(bulkData, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodes); - - VectorFieldType* coordField = eMesh->get_coordinates_field(); - - // Loop through all of the nodes and choose the "best" projection. - for(int i=nodes.size()-1; i>-1; i--) - { - Entity *cur_node = nodes[i]; - Bucket &node_bucket = cur_node->bucket(); - std::vector evaluators, curve_evals, surf_evals; - size_t s; - for (s=0; smMesh(node_bucket)) - { - if(geomKernel->is_curve(geomEvaluators[s]->mGeometry)) - curve_evals.push_back(s); - else if(geomKernel->is_surface(geomEvaluators[s]->mGeometry)) - surf_evals.push_back(s); - } - } - // favor lower order evaluators if they exist - if(surf_evals.size() > 0) - evaluators = surf_evals; - if(curve_evals.size() > 0) - evaluators = curve_evals; - - // If we have more than one evaluator we will project to each and - // keep the best one. - if(evaluators.size() > 1) - { - double * coords = stk_classic::mesh::field_data(*coordField , *cur_node); - double orig_pos[3] = {coords[0], coords[1], coords[2]}; - double smallest_dist_sq = 9999999.9; - double best_pos[3] = {0,0,0}; - for(s=0; s 0) - snap_node(eMesh, *cur_node, evaluators[0]); - } - -#if 0 - BulkData& bulkData = *eMesh->get_bulk_data(); - const std::vector & buckets = bulkData.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - Bucket& bucket = **k; -#define CONTAINS_DEBUG_NODE 0 -#if CONTAINS_DEBUG_NODE - if ( contains_dbg_node( eMesh, bucket ) ) - { - std::cout << " DBG Node FOUND" << std::endl; - } -#endif - - size_t curveOrSurfaceEvaluator; - int type = classify_bucket(bucket, curveOrSurfaceEvaluator); - switch (type) { - case 0: - // This is a bucket representing a vertex. No need to do anything - // since the node will already be on the vertex, and no new nodes - // ever get created assigned to vertices during refinement. - //std::cout << "Vertex node encountered" << std::endl; - break; - case 1: - // This bucket represents a geometric curve. Snap to it. - //std::cout << "Snapping to curve" << curveEvaluators[0] << std::endl; - snap_nodes( eMesh, bucket, curveOrSurfaceEvaluator ); - break; - case 2: - //std::cout << "Snapping to surface" << surfEvaluators[0] << std::endl; - // This bucket represents a geometric surface. Snap to it. - snap_nodes( eMesh, bucket, curveOrSurfaceEvaluator ); - break; - case -1: - default: - //printf( "ERROR: A bucket found without a geometric evaluator.\n" ); - break; - } - } -#endif -} - -void MeshGeometry::normal_at(PerceptMesh* eMesh, stk_classic::mesh::Entity * node, std::vector& normal) -{ - { - Bucket& bucket = node->bucket(); - - // Each bucket contains the set of nodes with unique part intersections. - // This means that every nodes will be in exactly one bucket. But, the - // nodes on curves are also in the part for the adjacent surfaces which - // means more than one evaluator will be selected for those buckets which - // are on the boundary of an entity (i.e. buckets representing curves - // and vertices). We first create a list of all the evaluators that - // might be relevant. - - size_t curveOrSurfaceEvaluator; - int type = classify_bucket(bucket, curveOrSurfaceEvaluator); - switch (type) { - case 0: - // This is a bucket representing a vertex. No need to do anything - // since the node will already be on the vertex, and no new nodes - // ever get created assigned to vertices during refinement. - //std::cout << "Vertex node encountered" << std::endl; - break; - case 1: - // This bucket represents a geometric curve. Snap to it. - //std::cout << "Snapping to curve" << curveEvaluators[0] << std::endl; - normal_at( eMesh, *node, curveOrSurfaceEvaluator, normal ); - break; - case 2: - //std::cout << "Snapping to surface" << surfEvaluators[0] << std::endl; - // This bucket represents a geometric surface. Snap to it. - normal_at( eMesh, *node, curveOrSurfaceEvaluator, normal ); - break; - case -1: - default: - //printf( "ERROR: A bucket found without a geometric evaluator.\n" ); - break; - } - - - } -} - -void MeshGeometry::snap_points_to_geometry(PerceptMesh* eMesh, std::vector& nodes) -{ - for (unsigned inode=0; inode < nodes.size(); inode++) - { - Bucket& bucket = nodes[inode]->bucket(); - -#if CONTAINS_DEBUG_NODE - if ( contains_dbg_node( eMesh, bucket ) ) - { - std::cout << " DBG Node FOUND" << std::endl; - } -#endif - - // Each bucket contains the set of nodes with unique part intersections. - // This means that every nodes will be in exactly one bucket. But, the - // nodes on curves are also in the part for the adjacent surfaces which - // means more than one evaluator will be selected for those buckets which - // are on the boundary of an entity (i.e. buckets representing curves - // and vertices). We first create a list of all the evaluators that - // might be relevant. - - size_t curveOrSurfaceEvaluator; - int type = classify_bucket(bucket, curveOrSurfaceEvaluator); - switch (type) { - case 0: - // This is a bucket representing a vertex. No need to do anything - // since the node will already be on the vertex, and no new nodes - // ever get created assigned to vertices during refinement. - //std::cout << "Vertex node encountered" << std::endl; - break; - case 1: - // This bucket represents a geometric curve. Snap to it. - //std::cout << "Snapping to curve" << curveEvaluators[0] << std::endl; - snap_node( eMesh, *nodes[inode], curveOrSurfaceEvaluator ); - break; - case 2: - //std::cout << "Snapping to surface" << surfEvaluators[0] << std::endl; - // This bucket represents a geometric surface. Snap to it. - snap_node( eMesh, *nodes[inode], curveOrSurfaceEvaluator ); - break; - case -1: - default: - //printf( "ERROR: A bucket found without a geometric evaluator.\n" ); - break; - } - - - } -} - - -void MeshGeometry::snap_node -( - PerceptMesh *eMesh, - Entity & node, - size_t evaluator_idx -) -{ - VectorFieldType* coordField = eMesh->get_coordinates_field(); - - /* - Part* new_nodes_part = eMesh->get_non_const_part("refine_new_nodes_part"); - Selector new_nodes_part_selector; - if (new_nodes_part) new_nodes_part_selector = Selector(*new_nodes_part); - */ - - { - - double * coord = stk_classic::mesh::field_data( *coordField , node ); - double delta[3] = {coord[0], coord[1], coord[2]}; - double coord_0[3] = {coord[0], coord[1], coord[2]}; - bool doPrint = m_doPrint; //DEBUG_GEOM_SNAP - bool doCheckMovement = m_doCheckMovement != 0.0; - bool doCheckCPUTime = m_checkCPUTime != 0.0; - - if ( is_dbg_node( coord ) ) - { - std::cout << "Node in question being projected" << std::endl; - doPrint=true; - } - - if (doPrint) - { - std::string str = geomKernel->get_attribute(evaluator_idx); - std::cout << "tmp geom snap_points_to_geometry eval name= " << str << " node id= " << node.identifier() - << " coords b4= " << coord[0] << " " << coord[1] << " " << coord[2] << " type= " << m_type << std::endl; - } - - double cpu0 = 0.0, cpu1 = 0.0; - if (doCheckCPUTime) cpu0 = stk_classic::cpu_time(); - - // Look at the neighboring edges and calculate an average edge length. This will be - // used as a tolerance to tell the projection code that if the projected point - // has moved less than this value we can consider it a valid solution. This will - // greatly reduce the number of iterations the projection code has to do. - double edge_length_ave=0.0; - // get edge lengths - stk_classic::mesh::PairIterRelation node_elements = node.relations(eMesh->element_rank()); - for(unsigned ii=0; ii < node_elements.size(); ii++) - { - edge_length_ave += eMesh->edge_length_ave(*node_elements[ii].entity()); - } - edge_length_ave /= ((double)node_elements.size()); - - geomKernel->snap_to(coord, geomEvaluators[evaluator_idx]->mGeometry, &edge_length_ave); - - if (doCheckCPUTime) cpu1 = stk_classic::cpu_time() - cpu0; - - delta[0] = coord[0] - delta[0]; - delta[1] = coord[1] - delta[1]; - delta[2] = coord[2] - delta[2]; - - if (doPrint || (doCheckCPUTime && cpu1 > m_checkCPUTime)) - { - if (m_checkCPUTimeMap.find(evaluator_idx) == m_checkCPUTimeMap.end()) - m_checkCPUTimeMap[evaluator_idx] = 0.0; - - m_checkCPUTimeMap[evaluator_idx] = std::max(m_checkCPUTimeMap[evaluator_idx], cpu1); - - bool print_every = true; - if (print_every) - { - std::string str = geomKernel->get_attribute(evaluator_idx); - double dtot = std::sqrt(delta[0]*delta[0]+delta[1]*delta[1]+delta[2]*delta[2]); - - std::cout << "big cpu = " << cpu1 << " coords_0 = " << coord_0[0] << " " << coord_0[1] << " " << coord_0[2] - << " delta= " << delta[0] << " " << delta[1] << " " << delta[2] - << " coords_1= " << coord[0] << " " << coord[1] << " " << coord[2] - << " deltaMag= " << dtot - << " block= " << str - << std::endl; - } - } - - if (doPrint || doCheckMovement) - { - std::string str = geomKernel->get_attribute(evaluator_idx); - double dtot = std::sqrt(delta[0]*delta[0]+delta[1]*delta[1]+delta[2]*delta[2]); - if(doPrint) - std::cout << " coords af= " << coord[0] << " " << coord[1] << " " << coord[2] - << " delta= " << delta[0] << " " << delta[1] << " " << delta[2] - << " deltaTot= " << dtot - << " block= " << str - << std::endl; - if (doCheckMovement) - { - if (m_doCheckMovement >= 0.0) - { - edge_length_ave = m_doCheckMovement; - } - double factor = 1.0; - if (dtot > edge_length_ave*factor) - { - if (m_checkMovementMap.find(evaluator_idx) == m_checkMovementMap.end()) - m_checkMovementMap[evaluator_idx] = 0.0; - m_checkMovementMap[evaluator_idx] = std::max(m_checkMovementMap[evaluator_idx], dtot); - const bool print_every = true; - if (print_every) - { - std::cout << "big delta coords_0 = " << coord_0[0] << " " << coord_0[1] << " " << coord_0[2] - << " delta= " << delta[0] << " " << delta[1] << " " << delta[2] - << " coords_1= " << coord[0] << " " << coord[1] << " " << coord[2] - << " deltaMag= " << dtot - << " block= " << str - << std::endl; - } - - } - } - - //if (str.substr(6,5)=="20004") block_20004 - //{ - // std::cout << "found 20004" << std::endl; - //} - } - } -} - -void MeshGeometry::print_node_movement_summary() -{ - //if (m_checkMovementMap.size()) std::cout << "MeshGeometry::print_node_movement_summary, size= " << m_checkMovementMap.size() << std::endl; - for (MaxDeltaOnGeometryType::iterator iter = m_checkMovementMap.begin(); iter != m_checkMovementMap.end(); ++iter) - { - std::cout << "MeshGeometry::print_node_movement_summary, delta= " << iter->second << " on geometry= " << iter->first << " = " << geomKernel->get_attribute(iter->first) << std::endl; - } - for (MaxDeltaOnGeometryType::iterator iter = m_checkCPUTimeMap.begin(); iter != m_checkCPUTimeMap.end(); ++iter) - { - std::cout << "MeshGeometry::print_node_movement_summary, cpu= " << iter->second << " on geometry= " << iter->first << " = " << geomKernel->get_attribute(iter->first) << std::endl; - } -} - -void MeshGeometry::normal_at -( - PerceptMesh *eMesh, - Entity & node, - size_t evaluator_idx, - std::vector& normal -) -{ - VectorFieldType* coordField = eMesh->get_coordinates_field(); - - { - - double * coord = stk_classic::mesh::field_data( *coordField , node ); - bool doPrint = DEBUG_GEOM_SNAP; - if (doPrint) - { - std::string str = geomKernel->get_attribute(evaluator_idx); - std::cout << "tmp geom snap_points_to_geometry eval name= " << str << " node id= " << node.identifier() - << " coords b4= " << coord[0] << " " << coord[1] << " " << coord[2]; - } - - if ( is_dbg_node( coord ) ) - { - std::cout << "Node in question being projected" << std::endl; - } - - geomKernel->normal_at(coord, geomEvaluators[evaluator_idx]->mGeometry, normal); - - if (doPrint) - { - std::cout << " normal = " << normal[0] << " " << normal[1] << " " << normal[2] - << std::endl; - //if (str.substr(6,5)=="20004") block_20004 - //{ - // std::cout << "found 20004" << std::endl; - //} - } - } -} - -void MeshGeometry::snap_nodes -( - PerceptMesh *eMesh, - Bucket &bucket, - size_t evaluator_idx -) -{ - //VectorFieldType* coordField = eMesh->get_coordinates_field(); - const unsigned num_nodes_in_bucket = bucket.size(); - - //std::string str = geomKernel->get_attribute(evaluator_idx); - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - Entity& node = bucket[iNode]; - - snap_node(eMesh, node, evaluator_idx); - } -} - -bool MeshGeometry::contains_dbg_node -( - PerceptMesh *eMesh, - Bucket &bucket -) -{ - VectorFieldType* coordField = eMesh->get_coordinates_field(); - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - Entity& node = bucket[iNode]; - - double * coord = stk_classic::mesh::field_data( *coordField , node ); - if ( is_dbg_node( coord ) ) - { - return true; - } - } - return false; -} - -bool MeshGeometry::is_dbg_node( double node_coord[3] ) -{ - double dx = node_coord[0] - mDbgNodeCoords[0]; - double dy = node_coord[1] - mDbgNodeCoords[1]; - double dz = node_coord[2] - mDbgNodeCoords[2]; - double dist = sqrt( (dx*dx) + (dy*dy) + (dz*dz) ); - if ( dist < 0.001 ) - { - return true; - } - return false; -} - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.hpp deleted file mode 100644 index 033f4fe2ff2b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/geometry/kernel/MeshGeometry.hpp +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef MESHGEOMETRY_HPP -#define MESHGEOMETRY_HPP - -#include -#include "GeometryKernel.hpp" - -#include - -#define DEBUG_GEOM_SNAP 0 - - -typedef std::vector PointSet; -typedef int GeometryHandle; -using namespace stk_classic; -using namespace mesh; -using namespace percept; - -struct GeometryEvaluator -{ - GeometryEvaluator(Part* part) : mMesh(*part), mPart(part) {} - GeometryHandle mGeometry; - Selector mMesh; - Part *mPart; -}; - -class MeshGeometry -{ -public: - typedef std::pair CacheBucketClassifyValueType; - typedef boost::unordered_map CacheBucketClassifyType; - typedef boost::unordered_map MaxDeltaOnGeometryType; - - MeshGeometry(GeometryKernel* geom, double doCheckMovement=0.0, double doCheckCpuTime=0.0, bool cache_bucket_selectors_is_active=false, bool doPrint=false); - ~MeshGeometry(); - - void print_node_movement_summary(); - - void add_evaluator(GeometryEvaluator* evaluator); - void add_evaluators(std::vector evaluators); - - // snaps all points in the mesh to their associated geometry - void snap_points_to_geometry(PerceptMesh* mesh_data); - - // snaps only specified points in the mesh to their associated geometry - void snap_points_to_geometry(PerceptMesh* mesh_data, std::vector& nodes); - - // gets normal at a surface (or curve, in which case it returns the curvature vector) - void normal_at(PerceptMesh* eMesh, stk_classic::mesh::Entity * node, std::vector& normal); - - /** - * Return 0,1,2,3 if the node or bucket is on a geometry vertex, curve, surface or domain. - * Return the found evaluators in the curveEvaluators and surfEvaluators. - */ - int classify_node(const stk_classic::mesh::Entity& node, size_t& curveOrSurfaceEvaluator); - int classify_bucket(const stk_classic::mesh::Bucket& bucket, size_t& curveOrSurfaceEvaluator); - - const std::vector& getGeomEvaluators(); - - // hold info for which nodes took maximum cpu time - //struct CpuMaxInfo - -private: - - int classify_bucket_internal(const stk_classic::mesh::Bucket& bucket, size_t& curveOrSurfaceEvaluator); - //int classify_bucket_internal(const stk_classic::mesh::Bucket& bucket, std::vector& curveEvaluators, std::vector& surfEvaluators); - -protected: - std::vector geomEvaluators; - GeometryKernel* geomKernel; - CacheBucketClassifyType m_cache_bucket_classify; - - double m_doCheckMovement; - double m_checkCPUTime; - MaxDeltaOnGeometryType m_checkMovementMap; - MaxDeltaOnGeometryType m_checkCPUTimeMap; - -public: - bool m_cache_classify_bucket_is_active; - bool m_doPrint; -protected: - void snap_point_to_geometry(stk_classic::mesh::Entity *node); - -private: - - double mDbgNodeCoords[3]; - int m_type; - - bool contains_dbg_node( PerceptMesh *mesh_data, - Bucket &bucket ); - bool is_dbg_node( double node_coord[3] ); - - void snap_nodes( PerceptMesh* mesh_data, - Bucket &bucket, - size_t evalautor_idx ); - - void snap_node( PerceptMesh* mesh_data, - Entity &node, - size_t evalautor_idx ); - - void normal_at( PerceptMesh* mesh_data, - Entity &node, - size_t evalautor_idx, - std::vector& normal); - -}; - -#endif // MESHGEOMETRY_HPP diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.cpp deleted file mode 100644 index d1abf9d929b6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.cpp +++ /dev/null @@ -1,239 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include "JacobianUtil.hpp" - -#include - -#include "mpi.h" - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - static inline Vector3D vector_3D(double *x) - { - return Vector3D(x[0], x[1], x[2]); - } - static inline Vector3D vector_2D(double *x) - { - return Vector3D(x[0], x[1], 0.0); - } - - void scale_to_unit(MsqMatrix<3,3>& A) - { - for (int jvert=0; jvert < 3; jvert++) - { - double sum=0.0; - for (int ixyz=0; ixyz < 3; ixyz++) - { - sum += A(ixyz, jvert)*A(ixyz, jvert); - } - sum = std::max(1.e-10, std::sqrt(sum)); - for (int ixyz=0; ixyz < 3; ixyz++) - { - A(ixyz, jvert) /= sum; - } - } - } - - bool JacobianUtil::jacobian_matrix_2D(double &detJ, MsqMatrix<3,3>& A, const Vector3D *x, const Vector3D &n, const Vector3D &d) - { - /* Calculate A */ - // x_xi, x_eta, x_zeta => A(ixyz, ixietazeta) = dx_i/dxi_j - A(0,0) = d[0]*(x[1][0] - x[0][0]); - A(0,1) = d[1]*(x[2][0] - x[0][0]); - A(0,2) = n[0]; - - A(1,0) = d[0]*(x[1][1] - x[0][1]); - A(1,1) = d[1]*(x[2][1] - x[0][1]); - A(1,2) = n[1]; - - A(2,0) = d[0]*(x[1][2] - x[0][2]); - A(2,1) = d[1]*(x[2][2] - x[0][2]); - A(2,2) = n[2]; - if (m_scale_to_unit) scale_to_unit(A); - - detJ = det(A); - return detJ < MSQ_MIN; - } - - bool JacobianUtil::jacobian_matrix_3D(double &detJ, MsqMatrix<3,3>& A, const Vector3D *x, const Vector3D &n, const Vector3D &d) - { - A(0,0) = (x[1][0] - x[0][0]); - A(0,1) = (x[2][0] - x[0][0]); - A(0,2) = (x[3][0] - x[0][0]); - - A(1,0) = (x[1][1] - x[0][1]); - A(1,1) = (x[2][1] - x[0][1]); - A(1,2) = (x[3][1] - x[0][1]); - - A(2,0) = (x[1][2] - x[0][2]); - A(2,1) = (x[2][2] - x[0][2]); - A(2,2) = (x[3][2] - x[0][2]); - if (m_scale_to_unit) scale_to_unit(A); - - detJ = det(A); - return detJ < MSQ_MIN; - } - - /// modeled after code from Mesquite::IdealWeightMeanRatio::evaluate() - bool JacobianUtil::operator()(double& m, PerceptMesh& eMesh, stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *coord_field, - const CellTopologyData * topology_data ) - { - MsqError err; - static MsqMatrix<3,3> J; - - static Vector3D n; // Surface normal for 2D objects - - // Prism and Hex element descriptions - static const int locs_prism[6][4] = {{0, 1, 2, 3}, {1, 2, 0, 4}, - {2, 0, 1, 5}, {3, 5, 4, 0}, - {4, 3, 5, 1}, {5, 4, 3, 2}}; - static const int locs_hex[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5}, - {2, 3, 1, 6}, {3, 0, 2, 7}, - {4, 7, 5, 0}, {5, 4, 6, 1}, - {6, 5, 7, 2}, {7, 6, 4, 3}}; - int i=0; - - static const Vector3D d_con(1.0, 1.0, 1.0); - - bool metric_valid = false; - if (!topology_data) topology_data = stk_classic::percept::PerceptMesh::get_cell_topology(element); - - stk_classic::mesh::PairIterRelation v_i = element.relations(eMesh.node_rank()); - m_num_nodes = v_i.size(); - - //#define VERTEX_2D(vi) vector_2D( eMesh.field_data(coord_field, *vi.entity() ) ) - //#define VERTEX_3D(vi) vector_3D( eMesh.field_data(coord_field, *vi.entity() ) ) - -#define VERTEX_2D(vi) vector_2D( stk_classic::mesh::field_data( *static_cast(coord_field) , *vi.entity() ) ) -#define VERTEX_3D(vi) vector_3D( stk_classic::mesh::field_data( *static_cast(coord_field) , *vi.entity() ) ) - - - switch(topology_data->key) - { - case shards::Triangle<3>::key: - n[0] = 0; n[1] = 0; n[2] = 1; - mCoords[0] = VERTEX_2D(v_i[0]); - mCoords[1] = VERTEX_2D(v_i[1]); - mCoords[2] = VERTEX_2D(v_i[2]); - metric_valid = jacobian_matrix_2D(m, J, mCoords, n, d_con); - for (i = 0; i < 4; i++) { m_detJ[i] = m; m_J[i] = J; } - break; - - case shards::Quadrilateral<4>::key: - n[0] = 0; n[1] = 0; n[2] = 1; - for (i = 0; i < 4; ++i) { - mCoords[0] = VERTEX_2D(v_i[locs_hex[i][0]]); - mCoords[1] = VERTEX_2D(v_i[locs_hex[i][1]]); - mCoords[2] = VERTEX_2D(v_i[locs_hex[i][2]]); - metric_valid = jacobian_matrix_2D(m_detJ[i], m_J[i], mCoords, n, d_con); - } - m = average_metrics(m_detJ, 4, err); MSQ_ERRZERO(err); - break; - - case shards::Tetrahedron<4>::key: - mCoords[0] = VERTEX_3D(v_i[0]); - mCoords[1] = VERTEX_3D(v_i[1]); - mCoords[2] = VERTEX_3D(v_i[2]); - mCoords[3] = VERTEX_3D(v_i[3]); - metric_valid = jacobian_matrix_3D(m, J, mCoords, n, d_con); - for (i = 0; i < 4; i++) { m_detJ[i] = m; m_J[i] = J; } - break; - - case shards::Pyramid<5>::key: - for (i = 0; i < 4; ++i) { - mCoords[0] = VERTEX_3D(v_i[ i ]); - mCoords[1] = VERTEX_3D(v_i[(i+1)%4]); - mCoords[2] = VERTEX_3D(v_i[(i+3)%4]); - mCoords[3] = VERTEX_3D(v_i[ 4 ]); - metric_valid = jacobian_matrix_3D(m_detJ[i], m_J[i], mCoords, n, d_con); - } - // FIXME - m_J[4] = (m_J[0]+m_J[1]+m_J[2]+m_J[3]); - m_J[4] *= 0.25; - m_detJ[4] = det(m_J[4]); - m = average_metrics(m_detJ, 5, err); MSQ_ERRZERO(err); - break; - - case shards::Wedge<6>::key: - for (i = 0; i < 6; ++i) { - mCoords[0] = VERTEX_3D(v_i[locs_prism[i][0]]); - mCoords[1] = VERTEX_3D(v_i[locs_prism[i][1]]); - mCoords[2] = VERTEX_3D(v_i[locs_prism[i][2]]); - mCoords[3] = VERTEX_3D(v_i[locs_prism[i][3]]); - metric_valid = jacobian_matrix_3D(m_detJ[i], m_J[i], mCoords, n, d_con); - } - m = average_metrics(m_detJ, 6, err); MSQ_ERRZERO(err); - break; - - case shards::Hexahedron<8>::key: - for (i = 0; i < 8; ++i) { - mCoords[0] = VERTEX_3D(v_i[locs_hex[i][0]]); - mCoords[1] = VERTEX_3D(v_i[locs_hex[i][1]]); - mCoords[2] = VERTEX_3D(v_i[locs_hex[i][2]]); - mCoords[3] = VERTEX_3D(v_i[locs_hex[i][3]]); - metric_valid = jacobian_matrix_3D(m_detJ[i], m_J[i], mCoords, n, d_con); - } - m = average_metrics(m_detJ, 8, err); MSQ_ERRZERO(err); - break; - - - // unimplemented - case shards::Node::key: - case shards::Particle::key: - case shards::Line<2>::key: - case shards::Line<3>::key: - case shards::ShellLine<2>::key: - case shards::ShellLine<3>::key: - case shards::Beam<2>::key: - case shards::Beam<3>::key: - - case shards::Triangle<4>::key: - case shards::Triangle<6>::key: - case shards::ShellTriangle<3>::key: - case shards::ShellTriangle<6>::key: - - case shards::Quadrilateral<8>::key: - case shards::Quadrilateral<9>::key: - case shards::ShellQuadrilateral<4>::key: - case shards::ShellQuadrilateral<8>::key: - case shards::ShellQuadrilateral<9>::key: - - case shards::Tetrahedron<8>::key: - case shards::Tetrahedron<10>::key: - case shards::Tetrahedron<11>::key: - - case shards::Hexahedron<20>::key: - case shards::Hexahedron<27>::key: - - case shards::Pyramid<13>::key: - case shards::Pyramid<14>::key: - - case shards::Wedge<15>::key: - case shards::Wedge<18>::key: - - case shards::Pentagon<5>::key: - case shards::Hexagon<6>::key: - - default: - shards::CellTopology topology(topology_data); - std::cout << "topology = " << topology.getName() << std::endl; - throw std::runtime_error("unknown/unhandled topology in JacobianUtil"); - break; - - } // end switch over element type - - return metric_valid; - } - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.hpp deleted file mode 100644 index c7906fac4551..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/JacobianUtil.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef JacobianUtil_hpp -#define JacobianUtil_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - class JacobianUtil : public Mesquite::AveragingQM - { - Vector3D mCoords[4]; - - public: - double m_detJ[8]; - MsqMatrix<3,3> m_J[8]; - int m_num_nodes; - bool m_scale_to_unit; - - bool jacobian_matrix_3D(double &detJ, MsqMatrix<3,3>& A, const Vector3D *x, const Vector3D &n, const Vector3D &d); - bool jacobian_matrix_2D(double &detJ, MsqMatrix<3,3>& A, const Vector3D *x, const Vector3D &n, const Vector3D &d); - - JacobianUtil() : - AveragingQM( QualityMetric::LINEAR ), - m_num_nodes(0), - m_scale_to_unit(false) - { - } - - bool operator()(double& averageJ, PerceptMesh& eMesh, stk_classic::mesh::Entity& element, stk_classic::mesh::FieldBase *coord_field, - const CellTopologyData * topology_data_in = 0 ); - - }; - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother.hpp deleted file mode 100644 index c0cb86bf6a0f..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMLaplaceSmoother_hpp -#define PMMLaplaceSmoother_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/// work derived from: -//------------------------------------------------------------------------- -// Filename : SCVFracMesquiteLaplaceSmoother.hpp -// -// Purpose : sculptor interface to mesquite Laplacian smoother -// -// Description : implements the Laplacian smoother -// -// Creator : Steve Owen -// -// Creation Date : April 2011 -// -// Owner : Steve Owen -//------------------------------------------------------------------------- - -namespace stk_classic { - namespace percept { - - class PMMLaplaceSmoother - { - public: - PMMLaplaceSmoother() {} - - void run(Mesquite::Mesh &mesh, Mesquite::MeshDomain &domain, bool always_smooth=true, int debug=0) - { - Mesquite::ParallelMesh *pmesh = dynamic_cast(&mesh); - - if (debug) - { - Mesquite::MsqDebug::enable(1); - if (debug > 1) Mesquite::MsqDebug::enable(2); - if (debug > 2) Mesquite::MsqDebug::enable(3); - } - Mesquite::MsqError mErr; - int num_invalid = 0; - bool check_quality=true; - if (check_quality) - { - num_invalid = PMMShapeImprover::count_invalid_elements(mesh, pmesh, domain); - std::cout << "tmp srk PMMLaplaceSmoother num_invalid before= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : " ") - << std::endl; - } - - if (num_invalid || always_smooth) - { - Mesquite::LaplaceWrapper lw; - lw.set_iteration_limit(1); - if (pmesh) - lw.run_instructions(pmesh, &domain, mErr); - else - lw.run_instructions(&mesh, &domain, mErr); - if (check_quality) - { - num_invalid = PMMShapeImprover::count_invalid_elements(mesh, pmesh, domain); - std::cout << "tmp srk PMMLaplaceSmoother num_invalid after= " << num_invalid << " " - << (num_invalid ? " ERROR still have invalid elements after Mesquite smoothing" : - " SUCCESS: smoothed and removed invalid elements ") - << std::endl; - } - } - } - }; - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.cpp deleted file mode 100644 index 4bc8715fb1ef..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include - - -namespace stk_classic { - namespace percept { - using namespace Mesquite; - - // this is a modified copy of Mesquite::LaplaceWrapper's run_wrapper method - - void PMMLaplaceSmoother1::run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* geom, - Settings* settings, - QualityAssessor* qa, - MsqError& err ) - { - std::cout << "tmp srk start PMMLaplaceSmoother1::run_wrapper... get_iteration_limit() = " << get_iteration_limit() << std::endl; - if (get_cpu_time_limit() <= 0.0 && get_vertex_movement_limit_factor() <= 0.0 && get_iteration_limit() <= 0) { - MSQ_SETERR(err)("No termination criterion set. " - "PMMLaplaceSmoother1 will run forever.", - MsqError::INVALID_STATE); - return; - } - - IdealWeightInverseMeanRatio qa_metric; - qa->add_quality_assessment( &qa_metric ); - - LaplacianSmoother& smoother = m_smoother; - TerminationCriterion outer(""), inner(""); - if (get_cpu_time_limit() > 0.0) - outer.add_cpu_time( get_cpu_time_limit() ); - if (get_iteration_limit() > 0) - outer.add_iteration_limit( get_iteration_limit() ); - if (is_culling_enabled() && get_vertex_movement_limit_factor() > 0.0) { - inner.cull_on_absolute_vertex_movement_edge_length( get_vertex_movement_limit_factor() ); - smoother.set_inner_termination_criterion( &inner ); - } - else if (get_vertex_movement_limit_factor() > 0.0) { - outer.add_absolute_vertex_movement_edge_length( get_vertex_movement_limit_factor() ); - } - smoother.set_outer_termination_criterion( &outer ); - - InstructionQueue q; - q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - q.set_master_quality_improver( &smoother, err ); MSQ_ERRRTN(err); - q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - q.run_common( mesh, pmesh, geom, settings, err ); MSQ_ERRRTN(err); - std::cout << "tmp srk start PMMLaplaceSmoother1::run_wrapper...done" << std::endl; - } - - void PMMLaplaceSmoother1::run(Mesquite::Mesh &mesh, Mesquite::MeshDomain &domain, bool always_smooth, int debug) - { - Mesquite::ParallelMesh *pmesh = dynamic_cast(&mesh); - - if (debug) - { - Mesquite::MsqDebug::enable(1); - if (debug > 1) Mesquite::MsqDebug::enable(2); - if (debug > 2) Mesquite::MsqDebug::enable(3); - } - - Mesquite::MsqError mErr; - - int num_invalid = 0; - bool check_quality=true; - if (check_quality) - { - num_invalid = PMMShapeImprover::count_invalid_elements(mesh, pmesh, domain); - std::cout << "tmp srk PMMLaplaceSmoother1 num_invalid before= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : " ") - << std::endl; - } - - if (num_invalid || always_smooth) - { - std::cout << "tmp srk PMMLaplaceSmoother1 running laplace smoother..." << std::endl; - if (pmesh) - this->run_instructions(pmesh, &domain, mErr); - else - this->run_instructions(&mesh, &domain, mErr); - std::cout << "tmp srk PMMLaplaceSmoother1 running laplace smoother...done" << std::endl; - if (check_quality) - { - num_invalid = PMMShapeImprover::count_invalid_elements(mesh, pmesh, domain); - std::cout << "tmp srk PMMLaplaceSmoother1 num_invalid after= " << num_invalid << " " - << (num_invalid ? " ERROR still have invalid elements after Mesquite smoothing" : - " SUCCESS: smoothed and removed invalid elements ") - << std::endl; - } - } - } - - - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.hpp deleted file mode 100644 index 7ebefbfd90a6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMLaplaceSmoother1.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMLaplaceSmoother1_hpp -#define PMMLaplaceSmoother1_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/// work derived from: -//------------------------------------------------------------------------- -// Filename : SCVFracMesquiteLaplaceSmoother.hpp -// -// Purpose : sculptor interface to mesquite Laplacian smoother -// -// Description : implements the Laplacian smoother -// -// Creator : Steve Owen -// -// Creation Date : April 2011 -// -// Owner : Steve Owen -//------------------------------------------------------------------------- - -namespace stk_classic { - namespace percept { - - class PMMLaplaceSmoother1 : public Mesquite::LaplaceWrapper - { - Mesquite::LaplacianSmoother m_smoother; - public: - - PMMLaplaceSmoother1(double max_cpu_time=0.0, double max_vertex_movement=1.e-4, int numIterMax=100, bool doCulling=false) : Mesquite::LaplaceWrapper() { - this->set_cpu_time_limit(max_cpu_time); - this->set_vertex_movement_limit_factor(max_vertex_movement); - this->set_iteration_limit(numIterMax); - this->enable_culling(doCulling); - } - - virtual ~PMMLaplaceSmoother1() {} - Mesquite::LaplacianSmoother& get_smoother() { return m_smoother; } - - void run(Mesquite::Mesh &mesh, Mesquite::MeshDomain &domain, bool always_smooth=true, int debug=0); - - protected: - - virtual void run_wrapper( Mesquite::Mesh* mesh, - Mesquite::ParallelMesh* pmesh, - Mesquite::MeshDomain* geom, - Mesquite::Settings* settings, - Mesquite::QualityAssessor* qa, - Mesquite::MsqError& err ); - - private: - - }; - - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMMsqMatrix.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMMsqMatrix.hpp deleted file mode 100644 index 5a4370a176fd..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMMsqMatrix.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMMsqMatrix_hpp -#define PMMMsqMatrix_hpp - - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include - -namespace stk_classic { - namespace percept { - - - - inline double my_sqr_Frobenius( const Mesquite::MsqMatrix<3,3>& m) - { - double sum=0.0; -#define R(i,j) sum += m(i,j)*m(i,j) - R(0,0); - R(0,1); - R(0,2); - - R(1,0); - R(1,1); - R(1,2); - - R(2,0); - R(2,1); - R(2,2); -#undef R - return sum; - } - - inline void inverse( const Mesquite::MsqMatrix<3,3>& m, Mesquite::MsqMatrix<3,3>& result ) - { - //return adj(m) * (1.0 / det(m)); - const double detInv = 1.0/det(m); - result(0,0) = (m(1,1)*m(2,2) - m(1,2)*m(2,1))*detInv; - result(0,1) = (m(0,2)*m(2,1) - m(0,1)*m(2,2))*detInv; - result(0,2) = (m(0,1)*m(1,2) - m(0,2)*m(1,1))*detInv; - - result(1,0) = (m(1,2)*m(2,0) - m(1,0)*m(2,2))*detInv; - result(1,1) = (m(0,0)*m(2,2) - m(0,2)*m(2,0))*detInv; - result(1,2) = (m(0,2)*m(1,0) - m(0,0)*m(1,2))*detInv; - - result(2,0) = (m(1,0)*m(2,1) - m(1,1)*m(2,0))*detInv; - result(2,1) = (m(0,1)*m(2,0) - m(0,0)*m(2,1))*detInv; - result(2,2) = (m(0,0)*m(1,1) - m(0,1)*m(1,0))*detInv; - } - - // z = x * y - inline void product( const Mesquite::MsqMatrix<3,3>& x, const Mesquite::MsqMatrix<3,3>& y, Mesquite::MsqMatrix<3,3>& z ) - { -#define R(i,j) z(i,j) = x(i,0)*y(0,j) + x(i,1)*y(1,j) + x(i,2)*y(2,j) - R(0,0); - R(0,1); - R(0,2); - - R(1,0); - R(1,1); - R(1,2); - - R(2,0); - R(2,1); - R(2,2); -#undef R - - } - - // z = x + y - inline void sum( const Mesquite::MsqMatrix<3,3>& x, const Mesquite::MsqMatrix<3,3>& y, Mesquite::MsqMatrix<3,3>& z ) - { -#define R(i,j) z(i,j) = x(i,j)+y(i,j) - R(0,0); - R(0,1); - R(0,2); - - R(1,0); - R(1,1); - R(1,2); - - R(2,0); - R(2,1); - R(2,2); -#undef R - - } - - // z = x - y - inline void difference( const Mesquite::MsqMatrix<3,3>& x, const Mesquite::MsqMatrix<3,3>& y, Mesquite::MsqMatrix<3,3>& z ) - { -#define R(i,j) z(i,j) = x(i,j)-y(i,j) - R(0,0); - R(0,1); - R(0,2); - - R(1,0); - R(1,1); - R(1,2); - - R(2,0); - R(2,1); - R(2,2); -#undef R - - } - - inline void identity( Mesquite::MsqMatrix<3,3>& I ) - { - I(0,0) = 1.0; - I(0,1) = 0.0; - I(0,2) = 0.0; - - I(1,0) = 0.0; - I(1,1) = 1.0; - I(1,2) = 0.0; - - I(2,0) = 0.0; - I(2,1) = 0.0; - I(2,2) = 1.0; - } - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.cpp deleted file mode 100644 index d8f821b3cdca..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "mpi.h" - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - void PMMParallelReferenceMeshSmoother::sync_fields(int iter) - { - std::vector< const stk_classic::mesh::FieldBase *> fields; - fields.push_back(m_eMesh->get_coordinates_field()); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(m_eMesh->get_bulk_data()->shared_aura(), fields); - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*m_eMesh->get_bulk_data()->ghostings()[0], fields); - } - - - bool PMMParallelReferenceMeshSmoother::check_convergence() - { - throw std::runtime_error("not implemented"); -#if 0 - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , stk_classic::ReduceMax<1>( & m_dmax ) ); - bool cond = (m_num_invalid == 0 && m_dmax < gradNorm); - return cond; -#endif - return false; - } - - double PMMParallelReferenceMeshSmoother::run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ) - { - throw std::runtime_error("not implemented"); - return 0.0; - } - - static void print_comm_list( const BulkData & mesh , bool doit ) - { - if ( doit ) { - std::ostringstream msg ; - - msg << std::endl ; - - for ( std::vector::const_iterator - i = mesh.entity_comm().begin() ; - i != mesh.entity_comm().end() ; ++i ) { - - Entity & entity = **i ; - msg << "P" << mesh.parallel_rank() << ": " ; - - print_entity_key( msg , MetaData::get(mesh) , entity.key() ); - - msg << " owner(" << entity.owner_rank() << ")" ; - - if ( EntityLogModified == entity.log_query() ) { msg << " mod" ; } - else if ( EntityLogDeleted == entity.log_query() ) { msg << " del" ; } - else { msg << " " ; } - - for ( PairIterEntityComm ec = mesh.entity_comm(entity.key()); ! ec.empty() ; ++ec ) { - msg << " gid, proc (" << ec->ghost_id << "," << ec->proc << ")" ; - } - msg << std::endl ; - } - - std::cout << msg.str(); - } - } - - void PMMParallelReferenceMeshSmoother::run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ) - { - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMParallelReferenceMeshSmoother innerIter= " << innerIter << " parallelIterations= " << parallelIterations << std::endl; - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelReferenceMeshSmoother: running shape improver... \n" << std::endl; - - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - m_pmm= pmm; - m_eMesh = eMesh; - m_num_nodes = m_eMesh->get_number_nodes(); - - print_comm_list(*eMesh->get_bulk_data(), false); - - stk_classic::mesh::FieldBase *coord_field = eMesh->get_coordinates_field(); - stk_classic::mesh::FieldBase *coord_field_current = coord_field; - stk_classic::mesh::FieldBase *coord_field_projected = eMesh->get_field("coordinates_N"); - stk_classic::mesh::FieldBase *coord_field_original = eMesh->get_field("coordinates_NM1"); - stk_classic::mesh::FieldBase *coord_field_lagged = eMesh->get_field("coordinates_lagged"); - - m_coord_field_original = coord_field_original; - m_coord_field_projected = coord_field_projected; - m_coord_field_lagged = coord_field_lagged; - m_coord_field_current = coord_field_current; - - eMesh->copy_field(coord_field_lagged, coord_field_original); - - // untangle - PMMSmootherMetricUntangle untangle_metric(eMesh); - - // shape-size-orient smooth - PMMSmootherMetricShapeSizeOrient shape_size_orient_metric(eMesh); - - // shape - PMMSmootherMetricShapeB1 shape_b1_metric(eMesh); - - // laplace - PMMSmootherMetricLaplace laplace_metric(eMesh); - - // scaled jacobian - PMMSmootherMetricScaledJacobianElemental scaled_jac_metric(eMesh); - - // scaled jacobian - nodal - PMMSmootherMetricScaledJacobianNodal scaled_jac_metric_nodal(eMesh); - - //double omegas[] = {0.0, 0.001, 0.01, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0}; - //double omegas[] = {0.001, 1.0}; - //double omegas[] = { 0.001, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.4, 0.45,0.46,0.47,0.48,0.49,0.5,0.52,0.54,0.56,0.59, 0.6, 0.8, 1.0}; - double omegas[] = { 1.0}; - //double omegas[] = {0.0, 0.001, 0.01, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.4, 0.6, 0.8, 1.0}; - int nomega = sizeof(omegas)/sizeof(omegas[0]); - - for (int outer = 0; outer < nomega; outer++) - { - double omega = (outer < nomega ? omegas[outer] : 1.0); - m_omega = omega; - m_omega_prev = omega; - if (outer > 0) m_omega_prev = omegas[outer-1]; - - // set current state and evaluate mesh validity (current = omega*project + (1-omega)*original) - eMesh->nodal_field_axpbypgz(omega, coord_field_projected, (1.0-omega), coord_field_original, 0.0, coord_field_current); - - int num_invalid = PMMParallelShapeImprover::parallel_count_invalid_elements(m_eMesh); - - if (!get_parallel_rank()) - std::cout << "\ntmp srk PMMParallelReferenceMeshSmoother num_invalid current= " << num_invalid << " for outer_iter= " << outer - << " omega= " << omega - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : " OK") - << std::endl; - //if (num_invalid) return; - m_num_invalid = num_invalid; - m_untangled = (m_num_invalid == 0); - - int iter_all=0; - - int do_anim = 0; // = frequency of anim writes - if (do_anim) - { - eMesh->save_as("anim_all."+toString(iter_all)+".e"); - } - - int nstage=2; - for (int stage = 0; stage < nstage; stage++) - { - m_stage = stage; - if (stage==0) - { - m_metric = &untangle_metric; - //m_metric = &scaled_jac_metric_nodal; - } - else - { - int num_invalid_1 = PMMParallelShapeImprover::parallel_count_invalid_elements(m_eMesh); - VERIFY_OP_ON(num_invalid_1, ==, 0, "Invalid elements exist for start of stage 2, aborting"); - - //m_metric = &shape_size_orient_metric; - m_metric = &shape_b1_metric; - //m_metric = &laplace_metric; - //m_metric = &scaled_jac_metric; - - } - - for (int iter = 0; iter < innerIter; ++iter, ++iter_all) - { - m_iter = iter; - int num_invalid_0 = PMMParallelShapeImprover::parallel_count_invalid_elements(m_eMesh); - m_num_invalid = num_invalid_0; - - // if (!get_parallel_rank() && num_invalid_0) - // std::cout << "\ntmp srk PMMParallelReferenceMeshSmoother num_invalid current= " << num_invalid_0 - // << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : "OK") - // << std::endl; - - m_global_metric = run_one_iteration(mesh, domain, err); - - sync_fields(iter); - num_invalid_0 = PMMParallelShapeImprover::parallel_count_invalid_elements(m_eMesh); - m_num_invalid = num_invalid_0; - bool conv = check_convergence(); - if (!get_parallel_rank()) - { - std::cout << "P[" << get_parallel_rank() << "] " << "tmp srk iter= " << iter << " dmax= " << m_dmax << " m_dnew= " << m_dnew - << " m_d0= " << m_d0 << " m_alpha= " << m_alpha << " m_scale= " << m_scale << " m_grad_norm= " << m_grad_norm << " m_scaled_grad_norm = " << m_scaled_grad_norm - << " num_invalid= " << num_invalid_0 - << " m_global_metric= " << m_global_metric << " stage= " << stage << " m_untangled= " << m_untangled - << std::endl; - } - - if (do_anim) - { - eMesh->save_as("iter_"+toString(outer)+"_"+toString(stage)+"."+toString(iter+1)+".e"); - if (iter_all % do_anim == 0) eMesh->save_as("anim_all."+toString(iter_all+1)+".e"); - } - - if (!m_untangled && m_num_invalid == 0) - { - m_untangled = true; - } - if (conv && m_untangled) break; - //if (iter == 5) break; - //if (iter == 0) exit(1); - } - - eMesh->save_as("outer_iter_"+toString(outer)+"_"+toString(stage)+"_mesh.e"); - } - - eMesh->copy_field(coord_field_lagged, coord_field); - - } - - //if (!get_parallel_rank()) - - MPI_Barrier( MPI_COMM_WORLD ); - - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelReferenceMeshSmoother: running shape improver... done \n" << std::endl; - - MSQ_ERRRTN(err); - } - - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.hpp deleted file mode 100644 index 21bc2bb7d1ed..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMParallelReferenceMeshSmoother_hpp -#define PMMParallelReferenceMeshSmoother_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - /// A weighted Laplace smother - tries to make the new mesh the same local size as original - class PMMParallelReferenceMeshSmoother : public PMMParallelShapeImprover::PMMParallelShapeImprovementWrapper { - - public: - - typedef std::vector Vector; - typedef boost::unordered_map NodeMap; - - - PMMParallelReferenceMeshSmoother(int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : PMMParallelShapeImprover::PMMParallelShapeImprovementWrapper(inner_iterations, cpu_time, grad_norm, parallel_iterations), - - m_scale(0), - m_dmax(0), - m_dnew(0), m_dold(0), m_d0(0), m_dmid(0), m_dd(0), m_alpha(0), m_grad_norm(0), m_scaled_grad_norm(0), - m_total_metric(0), - m_stage(0), - m_omega(0), - m_omega_prev(0), - m_iter(0), - m_num_invalid(0), m_global_metric(std::numeric_limits::max()), m_untangled(false), m_num_nodes(0) - - {} - - - protected: - - void run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ); - - virtual double run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ); - - void sync_fields(int iter=0); - virtual bool check_convergence(); - - template - void check_equal(T& val) - { - T global_min = val, global_max=val; - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & global_max ) ); - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & global_max ) ); - VERIFY_OP_ON( global_max, ==, val , "bad parallel val"); - VERIFY_OP_ON( global_min, ==, val , "bad parallel val"); - VERIFY_OP_ON( global_max, ==, global_min , "bad parallel val"); - } - - int count_invalid_elements(PerceptMesh *eMesh); - - protected: - NodeMap m_current_position; - NodeMap m_delta; - NodeMap m_weight; - NodeMap m_nweight; - - double m_scale; - double m_dmax; - double m_dnew, m_dold, m_d0, m_dmid, m_dd, m_alpha, m_grad_norm, m_scaled_grad_norm; - double m_total_metric; - int m_stage; - double m_omega; - double m_omega_prev; - int m_iter; - - int m_num_invalid; - double m_global_metric; - bool m_untangled; - int m_num_nodes; - - PerceptMesquiteMesh *m_pmm; - PerceptMesh *m_eMesh; - - stk_classic::mesh::FieldBase *m_coord_field_original; - stk_classic::mesh::FieldBase *m_coord_field_projected; - stk_classic::mesh::FieldBase *m_coord_field_current; - stk_classic::mesh::FieldBase *m_coord_field_lagged; - - PMMSmootherMetric *m_metric; - - }; - - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.cpp deleted file mode 100644 index c8d1523dd5a8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.cpp +++ /dev/null @@ -1,1321 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "mpi.h" -#include - -#define DEBUG_PRINT 0 -#define PRINT(a) do { if (DEBUG_PRINT && !m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_1(a) do { if (!m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_2(a) do { std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << " "; } while(0) - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - static bool m_use_local_scaling = false; - static bool m_use_hessian_scaling = false; - - static double macheps = std::numeric_limits::epsilon(); - static double sqrt_eps = std::sqrt(macheps); - static double cbrt_eps = std::pow(macheps, 1./3.); - - using namespace Mesquite; - const bool do_tot_test = false; - bool do_print_elem_val = false; - - void PMMParallelReferenceMeshSmoother1::nodal_gradient(stk_classic::mesh::Entity& node, double alpha, double *coord_current, double *cg_d, bool& valid, double *ng) - { - int spatialDim = m_eMesh->get_spatial_dim(); - valid = true; - - double xc[3]={0,0,0}; - double edge_length_ave = nodal_edge_length_ave(node); - double eps1 = sqrt_eps*edge_length_ave; - //if (m_metric->length_scaling_power() != 1.0) eps1 = std::pow(eps1, 1.0/m_metric->length_scaling_power()); - - for (int i=0; i < spatialDim; i++) - { - xc[i]=coord_current[i]; - double dt = eps1; - coord_current[i] += dt; - double mp = nodal_metric(node, 0.0, coord_current, cg_d, valid); - bool second_order = true; - if (second_order) - { - coord_current[i] -= 2.0*dt; - double mm = nodal_metric(node, 0.0, coord_current, cg_d, valid); - ng[i] = (mp-mm)/(2.0*eps1); - //if (std::fabs(mp) > 1.e-10) std::cout << "tmp srk i, mp = " << mp << " mm= " << mm << " ng= " << ng[i] << std::endl; - } - else - { - coord_current[i] = xc[i]; - double mm = nodal_metric(node, 0.0, coord_current, cg_d, valid); - ng[i] = (mp-mm)/(eps1); - //if (std::fabs(mp) > 1.e-10) std::cout << "tmp srk i, mp = " << mp << " mm= " << mm << " ng= " << ng[i] << std::endl; - } - coord_current[i] = xc[i]; - } - } - - double PMMParallelReferenceMeshSmoother1::nodal_metric(stk_classic::mesh::Entity& node, double alpha, double *coord_current, double *cg_d, bool& valid) - { - int spatialDim = m_eMesh->get_spatial_dim(); - valid = true; - double nm=0.0; - CombineOp combine = m_metric->get_combine_op(); - if (combine == COP_MIN) nm = std::numeric_limits::max(); - if (combine == COP_MAX) nm = -std::numeric_limits::max(); - m_metric->set_node(&node); - - double xc[3]={0,0,0}; - - for (int i=0; i < spatialDim; i++) - { - xc[i]=coord_current[i]; - double dt = alpha*cg_d[i]; - coord_current[i] += dt; - } - - stk_classic::mesh::PairIterRelation node_elems = node.relations(m_eMesh->element_rank()); - for (unsigned i_elem=0; i_elem < node_elems.size(); i_elem++) - { - stk_classic::mesh::Entity& element = *node_elems[i_elem].entity(); - bool local_valid = true; - double val = m_metric->metric(element, local_valid); - if (combine == COP_SUM) - nm += val; - else if (combine == COP_MAX) - nm = std::max(nm, val); - else if (combine == COP_MIN) - nm = std::min(nm, val); - valid = valid && local_valid; - } - for (int i=0; i < spatialDim; i++) - { - coord_current[i] = xc[i]; - } - - return nm; - } - - double PMMParallelReferenceMeshSmoother1::nodal_edge_length_ave(stk_classic::mesh::Entity& node) - { - //int spatialDim = m_eMesh->get_spatial_dim(); - double nm=0.0; - - stk_classic::mesh::PairIterRelation node_elems = node.relations(m_eMesh->element_rank()); - for (unsigned i_elem=0; i_elem < node_elems.size(); i_elem++) - { - stk_classic::mesh::Entity& element = *node_elems[i_elem].entity(); - double elem_edge_len = m_eMesh->edge_length_ave(element, m_coord_field_original); - nm += elem_edge_len; - } - nm /= double(node_elems.size()); - return nm; - } - - - bool PMMParallelReferenceMeshSmoother1::check_convergence() - { - double grad_check = gradNorm; - if (m_stage == 0 && (m_dnew == 0.0 || m_total_metric == 0.0)) - { - std::cout << "tmp srk untangle m_dnew= " << m_dnew << " m_total_metric = " << m_total_metric << std::endl; - return true; // for untangle - } - if (m_stage == 0 && m_num_invalid == 0 && (m_dmax < grad_check || m_scaled_grad_norm < grad_check)) - { - return true; - } - //grad_check = 1.e-8; - double scaled_grad_norm = std::sqrt(m_dnew)/double(m_num_nodes); - if (m_num_invalid == 0 && (m_scaled_grad_norm < grad_check || (m_iter > 0 && m_dmax < grad_check && (m_dnew < grad_check*grad_check*m_d0 || scaled_grad_norm < grad_check) ) ) ) - // if (m_num_invalid == 0 && (m_scaled_grad_norm < gradNorm || (m_iter > 0 && m_dmax < gradNorm ) ) ) - { - std::cout << "tmp srk untangle m_dnew(scaled nnode) check= " << (scaled_grad_norm < grad_check) - << " m_scaled_grad_norm check= " << (m_scaled_grad_norm < grad_check) - << " m_dmax check= " << (m_dmax < grad_check) - << " m_dnew check= " << (m_dnew < grad_check*grad_check*m_d0) - << " m_total_metric = " << m_total_metric << std::endl; - return true; - } - return false; - } - - double PMMParallelReferenceMeshSmoother1::metric(stk_classic::mesh::Entity& element, bool& valid) - { - return m_metric->metric(element,valid); - } - - /// fills cg_g_field with f'(x) - void PMMParallelReferenceMeshSmoother1::get_gradient( Mesh* mesh, MeshDomain *domain) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - stk_classic::mesh::FieldBase *coord_field = eMesh->get_coordinates_field(); - stk_classic::mesh::FieldBase *coord_field_current = coord_field; - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_d_field = eMesh->get_field("cg_d"); - stk_classic::mesh::FieldBase *cg_h_field = (m_use_hessian_scaling? eMesh->get_field("cg_h") : 0); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = eMesh->get_spatial_dim(); - bool valid=true; - - m_scale = 1.e-10; - - // g=0 - eMesh->nodal_field_set_value(cg_g_field, 0.0); - if (m_use_hessian_scaling) eMesh->nodal_field_set_value(cg_h_field, 0.0); - - if (m_metric->is_nodal()) - { - // node loop - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool fixed = pmm->get_fixed_flag(&node); - if (fixed) - { - continue; - } - - double edge_length_ave = nodal_edge_length_ave(node); - - double *coord_current = PerceptMesh::field_data(coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - - m_metric->set_node(&node); - - double gsav[3]={0,0,0}; - bool ng_valid = true; - if (node.identifier() == 16) - { - //std::cout << "tmp srk " << std::endl; - } - nodal_gradient(node, 0.0, coord_current, cg_d, ng_valid, gsav); - //std::cout << "tmp srk gsav = " << gsav[0] << " " << gsav[1] << std::endl; - - for (int idim=0; idim < spatialDim; idim++) - { - double dd = 0.0; - if (ng_valid || m_stage == 0) - dd = gsav[idim]; - m_scale = std::max(m_scale, std::abs(dd)/edge_length_ave); - - cg_g[idim] = dd; - } - } - } - } - } - else - { - // element loop: compute deltas - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (PerceptMesquiteMesh::select_bucket(**k, m_eMesh)) - //if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - m_metric->m_topology_data = m_eMesh->get_cell_topology(bucket); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - - double edge_length_ave = m_eMesh->edge_length_ave(element, m_coord_field_original); - - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - //VERIFY_OP_ON(isGhostNode, ==, false, "hmmmm"); - bool node_locally_owned = (eMesh->get_rank() == node.owner_rank()); - bool fixed = pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - continue; - - // FIXME - //edge_length_ave = nodal_edge_length_ave(node); - - m_metric->set_node(&node); - double *coord_current = PerceptMesh::field_data(coord_field_current, node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - unsigned stride_h=0; - double *cg_h = (m_use_hessian_scaling ? PerceptMesh::field_data(cg_h_field, node, &stride_h) : 0); - if (m_use_hessian_scaling) VERIFY_OP_ON(int(stride_h), ==, spatialDim*spatialDim, "hmm"); - - //double eps = 1.e-6; - double eps1 = sqrt_eps*edge_length_ave; - //if (m_metric->length_scaling_power() != 1.0) eps1 = std::pow(eps1, 1.0/m_metric->length_scaling_power()); - - double gsav[3]={0,0,0}; - //double hsav[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}; - - for (int idim=0; idim < spatialDim; idim++) - { - double cc = coord_current[idim]; - coord_current[idim] += eps1; - bool pvalid=false, mvalid=false; - double mp = metric(element, pvalid); - const bool second_order = true; - if (second_order) - coord_current[idim] -= 2.0*eps1; - else - coord_current[idim] = cc; - double mm = metric(element, mvalid); - coord_current[idim] = cc; - double dd = 0.0; - //if ((pvalid && mvalid) || m_stage == 0) - if (second_order) - { - dd = (mp - mm)/(2*eps1); - } - else - { - dd = (mp - mm)/(eps1); - } - gsav[idim] = dd; - - //if (std::fabs(mp) > 1.e-10) std::cout << "tmp srk mp = " << mp << " mm= " << mm << " dd= " << dd << std::endl; - - m_scale = std::max(m_scale, std::abs(dd)/edge_length_ave); - - if (node_locally_owned) - { - cg_g[idim] += dd; - } - else - { - cg_g[idim] = 0.0; - } - } - - if (m_use_hessian_scaling) - { - /// 1st-order accurate formula: f_xi_xj = ( f(x + h ei + h ej) - f(x + h ei) - f(x + h ej) + f(x) ) / h^2 - - MsqMatrix<2,2> H; - - double csav[3]={0,0,0}; - for (int idim=0; idim < spatialDim; idim++) - { - csav[idim] = coord_current[idim]; - } - - double eps_hess = cbrt_eps; - for (int idim=0; idim < spatialDim; idim++) - { - for (int jdim=0; jdim < spatialDim; jdim++) - { - double cc_i = csav[idim]; - double cc_j = csav[jdim]; - bool fvalid=false; - - coord_current[idim] = cc_i; - coord_current[jdim] = cc_j; - -#if 0 - coord_current[idim] += eps_hess; - coord_current[jdim] += eps_hess; - double fpp = metric(element, fvalid); - - coord_current[idim] = cc_i + eps_hess; - coord_current[jdim] = cc_j + 0; - double fpm = metric(element, fvalid); - - coord_current[idim] = cc_i + 0; - coord_current[jdim] = cc_j + eps_hess; - double fmp = metric(element, fvalid); - - coord_current[idim] = cc_i + 0; - coord_current[jdim] = cc_j + 0; - double fmm = metric(element, fvalid); - - // 1st-order accurate... - double f_xi_xj = (fpp - fpm - fmp + fmm)/(eps_hess*eps_hess); -#else - double eps2 = eps_hess/2.0; - - coord_current[idim] = cc_i; - coord_current[jdim] = cc_j; - coord_current[idim] += eps2; - coord_current[jdim] += eps2; - double fpp = metric(element, fvalid); - - coord_current[idim] = cc_i; - coord_current[jdim] = cc_j; - coord_current[idim] -= eps2; - coord_current[jdim] += eps2; - double fmp = metric(element, fvalid); - - coord_current[idim] = cc_i; - coord_current[jdim] = cc_j; - coord_current[idim] += eps2; - coord_current[jdim] -= eps2; - double fpm = metric(element, fvalid); - - coord_current[idim] = cc_i; - coord_current[jdim] = cc_j; - coord_current[idim] -= eps2; - coord_current[jdim] -= eps2; - double fmm = metric(element, fvalid); - - // 2nd-order accurate - double f_xi_xj = (fpp - fmp - fpm + fmm)/(4*eps2*eps2); -#endif - // c-style ordering - cg_h[jdim + idim*spatialDim] += f_xi_xj; - H(idim,jdim) = f_xi_xj; - if (0 && m_stage==1) - { - std::cout << "i,j= " << idim << " " << jdim << " fpp= " << fpp << " fpm= " << fpm << " fmp= " << fmp << " fmm= " << fmm << std::endl; - std::cout << "i,j= " << idim << " " << jdim << " f_xi_xj= " << f_xi_xj << " fpp-fmm= " << fpp-fmm << " fpm-fmm= " << fpm-fmm << " fmp-fmm= " << fmp-fmm << " eps_hess= " << eps_hess << std::endl; - } - } - } - for (int idim=0; idim < spatialDim; idim++) - { - coord_current[idim] = csav[idim]; - } - - - if (0 && m_stage==1) - { - double d = det(H); - //a00 - Sqrt(4*a01*a10 + Power(a00 - a11,2)) + a11)/2., (a00 + Sqrt(4*a01*a10 + Power(a00 - a11,2)) + a11)/2. - - double disc=4*H(0,1)*H(1,0) + std::pow(H(0,0) - H(1,1),2); - double eigen[] = {(H(0,0) - std::sqrt(disc) + H(1,1))/2., - (H(0,0) + std::sqrt(disc) + H(1,1))/2.}; - - //if (std::abs(d) > 1.e-10 && (std::abs(gsav[0])+std::abs(gsav[1]) > 1.e-10)) - //if (d > 1.e-10) - { - std::cout << "000 det(H) = " << d << " H= " << H << " eigen= " << eigen[0] << " " << eigen[1] << " disc= " << disc << " grad= " << gsav[0] << " " << gsav[1] << std::endl; - exit(1); - } - } - - - } - - // FIXME - if (DEBUG_PRINT) - { - double gsn=0.0; - for (int idim=0; idim < spatialDim; idim++) - { - gsn += gsav[idim]*gsav[idim]; - } - gsn = std::sqrt(gsn); - gsn = std::max(gsn,1.e-12); - if (gsn > 1.e-8*edge_length_ave) - { - double xsv[3] = {0,0,0}; - for (int idim=0; idim < spatialDim; idim++) - { - double dd = gsav[idim]/gsn*edge_length_ave; - xsv[idim] = coord_current[idim]; - coord_current[idim] -= dd*sqrt_eps; - } - double m1=metric(element, valid); - for (int idim=0; idim < spatialDim; idim++) - { - double dd = gsav[idim]/gsn*edge_length_ave; - coord_current[idim] += dd*sqrt_eps; - } - double metric_0 = metric(element, valid); - - for (int idim=0; idim < spatialDim; idim++) - { - coord_current[idim] = xsv[idim]; - } - if (metric_0 > 1.e-6) - { - if (!(m1 < metric_0*(1.0+sqrt_eps))) - { - PRINT( "bad grad" << " m1-metric_0 = " << (m1-metric_0) << " gsav= " << gsav[0] << " " << gsav[1] << " " << gsav[2] ); - } - VERIFY_OP_ON(m1, <, metric_0*(1.0+sqrt_eps), "bad gradient"); - } - } - } - - } // inode... - } // i_element - } // on_locally_owned_part... - } // buckets - } // element loop... - - VectorFieldType *cg_g_field_v = static_cast(cg_g_field); - stk_classic::mesh::parallel_reduce(*m_eMesh->get_bulk_data(), stk_classic::mesh::sum(*cg_g_field_v)); - - { - std::vector< const stk_classic::mesh::FieldBase *> fields; - fields.push_back(cg_g_field); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(m_eMesh->get_bulk_data()->shared_aura(), fields); - - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*m_eMesh->get_bulk_data()->ghostings()[0], fields); - } - - { - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_scale ) ); - m_scale = (m_scale < 1.0) ? 1.0 : 1.0/m_scale; - PRINT("tmp srk m_scale= " << m_scale); - } - - if (!m_use_local_scaling) - get_scale(mesh, domain); - } - - /// gets a global scale factor so that local gradient*scale is approximately the size of the local mesh edges - /// also uses the reference mesh to compute a local scaled gradient norm for convergence checks - void PMMParallelReferenceMeshSmoother1::get_scale( Mesh* mesh, MeshDomain *domain) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_s_field = eMesh->get_field("cg_s"); - stk_classic::mesh::FieldBase *cg_r_field = eMesh->get_field("cg_r"); - - stk_classic::mesh::FieldBase *cg_h_field = (m_use_hessian_scaling? eMesh->get_field("cg_h") : 0); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = eMesh->get_spatial_dim(); - - m_scale = 1.e-10; - - // element loop - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // FIXME - if (PerceptMesquiteMesh::select_bucket(**k, m_eMesh) && on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - - double edge_length_ave = m_eMesh->edge_length_ave(element, m_coord_field_original); - - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - VERIFY_OP_ON(isGhostNode, ==, false, "hmmmm"); - bool fixed = pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - continue; - - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - - for (int idim=0; idim < spatialDim; idim++) - { - m_scale = std::max(m_scale, std::abs(cg_g[idim])/edge_length_ave); - } - } - } - } - } - } - - if (m_use_local_scaling && m_stage==1) - // if (m_use_local_scaling) - { - m_scale = 1.0; - } - else - { - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_scale ) ); - m_scale = (m_scale < 1.0) ? 1.0 : 1.0/m_scale; - PRINT("tmp srk m_scale= " << m_scale); - } - - // node loop - m_scaled_grad_norm = 0.0; - double gn=0.0; - double el=1.e+10, es1=0, es2=0; - //double pw=std::max(m_metric->length_scaling_power() - 1.0,0.0); - - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - VERIFY_OP_ON(isGhostNode, ==, false, "hmmmm"); - bool fixed = pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - continue; - - double edge_length_ave = nodal_edge_length_ave(node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - double *cg_h = (m_use_hessian_scaling ? PerceptMesh::field_data(cg_h_field, node) : 0); - - double sum=0.0; - for (int idim=0; idim < spatialDim; idim++) - { - sum += cg_g[idim]*cg_g[idim]; - } - sum = std::sqrt(sum); - - if (0 && m_stage == 1 && sum > edge_length_ave) - { - for (int idim=0; idim < spatialDim; idim++) - { - cg_g[idim] = cg_g[idim]/sum*edge_length_ave; - } - sum = 1.0; - } - - gn = std::max(gn, sum); - double s1 = sum; - //sum = std::pow(sum, m_metric->length_scaling_power()); - double s2 = sum; - sum /= edge_length_ave; - //sum /= (pw != 0 ? std::pow(edge_length_ave, pw) : edge_length_ave); - //m_scaled_grad_norm = std::max(m_scaled_grad_norm, sum); - if ( m_use_hessian_scaling && spatialDim == 2 && m_stage==1) - //if ( m_use_hessian_scaling && spatialDim == 2 ) - { - m_scale = 1.0; - MsqMatrix<2,2> H(cg_h), HI; - double d = det(H); - //a00 - Sqrt(4*a01*a10 + Power(a00 - a11,2)) + a11)/2., (a00 + Sqrt(4*a01*a10 + Power(a00 - a11,2)) + a11)/2. - - double disc=4*H(0,1)*H(1,0) + std::pow(H(0,0) - H(1,1),2); - double eigen[] = {(H(0,0) - std::sqrt(disc) + H(1,1))/2., - (H(0,0) + std::sqrt(disc) + H(1,1))/2.}; - - //if (std::abs(d) > 1.e-10) - //if (d > 1.e-10) - if (s2 > 1.e-10 && (d < -1.e-6 || eigen[0] < -1.e-6 || eigen[1] < -1.e-6)) - { - std::cout << "det(H) = " << d << " H= " << H << " eigen= " << eigen[0] << " " << eigen[1] << " disc= " << disc << " grad= " << s2 << std::endl; - exit(1); - } - if (d > 1.e-10) - { - HI = inverse(H); - double gn[] = { cg_g[0], cg_g[1] }; - cg_g[0] = HI(0,0)*gn[0] + HI(0,1)*gn[1]; - cg_g[1] = HI(1,0)*gn[0] + HI(1,1)*gn[1]; - } - sum=0.0; - for (int idim=0; idim < spatialDim; idim++) - { - sum += cg_g[idim]*cg_g[idim]; - } - sum = std::sqrt(sum); - } - - if (sum > m_scaled_grad_norm) - { - m_scaled_grad_norm = sum; - el = edge_length_ave; - es1 = s1; - es2 = s2; - } - - - if (m_use_local_scaling && m_stage==1) - //if (m_use_local_scaling) - { - double *cg_r = PerceptMesh::field_data(cg_r_field, node); - double *cg_s = PerceptMesh::field_data(cg_s_field, node); - double len=0.0; - for (int idim=0; idim < spatialDim; idim++) - { - len += cg_r[idim]*cg_r[idim]; - } - len = std::sqrt(len); - if (len > edge_length_ave) - { - for (int idim=0; idim < spatialDim; idim++) - { - cg_s[idim] = cg_r[idim]/len*edge_length_ave; - } - } - } - - } - } - } - } - - { - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_scaled_grad_norm ) ); - PRINT("tmp srk m_scaled_grad_norm= " << m_scaled_grad_norm << " gn= " << gn << " el= " << el << " es1= " << es1 << " es2= " << es2); - } - - } - - double PMMParallelReferenceMeshSmoother1::run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - m_pmm = pmm; - PerceptMesh *eMesh = pmm->getPerceptMesh(); - - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_r_field = eMesh->get_field("cg_r"); - stk_classic::mesh::FieldBase *cg_d_field = eMesh->get_field("cg_d"); - stk_classic::mesh::FieldBase *cg_s_field = eMesh->get_field("cg_s"); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - bool total_valid=true; - - if (m_iter == 0) - { - m_dmax = 0.0; - - //PRINT_1("tmp srk get_gradient at m_iter=0"); - get_gradient(mesh, domain); - /// r = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_r_field); - /// s = r (allows for preconditioning later s = M^-1 r) - if (m_use_local_scaling && m_stage==1) - //if (m_use_local_scaling) - get_scale(mesh, domain); - else - eMesh->copy_field(cg_s_field, cg_r_field); - - /// d = s - eMesh->copy_field(cg_d_field, cg_s_field); - /// dnew = r.d - m_dnew = eMesh->nodal_field_dot(cg_r_field, cg_d_field); - PRINT("tmp srk m_dnew[0] = " << m_dnew); - - // FIXME - if (0) - { - double coord_mag = eMesh->nodal_field_dot(m_coord_field_current, m_coord_field_current); - if (!m_eMesh->get_rank()) printf("tmp srk m_dnew[%d] = %30.10g m_dmid= %30.10g coord_mag= %30.10g\n", m_iter, m_dnew, m_dmid, coord_mag); - } - - /// d0 = dnew - m_d0 = m_dnew; - m_grad_norm = std::sqrt(m_dnew); - } - - double metric_check = total_metric(mesh, 0.0, 1.0, total_valid); - m_total_metric = metric_check; - if (check_convergence() || metric_check == 0.0) - { - PRINT_1( "tmp srk already converged m_dnew= " << m_dnew << " gradNorm= " << gradNorm << " m_d0= " << m_d0 << " m_scaled_grad_norm= " << m_scaled_grad_norm); - //update_node_positions - return total_metric(mesh,0.0,1.0, total_valid); - } - - /// line search - bool restarted=false; - double alpha = m_scale; - { - double metric_0 = total_metric(mesh, 0.0, 1.0, total_valid); - double metric=0.0; - double tau = 0.5; - double c0 = 1.e-4; - double min_alpha_factor=1.e-12; - - double norm_gradient2 = eMesh->nodal_field_dot(cg_g_field, cg_g_field); - m_grad_norm = std::sqrt(norm_gradient2); - - double armijo_offset_factor = c0*norm_gradient2; - bool converged = false; - while (!converged) - { - metric = total_metric(mesh, alpha, 1.0, total_valid); - - double mfac = alpha*armijo_offset_factor; - converged = (metric < metric_0 + mfac); - if (m_untangled) converged = converged && total_valid; - PRINT( "tmp srk alpha= " << alpha << " metric_0= " << metric_0 << " metric= " << metric << " diff= " << metric - (metric_0 + mfac) - << " m_untangled = " << m_untangled - << " total_valid= " << total_valid ); - if (!converged) - alpha *= tau; - if (alpha < std::max(min_alpha_factor*m_scale, 1.e-16)) - break; - } - - if (!converged) - { - get_gradient(mesh, domain); - /// r = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_r_field); - if (m_use_local_scaling && m_stage==1) - //if (m_use_local_scaling) - get_scale(mesh, domain); - else - eMesh->copy_field(cg_s_field, cg_r_field); - norm_gradient2 = eMesh->nodal_field_dot(cg_g_field, cg_g_field); - m_grad_norm = std::sqrt(norm_gradient2); - - armijo_offset_factor = c0*norm_gradient2; - - alpha=m_scale; - /// d = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_d_field); - restarted = true; - - PRINT_1( "can't reduce metric= " << metric << " metric_0 + armijo_offset " << metric_0+alpha*armijo_offset_factor << " norm_gradient = " << std::sqrt(norm_gradient2) ); - - metric_0 = total_metric(mesh, 0.0, 1.0, total_valid); - if (m_stage != 0) VERIFY_OP_ON(total_valid, ==, true, "bad mesh..."); - double metric_1 = total_metric(mesh, 1.e-6, 1.0, total_valid); - PRINT_1( "tmp srk " << " metric_0= " << metric_0 << " metric(1.e-6) = " << metric_1 << " diff= " << metric_1-metric_0 ); - metric_1 = total_metric(mesh, -1.e-6, 1.0, total_valid); - PRINT_1( "tmp srk " << " metric_0= " << metric_0 << " metric(-1.e-6)= " << metric_1 << " diff= " << metric_1-metric_0 ); - } - - while (!converged) - { - metric = total_metric(mesh, alpha, 1.0, total_valid); - - double mfac = alpha*armijo_offset_factor; - converged = (metric < metric_0 + mfac); - if (m_untangled) converged = converged && total_valid; - PRINT_1( "tmp srk ### alpha= " << alpha << " metric_0= " << metric_0 << " metric= " << metric << " diff= " << metric - (metric_0 + mfac) - << " m_untangled = " << m_untangled - << " total_valid= " << total_valid ); - if (!converged) - alpha *= tau; - if (alpha < std::max(min_alpha_factor*m_scale, 1.e-16)) - break; - } - - if (!converged) - { - PRINT_1( "can't reduce metric 2nd time = " << metric << " metric_0 + armijo_offset " << metric_0+alpha*armijo_offset_factor << " norm_gradient = " << std::sqrt(norm_gradient2) << " m_scale= " << m_scale); - PRINT_1( "tmp srk 2nd m_dnew= " << m_dnew << " m_dmax= " << m_dmax << " gradNorm= " << gradNorm << " m_d0= " << m_d0 << " m_scaled_grad_norm= " << m_scaled_grad_norm); - if (check_convergence()) - { - PRINT_1( "tmp srk 2nd already converged m_dnew= " << m_dnew << " gradNorm= " << gradNorm << " m_d0= " << m_d0 << " m_scaled_grad_norm= " << m_scaled_grad_norm); - return total_metric(mesh,0.0,1.0, total_valid); - } - debug_print(0); - - //do_print_elem_val = true; - double metric_1 = total_metric(mesh, 1.e-6, 1.0, total_valid); - metric_0 = total_metric(mesh, 0.0, 1.0, total_valid); - //do_print_elem_val = false; - PRINT_1( "tmp srk " << " metric_0= " << metric_0 << " metric(1.e-6) = " << metric_1 << " diff= " << metric_1-metric_0 ); - metric_1 = total_metric(mesh, -1.e-6, 1.0, total_valid); - PRINT_1( "tmp srk " << " metric_0= " << metric_0 << " metric(-1.e-6)= " << metric_1 << " diff= " << metric_1-metric_0 ); - - throw std::runtime_error("can't reduce metric"); - } - - else - { - double a1 = alpha/2.; - double a2 = alpha; - double f0 = metric_0, f1 = total_metric(mesh, a1, 1.0, total_valid), f2 = total_metric(mesh, a2, 1.0, total_valid); - double den = 2.*(a2*(-f0 + f1) + a1*(f0 - f2)); - double num = a2*a2*(f1-f0)+a1*a1*(f0-f2); - if (std::fabs(den) > 1.e-10) - { - double alpha_quadratic = num/den; - if (alpha_quadratic > 1.e-10 && alpha_quadratic < 2*alpha) - { - double fm=total_metric(mesh, alpha_quadratic, 1.0, total_valid); - if (fm < f2 && (m_stage==0 || total_valid)) - { - alpha = alpha_quadratic; - PRINT( "tmp srk alpha_quadratic= " << alpha_quadratic << " alpha= " << a2 ); - } - if (fm < f2 && (m_stage!=0 && !total_valid)) - { - PRINT_1( "tmp srk WARNING !total_valid alpha_quadratic= " << alpha_quadratic << " alpha= " << a2 ); - } - } - } - - // try over-relaxation - if (0) - { - double an = alpha*1.5; - //double fa = total_metric(mesh, alpha, 1.0, total_valid); - double fn = total_metric(mesh, an, 1.0, total_valid); - if (fn < metric_0 && total_valid) - { - PRINT_1("tmp srk found accelerated alpha = " << an ); - alpha = an; - } - } - - } - } - - - /// x = x + alpha*d - m_alpha = alpha; - update_node_positions(mesh, alpha); - //PRINT_1( "tmp srk iter= "<< m_iter << " dmax= " << m_dmax << " alpha= " << alpha); - - if (DEBUG_PRINT) - { - bool total_valid_0=true; - total_metric(mesh, 0.0, 1.0, total_valid_0); - if (m_stage != 0) VERIFY_OP_ON(total_valid_0, ==, true, "bad mesh after update_node_positions..."); - } - - bool debug_par = false; - - // FIXME - double coord_mag = 0.0; - if (debug_par) coord_mag= eMesh->nodal_field_dot(m_coord_field_current, m_coord_field_current); - - /// f'(x) - get_gradient(mesh, domain); - double d_g = 0.0; - d_g = eMesh->nodal_field_dot(cg_g_field, cg_g_field); - m_grad_norm = std::sqrt(d_g); - if (debug_par) debug_print(alpha); - - /// r = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_r_field); - double d_r = 0.0; - if (debug_par) d_r = eMesh->nodal_field_dot(cg_r_field, cg_r_field); - - /// dold = dnew - m_dold = m_dnew; - - /// dmid = r.s - m_dmid = eMesh->nodal_field_dot(cg_r_field, cg_s_field); - - /// s = r (allows for preconditioning later s = M^-1 r) - if (m_use_local_scaling && m_stage==1) - //if (m_use_local_scaling) - get_scale(mesh, domain); - else - eMesh->copy_field(cg_s_field, cg_r_field); - - /// dnew = r.s - m_dnew = eMesh->nodal_field_dot(cg_r_field, cg_s_field); - //double f_cur=total_metric(mesh, 0.0, 1.0, total_valid); - //PRINT("tmp srk m_dnew[n] = " << m_dnew << " f_cur= " << f_cur << " total_valid= " << total_valid); - - double cg_beta = 0.0; - if (std::fabs(m_dold) < 1.e-12) - cg_beta = 0.0; - else - cg_beta = (m_dnew - m_dmid) / m_dold; - - PRINT("tmp srk beta = " << cg_beta); - - - // FIXME - int N = m_num_nodes; - if (m_iter % N == 0 || cg_beta <= 0.0 || restarted) - { - /// d = s - eMesh->copy_field(cg_d_field, cg_s_field); - } - else - { - /// d = s + beta * d - eMesh->nodal_field_axpby(1.0, cg_s_field, cg_beta, cg_d_field); - } - - double tm = total_metric(mesh,0.0,1.0, total_valid); - - if (debug_par) - { - double d_s=eMesh->nodal_field_dot(cg_s_field, cg_s_field); - if (0 && !m_eMesh->get_rank()) printf("dmax[%3d]=%20.12g tm=%20.12g dnew=%20.12g dmid= %20.12g d_g= %20.12g d_r= %20.12g d_s= %20.12g beta= %20.12g coord= %20.12g\n", - m_iter, m_dmax, tm, m_dnew, m_dmid, d_g, d_r, d_s, cg_beta, coord_mag); - if (!m_eMesh->get_rank()) printf("dmax[%3d]=%20.12e tm=%20.12e dnew=%20.12e d_g= %20.12e beta= %20.12e coord= %20.12e scl= %20.12e alp= %20.12e\n", - m_iter, m_dmax, tm, m_dnew, d_g, cg_beta, coord_mag, m_scale, alpha); - } - - return tm; - } - - void PMMParallelReferenceMeshSmoother1::debug_print(double alpha) - { - if (0) - { - //stk_classic::mesh::Selector on_locally_owned_part = ( m_eMesh->get_fem_meta_data()->locally_owned_part() ); - //stk_classic::mesh::Selector on_globally_shared_part = ( m_eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = m_eMesh->get_spatial_dim(); - stk_classic::mesh::FieldBase *cg_d_field = m_eMesh->get_field("cg_d"); - stk_classic::mesh::FieldBase *cg_g_field = m_eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_r_field = m_eMesh->get_field("cg_r"); - stk_classic::mesh::FieldBase *cg_s_field = m_eMesh->get_field("cg_s"); - - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // update local and globally shared - //if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - - double *coord_current = PerceptMesh::field_data(m_coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - double *cg_r = PerceptMesh::field_data(cg_r_field, node); - double *cg_s = PerceptMesh::field_data(cg_s_field, node); - - bool dopr=false; - unsigned nid = node.identifier(); - if (nid == 71 || nid == 84 || nid == 97) - //if (nid == 15) - dopr=true; - char buf[1024]; - std::ostringstream ostr; - bool owned = (node.owner_rank() == m_eMesh->get_rank()); - if (dopr) - ostr << "P[" << m_eMesh->get_rank() << "] dbp iter= " << m_iter << " nid= " << nid << " o= " << owned; - for (int i=0; i < spatialDim; i++) - { - double dt = alpha*cg_d[i]; - if (dopr) { - sprintf(buf, "dmax i= %d dt= %12g coord= %12g g= %12g r= %12g s= %12g d= %12g", i, dt, coord_current[i], cg_g[i], cg_r[i], cg_s[i], cg_d[i]); - ostr << buf; - } - } - if (dopr && owned) std::cout << ostr.str() << std::endl; - //if (dopr && m_eMesh->get_rank()==0) std::cout << ostr.str() << std::endl; - } - } - } - } - - if (1) - { - stk_classic::mesh::Selector on_locally_owned_part = ( m_eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( m_eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = m_eMesh->get_spatial_dim(); - stk_classic::mesh::FieldBase *cg_d_field = m_eMesh->get_field("cg_d"); - stk_classic::mesh::FieldBase *cg_g_field = m_eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_r_field = m_eMesh->get_field("cg_r"); - stk_classic::mesh::FieldBase *cg_s_field = m_eMesh->get_field("cg_s"); - - //if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - unsigned ids[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,71,84,97}; - unsigned idl = sizeof(ids)/sizeof(unsigned); - idl = 13*13; - for (unsigned i_node=0; i_node < idl; i_node++) - { - MPI_Barrier( MPI_COMM_WORLD ); - - //stk_classic::mesh::Entity* node_p = m_eMesh->get_bulk_data()->get_entity(0, ids[i_node]); - stk_classic::mesh::Entity* node_p = m_eMesh->get_bulk_data()->get_entity(0, i_node+1); - if (node_p) - { - stk_classic::mesh::Entity& node = *node_p; - - double *coord_current = PerceptMesh::field_data(m_coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - double *cg_r = PerceptMesh::field_data(cg_r_field, node); - double *cg_s = PerceptMesh::field_data(cg_s_field, node); - - bool dopr=true; - unsigned nid = node.identifier(); - char buf[1024]; - std::ostringstream ostr; - bool owned = (node.owner_rank() == m_eMesh->get_rank()); - if (dopr) - ostr << " nid= " << nid << " dmax "; - if (0) ostr << " owned= " << owned; - // ostr << "P[" << m_eMesh->get_rank() << "] dbp iter= " << m_iter << " nid= " << nid << " o= " << owned; - double ng[3]={0,0,0}; - bool ng_valid=true; - - { - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - bool fixed = m_pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - { - } - else - { - nodal_gradient(node, 0.0, coord_current, cg_d, ng_valid, ng); - } - } - for (int i=0; i < spatialDim; i++) - { - double dt = alpha*cg_d[i]; - if (dopr) { - if (0) sprintf(buf, "dt=%12g coord=%12g g=%12g r=%12g s=%12g d=%12g", dt, coord_current[i], cg_g[i], cg_r[i], cg_s[i], cg_d[i]); - if (0) sprintf(buf, "coord=%35.18e g=%35.18e ", coord_current[i], cg_g[i]); - sprintf(buf, "g=%20.12e ng=%20.12e diff=%20.12e ", cg_g[i], ng[i], cg_g[i]-ng[i]); - ostr << buf; - } - } - //if (dopr && owned) std::cout << ostr.str() << std::endl; - //if (dopr && m_eMesh->get_rank()==0) std::cout << ostr.str() << std::endl; - if (dopr && owned) std::cout << ostr.str() << std::endl; - } - MPI_Barrier( MPI_COMM_WORLD ); - - } - } - - } - - void PMMParallelReferenceMeshSmoother1::update_node_positions(Mesh* mesh, double alpha) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = eMesh->get_spatial_dim(); - stk_classic::mesh::FieldBase *cg_d_field = eMesh->get_field("cg_d"); - //stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - - m_dmax = 0.0; - //debug_print(alpha); - - // node loop: update node positions - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // update local and globally shared - if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool fixed = pmm->get_fixed_flag(&node); - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - if (fixed || isGhostNode) - { - continue; - } - - double *coord_current = PerceptMesh::field_data(m_coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - - for (int i=0; i < spatialDim; i++) - { - double dt = alpha*cg_d[i]; - m_dmax = std::max(std::fabs(dt), m_dmax); - coord_current[i] += dt; - } - } - } - } - } - - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_dmax ) ); - - { - std::vector< const stk_classic::mesh::FieldBase *> fields; - fields.push_back(m_eMesh->get_coordinates_field()); - //fields.push_back(cg_g_field); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(m_eMesh->get_bulk_data()->shared_aura(), fields); - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*m_eMesh->get_bulk_data()->ghostings()[0], fields); - } - - - } - - double PMMParallelReferenceMeshSmoother1::total_metric(Mesh *mesh, double alpha, double multiplicative_edge_scaling, bool& valid, int* num_invalid) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - stk_classic::mesh::FieldBase *coord_field = m_eMesh->get_coordinates_field(); - stk_classic::mesh::FieldBase *coord_field_current = coord_field; - stk_classic::mesh::FieldBase *coord_field_lagged = m_eMesh->get_field("coordinates_lagged"); - - stk_classic::mesh::FieldBase *cg_d_field = m_eMesh->get_field("cg_d"); - - stk_classic::mesh::Selector on_locally_owned_part = ( m_eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( m_eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = m_eMesh->get_spatial_dim(); - - double mtot = 0.0; - int n_invalid=0; - - // cache coordinates - m_eMesh->copy_field(coord_field_lagged, coord_field_current); - - // node loop - { - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // update local and globally shared - if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool fixed = pmm->get_fixed_flag(&node); - if (fixed) - { - continue; - } - - double *coord_current = PerceptMesh::field_data(coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - - for (int i=0; i < spatialDim; i++) - { - double dt = alpha * cg_d[i]; - coord_current[i] += dt; - } - } - } - } - } - - valid = true; - if (m_metric->is_nodal()) - { - // node loop - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool fixed = pmm->get_fixed_flag(&node); - if (fixed) - { - continue; - } - - double *coord_current = PerceptMesh::field_data(coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - - bool local_valid = true; - double nm = nodal_metric(node, 0.0, coord_current, cg_d, local_valid); - if (!local_valid) n_invalid++; - valid = valid && local_valid; - mtot += nm; - } - } - } - } - else - { - // element loop - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (PerceptMesquiteMesh::select_bucket(**k, m_eMesh) && on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - m_metric->m_topology_data = m_eMesh->get_cell_topology(bucket); - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - bool local_valid=true; - double mm = metric(element, local_valid); - if (!local_valid) n_invalid++; - - valid = valid && local_valid; - if (do_print_elem_val) PRINT( "element= " << element.identifier() << " metric= " << mm ); - if (do_print_elem_val && element.identifier() == 13) { std::cout << element.identifier() << " iter= " << m_iter << " element= " << element.identifier() << " metric= " << mm << std::endl;} - mtot += mm; - } - } - } - } - - // reset coordinates - m_eMesh->copy_field(coord_field_current, coord_field_lagged); - - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceSum<1>( & mtot ) ); - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMin<1>( & valid ) ); - - if (num_invalid) - { - *num_invalid = n_invalid; - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceSum<1>( num_invalid ) ); - } - - return mtot; - - } - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.hpp deleted file mode 100644 index 0cda40dd8ac0..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother1.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMParallelReferenceMeshSmoother1_hpp -#define PMMParallelReferenceMeshSmoother1_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - /// A Jacobian based optimization smoother, e.g. 1/A - 1/W, W/A - I, etc. (A = local current Jacobian, W is for original mesh) - /// Conjugate-gradient version, element-based metrics - class PMMParallelReferenceMeshSmoother1 : public PMMParallelReferenceMeshSmoother { - - public: - - /// max_edge_length_factor: used for scaling gradients to approximately this value times local edge length - PMMParallelReferenceMeshSmoother1(double max_edge_length_factor=1.0, - int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : PMMParallelReferenceMeshSmoother(inner_iterations, cpu_time, grad_norm, parallel_iterations), - m_max_edge_length_factor(max_edge_length_factor), m_pmm(0) - {} - - - protected: - double m_max_edge_length_factor; - - virtual void get_gradient( Mesh* mesh, MeshDomain *domain); - virtual void get_scale( Mesh* mesh, MeshDomain *domain); - void debug_print(double alpha); - - virtual double run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ); - - virtual double total_metric(Mesh *mesh, double alpha, double multiplicative_edge_scaling, bool& valid, int *num_invalid=0); - virtual double metric(stk_classic::mesh::Entity& entity, bool& valid); - virtual void update_node_positions(Mesh* mesh, double alpha); - virtual bool check_convergence(); - - double nodal_metric(stk_classic::mesh::Entity& node, double alpha, double *coord_current, double *cg_d, bool& valid ); - void nodal_gradient(stk_classic::mesh::Entity& node, double alpha, double *coord_current, double *cg_d, bool& valid, double *ng); - double nodal_edge_length_ave(stk_classic::mesh::Entity& node); - - PerceptMesquiteMesh *m_pmm; - - }; - - - } -} - -#endif -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.cpp deleted file mode 100644 index 537b5a746e79..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.cpp +++ /dev/null @@ -1,275 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include -#include -#include -#include - -#include -#include - -#include "mpi.h" -#include - -#define DEBUG_PRINT 0 -#define PRINT(a) do { if (DEBUG_PRINT && !m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_1(a) do { if (!m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_2(a) do { std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << " "; } while(0) - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - - double PMMParallelReferenceMeshSmoother2::run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - - int spatialDim = m_eMesh->get_spatial_dim(); - - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_r_field = eMesh->get_field("cg_r"); - stk_classic::mesh::FieldBase *cg_d_field = eMesh->get_field("cg_d"); - stk_classic::mesh::FieldBase *cg_s_field = eMesh->get_field("cg_s"); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - bool total_valid=true; - - bool reduced_metric=false; - - m_dmax = 0.0; - get_gradient(mesh, domain); - - { - /// r = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_r_field); - /// s = r (allows for preconditioning later s = M^-1 r) - eMesh->copy_field(cg_s_field, cg_r_field); - /// d = s - eMesh->copy_field(cg_d_field, cg_s_field); - /// dnew = r.d - m_dnew = eMesh->nodal_field_dot(cg_r_field, cg_d_field); - } - - double metric_orig = total_metric(mesh, 0.0, 1.0, total_valid); - m_total_metric = metric_orig; - if (check_convergence() || metric_orig == 0.0) - { - PRINT_1( "tmp srk already converged m_dnew= " << m_dnew << " gradNorm= " << gradNorm << " m_d0= " << m_d0 ); - //update_node_positions - return total_metric(mesh,0.0,1.0, total_valid); - } - - // node loop: local line search - double alpha_min = 1.e+30; - double alpha_max = 0.0; - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->node_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - // update local and globally shared - //if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool fixed = pmm->get_fixed_flag(&node); - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - if (fixed || isGhostNode) - { - continue; - } - - //double edge_length_ave = m_eMesh->edge_length_ave(element); - double edge_length_ave = nodal_edge_length_ave(node); - - double *coord_current = PerceptMesh::field_data(m_coord_field_current, node); - double *cg_d = PerceptMesh::field_data(cg_d_field, node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - - double local_scale = 0.0; - for (int i=0; i < spatialDim; i++) - { - local_scale = std::max(local_scale, std::abs(cg_g[i])/edge_length_ave); - } - - local_scale = (local_scale < 1.0) ? 1.0 : 1.0/local_scale; - //PRINT("tmp srk node= " << node.identifier() << " iter= " << m_iter << " local_scale= " << local_scale); - - /// line search - - //get_nodal_gradient(node, cg_g_local); - double norm_gradient2 = 0.0; - for (int i=0; i < spatialDim; i++) - { - norm_gradient2 += cg_g[i]*cg_g[i]; - } - - double alpha = local_scale; // m_scale - if (std::sqrt(norm_gradient2) > edge_length_ave*1.e-8) - { - bool local_valid=true, local_valid_0=true, local_valid_1=true; - double metric_0 = nodal_metric(node, 0.0, coord_current, cg_d, local_valid_0); - double metric=0.0; - //double sigma=0.95; - double tau = 0.5; - double c0 = 1.e-4; - - double armijo_offset_factor = c0*norm_gradient2; - bool converged = false; - while (!converged) - { - metric = nodal_metric(node, alpha, coord_current, cg_d, local_valid); - - //converged = (metric > sigma*metric_0) && (alpha > 1.e-16); - double mfac = alpha*armijo_offset_factor; - converged = metric == 0.0 || (metric < metric_0 + mfac); - if (m_untangled) converged = converged && local_valid; - PRINT( "tmp srk node= " << node.identifier() << " iter= " << m_iter - << " alpha= " << alpha << " metric_0= " << metric_0 << " metric= " << metric << " diff= " << metric - (metric_0 + mfac) - << " m_untangled = " << m_untangled << " norm_gradient2= " << norm_gradient2 - << " local_valid= " << local_valid ); - if (!converged) - alpha *= tau; - if (alpha < std::max(1.e-6*m_scale, 1.e-16)) - { - PRINT_1( "tmp srk not conv node= " << node.identifier() << " iter= " << m_iter - << " alpha= " << alpha << " metric_0= " << metric_0 << " metric= " << metric << " diff= " << metric - (metric_0 + mfac) - << " m_untangled = " << m_untangled << " norm_gradient2= " << norm_gradient2 - << " local_valid= " << local_valid ); - - break; - } - } - //if (metric > sigma*metric_0) - if (!converged) - { - metric_0 = nodal_metric(node, 0.0, coord_current, cg_d, local_valid_0); - double metric_1 = nodal_metric(node, 1.e-6, coord_current, cg_d, local_valid_1); - PRINT_1( "tmp srk can't reduce metric, node= " << node.identifier() << " iter= " << m_iter - << " alpha= " << alpha << " metric_0= " << metric_0 << " metric[1.e-6]= " << metric_1 << " diff[want neg]= " << metric_1 - metric_0 - << "\n m_untangled = " << m_untangled << " norm_gradient2= " << norm_gradient2 - << " local_valid= " << local_valid - << " local_valid_0= " << local_valid_0 - << " local_valid_1= " << local_valid_1 - << " cg_d= " << cg_d[0] << " " << cg_d[1] << " edge_length_ave= " << edge_length_ave); - alpha = 0.0; - } - else - { - reduced_metric = true; - double a1 = alpha/2.; - double a2 = alpha; - double f0 = metric_0, - f1 = nodal_metric(node, a1, coord_current, cg_d, total_valid), - f2 = nodal_metric(node, a2, coord_current, cg_d, total_valid); - double den = 2.*(a2*(-f0 + f1) + a1*(f0 - f2)); - double num = a2*a2*(f1-f0)+a1*a1*(f0-f2); - if (std::fabs(den) > 1.e-10) - { - double alpha_quadratic = num/den; - if (alpha_quadratic < 2.0*alpha) - { - double fm = nodal_metric(node, alpha_quadratic, coord_current, cg_d, total_valid); - //if (fm < f2 && (!m_untangled || total_valid)) - if (fm < f2) - { - alpha = alpha_quadratic; - PRINT( "tmp srk alpha_quadratic= " << alpha_quadratic << " alpha= " << a2 ); - } - } - } - } - } - alpha_min = std::min(alpha_min, alpha); - alpha_max = std::max(alpha_max, alpha); - // scale cg_d by local alpha - for (int i=0; i < spatialDim; i++) - { - cg_d[i] *= alpha; - } - } // node in bucket loop - } - } // bucket loop - } - - /// check for valid mesh - double alpha_global = 1.0; - if (m_stage == 1) - { - bool converged = false; - while (!converged) - { - int num_invalid=0; - double metric_new = total_metric(mesh, alpha_global, 1.0, total_valid, &num_invalid); - PRINT_1( "tmp srk global alpha = " << alpha_global << " metric_new= " << metric_new << " total_valid= " << total_valid << " num_invalid= " << num_invalid); - if (total_valid) - { - converged = true; - break; - } - else - { - alpha_global *= 0.5; - } - if (alpha_global < 1.e-10) - { - break; - } - } - //if (metric > sigma*metric_0) - if (!converged) - { - bool local_valid_0=true, local_valid_1=true; - double metric_0 = total_metric(mesh,0.0, 1.0, local_valid_0); - double metric_1 = total_metric(mesh, 1.e-6, 1.0, local_valid_1); - PRINT_1( "tmp srk can't get valid mesh... " - " metric_0= " << metric_0 << " metric[1.e-6]= " << metric_1 << " diff[want neg]= " << metric_1 - metric_0 - << "\n m_untangled = " << m_untangled - << " local_valid_0= " << local_valid_0 - << " local_valid_1= " << local_valid_1 ); - } - } - - /// x = x + alpha*d - m_dmax=0.0; - update_node_positions(mesh, alpha_global); - double metric_new = total_metric(mesh,0.0, 1.0, total_valid); - PRINT_1( "tmp srk iter= "<< m_iter << " dmax= " << m_dmax << " alpha_min= " << alpha_min << " alpha_max= " << alpha_max << " total_valid= " << total_valid); - if (m_stage == 1 && !total_valid) - { - throw std::runtime_error("created bad mesh"); - } - - //if (!reduced_metric || metric_new >= metric_orig) - if (!reduced_metric ) - { - PRINT_1( "can't reduce metric, metric_new= " << metric_new << " metric_0 = " << metric_orig << " reduced_metric= " << reduced_metric); - throw std::runtime_error("can't reduce metric"); - } - - return metric_new; - } - - - } -} - - -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.hpp deleted file mode 100644 index da6e13c6aded..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother2.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMParallelReferenceMeshSmoother2_hpp -#define PMMParallelReferenceMeshSmoother2_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - /// A Jacobian based optimization smoother, eg. 1/A - 1/W (A = local current Jacobian, W is for original mesh) - /// LOCAL patch version - class PMMParallelReferenceMeshSmoother2 : public PMMParallelReferenceMeshSmoother1 { - - public: - - /// max_edge_length_factor: used for scaling gradients to approximately this value times local edge length - PMMParallelReferenceMeshSmoother2(double max_edge_length_factor=1.0, - int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : PMMParallelReferenceMeshSmoother1(max_edge_length_factor, inner_iterations, cpu_time, grad_norm, parallel_iterations) - {} - - - protected: - - virtual double run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ); - - }; - - - } -} - -#endif -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.cpp deleted file mode 100644 index 1967528f13e6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include -#include -#include -#include - -#include -#include -#include - -#include "mpi.h" -#include - -#define DEBUG_PRINT 0 -#define PRINT(a) do { if (DEBUG_PRINT && !m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_1(a) do { if (!m_eMesh->get_rank()) std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << std::endl; } while(0) -#define PRINT_2(a) do { std::cout << "P[" << m_eMesh->get_rank() <<"] " << a << " "; } while(0) - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - //static double sqrt_eps = std::sqrt(std::numeric_limits::epsilon()); - - using namespace Mesquite; - - -#if 0 - bool PMMParallelReferenceMeshSmoother3::check_convergence() - { - if (m_stage == 0 && (m_dnew == 0.0 || m_total_metric == 0.0)) - { - return true; // for untangle - } - if (m_stage == 0 && m_num_invalid == 0 && (m_dmax < gradNorm || m_scaled_grad_norm < gradNorm)) - { - return true; - } - if (m_num_invalid == 0 && (m_scaled_grad_norm < gradNorm || (m_iter > 0 && m_dmax < gradNorm && m_dnew < gradNorm*gradNorm*m_d0))) - { - return true; - } - return false; - } - - /// gets a global scale factor so that local gradient*scale is approximately the size of the local mesh edges - /// also uses the reference mesh to compute a local scaled gradient norm for convergence checks - void PMMParallelReferenceMeshSmoother3::get_scale( Mesh* mesh, MeshDomain *domain) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - int spatialDim = eMesh->get_spatial_dim(); - - m_scale = 1.e-10; - - // element loop - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (PerceptMesquiteMesh::select_bucket(**k, m_eMesh) && on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - - double edge_length_ave = m_eMesh->edge_length_ave(element, m_coord_field_original); - - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = * elem_nodes[ inode ].entity(); - - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - VERIFY_OP_ON(isGhostNode, ==, false, "hmmmm"); - bool fixed = pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - continue; - - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - - for (int idim=0; idim < spatialDim; idim++) - { - m_scale = std::max(m_scale, std::abs(cg_g[idim])/edge_length_ave); - } - } - } - } - } - } - - { - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_scale ) ); - m_scale = (m_scale < 1.0) ? 1.0 : 1.0/m_scale; - PRINT("tmp srk m_scale= " << m_scale); - } - - // node loop - m_scaled_grad_norm = 0.0; - double gn=0.0; - double el=1.e+10, es1=0, es2=0; - //double pw=std::max(m_metric->length_scaling_power() - 1.0,0.0); - - { - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - bool isGhostNode = !(on_locally_owned_part(node) || on_globally_shared_part(node)); - VERIFY_OP_ON(isGhostNode, ==, false, "hmmmm"); - bool fixed = pmm->get_fixed_flag(&node); - if (fixed || isGhostNode) - continue; - - double edge_length_ave = nodal_edge_length_ave(node); - double *cg_g = PerceptMesh::field_data(cg_g_field, node); - - double sum=0.0; - for (int idim=0; idim < spatialDim; idim++) - { - sum += cg_g[idim]*cg_g[idim]; - } - sum = std::sqrt(sum); - gn = std::max(gn, sum); - double s1 = sum; - //sum = std::pow(sum, m_metric->length_scaling_power()); - double s2 = sum; - sum /= edge_length_ave; - //sum /= (pw != 0 ? std::pow(edge_length_ave, pw) : edge_length_ave); - //m_scaled_grad_norm = std::max(m_scaled_grad_norm, sum); - if (sum > m_scaled_grad_norm) - { - m_scaled_grad_norm = sum; - el = edge_length_ave; - es1 = s1; - es2 = s2; - } - } - } - } - } - - { - stk_classic::all_reduce( m_eMesh->get_bulk_data()->parallel() , ReduceMax<1>( & m_scaled_grad_norm ) ); - PRINT("tmp srk m_scaled_grad_norm= " << m_scaled_grad_norm << " gn= " << gn << " el= " << el << " es1= " << es1 << " es2= " << es2); - } - - } -#endif - - double PMMParallelReferenceMeshSmoother3::run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ) - { - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - m_pmm = pmm; - PerceptMesh *eMesh = pmm->getPerceptMesh(); - - stk_classic::mesh::FieldBase *cg_g_field = eMesh->get_field("cg_g"); - stk_classic::mesh::FieldBase *cg_d_field = eMesh->get_field("cg_d"); - - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( eMesh->get_fem_meta_data()->globally_shared_part() ); - bool total_valid=true; - - if (1) //m_iter == 0) - { - m_dmax = 0.0; - - //PRINT_1("tmp srk get_gradient at m_iter=0"); - get_gradient(mesh, domain); - - // d = -g - eMesh->nodal_field_axpby(-1.0, cg_g_field, 0.0, cg_d_field); - - m_dnew = eMesh->nodal_field_dot(cg_d_field, cg_d_field); - PRINT("tmp srk m_dnew = " << m_dnew); - - // FIXME - if (0) - { - double coord_mag = eMesh->nodal_field_dot(m_coord_field_current, m_coord_field_current); - if (!m_eMesh->get_rank()) printf("tmp srk m_dnew[%d] = %30.10g m_dmid= %30.10g coord_mag= %30.10g\n", m_iter, m_dnew, m_dmid, coord_mag); - } - - /// d0 = dnew - if (m_iter==0) m_d0 = m_dnew; - m_grad_norm = std::sqrt(m_dnew); - } - - double metric_check = total_metric(mesh, 0.0, 1.0, total_valid); - m_total_metric = metric_check; - if (check_convergence() || metric_check == 0.0) - { - PRINT_1( "tmp srk already converged m_dnew= " << m_dnew << " gradNorm= " << gradNorm << " m_d0= " << m_d0 << " m_scaled_grad_norm= " << m_scaled_grad_norm); - //update_node_positions - return total_metric(mesh,0.0,1.0, total_valid); - } - - /// line search - double cfl_factor = 0.2; - double alpha = m_scale*cfl_factor; - double metric_0 = total_metric(mesh, 0.0, 1.0, total_valid); - double metric=0.0; - metric = total_metric(mesh, alpha, 1.0, total_valid); - //converged = (metric < metric_0 + mfac); - // if (m_untangled) converged = converged && total_valid; - PRINT_1( "tmp srk alpha= " << alpha << " metric_0= " << metric_0 << " metric= " << metric << " diff= " << metric - (metric_0 ) - << " m_untangled = " << m_untangled - << " total_valid= " << total_valid ); - - /// x = x + alpha*d - m_alpha = alpha; - update_node_positions(mesh, alpha); - //PRINT_1( "tmp srk iter= "<< m_iter << " dmax= " << m_dmax << " alpha= " << alpha); - - if (DEBUG_PRINT) - { - bool total_valid_0=true; - total_metric(mesh, 0.0, 1.0, total_valid_0); - if (m_stage != 0) VERIFY_OP_ON(total_valid_0, ==, true, "bad mesh after update_node_positions..."); - } - - double tm = total_metric(mesh,0.0,1.0, total_valid); - - return tm; - } - - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.hpp deleted file mode 100644 index bcbb462599be..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelReferenceMeshSmoother3.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMParallelReferenceMeshSmoother3_hpp -#define PMMParallelReferenceMeshSmoother3_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - /// A Jacobian based optimization smoother - time-stepping approach, element-based metrics - class PMMParallelReferenceMeshSmoother3 : public PMMParallelReferenceMeshSmoother1 { - - public: - - /// max_edge_length_factor: used for scaling gradients to approximately this value times local edge length - PMMParallelReferenceMeshSmoother3(double max_edge_length_factor=1.0, - int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : PMMParallelReferenceMeshSmoother1(max_edge_length_factor, inner_iterations, cpu_time, grad_norm, parallel_iterations) - {} - - - protected: - //virtual void get_scale( Mesh* mesh, MeshDomain *domain); - - virtual double run_one_iteration( Mesh* mesh, MeshDomain *domain, MsqError& err ); - - }; - - - } -} - -#endif -#endif - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.cpp deleted file mode 100644 index b23e3d0f9a58..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.cpp +++ /dev/null @@ -1,344 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PMeanPTemplate.hpp" -#include "TQualityMetric.hpp" -#include "AddQualityMetric.hpp" - -#include "TShapeB1.hpp" -#include "TShapeNB1.hpp" - -#include "mpi.h" - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - using namespace Mesquite; - - // this is a sample (unfinished) implementation of how we might use Mesquite (needs to have global - // updates of ConjugateGradient global quantities, etc, to make it produce parallel/serial consistency) - double PMMParallelShapeImprover::PMMParallelShapeImprovementWrapper::run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ) - { - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper::run_one_iteration start..." << std::endl; - - // define shape improver - IdealWeightInverseMeanRatio inverse_mean_ratio; - inverse_mean_ratio.set_averaging_method( QualityMetric::LINEAR ); - LPtoPTemplate obj_func( 2, &inverse_mean_ratio ); - - ConjugateGradient shape_solver( &obj_func ); - TerminationCriterion term_inner(""), term_outer(""); - term_inner.write_iterations("shape.gpt", err); - - shape_solver.use_global_patch(); - //!!! qa->add_quality_assessment( &inverse_mean_ratio ); - - //!term_inner.add_relative_successive_improvement( successiveEps ); - - //term_inner.add_absolute_gradient_L2_norm( gradNorm ); - //term_inner.add_absolute_vertex_movement(0.0); - term_inner.add_iteration_limit( 1 ); - - //term_outer.add_absolute_gradient_L2_norm( gradNorm ); - //term_outer.add_absolute_vertex_movement(0.0); - term_outer.add_iteration_limit( 1 ); - - //term_outer.add_absolute_quality_improvement( 1.e-6 ); - //!term_outer.add_relative_successive_improvement( successiveEps ); - - shape_solver.set_inner_termination_criterion( &term_inner ); - shape_solver.set_outer_termination_criterion( &term_outer ); - - Timer totalTimer; - - // Run shape improver - InstructionQueue q2; - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper: running shape improver... \n" << std::endl; - - QualityAssessor qa_check( &inverse_mean_ratio ); - - Settings settings; - - q2.add_quality_assessor( &qa_check, err ); - q2.set_master_quality_improver( &shape_solver, err ); - q2.run_common( mesh, 0, domain, &settings, err ); - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper: running shape improver... done \n" << std::endl; - - return 0; - } - - void PMMParallelShapeImprover::PMMParallelShapeImprovementWrapper::run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ) - { -#if 0 - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper innerIter= " << innerIter << " parallelIterations= " << parallelIterations << std::endl; - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper: running shape improver... \n" << std::endl; - - PerceptMesquiteMesh *pmm = dynamic_cast(mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - stk_classic::mesh::FieldBase *coord_field = eMesh->get_coordinates_field(); - stk_classic::mesh::FieldBase *coord_field_current = coord_field; - stk_classic::mesh::FieldBase *coord_field_projected = eMesh->get_field("coordinates_N"); - stk_classic::mesh::FieldBase *coord_field_original = eMesh->get_field("coordinates_NM1"); - - //double alphas[] = {0.0,0.001,0.01,0.1,0.2,0.4,0.6,0.8,1.0}; - //double alphas[] = {0.001,0.01,0.1,0.2,0.4,0.6,0.8,1.0}; - double alphas[] = {0.001}; - int nalpha = sizeof(alphas)/sizeof(alphas[0]); - - for (int outer = 0; outer < nalpha; outer++) - { - double alpha = alphas[outer]; - - // set current state and evaluate mesh validity - eMesh->nodal_field_axpbypgz(alpha, coord_field_projected, (1.0-alpha), coord_field_original, 0.0, coord_field_current); - - int num_invalid = parallel_count_invalid_elements(eMesh); - if (!get_parallel_rank()) - std::cout << "\ntmp srk PMMParallelShapeImprover num_invalid current= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : "OK") - << std::endl; - -#if 0 - for (int iter = 0; iter < innerIter; iter++) - { - // - int num_invalid = parallel_count_invalid_elements(eMesh); - if (!get_parallel_rank()) - std::cout << "\ntmp srk PMMParallelShapeImprover num_invalid current= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : "OK") - << std::endl; - run_one_iteration(mesh, err); - sync_fields(); - check_convergence(); - } -#endif - } - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelShapeImprovementWrapper: running shape improver... done \n" << std::endl; - - MSQ_ERRRTN(err); -#endif - } - - - /// preferred for parallel - int PMMParallelShapeImprover::parallel_count_invalid_elements(PerceptMesh *eMesh) - { - PMMSmootherMetricUntangle utm(eMesh); - stk_classic::mesh::FieldBase *coord_field_current = eMesh->get_coordinates_field(); - stk_classic::mesh::FieldBase *coord_field_original = eMesh->get_field("coordinates_NM1"); - JacobianUtil jacA, jacW; - - double detA_min = std::numeric_limits::max(); - double detW_min = std::numeric_limits::max(); - double shapeA_max = 0.0; - double shapeW_max = 0.0; - const bool get_mesh_diagnostics = false; - - int num_invalid=0; - // element loop - { - stk_classic::mesh::Selector on_locally_owned_part = ( eMesh->get_fem_meta_data()->locally_owned_part() ); - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (PerceptMesquiteMesh::select_bucket(**k, eMesh) && on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - const CellTopologyData* topology_data = eMesh->get_cell_topology(bucket); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - bool valid=true; - if (get_mesh_diagnostics) - { - double A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *eMesh, element, coord_field_current, topology_data); - jacW(W_, *eMesh, element, coord_field_original, topology_data); - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - double detWi = jacW.m_detJ[i]; - MsqMatrix<3,3>& W = jacW.m_J[i]; - MsqMatrix<3,3>& A = jacA.m_J[i]; - if (detAi <= 0.) - { - valid = false; - } - detA_min = std::min(detA_min, detAi); - detW_min = std::min(detW_min, detWi); - double frobAi = std::sqrt(my_sqr_Frobenius(A)); - double frobWi = std::sqrt(my_sqr_Frobenius(W)); - double shapeAi = std::abs(frobAi*frobAi*frobAi/(3*std::sqrt(3.)*detAi) - 1.0); - double shapeWi = std::abs(frobWi*frobWi*frobWi/(3*std::sqrt(3.)*detWi) - 1.0); - shapeA_max = std::max(shapeA_max, shapeAi); - shapeW_max = std::max(shapeW_max, shapeWi); - } - } - else - { - utm.metric(element, valid); - } - if (!valid) - ++num_invalid; - } - } - } - } - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceSum<1>( &num_invalid ) ); - if (get_mesh_diagnostics) - { - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceMin<1>( &detA_min ) ); - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceMin<1>( &detW_min ) ); - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceMax<1>( &shapeA_max ) ); - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceMax<1>( &shapeW_max ) ); - if (eMesh->get_rank() == 0) - { - std::cout << "P[0] detA_min= " << detA_min << " detW_min= " << detW_min - << " shapeA_max= " << shapeA_max << " shapeW_max= " << shapeW_max << std::endl; - } - } - return num_invalid; - } - - - int PMMParallelShapeImprover::count_invalid_elements(Mesh &mesh, MeshDomain *domain) - { - MsqError err; - InstructionQueue q; - int num_invalid = 0; - VERIFY_OP_ON(get_parallel_size(), ==, 1, "not ready for parallel; use PerceptMesh form of count_invalid_elements"); - - if (1) - { - IdealWeightInverseMeanRatio metric; - //metric.set_averaging_method( QualityMetric::LINEAR ); - - // Check for inverted elements in the mesh - QualityAssessor inv_check( &metric ); - inv_check.disable_printing_results(); - q.add_quality_assessor( &inv_check, err ); MSQ_ERRZERO(err); - Settings settings; - q.run_common( &mesh, 0, domain, &settings, err ); MSQ_ERRZERO(err); - const QualityAssessor::Assessor* inv_b = inv_check.get_results( &metric ); - num_invalid = inv_b->get_invalid_element_count(); - } - else - { - // Set up barrier metric to see if mesh contains inverted elements - TShapeB1 mu_b; - IdealShapeTarget w_ideal; - TQualityMetric barrier( &w_ideal, &mu_b ); - - // Check for inverted elements in the mesh - QualityAssessor inv_check( &barrier ); - inv_check.disable_printing_results(); - q.add_quality_assessor( &inv_check, err ); MSQ_ERRZERO(err); - Settings settings; - q.run_common( &mesh, 0, domain, &settings, err ); MSQ_ERRZERO(err); - const QualityAssessor::Assessor* inv_b = inv_check.get_results( &barrier ); - num_invalid = inv_b->get_invalid_element_count(); - } - - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceSum<1>( &num_invalid ) ); - - return num_invalid; - } - - void PMMParallelShapeImprover::run(Mesquite::Mesh &mesh, Mesquite::MeshDomain *domain, bool always_smooth, int debug) - { -#ifdef USE_CALLGRIND - CALLGRIND_START_INSTRUMENTATION - CALLGRIND_TOGGLE_COLLECT -#endif - if (debug) - { - Mesquite::MsqDebug::enable(1); - if (debug > 1) Mesquite::MsqDebug::enable(2); - if (debug > 2) Mesquite::MsqDebug::enable(3); - } - - Mesquite::ParallelMesh *pmesh = dynamic_cast(&mesh); - if (!get_parallel_rank()) std::cout << "tmp srk PMMParallelShapeImprover::run: pmesh= " << pmesh << std::endl; - - PerceptMesquiteMesh *pmm = dynamic_cast(&mesh); - PerceptMesh *eMesh = pmm->getPerceptMesh(); - - Mesquite::MsqError mErr; - int num_invalid = parallel_count_invalid_elements(eMesh); - if (!get_parallel_rank()) - std::cout << "\ntmp srk PMMParallelShapeImprover num_invalid before= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : - (!always_smooth ? "WARNING: no smoothing requested since always_smooth=false" : " ")) - << std::endl; - //if (num_invalid) throw std::runtime_error("PMMParallelShapeImprover can't start from invalid mesh..."); - - if (always_smooth) - { - //int msq_debug = debug; // 1,2,3 for more debug info - - bool do_untangle_only = false; - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk innerIter= " << innerIter << " parallelIterations= " << parallelIterations << std::endl; - //PMMParallelShapeImprover::PMMParallelShapeImprovementWrapper siw(innerIter, 0.0, gradNorm, parallelIterations); - //PMMParallelReferenceMeshSmoother siw(innerIter, 0.0, gradNorm, parallelIterations); - //PMMParallelReferenceMeshSmoother1 siw(0.05, innerIter, 0.0, gradNorm, parallelIterations); - PMMParallelReferenceMeshSmoother1 siw(0.05, innerIter, 0.0, gradNorm, parallelIterations); - siw.m_do_untangle_only = do_untangle_only; - siw.run_instructions(&mesh, domain, mErr); - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMParallelShapeImprover: MsqError after ShapeImprovementWrapper: " << mErr << std::endl; - - num_invalid = parallel_count_invalid_elements(eMesh); - //if (!get_parallel_rank()) - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMParallelShapeImprover num_invalid after= " << num_invalid << " " - << (num_invalid ? " ERROR still have invalid elements after Mesquite smoothing" : - " SUCCESS: smoothed and removed invalid elements ") - << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk after barrier" << std::endl; - } - - MSQ_ERRRTN(mErr); - -#ifdef USE_CALLGRIND - CALLGRIND_TOGGLE_COLLECT - CALLGRIND_STOP_INSTRUMENTATION -#endif - } - - - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.hpp deleted file mode 100644 index 9a5d06b77ea2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMParallelShapeImprover.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMParallelShapeImprover_hpp -#define PMMParallelShapeImprover_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#undef USE_CALLGRIND -//#define USE_CALLGRIND -#ifdef USE_CALLGRIND -#include "/usr/netpub/valgrind-3.6.0/include/valgrind/callgrind.h" -#endif - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - const double PMMPS_DEF_UNT_BETA = 1e-8; - const double PMMPS_DEF_SUC_EPS = 1e-4; - - class PMMParallelShapeImprover - { - public: - class PMMParallelShapeImprovementWrapper : public Wrapper { - - public: - - //Constructor sets the instructions in the queue. - PMMParallelShapeImprovementWrapper(int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : innerIter(inner_iterations), - maxTime(cpu_time), - gradNorm(grad_norm), - untBeta(PMMPS_DEF_UNT_BETA), - successiveEps(PMMPS_DEF_SUC_EPS), - parallelIterations(parallel_iterations), - m_do_untangle_only(false) - {} - - - protected: - - void run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ); - - virtual double run_one_iteration( Mesh* mesh, MeshDomain *domain, - MsqError& err ); - - protected: - - int innerIter; - double maxTime, gradNorm; - // constants - const double untBeta; - const double successiveEps; - int parallelIterations; - public: - bool m_do_untangle_only; - - - }; - - protected: - int innerIter; - double gradNorm; - int parallelIterations; - public: - - PMMParallelShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - innerIter(innerIter), gradNorm(gradNorm), parallelIterations(parallelIterations) - {} - - static int count_invalid_elements(Mesh &mesh, Mesquite::MeshDomain *domain=0); - static int parallel_count_invalid_elements(PerceptMesh *eMesh); - - void run(Mesquite::Mesh &mesh, Mesquite::MeshDomain *domain, bool always_smooth=true, int debug=0); - - static void save_or_restore_debug_state(bool save) - { - static bool debug[3] = {false,false,false}; - if (save) - { - debug[0] = MsqDebug::get(1); - debug[1] = MsqDebug::get(2); - debug[2] = MsqDebug::get(3); - } - else - { - if (debug[0]) MsqDebug::enable(1); - if (debug[1]) MsqDebug::enable(2); - if (debug[2]) MsqDebug::enable(3); - } - } - - }; - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.cpp deleted file mode 100644 index 26a732bb9998..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include "mpi.h" - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - using namespace Mesquite; - - void PMMShapeImprover::PMMShapeImprovementWrapper::run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ) - { - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprovementWrapper innerIter= " << innerIter << " parallelIterations= " << parallelIterations << std::endl; - - // Define an untangler - //UntangleBetaQualityMetric untangle_metric( untBeta ); - UntangleBetaQualityMetric untangle_metric( 1.e-6 ); - - bool check_untangle = true; - if (check_untangle) - { - MPI_Barrier( MPI_COMM_WORLD ); - if (!get_parallel_rank()) std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprover.... running QA with untangle_metric before... " << std::endl; - InstructionQueue q1; - QualityAssessor qa_untangle(&untangle_metric); - q1.add_quality_assessor(&qa_untangle, err); MSQ_ERRRTN(err); - q1.run_common( mesh, pmesh, domain, settings, err ); - if (!get_parallel_rank()) std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprover.... running QA with untangle_metric... before... done " << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - //return; - } - - - LPtoPTemplate untangle_func( 2, &untangle_metric ); - ConjugateGradient untangle_solver( &untangle_func ); - //untangle_solver.set_debugging_level(3); - - //SteepestDescent untangle_solver( &untangle_func ); - TerminationCriterion untangle_inner(""), untangle_outer(""); - //TerminationCriterion untangle_inner, untangle_outer; - untangle_solver.use_global_patch(); - - //untangle_inner.add_absolute_gradient_L2_norm( gradNorm ); - //untangle_inner.add_absolute_successive_improvement( successiveEps ); - //untangle_inner.add_relative_successive_improvement( 1.e-6 ); - - //untangle_inner.add_untangled_mesh(); - untangle_inner.add_absolute_quality_improvement( 0.0 ); - untangle_inner.add_iteration_limit( 20 ); - untangle_inner.write_iterations("untangle.gpt", err); - - untangle_outer.add_absolute_quality_improvement( 0.0 ); - untangle_outer.add_iteration_limit( pmesh ? parallelIterations : 1 ); - - untangle_solver.set_inner_termination_criterion( &untangle_inner ); - untangle_solver.set_outer_termination_criterion( &untangle_outer ); - //exit(123); - - // define shape improver - IdealWeightInverseMeanRatio inverse_mean_ratio; - inverse_mean_ratio.set_averaging_method( QualityMetric::LINEAR ); - LPtoPTemplate obj_func( 2, &inverse_mean_ratio ); - - ConjugateGradient shape_solver( &obj_func ); - TerminationCriterion term_inner(""), term_outer(""); - term_inner.write_iterations("shape.gpt", err); - - shape_solver.use_global_patch(); - qa->add_quality_assessment( &inverse_mean_ratio ); - - //!term_inner.add_relative_successive_improvement( successiveEps ); - - term_inner.add_absolute_gradient_L2_norm( gradNorm ); - term_inner.add_absolute_vertex_movement(0.0); - term_inner.add_iteration_limit( innerIter ); - - term_outer.add_absolute_gradient_L2_norm( gradNorm ); - term_outer.add_absolute_vertex_movement(0.0); - term_outer.add_iteration_limit( pmesh ? parallelIterations : 1 ); - - //term_outer.add_absolute_quality_improvement( 1.e-6 ); - //!term_outer.add_relative_successive_improvement( successiveEps ); - - shape_solver.set_inner_termination_criterion( &term_inner ); - shape_solver.set_outer_termination_criterion( &term_outer ); - - // Apply CPU time limit to untangler - if (maxTime > 0.0) - untangle_inner.add_cpu_time( maxTime ); - - Timer totalTimer; - - // Run untangler - if (!get_parallel_rank()) std::cout << "\ntmp srk PMMShapeImprovementWrapper: running untangler...\n " << std::endl; - bool use_untangle_wrapper = true; - if (use_untangle_wrapper) - { - PMMShapeImprover::save_or_restore_debug_state(true); - //MsqDebug::disable_all(); - UntangleWrapper uw; - uw.set_untangle_metric(UntangleWrapper::BETA); - //uw.set_metric_constant( -1.e-6 ); - uw.set_outer_iteration_limit(200); - - //void UntangleWrapper::set_metric_constant( double value ) - //void UntangleWrapper::set_cpu_time_limit( double seconds ) - //void UntangleWrapper::set_vertex_movement_limit_factor( double f ) - //uw.set_vertex_movement_limit_factor( 1.e-4 ); - - if (pmesh) - uw.run_instructions(pmesh, domain, err); - else - uw.run_instructions(mesh, domain, err); - PMMShapeImprover::save_or_restore_debug_state(false); - } - else - { - InstructionQueue q1; -#if 0 - q1.set_master_quality_improver( &untangle_solver, err ); MSQ_ERRRTN(err); - q1.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); -#else - QualityAssessor qa_untangle(&untangle_metric); - q1.add_quality_assessor(&qa_untangle, err); MSQ_ERRRTN(err); - q1.set_master_quality_improver( &untangle_solver, err ); MSQ_ERRRTN(err); - q1.add_quality_assessor(&qa_untangle, err); MSQ_ERRRTN(err); -#endif - q1.run_common( mesh, pmesh, domain, settings, err ); - } - if (!get_parallel_rank()) std::cout << "\ntmp srk PMMShapeImprovementWrapper: running untangler... done\n " << std::endl; - if (!get_parallel_rank()) std::cout << "\ntmp srk PMMShapeImprovementWrapper: MsqError after untangler: " << err << std::endl; - - bool check_quality_after_untangler = true; - if (check_quality_after_untangler) - { - int num_invalid = count_invalid_elements(*mesh, pmesh, *domain); - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMShapeImprovementWrapper num_invalid after untangler= " << num_invalid << " " - << (num_invalid ? " ERROR still have invalid elements after Mesquite untangle" : - " SUCCESS: untangled invalid elements ") - << std::endl; - - if (check_untangle) - { - MPI_Barrier( MPI_COMM_WORLD ); - if (!get_parallel_rank()) std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprover.... running QA with untangle_metric " << std::endl; - InstructionQueue q1; - QualityAssessor qa_untangle(&untangle_metric); - q1.add_quality_assessor(&qa_untangle, err); MSQ_ERRRTN(err); - q1.run_common( mesh, pmesh, domain, settings, err ); - if (!get_parallel_rank()) std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprover.... running QA with untangle_metric... done " << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - } - - if (num_invalid) return; - } - if (m_do_untangle_only) return; - MSQ_ERRRTN(err); - - - // If limited by CPU time, limit next step to remaning time - if (maxTime > 0.0) { - double remaining = maxTime - totalTimer.since_birth(); - if (remaining <= 0.0 ){ - MSQ_DBGOUT(2) << "Optimization is terminating without perfoming shape improvement." << std::endl; - remaining = 0.0; - } - term_inner.add_cpu_time( remaining ); - } - - // Run shape improver - InstructionQueue q2; - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMShapeImprovementWrapper: running shape improver... \n" << std::endl; - - q2.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - q2.set_master_quality_improver( &shape_solver, err ); MSQ_ERRRTN(err); - q2.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - q2.run_common( mesh, pmesh, domain, settings, err ); - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMShapeImprovementWrapper: running shape improver... done \n" << std::endl; - - MSQ_ERRRTN(err); - } - - - int PMMShapeImprover::count_invalid_elements(Mesh &mesh, ParallelMesh *pmesh, MeshDomain &domain) - { - MsqError err; - InstructionQueue q; - -#if 1 - IdealWeightInverseMeanRatio metric; - metric.set_averaging_method( QualityMetric::LINEAR ); -#else - // Set up barrier metric to see if mesh contains inverted elements - TShapeB1 mu_b; - IdealShapeTarget w_ideal; - TQualityMetric metric( &w_ideal, &mu_b ); -#endif - - // Check for inverted elements in the mesh - QualityAssessor inv_check( &metric ); - //inv_check.disable_printing_results(); - q.add_quality_assessor( &inv_check, err ); MSQ_ERRZERO(err); - Settings settings; - //q.run_common( &mesh, pmesh, &domain, &settings, err ); MSQ_ERRZERO(err); - q.run_common( &mesh, 0, &domain, &settings, err ); MSQ_ERRZERO(err); - //q.remove_quality_assessor( 0, err ); MSQ_ERRZERO(err); - const QualityAssessor::Assessor* inv_b = inv_check.get_results( &metric ); - int num_invalid = inv_b->get_invalid_element_count(); - stk_classic::all_reduce( MPI_COMM_WORLD, stk_classic::ReduceSum<1>( &num_invalid ) ); - - return num_invalid; - } - - void PMMShapeImprover::run(Mesquite::Mesh &mesh, Mesquite::MeshDomain &domain, bool always_smooth, int debug) - { -#ifdef USE_CALLGRIND - CALLGRIND_START_INSTRUMENTATION - CALLGRIND_TOGGLE_COLLECT -#endif - if (debug) - { - Mesquite::MsqDebug::enable(1); - if (debug > 1) Mesquite::MsqDebug::enable(2); - if (debug > 2) Mesquite::MsqDebug::enable(3); - } - - Mesquite::ParallelMesh *pmesh = dynamic_cast(&mesh); - if (!get_parallel_rank()) std::cout << "tmp srk PMMShapeImprover::run: pmesh= " << pmesh << std::endl; - - Mesquite::MsqError mErr; - int num_invalid = 0; - bool check_quality=true; - if (check_quality) - { - num_invalid = count_invalid_elements(mesh, pmesh, domain); - if (!get_parallel_rank()) - std::cout << "\ntmp srk PMMShapeImprover num_invalid before= " << num_invalid - << (num_invalid ? " WARNING: invalid elements exist before Mesquite smoothing" : - (!always_smooth ? "WARNING: no smoothing requested since always_smooth=false" : " ")) - << std::endl; - } - - if (num_invalid || always_smooth) - { - bool use_canned_wrapper = false; - if (use_canned_wrapper) - { - Mesquite::ShapeImprovementWrapper siw(mErr); - if (pmesh) - siw.run_instructions(pmesh, &domain, mErr); - else - siw.run_instructions(&mesh, &domain, mErr); - } - else - { - int msq_debug = debug; // 1,2,3 for more debug info - bool always_smooth_local = false; - bool do_laplace = false; - bool do_jacobi = true; - - // Define a Laplace smoother - if (do_laplace) - { - int num_laplace_iter = 1; - PMMLaplaceSmoother1 ls(num_laplace_iter); - if (do_jacobi) ls.get_smoother().do_jacobi_optimization(); - ls.run(mesh, domain, always_smooth_local, msq_debug); - } - - bool do_untangle_only = false; - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk innerIter= " << innerIter << " parallelIterations= " << parallelIterations << std::endl; - PMMShapeImprover::PMMShapeImprovementWrapper siw(innerIter, 0.0, gradNorm, parallelIterations); - siw.m_do_untangle_only = do_untangle_only; - if (pmesh) - siw.run_instructions(pmesh, &domain, mErr); - else - siw.run_instructions(&mesh, &domain, mErr); - } - - //if (!get_parallel_rank()) - std::cout << "\nP[" << get_parallel_rank() << "] tmp srk PMMShapeImprover: MsqError after ShapeImprovementWrapper: " << mErr << std::endl; - - if (check_quality) - { - num_invalid = count_invalid_elements(mesh, pmesh, domain); - //if (!get_parallel_rank()) - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk PMMShapeImprover num_invalid after= " << num_invalid << " " - << (num_invalid ? " ERROR still have invalid elements after Mesquite smoothing" : - " SUCCESS: smoothed and removed invalid elements ") - << std::endl; - MPI_Barrier( MPI_COMM_WORLD ); - std::cout << "\nP[" << Mesquite::get_parallel_rank() << "] tmp srk after barrier" << std::endl; - } - - MSQ_ERRRTN(mErr); - - } -#ifdef USE_CALLGRIND - CALLGRIND_TOGGLE_COLLECT - CALLGRIND_STOP_INSTRUMENTATION -#endif - } - - } -} - - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.hpp deleted file mode 100644 index cc357415cb60..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeImprover.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMShapeImprover_hpp -#define PMMShapeImprover_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#undef USE_CALLGRIND -//#define USE_CALLGRIND -#ifdef USE_CALLGRIND -#include "/usr/netpub/valgrind-3.6.0/include/valgrind/callgrind.h" -#endif - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - const double DEF_UNT_BETA = 1e-8; - const double DEF_SUC_EPS = 1e-4; - - class PMMShapeImprover - { - public: - class PMMShapeImprovementWrapper : public Wrapper { - - public: - - //Constructor sets the instructions in the queue. - PMMShapeImprovementWrapper(int inner_iterations = 100, - double cpu_time = 0.0, - double grad_norm =1.e-8, - int parallel_iterations = 20) - : innerIter(inner_iterations), - maxTime(cpu_time), - gradNorm(grad_norm), - untBeta(DEF_UNT_BETA), - successiveEps(DEF_SUC_EPS), - parallelIterations(parallel_iterations), - m_do_untangle_only(false) - {} - - - protected: - - void run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ); - - private: - - int innerIter; - double maxTime, gradNorm; - // constants - const double untBeta; - const double successiveEps; - int parallelIterations; - public: - bool m_do_untangle_only; - - - }; - - private: - int innerIter; - double gradNorm; - int parallelIterations; - public: - - PMMShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - innerIter(innerIter), gradNorm(gradNorm), parallelIterations(parallelIterations) - {} - - static int count_invalid_elements(Mesh &mesh, ParallelMesh* pmesh, MeshDomain &domain); - - void run(Mesquite::Mesh &mesh, Mesquite::MeshDomain &domain, bool always_smooth=true, int debug=0); - - static void save_or_restore_debug_state(bool save) - { - static bool debug[3] = {false,false,false}; - if (save) - { - debug[0] = MsqDebug::get(1); - debug[1] = MsqDebug::get(2); - debug[2] = MsqDebug::get(3); - } - else - { - if (debug[0]) MsqDebug::enable(1); - if (debug[1]) MsqDebug::enable(2); - if (debug[2]) MsqDebug::enable(3); - } - } - - }; - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.cpp deleted file mode 100644 index 017701039b8d..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - void PMMShapeSizeOrientImprover::run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* domain, - Settings* settings, - QualityAssessor* qa, - MsqError& err ) - { - InstructionQueue q; - - // Set up barrier metric to see if mesh contains inverted elements - TShapeB1 mu_b; - IdealShapeTarget w_ideal; - TQualityMetric barrier( &w_ideal, &mu_b ); - - // Check for inverted elements in the mesh - QualityAssessor inv_check( &barrier ); - //inv_check.disable_printing_results(); - q.add_quality_assessor( &inv_check, err ); MSQ_ERRRTN(err); - q.run_common( mesh, pmesh, domain, settings, err ); MSQ_ERRRTN(err); - q.remove_quality_assessor( 0, err ); MSQ_ERRRTN(err); - const QualityAssessor::Assessor* inv_b = inv_check.get_results( &barrier ); - //const bool use_barrier = (0 == inv_b->get_invalid_element_count()); - std::cout << "tmp srk PMMShapeSizeOrientImprover::run_wrapper get_invalid_element_count= " - << inv_b->get_invalid_element_count() << std::endl; - - // Create remaining metric instances - TShapeNB1 mu; - TShapeSizeOrientNB1 mu_o; - TShapeSizeOrientB1 mu_ob; - - // Select which target metrics to use - //TMetric *mu_p, *mu_op; - //if (use_barrier) { - // mu_p = &mu_b; - // mu_op = &mu_ob; - //} - //else { - // mu_p = μ - // mu_op = &mu_o; - //} - - // Set up target and weight calculators - std::string altCoordName = "msq_jacobi_temp_coords"; // FIXME - bool should_clean_up_tag_data = true; // default - TagVertexMesh init_mesh( err, pmesh ? (Mesh*)pmesh : mesh, should_clean_up_tag_data, altCoordName ); MSQ_ERRRTN(err); - ReferenceMesh ref_mesh( &init_mesh ); - RefMeshTargetCalculator w_init( &ref_mesh ); - - //TetDihedralWeight c_dihedral( &ref_mesh, dCutoff, aVal ); - //RemainingWeight c_remaining( &c_dihedral ); - - // Create objective function - // TQualityMetric metric1( &w_ideal, &c_dihedral, mu_p ); - // TQualityMetric metric2( &w_init, &c_remaining, mu_op ); - // AddQualityMetric of_metric( &metric1, &metric2, err ); MSQ_ERRRTN(err); - TQualityMetric of_metric( &w_init, &mu_o ); - PMeanPTemplate obj_func( 1.0, &of_metric ); - - // Create optimizer - //TrustRegion solver( &obj_func ); - FeasibleNewton solver( &obj_func ); - TerminationCriterion term, ptc; - term.add_iteration_limit( iterationLimit ); - term.add_absolute_vertex_movement( maxVtxMovement ); - ptc.add_iteration_limit( pmesh ? parallelIterations : 1 ); - solver.set_inner_termination_criterion( &term ); - solver.set_outer_termination_criterion( &ptc ); - - // Create instruction queue - //qa->add_quality_assessment( &metric1 ); - //qa->add_quality_assessment( &metric2 ); - qa->add_quality_assessment( &of_metric ); - q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - q.set_master_quality_improver( &solver, err ); MSQ_ERRRTN(err); - q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err); - - // Optimize mesh - q.run_common( mesh, pmesh, domain, settings, err ); MSQ_CHKERR(err); - } - - } -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.hpp deleted file mode 100644 index 205e915cf2cf..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMShapeSizeOrientImprover.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMShapeSizeOrientImprover_hpp -#define PMMShapeSizeOrientImprover_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - class PMMShapeSizeOrientImprover : public Wrapper - { - private: - double dCutoff, aVal; - int iterationLimit; - int parallelIterations; - double maxVtxMovement; - - void run_wrapper( Mesh* mesh, - ParallelMesh* pmesh, - MeshDomain* geom, - Settings* settings, - QualityAssessor* qa, - MsqError& err ); - - public: - - /** - *\param max_vertex_movement Termination optimization if no vertex is moved - * by more than this distance in the previous solver - * step. - *\param a Coefficient for target metric weight - *\param d_prime Dihedral handle cut-off for target metric weight - *\param max_iterations Termination optimizaiton after this many solver - * steps. - */ - PMMShapeSizeOrientImprover( double max_vertex_movement, - double a = 0.4395, - double d_prime = 135, - int max_iterations = 50, - int parallel_iterations = 10 ) - : dCutoff(d_prime), - aVal(a), - iterationLimit( max_iterations ), - parallelIterations( parallel_iterations ), - maxVtxMovement( max_vertex_movement ) - {} - - void run(PerceptMesquiteMesh &mesh, PerceptMesquiteMeshDomain &domain, int debug=0) - { - if (debug) - { - Mesquite::MsqDebug::enable(1); - if (debug > 1) Mesquite::MsqDebug::enable(2); - if (debug > 2) Mesquite::MsqDebug::enable(3); - } - Mesquite::MsqError mErr; - - //this->set_iteration_limit(1); - Mesquite::ParallelMesh *pmesh = dynamic_cast(&mesh); - if (pmesh) - this->run_instructions(pmesh, &domain, mErr); - else - this->run_instructions(&mesh, &domain, mErr); - - //siw.run_instructions(&mesh, &domain, mErr); - } - }; - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMSmootherMetric.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMSmootherMetric.hpp deleted file mode 100644 index 6a69507ea270..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PMMSmootherMetric.hpp +++ /dev/null @@ -1,394 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef PMMSmootherMetric_hpp -#define PMMSmootherMetric_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include - -namespace stk_classic { - namespace percept { - - enum CombineOp { - COP_SUM, - COP_MIN, - COP_MAX - }; - - class PMMSmootherMetric - { - public: - PMMSmootherMetric(PerceptMesh *eMesh) : m_topology_data(0), m_eMesh(eMesh), m_node(0), m_is_nodal(false), m_combine(COP_SUM) - { - m_coord_field_current = eMesh->get_coordinates_field(); - m_coord_field_original = eMesh->get_field("coordinates_NM1"); - } - virtual double length_scaling_power() { return 1.0; } - virtual double metric(stk_classic::mesh::Entity& element, bool& valid)=0; - - const CellTopologyData * m_topology_data ; - void set_node(stk_classic::mesh::Entity *node) { m_node=node; } - stk_classic::mesh::Entity *get_node() { return m_node; } - void set_combine_op(CombineOp combine) { m_combine= combine; } - CombineOp get_combine_op() { return m_combine; } - bool is_nodal() { return m_is_nodal; } - - protected: - PerceptMesh *m_eMesh; - stk_classic::mesh::Entity *m_node; // for metrics that are node-based - bool m_is_nodal; - CombineOp m_combine; - stk_classic::mesh::FieldBase *m_coord_field_current; - stk_classic::mesh::FieldBase *m_coord_field_original; - - }; - - - class PMMSmootherMetricUntangle : public PMMSmootherMetric - { - double m_beta_mult; - public: - PMMSmootherMetricUntangle(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) { - //int spatialDim= eMesh->get_spatial_dim(); - m_beta_mult = 0.05; - } - virtual double length_scaling_power() { return 3.0; } - - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA, jacW; - - double A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_untangle=0.0; - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - double detWi = jacW.m_detJ[i]; - if (detAi <= 0.) - { - valid = false; - } - //fval = Math::my_max_hi(-temp_var,0.0,beta*0.001); - val_untangle += std::max(-(detAi - m_beta_mult*detWi),0.0); - } - val = val_untangle; - return val; - } - }; - - class PMMSmootherMetricShapeSizeOrient : public PMMSmootherMetric - { - public: - PMMSmootherMetricShapeSizeOrient(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) {} - virtual double length_scaling_power() { return 1.0; } - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA, jacW; - //jacA.m_scale_to_unit = true; - - double A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - MsqMatrix<3,3> Ident; - identity(Ident); - - MsqMatrix<3,3> AI, Atmp, WAI; - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - if (detAi < 0) - { - valid = false; - } - double shape_metric = 0.0; - if (std::fabs(detAi) > 1.e-10) - { - MsqMatrix<3,3>& W = jacW.m_J[i]; - MsqMatrix<3,3>& A = jacA.m_J[i]; - inverse(A, AI); - product(W, AI, WAI); - difference(WAI, Ident, Atmp); - shape_metric = my_sqr_Frobenius(Atmp); - } - val_shape += shape_metric; - } - val = val_shape; - return val; - } - }; - - class PMMSmootherMetricScaledJacobianNodal : public PMMSmootherMetric - { - public: - PMMSmootherMetricScaledJacobianNodal(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) - { m_is_nodal=true; m_combine=COP_MAX; } - virtual double length_scaling_power() { return 1.0; } - - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - VERIFY_OP_ON(m_node, !=, 0, "must set a node"); - valid = true; - JacobianUtil jacA, jacSA, jacW; - jacSA.m_scale_to_unit = true; - - double SA_ = 0.0, A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacSA(SA_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - - stk_classic::mesh::PairIterRelation elem_nodes = element.relations(m_eMesh->node_rank()); - VERIFY_OP_ON((int)elem_nodes.size(), ==, jacA.m_num_nodes, "node num mismatch"); - val_shape = 0.0; - bool found = false; - for (int i=0; i < jacA.m_num_nodes; i++) - { - if (elem_nodes[i].entity() == m_node) - { - double detAi = jacA.m_detJ[i]; - double detSAi = jacSA.m_detJ[i]; - double detWi = jacW.m_detJ[i]; - if (detAi < 0) - { - valid = false; - } - double shape_metric = 0.0; - //MsqMatrix<3,3>& A = jacA.m_J[i]; - double scale_factor = detWi; - scale_factor = 1.0; - double fac = 0.2; - shape_metric = scale_factor* (detSAi > fac ? fac : detSAi); - val_shape = shape_metric; - //std::cout << "tmp srk i= " << i << " detAi = " << detAi << " detSAi= " << detSAi << " shape_metric= " << shape_metric << " val_shape= " << val_shape << std::endl; - found = true; - break; - } - } - VERIFY_OP_ON(found, ==, true, "logic err"); - val = -val_shape; - //std::cout << "tmp srk val = " << val << std::endl; - return val; - } - }; - - class PMMSmootherMetricScaledJacobianElemental : public PMMSmootherMetric - { - public: - PMMSmootherMetricScaledJacobianElemental(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) {} - virtual double length_scaling_power() { return 1.0; } - - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA, jacSA, jacW; - jacSA.m_scale_to_unit = true; - - double SA_ = 0.0, A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacSA(SA_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - - val_shape = 0.0; - //val_shape = std::numeric_limits::max(); - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - double detSAi = jacSA.m_detJ[i]; - //double detWi = jacW.m_detJ[i]; - double FAi = Frobenius(jacA.m_detJ[i]); - double FWi = Frobenius(jacW.m_detJ[i]); - if (detAi < 0) - { - valid = false; - } - double shape_metric = 0.0; - //MsqMatrix<3,3>& A = jacA.m_J[i]; - double scale_factor = (FAi < FWi ? FAi/FWi : (FAi > 1.e-6? FWi / FAi : 1.0)); - scale_factor = FAi/FWi; - //scale_factor = 1.0; - //double sign_SA = (detSAi > 0.0 ? 1.0 : -1.0); - //double fac = 0.2; - //shape_metric = scale_factor* (detSAi > fac ? fac : detSAi); - shape_metric = scale_factor*detSAi; - val_shape += shape_metric; - //val_shape = std::min(val_shape, shape_metric); - //std::cout << "tmp srk i= " << i << " detAi = " << detAi << " detSAi= " << detSAi << " shape_metric= " << shape_metric << " val_shape= " << val_shape << " scale_factor= " << scale_factor << " FAi= " << FAi << " FWi= " << FWi << std::endl; - } - - val = -val_shape; - //std::cout << "tmp srk val = " << val << std::endl; - return val; - } - }; - - class PMMSmootherMetricShapeB1 : public PMMSmootherMetric - { - public: - PMMSmootherMetricShapeB1(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) {} - - virtual double length_scaling_power() { return 1.0; } - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA, jacW; - - int spatialDim = m_eMesh->get_spatial_dim(); - double A_ = 0.0, W_ = 0.0; // current and reference detJ - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - MsqMatrix<3,3> Ident; - identity(Ident); - - MsqMatrix<3,3> WI, T; - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - if (detAi < 0) - { - valid = false; - } - MsqMatrix<3,3>& W = jacW.m_J[i]; - MsqMatrix<3,3>& A = jacA.m_J[i]; - - // frob2 = h^2 + h^2 + 1 - // frob21 = 2 h^2 - // f = h sqrt(2) - // det = h*h - // met = f*f / (det*2) - 1 - // frob3 = 3 h^2 - // f = h sqrt(3) - // det = h*h*h - // met = f*f*f/(3^3/2 *det) - 1 = f*f*f/(3*sqrt(3)*det) - 1 - double shape_metric = 0.0; - if (std::fabs(detAi) > 1.e-15) - { - inverse(W, WI); - product(A, WI, T); - double d = det(T); - double f = my_sqr_Frobenius(T); - if (spatialDim==2) - { - // all our jacobians are 3D, with a 1 in the 3,3 slot for 2d, so we subtract it here - f = f - 1.0; - f = std::sqrt(f); - double fac = 2.0; - double den = fac * d; - shape_metric = (f*f)/den - 1.0; - } - else - { - f = std::sqrt(f); - double fac = 3.0*std::sqrt(3.0); - double den = fac * d; - shape_metric = (f*f*f)/den - 1.0; - } - //shape_metric = std::fabs(shape_metric); - //shape_metric = f/std::pow(den,1./3.) - 1.0; - } - val_shape += shape_metric; - //val_shape += std::fabs(shape_metric); - //val_shape += shape_metric*shape_metric; - } - val = val_shape; - //val = val_shape*val_shape; - return val; - } - - }; - - class PMMSmootherMetricLaplace : public PMMSmootherMetric - { - public: - PMMSmootherMetricLaplace(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) {} - - virtual double length_scaling_power() { return 2.0; } - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA; - //JacobianUtil jacW; - - double A_ = 0.0; - //double W_ = 0.0; - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - //jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - if (detAi < 0) - { - valid = false; - } - MsqMatrix<3,3>& A = jacA.m_J[i]; - double shape_metric = 0.0; - shape_metric = sqr_Frobenius(A); - val_shape += shape_metric; - } - val = val_shape; - return val; - } - - }; - - class PMMSmootherMetricVolumetricEnergy : public PMMSmootherMetric - { - public: - PMMSmootherMetricVolumetricEnergy(PerceptMesh *eMesh) : PMMSmootherMetric(eMesh) {} - - virtual double length_scaling_power() { return 6.0; } - virtual double metric(stk_classic::mesh::Entity& element, bool& valid) - { - valid = true; - JacobianUtil jacA; - //JacobianUtil jacW; - - double A_ = 0.0; - //double W_ = 0.0; - jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data); - //jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data); - double val=0.0, val_shape=0.0; - - for (int i=0; i < jacA.m_num_nodes; i++) - { - double detAi = jacA.m_detJ[i]; - if (detAi < 0) - { - valid = false; - } - double shape_metric = detAi*detAi; - val_shape += shape_metric; - } - val = val_shape; - return val; - } - - }; - - - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.cpp deleted file mode 100644 index c9c6cd6660e6..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.cpp +++ /dev/null @@ -1,1379 +0,0 @@ -//------------------------------------------------------------------------- -// Filename : PerceptMesquiteMesh.cpp, derived from SCVFracMesquiteMesh.cpp -// -// Purpose : mesh interface for using Mesquite -// -// Description : subclass of Mesquite::Mesh -// -// Creator : Steve Kennon, derived from Steve Owen's work -// -// Creation Date : Nov 2011 -// -// Owner : Steve Kennon -//------------------------------------------------------------------------- - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include "PerceptMesquiteMesh.hpp" -#include "PerceptMesquiteMeshDomain.hpp" -//#include -#include - -#include -#include - -#define DEBUG_PRINT 0 - -namespace stk_classic { - namespace percept { - - -#define PRINT_ERROR(a) do { std::cout << "PerceptMesquiteMesh::ERROR: " << a << std::endl; } while (0) - - //============================================================================ - // Description: initialize data - // Author: sjowen - // Date: 5/19/2011 - //============================================================================ - void PerceptMesquiteMesh::init(PerceptMesh *eMesh) - { - m_eMesh = eMesh; - -#if 0 - isSetup = false; - mOwners = entities; - nodeArray = NULL; - elementArray = NULL; - numNodes = 0; - numElements = 0; - triExists = false; - quadExists = false; - tetExists = false; - hexExists = false; - - doJacobiIterations = false; - - freeScheme = false; - jacobiCoords = NULL; - nextJacobiCoordsIndex = 0; - - myDimension = 0; -#endif - } - - - - //============================================================================ - // Description: constructor - // Author: sjowen - // Date: 03/30/2011, 11/15/11 - //============================================================================ - PerceptMesquiteMesh::PerceptMesquiteMesh(PerceptMesh *eMesh, PerceptMesquiteMeshDomain *domain, stk_classic::mesh::Selector *boundarySelector) - : m_meshDomain(domain), m_boundarySelector(boundarySelector), m_nodeCoords_tag_is_created(false), m_is_proc_id_active(false), - m_is_global_id_active(false), m_parallelHelperLocalIdMap_is_created(false) - { - init(eMesh); - } - - //============================================================================ - // Description: called once to set up nodes/elements to be smoothed - // Author: sjowen - // Note: assumes nodes have pointers to hexes and tets - // Date: 03/30/2011, 11/15/11 - //============================================================================ - int PerceptMesquiteMesh::setup() - { - return 0; - } - - - //============================================================================ - // Description: destructor - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - PerceptMesquiteMesh::~PerceptMesquiteMesh() - { - - //clean_out(); - - } - - //============================================================================ - // Description: Returns whether this mesh lies in a 2D or 3D coordinate system. - // Notes: We always pass in nodes in with three coordinates. This may change - // in the future if we want to do smoothing in a parametric space, but - // for now, we are always in three-dimensions. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - int PerceptMesquiteMesh::get_geometric_dimension( - Mesquite::MsqError &/*err*/) - { - return m_eMesh->get_spatial_dim(); - } - - //============================================================================ - // Description: Returns the number of verticies for the entity. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - //! Returns the number of verticies for the entity. - size_t PerceptMesquiteMesh::get_total_vertex_count( - Mesquite::MsqError &/*err*/) const - { - return (size_t) m_eMesh->get_number_nodes(); - } - - bool PerceptMesquiteMesh::select_bucket(stk_classic::mesh::Bucket& bucket) const - { - return select_bucket(bucket, m_eMesh); - } - - bool PerceptMesquiteMesh::select_bucket(stk_classic::mesh::Bucket& bucket, PerceptMesh *eMesh) - { - const CellTopologyData * cell_topo_data = eMesh->get_cell_topology(bucket); - shards::CellTopology cell_topo(cell_topo_data); - - if (cell_topo.getKey() == shards::getCellTopologyData >()->key - || cell_topo.getKey() == shards::getCellTopologyData >()->key - || cell_topo.getKey() == shards::getCellTopologyData >()->key - || cell_topo.getKey() == shards::getCellTopologyData >()->key) - { - return false; - } - else - { - return true; - } - } - - bool PerceptMesquiteMesh::select_element(stk_classic::mesh::Entity& element) const - { - return select_bucket(element.bucket()); - } - - - //============================================================================ - // Description: Returns the number of elements for the entity. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - size_t PerceptMesquiteMesh::get_total_element_count( - Mesquite::MsqError &/*err*/) const - { - //return (size_t) m_eMesh->get_number_elements(); - size_t num_elem=0; - - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->element_rank() ); - unsigned buckets_size = buckets.size(); - if (DEBUG_PRINT) std::cout << "tmp srk buckets_size= " << buckets_size << std::endl; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - if (select_bucket(bucket)) - { - const unsigned num_entity_in_bucket = bucket.size(); - - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - if (m_eMesh->hasFamilyTree(element) && m_eMesh->isParentElement(element, false)) - continue; - ++num_elem; - } - } - } - } - - if (DEBUG_PRINT) std::cout << "tmp srk num_elem= " << num_elem << std::endl; - - return num_elem; - - } - - //============================================================================ - // Description: Fills array with handles to all vertices in the mesh. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::get_all_vertices( - std::vector &vertices, - Mesquite::MsqError &/*err*/) - { - //otherwise add a handle to each vertex to the given array. - //int index = 0; - vertices.clear(); - - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& node = bucket[ientity]; - vertices.push_back(reinterpret_cast( &node ) ); - } - } - } - } - - //============================================================================ - // Description: Fills array with handles to all elements in the mesh. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::get_all_elements( - std::vector &elements, - Mesquite::MsqError &/*err*/ ) - { - elements.clear(); - - const std::vector & buckets = m_eMesh->get_bulk_data()->buckets( m_eMesh->element_rank() ); - unsigned buckets_size = buckets.size(); - if (DEBUG_PRINT) std::cout << "tmp srk buckets_size= " << buckets_size << std::endl; - - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - if (select_bucket(bucket)) - { - const CellTopologyData * cell_topo_data = m_eMesh->get_cell_topology(bucket); - shards::CellTopology cell_topo(cell_topo_data); - //std::cout << "tmp srk selected topo= " << cell_topo << std::endl; - - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - if (DEBUG_PRINT) { - std::cout << "tmp srk printing entity: "; - m_eMesh->print_entity(std::cout, element, m_eMesh->get_coordinates_field() ); - } - if (m_eMesh->hasFamilyTree(element) && m_eMesh->isParentElement(element, false)) - continue; - elements.push_back(reinterpret_cast( &element ) ); - } - } - } - } - - if (DEBUG_PRINT) std::cout << "tmp srk get_all_elements num_elem= " << elements.size() << std::endl; - } - - bool PerceptMesquiteMesh::get_fixed_flag(stk_classic::mesh::Entity* node_ptr) - { - int dof = -1; - bool fixed=true; - //if the owner is something other than the top-level owner, the node - // is on the boundary; otherwise, it isn't. - if (m_boundarySelector) - { - if ((*m_boundarySelector)(*node_ptr)) - fixed=true; - else - fixed=false; - } - else - { - if (m_meshDomain) - { - size_t curveOrSurfaceEvaluator; - dof = m_meshDomain->classify_node(*node_ptr, curveOrSurfaceEvaluator); - //std::cout << "tmp srk classify node= " << node_ptr->identifier() << " dof= " << dof << std::endl; - // vertex - if (dof == 0) - { - fixed=true; - } - // curve (for now we hold these fixed) - else if (dof == 1) - { - fixed=true; - //fixed=false; // FIXME - } - // surface - also fixed - else if (dof == 2) - { - //fixed=false; - fixed=true; - if (DEBUG_PRINT) std::cout << "tmp srk found surface node unfixed= " << node_ptr->identifier() << std::endl; - } - // interior/volume - free to move - else - { - fixed=false; - } - } - else - { - fixed=false; - } - } - if (DEBUG_PRINT) std::cout << "tmp srk classify node= " << node_ptr->identifier() << " dof= " << dof << " fixed= " << fixed << std::endl; - - return fixed; - } - - //============================================================================ - // Description: Returns true or false, indicating whether the vertex - //! is allowed to moved. - //! Note that this is a read-only - //! property; this flag can't be modified by users of the - //! Mesquite::Mesh interface. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertices_get_fixed_flag( - const Mesquite::Mesh::VertexHandle vert_array[], - std::vector& fixed_flag_array, - size_t num_vtx, - Mesquite::MsqError &err ) - { - - unsigned int i; - - /* if no boundary selector is set, this implies we allow all nodes to move... - if(!m_boundarySelector) - { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_is_on_boundary: No selector to determine vertex fixed-ness.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR(" PerceptMesquiteMesh::vertex_is_on_boundary: No selector to determine vertex fixed-ness.\n"); - return; - } - */ - - for (i = 0; i < num_vtx; ++i) - { - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(vert_array[i]); - - //if we've got a null pointer, something is wrong. - if(node_ptr==NULL) - { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_is_on_boundary: Null pointer to vertex.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR(" PerceptMesquiteMesh::vertex_is_on_boundary: Null pointer to vertex.\n"); - return; - } - - - bool fixed = get_fixed_flag(node_ptr); - fixed_flag_array.push_back(fixed); - } - - } - - - //============================================================================ - // Description: vertex is "slaved" if it is on a higher order element or - // has an owner that is not in the mOwner list. - for now we don't distinguish - // higher order nodes - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertices_get_slaved_flag( const VertexHandle vert_array[], - std::vector& slaved_flag_array, - size_t num_vtx, - Mesquite::MsqError &err ) - { - - unsigned int i; - - for (i = 0; i < num_vtx; ++i) - { - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(vert_array[i]); - - //if we've got a null pointer, something is wrong. - if(node_ptr==NULL){ - MSQ_SETERR(err)("PerceptMesquiteMesh::vertices_get_slaved_flag: Null pointer to vertex.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR(" PerceptMesquiteMesh::vertices_get_slaved_flag: Null pointer to vertex.\n"); - return; - } - - //if the owner is something other than the top-level owner, the node - // is on the boundary; otherwise, it isn't. - - slaved_flag_array.push_back(false); - - } - - } - - - //============================================================================ - // Description: Get location of a vertex - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertices_get_coordinates( - const Mesquite::Mesh::VertexHandle vert_array[], - Mesquite::MsqVertex* coordinates, - size_t num_vtx, - Mesquite::MsqError &err) - { - unsigned int i; - stk_classic::mesh::Entity* node_ptr = NULL; - for (i = 0; i(vert_array[i]); - - //if null pointer, there is a problem somewhere. We set the vector's - // position to (0,0,0) just to avoid un-initialized variable issues. - if(node_ptr==NULL) { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_get_coordinates: invalid vertex handle.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::vertex_get_coordinates: invalid vertex handle.\n"); - coordinates[i].set(0.0,0.0,0.0); - return; - } - //set coordinates to the vertex's position. - stk_classic::mesh::FieldBase* field = m_eMesh->get_coordinates_field(); - double *f_data = PerceptMesh::field_data(field, *node_ptr); - - coordinates[i].set(f_data[0], f_data[1], (m_eMesh->get_spatial_dim() == 2 ? 0 : f_data[2]) ); - } - } - - - //============================================================================ - // Description: Set the location of a vertex. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertex_set_coordinates( - VertexHandle vertex, - const Mesquite::Vector3D &coordinates, - Mesquite::MsqError &err) - { - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(vertex); - - //if null pointer, there is a problem somewhere. We set the vector's - // position to (0,0,0) just to avoid un-initialized variable issues. - if(node_ptr==NULL) { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_set_coordinates: invalid vertex handle.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::vertex_set_coordinates: invalid vertex handle.\n"); - return; - } - - stk_classic::mesh::FieldBase* field = m_eMesh->get_coordinates_field(); - double *f_data = PerceptMesh::field_data(field, *node_ptr); - - f_data[0] = coordinates[0]; - f_data[1] = coordinates[1]; - if (m_eMesh->get_spatial_dim() == 3 ) - f_data[2] = coordinates[2]; - - } - - - //============================================================================ - // Description: Each vertex has a byte-sized flag that can be used to store - //! flags. This byte's value is neither set nor used by the mesh - //! implementation. It is intended to be used by Mesquite algorithms. - //! Until a vertex's byte has been explicitly set, its value is 0. - //! Cubit stores the byte in a map associated with the node. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertex_set_byte (VertexHandle vertex, - unsigned char byte, - Mesquite::MsqError &err) - { - stk_classic::mesh::Entity* node_ptr=reinterpret_cast(vertex); - - //make sure there isn't a null pointer. - if(node_ptr==NULL) { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_set_byte: invalid vertex handle.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::vertex_set_byte: invalid vertex handle.\n"); - return; - } - - std::pair msq_data = std::pair(node_ptr->identifier(), byte); - - m_mesquiteNodeDataMap[node_ptr] = msq_data; - } - - //============================================================================ - // Description: Set the byte for a given array of vertices. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::vertices_set_byte ( - const VertexHandle *vert_array, - const unsigned char *byte_array, - size_t array_size, - Mesquite::MsqError &err) - { - //loop over the given vertices and call vertex_set_byte(...). - size_t i=0; - for(i=0;i(vertex); - - //make sure there isn't a null pointer. - if(node_ptr==NULL) { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_get_byte: invalid vertex handle.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::vertex_get_byte: invalid vertex handle."); - return; - } - *byte = m_mesquiteNodeDataMap[node_ptr].second; - } - - //============================================================================ - // Description: get the bytes associated with the vertices in a given array. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - //! get the bytes associated with the vertices in a given array. - void PerceptMesquiteMesh::vertices_get_byte(const VertexHandle *vertex_array, - unsigned char *byte_array, - size_t array_size, - Mesquite::MsqError &err) - { - //loop over the given nodes and call vertex_get_byte(...) - size_t i=0; - for(i=0;icentroid(); - CubitVector b = h1->centroid(); - if (a.x() == b.x()) - { - if (a.y() == b.y()) - { - return a.z() < b.z(); - } - return a.y() < b.y(); - } - return a.x() < b.x(); - } - - static void sort_hexes(DLIList &initial, DLIList &final) - { - std::vector hex_vec; - for (int ii=0; ii& elements, - std::vector& offsets, - Mesquite::MsqError& err ) - { - size_t i=0; - elements.clear(); - offsets.clear(); - stk_classic::mesh::Entity* node_ptr=NULL; - ElementHandle temp_e_handle; - size_t offset_counter = 0; - - for(i=0; i(vertex_array[i]); - - //make sure there isn't a null pointer - if(node_ptr==NULL) { - MSQ_SETERR(err)("PerceptMesquiteMesh::vertex_get_attached_elements: invalid vertex handle.", Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::vertex_get_attached_elements: invalid vertex handle.\n"); - return; - } - - stk_classic::mesh::PairIterRelation elements_of_node = node_ptr->relations(m_eMesh->element_rank()); - //sort_hexes( hex_patch, hex_list ); // to ensure parallel consistency - - for (unsigned iele=0; iele < elements_of_node.size(); iele++) - { - stk_classic::mesh::Entity& ele = *elements_of_node[iele].entity(); - - // only return hexes in the includedElements set - //if (includedElements.find(ent_ptr) != includedElements.end()) - if (select_element(ele)) - { - temp_e_handle = reinterpret_cast(&ele); - elements.push_back(temp_e_handle); - offset_counter++; - } - } - } - offsets.push_back(offset_counter); - - } - - - //============================================================================ - // Description: Get the connectivity (ordered list of vertex handles) for each - // element in the input array. - // - // elem_handles: The array of element handles for which to retrieve the connectivity list. - // num_elems: The length of elem_handles - // vert_handles: Array in which to place the vertex handles in each elements connectivity. - // offsets: For each element in elem_handles, the value in the same position in - // this array is the index into vert_handles at which the connectivity - // list for that element begins. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::elements_get_attached_vertices(const Mesquite::Mesh::ElementHandle *elem_handles, - size_t num_elems, - std::vector& vert_handles, - std::vector &offsets, - Mesquite::MsqError &err) - { - // Check for zero element case. - vert_handles.clear(); - offsets.clear(); - - if (num_elems == 0) - { - return; - } - - size_t i; - stk_classic::mesh::Entity* element_ptr=0; - - - //get a list of all nodes that are in these elements (the elements - // in the list will not necessarily be unique). - size_t offset_counter = 0; - for(i=0; i < ((size_t) num_elems);++i) - { - offsets.push_back(offset_counter); - element_ptr = reinterpret_cast(elem_handles[i]); - if(element_ptr==NULL){ - PRINT_ERROR("elements_get_attached_vertices: unexpected null pointer, element_ptr.\n"); - MSQ_SETERR(err)("elements_get_attached_vertices: unexpected null pointer, element_ptr.", - Mesquite::MsqError::INVALID_STATE); - return; - } - - VertexHandle temp_v_handle = NULL; - - stk_classic::mesh::PairIterRelation nodes = element_ptr->relations(m_eMesh->node_rank()); - if (DEBUG_PRINT) { - std::cout << "tmp srk in elements_get_attached_vertices, nodes.size= " << nodes.size() - << " elem= "; - m_eMesh->print_entity(std::cout, *element_ptr, m_eMesh->get_coordinates_field() ); - } - - for (unsigned inode=0; inode < nodes.size(); inode++) - { - if (!nodes[inode].entity()){ - std::cout << "elements_get_attached_vertices: unexpected null pointer, node= " << nodes[inode].entity() - << " elem= " << *element_ptr << " nodes.size= " << nodes.size() - << std::endl; - PRINT_ERROR("elements_get_attached_vertices: unexpected null pointer, nodes[inode].entity().\n"); - MSQ_SETERR(err)("elements_get_attached_vertices: unexpected null pointer, nodes[inode].entity().", - Mesquite::MsqError::INVALID_STATE); - } - stk_classic::mesh::Entity& node = *nodes[inode].entity(); - - temp_v_handle = reinterpret_cast(&node); - - if(temp_v_handle==NULL){ - std::cout << "elements_get_attached_vertices: unexpected null pointer, temp_v_handle= " << temp_v_handle << " &node= " << &node - << " elem= " << *element_ptr << " nodes.size= " << nodes.size() - << std::endl; - PRINT_ERROR("elements_get_attached_vertices: unexpected null pointer, temp_v_handle.\n"); - MSQ_SETERR(err)("elements_get_attached_vertices: unexpected null pointer, temp_v_handle.", - Mesquite::MsqError::INVALID_STATE); - return; - } - vert_handles.push_back(temp_v_handle); - ++offset_counter; - } - } - offsets.push_back(offset_counter); - - } - - //============================================================================ - // Description: Returns the topologies of the given entities. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::elements_get_topologies(const ElementHandle *element_handle_array, - Mesquite::EntityTopology *element_topologies, - size_t num_elements, - Mesquite::MsqError &err) - { - - stk_classic::mesh::Entity *ent = NULL; - - //loop over the elements - for ( ; num_elements--; ) - { - ent = reinterpret_cast(element_handle_array[num_elements]); - if(ent==NULL){ - PRINT_ERROR("elements_get_topologies: unexpected null pointer.\n"); - MSQ_SETERR(err)("elements_get_topologies: unexpected null pointer.", - Mesquite::MsqError::INVALID_STATE); - return; - } - - const CellTopologyData * cell_topo_data = m_eMesh->get_cell_topology(*ent); - if(cell_topo_data == NULL){ - PRINT_ERROR("elements_get_topologies: unexpected null topology.\n"); - MSQ_SETERR(err)("elements_get_topologies: unexpected null topology.", - Mesquite::MsqError::INVALID_STATE); - return; - } - - shards::CellTopology cell_topo(cell_topo_data); - - //add the appropriate EntityType to the element_topologies array - if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::QUADRILATERAL; - } - else if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::QUADRILATERAL; - } - else if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::TRIANGLE; - } - else if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::TRIANGLE; - } - else if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::HEXAHEDRON; - } - else if(cell_topo.getKey() == shards::getCellTopologyData >()->key ) - { - element_topologies[num_elements]=Mesquite::TETRAHEDRON; - } - else { - std::ostringstream ostr; - ostr << "elements_get_topologies: Type not recognized, cell_topo= " << cell_topo << " num_elements= " << num_elements << "\n"; - std::cout << ostr.str() << std::endl; - PRINT_ERROR(ostr.str()); - MSQ_SETERR(err)(ostr.str(), Mesquite::MsqError::UNSUPPORTED_ELEMENT); - return; - } - - }//end loop over elements - - } - - //============================================================================ - // Description: Create a tag. - // Create a user-defined data type that can be attached to any element or vertex - // in the mesh. For an opaque or undefined type, use type=BYTE and length=sizeof(..). - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - Mesquite::TagHandle PerceptMesquiteMesh::tag_create(const std::string &tag_name, - Mesquite::Mesh::TagType type, - unsigned length, - const void* default_value, - Mesquite::MsqError &err) - { - Mesquite::TagHandle handle = 0; - - //int numNodes = get_total_vertex_count(err); - if (1 || DEBUG_PRINT) std::cout << "tmp srk tag_create 0, length = " << length << " tag_name= " << tag_name - << " type= " << type << " DOUBLE= " << DOUBLE << " INT= " << INT << " HANDLE= " << HANDLE - << std::endl; - if (tag_name == "msq_jacobi_temp_coords" && type == DOUBLE && length == 3) - { - handle = reinterpret_cast(&m_nodeCoords); - if (DEBUG_PRINT) std::cout << "tmp srk tag_create msq_jacobi_temp_coords, length = " << length << " handle= " << handle << std::endl; - m_nodeCoords.clear(); - m_nodeCoords_tag_is_created = true; - } - else if (tag_name == "LOCAL_ID" && type == INT && length == 1) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_create LOCAL_ID length = " << length << std::endl; - handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - m_parallelHelperLocalIdMap.clear(); - m_parallelHelperLocalIdMap_is_created = true; - } - else if (tag_name == "msq_parallel_proc_id" && type == INT && length == 1) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_create msq_parallel_proc_id, length = " << length << std::endl; - - handle = reinterpret_cast(&m_is_proc_id_active); - m_is_proc_id_active = true; - } - else if (tag_name == "msq_parallel_global_id" && type == HANDLE && length == 1) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_create msq_parallel_global_id, length = " << length << std::endl; - - handle = reinterpret_cast(&m_is_global_id_active); - m_is_global_id_active = true; - } - else - { - //PRINT_ERROR("Unknown Tag %s in tag_create\n", tag_name.c_str()); - std::ostringstream ost; - ost << "Unknown Tag" << tag_name << " in tag_create\n"; - ost << " Tag not implemented.\n"; - MSQ_SETERR(err)(ost.str(),Mesquite::MsqError::NOT_IMPLEMENTED); - } - - return handle; - } - - //============================================================================ - // Description: Remove a tag and all corresponding data. - // Delete a tag. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_delete(Mesquite::TagHandle handle, - Mesquite::MsqError& err ) - { - - Mesquite::TagHandle jhandle = reinterpret_cast(&m_nodeCoords); - Mesquite::TagHandle ph_handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - Mesquite::TagHandle proc_id_handle = reinterpret_cast(&m_is_proc_id_active); - Mesquite::TagHandle global_id_handle = reinterpret_cast(&m_is_global_id_active); - if (jhandle == handle) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_delete jacobi handle" << std::endl; - m_nodeCoords.clear(); - m_nodeCoords_tag_is_created = false; - } - else if (ph_handle == handle) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_delete ph_handle handle" << std::endl; - m_parallelHelperLocalIdMap.clear(); - m_parallelHelperLocalIdMap_is_created = false; - } - else if (proc_id_handle == handle) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_delete proc_id_handle" << std::endl; - m_is_proc_id_active = false; - } - else if (global_id_handle == handle) - { - if (DEBUG_PRINT) std::cout << "tmp srk tag_delete global_id_handle" << std::endl; - m_is_global_id_active = false; - } - else - { - if ( DEBUG_PRINT) std::cout << "tmp srk tag_delete handle= " << handle << std::endl; - PRINT_ERROR("Unknown tag sent to PerceptMesquiteMesh::tag_delete\n"); - MSQ_SETERR(err)("Unknown tag sent to PerceptMesquiteMesh::tag_delete\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - - } - - //============================================================================ - // Description: - // Check for the existance of a tag given it's name and if it exists return a - // handle for it. If the specified tag does not exist, zero should be returned - // WITHOUT flagging an error. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - Mesquite::TagHandle PerceptMesquiteMesh::tag_get(const std::string& name, - Mesquite::MsqError& err ) - { - Mesquite::TagHandle handle = 0; - if (1 || DEBUG_PRINT) std::cout << "tmp srk tag_get tag_name= " << name - << std::endl; - - if (name == "msq_jacobi_temp_coords") - { - if (m_nodeCoords_tag_is_created) - { - handle = reinterpret_cast(&m_nodeCoords); - } - else - { - MSQ_SETERR(err)("tag msq_jacobi_temp_coords not found in PerceptMesquiteMesh::tag_get.\n",Mesquite::MsqError::TAG_NOT_FOUND); - } - } - else if (name == "LOCAL_ID") - { - if (m_parallelHelperLocalIdMap_is_created) - { - handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - } - else - { - MSQ_SETERR(err)("tag LOCAL_ID not found in PerceptMesquiteMesh::tag_get.\n",Mesquite::MsqError::TAG_NOT_FOUND); - } - } - else if (name == "msq_parallel_proc_id") - { - handle = reinterpret_cast(&m_is_proc_id_active); - if (!m_is_proc_id_active) - { - int default_pid_value = 0; - this->tag_create(PMM_proc_id_name, INT, 1, &default_pid_value, err); - //MSQ_SETERR(err)("tag msq_parallel_proc_id not found in PerceptMesquiteMesh::tag_get.\n",Mesquite::MsqError::TAG_NOT_FOUND); - } - } - else if (name == "msq_parallel_global_id") - { - handle = reinterpret_cast(&m_is_global_id_active); - if (!m_is_global_id_active) - { - size_t default_gid_value = 0; - this->tag_create(PMM_global_id_name, HANDLE, 1, &default_gid_value, err); - //MSQ_SETERR(err)("tag msq_parallel_global_id not found in PerceptMesquiteMesh::tag_get.\n",Mesquite::MsqError::TAG_NOT_FOUND); - } - } - else - { - MSQ_SETERR(err)("tag not found in PerceptMesquiteMesh::tag_get.\n",Mesquite::MsqError::TAG_NOT_FOUND); - } - - return handle; - } - - //============================================================================ - // Description: Get handle for existing tag, by name. - // Get data type and number of values per entity for tag. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_properties(Mesquite::TagHandle handle, - std::string &name_out, - Mesquite::Mesh::TagType &type_out, - unsigned &length_out, - Mesquite::MsqError& err ) - { - - Mesquite::TagHandle jhandle = reinterpret_cast(&m_nodeCoords); - Mesquite::TagHandle ph_handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - Mesquite::TagHandle proc_id_handle = reinterpret_cast(&m_is_proc_id_active); - Mesquite::TagHandle global_id_handle = reinterpret_cast(&m_is_global_id_active); - if (jhandle == handle) - { - if (!m_nodeCoords_tag_is_created) - { - MSQ_SETERR(err)("tag not yet created in PerceptMesquiteMesh::tag_properties.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - else - { - name_out = "msq_jacobi_temp_coords"; - type_out = Mesquite::Mesh::DOUBLE; - length_out = 3; - } - } - else if (ph_handle == handle) - { - if (!m_parallelHelperLocalIdMap_is_created) - { - MSQ_SETERR(err)("tag LOCAL_ID not yet created in PerceptMesquiteMesh::tag_properties.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - else - { - name_out = "LOCAL_ID"; - type_out = Mesquite::Mesh::INT; - length_out = 1; - } - } - else if (proc_id_handle == handle) - { - if (!m_is_proc_id_active) - { - MSQ_SETERR(err)("tag msq_parallel_proc_id not yet created in PerceptMesquiteMesh::tag_properties.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - else - { - name_out = "msq_parallel_proc_id"; - type_out = Mesquite::Mesh::INT; - length_out = 1; - } - } - else if (global_id_handle == handle) - { - if (!m_is_global_id_active) - { - MSQ_SETERR(err)("tag msq_parallel_global_id not yet created in PerceptMesquiteMesh::tag_properties.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - else - { - name_out = "msq_parallel_global_id"; - type_out = Mesquite::Mesh::HANDLE; - length_out = 1; - } - } - else - { - MSQ_SETERR(err)("Unknown tag in PerceptMesquiteMesh::tag_properties.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - - } - - //============================================================================ - // Description: Set tag values on elements. - // Set the value of a tag for a list of mesh elements. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_set_element_data(Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::ElementHandle* /*elem_array*/, - const void* /*tag_data*/, - Mesquite::MsqError& err ) - { - assert(0); - MSQ_SETERR(err)("Function not yet implemented.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - throw std::runtime_error("Function not yet ipmlemented, PerceptMesquiteMesh::tag_set_element_data"); - } - - //============================================================================ - // Description: Set tag values on vertices. - // Set the value of a tag for a list of mesh vertices. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_set_vertex_data (Mesquite::TagHandle handle, - size_t num_nodes, - const Mesquite::Mesh::VertexHandle* node_array, - const void* tag_data, - Mesquite::MsqError& err ) - { - - //int numNodes = get_total_vertex_count(err); - - Mesquite::TagHandle jhandle = reinterpret_cast(&m_nodeCoords); - Mesquite::TagHandle ph_handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - Mesquite::TagHandle proc_id_handle = reinterpret_cast(&m_is_proc_id_active); - Mesquite::TagHandle global_id_handle = reinterpret_cast(&m_is_global_id_active); - - if (jhandle == handle) - { - if (!m_nodeCoords_tag_is_created) - { - PRINT_ERROR("tag not yet created in PerceptMesquiteMesh::tag_set_vertex_data\n"); - MSQ_SETERR(err)("tag not yet created in PerceptMesquiteMesh::tag_set_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - double *coords_0 = (double *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - double *coords = &coords_0[inode*3]; - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - NodeCoordsType::iterator iter = m_nodeCoords.find(node_ptr); - if (iter == m_nodeCoords.end()) - { - Array3 coords_save; - coords_save[0] = coords[0]; - coords_save[1] = coords[1]; - coords_save[2] = (m_eMesh->get_spatial_dim() == 2 ? 0 : coords[2]); - m_nodeCoords[node_ptr] = coords_save; - } - else - { - Array3 &coords_save = m_nodeCoords[node_ptr]; - coords_save[0] = coords[0]; - coords_save[1] = coords[1]; - coords_save[2] = (m_eMesh->get_spatial_dim() == 2 ? 0 : coords[2]); - } - } - } - else if (ph_handle == handle) - { - if (!m_parallelHelperLocalIdMap_is_created) - { - PRINT_ERROR("tag LOCAL_ID not yet created in PerceptMesquiteMesh::tag_set_vertex_data\n"); - MSQ_SETERR(err)("tag LOCAL_ID not yet created in PerceptMesquiteMesh::tag_set_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - int *lid = (int *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - m_parallelHelperLocalIdMap[node_ptr] = lid[inode]; - } - } - else if (proc_id_handle == handle) - { - int *proc_id = (int *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - if (!proc_id || !node_ptr || (int)node_ptr->owner_rank() != proc_id[inode]) - { - PRINT_ERROR("proc_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_set_vertex_data\n"); - MSQ_SETERR(err)("proc_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_set_vertex_data\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - } - } - else if (global_id_handle == handle) - { - size_t *global_id = (size_t *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - if (!global_id || !node_ptr || (size_t)node_ptr->identifier() != global_id[inode]) - { - PRINT_ERROR("global_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_set_vertex_data\n"); - MSQ_SETERR(err)("global_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_set_vertex_data\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - } - } - else - { - PRINT_ERROR("Unknown tag handle in PerceptMesquiteMesh::tag_set_vertex_data\n"); - MSQ_SETERR(err)("Unknown tag handle in PerceptMesquiteMesh::tag_set_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - - - } - - //============================================================================ - // Description: Get tag values on elements. - // Get the value of a tag for a list of mesh elements. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_get_element_data(Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::ElementHandle* /*elem_array*/, - void* /*tag_data*/, - Mesquite::MsqError& err ) - { - assert(0); - MSQ_SETERR(err)("Function not yet implemented.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - throw std::runtime_error("Function not yet ipmlemented, PerceptMesquiteMesh::tag_get_element_data"); - } - - //============================================================================ - // Description: Get tag values on vertices. - // Get the value of a tag for a list of mesh vertices. - // Note: Pure virtual inherits from Mesquite::Mesh - // Author: sjowen, srkennon - // Date: 04/14/2011 - //============================================================================ - void PerceptMesquiteMesh::tag_get_vertex_data (Mesquite::TagHandle handle, - size_t num_nodes, - const Mesquite::Mesh::VertexHandle* node_array, - void* tag_data, - Mesquite::MsqError& err ) - { - - //int numNodes = get_total_vertex_count(err); - - Mesquite::TagHandle jhandle = reinterpret_cast(&m_nodeCoords); - Mesquite::TagHandle ph_handle = reinterpret_cast(&m_parallelHelperLocalIdMap); - Mesquite::TagHandle proc_id_handle = reinterpret_cast(&m_is_proc_id_active); - Mesquite::TagHandle global_id_handle = reinterpret_cast(&m_is_global_id_active); - if (jhandle == handle) - { - if (!m_nodeCoords_tag_is_created) - { - PRINT_ERROR("tag not yet created in PerceptMesquiteMesh::tag_get_vertex_data\n"); - MSQ_SETERR(err)("tag not yet created in PerceptMesquiteMesh::tag_get_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - double *coords_0 = (double *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - double *coords = &coords_0[inode*3]; - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - NodeCoordsType::iterator iter = m_nodeCoords.find(node_ptr); - if (iter == m_nodeCoords.end()) - { - MSQ_SETERR(err)("PerceptMesquiteMesh::tag_get_vertex_data: invalid vertex handle.",Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::tag_get_vertex_data: invalid vertex handle.\n"); - return; - } - else - { - Array3 &coords_save = m_nodeCoords[node_ptr]; - coords[0] = coords_save[0]; - coords[1] = coords_save[1]; - if (m_eMesh->get_spatial_dim() == 3) - coords[2] = coords_save[2]; - else - coords[2] = 0; - } - } - - } - else if (ph_handle == handle) - { - if (!m_parallelHelperLocalIdMap_is_created) - { - PRINT_ERROR("tag LOCAL_ID not yet created in PerceptMesquiteMesh::tag_get_vertex_data\n"); - MSQ_SETERR(err)("tag LOCAL_ID not yet created in PerceptMesquiteMesh::tag_get_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - int *lid = (int *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - ParallelHelperLocalIdType::iterator iter = m_parallelHelperLocalIdMap.find(node_ptr); - if (iter == m_parallelHelperLocalIdMap.end()) - { - MSQ_SETERR(err)("PerceptMesquiteMesh::tag_get_vertex_data: LOCAL_ID invalid vertex handle.",Mesquite::MsqError::INVALID_STATE); - PRINT_ERROR("PerceptMesquiteMesh::tag_get_vertex_data: LOCAL_ID invalid vertex handle.\n"); - return; - } - else - { - lid[inode] = m_parallelHelperLocalIdMap[node_ptr]; - } - } - } - else if (proc_id_handle == handle) - { - int *proc_id = (int *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - if (!proc_id || !node_ptr) - { - PRINT_ERROR("proc_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_get_vertex_data\n"); - MSQ_SETERR(err)("proc_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_get_vertex_data\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - proc_id[inode] = node_ptr->owner_rank(); - } - } - else if (global_id_handle == handle) - { - size_t *global_id = (size_t *)tag_data; - for(int inode = 0; inode < (int)num_nodes; inode++) - { - Mesquite::Mesh::VertexHandle vhandle = node_array[inode]; - stk_classic::mesh::Entity *node_ptr = reinterpret_cast(vhandle); - if (!global_id || !node_ptr) - { - PRINT_ERROR("global_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_get_vertex_data\n"); - MSQ_SETERR(err)("global_id/node_ptr/consistency problem in PerceptMesquiteMesh::tag_get_vertex_data\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - global_id[inode] = (size_t)node_ptr->identifier(); - } - } - else - { - PRINT_ERROR("Unknown tag handle in PerceptMesquiteMesh::tag_get_vertex_data\n"); - MSQ_SETERR(err)("Unknown tag handle in PerceptMesquiteMesh::tag_get_vertex_data.\n",Mesquite::MsqError::NOT_IMPLEMENTED); - } - - } - - - //============================================================================ - // Description: Tells the mesh that the client is finished with a given - // entity handle. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::release_entity_handles( - const EntityHandle* /*handle_array*/, - size_t /*num_handles*/, - Mesquite::MsqError &/*err*/) - { - // Do nothing... - } - - - //============================================================================ - // Description: Instead of deleting a Mesh when you think you are done, - //! call release(). In simple cases, the implementation could - //! just call the destructor. More sophisticated implementations - //! may want to keep the Mesh object to live longer than Mesquite - //! is using it. - // Author: sjowen, srkennon - // Date: 03/30/2011, 11/15/11 - //============================================================================ - void PerceptMesquiteMesh::release() - { - // We allocate on the stack, so don't delete this... - // delete this; - } - - //============================================================================ - // Description: return the location for a node stored in nodeCoords - // (used for storing updated nodal locations for Jacobi-type smoothing) - // Author: sjowen, srkennon - // Date: 4/4/2011 - //============================================================================ -#if 0 - bool PerceptMesquiteMesh::get_jacobi_vertex_coords(CMLNode *node_ptr, CubitVector &coords) - { - - std::map::iterator iter = nodeCoords.find( node_ptr ); - if (iter == nodeCoords.end()) - { - printf("#Jacobi Node Coords not set up for node %d.\n", node_ptr->id()); - return false; - } - coords = iter->second; - return true; - } -#endif - - - - //static bool myPerceptMesquiteMesh_cpp = true; - - - } // namespace percept -} // namespace stk_classic - -#endif // STK_BUILT_IN_SIERRA diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.hpp deleted file mode 100644 index cbf5000e2277..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMesh.hpp +++ /dev/null @@ -1,349 +0,0 @@ -//------------------------------------------------------------------------- -// Filename : PerceptMesquiteMesh.hpp, derived from SCVFracMesquiteMesh.hpp -// -// Purpose : mesh interface for using Mesquite -// -// Description : subclass of Mesquite::Mesh -// -// Creator : Steve Kennon, derived from Steve Owen's work -// -// Creation Date : Nov 2011 -// -// Owner : Steve Kennon -//------------------------------------------------------------------------- -#ifndef PERCEPT_MESQUITE_MESH_HPP -#define PERCEPT_MESQUITE_MESH_HPP - -// ibm can't compile mesquite - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -// #include -// #include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { - namespace percept { - - static const std::string PMM_global_id_name = "msq_parallel_global_id"; - static const std::string PMM_proc_id_name = "msq_parallel_proc_id"; - - class PerceptMesquiteMeshDomain; - - class PerceptMesquiteMesh : public Mesquite::Mesh - { - PerceptMesh *m_eMesh; - PerceptMesquiteMeshDomain *m_meshDomain; - stk_classic::mesh::Selector *m_boundarySelector; - //std::map > m_mesquiteNodeDataMap; - typedef boost::unordered_map > MesquiteNodeDataMapType; - MesquiteNodeDataMapType m_mesquiteNodeDataMap; - - typedef boost::array Array3; - typedef boost::unordered_map NodeCoordsType; - NodeCoordsType m_nodeCoords; - bool m_nodeCoords_tag_is_created; - bool m_is_proc_id_active; - bool m_is_global_id_active; - - typedef boost::unordered_map ParallelHelperLocalIdType; - ParallelHelperLocalIdType m_parallelHelperLocalIdMap; - bool m_parallelHelperLocalIdMap_is_created; - - public: - - PerceptMesquiteMesh(PerceptMesh *eMesh, PerceptMesquiteMeshDomain* domain=0, stk_classic::mesh::Selector *boundarySelector=0); - void init(PerceptMesh *eMesh); - int setup(); - - stk_classic::mesh::Selector *getBoundarySelector() { return m_boundarySelector; } - void setBoundarySelector(stk_classic::mesh::Selector *sel) { m_boundarySelector = sel; } - - PerceptMesh *getPerceptMesh() { return m_eMesh; } - bool get_fixed_flag(stk_classic::mesh::Entity* node_ptr); - - class PMMParallelMesh : public Mesquite::ParallelMeshImpl - { - public: - Mesquite::ParallelHelperImpl& helper; - - PMMParallelMesh(Mesquite::Mesh *mesh) : Mesquite::ParallelMeshImpl(mesh, PMM_global_id_name.c_str(), PMM_proc_id_name.c_str()), - helper(* new Mesquite::ParallelHelperImpl) - { - /* create parallel mesh instance, specifying tags - * containing parallel data */ - helper.set_communicator(MPI_COMM_WORLD); - helper.set_parallel_mesh(this); - this->set_parallel_helper(&helper); - } - - ~PMMParallelMesh() { delete &helper; } - - }; - - - public: - virtual ~PerceptMesquiteMesh(); - - //************ Operations on entire mesh **************** - //! Returns whether this mesh lies in a 2D or 3D coordinate system. - virtual int get_geometric_dimension(Mesquite::MsqError &err); - - //! Returns the number of entities of the indicated type. - virtual size_t get_total_vertex_count(Mesquite::MsqError &err) const; - virtual size_t get_total_element_count(Mesquite::MsqError &err) const; - - //! Fills vector with handles to all vertices/elements - //! in the mesh. - virtual void get_all_vertices(std::vector &vertices, - Mesquite::MsqError &err); - - virtual void get_all_elements(std::vector &elements, - Mesquite::MsqError &err); - - //! Returns a pointer to an iterator that iterates over the - //! set of all vertices in this mesh. The calling code should - //! delete the returned iterator when it is finished with it. - //! If vertices are added or removed from the Mesh after obtaining - //! an iterator, the behavior of that iterator is undefined. - //virtual Mesquite::VertexIterator* vertex_iterator(Mesquite::MsqError &err); - - //! Returns a pointer to an iterator that iterates over the - //! set of all top-level elements in this mesh. The calling code should - //! delete the returned iterator when it is finished with it. - //! If elements are added or removed from the Mesh after obtaining - //! an iterator, the behavior of that iterator is undefined. - //virtual Mesquite::ElementIterator* element_iterator(Mesquite::MsqError &err); - - - //! Returns true or false, indicating whether the vertex - //! is a higher-order node that should be slaved to the logical - //! mid-point of the element side it lies on or not, respectively. - //! - //! Note: This function will never be called unless this behavior is - //! requested by calling: - //! InstructionQueue::set_slaved_ho_node_mode( Settings::SLAVE_FLAG ) - virtual void vertices_get_fixed_flag(const Mesquite::Mesh::VertexHandle vert_array[], - std::vector& fixed_flag_array, - size_t num_vtx, - Mesquite::MsqError &err ); - - //! Returns true or false, indicating whether the vertex - //! is a higher-order node that should be slaved to the logical - //! mid-point of the element side it lies on or not, respectively. - //! - //! Note: This function will never be called unless this behavior is - //! requested by calling: - //! InstructionQueue::set_slaved_ho_node_mode( Settings::SLAVE_FLAG ) - virtual void vertices_get_slaved_flag(const VertexHandle vert_array[], - std::vector& slaved_flag_array, - size_t num_vtx, - Mesquite::MsqError &err ); - - - //! Get/set location of a vertex (vertices) - virtual void vertices_get_coordinates(const Mesquite::Mesh::VertexHandle vert_array[], - Mesquite::MsqVertex* coordinates, - size_t num_vtx, - Mesquite::MsqError &err); - - virtual void vertex_set_coordinates(Mesquite::Mesh::VertexHandle vertex, - const Mesquite::Vector3D &coordinates, - Mesquite::MsqError &err); - - //! Each vertex has a byte-sized flag that can be used to store - //! flags. This byte's value is neither set nor used by the mesh - //! implementation. It is intended to be used by Mesquite algorithms. - //! Until a vertex's byte has been explicitly set, its value is 0. - virtual void vertex_set_byte (Mesquite::Mesh::VertexHandle vertex, - unsigned char byte, - Mesquite::MsqError &err); - - virtual void vertices_set_byte (const Mesquite::Mesh::VertexHandle *vert_array, - const unsigned char *byte_array, - size_t array_size, - Mesquite::MsqError &err); - - //! Retrieve the byte value for the specified vertex or vertices. - //! The byte value is 0 if it has not yet been set via one of the - //! *_set_byte() functions. - virtual void vertex_get_byte(const Mesquite::Mesh::VertexHandle vertex, - unsigned char *byte, - Mesquite::MsqError &err); - - virtual void vertices_get_byte(const Mesquite::Mesh::VertexHandle *vertex_array, - unsigned char *byte_array, - size_t array_size, - Mesquite::MsqError &err); - - // //**************** Vertex Topology ***************** - // //! Gets the number of elements attached to this vertex. - // //! Useful to determine how large the "elem_array" parameter - // //! of the vertex_get_attached_elements() function must be. - //! Gets the elements attached to this vertex. - - virtual void vertices_get_attached_elements(const Mesquite::Mesh::VertexHandle* vertex_array, - size_t num_vertex, - std::vector& elements, - std::vector &offsets, - Mesquite::MsqError &err); - - virtual void elements_get_attached_vertices(const Mesquite::Mesh::ElementHandle *elem_handles, - size_t num_elems, - std::vector& vert_handles, - std::vector &offsets, - Mesquite::MsqError &err); - - //! Returns the topologies of the given entities. The "entity_topologies" - //! array must be at least "num_elements" in size. - virtual void elements_get_topologies(const Mesquite::Mesh::ElementHandle *element_handle_array, - Mesquite::EntityTopology *element_topologies, - size_t num_elements, - Mesquite::MsqError &err); - - - //BEGIN TAGs - virtual Mesquite::TagHandle tag_create(const std::string& /*tag_name*/, - Mesquite::Mesh::TagType /*type*/, - unsigned /*length*/, - const void* /*default_value*/, - Mesquite::MsqError &err); - - virtual void tag_delete(Mesquite::TagHandle /*handle*/, - Mesquite::MsqError& err ); - - - virtual Mesquite::TagHandle tag_get(const std::string& /*name*/, - Mesquite::MsqError& err ); - - virtual void tag_properties(Mesquite::TagHandle /*handle*/, - std::string& /*name_out*/, - Mesquite::Mesh::TagType& /*type_out*/, - unsigned& /*length_out*/, - Mesquite::MsqError& err ); - - - virtual void tag_set_element_data(Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::ElementHandle* /*elem_array*/, - const void* /*tag_data*/, - Mesquite::MsqError& err ); - - - virtual void tag_set_vertex_data (Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::VertexHandle* /*node_array*/, - const void* /*tag_data*/, - Mesquite::MsqError& err ); - - virtual void tag_get_element_data(Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::ElementHandle* /*elem_array*/, - void* /*tag_data*/, - Mesquite::MsqError& err ); - - virtual void tag_get_vertex_data (Mesquite::TagHandle /*handle*/, - size_t /*num_elems*/, - const Mesquite::Mesh::VertexHandle* /*node_array*/, - void* /*tag_data*/, - Mesquite::MsqError& err ); - - //END TAGS - - //**************** Memory Management **************** - //! Tells the mesh that the client is finished with a given - //! entity handle. - virtual void release_entity_handles(const Mesquite::Mesh::EntityHandle *handle_array, - size_t num_handles, - Mesquite::MsqError &err); - - //! Instead of deleting a Mesh when you think you are done, - //! call release(). In simple cases, the implementation could - //! just call the destructor. More sophisticated implementations - //! may want to keep the Mesh object to live longer than Mesquite - //! is using it. - virtual void release(); - - /* - CMLNode** get_node_array() - {return nodeArray;} - CMLMeshEntity** get_element_array() - {return elementArray;} - int get_num_nodes() - {return numNodes;} - int get_num_elements() - {return numElements;} - bool get_jacobi_vertex_coords(CMLNode *node_ptr, CubitVector &coords); - */ - - static bool select_bucket(stk_classic::mesh::Bucket& bucket, PerceptMesh *eMesh); - - private: - - bool select_bucket(stk_classic::mesh::Bucket& bucket) const; - bool select_element(stk_classic::mesh::Entity& element) const; - -#if 0 - // sjowen debug - bool dump_hexes(DLIList &hex_list, DLIList &node_list, int rank); - bool get_nodes_on_hexes(DLIList &hex_list, - DLIList &node_list); - bool isSetup; - int myRank; - - //MRefEntity* mOwner; - - DLIList mOwners; - - /*DLIList* cachedEntityList;*/ - /*MLNode** cachedNode;*/ - //DLIList elementList; - - std::map > mesquiteNodeDataMap; - std::map nodeCoords; - - std::map jacobiCoordsMap; - double *jacobiCoords; - int nextJacobiCoordsIndex; - - CMLNode** nodeArray; - CMLMeshEntity** elementArray; - std::set includedElements; - int numNodes; - int numElements; - - //booleans about what element types we have - CubitBoolean triExists; - CubitBoolean quadExists; - CubitBoolean tetExists; - CubitBoolean hexExists; - - bool freeScheme; - bool doJacobiIterations; - - unsigned char myDimension; - - bool is_on_my_patch_boundary(CMLNode *node_ptr); -#endif - - - }; - - - //static bool myPerceptMesquiteMesh_hpp = true; - - } // namespace percept -} // namespace stk_classic - -#endif // STK_BUILT_IN_SIERRA -#endif //has file been included diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.cpp deleted file mode 100644 index 3be5b132bc98..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.cpp +++ /dev/null @@ -1,317 +0,0 @@ -//------------------------------------------------------------------------- -// Filename : PerceptMesquiteMeshDomain.cpp -// -// Purpose : mesh domain interface for using Mesquite -// -// Description : subclass of Mesquite::MeshDomain -// -// Creator : Steve Kennon, derived from Steve Owen's work -// -// Creation Date : Dec 2011 -// -// Owner : Steve Kennon -//------------------------------------------------------------------------- - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include "PerceptMesquiteMeshDomain.hpp" -//#include -#include - -#include -#include - -namespace stk_classic { - namespace percept { - -#define PRINT_ERROR(a) do { std::cout << "PerceptMesquite::Mesh::ERROR: " << a << std::endl; } while (0) - - //! Modifies "coordinate" so that it lies on the - //! domain to which "entity_handle" is constrained. - //! The handle determines the domain. The coordinate - //! is the proposed new position on that domain. - void PerceptMesquiteMeshDomain:: - snap_to(Mesquite::Mesh::VertexHandle entity_handle, - Mesquite::Vector3D &coordinate) const { - - if (!m_meshGeometry) return; - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(entity_handle); - stk_classic::mesh::FieldBase* field = m_eMesh->get_coordinates_field(); - double *f_data = PerceptMesh::field_data(field, *node_ptr); - - double f_data_save[3] = {f_data[0], f_data[1], 0}; - if (m_eMesh->get_spatial_dim() > 2) f_data_save[2] = f_data[2]; - -// if (node_ptr->identifier() == 584) -// { -// std::cout << "tmp snap_to: node= " << node_ptr->identifier() << std::endl; -// } - - f_data[0] = coordinate[0]; - f_data[1] = coordinate[1]; - if (m_eMesh->get_spatial_dim() > 2) - f_data[2] = coordinate[2]; - - static std::vector nodes(1); - nodes[0] = node_ptr; - m_meshGeometry->snap_points_to_geometry(m_eMesh, nodes); - coordinate[0] = f_data[0]; - coordinate[1] = f_data[1]; - if (m_eMesh->get_spatial_dim() > 2) - coordinate[2] = f_data[2]; - - //if (node_ptr->identifier() == 584) - if (0) - { - std::cout << "tmp snap_to: node= " << node_ptr->identifier() << " orig= " - << f_data_save[0] << " " - << f_data_save[1] << " " - << f_data_save[2] << " " - << " new= " - << f_data[0] << " " - << f_data[1] << " " - << f_data[2] << " diff1= " - << (std::fabs(f_data[0] - f_data_save[0])+ - std::fabs(f_data[1] - f_data_save[1])+ - std::fabs(f_data[2] - f_data_save[2])) - << std::endl; - } - - f_data[0] = f_data_save[0]; - f_data[1] = f_data_save[1]; - if (m_eMesh->get_spatial_dim() > 2) - f_data[2] = f_data_save[2]; - - } - - //! Returns the normal of the domain to which - //! "entity_handle" is constrained. For non-planar surfaces, - //! the normal is calculated at the point on the domain that - //! is closest to the passed in value of "coordinate". If the - //! domain does not have a normal, or the normal cannot - //! be determined, "coordinate" is set to (0,0,0). Otherwise, - //! "coordinate" is set to the domain's normal at the - //! appropriate point. - //! In summary, the handle determines the domain. The coordinate - //! determines the point of interest on that domain. - //! - //! User should see also PatchData::get_domain_normal_at_vertex and - //! PatchData::get_domain_normal_at_element . - void PerceptMesquiteMeshDomain:: - vertex_normal_at(Mesquite::Mesh::VertexHandle entity_handle, - Mesquite::Vector3D &coordinate) const { - // FIXME srk - coordinate[0] = 0.0; - coordinate[1] = 0.0; - coordinate[2] = 1.0; - if (m_eMesh->get_spatial_dim() == 3) - { - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(entity_handle); - //stk_classic::mesh::FieldBase* field = m_eMesh->get_coordinates_field(); - //double *f_data = PerceptMesh::field_data(field, *node_ptr); - if (!m_meshGeometry) - { - return; - } - - std::vector normal(3,0.0); - m_meshGeometry->normal_at(m_eMesh, node_ptr, normal); - coordinate[0] = normal[0]; - coordinate[1] = normal[1]; - coordinate[2] = normal[2]; - } - } - - void PerceptMesquiteMeshDomain:: - element_normal_at(Mesquite::Mesh::ElementHandle entity_handle, - Mesquite::Vector3D &coordinate) const { - // FIXME srk - coordinate[0] = 0.0; - coordinate[1] = 0.0; - if (m_eMesh->get_spatial_dim() > 2) - { - coordinate[2] = 0.0; - } - else - { - coordinate[2] = 1.0; - return; - } - if (!m_meshGeometry) return; - - stk_classic::mesh::Entity* element_ptr = reinterpret_cast(entity_handle); - - stk_classic::mesh::PairIterRelation nodes = element_ptr->relations(m_eMesh->node_rank()); - double nodes_size = nodes.size(); - - for (unsigned inode=0; inode < nodes.size(); inode++) - { - stk_classic::mesh::Entity& node = *nodes[inode].entity(); - - std::vector normal(3,0.0); - m_meshGeometry->normal_at(m_eMesh, &node, normal); - coordinate[0] += normal[0]/nodes_size; - coordinate[1] += normal[1]/nodes_size; - coordinate[2] += normal[2]/nodes_size; - } - } - - /**\brief evaluate surface normals - * - * Returns normals for a domain. - * - *\param handles The domain evaluated is the one in which - * this mesh entity is constrained. - *\param coordinates As input, a list of positions at which to - * evaluate the domain. As output, the resulting - * domain normals. - *\param count The length of the coordinates array. - */ - void PerceptMesquiteMeshDomain:: - vertex_normal_at( const Mesquite::Mesh::VertexHandle* handles, - Mesquite::Vector3D coordinates[], - unsigned count, - Mesquite::MsqError& err ) const { - for (unsigned i=0; i < count; i++) - { - vertex_normal_at(handles[i], coordinates[i]); - } - } - - /**\brief evaluate closest point and normal - * - * Given a position in space, return the closest - * position in the domain and the domain normal - * at that point. - * - *\param entity_handle Evaluate the subset of the domain contianing - * this entity - *\param position Input position for which to evaluate - *\param closest Closest position in the domain. - *\param normal Domain normal at the location of 'closest' - */ - void PerceptMesquiteMeshDomain:: - closest_point( Mesquite::Mesh::VertexHandle handle, - const Mesquite::Vector3D& position, - Mesquite::Vector3D& closest, - Mesquite::Vector3D& normal, - Mesquite::MsqError& err ) const { - - // this could be more efficient if the MeshGeometry interface supported an - // auxiliary coordinate (e.g. the "position" arg) - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(handle); - stk_classic::mesh::FieldBase* field = m_eMesh->get_coordinates_field(); - double *f_data = PerceptMesh::field_data(field, *node_ptr); - if (!m_meshGeometry) - { - for (int isd=0; isd < m_eMesh->get_spatial_dim(); isd++) - { - closest[isd] = f_data[isd]; - normal[isd]=0; // FIXME - } - normal[2]=1.0; - return; - } - - // save coordinates, set to "position", project, copy to closest, set back to saved - double save_coords[3] = {f_data[0], f_data[1], 0}; - if (m_eMesh->get_spatial_dim() > 2) save_coords[2] = f_data[2]; - f_data[0] = position[0]; - f_data[1] = position[1]; - if (m_eMesh->get_spatial_dim() > 2) - f_data[2] = position[2]; - - static std::vector nodes(1); - nodes[0] = node_ptr; - m_meshGeometry->snap_points_to_geometry(m_eMesh, nodes); - - closest[0] = f_data[0]; - closest[1] = f_data[1]; - if (m_eMesh->get_spatial_dim() > 2) - closest[2] = f_data[2]; - - // FIXME srk - normal[0] = 0; - normal[1] = 0; - normal[2] = 1; - if (m_eMesh->get_spatial_dim() > 2) - { - std::vector norm(3,0.0); - m_meshGeometry->normal_at(m_eMesh, node_ptr, norm); - normal[0] = norm[0]; - normal[1] = norm[1]; - normal[2] = norm[2]; - } - - if (0) - { - std::cout << "tmp closest_point: orig= " - << save_coords[0] << " " - << save_coords[1] << " " - << save_coords[2] << " " - << " new= " - << f_data[0] << " " - << f_data[1] << " " - << f_data[2] - << std::endl; - } - - f_data[0] = save_coords[0]; - f_data[1] = save_coords[1]; - if (m_eMesh->get_spatial_dim() > 2) - f_data[2] = save_coords[2]; - } - - int PerceptMesquiteMeshDomain:: - classify_node(stk_classic::mesh::Entity& node, size_t& curveOrSurfaceEvaluator) const - { - int dof =0; - if (m_meshGeometry) - dof = m_meshGeometry->classify_node(node, curveOrSurfaceEvaluator); - else - dof = m_eMesh->get_spatial_dim(); - return dof; - } - - /**\brief Get degrees of freedom in vertex movement. - * - * Given a vertex, return how the domain constrains the - * location of that vertex as the number of degrees of - * freedom in the motion of the vertex. If the domain - * is a geometric domain, the degrees of freedom for a - * vertex is the dimension of the geometric entity the - * vertex is constrained to lie on (e.g. point = 0, curve = 1, - * surface = 2, volume = 3.) - */ - void PerceptMesquiteMeshDomain:: - domain_DoF( const Mesquite::Mesh::EntityHandle* handle_array, - unsigned short* dof_array, - size_t num_handles, - Mesquite::MsqError& err ) const { - - size_t curveOrSurfaceEvaluator; - - for (size_t i = 0; i < num_handles; i++) - { - stk_classic::mesh::Entity* node_ptr = reinterpret_cast(handle_array[i]); - int dof = classify_node(*node_ptr, curveOrSurfaceEvaluator); - - if (dof < 0) - { - PRINT_ERROR("dof < 0"); - MSQ_SETERR(err)("PerceptMesquiteMeshDomain::domain_DoF classify returned -1", Mesquite::MsqError::INVALID_STATE); - return; - } - dof_array[i] = (unsigned short)dof; - } - } - - - //static bool myPerceptMesquiteMesh_cpp = true; - - - } // namespace percept -} // namespace stk_classic - -#endif // STK_BUILT_IN_SIERRA diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.hpp deleted file mode 100644 index 852557ca01e9..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/PerceptMesquiteMeshDomain.hpp +++ /dev/null @@ -1,144 +0,0 @@ -//------------------------------------------------------------------------- -// Filename : PerceptMesquiteMeshDomain.hpp -// -// Purpose : mesh domain (geometry) interface for using Mesquite -// -// Description : subclass of Mesquite::Mesh::Domain -// -// Creator : Steve Kennon, derived from Steve Owen's work -// -// Creation Date : Dec 2011 -// -// Owner : Steve Kennon -//------------------------------------------------------------------------- -#ifndef PERCEPT_MESQUITE_MESH_DOMAIN_HPP -#define PERCEPT_MESQUITE_MESH_DOMAIN_HPP - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - - -#include -#include -#include - -#include -#include -#include - -class MeshGeometry; - -namespace stk_classic { - namespace percept { - - class PerceptMesquiteMeshDomain : public Mesquite::MeshDomain - { - PerceptMesh *m_eMesh; - MeshGeometry *m_meshGeometry; - - // stk_classic::mesh::Selector *m_boundarySelector; - // std::map > m_mesquiteNodeDataMap; - - public: - - PerceptMesquiteMeshDomain(PerceptMesh *eMesh, MeshGeometry *meshGeometry=0) : m_eMesh(eMesh), m_meshGeometry(meshGeometry) - { - if (m_meshGeometry) - m_meshGeometry->m_cache_classify_bucket_is_active = true; - } - - // void init(PerceptMesh *eMesh); - // int setup(); - // bool is_on_my_patch_boundary(stk_classic::mesh::Entity *node_ptr); - // void clean_out(); - - public: - virtual ~PerceptMesquiteMeshDomain() {} - - - //! Modifies "coordinate" so that it lies on the - //! domain to which "entity_handle" is constrained. - //! The handle determines the domain. The coordinate - //! is the proposed new position on that domain. - virtual void snap_to(Mesquite::Mesh::VertexHandle entity_handle, - Mesquite::Vector3D &coordinate) const ; - - //! Returns the normal of the domain to which - //! "entity_handle" is constrained. For non-planar surfaces, - //! the normal is calculated at the point on the domain that - //! is closest to the passed in value of "coordinate". If the - //! domain does not have a normal, or the normal cannot - //! be determined, "coordinate" is set to (0,0,0). Otherwise, - //! "coordinate" is set to the domain's normal at the - //! appropriate point. - //! In summary, the handle determines the domain. The coordinate - //! determines the point of interest on that domain. - //! - //! User should see also PatchData::get_domain_normal_at_vertex and - //! PatchData::get_domain_normal_at_element . - virtual void vertex_normal_at(Mesquite::Mesh::VertexHandle entity_handle, - Mesquite::Vector3D &coordinate) const ; - virtual void element_normal_at(Mesquite::Mesh::ElementHandle entity_handle, - Mesquite::Vector3D &coordinate) const ; - - /**\brief evaluate surface normals - * - * Returns normals for a domain. - * - *\param handles The domain evaluated is the one in which - * this mesh entity is constrained. - *\param coordinates As input, a list of positions at which to - * evaluate the domain. As output, the resulting - * domain normals. - *\param count The length of the coordinates array. - */ - virtual void vertex_normal_at( const Mesquite::Mesh::VertexHandle* handles, - Mesquite::Vector3D coordinates[], - unsigned count, - Mesquite::MsqError& err ) const ; - - /**\brief evaluate closest point and normal - * - * Given a position in space, return the closest - * position in the domain and the domain normal - * at that point. - * - *\param entity_handle Evaluate the subset of the domain contianing - * this entity - *\param position Input position for which to evaluate - *\param closest Closest position in the domain. - *\param normal Domain normal at the location of 'closest' - */ - virtual void closest_point( Mesquite::Mesh::VertexHandle handle, - const Mesquite::Vector3D& position, - Mesquite::Vector3D& closest, - Mesquite::Vector3D& normal, - Mesquite::MsqError& err ) const ; - - /**\brief Get degrees of freedom in vertex movement. - * - * Given a vertex, return how the domain constrains the - * location of that vertex as the number of degrees of - * freedom in the motion of the vertex. If the domain - * is a geometric domain, the degrees of freedom for a - * vertex is the dimension of the geometric entity the - * vertex is constrained to lie on (e.g. point = 0, curve = 1, - * surface = 2, volume = 3.) - */ - virtual void domain_DoF( const Mesquite::Mesh::EntityHandle* handle_array, - unsigned short* dof_array, - size_t num_handles, - Mesquite::MsqError& err ) const ; - - int classify_node(stk_classic::mesh::Entity& node, size_t& curveOrSurfaceEvaluator) const; - - }; - - - //static bool myPerceptMesquiteMeshDomain_hpp = true; - - } // namespace percept -} // namespace stk_classic - -#endif // STK_BUILT_IN_SIERRA -#endif //has file been included diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.cpp deleted file mode 100644 index af2b98755ab0..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include - -#include - -#include "SpacingFieldUtil.hpp" - -#include "mpi.h" - -namespace MESQUITE_NS { - - extern int get_parallel_rank(); -} - -namespace stk_classic { - namespace percept { - - using namespace Mesquite; - - void SpacingFieldUtil::compute_spacing_field() - { - stk_classic::mesh::FieldBase *spacing_field = m_eMesh.get_field("ref_spacing_field"); - stk_classic::mesh::FieldBase *spacing_field_counter = m_eMesh.get_field("ref_spacing_field_counter"); - - m_eMesh.nodal_field_set_value(spacing_field, 0.0); - m_eMesh.nodal_field_set_value(spacing_field_counter, 0.0); - - MsqMatrix<3,3> AI; - - int spatial_dim = m_eMesh.get_spatial_dim(); - - stk_classic::mesh::Selector on_locally_owned_part = ( m_eMesh.get_fem_meta_data()->locally_owned_part() ); - stk_classic::mesh::Selector on_globally_shared_part = ( m_eMesh.get_fem_meta_data()->globally_shared_part() ); - - { - // element loop: compute deltas - const std::vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.element_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (PerceptMesquiteMesh::select_bucket(**k, &m_eMesh) && on_locally_owned_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_elements_in_bucket = bucket.size(); - const CellTopologyData *topology_data = m_eMesh.get_cell_topology(bucket); - - for (unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) - { - stk_classic::mesh::Entity& element = bucket[i_element]; - JacobianUtil jacA; - - double A_ = 0.0; - jacA(A_, m_eMesh, element, m_eMesh.get_coordinates_field(), topology_data); - - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - unsigned num_node = elem_nodes.size(); - - for (unsigned inode=0; inode < num_node; inode++) - { - mesh::Entity & node = *elem_nodes[ inode ].entity(); - double *spacing = PerceptMesh::field_data(spacing_field, node); - double *spacing_counter = PerceptMesh::field_data(spacing_field_counter, node); - if (m_type == SPACING_AVE) - spacing_counter[0] += 1.0; - else - spacing_counter[0] = 1.0; - - inverse(jacA.m_J[inode], AI); - for (int jdim=0; jdim < spatial_dim; jdim++) - { - double sum=0.0; - for (int idim=0; idim < spatial_dim; idim++) - { - sum += AI(idim,jdim)*AI(idim,jdim); - } - sum = std::sqrt(sum); - if (m_type == SPACING_AVE) - spacing[jdim] += 1.0/sum; - else - spacing[jdim] = std::max(spacing[jdim], 1.0/sum); - } - } - } - } - } - - VectorFieldType *spacing_field_v = static_cast(spacing_field); - stk_classic::mesh::parallel_reduce(*m_eMesh.get_bulk_data(), stk_classic::mesh::sum(*spacing_field_v)); - - VectorFieldType *spacing_field_counter_v = static_cast(spacing_field_counter); - stk_classic::mesh::parallel_reduce(*m_eMesh.get_bulk_data(), stk_classic::mesh::sum(*spacing_field_counter_v)); - - { - std::vector< const stk_classic::mesh::FieldBase *> fields; - fields.push_back(spacing_field); - fields.push_back(spacing_field_counter); - - // only the aura = !locally_owned_part && !globally_shared_part (outer layer) - stk_classic::mesh::communicate_field_data(m_eMesh.get_bulk_data()->shared_aura(), fields); - - // the shared part (just the shared boundary) - //stk_classic::mesh::communicate_field_data(*m_eMesh->get_bulk_data()->ghostings()[0], fields); - } - - } - - { - // nodal loop - const std::vector & buckets = m_eMesh.get_bulk_data()->buckets( m_eMesh.node_rank() ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (on_locally_owned_part(**k) || on_globally_shared_part(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned i_node = 0; i_node < num_nodes_in_bucket; i_node++) - { - stk_classic::mesh::Entity& node = bucket[i_node]; - double *spacing = PerceptMesh::field_data(spacing_field, node); - double *spacing_counter = PerceptMesh::field_data(spacing_field_counter, node); - - for (int idim=0; idim < spatial_dim; idim++) - { - spacing[idim] /= spacing_counter[0]; - } - } - } - } - } - - - } - - } -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.hpp deleted file mode 100644 index 7d0533dec17b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/mesh/mod/mesquite-interface/SpacingFieldUtil.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef SpacingFieldUtil_hpp -#define SpacingFieldUtil_hpp - -#include -#if !defined(__IBMCPP__) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include "JacobianUtil.hpp" - -namespace stk_classic { - namespace percept { - - class SpacingFieldUtil - { - public: - /// either average or take max of spacing to the nodes - enum SpacingType { SPACING_AVE, SPACING_MAX }; - - SpacingFieldUtil(PerceptMesh& eMesh, SpacingType type=SPACING_AVE) : m_eMesh(eMesh), m_type(type) {} - - - void compute_spacing_field(); - - private: - PerceptMesh& m_eMesh; - SpacingType m_type; - - }; - } -} - -#endif -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/norm/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/norm/CMakeLists.txt deleted file mode 100644 index e9c2a8c64f2b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/norm/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/norm/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/norm/H1Norm.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/norm/H1Norm.hpp deleted file mode 100644 index 197411fe0688..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/norm/H1Norm.hpp +++ /dev/null @@ -1,168 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef stk_percept_H1Norm_hpp -#define stk_percept_H1Norm_hpp - -#include - -namespace stk_classic -{ - namespace percept - { - - - class H1_NormOp : public Function, public HasFinalOp > - { - Function& m_integrand; - Teuchos::RCP m_grad_integrand; - MDArray m_grad_codomain; - int m_spatialDim; - - public: - - /// integrand tells what fields Intrepid should compute, etc. - H1_NormOp(Function& integrand, int spatialDim=3) : Function("H1_NormOp",integrand.getCodomainDimensions(), integrand.getCodomainDimensions()) , m_integrand(integrand), m_spatialDim(spatialDim) { - m_grad_integrand = m_integrand.gradient(spatialDim); - m_grad_codomain = m_grad_integrand->getNewCodomain(); - } - - void operator()(MDArray& pc_mda, MDArray& iv_mda, double time_value_optional=0.0) - { - //VERIFY_OP(pc_mda.size(), ==, iv_mda.size(), "H1_NormOp::operator() bad sizes"); - - m_integrand(pc_mda, iv_mda, time_value_optional); - std::vector dims; - iv_mda.dimensions(dims); - dims.back() = m_grad_codomain.dimension(m_grad_codomain.rank()-1); - VERIFY_OP_ON(dims.back(), ==, m_spatialDim, "H1Norm::operator()"); - MDArray out_grad(Teuchos::Array(dims.begin(), dims.end())); - (*m_grad_integrand)(pc_mda, out_grad, time_value_optional); - VERIFY_OP_ON(out_grad.size(), ==, iv_mda.size()*m_spatialDim, "H1Norm::operator() 2"); - for (int i = 0; i < out_grad.size()/ m_spatialDim; i++) - { - double sum=0.0; - for (int j = 0; j < m_spatialDim; j++) - sum += SQR(out_grad[i * m_spatialDim + j]); - - sum += SQR(iv_mda(i)); - - iv_mda(i) = sum; - } - } - - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - (*this)(domain, codomain, time_value_optional); - } - - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Bucket& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - (*this)(domain, codomain, time_value_optional); - } - - void finalOp(const std::vector& vin, std::vector& vout) - { - for (unsigned i = 0; i < vin.size(); i++) - vout[i] = std::sqrt(vin[i]); - } - }; - - /// compute the H1 norm or semi-norm - class H1Norm : public Norm<2> - { - public: - typedef Norm<2> Base; - - H1Norm(mesh::BulkData& bulkData, std::string partName, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - Base(bulkData, partName, turboOpt, is_surface_norm) {} - - H1Norm(mesh::BulkData& bulkData, MDArrayString& partNames, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - Base(bulkData, partNames, turboOpt, is_surface_norm) {} - - H1Norm(mesh::BulkData& bulkData, mesh::Part *part = 0, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - Base(bulkData, part, turboOpt, is_surface_norm) {} - -#ifndef SWIG - H1Norm(mesh::BulkData& bulkData, mesh::Selector * selector,TurboOption turboOpt=TURBO_NONE, bool is_surface_norm = false) : - Base(bulkData, selector, turboOpt, is_surface_norm) {} -#endif - - virtual void operator()(Function& integrand, Function& result) - { - EXCEPTWATCH; - - /** contract: - * - * 1. @param integrand : maps input_phy_points([C],[P],[D]) to output_values([C],[P],[DOF]) - * 2. this function then copies output_values to the @param result (assumes it is a ConstantFunction) - * - * algorithm: - * 1. loop over elements (later buckets) and fire @param integrand on each quadrature point/cell collection - * 2. further process the output_values by the LN_Op function, which simply raises the results to the N'th power - * 3. (note: later we can pass in an Op instead of this being hard-coded to norm_LN) - * 4. fire a "finalOp" on the resulting parallel accumulation buffer (supplied by LN_Op) - */ - - //std::cout << "type= " << typeid(integrand).name() << " " << typeid(FieldFunction).name() << std::endl; - - { - // FIXME - make all stk_classic::percept code const-correct - PerceptMesh eMesh(&mesh::fem::FEMMetaData::get(m_bulkData), &m_bulkData); - int spatialDim = eMesh.get_spatial_dim(); - H1_NormOp H1_op(integrand, spatialDim); - //CompositeFunction H1_of_integrand("H1_of_integrand", integrand, H1_op); - IntegratedOp integrated_H1_op(H1_op, m_turboOpt); - integrated_H1_op.setCubDegree(m_cubDegree); - - const stk_classic::mesh::Part& locally_owned_part = mesh::fem::FEMMetaData::get(m_bulkData).locally_owned_part(); - stk_classic::mesh::Selector selector(*m_selector & locally_owned_part); - //eMesh.print_info("Norm"); - if (m_turboOpt == TURBO_NONE || m_turboOpt == TURBO_ELEMENT) - { - eMesh.elementOpLoop(integrated_H1_op, 0, &selector, m_is_surface_norm); - } - else if (m_turboOpt == TURBO_BUCKET) - { - eMesh.bucketOpLoop(integrated_H1_op, 0, &selector, m_is_surface_norm); - } - - unsigned vec_sz = integrated_H1_op.getValue().size(); - std::vector local = integrated_H1_op.getValue(); - - //unsigned p_rank = m_bulkData.parallel_rank(); - //std::cout << "P["< -#include -#include - - -#include "Intrepid_RealSpaceTools.hpp" -#include "Intrepid_DefaultCubatureFactory.hpp" -#include "Intrepid_Utils.hpp" - -#include "IntrepidManager.hpp" - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -//using namespace std; -using namespace Intrepid; - -namespace stk_classic -{ - namespace percept - { - - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( Elements_Tag ) - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( Cub_Points_Tag ) - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( NodesPerElem_Tag ) - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( Spatial_Dim_Tag ) - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( DOFs_Tag ) // [F] FIXME - IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( BasisFields_Tag ) // [B] FIXME - -#if (defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND)) - // workaround for PGI compiler bug - void IntrepidManager::bootstrap() - { - static BasisTypeRCP a1 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C1_FEM() ); - - // FIXME - static BasisTypeRCP a2 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_LINE_C1_FEM() ); - static BasisTypeRCP a3 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C1_FEM() ); - static BasisTypeRCP a4 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C2_FEM() ); - - static BasisTypeRCP a5 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C1_FEM() ); - static BasisTypeRCP a6 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM() ); - static BasisTypeRCP a7 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_FEM() ); - - static BasisTypeRCP a8 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C1_FEM() ); - static BasisTypeRCP a9 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C2_Serendipity_FEM() ); - static BasisTypeRCP a10 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_HEX_C2_FEM() ); - - static BasisTypeRCP a11 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TET_C1_FEM() ); - static BasisTypeRCP a12 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TET_C2_FEM() ); - - static BasisTypeRCP a13 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_WEDGE_C1_FEM() ); - - // Intrepid doesn't support wedge 15 - static BasisTypeRCP a14 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_WEDGE_C2_Serendipity_FEM() ); - - - // Shells - static BasisTypeRCP a15 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C1_FEM() ); - static BasisTypeRCP a16 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_TRI_C2_FEM() ); - static BasisTypeRCP a17 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C1_FEM() ); - static BasisTypeRCP a18 = Teuchos::rcp ( new Intrepid::Basis_HGRAD_QUAD_C2_Serendipity_FEM() ); - } -#endif - - void tni(void) - { - throw std::runtime_error("not implemented"); - } - - void IntrepidManager::setupCubature( CellTopology& cell_topo, unsigned cubDegree) - { - DefaultCubatureFactory cubFactory; // create cubature factory - m_cub = cubFactory.create(cell_topo, cubDegree); // create default cubature - unsigned numCubPoints = m_cub->getNumPoints(); // retrieve number of cubature points - m_Cub_Points_Tag = Cub_Points_Tag(numCubPoints); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([P],[D]) - IntrepidManager::CubaturePoints::CubaturePoints(IM& im) : BaseType( NUM(Cub_Points_Tag), NUM(Spatial_Dim_Tag) ), m_im(im) - { - } - -#if 1 - //using BaseBaseType::operator(); - - double& IntrepidManager::CubaturePoints::operator()(int i1, int i2, int i3) - { - throw std::runtime_error("CubaturePoints:: operator()(int i1, int i2, int i3) not implemented"); - return m_dummy; - } - const double& IntrepidManager::CubaturePoints::operator()(int i1, int i2, int i3) const { - throw std::runtime_error("CubaturePoints:: operator()(int i1, int i2, int i3) not implemented"); - return m_dummy; - } - - double& IntrepidManager::CubaturePoints::operator()(int i1, int i2) { return BaseBaseType::operator()(i1, i2); } - const double& IntrepidManager::CubaturePoints::operator()(int i1, int i2) const { return BaseBaseType::operator()(i1, i2); } -#endif - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([P]) - IntrepidManager::CubatureWeights:: CubatureWeights(IM& im) : BaseType( NUM(Cub_Points_Tag)) - { - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [V], [D]) - IntrepidManager::CellWorkSet:: - CellWorkSet(IM& im) : BaseType(NUM(Elements_Tag), NUM(NodesPerElem_Tag), NUM(Spatial_Dim_Tag)) - { - - } - -#if 0 - void - IntrepidManager::CellWorkSet:: - operator()(BulkData& bulkData, Bucket& bucket) - { - // FIXME - } -#endif - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P], [D]) - IntrepidManager::PhysicalCoords:: - PhysicalCoords(IM& im) : BaseType( NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(Spatial_Dim_Tag) ), m_im(im) - { - } - - void - IntrepidManager::PhysicalCoords:: - operator()(CellWorkSet& c, CubaturePoints& xi) - { - //FieldContainer images(1, cellDim ); - //Intrepid::CellTools::mapToPhysicalFrame(images, preImages, triNodes, triangle_3, whichCell); - CellTools::mapToPhysicalFrame(*this, xi, c, *m_im.m_topo, -1); - } -#if 1 - //using BaseBaseType::operator(); - - //double m_dummy; -#if 0 - double& - IntrepidManager::PhysicalCoords:: - operator()(int i1, int i2, int i3) - { - throw std::runtime_error("PhysicalCoords:: operator()(int i1, int i2, int i3) not implemented"); - return m_dummy; - } - const double& - IntrepidManager::PhysicalCoords:: - - operator()(int i1, int i2, int i3) const { - throw std::runtime_error("PhysicalCoords:: operator()(int i1, int i2, int i3) not implemented"); - return m_dummy; - } -#endif - - double& IntrepidManager::PhysicalCoords:: - operator()(int i1, int i2, int i3) { return BaseBaseType::operator()(i1, i2, i3); } - const double& IntrepidManager::PhysicalCoords:: - operator()(int i1, int i2, int i3) const { return BaseBaseType::operator()(i1, i2, i3); } -#endif - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P], [D], [D]) - IntrepidManager::Jacobian:: - Jacobian(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(Spatial_Dim_Tag), NUM(Spatial_Dim_Tag)), m_im(im) - { - - } - void - IntrepidManager::Jacobian:: - - operator()(CubaturePoints& xi, CellWorkSet& c, CellTopology& topo) - { - CellTools::setJacobian(*this, xi, c, topo); // compute cell Jacobians - } - //double m_dummy; - double& IntrepidManager::Jacobian:: - operator()(int i1, int i2, int i3) { return m_dummy;} - const double& IntrepidManager::Jacobian:: - operator()(int i1, int i2, int i3) const { return m_dummy;} - - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P], [D]) - IntrepidManager::FaceNormal:: - FaceNormal(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(Spatial_Dim_Tag)), m_im(im) - { - - } - void - IntrepidManager::FaceNormal:: - operator()(Jacobian& J, int i_face, CellTopology& topo) - { - // FIXME - don't instantiate this, since Intrepid isn't completely free of its own MDArray, FieldContainer -#if 0 - MDArray J_mda; - J.copyTo(J_mda); - MDArray fn_mda(m_im.m_Elements_Tag.num, m_im.m_Cub_Points_Tag.num, m_im.m_Spatial_Dim_Tag.num); - CellTools::getPhysicalFaceNormals(fn_mda, J_mda, i_face, cell_topo); - this->copyFrom(fn_mda); -#endif - //CellTools::getPhysicalFaceNormals(*this, jac, i_face, topo); - throw std::runtime_error(" don't instantiate this, since Intrepid isn't completely free of its own MDArray, FieldContainer"); - } - //double m_dummy; - double& IntrepidManager::FaceNormal:: - operator()(int i1, int i2) { return m_dummy;} - const double& IntrepidManager::FaceNormal:: - operator()(int i1, int i2) const { return m_dummy;} - - - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P], [D], [D]) - IntrepidManager::JacobianInverse:: - JacobianInverse(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(Spatial_Dim_Tag), NUM(Spatial_Dim_Tag)) - { - - } - void IntrepidManager::JacobianInverse:: - operator()(Jacobian& jac) - { - CellTools::setJacobianInv(*this, jac); - } - - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P]) - IntrepidManager::JacobianDet:: - JacobianDet(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag)) - { - } - - void - IntrepidManager::JacobianDet:: - operator()(Jacobian& jac) - { - CellTools::setJacobianDet(*this, jac); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P]) - IntrepidManager::WeightedMeasure:: - WeightedMeasure(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag)) - { - } - - void - IntrepidManager::WeightedMeasure:: - operator()(CubatureWeights& w, JacobianDet& dJ) - { - FunctionSpaceTools::computeCellMeasure(*this, dJ, w); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P], [DOF]) - IntrepidManager::IntegrandValuesDOF:: - IntegrandValuesDOF(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(DOFs_Tag)) - { - } - void - IntrepidManager::IntegrandValuesDOF:: - copyFrom(MDArray& mda) - { - std::copy(&mda[0], &mda[0] + mda.size(), this->contiguous_data()); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [P]) - IntrepidManager::IntegrandValues:: - IntegrandValues(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag)) - { - } - void - IntrepidManager::IntegrandValues:: - copyFrom(MDArray& mda) - { - std::copy(&mda[0], &mda[0] + mda.size(), this->contiguous_data()); - } - void - IntrepidManager::IntegrandValues:: - copyFrom(IntrepidManager& im, MDArray& mda, int iDof) - { - for (int iCell = 0; iCell < im.m_Elements_Tag.num; iCell++) - { - for (int iPoint = 0; iPoint < im.m_Cub_Points_Tag.num; iPoint++) - { - (*this)(iCell, iPoint) = mda(iCell, iPoint, iDof); - } - } - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C], [DOF]) - IntrepidManager::IntegralDOF:: - IntegralDOF(IM& im) : BaseType(NUM(Elements_Tag), NUM(DOFs_Tag)) - { - } - - /// wXdOmega: ([C], [P]) - /// iv: ([C], [P], [DOF]) - /// this: ([C], [DOF]) - void - IntrepidManager::IntegralDOF:: - operator()(IntegrandValuesDOF& iv, WeightedMeasure& wXdOmega, int comp_type) - { - VERIFY_OP(iv.rank(), == , 3, "IntrepidManager::Integral::operator() bad iv rank"); - VERIFY_OP(wXdOmega.rank(), == , 2, "IntrepidManager::Integral::operator() bad wXdOmega rank"); - VERIFY_OP((*this).rank(), == , 2, "IntrepidManager::Integral::operator() bad (*this) rank"); - VERIFY_OP(iv.dimension(0), == , this->dimension(0), "IntrepidManager::Integral::operator() bad"); - VERIFY_OP(iv.dimension(1), == , wXdOmega.dimension(1), "IntrepidManager::Integral::operator() bad"); - VERIFY_OP(iv.dimension(0), == , wXdOmega.dimension(0), "IntrepidManager::Integral::operator() bad"); - VERIFY_OP(iv.dimension(2), == , this->dimension(1), "IntrepidManager::Integral::operator() bad"); - -#if 0 - for (int iDof = 0; iDof < iv.dimension(2); iDof++) - { - Integral Is(...); - Is(iv, wXdOmega, COMP_BLAS); - FunctionSpaceTools::integrate(*this, iv, wXdOmega, COMP_BLAS); - } -#endif - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C]) - IntrepidManager::Integral:: - Integral(IM& im) : BaseType(NUM(Elements_Tag)) - { - } - - /// wXdOmega: ([C], [P]) - /// iv: ([C], [P]) - /// this: ([C]) - void - IntrepidManager::Integral:: - operator()(IntegrandValues& iv, WeightedMeasure& wXdOmega, int comp_type) - { - VERIFY_OP(iv.rank(), == , 2, "IntrepidManager::Integral::operator() bad iv rank"); - VERIFY_OP(wXdOmega.rank(), == , 2, "IntrepidManager::Integral::operator() bad wXdOmega rank"); - VERIFY_OP((*this).rank(), == , 1, "IntrepidManager::Integral::operator() bad (*this) rank"); - VERIFY_OP(iv.dimension(0), == , this->dimension(0), "IntrepidManager::Integral::operator() bad"); - VERIFY_OP(iv.dimension(1), == , wXdOmega.dimension(1), "IntrepidManager::Integral::operator() bad"); - VERIFY_OP(iv.dimension(0), == , wXdOmega.dimension(0), "IntrepidManager::Integral::operator() bad"); - - FunctionSpaceTools::integrate(*this, iv, wXdOmega, COMP_BLAS); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C],[B],[P]), or ([C],[B],[P],[D]) for GRAD - static ComputeBases s_compute_bases; - - IntrepidManager::Bases:: - Bases(IM& im) : BaseType(NUM(Elements_Tag), NUM(NodesPerElem_Tag), NUM(Cub_Points_Tag)) - , m_cb(ComputeBases()) - //, m_cb(new ComputeBases()) - { - //m_cb =&s_compute_bases; - } - - void - IntrepidManager::Bases:: - operator()(const stk_classic::mesh::Entity& element, const MDArray& parametric_coordinates) - { - m_cb.getBases(element, parametric_coordinates, *this); - } - - void - IntrepidManager::Bases:: - operator()(const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coordinates) - { - m_cb.getBases(bucket, parametric_coordinates, *this); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - /// ([C],[P],[DOF]): evaluated field values at each integration point in each cell: - IntrepidManager::FieldValues:: - FieldValues(IM& im) : BaseType(NUM(Elements_Tag), NUM(Cub_Points_Tag), NUM(DOFs_Tag)) {} - - void IntrepidManager::FieldValues::operator()(const stk_classic::mesh::Entity& element, MDArray& transformed_basis_values, mesh::FieldBase* field) - { - ComputeFieldValues cfv; - cfv.get_fieldValues(element, transformed_basis_values, field, *this); - } - void IntrepidManager::FieldValues::operator()(const stk_classic::mesh::Entity& element, MDArray& transformed_basis_values, mesh::FieldBase* field, MDArray& output_field_values) - { - ComputeFieldValues cfv; - cfv.get_fieldValues(element, transformed_basis_values, field, output_field_values); - } - - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - //------------------------------------------------------------------------------------------------------------------------ - - IntrepidManager::IntrepidManager(Elements_Tag el, Cub_Points_Tag ct, NodesPerElem_Tag nc, Spatial_Dim_Tag st, - DOFs_Tag dt) : - m_Elements_Tag(el.num), m_Cub_Points_Tag(ct.num), m_NodesPerElem_Tag(nc.num), m_Spatial_Dim_Tag(st.num), m_DOFs_Tag(dt.num), - m_topo(0) - { - } - - IntrepidManager::IntrepidManager(Elements_Tag el, CellTopology& cellTopo, unsigned cubDegree) - : m_Elements_Tag(el.num), m_Cub_Points_Tag(1), m_NodesPerElem_Tag(1), m_Spatial_Dim_Tag(1), m_DOFs_Tag(1), - m_topo(&cellTopo) - { - setupCubature(cellTopo, cubDegree); - m_NodesPerElem_Tag.num = cellTopo.getNodeCount(); - m_Spatial_Dim_Tag.num = cellTopo.getDimension(); - } - - - - - -#if 0 - void IntrepidManager::getCubature(CubaturePoints& cp, CubatureWeights& cw) - { - m_cub->getCubature(cp, cw); - } -#endif - - void test() - { - typedef IntrepidManager IM; - IntrepidManager im(Elements_Tag(1), Cub_Points_Tag(4), NodesPerElem_Tag(4), Spatial_Dim_Tag(3), DOFs_Tag(1)); - - CellTopology* topo=0; - - IM::Jacobian J (im); - IM::JacobianInverse Ji (im); - IM::JacobianDet dJ (im); - - IM::CubaturePoints xi (im); - IM::CellWorkSet c (im); - IM::CubatureWeights w (im); - - IM::PhysicalCoords pc (im); - - im.m_cub->getCubature(xi, w); - pc(c, xi); - -#if 0 - IM::WeightedMeasure wXdOmega(im); - - wXdOmega = w * dJ; -#endif - -#if 0 - IM::GradField gradP("pressure"); - IM::TransformedGradField tgradP(gradP); - IM::WeightedTransformedGrad wtgradP(tgradP); - - IM::GradField gradN_i("basis"); - IM::TransformedGradField tgradN_i(gradN_i); - IM::WeightedTransformedGrad wtgradN_i(tgradN_i); - IM::StiffnessMatrix K; - - IM::WeightedMeasure wXdOmega; - IM::HGRADPhysicalSpace tgradN_i; - IM::MultipliedByMeasure wXdOmegaTGradN_i; - IM::IntegratedOp K( COMP_CPP ); -#endif - - //IM::JacobianInv ji(im); - //std::cout << "j.size()= " << j.size() << std::endl; - //im.print(); - - -#if 0 - xi.set(); - w.set(); - gradN_i(xi); -#endif - //Step 6: Apply cell tools - J(xi, c, *topo); - Ji(J); - dJ(J); - -#if 0 - //Step 7: Apply function space tools - - wXdOmega = w * dJ; - - tgradN_i = Ji * gradN_i; - - wXdOmegaTGradN_i = wXdOmega * tgradN_i; - - K = tgradN_i * wXdOmegaTGradN_i; -#endif - - } - - void IntrepidManager::isInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, unsigned& found_it, const mesh::Entity& element, - const mesh::BulkData& bulkData) - { - found_it = 0; - - // FIXME consider caching the coords_field in FieldFunction - const mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(bulkData); - VectorFieldType *coords_field = metaData.get_field("coordinates"); - - const mesh::Bucket & bucket = element.bucket(); - const CellTopologyData * const bucket_cell_topo_data = PerceptMesh::get_cell_topology(bucket); - if (!bucket_cell_topo_data) - { - mesh::EntityRank bucket_rank = bucket.entity_rank(); - std::cout << "bucket_rank = " << bucket_rank << std::endl; - throw std::runtime_error("IntrepidManager::bogus topology"); - } - - unsigned numCells = 1; // FIXME - - shards::CellTopology topo(bucket_cell_topo_data); - unsigned numNodes = topo.getNodeCount(); - unsigned cellDim = topo.getDimension(); - MDArray cellWorkset(numCells, numNodes, cellDim); - - /// FIXME -- fill cellWorkset - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for (unsigned iCell = 0; iCell < numCells; iCell++) - { - for (unsigned iNode = 0; iNode < numNodes; iNode++) - { - mesh::Entity& node = *elem_nodes[iNode].entity(); - double * node_coord_data = stk_classic::mesh::field_data( *coords_field , node); - for (unsigned iDim=0; iDim < cellDim; iDim++) - { - cellWorkset(iCell, iNode, iDim) = node_coord_data[iDim]; - } - } - } - - // FIXME for multiple points - if (input_phy_points.rank() == 1) - { - VERIFY_1("IsInElement::isInElement bad rank of input_phy_points"); - } - VERIFY_OP(input_phy_points.dimension(0), == , 1, "IsInElement::isInElement bad input_phy_points 1st dim"); - if (input_phy_points.dimension(1) < (int)cellDim) - { - std::cout << "IsInElement::isInElement bad input_phy_points 2nd dim"; - } - VERIFY_OP(input_phy_points.dimension(1), >= , (int)cellDim, "IsInElement::isInElement bad input_phy_points 2nd dim"); - - if (found_parametric_coordinates.rank() == 1) - { - VERIFY_1("IsInElement::isInElement bad rank of found_parametric_coordinates"); - } - VERIFY_OP(found_parametric_coordinates.dimension(0), == , 1, "IsInElement::isInElement bad found_parametric_coordinates 1st dim"); - VERIFY_OP(found_parametric_coordinates.dimension(1), == , (int)cellDim, - "IsInElement::isInElement bad found_parametric_coordinates 2nd dim"); - - unsigned cellOrd = 0; // FIXME - Intrepid::CellTools::mapToReferenceFrame(found_parametric_coordinates, input_phy_points, cellWorkset, topo, cellOrd); - MDArrayUInt inclusion_results(1); // FIXME - double threshold = 1.e-4; // (INTREPID_THRESHOLD default = 10*double_eps ~ 20e-16) - Intrepid::CellTools::checkPointwiseInclusion(inclusion_results, found_parametric_coordinates, topo, threshold); - found_it = inclusion_results(0); - if (found_it) - { - // for testing only - if (0) - { - FieldContainer images(1, cellDim ); - //Intrepid::CellTools::mapToPhysicalFrame(images, preImages, triNodes, triangle_3, whichCell); - Intrepid::CellTools::mapToPhysicalFrame(images, found_parametric_coordinates, cellWorkset, topo, cellOrd); - } - } - } - - void IntrepidManager::more_template_instantiations() - { - throw std::runtime_error("NEVER invoke this method - for REDSTORM template instantiation only"); - CellTopology *cell_topo_ptr = 0; - CellTopology& cell_topo = *cell_topo_ptr; - unsigned numCells = 1; - unsigned numNodes = 1; - unsigned spaceDim = 1; - - // Rank-3 array with dimensions (C,N,D) for the node coordinates of 3 traingle cells - FieldContainer cellNodes(numCells, numNodes, spaceDim); - - DefaultCubatureFactory cubFactory; // create cubature factory - unsigned cubDegree = 2; // set cubature degree, e.g. 2 - Teuchos::RCP > myCub = cubFactory.create(cell_topo, cubDegree); // create default cubature - - unsigned numCubPoints = myCub->getNumPoints(); // retrieve number of cubature points - - FieldContainer cub_points(numCubPoints, spaceDim); - FieldContainer cub_weights(numCubPoints); - - // Rank-4 array (C,P,D,D) for the Jacobian and its inverse and Rank-2 array (C,P) for its determinant - FieldContainer jacobian(numCells, numCubPoints, spaceDim, spaceDim); - FieldContainer jacobian_inv(numCells, numCubPoints, spaceDim, spaceDim); - FieldContainer jacobian_det(numCells, numCubPoints); - - myCub->getCubature(cub_points, cub_weights); // retrieve cubature points and weights - - // Methods to compute cell Jacobians, their inverses and their determinants - - CellTools::setJacobian(jacobian, cub_points, cellNodes, cell_topo); // compute cell Jacobians - CellTools::setJacobianInv(jacobian_inv, jacobian); // compute inverses of cell Jacobians - CellTools::setJacobianDet(jacobian_det, jacobian); // compute determinants of cell Jacobians - - FieldContainer weightedMeasure(numCells, numCubPoints); - FieldContainer onesLeft(numCells, numCubPoints); - FieldContainer volume(numCells); - - // compute weighted measure - FunctionSpaceTools::computeCellMeasure(weightedMeasure, jacobian_det, cub_weights); - - // integrate to get volume - FunctionSpaceTools::integrate(volume, onesLeft, weightedMeasure, COMP_BLAS); - - } - - - - } -} - - - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/norm/IntrepidManager.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/norm/IntrepidManager.hpp deleted file mode 100644 index ad9b5b47e4bc..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/norm/IntrepidManager.hpp +++ /dev/null @@ -1,660 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef stk_percept_IntrepidManager_hpp -#define stk_percept_IntrepidManager_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "Intrepid_DefaultCubatureFactory.hpp" - -#include -#include -#include -#include - -#include -#include -#include "Teuchos_RCP.hpp" - - -// Shards includes -#include "Shards_CellTopology.hpp" -#include - -#include "Teuchos_Array.hpp" -#include "Teuchos_ArrayRCP.hpp" -#include "Teuchos_ArrayView.hpp" -// #include "Shards_Array.hpp" -#include "Teuchos_RCP.hpp" -// #include "Teuchos_BLAS.hpp" -#include "Teuchos_oblackholestream.hpp" -//#include "Teuchos_Assert.hpp" -#include "Intrepid_KokkosRank.hpp" -/*template -struct Rank >{ -static const int value=shards::ArrayVector::Rank; -}; - -template -struct Rank >{ -static const int value=shards::ArrayVector::Rank; -};*/ -template -struct Rank >{ -static const int value=shards::ArrayVector::Rank; -}; - - -//using namespace std; -//using namespace Intrepid; - -#define IM_TAG( ADT ) ADT ## _TAG - -#define IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( ADT ) \ - class ADT : public shards::ArrayDimTag { \ - public: \ - const char * name() const ; \ - static const ADT & tag(); \ - int num; \ - ADT(int n); \ - ~ADT(); \ - ADT( const ADT & adt); \ - ADT & operator = ( const ADT & adt); \ - private: \ - ADT(); \ - } - -/** \brief Macro for implementing the body of a simple ArrayDimTag - * \param ADT name of the tag. - */ -#define IM_SHARDS_ARRAY_DIM_TAG_IMPLEMENTATION( ADT ) \ - const char * ADT::name() const \ - { static const char n[] = # ADT ; return n; } \ - const ADT & ADT::tag() { static const ADT self ; return self ; } \ - ADT::ADT(int n) { num =n;} \ - ADT:: ~ADT() {} \ - ADT::ADT( const ADT & adt) { num=adt.num;} \ - ADT & ADT::operator = ( const ADT & adt) {num=adt.num; return *this;} \ - ADT::ADT() {} - - -namespace stk_classic -{ - namespace percept - { - - using shards::CellTopology; - - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( NodesPerElem_Tag ); - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( DOFs_Tag ); - IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( BasisFields_Tag ); - - void tni(void); - - /** - * |-------------------------------------------------------------------------------------------------| - * | Index type | Dimension | Description | - * |---------------------------|-----------|---------------------------------------------------------| - * | point | [P] | number of points stored in an MD array | - * | vertex | [V] | number of nodes stored in an MD aray | - * | field | [F] | number of fields stored in an MD array | - * | basis field | [B] | number of basis fields stored in an MD array | - * | cell | [C] | number of cells stored in an MD array | - * | field coordinate | [D] | space dimension | - * | derivative ordinal | [K] | cardinality of the set of kth derivatives | - * | | | | - * | dof | [DOF] | number of DOFs stored in an MD array | - * |-------------------------------------------------------------------------------------------------| - * - * Note: Intrepid really doesn't have a concept of "DOF" at a node. It's either a single variable, - * or a vector- or tensor-valued variable. So, no DOF-related arrays as used herein can be used - * with Intrepid - you must call Intrepd one DOF at a time. - * - * FieldContainer cub_points(numCubPoints, spaceDim); - * FieldContainer cub_weights(numCubPoints); - * - * FieldContainer cell_nodes(numCells, numNodes, spaceDim); - * - * FieldContainer jacobian(numCells, numCubPoints, spaceDim, spaceDim); - * FieldContainer jacobian_inv(numCells, numCubPoints, spaceDim, spaceDim); - * FieldContainer jacobian_det(numCells, numCubPoints); - * FieldContainer weighted_measure(numCells, numCubPoints); - * - * FieldContainer grad_at_cub_points(numFields, numCubPoints, spaceDim); - * FieldContainer transformed_grad_at_cub_points(numCells, numFields, numCubPoints, spaceDim); - * FieldContainer weighted_transformed_grad_at_cub_points(numCells, numFields, numCubPoints, spaceDim); - * FieldContainer stiffness_matrices(numCells, numFields, numFields); - * - * - */ - - class IntrepidManager - { - private: - -#if (defined(__PGI) && defined(USE_PGI_7_1_COMPILER_BUG_WORKAROUND)) - // workaround for PGI compiler bug - - typedef Intrepid::Basis BasisType; - typedef Teuchos::RCP BasisTypeRCP; - - static void bootstrap(); -#endif - - public: - typedef IntrepidManager IM; - -#define NUM(AClass) im.m_ ## AClass . num - - //hexJacobian(numCells, numCubPoints, spaceDim, spaceDim); - - - class temp - { - double m_dummy; - public: - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy; } - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} - - }; - - /// ([P],[D]) - class CubaturePoints : public shards::ArrayVector - { - IntrepidManager& m_im; - public: - typedef shards::ArrayVector BaseType; - typedef shards::Array BaseBaseType; - - CubaturePoints(IM& im) ; - - void copyTo(MDArray& mda) - { - mda.resize(m_im.m_Cub_Points_Tag.num, m_im.m_Spatial_Dim_Tag.num); - mda.setValues(contiguous_data(), size()); - } -#if 1 - //using BaseBaseType::operator(); - - double m_dummy; - double& operator()(int i1, int i2) ; //{ tni(); return m_dummy; } - const double& operator()(int i1, int i2) const ; //{ tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3); // { tni(); return m_dummy; } - const double& operator()(int i1, int i2, int i3) const; // { tni(); return m_dummy; } -#endif - }; - - /// ([P]) - class CubatureWeights : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - CubatureWeights(IM& im); - -#if 1 - double m_dummy; - - double& operator()(int i1, int i2) { tni(); return m_dummy;} - const double& operator()(int i1, int i2) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - - using BaseType::operator(); -#endif - }; - - /// ([C], [V], [D]) - class CellWorkSet : public shards::ArrayVector - { - public: - typedef shards::ArrayVector BaseType; - - CellWorkSet(IM& im) ; - using BaseType::operator(); - //void operator()(BulkData& bulkData, Bucket& bucket); - }; - - /// ([C], [P], [D]) - class PhysicalCoords : public shards::ArrayVector - { - - IntrepidManager& m_im; - public: - typedef shards::ArrayVector BaseType; - typedef shards::Array BaseBaseType; - - PhysicalCoords(IM& im); - - void operator()(CellWorkSet& c, CubaturePoints& xi); - - void copyTo(MDArray& mda) - { - mda.resize(m_im.m_Elements_Tag.num, m_im.m_Cub_Points_Tag.num, m_im.m_Spatial_Dim_Tag.num); - mda.setValues(contiguous_data(), size()); - } -#if 1 - //using BaseBaseType::operator(); - - double m_dummy; - double& operator()(int i1, int i2) { tni(); return m_dummy; } - const double& operator()(int i1, int i2) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3) ;// { tni(); return m_dummy; } - const double& operator()(int i1, int i2, int i3) const ;//{ tni(); return m_dummy; } - -#endif - - }; - - /// ([C], [P], [D], [D]) - class Jacobian : public shards::ArrayVector - { - - IntrepidManager& m_im; - - public: - typedef shards::ArrayVector BaseType; - - Jacobian(IM& im); - void operator()(CubaturePoints& xi, CellWorkSet& c, CellTopology& topo); - - void copyTo(MDArray& mda) - { - mda.resize(m_im.m_Elements_Tag.num, m_im.m_Cub_Points_Tag.num, m_im.m_Spatial_Dim_Tag.num, m_im.m_Spatial_Dim_Tag.num); - mda.setValues(contiguous_data(), size()); - } - - double m_dummy; - double& operator()(int i1, int i2, int i3); - const double& operator()(int i1, int i2, int i3) const; - using BaseType::operator(); - }; - - /// ([C], [P], [D]) - class FaceNormal : public shards::ArrayVector - { - IntrepidManager& m_im; - public: - typedef shards::ArrayVector BaseType; - - FaceNormal(IM& im); - void operator()(Jacobian& jac, int i_face, CellTopology& topo); - - double m_dummy; - double& operator()(int i1, int i2); - const double& operator()(int i1, int i2) const; - using BaseType::operator(); - }; - - /// ([C], [P], [D], [D]) - class JacobianInverse : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - JacobianInverse(IM& im); - void operator()(Jacobian& jac); -#if 0 - double m_dummy; - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy;} - - using BaseType::operator(); -#endif - double m_dummy; - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - }; - - /// ([C], [P]) - class JacobianDet : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - //Jacobian(shards::shards::Array& xi, shards::Array& c, Topology& topo) - JacobianDet(IM& im); - - void operator()(Jacobian& jac); - using BaseType::operator(); - - double m_dummy; - double& operator()(int i1, int i2, int i3); - const double& operator()(int i1, int i2, int i3) const; - - }; - - - /// weights multiplied by Jacobian det at cubature points - /// ([C], [P]) - class WeightedMeasure : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - WeightedMeasure(IM& im); - - void operator()(CubatureWeights& w, JacobianDet& dJ); - using BaseType::operator(); - -#if 1 - double m_dummy; - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy; } - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} -#endif - }; - - /// ([C], [P], [DOF]) - class IntegrandValuesDOF : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - IntegrandValuesDOF(IM& im); - - void copyFrom(MDArray& mda); - - using BaseType::operator(); - double m_dummy; - - double& operator()(int i1, int i2) { tni(); return m_dummy; } - const double& operator()(int i1, int i2) const { tni(); return m_dummy; } - - //double& operator()(int i1, int i2, int i3) { tni(); return m_dummy; } - //const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} - - }; - - /// ([C], [P]) - class IntegrandValues : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - IntegrandValues(IM& im); - - void copyFrom(MDArray& mda); - void copyFrom(IntrepidManager& im, MDArray& mda, int iDof); - - using BaseType::operator(); - double m_dummy; - - //double& operator()(int i1, int i2) { tni(); return m_dummy; } - //const double& operator()(int i1, int i2) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy; } - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy; } - - double& operator()(int i1, int i2, int i3, int i4) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} - - }; - - /// ([C], [DOF]) - class IntegralDOF : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - IntegralDOF(IM& im); - - /// wXdOmega: ([C], [P]) - /// iv: ([C], [P], [DOF]) - /// this: ([C], [DOF]) - void operator()(IntegrandValuesDOF& iv, WeightedMeasure& wXdOmega, int comp_type); - - using BaseType::operator(); - - double m_dummy; - double& operator()(int i1) { tni(); return m_dummy;} - const double& operator()(int i1) const { tni(); return m_dummy;} - -// double& operator()(int i1, int i2) { tni(); return m_dummy;} -// const double& operator()(int i1, int i2) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} - - }; - - /// ([C]) - class Integral : public shards::ArrayVector - { - - public: - typedef shards::ArrayVector BaseType; - - Integral(IM& im); - - /// wXdOmega: ([C], [P]) - /// iv: ([C], [P]) - /// this: ([C]) - void operator()(IntegrandValues& iv, WeightedMeasure& wXdOmega, int comp_type); - using BaseType::operator(); - - double m_dummy; - //double& operator()(int i1) { tni(); return m_dummy;} - //const double& operator()(int i1) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2) { tni(); return m_dummy;} - const double& operator()(int i1, int i2) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3) const { tni(); return m_dummy;} - - double& operator()(int i1, int i2, int i3, int i4, int i5) { tni(); return m_dummy;} - const double& operator()(int i1, int i2, int i3, int i4, int i5) const { tni(); return m_dummy;} - - }; - - // FIXME - change to shards array - //class FieldValues : public shards::ArrayVector - - /// ([C],[P],[DOF]): evaluated field values at each integration point in each cell: - class FieldValues : public MDArray - { - public: - typedef MDArray BaseType; - FieldValues(IM& im); - void operator()(const stk_classic::mesh::Entity& element, MDArray& transformed_basis_values, mesh::FieldBase* field); - void operator()(const stk_classic::mesh::Entity& element, MDArray& transformed_basis_values, mesh::FieldBase* field, MDArray& output_field_values); - }; - - // FIXME - change to shards array - /// these are the "transformed_basis_values" at each point in each cell in the work set - /// ([C],[B],[P]), or ([C],[B],[P],[D]) for GRAD - /// here we assume that [B] is equivalent to [V] - - class Bases : public MDArray - { - ComputeBases m_cb; - public: - typedef MDArray BaseType; - Bases(IM& im); - - using BaseType::operator(); - - void operator()(const stk_classic::mesh::Entity& element, const MDArray& parametric_coordinates); - void operator()(const stk_classic::mesh::Bucket& bucket, const MDArray& parametric_coordinates); - - }; - - - //-------------------------------------------------------------------------------------------------------------------------------------------------- - //-------------------------------------------------------------------------------------------------------------------------------------------------- - //-------------------------------------------------------------------------------------------------------------------------------------------------- - IntrepidManager(Elements_Tag el, Cub_Points_Tag ct, NodesPerElem_Tag nc, Spatial_Dim_Tag st, DOFs_Tag dt); - - IntrepidManager(Elements_Tag el, CellTopology& cellTopo, unsigned cubDegree = 2); - - void setupCubature(CellTopology& cellTopo, unsigned cubDegree=2); - - static void isInElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates, unsigned& found_it, const mesh::Entity& element, - const mesh::BulkData& bulkData); - static void more_template_instantiations(); - - //void print() {} - Elements_Tag m_Elements_Tag; - Cub_Points_Tag m_Cub_Points_Tag; - NodesPerElem_Tag m_NodesPerElem_Tag; - Spatial_Dim_Tag m_Spatial_Dim_Tag; - DOFs_Tag m_DOFs_Tag; - - // BasisFields_Tag m_BasisFields_Tag; - - CellTopology *m_topo; - Teuchos::RCP > m_cub; - - }; - - - //std::ostream& operator<<(std::ostream& os, const shards::Array& container) ; - - - } -} -/* -template -struct Rank >{ - -static const int value=stk_classic::percept::IntrepidManager::CubaturePoints::ArrayVector::Rank; -};*/ - -template<> -struct Rank{ - -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -//static const int value=2; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -static const int value=shards::ArrayVector::Rank; -//static const int value=2; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -//static const int value=3; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( NodesPerElem_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -//static const int value=3; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -static const int value=shards::ArrayVector::Rank; -//static const int value=2; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ - -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); - -static const int value=shards::ArrayVector::Rank; -//static const int value=2; -//stk_classic::percept::IntrepidManager::CubaturePoints::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -}; -template<> -struct Rank{ -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Cub_Points_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Elements_Tag ); -IM_SHARDS_ARRAY_DIM_TAG_DECLARATION( Spatial_Dim_Tag ); -static const int value=shards::ArrayVector::Rank; -}; -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/norm/Norm.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/norm/Norm.hpp deleted file mode 100644 index 94cd3a61b041..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/norm/Norm.hpp +++ /dev/null @@ -1,325 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -#ifndef stk_percept_Norm_hpp -#define stk_percept_Norm_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - - template - class HasFinalOp - { - public: - virtual void finalOp(const ValueType& vin, ValueType& vout)=0; - }; - - /// [DEPRECATED] - inline double square(double x) { return x*x; } - - /// for Power = -1, compute the inf-norm - template - class LN_NormOp : public Function, public HasFinalOp > - { - public: - - /// integrand tells what fields Intrepid should compute, etc. - /// Note: this function is intended to be used to wrap a Function using CompositeFunction and thus its domain and codomain - /// are the same as the wrapped function's codomain - LN_NormOp(Function& integrand) : Function("LN_NormOp",integrand.getCodomainDimensions(), integrand.getCodomainDimensions()) {} - - void operator()(MDArray& integrand_values, MDArray& output_values, double time_value_optional=0.0) - { - VERIFY_OP(integrand_values.size(), ==, output_values.size(), "LN_NormOp::operator() bad sizes"); - for (int i = 0; i < integrand_values.size(); i++) - { - output_values[i] = std::pow(std::fabs(integrand_values[i]), double(std::fabs(Power)) ); - } - } - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Entity& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - (*this)(domain, codomain, time_value_optional); - } - virtual void operator()(MDArray& domain, MDArray& codomain, const stk_classic::mesh::Bucket& element, const MDArray& parametric_coords, double time_value_optional=0.0) - { - (*this)(domain, codomain, time_value_optional); - } - - void finalOp(const std::vector& vin, std::vector& vout) - { - for (unsigned i = 0; i < vin.size(); i++) - vout[i] = std::pow(vin[i], 1./(double(std::fabs(Power))) ); - } - }; - - class MaxOfNodeValues : public Function - { - public: - - MaxOfNodeValues(int spatialDim, Function& integrand) : Function("MaxOfNodeValues", Dimensions(spatialDim), integrand.getCodomainDimensions()), m_integrand(integrand), maxVal(0) {} - Function& m_integrand; - std::vector maxVal; - - void operator()(MDArray& coords, MDArray& output_values, double time_value_optional) - { - //VERIFY_OP(coords.size(), ==, output_values.size(), "MaxOfNodeValues::operator() bad sizes"); - if (maxVal.size()==0) maxVal.resize(m_integrand.getCodomainDimensions()[0]); - MDArray out(maxVal.size()); - m_integrand(coords, out); - - for (unsigned i = 0; i < maxVal.size(); i++) - { - maxVal[i] = std::max(maxVal[i], out(i)); - } - } - - }; - - - /// for Power = -1, compute the inf-norm - template - class Norm : public FunctionOperator - { - protected: - bool m_is_surface_norm; - TurboOption m_turboOpt; - unsigned m_cubDegree; - public: - - Norm(mesh::BulkData& bulkData, std::string partName, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - FunctionOperator(bulkData, (mesh::Part*)0), m_is_surface_norm(is_surface_norm), m_turboOpt(turboOpt), m_cubDegree(2) - { - mesh::Part * part = stk_classic::mesh::fem::FEMMetaData::get(bulkData).get_part(partName); - if (!part) throw std::runtime_error(std::string("No part named ") +partName); - init(part); - error_check_is_surface_norm(); - } - - Norm(mesh::BulkData& bulkData, MDArrayString& partNames, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - FunctionOperator(bulkData, (mesh::Part*)0), m_is_surface_norm(is_surface_norm), m_turboOpt(turboOpt), m_cubDegree(2) - { - if (partNames.rank() != 1) throw std::runtime_error("Input array of strings should be rank 1 multi-d array (numpy array if from Python)"); - VERIFY_OP_ON(m_own_selector , ==, true, "logic error 1"); - VERIFY_OP_ON(m_selector, !=, 0, "logic error 2"); - delete m_selector; - m_selector = new stk_classic::mesh::Selector; - for (int i = 0; i < partNames.dimension(0); i++) - { - mesh::Part * part = stk_classic::mesh::fem::FEMMetaData::get(bulkData).get_part(partNames(i)); - if (!part) throw std::runtime_error(std::string("No part named ") +partNames(i)); - *m_selector = (*m_selector) | (*part); - } - error_check_is_surface_norm(); - } - - Norm(mesh::BulkData& bulkData, mesh::Part *part = 0, TurboOption turboOpt=TURBO_NONE, bool is_surface_norm=false) : - FunctionOperator(bulkData, part), m_is_surface_norm(is_surface_norm), m_turboOpt(turboOpt), m_cubDegree(2) - { - error_check_is_surface_norm(); - } - -#ifndef SWIG - Norm(mesh::BulkData& bulkData, mesh::Selector * selector,TurboOption turboOpt=TURBO_NONE, bool is_surface_norm = false) : - FunctionOperator(bulkData, selector), m_is_surface_norm(is_surface_norm), m_turboOpt(turboOpt), m_cubDegree(2) - { - error_check_is_surface_norm(); - } -#endif - - virtual ~Norm() {} - - void setCubDegree(unsigned cubDegree) { m_cubDegree= cubDegree; } - unsigned getCubDegree() { return m_cubDegree; } - - void set_is_surface_norm(bool is_surface_norm) { - m_is_surface_norm = is_surface_norm; - error_check_is_surface_norm(); - } - bool get_is_surface_norm() { return m_is_surface_norm; } - - double evaluate(Function& integrand) - { - ConstantFunction sfx_res(0.0, "sfx_res"); - (*this)(integrand, sfx_res); - return sfx_res.getValue(); - } - - /// if a Selector is specified with part(s) that are not auto-declared, make sure all parts are - /// of the same rank, and that m_is_surface_norm is set correctly (if not, warn...) - void error_check_is_surface_norm() - { - stk_classic::mesh::EntityRank element_rank = mesh::fem::FEMMetaData::get(m_bulkData).element_rank(); - const stk_classic::mesh::PartVector& parts = mesh::fem::FEMMetaData::get(m_bulkData).get_parts(); - stk_classic::mesh::EntityRank all_ranks = 0; - unsigned nparts = parts.size(); - for (unsigned ipart=0; ipart < nparts; ipart++) - { - stk_classic::mesh::Part& part = *parts[ipart]; - if (stk_classic::mesh::is_auto_declared_part(part)) - continue; - - bool in_selector = (*m_selector)(part); - stk_classic::mesh::EntityRank rank = part.primary_entity_rank(); - //std::cout << "tmp srk Part= " << part.name() << " rank= " << rank << " in_selector= " << in_selector << std::endl; - if (in_selector) - { - if (rank == element_rank || rank == element_rank-1) - { - if (all_ranks == 0) - all_ranks = rank; - std::cout << "all_ranks= " << all_ranks << " rank= " << rank << std::endl; - if (rank != all_ranks) - { - throw std::runtime_error("all parts in the Selector must be the same rank"); - } - } - } - } - - if ((all_ranks == 0 || all_ranks ==3) && m_is_surface_norm) - { - m_is_surface_norm = false; - std::cout << "WARNING: Norm was constructed with is_surface_norm, but no surface Parts given. Turning is_surface_norm off." << std::endl; - } - if (all_ranks == 2 && !m_is_surface_norm) - { - m_is_surface_norm = true; - std::cout << "WARNING: Norm was constructed with is_surface_norm=false, but surface Parts were given. Turning is_surface_norm on." << std::endl; - } - } - - virtual void operator()(Function& integrand, Function& result) - { - EXCEPTWATCH; - - /** contract: - * - * 1. @param integrand : maps input_phy_points([C],[P],[D]) to output_values([C],[P],[DOF]) - * 2. this function then copies output_values to the @param result (assumes it is a ConstantFunction) - * - * algorithm: - * 1. loop over elements (later buckets) and fire @param integrand on each quadrature point/cell collection - * 2. further process the output_values by the LN_Op function, which simply raises the results to the N'th power - * 3. (note: later we can pass in an Op instead of this being hard-coded to norm_LN) - * 4. fire a "finalOp" on the resulting parallel accumulation buffer (supplied by LN_Op) - */ - - //std::cout << "type= " << typeid(integrand).name() << " " << typeid(FieldFunction).name() << std::endl; - - if (1 || typeid(integrand) == typeid(FieldFunction)) - { - // FIXME - make all stk_classic::percept code const-correct - PerceptMesh eMesh(&mesh::fem::FEMMetaData::get(m_bulkData), &m_bulkData); - LN_NormOp LN_op(integrand); - CompositeFunction LN_of_integrand("LN_of_integrand", integrand, LN_op); - IntegratedOp integrated_LN_op(LN_of_integrand, m_turboOpt); - integrated_LN_op.setCubDegree(m_cubDegree); - if (Power == -1) { - integrated_LN_op.setAccumulationType(IntegratedOp::ACCUMULATE_MAX); - } - - const stk_classic::mesh::Part& locally_owned_part = mesh::fem::FEMMetaData::get(m_bulkData).locally_owned_part(); - stk_classic::mesh::Selector selector(*m_selector & locally_owned_part); - //eMesh.print_info("Norm"); - if (m_turboOpt == TURBO_NONE || m_turboOpt == TURBO_ELEMENT) - { - eMesh.elementOpLoop(integrated_LN_op, 0, &selector, m_is_surface_norm); - } - else if (m_turboOpt == TURBO_BUCKET) - { - eMesh.bucketOpLoop(integrated_LN_op, 0, &selector, m_is_surface_norm); - } - - unsigned vec_sz = integrated_LN_op.getValue().size(); - std::vector local = integrated_LN_op.getValue(); - - if (Power == -1) - { - MaxOfNodeValues maxOfNodeValues(eMesh.get_spatial_dim(), integrand); - eMesh.nodalOpLoop(maxOfNodeValues, 0, &selector); - for (unsigned iDim = 0; iDim < local.size(); iDim++) - local[iDim] = std::max(local[iDim], maxOfNodeValues.maxVal[iDim]); - } - - - //unsigned p_rank = m_bulkData.parallel_rank(); - //std::cout << "P["< 0: - res = res.replace(tstr, timingstrings1[jj]) - r_split = res.split() - print "time = res.split()= " , r_split - tt2 = convert_time(r_split[2])/float(nproc) - rtime[jj].append( tt2 ) - jj += 1 - - ii += 1 - -# if no data at 1 proc, approximate from nproc=2 value -jj = 0 -for tstr in timingstrings: - if rtime[jj][0] == 0: - rtime[jj][0] = 2.0*rtime[jj][1] - jj += 1 - -print "rtime= " , rtime - -ax1 = plt.subplot(121) -#ax1 = plt.subplot() -#ax1.set_xscale("log") -#ax1.set_yscale("log") -ax1.set_xlabel("nprocs") -ax1.set_ylabel("sec") -#ax1.set_xlim(1e1, 1e3) -#ax1.set_ylim(1e2, 1e3) -#ax1.set_aspect(1) -ax1.set_title("strong scaling") - -#symstrs=['o-','+-','x-','*-','^-','#-'] -symstrs=['o-', 's-', 'p-', '+-', 'x-', '*-', 'v-', '^-', 'h-', 'H-', 'D-', '<-', '>-', '1-', '2-', '3-', '4-', 'd-', '|-', '_-', '.-'] -lensym=len(symstrs) -for ii in range(0,len(timingstrings1)): - print " " - print timingstrings1[ii], " ", rtime[ii] - ax1.plot(nprocs, rtime[ii], symstrs[(ii+1) % lensym], label=timingstrings1[ii]) -ax1.legend(loc='upper left') - -ax2 = plt.subplot(122) -#ax2 = plt.subplot() -#ax2.set_xscale("log") -#ax2.set_yscale("log") -ax2.set_xlabel("nprocs") -ax2.set_ylabel("speedup") -#ax2.set_xlim(1e1, 1e3) -#ax2.set_ylim(1e2, 1e3) -#ax2.set_aspect(1) -ax2.set_title("strong scaling - speedup") - -nprocs1=[] -for ii in range(0,len(nprocs)): - nprocs1.append( float(nprocs[ii])/float(nprocs[0]) ) - -print "nprocs= ", nprocs, " nprocs1= " , nprocs1 - -ax2.plot(nprocs, nprocs1, symstrs[0], label="ideal") -for ii in range(0,len(timingstrings1)): - stime=[] - for jj in range(0,len(nprocs)): - rt = rtime[ii][jj] - if rt == 0: rt = 1.e-12 - stime.append(rtime[ii][0]/rt) - print " " - print timingstrings1[ii], " ", stime - - ax2.plot(nprocs, stime, symstrs[(ii+1) % lensym], label=timingstrings1[ii]) -ax2.legend(loc='upper left') - -plt.draw() -plt.show() - -# start = time.time() -# result = l2Norm.evaluate(ff_Tnd) -# print "|ff_Tnd|= " , result, " time= ", time.time()-start - -# start = time.time() -# result = l2Norm.evaluate(sf_exact) -# print "|exact|= " , result, " time= ", time.time()-start - -#test_result = l2Norm.evaluate(sf_exact) -#ff_result = l2Norm.evaluate(ff_Tnd) -#expected_test_result = 48.*sqrt(3041./5.) # result from Mathematica - -#print "norm exact= " , test_result, " expected_test_result= " , expected_test_result, " FEM norm = " , ff_result - - -######################################################################################################################### diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept b/packages/stk/stk_classic/stk_percept/stk_percept/percept deleted file mode 100755 index 1af81103bb57..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - elif (arg_name == "dout"): - if (arg_value is not None): - return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.exo" - return "--output_mesh=%s" % arg_value - elif (arg_name == "output_log"): - return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - elif (arg_name == "pout"): - if (arg_value is not None): - return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def run_cmd(cmd_str): - print cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc"] - num_proc = args.num_proc - cmd_str += " -j %d" % num_proc - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe -O "' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_str += " %s" % convert_to_stk_adapt_option(args, arg) - - if (num_proc > 1): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - cmd_str += '"' - run_cmd(cmd_str) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.1.py b/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.1.py deleted file mode 100755 index b077df47b160..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.1.py +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # Streaming operation - streaming = parser.add_argument_group('streaming control') - streaming.add_argument('-M', '--streaming-size', type=int, default=0, metavar='NM', help='number of virtual processors in streaming mode = M in file.e.M.iM decomposition (default: %(default)s)') - streaming.add_argument('-W', '--streaming-W', type=int, default=0, metavar='NW', help='number of actual parallel worker processes in streaming mode - must have (M mod W) == 0 (default: %(default)s)') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - diagnostic.add_argument('-D', '--debug', default=False, action='store_true', help='for internal debugging (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - elif (arg_name == "dout"): - if (arg_value is not None): - return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.e" - return "--output_mesh=%s" % arg_value - elif (arg_name == "output_log"): - return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - elif (arg_name == "pout"): - if (arg_value is not None): - return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def get_cmd_str(args, close_string=True): - streaming_size = args.streaming_size - streaming_W = args.streaming_W - - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - #cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc"] - num_proc = args.num_proc - - # for now, only allow serial streaming (later we can do M --> N by P workers, P==num_proc) - if streaming_size != 0: - msg = "" - if num_proc > 1: - msg = " [Note: num_proc reduced from %d to 1 for serial streaming mode - parallel streaming not yet supported] " % num_proc - num_proc = 1 - print "streaming_size= " , streaming_size, " num_proc= " , num_proc, msg - - cmd_str += " -j %d" % num_proc - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe -O "' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_str += " %s" % convert_to_stk_adapt_option(args, arg) - - if (num_proc > 1 and streaming_size == 0): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - if streaming_size > 0: - cmd_str += " --streaming_size=%d" % streaming_size - if streaming_W > 0: - cmd_str += " --streaming_W=%d" % streaming_W - - if close_string: - cmd_str += '"' - return cmd_str - -def run_cmd(cmd_str): - print cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - -def run_if(cmd_str, debug): - if debug: - print "debug print cmd_str= " , cmd_str - else: - run_cmd(cmd_str) - -def add_args(i_pass, streaming_W, iW): - add = " --streaming_pass_start=%d --streaming_pass_end=%d --streaming_W=%d --streaming_iW=%d" % (i_pass, i_pass, streaming_W, iW) - add += '"' - return add - - -def run(args, debug): - streaming_W = args.streaming_W - - if streaming_W == 0: - cmd_str = get_cmd_str(args) - run_if(cmd_str, debug) - else: - cmd_str = get_cmd_str(args, False) - - for i_pass in range(-1, 4): - - # initial sync point - iW = -1 - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - # parallel operation - for iW in range(0, streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - # final sync point - iW = streaming_W - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - - debug = args.debug - #debug = True - - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - - run(args, debug) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.2.py b/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.2.py deleted file mode 100755 index 952c970a4174..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.2.py +++ /dev/null @@ -1,385 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -from multiprocessing import Pool - - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # Streaming operation - streaming = parser.add_argument_group('streaming control') - streaming.add_argument('-M', '--streaming-size', type=int, default=0, metavar='NM', help='number of virtual processors in streaming mode = M in file.e.M.iM decomposition (default: %(default)s)') - streaming.add_argument('-W', '--streaming-W', type=int, default=0, metavar='NW', help='number of actual parallel worker processes in streaming mode - must have (M mod W) == 0 (default: %(default)s)') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - diagnostic.add_argument('-D', '--debug', default=False, action='store_true', help='for internal debugging (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - #elif (arg_name == "dout"): - # if (arg_value is not None): - # return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.e" - return "--output_mesh=%s" % arg_value - #elif (arg_name == "output_log"): - # return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - #elif (arg_name == "pout"): - # if (arg_value is not None): - # return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def get_cmd_str(args, close_string=True): - streaming_size = args.streaming_size - streaming_W = args.streaming_W - - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - #cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc"] - num_proc = args.num_proc - - # for now, only allow serial streaming (later we can do M --> N by P workers, P==num_proc) - if streaming_size != 0: - msg = "" - if num_proc > 1: - msg = " [Note: num_proc reduced from %d to 1 for serial streaming mode - parallel streaming not yet supported] " % num_proc - num_proc = 1 - print "streaming_size= " , streaming_size, " num_proc= " , num_proc, msg - - cmd_str += " -j %d" % num_proc - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe -O "' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_str += " %s" % convert_to_stk_adapt_option(args, arg) - - if (num_proc > 1 and streaming_size == 0): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - if streaming_size > 0: - cmd_str += " --streaming_size=%d" % streaming_size - if streaming_W > 0: - cmd_str += " --streaming_W=%d" % streaming_W - - if close_string: - cmd_str += '"' - return cmd_str - -def run_cmd(cmd_str): - print "run_cmd: ", cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - return output - -def run_if(cmd_str, debug=False): - if debug: - print "debug print cmd_str= " , cmd_str - else: - output = run_cmd(cmd_str) - return output - -def create_scripts(cmd_str, debug=False): - if debug: - print "debug print cmd_str= " , cmd_str - else: - output = run_cmd(cmd_str) - return output - -def add_args(i_pass, streaming_W, iW): - add = " --streaming_pass_start=%d --streaming_pass_end=%d --streaming_W=%d --streaming_iW=%d" % (i_pass, i_pass, streaming_W, iW) - add += '"' - return add - -def run_if_par_0(cmd_str, i_pass, streaming_W, iW, debug, timeout=60): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - -def run_if_par(cmd_str, i_pass, streaming_W, debug, timeout=600): - - pool = Pool(processes=streaming_W) - - # the first time we create the sierra.W.iW.sh script, then we execute it below - add_opt = " --script-only; mv sierra.sh sierra.W.%d.%d.sh" - argsl = [] - for iW in range(streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - cmd_str1 = cmd_str1 + (add_opt % (streaming_W,iW)) - argsl.append(cmd_str1) - - # this must be done in serial - result = map(create_scripts, argsl) - - if True: - for iW in range(streaming_W): - print "create_scripts result[", iW, "]= ", result[iW] - - # now create the final sierra command - add_opt = " --exec-script=sierra.W.%d.%d.sh" - argsl = [] - for iW in range(streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - cmd_str1 = cmd_str1 + (add_opt % (streaming_W,iW)) - argsl.append(cmd_str1) - - if False: - result = map(run_if, argsl) - else: - # parallel run - result = pool.map(run_if, argsl) - - if True: - for iW in range(streaming_W): - print "result[", iW, "]= ", result[iW] - -def run(args, debug): - streaming_W = args.streaming_W - - if streaming_W == 0: - cmd_str = get_cmd_str(args) - run_if(cmd_str, debug) - else: - cmd_str = get_cmd_str(args, False) - - for i_pass in range(-1, 4): - - # initial sync point - iW = -1 - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - # parallel operation - if False: - for iW in range(0, streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - else: - print "startparallel ..." - run_if_par(cmd_str, i_pass, streaming_W, debug) - print "end parallel" - - # final sync point - iW = streaming_W - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - - debug = args.debug - #debug = True - - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - - run(args, debug) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.3.py b/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.3.py deleted file mode 100644 index 423cb782ed36..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.3.py +++ /dev/null @@ -1,356 +0,0 @@ -### only for python 3.... due to concurrent.futures -#!/usr/netpub/python-3.2/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -import concurrent.futures -import urllib.request - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # Streaming operation - streaming = parser.add_argument_group('streaming control') - streaming.add_argument('-M', '--streaming-size', type=int, default=0, metavar='NM', help='number of virtual processors in streaming mode = M in file.e.M.iM decomposition (default: %(default)s)') - streaming.add_argument('-W', '--streaming-W', type=int, default=0, metavar='NW', help='number of actual parallel worker processes in streaming mode - must have (M mod W) == 0 (default: %(default)s)') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - diagnostic.add_argument('-D', '--debug', default=False, action='store_true', help='for internal debugging (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - elif (arg_name == "dout"): - if (arg_value is not None): - return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.e" - return "--output_mesh=%s" % arg_value - elif (arg_name == "output_log"): - return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - elif (arg_name == "pout"): - if (arg_value is not None): - return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def get_cmd_str(args, close_string=True): - streaming_size = args.streaming_size - streaming_W = args.streaming_W - - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - #cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc"] - num_proc = args.num_proc - - # for now, only allow serial streaming (later we can do M --> N by P workers, P==num_proc) - if streaming_size != 0: - msg = "" - if num_proc > 1: - msg = " [Note: num_proc reduced from %d to 1 for serial streaming mode - parallel streaming not yet supported] " % num_proc - num_proc = 1 - print "streaming_size= " , streaming_size, " num_proc= " , num_proc, msg - - cmd_str += " -j %d" % num_proc - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe -O "' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_str += " %s" % convert_to_stk_adapt_option(args, arg) - - if (num_proc > 1 and streaming_size == 0): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - if streaming_size > 0: - cmd_str += " --streaming_size=%d" % streaming_size - if streaming_W > 0: - cmd_str += " --streaming_W=%d" % streaming_W - - if close_string: - cmd_str += '"' - return cmd_str - -def run_cmd(cmd_str): - print cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - -def run_if(cmd_str, debug): - if debug: - print "debug print cmd_str= " , cmd_str - else: - run_cmd(cmd_str) - -def add_args(i_pass, streaming_W, iW): - add = " --streaming_pass_start=%d --streaming_pass_end=%d --streaming_W=%d --streaming_iW=%d" % (i_pass, i_pass, streaming_W, iW) - add += '"' - return add - -def run_if_par_0(cmd_str, i_pass, streaming_W, iW, debug, timeout=60): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - -def run_if_par(cmd_str, i_pass, streaming_W, debug, timeout=60): - - with concurrent.futures.ThreadPoolExecutor(max_workers=streaming_W) as executor: - print "here 1" - future_to_iW = dict((executor.submit(run_if_par_0, cmd_str, i_pass, streaming_W, iW, debug), iW) - for iW in range(0,streaming_W)) - print "here 2" - - for future in concurrent.futures.as_completed(future_to_iW): - iW = future_to_iW[future] - print "iW= " , iW - if future.exception() is not None: - print('%r generated an exception: %s' % (iW, - future.exception())) - else: - print('%r page is %d bytes' % (iW, len(future.result()))) - - -def run(args, debug): - streaming_W = args.streaming_W - - if streaming_W == 0: - cmd_str = get_cmd_str(args) - run_if(cmd_str, debug) - else: - cmd_str = get_cmd_str(args, False) - - for i_pass in range(-1, 4): - - # initial sync point - iW = -1 - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - # parallel operation - if False: - for iW in range(0, streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - else: - run_if_par(cmd_str, i_pass, streaming_W, debug) - - # final sync point - iW = streaming_W - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_if(cmd_str1, debug) - - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - - debug = args.debug - #debug = True - - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - - run(args, debug) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.4.py b/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.4.py deleted file mode 100755 index 356e41cdd8a7..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.4.py +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -from multiprocessing import Pool - -debug = False - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # sierra options - sierra_opts = parser.add_argument_group('sierra control') - sierra_opts.add_argument('-x', '--bin-dir', default="", metavar='PATH_TO_EXE', required=True, help='you must supply a path to which stk_adapt_exe to use') - - # Streaming operation - streaming = parser.add_argument_group('streaming control') - streaming.add_argument('-M', '--streaming-size', type=int, default=0, metavar='NM', help='number of virtual processors in streaming mode = M in file.e.M.iM decomposition (default: %(default)s)') - streaming.add_argument('-W', '--streaming-W', type=int, default=0, metavar='NW', help='number of actual parallel worker processes in streaming mode - must have (M mod W) == 0 (default: %(default)s)') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - diagnostic.add_argument('-D', '--debug', default=False, action='store_true', help='for internal debugging (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - #elif (arg_name == "dout"): - # if (arg_value is not None): - # return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.e" - return "--output_mesh=%s" % arg_value - #elif (arg_name == "output_log"): - # return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - #elif (arg_name == "pout"): - # if (arg_value is not None): - # return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def get_cmd_str(args, close_string=True): - streaming_size = args.streaming_size - streaming_W = args.streaming_W - - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - #cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc", "bin_dir"] - num_proc = args.num_proc - bin_dir = args.bin_dir - - # for now, only allow serial streaming (later we can do M --> N by P workers, P==num_proc) - if streaming_size != 0: - msg = "" - if num_proc > 1: - msg = " [Note: num_proc reduced from %d to 1 for serial streaming mode - parallel streaming not yet supported] " % num_proc - num_proc = 1 - print "streaming_size= " , streaming_size, " num_proc= " , num_proc, msg - - cmd_str += " -j %d" % num_proc - cmd_str += " --bin-dir %s " % bin_dir - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe ' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_str += " %s" % convert_to_stk_adapt_option(args, arg) - - if (num_proc > 1 and streaming_size == 0): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - if streaming_size > 0: - cmd_str += " --streaming_size=%d" % streaming_size - if streaming_W > 0: - cmd_str += " --streaming_W=%d" % streaming_W - - #if close_string: - # cmd_str += '"' - return cmd_str - -def run_cmd(cmd_str): - print "run_cmd: ", cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - return output - -def run_or_print(cmd_str): - global debug - output = "debug...%s"%debug - #print output - if debug: - print "debug print cmd_str= " , cmd_str - else: - output = run_cmd(cmd_str) - return output - -def create_scripts(cmd_str): - global debug - output = "debug...%s"%debug - #print output - if debug: - print "debug print cmd_str= " , cmd_str - else: - output = run_cmd(cmd_str) - return output - -def add_args(i_pass, streaming_W, iW): - add = " --streaming_pass_start=%d --streaming_pass_end=%d --streaming_W=%d --streaming_iW=%d" % (i_pass, i_pass, streaming_W, iW) - #add += '"' - return add - -def run_or_print_par_0(cmd_str, i_pass, streaming_W, iW, timeout=60): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_or_print(cmd_str1) - -def run_or_print_par(cmd_str, i_pass, streaming_W, timeout=600): - - pool = Pool(processes=streaming_W) - - # now create the final sierra command - argsl = [] - for iW in range(streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - argsl.append(cmd_str1) - - if False: - for a in argsl: - print "argsl= ", a - - if False: - result = map(run_or_print, argsl) - else: - # parallel run - result = pool.map(run_or_print, argsl) - - if True: - for iW in range(streaming_W): - print "result[", iW, "]= ", result[iW] - -def run(args): - streaming_W = args.streaming_W - - if streaming_W == 0: - cmd_str = get_cmd_str(args) - run_or_print(cmd_str) - else: - cmd_str = get_cmd_str(args, False) - - for i_pass in range(-1, 4): - - # initial sync point - iW = -1 - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_or_print(cmd_str1) - - # parallel operation - if False: - for iW in range(0, streaming_W): - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_or_print(cmd_str1) - else: - print "startparallel ..." - run_or_print_par(cmd_str, i_pass, streaming_W) - print "end parallel" - - # final sync point - iW = streaming_W - cmd_str1 = cmd_str + add_args(i_pass, streaming_W, iW) - run_or_print(cmd_str1) - - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - - global debug - debug = args.debug - print "debug = ", debug - #debug = True - - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - - run(args) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.py b/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.py deleted file mode 100755 index 7d9db6babc7b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/percept.streaming.proto.py +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -# TODO: how to ensure python 2.7 is installed everywhere? -# then use !/usr/bin/env python -# TODO: make a python .egg and have users install it? - -"""Main function for the Percept command line tool. - -This program provides functionality for a number of Percept tasks from -the command line. - -Example usage: -# Uniformly refine a mesh containing different element types.\" -percept refine -n \"Summer Vacation 2009\" -t Vermont ~/photos/vacation2009/* - -# blah blah -percept refine - -# Convert a mesh of hexahedral elements to a mesh of tetrahedra -percept convert - -# Convert a mesh of linear elements, e.g., HEX8, TET4, QUAD4, TRI3, -# into a mesh of quadratic elements, e.g., HEX27, TET8, QUAD9, TRI6 -percept enrich - -Some terminology in use: - task: What the client wants done (e.g. refine, enrich, convert). - -""" - -import os -import sys -import argparse -import textwrap -import subprocess - -def setup_parser(): - """Set up the parser. - - Returns: - argparse.ArgumentParser with all options configured. - """ - - epilog_txt = textwrap.dedent('''\ - Some commonly used %(prog)s commands are: - refine Divide blocks of elements uniformly - convert Convert blocks of elements to another specified type of element - enrich Add more nodes to blocks of elements to increase polynomial order - - See "%(prog)s COMMAND --help" for more information on a specific command. - - ''') - - parser = argparse.ArgumentParser(prog='percept', formatter_class=argparse.RawDescriptionHelpFormatter, - description='Percept is a tool for verifying modeling and simulation codes and solutions.', - epilog=epilog_txt) - - # version number of this script - # TODO: get the version from percept - parser.add_argument('--version', action='version', version='%(prog)s 1.0') - - subparsers = parser.add_subparsers() - - # the block argument can be used with multiple tasks, predefine string here - blocks_arg_list = ('-b', '--blocks') - blocks_arg_dict = {'metavar':'BLOCK_LIST', 'help':'include or exclude block numbers in a quoted, comma delimited string.'} - #(1) empty string or option not specified: convert all blocks in the input mesh file - #(2) file:my_filename.my_ext (e.g. file:filelist.dat) which will read input block names from the given file - #(3) [+]block_name_1,[+]block_name_2, etc ,block_name_n to include only these blocks, plus sign is optional - #(4) a single input block name (e.g. block_3) to be converted - #(5) -block_3,-block_5 to exclude blocks from those included (all blocks or include-only blocks), minus sign is mandatory - #(6) block_1..block_10 include the range of blocks #1 to #10 - #(7) any combination of [+] and - options and range (..) option can be specified - #Note: wherever you specify block_number this can be replaced with just the #, e.g. "1,2,4,5" - - blocks_file_arg_list = ('-B','--blocks-from') - blocks_file_arg_dict = {'metavar':'BLOCK_FILE', 'help':'include or exclude block numbers listed in a file.'} - - # hide the --remove-original-elements argument, for now - #original_arg_list = ('--keep-original-elements',) - #original_arg_dict = {'action':'store_true', 'default':False, 'help':'Keep the original mesh embedded in the output file.'} - - # Tasks: - # each task has a subparser and possibly task specific options - - # refine - parser_refine = subparsers.add_parser('refine') - parser_refine.add_argument('-n', '--number-refines', type=int, default=1, help='number of refinements (default: %(default)s)') - parser_refine.add_argument('-t', '--refine-type', default='DEFAULT', metavar='REFINE_TYPE', help='type of elements to refine into another type (one of: Quad4_Quad4_4, Tri3_Tri3_4, Tet4_Tet4_8, Hex8_Hex8_8, Wedge6_Wedge6_8, Tri6_Tri6_4, Quad9_Quad9_4, Hex27_Hex27_8, Tet10_Tet10_8, Wedge18_Wedge18_8, ShellTri3_ShellTri3_4, ShellQuad4_ShellQuad4_4)') - parser_refine.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_refine.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_refine.add_argument(*original_arg_list, **original_arg_dict) - - # convert - parser_convert = subparsers.add_parser('convert') - parser_convert.add_argument('-t', '--convert-type', default="", metavar='CONVERT_TYPE', help='type of elements to convert to another type (one of: Hex8_Tet4_24, Hex8_Tet4_6, Quad4_Tri3_2, Quad4_Tri3_6, Quad4_Tri3_4)') - parser_convert.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_convert.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_convert.add_argument(*original_arg_list, **original_arg_dict) - - # enrich - parser_enrich = subparsers.add_parser('enrich') - parser_enrich.add_argument('-t', '--enrich-type', default='DEFAULT', metavar='ENRICH_TYPE', help='type of elements to convert to another type (one of: Quad4_Quad8_1, Quad4_Quad9_1, Tri3_Tri6_1, Tet4_Tet10_1, Hex8_Hex20_1, Hex8_Hex27_1, Wedge6_Wedge15_1, Wedge6_Wedge18_1)') - parser_enrich.add_argument(*blocks_arg_list, **blocks_arg_dict) - parser_enrich.add_argument(*blocks_file_arg_list, **blocks_file_arg_dict) - #parser_enrich.add_argument(*original_arg_list, **original_arg_dict) - - # infile and outfile - parser.add_argument('infile', nargs=1, help='input mesh file name') - parser.add_argument('outfile', nargs='?', help='output mesh file name') - - # Other options - parser.add_argument('-C','--directory', metavar='DIR', help='change working directory') - - # Parallel operation - parallel = parser.add_argument_group('parallel control') - # NOTE: --load-balance is taken care of by number of processes argument - parallel.add_argument('-j', '--num-proc', type=int, default=1, metavar='NP', help='number of processors to use (default: %(default)s)') - parallel.add_argument('--proc-rank-field', action='store_true', default=False, help='store the processor-rank in an element field on mesh output') - - # Streaming operation - streaming = parser.add_argument_group('streaming control') - streaming.add_argument('-M', '--num-virtual-proc', type=int, default=0, metavar='NM', help='number of virtual processors in streaming mode = M in file.e.M.iM decomposition (default: %(default)s)') - - # Informative output - informative = parser.add_argument_group('informative output') - # NOTE: --print-info N is now verbose - informative.add_argument('-v', '--verbose', type=int, default=0, help='print more verbose information int >= 0 (default: %(default)s)') - informative.add_argument('--echo-command-line', default=False, action='store_true', help='output original command line and continue as normal') - informative.add_argument('-o','--output-log', default=('%s.log' % os.path.basename(sys.argv[0])), help='path where output log file will be written (default: %(prog)s.log)') - informative.add_argument('--show-defaults', action='store_true', default=False, help='show %(prog)s defaults') - - # diagnostic and debugging options - diagnostic = parser.add_argument_group('diagnostic and debugging') - diagnostic.add_argument('--pause-for-debugging', default=False, action='store_true', help='wait for your input to allow attaching debugger') - diagnostic.add_argument('--pout', default='-', help='path where per processor log files will be written (default: %(default)s)') - diagnostic.add_argument('--dout', default='cout', help='path, or stream (one of cout, cerr), where diagnostic log file will be written (default: %(default)s)') - # NOTE: -dw is now --writer - diagnostic.add_argument('--writer', metavar='WRITER', help='name of the diagnostic writer, for example "all"') - diagnostic.add_argument('--timer', metavar="TIMER", help='name of the diagnostic timer, for example "mesh"') - # NOTE: for now hide more esoteric diagnostics - #diagnostic.add_argument('--test-memory-elements', metavar='NUM-ELEMS', type=int, default=0, help='specify number of elements (default: %(default)s)') - #diagnostic.add_argument('--test-memory-nodes', metavar='NUM-NODES', type=int, default=0, help='specify number of nodes (default: %(default)s)') - - return parser - -def convert_to_stk_adapt_option(args, arg_name): - arg_value = getattr(args, arg_name) - if (arg_name == "block"): - if (arg_value is not None): - return "--block-name=%s" % arg_value - elif (arg_name == "blocks_from"): - if (arg_value is not None): - return "--block-name=file:%s" % arg_value - elif (arg_name == "directory"): - if (arg_value is not None): - return "--directory=%s" % arg_value - elif (arg_name == "dout"): - if (arg_value is not None): - return "--dout=%s" % arg_value - elif (arg_name == "echo_command_line"): - if (arg_value): - return "--echo-command-line" - elif (arg_name == "infile"): - assert type(arg_value) == list - assert len(arg_value) == 1 - return "--input_mesh=%s" % arg_value[0] - elif (arg_name == "number_refines"): - return "--number_refines=%d" % arg_value - elif (arg_name == "outfile"): - if (arg_value is None): - arg_value = getattr(args, "infile")[0].split(".")[0] + "_out.exo" - return "--output_mesh=%s" % arg_value - elif (arg_name == "output_log"): - return "--output-log=%s" % arg_value - elif (arg_name == "pause_for_debugging"): - if (arg_value): - return "--pause-for-debugging" - elif (arg_name == "pout"): - if (arg_value is not None): - return "--pout=%s" % arg_value - elif (arg_name == "proc_rank_field"): - if (arg_value): - return "--proc_rank_field=%d" % 1 - elif (arg_name == "refine_type"): - return "--refine=%s" % arg_value - elif (arg_name == "convert_type"): - return "--convert=%s" % arg_value - elif (arg_name == "enrich_type"): - return "--enrich=%s" % arg_value - elif (arg_name == "show_defaults"): - if (arg_value): - return "" # TODO - elif (arg_name == "timer"): - if (arg_value is not None): - return "--timer=%s" % arg_value - elif (arg_name == "verbose"): - if (arg_value > 0): - return "--print_info=%d" % arg_value - elif (arg_name == "writer"): - if (arg_value is not None): - return "--writer=%s" % arg_value - - return "" - -def run_cmd(cmd_str): - print cmd_str - - proc = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, errput = proc.communicate() - stat = proc.wait() - - if (stat != 0): - raise SystemExit("%s failed:\n\nError: %s" % (os.path.basename(sys.argv[0]), errput)) - -def main(): - """Entry point for Percept script.""" - parser = setup_parser() - #(options, args) = parser.parse_args() - args = parser.parse_args() - - debug = True - - # TODO: setup_logger(options) - if not args: - # TODO: run_interactive(parser) - print 'Interactive mode not yet working.' - else: - num_virtual_proc = args.num_virtual_proc - # loop over virtual procs - we expect to see file.e.M.iM in the current directory FIXME - M = num_virtual_proc - for iM in range(0,M): - - # Construct the sierra command from args - cmd_str = "sierra" - - # TODO: use release version by omitting this later - # for now we default to head - cmd_str += " -V head" - - # Find what args/options need to go to the sierra command itself (not the app) - skip_list = ["num_proc", "num_virtual_proc"] - num_proc = args.num_proc - # for now, only allow serial streaming (later we can do M --> N by P workers, P==num_proc) - if num_virtual_proc != 0: - msg = "" - if num_proc > 1: - msg = " [Note: num_proc reduced from %d to 1 for serial streaming mode - parallel streaming not yet supported] " % num_proc - num_proc = 1 - print "num_virtual_proc= " , num_virtual_proc, " num_proc= " , num_proc, msg - - cmd_str += " -j %d" % num_proc - - # Find what args/options need to go to stk_adapt - cmd_str += ' stk_adapt_exe -O "' - for arg in dir(args): - if (not arg.startswith("_") and arg not in skip_list): - cmd_piece = " %s" % convert_to_stk_adapt_option(args, arg) - #print "arg = " , arg, " cmd_piece= ", cmd_piece - if arg == "infile" or arg == "outfile": - cmd_piece += ".%d.%d" % (M, iM) - cmd_str += cmd_piece - - if (num_proc > 1): - cmd_str += " --load_balance=1" - else: - cmd_str += " --load_balance=0" - - cmd_str += '"' - if debug: - print "cmd_str= " , cmd_str - else: - run_cmd(cmd_str) - -def exit_from_int(*args): - """Handler for SIGINT signal.""" - print '' - exit(0) - -if __name__ == '__main__': - import signal - signal.signal(signal.SIGINT, exit_from_int) - main() diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/pyencore.h b/packages/stk/stk_classic/stk_percept/stk_percept/pyencore.h deleted file mode 100644 index 164f09dd2ab1..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/pyencore.h +++ /dev/null @@ -1,2 +0,0 @@ -#define PY_ENCORE 0 - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/stk_mesh.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/stk_mesh.hpp deleted file mode 100644 index 994dd5bfcee0..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/stk_mesh.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/util/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/stk_percept/util/CMakeLists.txt deleted file mode 100644 index 63ae85d5a7a8..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/util/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE(TribitsLibraryMacros) - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_percept/util/) - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/util/GeneralFunction.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/util/GeneralFunction.hpp deleted file mode 100644 index 0edc0a7da9d2..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/util/GeneralFunction.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef stk_percept_util_generalfunction_hpp -#define stk_percept_util_generalfunction_hpp - -#include - -//using namespace std; - -#if 0 -template void push_back( std::vector& dst, const std::vector& src) -{ - dst.insert(dst.end(), src.begin(), src.end()); -} -#endif - -namespace stk_classic { - - namespace percept { - - namespace util { - - /** example usage - * - * GeneralFunction > f; - * GeneralFunction, int > g; - * std::vector y; - * double x; - * y = f(x); - * f(x, y); - * - * // multiple points - * std::vector xv; - * std::vector< std::vector > yv; - * f(xv, yv); - * - * // function composition - * GeneralFunction g_of_f = g(f); - * int iy; - * iy = g_of_f(x); - * - * // gradient - * GeneralFunction > > grad_f = f.grad(); - * - */ - - template - class CompositeGeneralFunction; - - template - class GeneralFunction - { - public: - GeneralFunction() {} - - /// single value (default impl is identity op) - virtual codomain operator()(const domain& x) { return x; } // return value or reference? - virtual void operator()(const domain& x, codomain& y) { y = x; } - - // multiple values - virtual std::vector operator()(const std::vector& x) - { - // inefficient default impl - int n = x.size(); - std::vector y(n); - for(int i = 0; i < n; i++) - { - y[i] = (*this)(x[i]); - } - return y; - }; // return value or reference? - virtual void operator()(const std::vector& x, std::vector& y) - { - // inefficient default impl - int n = x.size(); - for(int i = 0; i < n; i++) - { - y[i] = (*this)(x[i]); - } - } - - // composition - template< typename codomain_f_and_domain_g> - GeneralFunction operator()(const GeneralFunction& f) - { - return CompositeGeneralFunction(*this, f); - } - - }; - - template - class GeneralFunctionWithGrad : public GeneralFunction - { - // return a function that computes the gradient of this - virtual GeneralFunction > grad()=0; // return GeneralFunction >(); } - }; - - template - class CompositeGeneralFunction : public GeneralFunction - { - private: - GeneralFunction m_g; - GeneralFunction m_f; - codomain_f_and_domain_g m_tmp_fv; - - public: - CompositeGeneralFunction(GeneralFunction& g, GeneralFunction& f, - codomain_f_and_domain_g& tmp_fv = 0) : m_g(g), m_f(f), m_tmp_fv(tmp_fv? tmp_fv : codomain_f_and_domain_g()) - { - } - virtual codomain_g operator()(domain_f& x) { return m_g(m_f(x)); } - virtual void operator()(domain_f& x, codomain_g& y) { - codomain_f_and_domain_g& fv = m_tmp_fv; - m_f(x, fv); - m_g(fv, y); - } - }; - - } // namespace util - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.cpp deleted file mode 100644 index 73d32a66c883..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -#include "Verifier.hpp" - -#include - -#include - -namespace stk_classic -{ - namespace percept - { - - - void Verifier::process_options(RunEnvironment& re) - { - re.clp.setDocString("verifier options"); - - re.clp.setOption("mesh", &mesh_opt, "mesh file." ); - re.clp.setOption("printTable", &printTable_opt, "print a table of min/max jacobian and quality measures " ); - re.clp.setOption("fullPrint", &fullPrint_opt, "print every element's jacobian" ); - - - } - - void Verifier::verify(int argc, char** argv) - { - //stk_classic::ParallelMachine parallel_machine = stk_classic::parallel_machine_init(&argc, &argv); - - bool printTable = false; - bool fullJacobianPrints = false; - std::string file_name; - - - bool debug_re=true; - ParallelMachineFinalize pmf(true); - RunEnvironment run_environment(&argc, &argv, debug_re); - process_options(run_environment); - run_environment.processCommandLine(); - - { - if (run_environment.help_opt) { - run_environment.printHelp(); - std::exit(EXIT_SUCCESS); - } - - std::string working_directory = ""; - std::string in_filename = ""; - - if (true) - { - in_filename = mesh_opt; - - working_directory = run_environment.directory_opt; - - file_name = in_filename; - if (in_filename[0] != '/' && !working_directory.empty() > 0) { - file_name = working_directory + in_filename; - } - - } - else - { - std::cout << "OPTION ERROR: The '--mesh ' option is required.\n"; - std::exit(EXIT_FAILURE); - } - - if (fullPrint_opt) - { - fullJacobianPrints = true; - } - if (printTable_opt) - { - printTable = true; - } - } - - //RunEnvironment::doLoadBalance(run_environment.m_comm, file_name); - - PerceptMesh mesh(3, run_environment.m_comm); - mesh.open_read_only(file_name); - std::cout << "read in file: " << file_name << std::endl; - - TopologyVerifier topoVerifier; - bool isBad= topoVerifier.isTopologyBad( *mesh.get_bulk_data() ); - if (isBad) - { - std::cout << "found bad topology" << std::endl; - } - - GeometryVerifier geomVerifier(fullJacobianPrints); - isBad= geomVerifier.isGeometryBad( *mesh.get_bulk_data(), printTable ); - if (isBad) - { - std::cout << "found bad jacobian" << std::endl; - } - - } - - //void MeshGeometryVerifier - - - }//namespace percept -}//namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.hpp b/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.hpp deleted file mode 100644 index 4c357e69b662..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/Verifier.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef stk_percept_Verifier_hpp -#define stk_percept_Verifier_hpp - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - - -namespace stk_classic -{ - namespace percept - { - - class Verifier - { - public: - Verifier() : printTable_opt(1), fullPrint_opt(0) {} - void verify(int argc, char** argv); - - void process_options(RunEnvironment& re); - // command line - std::string mesh_opt; - int printTable_opt; - int fullPrint_opt; - }; - - class MeshVerifier : public Verifier - { - }; - - class CodeVerifier : public Verifier - { - }; - - class MeshGeometryVerifier : public MeshVerifier - { - - }; - - class MeshTopologyVerifier : public MeshVerifier - { - - }; - - - }//namespace percept -}//namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/main1.cpp b/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/main1.cpp deleted file mode 100644 index 2a738d36245b..000000000000 --- a/packages/stk/stk_classic/stk_percept/stk_percept/verifier/mesh/main1.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -#include "Verifier.hpp" -#include -#include - -#include - - -using namespace stk_classic; -using namespace percept; - -#define doMPI 0 - -int main(int argc, char **argv) -{ - -#if doMPI - if ( MPI_SUCCESS != MPI_Init( & argc , & argv ) ) { - std::cerr << "MPI_Init FAILED" << std::endl ; - std::abort(); - } -#endif - - Verifier vf; - vf.verify(argc, argv); - - -#if doMPI -#endif - // MPI_Finalize(); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_percept/unit_tests/CMakeLists.txt deleted file mode 100644 index 7d5546d68d0f..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ - -INCLUDE(TribitsAddExecutableAndTest) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../stk_percept/fixtures) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util/stk_util/unit_test_support/) -#INCLUDE_DIRECTORIES(${TPL_gtest_INCLUDE_DIRS}/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_percept_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/Documentation.hpp b/packages/stk/stk_classic/stk_percept/unit_tests/Documentation.hpp deleted file mode 100644 index 2a2775f08af2..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/Documentation.hpp +++ /dev/null @@ -1,149 +0,0 @@ -// see http://stackoverflow.com/questions/1579007/how-can-i-include-a-subset-of-a-cpp-file-in-a-doxygen-comment - -/*! \mainpage STK Percept Documentation - - \image html intrepid.png - \image latex intrepid.jpg "Reconnaissance balloon ``Intrepid''" width=1in - - \section intro_sec Introduction - - %STK Percept is a library and application built on the Sierra Tool Kit (STK). Percept - is designed to perform operations on results from Sierra mechanics codes, such as post-processing, - norms, error estimation, adaptivity, and mesh transfer, thus the name "Percept". - - Percept is based around the concept of a generic function interface that takes multi-dimensional - arrays as input (the functions' domain objects) and produce multi-dimensional arrays as output - (codomain). From this generic interface, users can apply functions to evaluate the fields on - a mesh, such as pressure or temperature (\ref FieldFunction), or evaluate the gradient (\ref GradientFunction) - or analytic functions defined by a string expression (\ref StringFunction). - Multi-dimensional arrays used in Percept are based on mainly the Intrepid FieldContainer - Intrepid array but also use - the Shards array package. - Intrepid is used extensively in Percept for: - - evaluation of mesh Jacobians for geometry verification - - integration of Functions over mesh domains - - evaluation of norms of Functions using numerical quadrature - - evaluation (by interpolation) of field functions - - support for manufactured solutions - - \section overview_sec Overview - - %Percept includes the following features: - - Definition of analytic functions by providing a string expression, such as "x * sin(y * z)" (StringFunction) - - Read an Exodus model and results and define FieldFunction for each field - - add fields to a model (e.g. the gradient) - fields can be nodal or elemental (piecewise constant/linear/etc.) - - evaluate string or field functions at a given point \c (x,y,z) - - construct composite functions of StringFunction's by arithmetic operations - - embedding references to field functions inside a string function - - computing the norm (L2, H1 semi-norm, etc) of any Function (which includes the difference of two functions, - for example a field function and a known/manufactured solution) - - verifying mesh integrity by checking its topologic and geometric consistency/quality - - \section future_dev Future Capabilities - - STK Percept is a port and expansion from Sierra Percept (\ref xxx). Sierra Percept has a wealth of capabilities - for post-processing, error-estimation, adaptivity, mesh transfere, etc., to name a few. STK Percept will incorporate - these features over time, in the rough order of: - -# uniform mesh refinement for convergence studies - -# advanced stand-alone executable with new Python-based input syntax - -# a suite of physics-independent error indicators and error estimators - -# tools for physics-dependent error estimation - -# etc FIXME - - \section quickstart_sec Quick Start - - Familiarity with with the following concepts, objects, and tools is required: - - multi-dimensional arrays / Intrepid::FieldContainer / \ref md_array_page, - - Shards arrays - - Examples of the C++ interface to STK::Percept are shown below. We start with a simple example of an analytic - function and evaluate it at a given point. Then read in a model, construct a FieldFunction and evaluate it. - Then construct a complex function of the pressure field from a mesh. Finally, some other examples are shown. - - \subsection ex_string_function String Function - - - The following can be seen in \see UnitTestStringFunction.cpp unit tests file. - - \clip{UnitTestStringFunction.cpp,start_demo_stringFunction_xy_basic} - - Now a more complicated example that builds a new StringFunction from two others (\see TEST(function, stringFunction_arithmetic_ops) ) - - \clip{UnitTestStringFunction.cpp,start_demo_stringFunction_arithmetic_ops} - - Here's a series of examples on using the derivative capability to evaluate gradient of a StringFunction (note: the methods - with names derivative_test and derivative_test_fd are only for internal testing). The first example is very simple and shows - the derivative being defined for a simple linear function "x-y". - - \clip{UnitTestStringFunction.cpp,start_demo_stringFunction_derivative} - - The next example shows the gradient of the same function - - \clip{UnitTestStringFunction.cpp,start_demo_stringFunction_derivative_1} - - while the last derivative example shows the gradient of a more complex function "sin(x*y*z^2)" - - \clip{UnitTestStringFunction.cpp,start_demo_stringFunction_derivative_2} - - Here is an example of setting up a FieldFunction and evaluating it at a point - - \clip{UnitTestFieldFunction.cpp, start_demo_fieldFunction_1} - - Here is the same example but now we add a nodal field to contain the magnitude of the coordinates field at each node, - and use a StringFunction to define and compute the coordinate magnitude at any point. Finally, we show the interpolation - of that coordinate magnitude function to the field we created. - - \clip{UnitTestFieldFunction.cpp, start_demo_fieldFunction_2} - - Here is an example following on from the last one that shows a StringFunction referring to a FieldFunction's values: - \clip{UnitTestFieldFunction.cpp, start_demo_fieldFunction_3} - \code - ... - \endcode - - An example of evaluating the difference between a computed pressure field and an analytic function - - \clip{RegressionTestPerceptMeshFieldFunction.cpp, start_demo_open_new_close_PerceptMesh} - - Continuing, we can now compute the norm of the error. But, first a remark: now that we have introduced Functions, we - introduce the concept of operators on functions, under the base class of FunctionOperator. One type of operator is a norm. Norms take - a field function and return a value of the norm. We consider this to be a special type of more general operation, such - as a gradient operation which takes a field function and returns another one. So, we consider the single value returned - by Norm to be a special type of function, ConstantFunction. - - \code - Norm<2> l2Norm(bulkData, &metaData.universal_part()); - ConstantFunction norm_result(0.0, "norm_result"); - l2Norm (sf_error, norm_result); - std::cout << "Norm of error is: " << norm_result.getValue() << std::endl; - \endcode - - \section math_sec Mathematical Foundations - - Given a domain \f$ \Omega \in R^d \f$, discretized to represent a finite domain \f$ \Omega_h \f$ - with a finite element mesh \f$ T = {\Omega_e} s.t. \Omega_e \cap \Omega_f = \null - \forall e,f \mbox{and} \cup_e \Omega_e = \Omega_h \f$. We define \f$ x \f$ to be any point in \f$ \Omega_h \f$ -and a function \f$ f : x \rightarrow y \f$ where \f$ y \in Y \f$ where \f$ Y \f$ is a space of results from -the operator of \f$ f \f$ such as a scalar, vector or tensor field. For example, \f$ Y = R^d X R^d \f$. - - A function \c f has a \e domain and \e codomain. The domain of \c f is the set of points \c x where it is defined -to be evaluatable. The codomain is the set of all images \c y of the domain of \c f. This is not to be confused with -the \e range of \c f, which is a superset of the codomain. For example, the range of \f$ |x| \f$ is the real line, but -the codomain is just \f$ R^+ \f$. In Percept the user explicitly specifies the domain and codomain of each function. - Typically the domain is defined as \f$ R^3 \f$ and the codomain is \f$ R \f$. - - A function operator \c S has as its domain a subset of all functions and its codomain is a subset of all functions. - For example, the L2 norm \f$ L^2 \f$ is defined by - \f[ L^2 : f \rightarrow c = \sqrt{\int_{\Omega_h} |f(x)|^2 dx } \f] - - \page parallel_node_registry Parallel Node Registry - - The following demo shows use of the NodeRegistry class. This class enables registration of the need for new nodes - associated with sub-entities of the elements, for example edges and faces. This is used for uniform (or other) - refinement schemes where new nodes are inserted at the mid-points of edges, centroids of faces, etc., and then - become part of new elements that break the element into same-topology sub-elements. - - \clip{UnitTestNodeRegistry.cpp, start_demo_nodeRegistry_test_parallel_1} - -*/ - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/Example2.py b/packages/stk/stk_classic/stk_percept/unit_tests/Example2.py deleted file mode 100644 index d4c4a0afa11f..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/Example2.py +++ /dev/null @@ -1,83 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -from PerceptMesh import * -import unittest -from numpy import * -import subprocess - -class UseCases(unittest.TestCase): - - def test_use_case_2(self): - - pMesh = PerceptMesh() # create an empty PerceptMesh - pMesh.open("exodus_files/tet-mesh.e") # open the mesh, but don't commit its meta data - - uniform_refiner = Refiner(pMesh, TET4_TET4_8) # define a Refiner on the mesh - pMesh.commit() # commit the mesh - - i = 0 - while i < 3: - uniform_refiner.doBreak() # refine the mesh 3 times - i = i + 1 - - pMesh.save_as("tet-mesh-refined-3-times.e") # save in exodus format - - def test_fieldFunction_demo_2(self): - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")) # use a fixture to generate a 3x3x3 hex mesh - - vectorDimension = 0 - # add a field - eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension) - eMesh.commit() - - f_coords = eMesh.get_field("coordinates") # get pre-existing field - coords_mag_field = eMesh.get_field("coords_mag_field") # get the field we just created - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3) # define a field function - eval_vec3_print(0.1,0.1,0.1,0.0,ff_coords) # evaluate and print the field function a point {0.1, 0.1, 0.1} time=0.0 - - coords_mag_sf = StringFunction("sqrt(x*x + y*y + z*z)" , "coords_mag_sf", 3, 1) # define coordinate magnitude function - x = 0.123 - y = 0.234 - z = 0.345 - vv = sqrt(x*x + y*y + z*z) - v1 = eval_func(x,y,z,0,coords_mag_sf) - print "vv = ", vv, "== v1 = ", v1 - self.assertEqual(vv, v1) # ensure correctness of string function - - # define a field function - coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 3, 1) - - # interpolate the function onto the mesh - coords_mag_field_function.interpolateFrom(coords_mag_sf) - - eMesh.save_as("./cubehex8_withCoordMag_out.e") - - # demonstrate how to usa an alias - ff_coords.add_alias("mc") - - sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", 3, 1) - - def test_wedge6_wedge18_enrich(self): - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1: - wedgeFixture = WedgeFixture() - bulk = wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1,"") # create stk_classic::mesh::BulkData from wedge fixture - eMesh = PerceptMesh(wedgeFixture.getMetaData(), bulk, False) # adopt bulk data - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE6_WEDGE15_1, proc_rank_field) - eMesh.commit() - wedgeFixture.createBulkAfterMetaCommit(MPI.COMM_WORLD) # generate the mesh - breaker.doBreak() # refine - eMesh.save_as("./wedge6-15.e") # save - - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(UseCases) - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/FieldFunctionUnitTests.py b/packages/stk/stk_classic/stk_percept/unit_tests/FieldFunctionUnitTests.py deleted file mode 100644 index c13018140d2e..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/FieldFunctionUnitTests.py +++ /dev/null @@ -1,356 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -from PerceptMesh import * -from math import * -import random -import time -import unittest -from numpy import * - -class CheckCoordMag(GenericFunction): - - def __init__(self, name=""): - self.name = name - self.error = False - - def evaluate(self, domain, codomain, time_value_optional=0.0): - x = domain(0) - y = domain(1) - z = domain(2) - v = sqrt(x*x + y*y + z*z) - if fabs(v-cmag_field_node > 1.e-6): - print "CheckCoordMag:: ", self.name, "v= ", v, "x= ", x, "y= ", y, "z= ", z, "cmag_field_node= ", cmag_field_node - self.assertAlmostEqual(v, cmag_field_node) - self.error = True - -class FieldFunctionUnitTests(unittest.TestCase): - - def setUp(self): - self.testpoints = [[0.1234, 0.5678, 0.9, 0.812], - [0.1234e-3, 0.5678e-5, 0.97, 0.01], - [0.101, 0.02, 0.1020, 0.0122], - [0.003, 0.89, 0.01, 0.5] ] - - def test_fieldFunction_multiplePoints(self): - print "start..." - num_x = 3 - num_y = 3 - num_z = 3 - config_mesh = str(num_x) + "x" + str(num_y) + "x" + str(num_z) + "|bbox:0,0,0,1,1,1" - - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec(config_mesh)) - vectorDimension = 0 - eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension) - eMesh.commit() - f_coords = eMesh.get_field("coordinates") - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - val1 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords) - print "val1= ", val1 - - points = zeros(shape=(4,3)) - output_expect = zeros(shape=(4,3)) - output = zeros(shape=(4,3)) - - print "here 1" - i = 0 - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - points[i][0] = x - points[i][1] = y - points[i][2] = z - - vec = eval_vec3(x,y,z,t,ff_coords) - - tol0 = fabs(1.e-5*x) - tol1 = fabs(1.e-5*y) - tol2 = fabs(1.e-5*z) - - print "vec(0) = ", vec[0], " == x = ", x - print "vec(1) = ", vec[1], " == y = ", y - print "vec(2) = ", vec[2], " == z = ", z - - self.assertAlmostEqual(x, vec[0], delta=tol0) - self.assertAlmostEqual(y, vec[1], delta=tol1) - self.assertAlmostEqual(z, vec[2], delta=tol2) - - output_expect[i][0] = x - output_expect[i][1] = y - output_expect[i][2] = z - i = i + 1 - - print "field_op: NPTS= 4" - ff_coords.setDomainDimensions(Dimensions(3)) - ff_coords.setCodomainDimensions(Dimensions(3)) - #output = ff_coords.evaluate(points) - # pass in the output array to ensure result is properly dimensioned - output = ff_coords.value(points, output) - print "here 2, output= ", output - - for j in range(4): #NLM - output_expect_j = output_expect[j][0] - output_j = output[j][0] - - tol = 1.e-5*(fabs(output_expect_j)) - print "output[j] = ", output_j, " == output_expect[j] = ", output_expect_j , " points[j] = ", points[j] - self.assertAlmostEqual(output_j, output_expect_j, delta = tol) - print "start...done" - - def test_fieldFunction_demo_1_0_0(self): - eMesh = PerceptMesh(3) - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")) - eMesh.commit() - eMesh.print_info("fieldFunction_demo_1_0_0", 2) - - f_coords = eMesh.get_field("coordinates") - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3) - x = 0.123 - y = 0.234 - z = 0.345 - time = 0.0 - - eval_vec3_print(x, y, z, time, ff_coords) - - def test_fieldFunction_read_print(self): - print_info = 0 - - x = 3 - y = 3 - z = 3 - config_mesh = str(x) + "x" + str(y) + "x" + str(z) + "|bbox:0,0,0,1,1,1" - - eMesh = PerceptMesh() - eMesh.new_mesh_read_only(GMeshSpec(config_mesh)) - - metaData = eMesh.get_fem_meta_data() - - parts = metaData.get_parts() - nparts = len(parts) - - if print_info == 1: - print "Number of parts = ", nparts - fields = metaData.get_fields() - nfields = len(fields) - if print_info == 1: - print "Number of fields = ", nfields - for i in range(nfields): - field = fields[i] - # here we have a FieldBase* which we cannot access from Python - # is this a problem and will we want this functionality? - - def test_fieldFunction_demo_1(self): - gms = Gmesh_STKmesh_Fixture(MPI.COMM_WORLD, "3x3x3|bbox:0,0,0,1,1,1") - print "gms = ", gms - print "gms= end" - - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")) - eMesh.commit() - - f_coords = eMesh.get_field("coordinates") - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3) - - x = 0.123 - y = 0.234 - z = 0.345 - time = 0.0 - eval_vec3_print(x,y,z,time,ff_coords) - - def test_fieldFunction_demo_2(self): - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")) - - vectorDimension = 0 - eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension) - eMesh.commit() - - f_coords = eMesh.get_field("coordinates") - coords_mag_field = eMesh.get_field("coords_mag_field") - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3) - eval_vec3_print(0.1,0.1,0.1,0.0,ff_coords) - - coords_mag_sf = StringFunction("sqrt(x*x + y*y + z*z)" , "coords_mag_sf", 3, 1) - x = 0.123 - y = 0.234 - z = 0.345 - vv = sqrt(x*x + y*y + z*z) - v1 = eval_func(x,y,z,0,coords_mag_sf) - print "vv = ", vv, "== v1 = ", v1 - self.assertEqual(vv, v1) - - coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 3, 1) - - coords_mag_field_function.interpolateFrom(coords_mag_sf) - - eMesh.save_as("./cubehex8_withCoordMag_out.e") - - ff_coords.add_alias("mc") - - sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", 3, 1) - vv = eval_func(0.1,0.1,0.1,0.0, sfcm) - print "expected = ", sqrt(3*0.1*0.1), " actual= " , vv - - sfcm = StringFunction("sqrt(ff_coords[0]*ff_coords[0]+ff_coords[1]*ff_coords[1]+ff_coords[2]*ff_coords[2])", "sfcm", 3, 1) - vv = eval_func(0.1,0.1,0.1,0.0, sfcm) - print "expected = ", sqrt(3*0.1*0.1), " actual= " , vv - - def test_fieldFunction_readMesh_createField_interpolateFrom(self): - num_x = 3 - num_y = 3 - num_z = 3 - config_mesh = str(num_x) + "x" + str(num_y) + "x" + str(num_z) + "|bbox:0,0,0,1,1,1" - - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec(config_mesh)) - vectorDimension = 0 - eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension) - eMesh.commit() - - #p_rank = eMesh.get_bulk_data().parallel_rank() - #setRank(p_rank) - #from Util - f_coords = eMesh.get_field("coordinates") - - coords_mag_field = eMesh.get_field("coords_mag_field") - #VERIFY_OP_ON Here the unit test does something - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3, FieldFunction.SIMPLE_SEARCH) - - #here we could evaluate the function - #eval_vec3_print(0.1,0.2,0.3,0.0,ff_coords) - - coords_mag_sf = StringFunction("sqrt(x*x + y*y + z*z)", "coords_mag_sf", 3, 1) - coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 3, 3, FieldFunction.SIMPLE_SEARCH) - coords_mag_field_function.interpolateFrom(coords_mag_sf) - - #The following is not doable from Python - - checkCoordMag = CheckCoordMag() - #eMesh.nodalOpLoop(checkCoordMag, coords_mag_field) - print checkCoordMag.error - - ff_coords.add_alias("mc") - sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", Dimensions(3), Dimensions(1)) - - tol1 = 1.e-12 - - vv = eval_vec3(0.1, 0.2, 0.3, 0.0, ff_coords) - print - print "0.1 == vv[0] = ", vv[0], "passed" - print "0.2 == vv[1] = ", vv[1], "passed" - print "0.3 == vv[2] = ", vv[2], "passed" - - self.assertAlmostEqual(.1, vv[0], delta=tol1) - self.assertAlmostEqual(.2, vv[1], delta=tol1) - self.assertAlmostEqual(.3, vv[2], delta=tol1) - - vv = eval_func(0.1, 0.2, 0.3, 0.0, sfcm) - v_expect = sqrt(0.1*0.1+0.2*0.2+0.3*0.3) - - if ((vv-v_expect) < tol1): - print "vv = ", vv, " == v_expect = ", v_expect, "passed" - - coords_mag_field_function.interpolateFrom(sfcm) - - - - def test_fieldFunction_point_eval_verify(self): - num_x = 3 - num_y = 3 - num_z = 3 - config_mesh = str(num_x) + "x" + str(num_y) + "x" + str(num_z) + "|bbox:0,0,0,1,1,1" - - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec(config_mesh)) - eMesh.commit() - - f_coords = eMesh.get_field("coordinates") - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - - val1 = eval_vec3_print(0.2,0.3,0.4,0.0,ff_coords) - - bulkData = eMesh.get_bulk_data() - - try: - val10 = eval_print_vec3(1.2, 1.3, 1.4, 0.0, ff_coords) - except: - print "expected to catch this exception: " - - pts = array([0.2, 0.3, 0.4]) - output_pts = array([0.0, 0.0, 0.0]) - output_pts = ff_coords.value(pts, output_pts) - - tol = 1.e-9 - - print "output(0) = ", pts[0], " == output_pts(0) = ", output_pts[0] - print "output(1) = ", pts[1], " == output_pts(1) = ", output_pts[1] - print "output(2) = ", pts[2], " == output_pts(2) = ", output_pts[2] - - self.assertAlmostEqual(pts[0], output_pts[0], delta = tol) - self.assertAlmostEqual(pts[1], output_pts[1], delta = tol) - self.assertAlmostEqual(pts[2], output_pts[2], delta = tol) - - def test_fieldFunction_point_eval_timing(self): - num_x = 3 - num_y = 3 - num_z = 3 - config_mesh = str(num_x) + "x" + str(num_y) + "x" + str(num_z) + "|bbox:0,0,0,1,1,1" - - eMesh = PerceptMesh() - eMesh.new_mesh(GMeshSpec(config_mesh)) - eMesh.commit() - - #FIXME - #p_size = eMesh.get_bulk_data->parallel_size() - - f_coords = eMesh.get_field("coordinates") - - for iSearchType in range(2): - if iSearchType == 0: - search_type = FieldFunction.SIMPLE_SEARCH - search_type_name = "SIMPLE_SEARCH" - else: - search_type = FieldFunction.STK_SEARCH - search_type_name = "STK_SEARCH" - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, Dimensions(3), Dimensions(3), search_type) - - t1st = time.time() - val1 = eval_vec3(0.2,0.3,0.4,0.0,ff_coords) - val1 = eval_vec3(0.2,0.3,0.4,0.0,ff_coords) #evaluated twice??? - t1st = time.time() - t1st - - numIter = 10000 - random.seed(12345) - total_time = time.time() - max_rand = 32767 - - for iter in range(numIter): - num0 = random.randint(1, max_rand)*1.0 - num1 = random.randint(1, max_rand)*1.0 - num2 = random.randint(1, max_rand)*1.0 - pts = array([(num0/max_rand), (num1/max_rand), (num2/max_rand)]) - output_pts = array([0.0,0.0,0.0]) - output_pts = ff_coords.value(pts, output_pts, 0.0) - - total_time = time.time() - total_time - - print "TEST::function::fieldFunction_point_eval_timing: " - print " for search_type= ", search_type_name - print " time for 1st eval= ", t1st - print " for ", numIter, "iterations, evaluating field(x,y,z) time = ", total_time - print " average per point lookup and eval time = ", (total_time/numIter) - - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(FieldFunctionUnitTests) - unittest.TextTestRunner(verbosity=2).run(suite) - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/NormUnitTests.py b/packages/stk/stk_classic/stk_percept/unit_tests/NormUnitTests.py deleted file mode 100644 index 2863a72f5a4c..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/NormUnitTests.py +++ /dev/null @@ -1,266 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -import unittest -from math import * -from random import * -from numpy import * -from PerceptMesh import * - - -class LocalFixture: - - def __init__(self, num_xyz, num_y, num_z, sidesets=False): - - self.eMesh = PerceptMesh() - self.num_x = num_xyz - self.num_y = num_y - self.num_z = num_z - config_mesh = str(self.num_x) + "x" + str(self.num_y) + "x" + str(self.num_z) + "|bbox:-0.5,-0.5,-0.5,0.5,0.5,0.5" - if sidesets: - config_mesh += "|sideset:xXyYzZ" - - self.eMesh.new_mesh(GMeshSpec(config_mesh)) - self.eMesh.commit() - self.metaData = self.eMesh.get_fem_meta_data() - self.bulkData = self.eMesh.get_bulk_data() - self.coords_field = self.metaData.get_field("coordinates") - self.sfx = StringFunction("x", "sfx", Dimensions(3), Dimensions(1)) - self.sfx_res = ConstantFunction(0.0, "sfx_res") - -def rotationMatrix(axis, angle): - """ - Create a rotation matrix corresponding to the rotation around a general - axis by a specified angle. - - R = dd^T + cos(a) (I - dd^T) + sin(a) skew(d) - - Parameters: - - angle : float a - direction : array d - """ - if axis == 0: - direction = array([1,0,0]) - elif axis == 1: - direction = array([0,1,0]) - elif axis == 2: - direction = array([0,0,1]) - else: - print "ERROR: could not determine axis" - d = array(direction, dtype=float64) - d /= linalg.norm(d) - - iden = eye(3, dtype=float64) - ddt = outer(d, d) - skew = array([[ 0, d[2], -d[1]], - [-d[2], 0, d[0]], - [d[1], -d[0], 0]], dtype=float64) - - mtx = ddt + cos(angle) * (iden - ddt) + sin(angle) * skew - return mtx - -def scalingMatrix(axis, scale): - - sm = eye(3, dtype=float64) - sm[axis][axis] = scale - return sm - -def random01(): - rnd = random.randint(0, 32678) - rnd = (rnd+1.0)/2.0 - return rnd - -class NormUnitTests(unittest.TestCase): - - def test_norm_volume(self): - fix = LocalFixture(3,3,12) - metaData = fix.metaData - bulkData = fix.bulkData - eMesh = fix.eMesh - coords_field = fix.coords_field - - ff_coords = FieldFunction("ff_coords", coords_field, bulkData, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - - identity = ConstantFunction(1.0, "identity") - - l2Norm = L2Norm(bulkData) - - result = l2Norm.evaluate(identity) - #result = eval_norm(bulkData, identity, 2) - - self.assertAlmostEqual(1.0, result) - - eMesh.save_as("./gmesh_hex8_original_out.e") - - # rotate the mesh - rmx = rotationMatrix(0, 30) - rmy = rotationMatrix(1, -45) - rmz = rotationMatrix(2, 30) - rm = dot(rmy,rmz) - rm = dot(rmx,rm) - eMesh.transform_mesh(rm) - - eMesh.save_as("./gmesh_hex8_rotated_out.e") - result = l2Norm.evaluate(identity) - self.assertAlmostEqual(1.0, result) - - # scale the mesh - scx = pi - scy = e - scz = sqrt(3.0) - sc = scx*scy*scz - smx = scalingMatrix(0, scx) - smy = scalingMatrix(1, scy) - smz = scalingMatrix(2, scz) - sm = dot(smy,smz) - sm = dot(smx,sm) - eMesh.transform_mesh(sm) - result = l2Norm.evaluate(identity) - self.assertAlmostEqual(sqrt(sc), result) - - eMesh.save_as("./gmesh_hex8_scaled_out.e") - - def test_norm_area(self): - sidesets = True - fix = LocalFixture(3,3,12,sidesets) - metaData = fix.metaData - bulkData = fix.bulkData - eMesh = fix.eMesh - coords_field = fix.coords_field - - ff_coords = FieldFunction("ff_coords", coords_field, bulkData, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - - identity = ConstantFunction(1.0, "identity") - - surface = "surface_1" - is_surface_norm = True - l2Norm = L2Norm(bulkData, surface) - l2Norm.set_is_surface_norm(is_surface_norm) - - result = l2Norm.evaluate(identity) - #result = eval_norm(bulkData, identity, 2) - self.assertAlmostEqual(1.0, result) - - eMesh.save_as("./gmesh_hex8_area_out.e") - - rmx = rotationMatrix(0, 30) - rmy = rotationMatrix(1, -45) - rmz = rotationMatrix(2, 30) - rm = dot(rmy,rmz) - rm = dot(rmx,rm) - eMesh.transform_mesh(rm) - - eMesh.save_as("./gmesh_hex8_area_rotated_out.e") - result = l2Norm.evaluate(identity) - self.assertAlmostEqual(1.0, result) - - scx = pi - scy = pi - scz = pi - sc = scx*scy; - smx = scalingMatrix(0, scx) - smy = scalingMatrix(1, scy) - smz = scalingMatrix(2, scz) - sm = dot(smy,smz) - sm = dot(smx,sm) - eMesh.transform_mesh(sm) - - eMesh.save_as("./gmesh_hex8_area_scaled.e") - result = l2Norm.evaluate(identity) - self.assertAlmostEqual(sqrt(sc), result) - - def test_norm_string_function(self): - fix = LocalFixture(4,1,1) - metaData = fix.metaData - bulkData = fix.bulkData - eMesh = fix.eMesh - coords_field = fix.coords_field - sfx = fix.sfx - sfx_res = fix.sfx_res - - l2Norm = L2Norm(bulkData) - result = l2Norm.evaluate(sfx) - - sfx_expect = sqrt((0.25/3.0)) - self.assertAlmostEqual(sfx_expect, result) - - l1Norm = L1Norm(bulkData) - result = l1Norm.evaluate(sfx) - sfx_expect = 0.25 - self.assertAlmostEqual(sfx_expect, result) - - sfxyz = StringFunction("x*y*z", "sfxyz", Dimensions(3), Dimensions(1)) - result = l2Norm.evaluate(sfxyz) - sfx_expect = 0.0240562612162344 - self.assertAlmostEqual(sfx_expect, result) - - rmz = rotationMatrix(2, 30) - rm = rmz - eMesh.transform_mesh(rm) - - result = l2Norm.evaluate(sfxyz) - sfx_expect = 0.0178406008037016 - #if fabs(result-sfx_expect) > 0.01*sfx_expect: - #self.assertAlmostEqual(sfx_expect, result) - #self.assertTrue(False) - - def string_function_turbo_verify_correctness(self): - fix = LocalFixture(4,1,1) - metaData = fix.metaData - bulkData = fix.bulkData - eMesh = fix.eMesh - coords_field = fix.coords_field - sfx = fix.sfx - sfx_res = fix.sfx_res - - ff_coords = FieldFunction("ff_coords", coords_field, bulkData, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - ff_coords.add_alias("mc") - - sfx_mc = StringFunction("mc[0]", "sfx_mc", Dimensions(3), Dimensions(1)) - sfx_mc1 = StringFunction("mc[0]", "sfx_mc1", Dimensions(3), Dimensions(1)) - - x = -0.49+.98*random01() - y = -0.49+.98*random01() - z = -0.49+.98*random01() - - self.assertAlmostEqual(eval_func(x,y,z,0.0,sfx), eval_func(x,y,z,0.0,sfx_mc)) - self.assertAlmostEqual(eval_func(0.34,0,0,0.0,sfx), eval_func(0.34,0,0,0.0,sfx_mc)) - - sfx_res_turbo(0.0, "sfx_res_turbo") - - - - - - - - def test_norm_field_function(self): - fix = LocalFixture(4,1,1) - metaData = fix.metaData - bulkData = fix.bulkData - coords_field = fix.coords_field - - l2Norm = L2Norm(bulkData, metaData.universal_part()) - - ff_coords = FieldFunction("ff_coords", coords_field, bulkData, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH) - - vals = [3,0.0] - #sfx_res_vec = ConstantFunctionVec(vals, "sfx_res_vec") - result = l2Norm.evaluate(ff_coords) - sfx_expect = sqrt(.25/3.0) - self.assertAlmostEqual(sfx_expect, result) - - l1Norm = L1Norm(bulkData, metaData.universal_part()) - result_1 = l1Norm.evaluate(ff_coords) - sfx_expect_1 = .25 - self.assertAlmostEqual(sfx_expect_1, result_1) - - - - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(NormUnitTests) - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/PerceptMeshUnitTests.py b/packages/stk/stk_classic/stk_percept/unit_tests/PerceptMeshUnitTests.py deleted file mode 100644 index b00892e1a308..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/PerceptMeshUnitTests.py +++ /dev/null @@ -1,270 +0,0 @@ -import sys - -#sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -from PerceptMesh import * -import unittest -from numpy import * - -class PerceptMeshUnitTests(unittest.TestCase): - - is_setup = 0 - pm = MPI.COMM_WORLD - input_files = "./input_files/" - - def fixture_setup_0(self): - eMesh = PerceptMesh() - - p_size = eMesh.get_parallel_size() - - gmesh_spec = "4x4x" + str((4*p_size)) + "|bbox:0,0,0,1,1,1" - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - eMesh.commit() - eMesh.save_as("./exodus_files/hex_fixture.e") - - def fixture_setup_1(self): - - p_size = self.pm.size - if p_size <= 2: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(self.pm, nx, ny, 1) - fixture.meta_data.commit() - fixture.generate_mesh() - - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture", 2) - eMesh.save_as("./exodus_files/quad_fixture.e") - - if p_size <= 2: - n = 12 - nx = n - ny = n - - fixture = QuadFixture_4(self.pm, nx, ny, 0) - fixture.meta_data.commit() - fixture.generate_mesh() - - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture no sidesets", 2) - eMesh.save_as("./exodus_files/quad_fixture_no_sidesets.e") - - def fixture_setup(self): - if self.is_setup == 1: - pass - else: - self.fixture_setup_0() - self.fixture_setup_1() - self.is_setup = 1 - - def test_unit_perceptMesh_wedge6_1(self): - eMesh = PerceptMesh() - p_size = eMesh.get_parallel_size() - if p_size == 1: - wedgeFixture = WedgeFixture() - wedgeFixture.createMesh(self.pm, 4, 3, 2, 0, 1, 0, 1, 0, 1, "swept-wedge_0.e") - - def test_perceptMesh_walk_nodes(self): - self.fixture_setup() - p_size = self.pm.size - p_rank = self.pm.rank - if p_size <= 2: - n = 12 - nx = n - ny = n - - sidesets_on = 1 - fixture = QuadFixture_4(self.pm, nx, ny, sidesets_on) - fixture.meta_data.commit() - fixture.generate_mesh() - - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture", 2) - - metaData = eMesh.get_fem_meta_data() - parts = metaData.get_parts() - - nparts = len(parts) - print "Number of parts = ", nparts - - surface_id = 2 - surface_name = "surface_" + str(surface_id) - part = eMesh.get_part(surface_name) - in_surface_selector = Selector(part) - bulkData = eMesh.get_bulk_data() - coordField = eMesh.get_coordinates_field() - - if eMesh.get_spatial_dim() == 2: - buckets_arg = eMesh.edge_rank() - else: - buckets_arg = eMesh.face_rank - buckets = bulkData.buckets(buckets_arg) - sum = 0.0 - - # for bucket in buckets: #FIXME - # if in_surface_selector(bucket) == 1: - # cell_topo_data = PerceptMesh.get_cell_topology(bucket) - # cell_topo(cell_topo_data) #FIXME - # num_elements_in_bucket = bucket.size() - - # for iElement in range(num_elements_in_bucket): - # element = bucket[iElement] #FIXME - # elem_nodes = element.relations(FEMMetaData.NODE_RANK) #FIXME - # num_node = elem_nodes.size() #FIXME - # - # for inode in range(num_node): - # node = elem_nodes[inode].entity() - - def test_mesh_diff(self): - self.fixture_setup() - p_size = parallel_machine_size(self.pm) - - if p_size <= 2: - eMesh_0 = PerceptMesh(2) - eMesh_0.open_read_only("./exodus_files/quad_fixture.e") - eMesh_0.save_as("./exodus_files/quad_fixture_readwrite.e") - - eMesh_1 = PerceptMesh(2) - eMesh_2 = PerceptMesh(2) - eMesh_1.open_read_only("./exodus_files/quad_fixture_readwrite.e") - eMesh_2.open_read_only("./exodus_files/quad_fixture.e") - - if p_size == 1: - add_newlines = False - eMesh_1.print_info("quad fixture", 2, add_newlines) - eMesh_2.print_info("quad fixture", 2, add_newlines) - #Here the unit test compares an expected output string with the output of the print_infos - - diff_msg = "diff report: " - diff = PerceptMesh.mesh_difference(eMesh_1, eMesh_2, diff_msg, True ) - self.assertFalse(diff) - - #metaData_1 = eMesh_1.get_fem_meta_data() - #metaData_2 = eMesh_2.get_fem_meta_data() - bulkData_1 = eMesh_1.get_bulk_data() - #bulkData_2 = eMesh_2.get_bulk_data() - #coordField_1 = eMesh_1.get_coordinates_field() - #coordField_2 = eMesh_2.get_coordinates_field() - - #diff = PerceptMesh.mesh_difference(metaData_1, metaData_2, bulkData_1, bulkData_2, diff_msg, True) - #self.assertFalse(diff) - - buckets = bulkData_1.buckets(FEMMetaData.NODE_RANK) - # for bucket in buckets: #FIXME - # num_elements_in_bucket = bucket.size() - # for iEntity in range(num_elements_in_bucket): - # entity = bucket[iEntity] - # coord = field_data(coordField_1, entity) - # coord[0] = coord[0] + 0.01 - # diff_msg = "diff report after mod: " - # diff = PerceptMesh.mesh_difference(eMesh_1, eMesh_2, diff_msg, True) - # self.assertTrue(diff) - - # new tests of simplified high-level PerceptMesh interface - def test_high_level_interface(self): - self.fixture_setup() - p_size = parallel_machine_size(self.pm) - - if p_size <= 2: - eMesh = PerceptMesh(2) - eMesh.open("./exodus_files/quad_fixture.e") - - vectorDimension = 0 - eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension) - eMesh.commit() - - f_coords = eMesh.get_field("coordinates") - coords_mag_field = eMesh.get_field("coords_mag_field") - - ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 2, 2) - #eval_vec3_print(0.1,0.1,0.1,0.0,ff_coords) - - coords_mag_sf = StringFunction("sqrt(x*x + y*y )" , "coords_mag_sf", 2, 1) - x = 0.123 - y = 0.234 - vv = sqrt(x*x + y*y ) - v1 = eval_func2(x,y,0,coords_mag_sf) - print "vv = ", vv, "== v1 = ", v1 - self.assertEqual(vv, v1) - - coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 2, 1) - - coords_mag_field_function.interpolateFrom(coords_mag_sf) - - eMesh.save_as("./exodus_files/quad_fixture_with_coords_mag.e") - - ff_coords.add_alias("mc") - - sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", 3, 1) - - add_newlines = True - eMesh.print_info("quad fixture", 2, add_newlines) - - self.assertTrue(eMesh.get_spatial_dim() == 2) - self.assertTrue(eMesh.get_number_elements() == 12*12) - self.assertTrue(eMesh.get_number_nodes() == 13*13) - - self.assertTrue(eMesh.get_parallel_size() == p_size) - - self.assertTrue(eMesh.get_bulk_data() != 0) - self.assertTrue(eMesh.get_fem_meta_data() != 0) - - # // entity data setter/getters - node = eMesh.get_node(1) - self.assertTrue(node != 0) - cm1 = eMesh.get_field_data(coords_mag_field, node) - co1 = [0,0] - co1[0] = eMesh.get_field_data(f_coords, node, 0) - co1[1] = eMesh.get_field_data(f_coords, node, 1) - print "cm1= ", cm1, " co1= ", co1 - eMesh.set_field_data(123.0, f_coords, node, 0) - co1[0] = eMesh.get_field_data(f_coords, node, 0) - print " co1= ", co1 - - element = eMesh.get_element(1) - self.assertTrue(element != 0) - - element1 = eMesh.get_entity(eMesh.element_rank(), 1) - self.assertTrue(element == element1) - - #/// find node closest to given point - node = eMesh.get_node(0,0) - self.assertTrue(node != 0) - - #/// find element that contains given point - element = eMesh.get_element(0.01, 0.01) - self.assertTrue(element != 0) - - - - #self.assertFalse(diff) - - # - def test_time_dep_interface(self): - p_size = parallel_machine_size(self.pm) - - if p_size <= 2: - eMesh = PerceptMesh(2) - eMesh.open("./exodus_files/time-dep.e") - eMesh.commit() - - Tnd_field = eMesh.get_field("Tnd") - - # // entity data setter/getters - eMesh.read_database_at_time(0.0) - node = eMesh.get_node(2,2) - self.assertTrue(node != 0) - t0 = eMesh.get_field_data(Tnd_field, node) - self.assertTrue(t0 == 0.0) - eMesh.read_database_at_time(1.0) - t1 = eMesh.get_field_data(Tnd_field, node) - self.assertTrue(t1 == 11.0) - - print "t0= " , t0, " t1= " , t1 - - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(PerceptMeshUnitTests) - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/StringFunctionUnitTests.py b/packages/stk/stk_classic/stk_percept/unit_tests/StringFunctionUnitTests.py deleted file mode 100644 index 26f2966c4db1..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/StringFunctionUnitTests.py +++ /dev/null @@ -1,501 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from math import * -from numpy import * -import unittest -import time -import print_table - -from PerceptMesh import * - -class StringFunctionUnitTests(unittest.TestCase): - - def setUp(self): - self.testpoints = [ [0.1234, -0.5678, 0.9, 0.812], - [0.1234e-3, -0.5678e-5, 0.9e+8, 0.812e-4], - [.101, 102., 10201.0, 0.0122], - [0.003, -100001.1, 44.1, 3.0] - ] - - self.testpoints_fd = [ [0.1234, -0.5678, 0.9, 0.812], - [0.1234e-3, -0.5678e-5, 0.9e-3, 0.812e-4], - [101.0, 102.0, 10.2, 0.0122], - [0.003, .002, -0.0011, 0.0] - ] - - def test_stringFunction_xy_basic(self): - x=1.234 - y=2.345 - z=0.0 - - sf = StringFunction(" x - y ") - - input_array = array([x, y, z]) - - time = 0.0 - output_array = sf.value(input_array, time) - print output_array - - eval_print(x, y, z, time, sf) - - def test_stringFunction_xy_basic_1(self): - sfx = StringFunction("x") - sfy = StringFunction("y") - sfxy = StringFunction("x-y") - - x = 1.234 - y = 5.678 - z = 0.0 - t = 0.0 - xy = x-y - - eval_print(1,2,3,0, sfxy) - vx = eval_func(x, y, z, t, sfx) - print "x = ", x, "vx = ", vx - vy = eval_func(x, y, z, t, sfy) - vxy = eval_func(x, y, z, t, sfxy) - - print "y = ", y, "vy = ", vy - print "xy = ", xy, "vxy = ", vxy - - self.assertEqual(y, vy) - self.assertEqual(xy, vxy) - - def test_stringFunction_xy_basic_2(self): - sftestNA = StringFunction("x", "sftestNA", Dimensions(3), Dimensions(2, 3)) - sftestNA.setDomainDimensions(Dimensions(3)) - sftest = StringFunction("x", "sftestNA", Dimensions(3), Dimensions(2, 3)) - sftest_domain = sftest.getNewDomain() - sftest_codomain = sftest.getNewCodomain() - - sfx = StringFunction("x", "sfx") - - sfy = StringFunction("y") - sfxy = StringFunction("x-y") - - x = 1.234 - y = 5.678 - z = 0.0 - t = 0.0 - xy = x-y - - eval_print(1,2,3,0, sfxy) - vx = eval_func(x,y,z,t, sfx) - print "x = ", x, "vx = ", vx - vy = eval_func(x, y, z, t, sfy) - print "y = ", y, "vy = ", vy - vxy = eval_func(x, y, z, t, sfxy) - print "xy = ", xy, "vxy = ", vxy - - self.assertEqual(x, vx) - self.assertEqual(y, vy) - self.assertEqual(xy, vxy) - - def test_stringFunction_test_alias(self): - sfx = StringFunction("x", "sfx", Dimensions(3), Dimensions(1)) - sfy = StringFunction("y", "sfy", Dimensions(3), Dimensions(1)) - sfxy = StringFunction("x-y", "sfxy", Dimensions(3), Dimensions(1)) - sfembedded = StringFunction("sfxy", "sfembedded", Dimensions(3), Dimensions(1)) - - x = 1.234 - y = 5.678 - z = 0.0 - t = 0.0 - xy = x-y - - eval_print(1,2,3,0, sfxy) - vx = eval_func(x,y,z,t, sfx) - print "x = ", x, "vx = ", vx - vy = eval_func(x, y, z, t, sfy) - print "y = ", y, "vy = ", vy - vxy = eval_func(x, y, z, t, sfxy) - print "xy = ", xy, "vxy = ", vxy - - self.assertEqual(x, vx) - self.assertEqual(y, vy) - self.assertEqual(xy, vxy) - - print "sfembedded = ...", sfembedded - eval_print(1,2,3,0,sfembedded) - print "sfembedded = ", eval_func(x,y,z,t,sfembedded) - - vxy1 = eval_func(x,y,z,t,sfembedded) - sfembedded.add_alias("sfalias") - sftestalias = StringFunction("sfalias", "sftestalias") - vxy2 = eval_func(x,y,z,t,sftestalias) - print "sftestalias = ", vxy2 - - def test_stringFunction_vector_valued(self): - x = 1.234 - y = 5.678 - z = 3.456 - t = 0.0 - - didCatch = 0 - try: - sfv0 = StringFunction("v[0]=x; v[1]=y; v[2]=z; x", "sfv", Dimensions(1,4), Dimensions(1,3)) - eval_vec3_print(1,2,3,0, sfv0) - except: - didCatch = 1 - print "TEST::function::stringFunctionVector: expected to catch this since dom/codomain dimensions should be rank-1" - sfv = StringFunction("v[0]=x*y*z; v[1]=y; v[2]=z; x", "sfv", Dimensions(3), Dimensions(3)) - eval_vec3_print(1.234, 2.345e-3, 3.456e+5, 0.0, sfv) - vec = eval_vec3(x,y,z,t,sfv) - print "x = ", x - print "y = ", y - print "z = ", z - print "val = ", (vec[0]*vec[1]*vec[2]) - - self.assertEqual(vec[0], (x*y*z)) - self.assertEqual(vec[1], (y)) - self.assertEqual(vec[2], (z)) - - def test_stringFunction_constants(self): - x = 1.234 - y = 5.678 - z = 3.456 - t = 0.0 - myC = 4.5678 - - # dummy return value sf_myC, but could be used in table printing, or other pythonic uses - sf_myC = StringFunction(str(myC), "myC", Dimensions(3), Dimensions(1)); - - # alternative - # sf_myC = StringFunction("4.5678", "myC", Dimensions(3), Dimensions(1)); - - # this string function refers to the other through "myC" - sfv = StringFunction("x+myC", "sfv", Dimensions(3), Dimensions(1)) - - #eval_print(x,y,z, 0.0, sfv) - vec = eval_func(x,y,z,t,sfv) - print "x = ", x - print "y = ", y - print "z = ", z - print "constants test val = ", vec, " expected = ", (myC + x) - - self.assertEqual(vec, (myC + x)) - - # more... - myConstants = {"C":1.234,"rho":1.e-5} - sf_myC1 = [] - for cname, cvalue in myConstants.items(): # note: this could become a python function - sf_myC1.append( StringFunction(str(cvalue),cname,Dimensions(3),Dimensions(1)) ) - - sfv1 = StringFunction("x + C*rho", "sfv1", Dimensions(3), Dimensions(1)) - - #eval_print(x,y,z, 0.0, sfv1) - vec = eval_func(x,y,z,t,sfv1) - expected = (x + myConstants["C"]*myConstants["rho"]) - print "constants test val1 = ", vec, " expected = ", expected - - self.assertEqual(vec, expected) - - def test_stringFunction_arithmetic_ops(self): - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - - sfx = StringFunction("x") - sfy = StringFunction("y") - sfxy = StringFunction("x-y") - - sfxy2 = sfx - sfy - xy = x - y - vxy = eval_func(x,y,z,t,sfxy) - vxy2 = eval_func(x,y,z,t,sfxy2) - - sfx1 = StringFunction("x") - sfy2 = StringFunction("y") - vx = eval_func(x,y,z,t, sfx1) - vy = eval_func(x,y,z,t, sfy2) - - print "vxy2 = ", vxy2, " == vxy = ", vxy - print "xy = ", xy, " == vxy = ", vxy - print "x = ", x, " == vx = ", vx - print "y = ", y, " == y = ", vy - - self.assertEqual(x, vx) - self.assertEqual(y, vy) - self.assertEqual(xy, vxy) - self.assertEqual(vxy2, vxy) - - sfxy_minus = sfx - sfy - xy_minus = x - y - vxy_minus = eval_func(x,y,z,t,sfxy_minus) - vxy1_minus = eval_func(x,y,z,t,sfxy_minus) - print "xy_minus = ", xy_minus, " == vxy_minus = ", vxy_minus - print "xy_minus = ", xy_minus, " == vxy1_minus = ", vxy1_minus - - self.assertEqual(xy_minus, vxy_minus) - self.assertEqual(vxy_minus, vxy1_minus) - - sfxy_plus = sfx + sfy - xy_plus = x + y - vxy_plus = eval_func(x,y,z,t,sfxy_plus) - vxy1_plus = eval_func(x,y,z,t,sfxy_plus) - print "xy_plus = ", xy_plus, " == vxy_plus = ", vxy_plus - print "xy_plus = ", xy_plus, " == vxy1_plus = ", vxy1_plus - - self.assertEqual(xy_plus, vxy_plus) - self.assertEqual(vxy_plus, vxy1_plus) - - sfxy_mult = sfx * sfy - xy_mult = x * y - vxy_mult = eval_func(x,y,z,t,sfxy_mult) - vxy1_mult = eval_func(x,y,z,t,sfxy_mult) - print "xy_mult = ", xy_mult, " == vxy_mult = ", vxy_mult - print "xy_mult = ", xy_mult, " == vxy1_mult = ", vxy1_mult - - self.assertEqual(xy_mult, vxy_mult) - self.assertEqual(vxy_mult, vxy1_mult) - - sfxy_div = sfx / sfy - xy_div = x / y - vxy_div = eval_func(x,y,z,t,sfxy_div) - vxy1_div = eval_func(x,y,z,t,sfxy_div) - print "xy_div = ", xy_div, " == vxy_div = ", vxy_div - print "xy_div = ", xy_div, " == vxy1_div = ", vxy1_div - - self.assertEqual(xy_div, vxy_div) - self.assertEqual(vxy_div, vxy1_div) - - def test_stringFunction_derivative(self): - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - - sfxy = StringFunction("x-y") - dsfxy_y = StringFunction("-1") - dy = array([["y"]]) - #input_array = array([x, y, z]) - print "dy= " , dy , " dy.ndim= " , dy.ndim, " dy.dtype= " , dy.dtype, " dy.itemsize= ", dy.itemsize , " dy.size= " , dy.size - #sys.exit(1) - dsfxy_y_1 = sfxy.derivative_test(dy) - - dvxy = eval_func(x,y,z,t,dsfxy_y_1) - dvxy1 = eval_func(x,y,z,t,dsfxy_y) - print "dvxy = ", dvxy, " == dvxy1 = ", dvxy1 - print "-1.0 = -1 == dvxy = ", dvxy - - self.assertEqual(dvxy, dvxy1) - self.assertEqual(-1, dvxy) - print dsfxy_y_1 - - def test_stringFunction_derivative_1(self): - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - - print "here 1" - eps = 1.e-6 - eps_loc = eps*(fabs(x)+fabs(y)+fabs(z)+fabs(t))/4.0 - - sfxy = StringFunction("x-y") - dsfxy_grad = StringFunction("v[0]=1; v[1]= -1; v[2]=0", "test", Dimensions(3), Dimensions(3)) - dxyz = array([["x"],["y"],["z"]]) #new simpler user-interface - #dxyz = array([["x","y","z"]]) #new simpler user-interface - print "dxyz.shape= " , dxyz.shape - - grad = array(["1","-1","0"]) - sfxy.set_gradient_strings(grad) - dsfxy_grad_1 = sfxy.derivative_test(dxyz) - dsfxy_grad_fd = sfxy.derivative_test_fd(dxyz, eps_loc) - dsfxy_grad_2 = sfxy.derivative(dxyz) - - dvxy1 = eval_vec3(x,y,z,t,dsfxy_grad_1) - dvxy_fd = eval_vec3(x,y,z,t,dsfxy_grad_fd) - dvxy2 = eval_vec3(x,y,z,t,dsfxy_grad_2) - dvxy = eval_vec3(x,y,z,y,dsfxy_grad) - - i = 0 - while i < 3: - self.assertEqual(dvxy[i], dvxy1[i]) - self.assertEqual(dvxy[i], dvxy2[i]) - self.assertAlmostEqual(dvxy[i], dvxy_fd[i]) - i = i + 1 - - self.assertEqual(dvxy[0], 1.0) - self.assertEqual(dvxy[1], -1.0) - - def test_stringFunction_derivative_2(self): - for xyzt in self.testpoints_fd: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - eps = 1.e-10 - eps_loc = eps*(fabs(x)+fabs(y)+fabs(z)+fabs(t))/4.0 - sf = StringFunction(" sin(x*y*z*z) " ) - grad = array(["y*z*z*cos(x*y*z*z)", "x*z*z*cos(x*y*z*z)", "2*x*y*z*cos(x*y*z*z)"]) - gradv = "v[0]="+grad[0]+"; v[1]="+grad[1]+" ; v[2]="+grad[2]+";" - dsf_grad = StringFunction(gradv, "test", Dimensions(3), Dimensions(3)) - #dxyz = array([["x","y","z"]]) - dxyz = array([["x"],["y"],["z"]]) #new simpler user-interface - sf.set_gradient_strings(grad) - dsf_grad_fd = sf.derivative_test_fd(dxyz, eps_loc) - dsf_grad_2 = sf.derivative(dxyz) - - dv_fd = eval_vec3(x,y,z,t,dsf_grad_fd) - dv2 = eval_vec3(x,y,z,t,dsf_grad_2) - dv = eval_vec3(x,y,z,t,dsf_grad) - - i = 0 - while i < 3: - print "dv2[i] = ", dv2[i], " == dv[i] = ", dv[i] - self.assertEqual(dv[i], dv2[i]) - if fabs(dv[i]-dv_fd[i]) > 0.5*(fabs(dv_fd[i])+fabs(dv[i]))*1.e-6: - print "\n i = ", i, "x= ", x, "y= ", y, "z= ", z, "expected= ", dv[i], "actual = ", dv_fd[i] - self.assertAlmostEqual(dv[i], dv_fd[i], delta = 1.e-1) - i = i + 1 - - def test_stringFunction_multiplePoints(self): - points = zeros(shape=(4,3)) - output = zeros(shape=(4,1)) - output_expect = zeros(shape=(4,1)) - - sf1 = StringFunction("x+y*z") - i = 0 - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - points[i][0] = x - points[i][1] = y - points[i][2] = z - vx = eval_func(x,y,z,t,sf1) - output_expect[i][0] = vx - print "x+y*z = ", x+y*z, " == vx = ", vx - self.assertEqual((x+y*z), vx) - i = i + 1 - - sf2 = StringFunction(str(sf1.getFunctionString()), "sf2", Dimensions(3), Dimensions(1)) - output = sf2.value(points, output, 0.0) - - i = 0 - while i < 4: - print "output_expect(i, 0) = ", output_expect[i][0] , " == output(i, 0) = ", output[i][0] - self.assertEqual(output_expect[i][0], output[i][0]) - i = i + 1 - - def test_stringFunction_expressions(self): - x = 0.1234 - y = -0.5678 - z = 0.9 - t = 0.812 - global PI - global E - PI = pi - E = e - - sf1 = StringFunction("x+y") - ve = x + y - v = eval_func(x,y,z,t,sf1) - print "x = ", x, "y = ", y, "v = ", v, "ve = ", ve - - EXPR_TO_TEST1 = "(exp(x)+log(x)+log10(x)+pow(x,y)+sqrt(x)+erfc(x)+erf(x)+acos(x)+asin(x)+atan(x)+atan2(x,z)+cos(x)+cosh(x)+sin(x)+sinh(x)+tan(x)+tanh(x)+abs(y)+fabs(y))" - EXPR_TO_TEST2 = "(x/y*z-t+(4*x)-(1.23e-3/z))" - EXPR_TO_TEST3 = "(4 % 2)" - EXPR_TO_TEST4 = "(-z)" - EXPR_TO_TEST5 = "(exp(E))" - EXPR_TO_TEST6 = "(PI)" - - def DO_SF_STKUNIT_UNIT_TEST(expr,x,y,z,t): - - sf = StringFunction(expr) - v_loc = eval_func(x,y,z,t,sf) - if isinf(v_loc): #this is kind of wierd but Python doesn't handle infinite values like C++ and otherwise generates OverflowError - ve_loc = v_loc - else: - ve_loc = eval(expr) - print "ve_loc = ", ve_loc, " == v_loc = ", v_loc - self.assertEqual(ve_loc, v_loc) - - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST1,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST2,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST3,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST4,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST5,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST6,x,y,z,t) - - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST1,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST2,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST3,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST4,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST5,x,y,z,t) - DO_SF_STKUNIT_UNIT_TEST(EXPR_TO_TEST6,x,y,z,t) - - def test_stringFunction_timing(self): - numIt = 1024 - EXPR_TO_TEST1A = "(exp(x)+log(x)+log10(x)+pow(x,y)+sqrt(x)+erfc(x)+erf(x)+acos(x)+asin(x))" - EXPR_TO_TEST1B = "(atan(x)+atan2(x,z)+cos(x)+cosh(x)+sin(x)+sinh(x)+tan(x)+tanh(x)+abs(y)+fabs(y))" - EXPR_TO_TEST2 = "(x/y*z-t+(4*x)-(1.23e-3/z))" - EXPR_TO_TEST8 = "(sin(x+y))" - - def DO_SF_TIMING_TEST_CPP(expr, numIt, x, y, z, t): - val = 0.0 - for it in range(numIt): - try: - val = val + eval(expr) - except: - pass - - def DO_SF_TIMING_TEST_STRING(expr, numIt, x, y, z, t): - sf = StringFunction(expr) - val = 0.0 - for it in range(numIt): - try: - val = val + eval_func(x,y,z,t,sf) - except: - pass - - - def TIME_IT1(expr, numIt, x, y, z, t): - t_cpp = time.time() - DO_SF_TIMING_TEST_CPP(expr, numIt, x, y, z, t) - t_cpp = time.time() - t_cpp - t_string = time.time() - DO_SF_TIMING_TEST_STRING(expr, numIt, x, y, z, t) - t_string = time.time() - t_string - ratio = t_string/t_cpp - time_it = [expr, t_cpp, t_string, ratio] - return time_it - - print "" - i = 0 - for xyzt in self.testpoints: - x = xyzt[0] - y = xyzt[1] - z = xyzt[2] - t = xyzt[3] - - print "\n Timings for ", numIt, " iterations for point #", i, " x,y,z,t= ", x, y, z, t, " \n" - headers = ["expression", "cpp time", "string time", "ratio"] - - t1 = TIME_IT1(EXPR_TO_TEST1A, numIt, x, y, z, t) - t2 = TIME_IT1(EXPR_TO_TEST1B, numIt, x, y, z, t) - t3 = TIME_IT1(EXPR_TO_TEST2, numIt, x, y, z, t) - t4 = TIME_IT1(EXPR_TO_TEST8, numIt, x, y, z, t) - - table = [headers, t1, t2, t3, t4] - out = sys.stdout - print_table.print_table(out, table) - i = i + 1 - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(StringFunctionUnitTests) - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UniformRefinerUnitTests.py b/packages/stk/stk_classic/stk_percept/unit_tests/UniformRefinerUnitTests.py deleted file mode 100644 index 35555024659f..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UniformRefinerUnitTests.py +++ /dev/null @@ -1,916 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -from PerceptMesh import * -import unittest -from numpy import * - -input_files_loc = "./input_files_" - -def fixture_setup_0(): - eMesh = PerceptMesh() - p_size = eMesh.get_parallel_size() - gmesh_spec = "4x4x"+str(4*p_size)+"|bbox:0,0,0,1,1,1" - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - eMesh.commit() - eMesh.save_as("hex_fixture.e") - - eMesh = PerceptMesh() - eMesh.open("exodus_files/"+input_files_loc+"hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_TET4_24, proc_rank_field) - eMesh.commit() - - breaker.doBreak() - eMesh.save_as("tet_fixture.e") - -def fixture_setup_1(): - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm, nx, ny, True) - fixture.meta_data.commit() - fixture.generate_mesh() - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture", 2) - eMesh.save_as("quad_fixture.e") - - fixture = QuadFixture_4(pm, nx, ny, False) - fixture.meta_data.commit() - fixture.generate_mesh() - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture no sidesets", 2) - eMesh.save_as("quad_fixture_no_sidesets.e") - -is_setup = False -def fixture_setup(): - if is_setup == True: - pass - else: - fixture_setup_0() - fixture_setup_1() - is_setup == True - - - -class UniformRefinerUnitTests(unittest.TestCase): - - def test_break_quad_to_quad_sierra_1(self): - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 2: - n = 2 - nx = 1 - ny = n - createEdgeSets = False - fixture = QuadFixture_4(pm,nx,ny,createEdgeSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD4_4, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - breaker.setRemoveOldElements(False) - breaker.doBreak() - eMesh.dump_elements_compact() - - def test_break_tri_to_tri_sierra_1_test(self): - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 2: - n = 2 - nx = n - ny = n - createEdgeSets = False - fixture = QuadFixture_4(pm,nx,ny,createEdgeSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension) - breaker = Refiner(eMesh, TRI3_TRI3_4, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - breaker.setRemoveOldElements(False) - breaker.doBreak() - eMesh.dump_elements_compact() - - def test_break_quad_to_quad_sierra(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm, nx, ny, True) - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, False) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD4_4_SIERRA, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - eMesh.print_info("quad mesh") - breaker.doBreak() - - def test_hex8_hex8_8_1(self): - fixture_setup() - eMesh = PerceptMesh() - p_size = eMesh.get_parallel_size() - gmesh_spec = "4x4x"+str(4*p_size)+"|bbox:0,0,0,1,1,1" - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX8_8, proc_rank_field) - eMesh.commit() - breaker.doBreak - - def test_wedge6_1(self): - fixture_setup() - eMesh = PerceptMesh() - p_size = eMesh.get_parallel_size() - if p_size == 1: - wedgeFixture = WedgeFixture() - wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1, "swept_wedge_0.e") - - def test_beam_enrich(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 1: - - eMesh = PerceptMesh() - eMesh.open("exodus_files/beam.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.save_as("beam_enrich_0.e") - breaker = Refiner(eMesh, BEAM2_BEAM3_1, proc_rank_field) - eMesh.commit() - breaker.setIgnoreSideSets(True) - breaker.doBreak() - - eMesh.save_as("beam_enrich.e") - - def test_beam_refine(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 1: - mesh = BeamFixture(pm, False) - mesh.m_metaData.commit() - mesh.populate() - - isCommited = True - em1 = PerceptMesh(mesh.m_metaData, mesh.m_bulkData, isCommited) - em1.save_as("beam_0.e") - - eMesh = PerceptMesh() - eMesh.open("beam_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, BEAM2_BEAM2_2, proc_rank_field) - eMesh.commit() - breaker.setIgnoreSideSets(True) - breaker.doBreak() - - def test_break_quad_to_tri_6(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_TRI3_6, proc_rank_field) - eMesh.commit() - eMesh.print_info("quad mesh") - breaker.setIgnoreSideSets(True) - breaker.setRemoveOldElements(False) - breaker.doBreak() - eMesh.save_as("square_quad4_out.e") - - def test_break_quad_to_tri_4(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_TRI3_4, proc_rank_field) - eMesh.commit() - eMesh.print_info("quad mesh") - breaker.setIgnoreSideSets(True) - breaker.setRemoveOldElements(False) - breaker.doBreak() - eMesh.save_as("square_quad4_tri3_4_out.e") - - def test_break_quad_to_quad(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture_no_sidesets.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD4_4, proc_rank_field) - eMesh.commit() - eMesh.print_info("quad mesh") - breaker.setIgnoreSideSets(True) - breaker.doBreak() - eMesh.save_as("square_quad4_ref_out.e") - - def test_break_quad_to_quad_sierra_unit1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD4_4_SIERRA, proc_rank_field) - eMesh.commit() - eMesh.print_info("quad mesh") - breaker.doBreak() - eMesh.save_as("square_quad4_sierra_ref_out.e") - - def test_break_quad_to_quad_sierra_sidesets(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 2: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD4_4_SIERRA, proc_rank_field) - eMesh.commit() - eMesh.print_info("after refinement break_quad_to_quad_sierra_sidesets") - breaker.doBreak() - eMesh.save_as("quad_sidesets_sierra_out.e") - - def test_break_hex8_tet4_24_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - eMesh = PerceptMesh(3) - gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size) - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_TET4_24, proc_rank_field) - eMesh.commit() - eMesh.print_info() - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex_tet_24_cube1x1x1.e") - - def test_hex8_tet4_6_12_1(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size) - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_TET4_6_12, proc_rank_field) - eMesh.commit() - eMesh.print_info() - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex_tet_6_12_cube1x1x1.e") - - def test_hex8_tet4_6_12_2(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - eMesh = PerceptMesh(3) - eMesh.open("hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_TET4_6_12, proc_rank_field) - eMesh.commit() - eMesh.print_info() - breaker.doBreak() - eMesh.save_as("hex_tet_6_12_1.e") - - def test_quad4_quad4_test_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm,nx,ny,True) - fixture.meta_data.commit() - fixture.generate_mesh() - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data) - eMesh.print_info("quad fixture") - eMesh.save_as("quad_fixture_test_1.e") - - def test_break_quad_to_quad_sierra_1_unit1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - doGenSideSets = True - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm,nx,ny,doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - eMesh.commit() - fixture.generate_mesh() - eMesh.save_as("quad_fixture_0.e") - eMesh.close() - - i = 0 - while i < 2: - print "\n\n\n ================ tmp Refine Pass = ", i - eMesh1 = PerceptMesh(2) - eMesh1.open("quad_fixture_" + str(i) + ".e") - scalarDimension = 0 - proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh1, QUAD4_QUAD4_4_SIERRA, proc_rank_field) - eMesh1.commit() - breaker.doBreak() - eMesh1.save_as("quad_fixture_" + str(i+1) + ".e") - eMesh1.close() - i = i + 1 - - def test_break_quad_to_quad_sierra_2(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - doGenSideSets = True - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm,nx,ny,doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - eMesh.commit() - fixture.generate_mesh() - eMesh.save_as("quad_fixture_mbreak_0.e") - eMesh.close() - - eMesh1 = PerceptMesh(2) - eMesh1.open("quad_fixture_mbreak_0.e") - scalarDimension = 0 - proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh1, QUAD4_QUAD4_4_SIERRA, proc_rank_field) - eMesh1.commit() - - i = 0 - while i < 2: - print "\n\n\n ================ tmp Refine Pass = ", i - breaker.doBreak() - eMesh1.save_as("quad_fixture_mbreak_" + str(i) + ".e") - i = i + 1 - - def test_break_quad4_to_quad9(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - doGenSideSets = True - fixture = QuadFixture_4(pm,nx,ny,doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD9_1, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - eMesh.save_as("quad_fixture_quad9_0.e") - breaker.doBreak() - eMesh.save_as("quad_fixture_quad9_1.e") - - def test_break_quad4_to_quad9(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - doGenSideSets = True - fixture = QuadFixture_4(pm,nx,ny,doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD8_1, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - eMesh.save_as("quad_fixture_quad8_0.e") - breaker.doBreak() - eMesh.save_as("quad_fixture_quad8_1.e") - eMesh.save_as("quad_fixture_quad8_quad8_0.e") - - def test_quad8_to_quad8(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture_quad8_quad8_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD8_QUAD8_4, proc_rank_field) - eMesh.commit() - breaker.setIgnoreSideSets(False) - breaker.doBreak() - eMesh.save_as("quad_fixture_quad8_quad8_1.e") - - def test_break_quad4_to_quad9_to_quad9_0(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - doGenSideSets = False - if p_size <= 1: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm,nx,ny,doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD9_1, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - breaker.doBreak() - eMesh.save_as("quad_1x1x_quad9_quad9_0.e") - - em1 = PerceptMesh(2) - em1.open("quad_1x1x_quad9_quad9_0.e") - proc_rank_field = em1.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(em1, QUAD9_QUAD9_4, proc_rank_field) - em1.commit() - breaker.setIgnoreSideSets(True) - breaker.doBreak() - em1.save_as("quad_1x1x_quad9_quad9_1.e") - - def test_break_quad4_to_quad9_to_quad9(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - doGenSideSets = True - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_4(pm, nx, ny, doGenSideSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, QUAD4_QUAD9_1, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - breaker.doBreak() - eMesh.save_as("quad_fixture_quad9_quad9_0.e") - - em1 = PerceptMesh(2) - em1.open("quad_fixture_quad9_quad9_0.e") - scalarDimension = 0 - proc_rank_field = em1.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(em1, QUAD9_QUAD9_4, proc_rank_field) - em1.commit() - breaker.doBreak() - em1.save_as("quad_fixture_quad9_quad9_1.e") - - def test_break_tri_to_tri_sierra_0(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - fixture = QuadFixture_3(pm, nx, ny, True) - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, False) - eMesh.commit() - fixture.generate_mesh() - eMesh.print_info("tri mesh") - eMesh.save_as("quad_fixture_tri3.e") - - def test_break_tri_to_tri_sierra_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - n = 12 - nx = n - ny = n - createEdgeSets = True - fixture = QuadFixture_3(pm, nx, ny, createEdgeSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.add_field("proc_rank_ede", eMesh.edge_rank(), scalarDimension) - breaker = Refiner(eMesh, TRI3_TRI3_4, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - eMesh.print_info("tri mesh") - eMesh.save_as("quad_fixture_tri3_0.e") - breaker.doBreak() - eMesh.print_info("tri mesh refined") - eMesh.save_as("quad_fixture_tri3_1.e") - - def test_break_tri3_to_tri6_sierra(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - - print p_size, "++++++++++++++++++++" - for i in range(100): - print "-------------------" - if p_size <= 3: - n = 12 - nx = n - ny = n - createEdgeSets = True - fixture = QuadFixture_3(pm, nx, ny, createEdgeSets) - isCommited = False - eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.add_field("proc_rank_ede", eMesh.edge_rank(), scalarDimension) - breaker = Refiner(eMesh, TRI3_TRI6_1, proc_rank_field) - eMesh.commit() - fixture.generate_mesh() - eMesh.print_info("tri mesh tri6") - eMesh.save_as("quad_fixture_tri3_tri6_0.e") - breaker.doBreak() - eMesh.print_info("tri mesh enriched") - eMesh.save_as("quad_fixture_tri6_tri6_0.e") - eMesh.save_as("quad_fixture_tri3_tri6_1.e") - - def test_break_tri3_to_tri6_to_tri6_sierra(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size <= 3: - eMesh = PerceptMesh(2) - eMesh.open("quad_fixture_tri6_tri6_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - eMesh.add_field("proc_rank_ede", eMesh.edge_rank(), scalarDimension) - breaker = Refiner(eMesh, TRI6_TRI6_4, proc_rank_field) - eMesh.commit() - eMesh.print_info("tri mesh tri6") - eMesh.save_as("quad_fixture_tri6_tri6_0.e") - breaker.doBreak() - eMesh.print_info("tri mesh refined") - eMesh.save_as("quad_fixture_tri6_tri6_1.e") - - def test_break_tet4_tet4_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open_read_only("tet_fixture.e") - eMesh.save_as("tet_from_hex_fixture_0.e") - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("tet_from_hex_fixture_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, TET4_TET4_8, proc_rank_field) - eMesh.commit() - eMesh.print_info("tet mesh") - breaker.doBreak() - eMesh.save_as("tet4_refined_1.e") - breaker.doBreak() - eMesh.save_as("tet4_refined_2.e") - - def test_break_tet4_tet10_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open_read_only("tet_fixture.e") - eMesh.save_as("tet_from_hex_fixture_0.e") - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("tet_from_hex_fixture_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, TET4_TET10_1, proc_rank_field) - eMesh.commit() - eMesh.print_info("tet mesh") - breaker.doBreak() - eMesh.save_as("tet10_1.e") - - def test_break_tet4_tet10_tet10_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("tet_from_hex_fixture_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, TET4_TET10_1, proc_rank_field) - eMesh.commit() - eMesh.print_info("tet mesh") - breaker.doBreak() - eMesh.save_as("tet10_1.e") - eMesh.print_info("tet10_1") - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("tet10_1.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, TET10_TET10_8, proc_rank_field) - eMesh.commit() - breaker.doBreak() - eMesh.save_as("tet10_tet10_1.e") - - def test_hex8_hex8_8_1_unit1(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size) - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX8_8, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex_hex_cube1x1x" + str(p_size) + "-orig.e") - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as( "hex_hex_cube1x1x" + str(p_size)+".e") - - def test_hex8_hex8_8_2_unit1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX8_8, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex8_0.e") - breaker.doBreak() - eMesh.save_as("hex8_1.e") - breaker.doBreak() - eMesh.save_as("hex8_2.e") - - def test_hex8_hex27_1_2(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX27_1, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex27_0.e") - breaker.doBreak() - eMesh.save_as("hex27_1.e") - - def test_hex08_hex20_1_1(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size) - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX20_1, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex8_hex_20_cube1x1x"+str(p_size) + "-orig.e") - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex8_hex20_cube1x1x"+str(p_size) + ".e") - eMesh.save_as("hex20_hex20_cube1x1x"+str(p_size) + "_0.e") - - def test_hex08_hex20_1_2(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX20_1, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex20_0.e") - breaker.doBreak() - eMesh.save_as("hex20_1.e") - eMesh.save_as("hex20_hex20_0.e") - - def test_hex20_hex20_1(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - if p_size <= 3: - eMesh.open("hex20_hex20_cube1x1x"+str(p_size) + "_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX20_HEX20_8, proc_rank_field) - eMesh.commit() - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex20_hex20_cube1x1x" + str(p_size) + "_1.e") - - def test_hex20_hex20_1_2(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex20_hex20_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX20_HEX20_8, proc_rank_field) - eMesh.commit() - eMesh.save_as("hex20_hex20_0.e") - breaker.doBreak() - eMesh.save_as("hex20_hex20_1.e") - - def test_hex27_hex27_0(self): - fixture_setup() - scalarDimension = 0 - eMesh = PerceptMesh() - p_size = eMesh.get_parallel_size() - gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size) - eMesh.new_mesh(GMeshSpec(gmesh_spec)) - - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX27_1, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex27_hex27_cube1x1x" + str(p_size) + "-orig.e") - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex27_hex27_cube1x1x" + str(p_size) + "_0.e") - - em1 = PerceptMesh(3) - p_size = em1.get_parallel_size() - em1.open("hex27_hex27_cube1x1x" + str(p_size) + "_0.e") - proc_rank_field = em1.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(em1, HEX27_HEX27_8, proc_rank_field) - em1.commit() - breaker.setIgnoreSideSets(True) - breaker.setRemoveOldElements(True) - breaker.doBreak() - em1.save_as("hex27_hex27_cube1x1x" + str(p_size) + "_1.e") - - def test_hex27_hex27_1(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex_fixture.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX8_HEX27_1, proc_rank_field) - eMesh.commit() - eMesh.print_info() - eMesh.save_as("hex8_hex27_0.e") - breaker.doBreak() - eMesh.save_as("hex8_27_1.e") - if p_size == 1 or p_size == 3: - eMesh = PerceptMesh(3) - eMesh.open("hex8_27_1.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, HEX27_HEX27_8, proc_rank_field) - eMesh.commit() - breaker.setRemoveOldElements(True) - breaker.doBreak() - eMesh.save_as("hex8_hex27_hex27_1.e") - - def test_wedge6_2(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - if p_size == 1: - wedgeFixture = WedgeFixture() - wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1, "swept_wedge_0.e") - eMesh.open("swept_wedge_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE6_WEDGE6_8, proc_rank_field) - eMesh.commit() - breaker.doBreak() - eMesh.save_as("swept-wedge_1.e") - - def test_wedge6_enrich_1(self): - fixture_setup() - eMesh = PerceptMesh(3) - p_size = eMesh.get_parallel_size() - if p_size == 1: - wedgeFixture = WedgeFixture() - wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1, "swept_wedge_enrich_0.e") - eMesh.open("swept_wedge_enrich_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE6_WEDGE15_1, proc_rank_field) - eMesh.commit() - breaker.doBreak() - eMesh.save_as("swept-wedge_enrich_1.e") - eMesh.save_as("swept-wedge_enrich_refine_0.e") - - def test_wedge6_enrich_refine(self): - fixture_setup() - p_size = parallel_machine_size(MPI.COMM_WORLD) - if p_size == 1: - eMesh = PerceptMesh(3) - wedgeFixture = WedgeFixture() - wedgeFixture.createMesh(MPI.COMM_WORLD, 4,2,2,0,1,0,1,0,1, "tmp-swept-wedge_enrich_0.e") - eMesh.open("tmp-swept-wedge_enrich_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE6_WEDGE15_1, proc_rank_field) - eMesh.commit() - breaker.doBreak() - eMesh.save_as("swept-wedge_2_enrich_refine_0.e") - if p_size == 1: - eMesh = PerceptMesh(3) - eMesh.open("swept-wedge_2_enrich_refine_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE15_WEDGE15_8, proc_rank_field) - eMesh.commit() - breaker.setIgnoreSideSets(True) - breaker.doBreak() - eMesh.save_as("swept-wedge_2_enrich_refine_1.e") - - def test_heterogeneous_mesh(self): - fixture_setup() - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(MPI.COMM_WORLD) - if p_size <= 1: - mesh = HeterogeneousFixture(MPI.COMM_WORLD, False) - #put_io_part_attribute(mesh.m_block_hex) - #put_io_part_attribute(mesh.m_block_wedge) - #put_io_part_attribute(mesh.m_block_tet) - mesh.m_metaData.commit() - mesh.populate() - isCommited = True - em1 = PerceptMesh(mesh.m_metaData, mesh.m_bulkData, isCommited) - em1.save_as("heterogeneous_0.e") - em1.close() - - eMesh = PerceptMesh(3) - eMesh.open("heterogeneous_0.e") - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - #INCOMPLETE - - def test_wedge6_wedge18_enrich(self): - pm = MPI.COMM_WORLD - p_size = parallel_machine_size(pm) - if p_size == 1: - wedgeFixture = WedgeFixture() - bulk = wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1,"") - eMesh = PerceptMesh(wedgeFixture.getMetaData(), bulk, False) - scalarDimension = 0 - proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension) - breaker = Refiner(eMesh, WEDGE6_WEDGE18_1, proc_rank_field) - eMesh.commit() - wedgeFixture.createBulkAfterMetaCommit(MPI.COMM_WORLD) - breaker.doBreak() - - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(UniformRefinerUnitTests) - unittest.TextTestRunner(verbosity=2).run(suite) - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestFieldFunction.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestFieldFunction.cpp deleted file mode 100644 index 1a4ad63737a3..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestFieldFunction.cpp +++ /dev/null @@ -1,673 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace percept { -namespace unit_tests { - -#define EXTRA_PRINT 0 - - static int print_infoLevel = 0; - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, fieldFunction_demo_1_0_0) -{ - EXCEPTWATCH; - - // start_demo_fieldFunction_1 - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - eMesh.commit(); - eMesh.print_info("fieldFunction_demo_1_0_0", print_infoLevel); - - // the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - // create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, 3, 3); - - // here we could evaluate this field function - double x=0.123, y=0.234, z=0.345, time=0.0; - eval_vec3_print(x, y, z, time, ff_coords); - // end_demo - -} - -STKUNIT_UNIT_TEST(function, fieldFunction_read_print) -{ - EXCEPTWATCH; - // just reads a mesh file and prints some info about the meta data - - bool print_info = false; - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh_read_only(GMeshSpec(config_mesh)); - - mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - - const std::vector< stk_classic::mesh::Part * > & parts = metaData.get_parts(); - - unsigned nparts = parts.size(); - if (print_info) std::cout << "Number of parts = " << nparts << std::endl; - - // here's where we can add parts - // ... - // ... then we would have to commit the metaData - - const stk_classic::mesh::FieldVector & fields = metaData.get_fields(); - unsigned nfields = fields.size(); - if (print_info) - { - std::cout << "Number of fields = " << fields.size() << std::endl; - for (unsigned ifld = 0; ifld < nfields; ifld++) - { - stk_classic::mesh::FieldBase *field = fields[ifld]; - if (print_info) std::cout << "Field[" << ifld << "]= " << field->name() << " rank= " << field->rank() << std::endl; - if (print_info) std::cout << *field << std::endl; - unsigned nfr = field->restrictions().size(); - if (print_info) std::cout << " number of field restrictions= " << nfr << std::endl; - for (unsigned ifr = 0; ifr < nfr; ifr++) - { - const stk_classic::mesh::FieldRestriction& fr = field->restrictions()[ifr]; - mesh::Part& frpart = metaData.get_part(fr.part_ordinal()); - if (print_info) std::cout << " field restriction " << ifr << " stride[0] = " << fr.dimension() << - " type= " << fr.entity_rank() << " ord= " << fr.part_ordinal() << - " which corresponds to Part= " << frpart.name() << std::endl; - } - } - } -} - - -//============================================================================= -//============================================================================= -//============================================================================= - -#define EXPR_COORD_MAG (sqrt(x*x + y*y + z*z)) - -class CheckCoordMag : public GenericFunction -{ -public: - bool m_error; - std::string m_name; - CheckCoordMag(std::string name="") : m_error(false), m_name(name) {} - virtual void operator()(MDArray& domain, MDArray& codomain, double time_value_optional=0.0) - { - double x = domain(0); - double y = domain(1); - double z = domain(2); - double v = EXPR_COORD_MAG; - double cmag_field_node = codomain(0); - //STKUNIT_EXPECT_DOUBLE_EQ(v, cmag_field_node); - if (fabs(v-cmag_field_node) > 1.e-6) - { - std::cout << "CheckCoordMag:: " << m_name << - " v= " << v << " x= " << x << " y= " << y << " z= "<< z << " cmag_field_node= " << cmag_field_node << std::endl; - Util::pause(true, "cmag_field_node"); - STKUNIT_ASSERT_NEAR(v, cmag_field_node, 1.e-9); - m_error = true; - } - } - -}; - -//============================================================================= -//============================================================================= -//============================================================================= -STKUNIT_UNIT_TEST(function, fieldFunction_demo_1) -{ - EXCEPTWATCH; - - - { - stk_classic::io::util::Gmesh_STKmesh_Fixture gms(MPI_COMM_WORLD, "3x3x3|bbox:0,0,0,1,1,1"); - std::cout << "gms= " << &gms << std::endl; - } - - std::cout << "gms= end" << std::endl; - - // start_demo_fieldFunction_1 - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - eMesh.commit(); - - // the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - // create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, 3, 3); - - // here we could evaluate this field function - double x=0.123, y=0.234, z=0.345, time=0.0; - eval_vec3_print(x, y, z, time, ff_coords); - // end_demo - -} - -STKUNIT_UNIT_TEST(function, fieldFunction_demo_2) -{ - EXCEPTWATCH; - - // start_demo_fieldFunction_2 - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1")); // create a 3x3x3 hex mesh in the unit cube - - // add a new field - // NOTE: we have to create the fields here before committing the mesh - int vectorDimension = 0; // signifies a scalar field - eMesh.add_field("coords_mag_field", mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - - // the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - // get the new field created by PerceptMesh - stk_classic::mesh::FieldBase* coords_mag_field = eMesh.get_field("coords_mag_field"); - - // create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, 3, 3); - eval_vec3_print(0.1,0.1,0.1,0.0, ff_coords); - - // create a StringFunction to define the magnitude of the coordinates - StringFunction coords_mag_sf( "sqrt(x*x + y*y + z*z)" , Name("coords_mag_sf"), 3, 1); - double x=0.123, y=0.234, z=0.345; - double vv = std::sqrt(x*x + y*y + z*z); // evaluate the expression in C++ - double v1 = eval(x, y, z, 0, coords_mag_sf); // evaluate the analytic expression - STKUNIT_ASSERT_NEAR(vv, v1, 1.e-9); // the two results should be the same - - // Interpolate the analytic field defined by "coords_mag_sf" to the field we created to hold the coordinate magnitude field - // 1. create a field function to represent the new coordinate magnitude field, and interpolate the string function to its nodes - FieldFunction coords_mag_field_function("coords_mag_field_function", coords_mag_field, eMesh, 3, 1); - - coords_mag_field_function.interpolateFrom(coords_mag_sf); - - // We can now write the model with the new coordinates magnitude field to an Exodus file - eMesh.save_as("./cube_hex8_withCoordMag_out.e"); - // end_demo - - // start_demo_fieldFunction_3 - - // tell Percept that we want to refer to the ff_coords FieldFunction by a simple alias "mc" - ff_coords.add_alias("mc"); - - // define a new StringFunction that does the same thing as coords_mag_sf, evaluates the coordinate magnitudes - StringFunction sfcm("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", Name("sfcm"), 3, 1); - // end_demo - -} - -STKUNIT_UNIT_TEST(function, fieldFunction_readMesh_createField_interpolateFrom) -{ - EXCEPTWATCH; - // more i/o; adding a field; writing the resulting mesh; creating a FieldFunction, invoking interpolateFrom - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - int vectorDimension = 0; // signifies a scalar field - eMesh.add_field("coords_mag_field", mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - - unsigned p_rank = eMesh.get_bulk_data()->parallel_rank(); - //unsigned p_size = eMesh.get_bulk_data()->parallel_size(); - Util::setRank(p_rank); - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - /// get the new field created by readModelCreateOptionalFields() - stk_classic::mesh::FieldBase* coords_mag_field = eMesh.get_field("coords_mag_field"); - VERIFY_OP_ON(coords_mag_field, !=, 0, "TEST::function::fieldFunction_readMesh_createField_interpolateFrom: null coords_mag_field"); - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, 3, 3, FieldFunction::SIMPLE_SEARCH ); - - /// here we could evaluate this field function - if (0) - { - if (p_rank == 0) - { - std::cout << "TEST::function::fieldFunction_readMesh_createField_interpolateFrom eval ff_coords=" << std::endl; - eval_vec3_print(0.1, 0.2, 0.3, 0.0, ff_coords); - } - } - - StringFunction coords_mag_sf( EXPAND_AND_QUOTE(EXPR_COORD_MAG) , Name("coords_mag_sf"), 3, 1); - - /// create a field function to represent the new coordinate magnitude field, and interpolate the string function to its nodes - FieldFunction coords_mag_field_function("coords_mag_field_function", coords_mag_field, eMesh, 3, 3, FieldFunction::SIMPLE_SEARCH ); - coords_mag_field_function.interpolateFrom(coords_mag_sf); - - /// check that the coordinates mag field is set correctly - { - EXCEPTWATCH; - CheckCoordMag checkCoordMag; - //if (!p_rank) std::cout << "checkCoordMag..." << std::endl; - eMesh.nodalOpLoop(checkCoordMag, coords_mag_field); - //if (!p_rank) std::cout << "checkCoordMag...done" << std::endl; - STKUNIT_EXPECT_FALSE(checkCoordMag.m_error); - } - - try { - ff_coords.add_alias("mc"); - StringFunction sfcm("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", Name("sfcm"), Dimensions(3), Dimensions(1)); - - double tol1 = 1.e-12; - - { - MDArray vv = eval_vec3(0.1, 0.2, 0.3, 0.0, ff_coords); - - STKUNIT_ASSERT_NEAR(vv(0), 0.1, tol1); - STKUNIT_ASSERT_NEAR(vv(1), 0.2, tol1); - STKUNIT_ASSERT_NEAR(vv(2), 0.3, tol1); - } - - { - double vv = eval(0.1, 0.2, 0.3, 0.0, sfcm); - double v_expect = std::sqrt(0.1*0.1 + 0.2*0.2 + 0.3*0.3); - STKUNIT_ASSERT_NEAR(vv, v_expect, tol1); - } - - coords_mag_field_function.interpolateFrom(sfcm); - CheckCoordMag checkCoordMag1(std::string(EXPAND_AND_QUOTE(__FILE__))+": "+toString(__LINE__)); - if (!p_rank) std::cout << "checkCoordMag1..." << std::endl; - eMesh.nodalOpLoop(checkCoordMag1, coords_mag_field); - if (!p_rank) std::cout << "checkCoordMag1...done" << std::endl; - STKUNIT_EXPECT_FALSE(checkCoordMag1.m_error); - } - catch ( const std::exception * X ) { - std::cout << " unexpected exception: " << X->what() << std::endl; - exit(123); - } - catch ( const std::exception & X ) { - std::cout << " unexpected exception: " << X.what() << std::endl; - exit(124); - } - catch( ... ) { - std::cout << " ... exception" << std::endl; - exit(125); - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -enum {NPTS = 4}; -static double testpoints[NPTS][4] = { - {0.1234, 0.5678, 0.9, 0.812 }, - {0.1234e-3, 0.5678e-5, 0.97, 0.01 }, - {0.101, 0.02, 0.1020, 0.0122 }, - {0.003, 0.89, 0.01, 0.5 } -}; - -STKUNIT_UNIT_TEST(function, fieldFunction_multiplePoints) -{ - EXCEPTWATCH; - std::cout << "TEST::function::fieldFunction_multiplePoints" << std::endl; - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - int vectorDimension = 0; // signifies a scalar field - eMesh.add_field("coords_mag_field", mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - FieldFunction ff_coords("ff_coords", f_coords, eMesh, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - MDArray val1 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords); - std::cout << "val1= \n" << val1 << std::endl; - - MDArray points(NPTS, 3); - MDArray output(NPTS, 3); - MDArray output_expect(NPTS, 3); - - //StringFunction sf1("x+y*z"); - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - double x = testpoints[ipts][0]; - double y = testpoints[ipts][1]; - double z = testpoints[ipts][2]; - double t = testpoints[ipts][3]; - points(ipts, 0) = x; - points(ipts, 1) = y; - points(ipts, 2) = z; - //points(ipts, 3) = t; - - //std::cout << "field_op: ipts= " << ipts << std::endl; - - MDArray vec = eval_vec3(x, y, z, t, ff_coords); - STKUNIT_EXPECT_NEAR(vec(0), x, fabs(1.e-5*x)); - STKUNIT_EXPECT_NEAR(vec(1), y, fabs(1.e-5*y)); - STKUNIT_EXPECT_NEAR(vec(2), z, fabs(1.e-5*z)); - output_expect(ipts, 0) = x; - output_expect(ipts, 1) = y; - output_expect(ipts, 2) = z; - } - std::cout << "field_op: NPTS= " << NPTS << std::endl; - // ff_coords.setDomainDimensions(Dimensions(NPTS,3)); - // ff_coords.setCodomainDimensions(Dimensions(NPTS,3)); - ff_coords.setDomainDimensions(Dimensions(3)); - ff_coords.setCodomainDimensions(Dimensions(3)); - ff_coords(points, output, 0.0); - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - STKUNIT_EXPECT_NEAR(output(ipts, 0), output_expect(ipts, 0), 1.e-5*(fabs(output_expect(ipts,0))) ); - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, fieldFunction_point_eval_verify) -{ - EXCEPTWATCH; - /// test evaluation of field function at a point - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - - eMesh.commit(); - // no need for this in create mode: eMesh.readBulkData(); - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// here we evaluate this field function - MDArray val1 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords); - //std::cout << "eval = \n" << val1 << std::endl; - - stk_classic::mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - - - bool didCatch = false; - try { - // evaluate a point that is known to be outside the domain - MDArray val10 = eval_vec3(1.2, 1.3, 1.4, 0.0, ff_coords); - } - catch ( const std::exception & X ) { - std::cout << " expected to catch this exception: " << X.what() << std::endl; - didCatch = true; - } - catch( ... ) { - std::cout << " P:" << bulkData.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - didCatch = false; - } - STKUNIT_EXPECT_TRUE(didCatch); - - //double value = eval(1.2, 2.3, 3.4, 0.0, ff_coords); - MDArray pts(3); - MDArray output_pts(3); - pts(0) = 0.2; pts(1) = 0.3; pts(2) = 0.4; //pts(3) = 0.0; - ff_coords(pts, output_pts); - STKUNIT_ASSERT_NEAR(pts(0), output_pts(0), 1.e-9); - STKUNIT_ASSERT_NEAR(pts(1), output_pts(1), 1.e-9); - STKUNIT_ASSERT_NEAR(pts(2), output_pts(2), 1.e-9); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, fieldFunction_point_eval_deriv_verify) -{ - EXCEPTWATCH; - /// test evaluation of field function at a point - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - - int vectorDimension = 0; // signifies a scalar field - stk_classic::mesh::FieldBase *f_test = eMesh.add_field("test", mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - // no need for this in create mode: eMesh.readBulkData(); - - StringFunction sf1("x + y + z + t"); - - FieldFunction ff1("ff1", f_test, eMesh, 3, 1); - ff1.interpolateFrom(sf1); - - - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", f_coords, eMesh, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// here we evaluate this field function - MDArray val1 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords); - //std::cout << "eval = \n" << val1 << std::endl; - - //double value = eval(1.2, 2.3, 3.4, 0.0, ff_coords); - MDArray pts(3); - MDArray output_pts(3); - pts(0) = 0.2; pts(1) = 0.3; pts(2) = 0.4; //pts(3) = 0.0; - ff_coords(pts, output_pts); - STKUNIT_ASSERT_NEAR(pts(0), output_pts(0), 1.e-9); - STKUNIT_ASSERT_NEAR(pts(1), output_pts(1), 1.e-9); - STKUNIT_ASSERT_NEAR(pts(2), output_pts(2), 1.e-9); - -#if 0 - Teuchos::RCP deriv_ff = ff1.gradient(); - MDArray outp1(3); - deriv_ff->operator()(pts, outp1); - STKUNIT_ASSERT_NEAR(outp1(0), 1.0, 1.e-9); - STKUNIT_ASSERT_NEAR(outp1(1), 1.0, 1.e-9); - STKUNIT_ASSERT_NEAR(outp1(2), 1.0, 1.e-9); -#endif -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, fieldFunction_point_eval_timing) -{ - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - /// test evaluation of field function at a point - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - - eMesh.commit(); - // no need for this in create mode: eMesh.readBulkData(); - - //unsigned p_rank = eMesh.get_bulk_data()->parallel_rank(); - unsigned p_size = eMesh.get_bulk_data()->parallel_size(); - // FIXME - if (p_size > 1) return; - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - stk_classic::mesh::FieldBase *f_coords = eMesh.get_field("coordinates"); - - for (unsigned iSearchType = 0; iSearchType < 2; iSearchType++) - { - /// create a field function from the existing coordinates field - FieldFunction::SearchType search_type = (iSearchType == 0 ? FieldFunction::SIMPLE_SEARCH : FieldFunction::STK_SEARCH); - //std::cout << "P[" << Util::get_rank() << "] search_type = " << search_type << " = " << typeid(search_type).name() << std::endl; - FieldFunction ff_coords("ff_coords", f_coords, eMesh, - Dimensions(3), Dimensions(3), search_type - ); - - // The first point that is evaluated fires the setup of the stk_classic::search data structure (oct-tree, bih-tree) - double t1st = stk_classic::wall_time(); - MDArray val11 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords); - val11 = eval_vec3(0.2, 0.3, 0.4, 0.0, ff_coords); - t1st = stk_classic::wall_dtime(t1st); - - // timings - unsigned numIter = 10000; - //unsigned numIter = 1000; - MDArray pts(3); - MDArray output_pts(3); - - // ensure the same set of random data each run - Teuchos::ScalarTraits::seedrandom(12345); - - double tstart = stk_classic::wall_time(); - for (unsigned iter = 0; iter < numIter; iter++) - { - double rnd = Teuchos::ScalarTraits::random(); - pts(0) = (rnd+1.0)/2.0; - rnd = Teuchos::ScalarTraits::random(); - pts(1) = (rnd+1.0)/2.0; - rnd = Teuchos::ScalarTraits::random(); - pts(2) = (rnd+1.0)/2.0; - - // FIXME - //!! pts(0) = 0.2; pts(1) = 0.3; pts(2)= 0.4; - // FIXME - ff_coords(pts, output_pts, 0.0); -#if 0 - STKUNIT_EXPECT_DOUBLE_EQ(pts(0), output_pts(0)); - STKUNIT_EXPECT_DOUBLE_EQ(pts(1), output_pts(1)); - STKUNIT_EXPECT_DOUBLE_EQ(pts(2), output_pts(2)); -#endif - } - - double total_time = stk_classic::wall_dtime(tstart); - if (1 || EXTRA_PRINT) std::cout - << "TEST::function::fieldFunction_point_eval_timing: " - << " for search_type= " << (iSearchType==0?"SIMPLE_SEARCH":"STK_SEARCH")<< "\n" - << " time for 1st eval= " << t1st << "\n" - << " for " << numIter << " iterations, evaluating field(x,y,z) time = " << total_time << "\n" - << " average per point lookup and eval time = " << (total_time/((double)numIter)) << std::endl; - } - //std::cout << "P[" << Util::get_rank() << "] TEST::function::fieldFunction_point_eval_timing done " << std::endl; -} - -#if 0 -int main() -{ - StringFunction sf1("x + y + z + t"); - sf1(xyz, out); - - StringFunction sf2("x - y"); - sfx("x"); - sfy("y"); - sfxy("x-y"); - sfxy1== sfx-sfy; - - StringFunction sf21dif = sf2-sf1; - - mesh::fem::FEMMetaData m; - //... setup field, etc. - FieldFunction ff1("ff1", part1, field_1); // can be nodal or elemental - - ff1.interpolateFrom(sf1); - - FieldFunction ff2(ff1); // copy - FieldFunction ff3 = ff1; // copy - - Function ff21diff = ff2-ff1; // should be zero - ZeroFunction zero_func; - - //assert( ff21diff == zero_func ); - random_probe_assert(ff21diff, zero_func, 100); - - DifferenceFunction dfsf21(sf1,sf2); - //assert( sf21dif == dfsf21 ); - random_probe_assert( sf21dif, dfsf21, 100); - - // check copy - ff2.interpolateFrom(sf2); - ff2.assertMostlyEqual(ff1); -} -#endif - -} // namespace unit_tests -} // namespace percept -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestGeometryVerifier.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestGeometryVerifier.cpp deleted file mode 100644 index 01b1f25d5244..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestGeometryVerifier.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace percept { -namespace unit_tests { - -// on pathscale platform this doesn't work (something to do with static variables) - -static int dw_enabled = 1; -static stk_classic::diag::Writer s_diagWriter(std::cout.rdbuf(), dw_enabled); -static stk_classic::diag::Writer & -dw() -{ - //static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - - s_diagWriter.setPrintMask(LOG_NORM+LOG_ALWAYS); - - return s_diagWriter; -} - -#define EXTRA_PRINT 0 - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(geom, volume) -{ - dw().m(LOG_GEOMETRY_VERIFIER) << "TEST::geom::volume " << stk_classic::diag::dendl; - - const size_t num_x = 3; - const size_t num_y = 3; - const size_t num_z = 3; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:0,0,0,1,1,1"; - - PerceptMesh eMesh(3u); - eMesh.new_mesh(GMeshSpec(config_mesh)); - eMesh.commit(); - // no need for this in create mode: eMesh.readBulkData(); - - //FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - - eMesh.dump(); - GeometryVerifier geomVerifier(false); - geomVerifier.isGeometryBad(bulkData, true); - //setDoPause(true); - //pause(); -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestMain.cpp deleted file mode 100644 index ded0a462271d..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#if !PY_PERCEPT -STKUNIT_MAIN(argc, argv) -#else - int main() {return 0;} -#endif diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestNorm.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestNorm.cpp deleted file mode 100644 index f67e46e6ab4f..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestNorm.cpp +++ /dev/null @@ -1,1038 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace percept { -namespace unit_tests { - - -#if 0 -static stk_classic::diag::Writer & -dw() -{ - //static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - int dw_enabled = 1; - static stk_classic::diag::Writer s_diagWriter(std::cout.rdbuf(), dw_enabled); - - s_diagWriter.setPrintMask(LOG_NORM+LOG_ALWAYS); - return s_diagWriter; -} -#endif - -#define EXTRA_PRINT 0 - -//============================================================================= -//============================================================================= -//============================================================================= -struct LocalFixture -{ - PerceptMesh eMesh; - int bogus_init; - mesh::fem::FEMMetaData& metaData; - mesh::BulkData& bulkData; - mesh::FieldBase *coords_field; - StringFunction sfx; - ConstantFunction sfx_res; - - LocalFixture(size_t num_xyz = 4, size_t num_y=0, size_t num_z=0, bool sidesets=false, bool commit=true) : eMesh(3u), bogus_init(init(num_xyz, num_y, num_z, sidesets, commit)), - metaData(*eMesh.get_fem_meta_data()), bulkData(*eMesh.get_bulk_data()), - coords_field( metaData.get_field("coordinates") ), - sfx("x", Name("sfx"), Dimensions(3), Dimensions(1) ), - sfx_res (0.0, "sfx_res") - - { - - } - - int init(size_t num_xyz, size_t num_y_arg, size_t num_z_arg, bool sidesets=false, bool commit=true) - { - // Need a symmetric mesh around the origin for some of the tests below to work correctly (i.e. have analytic solutions) - const size_t num_x = num_xyz; - const size_t num_y = num_y_arg? num_y_arg : num_xyz; - const size_t num_z = num_z_arg? num_z_arg : num_xyz; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:-0.5,-0.5,-0.5,0.5,0.5,0.5"; - if (sidesets) config_mesh += "|sideset:xXyYzZ"; - - eMesh.new_mesh(GMeshSpec(config_mesh)); - if (commit) eMesh.commit(); - return 1; - } - -}; - -//============================================================================= -//============================================================================= -//============================================================================= - -//stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); -//dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); -//dw().setPrintMask(LOG_NORM+LOG_ALWAYS); - -STKUNIT_UNIT_TEST(norm, volume) -{ - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - dw().m(LOG_NORM) << "TEST::norm::volume " << stk_classic::diag::dendl; - - LocalFixture fix(3,3,12); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - PerceptMesh& eMesh = fix.eMesh; - - mesh::FieldBase *coords_field = fix.coords_field; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated - here it is just the identity, and when integrated should produce the volume - ConstantFunction identity(1.0, "identity"); - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction sqrt_volume(0.0, "sqrt_volume"); - - { - bool expected_1 = false; - bool expected_2 = false; - Norm<2> l2Norm_test(bulkData, &metaData.universal_part(), TURBO_NONE, true); - expected_1 = !l2Norm_test.get_is_surface_norm(); - Norm<2> l2Norm_test1(bulkData, &metaData.universal_part(), TURBO_NONE, false); - expected_2 = !l2Norm_test1.get_is_surface_norm(); - STKUNIT_EXPECT_TRUE(expected_1); - STKUNIT_EXPECT_TRUE(expected_2); - } - - - /// Create the operator that will do the work - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - /// get the l2 norm of identity - l2Norm(identity, sqrt_volume); - - Teuchos::ScalarTraits::seedrandom(12345); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_volume.getValue()); - - int niter=1; - for (int iter=0; iter < niter; iter++) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, eval(Math::random01(), Math::random01(), Math::random01(), 0.0, sqrt_volume)); - } - - //// rotate the mesh - -#define DO_IO_TESTING 1 - -#if DO_IO_TESTING - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_original_out.e ..." << std::endl; - eMesh.save_as("./gmesh_hex8_original_out.e"); - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_original_out.e done" << std::endl; -#endif - - if (1) - { - Math::Matrix rmx = Math::rotationMatrix(0, 30); - Math::Matrix rmy = Math::rotationMatrix(1, -45); - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm; - rm = rmy * rmz; - rm = rmx * rm; - eMesh.transform_mesh(rm); - - // for testing -#if DO_IO_TESTING - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_rotated_out.e ..." << std::endl; - eMesh.save_as("./gmesh_hex8_rotated_out.e"); - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_rotated_out.e done" << std::endl; -#endif - - l2Norm(identity, sqrt_volume); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_volume.getValue()); - } - - //// scale the mesh - if (1) - { - - double scx = M_PI; - double scy = M_E; - double scz = std::sqrt(3.0); - double sc=scx*scy*scz; - Math::Matrix smx = Math::scalingMatrix(0, scx); - Math::Matrix smy = Math::scalingMatrix(1, scy); - Math::Matrix smz = Math::scalingMatrix(2, scz); - Math::Matrix sm; - sm = smy * smz; - sm = smx * sm; - //std::cout << "sm= " << sm << std::endl; - eMesh.transform_mesh(sm); - - // for testing -#if DO_IO_TESTING - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_scaled_out.e ..." << std::endl; - eMesh.save_as("./gmesh_hex8_scaled_out.e"); - if (1 || EXTRA_PRINT) std::cout << "TEST.norm.volume: writing gmesh_hex8_scaled_out.e done" << std::endl; -#endif - - l2Norm(identity, sqrt_volume); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(std::sqrt(sc), sqrt_volume.getValue()); - } - - //Function coords_l2_norm = ff_coords.norm_l2(); - -#if 0 - /// OPTION 1 - separate classes for operations on fields - Norm_L2 coords_l2_norm("coords_l2_norm"); - FieldFunction result = coords_l2_norm(ff_coords); - - - /// OPTION 1a - just showing generic base class - /// A FunctionOperator takes a FieldFunction and returns a FieldFunction - FunctionOperator& coords_l2_norm_op = Norm_L2("coords_l2_norm"); - FieldFunction coords_l2_norm = coords_l2_norm_op(ff_coords); - - /// OPTION 2 - simple set of methods on FieldFunction or Function (depending on genericity) - FieldFunction coords_l2_norm = ff_coords.norm_l2(); - FieldFunction coords_gradient_tensor_field_nodewise = ff_coords.nodewise_gradient(); - FieldFunction coords_mag_nodewise_field = ff_coords.nodewise_magnitude(); - FieldFunction coords_gradient_tensor_field_elementwise = ff_coords.elementwise_gradient(); -#endif - /// Note: need to create new fields each time, which requires a change to the meta data - -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, surface_area) -{ - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - bool sidesets=true; - LocalFixture fix(3,3,12,sidesets); - //mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - PerceptMesh& eMesh = fix.eMesh; - //eMesh.save_as("junk.123.e"); - - mesh::FieldBase *coords_field = fix.coords_field; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated - here it is just the identity, and when integrated should produce the area of faces - ConstantFunction identity(1.0, "identity"); - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction sqrt_area(0.0, "sqrt_area"); - ConstantFunction sqrt_area1(0.0, "sqrt_area1"); - - /// Create the operator that will do the work - stk_classic::mesh::Part *surface_part = eMesh.get_part("surface_1"); - stk_classic::mesh::Part *block_part = eMesh.get_part("block_1"); - stk_classic::mesh::Selector selector(*surface_part); - stk_classic::mesh::Selector selector_test(*block_part); - selector_test = selector_test | selector; - bool is_surface_norm = true; - - { - bool expected_1 = false; - bool expected_2 = false; - bool expected_3 = false; - Norm<2> l2Norm_test(bulkData, &selector, TURBO_NONE, true); - expected_1 = l2Norm_test.get_is_surface_norm(); - Norm<2> l2Norm_test1(bulkData, &selector, TURBO_NONE, false); - expected_2 = l2Norm_test1.get_is_surface_norm(); - STKUNIT_EXPECT_TRUE(expected_1); - STKUNIT_EXPECT_TRUE(expected_2); - try { Norm<2> l2Norm_test2(bulkData, &selector_test, TURBO_NONE, true); } - catch ( const std::exception & X ) { - std::cout << "expected exception: " << X.what() << std::endl; - expected_3 = true; - } - STKUNIT_EXPECT_TRUE(expected_3); - } - - Norm<2> l2Norm(bulkData, &selector, TURBO_NONE, is_surface_norm); - Norm<2> l2Norm1(bulkData, "surface_1"); - l2Norm1.set_is_surface_norm(true); - - /// get the l2 norm of identity - l2Norm(identity, sqrt_area); - l2Norm1(identity, sqrt_area1); - - Teuchos::ScalarTraits::seedrandom(12345); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_area.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_area1.getValue()); - - int niter=1; - for (int iter=0; iter < niter; iter++) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, eval(Math::random01(), Math::random01(), Math::random01(), 0.0, sqrt_area)); - } - - //// rotate the mesh - -#if DO_IO_TESTING - eMesh.save_as("./gmesh_hex8_area_original_out.e"); -#endif - - if (1) - { - Math::Matrix rmx = Math::rotationMatrix(0, 30); - Math::Matrix rmy = Math::rotationMatrix(1, -45); - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm; - rm = rmy * rmz; - rm = rmx * rm; - eMesh.transform_mesh(rm); - - // for testing -#if DO_IO_TESTING - eMesh.save_as("./gmesh_hex8_area_rotated_out.e"); -#endif - - l2Norm(identity, sqrt_area); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_area.getValue()); - } - - //// scale the mesh - if (1) - { - - double scx = M_PI; - double scy = M_PI; - double scz = M_PI; - double sc=scx*scy; - Math::Matrix smx = Math::scalingMatrix(0, scx); - Math::Matrix smy = Math::scalingMatrix(1, scy); - Math::Matrix smz = Math::scalingMatrix(2, scz); - Math::Matrix sm; - sm = smy * smz; - sm = smx * sm; - //std::cout << "sm= " << sm << std::endl; - eMesh.transform_mesh(sm); - - // for testing -#if DO_IO_TESTING - eMesh.save_as("./gmesh_hex8_area_scaled_out.e"); -#endif - - l2Norm(identity, sqrt_area); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(std::sqrt(sc), sqrt_area.getValue()); - } - //Function coords_l2_norm = ff_coords.norm_l2(); - -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, string_function) -{ - EXCEPTWATCH; - //stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - //dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); - //dw().setPrintMask(LOG_NORM+LOG_ALWAYS); - - dw().m(LOG_NORM) << "TEST.norm.string_function " << stk_classic::diag::dendl; - - LocalFixture fix(4); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - PerceptMesh& eMesh = fix.eMesh; - //mesh::FieldBase* coords_field = fix.coords_field; - StringFunction sfx = fix.sfx; - ConstantFunction sfx_res = fix.sfx_res; - - /// Create the operator that will do the work - /// get the l2 norm - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l2Norm(sfx, sfx_res); - - double sfx_expect = std::sqrt(0.25/3.); - Teuchos::ScalarTraits::seedrandom(12345); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res.getValue()); - - int niter=1; - for (int iter=0; iter < niter; iter++) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, eval(Math::random01(), Math::random01(), Math::random01(), 0.0, sfx_res)); - } - - /// the function to be integrated: (Integral[ abs(x), dxdydz]) =?= (2 * |x|^2/2 @ [0, 0.5]) ==> .25) - Norm<1> l1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm(sfx, sfx_res); - - sfx_expect = 0.25; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - - /// the function to be integrated: (Max[ x^2+y^3+z^4, dxdydz]) =?= (@ [-0.5, 0.5]^3 ) ==> .5^2+.5^3+.5^4) - StringFunction sfmax("x^2 + y^3 + z^4", Name("sfmax"), Dimensions(3), Dimensions(1) ); - Norm<-1> lInfNorm(bulkData, &metaData.universal_part(), TURBO_NONE); - lInfNorm.setCubDegree(10); - lInfNorm(sfmax, sfx_res); - double sf1=eval(.5,.5,.5,0.0, sfmax); - sfx_expect = 0.5*0.5 + 0.5*0.5*0.5 + 0.5*0.5*0.5*0.5; - std::cout << "sfmax= " << sf1 << " sfx_expect= " << sfx_expect << " sfx_res= " << sfx_res.getValue() << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - - /// indirection - StringFunction sfmax_1("sfmax", Name("sfmax_1"), Dimensions(3), Dimensions(1) ); - double sf1_1=eval(.5,.5,.5,0.0, sfmax_1); - std::cout << "sfmax_1= " << sf1_1 << " sfx_expect= " << sfx_expect << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sf1_1); - - /// the function to be integrated: sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest1.py) - StringFunction sfxyz("x*y*z", Name("sfxyz"), Dimensions(3), Dimensions(1) ); - l2Norm(sfxyz, sfx_res); - sfx_expect = 0.0240562612162344; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - - /// indirection - std::cout << "tmp srk start..." << std::endl; - StringFunction sfxyz_2("sfxyz", Name("sfxyz_2"), Dimensions(3), Dimensions(1) ); - l2Norm(sfxyz_2, sfx_res); - sfx_expect = 0.0240562612162344; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - - /// the function to be integrated (but over a rotated domain): sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest2.py) - /// now rotate the mesh - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm = rmz; - eMesh.transform_mesh(rm); - - l2Norm(sfxyz, sfx_res); - sfx_expect = 0.0178406008037016; - // NOTE: we need extra quadrature accuracy to reproduce this result (cubDegree==4 in IntegratedOp almost gets it right) - // for now, we are satisfied with 2-3 digits - //STKUNIT_EXPECT_DOUBLE_EQ(sfx_res.getValue(), sfx_expect); - if (std::fabs(sfx_res.getValue()-sfx_expect) > 0.01*sfx_expect) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_TRUE(false); - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, string_function_1) -{ - EXCEPTWATCH; - LocalFixture fix(4); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - //PerceptMesh& eMesh = fix.eMesh; - //mesh::FieldBase* coords_field = fix.coords_field; - StringFunction sfx = fix.sfx; - ConstantFunction sfx_res = fix.sfx_res; - - /// Create the operator that will do the work - /// get the l2 norm - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - if (0) l2Norm(sfx, sfx_res); - - /// the function to be integrated: sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest1.py) - StringFunction sfxyz("x*y*z", Name("sfxyz"), Dimensions(3), Dimensions(1) ); - //l2Norm(sfxyz, sfx_res); - //sfx_expect = 0.0240562612162344; - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - - /// indirection - std::cout << "tmp srk start..." << std::endl; - StringFunction sfxyz_first("sfxyz", Name("sfxyz_first"), Dimensions(3), Dimensions(1) ); - l2Norm(sfxyz_first, sfx_res); - double sfx_expect = 0.0240562612162344; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -/// This test uses a back door to the function that passes in the element to avoid the lookup of the element when the -/// StringFunction contains references to FieldFunctions -void TEST_norm_string_function_turbo_verify_correctness(TurboOption turboOpt) -{ - EXCEPTWATCH; - //stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - //dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); - //dw().setPrintMask(LOG_NORM+LOG_ALWAYS); - - dw().m(LOG_NORM) << "TEST.norm.string_function " << stk_classic::diag::dendl; - - LocalFixture fix(4); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - PerceptMesh& eMesh = fix.eMesh; - mesh::FieldBase* coords_field = fix.coords_field; - StringFunction sfx = fix.sfx; - ConstantFunction sfx_res = fix.sfx_res; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated: sqrt(Integral[x^2, dxdydz]) =?= sqrt(x^3/3 @ [-0.5, 0.5]) ==> sqrt(0.25/3) - //StringFunction sfx("x", Name("sfx"), Dimensions(3), Dimensions(1) ); - - ff_coords.add_alias("mc"); - //StringFunction sfcm("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", Name("sfcm"), Dimensions(3), Dimensions(1)); - StringFunction sfx_mc("mc[0]", Name("sfx_mc"), Dimensions(3), Dimensions(1) ); - StringFunction sfx_mc1("mc[0]", Name("sfx_mc1"), Dimensions(3), Dimensions(1) ); - - if (1) - { - - - double x = -0.49+0.98*Math::random01(); - double y = -0.49+0.98*Math::random01(); - double z = -0.49+0.98*Math::random01(); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(eval(x,y,z,0.0, sfx), eval(x,y,z,0.0, sfx_mc)); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(eval(.034,0,0,0.0, sfx), eval(.034,0,0,0.0, sfx_mc)); - } - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction sfx_res_turbo(0.0, "sfx_res_turbo"); - ConstantFunction sfx_res_slow(0.0, "sfx_res_slow"); - ConstantFunction sfx_res_fast(0.0, "sfx_res_fast"); - ConstantFunction sfx_res_bucket(0.0, "sfx_res_bucket"); - - // STATE m_element.... - - /// Create the operator that will do the work - /// get the l2 norm - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l2Norm(sfx, sfx_res); - - Norm<2> l2Norm_turbo(bulkData, &metaData.universal_part(), turboOpt); - Norm<2> l2Norm_turbo_bucket(bulkData, &metaData.universal_part(), TURBO_BUCKET); - Norm<2> l2Norm_turbo1(bulkData, &metaData.universal_part(), turboOpt); - l2Norm_turbo(sfx, sfx_res_turbo); - - l2Norm_turbo1(sfx_mc1, sfx_res_fast); - l2Norm_turbo_bucket(sfx_mc1, sfx_res_bucket); - - l2Norm(sfx_mc, sfx_res_slow); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(eval(.023,0,0,0.0, sfx), eval(.023,0,0,0.0, sfx_mc)); - - double sfx_expect = std::sqrt(0.25/3.); - std::cout << "sfx_expect= " << sfx_expect << std::endl; - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_bucket.getValue()); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res.getValue()); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_turbo.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_slow.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_fast.getValue()); //! - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res.getValue()); - - //Util::pause(true, "13a"); - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_res_turbo.getValue(), sfx_expect); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX_TOL(sfx_expect, sfx_res_turbo.getValue(), 1.e-8); - //Util::pause(true, "13"); - - /// the function to be integrated: (Integral[ abs(x), dxdydz]) =?= (2 * |x|^2/2 @ [0, 0.5]) ==> .25) - Norm<1> l1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm(sfx, sfx_res); - - Norm<1> l1Norm_turbo(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm_turbo(sfx, sfx_res_turbo); - l1Norm_turbo(sfx_mc, sfx_res_fast); - l1Norm(sfx_mc, sfx_res_slow); - - sfx_expect = 0.25; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_slow.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_fast.getValue()); - - //// ----- here - /// the function to be integrated: sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest1.py) - StringFunction sfxyz("x*y*z", Name("sfxyz"), Dimensions(3), Dimensions(1) ); - l2Norm(sfxyz, sfx_res); - l2Norm_turbo(sfxyz, sfx_res_turbo); - sfx_expect = 0.0240562612162344; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - - - /// the function to be integrated (but over a rotated domain): sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest2.py) - /// now rotate the mesh - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm = rmz; - eMesh.transform_mesh(rm); - - l2Norm(sfxyz, sfx_res); - l2Norm_turbo(sfxyz, sfx_res_turbo); - sfx_expect = 0.0178406008037016; - // NOTE: we need extra quadrature accuracy to reproduce this result (cubDegree==4 in IntegratedOp almost gets it right) - // for now, we are satisfied with 3 digits - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_res.getValue(), sfx_expect); - if (std::fabs(sfx_res.getValue()-sfx_expect) > 0.01*sfx_expect) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_TRUE(false); - } - if (std::fabs(sfx_res_turbo.getValue()-sfx_expect) > 0.01*sfx_expect) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - STKUNIT_EXPECT_TRUE(false); - } -} - -STKUNIT_UNIT_TEST(norm, string_function_turbo_verify_correctness_element) -{ - EXCEPTWATCH; - - TEST_norm_string_function_turbo_verify_correctness(TURBO_ELEMENT); -} - -STKUNIT_UNIT_TEST(norm, string_function_turbo_verify_correctness_bucket) -{ - EXCEPTWATCH; - - TEST_norm_string_function_turbo_verify_correctness(TURBO_BUCKET); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -/// This test uses a back door to the function that passes in the element to avoid the lookup of the element when the -/// StringFunction contains references to FieldFunctions -void TEST_norm_string_function_turbo_timings(TurboOption turboOpt) -{ - EXCEPTWATCH; - //stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - //dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); - //dw().setPrintMask(LOG_NORM+LOG_ALWAYS); - - dw().m(LOG_NORM) << "TEST.norm.string_function " << stk_classic::diag::dendl; - - /// create a meta data/bulk data empty pair - PerceptMesh eMesh(3u); - - if (1) - { - // Need a symmetric mesh around the origin for some of the tests below to work correctly (i.e. have analytic solutions) - const size_t nxyz = 4; - const size_t num_x = nxyz; - const size_t num_y = nxyz; - const size_t num_z = nxyz; - std::string config_mesh = - Ioss::Utils::to_string(num_x) + "x" + - Ioss::Utils::to_string(num_y) + "x" + - Ioss::Utils::to_string(num_z) + "|bbox:-0.5,-0.5,-0.5,0.5,0.5,0.5"; - - eMesh.new_mesh(GMeshSpec(config_mesh)); - - eMesh.commit(); - } - - mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - - /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field - mesh::FieldBase *coords_field = metaData.get_field("coordinates"); - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated: sqrt(Integral[x^2, dxdydz]) =?= sqrt(x^3/3 @ [-0.5, 0.5]) ==> sqrt(0.25/3) - StringFunction sfx("x", Name("sfx"), Dimensions(3), Dimensions(1) ); - - ff_coords.add_alias("mc"); - //StringFunction sfcm("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", Name("sfcm"), Dimensions(3), Dimensions(1)); - StringFunction sfx_mc("mc[0]", Name("sfx_mc"), Dimensions(3), Dimensions(1) ); - - /// the function to be integrated: sqrt(Integral[x^2, dxdydz]) =?= sqrt(x^3/3 @ [-0.5, 0.5]) ==> sqrt(0.25/3) - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction sfx_res(0.0, "sfx_res"); - ConstantFunction sfx_res_turbo(0.0, "sfx_res_turbo"); - ConstantFunction sfx_res_slow(0.0, "sfx_res_slow"); - ConstantFunction sfx_res_fast(0.0, "sfx_res_fast"); - -#define COL_SEP "|" -#define EXPR_CELL_WIDTH (80) - -#define TIME_IT2(expr_none,expr_turbo,msg,topt) \ - { \ - double TURBO_NONE_time = 0; \ - double TURBO_ON_time = 0; \ - TIME_IT(expr_none,TURBO_NONE_time); \ - TIME_IT(expr_turbo,TURBO_ON_time); \ - if (1) std::cout << msg << #topt << "for expression= " << QUOTE(expr_none) << " timings= " << std::endl; \ - if (1) std::cout << "TURBO_NONE_time= " << TURBO_NONE_time << " " \ - << ( turboOpt==TURBO_ELEMENT?"TURBO_ELEMENT_time":"TURBO_BUCKET_time") <<"= " << TURBO_ON_time \ - << " ratio= " << TURBO_NONE_time/TURBO_ON_time << std::endl; \ - } - - int numIter = 1; - for (int iter = 0; iter < numIter; iter++) - { - /// Create the operator that will do the work - /// get the l2 norm - Norm<2> l2Norm (bulkData, &metaData.universal_part(), TURBO_NONE); - Norm<2> l2Norm_turbo(bulkData, &metaData.universal_part(), turboOpt); - - //double TURBO_ELEMENT_time=0; - TIME_IT2(l2Norm(sfx, sfx_res); , l2Norm_turbo(sfx, sfx_res_turbo);, "Should be the same turboOpt= ", turboOpt ); - TIME_IT2(l2Norm(sfx_mc, sfx_res_slow); , l2Norm_turbo(sfx, sfx_res_fast); , "StringFunction with ref to FF, slow vs. fast" ,turboOpt ); - - double sfx_expect = std::sqrt(0.25/3.); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX_TOL( sfx_expect, sfx_res_turbo.getValue(), 1.e-8); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_slow.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_fast.getValue()); - - /// the function to be integrated: (Integral[ abs(x), dxdydz]) =?= (2 * |x|^2/2 @ [0, 0.5]) ==> .25) - Norm<1> l1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm(sfx, sfx_res); - - Norm<1> l1Norm_turbo(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm_turbo(sfx, sfx_res_turbo); - - sfx_expect = 0.25; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - - /// the function to be integrated: sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest1.py) - StringFunction sfxyz("x*y*z", Name("sfxyz"), Dimensions(3), Dimensions(1) ); - - TIME_IT2(l2Norm(sfxyz, sfx_res); , l2Norm_turbo(sfxyz, sfx_res_turbo); , "should be the same", turboOpt ); - - sfx_expect = 0.0240562612162344; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - - /// the function to be integrated (but over a rotated domain): sqrt(Integral[(x*y*z)^2, dxdydz]) =?= (see unitTest2.py) - /// now rotate the mesh - Math::Matrix rmz = Math::rotationMatrix(2, 30); - Math::Matrix rm = rmz; - eMesh.transform_mesh(rm); - - TIME_IT2( l2Norm(sfxyz, sfx_res); , l2Norm_turbo(sfxyz, sfx_res_turbo); , "should be the same", turboOpt ); - - sfx_expect = 0.0178406008037016; - // NOTE: we need extra quadrature accuracy to reproduce this result (cubDegree==4 in IntegratedOp almost gets it right) - // for now, we are satisfied with 3 digits - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_res.getValue(), sfx_expect); - if (std::fabs(sfx_res.getValue()-sfx_expect) > 0.01*sfx_expect) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res.getValue()); - STKUNIT_EXPECT_TRUE(false); - } - if (std::fabs(sfx_res_turbo.getValue()-sfx_expect) > 0.01*sfx_expect) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_turbo.getValue()); - STKUNIT_EXPECT_TRUE(false); - } - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, string_function_turbo_timings) -{ - EXCEPTWATCH; - TEST_norm_string_function_turbo_timings(TURBO_ELEMENT); -} -STKUNIT_UNIT_TEST(norm, string_function_turbo_timings_bucket) -{ - EXCEPTWATCH; - TEST_norm_string_function_turbo_timings(TURBO_BUCKET); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, field_function) -{ - EXCEPTWATCH; - //stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - //dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); - //dw().setPrintMask(LOG_NORM+LOG_ALWAYS); - - dw().m(LOG_NORM) << "TEST.norm.field_function " << stk_classic::diag::dendl; - - LocalFixture fix(4); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - //PerceptMesh& eMesh = fix.eMesh; - mesh::FieldBase* coords_field = fix.coords_field; - - /// Create the operator that will do the work - /// get the l2 norm - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - std::vector vals(3,0.0); - ConstantFunctionVec sfx_res_vec(vals, "sfx_res_vec"); - - Util::setFlag(0, false); - l2Norm(ff_coords, sfx_res_vec); - - double sfx_expect = std::sqrt(0.25/3.); - //std::cout << "tmp vec" << sfx_res_vec.getValue() << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(sfx_expect, sfx_res_vec.getValue()[0]); - - /// the function to be integrated: (Integral[ abs(x), dxdydz]) =?= (2 * |x|^2/2 @ [0, 0.5]) ==> .25) - Norm<1> l1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - l1Norm(ff_coords, sfx_res_vec); - - sfx_expect = 0.25; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX( sfx_expect, sfx_res_vec.getValue()[0]); - - Util::setFlag(0, false); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, h1_volume) -{ - EXCEPTWATCH; - bool ret=true; - if (ret) return; - MPI_Barrier( MPI_COMM_WORLD ); - - LocalFixture fix(3,3,12); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - //PerceptMesh& eMesh = fix.eMesh; - - mesh::FieldBase *coords_field = fix.coords_field; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated - here it is just the identity, and when integrated should produce the volume - StringFunction identity("1.0", Name("identity")); - std::string grad[] = {"0", "0", "0"}; - identity.set_gradient_strings(grad, 3); - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction sqrt_volume(0.0, "sqrt_volume"); - - /// Create the operator that will do the work - H1Norm h1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - /// get the l2 norm of identity - h1Norm(identity, sqrt_volume); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, sqrt_volume.getValue()); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, h1_volume_1) -{ - EXCEPTWATCH; - bool ret=true; - if (ret) return; - MPI_Barrier( MPI_COMM_WORLD ); - - LocalFixture fix(3,3,12); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - PerceptMesh& eMesh = fix.eMesh; - - mesh::FieldBase *coords_field = fix.coords_field; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated - here it is just the identity, and when integrated should produce the volume - StringFunction plane("x+2.0*y+3.0*z", Name("plane")); - std::string grad[] = {"1", "2", "3"}; - plane.set_gradient_strings(grad, 3); - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction result1(0.0, "result1"); - - /// Create the operator that will do the work - H1Norm h1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - /// get the l2 norm of plane - h1Norm(plane, result1); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.89444048184931, result1.getValue()); - - //// rotate the mesh (result should be the same) - - if (1) - { - Math::Matrix rm = Math::rotationMatrix(0, 30); - eMesh.transform_mesh(rm); - eMesh.save_as("h1Norm_rotate.e"); - h1Norm(plane, result1); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.89444048184931, result1.getValue()); - } - -} -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(norm, h1_volume_2) -{ - EXCEPTWATCH; - bool ret=true; - if (ret) return; - MPI_Barrier( MPI_COMM_WORLD ); - - LocalFixture fix(3,3,12, false, false); - PerceptMesh& eMesh = fix.eMesh; - - int vectorDimension = 0; // signifies a scalar field - stk_classic::mesh::FieldBase *f_test = eMesh.add_field("test", mesh::fem::FEMMetaData::NODE_RANK, vectorDimension); - eMesh.commit(); - mesh::fem::FEMMetaData& metaData = fix.metaData; - mesh::BulkData& bulkData = fix.bulkData; - - mesh::FieldBase *coords_field = fix.coords_field; - - /// create a field function from the existing coordinates field - FieldFunction ff_coords("ff_coords", coords_field, &bulkData, - Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH ); - - /// the function to be integrated - here it is just the identity, and when integrated should produce the volume - StringFunction plane("x+2.0*y+3.0*z", Name("plane")); - std::string grad_str[] = {"1", "2", "3"}; - plane.set_gradient_strings(grad_str, 3); - - FieldFunction ff_plane("ff_plane", f_test, eMesh, 3, 1); - ff_plane.interpolateFrom(plane); - - { - MDArray in(3), out(1), grad(3); - double x=0.21, y=0.32, z=0.43; - in(0) = x; in(1) = y; in(2) = z; - //ff_plane.gradient() - ff_plane(in, out); - std::cout << "in= " << in << std::endl; - std::cout << "out= " << out << std::endl; - (*(ff_plane.gradient()))(in, grad); - std::cout << "grad= " << grad << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(x+2*y+3*z, out(0)); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(1.0, grad(0)); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(2.0, grad(1)); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.0, grad(2)); - } - - /// A place to hold the result. - /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are - /// since we interpolate values to them from other functions). - ConstantFunction result1(0.0, "result1"); - ConstantFunction result2(0.0, "result2"); - ConstantFunction result3(0.0, "result3"); - - /// Create the operator that will do the work - - Norm<2> l2Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - H1Norm h1Norm(bulkData, &metaData.universal_part(), TURBO_NONE); - /// get the l2 norm of plane - h1Norm(plane, result2); - h1Norm(ff_plane, result1); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(result1.getValue(), result2.getValue()); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.89444048184931, result1.getValue()); - - //// rotate the mesh (result should be the same) - - if (1) - { - Math::Matrix rm = Math::rotationMatrix(0, 30); - eMesh.transform_mesh(rm); - ff_plane.interpolateFrom(plane); - eMesh.save_as("h1Norm_rotate.e"); - h1Norm(ff_plane, result1); - l2Norm(plane, result3); - - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.89444048184931, result3.getValue()); - - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(3.89444048184931, result1.getValue()); - } - -} - - - -} -} -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesh.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesh.cpp deleted file mode 100644 index 48e6bbfaf134..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesh.cpp +++ /dev/null @@ -1,504 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - namespace unit_tests - { - -#define EXTRA_PRINT 0 - static int print_infoLevel = 0; - - //the following defines where to put the input and output files created by this set of functions -#if 0 - static const std::string input_files_loc="./input_files/"; - static const std::string output_files_loc="./output_files/"; -#else - static const std::string input_files_loc="./input_files_"; - static const std::string output_files_loc="./output_files_"; -#endif - - - //============================================================================= - //============================================================================= - //============================================================================= - - /// create a mesh of hex elements for use in other tests below - //STKUNIT_UNIT_TEST(unit_perceptMesh, build_meshes) - static void fixture_setup_0() - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demoperceptMesh_hex8_build - { - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - - // generate a 4x4x(4*p_size) mesh - std::string gmesh_spec = std::string("4x4x")+toString(4*p_size)+std::string("|bbox:0,0,0,1,1,1"); - // NLM eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - eMesh.commit(); - eMesh.save_as(input_files_loc+"hex_fixture.e"); - - // end_demo - } - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// using the QuadFixture, generate meshes with and without sidesets - // STKUNIT_UNIT_TEST(unit_perceptMesh, quad4_quad4_4_test_1) - static void fixture_setup_1() - { - - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= 2) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, true); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture", print_infoLevel); - eMesh.save_as(input_files_loc+"quad_fixture.e"); - } - - if (p_size <= 2) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - percept::QuadFixture fixture( pm , nx , ny, false); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture no sidesets", print_infoLevel); - eMesh.save_as(input_files_loc+"quad_fixture_no_sidesets.e"); - } - } - - static void fixture_setup() - { - static bool is_setup = false; - if (is_setup) return; - fixture_setup_0(); - fixture_setup_1(); - is_setup = true; - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// generate a mesh with wedge elements - - STKUNIT_UNIT_TEST(unit_perceptMesh, wedge6_1) - { - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - // start_demo_perceptMesh_wedge6_1 - - percept::PerceptMesh eMesh(3u); - - unsigned p_size = eMesh.get_parallel_size(); - if (p_size == 1) - { - - percept::WedgeFixture wedgeFixture; - wedgeFixture.createMesh(MPI_COMM_WORLD, - 4, 3, 2, - 0, 1, - 0, 1, - 0, 1, - std::string("swept-wedge_0.e") ); - } - } - - - //============================================================================= - //============================================================================= - //============================================================================= - - /// a tutorial on some of the innards of stk_mesh database - - STKUNIT_UNIT_TEST(perceptMesh, walk_nodes) - { - fixture_setup(); - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - if (p_size <= 2) - { - - // create a 12x12 quad mesh with sidesets - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets_on = true; - percept::QuadFixture fixture( pm , nx , ny, sidesets_on); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture", print_infoLevel); - //eMesh.save_as("./output_files/quad_fixture.e"); - - stk_classic::mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - - const std::vector< stk_classic::mesh::Part * > & parts = metaData.get_parts(); - - unsigned nparts = parts.size(); - if (1) std::cout << "Number of parts = " << nparts << std::endl; - - int surface_id = 2; - std::string surface_name = "surface_"+toString(surface_id); - stk_classic::mesh::Part *part = eMesh.get_non_const_part(surface_name); - stk_classic::mesh::Selector in_surface_selector(*part); - stk_classic::mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - VectorFieldType* coordField = eMesh.get_coordinates_field(); - - const std::vector & buckets = bulkData.buckets( (eMesh.get_spatial_dim() == 2 ? eMesh.edge_rank() : eMesh.face_rank() ) ); // Note - double sum = 0.0; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (in_surface_selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - // in case the cell topology is needed - const CellTopologyData * const cell_topo_data = stk_classic::percept::PerceptMesh::get_cell_topology(bucket); - shards::CellTopology cell_topo(cell_topo_data); - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iElement = 0; iElement < num_elements_in_bucket; iElement++) - { - stk_classic::mesh::Entity& element = bucket[iElement]; - - const stk_classic::mesh::PairIterRelation& elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - unsigned num_node = elem_nodes.size(); - for (unsigned inode=0; inode < num_node; inode++) - { - stk_classic::mesh::Entity & node = *elem_nodes[ inode ].entity(); - //stk_classic::mesh::EntityId nid = node.identifier(); - - double * const coord = stk_classic::mesh::field_data( *coordField , node ); - // do something with coord's - sum += coord[0]*coord[0] + coord[1]*coord[1]; - } - } - } - } - std::cout << "P[" << p_rank << ":" << p_size << "] sum = " << sum << std::endl; - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - /// Test the mesh_difference capability of PerceptMesh and the interface to stk_io - /// 1. read (and write and read back in) meshes generated above (quad_fixture) - /// 2. invoke PerceptMesh::print_info(ostringstream...) to create a string representation of the mesh - /// 3. compare the string with the saved, gold value of the string - /// 4. invoke mesh_difference to ensure it behaves as expected (two meshes are shown as identical) - /// 5. modify one mesh and ensure mesh_difference shows the meshes as being different - - STKUNIT_UNIT_TEST(perceptMesh, test_mesh_diff) - { - fixture_setup(); - EXCEPTWATCH; - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - - std::string expected_serialized_mesh_string = - "P[0] ======================================================== P[0] ========================================================P[0] ========================================================P[0] PerceptMesh::print_info: quad fixtureP[0] Uses { Node = 169 Edge = 48 Face = 144 Elem = 0 }P[0] info> Number of parts = 26 P[0] info> Part subset info: P[0] info> Part[0]= {UNIVERSAL} topology = null primary_entity_rank = 4294967295 subsets = {{OWNS} , {SHARES} , {FEM_ROOT_CELL_TOPOLOGY_PART_Node} , {FEM_ROOT_CELL_TOPOLOGY_PART_Line_2} , {FEM_ROOT_CELL_TOPOLOGY_PART_Line_3} , {FEM_ROOT_CELL_TOPOLOGY_PART_Particle} , {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_3} , {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_6} , {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_4} , {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_4} , {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_8} , {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_9} , {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_2} , {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_3} , {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_2} , {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_3} , block_1 , surface_1 , surface_2 , surface_3 , surface_4 , surface_quad4_edge2_1 , surface_quad4_edge2_2 , surface_quad4_edge2_3 , surface_quad4_edge2_4}P[0] info> Part[1]= {OWNS} topology = null primary_entity_rank = 4294967295 subsets = {}P[0] info> Part[2]= {SHARES} topology = null primary_entity_rank = 4294967295 subsets = {}P[0] info> Part[3]= {FEM_ROOT_CELL_TOPOLOGY_PART_Node} topology = Node primary_entity_rank = 0 subsets = {}P[0] info> Part[4]= {FEM_ROOT_CELL_TOPOLOGY_PART_Line_2} topology = Line_2 primary_entity_rank = 1 subsets = {surface_quad4_edge2_1 , surface_quad4_edge2_2 , surface_quad4_edge2_3 , surface_quad4_edge2_4}P[0] info> Part[5]= {FEM_ROOT_CELL_TOPOLOGY_PART_Line_3} topology = Line_3 primary_entity_rank = 1 subsets = {}P[0] info> Part[6]= {FEM_ROOT_CELL_TOPOLOGY_PART_Particle} topology = Particle primary_entity_rank = 2 subsets = {}P[0] info> Part[7]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_3} topology = Triangle_3 primary_entity_rank = 2 subsets = {}P[0] info> Part[8]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_6} topology = Triangle_6 primary_entity_rank = 2 subsets = {}P[0] info> Part[9]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_4} topology = Triangle_4 primary_entity_rank = 2 subsets = {}P[0] info> Part[10]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_4} topology = Quadrilateral_4 primary_entity_rank = 2 subsets = {block_1}P[0] info> Part[11]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_8} topology = Quadrilateral_8 primary_entity_rank = 2 subsets = {}P[0] info> Part[12]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_9} topology = Quadrilateral_9 primary_entity_rank = 2 subsets = {}P[0] info> Part[13]= {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_2} topology = Beam_2 primary_entity_rank = 2 subsets = {}P[0] info> Part[14]= {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_3} topology = Beam_3 primary_entity_rank = 2 subsets = {}P[0] info> Part[15]= {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_2} topology = ShellLine_2 primary_entity_rank = 2 subsets = {}P[0] info> Part[16]= {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_3} topology = ShellLine_3 primary_entity_rank = 2 subsets = {}P[0] info> Part[17]= block_1 topology = Quadrilateral_4 primary_entity_rank = 2 subsets = {}P[0] info> Part[18]= surface_1 topology = null primary_entity_rank = 1 subsets = {surface_quad4_edge2_1}P[0] info> Part[19]= surface_2 topology = null primary_entity_rank = 1 subsets = {surface_quad4_edge2_2}P[0] info> Part[20]= surface_3 topology = null primary_entity_rank = 1 subsets = {surface_quad4_edge2_3}P[0] info> Part[21]= surface_4 topology = null primary_entity_rank = 1 subsets = {surface_quad4_edge2_4}P[0] info> Part[22]= surface_quad4_edge2_1 topology = Line_2 primary_entity_rank = 1 subsets = {}P[0] info> Part[23]= surface_quad4_edge2_2 topology = Line_2 primary_entity_rank = 1 subsets = {}P[0] info> Part[24]= surface_quad4_edge2_3 topology = Line_2 primary_entity_rank = 1 subsets = {}P[0] info> Part[25]= surface_quad4_edge2_4 topology = Line_2 primary_entity_rank = 1 subsets = {} P[0] info> Part Uses information: P[0] info> Part[0]= {UNIVERSAL} : Uses { Node = 169 Edge = 48 Face = 144 Elem = 0 }P[0] info> Part[1]= {OWNS} : Uses { Node = 169 Edge = 48 Face = 144 Elem = 0 }P[0] info> Part[2]= {SHARES} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[3]= {FEM_ROOT_CELL_TOPOLOGY_PART_Node} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[4]= {FEM_ROOT_CELL_TOPOLOGY_PART_Line_2} : Uses { Node = 48 Edge = 48 Face = 0 Elem = 0 }P[0] info> Part[5]= {FEM_ROOT_CELL_TOPOLOGY_PART_Line_3} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[6]= {FEM_ROOT_CELL_TOPOLOGY_PART_Particle} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[7]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_3} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[8]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_6} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[9]= {FEM_ROOT_CELL_TOPOLOGY_PART_Triangle_4} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[10]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_4} : Uses { Node = 169 Edge = 48 Face = 144 Elem = 0 }P[0] info> Part[11]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_8} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[12]= {FEM_ROOT_CELL_TOPOLOGY_PART_Quadrilateral_9} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[13]= {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_2} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[14]= {FEM_ROOT_CELL_TOPOLOGY_PART_Beam_3} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[15]= {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_2} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[16]= {FEM_ROOT_CELL_TOPOLOGY_PART_ShellLine_3} : Uses { Node = 0 Edge = 0 Face = 0 Elem = 0 }P[0] info> Part[17]= block_1 : Uses { Node = 169 Edge = 48 Face = 144 Elem = 0 }P[0] info> Part[18]= surface_1 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[19]= surface_2 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[20]= surface_3 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[21]= surface_4 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[22]= surface_quad4_edge2_1 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[23]= surface_quad4_edge2_2 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[24]= surface_quad4_edge2_3 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Part[25]= surface_quad4_edge2_4 : Uses { Node = 13 Edge = 12 Face = 0 Elem = 0 }P[0] info> Number of fields = 6P[0] info> Field[0]= coordinates rank= 1P[0] info> number of field restrictions= 1P[0] info> field restriction 0 stride[0] = 2 type= 0 ord= 0 which corresponds to Part= {UNIVERSAL}P[0] info> Field[1]= surface_1_df rank= 1P[0] info> number of field restrictions= 1P[0] info> field restriction 0 stride[0] = 2 type= 1 ord= 22 which corresponds to Part= surface_quad4_edge2_1P[0] info> Field[2]= surface_2_df rank= 1P[0] info> number of field restrictions= 1P[0] info> field restriction 0 stride[0] = 2 type= 1 ord= 23 which corresponds to Part= surface_quad4_edge2_2P[0] info> Field[3]= surface_3_df rank= 1P[0] info> number of field restrictions= 1P[0] info> field restriction 0 stride[0] = 2 type= 1 ord= 24 which corresponds to Part= surface_quad4_edge2_3P[0] info> Field[4]= surface_4_df rank= 1P[0] info> number of field restrictions= 1P[0] info> field restriction 0 stride[0] = 2 type= 1 ord= 25 which corresponds to Part= surface_quad4_edge2_4P[0] info> Field[5]= distribution_factors rank= 0P[0] info> number of field restrictions= 0 P[0] ======================================================== P[0] ========================================================P[0] ========================================================"; - - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - if (p_size <= 2) - { - - percept::PerceptMesh eMesh_0(2u); - eMesh_0.open_read_only(input_files_loc+"quad_fixture.e"); - eMesh_0.save_as(input_files_loc+"quad_fixture_readwrite.e"); - - MPI_Barrier( MPI_COMM_WORLD ); - - percept::PerceptMesh eMesh_1(2u); - percept::PerceptMesh eMesh_2(2u); - eMesh_1.open_read_only(input_files_loc+"quad_fixture_readwrite.e"); - eMesh_2.open_read_only(input_files_loc+"quad_fixture.e"); - - if (p_size == 1) - { - std::ostringstream serialized_mesh_1; - std::ostringstream serialized_mesh_2; - bool add_newlines = false; - eMesh_1.print_info(serialized_mesh_1, "quad fixture", 2, add_newlines); - eMesh_2.print_info(serialized_mesh_2, "quad fixture", 2, add_newlines); - std::string serialized_mesh_string_1 = serialized_mesh_1.str(); - std::string serialized_mesh_string_2 = serialized_mesh_2.str(); - std::cout << "expected_serialized_mesh_string.size()= " << expected_serialized_mesh_string.size() << std::endl; - std::cout << "serialized_mesh_1.size()= " << serialized_mesh_string_1.size() << std::endl; - std::cout << "serialized_mesh_1=\n" << serialized_mesh_string_1 << std::endl; - std::cout << "...serialized_mesh_1" << std::endl; - //std::cout << "serialized_mesh_2= " << serialized_mesh_string_2 << std::endl; - STKUNIT_EXPECT_TRUE(expected_serialized_mesh_string == serialized_mesh_string_2); - STKUNIT_EXPECT_TRUE(serialized_mesh_string_1 == serialized_mesh_string_2); - } - - MPI_Barrier( MPI_COMM_WORLD ); - - { - std::string diff_msg = "diff report: \n"; - bool diff = PerceptMesh::mesh_difference(eMesh_1, eMesh_2, diff_msg, true); - STKUNIT_EXPECT_TRUE(!diff); - } - - stk_classic::mesh::fem::FEMMetaData& metaData_1 = *eMesh_1.get_fem_meta_data(); - stk_classic::mesh::fem::FEMMetaData& metaData_2 = *eMesh_2.get_fem_meta_data(); - - stk_classic::mesh::BulkData& bulkData_1 = *eMesh_1.get_bulk_data(); - VectorFieldType* coordField_1 = eMesh_1.get_coordinates_field(); - stk_classic::mesh::BulkData& bulkData_2 = *eMesh_2.get_bulk_data(); - //VectorFieldType* coordField_2 = eMesh_2.get_coordinates_field(); - - MPI_Barrier( MPI_COMM_WORLD ); - - { - std::string diff_msg = "diff report 1: \n"; - bool diff = PerceptMesh::mesh_difference(metaData_1, metaData_2, bulkData_1, bulkData_2, diff_msg, true); - STKUNIT_EXPECT_TRUE(!diff); - } - - const std::vector & buckets = bulkData_1.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (in_surface_selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * const coord = stk_classic::mesh::field_data( *coordField_1 , entity ); - - coord[0] += 0.01; - } - } - } - MPI_Barrier( MPI_COMM_WORLD ); - - { - std::string diff_msg = "diff report after mod: \n"; - bool diff = PerceptMesh::mesh_difference(eMesh_1, eMesh_2, diff_msg, true); - STKUNIT_EXPECT_TRUE(diff); - } - - - } - MPI_Barrier( MPI_COMM_WORLD ); - - } - - - STKUNIT_UNIT_TEST(perceptMesh, create_skewed_mesh) - { - bool notActive = false; - if (notActive) return; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - if (p_size > 1) return; - - int thetas[] = {0,10,20,30,40,45,50,60,70,80}; - for (unsigned itheta=0; itheta < sizeof(thetas)/sizeof(thetas[0]); itheta++) - { - double theta = thetas[itheta]; - theta *= M_PI/180.0; - // create a nxn quad mesh with sidesets - const unsigned n = 20; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets_on = true; - percept::QuadFixture fixture( pm , nx , ny, sidesets_on); - fixture.set_bounding_box(0,1,0,1); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - //stk_classic::mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data(); - //const std::vector< stk_classic::mesh::Part * > & parts = metaData.get_parts(); - - if (0 == itheta) eMesh.save_as("2d_duct.e"); - stk_classic::mesh::BulkData& bulkData = *eMesh.get_bulk_data(); - VectorFieldType* coordField = eMesh.get_coordinates_field(); - - const std::vector & buckets = bulkData.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - // right-shear, theta=angle from vertical, dxdy=tan(theta) - // up-shear, theta=angle from horizontal, dydx=tan(theta) - // choose one or other, set other to 0.0 - double dxdy = std::tan(theta); - double dydx = 0.0; - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (in_surface_selector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_nodes_in_bucket = bucket.size(); - - for (unsigned iNode = 0; iNode < num_nodes_in_bucket; iNode++) - { - stk_classic::mesh::Entity& node = bucket[iNode]; - //stk_classic::mesh::EntityId nid = node.identifier(); - - double * const coord = stk_classic::mesh::field_data( *coordField , node ); - - coord[0] += dxdy*coord[1]; - coord[1] += dydx*coord[0]; - } - } - } - if (dydx != 0) - eMesh.save_as(std::string("slantThetaDYDX")+boost::lexical_cast(thetas[itheta])+".g"); - else - eMesh.save_as(std::string("slantTheta")+boost::lexical_cast(thetas[itheta])+".g"); - - } - } - - STKUNIT_UNIT_TEST(perceptMesh, create_quad_streaming_mesh) - { - bool notActive = false; - if (notActive) return; - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - if (p_size != 2) return; - - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets_on = false; - percept::QuadFixture fixture( pm , nx , ny, sidesets_on); - fixture.set_bounding_box(0,1,0,1); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - - eMesh.save_as("quad_streaming.e"); - } - - STKUNIT_UNIT_TEST(perceptMesh, test_states) - { - fixture_setup(); - PerceptMesh eMesh(0); - eMesh.open(input_files_loc+"hex_fixture.e"); - eMesh.add_coordinate_state_fields(); - eMesh.commit(); - //std::cout << "eMesh.get_coordinates_field()->number_of_states() = " << eMesh.get_coordinates_field()->number_of_states() << std::endl; - // field, dst, src - stk_classic::mesh::FieldBase * coordinates_N = eMesh.get_field("coordinates_N"); - //stk_classic::mesh::FieldBase * coordinates_NM1 = eMesh.get_field("coordinates_NM1"); - stk_classic::mesh::FieldBase * coordinates_None = eMesh.get_coordinates_field(); - - // dst,src - eMesh.copy_field(coordinates_N, coordinates_None); - Math::Matrix rm = Math::rotationMatrix(0, 30); - eMesh.transform_mesh(rm); - eMesh.save_as(output_files_loc+"hex_copy_fields_rot.e"); - eMesh.copy_field(coordinates_None, coordinates_N); - eMesh.save_as(output_files_loc+"hex_copy_fields.e"); - } - - } - } -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesquiteMesh.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesquiteMesh.cpp deleted file mode 100644 index bcc7b03827ca..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestPerceptMesquiteMesh.cpp +++ /dev/null @@ -1,1350 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - - -#include - -#if defined( STK_PERCEPT_HAS_GEOMETRY ) && defined(STK_PERCEPT_HAS_MESQUITE) - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -//#include -//#include -//#include - -// place Mesquite-related headers between the StackTrace redefinitions -#define StackTraceTmp StackTrace -#undef StackTrace -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "MeshImpl.hpp" -#include "MsqTimer.hpp" -#include "Mesquite.hpp" -#include "MsqError.hpp" -#include "Vector3D.hpp" -#include "InstructionQueue.hpp" -#include "LaplaceWrapper.hpp" -#include "PatchData.hpp" -#include "TerminationCriterion.hpp" -#include "QualityAssessor.hpp" - -/* Mesquite includes */ -#include "ParallelMeshImpl.hpp" -#include "ParallelHelper.hpp" - - -// algorithms -#include "Randomize.hpp" -#include "ConditionNumberQualityMetric.hpp" -#include "UntangleBetaQualityMetric.hpp" -#include "LPtoPTemplate.hpp" -#include "LInfTemplate.hpp" -#include "SteepestDescent.hpp" -#include "ConjugateGradient.hpp" -#include "PlanarDomain.hpp" - -#define StackTrace StackTraceTmp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic -{ - namespace percept - { - namespace unit_tests - { - Mesquite::MeshImpl *create_mesquite_mesh(PerceptMesh *eMesh, stk_classic::mesh::Selector *boundarySelector); - - -#define DO_TESTS 0 -#if DO_TESTS - -#define EXTRA_PRINT 0 - static int s_par_size_max = 2; - - //static int print_infoLevel = 0; - - //the following defines where to put the input and output files created by this set of functions -#if 0 - static const std::string input_files_loc="./input_files/"; - static const std::string output_files_loc="./output_files/"; -#else - static const std::string input_files_loc="./input_files_"; - static const std::string output_files_loc="./output_files_"; -#endif - - //============================================================================= - //============================================================================= - //============================================================================= - - // run Laplace smoother on an interior-node perturbed domain - STKUNIT_UNIT_TEST(unit_perceptMesquite, quad_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = 1; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 2) - if (p_size <= par_size_max) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets=true; - percept::QuadFixture fixture( pm , nx , ny, sidesets); - - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - - eMesh.reopen(); - eMesh.addParallelInfoFields(true,true); - eMesh.commit(); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - eMesh.populateParallelInfoFields(true,true,&boundarySelector); - - eMesh.print_info("quad fixture", 2); - eMesh.save_as(input_files_loc+"quad_smooth.0.e"); - - unsigned center_node_id = 5; - stk_classic::mesh::Entity* node = eMesh.get_bulk_data()->get_entity(0, center_node_id); - double *data = 0; - if (node) - { - data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node ); - //std::cout << "tmp srk center node= " << data[0] << " " << data[1] << std::endl; - data[0] += .2; - data[1] += .3; - } - - eMesh.save_as(input_files_loc+"quad_smooth.0_perturbed.e"); - - - if (p_size == 1) - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMLaplaceSmoother ls; - ls.run(pmm, pmd); - } - else - { - PerceptMesquiteMesh pmm0(&eMesh, 0, &boundarySelector); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMLaplaceSmoother ls; - ls.run(pmm, pmd); - } - - if (node) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[0], 1.0); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[1], 1.0); - } - - eMesh.save_as(output_files_loc+"quad_smooth.1.e"); - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // run LaplaceSmoother1, and ShapeImprover on an interior-node perturbed domain - STKUNIT_UNIT_TEST(unit_perceptMesquite, quad_2) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = 1; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 2) - if (p_size <= par_size_max) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 3; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets=true; - percept::QuadFixture fixture( pm , nx , ny, sidesets); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture", 2); - eMesh.save_as(input_files_loc+"quad_2_smooth.0.e"); - - unsigned center_node_id[4] = {6,7,10,11}; - for (int ii=0; ii < 4; ii++) - { - stk_classic::mesh::Entity* node = eMesh.get_bulk_data()->get_entity(0, center_node_id[ii]); - if (node) - { - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node ); - //std::cout << "tmp srk center node= " << data[0] << " " << data[1] << std::endl; - data[0] += .02*(ii+1); - data[1] += .03*(ii+1); - } - } - - eMesh.save_as(input_files_loc+"quad_2_smooth.0_perturbed.e"); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - bool do_jacobi = false; - - if (p_size==1) - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMLaplaceSmoother1 ls; - if (do_jacobi) - ls.get_smoother().do_jacobi_optimization(); - ls.run(pmm, pmd); - } - else - { - PerceptMesquiteMesh pmm0(&eMesh, 0, &boundarySelector); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMLaplaceSmoother1 ls; - if (do_jacobi) - ls.get_smoother().do_jacobi_optimization(); - ls.run(pmm, pmd); - } - - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[0], 1.0); - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[1], 1.0); - - eMesh.save_as(output_files_loc+"quad_2_smooth.1.e"); - } - - if (p_size <= par_size_max) - { - percept::PerceptMesh eMesh(2); - eMesh.open(input_files_loc+"quad_2_smooth.0_perturbed.e"); - eMesh.commit(); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - //bool do_jacobi = true; - //Mesquite::MsqDebug::enable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - if (p_size == 1) - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - //pmm.setDoJacobiIterations(do_jacobi); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si; - si.run(pmm, pmd); - } - else - { - PerceptMesquiteMesh pmm0(&eMesh, 0, &boundarySelector); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - //pmm.setDoJacobiIterations(do_jacobi); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si; - si.run(pmm, pmd); - } - eMesh.save_as(output_files_loc+"quad_si_smooth.1.e"); - - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[0], 1.0); - //STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[1], 1.0); - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // run ShapeImprover on a domain with one side perturbed - STKUNIT_UNIT_TEST(unit_perceptMesquite, quad_3) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = s_par_size_max; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 2) - if (p_size <= par_size_max) - { - const unsigned n = 12; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets=true; - percept::QuadFixture fixture( pm , nx , ny, sidesets); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - eMesh.print_info("quad fixture", 2); - eMesh.save_as(input_files_loc+"quad_3_smooth.0.e"); - - eMesh.reopen(); - eMesh.addParallelInfoFields(true,true); - eMesh.commit(); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - eMesh.populateParallelInfoFields(true,true,&boundarySelector); - - const std::vector & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_1(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - double ix = data[0]/double(n); - data[1] += (ix)*(1.0-ix)*0.8*double(n); - //std::cout << "tmp srk surface 1 node = " << data[0] << " " << data[1] << std::endl; - } - } - } - - eMesh.save_as(input_files_loc+"quad_3_smooth.0_perturbed.e"); - - { - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_original_quad_mesh." << p_size << "." << p_rank << ".vtk"; - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - - //bool do_jacobi = true; - //Mesquite::MsqDebug::enable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - if (p_size == 1) - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si; - si.run(pmm, pmd); - } - else - { - PerceptMesquiteMesh pmm0(&eMesh, 0, &boundarySelector); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - //pmm.setDoJacobiIterations(do_jacobi); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si; - si.run(pmm, pmd); - } - eMesh.save_as(output_files_loc+"quad_3_si_smooth.1.e"); - - { - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_smoothed_quad_mesh." << p_size << "." << p_rank << ".vtk"; - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // run PMMParallelShapeImprover on a domain with one side perturbed - STKUNIT_UNIT_TEST(unit_perceptMesquite, quad_4) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = s_par_size_max; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 2) - if (1 || p_size <= par_size_max) - { - const unsigned nele = 12; - //const unsigned nx = nele , ny = nele , nz = p_size*nele ; - const unsigned nx = nele , ny = nele; - - bool sidesets=true; - percept::QuadFixture fixture( pm , nx , ny, sidesets); - fixture.set_bounding_box(0,1,0,1); - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - //eMesh.print_info("quad fixture", 2); - eMesh.save_as(input_files_loc+"quad_4_smooth.0.e"); - - eMesh.reopen(); - eMesh.add_coordinate_state_fields(); - eMesh.add_spacing_fields(); - stk_classic::mesh::FieldBase *proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), 0); - eMesh.commit(); - eMesh.set_proc_rank_field(proc_rank_field); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - const std::vector & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& node = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node ); - double iy = data[1]; // /double(nele); - iy = iy*iy; - data[1] = iy; // *double(nele); - } - } - } - SpacingFieldUtil sfu(eMesh); - sfu.compute_spacing_field(); - eMesh.save_as(input_files_loc+"quad_4_smooth.1.e"); - - // save state of original mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_NM1"), eMesh.get_coordinates_field()); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_1(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& node = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , node ); - double ix = data[0]; // /double(nele); - //double bump_size=2.8; // 0.8 - double bump_size=2.8; // 0.8 - data[1] += (ix)*(1.0-ix)*bump_size; //*double(nele); - //std::cout << "tmp srk surface 1 node = " << data[0] << " " << data[1] << std::endl; - } - } - } - - // save state of projected mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_N"), eMesh.get_coordinates_field()); - - eMesh.save_as(input_files_loc+"quad_4_smooth.0_perturbed.e"); - - if (0) - { - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_original_quad_4_mesh." << p_size << "." << p_rank << ".vtk"; - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - - int msq_debug = 0; // 1,2,3 for more debug info - bool always_smooth = true; - //bool do_jacobi = true; - Mesquite::MsqDebug::disable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - //PerceptMesquiteMeshDomain pmd(&eMesh, 0); - PlanarDomain planar_domain(PlanarDomain::XY); - //PMMParallelShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - if (1) - { - percept::PMMParallelShapeImprover pmmpsi(1001, 1.e-4, 1); - //pmmpsi.run(pmm, &pmd, always_smooth, msq_debug); - pmmpsi.run(pmm, &planar_domain, always_smooth, msq_debug); - } - else - { - percept::PMMLaplaceSmoother1 ls; - //if (do_jacobi) - // ls.get_smoother().do_jacobi_optimization(); - ls.run(pmm, planar_domain); - } - } - - eMesh.save_as(output_files_loc+"quad_4_si_smooth.1.e"); - - if (0) - { - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_smoothed_quad_4_mesh." << p_size << "." << p_rank << ".vtk"; - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // run new parallel smoother on an interior-node perturbed domain - STKUNIT_UNIT_TEST(unit_perceptMesquite, quad_4_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = 1; - - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 2) - if (p_size <= par_size_max) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - const unsigned n = 2; - //const unsigned nx = n , ny = n , nz = p_size*n ; - const unsigned nx = n , ny = n; - - bool sidesets=true; - percept::QuadFixture fixture( pm , nx , ny, sidesets); - - fixture.meta_data.commit(); - fixture.generate_mesh(); - - percept::PerceptMesh eMesh(&fixture.meta_data, &fixture.bulk_data); - - eMesh.reopen(); - //eMesh.addParallelInfoFields(true,true); - eMesh.add_coordinate_state_fields(); - stk_classic::mesh::FieldBase *proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), 0); - //eMesh.addParallelInfoFields(true,true); - eMesh.commit(); - eMesh.set_proc_rank_field(proc_rank_field); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4; - - //eMesh.populateParallelInfoFields(true,true,&boundarySelector); - - //eMesh.print_info("quad fixture", 2); - eMesh.save_as(input_files_loc+"quad_4_1_smooth.0.e"); - - eMesh.copy_field(eMesh.get_field("coordinates_NM1"), eMesh.get_coordinates_field()); - - unsigned center_node_id = 5; - stk_classic::mesh::Entity* node = eMesh.get_bulk_data()->get_entity(0, center_node_id); - double *data = 0; - if (node) - { - data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node ); - //std::cout << "tmp srk center node= " << data[0] << " " << data[1] << std::endl; - if (1) - { - data[0] += .2; - data[1] += .3; - } - } - - eMesh.save_as(input_files_loc+"quad_4_1_smooth.0_perturbed.e"); - eMesh.copy_field(eMesh.get_field("coordinates_N"), eMesh.get_coordinates_field()); - - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - //PerceptMesquiteMeshDomain pmd(&eMesh, 0); - PlanarDomain planar_domain(PlanarDomain::XY); - //PMMParallelShapeImprover(int innerIter=100, double gradNorm = 1.e-8, int parallelIterations=20) : - if (1) - { - percept::PMMParallelShapeImprover pmmpsi(1001, 1.e-4, 1); - //pmmpsi.run(pmm, &pmd, always_smooth, msq_debug); - pmmpsi.run(pmm, &planar_domain, true, 0); - } - } - - if (node) - { - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[0], 1.0); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(data[1], 1.0); - } - - eMesh.save_as(output_files_loc+"quad_4_1_smooth.1.e"); - } - } - - - //============================================================================= - //============================================================================= - //============================================================================= - - // a cube with an internally distorted mesh - - STKUNIT_UNIT_TEST(unit_perceptMesquite, hex_1) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = s_par_size_max; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= par_size_max) - { - //const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - //const unsigned p_size = stk_classic::parallel_machine_size( pm ); - - unsigned n = 4; - std::cout << "P[" << p_rank << "] " << "tmp srk doing Laplace smoothing for hex_1 case, n = " << n << std::endl; - unsigned nn = n+1; - //std::string gmesh_spec = toString(n)+"x"+toString(n)+"x"+toString(n*p_size)+std::string("|bbox:0,0,0,1,1,1|sideset:xXyYzZ"); - //std::string gmesh_spec = toString(n)+"x"+toString(n)+"x"+toString(n*2)+std::string("|bbox:0,0,0,1,1,1|sideset:xXyYzZ"); - std::string gmesh_spec = toString(n)+"x"+toString(n)+"x"+toString(n)+std::string("|bbox:0,0,0,1,1,1|sideset:xXyYzZ"); - PerceptMesh eMesh(3); - eMesh.new_mesh(percept::GMeshSpec(gmesh_spec)); - eMesh.commit(); - eMesh.save_as(input_files_loc+"hex_1_smooth.0.e"); - - stk_classic::mesh::Selector boundarySelector_1(*eMesh.get_non_const_part("surface_1") ); - stk_classic::mesh::Selector boundarySelector_2(*eMesh.get_non_const_part("surface_2") ); - stk_classic::mesh::Selector boundarySelector_3(*eMesh.get_non_const_part("surface_3") ); - stk_classic::mesh::Selector boundarySelector_4(*eMesh.get_non_const_part("surface_4") ); - stk_classic::mesh::Selector boundarySelector_5(*eMesh.get_non_const_part("surface_5") ); - stk_classic::mesh::Selector boundarySelector_6(*eMesh.get_non_const_part("surface_6") ); - stk_classic::mesh::Selector boundarySelector = boundarySelector_1 | boundarySelector_2 | boundarySelector_3 | boundarySelector_4 | boundarySelector_5 | boundarySelector_6; - - //double delta_max = 0.01/(double(n)); - double delta_max = 0.001/(double(n)); - for (unsigned ii=1; ii <= (nn*nn*nn); ii++) - { - stk_classic::mesh::Entity* node = eMesh.get_bulk_data()->get_entity(0, ii); - if (node) - { - if (boundarySelector(*node)) continue; - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , *node ); - //std::cout << "P["< gids; - std::vector pids; - std::vector fixed; - std::vector connectivity; - std::vector coords; - unsigned num_elem=0; - unsigned num_node=0; - std::map local_id; - //unsigned rank=eMesh->get_parallel_rank(); - //unsigned psize=eMesh->get_parallel_size(); - - const std::vector & node_buckets = eMesh->get_bulk_data()->buckets( eMesh->node_rank() ); - for ( std::vector::const_iterator k = node_buckets.begin() ; k != node_buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& node = bucket[ientity]; - bool is_fixed=false; - if (boundarySelector && ((*boundarySelector)(node))) is_fixed = true; - fixed.push_back(is_fixed); - double * const coord = stk_classic::mesh::field_data( *eMesh->get_coordinates_field() , node ); - coords.push_back(coord[0]); - coords.push_back(coord[1]); - if (eMesh->get_spatial_dim()==3) - coords.push_back(coord[2]); - else - coords.push_back(0.0); - - gids.push_back(node.identifier()); - pids.push_back(node.owner_rank()); - - local_id[node.identifier()] = num_node++; - } - } - } - - const std::vector & buckets = eMesh->get_bulk_data()->buckets( eMesh->element_rank() ); - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (removePartSelector(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned num_entity_in_bucket = bucket.size(); - for (unsigned ientity = 0; ientity < num_entity_in_bucket; ientity++) - { - stk_classic::mesh::Entity& element = bucket[ientity]; - ++num_elem; - const mesh::PairIterRelation elem_nodes = element.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - for (unsigned j = 0; j < elem_nodes.size(); j++) - { - mesh::Entity & node = * elem_nodes[ j ].entity(); - connectivity.push_back(local_id[node.identifier()]); - } - } - } - } - bool *fixed_bool = new bool[num_node]; - for (unsigned ii=0; ii < num_node; ii++) fixed_bool[ii] = fixed[ii]; - - Mesquite::MsqError err; - // FIXME - works for hexes only... - EntityTopology topo = HEXAHEDRON; - const CellTopologyData *const topology = stk_classic::percept::PerceptMesh::get_cell_topology(*buckets[0]); - switch(topology->key) - { - case shards::Triangle<3>::key: - topo = TRIANGLE; - break; - case shards::Quadrilateral<4>::key: - topo = QUADRILATERAL; - break; - case shards::Tetrahedron<4>::key: - topo = TETRAHEDRON; - break; - case shards::Hexahedron<8>::key: - topo = HEXAHEDRON; - break; - case shards::Wedge<6>::key: - topo = PRISM; - break; - - case shards::Node::key: - case shards::Particle::key: - case shards::Line<2>::key: - case shards::Line<3>::key: - case shards::ShellLine<2>::key: - case shards::ShellLine<3>::key: - case shards::Beam<2>::key: - case shards::Beam<3>::key: - - case shards::Triangle<4>::key: - case shards::Triangle<6>::key: - case shards::ShellTriangle<3>::key: - case shards::ShellTriangle<6>::key: - - case shards::Quadrilateral<8>::key: - case shards::Quadrilateral<9>::key: - case shards::ShellQuadrilateral<4>::key: - case shards::ShellQuadrilateral<8>::key: - case shards::ShellQuadrilateral<9>::key: - - case shards::Tetrahedron<8>::key: - case shards::Tetrahedron<10>::key: - case shards::Tetrahedron<11>::key: - - case shards::Hexahedron<20>::key: - case shards::Hexahedron<27>::key: - - case shards::Pyramid<5>::key: - case shards::Pyramid<13>::key: - case shards::Pyramid<14>::key: - - case shards::Wedge<15>::key: - case shards::Wedge<18>::key: - - case shards::Pentagon<5>::key: - case shards::Hexagon<6>::key: - default: - throw std::runtime_error("unknown/unhandled topology in create_mesquite_mesh"); - break; - - } - - Mesquite::MeshImpl *mesh = new Mesquite::MeshImpl(num_node, num_elem, topo, - fixed_bool, &coords[0], &connectivity[0]); - - std::vector vertices; - mesh->get_all_vertices( vertices, err); MSQ_ERRZERO(err); - - //size_t default_gid=0; - void *gid_tag = mesh->tag_create( "GLOBAL_ID", Mesh::HANDLE, 1, 0, err ); MSQ_ERRZERO(err); - mesh->tag_set_vertex_data( gid_tag, num_node, &vertices[0], &gids[0], err ); MSQ_ERRZERO(err); - - //int default_pid=0; - void *pid_tag = mesh->tag_create( "PROCESSOR_ID", Mesh::INT, 1, 0, err ); MSQ_ERRZERO(err); - mesh->tag_set_vertex_data( pid_tag, num_node, &vertices[0], &pids[0], err ); MSQ_ERRZERO(err); - - return mesh; - - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // A cube with an indented bump on the bottom - - STKUNIT_UNIT_TEST(unit_perceptMesquite, hex_2) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = s_par_size_max; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= par_size_max) - { - unsigned n = 5; - std::cout << "P["< & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - double ix = data[0]; - double iy = data[1]; - data[2] = (ix)*(1.0-ix)*(iy)*(1.0-iy)*2.0*.5; - } - } - } - eMesh.save_as(input_files_loc+"hex_2_smooth.0_perturbed_small.e"); - - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_original_hex_mesh." << p_size << "." << p_rank << ".vtk"; - - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - double ix = data[0]; - double iy = data[1]; - data[2] = (ix)*(1.0-ix)*(iy)*(1.0-iy)*2.0*4.; - } - } - } - eMesh.save_as(input_files_loc+"hex_2_smooth.0_perturbed.e"); - - msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file1; - vtk_file1 << "par_untangle_original_hex_mesh." << p_size << "." << p_rank << ".vtk"; - - msqMesh->write_vtk(vtk_file1.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - - std::cout << "tmp srk doing Shape smoothing for hex_2 case..." << std::endl; - - //bool do_jacobi = true; - //Mesquite::MsqDebug::enable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - - int msq_debug = 2; // 1,2,3 for more debug info - bool always_smooth = true; - int innerIter = 100; - - if (p_size == 1) - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si(innerIter); - si.run(pmm, pmd, always_smooth, msq_debug); - } - else - { - PerceptMesquiteMesh pmm0(&eMesh, 0, &boundarySelector); - PerceptMesquiteMesh::PMMParallelMesh pmm(&pmm0); - PerceptMesquiteMeshDomain pmd(&eMesh, 0); - percept::PMMShapeImprover si(innerIter); - si.run(pmm, pmd, always_smooth, msq_debug); - } - - eMesh.save_as(output_files_loc+"hex_2_si_smooth.1.e"); - - } - } - - //============================================================================= - //============================================================================= - //============================================================================= - - // A cube with an indented bump on the bottom, new parallel smoother - - STKUNIT_UNIT_TEST(unit_perceptMesquite, hex_4) - { - EXCEPTWATCH; - stk_classic::ParallelMachine pm = MPI_COMM_WORLD ; - MPI_Barrier( MPI_COMM_WORLD ); - unsigned par_size_max = s_par_size_max; - - const unsigned p_rank = stk_classic::parallel_machine_rank( pm ); - const unsigned p_size = stk_classic::parallel_machine_size( pm ); - //if (p_size == 1 || p_size == 3) - if (p_size <= par_size_max) - { - unsigned n = 12; - std::cout << "P["< & buckets = eMesh.get_bulk_data()->buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - // cluster the mesh towards the bump - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - //if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - data[2] = data[2]*data[2]; - } - } - } - eMesh.save_as(input_files_loc+"hex_4_smooth.0.e"); - - // save state of original mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_NM1"), eMesh.get_coordinates_field()); - - Mesquite::MsqError err; - Mesquite::MeshImpl *msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file; - vtk_file << "par_original_hex_mesh." << p_size << "." << p_rank << ".vtk"; - - msqMesh->write_vtk(vtk_file.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) - { - if (boundarySelector_5(**k)) - { - stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements_in_bucket = bucket.size(); - - for (unsigned iEntity = 0; iEntity < num_elements_in_bucket; iEntity++) - { - stk_classic::mesh::Entity& entity = bucket[iEntity]; - - double * data = stk_classic::mesh::field_data( *eMesh.get_coordinates_field() , entity ); - double ix = data[0]; - double iy = data[1]; - data[2] = (ix)*(1.0-ix)*(iy)*(1.0-iy)*2.0*4.; - } - } - } - // save state of projected mesh - // field, dst, src: - eMesh.copy_field(eMesh.get_field("coordinates_N"), eMesh.get_coordinates_field()); - - eMesh.save_as(input_files_loc+"hex_4_smooth.0_perturbed.e"); - - msqMesh = create_mesquite_mesh(&eMesh, &boundarySelector); - std::ostringstream vtk_file1; - vtk_file1 << "par_untangle_original_hex_mesh." << p_size << "." << p_rank << ".vtk"; - - msqMesh->write_vtk(vtk_file1.str().c_str(), err); - if (err) {std::cout << err << endl; STKUNIT_EXPECT_TRUE(false);} - - std::cout << "tmp srk doing Shape smoothing for hex_4 case..." << std::endl; - - //bool do_jacobi = true; - //Mesquite::MsqDebug::enable(1); - Mesquite::MsqDebug::disable(1); - //Mesquite::MsqDebug::enable(2); - //Mesquite::MsqDebug::enable(3); - - int msq_debug = 0; // 1,2,3 for more debug info - bool always_smooth = true; - int innerIter = 1001; - - { - PerceptMesquiteMesh pmm(&eMesh, 0, &boundarySelector); - percept::PMMParallelShapeImprover pmmpsi(innerIter, 1.e-4, 1); - pmmpsi.run(pmm, 0, always_smooth, msq_debug); - } - - eMesh.save_as(output_files_loc+"hex_4_si_smooth.1.e"); - - } - } - - -#define MSQ_TEST 0 -#if MSQ_TEST - - //============================================================================= - //============================================================================= - //============================================================================= - - // A test of Mesquite read/write vtk, parallel smooth - - static void run_laplace(Mesquite::Mesh *mesh, Mesquite::ParallelMesh *pmesh, Mesquite::MsqError& err) - { - using namespace Mesquite; - Settings settings; - QualityAssessor qa; - - IdealWeightInverseMeanRatio qa_metric; - qa.add_quality_assessment( &qa_metric ); - - LaplacianSmoother smoother; - TerminationCriterion outer(""), inner(""); - inner.add_iteration_limit( 1 ); - outer.add_iteration_limit( 100 ); - inner.add_absolute_vertex_movement_edge_length( 1.e-3 ); - outer.add_absolute_vertex_movement_edge_length( 1.e-3 ); - - smoother.set_inner_termination_criterion( &inner ); - smoother.set_outer_termination_criterion( &outer ); - - InstructionQueue q; - q.add_quality_assessor( &qa, err ); MSQ_ERRRTN(err); - q.set_master_quality_improver( &smoother, err ); MSQ_ERRRTN(err); - q.add_quality_assessor( &qa, err ); MSQ_ERRRTN(err); - q.run_common( mesh, pmesh, 0, &settings, err ); MSQ_ERRRTN(err); - } - - STKUNIT_UNIT_TEST(unit_perceptMesquite, msq_hex_2) - { - - using namespace Mesquite; - -#define VTK_3D_DIR "./" - - using namespace std; - - /* init MPI */ - int rank, nprocs; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - - /* create processor-specific file names */ - ostringstream in_name, out_name, echo_name; - if (nprocs > 1) - { - in_name << VTK_3D_DIR << "par_original_hex_mesh." << nprocs << "." << rank << ".vtk"; - out_name << "par_smoothed_hex_mesh." << nprocs << "." << rank << ".vtk"; - echo_name << "par_input_echo_hex_mesh." << nprocs << "." << rank << ".vtk"; - } - else - { - in_name << VTK_3D_DIR << "par_original_hex_mesh.1.0.vtk" ; - out_name << "par_smoothed_hex_mesh.1.0.vtk"; - echo_name << "par_input_echo_hex_mesh.1.0.vtk"; - } - - //out_name << VTK_3D_DIR << "par_smoothed_hex_mesh." << nprocs << "." << rank << ".vtk"; - - /* load different mesh files on each processor */ - Mesquite::MsqError err; - Mesquite::MeshImpl mesh; - std::cout << "P[" << rank << "] tmp srk ::msq_hex_2 read_vtk..." << std::endl; - mesh.read_vtk(in_name.str().c_str(), err); - std::cout << "P[" << rank << "] tmp srk ::msq_hex_2 read_vtk...done" << std::endl; - if (err) {cerr << err << endl; STKUNIT_EXPECT_TRUE(false);} - - std::cout << "P[" << rank << "] tmp srk ::msq_hex_2 write_vtk echo..." << std::endl; - mesh.write_vtk(echo_name.str().c_str(),err); - if (err) {cerr << err << endl; STKUNIT_EXPECT_TRUE(false);} - std::cout << "P[" << rank << "] tmp srk ::msq_hex_2 write_vtk echo...done" << std::endl; - - /* create parallel mesh instance, specifying tags - * containing parallel data */ - if (nprocs > 1) - { - Mesquite::ParallelMeshImpl parallel_mesh(&mesh, "GLOBAL_ID", "PROCESSOR_ID"); - Mesquite::ParallelHelperImpl helper; - helper.set_communicator(MPI_COMM_WORLD); - helper.set_parallel_mesh(¶llel_mesh); - parallel_mesh.set_parallel_helper(&helper); - - /* do Laplacian smooth */ - //LaplaceWrapper optimizer; - //optimizer.run_instructions(¶llel_mesh, err); - run_laplace(&mesh, ¶llel_mesh, err); - - if (err) {cerr << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - else - { - //LaplaceWrapper optimizer; - //optimizer.run_instructions(&mesh, err); - run_laplace(&mesh, 0, err); - - if (err) {cerr << err << endl; STKUNIT_EXPECT_TRUE(false);} - } - - /* write mesh */ - mesh.write_vtk(out_name.str().c_str(),err); - if (err) {cerr << err << endl; STKUNIT_EXPECT_TRUE(false);} - - print_timing_diagnostics(cout); - - } -#endif - -#endif - - } - - - - } - -} -#endif - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestSearch.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestSearch.cpp deleted file mode 100644 index 4b90b40ee73e..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestSearch.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -using namespace stk_classic::diag; - -static const int box_count = 100; - -namespace stk_classic { -namespace percept { -namespace unit_tests { -/// PLATFORM_NOTE gcc4.3 -/// If DIM here is set to 2, the code failes to compile due to dependence of Oct tree code on assuming Dim = 3 in bounding boxes -#define DIM 3 - -#ifndef REDS -STKUNIT_UNIT_TEST(search, test1) -{ - typedef stk_classic::search::ident::IdentProc IdentProc; - typedef stk_classic::search::box::PointBoundingBox BoundingPoint; - typedef stk_classic::search::box::AxisAlignedBoundingBox BoundingBox; - typedef std::vector > IdentProcRelation; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD; - //stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - //!dw().m(LOG_SEARCH) << "Use case 1" << stk_classic::diag::push << stk_classic::diag::dendl; - - int parallel_rank = stk_classic::parallel_machine_rank(comm); - // int parallel_size = stk_classic::parallel_machine_size(comm); - - std::vector domain_vector; - - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { -#if DIM == 3 - float box[6] = {(float)i,0.0f,0.0f,i+1.0f,1.0f,1.0f }; -#else - float box[4] = {(float)i,0.0f,0.0f,i+1.0f}; -#endif - - BoundingBox domain; - domain.key.ident = i; - domain.set_box(box); - - domain_vector.push_back(domain); - } - - std::vector range_vector; - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { -#if DIM == 3 - float center[3] = {i +0.5f,0.5f, 0.5f}; -#else - float center[2] = {i +0.5f,0.5f}; -#endif - - BoundingPoint p; - p.key.ident = i; - p.set_center(center); - - range_vector.push_back(p); - } - - //dw().m(LOG_SEARCH) << "range " << range_vector << dendl; - //dw().m(LOG_SEARCH) << "domain " << domain_vector << dendl; - - stk_classic::search::FactoryOrder order; - order.m_communicator = comm; - order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE; - - //dw().m(LOG_SEARCH) << "Search algorithm " << order.m_algorithm << dendl; - - IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, domain_vector, range_vector, order); - - if (0) - { - //for (unsigned i = 0; i < relation.size(); i++) - for (unsigned i = 0; i < 10; i++) - { - std::cout << "relation[ " << i << "]= {" << relation[i].first << "} --> { " << relation[i].second << "}" << std::endl; - } - } - //dw().m(LOG_SEARCH) << "relation " << relation << dendl; - - //dw().m(LOG_SEARCH) << stk_classic::diag::pop; -} - -#endif -} -} -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestStringFunction.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestStringFunction.cpp deleted file mode 100644 index 39b6c063b43b..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestStringFunction.cpp +++ /dev/null @@ -1,703 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace percept { -namespace unit_tests { - -//============================================================================= -//============================================================================= -//============================================================================= - -#ifndef REDS -STKUNIT_UNIT_TEST(function, stringFunction_xy_basic) -{ - EXCEPTWATCH; - - // start_demo_stringFunction_xy_basic - double x=1.234, y=2.345, z=0.0; - - StringFunction sfxy(" x - y "); // an analytic function defined by the expression x - y - MDArray xyz(3); // a rank-one array with the input point - MDArray is a typedef for Intrepid::FieldContainer - xyz(0) = x; - xyz(1) = y; - xyz(2) = z; - double time = 0.0; - MDArray result(1); // a rank-one array to hold the result - sfxy(xyz, result, time); // invoke the string function - std::cout << result(0) << std::endl; // this will print the result of -1.111 - - // now do it more easily with a helper function - eval_print(x,y,z,time, sfxy); // helper function that will evaluate sfxy at (1.234,2.345,0,0) and print result of -1.111 - // end_demo -} - -STKUNIT_UNIT_TEST(function, stringFunction_xy_basic_1) -{ - EXCEPTWATCH; - - StringFunction sfx("x"); - StringFunction sfy("y"); - StringFunction sfxy("x-y"); - double x = 1.234; - double y = 5.678; - double z = 0; - double t = 0; - double xy = x-y; - - //StringFunction sfxy1== sfx-sfy; - eval_print(1,2,3,0, sfxy); - double vx = eval(x, y, z, t, sfx); - std::cout << "x = " << x << " vx= " << vx << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(vx, x); - double vy = eval(x, y, z, t, sfy); - STKUNIT_EXPECT_DOUBLE_EQ(vy, y); - double vxy = eval(x, y, z, t, sfxy); - STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy); - -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_xy_basic_2) -{ - EXCEPTWATCH; - //StringFunction sfx("x","sfx", Dimensions(), Dimensions(), 1, 4, 1); - // StringFunction sfx("x","sfx", Dimensions<4>(), Dimensions<1>()); - // StringFunction sfx("x","sfx", Dimensions<4>(), Dimensions<2,2>()); - - //StringFunction sfx("x","sfx", Dimensions(3), Dimensions(2,2)); - -#define TEST_SF_NAMED_ARG 0 -#if TEST_SF_NAMED_ARG - // these should not compile and are tests of the "named argument" proxy - StringFunction sftestNA1("x","sftestNA1", Dimensions(3), Dimensions(2,3)); - StringFunction sftestNA2("x",std::string("sftestNA2"), Dimensions(3), Dimensions(2,3)); - sftestNA1.setDomainDimensions(Dimensions(3)); - sftestNA2.setDomainDimensions(Dimensions(3)); -#else - StringFunction sftestNA("x", Name("sftestNA"), Dimensions(3), Dimensions(2,3)); - sftestNA.setDomainDimensions(Dimensions(3)); -#endif - StringFunction sftest("x",Name("sftest"), Dimensions(3), Dimensions(2,3)); - MDArray sftest_domain = sftest.getNewDomain(); - MDArray sftest_codomain = sftest.getNewCodomain(); - STKUNIT_EXPECT_EQ(sftest_domain.rank(), 1); - STKUNIT_EXPECT_EQ(sftest_domain.dimension(0), 3); - STKUNIT_EXPECT_EQ(sftest_codomain.rank(), 2); - STKUNIT_EXPECT_EQ(sftest_codomain.dimension(0), 2); - STKUNIT_EXPECT_EQ(sftest_codomain.dimension(1), 3); - - StringFunction sfx("x",Name("sfx")); - STKUNIT_EXPECT_EQ(sfx.getDomainDimensions().size(), 1u); - STKUNIT_EXPECT_EQ(sfx.getDomainDimensions()[0], 3); - STKUNIT_EXPECT_EQ(sfx.getCodomainDimensions().size(), 1u); - STKUNIT_EXPECT_EQ(sfx.getCodomainDimensions()[0], 1); - - StringFunction sfy("y"); - StringFunction sfxy("x-y"); - double x = 1.234; - double y = 5.678; - double z = 0; - double t = 0; - double xy = x-y; - //StringFunction sfxy1== sfx-sfy; - eval_print(1,2,3,0, sfxy); - double vx = eval(x, y, z, t, sfx); - std::cout << "x = " << x << " vx= " << vx << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(vx, x); - double vy = eval(x, y, z, t, sfy); - STKUNIT_EXPECT_DOUBLE_EQ(vy, y); - double vxy = eval(x, y, z, t, sfxy); - STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy); - -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_test_alias) -{ - EXCEPTWATCH; - StringFunction sfx("x", Name("sfx"), Dimensions(3), Dimensions(1)); - StringFunction sfy("y", Name("sfy"), Dimensions(3), Dimensions(1)); - StringFunction sfxy("x-y", Name("sfxy"), Dimensions(3), Dimensions(1)); - StringFunction sfembedded("sfxy", Name("sfembedded"), Dimensions(3), Dimensions(1)); - double x = 1.234; - double y = 5.678; - double z = 0; - double t = 0; - double xy = x-y; - //StringFunction sfxy1== sfx-sfy; - eval_print(1,2,3,0, sfxy); - double vx = eval(x, y, z, t, sfx); - std::cout << "x = " << x << " vx= " << vx << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(vx, x); - double vy = eval(x, y, z, t, sfy); - STKUNIT_EXPECT_DOUBLE_EQ(vy, y); - double vxy = eval(x, y, z, t, sfxy); - STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy); - - // embedded function - std::cout << "sfembedded = ..." << sfembedded << std::endl; - eval_print(1,2,3,0, sfembedded); - std::cout << "sfembedded = " << eval(x, y, z, t, sfembedded) << std::endl; - - double vxy1 = eval(x, y, z, t, sfembedded); - STKUNIT_EXPECT_DOUBLE_EQ(vxy1, xy); - - sfembedded.add_alias("sfalias"); - StringFunction sftestalias("sfalias", Name("sftestalias")); - double vxy2 = eval(x, y, z, t, sftestalias); - std::cout << "sftestalias = " << eval(x, y, z, t, sftestalias) << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(vxy2, xy); -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_vector_valued) -{ - EXCEPTWATCH; - double x = 1.234; - double y = 5.678; - double z = 3.456; - double t = 0; - - bool didCatch = false; - try { - StringFunction sfv0("v[0]=x; v[1]=y; v[2]=z; x", Name("sfv"), Dimensions(1,4), Dimensions(1,3) ); - eval_vec3_print(1,2,3,0, sfv0); - } - catch (...) - { - didCatch = true; - std::cout << "TEST::function::stringFunctionVector: expected to catch this since dom/codomain dimensions should be rank-1" << std::endl; - } - STKUNIT_EXPECT_TRUE(didCatch); - - StringFunction sfv("v[0]=x*y*z; v[1]=y; v[2]=z; x", Name("sfv"), Dimensions(3), Dimensions(3) ); - eval_vec3_print(1.234, 2.345e-3, 3.456e+5, 0., sfv); - MDArray vec = eval_vec3(x, y, z, t, sfv); - std::cout << " x = " << x - << " y = " << y - << " z = " << z - << " val = " << (vec[0]*vec[1]*vec[2]) << std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(vec[0], x*y*z); - STKUNIT_EXPECT_DOUBLE_EQ(vec[1], y); - STKUNIT_EXPECT_DOUBLE_EQ(vec[2], z); - -} - -enum {NPTS = 4}; -static double testpoints[NPTS][4] = { - {0.1234, -0.5678, 0.9, 0.812}, - {0.1234e-3, -0.5678e-5, 0.9e+8, 0.812e-4}, - {.101, 102., 10201., 0.0122}, - {0.003, -100001.1, 44.1, 3.} -}; - -static double testpoints_fd[NPTS][4] = { - {0.1234, -0.5678, 0.9, 0.812}, - {0.1234e-3, -0.5678e-5, 0.9e-3, 0.812e-4}, - {101, 102., 10.2, 0.0122}, - {0.003, .002, -0.0011,0} -}; - - -// the extra name argument is only to get around an intel compiler warning -#define DO_OP_STKUNIT_UNIT_TEST(OP,name) \ -{ \ - double xy ## name = x OP y; \ - StringFunction sfxy ## name ("x" QUOTE(OP) "y"); \ - StringFunction sfxy1 ## name = sfx OP sfy; \ - double vxy ## name = eval(x, y, z, t, sfxy ## name ); \ - STKUNIT_EXPECT_DOUBLE_EQ(vxy ## name , xy ## name); \ - double vxy1 ## name = eval(x, y, z, t, sfxy1 ## name); \ - STKUNIT_EXPECT_DOUBLE_EQ(vxy1 ## name, xy ## name); \ -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_arithmetic_ops) -{ - EXCEPTWATCH; - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - double x = testpoints[ipts][0]; - double y = testpoints[ipts][1]; - double z = testpoints[ipts][2]; - double t = testpoints[ipts][3]; - - // start_demo_stringFunction_arithmetic_ops - StringFunction sfx("x"); //python: sfx = percept.StringFunction("x") - StringFunction sfy("y"); - StringFunction sfxy(" x - y "); - - // build a new StringFunction from two existing ones - StringFunction sfxy2 = sfx - sfy; - double xy = x - y; - double vxy = eval(x, y, z, t, sfxy); - double vxy2 = eval(x, y, z, t, sfxy2); - - // the two different functions should give the same result - STKUNIT_EXPECT_DOUBLE_EQ(vxy, vxy2); - - // and they should give the same result as C++ - STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy); - - // end_demo - - StringFunction sfx1("x"); - StringFunction sfy1("y"); - double vx = eval(x, y, z, t, sfx1); - STKUNIT_EXPECT_DOUBLE_EQ(vx, x); - double vy = eval(x, y, z, t, sfy1); - STKUNIT_EXPECT_DOUBLE_EQ(vy, y); - - DO_OP_STKUNIT_UNIT_TEST(-, _minus); - DO_OP_STKUNIT_UNIT_TEST(+, _plus); - DO_OP_STKUNIT_UNIT_TEST(*, _mult); - DO_OP_STKUNIT_UNIT_TEST(/, _div); - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_derivative) -{ - EXCEPTWATCH; - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - double x = testpoints[ipts][0]; - double y = testpoints[ipts][1]; - double z = testpoints[ipts][2]; - double t = testpoints[ipts][3]; - - // start_demo_stringFunction_derivative - StringFunction sfxy(" x - y "); - StringFunction dsfxy_y("-1"); - MDArrayString dy(1,1); - dy(0,0)="y"; - std::string dy1[1][1] = {{"y"}}; - std::cout << "dy1= " << dy1[0][0] << std::endl; - //Teuchos::RCP dsfxy_y_1 = sfxy.derivative(MDArrayString_from(dy1)); - //Teuchos::RCP dsfxy_y_1 = sfxy.derivative(dy); - Teuchos::RCP dsfxy_y_1 = sfxy.derivative_test(dy); - - - double dvxy = eval(x, y, z, t, *dsfxy_y_1); - double dvxy1 = eval(x, y, z, t, dsfxy_y); - - // the two different functions should give the same result - STKUNIT_EXPECT_DOUBLE_EQ(dvxy, dvxy1); - - // and they should give the same result as C++ - STKUNIT_EXPECT_DOUBLE_EQ(dvxy, -1.0); - - // end_demo - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_derivative_1) -{ - EXCEPTWATCH; - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - double x = testpoints[ipts][0]; - double y = testpoints[ipts][1]; - double z = testpoints[ipts][2]; - double t = testpoints[ipts][3]; - - double eps=1.e-6; - double eps_loc = eps*(std::fabs(x) + std::fabs(y) + std::fabs(z) + std::fabs(t))/4.0; - - // start_demo_stringFunction_derivative_1 - StringFunction sfxy(" x - y "); - StringFunction dsfxy_grad("v[0]=1; v[1]= -1; v[2]=0", Name("test"), Dimensions(3), Dimensions(3) ); - MDArrayString dxyz(3,1); - dxyz(0,0)="x"; dxyz(1,0)="y"; dxyz(2,0)="z"; - std::string grad[] = {"1","-1","0"}; - sfxy.set_gradient_strings(grad, 3); - Teuchos::RCP dsfxy_grad_1 = sfxy.derivative_test(dxyz); - Teuchos::RCP dsfxy_grad_fd = sfxy.derivative_test_fd(dxyz, eps_loc); - Teuchos::RCP dsfxy_grad_2 = sfxy.derivative(dxyz); - - MDArray dvxy1 = eval_vec3(x, y, z, t, *dsfxy_grad_1); - MDArray dvxy_fd = eval_vec3(x, y, z, t, *dsfxy_grad_fd); - MDArray dvxy2 = eval_vec3(x, y, z, t, *dsfxy_grad_2); - MDArray dvxy = eval_vec3(x, y, z, t, dsfxy_grad); - - // the two different functions should give the same result - for (int ii = 0; ii < 3; ii++) - { - STKUNIT_EXPECT_DOUBLE_EQ(dvxy(ii), dvxy1(ii)); - STKUNIT_EXPECT_DOUBLE_EQ(dvxy(ii), dvxy2(ii)); - STKUNIT_EXPECT_DOUBLE_EQ_APPROX(dvxy(ii), dvxy_fd(ii)); - } - - // and they should give the same result as C++ - STKUNIT_EXPECT_DOUBLE_EQ(dvxy(0), 1.0); - STKUNIT_EXPECT_DOUBLE_EQ(dvxy(1), -1.0); - - // end_demo - } -} - -//============================================================================= -//============================================================================= -//============================================================================= - -STKUNIT_UNIT_TEST(function, stringFunction_derivative_2) -{ - EXCEPTWATCH; - for (unsigned ipts = 0; ipts < NPTS; ipts++) - { - double x = testpoints_fd[ipts][0]; - double y = testpoints_fd[ipts][1]; - double z = testpoints_fd[ipts][2]; - double t = testpoints_fd[ipts][3]; - - double eps=1.e-10; - double eps_loc = eps*(std::fabs(x) + std::fabs(y) + std::fabs(z) + std::fabs(t))/4.0; - - // start_demo_stringFunction_derivative_2 - StringFunction sf(" sin(x*y*z*z) " ); - std::string grad[] = {"y*z*z*cos(x*y*z*z)", "x*z*z*cos(x*y*z*z)", "2*x*y*z*cos(x*y*z*z)"}; - std::string gradv = "v[0]="+grad[0]+"; v[1]="+grad[1]+" ; v[2]="+grad[2]+";"; - StringFunction dsf_grad(gradv.c_str(), Name("test"), Dimensions(3), Dimensions(3) ); - MDArrayString dxyz(3,1); - dxyz(0,0)="x"; dxyz(1,0)="y"; dxyz(2,0)="z"; - sf.set_gradient_strings(grad, 3); - Teuchos::RCP dsf_grad_fd = sf.derivative_test_fd(dxyz, eps_loc); - Teuchos::RCP dsf_grad_2 = sf.derivative(dxyz); - - MDArray dv_fd = eval_vec3(x, y, z, t, *dsf_grad_fd); - MDArray dv2 = eval_vec3(x, y, z, t, *dsf_grad_2); - MDArray dv = eval_vec3(x, y, z, t, dsf_grad); - - // the two different functions should give the same result - for (int ii = 0; ii < 3; ii++) - { - //std::cout << "\n ii= " << ii << "\n"<< std::endl; - STKUNIT_EXPECT_DOUBLE_EQ(dv(ii), dv2(ii)); - if (std::fabs(dv(ii)-dv_fd(ii)) > 0.5*(std::fabs(dv_fd(ii))+std::fabs(dv(ii)))*1.e-6) - { - std::cout << "\nii = " << ii << " x= "< google_sparse_map_type; - google_sparse_map_type google_sparse_map1(init_capacity); - google_sparse_map_type google_sparse_map2(init_capacity); - google_sparse_map_type::iterator google_sparse_map_it1; - google_sparse_map_type::iterator google_sparse_map_it2; - - { - FindMapItem1< google_sparse_map_type, google_sparse_map_type::iterator > fm1; - if (1) doTest(google_sparse_map1, google_sparse_map_it1, N, niter, fm1, "google_sparse_map, map[key]"); - - } -#endif - - { - FindMapItem1< boost_map_type, boost_map_type::iterator > fm1; - FindMapItem2< boost_map_type, boost_map_type::iterator > fm2; - if (1) doTest(boost_map1, boost_map_it1, N, niter, fm1, "boost_map, map[key]"); - if (1) doTest(boost_map2, boost_map_it2, N, niter, fm2, "boost_map, find(key)"); - } - - { - FindMapItem1< std_map_type, std_map_type::iterator > fm1; - FindMapItem2< std_map_type, std_map_type::iterator > fm2; - if (1) doTest(std_map1, std_map_it1, N, niter, fm1, "std_map, map[key]"); - if (1) doTest(std_map2, std_map_it2, N, niter, fm2, "std_map, find(key)"); - } - - //doTest(boost_map, N, niter); - -#endif - -} - -} -} -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestTopoCheck.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestTopoCheck.cpp deleted file mode 100644 index 18a166af1132..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestTopoCheck.cpp +++ /dev/null @@ -1,761 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2010, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -//static bool isParallel = true; // FIXME -static bool isParallel() -{ - stk_classic::ParallelMachine parallel_machine = MPI_COMM_WORLD ; - int mpi_size = stk_classic::parallel_machine_size(parallel_machine); - return mpi_size > 0; -} - -namespace stk_percept_unit -{ -void use_encr_case_1_driver( MPI_Comm comm ); - -int myMain() -{ - stk_classic::ParallelMachine parallel_machine = MPI_COMM_WORLD ; - - if (isParallel() ) return 0; - - use_encr_case_1_driver( parallel_machine ); - - // Need to check whether all use-cases actually did run ok. If they didn't, then don't - // print the following "OK" string. (The "OK" string is for the runtest tool to - // determine whether the test gets a "pass" or "fail" status.) - std::cout << "unit test cases ran OK" << std::endl; - - return 0; -} - -#ifndef REDS -STKUNIT_UNIT_TEST(topo, test1) -{ - /* %TRACE[OFF]% */ /* %TRACE% */ - - // totally different - STKUNIT_EXPECT_FALSE( 0 ); - - - if (!isParallel()) - { - myMain(); - } -} -#endif - -} // namespace SEncr - - -namespace stk_classic -{ -namespace percept -{ -namespace unit_tests -{ - -#ifndef REDS -STKUNIT_UNIT_TEST(topo, testCrossedElems) -{ - - if (isParallel() ) return; - using namespace stk_classic::percept::util; - using namespace stk_classic::percept::interface_table; - /* %TRACE[OFF]% */ /* %TRACE% */ - stk_classic::ParallelMachine parallel_machine = MPI_COMM_WORLD ; - bool verbose = false; - - // totally different - STKUNIT_EXPECT_FALSE( 0 ); - - stk_classic::percept::TopologyVerifier topoVerifier; - - unsigned line2Elems[] = { - 0,1, - 1,2, - 2,3, - 3,4, - 0,0 // sentinel - }; - enum { - numElemsL2 = sizeof(line2Elems)/(2*sizeof(line2Elems[0])) - 1 // drop sentinel - }; - if(verbose) std::cout << "numElemsL2= " << numElemsL2 << std::endl; - - boost::array coordsLine[] = { - //{{0,0,0}}, {{1,0,0}}, {{2,0,0}}, {{3,0,0}}, {{4,0,0}} - {{0,0,0}}, {{1.1,0,0}}, {{2.22,0,0}}, {{3.333,0,0}}, {{4.4444,0,0}} - }; - unsigned numNodesLine = sizeof(coordsLine)/sizeof(coordsLine[0]); - if(verbose) std::cout << "numNodesLine= " << numNodesLine << std::endl; - - //------ create a valid heterogeneous mesh - // line2 mesh - SweepMesher tp2; - tp2.dump(verbose); - - tp2.initNodes(coordsLine, numNodesLine); - tp2.initElems(shards_Line_2, line2Elems, numElemsL2); - if(verbose) std::cout << "line2 mesh\n"; - tp2.dump(); - - // sweep to make a quad mesh from line mesh - boost::array< double, 3> dir = {{0,1.234,0}}; - TransformDir xf( dir ); - std::vector xforms(3, &xf); - //xforms.push_back(xf); - tp2.sweep(shards_Line_2, shards_Quadrilateral_4, xforms); - if(verbose) std::cout << "after line to quad sweep\n"; - tp2.dump(); - - SweepMesher quadMeshCopy; - quadMeshCopy.CopyFromBasicMesh(tp2); - - // break one of the quads into tris - tp2.breakElement(0); - //tp2.breakElement(1); - if(verbose) std::cout << "after break\n"; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("topo-goodQuadTri.e"); - - // verify valid topology - bool isBad = false; - if(verbose) std::cout << "verify this is a good topology " << std::endl; - isBad = topoVerifier.isTopologyBad( *tp2.get_bulk_data() ); - STKUNIT_EXPECT_FALSE(isBad); - - //------- a bad topology with a duplicated node - tp2.initialize(); - tp2.dump(verbose); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "before creating invalid mesh\n"; - tp2.dump(); - - //ShardsInterfaceTable::s_elemInfo[shards_Quadrilateral_4].vertex_count; - // { 0 1 6 5 } - // { 1 2 7 6 } - int whichElem = 1; - - STKUNIT_EXPECT_EQ(tp2.m_elems[shards_Quadrilateral_4][ 4*whichElem + 3 ], 6u); - // create a duplicated node - tp2.m_elems[shards_Quadrilateral_4][ 4*whichElem + 3 ] = 7; - - if(verbose) std::cout << "after creating invalid mesh with duplicate node\n"; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("topo-badQuadDupl.e"); - - // verify bad topology - isBad = topoVerifier.isTopologyBad( *tp2.get_bulk_data() ); - STKUNIT_EXPECT_TRUE(isBad); - - //------ create a bad topology with crossed elements - tp2.initialize(); - tp2.dump(verbose); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "before creating invalid mesh\n"; - tp2.dump(); - - //ShardsInterfaceTable::s_elemInfo[shards_Quadrilateral_4].vertex_count; - // { 0 1 6 5 } - // { 1 2 7 6 } - whichElem = 1; - - STKUNIT_EXPECT_EQ(tp2.m_elems[shards_Quadrilateral_4][ 4*whichElem + 3 ], 6u); - // create a crossed mesh - tp2.m_elems[shards_Quadrilateral_4][ 4*whichElem + 3 ] = 5; - - if(verbose) std::cout << "after creating invalid mesh\n"; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("topo-badQuadCrossed.e"); - - // verify bad topology - isBad = topoVerifier.isTopologyBad( *tp2.get_bulk_data() ); - STKUNIT_EXPECT_TRUE(isBad); -} - -STKUNIT_UNIT_TEST(geom, geomPrints) -{ - if (isParallel() ) return; - using namespace stk_classic::percept::util; - using namespace stk_classic::percept::interface_table; - - /* %TRACE[OFF]% */ /* %TRACE% */ - stk_classic::ParallelMachine parallel_machine = MPI_COMM_WORLD ; - bool verbose = false; - - // totally different - STKUNIT_EXPECT_FALSE( 0 ); - - stk_classic::percept::GeometryVerifier geomVerifier(false); // true for more dumps - - unsigned line2Elems[] = { - 0,1, - 1,2, - 2,3, - 3,4, - 0,0 // sentinel - }; - enum { - numElemsL2 = sizeof(line2Elems)/(2*sizeof(line2Elems[0])) - 1 // drop sentinel - }; - if(verbose) std::cout << "numElemsL2= " << numElemsL2 << std::endl; - - boost::array coordsLine[] = { - //{{0,0,0}}, {{1,0,0}}, {{2,0,0}}, {{3,0,0}}, {{4,0,0}} - {{0,0,0}}, {{1.1,0,0}}, {{2.22,0,0}}, {{3.333,0,0}}, {{4.4444,0,0}} - }; - unsigned numNodesLine = sizeof(coordsLine)/sizeof(coordsLine[0]); - if(verbose) std::cout << "numNodesLine= " << numNodesLine << std::endl; - - //------ create a valid heterogeneous mesh - // line2 mesh - SweepMesher tp2; - tp2.dump(verbose); - - tp2.initNodes(coordsLine, numNodesLine); - tp2.initElems(shards_Line_2, line2Elems, numElemsL2); - if(verbose) std::cout << "line2 mesh\n"; - tp2.dump(); - - // sweep to make a quad mesh from line mesh - boost::array< double,3> dir = {{0,1.234,0}}; - TransformDir xf ( dir ); - std::vector xforms(3, &xf); - //xforms.push_back(xf); - tp2.sweep(shards_Line_2, shards_Quadrilateral_4, xforms); - - //if(true || verbose) std::cout << "after line to quad sweep\n"; - if( verbose) std::cout << "after line to quad sweep\n"; - //tp2.dump(true); - tp2.dump(); - - SweepMesher quadMeshCopy; - quadMeshCopy.CopyFromBasicMesh(tp2); - - // break one of the quads into tris - tp2.breakElement(0); - //tp2.breakElement(1); - if(verbose) std::cout << "after break\n"; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("geom-goodQuadTri.e"); - - // verify valid geometry - bool isBad = false; - if(verbose) std::cout << "verify this is a good geometry " << std::endl; - isBad = geomVerifier.isGeometryBad( *tp2.get_bulk_data() ); - STKUNIT_EXPECT_FALSE(isBad); - - /////////////// path test 3 - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - double rad = 10.0; - boost::array dirT = {{0,rad,0}}; - xf = TransformDir( dirT ); - tp2.transform(xf); - - VectorOfCoord path3; - VectorOfCoord dir3; - - boost::array pt0 = {{0,rad,0}} ; - path3.push_back(pt0); - boost::array dr0 = {{0,0,1}} ; - dir3.push_back(dr0); - - unsigned ntheta = 8; - for (unsigned ith = 1; ith <= ntheta; ith++) - { - double th = M_PI*((double)ith)/((double)ntheta); - boost::array pt1 = {{0, rad*cos(th), rad*sin(th)}}; - boost::array dr1 = {{0, -sin(th), cos(th)}}; - path3.push_back(pt1); - dir3.push_back(dr1); - } - tp2.sweep(path3, dir3); - - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("geom-all-hex-path3.e"); - geomVerifier = GeometryVerifier(false); - geomVerifier.isGeometryBad(*tp2.get_bulk_data() ); - - // break path3 of the hexes into tets - tp2.breakAllElements(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("geom-all-hex-tet-path3.e"); - geomVerifier.isGeometryBad(*tp2.get_bulk_data() ); - -} - -STKUNIT_UNIT_TEST(geom, geomEqui) -{ - if (isParallel() ) return; - using namespace stk_classic::percept::util; - using namespace stk_classic::percept::interface_table; - - /* %TRACE[OFF]% */ /* %TRACE% */ - stk_classic::ParallelMachine parallel_machine = MPI_COMM_WORLD ; - bool verbose = false; - - stk_classic::percept::GeometryVerifier geomVerifier(false); // true for more dumps - - unsigned tetElems[] = { - 0,1,2,3 - }; - enum { - numElems = 1 - }; - - boost::array coordsTet[] = { - {{0,0,0}}, {{1,0,0}}, {{0.5,sqrt(3.)/2.,0}}, {{0.5,sqrt(3.)/6.,sqrt(6.)/3.}} - }; - unsigned numNodesTet = sizeof(coordsTet)/sizeof(coordsTet[0]); - if(verbose) std::cout << "numNodesTet= " << numNodesTet << std::endl; - - //------ create a valid mesh of one tet element - // - SweepMesher tp2; - tp2.dump(verbose); - - tp2.initNodes(coordsTet, numNodesTet); - tp2.initElems(shards_Tetrahedron_4, tetElems, numElems); - if(verbose) std::cout << "tet4 mesh\n"; - tp2.dump(); - - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("equi-tet.e"); - geomVerifier = GeometryVerifier(false); - geomVerifier.isGeometryBad(*tp2.get_bulk_data(), true ); - - //------ scale the mesh - double sf= 4.0; - boost::array coordsTetScaled[] = { - {{0,0,0}}, {{sf*1,0,0}}, {{sf*0.5,sf*sqrt(3.)/2.,0}}, {{sf*0.5, sf*sqrt(3.)/6., sf*sqrt(6.)/3.}} - }; - - tp2.initialize(); - tp2.initNodes(coordsTetScaled, numNodesTet); - tp2.initElems(shards_Tetrahedron_4, tetElems, numElems); - if(verbose) std::cout << "tet4 mesh scaled\n"; - tp2.dump(); - - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("equi-tet-scaled.e"); - geomVerifier = GeometryVerifier(false); - geomVerifier.isGeometryBad(*tp2.get_bulk_data(), true ); - -} -#endif - - -} -} -} - - - -using namespace stk_classic ; - - -namespace stk_percept_unit { - -enum { SpatialDim = 3 }; - -//---------------------------------------------------------------------- - -typedef mesh::Field ScalarFieldType ; -typedef mesh::Field VectorFieldType ; - -// Specification for the aggressive gather pointer-field for elements. - -typedef mesh::Field ElementNodePointerFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. -// copied from stk_classic::mesh use cases - -void use_encr_case_1_generate_mesh( - mesh::BulkData & mesh , - const unsigned N[] , - const VectorFieldType & node_coord , - const ElementNodePointerFieldType & elem_node_coord , - mesh::Part & hex_block ); - - - -//-------------------------------------------------------------------- -// -// main driver for use-case 13: heterogeneous element mesh. -// - -void use_encr_case_1_driver( MPI_Comm comm ) -{ - const unsigned p_rank = parallel_machine_rank( comm ); - - //reset_malloc_stats(); - - const unsigned box_size[3] = { 1 , 1 , 1 }; - - //-------------------------------------------------------------------- - - if ( ! p_rank ) { - std::cout << "stk_percept_utest begin" << std::endl - << " Number Processes = " << parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - mesh::fem::FEMMetaData mesh_meta_data(3, mesh::fem::entity_rank_names(3) ); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - mesh::Part & universal = mesh_meta_data.universal_part(); - mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", mesh_meta_data.element_rank()); - - /// set cell topology for the part block_1 - stk_classic::mesh::fem::set_cell_topology< shards::Hexahedron<8> >( block_hex ); - - //-------------------------------- - // Declare coordinates field on all nodes with 3D: - - VectorFieldType & coordinates_field = - mesh_meta_data.declare_field< VectorFieldType >( "coordinates" ); - - stk_classic::mesh::put_field( - coordinates_field , mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - - //-------------------------------- - // Declare an aggressive "gather" field which is an - // array of pointers to the element's nodes' coordinate field data. - // The declaration specifies: - // - // double * elem_node_coord[number_of_nodes] - - ElementNodePointerFieldType & elem_node_coord = - mesh_meta_data. - declare_field< ElementNodePointerFieldType >( "elem_node_coord" ); - - // Declare that the 'elem_node_coord' pointer field data - // points to the 'coordinates_field' data on the nodes. - - mesh_meta_data.declare_field_relation( - elem_node_coord , - stk_classic::mesh::fem::get_element_node_stencil(3) , - coordinates_field ); - - // Declare the size of the aggressive "gather" field - // double * elem_node_coord[ size = number_of_nodes ] - // is the number of nodes of the elements. - // This size is different for each element block. - - stk_classic::mesh::put_field( - elem_node_coord , mesh_meta_data.element_rank() , block_hex , shards::Hexahedron<8> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - // mesh::BulkData bulk data conforming to the meta data. - - mesh::BulkData mesh_bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(mesh_meta_data) , MPI_COMM_WORLD ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_encr_case_1_generate_mesh( - mesh_bulk_data , - box_size , - coordinates_field , - elem_node_coord , - block_hex ); - - //use_encr_case_1_generate_sides( mesh_bulk_data , false ); - - - { - std::vector count ; - mesh::Selector selector(mesh_meta_data.globally_shared_part()); - count_entities( selector, mesh_bulk_data, count ); - - std::cout << " P" << p_rank << ": Uses {" ; - std::cout << " Node = " << count[ 0 ] ; - std::cout << " Edge = " << count[ 1 ] ; - std::cout << " Face = " << count[ 2 ] ; - std::cout << " Elem = " << count[ 3 ] ; - std::cout << " }" << std::endl ; - std::cout.flush(); - } - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<::const_iterator > -// -// Where PairIter is a wrapper for a pair of iterators. - - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - - -} // namespace stk_percept_unit - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_percept_unit { - -void use_encr_case_1_generate_mesh( - mesh::BulkData & mesh , - const unsigned N[] , - const VectorFieldType & node_coord_field , - const ElementNodePointerFieldType & elem_node_coord_field, - mesh::Part & hex_block ) -{ - //EXCEPTWATCH; - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - stk_classic::percept::TopologyVerifier topoVerifier; - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - stk_classic::io::util::GeneratedMesh gmesh( N[0], N[1], N[2], parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = wall_time(); - - std::vector node_map( num_nodes , 0 ); - - // global nodes - gmesh.node_map( node_map ); - - // create a bad element - node_map[1] = node_map[0]; - - //TODO CPPUNIT_ASSERT_EQUAL( num_nodes , node_map.size() ); - - { - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - gmesh.element_map( i, elem_map ); - - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.connectivity( i , elem_conn ); - - //std::cout << "top_info.first= " < node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - mesh::Entity * const node = mesh.get_entity( mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord_field , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - - //FIXME ??? elem_node_coord_field - } - - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - all_reduce( mesh.parallel() , ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = wall_dtime( t ); - - all_reduce( mesh.parallel() , ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_percept_unit - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestUtilities.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestUtilities.cpp deleted file mode 100644 index ace9b2128717..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UnitTestUtilities.cpp +++ /dev/null @@ -1,1043 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2009, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include - -using namespace stk_classic ; - -/** \addtogroup stk_io_module - * \{ - */ - -/** - * Example code showing a basic, but complete, mesh to results output - * coding including subsetting and periodic field input and output. - * Includes handling of nodeblocks, element blocks, nodesets, - * and sidesets. Attribute fields and distribution factor - * fields are also supported. - * - * This example can serve as the basis for adding binary IO support to - * an application. The code here uses the Ioss to/from stk_classic::mesh - * bridge functions in the stk_classic::io namespace defined in IossBridge.hpp - * include file. - */ -namespace stk_example_io { - -/// Declare "coordinates" field and put it on the universal part. This -/// example also defines all Ioss::Field::TRANSIENT fields that exist on the -/// Ioss::Nodeblock as fields on the universal part. -void process_nodeblocks (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - -/// Declare a part for each element block on the Ioss::Region -/// 'region' unless the element block has the "omitted" property set -/// to the value 1. The example then iterates each element block and -/// defines any Ioss::Field::ATTRIBUTE and Ioss::Field::TRANSIENT fields that exist on the -/// Ioss::ElementBlock as fields on the corresponding part. -void process_elementblocks (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - -/// Declare a part for each Ioss::NodeSet on the Ioss::Region -/// 'region' unless the nodeset has the "omitted" property set -/// to the value 1. The example then iterates each nodeset and -/// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that -/// exist on the Ioss::NodeSet as fields on the corresponding -/// part. -void process_nodesets (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - -/// Declare a part for each Ioss::SideSet on the Ioss::Region -/// 'region' unless the sideset has the "omitted" property set -/// to the value 1. The example then iterates each sideset and -/// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that -/// exist on the Ioss::SideSet as fields on the corresponding -/// part. -/// -/// Each sideblock in the active sidesets is then processed by -/// defining a part for each Ioss::SideBlock on the Ioss::SideSet -/// unless the sideblock has the "omitted" property set to the value -/// 1. The example then iterates each sideblock and defines any -/// "distribution factor" and Ioss::Field::TRANSIENT fields that exist on the -/// Ioss::SideBlock as fields on the corresponding part. -void process_sidesets (Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta); - -/// NOTE: This must be called after the process_elementblocks() call -/// since there may be nodes that exist in the database that are -/// not part of the analysis mesh due to subsetting of the element -/// blocks. -/// -/// Populates the "coordinates" field for all active nodes in the model. -void process_nodeblocks (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - -/// NOTE: This should be the first function called of any of the -/// "process_X" type functions that take an stk_classic::mesh::BulkData -/// argument, especially if the input Ioss::Region mesh is going to -/// be subsetted (have element blocks omitted). -/// -/// This function iterates all non-omitted element blocks and -/// declares each element (and the corresponding nodes) in the -/// element block. If there are any Ioss::Field::ATTRIBUTE fields on the element -/// block (for example, shell thickness or particle radius), then -/// that field data is alse read and the corresponding -/// stk_classic::mesh::Field populated. -void process_elementblocks (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - -/// Iterates each non-omitted Ioss::NodeSet and then iterates each -/// node in the Ioss::NodeSet. If the node exists (that is, it is -/// connected to a non-omitted Ioss::ElementBlock), then that node -/// is associated with the part corresponding to this -/// Ioss::NodeSet. If the "distribution_factor" field exists, then -/// that data is also associated with the field. -void process_nodesets (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - -/// Process each non-omitted Ioss::SideSet and the contained -/// non-omitted Ioss::SideBlock and associate each element-side pair with -/// the corresponding part if the underlying element is active. If -/// the "distribution_factor" field exists, then that data is also -/// associated with the corresponding field. -void process_sidesets (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - -/// A minimal example function showing how field data on the -/// Ioss::Region entities can be periodically transferred to the -/// corresponding field(s) on the stk_classic::mesh entities. This would be -/// used to bring in initial condition data or interpolation data or -/// any other scenario in which data on the mesh file needs to be -/// transferred to the stk_classic::mesh fields. -void process_input_request (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - -/// A minimal example function showing how stk_classic::mesh field data can -/// periodically be output to a results, history, heartbeat, or -/// restart database. The scheduling would be done either in this -/// function or at a higher level and is not shown here. The -/// function iterates all parts and if there is a corresponding Ioss -/// part on the Ioss::Region, all fields defined to be output are -/// iterated and their data output to the corresponding -/// Ioss::Field. The function calls the -/// stk_classic::io::is_valid_part_field() function to determine whether the -/// field should be output and then calls the -/// stk_classic::io::field_data_to_ioss() function to do the actual output -/// of the field. -void process_output_request(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - -/// This function shows the basic calls needed to perform definition -/// and input of the mesh model and definition and periodic output -/// of a results database. The function is given the mesh filename -/// and the output filename and goes through all steps of -/// associating the filename with an Ioss::DatabaseIO object of the -/// correct type ("exodusII" in this example); creating an -/// Ioss::Region and then defining an stk_classic::mesh corresponding to -/// this mesh. The function also provides an example of how -/// specific element blocks existing in the mesh database could be -/// omitted from the analysis model. -/// -/// The example then shows how to define a results database -/// corresponding to the analysis model and periodically output the -/// results in an execute loop. -/// -/// A true application would have to provide additional -/// functionality and robustness, but the example shows how the -/// basic functionality can be provided by an application. -/// -/// Note that the paradigm illustrated here is different than the -/// mesh input and output paradigm provided in the current -/// framework. In this case, the application is responsible for the -/// majority of the IO behavior and the toolkit only provides some -/// helper functions to bridge between the Ioss and the stk_classic::mesh. -/// It is hoped that this paradigm will result in more functionality -/// for the application with less complication and overhead. - -typedef mesh::Field ScalarFieldType ; -typedef mesh::Field VectorFieldType ; - -// Specification for the aggressive gather pointer-field for elements. - -typedef mesh::Field ElementNodePointerFieldType ; -void my_test( - mesh::BulkData & M , - const unsigned elem_type , - const VectorFieldType & coord_field , - const VectorFieldType & elem_centroid_field ); - -void io_example( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string& out_filename) -{ - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - std::cout << "========================================================================\n" - << " Use Case: Subsetting with df and attribute field input/output \n" - << "========================================================================\n"; - - std::string dbtype("exodusII"); - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(dbtype, in_filename, Ioss::READ_MODEL, - comm); - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << in_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - Ioss::Region in_region(dbi, "input_model"); - - // SUBSETTING PARSING/PREPROCESSING... - // Just an example of how application could control whether an - // entity is subsetted or not... - - - // Example command line in current code corresponding to behavior below: - std::cout << "\nWhen processing file multi-block.g for use case 2, the blocks below will be omitted:\n"; - std::cout << "\tOMIT BLOCK Cblock Eblock I1 I2\n\n"; - Ioss::ElementBlock *eb = in_region.get_element_block("cblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("eblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i1"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i2"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - -#if 0 - // Example for subsetting -- omit "odd" blocks - if (entity->type() == Ioss::ELEMENTBLOCK) { - int id = entity->get_property("id").get_int(); - if (id % 2) { - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - std::cout << "Skipping " << entity->type_string() << ": " << entity->name() << "\n"; - } - } -#endif - -#define IOTEST 1 - - //---------------------------------- - // Process Entity Types. Subsetting is possible. - stk_classic::mesh::fem::FEMMetaData meta_data(3, stk_classic::mesh::fem::entity_rank_names(3) ); - stk_classic::mesh::Part & universal = meta_data.universal_part(); -#if IOTEST - process_elementblocks(in_region, meta_data); - process_nodeblocks(in_region, meta_data); - process_sidesets(in_region, meta_data); - process_nodesets(in_region, meta_data); -#endif - - //-------------------------------- - // Declare coordinates field on all nodes with 3D: - - VectorFieldType & coordinates_field = - meta_data.declare_field< VectorFieldType >( "coordinates" ); - - //int SpatialDim = 3; - enum { SpatialDim = 3 }; - - stk_classic::mesh::put_field( - coordinates_field , mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - - //VectorFieldType & face_field = - // mesh_meta_data.declare_field< VectorFieldType >( "face_flux" ); - - VectorFieldType & elem_centroid_field = - *meta_data.get_field< VectorFieldType >( "ind_coarse" ); - - VectorFieldType & elem_centroid_field2 = - meta_data.declare_field< VectorFieldType >( "ind_coarse2" ); - - mesh::Part * block_1 = meta_data.get_part("block_1"); - stk_classic::mesh::put_field( - elem_centroid_field2 , meta_data.element_rank() , *block_1 , SpatialDim ); - - - //-------------------------------- - // Declare an aggressive "gather" field which is an - // array of pointers to the element's nodes' coordinate field data. - // The declaration specifies: - // - // double * elem_node_coord[number_of_nodes] - - ElementNodePointerFieldType & elem_node_coord = - meta_data. - declare_field< ElementNodePointerFieldType >( "elem_node_coord" ); - - // Declare that the 'elem_node_coord' pointer field data - // points to the 'coordinates_field' data on the nodes. - - meta_data.declare_field_relation( - elem_node_coord , - stk_classic::mesh::fem::get_element_node_stencil(SpatialDim), - coordinates_field ); - - // Declare the size of the aggressive "gather" field - // double * elem_node_coord[ size = number_of_nodes ] - // is the number of nodes of the elements. - // This size is different for each element block. - - stk_classic::mesh::put_field( - elem_node_coord , meta_data.element_rank() , universal , shards::Hexahedron<8> ::node_count ); - - - //---------------------------------- - // Done populating meta data, commit and create bulk data - meta_data.commit(); - - //---------------------------------- - // Process Bulkdata for all Entity Types. Subsetting is possible. - stk_classic::mesh::BulkData bulk_data(mesh::fem::FEMMetaData::get_meta_data(meta_data), comm); -#if IOTEST - process_elementblocks(in_region, bulk_data); - process_nodeblocks(in_region, bulk_data); - process_sidesets(in_region, bulk_data); - process_nodesets(in_region, bulk_data); -#endif - - - //---------------------------------- - // OUTPUT...Create the output "mesh" portion - - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create(dbtype, out_filename, - Ioss::WRITE_RESULTS, - comm); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - Ioss::Region out_region(dbo, "results_output"); - - stk_classic::io::define_output_db(out_region, bulk_data, &in_region); - stk_classic::io::write_output_db(out_region, bulk_data); - - // ------------------------------------------------------------------------ - /** \todo REFACTOR A real app would register a subset of the - * fields on the mesh database as fields that the app would want - * read at one or all or specified steps. In this example, all - * fields existing on the input mesh database are defined on the - * parts in the stk_classic::mesh. - * - * The real app would also only register a subset of the stk_classic::mesh - * fields as output fields and would probably have a mapping from - * the internally used name to some name picked by the user. In - * this example, all Ioss::Field::TRANSIENT fields defined on the stk_classic::mesh are - * output to the results database and the internal stk_classic::mesh field - * name is used as the name on the database.... - */ - - out_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields(meta_data.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - out_region.get_node_blocks()[0], - Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = out_region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = sset->get_block(i); - stk_classic::io::ioss_add_fields(*part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - fb, Ioss::Field::TRANSIENT); - } - } else { - stk_classic::io::ioss_add_fields(*part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - out_region.end_mode(Ioss::STATE_DEFINE_TRANSIENT); - // ------------------------------------------------------------------------ - - // Read and Write transient fields... - out_region.begin_mode(Ioss::STATE_TRANSIENT); - int timestep_count = in_region.get_property("state_count").get_int(); - for (int step = 1; step <= timestep_count; step++) { - double time = in_region.get_state_time(step); - - // Read data from the io input mesh database into stk_classic::mesh fields... - process_input_request(in_region, bulk_data, step); - - // execute() - my_test (bulk_data, meta_data.element_rank() , coordinates_field, elem_centroid_field); - - // Write data from the stk_classic::mesh fields out to the output database.a - int out_step = out_region.add_state(time); - process_output_request(out_region, bulk_data, out_step); - } - out_region.end_mode(Ioss::STATE_TRANSIENT); -} - -// ======================================================================== -void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) -{ - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - assert(nb->field_exists("mesh_model_coordinates")); - Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); - int spatial_dim = coordinates.transformed_storage()->component_count(); - - stk_classic::mesh::Field & coord_field = - meta.declare_field >("coordinates"); - - stk_classic::mesh::put_field( coord_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta.universal_part(), - spatial_dim); - - /** \todo IMPLEMENT truly handle fields... For this case we are - * just defining a field for each transient field that is present - * in the mesh... - */ - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK); -} - -// ======================================================================== -void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) -{ - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - mesh::EntityRank stk_mesh_Element = 3; - stk_classic::io::default_part_processing(elem_blocks, stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta), stk_mesh_Element); - - // Parts were created above, now handle element block specific - // information (topology, attributes, ...); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - - // Element Block attributes (if any)... - /** \todo IMPLEMENT truly handle attribute fields... For this - * case we are just defining a field for each attribute field - * that is present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::ATTRIBUTE, - *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ) ); - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ) ); - - const CellTopologyData* cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(*part); - std::string cell_topo_name = "UNKNOWN"; - if (cell_topo != NULL) - cell_topo_name = cell_topo->name; - - std::cout << entity->type_string() << ": " << entity->name() - << " , celltop = " << cell_topo_name - << std::endl ; - } - } -} - -// ======================================================================== -void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) -{ - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - stk_classic::io::default_part_processing(node_sets, stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta), stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - /** \todo REFACTOR should "distribution_factor" be a default field - * that is automatically declared on all objects that it exists - * on as is done in current framework? - */ - stk_classic::mesh::Field & distribution_factors_field = - meta.declare_field >("distribution_factors"); - - /** \todo REFACTOR How to associate distribution_factors field - * with the nodeset part if a node is a member of multiple - * nodesets - */ - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - assert(entity->field_exists("distribution_factors")); - - stk_classic::mesh::put_field(distribution_factors_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, *part); - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ) ); - } - } -} - -// ======================================================================== -void process_surface_entity(Ioss::SideSet *entity, stk_classic::mesh::fem::FEMMetaData &meta, - stk_classic::mesh::EntityRank entity_rank) -{ - assert(entity->type() == Ioss::SIDESET); - const Ioss::SideBlockContainer& blocks = entity->get_side_blocks(); - stk_classic::io::default_part_processing(blocks, stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta), entity_rank); - - stk_classic::mesh::Part* const fs_part = meta.get_part(entity->name()); - assert(fs_part != NULL); - - stk_classic::mesh::Field *distribution_factors_field = NULL; - bool surface_df_defined = false; // Has the surface df field been defined yet? - - int block_count = entity->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = entity->get_block(i); - if (stk_classic::io::include_entity(fb)) { - std::cout << fb->type_string() << " " << fb->name() << "\n"; - stk_classic::mesh::Part * const fb_part = meta.get_part(fb->name()); - assert(fb_part != NULL); - meta.declare_part_subset(*fs_part, *fb_part); - - if (fb->field_exists("distribution_factors")) { - if (!surface_df_defined) { - std::string field_name = entity->name() + "_df"; - distribution_factors_field = - &meta.declare_field >(field_name); - stk_classic::io::set_distribution_factor_field(*fs_part, *distribution_factors_field); - surface_df_defined = true; - } - stk_classic::io::set_distribution_factor_field(*fb_part, *distribution_factors_field); - int face_node_count = fb->topology()->number_nodes(); - stk_classic::mesh::put_field(*distribution_factors_field, - stk_classic::percept::PerceptMesh::fem_entity_rank( fb_part->primary_entity_rank() ), - *fb_part, face_node_count); - } - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(fb, Ioss::Field::TRANSIENT, - *fb_part, - stk_classic::percept::PerceptMesh::fem_entity_rank( fb_part->primary_entity_rank() ) ); - } - } -} - -// ======================================================================== -void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) -{ - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - //!< - mesh::EntityRank stk_mesh_Side = 2; - stk_classic::io::default_part_processing(side_sets, stk_classic::mesh::fem::FEMMetaData::get_meta_data(meta), stk_mesh_Side); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, meta, stk_mesh_Side); // FIXME - } - } -} - -// ======================================================================== -// Bulk Data -// ======================================================================== -void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - // This must be called after the "process_element_blocks" call - // since there may be nodes that exist in the database that are - // not part of the analysis mesh due to subsetting of the element - // blocks. - - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - std::vector nodes; - stk_classic::io::get_entity_list(nb, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, bulk, nodes); - - /** \todo REFACTOR Application would probably store this field - * (and others) somewhere after the declaration instead of - * looking it up each time it is needed. - */ - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates"); -} - -// ======================================================================== -void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string &name = entity->name(); - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - - const CellTopologyData* cell_topo = stk_classic::percept::PerceptMesh::get_cell_topology(*part); - if (cell_topo == NULL) { - std::ostringstream msg ; - msg << " UnitTestUtilities::process_elementblocks::INTERNAL_ERROR: Part " << part->name() << " returned NULL from stk_classic::percept::PerceptMesh::get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - - std::vector elem_ids ; - std::vector connectivity ; - - entity->get_field_data("ids", elem_ids); - entity->get_field_data("connectivity", connectivity); - - size_t element_count = elem_ids.size(); - int nodes_per_elem = cell_topo->node_count ; - std::vector e_connectivity(nodes_per_elem) ; - - std::vector elements(element_count); - for(size_t i=0; ifield_describe(Ioss::Field::ATTRIBUTE, &names); - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if (*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = meta.get_field(*I); - stk_classic::io::field_data_from_ioss(field, elements, entity, *I); - - } - } - } -} - -// ======================================================================== -void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - // Should only process nodes that have already been defined via the element - // blocks connectivity lists. - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string & name = entity->name(); - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - stk_classic::mesh::PartVector add_parts( 1 , part ); - - std::vector node_ids ; - int node_count = entity->get_field_data("ids", node_ids); - - std::vector nodes(node_count); - for(int i=0; i *df_field = - meta.get_field >("distribution_factors"); - - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors"); - } - } - } -} - -// ======================================================================== -void process_surface_entity(const Ioss::SideSet* io , - stk_classic::mesh::BulkData & bulk) -{ - assert(io->type() == Ioss::SIDESET); - const stk_classic::mesh::fem::FEMMetaData& meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - int block_count = io->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *block = io->get_block(i); - if (stk_classic::io::include_entity(block)) { - std::vector side_ids ; - std::vector elem_side ; - - stk_classic::mesh::Part * const fb_part = meta.get_part(block->name()); - - block->get_field_data("ids", side_ids); - block->get_field_data("element_side", elem_side); - - assert(side_ids.size() * 2 == elem_side.size()); - stk_classic::mesh::PartVector add_parts( 1 , fb_part ); - - size_t side_count = side_ids.size(); - std::vector sides(side_count); - for(size_t is=0; is *df_field = - stk_classic::io::get_distribution_factor_field(*fb_part); - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors"); - } - } - } -} - -// ======================================================================== -void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) -{ - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } -} - -// ======================================================================== -// ======================================================================== -void get_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) -{ - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::fem::FEMMetaData & meta = stk_classic::mesh::fem::FEMMetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_from_ioss(f, entities, io_entity, f->name()); - } - } -} - -void process_input_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) -{ - region.begin_state(step); - - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::fem::FEMMetaData & meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - // ??? Get field data from nodeblock... - get_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = sset->get_block(i); - get_field_data(bulk, *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - fb, Ioss::Field::TRANSIENT); - } - } else { - get_field_data(bulk, *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - - region.end_state(step); -} - -void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) -{ - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::fem::FEMMetaData & meta = stk_classic::mesh::fem::FEMMetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role); - } - } -} - -void process_output_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) -{ - region.begin_state(step); - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::fem::FEMMetaData & meta = stk_classic::mesh::fem::FEMMetaData::get(bulk); - - put_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - int block_count = sset->block_count(); - - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = sset->get_block(i); - put_field_data(bulk, *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - fb, Ioss::Field::TRANSIENT); - } - } else { - put_field_data(bulk, *part, - stk_classic::percept::PerceptMesh::fem_entity_rank( part->primary_entity_rank() ), - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - region.end_state(step); -} - -void my_test( - mesh::BulkData & M , - const unsigned elem_type , - const VectorFieldType & coord_field , - const VectorFieldType & elem_centroid_field ) -{ - const mesh::fem::FEMMetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get(M); - - // Get vector of buckets ( entities and field data) - // for which the sides are all locally owned. - - mesh::Selector select_owned( meta_data.locally_owned_part() ); - - const std::vector & buckets = M.buckets( elem_type ); - //double sum[3]; - - for ( std::vector::const_iterator - ik = buckets.begin() ; ik != buckets.end() ; ++ik ) if ( select_owned( **ik ) ) { - - const mesh::Bucket & bucket = **ik ; - - // Number of elems in this bucket of elems and elem field data - - const int number = bucket.size(); - - //double * elem_node_data = field_data( coord_field , bucket.begin() ); - double * elem_centroid_data = field_data( elem_centroid_field , bucket.begin() ); - - for ( int i = 0 ; i < number ; ++i, elem_centroid_data += 3) { - - mesh::Entity & elem = bucket[i] ; - - const mesh::PairIterRelation elem_nodes = elem.relations( mesh::fem::FEMMetaData::NODE_RANK ); - - if ( elem_nodes.size() == 8 ) { - - for (int ic=0; ic < 3; ic++) elem_centroid_data[ic]=0; - - for (int inode=0; inode < 8; inode++) - { - mesh::Entity & node = * elem_nodes[inode].entity(); - - double * const node_data = field_data(coord_field , node ); - for (int ic=0; ic < 3; ic++) { - elem_centroid_data[ic] += node_data[ic]/8.; - } - //double * const elem2_data = field_data( elem_centroid , elem2 ); - - // Which way is the side oriented, natural for #1 or #2 ? - //node_data[0] = 1; - //elem_centroid_data[ic] = sum[ic]; - } - } - } - } -} - -} - -// ======================================================================== - -#include - -int myMain(int argc, char** argv) -{ - //---------------------------------- - // Broadcast argc and argv to all processors. - - stk_classic::ParallelMachine comm = stk_classic::parallel_machine_init(&argc, &argv); - - stk_classic::BroadcastArg b_arg(comm, argc, argv); - - //---------------------------------- - // Process the broadcast command line arguments - - stk_classic::percept::RunEnvironment run_environment(&argc, &argv); - - run_environment.clp.setDocString("options"); - - std::string mesh = ""; - run_environment.clp.setOption("mesh", &mesh, "mesh file" ); - run_environment.processCommandLine(); - - //---------------------------------- - - if ( mesh.length() ) { - std::string in_filename = mesh; - std::string out_filename = in_filename + ".out"; - std::cout << "file: " << in_filename << "\n"; - stk_example_io::io_example(comm, in_filename, out_filename ); - } else { - std::cout << "OPTION ERROR: The '--mesh ' option is required!\n"; - std::exit(EXIT_FAILURE); - } - stk_classic::parallel_machine_finalize(); - - return 0; -} - -/** - * \} - */ - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/UseCases.py b/packages/stk/stk_classic/stk_percept/unit_tests/UseCases.py deleted file mode 100644 index ca5bf9dc8ef5..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/UseCases.py +++ /dev/null @@ -1,94 +0,0 @@ -import sys - -sys.path.insert(0,"../build/build.dir/packages/PyTrilinos/src/stk/PyPercept") - -from mpi4py import MPI -from PerceptMesh import * -import unittest -from numpy import * -import subprocess - -class UseCases(unittest.TestCase): - - def test_use_case_1(self): - - pMesh = PerceptMesh() - pMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,2,2,2")) - field = pMesh.add_field("coordinates", 1) - pMesh.commit() - - input_array = array([1.0, 0.5, 0.5]) - input_array_2 = array([1.0, 1.5, 1.5]) - - ff = FieldFunction("ff", field, pMesh, 3, 3) - ff.add_alias("myalias") - ff_output = ff.evaluate(input_array) - - f2 = FieldFunction("f2", field, pMesh, 3, 3) - f2_output = f2.evaluate(input_array_2) - - sf = StringFunction("x+y+z", "myname", 3, 1) - sf_output = sf.evaluate(input_array) - - sf_diff = StringFunction("ff-f2", "myname") - - norm = L1Norm(pMesh.get_bulk_data()) - value = norm.evaluate(ff) - diffnorm = norm.evaluate(sf_diff) - - - #Now use a helper function to evaluate the norm - #eval_norm(bulkData, Function, power) - - #value1 = eval_norm(pMesh.get_bulk_data(), ff, 1) - #diffnorm1 = eval_norm(pMesh.get_bulk_data(), sf_diff, 1) - - #self.assertEqual(value, value1) - #self.assertEqual(diffnorm, diffnorm1) - - def test_use_case_2(self): - - pMesh = PerceptMesh() - pMesh.open("exodus_files/tet-mesh.e") - - uniform_refiner = Refiner(pMesh, TET4_TET4_8) - pMesh.commit() - - i = 0 - while i < 3: - uniform_refiner.doBreak() - i = i + 1 - - pMesh.save_as("tet-mesh-refined-3-times.e") - - def test_use_case_3(self): - try: - subprocess.call("sierra aria -i tet_mesh.e -o result_0.e") - - pMesh = PerceptMesh() - pMesh.open("tet-mesh.e") - uniform_refiner = Refiner(pMesh, TET4_TET4_8) - pMesh.commit() - - uniform_refiner.doBreak() - pMesh.save_as("tet-mesh_refined.e") - - subprocess.call("sierra aria -i tet_mesh_refined.e -o result_1.e") - - pMesh_0 = PerceptMesh() - pMesh_1 = PerceptMesh() - pMesh_0.open_read_only("result_0.e") - pMesh_1.open_read_only("result_1.e") - - ff_0 = Field_Function(pMesh_0) - ff_1 = Field_Function(pMesh_1) - diff = StringFunction("ff_0 - ff_1") - - #diffnorm = eval_norm(pMesh.get_bulk_data, diff, 2) - #print "diffnorm = ", diffnorm - except: - print "Sierra not found." - -if __name__ == "__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(UseCases) - unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/boost_python_getting_started1.cref b/packages/stk/stk_classic/stk_percept/unit_tests/boost_python_getting_started1.cref deleted file mode 100644 index 6530398dde71..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/boost_python_getting_started1.cref +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Ralf W. Grosse-Kunstleve 2002-2004. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#if 1 -namespace { // Avoid cluttering the global namespace. - - // A couple of simple C++ functions that we want to expose to Python. - std::string greet() { return "hello, world"; } - int square(int number) { return number * number; } -} - -namespace python = boost::python; - -// Python requires an exported function called init in every -// extension module. This is where we build the module contents. -//BOOST_PYTHON_MODULE(getting_started1) -void test123() -{ - // Add regular functions to the module. - python::def("greet", greet); - python::def("square", square); -} -#else - -void test122() -{ - //boost::python::numeric::throw_load_failure(); -} -#endif diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/cube_hex8.e b/packages/stk/stk_classic/stk_percept/unit_tests/cube_hex8.e deleted file mode 100644 index baa11eb322f08bd59ebfc5c9706ffc30d9bdcb58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3580 zcmc(f%W@l45QY_OVM!qgcfvIZ*O-efI|MuCVima*S*FUe*$uKZCR0c=LLQULiUp6r zf(1KXg;$_>0(LBTfGqgGnQ3d>gCh#4;#B?WbGrZT)8{{DboJVe6SaJ_WKIgLVHgMd z=_HE3%mNqm+rT%B;!yKj!u(!xFu@AVG#Z6U2*+9!V5(p%>oVi9~0`r z$=)~$z6mG$Q4(vJ`A&4cz4g213l)For(fkiyEjaFsgwxDNff8Son$fy_M`jgz}e}M zJ(_#bP#WZcQcTlYJ&n>K2^xlWPm)Ox z_eRAf5#x;Ifo~xG&$12fE*SN=c6wod8{`d@eo?j=?&@{)(u3me;Vu|a7OpV=y=+6= z@gx~@dB)@Zn9tLiEIrKKyr$o2?hl$b`bivz{ghldO@TLU`OU1~^xn917xmAsf4(jb zLp{uWA@if=b+j00qG3AJ^JVs{vvS;p2UokF-rOn$D$|wrl3ipamN}+3|JU)Fdk$6B z-Ky)T=ibp}b#=e$s(QGCOnX^rm3=>%2%7V@OmF@}(EOBeS~w#-E<7PTDLf@SEj%MU zD?BHh6`mJf5crna%kZ#0%lFJ1rytv&H%3p^hyA}bG4kjY4l(lR z8xAqf$Qj@egI;q@X`)`Qp^!kYpdVr4yuy(RG7!tr`gle|UYZNck7jJ$UQI9?B8)P7fh zdG85Jg4cr>dCLMEuLm(|w*@#}j}`g&94`s)3tkUmmxT`mI9?B8Yr?t!$Lm2&@~#LQ zg4cr>c^?XJydK1;{gD92>p@NOJ{CR^ydK2J+Z5n-{sd)$#b^Ck0 zwj9s&v3*UK>3jXV?<;@*R|`*ltKK+zJFxD0dRulH})GoAqg6DN68W&1c4RU{+HBgUi+M*eU7AcXY=k0g|wAn=76%Nd^?Im z*WXV9i?|l)^ITuy{(IokAQ*+TKq+<)6cW@BovfAp(SiM=V~47jc&2bI(&zev0QZ-H zS@!$x0SVJUiG4rltB9ULVFO5Vl&45~6G+BYp565xpjRkx+TE@bnTy17`cIuZea$P+IaNa@36CD{5J<);KZnmJq%nwwhx1_Z%6J! z)`hi5o)fk-a6Qx{4dh~s&%|!*F#(OWU)Xk47&^w*C?1YtV^a;Bkrx{sVa*T2pr@iJ z2&H=IT(WN*=ep-aSWW20F*b@DLT_5X z;~p;MbT9F=>E@8j=gqGH-K76BZxH?kmpSe?PeGPReo|*LvIgJOU+MkK0_+^mfX&T2 zaCoG+Htv@+%u5&BEY~o{^P%yxwI?KUyyUJ>%o&qTg)A^p@b&zxc}@O{;bStrK$ zJ>hwiT9uN0ijRl6vp;iR9W}vWL(Qh|!J=JF%|BgNDrTc%F4s+~*<9WqbepEN)~hcc z1buhlDy++@nYC)os+wHSdCgpDHOy9hT)0s97U!^K97bKw=_|8QUoy6~TgKO}KRPn3 z%4)@IE}N?>ys0R!v1HsbjqPu~Gdd$>Z1rNpS~E$a2mcgI-a>v8dm z)#E$skJA(d$9|!#vSEdOa9p9<>lTdOaAUW?BNs z(d$7S#XQkadOa9p9<>!YdOaB9*foG0y&fifc`c^bgRus%3e*9;9*l`@BS)_X^&Rs> u)9LkKjCs_0$PNupVRmMeXy?LS2? z)B7s%9g-f$z&IgoMUg#o(O4B*ly ze|!ED>MN)4YqkyijXghf6|Ch%p%*CUSr~Vn#CuL#(LQ?Zs7rgE4?AT8C&tjUW|XIV zGN8N$xOK1VMoM;ty)L#sYVErb+UsG@^|V^n)hG@-GD*VNSTvi9yrx|9-2~dio>JI6 zZc;Y#D^%3UlsC}03YgRT_-sGS6(J4x#T4?vez(3yJ(uk*R+?=V>A2RD^P{W#f5Fhd z(4Obs(<5>&(rWvXFfYJe`xfXe^yldd4mYdk(zU1$_sA5^=Udiw*7Nj{0xkF26w(OL zQcg*>;jOMpb3dcp62KJF0?p2*c*Z&R+^nOdZKsZ+6aF`|FAo``ESIz8-uwpbH@P4LQ$KisqfE*=S%|w0Um?%6 z1J_UbJT=+QLR9n7Z>WzcT=ys7`vG;fr-)HUxoz|*lQuj#7j&b3xBk5mz^(EH0C&37 z%2oX8)#}~qQgx}eSYNU015_NURF^8XT)lxocB(6l#f8S=sA0=`0Doy7Gy*jV2c zP{+F6>^4L*l!wl`3mdqJY;Kp=?i`3(xwg1W5@>8!>R?@IEYuoyO+4u)e|FtiY#c@c z8&D`xzu;?%)&cxk+*!&|mfTq;$v{0+p>h_YoBtDhOJ(G9n zU?7nryhPaL>f%M1&Da*)vZV!$xf_fqADtO zgJe&}{f5pXa8$?cI-Sss6X~eXu|Abgyg;-(8ON>|n+t|+!!L{!VwXp}_)G>ec9j%s zT6@t9x?aasVJtR1>34r&EzS}z;J>uurWbh7Zv#mlh8Fjc)qIiL8lJj;mW+Wh!D2F( zc!0nbAB#@fmJUxBXSqCW@Cj^fR}9SYigk<)Tl)GeHq)S^aFrCv9$M$oRon2f>!(sQ z6Y<{RhesbifA2hk43D;<>AaG)v0>kM$00&1;=(&+lxQ2a5Mr=lz<|p$$GKOp1wKmT z1?+F8!~f5wWVuy5g+=pp&F_(^?5S;-r|r;Bb(E}yfr>*P=Sk9uy@#_{l%-s|3lmwwnlqWZJk~sB*W7&ioI9<;7z_oXtcATOMaDjklkLDH z>=-E>`R7rB?^7{0d~$)?se-^k5o1&tF-(ET*&{~Jfu_Kg*GqkTabsOA<;Dspt3Fz) z=a6R=1n$bX=LMPYTU|9F$2YAUwX&5mu>MqkMB$79dib4^9DDIHs762zMJu#oNuOY0p12& z1N<8B8^CV?zXQAjxDL1hco%RJz&Gu2b8-Aq+YdWWoyiXg@SG~EFEZ4qy2wzZn{>R- z_n&;em#in9*U7&`y} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/example.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/example.cpp deleted file mode 100644 index b1b32747d2a6..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/example.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#if PY_PERCEPT - -/* File : example.c */ - -#include "example.hpp" -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area(void) { - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/example.hpp b/packages/stk/stk_classic/stk_percept/unit_tests/example.hpp deleted file mode 100644 index 46d90136108d..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/example.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* File : example.h */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - }; - double x, y; - void move(double dx, double dy); - virtual double area(void) = 0; - virtual double perimeter(void) = 0; - static int nshapes; -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { }; - virtual double area(void); - virtual double perimeter(void); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { }; - virtual double area(void); - virtual double perimeter(void); -}; - - - - - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/example.i b/packages/stk/stk_classic/stk_percept/unit_tests/example.i deleted file mode 100644 index 75700b305437..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/example.i +++ /dev/null @@ -1,10 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/example.py b/packages/stk/stk_classic/stk_percept/unit_tests/example.py deleted file mode 100644 index 4c3cac94be6d..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/example.py +++ /dev/null @@ -1,118 +0,0 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 2.0.0 -# -# Do not make changes to this file unless you know what you are doing--modify -# the SWIG interface file instead. -# This file is compatible with both classic and new-style classes. - -from sys import version_info -if version_info >= (2,6,0): - def swig_import_helper(): - from os.path import dirname - import imp - fp = None - try: - fp, pathname, description = imp.find_module('_example', [dirname(__file__)]) - except ImportError: - import _example - return _example - if fp is not None: - try: - _mod = imp.load_module('_example', fp, pathname, description) - finally: - fp.close() - return _mod - _example = swig_import_helper() - del swig_import_helper -else: - import _example -del version_info -def _swig_setattr_nondynamic(self,class_type,name,value,static=1): - if (name == "thisown"): return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'SwigPyObject': - self.__dict__[name] = value - return - method = class_type.__swig_setmethods__.get(name,None) - if method: return method(self,value) - if (not static) or hasattr(self,name): - self.__dict__[name] = value - else: - raise AttributeError("You cannot add attributes to %s" % self) - -def _swig_setattr(self,class_type,name,value): - return _swig_setattr_nondynamic(self,class_type,name,value,0) - -def _swig_getattr(self,class_type,name): - if (name == "thisown"): return self.this.own() - method = class_type.__swig_getmethods__.get(name,None) - if method: return method(self) - raise AttributeError(name) - -def _swig_repr(self): - try: strthis = "proxy of " + self.this.__repr__() - except: strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - -class Shape: - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, Shape, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, Shape, name) - def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") - __repr__ = _swig_repr - __swig_destroy__ = _example.delete_Shape - __del__ = lambda self : None; - __swig_setmethods__["x"] = _example.Shape_x_set - __swig_getmethods__["x"] = _example.Shape_x_get - __swig_setmethods__["y"] = _example.Shape_y_set - __swig_getmethods__["y"] = _example.Shape_y_get - def move(self, *args): return _example.Shape_move(self, *args) - def area(self): return _example.Shape_area(self) - def perimeter(self): return _example.Shape_perimeter(self) - __swig_setmethods__["nshapes"] = _example.Shape_nshapes_set - __swig_getmethods__["nshapes"] = _example.Shape_nshapes_get -Shape_swigregister = _example.Shape_swigregister -Shape_swigregister(Shape) -cvar = _example.cvar - -class Circle(Shape): - __swig_setmethods__ = {} - for _s in [Shape]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) - __setattr__ = lambda self, name, value: _swig_setattr(self, Circle, name, value) - __swig_getmethods__ = {} - for _s in [Shape]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) - __getattr__ = lambda self, name: _swig_getattr(self, Circle, name) - __repr__ = _swig_repr - def __init__(self, *args): - this = _example.new_Circle(*args) - try: self.this.append(this) - except: self.this = this - def area(self): return _example.Circle_area(self) - def perimeter(self): return _example.Circle_perimeter(self) - __swig_destroy__ = _example.delete_Circle - __del__ = lambda self : None; -Circle_swigregister = _example.Circle_swigregister -Circle_swigregister(Circle) - -class Square(Shape): - __swig_setmethods__ = {} - for _s in [Shape]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) - __setattr__ = lambda self, name, value: _swig_setattr(self, Square, name, value) - __swig_getmethods__ = {} - for _s in [Shape]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) - __getattr__ = lambda self, name: _swig_getattr(self, Square, name) - __repr__ = _swig_repr - def __init__(self, *args): - this = _example.new_Square(*args) - try: self.this.append(this) - except: self.this = this - def area(self): return _example.Square_area(self) - def perimeter(self): return _example.Square_perimeter(self) - __swig_destroy__ = _example.delete_Square - __del__ = lambda self : None; -Square_swigregister = _example.Square_swigregister -Square_swigregister(Square) - - - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/example_wrap.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/example_wrap.cpp deleted file mode 100644 index 4d43e1b8734d..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/example_wrap.cpp +++ /dev/null @@ -1,4128 +0,0 @@ - -#include -#if PY_PERCEPT - -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -#define SWIGPYTHON -#define SWIG_PYTHON_DIRECTOR_NO_VTABLE -#define SWIG_PYTHON_CLASSIC - - -#ifdef __cplusplus -/* SwigValueWrapper is described in swig.swg */ -template class SwigValueWrapper { - struct SwigMovePointer { - T *ptr; - SwigMovePointer(T *p) : ptr(p) { } - ~SwigMovePointer() { delete ptr; } - SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } - } pointer; - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); - SwigValueWrapper(const SwigValueWrapper& rhs); -public: - SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } - operator T&() const { return *pointer.ptr; } - T *operator&() { return pointer.ptr; } -}; - -template T SwigValueInit() { - return T(); -} -#endif - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - - - -/* Python.h has to appear first */ -#include - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -/* Compatibility macros for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Warning: This function will allocate a new string in Python 3, - * so please call SWIG_Python_str_DelForPy3(x) to free the space. - */ -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; - str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); - return newstr; -#else - return PyString_AsString(str); -#endif -} - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) -#else -# define SWIG_Python_str_DelForPy3(x) -#endif - - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif - -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif - -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return NULL; -#endif -} - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - - -/* ----------------------------------------------------------------------------- - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} SwigPyObject; - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", name, v); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -#else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -#endif -#if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -#else - PyString_ConcatAndDel(&repr,nrep); -#endif - } - return repr; -} - -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; -} - - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!SwigPyObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpyobject_type = tmp; - /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpyobject_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpyobject_type; -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpypacked_type = tmp; - /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpypacked_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpypacked_type; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (SwigPyObject_Check(pyobj)) { - return (SwigPyObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) - return SWIG_ERROR; - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, without calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; -#else - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); -#endif - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = SwigPyObject_New(ptr, type, own); - SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); -#else - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); -#endif - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); - } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - } - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - SWIG_Python_str_DelForPy3(cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); -#if SWIG_POINTER_EXCEPTION - if (flags) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } -#endif - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - - - -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) - -#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else - - - -/* -------- TYPES TABLE (BEGIN) -------- */ - -#define SWIGTYPE_p_Circle swig_types[0] -#define SWIGTYPE_p_Shape swig_types[1] -#define SWIGTYPE_p_Square swig_types[2] -#define SWIGTYPE_p_char swig_types[3] -static swig_type_info *swig_types[5]; -static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0}; -#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) -#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) - -/* -------- TYPES TABLE (END) -------- */ - -#if (PY_VERSION_HEX <= 0x02000000) -# if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires swig to be run with the '-classic' option" -# endif -#endif - -/*----------------------------------------------- - @(target):= _example.so - ------------------------------------------------*/ -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_init PyInit__example - -#else -# define SWIG_init init_example - -#endif -#define SWIG_name "_example" - -#define SWIGVERSION 0x020000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) - - -#include - - -namespace swig { - class SwigPtr_PyObject { - protected: - PyObject *_obj; - - public: - SwigPtr_PyObject() :_obj(0) - { - } - - SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) - { - Py_XINCREF(_obj); - } - - SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) - { - if (initial_ref) { - Py_XINCREF(_obj); - } - } - - SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) - { - Py_XINCREF(item._obj); - Py_XDECREF(_obj); - _obj = item._obj; - return *this; - } - - ~SwigPtr_PyObject() - { - Py_XDECREF(_obj); - } - - operator PyObject *() const - { - return _obj; - } - - PyObject *operator->() const - { - return _obj; - } - }; -} - - -namespace swig { - struct SwigVar_PyObject : SwigPtr_PyObject { - SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } - - SwigVar_PyObject & operator = (PyObject* obj) - { - Py_XDECREF(_obj); - _obj = obj; - return *this; - } - }; -} - - -#include "example.hpp" - - -SWIGINTERN int -SWIG_AsVal_double (PyObject *obj, double *val) -{ - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; - } else if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } - } -#endif - return res; -} - - - #define SWIG_From_double PyFloat_FromDouble - - -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - -#include - - -#include - - -SWIGINTERNINLINE int -SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ - if ((errno == EDOM) || (errno == ERANGE)) { - errno = 0; - } else { - double summ, reps, diff; - if (rd < x) { - diff = x - rd; - } else if (rd > x) { - diff = rd - x; - } else { - return 1; - } - summ = rd + x; - reps = diff/summ; - if (reps < 8*DBL_EPSILON) { - *d = rd; - return 1; - } - } - } - return 0; -} - - -SWIGINTERN int -SWIG_AsVal_long (PyObject *obj, long* val) -{ - if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - long v = PyInt_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< int >(v); - } - } - return res; -} - - - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERNINLINE PyObject * -SWIG_From_int (int value) -{ - return SWIG_From_long (value); -} - -#ifdef __cplusplus -extern "C" { -#endif -SWIGINTERN PyObject *_wrap_delete_Shape(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_Shape",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Shape" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - delete arg1; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_x_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - double arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:Shape_x_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_x_set" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - ecode2 = SWIG_AsVal_double(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_x_set" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - if (arg1) (arg1)->x = arg2; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_x_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Shape_x_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_x_get" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - result = (double) ((arg1)->x); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_y_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - double arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:Shape_y_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_y_set" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - ecode2 = SWIG_AsVal_double(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_y_set" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - if (arg1) (arg1)->y = arg2; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_y_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Shape_y_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_y_get" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - result = (double) ((arg1)->y); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_move(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - double arg2 ; - double arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - double val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:Shape_move",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_move" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - ecode2 = SWIG_AsVal_double(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_move" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - ecode3 = SWIG_AsVal_double(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Shape_move" "', argument " "3"" of type '" "double""'"); - } - arg3 = static_cast< double >(val3); - (arg1)->move(arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_area(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Shape_area",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_area" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - result = (double)(arg1)->area(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Shape_perimeter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Shape *arg1 = (Shape *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Shape_perimeter",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Shape, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_perimeter" "', argument " "1"" of type '" "Shape *""'"); - } - arg1 = reinterpret_cast< Shape * >(argp1); - result = (double)(arg1)->perimeter(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var_Shape_nshapes_set(PyObject *_val) { - { - int val; - int res = SWIG_AsVal_int(_val, &val); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""Shape::nshapes""' of type '""int""'"); - } - Shape::nshapes = static_cast< int >(val); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var_Shape_nshapes_get(void) { - PyObject *pyobj = 0; - - pyobj = SWIG_From_int(static_cast< int >(Shape::nshapes)); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_Shape_nshapes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(args)) { - return Swig_var_Shape_nshapes_get(); -} - - -SWIGINTERN PyObject *_wrap_Shape_nshapes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *value; - int res; - - if (!PyArg_ParseTuple(args,(char *)"O:set",&value)) return NULL; - res = Swig_var_Shape_nshapes_set(value); - return !res ? SWIG_Py_Void() : NULL; -} - - -SWIGINTERN PyObject *Shape_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_Shape, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_new_Circle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - double arg1 ; - double val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - Circle *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_Circle",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_double(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Circle" "', argument " "1"" of type '" "double""'"); - } - arg1 = static_cast< double >(val1); - result = (Circle *)new Circle(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Circle, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Circle_area(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Circle *arg1 = (Circle *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Circle_area",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Circle, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_area" "', argument " "1"" of type '" "Circle *""'"); - } - arg1 = reinterpret_cast< Circle * >(argp1); - result = (double)(arg1)->area(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Circle_perimeter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Circle *arg1 = (Circle *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Circle_perimeter",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Circle, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_perimeter" "', argument " "1"" of type '" "Circle *""'"); - } - arg1 = reinterpret_cast< Circle * >(argp1); - result = (double)(arg1)->perimeter(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_Circle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Circle *arg1 = (Circle *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_Circle",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Circle, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Circle" "', argument " "1"" of type '" "Circle *""'"); - } - arg1 = reinterpret_cast< Circle * >(argp1); - delete arg1; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *Circle_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_Circle, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_new_Square(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - double arg1 ; - double val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - Square *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_Square",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_double(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Square" "', argument " "1"" of type '" "double""'"); - } - arg1 = static_cast< double >(val1); - result = (Square *)new Square(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Square, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Square_area(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Square *arg1 = (Square *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Square_area",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Square, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Square_area" "', argument " "1"" of type '" "Square *""'"); - } - arg1 = reinterpret_cast< Square * >(argp1); - result = (double)(arg1)->area(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Square_perimeter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Square *arg1 = (Square *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - double result; - - if (!PyArg_ParseTuple(args,(char *)"O:Square_perimeter",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Square, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Square_perimeter" "', argument " "1"" of type '" "Square *""'"); - } - arg1 = reinterpret_cast< Square * >(argp1); - result = (double)(arg1)->perimeter(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_Square(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - Square *arg1 = (Square *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_Square",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Square, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Square" "', argument " "1"" of type '" "Square *""'"); - } - arg1 = reinterpret_cast< Square * >(argp1); - delete arg1; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *Square_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_Square, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - - - -#include - -#ifdef __cplusplus -extern "C" -#endif -void SWIG_init(); /* Forward reference */ - -#define _PyImport_Inittab swig_inittab - -/* Grab Python's inittab[] structure */ - -#ifdef __cplusplus -extern "C" { -#endif -#include - -#undef _PyImport_Inittab - -/* Now define our own version of it. - Hopefully someone does not have more than 1000 built-in modules */ - -struct _inittab SWIG_Import_Inittab[1000]; - -static int swig_num_modules = 0; - -/* Function for adding modules to Python */ - -static void swig_add_module(char *name, void (*initfunc)()) { - SWIG_Import_Inittab[swig_num_modules].name = name; - SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; - swig_num_modules++; - SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; - SWIG_Import_Inittab[swig_num_modules].initfunc = 0; -} - -/* Function to add all of Python's build in modules to our interpreter */ - -static void swig_add_builtin() { - int i = 0; - while (swig_inittab[i].name) { - swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); - i++; - } -#ifdef SWIGMODINIT - SWIGMODINIT -#endif - /* Add SWIG builtin function */ - swig_add_module(SWIG_name, SWIG_init); -} - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern int Py_Main(int, char **); - -#ifdef __cplusplus -} -#endif - -extern struct _inittab *PyImport_Inittab; - -int -main(int argc, char **argv) { - swig_add_builtin(); - PyImport_Inittab = SWIG_Import_Inittab; - return Py_Main(argc,argv); -} - - -static PyMethodDef SwigMethods[] = { - { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"delete_Shape", _wrap_delete_Shape, METH_VARARGS, NULL}, - { (char *)"Shape_x_set", _wrap_Shape_x_set, METH_VARARGS, NULL}, - { (char *)"Shape_x_get", _wrap_Shape_x_get, METH_VARARGS, NULL}, - { (char *)"Shape_y_set", _wrap_Shape_y_set, METH_VARARGS, NULL}, - { (char *)"Shape_y_get", _wrap_Shape_y_get, METH_VARARGS, NULL}, - { (char *)"Shape_move", _wrap_Shape_move, METH_VARARGS, NULL}, - { (char *)"Shape_area", _wrap_Shape_area, METH_VARARGS, NULL}, - { (char *)"Shape_perimeter", _wrap_Shape_perimeter, METH_VARARGS, NULL}, - { (char *)"Shape_nshapes_get", _wrap_Shape_nshapes_get, METH_VARARGS, NULL}, - { (char *)"Shape_nshapes_set", _wrap_Shape_nshapes_set, METH_VARARGS, NULL}, - { (char *)"Shape_swigregister", Shape_swigregister, METH_VARARGS, NULL}, - { (char *)"new_Circle", _wrap_new_Circle, METH_VARARGS, NULL}, - { (char *)"Circle_area", _wrap_Circle_area, METH_VARARGS, NULL}, - { (char *)"Circle_perimeter", _wrap_Circle_perimeter, METH_VARARGS, NULL}, - { (char *)"delete_Circle", _wrap_delete_Circle, METH_VARARGS, NULL}, - { (char *)"Circle_swigregister", Circle_swigregister, METH_VARARGS, NULL}, - { (char *)"new_Square", _wrap_new_Square, METH_VARARGS, NULL}, - { (char *)"Square_area", _wrap_Square_area, METH_VARARGS, NULL}, - { (char *)"Square_perimeter", _wrap_Square_perimeter, METH_VARARGS, NULL}, - { (char *)"delete_Square", _wrap_delete_Square, METH_VARARGS, NULL}, - { (char *)"Square_swigregister", Square_swigregister, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ - -static void *_p_SquareTo_p_Shape(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((Shape *) ((Square *) x)); -} -static void *_p_CircleTo_p_Shape(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((Shape *) ((Circle *) x)); -} -static swig_type_info _swigt__p_Circle = {"_p_Circle", "Circle *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_Shape = {"_p_Shape", "Shape *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_Square = {"_p_Square", "Square *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; - -static swig_type_info *swig_type_initial[] = { - &_swigt__p_Circle, - &_swigt__p_Shape, - &_swigt__p_Square, - &_swigt__p_char, -}; - -static swig_cast_info _swigc__p_Circle[] = { {&_swigt__p_Circle, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_Shape[] = { {&_swigt__p_Square, _p_SquareTo_p_Shape, 0, 0}, {&_swigt__p_Shape, 0, 0, 0}, {&_swigt__p_Circle, _p_CircleTo_p_Shape, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_Square[] = { {&_swigt__p_Square, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; - -static swig_cast_info *swig_cast_initial[] = { - _swigc__p_Circle, - _swigc__p_Shape, - _swigc__p_Square, - _swigc__p_char, -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ - -static swig_const_info swig_const_table[] = { -{0, 0, 0, 0.0, 0, 0}}; - -#ifdef __cplusplus -} -#endif -/* ----------------------------------------------------------------------------- - * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to - * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of - * swig_module, and does all the lookup, filling in the swig_module.types - * array with the correct data and linking the correct swig_cast_info - * structures together. - * - * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop through that array, and handle each type individually. - * First we lookup if this type has been already loaded, and if so, use the - * loaded structure instead of the generated one. Then we have to fill in the - * cast linked list. The cast data is initially stored in something like a - * two-dimensional array. Each row corresponds to a type (there are the same - * number of rows as there are in the swig_type_initial array). Each entry in - * a column is one of the swig_cast_info structures for that type. - * The cast_initial array is actually an array of arrays, because each row has - * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it - * adding the casts to the list. The one last trick we need to do is making - * sure the type pointer in the swig_cast_info struct is correct. - * - * First off, we lookup the cast->type name to see if it is already loaded. - * There are three cases to handle: - * 1) If the cast->type has already been loaded AND the type we are adding - * casting info to has not been loaded (it is in this module), THEN we - * replace the cast->type pointer with the type pointer that has already - * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the - * cast->type) are loaded, THEN the cast info has already been loaded by - * the previous module so we just ignore it. - * 3) Finally, if cast->type has not already been loaded, then we add that - * swig_cast_info to the linked list (because the cast->type) pointer will - * be correct. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* c-mode */ -#endif -#endif - -#if 0 -#define SWIGRUNTIME_DEBUG -#endif - - -SWIGRUNTIME void -SWIG_InitializeModule(void *clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; - iter=module_head; - do { - if (iter==&swig_module) { - found=1; - break; - } - iter=iter->next; - } while (iter!= module_head); - - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } - - /* When multiple interpeters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); -#endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); -#endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); -#endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); -#endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); -#endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); -#ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); -#endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); -#endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); -#ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); -#endif - if (!ocast) ret = 0; - } - } - - if (!ret) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); -#endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; - } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; - } - swig_module.types[i] = 0; - -#ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n",j); - } - printf("**** SWIG_InitializeModule: Cast List ******\n"); -#endif -} - -/* This function will propagate the clientdata field of type to -* any new swig_type_info structures that have been added into the list -* of equivalent types. It is like calling -* SWIG_TypeClientData(type, clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } - } - } -} - -#ifdef __cplusplus -#if 0 -{ - /* c-mode */ -#endif -} -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - /* Python-specific SWIG API */ -#define SWIG_newvarlink() SWIG_Python_newvarlink() -#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) -#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - - /* ----------------------------------------------------------------------------- - * global variable support code. - * ----------------------------------------------------------------------------- */ - - typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; - } swig_globalvar; - - typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; - } swig_varlinkobject; - - SWIGINTERN PyObject * - swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); -#else - return PyString_FromString(""); -#endif - } - - SWIGINTERN PyObject * - swig_varlink_str(swig_varlinkobject *v) { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - tail = PyUnicode_FromString(var->name); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - } - } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; -#else - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - PyString_ConcatAndDel(&str,PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str,PyString_FromString(")")); -#endif - return str; - } - - SWIGINTERN int - swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; - PyObject *str = swig_varlink_str(v); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(str); - return 0; - } - - SWIGINTERN void - swig_varlink_dealloc(swig_varlinkobject *v) { - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } - } - - SWIGINTERN PyObject * - swig_varlink_getattr(swig_varlinkobject *v, char *n) { - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; - } - if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); - } - return res; - } - - SWIGINTERN int - swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); - } - return res; - } - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { - static char varlink__doc__[] = "Swig var link object"; - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* Number of items in variable part (ob_size) */ -#endif - (char *)"swigvarlink", /* Type name (tp_name) */ - sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ - 0, /* Itemsize (tp_itemsize) */ - (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ - (printfunc) swig_varlink_print, /* Print (tp_print) */ - (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ - (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ - 0, /* tp_compare */ - (reprfunc) swig_varlink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) swig_varlink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - varlink__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - varlink_type = tmp; - /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - varlink_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &varlink_type; - } - - /* Create a variable linking object for use later */ - SWIGINTERN PyObject * - SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject*) result); - } - - SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name)+1; - gv->name = (char *)malloc(size); - if (gv->name) { - strncpy(gv->name,name,size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } - } - v->vars = gv; - } - - SWIGINTERN PyObject * - SWIG_globals(void) { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; - } - - /* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - - /* Install Constants */ - SWIGINTERN void - SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { - PyObject *obj = 0; - size_t i; - for (i = 0; constants[i].type; ++i) { - switch(constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - Py_DECREF(obj); - } - } - } - - /* -----------------------------------------------------------------------------*/ - /* Fix SwigMethods to carry the callback ptrs when needed */ - /* -----------------------------------------------------------------------------*/ - - SWIGINTERN void - SWIG_Python_FixMethods(PyMethodDef *methods, - swig_const_info *const_table, - swig_type_info **types, - swig_type_info **types_initial) { - size_t i; - for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; - if (c && (c = strstr(c, "swig_ptr: "))) { - int j; - swig_const_info *ci = 0; - const char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - strncpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - strncpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } - } - } - } - } - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" -#endif - -SWIGEXPORT -#if PY_VERSION_HEX >= 0x03000000 -PyObject* -#else -void -#endif -SWIG_init(void) { - PyObject *m, *d; -#if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { - PyModuleDef_HEAD_INIT, - (char *) SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - -#if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); -#else - m = Py_InitModule((char *) SWIG_name, SwigMethods); -#endif - d = PyModule_GetDict(m); - - SWIG_InitializeModule(0); - SWIG_InstallConstants(d,swig_const_table); - - - PyDict_SetItemString(d,(char*)"cvar", SWIG_globals()); - SWIG_addvarlink(SWIG_globals(),(char*)"Shape_nshapes",Swig_var_Shape_nshapes_get, Swig_var_Shape_nshapes_set); -#if PY_VERSION_HEX >= 0x03000000 - return m; -#else - return; -#endif -} - -#endif diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/beam.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/beam.e deleted file mode 100644 index cc6c59a1a3267e6934b7c22d408a576967fc38fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2188 zcmeHI!EV$r5N+9(O#*^zk05b?OS8Lxpev!4wn9{JpwOP9B>68 zDIoCyAaUTpC-9z=EN<1R5^(HDlNmohkH_OlvbFtWaiNv~<|;JEgo-LtN_A)_ZsO?? z%cK(UccDuMdQ#FteIs*$1){*9k*=EL(MaYTUV{1@D?JibP2f6@n8*Z49cWOGqa+(! z67#ayQ5=;bwOAL=YYk5-Qu`L?`s>XeQ6WmiwG-Ui;;}K2vw(b_bs2gkE@bpZl$F#9 zLyIkLe0X#Ozk3G0a**lRph8ihr83b}m!qhX?^qw6jk$YJ|3GG_O+Dev!ChE3(qvo! zVV=9`B$4Jes;sLpnaFGuimzD>DZ4YVTQ?h&W#rcZN55 z55oS#aM0`b;jh`qI3FzUHn8_JeXW~KnIr4a%4Imn*?SKg)HTPc>I)-}=V6|%VBGl# z{R}WjwJswS=glRP%UZZXY#U`|t9T-rvx)O=T_JW0@F!T0eS&gu9rI?ct#A+AW%nzr zkC>H-&7|owa^1M(Lc8B!xqngWf{oJh*c0@ZcnnzP(An9>vpx&g{(#>_Kb10>_m~fi zb#8_EJq7J2te0w~L~2N8JaXH2jeGg_Y-UzCy|A?T_$8)n{ZIfrsE6equ$yOJ$Bcge-66Nxm%n|xX7Wd=S3a< zR~@$YH+S~jCOzr*2dlm0B7I+w9xUpJjgoNM`PI diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/hex_fixture.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/hex_fixture.e deleted file mode 100644 index a956029e4bef62b2d376212afaa955711926722e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7508 zcmeI0TXz&y8iqR}kRYOrCvLf})qk(|I^P#OI)k%>)(FYPx@8+kt z{5}2zF1?(K`2q7h)m<3(vT5fI)?}~sbXD!|t?#Sa@2={#>-^%yhYE$l2poY&-By!& zx!q}{^-Ycng_AI9Up1{K>|ce4D~)c;EsS;2TEYoQlY@RcQt#HvH{xIL@1j34F1=_v*RsT%&nNKSE&Ay*{`vvy?YALK|~CiXNMqPQYC2 z9CZKT{`25H99UZ9w|8!SzGLY5${aa$)^dFFX5UM_gE8|ST5m8~yIGGl`aWdGoOi%+ zrHxJU)6?F{I_{x;^u%55?P1#E3XXUUcdxp4-Oiuzx;L_Hg(tnH(e*~Xo~(BqC-2F* z=KbVjHJ16*xz*hBd>q_Lc4yGo7_Gk|k zD^AW8r{~TM3Kt5OnTK=HPJ68yZzRQYv!|n#)wyUnt#@~$()jdvapp|v?9BM=cyT=)WMa7w@SelzE&7GZ%E-YS)N`<9HvRht^JMmiFPL@{2&quwB zoSG=kMw=V$>v8N$`hRTtp3OhD&O4tkebO%n)Mvptm;2%Ke+(W2pC1kX3p@c&!c*`x zJOj>~XW=>cD?AS`z~A8S5Wz`!5l(^g_#f~xyaKPnYw$X}0jJ>%jKc&thc%!CXJHD? z!8E)H&W%}^gSX&qcnAIo^RNK#!h3KY7U2S1g!kbCSb`7XBUpw@a2ZzM3S5PcVHK{y zC-5nJ2A{(h@Fjc&U&A->EtKIqh+z%ZVFR4r71)F=NZ~qcLltV^#P)x+2{%C7eLr-d z3pZg0cEP9Hr}lgJ0sLPbfrsD#{6Bi`{g13w8|&L;r_b;<|4UCZf2Y6wwZHv$Z=3(_ z>-NXR5!jyx59U1RUG?DKyT0b{gF)Ln{rexb&EF%#w*B|a{E+S7EB}3D|2_uzGt7rP zKE#LIr{9nI;G=y%?k_(EJ9U3V{`7nq^nSWu`tJ}m z&*rM=p3NoG(3Y>GTr0a~ehyscM&SB3Ut^83uf~{b;FAzRzW#EJt;U$^;}=0qzBY6H zt;U#Z=To4@n&$NziR<%xP3;=`B`{`Q*X(K{Fz?Ht#+Z3s&#N(J-d8}4F>AZlS7XfD zuYwwDn)f(74%Rg9>+l*FGq2wV)EG1G8=%IRdHr^v#+Z3egBoMj_Pc@_W7a+cYOHBq zzc={Z!J6isfN?NpUcW`CF=pOLP-D!zCqRuc^A5~yYK&RC1ZqOR&(b#qvoHgp z-^TntF$Zcwzl}}9Tc9TN+t{1%HmC{xwx)UgzVQx3u-9*6=A8#Mq2I>Ly8voJzl~Y@ zU08t7Z)=+OJiG^?-^R?l2x>yVjV-_hP!sxX%-R=0P3X5Z&HDko524@2%)10?Lcfif z_d`$<`fbeGAAy?C?`8Tf!N+hFLcfh&hE-4#`fY3lu7R4+Z(~>B6HpWSZB6rj2A@Lc zw=wg64r)TbjhXigP!sxX%-Uaqn$T}+n)hq?3PQh)nfDt|6Z&n;yx)SF1=#DiF>9AW zP3X5Z%^Sma5c+M*ylbE)^xK$u*FjC_w=rvPfSSP!sxXYzu0j zCiL4_3UyEu`fW|~HlYEb-^R>)1Js0m8#8YU)P#N;vvwQQgnnDoyj|!(=(jQR-UKzF y-^R?l18PFQjahpa)P#Op)4aFg7KDBqGw=7HCiL5wd4B*kq2I=={UfN!+J6C6?c1jS diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/input_files_hex_fixture.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/input_files_hex_fixture.e deleted file mode 100644 index df8d81323f106b51bbd7817922c8b7b70c8e270b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7428 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 diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture.e deleted file mode 100644 index 4455d9a83eed3d7a73f4219cb8d571b0559cb29a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9052 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 W^wehm4fNDz{~h$yW`7EL<@Rrrw1)ox diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture_readwrite.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/quad_fixture_readwrite.e deleted file mode 100644 index 4455d9a83eed3d7a73f4219cb8d571b0559cb29a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9052 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 G68{0{HDCJLm^nr_*-oIChGy7Fn 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 W`ri4@63_X_Q879>C`Km+?8ZMtB?jUE diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/tet_from_hex_fixture_0.e b/packages/stk/stk_classic/stk_percept/unit_tests/exodus_files/tet_from_hex_fixture_0.e deleted file mode 100644 index 31ee54044f1f906d449d898e57da2c3b7817090c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 56872 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 -#include - -#include - -#include -#include - -#include - -//using namespace stk_classic; -using namespace stk_classic::percept::util; -using namespace stk_classic::percept::interface_table; - -typedef shards::ArrayVector ArrayInt2 ; - -///#define NUM_ELEM_CPP_ARRAY(arr, nodes_per_elem) (sizeof(arr)/(nodes_per_elem*sizeof(arr[0]))) // drop sentinel - -namespace stk_classic -{ - namespace percept - { - namespace unit_tests - { - - void test_shards_array() - { - - using namespace shards; - typedef ArrayVector ArrayInt2 ; - - //works - { - typedef Array ArrayUndim; - - double storage[100]; - int dims[2] = {1,2}; - const ArrayDimTag* tags[2] = {&Tag1::tag(), &Tag2::tag()}; - ArrayUndim uu(storage, 2, dims, tags); - uu(0,0)=1.0; - std::cout << "uu= " << uu(0,0) << std::endl; - } - -#if 0 - // doesn't compile - { - typedef ArrayVector ArrayVectorUnDim; - ArrayVectorUnDim u1; - u1.resize(1,2); - } -#endif - } - - class XF1 : public Transform - { - using Transform::operator(); - virtual Coord operator()(const Coord& x) - { - Coord y; - operator()(x, y); - return y; - } - virtual void operator()(const Coord& x, Coord& y) - { - double z = x[2]; - double xnew = x[0]*(z+5)/12; - double ynew = x[1]*(z+5)/12; - y[0] =xnew; - y[1] =ynew; - y[2] =z; - } - }; - - int testSweepMesher(stk_classic::ParallelMachine parallel_machine ) - { - bool verbose = false; - - //stk_classic::ParallelMachine parallel_machine = stk_classic::parallel_machine_init(&argc, &argv); - - { - // FIXME: Please use a mesh from stk_mesh/fixture instead of a use_case mesh - //if(verbose) std::cout << "Use Case 3 ... "; - //stk_classic::mesh::use_cases::UseCase_3_Mesh mesh(parallel_machine); - //mesh.populate(); - //const bool local_status = stk_classic::mesh::use_cases::verifyMesh(mesh); - //if(verbose) std::cout << local_status << std::endl; - //stk_classic::mesh::use_cases::verifyMesh(mesh); - //printStatus(local_status); - //status = status && local_status; - } - - SweepMesher tp1; - - //int6 a = {{0,1,2,3,4,5}}; - boost::array a = {{0,1,2,3,4,5}}; - boost::array aa[] = { - {{0,1,2,3,4,5}}, - {{40,41,42,43,44,45}} - }; - - boost::array coords[] = { - {{0,0,0}}, {{1,0,0}}, {{2,2,0}}, {{0,3,0}}, - {{0,0,1}}, {{1,0,1}}, {{2,2,1}}, {{0,3,1}} - }; - - boost::array coordsLine[] = { - {{0,0,0}}, {{1,0,0}}, {{2,0,0}}, {{3,0,0}}, {{4,0,0}} - }; - - double coordsCPP[][3] = { - {0,0,0}, {1,0,0}, {2,2,0}, {0,3,0}, - {0,0,1}, {1,0,1}, {2,2,1}, {0,3,1} - }; - unsigned numNodes = sizeof(coordsCPP)/sizeof(coordsCPP[0]); - unsigned numNodesLine = sizeof(coordsLine)/sizeof(coordsLine[0]); - if(verbose) std::cout << "numNodes= " << numNodes << std::endl; - if(verbose) std::cout << "numNodesLine= " << numNodesLine << std::endl; - - unsigned quad4Elems[] = { - 0,1,2,3, - 4,5,6,7, - 0,0,0,0 // sentinel - }; - enum { - numElems = sizeof(quad4Elems)/(4*sizeof(quad4Elems[0])) - 1 // drop sentinel - }; - if(verbose) std::cout << "numElems= " << numElems << std::endl; - - unsigned line2Elems[] = { - 0,1, - 1,2, - 2,3, - 3,4, - 0,0 // sentinel - }; - enum { - numElemsL2 = sizeof(line2Elems)/(2*sizeof(line2Elems[0])) - 1 // drop sentinel - }; - if(verbose) std::cout << "numElemsL2= " << numElemsL2 << std::endl; - - ArrayInt2 an(numElems, 4); - an.assign(quad4Elems, numElems, 4); - - - if(verbose) std::cout << an(0,0) << std::endl; - if(verbose) std::cout << an(1,0) << std::endl; - - //ArrayInt2 an1(an); - // std::cout << an1(0,0) << std::endl; - // std::cout << an1(1,0) << std::endl; - - boost::array b = a; - boost::array bb = aa[1]; - if(verbose) std::cout << b.data()[3] << std::endl; - if(verbose) std::cout << bb[4] << std::endl; - if(verbose) std::cout << coords[3][0] << std::endl; - - std::vector vec(10); - vec[0] = coords[3].data(); - if(verbose) std::cout << vec[0][0] << std::endl; - - std::vector< boost::array > vec1(10); - vec1[0] = aa[1]; - if(verbose) std::cout << vec1[0][4] << std::endl; - - // - std::vector vquad(quad4Elems, quad4Elems+numElems*4); - if(verbose) std::cout << vquad.size() << std::endl; - - // quad mesh - SweepMesher tp2; - SweepMesher quadMeshCopy; - - tp2.dump(verbose); // true to turn it on, off by default - tp2.initNodes(coords, numNodes); - tp2.initElems(shards_Quadrilateral_4, quad4Elems, numElems); - tp2.dump(); - - // line2 mesh - tp2.initialize(); - - tp2.initNodes(coordsLine, numNodesLine); - tp2.initElems(shards_Line_2, line2Elems, numElemsL2); - if(verbose) std::cout << "line2 mesh\n"; - tp2.dump(); - - // sweep to make a quad mesh from line mesh - boost::array dir = {{0,1.234,0}}; - - TransformDir xf0 ( dir ); - Transform* xf = &xf0;//new TransformDir( dir ); - - std::vector xforms(3, xf); - //xforms.push_back(xf); - tp2.sweep(shards_Line_2, shards_Quadrilateral_4, xforms); - if(verbose) std::cout << "after line to quad sweep\n"; - tp2.dump(); - - quadMeshCopy.CopyFromBasicMesh(tp2); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-quad.e"); - - // break one of the quads into tris - tp2.breakElement(0); - //tp2.breakElement(1); - //verbose=true; - if(verbose) std::cout << "after break quad to tri\n"; - tp2.dump(verbose); - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-quad-tri.e"); - - // sweep again to make a mixed hex and wedge mesh - boost::array dir1 = {{0,0,2.345}}; - std::vector xforms0(1); - TransformDir xf01(dir1); - xforms0[0] = &xf01; //new TransformDir(dir1); - //tp2.sweep( shards_Quadrilateral_4, shards_Hexahedron_8, xforms); - tp2.sweep(xforms0); - - if(verbose) std::cout << "after sweep for mixed hex/wedge \n"; - tp2.dump(); - //tp2.stkMeshCreate(parallel_machine); - //tp2.writeSTKMesh("tp2-hex-wedge.e"); - - // break one of the wedges into tets (note: this creates an inconsistent mesh - for testing purposes only) - tp2.breakElement(0); - tp2.breakElement(0); - - if(verbose) std::cout << "after wedge/tet break" << std::endl; - tp2.dump(); - - // std::cout << "creating stk mesh 1" << std::endl; - // tp2.stkMeshCreate1(parallel_machine); - // std::cout << "after creating stk mesh 1" << std::endl; - - if(verbose) std::cout << "creating stk mesh" << std::endl; - tp2.stkMeshCreate(parallel_machine); - if(verbose) std::cout << "after creating stk mesh" << std::endl; - tp2.dumpSTK(); - tp2.writeSTKMesh("tp2-hex-tet.e"); - - /////////////// break all testing - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "all elems dump" << std::endl; - tp2.dump(); - if(verbose) std::cout << "all elems dump done" << std::endl; - - // break all quads - tp2.breakAllElements(); - if(verbose) std::cout << "all elems: after break\n"; - tp2.dump(); - - // sweep again to make an all-wedge mesh - //boost::array dir1 = {{0,0,2.345}}; - TransformDir xforms02(dir1); - xforms[0] = &xforms02; //new TransformDir(dir1); - std::vector xforms1(8, xforms[0]); - //tp2.sweep( shards_Quadrilateral_4, shards_Hexahedron_8, xforms); - tp2.sweep(xforms1); - - if(verbose) std::cout << "all elems: after sweep for all wedge \n"; - tp2.dump(); - - // break all of the wedges into tets - tp2.breakAllElements(); - - if(verbose) std::cout << "all elems: after all wedge/tet break" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all.e"); - - /////////////// break all testing - hexes - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "hex all elems dump" << std::endl; - tp2.dump(); - if(verbose) std::cout << "hex all elems dump done" << std::endl; - - // sweep again to make an all-hex mesh - tp2.sweep(xforms1); - - if(verbose) std::cout << "hex all elems: after sweep for all hex \n"; - tp2.dump(); - - if(verbose) std::cout << "hex all elems: after sweep" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex.e"); - - // break hex all of the hexes into tets - tp2.breakAllElements(); - if(verbose) std::cout << "hex all elems: after all hex/tet break" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-tet.e"); - - /////////////// path test - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "path elems dump" << std::endl; - tp2.dump(); - if(verbose) std::cout << "path elems dump done" << std::endl; - - // sweep again to make an all-hex mesh - // VectorOfCoord vpath; - // boost::array path[7] = {{{0,0,0}},{{0,0,.2}},{{0,0,.4}},{{0,0,.8}},{{0,0,1.6}},{{0,0,3.2}},{{0,0,6.4}} }; - // for (unsigned i = 0; i < 7; i++) - // { - // vpath.push_back(path[i]); - // } - // tp2.sweep(vpath); - double path[7][3] = {{0,0,0},{0,0,.2},{0,0,.4},{0,0,.8},{0,0,1.6},{0,0,3.2},{0,0,6.4} }; - tp2.sweep(path, 7); - - if(verbose) std::cout << "path elems: after sweep for all hex \n"; - tp2.dump(); - - if(verbose) std::cout << "path elems: after sweep" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-path.e"); - - // break path of the hexes into tets - tp2.breakAllElements(); - if(verbose) std::cout << "path elems: after all hex/tet break path" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-tet-path.e"); - - /////////////// path test 2 - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - if(verbose) std::cout << "path 2 elems dump" << std::endl; - tp2.dump(); - if(verbose) std::cout << "path 2 elems dump done" << std::endl; - - // sweep again to make an all-hex mesh - // VectorOfCoord vpath; - // boost::array path[7] = {{{0,0,0}},{{0,0,.2}},{{0,0,.4}},{{0,0,.8}},{{0,0,1.6}},{{0,0,3.2}},{{0,0,6.4}} }; - // for (unsigned i = 0; i < 7; i++) - // { - // vpath.push_back(path[i]); - // } - // tp2.sweep(vpath); - //double path2[7][3] = {{0,0,0},{0,0,.2},{0,0,.4},{0,0,.8},{0,0,1.6},{0,0,3.2},{0,0,6.4} }; - - - double rad = 10.0; - double pi = M_PI; - VectorOfCoord path2; - VectorOfCoord dir2; - //boost::array pt[] = { {{0,0,0}}, {{0, rad*cos(pi/8.), rad*sin(pi/8.)}} }; - boost::array pt[] = { {{0,0,0}}, {{0, 0, rad}} }; - path2.push_back(pt[0]); - path2.push_back(pt[1]); - boost::array dr[] = { {{0,0,1}}, {{0, -sin(pi/8.), cos(pi/8.)}} }; - dir2.push_back(dr[0]); - dir2.push_back(dr[1]); - tp2.sweep(path2, dir2); - - - if(verbose) std::cout << "path2 elems: after sweep for all hex \n"; - tp2.dump(); - - if(verbose) std::cout << "path2 elems: after sweep" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-path2.e"); - - // break path2 of the hexes into tets - tp2.breakAllElements(); - if(verbose) std::cout << "path2 elems: after all hex/tet break path2" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-tet-path2.e"); - - /////////////// path test 3 - tp2.initialize(); - tp2.CopyFromBasicMesh(quadMeshCopy); - rad = 10.0; - boost::array dirT = {{0,rad,0}}; - TransformDir xf03 ( dirT ); - xf = &xf03; //new TransformDir( dirT ); - tp2.transform(*xf); - - if(verbose) std::cout << "path 3 elems dump" << std::endl; - tp2.dump(); - if(verbose) std::cout << "path 3 elems dump done" << std::endl; - - VectorOfCoord path3; - VectorOfCoord dir3; - - boost::array pt0 = {{0,rad,0}} ; - path3.push_back(pt0); - boost::array dr0 = {{0,0,1}} ; - dir3.push_back(dr0); - - unsigned ntheta = 8; - for (unsigned ith = 1; ith <= ntheta; ith++) - { - double th = M_PI*((double)ith)/((double)ntheta); - boost::array pt1 = {{0, rad*cos(th), rad*sin(th)}}; - boost::array dr1 = {{0, -sin(th), cos(th)}}; - path3.push_back(pt1); - dir3.push_back(dr1); - } - tp2.sweep(path3, dir3); - - if(verbose) std::cout << "path3 elems: after sweep for all hex \n"; - tp2.dump(); - - if(verbose) std::cout << "path3 elems: after sweep" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-path3.e"); - - // break path3 of the hexes into tets - tp2.breakAllElements(); - if(verbose) std::cout << "path3 elems: after all hex/tet break path3" << std::endl; - tp2.dump(); - tp2.stkMeshCreate(parallel_machine); - tp2.writeSTKMesh("tp2-all-hex-tet-path3.e"); - - //////////////// square mesh - SweepMesher tp3; - tp3.squareMesh(10, 20, 10., 20.); - if(verbose) std::cout << "test square mesh" << std::endl; - tp3.dump(); - tp3.stkMeshCreate(parallel_machine); - tp3.writeSTKMesh("tp3-square.e"); - - //////////////// cube mesh - SweepMesher tp4; - tp4.cubeMesh(5, 10, 12, 5., 10., 12.); - if(verbose) std::cout << "test cube mesh" << std::endl; - tp4.dump(); - - XF1 xf11; - tp4.transform(xf11); - - tp4.stkMeshCreate(parallel_machine); - tp4.writeSTKMesh("tp4-cube.e"); - - //MPI_Finalize(); - return 0; - } - - }//namespace unit_tests - }//namespace percept -}//namespace stk_classic diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi.cpp deleted file mode 100644 index b0b182b44dc8..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -//#include -//#include "Intrepid_CellToolsDef.hpp" -#include "Shards_CellTopology.hpp" - - -#include "Intrepid_HGRAD_HEX_C1_FEM.hpp" - -// #ifdef __PGI -// #include "Intrepid_HGRAD_HEX_C1_FEMDef.hpp" -// #endif - - - -int mymainpgi(int argc, char **argv); -int main(int argc, char **argv) { -#if 1 - if( new Intrepid::Basis_HGRAD_HEX_C1_FEM >()) - { - } -#endif -#if 0 - { - using namespace Intrepid; - using namespace shards; - CellTopology cell_topo(shards::getCellTopologyData >() ); - - Teuchos::RCP< Basis< double, FieldContainer > > HGRAD_Basis = getHGRAD_Basis(cell_topo); - } -#endif - mymainpgi(argc, argv); -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi1.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi1.cpp deleted file mode 100644 index 7a32030bce81..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/pgi_compile/testpgi1.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#define REDS1 1 - - -#include "Intrepid_HGRAD_HEX_C1_FEM.hpp" - -#include "Intrepid_RealSpaceTools.hpp" -#include "Intrepid_FunctionSpaceTools.hpp" -#include "Intrepid_DefaultCubatureFactory.hpp" -#include -#include "Shards_CellTopology.hpp" - - -#include "Intrepid_CellTools.hpp" - -int mymainpgi(int argc, char **argv) { -#if 0 - if( new Intrepid::Basis_HGRAD_HEX_C1_FEM >()) - { - } -#endif - - if (new Intrepid::DefaultCubatureFactory) - { - } -#if 1 - //Intrepid::Basis BasisType; - { - using namespace Intrepid; - using namespace shards; - - CellTopology cell_topo(shards::getCellTopologyData >() ); - unsigned numCells = 1; - unsigned numNodes = cell_topo.getNodeCount(); - unsigned spaceDim = cell_topo.getDimension(); - - // Rank-3 array with dimensions (C,N,D) for the node coordinates of 3 traingle cells - FieldContainer cellNodes(numCells, numNodes, spaceDim); - - DefaultCubatureFactory cubFactory; // create cubature factory - unsigned cubDegree = 2; // set cubature degree, e.g. 2 - Teuchos::RCP > myCub = cubFactory.create(cell_topo, cubDegree); // create default cubature - - unsigned numCubPoints = myCub->getNumPoints(); // retrieve number of cubature points - - FieldContainer cub_points(numCubPoints, spaceDim); - FieldContainer cub_weights(numCubPoints); - - // Rank-4 array (C,P,D,D) for the Jacobian and its inverse and Rank-2 array (C,P) for its determinant - FieldContainer jacobian(numCells, numCubPoints, spaceDim, spaceDim); - FieldContainer jacobian_inv(numCells, numCubPoints, spaceDim, spaceDim); - FieldContainer jacobian_det(numCells, numCubPoints); - - myCub->getCubature(cub_points, cub_weights); // retrieve cubature points and weights - // Methods to compute cell Jacobians, their inverses and their determinants - - CellTools::setJacobian(jacobian, cub_points, cellNodes, cell_topo); // compute cell Jacobians -#if 0 - - CellTools::setJacobianInv(jacobian_inv, jacobian); // compute inverses of cell Jacobians - CellTools::setJacobianDet(jacobian_det, jacobian); // compute determinants of cell Jacobians -#endif - } -#endif - return 0; -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/print_table.py b/packages/stk/stk_classic/stk_percept/unit_tests/print_table.py deleted file mode 100755 index c07b4ad1306d..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/print_table.py +++ /dev/null @@ -1,69 +0,0 @@ -#coding: UTF8 -""" -Prints out a table. - -call print_table with an output (e.g. sys.stdout, cStringIO, file) -and table as a list of lists. Make sure table is "rectangular" -- each -row has the same number of columns. - -MIT License -""" - -__version__ = "0.1" -__author__ = "Ryan Ginstrom" -__modified__ = "Nathan Merkley(csimsoft)" - -import locale -locale.setlocale(locale.LC_NUMERIC, "") - -def format_num(num): - """Format a number according to given places. - Adds commas, etc. - - Will truncate floats into ints!""" - - try: - #inum = int(num) - return locale.format("%16.4f", (0, num), True) - - except (ValueError, TypeError): - return str(num) - -def get_max_width(table, index): - """Get the maximum width of the given column index - """ - - return max([len(format_num(row[index])) for row in table]) - -def print_table(out, table): - """Prints out a table of data, padded for alignment - - @param out: Output stream ("file-like object") - @param table: The table to print. A list of lists. Each row must have the same - number of columns. - - """ - - col_paddings = [] - - for i in range(len(table[0])): - col_paddings.append(get_max_width(table, i)) - - for row in table: - # left col - print >> out, row[0].ljust(col_paddings[0] + 1), - # rest of the cols - for i in range(1, len(row)): - col = format_num(row[i]).rjust(col_paddings[i] + 2) - print >> out, col, - print >> out - -if __name__ == "__main__": - table = [["", "taste", "land speed", "life"], - ["spam", 300101, 4, 1003], - ["eggs", 105, 13, 42], - ["lumberjacks", 13, 105, 10]] - - import sys - out = sys.stdout - pprint_table(out, table) diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/run-py-unit b/packages/stk/stk_classic/stk_percept/unit_tests/run-py-unit deleted file mode 100755 index fc5fa7528df4..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/run-py-unit +++ /dev/null @@ -1,7 +0,0 @@ -#python Example.py -python FieldFunctionUnitTests.py -python NormUnitTests.py -python PerceptMeshUnitTests.py -python StringFunctionUnitTests.py -python UniformRefinerUnitTests.py -#python UseCases.py diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/runme_example.py b/packages/stk/stk_classic/stk_percept/unit_tests/runme_example.py deleted file mode 100644 index f1272ae81556..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/runme_example.py +++ /dev/null @@ -1,51 +0,0 @@ -# file: runme.py - -# This file illustrates the proxy class C++ interface generated -# by SWIG. - -import example - -# ----- Object creation ----- - -print "Creating some objects:" -c = example.Circle(10) -print " Created circle", c -s = example.Square(10) -print " Created square", s - -# ----- Access a static member ----- - -print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" - -# ----- Member data access ----- - -# Set the location of the object - -c.x = 20 -c.y = 30 - -s.x = -10 -s.y = 5 - -print "\nHere is their current position:" -print " Circle = (%f, %f)" % (c.x,c.y) -print " Square = (%f, %f)" % (s.x,s.y) - -# ----- Call some methods ----- - -print "\nHere are some properties of the shapes:" -for o in [c,s]: - print " ", o - print " area = ", o.area() - print " perimeter = ", o.perimeter() - -print "\nGuess I'll clean up now" - -# Note: this invokes the virtual destructor -del c -del s - -s = 3 -print example.cvar.Shape_nshapes,"shapes remain" -print "Goodbye" - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/sun_compile/main-sun.cpp b/packages/stk/stk_classic/stk_percept/unit_tests/sun_compile/main-sun.cpp deleted file mode 100644 index 949aaba157dd..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/sun_compile/main-sun.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -//======================================================================================================================== -//======================================================================================================================== -//======================================================================================================================== - -#include -#include -#include "Intrepid_DefaultCubatureFactory.hpp" - -int main() -{ - using namespace Intrepid; - using namespace shards; - - Intrepid::FieldContainer aa(1,2); - aa(0,1)=1.0; - std::cout << "aa= \n" << aa << std::endl; - - CellTopology triangle_3( shards::getCellTopologyData >() ); - - DefaultCubatureFactory cubFactory; // create cubature factory - unsigned cubDegree = 2; // set cubature degree, e.g. 2 - Teuchos::RCP > myCub = cubFactory.create(triangle_3, cubDegree); // create default cubature - - - -} - - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/README b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/README deleted file mode 100644 index dce56c5d0e21..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/README +++ /dev/null @@ -1,9 +0,0 @@ -# run cmd: - -code_verify.py -nf P output1.gold.e output2.gold.e output3.gold.e - -# output (truncated): columns 3-4 are error norms, which are not going to zero. - -7 16.0 25216.3550929 38646.957713 -8 64.0 25212.0319533 37295.9369793 -8 256.0 25212.6756225 37388.725627 diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.debug.py b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.debug.py deleted file mode 100644 index cf0b56a33f2f..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.debug.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -from PerceptMesh import * -from math import * - -import argparse - -"""Entry point for Percept script.""" -parser = argparse.ArgumentParser() - -parser.add_argument("-nf", "--nodal_field", nargs=1, help="name of nodal field") -parser.add_argument("-sf", "--exact_soln_string", nargs=1, help="name of nodal field") -parser.add_argument("results_files", nargs=argparse.REMAINDER, help="list of Exodus results files") - -args = parser.parse_args() - -# A) user inputs - -# INPUT: list of exodus output files -mesh_files=args.results_files - -#mesh_files=["output1.gold.e"] -num_meshes=len(mesh_files) - -nodal_fields=args.nodal_field - -#eps = 0.05 -#sf_eps = StringFunction(str(eps), "eps", Dimensions(2), Dimensions(1)); - -#p0 = 35651.28116 -#sf_p0 = StringFunction(str(p0), "p0", Dimensions(2), Dimensions(1)); - -#exact_soln_string="p0*(1.0 - eps*sin(PI*x)*cos(PI*y))" -exact_soln_string="35651.28116*(1.0 - 0.05*sin(PI*x)*cos(PI*y))" - -exact_soln_name = [nodal_fields[0]+"_ex"] -sf_ex = [StringFunction(exact_soln_string, exact_soln_name[0], Dimensions(2), Dimensions(1))] - -num_norms=2 -errors=[0]*num_meshes*num_norms - -expected_rates=[2,2] - -tolerances=[1e-2]*num_norms - -dofs_are_elems=True; -dofs=[0]*num_meshes - -rates=[0]*(num_meshes-1)*num_norms -print "rates= ", rates - -##################################################################################### - -# B) loop over meshes and compute errors - -for i in range(0,num_meshes): - pMesh = PerceptMesh(2) - pMesh.open(mesh_files[i]) - pMesh.commit() - print "mesh_files[i]= " , i, mesh_files[i] - - spatial_dim=pMesh.get_spatial_dim() - # TODO: check that this matches the StringFunction exact solution - - metaData = pMesh.get_fem_meta_data() - bulkData = pMesh.get_bulk_data() - - nodal_field = metaData.get_field(nodal_fields[0]) - ff_Tnd = FieldFunction(nodal_fields[0], nodal_field, bulkData, Dimensions(spatial_dim), Dimensions(1)) - - error_string = [exact_soln_name[0]+" - "+nodal_fields[0]]; - error_name = [nodal_fields[0]+"_err"] - print "error_string= ", error_string - sf_Terr = StringFunction(error_string[0], error_name[0], Dimensions(spatial_dim), Dimensions(1)) - - numSteps = pMesh.get_database_time_step_count() - print "numSteps= ", numSteps, " nodal_fields[0]= ", nodal_fields[0] - pMesh.read_database_at_step(numSteps) - - - p_field = pMesh.get_field("P") - node = pMesh.get_node(1) - p1 = pMesh.get_field_data(p_field, node) - print "p1= " , p1 - - p21 = eval_func2(2,1,0,ff_Tnd) - p21_ex = eval_func2(2,1,0,sf_ex[0]) - err = eval_func2(2,1,0,sf_Terr) - print "p21 = ", p21, p21_ex, err - - # DEBUG - print numSteps, pMesh.get_current_database_step(), pMesh.get_current_database_time() - - cubDegree = 2 - lInfNorm = LInfNorm(bulkData) - lInfNorm.setCubDegree(cubDegree) - - l2Norm = L2Norm(bulkData) - l2Norm.setCubDegree(cubDegree) - - errors[i*2]=l2Norm.evaluate(sf_Terr) - errors[i*2+1]=lInfNorm.evaluate(sf_Terr) - - if dofs_are_elems: - dofs[i] = float(pMesh.get_number_elements()) - else: - dofs[i] = float(pMesh.get_number_nodes()) - - print "done: ", numSteps, dofs[i], errors[i*2], errors[i*2+1] - -for i in range(0,num_meshes-1): - mesh_ratio=pow(dofs[i]/dofs[i+1],-1.0/spatial_dim) - for n in range(0,2): - rates[i*2+n]=log(errors[i*2+n]/errors[(i+1)*2+n])/log(mesh_ratio) - print rates[i*2+n], rates[i*2+n]-expected_rates[n], tolerances[n] - -# OUTPUT: -# pass: if rates are within tolerance of expected rates -# fail: otherwise - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.py b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.py deleted file mode 100755 index 2adbb2eaf348..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/code_verify.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/netpub/python-2.7/bin/python - -from PerceptMesh import * -from math import * - -import argparse - -"""Entry point for Percept script.""" -parser = argparse.ArgumentParser() - --nf euler_p -parser.add_argument("-nf", "--nodal_field", nargs=1, help="name of nodal field") -parser.add_argument("-sf", "--exact_soln_string", nargs=1, help="name of nodal field") -parser.add_argument("results_files", nargs=argparse.REMAINDER, help="list of Exodus results files") - -args = parser.parse_args() - -# A) user inputs - -# INPUT: list of exodus output files -mesh_files=args.results_files -num_meshes=len(mesh_files) - -nodal_fields=args.nodal_field - -#eps = 0.05 -#sf_eps = StringFunction(str(eps), "eps", Dimensions(2), Dimensions(1)); - -#p0 = 35651.28116 -#sf_p0 = StringFunction(str(p0), "p0", Dimensions(2), Dimensions(1)); - -#exact_soln_string="p0*(1.0 - eps*sin(PI*x)*cos(PI*y))" -exact_soln_string="35651.28116*(1.0 - 0.05*sin(PI*x)*cos(PI*y))" - -exact_soln_name = [nodal_fields[0]+"_ex"] -sf_ex = [StringFunction(exact_soln_string, exact_soln_name[0], Dimensions(2), Dimensions(1))] - -num_norms=2 -errors=[0]*num_meshes*num_norms - -expected_rates=[2,2] - -tolerances=[1e-2]*num_norms - -dofs_are_elems=True; -dofs=[0]*num_meshes - -rates=[0]*(num_meshes-1)*num_norms -print "rates= ", rates - -##################################################################################### - -# B) loop over meshes and compute errors - -for i in range(0,num_meshes): - pMesh = PerceptMesh(2) - pMesh.open(mesh_files[i]) - pMesh.commit() - - spatial_dim=pMesh.get_spatial_dim() - # TODO: check that this matches the StringFunction exact solution - - metaData = pMesh.get_fem_meta_data() - bulkData = pMesh.get_bulk_data() - - nodal_field = metaData.get_field(nodal_fields[0]) - ff_Tnd = FieldFunction(nodal_fields[0], nodal_field, bulkData, Dimensions(spatial_dim), Dimensions(1)) - - error_string = [exact_soln_name[0]+" - "+nodal_fields[0]]; - error_name = [nodal_fields[0]+"_err"] - sf_Terr = StringFunction(error_string[0], error_name[0], Dimensions(spatial_dim), Dimensions(1)) - - numSteps = pMesh.get_database_time_step_count() - pMesh.read_database_at_step(numSteps) - - # DEBUG - print numSteps, pMesh.get_current_database_step(), pMesh.get_current_database_time() - - cubDegree = 2 - lInfNorm = LInfNorm(bulkData) - lInfNorm.setCubDegree(cubDegree) - - l2Norm = L2Norm(bulkData) - l2Norm.setCubDegree(cubDegree) - - errors[i*2]=l2Norm.evaluate(sf_Terr) - errors[i*2+1]=lInfNorm.evaluate(sf_Terr) - - if dofs_are_elems: - dofs[i] = float(pMesh.get_number_elements()) - else: - dofs[i] = float(pMesh.get_number_nodes()) - - print numSteps, dofs[i], errors[i*2], errors[i*2+1] - -for i in range(0,num_meshes-1): - mesh_ratio=pow(dofs[i]/dofs[i+1],-1.0/spatial_dim) - for n in range(0,2): - rates[i*2+n]=log(errors[i*2+n]/errors[(i+1)*2+n])/log(mesh_ratio) - print rates[i*2+n], rates[i*2+n]-expected_rates[n], tolerances[n] - -# OUTPUT: -# pass: if rates are within tolerance of expected rates -# fail: otherwise - diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/mms_user.C b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/mms_user.C deleted file mode 100644 index f29c17e60b0c..000000000000 --- a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/mms_user.C +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include - -namespace stk_classic -{ -namespace mms -{ - // global params - const double eps = 0.05; - - const double gamma = 1.4; - const double Rgas = 287.0973757; - const double Cv = Rgas/(gamma-1.0); - - const double M0 = 2.5; - const double p0 = 35651.28116; - const double T0 = 236.215; - - const double rho0 = p0/(Rgas*T0); - const double u0 = M0*sqrt(gamma*p0/rho0); - -extern "C" FAD2_Type euler_p(const FAD2_Type & x, - const FAD2_Type & y, - const FAD2_Type & z, - const FAD2_Type & t) { - return p0*(1.0 - eps*sin(M_PI*x)*cos(M_PI*y)); -} - -extern "C" FAD2_Type euler_T(const FAD2_Type & x, - const FAD2_Type & y, - const FAD2_Type & z, - const FAD2_Type & t) { - return T0*(1.0 + eps*sin(M_PI*x)*sin(M_PI*y)); -} - -extern "C" FAD2_Type euler_u(const FAD2_Type & x, - const FAD2_Type & y, - const FAD2_Type & z, - const FAD2_Type & t) { - return u0*(1.0 - eps*sin(M_PI*x)*cos(M_PI*y)); -} - -extern "C" FAD2_Type euler_v(const FAD2_Type & x, - const FAD2_Type & y, - const FAD2_Type & z, - const FAD2_Type & t) { - return u0*eps*sin(M_PI*x)*sin(M_PI*y); -} - -extern "C" void register_euler() -{ - sierra::Plugin::UserSubroutine::instance(). - registerFunction(std::string("euler_p"), euler_p); - - sierra::Plugin::UserSubroutine::instance(). - registerFunction(std::string("euler_T"), euler_T); - - sierra::Plugin::UserSubroutine::instance(). - registerFunction(std::string("euler_u"), euler_u); - - sierra::Plugin::UserSubroutine::instance(). - registerFunction(std::string("euler_v"), euler_v); -} - -} -} diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output1.gold.e b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output1.gold.e deleted file mode 100644 index 39a4c7a4b2d72e7f72d673e91cef0c8774b31744..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19748 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 diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output2.gold.e b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output2.gold.e deleted file mode 100644 index 7492226b2ad33b85c5fc802d4d1c5b4f4e76c107..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40884 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%0DR?*rH(@s@Q#`O3lBnmMR7`o{RbbwpTZh*^>P4@ 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 Hq&EByO1AX3 diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output3.gold.e b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output3.gold.e deleted file mode 100644 index f187ac38b6801973ef83791bd0510fb3ead2eaf8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 115700 zcmeFY2Urx#w*HNx1Qit(P%(@OMsgBC>>{ZsIhYj@5RjPx34$3FnZbyPIbaqeia9do ztRRA7Vj4ljoCBusT`;)ao*mCQ_u2P;f9CN=tzO+-UGJ(@)jd6>qf^hCN=iyMm}MfI2g7Us5LSoHi}B19up=C#tFfZ*id}xh+{?mqXYb- zf&(i&HSkxBd|~2|5wMAhI>iAZs*|pvO8bMtL@<@8P3p8QjtB~lCXZ5$igu7MSQw0h zs7j@Z>jVq^M+n1dv%;xC$3%w(p-sUtmFHHpvwr2dXaXH>T6MTm1I2axBZH$*cf}6U zRqvO2qRH9tC!g7G_{@L9XQA-bt-8*b01BN_ZBP%WgSr8cVg6%+qoTti#MrFZSA%UF zITE(&@A#XJ6h;KZpqKn3Bf`Wn{&5jeLC`&p;z{kVh&f92kzqo_qH@O%`)GeXoM>f% z&I^c%rBGF!2UDqbOjwMND#M5RL(3_6WI(JiM&J_`92FHH@cm`CQvJxNh``|J=!mGQ z98Gcd2ZGD+ptaN(_s`jI*zVI@vZuhPp@*rVkb)V=;(iGAN5<+hw7#=g^$H` z{87X4KemsK{j>H}onNdt|Ht;x`9HTW5k7n@-r$c)U<7(IzQXZy-{3rTMc!D_5tYY| z{j+0xB;bfTRPXmlRmMt{>Zmxo@(;zzsnYBvMX44TAr=P*#!%nTKGLnBD5-7g6}b^J zHu8t@sN&^k??jUeK8U3v6iU4=VOy=@_~?pxi_Wi42Pr-{R*6;G{VR^GoGbtA*a6h0 zs(NYeqk0=u)>HBKhk6IN!lS0B_s@=;NfE1wL+`f}T-f0=IxDfvL5?)Xc`h%*MQ%z}d-HV5Z~}5ghOD z6c7_IA|N{0#ly%^P}xWeW7BSekf7*M0hLbx-&^o!hH-RYR6tB%sPTxvfGBZrw6Twi zv$waszpuB8tBbpbk8vO*7)J$1f^id8(i7N6 zMg?QG6?F6t9ur279X8NvX4Og1KR5`o#tKZW1eKAqu&QYOAGgsVI3!G5^?h>j{(It2k3yz8zEAWX74h$O^7Kms02ysRCD8|oU3^c_sBtRqzK>nE;DJJ

;FQh;JZ|iAT~NUN)RcG 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 F#lQSq>#P6( diff --git a/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output4.gold.e b/packages/stk/stk_classic/stk_percept/unit_tests/transient_example/output4.gold.e deleted file mode 100644 index 44a0dae1e662a9460cffd841b764f5ae60fc90f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 403572 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

p6-e`r0#8-!A` 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

4e^g=G*1(J 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 -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -namespace { - -/** To create a movie from this performance test, change the - output_exodus_file flag to true and run. Then do the following: - > conjoin -output gears.e mesh_* - > module load viz - > paraview - [ open conjoin file, filter until happy ] - [ change viewport to largest possible (to increase resolution of image)] - [ press play till happy ] - [ save as animation with 60fps ] -**/ - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::fixtures::GearsFixture::CartesianField CartesianField; -typedef stk_classic::mesh::Field IntField; - -// -//----------------------------------------------------------------------------- -// - -/** - * Make a single wedge seperate itself from the cylinder and fly off on its - * own. - */ -// if do_separate_wedge == true then wedge must be nonnull pointer -void separate_wedge( - bool do_separate_wedge, - stk_classic::mesh::fixtures::GearsFixture & fixture, - stk_classic::mesh::Entity * wedge, - CartesianField & velocity_field, - stk_classic::mesh::Part & skin_part - ) -{ - // Parallel collective call: - fixture.bulk_data.modification_begin(); - - // Request new nodes - const size_t num_nodes_per_wedge = 6; - const size_t spatial_dim = fixture.meta_data.spatial_dimension(); - stk_classic::mesh::EntityVector new_nodes; - - std::vector requests(fixture.meta_data.entity_rank_count(), 0); - if (do_separate_wedge) { - requests[NODE_RANK] = num_nodes_per_wedge; - } else { - requests[NODE_RANK] = 0; - } - - // Parallel collective call: - fixture.bulk_data.generate_new_entities(requests, new_nodes); - - if (do_separate_wedge) { - - // Remove wedge from cylidrical_coord_part - stk_classic::mesh::PartVector empty_parts, remove_parts; - remove_parts.push_back(& fixture.cylindrical_coord_part); - fixture.bulk_data.change_entity_parts(*wedge, empty_parts, remove_parts); - - // Replace wedge's nodes with new nodes because any nodes shared with other - // entities cannot be taken along with the separated wedge. As a - // simplification, we simply leave all the old nodes behind. - stk_classic::mesh::PairIterRelation relations = wedge->relations(NODE_RANK); - ThrowRequire(relations.size() == num_nodes_per_wedge); - - for (size_t i = 0; i < num_nodes_per_wedge; ++i) { - stk_classic::mesh::Entity & old_node = *(relations[ i ].entity()); - stk_classic::mesh::Entity & new_node = *(new_nodes[i]); - - fixture.bulk_data.destroy_relation(*wedge, old_node, i); - fixture.bulk_data.declare_relation(*wedge, new_node, i); - - fixture.bulk_data.copy_entity_fields( old_node, new_node); - } - - // Compute the velocities of the nodes by taking the average of the - // differences in the displacements in the last time step. Note that we need - // all the nodes to have the same velocity; otherwise, the wedge will stretch - std::vector avg_velocity_data(spatial_dim, 0); - for (size_t i = 0; i < num_nodes_per_wedge; ++i) { - stk_classic::mesh::Entity & new_node = *(new_nodes[i]); - const double * const new_displacement_data = - stk_classic::mesh::field_data( fixture.displacement_field.field_of_state(stk_classic::mesh::StateNew), new_node); - - const double * const old_displacement_data = - stk_classic::mesh::field_data( fixture.displacement_field.field_of_state(stk_classic::mesh::StateOld), new_node); - - for (size_t k=0 ; k < spatial_dim ; ++k) { - avg_velocity_data[k] += new_displacement_data[k] - old_displacement_data[k]; - } - - } - - for (size_t k=0 ; k < spatial_dim ; ++k) { - avg_velocity_data[k] /= 1.0*num_nodes_per_wedge; - } - - const double detached_wedge_speedup_multiplier = 1.1; - for (size_t i = 0; i < num_nodes_per_wedge; ++i) { - stk_classic::mesh::Entity & new_node = *(new_nodes[i]); - double * const velocity_data = - stk_classic::mesh::field_data( velocity_field , new_node ); - - for (size_t k=0 ; k < spatial_dim ; ++k) { - velocity_data[k] = detached_wedge_speedup_multiplier*avg_velocity_data[k]; - } - - } - } - - // Parallel collective call: - fixture.bulk_data.modification_end(); - - // Parallel collective call: - stk_classic::mesh::skin_mesh( fixture.bulk_data, fixture.element_rank, &skin_part); - - // Parallel collective call: - fixture.communicate_model_fields(); - -} - -// -//----------------------------------------------------------------------------- -// - -/** - * Stores all the wedges still attached to the cylinder, in random order, - * in the wedges argument. - */ -void find_and_shuffle_wedges_to_separate( - stk_classic::mesh::fixtures::GearsFixture & fixture, - stk_classic::mesh::EntityVector & wedges - ) -{ - // Get all wedges still attached to the cylinder and shuffle them. - - stk_classic::mesh::Selector select_wedge = - fixture.cylindrical_coord_part & - fixture.wedge_part & - fixture.meta_data.locally_owned_part(); - - const stk_classic::mesh::BucketVector wedge_buckets = fixture.bulk_data.buckets(fixture.element_rank); - - stk_classic::mesh::get_selected_entities( - select_wedge, - wedge_buckets, - wedges - ); - - std::random_shuffle(wedges.begin(),wedges.end()); -} - -// -//----------------------------------------------------------------------------- -// - -/** - * Make all the wedges that have already been detached from the cylinder - * continue flying through the air. - */ -void move_detached_wedges( - stk_classic::mesh::fixtures::GearsFixture & fixture, - CartesianField & velocity_field - ) -{ - - // Select all detached nodes by creating a selector for things not in the - // cylinder part. - stk_classic::mesh::Selector select_detached_wedges = (! fixture.cylindrical_coord_part ) & - (fixture.meta_data.locally_owned_part() | fixture.meta_data.globally_shared_part()); - - const stk_classic::mesh::BucketVector all_node_buckets = - fixture.bulk_data.buckets(NODE_RANK); - - stk_classic::mesh::BucketVector node_buckets; - - stk_classic::mesh::get_buckets( - select_detached_wedges, - all_node_buckets, - node_buckets - ); - - // Iterate over selected node_buckets, then iterate over each node in the - // bucket, adjusting the node's displacement according to its velocity. - for (stk_classic::mesh::BucketVector::iterator b_itr = node_buckets.begin(); - b_itr != node_buckets.end(); - ++b_itr) - { - stk_classic::mesh::Bucket & b = **b_itr; - - const stk_classic::mesh::BucketArray velocity_data( velocity_field, b); - stk_classic::mesh::BucketArray old_displacement_data( fixture.displacement_field.field_of_state(stk_classic::mesh::StateOld), b); - stk_classic::mesh::BucketArray new_displacement_data( fixture.displacement_field.field_of_state(stk_classic::mesh::StateNew), b); - - for (size_t i = 0; i < b.size(); ++i) { - for (size_t j = 0; j < fixture.meta_data.spatial_dimension(); ++j) { - new_displacement_data(j,i) = old_displacement_data(j,i) + velocity_data(j,i); - } - } - } -} - - -// -//----------------------------------------------------------------------------- -// - - -void populate_processor_id_field_data( stk_classic::mesh::fixtures::GearsFixture & fixture, - IntField & processor_field - ) -{ - const unsigned p_rank = fixture.bulk_data.parallel_rank(); - - stk_classic::mesh::Selector locally_owned_selector = fixture.meta_data.locally_owned_part(); - - stk_classic::mesh::BucketVector all_element_buckets = - fixture.bulk_data.buckets(fixture.element_rank); - stk_classic::mesh::BucketVector element_buckets; - - stk_classic::mesh::get_buckets( - locally_owned_selector, - all_element_buckets, - element_buckets - ); - - for (stk_classic::mesh::BucketVector::iterator b_itr = element_buckets.begin(); - b_itr != element_buckets.end(); - ++b_itr) - { - stk_classic::mesh::Bucket & b = **b_itr; - stk_classic::mesh::BucketArray processor_data( processor_field, b); - for (size_t index = 0; index < b.size(); ++index) { - processor_data(index) = p_rank; - } - } -} - -// -//----------------------------------------------------------------------------- -// - -} // unnamed namespace - -namespace { - -Ioss::Region *create_output_mesh( - const std::string &mesh_filename, - stk_classic::mesh::BulkData &bulk_data, - const bool skin = false) -{ - const bool add_all_fields = false; - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create( - "exodusII", - mesh_filename, - Ioss::WRITE_RESULTS, - bulk_data.parallel() - ); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << mesh_filename - << "' of type 'exodusII'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - const std::string name = std::string("results_output_")+mesh_filename; - Ioss::Region *out_region = new Ioss::Region(dbo, name); - - const Ioss::Region * null_in_region = NULL; - stk_classic::io::define_output_db(*out_region, bulk_data, null_in_region); - stk_classic::io::write_output_db (*out_region, bulk_data); - - out_region->begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - const Ioss::Field::RoleType role_type = skin ? Ioss::Field::ATTRIBUTE : Ioss::Field::TRANSIENT; - stk_classic::io::ioss_add_fields(stk_classic::mesh::MetaData::get(bulk_data).universal_part(), NODE_RANK, - out_region->get_node_blocks()[0], role_type, add_all_fields); - - const stk_classic::mesh::PartVector & all_parts = stk_classic::mesh::MetaData::get(bulk_data).get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = out_region->get_entity(part->name()); - if (entity != NULL) { - if (skin) { - const bool skin_part = part->name() == "Skin_part"; - if(skin_part) { - Ioss::SideSet *sset = dynamic_cast(entity); - if (!sset) { - std::cerr << "ERROR: could not dynamic_cast entity.\n"; - std::exit(EXIT_FAILURE); - } - for (unsigned i=0; i < sset->block_count(); i++) { - Ioss::SideBlock *fb = sset->get_block(i); - stk_classic::io::ioss_add_fields(*part, part->primary_entity_rank(), - fb, Ioss::Field::TRANSIENT); - } - } - } else if (entity->type() == Ioss::ELEMENTBLOCK) { - stk_classic::io::ioss_add_fields(*part, part->primary_entity_rank(), - entity, Ioss::Field::TRANSIENT, add_all_fields); - } - } - } - } - out_region->end_mode(Ioss::STATE_DEFINE_TRANSIENT); - return out_region; -} - - -} // namespace - -STKUNIT_UNIT_TEST( GearsDemo, skin_gear ) { - - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - const size_t NUM_GEARS = 1; - - stk_classic::mesh::fixtures::GearsFixture fixture(MPI_COMM_WORLD, NUM_GEARS); - const unsigned p_rank = fixture.bulk_data.parallel_rank(); - std::srand(p_rank); // Seed pseudo-random generator based on processor rank. - - stk_classic::mesh::Part & skin_part = fixture.meta_data.declare_part("Skin_part",fixture.element_rank-1); - - const unsigned ONE_STATE = 1; - CartesianField & velocity_field = fixture.meta_data.declare_field("velocity",ONE_STATE); - CartesianField & displacement = fixture.meta_data.declare_field("face_displacement",ONE_STATE); - IntField & processor_field = fixture.meta_data.declare_field("processor_id",ONE_STATE); - - stk_classic::mesh::put_field( - velocity_field, - NODE_RANK, - fixture.meta_data.universal_part(), - fixture.meta_data.spatial_dimension() - ); - - stk_classic::mesh::put_field( - processor_field, - fixture.element_rank, - fixture.meta_data.universal_part() - ); - - // add io parts - stk_classic::io::put_io_part_attribute( fixture.hex_part); - stk_classic::io::put_io_part_attribute( fixture.wedge_part); - stk_classic::io::put_io_part_attribute( skin_part); - stk_classic::io::set_field_role(fixture.displacement_field.field_of_state(stk_classic::mesh::StateNew), Ioss::Field::TRANSIENT); - stk_classic::io::set_field_role(displacement, Ioss::Field::TRANSIENT); - stk_classic::io::set_field_role(processor_field, Ioss::Field::TRANSIENT); - - std::set skin_io_parts; skin_io_parts.insert(&skin_part); - const stk_classic::mesh::PartVector & parts = fixture.meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = parts.begin(); ip != parts.end(); ++ip ) { - stk_classic::mesh::Part & topo_part = **ip; - if(topo_part.primary_entity_rank() == fixture.element_rank-1 && std::string::npos!=topo_part.name().find("FEM_ROOT_CELL_TOPOLOGY_PART")) { - std::string t; - if (t.npos != topo_part.name().find("Triangle_3")) t = "skin_wedge6_tri3_1"; - else if (t.npos != topo_part.name().find("Triangle_6")) t = "skin_wedge15_tri6_2"; - else if (t.npos != topo_part.name().find("Triangle_4")) t = "skin_wedge6_tri4_3"; - else if (t.npos != topo_part.name().find("Quadrilateral_4")) t = "skin_hex8_quad4_4"; - else if (t.npos != topo_part.name().find("Quadrilateral_8")) t = "skin_hex20_quad8_5"; - else if (t.npos != topo_part.name().find("Quadrilateral_9")) t = "skin_hex27_quad9_6"; - else { - t = topo_part.name()+std::string("_Skin_part"); - t.erase(t.find("FEM_ROOT_CELL_TOPOLOGY_PART"), sizeof("FEM_ROOT_CELL_TOPOLOGY_PART")); - } - stk_classic::mesh::Part & topo_skin_part = fixture.meta_data.declare_part(t, fixture.element_rank-1); - skin_io_parts.insert(&topo_skin_part); - stk_classic::io::put_io_part_attribute(topo_skin_part); - fixture.meta_data.declare_part_subset(topo_part, topo_skin_part); - fixture.meta_data.declare_part_subset(skin_part, topo_skin_part); - if ( t == "skin_hex8_quad4_4" || t == "skin_hex20_quad8_5") { - if (t == "skin_hex8_quad4_4") t = "skin_wedge6_quad4_4"; - else t = "skin_wedge15_quad4_8"; - stk_classic::mesh::Part & topo_skin_part2 = fixture.meta_data.declare_part(t, fixture.element_rank-1); - skin_io_parts.insert(&topo_skin_part2); - stk_classic::io::put_io_part_attribute(topo_skin_part2); - fixture.meta_data.declare_part_subset(topo_part, topo_skin_part2); - fixture.meta_data.declare_part_subset(skin_part, topo_skin_part2); - } - } - } - stk_classic::mesh::Selector surface_select = fixture.meta_data.locally_owned_part(); - { - stk_classic::mesh::put_field( displacement, fixture.element_rank-1, skin_part); - const stk_classic::mesh::PartVector &surf_parts = skin_part.subsets(); - for ( stk_classic::mesh::PartVector::const_iterator ip = surf_parts.begin(); ip != surf_parts.end(); ++ip ) { - stk_classic::mesh::Part & surf_part = **ip; - if (surf_part.primary_entity_rank() == fixture.element_rank-1) { - surface_select |= surf_part; - stk_classic::mesh::put_field( displacement, fixture.element_rank-1, surf_part); - } - } - } - - fixture.meta_data.commit(); - - fixture.generate_mesh(); - - populate_processor_id_field_data(fixture,processor_field); - - const size_t spatial_dim = fixture.meta_data.spatial_dimension(); - stk_classic::mesh::skin_mesh( fixture.bulk_data, spatial_dim, &skin_part); - - stk_classic::mesh::EntityVector wedges_to_separate; - - find_and_shuffle_wedges_to_separate( fixture, wedges_to_separate ); - - const size_t NUM_TIME_STEPS = 150; - const size_t separation_interval = 30; - - const double rotation = TWO_PI*4.0/NUM_TIME_STEPS; - const double x = 0; - const double y = 0; - const double z = 0; - const stk_classic::mesh::fixtures::GearMovement gear_movement_data(rotation,x,y,z); - - Ioss::Region * volume_out_region = NULL; - Ioss::Region * surface_out_region = NULL; - - stk_classic::mesh::fixtures::Gear & gear = fixture.get_gear(0); - - // Iterate over the time steps, updating the locations of the entities and - // writing the current mesh state to output files. - const bool output_exodus_file = true; - for (size_t time_step = 0; time_step < NUM_TIME_STEPS; ++time_step) { - - // Determine if it's time to separate a wedge - const bool do_separate_wedge = !wedges_to_separate.empty() && (time_step%separation_interval == 0); - - if (time_step > 0) { - - fixture.bulk_data.update_field_data_states(); - - // Move the gear; this will only rotate the gear since x,y,z are all 0 - gear.move(gear_movement_data); - stk_classic::mesh::Entity * wedge = NULL; - - // Separate the wedge if it's time - if (do_separate_wedge) { - wedge = wedges_to_separate.back(); - wedges_to_separate.pop_back(); - } - - separate_wedge( - do_separate_wedge, - fixture, - wedge, - velocity_field, - skin_part); - - move_detached_wedges( - fixture, - velocity_field - ); - - // Parallel collective call: - fixture.communicate_model_fields(); - } - - // update a face field - stk_classic::mesh::BucketVector face_buckets; - stk_classic::mesh::BucketVector all_face_buckets = fixture.bulk_data.buckets(fixture.element_rank-1); - stk_classic::mesh::get_buckets( surface_select, all_face_buckets, face_buckets); - for (stk_classic::mesh::BucketVector::iterator b_itr = face_buckets.begin(); b_itr != face_buckets.end(); ++b_itr) { - stk_classic::mesh::Bucket & b = **b_itr; - for (size_t i = 0; i < b.size(); ++i) { - stk_classic::mesh::Entity& face = b[i]; - double *elem_node_disp = field_data(displacement, face); - if (elem_node_disp) { - stk_classic::mesh::PairIterRelation node_rels = face.node_relations(); - const size_t num_nodes = node_rels.size(); - for(; !node_rels.empty(); ++node_rels) { - const stk_classic::mesh::Entity& node = *node_rels->entity(); - double* node_disp = stk_classic::mesh::field_data(fixture.displacement_field, node); - elem_node_disp[0] = node_disp[0]; - elem_node_disp[1] = node_disp[1]; - elem_node_disp[2] = node_disp[2]; - } - elem_node_disp[0] /= num_nodes; - elem_node_disp[1] /= num_nodes; - elem_node_disp[2] /= num_nodes; - } - } - } - - - - - //This section writes mesh data out to an exodus file: - if (output_exodus_file) { - // Write the output file at the first time step and every time the mesh is modified. - const bool create_output_file = do_separate_wedge || !time_step; - // Write the model to the mesh file (topology, coordinates, attributes, etc) - if (create_output_file) { - delete volume_out_region; volume_out_region = NULL; - delete surface_out_region; surface_out_region = NULL; - std::ostringstream volume_out_filename; - volume_out_filename << "volume_mesh_" << std::setw(7) << std::setfill('0') << time_step << ".e"; - volume_out_region = create_output_mesh( volume_out_filename.str(), fixture.bulk_data, false); - std::ostringstream surface_out_filename; - surface_out_filename << "surface_mesh_" << std::setw(7) << std::setfill('0') << time_step << ".e"; - surface_out_region = create_output_mesh( surface_out_filename.str(), fixture.bulk_data, true); - } - - stk_classic::io::MeshData mesh; - mesh.m_output_region=volume_out_region; - stk_classic::io::process_output_request(mesh, fixture.bulk_data, time_step/60.0, skin_io_parts); - mesh.m_output_region = NULL; - mesh.m_output_region=surface_out_region; - stk_classic::io::process_output_request(mesh, fixture.bulk_data, time_step/60.0); - mesh.m_output_region = NULL; - } - } - - delete volume_out_region; volume_out_region = NULL; - delete surface_out_region; surface_out_region = NULL; -} - diff --git a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/HeavyTest.cpp b/packages/stk/stk_classic/stk_performance_tests/stk_mesh/HeavyTest.cpp deleted file mode 100644 index d8329c742759..000000000000 --- a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/HeavyTest.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include - -#include -#include - -#include -#include - -#include - -#include - -#include - -#include - -#include - -// Globals for command-line arguments -extern int* STKUNIT_ARGC; -extern char** STKUNIT_ARGV; - -STKUNIT_UNIT_TEST( HeavyTest, heavytest ) -{ - // A performance test that stresses important parts of stk_mesh - // (such as mesh-modification in parallel, creation of relations, - // skinning, etc) so that we can measure stk_mesh performance over - // time to protect against degradation due to continuing code - // development. - // - // This test uses IO_Fixture to conveniently get a usable mesh from - // an exodus file. - - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - const size_t p_size = stk_classic::parallel_machine_size(pm); - const size_t p_rank = stk_classic::parallel_machine_rank(pm); - - stk_classic::io::util::IO_Fixture fixture(pm); - - // Test constants: - - const unsigned NUM_PHASES = 6; - - const unsigned INIT_META_DATA_PHASE_ID = 0; - const unsigned INIT_BULK_DATA_PHASE_ID = 1; - const unsigned REBALANCE_PHASE_ID = 2; - const unsigned SKIN_MESH_PHASE_ID = 3; - const unsigned EXODUS_CREATE_PHASE_ID = 4; - const unsigned PROCESS_OUTPUT_PHASE_ID = 5; - - std::vector PHASE_NAMES(NUM_PHASES); - PHASE_NAMES[INIT_META_DATA_PHASE_ID] = "Init meta data"; - PHASE_NAMES[INIT_BULK_DATA_PHASE_ID] = "Init bulk data"; - PHASE_NAMES[REBALANCE_PHASE_ID] = "Rebalance mesh"; - PHASE_NAMES[SKIN_MESH_PHASE_ID] = "Skin mesh"; - PHASE_NAMES[EXODUS_CREATE_PHASE_ID] = "Exodus file creation"; - PHASE_NAMES[PROCESS_OUTPUT_PHASE_ID] = "Process output"; - - // timings[6] = sum(timings[0:5]) - std::vector timings(NUM_PHASES + 1, 0.0); // leave room for sum - - // Compute input/output filename - - std::string input_base_filename = "heavy_performance_test.g"; // Default - std::string output_base_filename = "heavy_performance_test.e"; // Default - - // Search cmd-line args - const std::string input_flag = "--heavy-test:input-file="; - const std::string output_flag = "--heavy-test:output-file="; - for (int argitr = 1; argitr < *STKUNIT_ARGC; ++argitr) { - std::string argv(STKUNIT_ARGV[argitr]); - if (argv.find(input_flag) == 0) { - input_base_filename = argv.replace(0, input_flag.size(), ""); - } - else if (argv.find(output_flag) == 0) { - output_base_filename = argv.replace(0, output_flag.size(), ""); - } - } - - // time meta_data initialize - { - double start_time = stk_classic::wall_time(); - fixture.initialize_meta_data( input_base_filename, "exodusii" ); - timings[INIT_META_DATA_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - // Commit meta_data - stk_classic::mesh::fem::FEMMetaData & meta_data = fixture.meta_data(); - meta_data.commit(); - - // time bulk_data initialize - { - double start_time = stk_classic::wall_time(); - fixture.initialize_bulk_data(); - timings[INIT_BULK_DATA_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - stk_classic::mesh::BulkData & bulk_data = fixture.bulk_data(); - - // time rebalance bulk_data - { - Teuchos::ParameterList emptyList; - stk_classic::rebalance::Zoltan zoltan_partition(pm, meta_data.spatial_dimension(), emptyList); - stk_classic::mesh::Selector selector(meta_data.locally_owned_part()); - - double start_time = stk_classic::wall_time(); - stk_classic::rebalance::rebalance(bulk_data, - selector, - &fixture.get_coordinate_field(), - NULL /*weight field*/, - zoltan_partition); - timings[REBALANCE_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - // time skin bulk_data - { - double start_time = stk_classic::wall_time(); - stk_classic::mesh::skin_mesh( bulk_data, meta_data.spatial_dimension()); - timings[SKIN_MESH_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - // time exodus file creation - { - double start_time = stk_classic::wall_time(); - fixture.create_output_mesh( output_base_filename, "exodusii" ); - timings[EXODUS_CREATE_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - // time process output - { - double time_step = 0; - double start_time = stk_classic::wall_time(); - fixture.add_timestep_to_output_mesh( time_step ); - timings[PROCESS_OUTPUT_PHASE_ID] = stk_classic::wall_dtime(start_time); - } - - // Sum times: - for (unsigned i = 0; i < NUM_PHASES; ++i) { - timings[NUM_PHASES] += timings[i]; - } - - ThrowRequireMsg(timings.size() == NUM_PHASES+1, "Do not push back on to timings vector"); - - // Now process and print times, we print in XML to make parsing easier - { - stk_classic::all_reduce(pm, stk_classic::ReduceMax(&timings[0])); - - std::vector counts ; - stk_classic::mesh::fem::comm_mesh_counts( bulk_data , counts); - - if (p_rank == 0) { - std::cout << "\n\n"; - std::cout << "\n"; - std::cout << " \n"; - for (unsigned i = 0; i < counts.size(); ++i) { - std::cout << " \n"; - } - std::cout << " \n"; - - std::cout << " \n"; - for (unsigned i = 0; i < NUM_PHASES; ++i) { - std::cout << "

\n"; - } - std::cout << " \n"; - std::cout << "\n"; - std::cout << "\n\n"; - } - } -} diff --git a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestLoopIteration.cpp b/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestLoopIteration.cpp deleted file mode 100644 index cc4db74801da..000000000000 --- a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestLoopIteration.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include -#include - -void force_calculation( long long sum ) -{ - static int count = 0; - //volatile to prevent the compiler from optimizing the loops away - static volatile long long value; - - if( count && value != sum ) - { - STKUNIT_EXPECT_TRUE(false); - } - - value = sum; - ++count; -} - -struct sum_func -{ - sum_func() : sum(0) {} - long long sum; - void operator()( unsigned i ) - { - sum += i; - } -}; - -STKUNIT_UNIT_TEST( PerformanceTest, LoopIteration) -{ - boost::timer total_time; - -# ifdef __PGI - const size_t vector_size = 2000000000/4; -#else - const size_t vector_size = 2000000000; -#endif - - std::vector data; - data.reserve(vector_size); - - { - boost::timer timer; - std::srand(10); - std::generate_n(std::back_inserter(data), vector_size, &std::rand); - double elapsedtime = timer.elapsed(); - std::cout << "Construction time: " << elapsedtime << " seconds." << std::endl; - } - - { - boost::timer timer; - long long sum = std::accumulate( data.begin(), data.end(), 0ll ); - double elapsedtime = timer.elapsed(); - std::cout << "Iterator accumulate took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - unsigned* begin = &data.front(); - long long sum = std::accumulate( begin, begin+data.size(), 0ll ); - double elapsedtime = timer.elapsed(); - std::cout << "Pointer accumulate took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = 0; - for( std::vector::iterator it = data.begin(), iend = data.end(); it != iend; ++it ) - { - sum += *it; - } - double elapsedtime = timer.elapsed(); - std::cout << "Iterator for loop took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = 0; - unsigned* it = &data.front(); - for( unsigned* iend = it+data.size(); it != iend; ++it ) - { - sum += *it; - } - double elapsedtime = timer.elapsed(); - std::cout << "Pointer for loop took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = 0; - for( std::size_t i = 0, size = data.size(); i != size; ++i ) - { - sum += data[i]; - } - double elapsedtime = timer.elapsed(); - std::cout << "Index for (size_t) loop took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = 0; - for( int i = 0, size = data.size(); i != size; ++i ) - { - sum += data[i]; - } - double elapsedtime = timer.elapsed(); - std::cout << "Index for (int) loop took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = std::for_each( data.begin(), data.end(), sum_func() ).sum; - double elapsedtime = timer.elapsed(); - std::cout << "Index for_each took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - unsigned* begin = &data.front(); - long long sum = std::for_each( begin, begin+data.size(), sum_func() ).sum; - double elapsedtime = timer.elapsed(); - std::cout << "Pointer for_each took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - { - boost::timer timer; - long long sum = 0; - BOOST_FOREACH( unsigned i, data ) - { - sum += i; - } - double elapsedtime = timer.elapsed(); - std::cout << "BOOST_FOREACH took " << elapsedtime << " seconds." << std::endl; - force_calculation(sum); - } - - double elapsedtime = total_time.elapsed(); - - std::cout << "Total time: " << elapsedtime << " seconds." << std::endl; -} - diff --git a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestMain.cpp b/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestMain.cpp deleted file mode 100644 index b3cf8e41f4de..000000000000 --- a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestSelector.cpp b/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestSelector.cpp deleted file mode 100644 index ed7849398951..000000000000 --- a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestSelector.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace { - -using stk_classic::mesh::fixtures::VariableSelectorFixture ; - -} - -STKUNIT_UNIT_TEST( PerformanceTestSelector, start) -{ - size_t N = 5; - VariableSelectorFixture fix(N); - stk_classic::mesh::Selector selectUnion; - for (size_t part_i = 0 ; part_i buckets_out; - unsigned entity_rank = 0; - get_buckets(selectUnion, fix.m_BulkData.buckets(entity_rank), buckets_out); - STKUNIT_ASSERT_EQUAL( buckets_out.size(), N ); - // Construct once for large N - // Graph time for get_buckets against 1..N -} - -STKUNIT_UNIT_TEST( PerformanceTestSelector, timings) -{ - // Construction - - // If we are running with STL in debug mode we shrink the problem - // down in order to keep things running in a reasonable amount of - // time. -#ifdef _GLIBCXX_DEBUG - size_t N = 1000; -#else - size_t N = 10000; -#endif - - VariableSelectorFixture fix(N); - - std::vector selector_creation(N/2); - std::vector get_buckets_usage(N/2); - double start_time = stk_classic::wall_time(); - size_t timing_index = 0; - for (size_t n = 1 ; n buckets_out; - unsigned entity_rank = 0; - get_buckets(selectUnion, fix.m_BulkData.buckets(entity_rank), buckets_out); - get_buckets_usage[timing_index] = stk_classic::wall_dtime(start_time); - ++timing_index; - } - - // Print out table - std::cout << "\"N\" \"selector_creation_time\" \"get_buckets_time\" " << std::endl; - timing_index = 0; - for (size_t n = 1 ; n - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace { - -using stk_classic::mesh::EntityRank; - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -size_t count_skin_entities( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Part & skin_part, EntityRank skin_rank ) { - - const stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(mesh); - - stk_classic::mesh::Selector select_skin = skin_part & fem_meta.locally_owned_part() ; - - const std::vector& buckets = mesh.buckets( skin_rank ); - - return count_selected_entities( select_skin, buckets); -} - -void delete_skin( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Part & skin_part, EntityRank skin_rank ) { - - const stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(mesh); - - stk_classic::mesh::Selector select_skin = skin_part & fem_meta.locally_owned_part() ; - - const std::vector& buckets = mesh.buckets( skin_rank ); - - stk_classic::mesh::EntityVector skin_entities; - - stk_classic::mesh::get_selected_entities( select_skin, buckets, skin_entities); - - mesh.modification_begin(); - - for ( stk_classic::mesh::EntityVector::iterator i = skin_entities.begin(); i != skin_entities.end(); ++i) { - mesh.destroy_entity(*i); - } - - mesh.modification_end(); - - -} - -void update_skin( stk_classic::mesh::BulkData & mesh, stk_classic::mesh::Part *skin_part, EntityRank element_rank ) { - - stk_classic::mesh::EntityVector owned_elements, modified_elements; - - // select owned - const stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(mesh); - stk_classic::mesh::Selector owned = fem_meta.locally_owned_part(); - stk_classic::mesh::get_selected_entities( owned, - mesh.buckets(element_rank), - owned_elements); - - for( stk_classic::mesh::EntityVector::iterator i = owned_elements.begin(); - i != owned_elements.end(); ++i ) - { - stk_classic::mesh::Entity * entity= *i; - if ( entity->log_query() == stk_classic::mesh::EntityLogCreated || - entity->log_query() == stk_classic::mesh::EntityLogModified ) { - modified_elements.push_back(entity); - } - } - - - stk_classic::mesh::reskin_mesh(mesh, element_rank, - modified_elements, skin_part); -} - -void find_owned_nodes_with_relations_outside_closure( - stk_classic::mesh::EntityVector & closure, - stk_classic::mesh::Selector select_owned, - stk_classic::mesh::EntityVector & nodes) -{ - nodes.clear(); - - //the closure is a sorted unique vector - const EntityRank upward_rank = NODE_RANK + 1; - stk_classic::mesh::EntityVector::iterator node_end = std::lower_bound(closure.begin(), - closure.end(), - stk_classic::mesh::EntityKey(upward_rank, 0), - stk_classic::mesh::EntityLess()); - - for (stk_classic::mesh::EntityVector::iterator itr = closure.begin(); itr != node_end; ++itr) { - stk_classic::mesh::Entity & node = **itr; - - if (select_owned(node)) { - stk_classic::mesh::PairIterRelation relations_pair = node.relations(); - - //loop over the relations and check to see if they are in the closure - for (; relations_pair.first != relations_pair.second; ++relations_pair.first) { - stk_classic::mesh::Entity * current_entity = (relations_pair.first->entity()); - - //has relation outside of closure - if ( !std::binary_search(node_end, - closure.end(), - current_entity, - stk_classic::mesh::EntityLess()) ) - { - nodes.push_back(&node); - break; - } - } - } - } -} - -void copy_nodes_and_break_relations( stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::EntityVector & closure, - stk_classic::mesh::EntityVector & nodes, - stk_classic::mesh::EntityVector & new_nodes) -{ - - - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity * entity = nodes[i]; - stk_classic::mesh::Entity * new_entity = new_nodes[i]; - - stk_classic::mesh::PairIterRelation relations_pair = entity->relations(); - - std::vector sides; - - //loop over the relations and check to see if they are in the closure - for (; relations_pair.first != relations_pair.second;) { - --relations_pair.second; - stk_classic::mesh::Entity * current_entity = (relations_pair.second->entity()); - size_t side_ordinal = relations_pair.second->identifier(); - - if (stk_classic::mesh::in_receive_ghost(*current_entity)) { - // TODO deleteing the ghost triggers a logic error at the - // end of the NEXT modification cycle. We need to fix this! - //mesh.destroy_entity(current_entity); - continue; - } - else if ( std::binary_search(closure.begin(), - //has relation in closure - closure.end(), - current_entity, - stk_classic::mesh::EntityLess()) ) - { - sides.push_back(stk_classic::mesh::EntitySideComponent(current_entity,side_ordinal)); - } - } - - //loop over the sides and break the relations between the old nodes - //and set up the relations with the new - for ( std::vector::iterator itr = sides.begin(); - itr != sides.end(); ++itr) - { - mesh.destroy_relation(*(itr->entity), *entity, itr->side_ordinal); - mesh.declare_relation(*(itr->entity), *new_entity, itr->side_ordinal); - } - - //copy non-induced part membership from nodes[i] to new_nodes[i] - //there are NO non-induced parts for this example - - //copy field data from nodes[i] to new_nodes[i] - mesh.copy_entity_fields( *entity, *new_entity); - - if (entity->relations().empty()) { - mesh.destroy_entity(entity); - } - - if (new_entity->relations().empty()) { - mesh.destroy_entity(new_entity); - } - - - } - -} - -void communicate_and_create_shared_nodes( stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::EntityVector & nodes, - stk_classic::mesh::EntityVector & new_nodes) -{ - - - stk_classic::CommAll comm(mesh.parallel()); - - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity & node = *nodes[i]; - stk_classic::mesh::Entity & new_node = *new_nodes[i]; - - stk_classic::mesh::PairIterEntityComm entity_comm = node.sharing(); - - for (; entity_comm.first != entity_comm.second; ++entity_comm.first) { - - size_t proc = entity_comm.first->proc; - comm.send_buffer(proc).pack(node.key()) - .pack(new_node.key()); - - } - } - - comm.allocate_buffers( mesh.parallel_size()/4 ); - - for (size_t i = 0; i < nodes.size(); ++i) { - stk_classic::mesh::Entity & node = *nodes[i]; - stk_classic::mesh::Entity & new_node = *new_nodes[i]; - - stk_classic::mesh::PairIterEntityComm entity_comm = node.sharing(); - - for (; entity_comm.first != entity_comm.second; ++entity_comm.first) { - - size_t proc = entity_comm.first->proc; - comm.send_buffer(proc).pack(node.key()) - .pack(new_node.key()); - - } - } - - comm.communicate(); - - const stk_classic::mesh::PartVector no_parts; - - for (size_t process = 0; process < mesh.parallel_size(); ++process) { - stk_classic::mesh::EntityKey old_key; - stk_classic::mesh::EntityKey new_key; - - while ( comm.recv_buffer(process).remaining()) { - - comm.recv_buffer(process).unpack(old_key) - .unpack(new_key); - - stk_classic::mesh::Entity * old_entity = mesh.get_entity(old_key); - stk_classic::mesh::Entity * new_entity = & mesh.declare_entity(new_key.rank(), new_key.id(), no_parts); - - nodes.push_back(old_entity); - new_nodes.push_back(new_entity); - - } - } -} - -void separate_and_skin_mesh( - stk_classic::mesh::fem::FEMMetaData & fem_meta, - stk_classic::mesh::BulkData & mesh, - stk_classic::mesh::Part & skin_part, - stk_classic::mesh::EntityVector & entities_to_separate - ) -{ - - stk_classic::mesh::EntityVector entities_closure; - stk_classic::mesh::find_closure(mesh, - entities_to_separate, - entities_closure); - - stk_classic::mesh::Selector select_owned = fem_meta.locally_owned_part(); - - stk_classic::mesh::EntityVector nodes; - find_owned_nodes_with_relations_outside_closure( entities_closure, select_owned, nodes); - - //ask for new nodes to represent the copies - std::vector requests(fem_meta.entity_rank_count(), 0); - requests[NODE_RANK] = nodes.size(); - - mesh.modification_begin(); - - // generate_new_entities creates new blank entities of the requested ranks - stk_classic::mesh::EntityVector new_nodes; - mesh.generate_new_entities(requests, new_nodes); - - //communicate and create new nodes everywhere the old node is shared - communicate_and_create_shared_nodes(mesh, nodes, new_nodes); - - copy_nodes_and_break_relations(mesh, entities_closure, nodes, new_nodes); - - mesh.modification_end(); - - - return; -} - -}//end unnamped namespace - -// \TODO Idea: ADD scaling test over mesh size and compute the slope. -// \TODO Idea: ADD different partitioning such that the reskinning spans more than one process. - -STKUNIT_UNIT_TEST( PerformanceTestSkinning, large_cube) -{ - stk_classic::ParallelMachine pm = MPI_COMM_WORLD; - - const size_t p_size = stk_classic::parallel_machine_size(pm); - const size_t p_rank = stk_classic::parallel_machine_rank(pm); - - // Every processor will be involved in detachment and skin-update up to 500 processors. - // This puts 5000 elements on each process unless we are running with STL - // in debug mode in which case we shrink the problem down in order - // to keep things running in a reasonable amount of time. -#ifdef _GLIBCXX_DEBUG - const size_t NX = p_size*10, NY = 4, NZ = 5; -#else - const size_t NX = p_size*10, NY = 20, NZ = 25; -#endif - - /* timings[0] = create mesh - * timings[1] = intial skin mesh - * timings[2] = detach mesh - * timings[3] = delete skin - * timings[4] = reskin mesh - * timings[5] = sum(timings[0:4]) - */ - double timings[6] = {0}; - double start_time = 0; - - //recreate skin - for ( int test_run = 0; test_run < 4; ++test_run) { - //create the mesh - - start_time = stk_classic::wall_time(); - stk_classic::mesh::fixtures::HexFixture fixture(pm,NX,NY,NZ); - const EntityRank element_rank = fixture.m_fem_meta.element_rank(); - const EntityRank side_rank = fixture.m_fem_meta.side_rank(); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = fixture.m_fem_meta; - stk_classic::mesh::BulkData & mesh = fixture.m_bulk_data; - - stk_classic::mesh::Part & skin_part = fem_meta.declare_part("skin_part"); - fem_meta.commit(); - - fixture.generate_mesh(); - timings[0] = stk_classic::wall_dtime(start_time); - - //intial skin of the mesh - start_time = stk_classic::wall_time(); - stk_classic::mesh::skin_mesh(mesh, element_rank, &skin_part); - timings[1] = stk_classic::wall_dtime(start_time); - - stk_classic::mesh::EntityVector entities_to_separate; - - if ( test_run < 2) { - //detach 1/3 of the mesh - size_t num_detached_this_proc = 0; - for (size_t ix=NX/3; ix < 2*NX/3; ++ix) { - for (size_t iy=0; iy < NY; ++iy) { - for (size_t iz=0; iz < NZ; ++iz) { - stk_classic::mesh::Entity * element = fixture.elem(ix,iy,iz); - if (element != NULL && element->owner_rank() == mesh.parallel_rank()) { - entities_to_separate.push_back(element); - num_detached_this_proc++; - } - } - } - } - STKUNIT_EXPECT_TRUE( num_detached_this_proc > 0u ); - } else { - //detach middle of the mesh - for (size_t ix=NX/2; ix < NX/2+1; ++ix) { - for (size_t iy=NY/2; iy < NY/2+1; ++iy) { - for (size_t iz=NZ/2; iz < NZ/2+1; ++iz) { - stk_classic::mesh::Entity * element = fixture.elem(ix,iy,iz); - if (element != NULL && element->owner_rank() == mesh.parallel_rank()) { - entities_to_separate.push_back(element); - } - } - } - } - } - - start_time = stk_classic::wall_time(); - separate_and_skin_mesh( - fem_meta, - mesh, - skin_part, - entities_to_separate - ); - timings[2] = stk_classic::wall_dtime(start_time); - - if (test_run%2 == 0) { // delete the skin - start_time = stk_classic::wall_time(); - delete_skin( mesh, skin_part, side_rank ); - timings[3] = stk_classic::wall_dtime(start_time); - - //reskin the entire mesh - start_time = stk_classic::wall_time(); - stk_classic::mesh::skin_mesh( mesh, element_rank, &skin_part); - timings[4] = stk_classic::wall_dtime(start_time); - } - else { //update the skin - timings[3] = 0; - - //update the skin of the mesh - start_time = stk_classic::wall_time(); - update_skin( mesh, &skin_part, element_rank); - timings[4] = stk_classic::wall_dtime(start_time); - } - - //total the timings - timings[5] = 0; - for (int i=0; i <5; ++i) { - timings[5] += timings[i]; - } - - stk_classic::all_reduce(pm, stk_classic::ReduceMax<5>(timings)); - - if (p_rank == 0) { - std::cout << "\n\n"; - switch (test_run) { - case 0: - std::cout << "Recreate entire skin after detaching 1/3 of the mesh:\n"; - break; - case 1: - std::cout << "Update skin after detaching 1/3 of the mesh:\n"; - break; - case 2: - std::cout << "Recreate entire skin after detaching middle of the mesh:\n"; - break; - case 3: - std::cout << "Update skin after detaching middle of the mesh:\n"; - break; - } - - std::cout << "Num procs: " << p_size << "\n"; - std::cout << "Mesh size: " << NX << 'x' << NY << 'x' << NZ << " = " << NX*NY*NZ << " elements\n"; - std::cout << "Total time: " << timings[5] << "\n"; - std::cout << "\tCreate mesh: " << timings[0] << "\n"; - std::cout << "\tInitial skin: " << timings[1] << "\n"; - std::cout << "\tDetach mesh: " << timings[2] << "\n"; - std::cout << "\tDelete skin: " << timings[3] << "\n"; - std::cout << "\tReskin: " << timings[4] << "\n"; - std::cout << "\n\n"; - } - - size_t num_skin_entities = count_skin_entities(mesh, skin_part, side_rank ); - - stk_classic::all_reduce(pm, stk_classic::ReduceSum<1>(&num_skin_entities)); - - size_t expected_num_skin; - - if ( test_run < 2) { - expected_num_skin = 2*(NX*NY + NX*NZ + 3*NY*NZ); - } else { - expected_num_skin = 2*(NX*NY + NX*NZ + NY*NZ) + 12; - } - - STKUNIT_EXPECT_EQUAL( num_skin_entities, expected_num_skin ); - } -} diff --git a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestTimingMaps.cpp b/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestTimingMaps.cpp deleted file mode 100644 index 94c4fba0502e..000000000000 --- a/packages/stk/stk_classic/stk_performance_tests/stk_mesh/PerformanceTestTimingMaps.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -// Only run tests for GCC 4 for now -// Altix preprocessor variables are bizzare: defines __GNUC__, does not define __ICC even though it's intel -#if __GNUC__ == 4 && !defined __itanium__ && !defined __ICC && !defined __PATHSCALE__ && !defined __PGI - -#define FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_STD 1 -#define FLAG_EASTL_HASH_MAP 0 -#define FLAG_RDESTL_HASH_MAP 0 -#if defined(__PGI) || defined(__PATHSCALE__) - #define FLAG_GOOGLE_SPARSE_HASH_MAP 0 - #define FLAG_GOOGLE_DENSE_HASH_MAP 0 -#else - #define FLAG_GOOGLE_SPARSE_HASH_MAP 1 - #define FLAG_GOOGLE_DENSE_HASH_MAP 1 -#endif -#define FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 1 -#define FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_BOOST 1 -#define FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TEUCHOS_HASHTABLE 0 - -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 - #include -#endif - -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_BOOST - #include - #include -#endif - -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TEUCHOS_HASHTABLE - #include - #include - using Teuchos::Hashtable; -#endif - -#if FLAG_EASTL_HASH_MAP - #include - using eastl::hash_map; -#endif - -#if FLAG_GOOGLE_SPARSE_HASH_MAP - #include - #include HASH_MAP_H - #include - #include - using google::sparse_hash_map; -#endif - -#if FLAG_GOOGLE_DENSE_HASH_MAP - #include - #include HASH_MAP_H - #include - #include - #include - using google::dense_hash_map; -#endif - -#if FLAG_RDESTL_HASH_MAP - #include - #include -#endif - -using stk_classic::mesh::EntityKey; -using stk_classic::mesh::Entity; - -namespace { - -const int NUM_KEYS = 10000000; - -// Generic performance test -template -void time_map(MapType& testmap, int iters, const std::string& mapname) -{ - std::cout << "For " << mapname << std::endl; - - // Populate map - double start_time = stk_classic::wall_time(); - for (int i = 0; i < iters ; ++i) { - testmap[EntityKey(1,i)] = i; - } - double timing0 = stk_classic::wall_dtime(start_time); - std::cout << mapname << "\ttiming map growth: \t" << timing0 << " s" << std::endl; - - // Time item lookup - sequential - start_time = stk_classic::wall_time(); - int counter_to_fool_optimizer = 0; - for (int i = 0; i < iters; ++i) { - counter_to_fool_optimizer += testmap[EntityKey(1,i)]; - } - double timing = stk_classic::wall_dtime(start_time); - std::cout << mapname << "\tsequential timing map lookups: \t" << timing << " s" << std::endl; - - // - // Time item lookup - random - // - - // Create list of random ids; pulls the cost of rand and modulo out of the timed section - int* num_array = new int[iters]; - for (int i=0; i < iters; i++ ) { - num_array[i] = std::rand() % NUM_KEYS; - } - - // Do random key lookups - start_time = stk_classic::wall_time(); - counter_to_fool_optimizer = 0; - for (int i = 0; i < iters; ++i) { - counter_to_fool_optimizer += testmap[EntityKey(1,num_array[i])]; - } - double timing2 = stk_classic::wall_dtime(start_time); - delete[] num_array; - - std::cout << mapname << "\trandom timing map lookups: \t" << timing2 << " s" << std::endl; - - // Code to fool optimizer - if (counter_to_fool_optimizer == 666) std::cout << ""; -} - -// -// Hash functions -// - -struct stk_entity_rep_hash : public std::unary_function< EntityKey, std::size_t > -{ - inline std::size_t - operator()(const EntityKey& x) const - { - return (std::size_t)(x.raw_key()); - } -}; - -} // empty namespace - -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TEUCHOS_HASHTABLE -namespace Teuchos { - -// Teuchos expects the developer to define Teuchos::hashCode -template<> -int hashCode(const EntityKey& x) -{ - return (int)(x.raw_key()); -} - -} -#endif - -#if FLAG_EASTL_HASH_MAP -// EASTL expects the developer to define "new", see allocator_eastl.h line 194 -void* operator new[](size_t size, const char* pName, int flags, - unsigned debugFlags, const char* file, int line) -{ - return malloc(size); -} - -void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, - const char* pName, int flags, unsigned debugFlags, const char* file, int line) -{ - // this allocator doesn't support alignment - EASTL_ASSERT(alignment <= 8); - return malloc(size); -} - -struct eastl_stk_entity_rep_hash : public eastl::unary_function< EntityKey, std::size_t> -{ - inline std::size_t - operator()(const EntityKey& x) const - { - return (std::size_t)(x.raw_key()); - } -}; -#endif - -namespace { - -#if FLAG_GOOGLE_SPARSE_HASH_MAP || FLAG_GOOGLE_DENSE_HASH_MAP -struct google_stk_entity_rep_hash : public google::is_integral< EntityKey > -{ - inline std::size_t - operator()(const EntityKey& x) const - { - return (std::size_t)(x.raw_key()); - } -}; -#endif - -#if FLAG_RDESTL_HASH_MAP -struct rdestl_stk_entity_rep_hash : public rde::hash< EntityKey > -{ - inline std::size_t - operator()(const EntityKey& x) const - { - return (std::size_t)(x.raw_key()); - } -}; -#endif - -// -// Performance tests -// - -//First map type: std -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_STD -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, stdmap) -{ - typedef std::map EntityMap; - EntityMap testmap; - - time_map(testmap, NUM_KEYS, "std map"); -} -#endif //end of std map - -//Second map type: tr1 -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, tr1map) -{ - typedef std::tr1::unordered_map, std::allocator > > EntityMap; - - EntityMap testmap; - - time_map(testmap, NUM_KEYS, "tr1 map"); -} -#endif //end of tr1 map - -//Third map type: boost -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_BOOST -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, boostmap) -{ - typedef boost::unordered_map< EntityKey, int, stk_entity_rep_hash > EntityMap; - - EntityMap testmap; - - time_map(testmap, NUM_KEYS, "boost map"); -} -#endif //end of boost map - -//Fourth map type: Teuchos -//NB: include files taken from stk_percept and adapted -#if FLAG_STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TEUCHOS_HASHTABLE -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, teuchosmap) -{ - typedef Teuchos::Hashtable EntityMap; - EntityMap testmap; - EntityMap testmap2; - - time_map(testmap, NUM_KEYS, "teuchos map"); - time_map2(testmap2, NUM_KEYS, "teuchos map"); -} -#endif // end of teuchos map - -//Fifth map type: eastl -//From http://github.com/paulhodge/EASTL -#if FLAG_EASTL_HASH_MAP -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, eastlmap) -{ - typedef eastl::hash_map< EntityKey, int, stk_entity_rep_hash, eastl::equal_to > EntityMap; - EntityMap testmap; - - time_map(testmap, NUM_KEYS, "eastl map"); -} -#endif // end of eastl map - -//Sixth map type: google sparse -//From http://code.google.com/p/google-sparsehash -#if FLAG_GOOGLE_SPARSE_HASH_MAP -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, googlesparsemap) -{ - typedef google::sparse_hash_map< EntityKey, int, stk_entity_rep_hash > EntityMap; - - EntityMap testmap; - - time_map(testmap, NUM_KEYS, "google sparse map"); -} -#endif //end of sparse_hash_map - -//Seventh map type: google dense -//From http://code.google.com/p/google-sparsehash -#if FLAG_GOOGLE_DENSE_HASH_MAP - -template inline void SET_EMPTY_KEY(MapType&, EntityKey /*key*/) {} - -template -inline void SET_EMPTY_KEY(dense_hash_map& m, EntityKey key) -{ - m.set_empty_key(key); -} - -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, googledensemap) -{ - typedef google::dense_hash_map< EntityKey, int, stk_entity_rep_hash > EntityMap; - - EntityMap testmap; - - SET_EMPTY_KEY(testmap, EntityKey(0,0)); - - time_map(testmap, NUM_KEYS, "google dense map"); -} -#endif //end of dense_hash_map - -//Eighth map type: rdestl -//From http://rdestl.googlecode.com.svn -#if FLAG_RDESTL_HASH_MAP -STKUNIT_UNIT_TEST( PerformanceTestTimingMaps, rdestlmap) -{ - typedef rde::hash_map< EntityKey, int, stk_entity_rep_hash, 6, rde::equal_to > EntityMap; - - EntityMap testmap; - time_map(testmap, NUM_KEYS, "rdestl map"); -} -#endif //end of rdestl map - -}//namespace - -#endif // GCC 4 - diff --git a/packages/stk/stk_classic/stk_rebalance/CMakeLists.txt b/packages/stk/stk_classic/stk_rebalance/CMakeLists.txt deleted file mode 100644 index 6bfdcad520ad..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ - -ADD_SUBDIRECTORY(stk_rebalance) -ADD_SUBDIRECTORY(stk_rebalance_utils) - -TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - -# The use cases currently depend on boost::program_options through -# lib stk_util_use_cases. -IF ( TPL_Enable_BoostLib ) - TRIBITS_ADD_TEST_DIRECTORIES(use_cases) -ENDIF() - diff --git a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile b/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.input b/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.input deleted file mode 100644 index 189b0ea5938e..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/doc/Doxyfile.input +++ /dev/null @@ -1,22 +0,0 @@ -#BANNER @copydoc stk_rebalance_banner -#HOWTO @copydoc stk_rebalance_howto - -# Note, any path you set here will have to be set twice; once for when doxygen -# is run from this directory, and once for when doxygen is run from the -# TPLs_src/Trilinos/packages/stk/doc directory. - -# Put local appends here! Note: Please only put append-type changes -# (IE, VAR += CHANGE) in this section. All the STK products must -# use the same configuration because, when doxygen is run from stk/doc -# to assemble HTML for the entire STK, any configuration overrides -# that happened here would affect the html generation for ALL the -# STK products. - -EXAMPLE_PATH += ../use_cases \ - ../stk_rebalance/unit_tests \ - ../stk_rebalance/use_cases - -INPUT += ../stk_rebalance/doc/index.dox \ - ../stk_rebalance/stk_rebalance \ - ../stk_rebalance/unit_tests \ - ../stk_rebalance/use_cases diff --git a/packages/stk/stk_classic/stk_rebalance/doc/index.dox b/packages/stk/stk_classic/stk_rebalance/doc/index.dox deleted file mode 100644 index 1e2b1fe8a819..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/doc/index.dox +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * \page stk_rebalance_banner Sierra Toolkit Rebalance - * - * \ref stk_rebalance_module "Sierra Toolkit Rebalance" - * - * The Sierra Toolkit Rebalance package supports computing a new mesh - * partition to reduce computational load imbalance and the corresponding - * migration of mesh entities to the new partition. - * - * - * \addtogroup stk_rebalance_module Sierra Toolkit Rebalance Product - * - * The Sierra Toolkit Rebalance package supports computing a new mesh - * partition to reduce computational load imbalance and the corresponding - * migration of mesh entities to the new partition. Contents are as follows - * - *
    - *
  • \ref stk_rebalance_unit_test_module "Unit Tests" - * - *
  • \ref stk_rebalance_use_case_module "Use Cases" - * - *
- * - *

How to build stk with Rebalance enabled.

- * - * The stk_rebalance capability is enabled in a Trilinos build that - * has been configured with the Zoltan and STK pacgakes enabled, eg - * \code - * cmake \ - * .... other cmake options .... - * - * -D Trilinos_ENABLE_STK:BOOL=ON \ - * -D Trilinos_ENABLE_Zoltan:BOOL=ON \ - * - * .... other cmake options .... - * \endcode - * - * \defgroup stk_rebalance_unit_test_module Sierra Toolkit Rebalance Unit Tests - * \ingroup stk_rebalance_module - * - * \defgroup stk_rebalance_use_case_module Sierra Toolkit Rebalance Use Cases - * \ingroup stk_rebalance_module - * - **/ diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/CMakeLists.txt b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/CMakeLists.txt deleted file mode 100644 index 9a6f4cc16fb7..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_rebalance - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_util_env stkclassic_mesh_base - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_rebalance/) diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.cpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.cpp deleted file mode 100644 index 2378bb028e19..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002, 2010, 2011 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001, 2002 Sandia Corporation, Albuquerque, NM. - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -namespace stk_classic { -namespace rebalance { - -std::vector GeomDecomp::entity_coordinates(const mesh::Entity & entity, - const VectorField & nodal_coor, - std::vector > & coordinates) -{ - coordinates.clear(); - std::vector mesh_nodes; - - const mesh::EntityRank enttype = entity.entity_rank(); - if ( enttype == NODE_RANK ) - { - throw std::runtime_error("GeomDecomp::entity_coordinates Error: Can not be called for nodal entities."); - } else { - - // Loop over node relations in mesh entities - mesh::PairIterRelation nr = entity.relations( NODE_RANK ); - - for ( ; nr.first != nr.second; ++nr.first ) - { - const mesh::Relation &rel = *nr.first; - if (rel.entity_rank() == NODE_RANK) { // %fixme: need to check for USES relation - const mesh::Entity *nent = rel.entity(); - const unsigned ndim(field_data_size(nodal_coor, *nent)/sizeof(double)); // TODO - is there a better way to get this info? - double * coor = mesh::field_data(nodal_coor, *nent); - if (!coor) { - throw std::runtime_error("GeomDecomp::entity_coordinates Error: The coordinate field does not exist."); - } - std::vector temp(ndim); - for ( unsigned i = 0; i < ndim; ++i ) { temp[i] = coor[i]; } - coordinates.push_back(temp); - mesh_nodes.push_back(nent); - } - } - } - return mesh_nodes; -} - -std::vector > GeomDecomp::compute_entity_centroid(const mesh::Entity & entity, - const VectorField & nodal_coor_ref, - std::vector & centroid) -{ - std::vector > coordinates; - entity_coordinates(entity, nodal_coor_ref, coordinates); - - const int ndim = coordinates.front().size(); - const int num_nodes = coordinates.size(); - - centroid.resize(ndim); - for (int i=0; i &coor) -{ - // Apply slight transformation to "disalign" RCB coordinates - // from the model coordinates. This causes the RCB axis cuts - // to be "disaligned" from straight lines of the model. - - static const double tS = 0.0001 ; /* sin( angle / 2 ), angle = 0.012 deg */ - static const double tC = sqrt( (double)( 1.0 - tS * tS ) ); - static const double tQ = tS / sqrt( (double) 3.0 ); - static const double t1 = tC * tC - tQ * tQ ; - static const double t2 = 2.0 * tQ * ( tC + tQ ); - static const double t3 = -2.0 * tQ * ( tC - tQ ); - - - std::vector temp(coor); - const size_t nd = temp.size(); - - // Apply minute transformation to the coordinate - // to rotate the RCB axis slightly away from the model axis. - - if ( nd == 3 ) { - coor[0] = t1 * temp[0] + t3 * temp[1] + t2 * temp[2] ; - coor[1] = t2 * temp[0] + t1 * temp[1] + t3 * temp[2] ; - coor[2] = t3 * temp[0] + t2 * temp[1] + t1 * temp[2] ; - } - else if ( nd == 2 ) { - coor[0] = tC * temp[0] - tS * temp[1] ; - coor[1] = tS * temp[0] + tC * temp[1] ; - } - else if ( nd == 1 ) { - coor[0] = temp[0] ; - } - else { - ThrowRequireMsg(false, "Spatial Dimention not 1, 2, or 3, can not apply rotation."); // Should never make it here - } - return; -} -} - -//: Convert a mesh entity to a single point -//: in cartesian coordinates (x,y,z) -void GeomDecomp::entity_to_point (const mesh::Entity & entity, - const VectorField & nodeCoord, - std::vector & coor) -{ - compute_entity_centroid(entity, nodeCoord, coor); - apply_rotation (coor); -} -} // namespace rebalance -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.hpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.hpp deleted file mode 100644 index c6a15c83356f..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/GeomDecomp.hpp +++ /dev/null @@ -1,146 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2001, 2002, 2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001, 2002 Sandia Corporation, Albuquerque, NM. - -#ifndef stk_rebalance_GeomDecomp_hpp -#define stk_rebalance_GeomDecomp_hpp - -// STL components -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -/** Rebalance API -*/ -namespace rebalance { - -/** \addtogroup stk_rebalance_module - * \{ - */ - -/** \file GeomDecomp.hpp - * - * \brief Geometric support for partitioning of mesh entities. - * - * This file contains a single class GeomDecomp derived from - * the Partition class. GeomDecomp adds geometric computations - * to be used in determining an optimal distribution of mesh - * entities. GeomDecomp defines some virtual functions that - * are to be specialized by the class that actually determines - * the optimal distribution. - * - * Presently, only the support class for Zoltan, - * specializes the GeomDecomp class. If another optimal - * distribution method is to be implemented, it should - * be based on the GeomDecomp class. This will enable application - * codes to include just the GeomDecomp base class without - * having specialized knowledge of the derived classes. - */ - - -/** \class GeomDecomp - * - * \brief Class for determining the optimal partitioning of mesh entities. - * - * Derived from the \a Partition class. - * - * The \a GeomDecomp class has no data associated with it, only - * member functions. All data is inherited from the \a Partition - * class. - * - * \a GeomDecomp has two functions. It adds functions to - * compute geometry information for mesh entities, such as the - * center point for a mesh entity. And it defines virtual - * functions to be specialized by other classes that interface - * to partitioning packages such as \a Zoltan. - */ - -class GeomDecomp: public Partition { -public: - typedef mesh::Field VectorField ; -public: - - GeomDecomp(ParallelMachine comm): Partition(comm) {} - - virtual ~GeomDecomp(){} - - /** \brief Convert a single mesh entity to a single point. - * - * \param entity Entity to take centroid of, element, side, face or node. - * - * \param ref Coordinate field to average, usually defined on the nodes. - * - * \param coor Is the output coordinate and is assumed to - * be large enough to hold a single coordinate. - * Note the maximum needed in all cases is length 3. - * - * The \a entity_to_point function is used in the case where a mesh entity is - * an element with many nodes. Then something like - * the element centroid can be used to define - * a single coordinate point for it. - * - */ - static void entity_to_point( const mesh::Entity & entity, - const VectorField & ref, - std::vector & coor); - - /** \brief Used to return the nodal entities that \a compute_entity_centroid averages. - * - * \param entity Entity to take coordinates of, element, side, face or node. - * - * \param ref Coordinate field to average, usually defined on the nodes. - * - * \param coor Is the output coordinates that entity_to_point would average to - * determine a centroid. - * - * The return value is the mesh entities from which the coordinates were obtained. - */ - - static std::vector entity_coordinates(const mesh::Entity & entity, - const VectorField & ref, - std::vector > & coordinates); - - /** \brief Returns a vector of vectors containing the coordinates of the nodes that were used to compute the centroid. - * - * \param entity Entity to take coordinates of, element, side, face or node. - * - * \param ref Coordinate field to average, usually defined on the nodes. - * - * \param coor Is the output coordinated and is assumed to - * be large enough to hold a single coordinate. - * Note the maximum needed in all cases is length 3. - * - * return value is the output coordinates that entity_to_point would average to - * determine a centroid. - * - */ - static std::vector > compute_entity_centroid( const mesh::Entity & entity, - const VectorField & ref, - std::vector & coor); - /** \brief Check existence of library entry name on domain library. - * This is a simple one line convenience function - */ - - static bool confirm ( const std::string ¶m_set_name ); - -}; - -/** \} */ - -} -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.cpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.cpp deleted file mode 100644 index ab3301329d63..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2001, 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001, 2002 Sandia Corporation, Albuquerque, NM. - -#include - -#include - -using namespace stk_classic; -namespace stk_classic { - using namespace rebalance; -} - -Partition::Partition(ParallelMachine comm) : comm_(comm) { } -Partition::~Partition() { } - - - diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.hpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.hpp deleted file mode 100644 index c8c4ab2b6567..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Partition.hpp +++ /dev/null @@ -1,160 +0,0 @@ - -/*--------------------------------------------------------------------*/ -/* Copyright 2001, 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001, 2002 Sandia Corporation, Albuquerque, NM. - -#ifndef stk_rebalance_Partition_hpp -#define stk_rebalance_Partition_hpp - -/** \addtogroup stk_rebalance_module - * \{ - */ -/** \file Partition.hpp - * \brief For partitioning of mesh entities over a processing grid. - * - * This file defines a single class, Partition. This class describes - * how a set of mesh entities is distributed over a processing grid. - * The class contains a list of mesh entities and owning processors. - * The class is initialized when each processor inserts it's list - * of mesh entities. During initialization it is assumed that the - * current processor is the owning processor so the owning processor - * list is initialized to the current processor number at that time. - * - * A different distribution is defined by changing the owning - * processor of an entity. - * - * The Partition class does not provide advanced communication - * routines to transfer entities to the new owning processor. - * The Partition class simply keeps track of the owning - * processor information. - * - * If the mesh entities are redistributed by another class, then the - * information contained in the Partition class will be out of - * date and should be cleared and re-initialized. - */ - -#include - -// STL components -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace rebalance { - -typedef mesh::Field VectorField ; -typedef mesh::Field ScalarField ; - - -/** @class Partition for keeping track of a mesh entity partition. - * - * \brief Initialized with a list of mesh entities unique to each processor. - * - * the Field references determine what will be used - * for the physical coordinate reference and a weight. - * These fields are made available for the computation - * of a redistribution by a derived class. - * - * The destination processors ids are initialized to the - * current processor. Thus the initialization defines - * a default partition that fits the current mesh entity - * distribution. It is then assumed that a new partition - * will be defined by updating the owing processors. - * Subsequently the new partition will be realized by - * a function that actually redistributes the mesh entities - * to the new owning processors. But these actions - * are beyond the scope of this class. - */ - -class Partition { - -public: - - /** \brief Constructors. */ - Partition(stk_classic::ParallelMachine comm); -private: - Partition(const Partition &p); -public: - - /** \brief Define mesh entities to balance. - * - * \param mesh_entities Vector of mesh entities to rebalance - * - * \param nodal_coord_ref Nodal coordinate field to determine new partition - * if using geometric based partitioning. - * - * \param elem_weight_ref Weighting of elements used in defining - * the new partition. If used, the total element - * weight will be balanced across all of the - * processors. Can be NULL. - */ - virtual void set_mesh_info ( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref=NULL) = 0; - - /** \brief Destructor. */ - virtual ~Partition(); - - /** \brief Return the parallel communicator for this partition entity.*/ - ParallelMachine parallel() const { return comm_; } - - /** \brief Return the total number of mesh entities in all lists. */ - virtual unsigned num_elems() const = 0; - - /** \brief determine New Partition. - * - * \param RebalancingNeeded If true, then a new partition - * has been defined. If false, the - * new partition is the same as the old - * one and no rebalancing is needed. - * - * This is where all of the real work takes place. This - * virtual function should be specialized to determine - * the new partition. \a RebalancingNeeded is set if the new - * partition is different than the old one. - */ - virtual void determine_new_partition(bool &RebalancingNeeded) = 0; - - /** \brief Perform communication to create new partition. - * - * \param new_partition New layout of mesh entities on the processing grid. - * - * Given a communication specification this - * function will apply the new partition by - * transferring the ownership of the registered - * mesh entities according to the specification - * determined by the function \a Determine_New_Partition. - * After \a move_mesh_entities is called, GeomDecomp - * should be reinitialized with new vectors of - * mesh entities before rebalancing is performed - * again. - */ - virtual int get_new_partition(stk_classic::mesh::EntityProcVec &new_partition) = 0; - - /** \brief Query whether element dependents need to be rebalanced outside this Partition. */ - virtual bool partition_dependents_needed() const = 0; - - -protected: - - const stk_classic::ParallelMachine comm_; -}; - -/** \} */ - -} -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.cpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.cpp deleted file mode 100644 index d50cdeaa8cbd..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2001, 2008, 2009, 2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001,2002 Sandia Corporation, Albuquerque, NM. - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -using namespace stk_classic; -using namespace stk_classic::rebalance; - -namespace { - -bool balance_comm_spec_domain( Partition * partition, - mesh::EntityProcVec & rebal_spec ) -{ - bool rebalancingHasOccurred = false; - { - int num_elems = partition->num_elems(); - int tot_elems; - all_reduce_sum(partition->parallel(), &num_elems, &tot_elems, 1); - - if (tot_elems) { - partition->determine_new_partition(rebalancingHasOccurred); - } - } - if (rebalancingHasOccurred) partition->get_new_partition(rebal_spec); - - return rebalancingHasOccurred; -} - - -/* - * Traversing the migrating elements in reverse order produces a simplistic - * attempt at lowest-rank element proc greedy partitioning of dependents - * which seems to often work in practice. Some logic could be added here - * as needed to enforce more deterministic dependent partitions. - */ - -void rebalance_dependent_entities( const mesh::BulkData & bulk_data , - const Partition * partition, - const mesh::EntityRank & dep_rank, - mesh::EntityProcVec & entity_procs, - const stk_classic::mesh::EntityRank rank) -{ - - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - const stk_classic::mesh::EntityRank element_rank = (rank != stk_classic::mesh::InvalidEntityRank) ? rank : - fem_meta.element_rank(); - - if (dep_rank == element_rank) return; - // Create a map of ids of migrating elements to their owner proc and a vector of the migrating elements. - std::map elem_procs; - mesh::EntityVector owned_moving_elems; - mesh::EntityProcVec::iterator ep_iter = entity_procs.begin(), - ep_end = entity_procs.end(); - for( ; ep_end != ep_iter; ++ep_iter ) { - if( element_rank == ep_iter->first->entity_rank() ) - { - const mesh::EntityId elem_id = ep_iter->first->identifier(); - elem_procs[elem_id] = ep_iter->second; - owned_moving_elems.push_back(ep_iter->first); - } - } - // TODO: Determine if this "dumb" greedy approach is adequate and the cost/benefit - // of doing something more sophisticated - - // This reverse traversal of elements overwrites assignment of procs for - // dependents resulting in the last assignment winning. - - // For all dep-rank entities related to migrating elements, pack their info in to - // dep_entity_procs. - std::map dep_entity_procs; - mesh::EntityVector::reverse_iterator r_iter = owned_moving_elems.rbegin(), - r_end = owned_moving_elems.rend(); - for( ; r_end != r_iter; ++r_iter ) - { - const mesh::EntityId elem_id = (*r_iter)->identifier(); - mesh::EntityVector related_entities; - mesh::EntityVector elems(1); - elems[0] = *r_iter; - stk_classic::mesh::get_entities_through_relations(elems, dep_rank, related_entities); - for( size_t j = 0; j < related_entities.size(); ++j ) { - dep_entity_procs[related_entities[j]->identifier()] = elem_procs[elem_id]; - } - } - - - std::map::const_iterator c_iter = dep_entity_procs.begin(), - c_end = dep_entity_procs.end(); - for( ; c_end != c_iter; ++c_iter ) - { - mesh::Entity * de = bulk_data.get_entity( dep_rank, c_iter->first ); - if( parallel_machine_rank(partition->parallel()) == de->owner_rank() ) - { - stk_classic::mesh::EntityProc dep_proc(de, c_iter->second); - entity_procs.push_back(dep_proc); - } - } -} - - -bool full_rebalance(mesh::BulkData & bulk_data , - Partition * partition, - const stk_classic::mesh::EntityRank rank) -{ - mesh::EntityProcVec cs_elem; - bool rebalancingHasOccurred = balance_comm_spec_domain( partition, cs_elem ); - - if(rebalancingHasOccurred && partition->partition_dependents_needed() ) - { - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - - const stk_classic::mesh::EntityRank node_rank = fem_meta.node_rank(); - const stk_classic::mesh::EntityRank edge_rank = fem_meta.edge_rank(); - const stk_classic::mesh::EntityRank face_rank = fem_meta.face_rank(); - const stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank cons_rank = elem_rank+1; - - // Don't know the rank of the elements rebalanced, assume all are dependent. - rebalance_dependent_entities( bulk_data, partition, node_rank, cs_elem, rank ); - if (stk_classic::mesh::InvalidEntityRank != edge_rank && rank != edge_rank) - rebalance_dependent_entities( bulk_data, partition, edge_rank, cs_elem, rank ); - if (stk_classic::mesh::InvalidEntityRank != face_rank && rank != face_rank) - rebalance_dependent_entities( bulk_data, partition, face_rank, cs_elem, rank ); - if (stk_classic::mesh::InvalidEntityRank != elem_rank && rank != elem_rank) - rebalance_dependent_entities( bulk_data, partition, elem_rank, cs_elem, rank ); - if (stk_classic::mesh::InvalidEntityRank != cons_rank && rank != cons_rank) - rebalance_dependent_entities( bulk_data, partition, cons_rank, cs_elem, rank ); - } - - if ( rebalancingHasOccurred ) - { - bulk_data.modification_begin(); - bulk_data.change_entity_owner( cs_elem ); - bulk_data.modification_end(); - } - - //: Finished - return rebalancingHasOccurred; -} -} // namespace - - -bool stk_classic::rebalance::rebalance(mesh::BulkData & bulk_data , - const mesh::Selector & selector , - const VectorField * rebal_coord_ref , - const ScalarField * rebal_elem_weight_ref , - Partition & partition, - const stk_classic::mesh::EntityRank rank) -{ - stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - const stk_classic::mesh::EntityRank element_rank = (rank != stk_classic::mesh::InvalidEntityRank) ? rank : - fem_meta.element_rank(); - - mesh::EntityVector rebal_elem_ptrs; - mesh::EntityVector entities; - - mesh::get_selected_entities(selector, - bulk_data.buckets(element_rank), - entities); - - for (mesh::EntityVector::iterator iA = entities.begin() ; iA != entities.end() ; ++iA ) { - if(rebal_elem_weight_ref) - { - double * const w = mesh::field_data( *rebal_elem_weight_ref, **iA ); - ThrowRequireMsg( NULL != w, - "Rebalance weight field is not defined on entities but should be defined on all entities."); - // Should this be a throw instead??? - if ( *w <= 0.0 ) { - *w = 1.0 ; - } - } - rebal_elem_ptrs.push_back( *iA ); - } - - (&partition)->set_mesh_info( - rebal_elem_ptrs, - rebal_coord_ref, - rebal_elem_weight_ref); - - bool rebalancingHasOccurred = full_rebalance(bulk_data, &partition, rank); - - return rebalancingHasOccurred; -} diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.hpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.hpp deleted file mode 100644 index 345e985c69c7..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/Rebalance.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Copyright 2001,2002 Sandia Corporation, Albuquerque, NM. - -#ifndef stk_rebalance_Rebalance_hpp -#define stk_rebalance_Rebalance_hpp - -#include - -#include -#include -#include -#include -#include - -#include - -/** \file Rebalance.hpp - * \ingroup stk_rebalance_module - * - * \brief Static functions for dynamic load balancing. - * - * The rebalance namespace is intended to provide an application - * the top level functions to perform a mesh redistribution. - * The action is controlled by instances of the Partition - * class that is passed into the rebalance function. - */ - -namespace stk_classic { -namespace rebalance { - -/** \brief Rebalance with a Partition object. - * - * \param bulk_data BulkData must be in a parallel consistent state. - * - * \param selector Used to select a subset of mesh entities to compute measure. - * - * \param coord_ref The field containing the nodal coordinates. For the default - * ZoltanPartition class in stk_classic::reblance, this should be non-NULL. - * - * \param elem_weight_ref This field will be used by the \a Partition class and - * can be NULL. - * - * \param Partition The base class of a derived class that is used to - * determine the new partition. See the \a ZoltanPartition - * class for an example. - * - * \param rank Rank of the entities \a elem_weight_ref is defined on. - * - * This \a rebalance function will use the \a Partition object passed - * to perform the rebalancing. It will be necessary to use one of the - * pre-defined derived classes in stk_classic::rebalance, like \a ZoltanPartition, - * or to define your own. - */ -bool rebalance(mesh::BulkData & bulk_data , - const mesh::Selector & selector , - const VectorField * coord_ref , - const ScalarField * elem_weight_ref, - Partition & partition, - const stk_classic::mesh::EntityRank rank = stk_classic::mesh::InvalidEntityRank); - -/** \} */ - -} -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.cpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.cpp deleted file mode 100644 index 1b7d53b508d3..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.cpp +++ /dev/null @@ -1,1036 +0,0 @@ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -using namespace std; -using namespace stk_classic; -using namespace stk_classic::rebalance; - -#define STK_GEOMDECOMP_DEBUG 0 - -namespace { - - -double static_zoltan_version(const double v=0) { - static double version=0; - if (v) { version=v;} - return version; -} - -inline unsigned num_gid_entries() { - static const unsigned n=2; - return n; -} - -inline unsigned num_lid_entries() { - static const unsigned n=2; - return n; -} -inline unsigned wdim() { - static const unsigned n=1; - return n; -} - -inline void convert_param_to_string(const Parameters &from, - vector < pair > &to) -{ - Parameters::ConstIterator - from_iter = from.begin(), - from_end = from.end(); - - for (; from_iter != from_end; ++from_iter) { - std::string s; - const std::string name = from.name(from_iter); - const std::string entry = from.entry(from_iter).getValue(&s); - std::pair p(name,entry); - - to.push_back(p); - } -} - -inline void fill_parameters (const char *T[][2], - const int i, - Parameters &Entry) -{ - for (int j=0; j=2 -void debug_print_decomp_export(Zoltan *zoltan, - Zoltan *zoltan_id ) -{ - int i; - int num_export = zoltan->Num_Exported(); - ZOLTAN_ID_PTR export_lids = zoltan->Export_Local_IDs(); - ZOLTAN_ID_PTR export_gids = zoltan->Export_Global_IDs(); - int* export_procs = zoltan->Export_Proc_IDs(); - int Z_LID_SIZE = zoltan->Num_Lid_Entries(); - int Z_GID_SIZE = zoltan->Num_Gid_Entries(); - - if ( export_gids!=NULL && export_lids!=NULL && export_procs!=NULL ) { - Env::output() << ": Zoltan RCB EXPORTS" << std::endl; - for ( i = 0; i < num_export; i++ ) { - Env::output() - << " " << i - << ": GID = " - << "T" << zoltan_id->Type( &export_gids[i*Z_GID_SIZE]) << " " - << "I" << zoltan_id->Index(&export_gids[i*Z_GID_SIZE]) << " " - << "P" << zoltan_id->Proc( &export_gids[i*Z_GID_SIZE]) << " " - << " LID = " - << "T" << zoltan_id->Type( &export_lids[i*Z_LID_SIZE]) << " " - << "I" << zoltan_id->Index(&export_lids[i*Z_LID_SIZE]) << " " - << " EXPORT_PROC_ID = " - << export_procs[i] - << std::endl; - } - Env::output_flush(); - } -} -#endif - - - -extern "C" { - int stkCallback_Num_Elements( void *data, int *ierr ); - void stkCallback_Element_List( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_ids, - ZOLTAN_ID_PTR local_ids, //{Iterator or index} - int wdim, - float *weights, - int *ierr ); - int stkCallback_Num_Dimensions( void *data, int *ierr ); - void stkCallback_Centroid_Coord( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - double *geom, - int *ierr ); - int stkCallback_Num_Edges( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - int *ierr ); - void stkCallback_Edge_List( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - ZOLTAN_ID_PTR nbor_global_id, - int *nbor_procs, - int wgt_dim, - float *ewgts, - int *ierr ); -} - - -int stkCallback_Num_Elements( void *data, int *ierr ) -{ - if ( data == NULL ) { - *ierr = ZOLTAN_FATAL; // Set FATAL Zoltan error flag - return 0; - } - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast(gdata); - - if (zdata == NULL ) { - *ierr = ZOLTAN_FATAL; // Set FATAL Zoltan error flag - return 0; - } - - int ne = zdata->num_elems(); - - *ierr = ZOLTAN_OK; - return ne; -} - -void stkCallback_Element_List( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_ids, - ZOLTAN_ID_PTR local_ids, //{Iterator or index} - int weightdim, - float *weights, - int *ierr ) -{ - if (!data) { - *ierr = ZOLTAN_FATAL; // Set FATAL Zoltan error flag - return; - } - - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast (gdata); - - if (!zdata) { - *ierr = ZOLTAN_FATAL; // Set FATAL Zoltan error flag - return; - } - - unsigned k=0, l=0; - const unsigned num_local_ids = zdata->num_moid(); - for (unsigned j=0; j(zdata->globalID(j)); - ++k; - if (weightdim) { - weights[l++] = zdata->entity_weight(j); - } else { - ++l; - } - } - *ierr = ZOLTAN_OK; - return; - -} - -int stkCallback_Num_Dimensions( void *data, int *ierr ) -{ - if ( !data ) { - *ierr = ZOLTAN_FATAL; - return 0; - } - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast (gdata); - - if ( !zdata ) { - *ierr = ZOLTAN_FATAL; - return 0; - } - - const int nd = zdata->spatial_dimension(); - - *ierr = ZOLTAN_OK; - return nd; - -} - -void stkCallback_Centroid_Coord( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - double *geom, - int *ierr ) -{ - std::vector temp(3,0.0); - - // (from include Fmwk_Sierra_Zoltan_Defines.h:) - // ( Num_gid_entries = ZOLTAN_GID_SIZE 2 ) - // ( Num_lid_entries = ZOLTAN_LID_SIZE 2 ) - - if ( !data ) { - *ierr = ZOLTAN_FATAL; - return ; - } - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast (gdata); - - if ( !zdata ) { - *ierr = ZOLTAN_FATAL; - return ; - } - - int lid = local_id[ 0 ]; // Local Element ID - - const mesh::Entity & target_entity = * zdata->mesh_entity( lid ); - const GeomDecomp::VectorField & coor = * zdata->entity_coord_ref(); - const unsigned nd = zdata->spatial_dimension(); - - /* - * Obtain the centroid coordinates of the element by averaging all - * the nodal coordinates of the nodes associated with the element. - * Use GeomDecomp friend function, ent( , , ) - * - */ - - rebalance::GeomDecomp::entity_to_point( target_entity, coor, temp ); - - for (size_t i=0 ; i < nd ; i++ ) geom[ i ] = (double) temp[ i ]; - - *ierr = ZOLTAN_OK; -} - - - -void getNeighbors( const mesh::Entity & entity, - std::set & nodes ) -{ - stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(entity); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - nodes.clear(); - - mesh::PairIterRelation iElem = entity.relations(element_rank); - - for ( ; iElem.first != iElem.second; ++iElem.first ) { - mesh::Entity * elem = iElem.first->entity(); - mesh::PairIterRelation iNode = elem->relations(fem_meta.node_rank()); - for ( ; iNode.first != iNode.second; ++iNode.first ) { - mesh::Entity * node = iNode.first->entity(); - if (&entity != node) nodes.insert( node ); - } - } -} - -int numEdges( const mesh::Entity & entity ) { - - std::set nodes; - - getNeighbors( entity, nodes ); - return nodes.size(); -} - -int stkCallback_Num_Edges( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - int *ierr ) -{ - // (from include Fmwk_Sierra_Zoltan_Defines.h:) - // ( Num_gid_entries = ZOLTAN_GID_SIZE 2 ) - // ( Num_lid_entries = ZOLTAN_LID_SIZE 2 ) - - *ierr = ZOLTAN_OK; - - if ( !data ) { - *ierr = ZOLTAN_FATAL; - return 0; - } - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast (gdata); - - if ( !zdata ) { - *ierr = ZOLTAN_FATAL; - return 0; - } - - int lid = local_id[ 0 ]; // Local Element ID - - const mesh::Entity & target_entity = * zdata->mesh_entity( lid ); - - return numEdges( target_entity ); - -} - -void stkCallback_Edge_List( void *data, - int Num_gid_entries, - int Num_lid_entries, - ZOLTAN_ID_PTR global_id, - ZOLTAN_ID_PTR local_id, //{Iterator or index} - - // Returned - ZOLTAN_ID_PTR nbor_global_id, //owning processor - int *nbor_procs, - int wgt_dim, - float *ewgts, - - int *ierr ) -{ - // (from include Fmwk_Sierra_Zoltan_Defines.h:) - // ( Num_gid_entries = ZOLTAN_GID_SIZE 2 ) - // ( Num_lid_entries = ZOLTAN_LID_SIZE 2 ) - - *ierr = ZOLTAN_OK; - - if ( !data ) { - *ierr = ZOLTAN_FATAL; - return ; - } - stk_classic::rebalance::GeomDecomp *gdata = static_cast (data); - stk_classic::rebalance::Zoltan *zdata = dynamic_cast (gdata); - - if ( !zdata ) { - *ierr = ZOLTAN_FATAL; - return ; - } - - int lid = local_id[ 0 ]; // Local Node ID - - const mesh::Entity & target_entity = * zdata->mesh_entity( lid ); - - std::set nodes; - getNeighbors( target_entity, nodes ); - - int counter(0); - for ( std::set::iterator i = nodes.begin(); - i != nodes.end(); ++i ) { - nbor_global_id[counter*2+0] = 0; // region_id - - const mesh::Entity & n = **i; - nbor_global_id[counter*2+1] = n.key().id(); - - nbor_procs[counter] = n.owner_rank(); - - if ( wgt_dim ) { - ewgts[counter] = 1; - } - ++counter; - } -} - -} - - - -const std::string Zoltan::m_zoltanparametersname_="Zoltan_Parameters"; -const std::string Zoltan::m_defaultparametersname_="DEFAULT"; - - -const std::string Zoltan::zoltan_parameters_name() -{ - return m_zoltanparametersname_; -} - -const std::string Zoltan::default_parameters_name() -{ - return m_defaultparametersname_; -} - -void Zoltan::init_default_parameters() -{ - fill_default_values(m_default_parameters_); -} - - -static Parameters *Name_Conversion =NULL; -static Parameters *Value_Conversion=NULL; - -double Zoltan::zoltan_version() const { return static_zoltan_version(); } - -//: =========== -//: Constructor -//: =========== - -namespace { -void merge_parameters(std::vector > &str_zoltan_params, - const Parameters &Zoltan_Params) { - Parameters Merged_Zoltan_Params ; - Parameters Converted_Zoltan_Params; - - rebalance::Zoltan::merge_default_values (Zoltan_Params, - Merged_Zoltan_Params); - - rebalance::Zoltan::convert_names_and_values(Merged_Zoltan_Params, - Converted_Zoltan_Params); - - convert_param_to_string (Converted_Zoltan_Params, - str_zoltan_params); - return; -} -} - -Zoltan::Zoltan(ParallelMachine pm, const unsigned ndim, Parameters & rebal_region_parameters, const std::string parameters_name) : - GeomDecomp(pm), - m_zoltan_id_(NULL), - m_spatial_dimension_(ndim), - m_total_number_entities_(0) -{ - /* Determine if the default set of parameters already exists. */ - if( !rebal_region_parameters.isSublist(default_parameters_name()) ) - { - init_default_parameters(); - rebal_region_parameters.sublist(default_parameters_name()) = m_default_parameters_; - } - - /* If name is empty, use default values */ - std::string default_name = - (parameters_name.empty()) ? default_parameters_name() : parameters_name ; - - if( !rebal_region_parameters.isSublist(default_name) ) { - throw std::runtime_error("The Zoltan parameter set '" + default_name + "' does not exist."); - } - const Parameters & zoltan_params = rebal_region_parameters.sublist(default_name); - - std::vector > str_zoltan_params; - merge_parameters(str_zoltan_params, zoltan_params); - - init(str_zoltan_params); -} - -void -Zoltan::set_mesh_info( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref) -{ - MeshInfo mesh_info; - - /* Keep track of the total number of elements. */ - m_total_number_entities_ = mesh_entities.size(); - - mesh_info.mesh_entities = mesh_entities; - mesh_info.nodal_coord_ref = nodal_coord_ref; - mesh_info.elem_weight_ref = elem_weight_ref; - - /** Default destination for an entity is the processor - that already owns the entity, which is this processor. - The length of the dest_proc_ids vector is the same - length as the mesh_entities vector. - */ - mesh_info.dest_proc_ids.assign(mesh_entities.size(), stk_classic::parallel_machine_rank(comm_)); - - m_mesh_information_ = mesh_info; -} - -void Zoltan::init( const vector< pair > - &dynamicLoadRebalancingParameters ) { - if (0==static_zoltan_version()) { - const double v = init_zoltan_library(); - static_zoltan_version(v); - } - - /** - * Create a zoltanID entity - */ - - m_zoltan_id_ = Zoltan_Create( comm_ ); - if ( m_zoltan_id_ == NULL ) { - throw runtime_error ("(FATAL ERROR) Zoltan_Create() returned NULL"); - } - - /** - * Set up dynamic load rebalancing - */ - - vector >::const_iterator - P = dynamicLoadRebalancingParameters.begin(), - PE = dynamicLoadRebalancingParameters.end(); - - for ( ; PE != P ; P++ ) { - - char * label = const_cast( P->first.c_str() ) ; - char * value = const_cast( P->second.c_str() ) ; - - if (ZOLTAN_OK != (Zoltan_Set_Param(m_zoltan_id_,label,value))) - { - throw runtime_error(": FATAL ERROR returned from Zoltan_Set_Param "); - } - } - - /** - * Register the Zoltan/SIERRA "call-back" (querry) functions. - */ - if ( ZOLTAN_OK != register_callbacks() ) - throw runtime_error ("zoltan->Register_Callbacks error. "); - -#if STK_GEOMDECOMP_DEBUG>=2 - { - debug_print_decomp_export( zoltan, m_zoltan_id_ ); - } -#endif - return; - -} - -double Zoltan::init_zoltan_library () { - float version = 0.0; - if ( Zoltan_Initialize( 0, NULL, &version) != ZOLTAN_OK ) - throw std::runtime_error("Return code from Zoltan_Initialize() != ZOLTAN_OK "); - - static_zoltan_version(version); - std::ostringstream s; - s << version; - - //sierra::ProductRegistry::instance().addTPL("Zoltan", s.str()); - - return version; -} - - - -//: ========== -//: Destructor -//: ========== - -Zoltan::~Zoltan() -{ - if ( m_zoltan_id_ != NULL ) { - Zoltan_Destroy( &m_zoltan_id_ ); - } - m_zoltan_id_ = NULL ; - if(Name_Conversion) { - delete Name_Conversion; - Name_Conversion = NULL; - } - if(Value_Conversion) { - delete Value_Conversion; - Value_Conversion = NULL; - } -} - -void -Zoltan::reset_dest_proc_data() -{ - const int proc = parallel_machine_rank(comm_); - const unsigned size = m_mesh_information_.mesh_entities.size(); - m_mesh_information_.dest_proc_ids.assign(size, proc); -} - -void -Zoltan::set_destination_proc(const unsigned moid, - const unsigned proc ) -{ - m_mesh_information_.dest_proc_ids[ moid ] = proc; -} - -unsigned -Zoltan::destination_proc(const unsigned moid) const -{ - return m_mesh_information_.dest_proc_ids[ moid ]; -} - -bool -Zoltan::find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const -{ - unsigned len = m_mesh_information_.mesh_entities.size(); - for(moid = 0; moid < len; ++moid) - { - if(m_mesh_information_.mesh_entities[moid] == entity) return true; - } - return false; -} - -int -Zoltan::get_new_partition(stk_classic::mesh::EntityProcVec &rebal_spec) -{ - const unsigned entity_iter_len = m_mesh_information_.mesh_entities.size(); - for (unsigned entity_iter =0; entity_iter != entity_iter_len; ++entity_iter) { - mesh::Entity * mesh_ent = mesh_entity(entity_iter); - int proc = destination_proc(entity_iter); - mesh::EntityProc et(mesh_ent, proc); - rebal_spec.push_back(et); - } - return 0; -} - -const VectorField * -Zoltan::entity_coord_ref() const -{ - return m_mesh_information_.nodal_coord_ref; -} - -mesh::Entity * -Zoltan::mesh_entity(const unsigned moid ) const -{ - return m_mesh_information_.mesh_entities[ moid ]; -} - -double -Zoltan::entity_weight(const unsigned moid ) const -{ - double mo_weight = 1.0; - if (entity_weight_ref()) { - mo_weight = * static_cast - ( mesh::field_data (*entity_weight_ref(), *m_mesh_information_.mesh_entities[ moid ])); - } - return mo_weight; -} - -const ScalarField * -Zoltan::entity_weight_ref() const -{ - return m_mesh_information_.elem_weight_ref; -} - -unsigned -Zoltan::num_moid() const -{ - return m_mesh_information_.mesh_entities.size() ; -} - -const std::string &Zoltan::parameter_entry_name() const -{ - return m_parameter_entry_name_; -} - - -//: Load Balance calls or Load "Re-partitioning" calls - -int Zoltan::register_callbacks() -{ - /* - * Register the Zoltan/SIERRA "call-back" (querry) functions. - * Use ONLY THE BARE ESSENTIALS for decompositions: - * - * Zoltan_Set_Num_Obj_Fn - * Zoltan_Set_Obj_List_Fn - * Zoltan_Set_Num_Geom_Fn - * Zoltan_Set_Geom_Fn - */ - - /* - * flag for what data is to be registered with the zoltan callback - * functions in combination with the "static_cast(data)" - * statement used in the zoltan interface routine, - * Fmwk_Zoltaninterface.C - * - */ - - if ( Zoltan_Set_Num_Obj_Fn( m_zoltan_id_, - stkCallback_Num_Elements, - this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Num_Obj_Fn using stkCallback_Num_Elements failed to register"); - } - if ( Zoltan_Set_Obj_List_Fn( m_zoltan_id_, stkCallback_Element_List,this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Obj_List_Fn using stkCallback_Element_List"); - } - if ( Zoltan_Set_Num_Geom_Fn( m_zoltan_id_, stkCallback_Num_Dimensions,this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Num_Geom_Fn using stkCallback_Num_Dimensions"); - } - if ( Zoltan_Set_Geom_Fn( m_zoltan_id_, stkCallback_Centroid_Coord,this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Geom_Fn using stkCallback_Centroid_Coord"); - } - if ( Zoltan_Set_Num_Edges_Fn( m_zoltan_id_, stkCallback_Num_Edges,this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Num_Edges_Fn using stkCallback_Num_Edges"); - } - if ( Zoltan_Set_Edge_List_Fn( m_zoltan_id_, stkCallback_Edge_List,this ) - != ZOLTAN_OK ) { - throw std::runtime_error("Zoltan_Set_Edge_List_Fn using stkCallback_Edge_List"); - } - - return 0; - -} - - -int Zoltan::evaluate( int print_stats, - int* nentity, - double* entity_wgt, - int* ncuts, - double* cut_wgt, - int* nboundary, - int* nadj ) -{ - int ierr = 0; - - ZOLTAN_BALANCE_EVAL eval = {0}; - ZOLTAN_GRAPH_EVAL graph = {{0}}; - if (Zoltan_LB_Eval_Balance( m_zoltan_id_, print_stats, &eval)) ierr = 1; - if (Zoltan_LB_Eval_Graph( m_zoltan_id_, print_stats, &graph) ) ierr = 1; - *nentity = (int)eval.nobj[0]; - *entity_wgt = eval.obj_wgt[0]; - *ncuts = (int)graph.cuts[0]; - *cut_wgt = graph.cut_wgt[0]; - *nboundary = (int)graph.num_boundary[0]; - *nadj = (int)graph.nnborparts[0]; - - return ierr; - -} - -void Zoltan::determine_new_partition (bool &RebalancingNeeded) -{ - //: Transfer export global ID lists and owning processors - //: to SIERRA Framework's data structures - - /** - * Perform the dynamic load rebalancing. This just determines - * the redistribution. It does not actually redistribute - * the entities. - */ - - int length_gid, length_lid; - - int new_decomp; - int num_imported; - ZOLTAN_ID_PTR import_gids; - ZOLTAN_ID_PTR import_lids; - int *import_procs=NULL; - int num_exported; - ZOLTAN_ID_PTR export_gids; - ZOLTAN_ID_PTR export_lids; - int *export_procs=NULL; - - - - /** Zoltan_LB_Balance(): - * - * lb Pointer to the load-balancing structure, created by - * Zoltan_Create, to be used in this invocation - * of the load-balancing routine. - * new_decomp Set to 1 or .TRUE. if the decomposition was - * changed by the load-balancing method; 0 or - * .FALSE. otherwise. - * num_gid_entries Upon return, the number of array entries used to - * describe a single global ID. This value is the - * maximum value over all processors of the parameter - * NUM_GID_ENTRIES. - * num_lid_entries Upon return, the number of array entries used to - * describe a single local ID. This value is the - * maximum value over all processors of the parameter - * NUM_LID_ENTRIES. - * num_imported Upon return, the number of entities that are now - * assigned to this processor that were assigned to - * other processors in the old decomposition (i.e., - * the number of entities to be imported to this - * processor). If the value returned is -1, no import - * information has been returned and all import arrays - * below are NULL (see the RETURN_LISTS parameter for - * more information). - * import_gids Upon return, an array of num_import global IDs of - * entities to be imported to this processor. - * (size = num_import * num_gid_entries) - * import_lids Upon return, an array of num_import local IDs of - * entities to be imported to this processor. - * (size = num_import * num_lid_entries) - * import_procs Upon return, an array of size num_import listing - * the processor IDs of the processors that owned the - * imported entities in the previous decomposition - * (i.e., the source processors). - * num_exported Upon return, the number of entities that were - * assigned to this processor in the previous - * decomposition that are now assigned to other - * processors (i.e., the number of entities that must - * be exported from this processor to other processors) - * If the value returned is -1, no export information - * has been returned and all export arrays below are - * NULL (see the RETURN_LISTS parameter for more - * information). - * export_gids Upon return, an array of num_export global IDs of - * entities to be exported from this processor. - * (size = num_export * num_gid_entries) - * export_lids Upon return, an array of num_export local IDs of - * entities to be exported from this processor. - * (size = num_export * num_lid_entries) - * export_procs Upon return, an array of size num_export listing - * the processor IDs of processors that will own the - * exported entities in the new decomposition (i.e., - * the destination processors). - */ - - int status = Zoltan_LB_Balance( m_zoltan_id_, &new_decomp, - &length_gid , &length_lid, - &num_imported, &import_gids, - &import_lids, &import_procs, - &num_exported, &export_gids, - &export_lids, &export_procs ); - if (status != ZOLTAN_OK) { - throw std::runtime_error("Zoltan_Balance() returned error code " + status); - } - - //: Initialize destination processor IDs (dest_proc_ids) - reset_dest_proc_data(); - - int actual_exported = 0; - if ( new_decomp && ( num_exported != -1 ) ) { - const unsigned parallel_rank = parallel_machine_rank(comm_); - /* New Decomposition was generated */ - for (int j=0; j < num_exported; ++j ) { - - //: Get exported region, local, global, and processor ids - //const unsigned rid = export_gids[ j*::num_gid_entries() ]; // Region ID variable - //if (!rid) throw runtime_error ("Region ID variable should be non-zero."); - const unsigned lid = export_lids[ j*::num_lid_entries() ]; // Local ID variable - const unsigned pid = export_procs[ j ]; // Exported Processor ID (i.e., MPI "rank" ) - - if (parallel_rank != pid) { - ++actual_exported; - set_destination_proc(lid, pid); - } - } - } - - RebalancingNeeded = 0 ; - if (new_decomp) { - int rebalneeded=0; - stk_classic::all_reduce_sum(comm_, &actual_exported, &rebalneeded, 1); - if (rebalneeded) RebalancingNeeded = 1; - } - - /** - * Clean up after zoltan - */ - if ( ZOLTAN_OK != - Zoltan_LB_Free_Data( &import_gids, &import_lids, &import_procs, - &export_gids, &export_lids, &export_procs )) { - throw runtime_error (" FATAL ERROR in Zoltan_LB_Free_Data."); - } - -} - -void Zoltan::convert_names_and_values(const Parameters &from, Parameters &to) -{ - /* First time through, fill the conversion tables. */ - if (!Name_Conversion) { - Name_Conversion = new Parameters; - fill_name_conversion (*Name_Conversion); - } - if (!Value_Conversion) { - Value_Conversion = new Parameters; - fill_value_conversion(*Value_Conversion); - } - - // NOTE: "LOAD BALANCING METHOD" default - // is also hard coded in fill_default_values(); - std::string algorithm; - const std::string keyname("LOAD BALANCING METHOD"); - if( from.isParameter(keyname) ) - algorithm = from.get(keyname); - else - algorithm = "0"; - - const Parameters & General = Name_Conversion->sublist("General"); - const Parameters & Algorithm = Name_Conversion->sublist(algorithm); - - Parameters::ConstIterator - from_iter = from.begin(), - from_end = from.end(); - - /* Iterate over all of the input parameters to find proper - Zoltan names and Zoltan parameter values. */ - for (; from_iter != from_end; ++from_iter) { - std::string - from_name = from.name(from_iter), - to_name; - - /* Check to see if this is a general parameter name - and if not, check if it is an algorithm specific name. */ - - if (General.isParameter(from_name)) { - to_name = General.get(from_name); - } else { - to_name = Algorithm.get(from_name); - } - - /* Now convert the parameter value to the correct form. - Only a couple of parameters have parameter conversion. - The ones converted are nested in Value_Conversion. - */ - std::string to_value = Teuchos::getValue(from.entry(from_iter)); - //if (Value_Conversion->isParameter(from_name)) to_value = Value_Conversion->get(to_value); - if (Value_Conversion->isParameter(from_name)) to_value = Value_Conversion->sublist(from_name).get(to_value); - if (!to_name.empty()) to.set(to_name, to_value); - } -} - -void Zoltan::merge_default_values(const Parameters &from, - Parameters &to) -{ - Parameters default_values; - fill_default_values(default_values); - to.setParameters(default_values); - to.setParameters(from); -} diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.hpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.hpp deleted file mode 100644 index 9ae42681649b..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance/ZoltanPartition.hpp +++ /dev/null @@ -1,342 +0,0 @@ -/*----------------------------------------------------------------------*/ -/* */ -/* author: Jonathan Scott Rath */ -/* author2: Michael W. Glass (DEC/2000) */ -/* filename: ZoltanPartition.h */ -/* purpose: header file for stk toolkit zoltan methods */ -/* */ -/*----------------------------------------------------------------------*/ -/* Copyright 2001,2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*----------------------------------------------------------------------*/ - -// Copyright 2001 Sandia Corporation, Albuquerque, NM. - -#ifndef stk_rebalance_ZoltanPartition_hpp -#define stk_rebalance_ZoltanPartition_hpp - -#include -#include -#include - -#include -#include -#include - -//Forward declaration for pointer to a Zoltan structrue. -struct Zoltan_Struct; - -/** \addtogroup stk_rebalance_module - * \{ - */ - -/** \file ZoltanPartition.hpp derived from \a Partition to implement Zoltan based rebalancing. - * - * \class Zoltan - * - * \brief Class for implementing Zoltan based rebalancing - * - * Derived from the \a GeomDecomp class. - * - * The \a Partition class can be derived from to define all different ways of - * determining a new partition for rebalancing. This is one example where the - * derived class uses Zoltan to determine the new partition. - */ -namespace stk_classic { -namespace rebalance { - -typedef Teuchos::ParameterList Parameters; - -class Zoltan : public GeomDecomp { - -public: - - /** \struct MeshInfo - * - * \brief A structure to organize the mesh entity data. - * - * \param mesh_entities Vector of mesh entities to balance - * these can span multiple regons. - * - * \param nodal_coord_ref Coordinate reference defined on the - * nodes of the entities in \a mesh_entities. - * - * \param elem_weight_ref Element weight used in determining the - * new partition. - * - * \param dest_proc_ids A vector of same length at \a mesh_entities - * that will be filled with the new owner processor. - * - * A geometric decomposition can be constructed from one or more - * regions; furthermore, for each region, the decomposition can - * be based on any type of mesh entity. Each region has it's - * own node coordinate field and weight field. - * - * Mesh entities are organized according to a vector of MeshInfo - * structures. The major index of a mesh entity is the index - * of the MeshInfo vector and the minor index is the index - * within the mesh_entities vector. - * - * A unique global id is constructed by taking the major index - * of the MeshInfo vector along with the global_id() of - * the individual mesh entity. Together these two integers - * should form a unique global identification across all - * processors. - */ - struct MeshInfo { - std::vector mesh_entities; - const VectorField * nodal_coord_ref ; - const ScalarField * elem_weight_ref; - std::vector dest_proc_ids ; - - /** \brief Default Constructor. */ - MeshInfo(): - nodal_coord_ref(NULL), - elem_weight_ref(NULL) {} - - /** \brief Destructor. */ - ~MeshInfo() {} - }; - - /** \brief Define mesh entities to balance. - * - * \param mesh_entities Vector of mesh entities to rebalance - * - * \param nodal_coord_ref Nodal coordinate field to determine new partition - * if using geometric based partitioning. - * - * \param elem_weight_ref Weighting of elements used in defining - * the new partition. If used, the total element - * weight will be balanced across all of the - * processors. Can be NULL. - */ - - virtual void set_mesh_info ( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref=NULL); - - /** \brief Reset owning processor. - * - * Default destination for an entity is the processor - * that already owns the entity, which is this processor. - * The length of the dest_proc_ids vector is the same - * length as the mesh_entities vector. - */ - void reset_dest_proc_data (); - - /** \brief Return name of Zoltan parameter block being used. */ - static const std::string zoltan_parameters_name(); - - /** \brief Return name of default Zoltan parameter block being used. */ - static const std::string default_parameters_name(); - - - /** \brief Constructor - * - * \param pm The parallel communicator. - * - * \param ndim The spatial dimention of the mesh being balanced. - * - * \param rebal_region_parameters This is a hierarchial map of strings to strings - * that defines the parameters used to - * initialize \a Zoltan. See the - * \a fill_default_values function - * for a list of valid parameter names. - * - * \param parameters_name The subset of parameter in \a rebal_region_parameters - * to use. The default name is \a 'DEFAULT". - * - * There are many parameters that effect the wrokings of Zoltan and more are - * added with each release. Examine the source code, ZoltanPartition.cpp for - * a list of the latest releaseed and supported parameters. - */ - - explicit Zoltan(ParallelMachine pm, - const unsigned ndim, - Teuchos::ParameterList & rebal_region_parameters, - std::string parameters_name=default_parameters_name()); - - /** - * \brief Destructor - */ - - virtual ~Zoltan(); - - /** \brief Return the total number of mesh entities in all lists. */ - unsigned num_elems() const { return m_total_number_entities_ ; } - - /** \brief Return the owning processor.*/ - double entity_weight(const unsigned moid) const; - - /** \brief Set the owning processor.*/ - void set_destination_proc(const unsigned moid, - const unsigned proc ); - - /** \brief Various data access functions. - */ - int globalID (const unsigned moid) const - { return m_mesh_information_.mesh_entities[ moid ]->identifier(); } - - /** \brief Return the number of local ids per global ids (entities per region).*/ - unsigned num_moid() const; - - /** \brief Find the local ID of a given mesh entity. */ - bool find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const; - - /** \brief Return a mesh entity pointer. */ - mesh::Entity *mesh_entity(const unsigned moid ) const; - - /** \brief Return the Field points to the entity coordinates.*/ - const VectorField * entity_coord_ref () const; - - /** \brief Return the Field points to the entity coordinates.*/ - const ScalarField * entity_weight_ref () const; - - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - - /** \brief Name Conversion Functions. - * Long friendly string prarameters - * need to be converted into short Zoltan names. The - * \a merge_default_values and \a convert_names_and_values - * functions do that. Merge_Default_Values should be called - * first because it merges with the long names. - */ - static void merge_default_values (const Teuchos::ParameterList &from, - Teuchos::ParameterList &to); - - /** \brief Name Conversion Functions. - * \a Convert_Names_and_Values - * should then be called after \a merge_default_values - * to convert long names to short names. - */ - static void convert_names_and_values (const Teuchos::ParameterList &from, - Teuchos::ParameterList &to); - - - /** \brief determine New Partition. - * - * \param RebalancingNeeded If true, then a new partition - * has been defined. If false, the - * new partition is the same as the old - * one and no rebalancing is needed. - * - * This is where all of the real work takes place. This - * virtual function should be specialized to determine - * the new partition. \a RebalancingNeeded is set if the new - * partition is different than the old one. - */ - - virtual void determine_new_partition (bool & RebalancingNeeded); - - /** \brief Perform communication to create new partition. - * - * \param new_partition New layout of mesh entities on the processing grid. - * - * Given a communication specification this - * function will apply the new partition by - * transferring the ownership of the registered - * mesh entities according to the specification - * determined by the function \a Determine_New_Partition. - * After \a move_mesh_entities is called, GeomDecomp - * should be reinitialized with new vectors of - * mesh entities before rebalancing is performed - * again. - */ - virtual int get_new_partition(stk_classic::mesh::EntityProcVec &new_partition); - - /** \brief Query whether element dependents need to be rebalanced outside this Partition. */ - bool partition_dependents_needed() const - { return true; /* Zoltan partitions elements and leaves the rest to someone else */ } - - /** - * \brief Evaluate the performance/quality of dynamic load rebalancing - * - * \param print_stats Zoltan should print some info about the partition. - * - * \param nentity Number of entities partitioned on this processor. - * - * \param entity_wgt Total weight of entities on this processor. - * - * \param ncuts Total number of cuts used in partition - * - * \param cut_wgt Not sure about this one. - * - * \param nboundary Maybe the number of entities on the processor boundary. - * - * \param nadj Not sure about this one. - * - * This is a non-virtual function specific to just the Zoltan interface. - * It calls through to \a Zoltan_LB_Eval_Balance and \a Zoltan_LB_Eval_Graph - * to return some information about the Zoltan defined partition. - * - */ - int evaluate ( int print_stats, - int *nentity, - double *entity_wgt, - int *ncuts, - double *cut_wgt, - int *nboundary, - int *nadj ); - - /** \brief Return version of Zoltan linked into executable */ - double zoltan_version() const; - - /** \brief Return the parameter list that is being used for this partition. */ - const std::string & parameter_entry_name() const; - - /** \brief Zoltan_Struct is an internal Zoltan handle. */ - Zoltan_Struct * zoltan() { - return m_zoltan_id_; - } - - /** \brief Zoltan_Struct is an internal Zoltan handle. */ - const Zoltan_Struct * zoltan() const { - return m_zoltan_id_; - } - - /** \brief Return the spatial dimention of the entities being rebalanced. */ - unsigned spatial_dimension() const { - return m_spatial_dimension_; - } - -private: - /** Zoltan load balancing struct */ - struct Zoltan_Struct *m_zoltan_id_; - - const unsigned m_spatial_dimension_; - /** Name that was used to initialize this Zoltan_Struct - * if the parameter constructor was used. - */ - std::string m_parameter_entry_name_; - - static const std::string m_zoltanparametersname_; - static const std::string m_defaultparametersname_; - Parameters m_default_parameters_; - MeshInfo m_mesh_information_; - unsigned m_total_number_entities_; - - void init_default_parameters(); - void init(const std::vector< std::pair > - &dynamicLoadRebalancingParameters); - static double init_zoltan_library(); - - /** \brief Return the owning processor.*/ - unsigned destination_proc(const unsigned moid) const; - - /** \brief Register SIERRA Framework Zoltan call-back functions */ - int register_callbacks(); - - -}; - -/** \} */ - -} -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/CMakeLists.txt b/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/CMakeLists.txt deleted file mode 100644 index e13d37cdc1ad..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) - -SET(SOURCES "") -SET(HEADERS "") - -FILE(GLOB SOURCES *.cpp) -FILE(GLOB HEADERS *.hpp) - -TRIBITS_ADD_LIBRARY( - stkclassic_rebalance_utils - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_util_env stkclassic_mesh_base - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_rebalance_utils) diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.cpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.cpp deleted file mode 100644 index 0f099bcd4577..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include - - -//---------------------------------------------------------------------- - -double stk_classic::rebalance::check_balance(mesh::BulkData & bulk_data, - const mesh::Field * load_measure, - const stk_classic::mesh::EntityRank rank, - const mesh::Selector *selector) -{ - const ParallelMachine &comm = bulk_data.parallel(); - double my_load = 0.0; - - const mesh::MetaData & meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - mesh::EntityVector local_elems; - if (selector) { - mesh::get_selected_entities(*selector, - bulk_data.buckets(rank), - local_elems); - } else { - mesh::Selector select_owned( meta_data.locally_owned_part() ); - // Determine imbalance based on current element decomposition - mesh::get_selected_entities(select_owned, - bulk_data.buckets(rank), - local_elems); - } - - for(mesh::EntityVector::iterator elem_it = local_elems.begin(); elem_it != local_elems.end(); ++elem_it) - { - if (load_measure) { - const double * load_val = mesh::field_data(*load_measure, **elem_it); - my_load += *load_val; - } else { - my_load += 1; - } - } - - double max_load = my_load; - double tot_load = my_load; - - all_reduce(comm, ReduceMax<1>(&max_load) & ReduceSum<1>(&tot_load)); - - const int proc_size = parallel_machine_size(comm); - const double avg_load = tot_load / proc_size; - - const double imbalance_threshold = max_load / avg_load; - - return imbalance_threshold; -} - - - -bool stk_classic::rebalance::verify_dependent_ownership( const stk_classic::mesh::EntityRank & parent_rank, - stk_classic::mesh::EntityVector & entities ) -{ - bool is_with_elem = true; - for( size_t i = 0; i < entities.size(); ++i ) - { - is_with_elem = false; - - stk_classic::mesh::Entity * entity = entities[i]; - unsigned owner_proc = entity->owner_rank(); - const stk_classic::mesh::PairIterRelation rel = entity->relations( parent_rank ); - const unsigned num_elems = rel.size(); - - for ( unsigned j = 0 ; j < num_elems ; ++j ) - { - stk_classic::mesh::Entity & elem = * rel[j].entity(); - if( owner_proc == elem.owner_rank() ) - { - is_with_elem = true; - break; - } - } - if( !is_with_elem ) - return false; - } - - return is_with_elem; -} diff --git a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.hpp b/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.hpp deleted file mode 100644 index d8431b0ce6d3..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/stk_rebalance_utils/RebalanceUtils.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - - -//---------------------------------------------------------------------- - -namespace stk_classic { - namespace rebalance { - -/** \addtogroup stk_rebalance_module - * \{ - */ - -/** \brief Determine if rebalancing is needed. - * - * \param bulk_data BulkData must be in a parallel consistent state. - * - * \param load_measure Field defined on mesh entities of rank \a rank. - * Can be a NULL pointer. - * - * \param imbalance_threshold Rebalance needed if MAX divided by average load - * measure exceeds this value. - * - * \param rank Rank of mesh entities to define load measure. - * - * \param selector Used to select a subset of mesh entities to compute measure. - * - * This function calculates the total weight of the load on each processor by summing - * the \a load_measure field over the \a selector entities of rank \a rank. If \a selector is not - * specified, all ejects of rank are summed. If \a load_balance is not specified, it is - * assumed to be 1 for each entity and the weight per processor is just the number - * of entities on each processor. After a processor weight is defined the MAX over the - * processing grid is divided by the average to get a global imbalance which is - * compared to \a imbalance_threshold. True is returned if the global imbalance is - * greater than \a imbalance_threshold. - */ - - double check_balance(mesh::BulkData & bulk_data, - const mesh::Field * load_measure, - const stk_classic::mesh::EntityRank rank, - const mesh::Selector * selector=NULL); - - bool verify_dependent_ownership(const stk_classic::mesh::EntityRank & parent_rank, - stk_classic::mesh::EntityVector & entities ); - - } // namepsace rebalance -} // namepsace stk diff --git a/packages/stk/stk_classic/stk_rebalance/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_rebalance/unit_tests/CMakeLists.txt deleted file mode 100644 index 1304911189da..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -APPEND_SET(SOURCES - UnitTestMain.cpp - UnitTestSimple.cpp - UnitTestZoltanSimple.cpp - ) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_rebalance_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM mpi - NUM_MPI_PROCS 1-4 - ) - diff --git a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 440f082689bb..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include -#include - -STKUNIT_MAIN(argc,argv) - diff --git a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestSimple.cpp b/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestSimple.cpp deleted file mode 100644 index 0f106c52a8d2..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestSimple.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -// relevant headers -#include -#include -#include -// end relevant headers - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -static const int spatial_dimension = 2; - -enum { nx = 2, ny = 2 }; - -class MockPartition : public stk_classic::rebalance::Partition -{ - public: - - enum BALANCE_TEST_STEP - { FIRST, - SECOND, - THIRD }; - - MockPartition( stk_classic::mesh::fem::FEMMetaData & fmd, stk_classic::mesh::BulkData & bd ) : - stk_classic::rebalance::Partition(bd.parallel()), - m_fem_meta(fmd), - m_bulk_data(bd), - m_step(FIRST) - { } - - ~MockPartition() { } - - void set_balance_step(BALANCE_TEST_STEP step) - { m_step = step; } - - void set_mesh_info ( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref) - { total_number_entities_ = mesh_entities.size(); } - - unsigned num_elems() const - { return total_number_entities_; } - - void determine_new_partition(bool &RebalancingNeeded) - { RebalancingNeeded = (m_bulk_data.parallel_size() > 1); } - - int get_new_partition(std::vector &new_partition); - - bool partition_dependents_needed() const - { return false; /* I handle both element and dependent node partitioning */ } - - private: - - unsigned total_number_entities_; - stk_classic::mesh::fem::FEMMetaData & m_fem_meta; - stk_classic::mesh::BulkData & m_bulk_data; - BALANCE_TEST_STEP m_step; -}; - -int -MockPartition::get_new_partition(std::vector &new_partition) -{ - const unsigned p_size = m_bulk_data.parallel_size(); - const unsigned p_rank = m_bulk_data.parallel_rank(); - const stk_classic::mesh::EntityRank element_rank = m_fem_meta.element_rank(); - - new_partition.clear(); - - if ( 1 < p_size ) { - - if( FIRST == m_step ) - { - if ( p_rank == 0 ) { - if ( p_size == 3 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - unsigned proc = ix < nx/2 ? 1 : 2; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( NODE_RANK , id ) , proc ); - new_partition.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - unsigned proc = ix < nx/2 ? 1 : 2; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( element_rank , id ) , proc ); - new_partition.push_back( tmp ); - } - } - } - else - { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( NODE_RANK , id ) , 1 ); - new_partition.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( element_rank , id ) , 1 ); - new_partition.push_back( tmp ); - } - } - } - } - } - - else if( SECOND == m_step ) - { - if ( p_rank == 0 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = 0 ; iy < nny / 2 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( NODE_RANK , id ) , 1 ); - new_partition.push_back( tmp ); - } - } - for ( unsigned iy = 0 ; iy < ny / 2 ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( element_rank , id ) , 1 ); - new_partition.push_back( tmp ); - } - } - } - } - - else if( THIRD == m_step ) - { - if ( p_size == 3 ) { - new_partition.clear(); - - if ( p_rank == 2 ) { - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = nny / 2 ; iy < nny ; ++iy ) { - for ( unsigned ix = nx / 2 ; ix < nnx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nnx ; - unsigned proc = 1; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( NODE_RANK , id ) , proc ); - new_partition.push_back( tmp ); - } - } - for ( unsigned iy = ny / 2 ; iy < ny ; ++iy ) { - for ( unsigned ix = nx / 2 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId id = 1 + ix + iy * nx ; - unsigned proc = 1; - stk_classic::mesh::EntityProc tmp( m_bulk_data.get_entity( element_rank , id ) , proc ); - new_partition.push_back( tmp ); - } - } - } - } - } - } - - return 0; -} - - -STKUNIT_UNIT_TEST(UnitTestRebalanceSimple, testUnit) -{ -#ifdef STK_HAS_MPI - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); -#else - stk_classic::ParallelMachine comm(0); -#endif - - unsigned spatial_dimension = 2; - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension) ); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , comm , 100 ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & quad_part( fem_meta.declare_part("quad", quad_top ) ); - VectorField & coord_field( fem_meta.declare_field< VectorField >( "coordinates" ) ); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "element_weights" ) ); - - stk_classic::mesh::put_field( coord_field , NODE_RANK , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - // create initial mesh - bulk_data.modification_begin(); - - if ( p_rank == 0 ) { - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - } - } - // end create initial mesh - - // assign element weights - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::Entity * e = bulk_data.get_entity( element_rank, elem ); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *e ); - *e_weight = 1.0; - } - } - // end assign element weights - } - - // Only P0 has any nodes or elements - if ( p_rank == 0 ) { - STKUNIT_ASSERT( ! bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( ! bulk_data.buckets( element_rank ).empty() ); - } - else { - STKUNIT_ASSERT( bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( bulk_data.buckets( element_rank ).empty() ); - } - - bulk_data.modification_end(); - - // Create our Partition and Selector objects - MockPartition partition(fem_meta, bulk_data); - stk_classic::mesh::Selector selector(fem_meta.universal_part()); - - partition.set_balance_step(MockPartition::FIRST); - // Exercise the threshhold calculation by using imblance_threshhold > 1.0 - bool do_rebal = 1.5 < stk_classic::rebalance::check_balance(bulk_data, &weight_field, element_rank); - if( do_rebal ) - { - // Pick a few values as negative to exercise a check in rebalance::rebalance(...) - // which converts negative weights to 1.0 - if ( p_rank == 0 ) - { - for ( unsigned iy = 0 ; iy < ny ; ++iy ) - { - stk_classic::mesh::EntityId elem = 1 + iy * nx ; - stk_classic::mesh::Entity * e = bulk_data.get_entity( element_rank, elem ); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *e ); - *e_weight = -2.0; - } - } - // Do the actual rebalance - stk_classic::rebalance::rebalance(bulk_data, selector, NULL, &weight_field, partition); - } - - partition.set_balance_step(MockPartition::SECOND); - stk_classic::rebalance::rebalance(bulk_data, selector, NULL, &weight_field, partition); - - partition.set_balance_step(MockPartition::THIRD); - stk_classic::rebalance::rebalance(bulk_data, selector, NULL, &weight_field, partition); - - if ( 1 < p_size ) { - // Only P1 has any nodes or elements - if ( p_rank == 1 ) { - STKUNIT_ASSERT( ! bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( ! bulk_data.buckets( element_rank ).empty() ); - } - else { - STKUNIT_ASSERT( bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( bulk_data.buckets( element_rank ).empty() ); - } - } -} - -/// \page stk_rebalance_unit_test_simple -/// \ingroup stk_rebalance_unit_test_module -/// -/// \section stk_rebalance_unit_test_simple_description Simple Basic Unit Test -/// -/// This unit test creates a 2D quad mesh on proc 0 and then moves these elements -/// in a predetermined way to other procs and finally all to proc 1 in parallel. -/// The test passes in serial trivially and in paralle if all entities -/// end up on proc 1. -/// -/// The relevant headers for this unit test are -/// \dontinclude UnitTestSimple.cpp -/// \skip relevant headers -/// \until end relevant headers -/// The following quad4 mesh : -/// -/// Global node and element numbering -///
-///     
-///        7       8       9
-///        +-------+-------+
-///        |       |       |
-///        |  e3   |  e4   |
-///        |       |5      |
-///       4+-------+-------+6   
-///        |       |       |     Y
-///        |  e1   |  e2   |     |
-///        |       |       |     |
-///        +-------+-------+     *--> X
-///        1       2      3 
-///      
-/// -/// Local node numbering -/// -///
-///          
-///        3       4
-///        +-------+
-///        |       |
-///        |  e1   |
-///        |       |
-///        +-------+
-///        1       2
-///      
-/// -/// is constructed on proc 0 by the code -/// \skip create initial mesh -/// \until end create initial mesh -/// -/// Uniform unit weights are assigned to elements via -/// \skip assign element weights -/// \until end assign element weights -/// -/// Mesh creation is signaled complete by calling -/// \skipline modification_end -/// -/// We instantiate our MockPartition, our Selector to include all elements in the mesh -/// and our imbalance threshold we want to use to determine whether or not to -/// compute a new element partition among processors: -/// \skip Partition and Selector -/// \until universal_part -/// \skipline double imblance_threshhold -/// -/// We interrogate whether a rebalance is needed by calling -/// \skipline rebalance::check_balance -/// If the current imbalance is above the threshold, the call returns true -/// and we can then invoke the actual rebalance via -/// \skip Do the actual rebalance -/// \until rebalance::rebalance -/// -/// Upon return the bulk_data will reflect the new partiioning of elements with -/// dependent entities, eg faces, edges, nodes, partitioned in a default -/// greedy manner. -/// -/// See \ref UnitTestSimple.cpp for the complete source listing. -/// diff --git a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanGraph.cpp b/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanGraph.cpp deleted file mode 100644 index 2e2275239478..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanGraph.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -enum { nx = 2, ny = 2 }; - -//STKUNIT_UNIT_TEST(UnitTestZoltanGraph, testUnit) -void disabled_unit_test() -{ -#ifdef STK_HAS_MPI - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); -#else - stk_classic::ParallelMachine comm(0); -#endif - - unsigned spatial_dimension = 2; - std::vector rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - const stk_classic::mesh::EntityRank constraint_rank = rank_names.size(); - rank_names.push_back("Constraint"); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, rank_names); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , comm , 100 ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & quad_part( fem_meta.declare_part("quad", quad_top ) ); - VectorField & coord_field( fem_meta.declare_field< VectorField >( "coordinates" ) ); - - stk_classic::mesh::put_field( coord_field , NODE_RANK , fem_meta.universal_part() ); - - fem_meta.commit(); - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - bulk_data.modification_begin(); - - if ( p_rank == 0 ) { - - std::vector > quads(nx); - for ( unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny); - - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::Entity &q = stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - quads[ix][iy] = &q; - } - } - - for ( unsigned iy = 0 ; iy <= ny ; ++iy ) { - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid ); - double * const coord = stk_classic::mesh::field_data( coord_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - - { - const unsigned iy_left = 0; - const unsigned iy_right = ny; - stk_classic::mesh::PartVector add(1, &fem_meta.locally_owned_part()); - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid_left = 1 + ix + iy_left * nnx ; - stk_classic::mesh::EntityId nid_right = 1 + ix + iy_right * nnx ; - stk_classic::mesh::Entity * n_left = bulk_data.get_entity( NODE_RANK, nid_left ); - stk_classic::mesh::Entity * n_right = bulk_data.get_entity( NODE_RANK, nid_right ); - const stk_classic::mesh::EntityId constraint_entity_id = 1 + ix + nny * nnx; - stk_classic::mesh::Entity & c = bulk_data.declare_entity( constraint_rank, constraint_entity_id, add ); - bulk_data.declare_relation( c , *n_left , 0 ); - bulk_data.declare_relation( c , *n_right , 1 ); - } - } - - } - - // Only P0 has any nodes or elements - if ( p_rank == 0 ) { - STKUNIT_ASSERT( ! bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( ! bulk_data.buckets( element_rank ).empty() ); - } - else { - STKUNIT_ASSERT( bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( bulk_data.buckets( element_rank ).empty() ); - } - - - bulk_data.modification_end(); - - // create some sides and faces to rebalance. - stk_classic::mesh::PartVector add_parts; - stk_classic::mesh::create_adjacent_entities(bulk_data, add_parts); - - // Zoltan partition is specialized form a virtual base class, stk_classic::rebalance::Partition. - // Other specializations are possible. - // Configure Zoltan to use graph-based partitioning - Teuchos::ParameterList graph; - Teuchos::ParameterList lb_method; - lb_method.set("LOAD BALANCING METHOD" , "4"); - graph.sublist(stk_classic::rebalance::Zoltan::default_parameters_name())=lb_method; - stk_classic::rebalance::Zoltan zoltan_partition(comm, spatial_dimension, graph); - // end configure snippet - stk_classic::mesh::Selector selector(fem_meta.universal_part()); - - // Coordinates are passed to support geometric-based load balancing algorithms - stk_classic::rebalance::rebalance(bulk_data, selector, &coord_field, NULL, zoltan_partition, fem_meta.node_rank()); - - const double imbalance_threshold = stk_classic::rebalance::check_balance(bulk_data, NULL, fem_meta.node_rank(), &selector); - const bool do_rebal = 1.5 < imbalance_threshold; - - // Check that we satisfy our threshhold - STKUNIT_ASSERT( !do_rebal ); - if( (2 == p_size) || (4 == p_size) ) - { - STKUNIT_ASSERT_NEAR(imbalance_threshold, 1.0, .1); - } - else - { - STKUNIT_ASSERT_LE(imbalance_threshold, 1.5); - } - - // And verify that all dependent entities are on the same proc as their parent element - { - stk_classic::mesh::EntityVector entities; - stk_classic::mesh::Selector selector1 = fem_meta.universal_part(); - - get_selected_entities(selector1, bulk_data.buckets(element_rank), entities); - bool result = stk_classic::rebalance::verify_dependent_ownership(NODE_RANK, entities); - STKUNIT_ASSERT( result ); - } -} - -/// \page stk_rebalance_unit_test_zoltan -/// \ingroup stk_rebalance_unit_test_module -/// \section stk_rebalance_unit_test_zoltan_graph Simple Zoltan Unit Test using Graph-Based Partitioning -/// -/// This unit test is identical to -/// \ref stk_rebalance_unit_test_zoltan_description "Simple Zoltan Unit Test" -/// with the only difference being use of graph-based partitioning instead -/// of element weights. -/// -/// The distinction involves setting up an appropriate parameter list, -/// \dontinclude UnitTestZoltanGraph.cpp -/// \skip Configure Zoltan to use graph-based partitioning -/// \until end configure snippet -/// and then calling check_balance and rebalance with NULL weight fields -/// and calling rebalance with non-NULL coordinates, eg -/// \skip double imbalance_threshold = -/// \until rebalance::rebalance( -/// -/// -/// The test passes if the resulting rebalance produces an imbalance measure -/// below 1.1 for 2 or 4 procs and below 1.5 otherwise. -/// -/// -/// See \ref UnitTestZoltanGraph.cpp for the complete source listing. -/// diff --git a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanSimple.cpp b/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanSimple.cpp deleted file mode 100644 index 022f87d04ce2..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/unit_tests/UnitTestZoltanSimple.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -enum { nx = 2, ny = 2 }; - -STKUNIT_UNIT_TEST(UnitTestZoltanSimple, testUnit) -{ -#ifdef STK_HAS_MPI - stk_classic::ParallelMachine comm(MPI_COMM_WORLD); -#else - stk_classic::ParallelMachine comm(0); -#endif - - unsigned spatial_dimension = 2; - std::vector rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - const stk_classic::mesh::EntityRank constraint_rank = rank_names.size(); - rank_names.push_back("Constraint"); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize( spatial_dimension, rank_names ); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , comm , 100 ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & quad_part( fem_meta.declare_part("quad", quad_top ) ); - VectorField & coord_field( fem_meta.declare_field< VectorField >( "coordinates" ) ); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "element_weights" ) ); - - stk_classic::mesh::put_field( coord_field , NODE_RANK , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - - const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - bulk_data.modification_begin(); - - if ( p_rank == 0 ) { - - std::vector > quads(nx); - for ( unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny); - - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::Entity &q = stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - quads[ix][iy] = &q; - } - } - - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::Entity * e = bulk_data.get_entity( element_rank, elem ); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *e ); - *e_weight = 1.0; - } - } - - for ( unsigned iy = 0 ; iy <= ny ; ++iy ) { - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid ); - double * const coord = stk_classic::mesh::field_data( coord_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - - { - const unsigned iy_left = 0; - const unsigned iy_right = ny; - stk_classic::mesh::PartVector add(1, &fem_meta.locally_owned_part()); - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid_left = 1 + ix + iy_left * nnx ; - stk_classic::mesh::EntityId nid_right = 1 + ix + iy_right * nnx ; - stk_classic::mesh::Entity * n_left = bulk_data.get_entity( NODE_RANK, nid_left ); - stk_classic::mesh::Entity * n_right = bulk_data.get_entity( NODE_RANK, nid_right ); - const stk_classic::mesh::EntityId constraint_entity_id = 1 + ix + nny * nnx; - stk_classic::mesh::Entity & c = bulk_data.declare_entity( constraint_rank, constraint_entity_id, add ); - bulk_data.declare_relation( c , *n_left , 0 ); - bulk_data.declare_relation( c , *n_right , 1 ); - } - } - - } - - // Only P0 has any nodes or elements - if ( p_rank == 0 ) { - STKUNIT_ASSERT( ! bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( ! bulk_data.buckets( element_rank ).empty() ); - } - else { - STKUNIT_ASSERT( bulk_data.buckets( NODE_RANK ).empty() ); - STKUNIT_ASSERT( bulk_data.buckets( element_rank ).empty() ); - } - - - bulk_data.modification_end(); - - // create some sides and faces to rebalance. - stk_classic::mesh::PartVector add_parts; - stk_classic::mesh::create_adjacent_entities(bulk_data, add_parts); - - // Zoltan partition is specialized fomm a virtual base class, stk_classic::rebalance::Partition. - // Other specializations are possible. - Teuchos::ParameterList emptyList; - stk_classic::rebalance::Zoltan zoltan_partition(comm, spatial_dimension, emptyList); - - { - stk_classic::mesh::Selector selector(fem_meta.universal_part()); - - stk_classic::rebalance::rebalance(bulk_data, selector, &coord_field, &weight_field, zoltan_partition); - } - - const double imbalance_threshold = stk_classic::rebalance::check_balance(bulk_data, &weight_field, element_rank); - const bool do_rebal = 1.5 < imbalance_threshold; - - // Check that we satisfy our threshhold - STKUNIT_ASSERT( !do_rebal ); - if( (2 == p_size) || (4 == p_size) ) - { - STKUNIT_ASSERT_NEAR(imbalance_threshold, 1.0, 1.e-8); - } - else - { - STKUNIT_ASSERT_LE(imbalance_threshold, 1.5); - } - - // And verify that all dependent entities are on the same proc as their parent element - { - stk_classic::mesh::EntityVector entities; - stk_classic::mesh::Selector selector = fem_meta.locally_owned_part(); - - get_selected_entities(selector, bulk_data.buckets(NODE_RANK), entities); - bool result = stk_classic::rebalance::verify_dependent_ownership(element_rank, entities); - //get_selected_entities(selector, bulk_data.buckets(constraint_rank), entities); - //result &= stk_classic::rebalance::verify_dependent_ownership(element_rank, entities); - STKUNIT_ASSERT( result ); - } -} - -/// \page stk_rebalance_unit_test_zoltan -/// \ingroup stk_rebalance_unit_test_module -/// \section stk_rebalance_unit_test_zoltan_description Simple Zoltan Unit Test -/// -/// This unit test creates a 2D quad mesh on proc 0 with coordinates and -/// Parts associated with edges, nodes, and constraints and then moves these entities -/// as determined by calling Zoltan's load balancing capability using -/// default settings. -/// -/// Using the following mesh of 4 quads, -/// -/// Global node and element numbering -///
-///
-///   7       8       9
-///   +-------+-------+
-///   |       |       |
-///   |  e3   |  e4   |
-///   |       |5      |
-///  4+-------+-------+6   
-///   |       |       |     Y
-///   |  e1   |  e2   |     |
-///   |       |       |     |
-///   +-------+-------+     *--> X
-///   1       2      3 
-/// 
-/// -/// Local node numbering -/// -///
-///     
-///   3       4
-///   +-------+
-///   |       |
-///   |  e1   |
-///   |       |
-///   +-------+
-///   1       2
-/// 
-/// -/// Use of Zoltan with default settings is achieved by instantiating the -/// appropriate Partition class with an empty parameter list as follows, -/// \dontinclude UnitTestZoltanSimple.cpp -/// \skip Zoltan partition is -/// \until zoltan_partition( -/// -/// An initial assessment of imbalance is made using an element weight field -/// followed by a call to actually do the rebalance as follows, -/// \skip Force a rebalance -/// \until rebalance::rebalance( -/// -/// Perfect balancing should result using 2 or 4 procs, and -/// on 3 procs, the imbalance threshold should be below 1.5. -/// The test passes if these criteria are satisfied. -/// -/// See \ref UnitTestZoltanSimple.cpp for the complete source listing. -/// diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/CMakeLists.txt b/packages/stk/stk_classic/stk_rebalance/use_cases/CMakeLists.txt deleted file mode 100644 index 6404891b390f..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_rebalance_use_cases - SOURCES ${SOURCES} - DEPLIBS stkclassic_util_use_cases - ARGS "" - COMM mpi - NUM_MPI_PROCS 1-4 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCaseMain.cpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCaseMain.cpp deleted file mode 100644 index 333e0c93165a..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCaseMain.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -void printStatus(bool status) -{ - if (status) { - std::cout << "passed" << std::endl; - } - else { - std::cout << "FAILED" << std::endl; - } -} - -int main ( int argc, char * argv[] ) -{ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - stk_classic::ParallelMachine parallel_machine = use_case_environment.m_comm; - - bool status = true; - { - std::cout << "Use Case 1, unequal element weights ... "; - bool local_status = stk_classic::rebalance::use_cases::test_unequal_weights(parallel_machine); - stk_classic::all_reduce(parallel_machine, stk_classic::ReduceMin<1>(&local_status)); - printStatus(local_status); - status = status && local_status; - } - { - std::cout << "Use Case 2, heavy entities ... "; - bool local_status = stk_classic::rebalance::use_cases::test_heavy_nodes(parallel_machine); - stk_classic::all_reduce(parallel_machine, stk_classic::ReduceMin<1>(&local_status)); - printStatus(local_status); - status = status && local_status; - } - - { - std::cout << "Use Case 3, contact surfaces ... "; - bool local_status = stk_classic::rebalance::use_cases::test_contact_surfaces(parallel_machine); - stk_classic::all_reduce(parallel_machine, stk_classic::ReduceMin<1>(&local_status)); - printStatus(local_status); - status = status && local_status; - } - { - std::cout << "Use Case 4, greedy sideset ... "; - bool local_status = stk_classic::rebalance::use_cases::test_greedy_sideset(parallel_machine); - stk_classic::all_reduce(parallel_machine, stk_classic::ReduceMin<1>(&local_status)); - printStatus(local_status); - status = status && local_status; - } - - bool collective_result = use_case::print_status(parallel_machine, status); - int return_code = collective_result ? 0 : -1; - - return return_code; -} diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.cpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.cpp deleted file mode 100644 index 7a6b52f44bfd..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- - -using namespace stk_classic::mesh::fixtures; - -typedef stk_classic::mesh::Field ScalarField ; - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - -bool test_unequal_weights( stk_classic::ParallelMachine pm ) -{ - const unsigned p_size = stk_classic::parallel_machine_size(pm); - const unsigned p_rank = stk_classic::parallel_machine_rank(pm); - - const unsigned ngx = p_size*(p_size+1)/2; - - unsigned nx = 0; - if( 0 == p_rank ) - nx = ngx; - unsigned ny = 1; - unsigned nz = 1; - - stk_classic::mesh::fixtures::HexFixture fixture(pm, nx, ny, nz); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = fixture.m_fem_meta; - stk_classic::mesh::BulkData & bulk = fixture.m_bulk_data; - - // Put weights field on all elements - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "element_weights" ) ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - - bulk.modification_begin(); - - // Initially put all elements on proc 0 - std::vector my_element_ids; - for ( unsigned i = 0 ; i < nx*ny*nz; ++i ) - my_element_ids.push_back(i+1); - - fixture.generate_mesh(my_element_ids); - - // Assign weights so that a perfect rebalance is possible so long as the rebalancer can figure out - // to put p_rank+1 elements on proc = p_rank based on these weights. - unsigned nslabs = 0; - if( 0 == p_rank ) { - for ( unsigned l = 1 ; l <= p_size ; ++l ) { - for ( unsigned k = 0 ; k < nz ; ++k ) { - for ( unsigned j = 0 ; j < ny ; ++j ) { - for ( unsigned i = 0 ; i < l ; ++i ) { - const stk_classic::mesh::EntityId elem_id = 1 + nslabs + i + j*ngx + k*ngx*ny; - stk_classic::mesh::Entity * elem = bulk.get_entity(element_rank, elem_id); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *elem ); - *e_weight = double(ngx) / double(l); - } - } - } - nslabs += l; - } - } - // end assign weights - - bulk.modification_end(); - - // Use Zoltan to determine new partition - Teuchos::ParameterList emptyList; - stk_classic::rebalance::Zoltan zoltan_partition(pm, fixture.m_spatial_dimension, emptyList); - - stk_classic::mesh::Selector selector(fem_meta.universal_part()); - - stk_classic::rebalance::rebalance(bulk, selector, &fixture.m_coord_field, &weight_field, zoltan_partition); - - const double imbalance_threshold = stk_classic::rebalance::check_balance(bulk, &weight_field, element_rank); - const bool do_rebal = 1.5 < imbalance_threshold; - - if( 0 == p_rank ) - std::cerr << std::endl - << "imbalance_threshold after rebalance = " << imbalance_threshold << ", " << do_rebal << std::endl; - - stk_classic::mesh::Selector owned_selector = fem_meta.locally_owned_part(); - size_t num_local_elems = stk_classic::mesh::count_selected_entities(owned_selector, bulk.buckets(element_rank)); - - // Check that we satisfy our threshhold - bool result = true; - if( 4 > p_size ) - { - result = (fabs(imbalance_threshold - 1.0) < 1.e-8); - result = result & (num_local_elems == p_rank+1); - } - else - { - // Would like to put something here, but Zoltan using its default algorithm (RCB) - // isn't able to do an adequate job rebalancing - result = !do_rebal; - } - - return result; -} - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.hpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.hpp deleted file mode 100644 index ef5546b5474a..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_1.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Rebalance_Use_Cases_UseCase_1_hpp -#define Stk_Rebalance_Use_Cases_UseCase_1_hpp - -#include - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - - bool test_unequal_weights( stk_classic::ParallelMachine comm ); - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - -#endif // Stk_Rebalance_Use_Cases_UseCase_1_hpp - -/// \page stk_rebalance_use_case_1 -/// \ingroup stk_rebalance_use_case_module -/// -/// \section stk_rebalance_use_case_1_description Use Case 1: Unequal element weights -/// -/// This use case demonstrates unequal element weights. A -/// single-element-thick column of hex elements is constructed in the -/// x-direction. Weights are assigned to elements such that a perfect -/// rebalance is possible with Proc_Rank+1 elements placed on each processor. -/// This is achieved when running on #procs < 4, but Zoltan does not -/// produce the optimal new distribution for 4 or more procs. -/// -/// -/// The following hex8 mesh is used in this use case: -/// -/// Global node and element numbering -///
-///           3       7      11      15      19                 
-///           +-------+-------+-------+-------+                +-------+
-///          /       /       /       /       /|               /       /|
-///        4/      8/     12/     16/     20/ |              /       / |    Z  Y
-///        +-------+-------+-------+-------+  |     ......  +-------+  |    | / 
-///        |       |       |       |       |  +18           |       |  /    |/  
-///        |  e1   |  e2   |  e3   |  e4   | /              |  eN   | /     *--X       
-///        |       |       |       |       |/               |       |/         
-///        +-------+-------+-------+-------+                +-------+
-///        1       5      9       13      17                  
-///      
-/// where N = #elements = (#procs)(#procs+1)/2 -/// -/// Local node numbering -///
-///           8       7
-///           +-------+
-///          /       /|
-///        5/      6/ |
-///        +-------+  |
-///        |       |  +3
-///        |  e1   | /
-///        |       |/
-///        +-------+
-///        1       2
-///      
-/// -/// The mesh is constructed on proc 0 using the HexFixture class -/// and unequal element weights are assigned as follows: -/// \dontinclude UseCase_Rebal_1.cpp -/// \skip Assign weights -/// \until end assign weights -/// -/// See \ref UseCase_Rebal_1.cpp for the complete source listing. -/// -/// -/// -/// diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.cpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.cpp deleted file mode 100644 index 8cf2053a570c..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- - -using namespace stk_classic::mesh::fixtures; - -typedef stk_classic::mesh::Field ScalarField ; - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - -namespace { - - void sum_element_weights_through_relations( stk_classic::mesh::EntityVector & elements, - ScalarField & field, const std::vector & ranks ) - { - for( size_t i = 0; i < ranks.size(); ++i ) - { - for( size_t ielem = 0; ielem < elements.size(); ++ielem ) - { - stk_classic::mesh::Entity * elem = elements[ielem]; - double * elem_weight = field_data( field , *elem ); - const stk_classic::mesh::PairIterRelation rel = elem->relations( ranks[i] ); - const unsigned num_entities = rel.size(); - - for ( unsigned j = 0 ; j < num_entities ; ++j ) - { - stk_classic::mesh::Entity & entity = * rel[j].entity(); - const double * entity_weight = field_data( field , entity ); - elem_weight[0] += entity_weight[0]; - } - } - } - } - -} // namespace - -bool test_heavy_nodes( stk_classic::ParallelMachine pm ) -{ - const size_t nx = 3; - const size_t ny = 3; - const size_t nz = 3; - - const unsigned p_size = stk_classic::parallel_machine_size(pm); - const unsigned p_rank = stk_classic::parallel_machine_rank(pm); - - stk_classic::mesh::fixtures::HexFixture fixture(pm, nx, ny, nz); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = fixture.m_fem_meta; - stk_classic::mesh::BulkData & bulk = fixture.m_bulk_data; - - // Put weights field on all entities - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank face_rank = fem_meta.face_rank(); - const stk_classic::mesh::EntityRank edge_rank = fem_meta.edge_rank(); - const stk_classic::mesh::EntityRank node_rank = fem_meta.node_rank(); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "entity_weights" ) ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , face_rank , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , edge_rank , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , node_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - - // Configure our mesh on proc 0 - std::vector my_element_ids; - if( 0 == p_rank ) - { - for ( unsigned i = 0 ; i < nx*ny*nz; ++i ) - my_element_ids.push_back(i+1); - } - - fixture.generate_mesh(my_element_ids); - - // create faces and edges for the mesh - stk_classic::mesh::PartVector add_parts; - stk_classic::mesh::create_adjacent_entities(bulk, add_parts); - - bulk.modification_begin(); - - // Assign entity weights - if( 0 == p_rank ) - { - // Get the faces on the x=0 plane and give them a characteristic weight - stk_classic::mesh::EntityVector selected_nodes; - stk_classic::mesh::EntityVector selected_faces; - stk_classic::mesh::EntityVector one_face; - for ( unsigned j = 0 ; j < ny; ++j ) - for ( unsigned k = 0 ; k < nz; ++k ) - { - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, j, k ) ); - selected_nodes.push_back( fixture.node(0, j+1, k ) ); - selected_nodes.push_back( fixture.node(0, j, k+1) ); - selected_nodes.push_back( fixture.node(0, j+1, k+1) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, face_rank, one_face); - selected_faces.push_back(one_face[0]); - } - - for( size_t iface = 0; iface < selected_faces.size(); ++iface ) - { - stk_classic::mesh::Entity * face = selected_faces[iface]; - double * const weight = stk_classic::mesh::field_data( weight_field, *face ); - weight[0] = 10.0; - } - - // Get the edges on the boundary of the x=0 plane and give them a characteristic weight - stk_classic::mesh::EntityVector selected_edges; - stk_classic::mesh::EntityVector one_edge; - for ( unsigned j = 0 ; j < ny; ++j ) - { - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, j, 0) ); - selected_nodes.push_back( fixture.node(0, j+1, 0) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, edge_rank, one_edge); - selected_edges.push_back(one_edge[0]); - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, j, nz) ); - selected_nodes.push_back( fixture.node(0, j+1, nz) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, edge_rank, one_edge); - selected_edges.push_back(one_edge[0]); - } - for ( unsigned k = 0 ; k < nz; ++k ) - { - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, 0, k) ); - selected_nodes.push_back( fixture.node(0, 0, k+1) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, edge_rank, one_edge); - selected_edges.push_back(one_edge[0]); - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, ny, k) ); - selected_nodes.push_back( fixture.node(0, ny, k+1) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, edge_rank, one_edge); - selected_edges.push_back(one_edge[0]); - } - for( size_t iedge = 0; iedge < selected_edges.size(); ++iedge ) - { - stk_classic::mesh::Entity * edge = selected_edges[iedge]; - double * const weight = stk_classic::mesh::field_data( weight_field, *edge ); - weight[0] = 100.0; - } - - // Finally, give the corner nodes of the x=0 plane a characteristic weight - selected_nodes.clear(); - double * weight = stk_classic::mesh::field_data( weight_field, *fixture.node(0, 0, 0) ); - weight[0] = 1000.0; - weight = stk_classic::mesh::field_data( weight_field, *fixture.node(0, ny, 0) ); - weight[0] = 1000.0; - weight = stk_classic::mesh::field_data( weight_field, *fixture.node(0, 0, nz) ); - weight[0] = 1000.0; - weight = stk_classic::mesh::field_data( weight_field, *fixture.node(0, ny, nz) ); - weight[0] = 1000.0; - - // Assign element weights - for( size_t i = 0; i < my_element_ids.size(); ++i ) - { - stk_classic::mesh::Entity * elem = bulk.get_entity(element_rank, my_element_ids[i]); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *elem ); - *e_weight = 1.0; - } - // - // Get the elements on the x=0 plane and sum in weights from relations - selected_nodes.clear(); - for ( unsigned j = 0 ; j < ny+1; ++j ) - for ( unsigned k = 0 ; k < nz+1; ++k ) - selected_nodes.push_back( fixture.node(0, j, k) ); - - std::vector ranks; - ranks.push_back(face_rank); - ranks.push_back(edge_rank); - ranks.push_back(node_rank); - stk_classic::mesh::EntityVector selected_elems; - for ( unsigned j = 0 ; j < ny; ++j ) - for ( unsigned k = 0 ; k < nz; ++k ) - { - selected_nodes.clear(); - selected_nodes.push_back( fixture.node(0, j, k ) ); - selected_nodes.push_back( fixture.node(0, j+1, k ) ); - selected_nodes.push_back( fixture.node(0, j, k+1) ); - selected_nodes.push_back( fixture.node(0, j+1, k+1) ); - stk_classic::mesh::get_entities_through_relations(selected_nodes, element_rank, one_face); - selected_elems.push_back(one_face[0]); - } - sum_element_weights_through_relations(selected_elems, weight_field, ranks); - } - - bulk.modification_end(); - - // Use Zoltan to determine new partition - Teuchos::ParameterList emptyList; - stk_classic::rebalance::Zoltan zoltan_partition(pm, fixture.m_spatial_dimension, emptyList); - - stk_classic::rebalance::rebalance(bulk, fem_meta.universal_part(), &fixture.m_coord_field, &weight_field, zoltan_partition); - - const double imbalance_threshold = ( 3 == p_size )? 1.45 // Zoltan does not do so well for 3 procs - : 1.1; // ... but does pretty well for 2 and 4 procs - const bool do_rebal = imbalance_threshold < stk_classic::rebalance::check_balance(bulk, &weight_field, element_rank); - - if( 0 == p_rank ) - std::cerr << std::endl - << "imbalance_threshold after rebalance = " << imbalance_threshold << ", " << do_rebal << std::endl; - - - // Check that we satisfy our threshhold - bool result = !do_rebal; - - // And verify that all dependent entities are on the same proc as their parent element - { - stk_classic::mesh::EntityVector entities; - stk_classic::mesh::Selector selector = fem_meta.locally_owned_part(); - - get_selected_entities(selector, bulk.buckets(node_rank), entities); - result &= verify_dependent_ownership(element_rank, entities); - - get_selected_entities(selector, bulk.buckets(edge_rank), entities); - result &= verify_dependent_ownership(element_rank, entities); - - get_selected_entities(selector, bulk.buckets(face_rank), entities); - result &= verify_dependent_ownership(element_rank, entities); - } - - return result; -} - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.hpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.hpp deleted file mode 100644 index 86be432505f5..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_2.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef Stk_Rebalance_Use_Cases_UseCase_2_hpp -#define Stk_Rebalance_Use_Cases_UseCase_2_hpp - -#include - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - - bool test_heavy_nodes( stk_classic::ParallelMachine comm ); - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - -#endif // Stk_Rebalance_Use_Cases_UseCase_2_hpp - -/// \page stk_rebalance_use_case_2 -/// \ingroup stk_rebalance_use_case_module -/// -/// \section stk_rebalance_use_case_2_description Use Case 2: Node, Edge, Face and Element weights on subset -/// -/// This use case demonstrates element weights comprised of contributions -/// from nodes, edges, faces and elements over a subset of the mesh. -/// A 3x3x3 cube of hex8 elements is constructed on proc 0 -/// and weights are assigned to a subset of mesh entities. The mesh and weights -/// are assigned as follows: -/// -/// Global node and element numbering -///
-///
-///                +-------+-------+-------+               +                   +                 +
-///               /       /       /       /|              /|                  /|         
-///              /       /       /       / |             / |                 / |        
-///             +-------+-------+-------+  |            +  |                +  |    
-///            /       /       /       /|  +           /|  +               /   +   
-///           /       /       /       / | /|          / | /|              /    |  
-///          +-------+-------+-------+  |/ |         +  |/ |             +     | 
-///         /       /       /       /|  +  |        /|  +  |            /      |
-///        /       /       /       / | /|  +       / | /|  +           /       +
-///       +-------+-------+-------+  |/ | /|      +  |/ | /|          +        |        +
-///       |       |       |       |  +  |/ |      |  +  |/ |          |        |    
-///       |  e1   |  e2   |  e3   | /|  +  |      | /|  +  |          |        |        
-///       |       |       |       |/ | /|  +      |/ | /|  +          |        +                 +
-///       +-------+-------+-------+  |/ | /       +  |/ | /           +       /         
-///       |       |       |       |  +  |/        |  +  |/            |      /      
-///       |  e1   |  e2   |  e3   | /|  +         | /|  +             |     +      
-///       |       |       |       |/ | /          |/ | /              |    /      
-///       +-------+-------+-------+  |/           +  |/               +   /      
-///       |       |       |       |  +            |  +                |  +      
-///       |  e1   |  e2   |  e3   | /             | /                 | /      
-///       |       |       |       |/              |/                  |/      
-///       +-------+-------+-------+               +                   +                 +
-///     x = 0
-///      
-/// -///
-///   Weight_elems = 1.0                 Z  Y      Local node numbering
-///   Weight_faces = 10.0                | /      
-///   Weight_edges = 100.0               |/            8       7       
-///   Weight_nodes = 1000.0              *--X          +-------+              
-///                                                   /       /|       
-///                                                 5/      6/ |       
-///                                                 +-------+  |   
-///                                                 |       |  +3   
-///                                                 |  e1   | /
-///                                                 |       |/
-///                                                 +-------+
-///                                                 1       2
-///   
-/// -/// where all 27 elements are assigned weights along with the 9 faces, 12 edges and 4 nodes -/// on the plane at x = 0. -/// \dontinclude UseCase_Rebal_2.cpp -/// \skip bulk.modification_begin -/// \until bulk.modification_end -/// -/// The use case passes if the amount of imbalance following a rebalance is -/// below 1.45 for 3 procs and below 1.1 for 2 or 4 procs. -/// -/// See \ref UseCase_Rebal_2.cpp for the complete source listing. diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_3.cpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_3.cpp deleted file mode 100644 index b9a3337e75f9..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_3.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- - -using namespace stk_classic::mesh::fixtures; - -typedef stk_classic::mesh::Field ScalarField ; - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - -class Test_Case_3_Partition : public stk_classic::rebalance::Zoltan { - public : - explicit Test_Case_3_Partition(ParallelMachine pm, - const unsigned ndim, - Teuchos::ParameterList & rebal_region_parameters, - std::string parameters_name=default_parameters_name()); - virtual ~Test_Case_3_Partition(); - virtual bool partition_dependents_needed() const; -}; - -Test_Case_3_Partition::Test_Case_3_Partition(ParallelMachine pm, - const unsigned ndim, - Teuchos::ParameterList & rebal_region_parameters, - std::string parameters_name) : - stk_classic::rebalance::Zoltan(pm, ndim, rebal_region_parameters, parameters_name) {} -Test_Case_3_Partition::~Test_Case_3_Partition() {} -bool Test_Case_3_Partition::partition_dependents_needed() const -{return false;} //Do NOT move dependent entities for this case - -enum { nx = 4, ny = 4 }; - -bool test_contact_surfaces( stk_classic::ParallelMachine comm ) -{ - unsigned spatial_dimension = 2; - std::vector rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - const stk_classic::mesh::EntityRank constraint_rank = rank_names.size(); - rank_names.push_back("Constraint"); - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, rank_names); - - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , comm , 100 ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank side_rank = fem_meta.side_rank(); - const stk_classic::mesh::EntityRank node_rank = fem_meta.node_rank(); - - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & quad_part( fem_meta.declare_part("quad", quad_top ) ); - stk_classic::mesh::fem::CellTopology side_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & side_part( fem_meta.declare_part("line", side_top ) ); - VectorField & coord_field( fem_meta.declare_field< VectorField >( "coordinates" ) ); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "element_weights" ) ); - - stk_classic::mesh::put_field( coord_field , node_rank , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - - //const unsigned p_size = bulk_data.parallel_size(); - const unsigned p_rank = bulk_data.parallel_rank(); - - bulk_data.modification_begin(); - - if ( !p_rank ) { - - std::vector quads(nx); - for ( unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny); - - const unsigned nnx = nx + 1 ; - const unsigned nny = ny + 1 ; - unsigned face_id = 1; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::Entity &q = stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - if (0==ix) { - stk_classic::mesh::fem::declare_element_side( bulk_data, face_id, q, 0 /*local side id*/, &side_part); - ++face_id; - } - quads[ix][iy] = &q; - } - } - - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::Entity * e = bulk_data.get_entity( element_rank, elem ); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *e ); - *e_weight = 1.0; - } - } - for ( unsigned iy = 0 ; iy <= ny ; ++iy ) { - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( node_rank, nid ); - double * const coord = stk_classic::mesh::field_data( coord_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - - // Assign constraint relations between nodes at top and bottom of mesh - { - const unsigned iy_bottom = 0; - const unsigned iy_top = ny; - stk_classic::mesh::PartVector add(1, &fem_meta.locally_owned_part()); - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid_bottom = 1 + ix + iy_bottom * nnx ; - stk_classic::mesh::EntityId nid_top = 1 + ix + iy_top * nnx ; - stk_classic::mesh::Entity * n_bottom = bulk_data.get_entity( node_rank, nid_bottom ); - stk_classic::mesh::Entity * n_top = bulk_data.get_entity( node_rank, nid_top ); - const stk_classic::mesh::EntityId constraint_entity_id = 1 + ix + nny * nnx; - stk_classic::mesh::Entity & c = bulk_data.declare_entity( constraint_rank, constraint_entity_id, add ); - bulk_data.declare_relation( c , *n_bottom , 0 ); - bulk_data.declare_relation( c , *n_top , 1 ); - } - } // end snippet - - } - - bulk_data.modification_end(); - - stk_classic::mesh::Selector selector(side_part); - selector &= fem_meta.locally_owned_part(); - // Coordinates are passed to support geometric-based load balancing algorithms - // Zoltan partition is specialized form a virtual base class, stk_classic::rebalance::Partition. - // Other specializations are possible. - Teuchos::ParameterList emptyList; - stk_classic::rebalance::use_cases::Test_Case_3_Partition zoltan_partition(comm, spatial_dimension, emptyList); - stk_classic::rebalance::rebalance(bulk_data, selector, &coord_field, NULL, zoltan_partition, side_rank); - - const double imbalance_threshold = 1.5; - const bool do_rebal = imbalance_threshold < stk_classic::rebalance::check_balance(bulk_data, NULL, side_rank, &selector); - - if( !p_rank ) - std::cerr << std::endl - << "imbalance_threshold after rebalance = " << imbalance_threshold <<", "< - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - - bool test_contact_surfaces( stk_classic::ParallelMachine comm ); - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - -#endif // Stk_Rebalance_Use_Cases_UseCase_3_hpp - -/// \page stk_rebalance_use_case_3 -/// \ingroup stk_rebalance_use_case_module -/// -/// \section stk_rebalance_use_case_3 Use Case 3: Periodic Boundary via Constraint Relations -/// -/// This use case sets up a 2D mesh of quad4 elements and then establishes a constraint -/// realtion between the top and bottom of the mesh as would be needed to enforce -/// periodic boundary conditions. -/// -/// The following quad4 mesh is manually constructed on proc 0: -/// -/// Global node and element numbering -///
-///     
-///        21      22      23      24      25
-///        +-------+-------+-------+-------+   y = top
-///        |       |       |       |       |
-///        |  e13  |  e14  |  e15  |  e16  |
-///        |       |       |       |5      |
-///     16 +-------+-------+-------+-------+ 20
-///        |       |       |       |       |      
-///        |  e9   |  e10  |  e11  |  e12  |      
-///        |       |       |       |       |      
-///     11 +-------+-------+-------+-------+ 15
-///        |       |       |       |       |
-///        |  e5   |  e6   |  e7   |  e8   |
-///        |       |5      |       |       |  
-///      6 +-------+-------+-------+-------+ 10
-///        |       |       |       |       |  
-///        |  e1   |  e2   |  e3   |  e4   |    
-///        |       |       |       |       | 
-///        +-------+-------+-------+-------+   y = bottom
-///        1       2       3       4       5
-///      
-/// -/// Local node numbering: -/// -///
-///        3       4
-///        +-------+     Y
-///        |       |     |
-///        |  e1   |     |
-///        |       |     *--> X
-///        +-------+
-///        1       2
-///      
-/// -/// and the two sets of nodes at y=bottom and y=top are -/// related through constraint relations as follows: -/// \dontinclude UseCase_Rebal_3.cpp -/// \skip Assign constraint relations between nodes -/// \until end snippet -/// -/// The use case passes if the load imbalance of the new partition -/// is below the nominal value of 1.5. -/// -/// See \ref UseCase_Rebal_3.cpp for the complete source listing. -/// diff --git a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_4.cpp b/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_4.cpp deleted file mode 100644 index 6e1bf02c889a..000000000000 --- a/packages/stk/stk_classic/stk_rebalance/use_cases/UseCase_Rebal_4.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- - -using namespace stk_classic::mesh::fixtures; - -typedef stk_classic::mesh::Field ScalarField ; - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - -class GreedySideset : public Partition { - public : - struct MeshInfo { - std::vector mesh_entities; - const VectorField * nodal_coord_ref ; - const ScalarField * elem_weight_ref; - std::vector dest_proc_ids ; - - /** Default Constructor. */ - MeshInfo(): - nodal_coord_ref(NULL), - elem_weight_ref(NULL) {} - - /** Destructor. */ - ~MeshInfo() {} - }; - explicit GreedySideset(ParallelMachine pm, - const stk_classic::mesh::PartVector & surfaces, - mesh::BulkData & bulk_data); - virtual ~GreedySideset(); - virtual void reset_dest_proc_data(); - virtual void set_mesh_info ( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref=NULL); - virtual void determine_new_partition(bool &RebalancingNeeded); - virtual unsigned num_elems() const; - virtual int get_new_partition(stk_classic::mesh::EntityProcVec &new_partition); - virtual bool partition_dependents_needed()const; - bool find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const; - unsigned destination_proc(const unsigned moid) const; - void set_destination_proc(const unsigned moid, const unsigned proc ); - MeshInfo mesh_information_; - unsigned total_number_entities_; - const stk_classic::mesh::PartVector & surfaces_; - mesh::BulkData & bulk_data_; -}; - -GreedySideset::GreedySideset(ParallelMachine pm, - const stk_classic::mesh::PartVector & surfaces, - mesh::BulkData & bulk_data) : - stk_classic::rebalance::Partition(pm), - mesh_information_(), - surfaces_(surfaces), - bulk_data_(bulk_data) {} -GreedySideset::~GreedySideset() {} -void GreedySideset::reset_dest_proc_data() { - const int proc = parallel_machine_rank(comm_); - const unsigned size = mesh_information_.mesh_entities.size(); - mesh_information_.dest_proc_ids.assign(size, proc); -} -void GreedySideset::set_mesh_info ( const std::vector &mesh_entities, - const VectorField * nodal_coord_ref, - const ScalarField * elem_weight_ref){ - MeshInfo mesh_info; - - /* Keep track of the total number of elements. */ - total_number_entities_ = mesh_entities.size(); - - mesh_info.mesh_entities = mesh_entities; - mesh_info.nodal_coord_ref = nodal_coord_ref; - mesh_info.elem_weight_ref = elem_weight_ref; - - /** Default destination for an entity is the processor - that already owns the entity, which is this processor. - The length of the dest_proc_ids vector is the same - length as the mesh_entities vector. - */ - mesh_info.dest_proc_ids.assign(mesh_entities.size(), stk_classic::parallel_machine_rank(comm_)); - - mesh_information_ = mesh_info; -} - -unsigned GreedySideset::num_elems() const {return total_number_entities_ ;} -int GreedySideset::get_new_partition(stk_classic::mesh::EntityProcVec &new_partition){ -std::vector::iterator i=mesh_information_.mesh_entities.begin(); -std::vector ::iterator j=mesh_information_.dest_proc_ids.begin(); - for (;i != mesh_information_.mesh_entities.end(), - j != mesh_information_.dest_proc_ids.end(); - ++i,++j) { - mesh::Entity * mesh_entity = *i; - unsigned proc = *j; - mesh::EntityProc et(mesh_entity, proc); - new_partition.push_back(et); - } - return 0; -} -bool GreedySideset::partition_dependents_needed()const{return true;} - -bool GreedySideset::find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const -{ - unsigned len = mesh_information_.mesh_entities.size(); - for(moid = 0; moid < len; ++moid) - { - if(mesh_information_.mesh_entities[moid] == entity) return true; - } - return false; -} -unsigned GreedySideset::destination_proc(const unsigned moid) const -{ - return mesh_information_.dest_proc_ids[ moid ]; -} -void GreedySideset::set_destination_proc(const unsigned moid, - const unsigned proc ) -{ - mesh_information_.dest_proc_ids[ moid ] = proc; -} - - -void GreedySideset::determine_new_partition(bool &RebalancingNeeded) { - - reset_dest_proc_data(); - - stk_classic::mesh::fem::FEMMetaData & fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data_); - const stk_classic::mesh::EntityRank side_rank = fem_meta.side_rank(); - const stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank(); - - // Select active ghosted side faces. - stk_classic::mesh::Selector selector(!fem_meta.locally_owned_part() & - stk_classic::mesh::selectIntersection(surfaces_)); - - mesh::EntityVector sides; - mesh::get_selected_entities(selector, bulk_data_.buckets(side_rank), sides); - - const unsigned p_rank = bulk_data_.parallel_rank(); - size_t local_changes = 0; - const unsigned nSide = sides.size(); - for(unsigned iSide = 0; iSide < nSide; ++iSide) - { - const mesh::Entity & side = *sides[iSide]; - const unsigned sideProc = side.owner_rank(); - ThrowRequireMsg(sideProc!=p_rank, - "When iterating Non-locally owned sides, found a locally owned side."); - - stk_classic::mesh::PairIterRelation iElem = side.relations(elem_rank); - for ( ; iElem.first != iElem.second; ++iElem.first ) { - const mesh::Entity & elem = *iElem.first->entity(); - unsigned moid; - const bool mesh_entity_found = find_mesh_entity(&elem, moid); - if (mesh_entity_found) { - const unsigned elemProc = elem.owner_rank(); - ThrowRequireMsg(elemProc==p_rank, - "When iterating locally owned elements, found a non-locally owned element."); - const unsigned destProc = destination_proc(moid); - ThrowRequireMsg(destProc==p_rank || destProc==sideProc, - " Sanity check failed: " - "It's possible that an element is connected to " - "two sides that are owned by different procs. We don't " - "yet handle that situation here but we can, at least, " - "detect it. "); - if(elemProc != sideProc) - { - ++local_changes; - set_destination_proc(moid, sideProc); - } - } - } - } - size_t global_changes = 0; - stk_classic::all_reduce_sum (comm_, &local_changes, &global_changes, 1); - RebalancingNeeded = global_changes > 0; -} - -enum { nx = 3, ny = 3 }; - -bool test_greedy_sideset ( stk_classic::ParallelMachine comm ) -{ - unsigned spatial_dimension = 2; - std::vector rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension); - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(spatial_dimension, rank_names); - stk_classic::mesh::MetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - stk_classic::mesh::BulkData bulk_data( meta_data , comm , 100 ); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - const stk_classic::mesh::EntityRank node_rank = fem_meta.node_rank(); - - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData >()); - stk_classic::mesh::Part & quad_part( fem_meta.declare_part("quad", quad_top ) ); - stk_classic::mesh::Part & side_part( fem_meta.declare_part("line", line_top ) ); - VectorField & coord_field( fem_meta.declare_field< VectorField >( "coordinates" ) ); - ScalarField & weight_field( fem_meta.declare_field< ScalarField >( "element_weights" ) ); - - stk_classic::mesh::put_field( coord_field , node_rank , fem_meta.universal_part() ); - stk_classic::mesh::put_field(weight_field , element_rank , fem_meta.universal_part() ); - - fem_meta.commit(); - const unsigned p_rank = bulk_data.parallel_rank(); - bulk_data.modification_begin(); - - if ( !p_rank ) { - - std::vector > quads(nx); - for ( unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny); - - const unsigned nnx = nx + 1 ; - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::EntityId nodes[4] ; - nodes[0] = 1 + ix + iy * nnx ; - nodes[1] = 2 + ix + iy * nnx ; - nodes[2] = 2 + ix + ( iy + 1 ) * nnx ; - nodes[3] = 1 + ix + ( iy + 1 ) * nnx ; - - stk_classic::mesh::Entity &q = stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes ); - quads[ix][iy] = &q; - } - } - - for ( unsigned iy = 0 ; iy < ny ; ++iy ) { - for ( unsigned ix = 0 ; ix < nx ; ++ix ) { - stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ; - stk_classic::mesh::Entity * e = bulk_data.get_entity( element_rank, elem ); - double * const e_weight = stk_classic::mesh::field_data( weight_field , *e ); - *e_weight = 1.0; - } - } - for ( unsigned iy = 0 ; iy <= ny ; ++iy ) { - for ( unsigned ix = 0 ; ix <= nx ; ++ix ) { - stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ; - stk_classic::mesh::Entity * n = bulk_data.get_entity( node_rank, nid ); - double * const coord = stk_classic::mesh::field_data( coord_field , *n ); - coord[0] = .1*ix; - coord[1] = .1*iy; - coord[2] = 0; - } - } - } - - bulk_data.modification_end(); - - // create some sides and faces to rebalance. - stk_classic::mesh::PartVector add_parts; - stk_classic::mesh::create_adjacent_entities(bulk_data, add_parts); - - bulk_data.modification_begin(); - - const stk_classic::mesh::PartVector surfaces(1, &side_part); - { - const stk_classic::mesh::PartVector empty_remove_parts; - stk_classic::mesh::fem::FEMMetaData & fmeta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - const stk_classic::mesh::EntityRank side_rank = fmeta.side_rank(); - stk_classic::mesh::Selector selector2( fmeta.locally_owned_part()); - mesh::EntityVector sides; - mesh::get_selected_entities(selector2, bulk_data.buckets(side_rank), sides); - - const unsigned nSide = sides.size(); - for(unsigned iSide = 0; iSide < nSide; ++iSide) - { - mesh::Entity & side = *sides[iSide]; - if (side.identifier()==7) { - bulk_data.change_entity_parts(side, surfaces, empty_remove_parts); - } - } - } - bulk_data.modification_end(); - - // Zoltan partition is specialized form a virtual base class, stk_classic::rebalance::Partition. - // Other specializations are possible. - Teuchos::ParameterList emptyList; - stk_classic::rebalance::Zoltan zoltan_partition(comm, spatial_dimension, emptyList); - stk_classic::mesh::Selector selector3(fem_meta.locally_owned_part()); - stk_classic::rebalance::rebalance(bulk_data, selector3, &coord_field, NULL, zoltan_partition); - { - const int print_stats = 1; - int nentity = 0; - double entity_wgt = 0; - int ncuts = 0; - double cut_wgt = 0; - int nboundary = 0; - int nadj = 0; - const int ierr = zoltan_partition.evaluate (print_stats, &nentity, &entity_wgt, &ncuts, &cut_wgt, &nboundary, &nadj); - std::cout <<" Information returned from the Zoltan evaluate function:"<entity(); - const unsigned elemProc = elem.owner_rank(); - if (elemProc!=p_rank) { - std::cout <entity(); - const unsigned elemProc = elem.owner_rank(); - if (elemProc!=p_rank) { - std::cerr < - -namespace stk_classic { -namespace rebalance { -namespace use_cases { - - bool test_greedy_sideset ( stk_classic::ParallelMachine comm ); - -} //namespace use_cases -} //namespace rebalance -} //namespace stk_classic - -#endif // Stk_Rebalance_Use_Cases_UseCase_1_hpp - -/// \page stk_rebalance_use_case_4 -/// \ingroup stk_rebalance_use_case_module -/// -/// \section stk_rebalance_use_case_4_description Use Case 4: User-customization following default rebalance -/// -/// This use case demonstrates additional user customization following a -/// default rebalance in order to enforce constraints for new partitions. In -/// this case, the constraint is that two quad4 elements sharing edge #7 -/// be collocated on the same proc following rebalance. This is enforced using -/// a greedy sideset class which inherits the determine_new_partition method. -/// -/// The following quad4 mesh is used in this use case: -/// -/// Global node and element numbering -///
-///
-///     13      14      15      16
-///     +-------+-------+-------+
-///     |       |       |       |
-///     |  e7   |  e8   |  e9   |
-///     |       |       |       |
-///   9 +-------+-------+-------+ 12    Y
-///     |       |       |       |       |
-///     |  e4   |  e5   |  e6   |       |
-///     |       |       |       |       *--> X
-///   5 +-------+-------+-------+ 8
-///     |       |       |       | 
-///     |  e1   |  e2   |  e3   |
-///     |       |       |       | 
-///     +-------+-------+-------+ 
-///     1       2       3       4
-/// 
-/// -/// Local node numbering -///
-///           3       4
-///           +-------+
-///           |       |
-///           |  e1   |
-///           |       |
-///           +-------+
-///           1       2
-/// 
-/// -/// See \ref UseCase_Rebal_4.cpp for the complete source listing. -/// -/// -/// -/// diff --git a/packages/stk/stk_classic/stk_search/CMakeLists.txt b/packages/stk/stk_classic/stk_search/CMakeLists.txt deleted file mode 100644 index 58e1ce3c4b15..000000000000 --- a/packages/stk/stk_classic/stk_search/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -ADD_SUBDIRECTORY(stk_search) - -#TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - diff --git a/packages/stk/stk_classic/stk_search/doc/Doxyfile b/packages/stk/stk_classic/stk_search/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_search/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_search/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_search/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_search/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_search/doc/index.dox b/packages/stk/stk_classic/stk_search/doc/index.dox deleted file mode 100644 index e0d4ef88951d..000000000000 --- a/packages/stk/stk_classic/stk_search/doc/index.dox +++ /dev/null @@ -1,96 +0,0 @@ - -/** @brief Sierra Toolkit */ -namespace stk_classic { -}//namespace stk_classic - -/** - * \mainpage Sierra Toolkit Search Product - * - * \copydoc stk_search_module - * - * \page stk_search_banner Sierra Toolkit Search - * - * \ref stk_search_module "Sierra Toolkit Search" - * - * The Sierra Toolkit Search product provides... - * - * \page stk_search_module Sierra Toolkit Search Product - * - * The Sierra Toolkit Search product provides... - * - * \code - * #include - * #include - * \endcode - * - * where directory is one of the following: - * - *
    - *
  • \ref stk_search_diagnostics_module "diag" - * - * functions and classes that support diagnostic output, traceback and runtime timing and metrics - * - *
- * - * Search How To ... - * - * \copydoc stk_search_howto - * - * \page stk_search_howto Search How To ... - * - * Sierra Tookit Search - * - * - Coarse Search Interface - * - \ref stk_search_coarse_howto_create "Create Coarse Searchers"
- * - \ref stk_search_coarse_howto_use "Use Coarse Searchers"
- * - OctTree - * - \ref stk_search_octtree_howto_create "Use OctTree as coarse search"
- * - \ref stk_search_octtree_howto_use "Use OctTree stand alone"
- * - BIH - * - \ref stk_search_bihtree_howto_create "Use BihTree as coarse search"
- * - \ref stk_search_bihtree_howto_use "Use BihTree stand alone"
- * - ACME - * - \ref stk_search_acme_howto_create "Use ACME as coarse search"
- * - \ref stk_search_acme_howto_use "Use ACME stand alone"
- * - * \defgroup stk_search_module_detail Sierra Toolkit Search - * @{ - * - * \defgroup stk_search_coarse_module Coarse Search - * - * The coarse search module... - * - * blah blah lah - * - * @{ - * \defgroup stk_search_coarse_detail Command Line Options - * \defgroup - * @} - * - * \defgroup diagnostics_module Search Diagnostics - * @{ - * \defgroup stk_search_diag_detail Diagnostics available for search - * \defgroup - * @} - * - * \defgroup stk_search_octtree_module OctTree - * @{ - * \defgroup stk_search_octtree_detail OctTree - * \defgroup - * @} - * - * \defgroup stk_search_bihtree_module BIH - * @{ - * \defgroup stk_search_bihtree_detail BihTree - * \defgroup - * @} - * - * \defgroup stk_search_acme_module ACME - * @{ - * \defgroup stk_search_acme_detail ACME - * \defgroup - * @} - * - * @} - */ - diff --git a/packages/stk/stk_classic/stk_search/stk_search/BihTree.dox b/packages/stk/stk_classic/stk_search/stk_search/BihTree.dox deleted file mode 100644 index 3214bcf8e04e..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/BihTree.dox +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// \addtogroup stk_search_bihtree_detail -/// @{ -/// -/// @brief Searches using bihtree -/// -/// Some descriptive stuff here -/// -/// \anchor stk_search_howto_bihtree -/// For example: -/// -/// \code -/// #include -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// boost::program_options::options_description desc("Use case options"); -/// desc.add_options() -/// ("performance", "run performance test") -/// ("mesh", boost::program_options::value(), "run mesh file performance test"); -/// -/// stk_classic::env::get_options_description().add(desc); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// \endcode -/// -/// -/// Maybe more stuff here... -/// -/// @} -/// - diff --git a/packages/stk/stk_classic/stk_search/stk_search/BihTree.hpp b/packages/stk/stk_classic/stk_search/stk_search/BihTree.hpp deleted file mode 100644 index 880a695f3847..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/BihTree.hpp +++ /dev/null @@ -1,495 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_BihTree_hpp -#define stk_search_BihTree_hpp - -#include - -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace search { -namespace bih { - -class UnitTestBihTree; - -/** Bih tree */ - -template -class BihTree -{ - public: - typedef typename RangeBoundingVolume::Key RangeKey; - - - template - BihTree( - const InputIterator & first, - const InputIterator & last, - unsigned max_depth = 32, - unsigned items_per_leaf = 1 ) : - MAX_DEPTH(max_depth), ITEMS_PER_LEAF(items_per_leaf), m_range(), m_root(), m_depth(0), m_num_nodes(0) - { - m_range.insert(m_range.begin(),first,last); - build_tree(m_root, m_range.begin(), m_range.end(), 0); - } - - /** - * RelationshipContainer can be - * std::vector< RangeBoundingVoulme > - * std::vector< std::pair< DomainBoundingVolume::Key, RangeBoundingVolume::Key> > > - * std::set< std::pair< DomainBoundingVolume::Key, RangeBoundingVolume::Key> > > - */ - template - void intersect( - const DomainBoundingVolume & domain, - RelationshipContainer & relations) const - { - intersect_helper(m_root,domain,relations); - } - - /** - * RelationshipContainer can be - * std::vector< RangeBoundingVoulme > - * std::vector< std::pair< DomainBoundingVolume::Key, RangeBoundingVolume::Key> > > - * std::set< std::pair< DomainBoundingVolume::Key, RangeBoundingVolume::Key> > > - */ - template - void intersect( - const DomainIterator & first, - const DomainIterator & last, - RelationshipContainer & relations) const - { - for (DomainIterator i = first; i != last; ++i) - intersect_helper(m_root,*i,relations); - } - - /** - * RelationshipContainer can be - * std::vector< RangeBoundingVoulme > - * std::vector< std::pair< RangeBoundingVolume::Key, RangeBoundingVolume::Key> > > - * std::set< std::pair< RangeBoundingVolume::Key, RangeBoundingVolume::Key> > > - */ - template - void self_intersect (RelationshipContainer & relations) const { - intersect(m_range.begin(),m_range.end(),relations); - } - - unsigned depth() const { return m_depth; } - unsigned num_nodes() const { return m_num_nodes; } - - const unsigned MAX_DEPTH; - const unsigned ITEMS_PER_LEAF; - - private: - - /** Node for a BihTree. Each Node is 16 bytes. Leaf Nodes store an array of type K. - */ - class Node - { - private: // functions to use inside of BihTree - static const uint64_t LEAF_NODE = 3; - static const uint64_t BIT_MASK = 3; - - Node() - : m_children_ptr(LEAF_NODE) - { - m_data.volumes = 0; - } - - ~Node() { - if (!is_leaf()) // remove volumes - delete [] children(); - } - - /** return what axis the node is split along */ - inline int axis() const { return static_cast(m_children_ptr & BIT_MASK); } - - /** true if the node is a leaf node */ - inline bool is_leaf() const { return (m_children_ptr & BIT_MASK) == LEAF_NODE; } - - /** number of items in the leaf node - * returns -1 if the node is not a leaf node */ - inline int size() const { return is_leaf() ? static_cast(m_children_ptr >> 2) : -1; } - - /** begin of key list - * it is an unchecked error to call begin or end on an interior node */ - inline const RangeBoundingVolume * begin() const { return m_data.volumes; } - - /** end of key list - * it is an unchecked error to call begin or end on an interior node */ - inline const RangeBoundingVolume * end() const { return m_data.volumes + size(); } - - /** if !is_leaf() returns a pointer to a pair of children, otherwise returns NULL */ - inline Node * children() const { return is_leaf() ? 0 : reinterpret_cast(m_children_ptr & ~BIT_MASK); } - - /** left child */ - inline Node & left() const { return children()[0]; } - - /** right child */ - inline Node & right() const { return children()[1]; } - - /** left_max clip plane - * it is an unchecked error to call left_max or right_min on a leaf node */ - inline float left_max() const { return m_data.planes[0]; } - - /** right_min clip plane - * it is an unchecked error to call left_max or right_min on a leaf node */ - inline float right_min() const { return m_data.planes[1]; } - - /** make the current node and interior node */ - inline void make_interior_node(uint64_t axis, const float clipplanes[]) { - Node * child = new Node[2]; - m_children_ptr = reinterpret_cast(child) | axis; - m_data.planes[0] = clipplanes[0]; - m_data.planes[1] = clipplanes[1]; - } - - /** make the current node a leaf node */ - void make_leaf_node(const RangeBoundingVolume * volumes, size_t num) { - // the size is stored in the upper bytes of the children_ptr - m_children_ptr = (num << 2) | LEAF_NODE; - m_data.volumes = volumes; - } - - - /** stores either a pointer to the children or the number of volumes in the leaf in the upper bits - * the lowest 2 bits store the axis */ - uint64_t m_children_ptr; - - union { - const RangeBoundingVolume * volumes ; - float planes[2] ; - }m_data; - - //disallow copy constructor and assignment operator - Node(const Node &); - void operator = (const Node &); - - friend class BihTree; - friend class ::stk_classic::search::bih::UnitTestBihTree; - }; //end class Node - - - private: - - /** build a tree using the middle_longest_side heristic */ - void build_tree( - Node & node, - typename std::vector::iterator begin, - typename std::vector::iterator end, - unsigned current_depth); - - template - void intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::vector > & relations) const; - - template - void intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::set > & relations) const; - - template - void intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::vector & range) const; - private: - - - /** find max value of the bounding boxes along the given axis */ - float find_max( - typename std::vector::iterator begin, - typename std::vector::iterator end, - int axis) const - { - float value = begin->upper(axis); - - for (typename std::vector::const_iterator i = begin+1; i!=end; ++i) { - if ( static_cast(i->upper(axis)) > value) { - value = static_cast(i->upper(axis)); - } - } - return value; - } - - /** find ratio of left to right child using the given split plane and axis */ - float find_ratio( - typename std::vector::iterator begin, - typename std::vector::iterator end, - int axis, - float split_plane) const - { - int count = 0; - for (typename std::vector::const_iterator i = begin; i!=end; ++i) { - if ( static_cast(i->center(axis)) < split_plane) { - ++count; - } - } - float value = static_cast(count)/(end-begin) - 0.5f; - return value >=0 ? value : -1 * value; - } - - /** find min value of the bounding boxes along the given axis */ - float find_min( - typename std::vector::iterator begin, - typename std::vector::iterator end, - int axis) const - { - float value = begin->lower(axis); - - for (typename std::vector::const_iterator i = begin+1; i!=end; ++i) { - if ( static_cast(i->lower(axis)) < value) { - value = static_cast(i->lower(axis)); - } - } - return value; - } - - - bool find_split_plane( - const typename std::vector::iterator begin, - const typename std::vector::iterator end, - int & axis, - typename RangeBoundingVolume::Data & split_plane ) - { - bool split_by_space = true; - axis = 0; - - int size = end - begin; - - typename RangeBoundingVolume::Data length = 0, mean_length = 0, max_length = 0; - - - for (int j = 0; j < RangeBoundingVolume::DIMENSION; ++j) { - typename RangeBoundingVolume::Data min = FLT_MAX, max = -FLT_MAX, temp_mean_length = 0, temp_max_length = 0; - for (typename std::vector::const_iterator i = begin; i!=end; ++i) { - temp_mean_length += i->length(j); - if (i->length(j) > temp_max_length) temp_max_length = i->length(j); - if (i->lower(j) < min) min = i->lower(j); - if (i->upper(j) > max) max = i->upper(j); - } - temp_mean_length /= size; - if (max-min > length) { - length = max-min; - axis = j; - split_plane = min + length/2; - mean_length = temp_mean_length; - max_length = temp_max_length; - } - } - - if (mean_length*8 < max_length) { - split_by_space = false; - split_plane = mean_length*5; - } - - return split_by_space; - } - - void make_leaf( - Node & node, - typename std::vector::iterator begin, - typename std::vector::iterator end ) - { - int num = end - begin; - if (num > 0) { - node.make_leaf_node(&(*begin),num); - } - else { - node.make_leaf_node(0,0); - } - } - - private: - - //member variables - std::vector m_range; - Node m_root; - unsigned m_depth; - unsigned m_num_nodes; - - - //disable copy constructor and assignment operator - explicit BihTree( const BihTree &); - void operator = ( const BihTree &); - - friend class ::stk_classic::search::bih::UnitTestBihTree; -}; - - -template -void BihTree::build_tree( - Node & node, - typename std::vector::iterator begin, - typename std::vector::iterator end, - unsigned current_depth) -{ - //update tree depth - m_depth = current_depth > m_depth ? current_depth : m_depth; - - // make leaf node - if (current_depth >= MAX_DEPTH || end-begin <= static_cast(ITEMS_PER_LEAF)) { - make_leaf(node,begin,end); - return; - } - - typename std::vector::iterator k = end; - typename RangeBoundingVolume::Data split_plane = 0; - int axis = 0; - - bool split_by_space = find_split_plane(begin,end, axis, split_plane); - - if (split_by_space) { // split by space - k = std::partition(begin,end,stk_classic::search::box::compare::Partition(axis,split_plane)); - - float ratio = static_cast(k-begin) / (end-begin); - ratio -= 0.5f; - ratio = ratio >= 0 ? ratio : -1.0f * ratio; - - if (ratio > 0.35f) { - k = begin + (end - begin)/2; - std::nth_element(begin,k,end,stk_classic::search::box::compare::Compare(axis)); - } - } - else { // split by length - k = std::partition(begin,end,stk_classic::search::box::compare::Partition(axis,split_plane)); - } - - float clip_planes[2] = {-FLT_MAX,FLT_MAX}; - - if (k - begin >= 1) {// left child non-empty - clip_planes[0] = find_max(begin,k,axis); - } - - if (end - k >= 1) { // right child non-empty - clip_planes[1] = find_min(k,end,axis); - } - - //make the node an interior node - node.make_interior_node(axis,clip_planes); - - m_num_nodes += 2; - - build_tree( - node.left(), - begin, - k, - current_depth+1 - ); - - build_tree( - node.right(), - k, - end, - current_depth+1 - ); -} - -template -template -void BihTree::intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::vector > & relations) const -{ - //if leaf add items to vector - if (node.is_leaf()) { - if (node.size() > 0 ) { - for( const RangeBoundingVolume * i = node.begin(); i != node.end(); ++i) { - relations.push_back( std::pair(domain.key,i->key) ); - } - } - return; - } - - int axis = node.axis(); - - if (domain.lower(axis) <= node.left_max()) { //go left - intersect_helper( node.left(), domain, relations ); - } - - if (domain.upper(axis) >= node.right_min()) { //go right - intersect_helper( node.right(), domain, relations ); - } - -} - -template -template -void BihTree::intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::set > & relations) const -{ - //if leaf add items to vector - if (node.is_leaf()) { - if (node.size() > 0 ) { - for( const RangeBoundingVolume * i = node.begin(); i != node.end(); ++i) { - relations.insert( std::pair(domain.key,i->key) ); - } - } - return; - } - - int axis = node.axis(); - - if (domain.lower(axis) <= node.left_max()) { //go left - intersect_helper( node.left(), domain, relations ); - } - - if (domain.upper(axis) >= node.right_min()) { //go right - intersect_helper( node.right(), domain, relations ); - } - -} - - -template -template -void BihTree::intersect_helper( - const Node & node, - const DomainBoundingVolume & domain, - std::vector & range) const -{ - //if leaf add items to vector - if (node.is_leaf()) { - if (node.size() > 0 ) { - for( const RangeBoundingVolume * i = node.begin(); i != node.end(); ++i) { - range.push_back(*i); - } - } - return; - } - - int axis = node.axis(); - - if (domain.lower(axis) <= node.left_max()) { //go left - intersect_helper( node.left(), domain, range ); - } - - if (domain.upper(axis) >= node.right_min()) { //go right - intersect_helper( node.right(), domain, range ); - } - -} - -} // namespace bih -} // namespace search -} // namespace stk_classic - -#endif // stk_search_BihTree_hpp diff --git a/packages/stk/stk_classic/stk_search/stk_search/BihTreeParallelOps.hpp b/packages/stk/stk_classic/stk_search/stk_search/BihTreeParallelOps.hpp deleted file mode 100644 index 931ec44ab5ce..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/BihTreeParallelOps.hpp +++ /dev/null @@ -1,189 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_BihTreeParallelOps_hpp -#define stk_search_BihTreeParallelOps_hpp - -#include -#include -#include -#include - -namespace stk_classic { -namespace search { - -template -bool oct_tree_bih_tree_proximity_search( - ParallelMachine arg_comm , - const float * const arg_global_box , - const size_t arg_domain_boxes_number , - const DomainBoundingBox * const arg_domain_boxes , - const size_t arg_range_boxes_number , - const RangeBoundingBox * const arg_range_boxes , - const OctTreeKey * const arg_cuts , - std::vector< std::pair< typename DomainBoundingBox::Key, typename RangeBoundingBox::Key > > & arg_relation , - unsigned * const arg_search_tree_stats = NULL ) -{ - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - enum { Dim = 3 }; - - const unsigned p_rank = parallel_machine_rank( arg_comm ); - - //---------------------------------------------------------------------- - // Search tree defined by oct-tree covering for boxes - - bool local_violations = false ; - bool global_violations = false ; - - SearchTree search_tree ; - - { - stk_classic::OctTreeKey covering[8] ; - unsigned number = 0 ; - - double scale = arg_global_box[0+Dim] - arg_global_box[0]; - for ( unsigned i = 1 ; i < Dim ; ++i ) { - double tst_scale = arg_global_box[i+Dim] - arg_global_box[i]; - if (tst_scale > scale) scale = tst_scale; - } - if (scale > 0.0) // Not an error. Could arise with a point bounding box in the range/domain... - scale = 1.0 / scale; - else - scale = 1.0; - - for ( size_t i = 0 ; i < arg_domain_boxes_number ; ++i ) { - - DomainBoundingBox tmp( arg_domain_boxes[i] ); - - tmp.key.proc = p_rank ; - - float box[6]; - - for (int x=0; x > tmp_relation ; - - { - // Communicate search_tree members - - SearchTree local_tree ; - - std::set< std::pair > local_relation ; - - if ( arg_cuts ) { - global_violations = - communicate( arg_comm , arg_cuts , search_tree , local_tree , - local_violations ); - } - else { - const double tolerance = 0.001 ; - - std::vector< stk_classic::OctTreeKey > cuts ; - - oct_tree_partition( arg_comm , search_tree , tolerance , cuts ); - - global_violations = - communicate(arg_comm , & cuts[0] , search_tree , local_tree , - local_violations ); - } - - // Local proximity search with received members - - if ( arg_search_tree_stats ) { - search_tree_statistics( arg_comm , local_tree , - arg_search_tree_stats ); - } - - std::set > domain; - std::set > range; - - for (typename SearchTree::iterator i = local_tree.begin(); i != local_tree.end(); ++i) { - //insert domain list - std::list & domain_list = i->second.first; - for (typename std::list::iterator j = domain_list.begin(); j != domain_list.end(); ++j) - domain.insert(*j); - - //insert range list - std::list & range_list = i->second.second; - for (typename std::list::iterator j = range_list.begin(); j != range_list.end(); ++j) - range.insert(*j); - } - - stk_classic::search::bih::BihTree tree(range.begin(),range.end()); - for (typename std::set >::iterator i = domain.begin(); - i != domain.end() ; ++i) - { - tree.intersect(*i,local_relation); - } - - - - - // Communicate relations back to domain and range processors - - communicate( arg_comm , local_relation , tmp_relation ); - } - - arg_relation.clear(); - arg_relation.reserve( tmp_relation.size() ); - - typename std::set< std::pair >::iterator ir ; - for ( ir = tmp_relation.begin() ; ir != tmp_relation.end() ; ++ir ) { - arg_relation.push_back( *ir ); - } - return global_violations ; -} - -} //namespace search -} //namespace stk_classic -#endif //stk_search_BihTreeParallelOps_hpp diff --git a/packages/stk/stk_classic/stk_search/stk_search/BoundingBox.hpp b/packages/stk/stk_classic/stk_search/stk_search/BoundingBox.hpp deleted file mode 100644 index bc4196669140..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/BoundingBox.hpp +++ /dev/null @@ -1,314 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_BoundingBox_hpp -#define stk_search_BoundingBox_hpp - -#include -#include -#include -#include - -namespace stk_classic { -namespace search { -namespace box { - -template - struct PointBoundingBox; - -template - struct SphereBoundingBox; - -template - struct AxisAlignedBoundingBox; - -template -struct PointBoundingBox -{ - typedef K Key; - typedef T Data; - - const static int DIMENSION = Dim; - - inline Data lower(int axis) const { return center[axis]; } - inline Data middle(int axis) const { return center[axis]; } - inline Data upper(int axis) const { return center[axis]; } - - inline Data length(int /* axis */ = 0) const { return 0; } - - PointBoundingBox() - : center(), key() - {} - - PointBoundingBox(const Data center_[], const Key & key_) - : center(), key(key_) - { - set_center(center_); - } - - PointBoundingBox(const PointBoundingBox &point_) - : center(), key(point_.key) - { - set_center(point_.center); - } - - PointBoundingBox & operator = ( const PointBoundingBox &point_) { - if (this != &point_) { - set_center(point_.center); - key = point_.key; - } - return *this; - } - - inline - void set_center(const Data center_[]) { - for (int i = 0; i & point_) const { - Data dist = 0; - for (int i=0; i & sphere_) const { - Data tmp = 0; - Data dist = 0; - for (int i=0; i & box_) const { - for (int i=0; i box_.upper(i)) { - return false; - } - } - return true; - } - - Data center[DIMENSION]; - Key key; - -}; - -template -struct SphereBoundingBox -{ - typedef K Key; - typedef T Data; - - const static int DIMENSION = Dim; - - inline Data lower(int axis) const { return center[axis] - radius; } - inline Data middle(int axis) const { return center[axis]; } - inline Data upper(int axis) const { return center[axis] + radius; } - - inline Data length(int /* axis */ = 0) const { return 2*radius; } - - inline void expand(const Data delta) { radius += delta; } - - - SphereBoundingBox() - : center(), radius(0), key() - {} - - SphereBoundingBox(const SphereBoundingBox &sphere_) - : center(), radius(sphere_.radius), key(sphere_.key) - { - set_center(sphere_.center); - } - - SphereBoundingBox & operator = ( const SphereBoundingBox &sphere_) { - if (this != &sphere_) { - set_center(sphere_.center); - radius = sphere_.radius; - key = sphere_.key; - } - return *this; - } - - SphereBoundingBox( const PointBoundingBox & point_ ) - : center(), radius(0), key(point_.key) - { - set_center(point_.center); - } - - SphereBoundingBox( const AxisAlignedBoundingBox & box_) - : center(), radius(0), key(box_.key) - { - Data dist; - Data radius_squared = 0; - for (int i=0; i & point_) const { - return point_.intersect(*this); - } - - bool intersect( const SphereBoundingBox & sphere_) const { - Data tmp = 0; - Data dist = 0; - for (int i=0; i & box_) const { - Data tmp = 0; - Data dist = 0; - for (int i=0; i box_.upper(i)) { - tmp = middle(i) - box_.upper(i); - dist += tmp*tmp; - } - } - - return dist <= radius*radius; - } - Data center[DIMENSION]; - Data radius; - Key key; - -}; - - -template -struct AxisAlignedBoundingBox -{ - typedef K Key; - typedef T Data; - - const static int DIMENSION = Dim; - - inline Data lower(int axis) const { return box[axis]; } - inline Data middle(int axis) const { return lower(axis) + length(axis)/2; } - inline Data upper(int axis) const { return box[axis+DIMENSION]; } - - inline Data length(int axis) const { return upper(axis) - lower(axis); } - - inline void expand(const Data delta) { - for (int i=0; i & point_) - : box(), key(point_.key) - { - for (int i=0; i & sphere_) - : box(), key(sphere_.key) - { - for (int i=0; i & point_) const { - return point_.intersect(*this); - } - - inline - bool intersect( const SphereBoundingBox & sphere_) const { - return sphere_.intersect(*this); - } - - bool intersect( const AxisAlignedBoundingBox & box_) const { - for (int i=0; i box_.upper(i)) return false; - } - return true; - } - - Data box[2*DIMENSION]; - Key key; - -}; - - - -} // namespace box -} // namespace search -} // namespace stk_classic - -#endif // stk_search_BoundingBox_hpp diff --git a/packages/stk/stk_classic/stk_search/stk_search/BoundingBoxCompare.hpp b/packages/stk/stk_classic/stk_search/stk_search/BoundingBoxCompare.hpp deleted file mode 100644 index 368d9376ce96..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/BoundingBoxCompare.hpp +++ /dev/null @@ -1,149 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_BoundingBoxCompare_hpp -#define stk_search_BoundingBoxCompare_hpp - -namespace stk_classic { -namespace search { -namespace box { -namespace compare{ - -enum { -LOWER = 0, -MIDDLE = 1, -UPPER = 2, -LENGTH = 3, -KEY = 4 -}; - -template -class Compare; - -template -class Partition; - -template -class Compare { - public: - Compare(int axis) : m_axis(axis) {} - inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const { - return a.lower(m_axis) < b.lower(m_axis); - } - private: - const int m_axis; -}; - -template -class Compare { - public: - Compare(int axis) : m_axis(axis) {} - inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const { - return a.upper(m_axis) < b.upper(m_axis); - } - private: - const int m_axis; -}; - -template -class Compare { - public: - Compare(int axis) : m_axis(axis) {} - inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const { - return a.middle(m_axis) < b.middle(m_axis); - } - private: - const int m_axis; -}; - -template -class Compare { - public: - Compare(int axis) : m_axis(axis) {} - inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const { - return a.length(m_axis) < b.length(m_axis); - } - private: - const int m_axis; -}; - -template -class Compare { - public: - Compare(int /*axis*/ = 0) {} - inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const { - return a.key < b.key; - } - private: -}; - -template -class Partition { - public: - Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {} - inline bool operator ()(const BoundingBox &a) const { - return a.lower(m_axis) < m_split_plane; - } - private: - const int m_axis; - typename BoundingBox::Data m_split_plane; -}; - -template -class Partition { - public: - Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {} - inline bool operator ()(const BoundingBox &a) const { - return a.upper(m_axis) < m_split_plane; - } - private: - const int m_axis; - typename BoundingBox::Data m_split_plane; -}; - -template -class Partition { - public: - Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {} - inline bool operator ()(const BoundingBox &a) const { - return a.middle(m_axis) < m_split_plane; - } - private: - const int m_axis; - typename BoundingBox::Data m_split_plane; -}; - -template -class Partition { - public: - Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {} - inline bool operator ()(const BoundingBox &a) const { - return a.length(m_axis) < m_split_plane; - } - private: - const int m_axis; - typename BoundingBox::Data m_split_plane; -}; - -template -class Partition { - public: - Partition(typename BoundingBox::Key split_plane) : m_split_plane(split_plane) {} - inline bool operator ()(const BoundingBox &a) const { - return a.key < m_split_plane; - } - private: - typename BoundingBox::Key m_split_plane; -}; - -} // namespace compare -} // namespace box -} // namespace search -} // namespace stk_classic - -#endif // stk_search_BoundingBoxCompare_hpp diff --git a/packages/stk/stk_classic/stk_search/stk_search/CMakeLists.txt b/packages/stk/stk_classic/stk_search/stk_search/CMakeLists.txt deleted file mode 100644 index 62e9b601e1a4..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/CMakeLists.txt +++ /dev/null @@ -1,65 +0,0 @@ - - -ADD_SUBDIRECTORY(diag) - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -BihTree.hpp -BoundingBoxCompare.hpp -CoarseSearch.hpp -OctTree.hpp -SearchTypes.hpp -BihTreeParallelOps.hpp -BoundingBox.hpp -IdentProc.hpp -OctTreeOps.hpp - ) - -APPEND_SET(SOURCES -OctTree.cpp -OctTreeOps.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_search - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_search) diff --git a/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.dox b/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.dox deleted file mode 100644 index 713981aa56d1..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.dox +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// \addtogroup stk_search_octtree_detail -/// @{ -/// -/// @brief Searches using octtree -/// -/// Some descriptive stuff here -/// -/// \anchor stk_search_howto_octtree -/// For example: -/// -/// \code -/// #include -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// boost::program_options::options_description desc("Use case options"); -/// desc.add_options() -/// ("performance", "run performance test") -/// ("mesh", boost::program_options::value(), "run mesh file performance test"); -/// -/// stk_classic::env::get_options_description().add(desc); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// \endcode -/// -/// -/// Maybe more stuff here... -/// -/// @} -/// - diff --git a/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.hpp b/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.hpp deleted file mode 100644 index b010d491b526..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/CoarseSearch.hpp +++ /dev/null @@ -1,159 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_CoarseSearch_hpp -#define stk_search_CoarseSearch_hpp - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace search { - -// Structure to hold factory specification -struct FactoryOrder { - // Enumerate search algorithms - enum Algorithm {OCTREE, BIHTREE}; - - // Define virtual base class to derive holder for input processor cuts. - class Cuts { - Cuts(){} - // assignment operator not needed - // copy constructor not needed - virtual ~Cuts(); - }; - - Algorithm m_algorithm; - stk_classic::ParallelMachine m_communicator; - Cuts * m_cuts; - unsigned * m_search_tree_stats; - unsigned m_debug_level; - FactoryOrder() : - m_algorithm (OCTREE), - m_communicator (MPI_COMM_SELF), - m_cuts (NULL), - m_search_tree_stats(NULL), - m_debug_level (0) - {} -}; - -template -bool parallel_bihtree_search( - std::vector > & domain_to_range_keys, - const std::vector &range, - const std::vector &domain, - const FactoryOrder & order) -{ - - //find the global box - std::vector global_box(6); - stk_classic::search::box_global_bounds(order.m_communicator, - domain.size() , - &domain[0] , - range.size(), - &range[0], - &global_box[0]); - - // - stk_classic::search::oct_tree_bih_tree_proximity_search(order.m_communicator, - &global_box[0], - domain.size() , - &domain[0] , - range.size(), - &range[0], - NULL, - domain_to_range_keys , - order.m_search_tree_stats); - - return true; -} - - -template -bool coarse_search_bihtree( - std::vector > & domain_to_range_keys, - const std::vector &range, - const std::vector &domain, - const FactoryOrder & order) -{ - const unsigned p_size = parallel_machine_size( order.m_communicator ); - //const unsigned p_rank = parallel_machine_rank( order.m_communicator ); - - if (p_size == 1) { - bih::BihTree tree(range.begin(),range.end()); - unsigned size = domain.size(); - for (unsigned i = 0; i < size ; ++i) { - tree.intersect(domain[i],domain_to_range_keys); - } - } - else { - parallel_bihtree_search(domain_to_range_keys,range,domain,order); - } - return true; -} - -template -bool coarse_search_octree( - std::vector > & domain_to_range_keys, - const std::vector &range, - const std::vector &domain, - const FactoryOrder & order) -{ - - std::vector global_box(6); - stk_classic::search::box_global_bounds(order.m_communicator, - domain.size() , - &domain[0] , - range.size(), - &range[0], - &global_box[0]); - - stk_classic::search::oct_tree_proximity_search(order.m_communicator, - &global_box[0], - domain.size() , - &domain[0] , - range.size(), - &range[0], - NULL, - domain_to_range_keys , - order.m_search_tree_stats); - return true; -} - -template -bool coarse_search( - std::vector > & domain_to_range_keys, - const std::vector &range, - const std::vector &domain, - const FactoryOrder & order) -{ - switch (order.m_algorithm) { - case FactoryOrder::BIHTREE: - return coarse_search_bihtree(domain_to_range_keys,range,domain,order); - case FactoryOrder::OCTREE: - return coarse_search_octree(domain_to_range_keys,range,domain,order); - break; - } - return false; -} - - -} // namespace search -} // namespace stk_classic - -#endif // stk_search_CoarseSearch_hpp diff --git a/packages/stk/stk_classic/stk_search/stk_search/IdentProc.hpp b/packages/stk/stk_classic/stk_search/stk_search/IdentProc.hpp deleted file mode 100644 index 301b3bb428f9..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/IdentProc.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_IdentProc_hpp -#define stk_search_IdentProc_hpp - -#include -#include - -#include -#include - -namespace stk_classic { -namespace search { -namespace ident { - -/** - * @brief Class template IdentProc. Template parallel identification used for search, sorts first by identifier and then processor. - * - * K and P need to provide a default constructor, copy constructor, assignment operator, less than operator (<), and stream insertion operator (<<). - */ -template -struct IdentProc { - - typedef K Key; - typedef P Proc; - - /** - * Creates a new IdentProc instance. - * - */ - IdentProc() - : ident(), - proc() - {} - - /** - * Destroys a IdentProc instance. - * - */ - ~IdentProc() - {} - - /** - * Creates a new IdentProc instance. - * - * @param rhs an IdentProc const ... - * - */ - IdentProc( const IdentProc & rhs ) - : ident(rhs.ident), - proc(rhs.proc) - {} - - /** - * Creates a new IdentProc instance. - * - * @param i an unsigned int ... - * - * @param p an unsigned int ... - * - */ - IdentProc( Key i , Proc p ) - : ident(i), - proc(p) - {} - - /** - * @brief Member function = ... - * - * @param rhs an IdentProc const ... - * - * @return an IdentProc ... - */ - IdentProc & operator = ( const IdentProc & rhs ) { - ident = rhs.ident ; - proc = rhs.proc ; - return *this ; - } - /** - * @brief Member function == ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator==( const IdentProc & rhs ) const { - return !( (ident < rhs.ident || rhs.ident < ident) || - (proc < rhs.proc || rhs.proc < proc ) ); - } - - /** - * @brief Member function < ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator<( const IdentProc & rhs ) const { - return ident < rhs.ident || (!(rhs.ident < ident) && proc < rhs.proc); - } - - /** - * @brief Member function != ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator!=( const IdentProc &rhs ) const { - return ( (ident < rhs.ident || rhs.ident < ident) || - (proc < rhs.proc || rhs.proc < proc ) ); - } - - /** - * @brief Member function > ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator>( const IdentProc &rhs ) const{ - return rhs < *this; - } - - /** - * @brief Member function <= ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator<=( const IdentProc &rhs ) const { - return !(rhs < *this); - } - - /** - * @brief Member function >= ... - * - * @param rhs an IdentProc const ... - * - * @return a bool ... - */ - inline bool operator>=(const IdentProc &rhs ) const { - return !(*this < rhs); - } - - - Key ident; ///< Identifier - Proc proc; ///< Processor -}; - - -template -std::ostream& operator<<(std::ostream &dout, const IdentProc &ident_proc){ - dout << "id " << ident_proc.ident << ", proc " << ident_proc.proc; - return dout; -} - - -} // namespace ident -} // namespace search -} // namespace stk_classic - -#endif diff --git a/packages/stk/stk_classic/stk_search/stk_search/OctTree.cpp b/packages/stk/stk_classic/stk_search/stk_search/OctTree.cpp deleted file mode 100644 index 668ef8a3d6b4..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/OctTree.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* stk : Parallel Heterogneous Dynamic unstructured Mesh */ -/* Copyright (2007) Sandia Corporation */ -/* */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* */ -/* This library is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as */ -/* published by the Free Software Foundation; either version 2.1 of the */ -/* License, or (at your option) any later version. */ -/* */ -/* This library is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ -/* Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public */ -/* License along with this library; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ -/* USA */ -/*------------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date January 2007 - */ - -#include -#include -#include -#include - -namespace std { - -ostream & operator << ( ostream & os , const stk_classic::OctTreeKey & otk ) -{ - unsigned j = 0 ; - - while ( j < stk_classic::OctTreeKey::MaxDepth ) { - os << otk.index(++j); - } - - return os ; -} - -} - -namespace stk_classic { - -enum { OK = StaticAssert< OctTreeKey::NWord == 2 >::OK }; - -namespace { - void throw_index( const unsigned d , const unsigned i ) - { - std::ostringstream msg ; - msg << "OctTree.cpp: index[" << d << "] = " << i << " is out of range [1..8]" ; - throw std::range_error( msg.str() ); - } - - void throw_depth( const unsigned min_depth, const unsigned depth ) - { - const unsigned m = stk_classic::OctTreeKey::MaxDepth ; - std::ostringstream msg ; - msg << "OctTree.cpp: depth = " << depth << " is out of range [" << min_depth << ".." << m << "]" ; - throw std::range_error( msg.str() ); - } -} - -unsigned OctTreeKey::depth() const -{ - const unsigned which = m_value[1] ? 1 : 0 ; - const unsigned val = m_value[which] ; - - int d = IndexPerWord ; - while ( d-- && ( val & ( MaskIndex << ( BitsPerIndex * d ) ) ) ); - return ( which + 1 ) * IndexPerWord - ( d + 1 ); -} - -unsigned OctTreeKey::index( const unsigned Depth ) const -{ - if ( Depth < 1 || MaxDepth < Depth ) { throw_depth( 1, Depth ); } - - const unsigned which = ( Depth - 1 ) / IndexPerWord ; - const unsigned shift = BitsPerWord - - BitsPerIndex * ( Depth % IndexPerWord ) ; - - return ( m_value[ which ] >> shift ) & MaskIndex ; -} - -OctTreeKey & OctTreeKey::clear_index( const unsigned Depth ) -{ - if ( Depth < 1 || MaxDepth < Depth ) { throw_depth( 1, Depth ); } - - const value_type m = MaskIndex ; - const unsigned which = ( Depth - 1 ) / IndexPerWord ; - const unsigned shift = BitsPerWord - - BitsPerIndex * ( Depth % IndexPerWord ) ; - const unsigned mask = ~( m << shift ); - - m_value[ which ] &= mask ; - - return *this ; -} - -OctTreeKey & -OctTreeKey::set_index( const unsigned Depth , const unsigned Index ) -{ - if ( Depth < 1 || MaxDepth < Depth ) { throw_depth( 1, Depth ); } - if ( Index < 1 || 8 < Index ) { throw_index( Depth , Index ); } - - const value_type m = MaskIndex ; - const unsigned which = ( Depth - 1 ) / IndexPerWord ; - const unsigned shift = BitsPerWord - - BitsPerIndex * ( Depth % IndexPerWord ) ; - - ( m_value[which] &= ~( m << shift ) ) |= Index << shift ; - - return *this ; -} - -OctTreeKey & -OctTreeKey::set_value( const unsigned * val ) -{ - Copy( m_value , 0u ); - - for ( unsigned d = 1 ; d <= MaxDepth ; ++d ) { - const unsigned which = ( d - 1 ) / IndexPerWord ; - const unsigned shift = BitsPerWord - BitsPerIndex * ( d % IndexPerWord ) ; - const unsigned index = ( val[ which ] >> shift ) & MaskIndex ; - - if ( 8 < index ) { throw_index( d , index ); } - - m_value[ which ] |= index << shift ; - } - return *this ; -} - -bool OctTreeKey::intersect( const OctTreeKey & k ) const -{ - const unsigned which = m_value[0] != k.m_value[0] ? 0 : ( - m_value[1] != k.m_value[1] ? 1 : 2 ); - - bool result = which == 2 ; - - if ( ! result ) { - const value_type lval = m_value[which]; - const value_type rval = k.m_value[which]; - - result = true ; - for ( unsigned d = IndexPerWord ; result && d ; ) { - --d ; - const value_type mask = MaskIndex << ( BitsPerIndex * d ); - const value_type l = lval & mask ; - const value_type r = rval & mask ; - if ( l && r ) { result = l == r ; } - else { d = 0 ; } - } - } - return result ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -const unsigned tree_size[11] = { - OctTreeSize< 0>::value , - OctTreeSize< 1>::value , - OctTreeSize< 2>::value , - OctTreeSize< 3>::value , - OctTreeSize< 4>::value , - OctTreeSize< 5>::value , - OctTreeSize< 6>::value , - OctTreeSize< 7>::value , - OctTreeSize< 8>::value , - OctTreeSize< 9>::value , - OctTreeSize<10>::value -}; - -} - -unsigned oct_tree_size( const unsigned Depth ) -{ - if ( stk_classic::OctTreeKey::MaxDepth < Depth ) - { throw_depth( 0, Depth ); } - - return tree_size[ Depth ]; -} - -unsigned oct_tree_offset( const unsigned Depth , const OctTreeKey & k ) -{ - if ( stk_classic::OctTreeKey::MaxDepth < Depth ) - { throw_depth( 0, Depth ); } - - unsigned index = 0 ; - - unsigned d = Depth ; - - while ( d ) { - --d ; - const unsigned i = k.index( Depth - d ); - if ( i ) { index += 1 + ( i - 1 ) * tree_size[ d ] ; } - else { d = 0 ; } // Stop at a zero index - } - - return index ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -OctTreeKey hsfc3d( const unsigned Depth , const unsigned * const coord ) -{ - // Gray & Inverse Gray coding for 3D octree - -/* - const unsigned gray_fwd[8] = { 0 , 1 , 3 , 2 , 6 , 7 , 5 , 4 }; -*/ - const unsigned gray_inv[8] = { 0 , 1 , 3 , 2 , 7 , 6 , 4 , 5 }; - - // Three dimensional HSFC rotation data - - const unsigned hsfc3d_rotation_perm[8][3] = - { /* 0 */ { 2 , 1 , 0 } , - /* 1 */ { 0 , 2 , 1 } , - /* 2 */ { 0 , 1 , 2 } , - /* 3 */ { 2 , 0 , 1 } , - /* 4 */ { 2 , 0 , 1 } , - /* 5 */ { 0 , 1 , 2 } , - /* 6 */ { 0 , 2 , 1 } , - /* 7 */ { 2 , 1 , 0 } }; - - const unsigned hsfc3d_rotation_flip[8][3] = - { /* 0 */ { 0 , 0 , 0 } , - /* 1 */ { 0 , 0 , 0 } , - /* 2 */ { 0 , 0 , 0 } , - /* 3 */ { 1 , 1 , 0 } , - /* 4 */ { 0 , 1 , 1 } , - /* 5 */ { 0 , 0 , 0 } , - /* 6 */ { 0 , 1 , 1 } , - /* 7 */ { 1 , 0 , 1 } }; - - OctTreeKey key ; - - // Initial rotation - - unsigned axis[3] ; - - axis[0] = 0 << 1 ; - axis[1] = 1 << 1 ; - axis[2] = 2 << 1 ; - - for ( unsigned d = 1 ; d <= Depth ; ++d ) { - - const unsigned s = OctTreeKey::BitsPerWord - d ; - - // The ordinal for this depth - - const unsigned ord = gray_inv[ - (((( coord[ axis[0] >> 1 ] >> s ) ^ axis[0] ) & 01 ) << 0 ) | - (((( coord[ axis[1] >> 1 ] >> s ) ^ axis[1] ) & 01 ) << 1 ) | - (((( coord[ axis[2] >> 1 ] >> s ) ^ axis[2] ) & 01 ) << 2 ) ]; - - key.set_index( d , ord + 1 ); - - // Determine the recursive rotation for the next ordinal - { - const unsigned * const p = hsfc3d_rotation_perm[ ord ] ; - const unsigned * const f = hsfc3d_rotation_flip[ ord ] ; - - unsigned tmp[3] ; - - tmp[0] = axis[0] ; - tmp[1] = axis[1] ; - tmp[2] = axis[2] ; - - axis[0] = tmp[ p[0] ] ^ f[0] ; - axis[1] = tmp[ p[1] ] ^ f[1] ; - axis[2] = tmp[ p[2] ] ^ f[2] ; - } - } - - return key ; -} - - -} - - diff --git a/packages/stk/stk_classic/stk_search/stk_search/OctTree.dox b/packages/stk/stk_classic/stk_search/stk_search/OctTree.dox deleted file mode 100644 index 713981aa56d1..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/OctTree.dox +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// \addtogroup stk_search_octtree_detail -/// @{ -/// -/// @brief Searches using octtree -/// -/// Some descriptive stuff here -/// -/// \anchor stk_search_howto_octtree -/// For example: -/// -/// \code -/// #include -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// boost::program_options::options_description desc("Use case options"); -/// desc.add_options() -/// ("performance", "run performance test") -/// ("mesh", boost::program_options::value(), "run mesh file performance test"); -/// -/// stk_classic::env::get_options_description().add(desc); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// \endcode -/// -/// -/// Maybe more stuff here... -/// -/// @} -/// - diff --git a/packages/stk/stk_classic/stk_search/stk_search/OctTree.hpp b/packages/stk/stk_classic/stk_search/stk_search/OctTree.hpp deleted file mode 100644 index 89538f2519d4..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/OctTree.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_OctTree_hpp -#define stk_search_OctTree_hpp - -#include -#include -#include -#include - -namespace stk_classic { - -class OctTreeKey ; - -} - -namespace std { - -ostream & operator << ( ostream & , const stk_classic::OctTreeKey & otk); - -} - -namespace stk_classic { - -/** \ingroup util_module - * \class OctTreeKey - * \brief Type for identifying a particular node in a hierarchical oct-tree - */ -class OctTreeKey { -public: - /** \brief Integer type for the key components and indices */ - typedef unsigned value_type ; - enum { MaxDepth = 16 }; - enum { MaskIndex = 0x0f }; - enum { BitsPerIndex = 4 }; - enum { BitsPerWord = std::numeric_limits::digits }; - enum { IndexPerWord = BitsPerWord / BitsPerIndex }; - enum { NWord = MaxDepth / IndexPerWord }; - enum { OKBits = StaticAssert< 0 == BitsPerWord % BitsPerIndex >::OK }; - enum { OKWord = StaticAssert< 0 == MaxDepth % IndexPerWord >::OK }; -private: - value_type m_value[ NWord ]; -public: - - /** \brief Default construct to the root node */ - OctTreeKey() : m_value() - { Copy( m_value , 0u ); } - - /** \brief Copy construct */ - OctTreeKey( const OctTreeKey & k ) : m_value() - { Copy( m_value , k.m_value ); } - - /** \brief Assignment */ - OctTreeKey & operator = ( const OctTreeKey & k ) - { Copy( m_value , k.m_value ); return *this ; } - - /** \brief Query depth of this key */ - unsigned depth() const ; - - /** \brief Index of the key at the depth [1..8] - * A zero value indicates it is not defined at that depth. - */ - unsigned index( const unsigned Depth ) const ; - - /** \brief Clear index at depth */ - OctTreeKey & clear_index( const unsigned Depth ); - - /** \brief Set index at depth */ - OctTreeKey & set_index( const unsigned Depth , const unsigned Index); - - /** \brief Query raw value */ - const value_type * value() const { return m_value ; } - - /** \brief Set raw value */ - OctTreeKey & set_value( const value_type * val); - - /** \brief Intersects if either key contains the other. */ - bool intersect( const OctTreeKey & k ) const ; -}; - -/** \brief Equality test */ -inline bool operator == ( const OctTreeKey & l, const OctTreeKey & r ) - { return Compare::equal( l.value() , r.value() ); } - -/** \brief Inequality test */ -inline bool operator != ( const OctTreeKey & l, const OctTreeKey & r ) - { return Compare::not_equal( l.value() , r.value() ); } - -/** \brief Comparison using depth-first full ordering */ -inline bool operator < ( const OctTreeKey & l, const OctTreeKey & r ) - { return Compare::less( l.value() , r.value()) ; } - -//---------------------------------------------------------------------- - -/** \ingroup util_module - * \brief Generate a 3D Hilbert space filling curve oct-tree key from - * an integer XYZ coordinate. - * \param Depth Depth for the generated key. - * \param coord XYZ coordinates in the range [0u:~0u]. - */ -OctTreeKey hsfc3d( const unsigned Depth , const unsigned * const coord ); - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template struct OctTreeSize ; - -template<> -struct OctTreeSize<0> -{ enum { value = 1 }; }; - -template -struct OctTreeSize -{ - enum { MaxDepth = 10 , N = Depth }; // Size representable by an unsigned int - - enum { OK = StaticAssert< N <= MaxDepth >::OK }; - - enum { value = 1 + 8 * OctTreeSize::value }; -}; - -/** \brief Number of nodes in an oct-tree of a given depth */ -unsigned oct_tree_size( const unsigned Depth ); - -/** \brief Offset of a oct-tree node in a dense tree of a given depth. */ -unsigned oct_tree_offset( const unsigned Depth , const OctTreeKey & k); -} - -#endif - diff --git a/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.cpp b/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.cpp deleted file mode 100644 index eafa2c7b276b..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* stk : Parallel Heterogneous Dynamic unstructured Mesh */ -/* Copyright (2007) Sandia Corporation */ -/* */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* */ -/* This library is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as */ -/* published by the Free Software Foundation; either version 2.1 of the */ -/* License, or (at your option) any later version. */ -/* */ -/* This library is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ -/* Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public */ -/* License along with this library; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ -/* USA */ -/*------------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date January 2007 - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace search { -namespace { - -inline unsigned int log2(unsigned int x) -{ - unsigned int l=0; - if(x >= 1<<16) { x>>=16; l|=16; } - if(x >= 1<< 8) { x>>= 8; l|= 8; } - if(x >= 1<< 4) { x>>= 4; l|= 4; } - if(x >= 1<< 2) { x>>= 2; l|= 2; } - if(x >= 1<< 1) { l|= 1; } - return l; -} - -} - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -bool hsfc_box_covering( const float * const global_box , - const float * const small_box , - stk_classic::OctTreeKey * const covering , - unsigned & number, - double scale) -{ - enum { Dimension = 3 }; - enum { Combinations = 8 }; - - const double min = std::numeric_limits::epsilon(); - const double max = 1.0 - min ; - - // Determine the unit-box bounds and bisection depth for the box - - double ubox_low[ Dimension ] ; - double ubox_up[ Dimension ] ; - - bool valid = true ; - - // Determine unit box and is maximum length - // The box is bounded by [eps,1-eps]. - - double unit_size = 0.0 ; - - for ( unsigned i = 0 ; i < Dimension ; ++i ) { - - const float global_low = global_box[i] ; - const float global_up = global_box[i+Dimension] ; - const float small_low = small_box[i] ; - const float small_up = small_box[i+Dimension] ; - - if ( small_up < global_low ) { - // Entirely less than 'min' - ubox_low[i] = ubox_up[i] = min ; - valid = false ; - } - else if ( global_up < small_low ) { - // Entirely greater than 'max' - ubox_low[i] = ubox_up[i] = max ; - valid = false ; - } - else { - double unit_low = ( small_low - global_low ) * scale ; - double unit_up = ( small_up - global_low ) * scale ; - - if ( unit_low < min ) { - unit_low = min ; - valid = false ; - } - - if ( max < unit_up ) { - unit_up = max ; - valid = false ; - } - - if ( unit_up < unit_low ) { - // A negative volume, consider it a point at the lower - unit_up = unit_low ; - valid = false ; - } - else { - const double tmp_size = unit_up - unit_low ; - if ( unit_size < tmp_size ) { unit_size = tmp_size ; } - } - - ubox_low[i] = unit_low ; - ubox_up[i] = unit_up ; - } - } - - // Depth is determined by smallest cell depth - // that could contain the small_box - - unsigned depth = stk_classic::OctTreeKey::MaxDepth ; - - if ( 0 < unit_size ) { - const unsigned size_inv = static_cast(1.0 / unit_size); - depth = log2(size_inv); - if (depth > stk_classic::OctTreeKey::MaxDepth) depth = stk_classic::OctTreeKey::MaxDepth; - } - - // Determine the oct-tree nodes for each key - - const unsigned shift = stk_classic::OctTreeKey::BitsPerWord - depth ; - const unsigned num_cell = 1 << depth ; - - // At most two cells in each axis at this depth - - unsigned coord_low[ Dimension ]; - unsigned coord_up[ Dimension ]; - - for ( unsigned i = 0 ; i < Dimension ; ++i ) { - const unsigned low = static_cast( ubox_low[i] * num_cell ); - const unsigned up = static_cast( ubox_up[i] * num_cell ); - - if ( low + 1 < up ) { - std::string msg("stk_classic::hsfc_box_covering FAILED : depth determination logic error"); - throw std::logic_error( msg ); - } - - coord_low[i] = low << shift ; - coord_up[i] = up << shift ; - } - - unsigned n = 0 ; - - // Combination 0. No duplicate possible, so pull out of loop. - covering[n] = hsfc3d( depth , coord_low ); - ++n ; - - for ( unsigned i = 1 ; i < Combinations ; ++i ) { - - const bool duplicate = - ( ( i & 01 ) && coord_up[0] == coord_low[0] ) || - ( ( i & 02 ) && coord_up[1] == coord_low[1] ) || - ( ( i & 04 ) && coord_up[2] == coord_low[2] ) ; - - if ( ! duplicate ) { - unsigned coord[3] ; - - coord[0] = ( i & 01 ) ? coord_up[0] : coord_low[0] ; - coord[1] = ( i & 02 ) ? coord_up[1] : coord_low[1] ; - coord[2] = ( i & 04 ) ? coord_up[2] : coord_low[2] ; - - covering[n] = hsfc3d( depth , coord ); - - ++n ; - } - } - - number = n ; - - return valid ; -} - - -namespace { - -//------------------------------------------//---------------------------------------------------------------------- -// Reset the accumulated node weights to only include -// those nodes in the range [ k_first , k_last ] - -void accumulate_weights( - const stk_classic::OctTreeKey &k_node_p , - const stk_classic::OctTreeKey &k_first_p , - const unsigned ord_end , - const unsigned depth , - float * const weights ) -{ - stk_classic::OctTreeKey k_node (k_node_p); - stk_classic::OctTreeKey k_first(k_first_p); - const unsigned ord_node_2 = 2 * oct_tree_offset( depth , k_node ); - - if ( k_node.depth() < depth ) { - - double w = 0 ; - - const unsigned d1 = k_node.depth() + 1 ; - - unsigned i = k_first.index( d1 ); - - if ( i ) { - k_node.set_index( d1 , i ); - - const unsigned ord = oct_tree_offset( depth , k_node ); - const unsigned ord_2 = ord * 2 ; - - accumulate_weights( k_node , k_first , ord_end , depth , weights ); - - // Counts of this node and all of its descending nodes - w += weights[ord_2] + weights[ ord_2 + 1 ] ; - - k_first = stk_classic::OctTreeKey(); // Done with the lower bound - } - - for ( ++i ; i <= 8 ; ++i ) { - - k_node.set_index( d1 , i ); - - const unsigned ord = oct_tree_offset( depth , k_node ); - const unsigned ord_2 = ord * 2 ; - - if ( ord < ord_end ) { - accumulate_weights( k_node, k_first , ord_end , depth , weights ); - - // Counts of this node and all of its descending nodes - w += weights[ord_2] + weights[ ord_2 + 1 ] ; - } - } - - // Descending node weight - - weights[ ord_node_2 + 1 ] = static_cast(w); - } -} - -//---------------------------------------------------------------------- - -void oct_key_split( - const stk_classic::OctTreeKey & key , - const unsigned upper_ord , - stk_classic::OctTreeKey & key_upper ) -{ - // Split key at key.depth() + 1 - - unsigned d = key.depth(); - - key_upper = key ; - - if ( upper_ord == 1 ) { // key_upper gets it all - while ( d && 1 == key_upper.index(d) ) { - key_upper.clear_index(d); - --d ; - } - } - else if ( 8 < upper_ord ) { // key_upper get none of it, Increment key_upper - - unsigned i = 0 ; - while ( d && 8 == ( i = key_upper.index(d) ) ) { - key_upper.clear_index(d); - --d ; - } - if ( d ) { key_upper.set_index( d , i + 1 ); } - } - else { - key_upper.set_index( d + 1 , upper_ord ); - } -} - -//---------------------------------------------------------------------- - -void partition( - const stk_classic::OctTreeKey & k_first , - const unsigned i_end , - const stk_classic::OctTreeKey & key , - const unsigned depth , - const float * weights , - const double tolerance , - const double target_ratio , - double w_lower , - double w_upper , - stk_classic::OctTreeKey & k_upper ) -{ - const unsigned ord_node = oct_tree_offset( depth , key ); - const float * const w_node = weights + ord_node * 2 ; - - const unsigned d1 = key.depth() + 1 ; - - // Add weights from nested nodes and their descendents - // Try to achieve the ratio. - - const unsigned i_first = k_first.index( d1 ); - - unsigned i = ( i_first ) ? i_first : 1 ; - unsigned j = 8 ; - { - stk_classic::OctTreeKey k_upp = key ; - k_upp.set_index( d1 , j ); - while ( i_end <= oct_tree_offset( depth , k_upp ) ) { - k_upp.set_index( d1 , --j ); - } - } - - w_lower += w_node[0] ; - w_upper += w_node[0] ; - - // At the maximum depth? - - if ( key.depth() == depth ) { - // Assume weight from unrepresented nested nodes is - // evenly distributed among the nodes in the span [i,j] - - const unsigned n = 1 + j - i ; - - const double val = static_cast(w_node[1]) / static_cast(n); - - // val = val_lower + val_upper - // ( w_lower + val_lower ) / ( w_upper + val_upper ) == target_ratio - - const double val_lower = - ( target_ratio * ( w_upper + val ) - w_lower ) / - ( target_ratio + 1 ) ; - - if ( 0 < val_lower ) { - // How much of the range does the lower portion get? - // Roundoff instead of merely truncating: - i += static_cast( 0.5 + ( n * val_lower ) / val ); - - // Can only get up to the maximum - if ( j < i ) { i = j ; } - } - oct_key_split( key , i , k_upper ); - } - else { - -// while ( i != j ) { - while ( i < j ) { - stk_classic::OctTreeKey ki = key ; ki.set_index( d1 , i ); - stk_classic::OctTreeKey kj = key ; kj.set_index( d1 , j ); - - const float * const vi = weights + 2 * oct_tree_offset( depth , ki ); - const float * const vj = weights + 2 * oct_tree_offset( depth , kj ); - - const double vali = vi[0] + vi[1] ; - const double valj = vj[0] + vj[1] ; - - if ( 0 < vali && 0 < valj ) { - - // Choose between ( w_lower += vali ) vs. ( w_upper += valj ) - // Knowing that the skipped value will be revisited. - - if ( ( w_lower + vali ) < target_ratio * ( w_upper + valj ) ) { - // Add to 'w_lower' and will still need more later - w_lower += vali ; - ++i ; - } - else { - // Add to 'w_upper' and will still need more later - w_upper += valj ; - --j ; - } - } - else { - if ( vali <= 0.0 ) { ++i ; } - if ( valj <= 0.0 ) { --j ; } - } - } - - // If 'i' has not incremented then 'k_first' is still in force - stk_classic::OctTreeKey nested_k_first ; - if ( i_first == i ) { nested_k_first = k_first ; } - - // Split node nested[i] ? - stk_classic::OctTreeKey ki = key ; ki.set_index( d1 , i ); - - const float * const vi = weights + 2 * oct_tree_offset( depth , ki ); - const double vali = vi[0] + vi[1] ; - - double diff = 0.0 ; - - if ( vali <= 0.0 ) { - diff = 0.0 ; // Nothing can be done. Give 'i' to the upper range - } - else if ( w_lower < w_upper * target_ratio ) { - // Try adding to w_lower - diff = static_cast (w_lower + vali) / static_cast(w_upper) - target_ratio ; - ++i ; - } - else { - // Try adding to w_upper - diff = static_cast(w_lower) / static_cast(w_upper + vali) - target_ratio ; - } - - if ( - tolerance < diff && diff < tolerance ) { - oct_key_split( key , i , k_upper ); - } - else { - partition( nested_k_first , i_end , ki , - depth , weights , - tolerance , target_ratio , - w_lower , w_upper , k_upper ); - } - } -} - -} // namespace - -unsigned processor( const stk_classic::OctTreeKey * const cuts_b , - const stk_classic::OctTreeKey * const cuts_e , - const stk_classic::OctTreeKey & key ) -{ - const stk_classic::OctTreeKey * const cuts_p = std::upper_bound( cuts_b , cuts_e , key ); - - if ( cuts_p == cuts_b ) { - std::string msg("stk_classic::processor FAILED: Bad cut-key array"); - throw std::runtime_error(msg); - } - - return ( cuts_p - cuts_b ) - 1 ; -} - -//---------------------------------------------------------------------- - -void oct_tree_partition_private( - const unsigned p_first , - const unsigned p_end , - const unsigned depth , - const double tolerance , - float * const weights , - const unsigned cuts_length , - stk_classic::OctTreeKey * const cuts ) -{ - // split tree between [ p_first , p_end ) - const unsigned p_size = p_end - p_first ; - const unsigned p_upper = ( p_end + p_first ) / 2 ; - - const double target_fraction = - static_cast ( p_upper - p_first ) / static_cast(p_size); - - const double target_ratio = target_fraction / ( 1.0 - target_fraction ); - - // Determine k_lower and k_upper such that - // - // Weight[ k_first , k_lower ] / Weight [ k_upper , k_last ] == target_ratio - // - // Within a tollerance - - const stk_classic::OctTreeKey k_first = cuts[ p_first ]; - - const unsigned i_end = - p_end < cuts_length ? oct_tree_offset( depth , cuts[ p_end ] ) - : oct_tree_size( depth ); - - // Walk the tree [ k_first , k_last ] and accumulate weight - - accumulate_weights( stk_classic::OctTreeKey() , k_first , i_end , depth , weights ); - - stk_classic::OctTreeKey k_root ; - stk_classic::OctTreeKey & k_upper = cuts[ p_upper ] ; - - unsigned w_lower = 0 ; - unsigned w_upper = 0 ; - - partition( k_first, i_end, k_root , - depth, weights, - tolerance, target_ratio, - w_lower, w_upper, k_upper ); - - const bool nested_lower_split = p_first + 1 < p_upper ; - const bool nested_upper_split = p_upper + 1 < p_end ; - - // If splitting both lower and upper, and a thread is available - // then one of the next two calls could be a parallel thread - // with a local copy of the shared 'weights' array. - - if ( nested_lower_split ) { - oct_tree_partition_private( p_first, p_upper, depth, - tolerance, weights, cuts_length, cuts ); - } - - if ( nested_upper_split ) { - oct_tree_partition_private( p_upper, p_end, depth, - tolerance, weights, cuts_length, cuts ); - } -} - -} // namespace search -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.hpp b/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.hpp deleted file mode 100644 index 48e3c1740647..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/OctTreeOps.hpp +++ /dev/null @@ -1,1024 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_OctTreeOps_hpp -#define stk_util_util_OctTreeOps_hpp - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace search { - -//---------------------------------------------------------------------- -/** A recursive kernel used within the oct_tree_partitioning algorithms. - * Exposed to support unit testing. - */ - -void oct_tree_partition_private( - const unsigned p_first , - const unsigned p_end , - const unsigned depth , - const double tolerance , - float * const weights , - const unsigned cuts_length , - OctTreeKey * const cuts ); - -//---------------------------------------------------------------------- -/** Generate an oct-tree covering of a small box within a global box. - * The cartesian space is mapped to an oct-tree via Hilbert space - * filling curve. The covering consists of 1..8 oct-tree cells, - * the 'covering' array must be dimensioned to at least eight. - * Returns true for a "good" small box: it a non-negative volume - * and is fully contained within the global box. - */ -bool hsfc_box_covering( - const float * const global_box , - const float * const small_box , - OctTreeKey * const covering , - unsigned & number, - double scale - ); - -template -void search_tree_statistics( stk_classic::ParallelMachine arg_comm , - const std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & s , - unsigned * const data ) -{ - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - const unsigned huge = std::numeric_limits::max(); - unsigned avg[2] = { 0 , 0 }; - unsigned max[2] = { 0 , 0 }; - unsigned min[2] ; - min[0] = min[1] = huge ; - - typename SearchTree::const_iterator i ; - - unsigned rcnt = 0; - unsigned dcnt = 0; - for ( i = s.begin() ; i != s.end() ; ++i ) { - const typename SearchTree::value_type & inode = *i ; - const unsigned d_size = inode.second.first.size(); - const unsigned r_size = inode.second.second.size(); - - if (d_size > 0) { - avg[0] += d_size ; - if ( d_size < min[0] ) { min[0] = d_size ; } - if ( max[0] < d_size ) { max[0] = d_size ; } - ++dcnt; - } - - if (r_size > 0) { - avg[1] += r_size ; - if ( r_size < min[1] ) { min[1] = r_size ; } - if ( max[1] < r_size ) { max[1] = r_size ; } - ++rcnt; - } - } - - // Average for this processor - - if (dcnt) - avg[0] = ( avg[0] + dcnt - 1 ) / dcnt ; - - if ( rcnt ) { - avg[1] = ( avg[1] + rcnt - 1 ) / rcnt ; - } - - if ( min[0] == huge ) { min[0] = 0 ; } - if ( min[1] == huge ) { min[1] = 0 ; } - - all_reduce( arg_comm, ReduceMin<2>( min ) ); - all_reduce( arg_comm, ReduceMax<2>( max ) ); - all_reduce( arg_comm, ReduceSum<2>( avg ) ); - - const unsigned p_size = parallel_machine_size( arg_comm ); - - // Average among all processors: - - avg[0] = ( avg[0] + p_size - 1 ) / p_size ; - avg[1] = ( avg[1] + p_size - 1 ) / p_size ; - - data[0] = min[0] ; - data[1] = max[0] ; - data[2] = avg[0] ; - - data[3] = min[1] ; - data[4] = max[1] ; - data[5] = avg[1] ; -} - -//---------------------------------------------------------------------- -/** Global bounds for a set of boxes. - * The lower bound is the minimum of all boxes, decreased by epsilon. - * The upper bound is the maximum of all boxes, increased by epsilon. - * Thus all input boxes are fully contained within the global box. - */ -template -void box_global_bounds( - ParallelMachine arg_comm , - const size_t arg_domain_boxes_number , - const DomainBoundingBox * const arg_domain_boxes , - const size_t arg_range_boxes_number , - const RangeBoundingBox * const arg_range_boxes , - float * const arg_global_box ) -{ - enum { Dim = 3 }; - -#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 1210) -#pragma warning disable 191 -#endif - const bool symmetric = static_cast(arg_range_boxes) == static_cast(arg_domain_boxes ) || - arg_range_boxes == NULL; - - - Copy( arg_global_box , std::numeric_limits::max() ); - Copy( arg_global_box + Dim , - std::numeric_limits::max() ); - - //------------------------------------ - // Trivial loop threading possible: - - for ( size_t i = 0 ; i < arg_domain_boxes_number ; ++i ) { - const DomainBoundingBox & box = arg_domain_boxes[i]; - for (int j=0; j static_cast(box.lower(j)) ) { - arg_global_box[j] = static_cast(box.lower(j)); - } - if (arg_global_box[j+Dim] < static_cast(box.upper(j)) ) { - arg_global_box[j+Dim] = static_cast(box.upper(j)); - } - } - } - - if ( ! symmetric ) { - for ( size_t i = 0 ; i < arg_range_boxes_number ; ++i ) { - const RangeBoundingBox & box = arg_range_boxes[i]; - for (int j=0; j static_cast(box.lower(j)) ) { - arg_global_box[j] = static_cast(box.lower(j)); - } - if (arg_global_box[j+Dim] < static_cast(box.upper(j)) ) { - arg_global_box[j+Dim] = static_cast(box.upper(j)); - } - } - } - } - - //------------------------------------ - - all_reduce( arg_comm , ReduceMin( arg_global_box ) ); - all_reduce( arg_comm , ReduceMax( arg_global_box + Dim ) ); - - if (arg_domain_boxes_number == 0 && - arg_range_boxes_number == 0) - return; - - // Scale up and down by epsilon - - const double eps = std::numeric_limits::epsilon(); - - for ( unsigned i = 0 ; i < Dim ; ++i ) { - float upper = arg_global_box[i+Dim] ; - float lower = arg_global_box[i] ; - - double delta = eps * ( upper - lower ); - delta = delta > 0 ? delta : eps; - - while ( upper <= arg_global_box[i+Dim] || - arg_global_box[i] <= lower ) { - upper = static_cast( upper + delta ); - lower = static_cast( lower - delta ); - delta *= 2 ; - } - - arg_global_box[i+Dim] = static_cast(upper); - arg_global_box[i] = static_cast(lower); - } -} - -//---------------------------------------------------------------------- - -template< class S > -struct SetInsertBuffer { - enum { N = 128 }; - S & m_set ; - unsigned m_lock ; - unsigned m_iter ; - typename S::value_type m_buffer[ N ] ; - - void overflow(); - void operator()( const typename S::value_type & v ); - - SetInsertBuffer( S & s , unsigned l ) - : m_set(s), m_lock(l), m_iter(0) {} - - ~SetInsertBuffer() { overflow(); } -}; - -template -void SetInsertBuffer::overflow() -{ - try { - TPI_Lock( m_lock ); - while ( m_iter ) { - m_set.insert( m_buffer[ --m_iter ] ); - } - TPI_Unlock( m_lock ); - } - catch(...) { - TPI_Unlock( m_lock ); - throw ; - } -} - -template -void SetInsertBuffer::operator()( const typename S::value_type & v ) -{ - m_buffer[ m_iter ] = v ; - if ( N == ++m_iter ) { overflow(); } -} - - -/* -template -void proximity_search_symmetric( - const typename std::map< stk_classic::OctTreeKey, - std::pair< std::list< DomainBoundingBox >, - std::list< RangeBoundingBox > > >::const_iterator i_beg , - const typename std::map< stk_classic::OctTreeKey, - std::pair< std::list< DomainBoundingBox >, - std::list< RangeBoundingBox > > >::const_iterator i_end , - SetInsertBuffer< std::set< std::pair< typename DomainBoundingBox::Key, - typename RangeBoundingBox::Key > > > & arg_out ) -{ - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - typename SearchTree::const_iterator j ; - - typename std::list::const_iterator id; - typename std::list::const_iterator ir; - - const typename SearchTree::value_type & inode = *i_beg ; - const std::list & domain_outer = inode.second.first ; - - const typename std::list::const_iterator - beg_dom_out = domain_outer.begin(), - end_dom_out = domain_outer.end(); - - // Outer cell vs. itself - - for ( id = beg_dom_out ; id != end_dom_out ; ++id ) { - const DomainBoundingBox & d = *id ; - for ( ir = id ; ++ir != end_dom_out ; ) { - const RangeBoundingBox & r = *ir ; - if ( d.intersect(r) ) { - const DomainKey & dip = d.key ; - const RangeKey & rip = r.key ; - if ( dip < rip ) { - std::pair tmp( dip , rip ); - arg_out( tmp ); - } - else { - std::pair tmp( rip , dip ); - arg_out( tmp ); - } - } - } - } - - // Outer cell searching inner cells. - // Outer cell always precedes inner cells - // Iterate forward until the cell is not contained. - - const stk_classic::OctTreeKey & outer_key = inode.first ; - - for ( j = i_beg ; ++j != i_end && outer_key.intersect( (*j).first ) ; ) { - - const typename SearchTree::value_type & jnode = *j ; - - const std::list & domain_inner = jnode.second.first ; - - const typename std::list::const_iterator - beg_dom_inn = domain_inner.begin(), - end_dom_inn = domain_inner.end(); - - // Check domain_outer vs. domain_inner, - // skip if the same box. - - for ( id = beg_dom_out ; id != end_dom_out ; ++id ) { - const BoundingBox & d = *id ; - for ( ir = beg_dom_inn ; ir != end_dom_inn ; ++ir ) { - const BoundingBox & r = *ir ; - if ( d.key != r.key ) { - if ( d.intersect(r) ) { - const Key & dip = d.key ; - const Key & rip = r.key ; - if ( dip < rip ) { - std::pair tmp( dip , rip ); - arg_out( tmp ); - } - else { - std::pair tmp( rip , dip ); - arg_out( tmp ); - } - } - } - } - } - } -} -*/ - -template -void proximity_search_asymmetric( - const typename std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > >::const_iterator i_beg , - const typename std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > >::const_iterator i_end , - SetInsertBuffer< std::set< std::pair< typename DomainBoundingBox::Key, typename RangeBoundingBox::Key > > > & arg_out ) -{ - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - typename SearchTree::const_iterator j ; - - typename std::list::const_iterator id; - typename std::list::const_iterator ir; - - const typename SearchTree::value_type & inode = *i_beg ; - - const std::list & domain_outer = inode.second.first ; - const std::list & range_outer = inode.second.second ; - - const typename std::list::const_iterator - beg_dom_out = domain_outer.begin(), - end_dom_out = domain_outer.end(); - const typename std::list::const_iterator - beg_ran_out = range_outer.begin(), - end_ran_out = range_outer.end(); - - // domain_outer vs. range_outer - - for ( id = beg_dom_out ; id != end_dom_out ; ++id ) { - const DomainBoundingBox & d = *id ; - for ( ir = beg_ran_out ; ir != end_ran_out ; ++ir ) { - const RangeBoundingBox & r = *ir ; - if ( d.intersect(r) ) { - std::pair tmp( d.key , r.key ); - arg_out( tmp ); - } - } - } - - // Outer cell searching inner cells. - // Outer cell always precedes inner cells - // Iterate forward until the cell is not contained. - - const stk_classic::OctTreeKey & outer_key = inode.first ; - - for ( j = i_beg ; ++j != i_end && outer_key.intersect( (*j).first ) ; ) { - - const typename SearchTree::value_type & jnode = *j ; - - const std::list & range_inner = jnode.second.second ; - - const typename std::list::const_iterator - beg_ran_inn = range_inner.begin(), - end_ran_inn = range_inner.end(); - - // Check domain_outer vs. range_inner - - for ( ir = beg_ran_inn ; ir != end_ran_inn ; ++ir ) { - const RangeBoundingBox & r = *ir ; - for ( id = beg_dom_out ; id != end_dom_out ; ++id ) { - const DomainBoundingBox & d = *id ; - if ( d.intersect(r) ) { - std::pair tmp( d.key , r.key ); - arg_out( tmp ); - } - } - } - - // Check domain_inner vs. range_outer if non-symmetric - const std::list & domain_inner = jnode.second.first ; - - const typename std::list::const_iterator - beg_dom_inn = domain_inner.begin(), - end_dom_inn = domain_inner.end(); - - for ( id = beg_dom_inn ; id != end_dom_inn ; ++id ) { - const DomainBoundingBox & d = *id ; - for ( ir = beg_ran_out ; ir != end_ran_out ; ++ir ) { - const RangeBoundingBox & r = *ir ; - if ( d.intersect(r) ) { - std::pair tmp( d.key , r.key ); - arg_out( tmp ); - } - } - } - } -} - -unsigned processor( const stk_classic::OctTreeKey * const cuts_b , - const stk_classic::OctTreeKey * const cuts_e , - const stk_classic::OctTreeKey & key ); - -template -void pack( - CommAll & comm_all , - const stk_classic::OctTreeKey * const cuts_b , - const std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & send_tree , - std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > * recv_tree ) -{ - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - const unsigned p_rank = comm_all.parallel_rank(); - const unsigned p_size = comm_all.parallel_size(); - const stk_classic::OctTreeKey * const cuts_e = cuts_b + p_size ; - - typename SearchTree::const_iterator i ; - - for ( i = send_tree.begin() ; i != send_tree.end() ; ++i ) { - const stk_classic::OctTreeKey & key = (*i).first ; - - unsigned p = processor( cuts_b , cuts_e , key ); - - do { - if ( p != p_rank ) { - CommBuffer & buf = comm_all.send_buffer(p); - - const std::list< DomainBoundingBox > & domain = (*i).second.first ; - const std::list< RangeBoundingBox > & range = (*i).second.second ; - - typename std::list< DomainBoundingBox >::const_iterator jd ; - typename std::list< RangeBoundingBox >::const_iterator jr ; - - const unsigned dsize = domain.size(); - const unsigned rsize = range.size(); - - buf.pack( key.value() , stk_classic::OctTreeKey::NWord ); - buf.pack( dsize ); - buf.pack( rsize ); - - for ( jd = domain.begin() ; jd != domain.end() ; ++jd ) { - const DomainBoundingBox & box = *jd ; - buf.pack( box ); - } - - for ( jr = range.begin() ; jr != range.end() ; ++jr ) { - const RangeBoundingBox & box = *jr ; - buf.pack( box ); - } - } - else if ( recv_tree ) { - // Copy contents of the send node - (*recv_tree)[ key ] = (*i).second ; - } - - // If the cut keys are at a finer granularity than - // this key then this key may overlap more than one - // processor's span. Check for overlap with the - // beginning key of the next processor. - - ++p ; - - } while( p < p_size && key.intersect( cuts_b[p] ) ); - } -} - -template -void unpack( - CommAll & comm_all , - std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & tree ) -{ - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - unsigned domain_size(0) ; - unsigned range_size(0) ; - unsigned value[ stk_classic::OctTreeKey::NWord ]; - stk_classic::OctTreeKey key ; - DomainBoundingBox domain_box ; - RangeBoundingBox range_box ; - - const unsigned p_size = comm_all.parallel_size(); - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = comm_all.recv_buffer(p); - - while ( buf.remaining() ) { - buf.unpack( value , stk_classic::OctTreeKey::NWord ); - buf.unpack( domain_size ); - buf.unpack( range_size ); - - // Insert key, get domain and range - - key.set_value( value ); - - typename SearchTree::mapped_type & node = tree[ key ]; - - std::list< DomainBoundingBox > & domain = node.first ; - std::list< RangeBoundingBox > & range = node.second ; - - for ( unsigned j = 0 ; j < domain_size ; ++j ) { - buf.unpack( domain_box ); - domain.push_back( domain_box ); - } - - for ( unsigned j = 0 ; j < range_size ; ++j ) { - buf.unpack( range_box ); - range.push_back( range_box ); - } - } - } -} - -template -bool communicate( - stk_classic::ParallelMachine arg_comm , - const stk_classic::OctTreeKey * const arg_cuts , - const std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & send_tree , - std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & recv_tree , - const bool local_flag ) -{ - const unsigned p_size = parallel_machine_size( arg_comm ); - - // Communicate search_tree members - - CommAll comm_all( arg_comm ); - - // Sizing pass for pack - pack( comm_all , arg_cuts , send_tree , NULL ); - - // If more than 25% then is dense - const bool global_flag = - comm_all.allocate_buffers( p_size / 4 , false , local_flag ); - - // Actual packing pass, copy local entries too - pack( comm_all , arg_cuts , send_tree , & recv_tree ); - - comm_all.communicate(); - - unpack( comm_all , recv_tree ); - - return global_flag ; -} - - -template -void communicate( - stk_classic::ParallelMachine arg_comm , - const std::set< std::pair< typename DomainBoundingBox::Key, typename RangeBoundingBox::Key > > & send_relation , - std::set< std::pair< typename DomainBoundingBox::Key, typename RangeBoundingBox::Key > > & recv_relation ) -{ - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::pair ValueType ; - - CommAll comm_all( arg_comm ); - - const unsigned p_rank = comm_all.parallel_rank(); - const unsigned p_size = comm_all.parallel_size(); - - typename std::set< ValueType >::const_iterator i ; - - for ( i = send_relation.begin() ; i != send_relation.end() ; ++i ) { - const ValueType & val = *i ; - if ( val.first.proc == p_rank || val.second.proc == p_rank ) { - recv_relation.insert( val ); - } - if ( val.first.proc != p_rank ) { - CommBuffer & buf = comm_all.send_buffer( val.first.proc ); - buf.skip( 1 ); - } - if ( val.second.proc != p_rank && val.second.proc != val.first.proc ) { - CommBuffer & buf = comm_all.send_buffer( val.second.proc ); - buf.skip( 1 ); - } - } - - // If more than 25% messages then is dense - - comm_all.allocate_buffers( p_size / 4 , false ); - - for ( i = send_relation.begin() ; i != send_relation.end() ; ++i ) { - const ValueType & val = *i ; - if ( val.first.proc != p_rank ) { - CommBuffer & buf = comm_all.send_buffer( val.first.proc ); - buf.pack( val ); - } - if ( val.second.proc != p_rank && val.second.proc != val.first.proc ) { - CommBuffer & buf = comm_all.send_buffer( val.second.proc ); - buf.pack( val ); - } - } - - comm_all.communicate(); - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = comm_all.recv_buffer( p ); - while ( buf.remaining() ) { - ValueType val ; - buf.unpack( val ); - recv_relation.insert( val ); - } - } -} - -//---------------------------------------------------------------------- -// Partition a search tree among processors - -template -void oct_tree_partition( - stk_classic::ParallelMachine arg_comm , - const std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > & arg_tree , - const double arg_tolerance , - std::vector< stk_classic::OctTreeKey > & arg_cuts ) -{ - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - enum { tree_depth = 4 }; - enum { tree_size = OctTreeSize< tree_depth >::value }; - enum { tree_size_2 = tree_size * 2 }; - - const unsigned p_size = parallel_machine_size( arg_comm ); - const stk_classic::OctTreeKey k_null ; - - arg_cuts.assign( p_size , k_null ); - - float local_count[ tree_size_2 ]; - float global_count[ tree_size_2 ]; - - for ( unsigned i = 0 ; i < tree_size_2 ; ++i ) { - local_count[i] = 0.0 ; - } - - for ( typename SearchTree::const_iterator i = arg_tree.begin() ; - i != arg_tree.end() ; ++i ) { - - const stk_classic::OctTreeKey & key = (*i).first ; - - const std::list< DomainBoundingBox > & domain = (*i).second.first ; - const std::list< RangeBoundingBox > & range = (*i).second.second ; - - const unsigned depth = key.depth(); - const unsigned ordinal = oct_tree_offset( tree_depth , key ); - const unsigned num_d = domain.size(); - const unsigned num_r = range.size(); - const unsigned number = num_d + num_r ; - - if ( depth <= 4 ) { // Values for this node: - local_count[ 2 * ordinal ] += number ; - } - else { // Values for a deeper node - local_count[ 2 * ordinal + 1 ] += number ; - } - } - - all_reduce_sum( arg_comm , local_count , global_count , tree_size_2 ); - - oct_tree_partition_private( 0, p_size, tree_depth, - arg_tolerance, global_count, - p_size, & arg_cuts[0]); -} - -template -class ProximitySearch { -public: - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - typedef void (*proximity_search_work_routine)( - const typename SearchTree::const_iterator i_beg , - const typename SearchTree::const_iterator i_end , - SetInsertBuffer< std::set< std::pair > > & ); - - enum { NLOCKS = 2 }; - enum { GET_LOCK = 0 }; - enum { PUT_LOCK = 1 }; - - bool m_symmetric; - - std::set< std::pair > & m_relation ; - typename SearchTree::const_iterator m_tree_iter ; - typename SearchTree::const_iterator m_tree_end ; - - ~ProximitySearch() {} - - ProximitySearch( - bool symmetric , - const SearchTree & search_tree , - std::set< std::pair > & relation ); - void iterate_tree(); - -private: - ProximitySearch(); - ProximitySearch( const ProximitySearch & ); - ProximitySearch & operator = ( const ProximitySearch & ); -}; - -template -void proximity_search_work( TPI_Work * work ) -{ - ProximitySearch * p = (ProximitySearch *) work->info ; - p->iterate_tree(); -} - - -template -void ProximitySearch::iterate_tree() -{ - enum { N_WORK = 32 }; - - try { - SetInsertBuffer< std::set< std::pair > > - tmp( m_relation , PUT_LOCK ); - - const typename SearchTree::const_iterator i_tree_end = m_tree_end ; - - unsigned n_work = N_WORK ; - - while ( n_work ) { - - n_work = 0 ; - - typename SearchTree::const_iterator i_beg , i_end ; - - // Get work: - - try { - TPI_Lock( GET_LOCK ); - - i_end = i_beg = m_tree_iter ; - - while ( n_work < N_WORK && i_tree_end != i_end ) { - ++i_end ; ++n_work ; - } - - m_tree_iter = i_end ; - - TPI_Unlock( GET_LOCK ); - } - catch( ... ) { - TPI_Unlock( GET_LOCK ); - throw ; - } - - // Perform work: - - // if (m_symmetric) { - // for ( ; i_beg != i_end ; ++i_beg ) { - // proximity_search_symmetric( i_beg , i_tree_end , tmp ); - // } - // } else { - for ( ; i_beg != i_end ; ++i_beg ) { - proximity_search_asymmetric( i_beg , i_tree_end , tmp ); - } - // } - } - } - catch ( const std::exception & x ) { - std::cerr << x.what() << std::endl ; - std::cerr.flush(); - } - catch ( ... ) { - std::cerr << "ProximitySearch::iterate_tree FAILED" << std::endl ; - std::cerr.flush(); - } -} - - -template -ProximitySearch::ProximitySearch( - bool symmetric , - const SearchTree & search_tree , - std::set< std::pair > & relation ) - : m_symmetric(symmetric), - m_relation( relation ), - m_tree_iter( search_tree.begin() ), - m_tree_end( search_tree.end() ) -{ - if ( m_tree_iter != m_tree_end ) { - - TPI_work_subprogram worker = (TPI_work_subprogram) proximity_search_work; - TPI_Run_threads(worker, this, NLOCKS ); - - if ( m_tree_iter != m_tree_end ) { - std::string msg("stk_classic::proximity_search FAILED to complete" ); - throw std::runtime_error(msg); - } - } -} - - -//---------------------------------------------------------------------- -/** Search for intersection of domain boxes with range boxes - * within a given global bounding box. - * Output vector of matches with a domain or range box on - * the local processor. - * - * If 'arg_cuts' is given it will be used for the parallel - * search. If 'arg_cuts == NULL' then a balanced internal - * partitioning will be generated. - * - * The search_tree_stats are for the local search: - * [0] = minimum search tree domain cell size - * [1] = maximum search tree domain cell size - * [2] = average search tree domain cell size - * [3] = minimum search tree range cell size - * [4] = maximum search tree range cell size - * [5] = average search tree range cell size - * These statistics require an extra communication to gather. - * - * Returns 'true' if all small boxes on all processors - * had non-negative volumes and were fully contained within - * the global box. - */ - -template -bool oct_tree_proximity_search( - ParallelMachine arg_comm , - const float * const arg_global_box , - const size_t arg_domain_boxes_number , - const DomainBoundingBox * const arg_domain_boxes , - const size_t arg_range_boxes_number , - const RangeBoundingBox * const arg_range_boxes , - const OctTreeKey * const arg_cuts , - std::vector< std::pair< typename DomainBoundingBox::Key, typename RangeBoundingBox::Key > > & arg_relation , - unsigned * const arg_search_tree_stats = NULL ) -{ - typedef typename DomainBoundingBox::Key DomainKey; - typedef typename RangeBoundingBox::Key RangeKey; - typedef std::map< stk_classic::OctTreeKey, std::pair< std::list< DomainBoundingBox >, std::list< RangeBoundingBox > > > SearchTree ; - - enum { Dim = 3 }; - - //const bool symmetric = static_cast(arg_range_boxes) == static_cast(arg_domain_boxes ) || - // arg_range_boxes == NULL; - const bool symmetric = false; - - const unsigned p_size = parallel_machine_size( arg_comm ); - const unsigned p_rank = parallel_machine_rank( arg_comm ); - - //---------------------------------------------------------------------- - // Search tree defined by oct-tree covering for boxes - - bool local_violations = false ; - bool global_violations = false ; - - SearchTree search_tree ; - - { - stk_classic::OctTreeKey covering[8] ; - unsigned number = 0 ; - - double scale = arg_global_box[0+Dim] - arg_global_box[0]; - for ( unsigned i = 1 ; i < Dim ; ++i ) { - double tst_scale = arg_global_box[i+Dim] - arg_global_box[i]; - if (tst_scale > scale) scale = tst_scale; - } - if (scale > 0.0) // Not an error. Could arise with a point bounding box in the range/domain... - scale = 1.0 / scale; - else - scale = 1.0; - - for ( size_t i = 0 ; i < arg_domain_boxes_number ; ++i ) { - - DomainBoundingBox tmp( arg_domain_boxes[i] ); - - tmp.key.proc = p_rank ; - - float box[6]; - - for (int x=0; x > tmp_relation ; - - if ( p_size == 1 ) { - - global_violations = local_violations ; - - if ( arg_search_tree_stats ) { - search_tree_statistics( arg_comm , search_tree , - arg_search_tree_stats ); - } - ProximitySearch( symmetric, search_tree, tmp_relation); - } - else { - // Communicate search_tree members - - SearchTree local_tree ; - - std::set< std::pair > local_relation ; - - if ( arg_cuts ) { - global_violations = - communicate( arg_comm , arg_cuts , search_tree , local_tree , - local_violations ); - } - else { - const double tolerance = 0.001 ; - - std::vector< stk_classic::OctTreeKey > cuts ; - - oct_tree_partition( arg_comm , search_tree , tolerance , cuts ); - - global_violations = - communicate(arg_comm , & cuts[0] , search_tree , local_tree , - local_violations ); - } - - // Local proximity search with received members - - if ( arg_search_tree_stats ) { - search_tree_statistics( arg_comm , local_tree , - arg_search_tree_stats ); - } - - ProximitySearch( symmetric, local_tree, local_relation); - - // Communicate relations back to domain and range processors - - communicate( arg_comm , local_relation , tmp_relation ); - } - - arg_relation.clear(); - arg_relation.reserve( tmp_relation.size() ); - - typename std::set< std::pair >::iterator ir ; - for ( ir = tmp_relation.begin() ; ir != tmp_relation.end() ; ++ir ) { - arg_relation.push_back( *ir ); - } - return global_violations ; -} - -//---------------------------------------------------------------------- - -} // namespace search -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_search/stk_search/SearchTypes.hpp b/packages/stk/stk_classic/stk_search/stk_search/SearchTypes.hpp deleted file mode 100644 index 5bfe2d9064b6..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/SearchTypes.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_SearchTypes_hpp -#define stk_search_SearchTypes_hpp - -#include -typedef uint64_t search_ident_type; -typedef float search_bbox_type; -#endif diff --git a/packages/stk/stk_classic/stk_search/stk_search/diag/CMakeLists.txt b/packages/stk/stk_classic/stk_search/stk_search/diag/CMakeLists.txt deleted file mode 100644 index 63d60b9f6992..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/diag/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FILE(GLOB HEADERS *.hpp) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_search/diag/) - diff --git a/packages/stk/stk_classic/stk_search/stk_search/diag/IdentProc.hpp b/packages/stk/stk_classic/stk_search/stk_search/diag/IdentProc.hpp deleted file mode 100644 index 3b2c0dc911cd..000000000000 --- a/packages/stk/stk_classic/stk_search/stk_search/diag/IdentProc.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_diag_IdentProc_hpp -#define stk_search_diag_IdentProc_hpp - -#include -#include - - -namespace stk_classic { -namespace search { -namespace ident { - -template -stk_classic::diag::Writer &operator<<(stk_classic::diag::Writer &dout, const IdentProc &ident_proc) { - if (dout.shouldPrint()) { - dout << "id " << std::hex << ident_proc.ident << std::dec << ", proc " << ident_proc.proc; - } - - return dout; -} - -} // namespace ident -} // namespace search -} // namespace stk_classic - -#endif // stk_search_diag_IdentProc_hpp diff --git a/packages/stk/stk_classic/stk_search/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_search/unit_tests/CMakeLists.txt deleted file mode 100644 index ef4fab5b84fe..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -APPEND_SET(SOURCES -UnitTest_1.cpp -UnitTestBihTree.cpp -UnitTestCoarseSearch.cpp -UnitTestMain.cpp -UnitTest_4.cpp -UnitTestBoundingBox.cpp -UnitTestIdentProc.cpp -UnitTestRange.cpp - ) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - search_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBihTree.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBihTree.cpp deleted file mode 100644 index bda2b9286b30..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBihTree.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include -#include - -typedef stk_classic::search::box::AxisAlignedBoundingBox BoundingVolume; - -namespace stk_classic { -namespace search { -namespace bih { - -class UnitTestBihTree { -public: - UnitTestBihTree() {} - ~UnitTestBihTree() {} - void testNode(); - void testTree(); -}; - - -void UnitTestBihTree::testNode() -{ - BihTree::Node test; - - STKUNIT_ASSERT_EQUAL( test.is_leaf() , true); - STKUNIT_ASSERT_EQUAL( test.size() , 0); - - //make the node an interior node - float clip_planes[4] = {-1,1}; - test.make_interior_node( 0 , clip_planes); - - //the num of items in an interior node is -1 - STKUNIT_ASSERT_EQUAL( test.size() , -1); - - STKUNIT_ASSERT_EQUAL( test.is_leaf() , false); - STKUNIT_ASSERT( test.axis() == 0 ); - STKUNIT_ASSERT_EQUAL( test.left_max(), -1.0f); - STKUNIT_ASSERT_EQUAL( test.right_min(), 1.0f); - - //check that the axis is being encoded in the pointer correctly - int axis = static_cast(test.m_children_ptr - reinterpret_cast(test.children())); - STKUNIT_ASSERT_EQUAL( axis , test.axis()); - - - //test leaf node - stk_classic::search::bih::BihTree::Node & leftChild = test.left(); - stk_classic::search::bih::BihTree::Node & rightChild = test.right(); - - - leftChild.make_leaf_node(0,0); - - STKUNIT_ASSERT_EQUAL( leftChild.is_leaf() , true); - STKUNIT_ASSERT_EQUAL( leftChild.size() , 0); - - std::vector m_test_keys(4); - - - for (unsigned i=0; i<4; ++i) { - m_test_keys[i].key = i; - } - - //make empty left child - rightChild.make_leaf_node(&m_test_keys[0],4); - - STKUNIT_ASSERT_EQUAL( rightChild.is_leaf() , true); - STKUNIT_ASSERT_EQUAL( rightChild.size() , 4); - -} - -void test_tree( - std::vector & range, - const std::vector & domain, - unsigned max_depth, - unsigned items_per_leaf) -{ - stk_classic::search::bih::BihTree tree(range.begin(),range.end(),max_depth,items_per_leaf); - - int extra_intersections = 0; - - std::vector< std::pair< BoundingVolume::Key, BoundingVolume::Key> > relations_vector; - std::set< std::pair< BoundingVolume::Key, BoundingVolume::Key> > relations_set; - std::vector range_overlap; - - for (std::vector::const_iterator i = domain.begin(); i != domain.end(); ++i) { - relations_vector.clear(); - relations_set.clear(); - range_overlap.clear(); - - tree.intersect(*i,relations_vector); - tree.intersect(*i,relations_set); - tree.intersect(*i,range_overlap); - - extra_intersections += range_overlap.size() - 64; - - STKUNIT_ASSERT(relations_vector.size() >= 64); - STKUNIT_ASSERT(relations_set.size() >= 64); - STKUNIT_ASSERT(range_overlap.size() >= 64); - } - - std::set< std::pair< BoundingVolume::Key, BoundingVolume::Key> > self_relations_set; - //test for self intersection - tree.self_intersect(self_relations_set); -} - -void UnitTestBihTree::testTree( ) -{ - std::vector range; - - const int END = 25; - - for (int i = 0; i domain; - for (int i = 2; i= 1; i >>= 1) { - test_tree(range,domain,64,i); - } - - { - //test bih tree with single box - stk_classic::search::bih::BihTree tree(range.begin(),range.begin()+1); - } - - { - //test a very unbalanced tree - std::vector unbalanced; - - for (int i=0; i tree(unbalanced.begin(),unbalanced.end()); - - std::set< std::pair< BoundingVolume::Key, BoundingVolume::Key> > self_relations_set; - //test for self intersection - tree.self_intersect(self_relations_set); - } -} - -} // namespace bih -} // namespace search -} // namespace stk_classic - -STKUNIT_UNIT_TEST(UnitTestingOfSearchBih, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_classic::search::bih::UnitTestBihTree unitTest; - unitTest.testNode(); - unitTest.testTree(); -} - diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBoundingBox.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBoundingBox.cpp deleted file mode 100644 index fe0cc084b33c..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestBoundingBox.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include -#include - -#include -#include - -namespace stk_classic { -namespace search { -namespace box { - -void tests() { - float center[3] = {0.0f, 0.0f, 0.0f}; - float one[3] = {1.0f, 1.0f, 1.0f}; - float radius = 1.0f; - float box[6] = {-1.0f,-1.0f,-1.0f,1.0f,1.0f,1.0f}; - - //test constructors - PointBoundingBox pa, pb(center,1); - SphereBoundingBox sa, sb(center,radius,1); - AxisAlignedBoundingBox aa, ab(box,1); - - std::vector > paa(3); - std::vector > saa(3); - std::vector > aaa(3); - - //test assignment - pa = pb; - sa = sb; - aa = ab; - - //test copy constructors - PointBoundingBox pc(pa); - SphereBoundingBox sc(sa); - AxisAlignedBoundingBox ac(aa); - - SphereBoundingBox sd(pa); - SphereBoundingBox se(aa); - - AxisAlignedBoundingBox ad(pa); - AxisAlignedBoundingBox ae(sa); - - //test member functions - for (int i = 0; i<3; ++i) { - STKUNIT_ASSERT_EQUAL( pa.lower(i), center[i]); - STKUNIT_ASSERT_EQUAL( pa.middle(i), center[i]); - STKUNIT_ASSERT_EQUAL( pa.upper(i), center[i]); - STKUNIT_ASSERT_EQUAL( pa.length(i), 0.0f); - - STKUNIT_ASSERT_EQUAL( sa.lower(i), center[i] - radius); - STKUNIT_ASSERT_EQUAL( sa.middle(i), center[i] ); - STKUNIT_ASSERT_EQUAL( sa.upper(i), center[i] + radius ); - STKUNIT_ASSERT_EQUAL( sa.length(i), 2.0f * radius); - - STKUNIT_ASSERT_EQUAL( sa.lower(i), box[i]); - STKUNIT_ASSERT_EQUAL( sa.middle(i), box[i] + (box[i+3]-box[i])/2.0f); - STKUNIT_ASSERT_EQUAL( sa.upper(i), box[i+3] ); - STKUNIT_ASSERT_EQUAL( sa.length(i), box[i+3]-box[i]); - } - - STKUNIT_ASSERT_EQUAL( pa.intersect(pb), true); - STKUNIT_ASSERT_EQUAL( pa.intersect(sb), true); - STKUNIT_ASSERT_EQUAL( pa.intersect(ab), true); - - STKUNIT_ASSERT_EQUAL( sa.intersect(pb), true); - STKUNIT_ASSERT_EQUAL( sa.intersect(sb), true); - STKUNIT_ASSERT_EQUAL( sa.intersect(ab), true); - - STKUNIT_ASSERT_EQUAL( aa.intersect(pb), true); - STKUNIT_ASSERT_EQUAL( aa.intersect(sb), true); - STKUNIT_ASSERT_EQUAL( aa.intersect(ab), true); - - - //test bounding box compare - PointBoundingBox a(center,0), b(one,1); - - compare::Compare,compare::LOWER> compare_lower(0); - STKUNIT_ASSERT_EQUAL(compare_lower(a,b),true); - - compare::Compare,compare::MIDDLE> compare_middle(0); - STKUNIT_ASSERT_EQUAL(compare_middle(a,b),true); - - compare::Compare,compare::UPPER> compare_upper(0); - STKUNIT_ASSERT_EQUAL(compare_upper(a,b),true); - - compare::Compare,compare::LENGTH> compare_length(0); - STKUNIT_ASSERT_EQUAL(compare_length(a,b),false); - STKUNIT_ASSERT_EQUAL(compare_length(b,a),false); - - compare::Compare,compare::KEY> compare_key; - STKUNIT_ASSERT_EQUAL(compare_key(a,b),true); - - compare::Partition,compare::LOWER> partition_lower(0,2.0f); - STKUNIT_ASSERT_EQUAL(partition_lower(a),true); - - compare::Partition,compare::MIDDLE> partition_middle(0,2.0f); - STKUNIT_ASSERT_EQUAL(partition_middle(a),true); - - compare::Partition,compare::UPPER> partition_upper(0,2.0f); - STKUNIT_ASSERT_EQUAL(partition_upper(a),true); - - compare::Partition,compare::LENGTH> partition_length(0,2.0f); - STKUNIT_ASSERT_EQUAL(partition_length(a),true); - - compare::Partition,compare::KEY> partition_key(2); - STKUNIT_ASSERT_EQUAL(partition_key(a),true); - - // use_case::dw() << "Test diag writer for BoundingBox" << std::endl; - // use_case::dw() << pa << std::endl; - // use_case::dw() << sa << std::endl; - // use_case::dw() << aa << std::endl; - - - std::stringstream output; - - output << "Test writer for BoundingBox" << std::endl; - output << pa << std::endl; - output << sa << std::endl; - output << aa << std::endl; - - output << paa << std::endl; - output << saa << std::endl; - output << aaa << std::endl; - -} - -} // namespace box -} // namespace search -} // namespace stk_classic - -STKUNIT_UNIT_TEST(UnitTestingOfSearchBox, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_classic::search::box::tests(); -} diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestCoarseSearch.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestCoarseSearch.cpp deleted file mode 100644 index 24c1adc08964..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestCoarseSearch.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include - -#include -#include -#include - -#include - -namespace stk_search_unit { - -STKUNIT_UNIT_TEST(UnitTestingOfSearchCoarse, octtree) -{ - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::search::FactoryOrder order; - order.m_algorithm = stk_classic::search::FactoryOrder::OCTREE; - order.m_communicator = MPI_COMM_WORLD; - - OverlappingBoxes box_test; - OverlappingBoxes::IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, box_test.range(), box_test.domain(), order); - STKUNIT_ASSERT_TRUE(box_test.check_results(relation)); -} - -STKUNIT_UNIT_TEST(UnitTestingOfSearchCoarse, bihtree) -{ - MPI_Barrier( MPI_COMM_WORLD ); - - stk_classic::search::FactoryOrder order; - order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE; - order.m_communicator = MPI_COMM_WORLD; - - OverlappingBoxes box_test; - OverlappingBoxes::IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, box_test.range(), box_test.domain(), order); - STKUNIT_ASSERT_TRUE(box_test.check_results(relation)); -} - -} // namespace stk_search_unit - diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestIdentProc.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestIdentProc.cpp deleted file mode 100644 index 2f392b051f7d..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestIdentProc.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include -#include - -#include - -namespace stk_search_identproc_test { - -void tests() { - - stk_classic::search::ident::IdentProc a(1,0), b; - b = a; - stk_classic::search::ident::IdentProc c(a), d(1,1), e(0,0); - - - STKUNIT_ASSERT_EQUAL(a == b,true); - STKUNIT_ASSERT_EQUAL(a == d,false); - STKUNIT_ASSERT_EQUAL(a != d,true); - STKUNIT_ASSERT_EQUAL(a != b,false); - STKUNIT_ASSERT_EQUAL(a < d,true); - STKUNIT_ASSERT_EQUAL(a < b,false); - STKUNIT_ASSERT_EQUAL(a > e,true); - STKUNIT_ASSERT_EQUAL(a > b,false); - STKUNIT_ASSERT_EQUAL(a <= b,true); - STKUNIT_ASSERT_EQUAL(a <= d,true); - STKUNIT_ASSERT_EQUAL(a <= e,false); - STKUNIT_ASSERT_EQUAL(a >= b,true); - STKUNIT_ASSERT_EQUAL(a >= d,false); - STKUNIT_ASSERT_EQUAL(a >= e,true); - - //use_case::dw() << "Test diag writer for IdentProc: " << a << std::endl; - -} - -} // namespace stk_search_identproc_test - -STKUNIT_UNIT_TEST(UnitTestingOfIdentProc, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_search_identproc_test::tests(); -} diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestMain.cpp deleted file mode 100644 index d785e32f42e0..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include -#include - -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestRange.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestRange.cpp deleted file mode 100644 index 0502468e4772..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestRange.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -namespace stk_search_unitrange_test { - -void test() -{} - -} // namespace stk_search_unitrange_test - -STKUNIT_UNIT_TEST(UnitTestingOfUnitRange, testUnit) -{ - stk_search_unitrange_test::test(); -} - diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestStkSearchFixture.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTestStkSearchFixture.cpp deleted file mode 100644 index 52b86ace66b9..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTestStkSearchFixture.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -namespace stk_search_unit { - -OverlappingBoxes::OverlappingBoxes() { - - const int END = 25; - unsigned current_id = 0; - - for (int i = 2; i count; - count.resize(m_domain.size()); - - for (unsigned i = 0; i -#include - -namespace stk_search_unit { - -class OverlappingBoxes { - public: - - typedef stk_classic::search::ident::IdentProc IdentProc; - typedef std::vector > IdentProcRelation; - typedef stk_classic::search::box::AxisAlignedBoundingBox BoundingVolume; - typedef std::vector BoundingVolumeVector; - - OverlappingBoxes(); - - inline - const BoundingVolumeVector & domain() const { return m_domain; } - - inline - const BoundingVolumeVector & range() const { return m_range; } - - bool check_results(const IdentProcRelation & relations) const; - - private: - - enum {EXPECTED_INTERSECTIONS = 64}; - - BoundingVolumeVector m_domain; - BoundingVolumeVector m_range; - -}; - - - -} - - - - -#endif //UNIT_TEST_STK_SEARCH_FIXTURE_HPP diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_1.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_1.cpp deleted file mode 100644 index ee1c1770706d..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace use_case; - -using namespace stk_classic::diag; - -typedef stk_classic::search::ident::IdentProc IdentProc; -typedef stk_classic::search::box::PointBoundingBox BoundingPoint; -typedef stk_classic::search::box::AxisAlignedBoundingBox BoundingBox; -typedef std::vector > IdentProcRelation; - -static const int box_count = 100; - -void -use_case_1_driver( - stk_classic::ParallelMachine comm) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - dw().m(LOG_SEARCH) << "Use case 1" << stk_classic::diag::push << stk_classic::diag::dendl; - - int parallel_rank = stk_classic::parallel_machine_rank(comm); -// int parallel_size = stk_classic::parallel_machine_size(comm); - - std::vector domain_vector; - - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { - float box[6] = {i,0.0f,0.0f,i+1.0f,1.0f,1.0f }; - - BoundingBox domain; - domain.key.ident = i; - domain.set_box(box); - - domain_vector.push_back(domain); - } - - std::vector range_vector; - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { - float center[3] = {i +0.5f,0.5f,0.5f}; - - BoundingPoint p; - p.key.ident = i; - p.set_center(center); - - range_vector.push_back(p); - } - - dw().m(LOG_SEARCH) << "range " << range_vector << dendl; - dw().m(LOG_SEARCH) << "domain " << domain_vector << dendl; - - stk_classic::search::FactoryOrder order; - order.m_communicator = comm; - order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE; - - dw().m(LOG_SEARCH) << "Search algorithm " << order.m_algorithm << dendl; - - IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - - dw().m(LOG_SEARCH) << "relation " << relation << dendl; - - dw().m(LOG_SEARCH) << stk_classic::diag::pop; -} diff --git a/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_4.cpp b/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_4.cpp deleted file mode 100644 index cad3984a9117..000000000000 --- a/packages/stk/stk_classic/stk_search/unit_tests/UnitTest_4.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace use_case; - -using namespace stk_classic::diag; - - -typedef stk_classic::search::ident::IdentProc IdentProc; -typedef stk_classic::search::box::AxisAlignedBoundingBox BoundingBox; -typedef std::vector > IdentProcRelation; - -static const int box_count = 100; - -void -use_case_4_driver( - stk_classic::ParallelMachine comm) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - dw().m(LOG_SEARCH) << "Use case 4" << stk_classic::diag::push << stk_classic::diag::dendl; - - int parallel_rank = stk_classic::parallel_machine_rank(comm); -// int parallel_size = stk_classic::parallel_machine_size(comm); - - std::vector range_vector; - - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { - float box[6] = {i,0.0f,0.0f,i+1.0f,1.0f,1.0f }; - - BoundingBox range; - range.key.ident = i; - range.set_box(box); - - range_vector.push_back(range); - } - - std::vector domain_vector; - - for (int i = parallel_rank*box_count; i < (parallel_rank + 1)*box_count; ++i) { - float box[6] = {i,0.0f,0.0f,i+1.0f,1.0f,1.0f }; - - BoundingBox domain; - domain.key.ident = i; - domain.set_box(box); - - domain_vector.push_back(domain); - } - - dw().m(LOG_SEARCH) << "range " << range_vector << dendl; - dw().m(LOG_SEARCH) << "domain " << domain_vector << dendl; - - stk_classic::search::FactoryOrder order; - order.m_communicator = comm; - - - dw().m(LOG_SEARCH) << "Search algorithm " << order.m_algorithm << dendl; - - IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - - dw().m(LOG_SEARCH) << "relation " << relation << dendl; - - dw().m(LOG_SEARCH) << stk_classic::diag::pop; -} diff --git a/packages/stk/stk_classic/stk_search_util/CMakeLists.txt b/packages/stk/stk_classic/stk_search_util/CMakeLists.txt deleted file mode 100644 index 98d0bb450862..000000000000 --- a/packages/stk/stk_classic/stk_search_util/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -ADD_SUBDIRECTORY(stk_search_util) - diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/CMakeLists.txt b/packages/stk/stk_classic/stk_search_util/stk_search_util/CMakeLists.txt deleted file mode 100644 index 67bdd9abee2d..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -ADD_SUBDIRECTORY(stk_mesh) - diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CMakeLists.txt deleted file mode 100644 index 925daf5cc10e..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS - CreateBoundingBox.hpp - PrintBoundingBox.hpp - PrintEntityProc.hpp - ) - -APPEND_SET(SOURCES - CreateBoundingBox.cpp - PrintEntityProc.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_search_util - NOINSTALLHEADERS ${HEADERS} - DEPLIBS stkclassic_mesh_fem stkclassic_util_diag - SOURCES ${SOURCES} - ) - -#INSTALL(FILES ${HEADERS} DESTINATION -# ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_search) diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.cpp b/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.cpp deleted file mode 100644 index bbc7359a3e50..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK; - -#define ct_assert(e) extern char (*ct_assert(void)) [sizeof(char[1 - 2*!(e)])] - -typedef stk_classic::search::ident::IdentProc IdentProc; -typedef stk_classic::search::box::AxisAlignedBoundingBox AxisAlignedBoundingBox3D; -typedef stk_classic::search::box::PointBoundingBox PointBoundingBox3D; - -namespace { -void build_node_axis_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - const stk_classic::search_util::Op &op); - -void build_axis_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - const stk_classic::search_util::Op &op); - -void build_node_cent_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector); - -void build_cent_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector); -} - -namespace stk_classic { -namespace search_util { - -// The adjust_box should be implemented as an Op rather than a scale and offset parameter. -void build_axis_aligned_bbox(stk_classic::mesh::BulkData &bulk_data, stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - bool use_universal_part, - const stk_classic::search_util::Op &op) -{ - // Build an axis-aligned bounding box of each entity in the mesh... - - // NOTE: Unless 'use_universal_part' is true, then a - // 'type' of 'Node' will search for a nodeset, not all nodes in - // the model. - - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - const stk_classic::mesh::fem::FEMMetaData & fem = stk_classic::mesh::fem::FEMMetaData::get(meta_data); - const stk_classic::mesh::EntityRank side_rank = fem.side_rank(); - - if (use_universal_part && type == NODE_RANK) { - stk_classic::mesh::Part &universal = meta_data.universal_part(); - build_node_axis_bbox(universal, bulk_data, type, coordinates, box_vector, op); - } else if (use_universal_part && type == side_rank) { - stk_classic::mesh::Part *skin = meta_data.get_part("skin"); - build_axis_bbox(*skin, bulk_data, type, coordinates, box_vector, op); - } else { - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); - ip != all_parts.end(); ++ip ) { - stk_classic::mesh::Part * const part = *ip; - if ( part->primary_entity_rank() == type ) { - if (type == NODE_RANK) { - build_node_axis_bbox(*part, bulk_data, type, coordinates, box_vector, op); - } else { - if (type == side_rank && part->name() == "skin") - continue; - build_axis_bbox(*part, bulk_data, type, coordinates, box_vector, op); - } - } - } - } -} - -void build_centroid_bbox(stk_classic::mesh::BulkData &bulk_data, stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - bool use_universal_part) -{ - // NOTE: Unless 'nodes_use_universal_part' is true, then a - // 'type' of 'Node' will search for a nodeset, not all nodes in - // the model. - - // The box for this case is the centroid of each entity in the mesh... - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - const stk_classic::mesh::fem::FEMMetaData & fem = stk_classic::mesh::fem::FEMMetaData::get(meta_data); - const stk_classic::mesh::EntityRank side_rank = fem.side_rank(); - - if (use_universal_part && type == NODE_RANK) { - stk_classic::mesh::Part &universal = meta_data.universal_part(); - build_node_cent_bbox(universal, bulk_data, type, coordinates, box_vector); - } else if (use_universal_part && type == side_rank) { - stk_classic::mesh::Part *skin = meta_data.get_part("skin"); - build_cent_bbox(*skin, bulk_data, type, coordinates, box_vector); - } else { - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); - ip != all_parts.end(); ++ip ) { - stk_classic::mesh::Part * const part = *ip; - if ( part->primary_entity_rank() == type ) { - if (type == NODE_RANK) { - build_node_cent_bbox(*part, bulk_data, type, coordinates, box_vector); - } else { - if (type == side_rank && part->name() == "skin") - continue; - build_cent_bbox(*part, bulk_data, type, coordinates, box_vector); - } - } - } - } -} - -void OffsetScaleOp::operator()(Data &xmin, Data &ymin, Data &zmin, - Data &xmax, Data &ymax, Data &zmax) const { - if (m_offset != 0.0 || m_scale != 0.0) { - const double dx = (xmax - xmin); - const double dy = (ymax - ymin); - const double dz = (zmax - zmin); - - double delta = dx; - if (delta < dy) - delta = dy; - if (delta < dz) - delta = dz; - - delta = delta * m_scale + m_offset; - - xmin -= delta; - ymin -= delta; - zmin -= delta; - xmax += delta; - ymax += delta; - zmax += delta; - } -} - -void OffsetScaleOp::operator()(AxisAlignedBoundingBox3D &box) const { - if (m_offset != 0.0 || m_scale != 0.0) { - double dx = box.upper(0) - box.lower(0); - double dy = box.upper(1) - box.lower(1); - double dz = box.upper(2) - box.lower(2); - - double delta = dx; - if (delta < dy) - delta = dy; - if (delta < dz) - delta = dz; - - delta = delta * m_scale + m_offset; - - box.expand(delta); - } -} - -} // namespace search_util -} // namespace stk_classic - -namespace { - -void build_node_axis_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - const stk_classic::search_util::Op &op) -{ - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = part & ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ); - get_selected_entities(selector, bulk_data.buckets(type), entities); - size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { - AxisAlignedBoundingBox3D domain; - ct_assert(sizeof(domain.key.ident) >= sizeof(stk_classic::mesh::EntityKey)); - domain.key.ident = entities[i]->key(); - - double *fld_data = (double*)stk_classic::mesh::field_data(*coordinates, *entities[i]); - assert(fld_data != NULL); - - domain.set_box(fld_data); - op(domain); - box_vector.push_back(domain); - } -} - -void build_axis_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - const stk_classic::search_util::Op &op) -{ - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - stk_classic::mesh::fem::FEMMetaData * fem_meta = const_cast(meta_data.get_attribute()); - - const CellTopologyData * cell_topo = NULL; - cell_topo = fem_meta->get_cell_topology(part).getCellTopologyData(); - if (fem_meta && !cell_topo) cell_topo = fem_meta->get_cell_topology(part).getCellTopologyData(); - if (cell_topo == NULL) - return; - - const int nodes_per_entity = cell_topo->node_count; - - std::vector entities; - stk_classic::mesh::Selector selector = part & ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ); - get_selected_entities(selector, bulk_data.buckets(type), entities); - size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { - AxisAlignedBoundingBox3D domain; - ct_assert(sizeof(domain.key.ident) >= sizeof(stk_classic::mesh::EntityKey)); - domain.key.ident = entities[i]->key(); - - const stk_classic::mesh::PairIterRelation entity_nodes = entities[i]->relations(NODE_RANK); - assert(static_cast(entity_nodes.size()) == nodes_per_entity); - - double *fld_data = (double*)stk_classic::mesh::field_data(*coordinates, *entity_nodes[0].entity()); - assert(fld_data != NULL); - - AxisAlignedBoundingBox3D::Data bbox[6]; - bbox[0]= fld_data[0]; - bbox[1] = fld_data[1]; - bbox[2] = fld_data[2]; - - bbox[3] = fld_data[0]; - bbox[4] = fld_data[1]; - bbox[5] = fld_data[2]; - - for (int j = 1; j < nodes_per_entity; ++j) { - fld_data = (double*)stk_classic::mesh::field_data(*coordinates, *entity_nodes[j].entity()); - assert(fld_data != NULL); - bbox[0] = fld_data[0] < bbox[0] ? fld_data[0] : bbox[0]; - bbox[1] = fld_data[1] < bbox[1] ? fld_data[1] : bbox[1]; - bbox[2] = fld_data[2] < bbox[2] ? fld_data[2] : bbox[2]; - - bbox[3] = fld_data[0] > bbox[3] ? fld_data[0] : bbox[3]; - bbox[4] = fld_data[1] > bbox[4] ? fld_data[1] : bbox[4]; - bbox[5] = fld_data[2] > bbox[5] ? fld_data[2] : bbox[5]; - } - - domain.set_box(bbox); - op(domain); - box_vector.push_back(domain); - } -} - -void build_node_cent_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector) -{ - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = part & ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ); - get_selected_entities(selector, bulk_data.buckets(type), entities); - size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { - PointBoundingBox3D p; - ct_assert(sizeof(p.key.ident) >= sizeof(stk_classic::mesh::EntityKey)); - p.key.ident = entities[i]->key(); - - double *fld_data = (double*)stk_classic::mesh::field_data(*coordinates, *entities[i]); - assert(fld_data != NULL); - - p.set_center(fld_data); - box_vector.push_back(p); - } -} - -void build_cent_bbox(stk_classic::mesh::Part &part, - stk_classic::mesh::BulkData &bulk_data, - stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector) -{ - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = part & ( meta_data.locally_owned_part() | meta_data.globally_shared_part() ); - get_selected_entities(selector, bulk_data.buckets(type), entities); - size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { - PointBoundingBox3D p; - ct_assert(sizeof(p.key.ident) >= sizeof(stk_classic::mesh::EntityKey)); - p.key.ident = entities[i]->key(); - - p.center[0] = 0; - p.center[1] = 0; - p.center[2] = 0; - - const stk_classic::mesh::PairIterRelation entity_nodes = entities[i]->relations(NODE_RANK); - const size_t nodes_per_entity = entity_nodes.size(); - for (size_t j = 0; j < nodes_per_entity; ++j) { - double *fld_data = (double*)stk_classic::mesh::field_data(*coordinates, *entity_nodes[j].entity()); - assert(fld_data != NULL); - p.center[0] += fld_data[0]; - p.center[1] += fld_data[1]; - p.center[2] += fld_data[2]; - } - p.center[0] /= nodes_per_entity; - p.center[1] /= nodes_per_entity; - p.center[2] /= nodes_per_entity; - box_vector.push_back(p); - } -} - -} diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.hpp b/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.hpp deleted file mode 100644 index 6bd60443fbcc..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/CreateBoundingBox.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_util_stk_mesh_CreateBoundingBox_hpp -#define stk_search_util_stk_mesh_CreateBoundingBox_hpp -#include -#include -#include -#include -#include -#include -#include - -typedef stk_classic::mesh::Field CartesianField ; -typedef stk_classic::search::ident::IdentProc IdentProc; -typedef stk_classic::search::box::AxisAlignedBoundingBox AxisAlignedBoundingBox3D; -typedef stk_classic::search::box::PointBoundingBox PointBoundingBox3D; -typedef std::vector > IdentProcRelation; - -namespace stk_classic { - -namespace mesh { -class BulkData; -} - -namespace search_util { - -struct Op -{ - typedef double Data; - - virtual void operator()(Data &xmin, Data &ymin, Data &zmin, - Data &xmax, Data &ymax, Data &zmax) const = 0; - virtual void operator()(AxisAlignedBoundingBox3D &box) const = 0; - virtual ~Op(){} -}; - -struct NoOp : public Op -{ - typedef double Data; - - NoOp(){} - virtual ~NoOp(){} - virtual void operator()(Data &xmin, Data &ymin, Data &zmin, - Data &xmax, Data &ymax, Data &zmax) const - {} - virtual void operator()(AxisAlignedBoundingBox3D &box) const - {} -}; - -void build_axis_aligned_bbox(stk_classic::mesh::BulkData &bulk_data, stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - bool use_universal_part = false, - const Op &op = NoOp()); - - -void build_centroid_bbox(stk_classic::mesh::BulkData &bulk_data, stk_classic::mesh::EntityRank type, - CartesianField *coordinates, - std::vector &box_vector, - bool use_universal_part = false); - -/** - * The bounding box is expanded in all directions by the amount - * "max_d * scale + offset" where "max_d" is the maximum extent - * of the bounding box.in any coordinate direction (xmax-xmin, - * ymax-ymin, zmax-zmin). - */ -struct OffsetScaleOp : public Op -{ - typedef double Data; - - OffsetScaleOp(double scale, double offset) - : m_scale(scale), - m_offset(offset) - {} - virtual ~OffsetScaleOp(){} - virtual void operator()(Data &xmin, Data &ymin, Data &zmin, - Data &xmax, Data &ymax, Data &zmax) const; - virtual void operator()(AxisAlignedBoundingBox3D &box) const; - - const double m_scale; - const double m_offset; -}; - -} // namespace search_util -} // namespace stk_classic -#endif // stk_search_util_stk_mesh_CreateBoundingBox_hpp diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintBoundingBox.hpp b/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintBoundingBox.hpp deleted file mode 100644 index c5fe180aa9a3..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintBoundingBox.hpp +++ /dev/null @@ -1,166 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_search_PrintBoundingBox_hpp -#define stk_util_search_PrintBoundingBox_hpp - -#include -#include - -#include -#include - -namespace stk_classic { -namespace search { -namespace box { - -template -stk_classic::diag::Writer & -operator<<( - stk_classic::diag::Writer & dout, - const PointBoundingBox & point_) -{ - if (dout.shouldPrint()) { - dout << "(" << point_.key << ": "; - for (int i=0; i -std::ostream & -operator<<( - std::ostream & dout, - const PointBoundingBox & point_) -{ - dout << "(" << point_.key << ": "; - for (int i=0; i -stk_classic::diag::Writer & -operator<<( - stk_classic::diag::Writer & dout, - const AxisAlignedBoundingBox & box_) -{ - if (dout.shouldPrint()) { - dout << "(" << box_.key << ": "; - for (int i=0; i<2*DIMENSION; ++i) { - dout << box_.box[i]; - if (i != DIMENSION-1) - dout << ","; - else - dout << ")"; - } - } - return dout; -} - -template -std::ostream & -operator<<( - std::ostream & dout, - const AxisAlignedBoundingBox & box_) -{ - dout << "(" << box_.key << ": "; - for (int i=0; i<2*DIMENSION; ++i) { - dout << box_.box[i]; - if (i != DIMENSION-1) - dout << ","; - else - dout << ")"; - } - return dout; -} - - -template -stk_classic::diag::Writer & -operator<<( - stk_classic::diag::Writer & dout, - const SphereBoundingBox & sphere_) -{ - if (dout.shouldPrint()) { - dout << "(" << sphere_.key << ", center: "; - for (int i=0; i -std::ostream & -operator<<( - std::ostream & dout, - const SphereBoundingBox & sphere_) -{ - dout << "(" << sphere_.key << ", center: "; - for (int i=0; i -std::ostream & -operator<<( - std::ostream & dout, - const std::vector > & points) -{ - dout << "[Size: " << points.size() << "]\n"; - for (unsigned i = 0; i < points.size(); ++i) - dout << points[i] < -std::ostream & -operator<<( - std::ostream & dout, - const std::vector > & boxes) -{ - dout << "[Size: " << boxes.size() << "]\n"; - for (unsigned i = 0; i < boxes.size(); ++i) - dout << boxes[i] < -std::ostream & -operator<<( - std::ostream & dout, - const std::vector > & spheres) -{ - dout << "[Size: " << spheres.size() << "]\n"; - for (unsigned i = 0; i < spheres.size(); ++i) - dout << spheres[i] < -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace search_util { - -typedef stk_classic::search::ident::IdentProc IdentProc; - -typedef std::vector > IdentProcRelation; - -// Used to output the results of a coarse or direct search to -// verify which entity contains another entity. -void print_entity_map(stk_classic::diag::Writer &writer, - const std::vector >& entity_map, - const std::string & relation) -{ - if (writer.shouldPrint()) { - size_t size = entity_map.size(); - for (size_t i=0; i < size; i++) { - stk_classic::mesh::EntityKey key1 = entity_map[i].first->key(); - stk_classic::mesh::EntityKey key2 = entity_map[i].second->key(); - const stk_classic::mesh::MetaData& meta1 = stk_classic::mesh::MetaData::get(*(entity_map[i].first)); - const stk_classic::mesh::MetaData& meta2 = stk_classic::mesh::MetaData::get(*(entity_map[i].second)); - - writer << "[" << i << "] " - << meta1.entity_rank_name(stk_classic::mesh::entity_rank(key1)) << " " - << stk_classic::mesh::entity_id(key1) << relation - << meta2.entity_rank_name(stk_classic::mesh::entity_rank(key2)) << " " - << stk_classic::mesh::entity_id(key2) << "\n"; - } - } -} - -/** - * Used to output a sharing or ghosting vector in human readable - * form. - * The "action" argument will typically be "Share " or "Ghost " - * The "to_from" argument will typically be - * - for sharing " with " - * - for ghosting " from " or " to " - * - * Decodes the entity key and prints as entity type, entity id - * - * Example output: "Share NODE 37 with processor 12" - */ -void print_entity_proc_map(stk_classic::diag::Writer &writer, - const std::vector& entity_proc, - const std::string &action, - const std::string &to_from) -{ - if (writer.shouldPrint()) { - size_t size = entity_proc.size(); - for (size_t i=0; i < size; i++) { - stk_classic::mesh::EntityKey key = entity_proc[i].first->key(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get( *(entity_proc[i].first) ); - - writer << "[" << i << "] " - << action - << meta.entity_rank_name(stk_classic::mesh::entity_rank(key)) << " " - << stk_classic::mesh::entity_id(key) << " " << to_from << " processor " - << entity_proc[i].second << "\n"; - } - } -} - -void print_entity_proc_map(stk_classic::diag::Writer &writer, - const std::vector& entity_proc, - const std::string &action, - const std::string &to_from) -{ - if (writer.shouldPrint()) { - size_t size = entity_proc.size(); - for (size_t i=0; i < size; i++) { - stk_classic::mesh::EntityKey key = entity_proc[i]->key(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get( entity_proc[i]->bucket() ); - - writer << "[" << i << "] " - << action - << meta.entity_rank_name(stk_classic::mesh::entity_rank(key)) << " " - << stk_classic::mesh::entity_id(key) << " " << to_from << " processor " - << entity_proc[i]->owner_rank() << "\n"; - } - } -} - - -void print_entity_proc_map( stk_classic::diag::Writer & writer , - const stk_classic::mesh::BulkData & mesh ) -{ - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(mesh); - const std::vector & comm = mesh.entity_comm(); - const std::vector & ghost = mesh.ghostings(); - - size_t counter = 0 ; - - for ( size_t ig = 0 ; ig < ghost.size() ; ++ig ) { - - const stk_classic::mesh::Ghosting & g = * ghost[ig] ; - - writer << "P" << mesh.parallel_rank() - << " " << g.name() << " Communication:" << std::endl ; - - for ( std::vector::const_iterator - i = comm.begin() ; i != comm.end() ; ++i ) { - - const stk_classic::mesh::Entity & entity = **i ; - - std::vector procs ; - - stk_classic::mesh::comm_procs( g , entity , procs ); - - if ( ! procs.empty() ) { - writer << "[" << counter << "] " - << meta.entity_rank_name( entity.entity_rank() ) - << "[" << entity.identifier() << " " ; - if ( entity.owner_rank() != mesh.parallel_rank() ) { - writer << "not_" ; - } - writer << "owned ] {" ; - for ( size_t j = 0 ; j < procs.size() ; ++j ) { - writer << " " << procs[j] ; - } - writer << " }" << std::endl ; - } - } - } -} - - -/** - * Used to output the results of a relation vector in human - * readable form. This function cannot be used as the default - * output of an IdentProcRelation since it is using knowledge that - * what is really being stored in the IdentProc is stk_classic::mesh - * entity keys. - */ -void print_stk_mesh_relation_map( - stk_classic::diag::Writer &writer, - const std::vector &entity_names, - IdentProcRelation relation) -{ - if (writer.shouldPrint()) { - size_t size = relation.size(); - writer << "relation [size " << size << "]\n"; - for (size_t i=0; i < size; i++) { - IdentProc domain = relation[i].first; - IdentProc range = relation[i].second; - -// stk_classic::mesh::EntityKey domain_entity_key; -// stk_classic::mesh::EntityKey range_entity_key; -// domain_entity_key.value(domain.ident); -// range_entity_key.value(range.ident); - - stk_classic::mesh::EntityKey domain_entity_key(domain.ident); - stk_classic::mesh::EntityKey range_entity_key(range.ident); - - writer << "[" << i << "] (" - << entity_names[stk_classic::mesh::entity_rank(domain_entity_key)] << " " - << stk_classic::mesh::entity_id(domain_entity_key) - << ", proc " << domain.proc - << " -> " - << entity_names[stk_classic::mesh::entity_rank(range_entity_key)] << " " - << stk_classic::mesh::entity_id(range_entity_key) - << ", proc " << range.proc - << ")\n"; - } - } -} -} -} diff --git a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintEntityProc.hpp b/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintEntityProc.hpp deleted file mode 100644 index 68c28757c070..000000000000 --- a/packages/stk/stk_classic/stk_search_util/stk_search_util/stk_mesh/PrintEntityProc.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_util_PrintEntityProc_hpp -#define stk_search_util_PrintEntityProc_hpp - -#include -#include - -#include -#include -#include -#include - -#include - - -namespace stk_classic { -namespace mesh { -class Entity; -} - -namespace search_util { - - -/** - * Used to output the results of a coarse or direct search to - * verify which entity contains another entity. - */ -void print_entity_map(stk_classic::diag::Writer &writer, - const std::vector >& entity_map, - const std::string & relation); - -/** - * Used to output a sharing or ghosting vector in human readable - * form. - * The "action" argument will typically be "Share " or "Ghost " - * The "to_from" argument will typically be - * - for sharing " with " - * - for ghosting " from " or " to " - * - * Decodes the entity key and prints as entity type, entity id - * - * Example output: "Share NODE 37 with processor 12" - */ -void print_entity_proc_map(stk_classic::diag::Writer &writer, - const std::vector& entity_proc, - const std::string &action, - const std::string &to_from); - -/** - * Used to output a sharing or ghosting vector in human readable - * form using the owner processor. - * The "action" argument will typically be "Share " or "Ghost " - * The "to_from" argument will typically be - * - for sharing " with " - * - for ghosting " from " or " to " - * - * Decodes the entity key and prints as entity type, entity id - * - * Example output: "Share NODE 37 with processor 12" - */ -void print_entity_proc_map(stk_classic::diag::Writer &writer, - const std::vector& entity_proc, - const std::string &action, - const std::string &to_from); - -void print_entity_proc_map( stk_classic::diag::Writer & writer , - const stk_classic::mesh::BulkData & mesh ); - -/** - * Used to output the results of a relation vector in human - * readable form. This function cannot be used as the default - * output of an IdentProcRelation since it is using knowledge that - * what is really being stored in the IdentProc is stk_classic::mesh - * entity keys. - */ -void print_stk_mesh_relation_map(stk_classic::diag::Writer &writer, - const std::vector &entity_names, - IdentProcRelation relation); -} // namespace search_util -} // namespace stk_classic -#endif diff --git a/packages/stk/stk_classic/stk_transfer/CMakeLists.txt b/packages/stk/stk_classic/stk_transfer/CMakeLists.txt deleted file mode 100644 index 2b71da93542d..000000000000 --- a/packages/stk/stk_classic/stk_transfer/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - -TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) - diff --git a/packages/stk/stk_classic/stk_transfer/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_transfer/unit_tests/CMakeLists.txt deleted file mode 100644 index 5730d3c37ad5..000000000000 --- a/packages/stk/stk_classic/stk_transfer/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -APPEND_SET(SOURCES -UnitTest_1.cpp -UnitTestMain.cpp - ) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - transfer_unit_tests - SOURCES ${SOURCES} - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - diff --git a/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 63da13775c88..000000000000 --- a/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTest_1.cpp b/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTest_1.cpp deleted file mode 100644 index 1c1354bfaebb..000000000000 --- a/packages/stk/stk_classic/stk_transfer/unit_tests/UnitTest_1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include - -namespace stk_transfer_unit_tests { - -//The following ::testUnit() function is where the actual unit-test is: -//(This one doesn't do much, it's mainly a template to demonstrate how -// to create a unit-test.) -// -//To create another unit-test, copy this file, change all occurrences of -//'UnitTest_1' to something else, and write your test code in its body. - -void UnitTest_1( MPI_Comm comm ) -{ - int mpi_rank = 0; - int mpi_size = 1; - -#ifdef STK_HAS_MPI - STKUNIT_ASSERT_EQUAL(MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank), MPI_SUCCESS); - STKUNIT_ASSERT_EQUAL(MPI_Comm_size(MPI_COMM_WORLD, &mpi_size), MPI_SUCCESS); -#endif - - STKUNIT_ASSERT(mpi_rank < mpi_size); -} - -} // namespace stk_transfer_unit_tests - -STKUNIT_UNIT_TEST(UnitTestingOfTransfer, testUnit) -{ - MPI_Barrier( MPI_COMM_WORLD ); - stk_transfer_unit_tests::UnitTest_1 ( MPI_COMM_WORLD ); -} - diff --git a/packages/stk/stk_classic/stk_usecases/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/CMakeLists.txt deleted file mode 100644 index 51e95023a164..000000000000 --- a/packages/stk/stk_classic/stk_usecases/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ - -ADD_SUBDIRECTORY(util) - -IF( ${PACKAGE_NAME}_ENABLE_SEACASIoss) - ADD_SUBDIRECTORY(app) - ADD_SUBDIRECTORY(io) -# ADD_SUBDIRECTORY(mesh) -ENDIF() - -#IF( ${PACKAGE_NAME}_ENABLE_SEACASIoss AND ${PACKAGE_NAME}_ENABLE_FEI AND ${PACKAGE_NAME}_ENABLE_AztecOO ) -# ADD_SUBDIRECTORY(linsys) -#ENDIF() - -#IF( ${PACKAGE_NAME}_ENABLE_ThreadPool AND TPL_ENABLE_MPI ) -# ADD_SUBDIRECTORY(transfer) -#ENDIF() diff --git a/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.cpp b/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.cpp deleted file mode 100644 index d7d3a5aed144..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.cpp +++ /dev/null @@ -1,604 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 14: internal force computation. -// The function 'use_case_14_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -static const size_t spatial_dimension = 3; - -bool use_case_14_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int bucket_size, - bool performance_test) -{ - bool output = !performance_test; // If running for performance measurements, turn off output - - if (stk_classic::parallel_machine_rank(comm) == 0) { - std::cout << " stk_mesh Use Case #14 - element internal force, begin" << std::endl ; - std::cout << "Running '" << mesh_filename << "' case, num_trials = " - << num_trials << std::endl; - } - - - const AlgorithmRunnerInterface* alg_runner = NULL ; - if ( thread_runner.empty() || - thread_runner == std::string("NonThreaded") ) { - alg_runner = stk_classic::algorithm_runner_non_thread(); - } - else if ( thread_runner == std::string("TPI") ) { - alg_runner = stk_classic::algorithm_runner_tpi(num_threads); - } - else if ( thread_runner == std::string("TBB") ) { - alg_runner = stk_classic::algorithm_runner_tbb(num_threads); - } - - if (alg_runner != NULL) { - if (stk_classic::parallel_machine_rank(comm) == 0) - std::cout << "Using " << thread_runner - << " algorithm runner, num_threads = " << num_threads - << std::endl; - } else { - std::cout << "ERROR, failed to obtain requested AlgorithmRunner '" - << thread_runner << "'." << std::endl; - return false; - } - - double dt = 1.0e-03; - double YM = 1e7; // Young's Modulus - double PR = 0.33; // Poisson Ratio - std::string material_model_name("ELASTIC"); - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - lame::MatProps materialProperties; - - std::vector youngs_modulus; youngs_modulus.push_back(YM); - std::vector poissons_ratio; poissons_ratio.push_back(PR); - std::vector bulk_modulus; bulk_modulus.push_back(BM); - std::vector shear_modulus; shear_modulus.push_back(SM); - std::vector two_mu; two_mu.push_back(TM); - std::vector lambda; lambda.push_back(LAMBDA); - std::vector dilatational_modulus; dilatational_modulus.push_back(DM); - - materialProperties["YOUNGS_MODULUS"] = youngs_modulus; - materialProperties["POISSONS_RATIO"] = poissons_ratio; - materialProperties["BULK_MODULUS"] = bulk_modulus; - materialProperties["SHEAR_MODULUS"] = shear_modulus; - materialProperties["TWO_MU"] = two_mu; - materialProperties["LAMBDA"] = lambda; - materialProperties["DILATATIONAL_MODULUS"] = dilatational_modulus; - - lame::Material * matmodel = lame::Elastic::createMaterial( materialProperties ); - - //---------------------------------- - - APSHex8ug hex_element; - - lame::matParams materialParameters; - materialParameters.dt = dt; - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - // [4] = Parallel swap-add of internal force - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case #14" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::io::MeshData mesh_data; - std::string filename = working_directory + mesh_filename; - stk_classic::io::create_input_mesh(mesh_type, filename, comm, - meta_data, mesh_data); - stk_classic::io::define_input_fields(mesh_data, meta_data); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_1", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_2", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_10", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_20", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_30", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - { - stk_classic::mesh::Part & block_hex = meta_data.declare_part("block_40", meta_data.element_rank()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - } - - // Add property to each hex element block... - { - stk_classic::mesh::Property& delta_t = meta_data.get_meta_data(meta_data).declare_property("dt"); - stk_classic::mesh::Property& mprops = - meta_data.get_meta_data(meta_data).declare_property("materialProperties"); - - // All parts of the meta data: - const mesh::PartVector & all_parts = meta_data.get_parts(); - for (mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - - mesh::Part * const part = *i ; - if ( part->primary_entity_rank() == meta_data.element_rank()) { - const CellTopologyData *const topology = meta_data.get_cell_topology(*part).getCellTopologyData(); - if (topology->key == shards::Hexahedron<8>::key) { - - meta_data.get_meta_data(meta_data).put_property( delta_t, *part); - double* delta_t_ptr = stk_classic::mesh::property_data(delta_t, *part); - *delta_t_ptr = dt; - - meta_data.get_meta_data(meta_data).put_property(mprops, *part); - lame::MatProps* mprops_ptr = stk_classic::mesh::property_data(mprops, *part); - *mprops_ptr = materialProperties; - } - } - } - } - - Fields fields; - use_case_14_declare_fields(fields, meta_data.get_meta_data(meta_data)); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - stk_classic::mesh::BulkData bulk_data(meta_data.get_meta_data(meta_data) , comm, bucket_size); - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - //------------------------------------------------------------------ - // Create output mesh... (input filename + ".out14") - if (output) { - filename = working_directory + mesh_filename + ".out14"; - stk_classic::io::create_output_mesh(filename, comm, bulk_data, mesh_data); - stk_classic::io::define_output_fields(mesh_data, meta_data, true); - } - - stk_classic::app::use_case_14_initialize_nodal_data(bulk_data , - *fields.model_coordinates , - *fields.coordinates_field , - *fields.velocity_field, - dt); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - stk_classic::mesh::PartVector hex_parts; - - bool skip_topology_root_parts = true; - stk_classic::mesh::fem::get_parts_with_topology >(bulk_data, hex_parts, skip_topology_root_parts); - - // Reference to all node and element buckets, - // will select which ones we need later - - const std::vector< stk_classic::mesh::Bucket * > & element_buckets = bulk_data.buckets( meta_data.element_rank()); - const std::vector< stk_classic::mesh::Bucket * > & node_buckets = bulk_data.buckets( meta_data.node_rank() ); - - // Selectors for buckets: - - stk_classic::mesh::Selector select_owned_hexahedrons = - meta_data.locally_owned_part() & selectUnion(hex_parts); - - - stk_classic::mesh::Selector select_used = - meta_data.locally_owned_part() | - meta_data.globally_shared_part() ; - - // Initialize bucket fields: - - use_case_14_initialize_element_fields(fields, select_owned_hexahedrons, element_buckets, YM, PR); - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - wtime = stk_classic::wall_time(); - - MyHexInternalForceAlg elem_alg(fields, materialParameters, - matmodel, meta_data.get_meta_data(meta_data) ); - MyNodalForceScatterAlg node_alg(fields, meta_data.element_rank()); - - for(int n=0; nrun_parts( select_owned_hexahedrons , hex_parts, element_buckets , elem_alg ); - - stk_classic::mesh::PartVector empty_union_vector; - alg_runner->run( select_used , empty_union_vector, node_buckets , node_alg ); - - time_max[3] += stk_classic::wall_dtime( wtime ); - - stk_classic::mesh::parallel_reduce( bulk_data , stk_classic::mesh::sum(*fields.fint_field) ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - if (output) { - stk_classic::io::process_output_request(mesh_data, bulk_data, n); - } - - }//end for(..num_trials... - delete matmodel; - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation= " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Internal force = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Internal force (total) = " << time_min[3]*num_trials - << std::endl - << " Swap-add = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace app -} // namespace stk_classic - -MyHexInternalForceAlg::MyHexInternalForceAlg( - const stk_classic::app::Fields & fields, - lame::matParams & matParameters, - lame::Material * matModel, - stk_classic::mesh::MetaData & md) - : hex_element(), - materialParameters(matParameters), - matmodel(matModel), - m_fields(fields) -{ - // element-block property - delta_t = md.get_property("dt"); - m_materialProperties = md.get_property("materialProperties"); -} - -void -MyHexInternalForceAlg::apply( - stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend , - const stk_classic::mesh::PartVector & parts ) const -{ - enum { num_nodes = 8, - num_nodes_X_3 = 24 }; - - if (parts.size() != 1) { - std::cout << "MyHexInternalForceAlg::apply ERROR, expect parts.size() == 1."<::const_iterator - iter = elem_relations.first; - iter != elem_relations.second; ++iter) { - - stk_classic::mesh::Entity* elem = iter->entity(); - - int local_node = iter->identifier(); - - int elem_offset = local_node*num_dof; - - const double* f_new = field_data( *force_new_field, *elem ) + elem_offset; - - fint[0] += f_new[0]; - fint[1] += f_new[1]; - fint[2] += f_new[2]; - } - fint += num_dof; - } -} - diff --git a/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.hpp b/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.hpp deleted file mode 100644 index 86cd78074081..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/AppUseCase_14.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef USECASE_14_HPP -#define USECASE_14_HPP - -int use_case_14(); - -#include -#include - -typedef stk_classic::mesh::Field VectorField ; - -class MyHexInternalForceAlg -{ -public: - MyHexInternalForceAlg(const stk_classic::app::Fields &fields, - lame::matParams &matParameters, - lame::Material *matModel, - stk_classic::mesh::MetaData &md); - - enum { maximum_entity_count = 1000 }; - - void apply( stk_classic::mesh::Bucket::iterator , - stk_classic::mesh::Bucket::iterator , - const stk_classic::mesh::PartVector & ) const ; - -private: - MyHexInternalForceAlg& operator=(const MyHexInternalForceAlg&); - MyHexInternalForceAlg(const MyHexInternalForceAlg&); - - APSHex8ug hex_element; - lame::matParams & materialParameters; - stk_classic::mesh::Property * delta_t; - stk_classic::mesh::Property * m_materialProperties; - lame::Material * matmodel; - - stk_classic::app::Fields m_fields; -}; - -//-------------------------------------------------------------------- -//-------------------------------------------------------------------- - -class MyNodalForceScatterAlg -{ -public: - MyNodalForceScatterAlg(const stk_classic::app::Fields &fields, stk_classic::mesh::EntityRank element_rank); - - enum { maximum_entity_count = 0 }; /**< Don't slice the buckets */ - - void apply( stk_classic::mesh::Bucket::iterator , - stk_classic::mesh::Bucket::iterator ) const ; - - -private: - MyNodalForceScatterAlg& operator=(const MyNodalForceScatterAlg&); - MyNodalForceScatterAlg(const MyNodalForceScatterAlg&); - - ElementNodeVectorField * force_new_field; - VectorField * fint_field; - stk_classic::mesh::EntityRank m_elementRank; -}; - -#undef INLINE /* */ - -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/app/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/app/CMakeLists.txt deleted file mode 100644 index a41c2ad811f3..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_io) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../seacas/libraries/ioss/src) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_use_cases_app - SOURCES ${SOURCES} - DEPLIBS stkclassic_io - NAME stk_app_use_case_14 - ARGS "--use_case_14 --mesh gen:10x10x10 --trials 30" - COMM serial mpi - NUM_MPI_PROCS 2 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_10.hpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_10.hpp deleted file mode 100644 index 7f9d99a28079..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_10.hpp +++ /dev/null @@ -1,1691 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef USECASE_10_HPP -#define USECASE_10_HPP - - -#include -#include -#include -#include -#include -#include - -using std::sqrt; - - -#ifdef COMMENT_OUT - -typedef int Int; -typedef double Real; - -// -// Defined numerical constants -// -const double ONE12TH = (1.0/12.0); -// -// Indexes into a 4 by 3 matrix of hourglass constants -// -const int HG_X1 = 0; -const int HG_Y1 = 1; -const int HG_Z1 = 2; -const int HG_X2 = 3; -const int HG_Y2 = 4; -const int HG_Z2 = 5; -const int HG_X3 = 6; -const int HG_Y3 = 7; -const int HG_Z3 = 8; -const int HG_X4 = 9; -const int HG_Y4 = 10; -const int HG_Z4 = 11; -// -// Indexes into a 3 by 3 symmetric tensor stored as a length 6 vector -// -const int K_S_XX = 0; -const int K_S_YY = 1; -const int K_S_ZZ = 2; -const int K_S_XY = 3; -const int K_S_YZ = 4; -const int K_S_ZX = 5; -const int K_S_YX = 3; -const int K_S_ZY = 4; -const int K_S_XZ = 5; -// -// Indexes into a full 3 by 3 tensor stored as a length 9 vector -// -const int K_F_XX = 0; -const int K_F_YY = 1; -const int K_F_ZZ = 2; -const int K_F_XY = 3; -const int K_F_YZ = 4; -const int K_F_ZX = 5; -const int K_F_YX = 6; -const int K_F_ZY = 7; -const int K_F_XZ = 8; -// -// Indexes into a 3 by 3 skew symmetric tensor stored as a length 9 vector -// -const int K_V_XY = 0; -const int K_V_YZ = 1; -const int K_V_ZX = 2; -// -// Indexes into a 2 by 2 symmetric tensor stored as a length 3 vector -// -const int K_S_21_XX = 0; -const int K_S_21_YY = 1; -const int K_S_21_XY = 2; -const int K_S_21_YX = 2; -// -// Indexes into a full 2 by 2 tensor stored as a length 3 vector -// -const int K_F_22_XX = 0; -const int K_F_22_YY = 1; -const int K_F_22_XY = 2; -const int K_F_22_YX = 3; - -namespace APS { -namespace Hex { - -//*************************************************************************************************************** -// -// Additive decomposition for a gradient operator -// -// Input: -// gradient(9) Input velocity gradient -// -// Output: -// stretching(6) -// vorticity(3) -// -//*************************************************************************************************************** -template -inline void additive_decomp36(const T *const gradient, T *const stretching, T *const vorticity) { - // - // Symmetric part - // - stretching[K_S_XX] = gradient[K_F_XX]; - stretching[K_S_YY] = gradient[K_F_YY]; - stretching[K_S_ZZ] = gradient[K_F_ZZ]; - stretching[K_S_XY] = 0.5*(gradient[K_F_XY] + gradient[K_F_YX]); - stretching[K_S_YZ] = 0.5*(gradient[K_F_YZ] + gradient[K_F_ZY]); - stretching[K_S_ZX] = 0.5*(gradient[K_F_ZX] + gradient[K_F_XZ]); - // - // Skew Symmetric part - // - vorticity[K_V_XY] = 0.5*(gradient[K_F_XY] - gradient[K_F_YX]); - vorticity[K_V_YZ] = 0.5*(gradient[K_F_YZ] - gradient[K_F_ZY]); - vorticity[K_V_ZX] = 0.5*(gradient[K_F_ZX] - gradient[K_F_XZ]); -} - -//*************************************************************************************************************** -// -// Polar decomposition of a stretching tensor -// -// Input -// dt Time multiplication factor -// stretching(6) Current element stretching tensor -// vorticity(3) The skew symmetric portion of the velocity gradient -// rotation_old(9) Old element rotation tensor -// Output -// stretch(6) New calculated element stretch -// rotation_new(9) New element rotation tensor -// -//*************************************************************************************************************** -template -inline void polar_decomp33r2(const T dt, - const T *const stretching, - const T *const vorticity, - const T *const rotation_old, - T *const stretch, - T *const rotation_new) -{ - // - // calculate the rates of rotation via gauss elimination. - // - T z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - T z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - T z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - - // - // forward elimination - // - T a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - - T a4BYa1 = -stretch[K_S_XY] * a1inv; - T a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - - T a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - T a6BYa1 = -stretch[K_S_ZX] * a1inv; - T a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const T dt_half = 0.5 * dt; - T r_XX = rotation_old[K_F_XX] + dt_half*( z3 * rotation_old[K_F_YX] - z2 * rotation_old[K_F_ZX] ); - T r_YX = rotation_old[K_F_YX] + dt_half*( z1 * rotation_old[K_F_ZX] - z3 * rotation_old[K_F_XX] ); - T r_ZX = rotation_old[K_F_ZX] + dt_half*( z2 * rotation_old[K_F_XX] - z1 * rotation_old[K_F_YX] ); - T r_XY = rotation_old[K_F_XY] + dt_half*( z3 * rotation_old[K_F_YY] - z2 * rotation_old[K_F_ZY] ); - T r_YY = rotation_old[K_F_YY] + dt_half*( z1 * rotation_old[K_F_ZY] - z3 * rotation_old[K_F_XY] ); - T r_ZY = rotation_old[K_F_ZY] + dt_half*( z2 * rotation_old[K_F_XY] - z1 * rotation_old[K_F_YY] ); - T r_XZ = rotation_old[K_F_XZ] + dt_half*( z3 * rotation_old[K_F_YZ] - z2 * rotation_old[K_F_ZZ] ); - T r_YZ = rotation_old[K_F_YZ] + dt_half*( z1 * rotation_old[K_F_ZZ] - z3 * rotation_old[K_F_XZ] ); - T r_ZZ = rotation_old[K_F_ZZ] + dt_half*( z2 * rotation_old[K_F_XZ] - z1 * rotation_old[K_F_YZ] ); - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - T a12 = - dt_half * z3; - T a13 = dt_half * z2; - T b32 = - dt_half * z1; - T a22inv = 1.0 / (1.0 + a12 * a12); - - T a13a12 = a13*a12; - T a23 = b32 + a13a12; - r_YX += r_XX * a12; - r_YY += r_XY * a12; - r_YZ += r_XZ * a12; - b32 = (b32 - a13a12) * a22inv; - r_ZX += r_XX * a13 + r_YX * b32; - r_ZY += r_XY * a13 + r_YY * b32; - r_ZZ += r_XZ * a13 + r_YZ * b32; - // - // backward substitution - - // - T a33inv = 1.0 / (1.0 + a13 * a13 + a23 * b32); - - rotation_new[K_F_ZX] = r_ZX * a33inv; - rotation_new[K_F_ZY] = r_ZY * a33inv; - rotation_new[K_F_ZZ] = r_ZZ * a33inv; - rotation_new[K_F_YX] = ( r_YX - rotation_new[K_F_ZX] * a23 ) * a22inv; - rotation_new[K_F_YY] = ( r_YY - rotation_new[K_F_ZY] * a23 ) * a22inv; - rotation_new[K_F_YZ] = ( r_YZ - rotation_new[K_F_ZZ] * a23 ) * a22inv; - rotation_new[K_F_XX] = r_XX - rotation_new[K_F_ZX] * a13 - rotation_new[K_F_YX] * a12; - rotation_new[K_F_XY] = r_XY - rotation_new[K_F_ZY] * a13 - rotation_new[K_F_YY] * a12; - rotation_new[K_F_XZ] = r_XZ - rotation_new[K_F_ZZ] * a13 - rotation_new[K_F_YZ] * a12; - // - // update stretch tensor in the new configuration - - // - T a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - T a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - T a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - T b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - T b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - T b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - T s_XX = stretch[K_S_XX]; - T s_YY = stretch[K_S_YY]; - T s_ZZ = stretch[K_S_ZZ]; - T s_XY = stretch[K_S_XY]; - T s_YZ = stretch[K_S_YZ]; - T s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); -} - -template -inline void polar_decomp33_nr(const T dt, - const T *const stretching, - const T *const vorticity, - T *const stretch) { - // - // calculate the rates of rotation via gauss elimination. - // - T z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - T z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - T z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - // - // forward elimination - // - T a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - T a4BYa1 = -stretch[K_S_XY] * a1inv; - T a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - T a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - T a6BYa1 = -stretch[K_S_ZX] * a1inv; - T a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const T dt_half = 0.5 * dt; - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - T a12 = - dt_half * z3; - T a13 = dt_half * z2; - T b32 = - dt_half * z1; - T a22inv = 1.0 / (1.0 + a12 * a12); - b32 = (b32-a12 * a13) * a22inv; - // - // update stretch tensor in the new configuration - - // - { - T a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - T a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - T a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - T b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - T b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - T b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - T s_XX = stretch[K_S_XX]; - T s_YY = stretch[K_S_YY]; - T s_ZZ = stretch[K_S_ZZ]; - T s_XY = stretch[K_S_XY]; - T s_YZ = stretch[K_S_YZ]; - T s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor forward -// -// Input: -// rotation(9) Rotation tensor -// orig_tensor(6) Input symmetric tensor -// -// Output: -// rot_tensor(6) Output symmetric tensor -// -//*************************************************************************************************************** -template -inline void rotate_tensor_forward(const T *const rotation, - const T *const orig_tensor, - T *const rot_tensor) { - - T t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_YX] + orig_tensor[K_S_XZ]*rotation[K_F_ZX]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_YX] + orig_tensor[K_S_YZ]*rotation[K_F_ZX]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_YX] + orig_tensor[K_S_ZZ]*rotation[K_F_ZX]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_XY] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_ZY]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_XY] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_ZY]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_XY] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZY]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_XZ] + orig_tensor[K_S_XY]*rotation[K_F_YZ] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_XZ] + orig_tensor[K_S_YY]*rotation[K_F_YZ] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_XZ] + orig_tensor[K_S_ZY]*rotation[K_F_YZ] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_YX]*t_const[1] + rotation[K_F_ZX]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_XY]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_ZY]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_XZ]*t_const[6] + rotation[K_F_YZ]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_YX]*t_const[4] + rotation[K_F_ZX]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_XY]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_ZY]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_XZ]*t_const[0] + rotation[K_F_YZ]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor backward -// -// Input: -// rotation(9) Rotation tensor -// orig_tensor(6) Input symmetric tensor -// -// Output: -// rot_tensor(6) Output symmetric tensor -// -//*************************************************************************************************************** -template -inline void rotate_tensor_backward(const T *const rotation, - const T *const orig_tensor, - T *const rot_tensor) { - T t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_XY] + orig_tensor[K_S_XZ]*rotation[K_F_XZ]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_XY] + orig_tensor[K_S_YZ]*rotation[K_F_XZ]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_XY] + orig_tensor[K_S_ZZ]*rotation[K_F_XZ]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_YX] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_YZ]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_YX] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_YZ]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_YX] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_YZ]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_ZX] + orig_tensor[K_S_XY]*rotation[K_F_ZY] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_ZX] + orig_tensor[K_S_YY]*rotation[K_F_ZY] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_ZX] + orig_tensor[K_S_ZY]*rotation[K_F_ZY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_XY]*t_const[1] + rotation[K_F_XZ]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_YX]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_YZ]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_ZX]*t_const[6] + rotation[K_F_ZY]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_XY]*t_const[4] + rotation[K_F_XZ]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_YX]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_YZ]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_ZX]*t_const[0] + rotation[K_F_ZY]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor forward -// -// Input: -// rotation(4) Rotation tensor -// orig_tensor(3) Input symmetric tensor -// -// Output: -// rot_tensor(3) Output symmetric tensor -// -//*************************************************************************************************************** -template -inline void rotate_tensor_21_forward(const T *const rotation, const T *const orig_tensor, T *const rot_tensor){ - T t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YX]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YX]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_YX]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_XY]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_YX]*t_const[3]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor backward -// -// Input: -// rotation(4) Rotation tensor -// orig_tensor(3) Input symmetric tensor -// -// Output: -// rot_tensor(3) Output symmetric tensor -// -//*************************************************************************************************************** -template -inline void rotate_tensor_21_backward(const T *const rotation, const T *const orig_tensor, T *const rot_tensor) -{ - T t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_XY]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_XY]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_XY]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_YX]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_XY]*t_const[3]; -} - -/** - * Compute the dot product of two length 8 vectors - * - * Input - * x1(8) first vector - * x2(8) second vector - */ -template inline T ddot8(const T *const x1, const T *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2] + - x1[3] * x2[3] + - x1[4] * x2[4] + - x1[5] * x2[5] + - x1[6] * x2[6] + - x1[7] * x2[7]); -} - -/** - * Compute the dot product of two length 3 vectors - * - * Input - * x1(3) first vector - * x2(3) second vector - */ -template inline T ddot3(const T *const x1, const T *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2]); -} - -/** - * Compute the dot product of two length 8 vectors using vector striding - * - * Input - * x1(8) first vector - * x2(8) second vector - */ -template inline T ddot8_stride1_stride3(const T *const x1, const T *const x2) { - return (x1[0] * x2[ 0] + - x1[1] * x2[ 3] + - x1[2] * x2[ 6] + - x1[3] * x2[ 9] + - x1[4] * x2[12] + - x1[5] * x2[15] + - x1[6] * x2[18] + - x1[7] * x2[21]); -} - -/** - * Rotate a [3,8] matrix into a [8,3] matrix - * - * Input: - * cur_coords Old matrix - * - * Output: - * cordel_ptr New matrix - */ -template -inline void transform_38_matrix_to_83_matrix(const T *cordel_ptr, T *cur_coords) { - cur_coords[0] = cordel_ptr[0]; - cur_coords[1] = cordel_ptr[3]; - cur_coords[2] = cordel_ptr[6]; - cur_coords[3] = cordel_ptr[9]; - cur_coords[4] = cordel_ptr[12]; - cur_coords[5] = cordel_ptr[15]; - cur_coords[6] = cordel_ptr[18]; - cur_coords[7] = cordel_ptr[21]; - - cur_coords[8] = cordel_ptr[1]; - cur_coords[9] = cordel_ptr[4]; - cur_coords[10] = cordel_ptr[7]; - cur_coords[11] = cordel_ptr[10]; - cur_coords[12] = cordel_ptr[13]; - cur_coords[13] = cordel_ptr[16]; - cur_coords[14] = cordel_ptr[19]; - cur_coords[15] = cordel_ptr[22]; - - cur_coords[16] = cordel_ptr[2]; - cur_coords[17] = cordel_ptr[5]; - cur_coords[18] = cordel_ptr[8]; - cur_coords[19] = cordel_ptr[11]; - cur_coords[20] = cordel_ptr[14]; - cur_coords[21] = cordel_ptr[17]; - cur_coords[22] = cordel_ptr[20]; - cur_coords[23] = cordel_ptr[23]; -} - -/** - * Add bulk viscosity terms to a set of symmetric 3x3 tensors. Bulk viscosity terms - * will only be added to the terms on the diagonal of the tensor. - * - * Input: - * Int num_elements : Number of input tensors - * Real *bulkq : Bulk viscosity term to add - * Real *stress_in : Input set of tensors - * - * Output: - * Real *stress_out : Modified output tensors - */ -template inline void add_bulk_visc(const Int num_elements, const T* bulkq, const T* stress_in, T* stress_out) { - for(Int ielem = 0; ielem < num_elements; ++ielem) { - stress_out[K_S_XX] = stress_in[K_S_XX] + bulkq[ielem]; - stress_out[K_S_YY] = stress_in[K_S_YY] + bulkq[ielem]; - stress_out[K_S_ZZ] = stress_in[K_S_ZZ] + bulkq[ielem]; - stress_out[K_S_XY] = stress_in[K_S_XY]; - stress_out[K_S_XZ] = stress_in[K_S_XZ]; - stress_out[K_S_YZ] = stress_in[K_S_YZ]; - stress_out += 6; - stress_in += 6; - } -} - - /** - * Compute the aspect ratio for an element - * - * Input: - * gradop12x(24) 12 times the gradient operator - * volume12x 12 times the element volume - */ - template - inline T comp_aspect(const T *const gradop12x, const T &volume12x) { - return 6.0 * volume12x / - (gradop12x[0] * gradop12x[0]+ - gradop12x[1] * gradop12x[1]+ - gradop12x[2] * gradop12x[2]+ - gradop12x[3] * gradop12x[3]+ - gradop12x[4] * gradop12x[4]+ - gradop12x[5] * gradop12x[5]+ - gradop12x[6] * gradop12x[6]+ - gradop12x[7] * gradop12x[7]+ - gradop12x[8] * gradop12x[8]+ - gradop12x[9] * gradop12x[9]+ - gradop12x[10] * gradop12x[10]+ - gradop12x[11] * gradop12x[11]+ - gradop12x[12] * gradop12x[12]+ - gradop12x[13] * gradop12x[13]+ - gradop12x[14] * gradop12x[14]+ - gradop12x[15] * gradop12x[15]+ - gradop12x[16] * gradop12x[16]+ - gradop12x[17] * gradop12x[17]+ - gradop12x[18] * gradop12x[18]+ - gradop12x[19] * gradop12x[19]+ - gradop12x[20] * gradop12x[20]+ - gradop12x[21] * gradop12x[21]+ - gradop12x[22] * gradop12x[22]+ - gradop12x[23] * gradop12x[23]); - } - - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations after the element stress calculation - * - * Input: - * Int nelem Number of elements in workset - * Int dt Last step time step - * Real *cordel Element nodal coordinates - * Real *vel Element nodal velocities - * Real *rotation elemetn rotation tensor - * Real *stress_new The new element stress - * Real *rotated_stretching The element stretching rate tensor - * Real *spin_rate rigid body elemetn spining rate - * Real linBulkVisc Linear artificial bulk viscosity parameter - * Real quadBulkVisc Quadradic bulk viscosity parameter - * Real *elem_mass The element mass - * Real *elem_dilmod Element dilatation modulus as computed by the effective modulus routine - * Real *elem_shrmod Element shear modulus as coputed by the effective modulus routine - * Real hg_stiffness Element hourglass stiffness scaling constant - * Real hg_viscosity Element hourglass viscosity scaling constant - * - * Output: - * Real *rotated_stress Element rotated stress tensor - * Real min_elem_time_step New mimumum element based time step - * Real *volume Element end of step volume - * Real *elem_time_step Element time steps on per element basis - * Real *hg_resist_old Old hourglass resitance rate - * Real *hg_resist_new New hourglass resistance rate - * Real *force_new Computed internal force - * Real *hg_energy Per element hourglass force energy - * Real *int_energy Per element internal energy - * - * ********************************************************************************************** - */ - - //*************************************************************************************************************** - // - // Compute a set of 8 components for a gradient operator. - // - // 48*3 = 144 multiplications. - // - // Input - // grad_ptr(24) Array in which to store the current gradient operator components - // x(8) X nodal coordinates - // y(8) Y nodal coorindates - // z(8) Z nodal coordinates - // - //*************************************************************************************************************** - template - inline - void comp_grad12x(T *const grad_ptr, const T* const x, const T *const y, const T *const z) { - T R42=(z[3] - z[1]); - T R52=(z[4] - z[1]); - T R54=(z[4] - z[3]); - - T R63=(z[5] - z[2]); - T R83=(z[7] - z[2]); - T R86=(z[7] - z[5]); - - T R31=(z[2] - z[0]); - T R61=(z[5] - z[0]); - T R74=(z[6] - z[3]); - - T R72=(z[6] - z[1]); - T R75=(z[6] - z[4]); - T R81=(z[7] - z[0]); - - T t1 =(R63 + R54); - T t2 =(R61 + R74); - T t3 =(R72 + R81); - T t4 =(R86 + R42); - T t5 =(R83 + R52); - T t6 =(R75 + R31); - - grad_ptr[0] = (y[1] * t1) - (y[2] * R42) - (y[3] * t5) + (y[4] * t4) + (y[5] * R52) - (y[7] * R54); - grad_ptr[1] = (y[2] * t2) + (y[3] * R31) - (y[0] * t1) - (y[5] * t6) + (y[6] * R63) - (y[4] * R61); - grad_ptr[2] = (y[3] * t3) + (y[0] * R42) - (y[1] * t2) - (y[6] * t4) + (y[7] * R74) - (y[5] * R72); - grad_ptr[3] = (y[0] * t5) - (y[1] * R31) - (y[2] * t3) + (y[7] * t6) + (y[4] * R81) - (y[6] * R83); - grad_ptr[4] = (y[5] * t3) + (y[6] * R86) - (y[7] * t2) - (y[0] * t4) - (y[3] * R81) + (y[1] * R61); - grad_ptr[5] = (y[6] * t5) - (y[4] * t3) - (y[7] * R75) + (y[1] * t6) - (y[0] * R52) + (y[2] * R72); - grad_ptr[6] = (y[7] * t1) - (y[5] * t5) - (y[4] * R86) + (y[2] * t4) - (y[1] * R63) + (y[3] * R83); - grad_ptr[7] = (y[4] * t2) - (y[6] * t1) + (y[5] * R75) - (y[3] * t6) - (y[2] * R74) + (y[0] * R54); - - R42=(x[3] - x[1]); - R52=(x[4] - x[1]); - R54=(x[4] - x[3]); - - R63=(x[5] - x[2]); - R83=(x[7] - x[2]); - R86=(x[7] - x[5]); - - R31=(x[2] - x[0]); - R61=(x[5] - x[0]); - R74=(x[6] - x[3]); - - R72=(x[6] - x[1]); - R75=(x[6] - x[4]); - R81=(x[7] - x[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[8 ] = (z[1] * t1) - (z[2] * R42) - (z[3] * t5) + (z[4] * t4) + (z[5] * R52) - (z[7] * R54); - grad_ptr[9 ] = (z[2] * t2) + (z[3] * R31) - (z[0] * t1) - (z[5] * t6) + (z[6] * R63) - (z[4] * R61); - grad_ptr[10] = (z[3] * t3) + (z[0] * R42) - (z[1] * t2) - (z[6] * t4) + (z[7] * R74) - (z[5] * R72); - grad_ptr[11] = (z[0] * t5) - (z[1] * R31) - (z[2] * t3) + (z[7] * t6) + (z[4] * R81) - (z[6] * R83); - grad_ptr[12] = (z[5] * t3) + (z[6] * R86) - (z[7] * t2) - (z[0] * t4) - (z[3] * R81) + (z[1] * R61); - grad_ptr[13] = (z[6] * t5) - (z[4] * t3) - (z[7] * R75) + (z[1] * t6) - (z[0] * R52) + (z[2] * R72); - grad_ptr[14] = (z[7] * t1) - (z[5] * t5) - (z[4] * R86) + (z[2] * t4) - (z[1] * R63) + (z[3] * R83); - grad_ptr[15] = (z[4] * t2) - (z[6] * t1) + (z[5] * R75) - (z[3] * t6) - (z[2] * R74) + (z[0] * R54); - - R42=(y[3] - y[1]); - R52=(y[4] - y[1]); - R54=(y[4] - y[3]); - - R63=(y[5] - y[2]); - R83=(y[7] - y[2]); - R86=(y[7] - y[5]); - - R31=(y[2] - y[0]); - R61=(y[5] - y[0]); - R74=(y[6] - y[3]); - - R72=(y[6] - y[1]); - R75=(y[6] - y[4]); - R81=(y[7] - y[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[16] = (x[1] * t1) - (x[2] * R42) - (x[3] * t5) + (x[4] * t4) + (x[5] * R52) - (x[7] * R54); - grad_ptr[17] = (x[2] * t2) + (x[3] * R31) - (x[0] * t1) - (x[5] * t6) + (x[6] * R63) - (x[4] * R61); - grad_ptr[18] = (x[3] * t3) + (x[0] * R42) - (x[1] * t2) - (x[6] * t4) + (x[7] * R74) - (x[5] * R72); - grad_ptr[19] = (x[0] * t5) - (x[1] * R31) - (x[2] * t3) + (x[7] * t6) + (x[4] * R81) - (x[6] * R83); - grad_ptr[20] = (x[5] * t3) + (x[6] * R86) - (x[7] * t2) - (x[0] * t4) - (x[3] * R81) + (x[1] * R61); - grad_ptr[21] = (x[6] * t5) - (x[4] * t3) - (x[7] * R75) + (x[1] * t6) - (x[0] * R52) + (x[2] * R72); - grad_ptr[22] = (x[7] * t1) - (x[5] * t5) - (x[4] * R86) + (x[2] * t4) - (x[1] * R63) + (x[3] * R83); - grad_ptr[23] = (x[4] * t2) - (x[6] * t1) + (x[5] * R75) - (x[3] * t6) - (x[2] * R74) + (x[0] * R54); - } - - //*************************************************************************************************************** - // - // Compute the hourglass operator - // - // Input: - // x_ptr, y_ptr, z_ptr The x, y, and z nodal coordinates - // - // gradop12x_ptr_x 12 times the gradient operator components - // gradop12x_ptr_y 12 times the gradient operator components - // gradop12x_ptr_z 12 times the gradient operator components - // - // volinv12th The inverse of the element voluem, times one 12th - // - //*************************************************************************************************************** - template - inline - void comp_hgop(const T *const x, const T *const y, const T * const z, - const T *const gradop12x_ptr_x, - const T *const gradop12x_ptr_y, - const T *const gradop12x_ptr_z, - const T volinv12th, - T *const hgop) { - - // - // KHP: Perhaps, this static array should be passed in from the calling - // routine? - // - static const T hgop_arr[32] = { 1.0, 1.0,-1.0,-1.0,-1.0,-1.0, 1.0, 1.0, - 1.0,-1.0,-1.0, 1.0,-1.0, 1.0, 1.0,-1.0, - 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, - -1.0, 1.0,-1.0, 1.0, 1.0,-1.0, 1.0,-1.0}; - - // KHP: Alternatively, we could have - // hx0,hx1,hx2,hx3,...,hz0,hz1,hz2,hz3 - static T hgconst12th[12]; - - T t0 = x[0] - x[1]; - T t1 = x[2] - x[3]; - T t2 = x[4] - x[5]; - T t3 = x[6] - x[7]; - - hgconst12th[0] = ( (x[0]+x[1]) - (x[2]+x[3]) - (x[4]+x[5]) + (x[6]+x[7]) ) * volinv12th; - hgconst12th[1] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[2] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[3] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (y[0] - y[1]); - t1 = (y[2] - y[3]); - t2 = (y[4] - y[5]); - t3 = (y[6] - y[7]); - - hgconst12th[4] = ( (y[0]+y[1]) - (y[2]+y[3]) - (y[4]+y[5]) + (y[6]+y[7]) ) * volinv12th; - hgconst12th[5] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[6] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[7] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (z[0] - z[1]); - t1 = (z[2] - z[3]); - t2 = (z[4] - z[5]); - t3 = (z[6] - z[7]); - - hgconst12th[8] = ( (z[0]+z[1]) - (z[2]+z[3]) - (z[4]+z[5]) + (z[6]+z[7]) ) * volinv12th; - hgconst12th[9] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[10] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[11] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - // 8 times 12 = 96 + 12 = 108 multiplications. - for(int i = 0; i < 8; ++i) { - hgop[i ] = hgop_arr[i ] - (hgconst12th[0] * gradop12x_ptr_x[i] + hgconst12th[4] * gradop12x_ptr_y[i] + hgconst12th[8 ] * gradop12x_ptr_z[i]); - hgop[i+8 ] = hgop_arr[i+8 ] - (hgconst12th[1] * gradop12x_ptr_x[i] + hgconst12th[5] * gradop12x_ptr_y[i] + hgconst12th[9 ] * gradop12x_ptr_z[i]); - hgop[i+16] = hgop_arr[i+16] - (hgconst12th[2] * gradop12x_ptr_x[i] + hgconst12th[6] * gradop12x_ptr_y[i] + hgconst12th[10] * gradop12x_ptr_z[i]); - hgop[i+24] = hgop_arr[i+24] - (hgconst12th[3] * gradop12x_ptr_x[i] + hgconst12th[7] * gradop12x_ptr_y[i] + hgconst12th[11] * gradop12x_ptr_z[i]); - } - } - - //*************************************************************************************************************** - // - // Compute the new internal forces, hg resistances, and element energies - // - // Input: - // dt last time step - // spin_rate_ptr pointer into the spin rate array - // hgop element hourglass operator - // vel_ptr element velocity - // fac1 hourglass stiffness resitance factor - // fac2 hourglass viscosity resitance factor - // hg_resist_old_ptr Old hourglass resitances - // - // Output: - // hg_resist_new_ptr New hourglass resitances - // hg_resist_total_ptr Total hourglass resistance - // - //*************************************************************************************************************** - - template - inline - void comp_force(const T &dt, - const T *const spin_rate_ptr, - const T *const hgop_for_resist_calc, - const T *const hgop_ptr0, - const T *const hgop_ptr1, - const T *const hgop_ptr2, - const T *const hgop_ptr3, - const T *const vel, - const T &fac1, - const T &fac2, - const T *const hg_resist_old, - T *const hg_resist_new, - const T *const total_stress12th, - const T *const gradop12x_ptr_x, - const T *const gradop12x_ptr_y, - const T *const gradop12x_ptr_z, - T *const hg_energy, - T *const int_energy, - T *const force_new, - bool scaleHGRotation) { - - static T dwxy, dwyz, dwzx; - static const T *hgop_ptr; - static const T *vel_ptr; - static const T *hg_resist_old_ptr; - static T *hg_resist_total_ptr; - static T *hg_resist_new_ptr; - static T *hg_energy_ptr; - static T *int_energy_ptr; - static T *force_new_ptr; - static T hg_rate[3]; - static T hg_resist_total[12]; - static T hg_force[3]; - static T rot_hg_resist_old[3]; - static T fnorm; - // - // NKC, does Presto T need these spin rate terms? Pronto appears to have dumped them.... - // - dwxy = dt * spin_rate_ptr[0]; - dwyz = dt * spin_rate_ptr[1]; - dwzx = dt * spin_rate_ptr[2]; - // - // Compute new hourglass resitance by the old rotated hourglass resitance plus a hourglass rate term - // - hgop_ptr = hgop_for_resist_calc; - hg_resist_total_ptr = hg_resist_total; - vel_ptr = vel; - hg_resist_old_ptr = hg_resist_old; - hg_resist_new_ptr = hg_resist_new; - hg_energy_ptr = hg_energy; - int_energy_ptr = int_energy; - force_new_ptr = force_new; - - if (!scaleHGRotation){ - for(int i = 0; i < 4; ++i) { - hg_rate[0] = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - T hg_resist_old_0 = hg_resist_old_ptr[0]; - T hg_resist_old_1 = hg_resist_old_ptr[1]; - T hg_resist_old_2 = hg_resist_old_ptr[2]; - hg_resist_new_ptr[0] = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2 + fac1* hg_rate[0]; - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2* hg_rate[0]; - hg_rate[1] = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - hg_resist_new_ptr[1] = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2 + fac1* hg_rate[1]; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2* hg_rate[1]; - hg_rate[2] = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - hg_resist_new_ptr[2] = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1 + fac1* hg_rate[2]; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2* hg_rate[2]; - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } else { - for(int i = 0; i < 4; ++i) { - hg_rate[0] = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - hg_rate[1] = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - hg_rate[2] = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - - T hg_resist_old_0 = hg_resist_old_ptr[0]; - T hg_resist_old_1 = hg_resist_old_ptr[1]; - T hg_resist_old_2 = hg_resist_old_ptr[2]; - - rot_hg_resist_old[0] = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2; - rot_hg_resist_old[1] = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2; - rot_hg_resist_old[2] = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1; - - //fnorm = rot_hg_resist_old[0]*rot_hg_resist_old[0] + rot_hg_resist_old[1]*rot_hg_resist_old[1] + rot_hg_resist_old[2]*rot_hg_resist_old[2]; - fnorm = ddot3(rot_hg_resist_old, rot_hg_resist_old); - if (fnorm > 1.e-30){ - fnorm = sqrt ( (hg_resist_old_0*hg_resist_old_0 + - hg_resist_old_1*hg_resist_old_1 + - hg_resist_old_2*hg_resist_old_2) / fnorm ); - hg_resist_new_ptr[0] = fnorm*rot_hg_resist_old[0] + fac1*hg_rate[0]; - hg_resist_new_ptr[1] = fnorm*rot_hg_resist_old[1] + fac1*hg_rate[1]; - hg_resist_new_ptr[2] = fnorm*rot_hg_resist_old[2] + fac1*hg_rate[2]; - } else { - hg_resist_new_ptr[0] = rot_hg_resist_old[0] + fac1*hg_rate[0]; - hg_resist_new_ptr[1] = rot_hg_resist_old[1] + fac1*hg_rate[1]; - hg_resist_new_ptr[2] = rot_hg_resist_old[2] + fac1*hg_rate[2]; - } - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2*hg_rate[0]; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2*hg_rate[1]; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2*hg_rate[2]; - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } - - *hg_energy_ptr = 0.0; - *int_energy_ptr = 0.0; - for(int i = 0; i < 8; ++i) { - hg_force[0] = (hg_resist_total[HG_X1] * hgop_ptr0[i] + - hg_resist_total[HG_X2] * hgop_ptr1[i] + - hg_resist_total[HG_X3] * hgop_ptr2[i] + - hg_resist_total[HG_X4] * hgop_ptr3[i]); - - force_new_ptr[0] = total_stress12th[K_S_XX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_XY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_XZ] * gradop12x_ptr_z[i] + hg_force[0]; - - hg_force[1] = (hg_resist_total[HG_Y1] * hgop_ptr0[i] + - hg_resist_total[HG_Y2] * hgop_ptr1[i] + - hg_resist_total[HG_Y3] * hgop_ptr2[i] + - hg_resist_total[HG_Y4] * hgop_ptr3[i]); - - force_new_ptr[1] = total_stress12th[K_S_YX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_YY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_YZ] * gradop12x_ptr_z[i] + hg_force[1]; - - hg_force[2] = (hg_resist_total[HG_Z1] * hgop_ptr0[i] + - hg_resist_total[HG_Z2] * hgop_ptr1[i] + - hg_resist_total[HG_Z3] * hgop_ptr2[i] + - hg_resist_total[HG_Z4] * hgop_ptr3[i]); - force_new_ptr[2] = total_stress12th[K_S_ZX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_ZY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_ZZ] * gradop12x_ptr_z[i] + hg_force[2]; - - *hg_energy_ptr += hg_force[0]*vel_ptr[0] + hg_force[1]*vel_ptr[1] + hg_force[2]*vel_ptr[2]; - *int_energy_ptr += force_new_ptr[0]*vel_ptr[0] + force_new_ptr[1]*vel_ptr[1] + force_new_ptr[2]*vel_ptr[2]; - - - force_new_ptr += 3; - vel_ptr += 3; - } - hg_energy_ptr += 1; - int_energy_ptr += 1; - } - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations required for the material stress calculations. - * - * Input: - * Int nelem Number of elements in workset - * T dt_scale Should be -0.5*delta_t, describes how to move the coordinates - * from the end of step to the mid-step using the velocities. - * T *cordel Array of element nodal coordinates - * T *vel Array of element nodal velocities - * T *rotation_old Array of old roation tensors - * - * Output: - * T *mid_volume Compute element volume from the mid step coordinates - * T *vorticity Asymmetric portion of the element stretch tensor - * T *rotation_new Updated material rotation tensors - * T *stretch New element stretch - * Real *rotated_stretching Rotated element stretching tensor - * - * ********************************************************************************************** - */ - template - inline Int elem_ug3dh8_mi_compute_stretch(const Int nelem, - const T dt, - const T *const cordel, - const T *const vel, - const T *const rotation_old, - T *const mid_vol, - T *const vorticity, - T *const rotation_new, - T *const stretch, - T *const rotated_stretching, - T *const mid_hgop) { - - // - // Extract pointers to the input variables, set up any required temporary variables. The temporaries will - // be reused by every element in the workset. - // - const T* cordel_ptr (cordel ); - const T* vel_ptr (vel ); - T * mid_vol_ptr (mid_vol ); - T * vorticity_ptr(vorticity); - const T* rotation_old_ptr(rotation_old); - T * rotation_new_ptr(rotation_new); - T * stretch_ptr(stretch); - T * rotated_stretching_ptr(rotated_stretching); - T * mid_hgop_ptr(mid_hgop); - // - // Storage for the midstep gradient operator, 12x denotes that this will actually be the midstep gradient - // operator components. - // - T mid_gradop12x[24]; - T *const mid_gradop12x_ptr_x(mid_gradop12x); - T *const mid_gradop12x_ptr_y(mid_gradop12x+8); - T *const mid_gradop12x_ptr_z(mid_gradop12x+16); - // - // Midstep coordinates - // - T mid_coords[24]; - T *const x_ptr(mid_coords); - T *const y_ptr(mid_coords+8); - T *const z_ptr(mid_coords+16); - // - // Element stretching tensor - // - T stretching_tensor[6]; - // - // Element velocity gradient - // - T vel_grad[9]; - // - // Loop over all elements in the workset - // - T dt_scale = -0.5 * dt; - - Int return_value = 0; - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Get current element coordinates and update them so that they reference the midstep - // configuration. Note, this routine changes the coordinate ordering from - // - // (x1, y1, z1, x2, y2, z2, ........) - // - // to - // - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3 ......) - // - // The array reordering allows better variable access later for optimization purposes - // - for(int i = 0; i < 8; ++i) { - x_ptr[i] = cordel_ptr[0] + dt_scale * vel_ptr[0]; - y_ptr[i] = cordel_ptr[1] + dt_scale * vel_ptr[1]; - z_ptr[i] = cordel_ptr[2] + dt_scale * vel_ptr[2]; - //std::cout << "KHP: x= " << x_ptr[i] << ", " << y_ptr[i] << ", " << z_ptr[i] << "\n"; - //std::cout << "KHP: C= " << cordel_ptr[0] << ", " << cordel_ptr[1] << ", " << cordel_ptr[2] << "\n"; - //std::cout << "KHP: V= " << vel_ptr[0] << ", " << vel_ptr[1] << ", " << vel_ptr[2] << "\n"; - cordel_ptr += 3; - vel_ptr += 3; - } - - vel_ptr -= 24; - // - // Do grad op in three seperate steps using the helper routine. - // NKC, I'm not positive what the helper is mathematically equivalent too, - // however, the combination of these three steps will compute the full gradient. - // Note, the comp12x routine actually calculates 12.0 times the gradient, this - // 12 will be factored out later. - // - comp_grad12x(mid_gradop12x, x_ptr, y_ptr, z_ptr); - - // - // Compute the midstep volume. Note that 12 times the volume is being calculated, - // The actually output value of volume is then multipled by one twelth - // - const T volume12x = ddot8(x_ptr, mid_gradop12x_ptr_x); - *mid_vol_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const T volinv12th(1.0/volume12x); - // - // Compute the velocity gradients from the dot products of the input velocities with the - // relevant columns of the gradient operator. Note that the velocity gradient is calculated - // as Velocity * 12 * mid_gradop * volinv/12, the twelves cancel. - // - // 81 multiplications (9 tensor entries * (8 mults per dot + 1 mult for volinv)) - // - vel_grad[K_F_XX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr ) * volinv12th; - vel_grad[K_F_XY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr ) * volinv12th; - vel_grad[K_F_XZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr ) * volinv12th; - vel_grad[K_F_YZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+1) * volinv12th; - vel_grad[K_F_YY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+1) * volinv12th; - vel_grad[K_F_YX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+1) * volinv12th; - vel_grad[K_F_ZX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+2) * volinv12th; - // - // Compute the stretching tensors from the current velocity gradient - // - // Let G = Gradient (velocity gradient in this case). - // Let S = Stretch - // Let V = Vorticity - // - // Then: - // - // S = 0.5 * ( G + G'); // S = 0.5 * ( G + transpose(G)); - // V = 0.5 * ( G - G'); // V = 0.5 * ( G - transpose(G)); - // - APS::Hex::additive_decomp36(vel_grad, stretching_tensor, vorticity_ptr); - - polar_decomp33r2(dt, stretching_tensor, vorticity_ptr, rotation_old_ptr, stretch_ptr, rotation_new_ptr); - - rotate_tensor_forward(rotation_new_ptr, stretching_tensor, rotated_stretching_ptr); - - // - // Compute the midstep hourglass operator if needed. Here one 12th the volume is - // multiplied by 12 times the gradient operators, so the true hourglass operator - // is computed. - // - if (mid_hgop_ptr) { - comp_hgop(x_ptr, y_ptr, z_ptr, - mid_gradop12x_ptr_x, - mid_gradop12x_ptr_y, - mid_gradop12x_ptr_z, - volinv12th, mid_hgop_ptr); - mid_hgop_ptr += 32; - } - - } else { - return_value = -1; - } - mid_vol_ptr += 1; - vel_ptr += 24; - vorticity_ptr +=3; - rotation_old_ptr += 9; - stretch_ptr += 6; - rotation_new_ptr += 9; - rotated_stretching_ptr += 6; - } - return return_value; - } - - //*********************************************************************n - // - // STANDARD PRESTO VERSION - // - // description: - // This routine is implemented for the 8 node brick, uniform strain - // element. It is the divergence operator, hourglass force operator, - // and time step calcuator. Combination of multiple routines yields - // better cache usage. - // - // Input: - // nelem Number of elements in the workset - // - // dt Previous time step - // - // cordel(24,nelem) End of step element coordinates, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // vel(24,nelem) Element nodal velocity, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // rotated_stress(6,nelem) Element stress in the rotated configuration - // - // rotated_stretching(6,nelem) Element stretch rate tensor in rotated configuration - // - // spin_rate(3,nelem) Asymmetric portion of stretching rate, represents amount element is spinning - // about each axis. - // - // linBulkVisc Linear bulk viscosity material constant - // - // quadBulkVisc Quadradic bulk viscosity material constant - // - // elem_mass(nelem) Current element masses - // - // elem_dilmod(nelem) Current material dilitational modulus - // - // elem_shrmod(nelem) Current material shear modulus - // - // hg_stiffness Hourglass stiffness parameter - // - // hg_viscosity Hourglass viscosity parameter - // - // hg_resist_old(12,nelem) Old hourglass resistance - // - // Output: - // min_elem_time_step The computed mimimum stable element time step - // - // volume(nelem) The element end of step volume - // - // elem_time_step(nelem) Time steps on a per element basis - // - // hg_resist_new(12,nelem) New hourglass resistance - // - // force_new(24,nelem) New element total internal force - // - // hg_energy(nelem) New element total hourglass energy increment - // - // int_energy(ielem) New element internal energy increment - // - // Returns, 0 if no errors, -1 if any negative volume elements were found - // - //*********************************************************************** - - template - inline - Int elem_ug3dh8_mi_compute_divergence_presto(const Int nelem, - const T dt, - const T *const cordel, - const T *const vel, - const T *const rotation, - const T *const stress_new, - const T *const rotated_stretching, - const T *const spin_rate, - const T linBulkVisc, - const T quadBulkVisc, - const T *const elem_mass, - const T *const elem_dilmod, - const T *const elem_shrmod, - const T hg_stiffness, - const T hg_viscosity, - T *const rotated_stress, - T &min_elem_time_step, - T *const volume, - T *const elem_time_step, - T *const hg_resist_old, - T *const hg_resist_new, - T *const force_new, - T *const hg_energy, - T *const int_energy, - T *const mid_hgop, - const bool scaleHGRotation) { - Int return_value = 0; - // - // Store pointers to the input variables - // - const T* cordel_ptr(cordel); - const T* vel_ptr(vel); - const T* elem_mass_ptr(elem_mass); - const T* elem_dilmod_ptr(elem_dilmod); - const T* elem_shrmod_ptr(elem_shrmod); - const T* rotated_stretching_ptr(rotated_stretching); - const T* spin_rate_ptr(spin_rate); - const T* stress_new_ptr(stress_new); - const T* rotation_ptr(rotation); - - T* rotated_stress_ptr(rotated_stress); - T* volume_ptr(volume); - T* elem_time_step_ptr(elem_time_step); - T* hg_resist_old_ptr(hg_resist_old); - T* hg_resist_new_ptr(hg_resist_new); - T* force_new_ptr(force_new); - T* hg_energy_ptr(hg_energy); - T* int_energy_ptr(int_energy); - // - // Create temporaries to be reused by every element - // - T gradop12x[24]; - T* gradop12x_ptr_x(gradop12x); - T* gradop12x_ptr_y(gradop12x+8); - T* gradop12x_ptr_z(gradop12x+16); - - T cur_coords[24]; - const T *const x_ptr(cur_coords); - const T *const y_ptr(cur_coords+8); - const T *const z_ptr(cur_coords+16); - - T total_stress12th[6]; - - T hgop[32]; - const T *const hgop_ptr0(hgop); - const T *const hgop_ptr1(hgop+8); - const T *const hgop_ptr2(hgop+16); - const T *const hgop_ptr3(hgop+24); - T * hgop_for_resist_calc(mid_hgop); - if (mid_hgop == NULL){ - hgop_for_resist_calc = hgop; - } - // - // This factor will be used in hourglass computations, however is a loop constant - // - const T fac1_pre(dt * hg_stiffness * 0.0625); - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Store local coordintes, note this changes the way coordinates are stored from - // - // (x1, y1, z1, x2, y2, z2 .......) - // to - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3, .....) - // - transform_38_matrix_to_83_matrix(cordel_ptr, cur_coords); - // - // Compute 12 times the gradient operator in three seperate steps - // - comp_grad12x(gradop12x, x_ptr, y_ptr, z_ptr); - // - // calculate 12 times the element volume, store the actual element volume - // - const T volume12x = ddot8(x_ptr, gradop12x); - *volume_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const T volinv12th(1.0/volume12x); - // - // Compute the aspect ratio. Aspect ratio is 0.5 * volume / (grad . grad) - // With the 12 factors this is actually 6.0 * 12 * volume / (12 * grad . 12 * grad) - // - const T aspect = comp_aspect(gradop12x, volume12x); - const T aspect_inv = 1.0/aspect; - // - // Compute the stable time step and bulk viscosity - // - const T dtrial(sqrt(elem_mass_ptr[0] * aspect / elem_dilmod_ptr[0])); - - const T traced(rotated_stretching_ptr[0] + rotated_stretching_ptr[1] + rotated_stretching_ptr[2]); - - const T eps(linBulkVisc - quadBulkVisc * std::min(0.0, traced)*dtrial); - - const T bulkq = eps * elem_dilmod_ptr[0] *dtrial *traced; - - const T cur_time_step = dtrial * ( sqrt( 1.0 + eps * eps) - eps); - *elem_time_step_ptr = cur_time_step; - min_elem_time_step = std::min(min_elem_time_step, cur_time_step); - // - // Rotate the stress - // - rotate_tensor_backward(rotation_ptr, stress_new_ptr, rotated_stress_ptr); - // - // Compute the total stress (includes bulk viscosity terms) - // - total_stress12th[0] = ONE12TH*(rotated_stress_ptr[0] + bulkq); - total_stress12th[1] = ONE12TH*(rotated_stress_ptr[1] + bulkq); - total_stress12th[2] = ONE12TH*(rotated_stress_ptr[2] + bulkq); - total_stress12th[3] = ONE12TH*(rotated_stress_ptr[3]); - total_stress12th[4] = ONE12TH*(rotated_stress_ptr[4]); - total_stress12th[5] = ONE12TH*(rotated_stress_ptr[5]); - // - // Compute the hourglass operator. Here one 12th the volume is multiplied by - // 12 times the gradient operators, so the true hourglass operator is computed. - // - comp_hgop(x_ptr, y_ptr, z_ptr, - gradop12x_ptr_x, - gradop12x_ptr_y, - gradop12x_ptr_z, - volinv12th, hgop); - // - // Compute the hourglass resistance terms. These are based on the hourglass stiffness and hourglass viscosities - // - const T fac1 = fac1_pre * elem_shrmod_ptr[0] * aspect_inv; - const T fac2 = hg_viscosity * sqrt(elem_shrmod_ptr[0] * elem_mass_ptr[0] * aspect_inv); - comp_force(dt, - spin_rate_ptr, - hgop_for_resist_calc, - hgop_ptr0, hgop_ptr1, hgop_ptr2, hgop_ptr3, - vel_ptr, fac1, fac2, hg_resist_old_ptr, hg_resist_new_ptr, - total_stress12th, - gradop12x_ptr_x, gradop12x_ptr_y, gradop12x_ptr_z, - hg_energy_ptr, int_energy_ptr, force_new_ptr, scaleHGRotation); - } else { - return_value = -1; - } - cordel_ptr += 24; - vel_ptr += 24; - volume_ptr += 1; - rotated_stretching_ptr += 6; - elem_mass_ptr += 1; - elem_dilmod_ptr += 1; - elem_shrmod_ptr += 1; - elem_time_step_ptr += 1; - rotation_ptr += 9; - stress_new_ptr += 6; - rotated_stress_ptr += 6; - spin_rate_ptr += 3; - hg_resist_old_ptr += 12; - hg_resist_new_ptr += 12; - hg_energy_ptr += 1; - int_energy_ptr += 1; - force_new_ptr += 24; - if (mid_hgop){ - hgop_for_resist_calc += 32; - } - } - return return_value; - } - - } // end namespace Hex -} // end namespace APS - -#endif - -class APSTet4nug { - public: - APSTet4nug() {} - ~APSTet4nug() {} - int num_nodes() const { return 4; } - /* - int compute_stretch( const int num_elements, - const double dt, - const double *coordinates, - const double *velocity, - const double *rotation_old, - double *volume, - double *vorticity_tensor, - double *rotation_new, - double *stretch, - double *strain_rate, - double *mid_hgop, - bool debug = false - ) const { - int err = APS::Hex::elem_ug3dh8_mi_compute_stretch(num_elements, - dt, - coordinates, - velocity, - rotation_old, - volume, - vorticity_tensor, - rotation_new, - stretch, - strain_rate, - mid_hgop); - - return err; - } - - int internalForce( const int num_elements, - const double dt, - double current_stable_time_step, - double element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - std::vector &coordinates, - std::vector &velocity, - std::vector &rotation_old, std::vector &rotation_new, - std::vector &midstep_volume, - std::vector &vorticity_tensor, - std::vector &stretch, - std::vector &strain_rate, - std::vector &mid_hgop, - std::vector &stress_old, std::vector &stress_new, - std::vector &rotated_stress, - std::vector &material_eff_bulk_mod, - std::vector &material_eff_twomu, - std::vector &shrmod, - std::vector &dilmod, - std::vector &element_mass, - std::vector &force_new, - std::vector &hourglass_energy, - std::vector &internal_energy, - std::vector &hg_resistance_old, std::vector &hg_resistance_new - ) const { - - compute_stretch(num_elements, dt, &coordinates[0], &velocity[0], &rotation_old[0], &midstep_volume[0], &vorticity_tensor[0], &rotation_new[0], &stretch[0], &strain_rate[0], &mid_hgop[0]); - - Int err = material_model.getStress(&materialParameters); - - double dilatationalHGParam = 0.05; - double deviatoricHGParam = 0.0; - - for(int k=0; k 0.0) ? 1.0 / dt : 1.0; - - for ( int i = 0 ; i < 24 ; i++ ) { - vel[i] *= dt_inv; - } - } - private: - double * dgrad; -}; - -#endif -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Common.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Common.cpp deleted file mode 100644 index 594b17bac693..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Common.cpp +++ /dev/null @@ -1,1758 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -typedef int Int; -typedef double Real; - - -// -// Defined numerical constants -// -const double ONE12TH = (1.0/12.0); -// -// Indexes into a 4 by 3 matrix of hourglass constants -// -const int HG_X1 = 0; -const int HG_Y1 = 1; -const int HG_Z1 = 2; -const int HG_X2 = 3; -const int HG_Y2 = 4; -const int HG_Z2 = 5; -const int HG_X3 = 6; -const int HG_Y3 = 7; -const int HG_Z3 = 8; -const int HG_X4 = 9; -const int HG_Y4 = 10; -const int HG_Z4 = 11; -// -// Indexes into a 3 by 3 symmetric tensor stored as a length 6 vector -// -const int K_S_XX = 0; -const int K_S_YY = 1; -const int K_S_ZZ = 2; -const int K_S_XY = 3; -const int K_S_YZ = 4; -const int K_S_ZX = 5; -const int K_S_YX = 3; -const int K_S_ZY = 4; -const int K_S_XZ = 5; -// -// Indexes into a full 3 by 3 tensor stored as a length 9 vector -// -const int K_F_XX = 0; -const int K_F_YY = 1; -const int K_F_ZZ = 2; -const int K_F_XY = 3; -const int K_F_YZ = 4; -const int K_F_ZX = 5; -const int K_F_YX = 6; -const int K_F_ZY = 7; -const int K_F_XZ = 8; -// -// Indexes into a 3 by 3 skew symmetric tensor stored as a length 9 vector -// -const int K_V_XY = 0; -const int K_V_YZ = 1; -const int K_V_ZX = 2; -// -// Indexes into a 2 by 2 symmetric tensor stored as a length 3 vector -// -const int K_S_21_XX = 0; -const int K_S_21_YY = 1; -const int K_S_21_XY = 2; -const int K_S_21_YX = 2; -// -// Indexes into a full 2 by 2 tensor stored as a length 3 vector -// -const int K_F_22_XX = 0; -const int K_F_22_YY = 1; -const int K_F_22_XY = 2; -const int K_F_22_YX = 3; - -namespace APS { -namespace Hex { - -//*************************************************************************************************************** -// -// Additive decomposition for a gradient operator -// -// Input: -// gradient(9) Input velocity gradient -// -// Output: -// stretching(6) -// vorticity(3) -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void additive_decomp36(const Scalar *const gradient, Scalar *const stretching, Scalar *const vorticity) { - // - // Symmetric part - // - stretching[K_S_XX] = gradient[K_F_XX]; - stretching[K_S_YY] = gradient[K_F_YY]; - stretching[K_S_ZZ] = gradient[K_F_ZZ]; - stretching[K_S_XY] = 0.5*(gradient[K_F_XY] + gradient[K_F_YX]); - stretching[K_S_YZ] = 0.5*(gradient[K_F_YZ] + gradient[K_F_ZY]); - stretching[K_S_ZX] = 0.5*(gradient[K_F_ZX] + gradient[K_F_XZ]); - // - // Skew Symmetric part - // - vorticity[K_V_XY] = 0.5*(gradient[K_F_XY] - gradient[K_F_YX]); - vorticity[K_V_YZ] = 0.5*(gradient[K_F_YZ] - gradient[K_F_ZY]); - vorticity[K_V_ZX] = 0.5*(gradient[K_F_ZX] - gradient[K_F_XZ]); -} - -//*************************************************************************************************************** -// -// Polar decomposition of a stretching tensor -// -// Input -// dt Time multiplication factor -// stretching(6) Current element stretching tensor -// vorticity(3) The skew symmetric portion of the velocity gradient -// rotation_old(9) Old element rotation tensor -// Output -// stretch(6) New calculated element stretch -// rotation_new(9) New element rotation tensor -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void polar_decomp33r2(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - const Scalar *const rotation_old, - Scalar *const stretch, - Scalar *const rotation_new) -{ - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - - // - // forward elimination - // - const Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - - const Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - const Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - - const Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - const Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - const Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - Scalar r_XX = rotation_old[K_F_XX] + dt_half*( z3 * rotation_old[K_F_YX] - z2 * rotation_old[K_F_ZX] ); - Scalar r_YX = rotation_old[K_F_YX] + dt_half*( z1 * rotation_old[K_F_ZX] - z3 * rotation_old[K_F_XX] ); - Scalar r_ZX = rotation_old[K_F_ZX] + dt_half*( z2 * rotation_old[K_F_XX] - z1 * rotation_old[K_F_YX] ); - Scalar r_XY = rotation_old[K_F_XY] + dt_half*( z3 * rotation_old[K_F_YY] - z2 * rotation_old[K_F_ZY] ); - Scalar r_YY = rotation_old[K_F_YY] + dt_half*( z1 * rotation_old[K_F_ZY] - z3 * rotation_old[K_F_XY] ); - Scalar r_ZY = rotation_old[K_F_ZY] + dt_half*( z2 * rotation_old[K_F_XY] - z1 * rotation_old[K_F_YY] ); - Scalar r_XZ = rotation_old[K_F_XZ] + dt_half*( z3 * rotation_old[K_F_YZ] - z2 * rotation_old[K_F_ZZ] ); - Scalar r_YZ = rotation_old[K_F_YZ] + dt_half*( z1 * rotation_old[K_F_ZZ] - z3 * rotation_old[K_F_XZ] ); - Scalar r_ZZ = rotation_old[K_F_ZZ] + dt_half*( z2 * rotation_old[K_F_XZ] - z1 * rotation_old[K_F_YZ] ); - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - - Scalar a13a12 = a13*a12; - Scalar a23 = b32 + a13a12; - r_YX += r_XX * a12; - r_YY += r_XY * a12; - r_YZ += r_XZ * a12; - b32 = (b32 - a13a12) * a22inv; - r_ZX += r_XX * a13 + r_YX * b32; - r_ZY += r_XY * a13 + r_YY * b32; - r_ZZ += r_XZ * a13 + r_YZ * b32; - // - // backward substitution - - // - const Scalar a33inv = 1.0 / (1.0 + a13 * a13 + a23 * b32); - - rotation_new[K_F_ZX] = r_ZX * a33inv; - rotation_new[K_F_ZY] = r_ZY * a33inv; - rotation_new[K_F_ZZ] = r_ZZ * a33inv; - rotation_new[K_F_YX] = ( r_YX - rotation_new[K_F_ZX] * a23 ) * a22inv; - rotation_new[K_F_YY] = ( r_YY - rotation_new[K_F_ZY] * a23 ) * a22inv; - rotation_new[K_F_YZ] = ( r_YZ - rotation_new[K_F_ZZ] * a23 ) * a22inv; - rotation_new[K_F_XX] = r_XX - rotation_new[K_F_ZX] * a13 - rotation_new[K_F_YX] * a12; - rotation_new[K_F_XY] = r_XY - rotation_new[K_F_ZY] * a13 - rotation_new[K_F_YY] * a12; - rotation_new[K_F_XZ] = r_XZ - rotation_new[K_F_ZZ] * a13 - rotation_new[K_F_YZ] * a12; - // - // update stretch tensor in the new configuration - - // - const Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - const Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - const Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - const Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - const Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - const Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - const Scalar s_XX = stretch[K_S_XX]; - const Scalar s_YY = stretch[K_S_YY]; - const Scalar s_ZZ = stretch[K_S_ZZ]; - const Scalar s_XY = stretch[K_S_XY]; - const Scalar s_YZ = stretch[K_S_YZ]; - const Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); -} - -TEMPLATE_SCALAR -INLINE void polar_decomp33_nr(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - Scalar *const stretch) { - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - // - // forward elimination - // - Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - b32 = (b32-a12 * a13) * a22inv; - // - // update stretch tensor in the new configuration - - // - { - Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - Scalar s_XX = stretch[K_S_XX]; - Scalar s_YY = stretch[K_S_YY]; - Scalar s_ZZ = stretch[K_S_ZZ]; - Scalar s_XY = stretch[K_S_XY]; - Scalar s_YZ = stretch[K_S_YZ]; - Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor forward -// -// Input: -// rotation(9) Rotation tensor -// orig_tensor(6) Input symmetric tensor -// -// Output: -// rot_tensor(6) Output symmetric tensor -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void rotate_tensor_forward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_YX] + orig_tensor[K_S_XZ]*rotation[K_F_ZX]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_YX] + orig_tensor[K_S_YZ]*rotation[K_F_ZX]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_YX] + orig_tensor[K_S_ZZ]*rotation[K_F_ZX]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_XY] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_ZY]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_XY] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_ZY]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_XY] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZY]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_XZ] + orig_tensor[K_S_XY]*rotation[K_F_YZ] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_XZ] + orig_tensor[K_S_YY]*rotation[K_F_YZ] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_XZ] + orig_tensor[K_S_ZY]*rotation[K_F_YZ] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_YX]*t_const[1] + rotation[K_F_ZX]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_XY]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_ZY]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_XZ]*t_const[6] + rotation[K_F_YZ]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_YX]*t_const[4] + rotation[K_F_ZX]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_XY]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_ZY]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_XZ]*t_const[0] + rotation[K_F_YZ]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor backward -// -// Input: -// rotation(9) Rotation tensor -// orig_tensor(6) Input symmetric tensor -// -// Output: -// rot_tensor(6) Output symmetric tensor -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void rotate_tensor_backward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_XY] + orig_tensor[K_S_XZ]*rotation[K_F_XZ]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_XY] + orig_tensor[K_S_YZ]*rotation[K_F_XZ]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_XY] + orig_tensor[K_S_ZZ]*rotation[K_F_XZ]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_YX] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_YZ]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_YX] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_YZ]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_YX] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_YZ]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_ZX] + orig_tensor[K_S_XY]*rotation[K_F_ZY] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_ZX] + orig_tensor[K_S_YY]*rotation[K_F_ZY] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_ZX] + orig_tensor[K_S_ZY]*rotation[K_F_ZY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_XY]*t_const[1] + rotation[K_F_XZ]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_YX]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_YZ]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_ZX]*t_const[6] + rotation[K_F_ZY]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_XY]*t_const[4] + rotation[K_F_XZ]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_YX]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_YZ]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_ZX]*t_const[0] + rotation[K_F_ZY]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor forward -// -// Input: -// rotation(4) Rotation tensor -// orig_tensor(3) Input symmetric tensor -// -// Output: -// rot_tensor(3) Output symmetric tensor -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void rotate_tensor_21_forward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor){ - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YX]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YX]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_YX]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_XY]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_YX]*t_const[3]; -} - -//*************************************************************************************************************** -// -// Use a rotation matrix to rotate a given tensor backward -// -// Input: -// rotation(4) Rotation tensor -// orig_tensor(3) Input symmetric tensor -// -// Output: -// rot_tensor(3) Output symmetric tensor -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE void rotate_tensor_21_backward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor) -{ - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_XY]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_XY]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_XY]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_YX]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_XY]*t_const[3]; -} - -/** - * Compute the dot product of two length 8 vectors - * - * Input - * x1(8) first vector - * x2(8) second vector - */ -TEMPLATE_SCALAR -inline Scalar ddot8(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2] + - x1[3] * x2[3] + - x1[4] * x2[4] + - x1[5] * x2[5] + - x1[6] * x2[6] + - x1[7] * x2[7]); -} - -/** - * Compute the dot product of two length 3 vectors - * - * Input - * x1(3) first vector - * x2(3) second vector - */ -TEMPLATE_SCALAR -inline Scalar ddot3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2]); -} - -/** - * Compute the dot product of two length 8 vectors using vector striding - * - * Input - * x1(8) first vector - * x2(8) second vector - */ -TEMPLATE_SCALAR -inline Scalar ddot8_stride1_stride3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[ 0] + - x1[1] * x2[ 3] + - x1[2] * x2[ 6] + - x1[3] * x2[ 9] + - x1[4] * x2[12] + - x1[5] * x2[15] + - x1[6] * x2[18] + - x1[7] * x2[21]); -} - -/** - * Rotate a [3,8] matrix into a [8,3] matrix - * - * Input: - * cur_coords Old matrix - * - * Output: - * cordel_ptr New matrix - */ -TEMPLATE_SCALAR -INLINE void transform_38_matrix_to_83_matrix(const Scalar *cordel_ptr, Scalar *cur_coords) { - cur_coords[0] = cordel_ptr[0]; - cur_coords[1] = cordel_ptr[3]; - cur_coords[2] = cordel_ptr[6]; - cur_coords[3] = cordel_ptr[9]; - cur_coords[4] = cordel_ptr[12]; - cur_coords[5] = cordel_ptr[15]; - cur_coords[6] = cordel_ptr[18]; - cur_coords[7] = cordel_ptr[21]; - - cur_coords[8] = cordel_ptr[1]; - cur_coords[9] = cordel_ptr[4]; - cur_coords[10] = cordel_ptr[7]; - cur_coords[11] = cordel_ptr[10]; - cur_coords[12] = cordel_ptr[13]; - cur_coords[13] = cordel_ptr[16]; - cur_coords[14] = cordel_ptr[19]; - cur_coords[15] = cordel_ptr[22]; - - cur_coords[16] = cordel_ptr[2]; - cur_coords[17] = cordel_ptr[5]; - cur_coords[18] = cordel_ptr[8]; - cur_coords[19] = cordel_ptr[11]; - cur_coords[20] = cordel_ptr[14]; - cur_coords[21] = cordel_ptr[17]; - cur_coords[22] = cordel_ptr[20]; - cur_coords[23] = cordel_ptr[23]; -} - -/** - * Add bulk viscosity terms to a set of symmetric 3x3 tensors. Bulk viscosity terms - * will only be added to the terms on the diagonal of the tensor. - * - * Input: - * Int num_elements : Number of input tensors - * Real *bulkq : Bulk viscosity term to add - * Real *stress_in : Input set of tensors - * - * Output: - * Real *stress_out : Modified output tensors - */ -TEMPLATE_SCALAR -INLINE void add_bulk_visc(const Int num_elements, const Scalar * bulkq, const Scalar * stress_in, Scalar * stress_out) { - for(Int ielem = 0; ielem < num_elements; ++ielem) { - stress_out[K_S_XX] = stress_in[K_S_XX] + bulkq[ielem]; - stress_out[K_S_YY] = stress_in[K_S_YY] + bulkq[ielem]; - stress_out[K_S_ZZ] = stress_in[K_S_ZZ] + bulkq[ielem]; - stress_out[K_S_XY] = stress_in[K_S_XY]; - stress_out[K_S_XZ] = stress_in[K_S_XZ]; - stress_out[K_S_YZ] = stress_in[K_S_YZ]; - stress_out += 6; - stress_in += 6; - } -} - -/** - * Compute the aspect ratio for an element - * - * Input: - * gradop12x(24) 12 times the gradient operator - * volume12x 12 times the element volume - */ -TEMPLATE_SCALAR -INLINE Scalar comp_aspect(const Scalar *const gradop12x, const Scalar &volume12x) { - return 6.0 * volume12x / - (gradop12x[0] * gradop12x[0]+ - gradop12x[1] * gradop12x[1]+ - gradop12x[2] * gradop12x[2]+ - gradop12x[3] * gradop12x[3]+ - gradop12x[4] * gradop12x[4]+ - gradop12x[5] * gradop12x[5]+ - gradop12x[6] * gradop12x[6]+ - gradop12x[7] * gradop12x[7]+ - gradop12x[8] * gradop12x[8]+ - gradop12x[9] * gradop12x[9]+ - gradop12x[10] * gradop12x[10]+ - gradop12x[11] * gradop12x[11]+ - gradop12x[12] * gradop12x[12]+ - gradop12x[13] * gradop12x[13]+ - gradop12x[14] * gradop12x[14]+ - gradop12x[15] * gradop12x[15]+ - gradop12x[16] * gradop12x[16]+ - gradop12x[17] * gradop12x[17]+ - gradop12x[18] * gradop12x[18]+ - gradop12x[19] * gradop12x[19]+ - gradop12x[20] * gradop12x[20]+ - gradop12x[21] * gradop12x[21]+ - gradop12x[22] * gradop12x[22]+ - gradop12x[23] * gradop12x[23]); -} - - -/** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations after the element stress calculation - * - * Input: - * Int nelem Number of elements in workset - * Int dt Last step time step - * Real *cordel Element nodal coordinates - * Real *vel Element nodal velocities - * Real *rotation elemetn rotation tensor - * Real *stress_new The new element stress - * Real *rotated_stretching The element stretching rate tensor - * Real *spin_rate rigid body elemetn spining rate - * Real linBulkVisc Linear artificial bulk viscosity parameter - * Real quadBulkVisc Quadradic bulk viscosity parameter - * Real *elem_mass The element mass - * Real *elem_dilmod Element dilatation modulus as computed by the effective modulus routine - * Real *elem_shrmod Element shear modulus as coputed by the effective modulus routine - * Real hg_stiffness Element hourglass stiffness scaling constant - * Real hg_viscosity Element hourglass viscosity scaling constant - * - * Output: - * Real *rotated_stress Element rotated stress tensor - * Real min_elem_time_step New mimumum element based time step - * Real *volume Element end of step volume - * Real *elem_time_step Element time steps on per element basis - * Real *hg_resist_old Old hourglass resitance rate - * Real *hg_resist_new New hourglass resistance rate - * Real *force_new Computed internal force - * Real *hg_energy Per element hourglass force energy - * Real *int_energy Per element internal energy - * - * ********************************************************************************************** - */ - -//*************************************************************************************************************** -// -// Compute a set of 8 components for a gradient operator. -// -// 48*3 = 144 multiplications. -// -// Input -// grad_ptr(24) Array in which to store the current gradient operator components -// x(8) X nodal coordinates -// y(8) Y nodal coorindates -// z(8) Z nodal coordinates -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE -void comp_grad12x( Scalar *const grad_ptr, const Scalar * const x, const Scalar *const y, const Scalar *const z) { - Scalar R42=(z[3] - z[1]); - Scalar R52=(z[4] - z[1]); - Scalar R54=(z[4] - z[3]); - - Scalar R63=(z[5] - z[2]); - Scalar R83=(z[7] - z[2]); - Scalar R86=(z[7] - z[5]); - - Scalar R31=(z[2] - z[0]); - Scalar R61=(z[5] - z[0]); - Scalar R74=(z[6] - z[3]); - - Scalar R72=(z[6] - z[1]); - Scalar R75=(z[6] - z[4]); - Scalar R81=(z[7] - z[0]); - - Scalar t1 =(R63 + R54); - Scalar t2 =(R61 + R74); - Scalar t3 =(R72 + R81); - Scalar t4 =(R86 + R42); - Scalar t5 =(R83 + R52); - Scalar t6 =(R75 + R31); - - grad_ptr[0] = (y[1] * t1) - (y[2] * R42) - (y[3] * t5) + (y[4] * t4) + (y[5] * R52) - (y[7] * R54); - grad_ptr[1] = (y[2] * t2) + (y[3] * R31) - (y[0] * t1) - (y[5] * t6) + (y[6] * R63) - (y[4] * R61); - grad_ptr[2] = (y[3] * t3) + (y[0] * R42) - (y[1] * t2) - (y[6] * t4) + (y[7] * R74) - (y[5] * R72); - grad_ptr[3] = (y[0] * t5) - (y[1] * R31) - (y[2] * t3) + (y[7] * t6) + (y[4] * R81) - (y[6] * R83); - grad_ptr[4] = (y[5] * t3) + (y[6] * R86) - (y[7] * t2) - (y[0] * t4) - (y[3] * R81) + (y[1] * R61); - grad_ptr[5] = (y[6] * t5) - (y[4] * t3) - (y[7] * R75) + (y[1] * t6) - (y[0] * R52) + (y[2] * R72); - grad_ptr[6] = (y[7] * t1) - (y[5] * t5) - (y[4] * R86) + (y[2] * t4) - (y[1] * R63) + (y[3] * R83); - grad_ptr[7] = (y[4] * t2) - (y[6] * t1) + (y[5] * R75) - (y[3] * t6) - (y[2] * R74) + (y[0] * R54); - - R42=(x[3] - x[1]); - R52=(x[4] - x[1]); - R54=(x[4] - x[3]); - - R63=(x[5] - x[2]); - R83=(x[7] - x[2]); - R86=(x[7] - x[5]); - - R31=(x[2] - x[0]); - R61=(x[5] - x[0]); - R74=(x[6] - x[3]); - - R72=(x[6] - x[1]); - R75=(x[6] - x[4]); - R81=(x[7] - x[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[8 ] = (z[1] * t1) - (z[2] * R42) - (z[3] * t5) + (z[4] * t4) + (z[5] * R52) - (z[7] * R54); - grad_ptr[9 ] = (z[2] * t2) + (z[3] * R31) - (z[0] * t1) - (z[5] * t6) + (z[6] * R63) - (z[4] * R61); - grad_ptr[10] = (z[3] * t3) + (z[0] * R42) - (z[1] * t2) - (z[6] * t4) + (z[7] * R74) - (z[5] * R72); - grad_ptr[11] = (z[0] * t5) - (z[1] * R31) - (z[2] * t3) + (z[7] * t6) + (z[4] * R81) - (z[6] * R83); - grad_ptr[12] = (z[5] * t3) + (z[6] * R86) - (z[7] * t2) - (z[0] * t4) - (z[3] * R81) + (z[1] * R61); - grad_ptr[13] = (z[6] * t5) - (z[4] * t3) - (z[7] * R75) + (z[1] * t6) - (z[0] * R52) + (z[2] * R72); - grad_ptr[14] = (z[7] * t1) - (z[5] * t5) - (z[4] * R86) + (z[2] * t4) - (z[1] * R63) + (z[3] * R83); - grad_ptr[15] = (z[4] * t2) - (z[6] * t1) + (z[5] * R75) - (z[3] * t6) - (z[2] * R74) + (z[0] * R54); - - R42=(y[3] - y[1]); - R52=(y[4] - y[1]); - R54=(y[4] - y[3]); - - R63=(y[5] - y[2]); - R83=(y[7] - y[2]); - R86=(y[7] - y[5]); - - R31=(y[2] - y[0]); - R61=(y[5] - y[0]); - R74=(y[6] - y[3]); - - R72=(y[6] - y[1]); - R75=(y[6] - y[4]); - R81=(y[7] - y[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[16] = (x[1] * t1) - (x[2] * R42) - (x[3] * t5) + (x[4] * t4) + (x[5] * R52) - (x[7] * R54); - grad_ptr[17] = (x[2] * t2) + (x[3] * R31) - (x[0] * t1) - (x[5] * t6) + (x[6] * R63) - (x[4] * R61); - grad_ptr[18] = (x[3] * t3) + (x[0] * R42) - (x[1] * t2) - (x[6] * t4) + (x[7] * R74) - (x[5] * R72); - grad_ptr[19] = (x[0] * t5) - (x[1] * R31) - (x[2] * t3) + (x[7] * t6) + (x[4] * R81) - (x[6] * R83); - grad_ptr[20] = (x[5] * t3) + (x[6] * R86) - (x[7] * t2) - (x[0] * t4) - (x[3] * R81) + (x[1] * R61); - grad_ptr[21] = (x[6] * t5) - (x[4] * t3) - (x[7] * R75) + (x[1] * t6) - (x[0] * R52) + (x[2] * R72); - grad_ptr[22] = (x[7] * t1) - (x[5] * t5) - (x[4] * R86) + (x[2] * t4) - (x[1] * R63) + (x[3] * R83); - grad_ptr[23] = (x[4] * t2) - (x[6] * t1) + (x[5] * R75) - (x[3] * t6) - (x[2] * R74) + (x[0] * R54); -} - -//*************************************************************************************************************** -// -// Compute the hourglass operator -// -// Input: -// x_ptr, y_ptr, z_ptr The x, y, and z nodal coordinates -// -// gradop12x_ptr_x 12 times the gradient operator components -// gradop12x_ptr_y 12 times the gradient operator components -// gradop12x_ptr_z 12 times the gradient operator components -// -// volinv12th The inverse of the element voluem, times one 12th -// -//*************************************************************************************************************** -TEMPLATE_SCALAR -INLINE -void comp_hgop(const Scalar *const x, const Scalar *const y, const Scalar * const z, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - const Scalar volinv12th, - Scalar *const hgop) { - - // - // KHP: Perhaps, this static array should be passed in from the calling - // routine? - // - static const Scalar hgop_arr[32] = { - 1.0, 1.0,-1.0,-1.0,-1.0,-1.0, 1.0, 1.0, - 1.0,-1.0,-1.0, 1.0,-1.0, 1.0, 1.0,-1.0, - 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, - -1.0, 1.0,-1.0, 1.0, 1.0,-1.0, 1.0,-1.0}; - - // KHP: Alternatively, we could have - // hx0,hx1,hx2,hx3,...,hz0,hz1,hz2,hz3 - Scalar hgconst12th[12]; - - Scalar t0 = x[0] - x[1]; - Scalar t1 = x[2] - x[3]; - Scalar t2 = x[4] - x[5]; - Scalar t3 = x[6] - x[7]; - - hgconst12th[0] = ( (x[0]+x[1]) - (x[2]+x[3]) - (x[4]+x[5]) + (x[6]+x[7]) ) * volinv12th; - hgconst12th[1] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[2] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[3] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (y[0] - y[1]); - t1 = (y[2] - y[3]); - t2 = (y[4] - y[5]); - t3 = (y[6] - y[7]); - - hgconst12th[4] = ( (y[0]+y[1]) - (y[2]+y[3]) - (y[4]+y[5]) + (y[6]+y[7]) ) * volinv12th; - hgconst12th[5] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[6] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[7] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (z[0] - z[1]); - t1 = (z[2] - z[3]); - t2 = (z[4] - z[5]); - t3 = (z[6] - z[7]); - - hgconst12th[8] = ( (z[0]+z[1]) - (z[2]+z[3]) - (z[4]+z[5]) + (z[6]+z[7]) ) * volinv12th; - hgconst12th[9] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[10] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[11] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - // 8 times 12 = 96 + 12 = 108 multiplications. - for(int i = 0; i < 8; ++i) { - hgop[i ] = hgop_arr[i ] - (hgconst12th[0] * gradop12x_ptr_x[i] + hgconst12th[4] * gradop12x_ptr_y[i] + hgconst12th[8 ] * gradop12x_ptr_z[i]); - hgop[i+8 ] = hgop_arr[i+8 ] - (hgconst12th[1] * gradop12x_ptr_x[i] + hgconst12th[5] * gradop12x_ptr_y[i] + hgconst12th[9 ] * gradop12x_ptr_z[i]); - hgop[i+16] = hgop_arr[i+16] - (hgconst12th[2] * gradop12x_ptr_x[i] + hgconst12th[6] * gradop12x_ptr_y[i] + hgconst12th[10] * gradop12x_ptr_z[i]); - hgop[i+24] = hgop_arr[i+24] - (hgconst12th[3] * gradop12x_ptr_x[i] + hgconst12th[7] * gradop12x_ptr_y[i] + hgconst12th[11] * gradop12x_ptr_z[i]); - } -} - -//************************************************************************************************* -// -// Compute the new internal forces, hg resistances, and element energies -// -// Input: -// dt last time step -// spin_rate_ptr pointer into the spin rate array -// hgop element hourglass operator -// vel_ptr element velocity -// fac1 hourglass stiffness resitance factor -// fac2 hourglass viscosity resitance factor -// hg_resist_old_ptr Old hourglass resitances -// -// Output: -// hg_resist_new_ptr New hourglass resitances -// hg_resist_total_ptr Total hourglass resistance -// -//************************************************************************************************* - -TEMPLATE_SCALAR -INLINE -void comp_force(const Scalar &dt, - const Scalar *const spin_rate_ptr, - const Scalar *const hgop_for_resist_calc, - const Scalar *const hgop_ptr0, - const Scalar *const hgop_ptr1, - const Scalar *const hgop_ptr2, - const Scalar *const hgop_ptr3, - const Scalar *const vel, - const Scalar &fac1, - const Scalar &fac2, - const Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - const Scalar *const total_stress12th, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const force_new, - bool scaleHGRotation) { - - // - // NKC, does Presto Scalar need these spin rate terms? Pronto appears to have dumped them.... - // - const Scalar dwxy = dt * spin_rate_ptr[0]; - const Scalar dwyz = dt * spin_rate_ptr[1]; - const Scalar dwzx = dt * spin_rate_ptr[2]; - // - // Compute new hourglass resitance by the old rotated hourglass resitance plus a hourglass rate term - // - Scalar hg_resist_total[12]; - Scalar * hg_resist_total_ptr = hg_resist_total; - const Scalar * hgop_ptr = hgop_for_resist_calc; - const Scalar * vel_ptr = vel; - const Scalar * hg_resist_old_ptr = hg_resist_old; - Scalar * hg_resist_new_ptr = hg_resist_new; - Scalar * hg_energy_ptr = hg_energy; - Scalar * int_energy_ptr = int_energy; - Scalar * force_new_ptr = force_new; - - if (!scaleHGRotation){ - for(int i = 0; i < 4; ++i) { - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - hg_resist_new_ptr[0] = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2 + fac1* hg_rate_0 ; - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2* hg_rate_0 ; - - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - hg_resist_new_ptr[1] = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2 + fac1* hg_rate_1 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2* hg_rate_1 ; - - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - hg_resist_new_ptr[2] = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1 + fac1* hg_rate_2 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2* hg_rate_2 ; - - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } else { - for(int i = 0; i < 4; ++i) { - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar rot_hg_resist_old_0 = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2; - const Scalar rot_hg_resist_old_1 = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2; - const Scalar rot_hg_resist_old_2 = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1; - - Scalar fnorm = rot_hg_resist_old_0 *rot_hg_resist_old_0 + rot_hg_resist_old_1 *rot_hg_resist_old_1 + rot_hg_resist_old_2 *rot_hg_resist_old_2 ; - if (fnorm > 1.e-30){ - fnorm = sqrt ( (hg_resist_old_0*hg_resist_old_0 + - hg_resist_old_1*hg_resist_old_1 + - hg_resist_old_2*hg_resist_old_2) / fnorm ); - hg_resist_new_ptr[0] = fnorm*rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = fnorm*rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = fnorm*rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } else { - hg_resist_new_ptr[0] = rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2*hg_rate_0 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2*hg_rate_1 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2*hg_rate_2 ; - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } - - Scalar hg_force_0[8]; - Scalar hg_force_1[8]; - Scalar hg_force_2[8]; - - *hg_energy_ptr = 0.0; - *int_energy_ptr = 0.0; - for(int i = 0; i < 8; ++i) { - hg_force_0[i] = - (hg_resist_total[HG_X1] * hgop_ptr0[i] + - hg_resist_total[HG_X2] * hgop_ptr1[i] + - hg_resist_total[HG_X3] * hgop_ptr2[i] + - hg_resist_total[HG_X4] * hgop_ptr3[i]); - - hg_force_1[i] = - (hg_resist_total[HG_Y1] * hgop_ptr0[i] + - hg_resist_total[HG_Y2] * hgop_ptr1[i] + - hg_resist_total[HG_Y3] * hgop_ptr2[i] + - hg_resist_total[HG_Y4] * hgop_ptr3[i]); - - hg_force_2[i] = - (hg_resist_total[HG_Z1] * hgop_ptr0[i] + - hg_resist_total[HG_Z2] * hgop_ptr1[i] + - hg_resist_total[HG_Z3] * hgop_ptr2[i] + - hg_resist_total[HG_Z4] * hgop_ptr3[i]); - } - - for(int i = 0; i < 8; ++i) { - force_new_ptr[0] = - total_stress12th[K_S_XX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_XY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_XZ] * gradop12x_ptr_z[i] + hg_force_0[i] ; - - force_new_ptr[1] = - total_stress12th[K_S_YX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_YY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_YZ] * gradop12x_ptr_z[i] + hg_force_1[i] ; - - force_new_ptr[2] = - total_stress12th[K_S_ZX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_ZY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_ZZ] * gradop12x_ptr_z[i] + hg_force_2[i] ; - - *hg_energy_ptr += hg_force_0[i] *vel_ptr[0] + hg_force_1[i] *vel_ptr[1] + hg_force_2[i] *vel_ptr[2]; - *int_energy_ptr += force_new_ptr[0]*vel_ptr[0] + force_new_ptr[1]*vel_ptr[1] + force_new_ptr[2]*vel_ptr[2]; - - - force_new_ptr += 3; - vel_ptr += 3; - } - ++hg_energy_ptr ; - ++int_energy_ptr ; -} - -/** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations required for the material stress calculations. - * - * Input: - * Int nelem Number of elements in workset - * Scalar dt_scale Should be -0.5*delta_t, describes how to move the coordinates - * from the end of step to the mid-step using the velocities. - * Scalar *cordel Array of element nodal coordinates - * Scalar *vel Array of element nodal velocities - * Scalar *rotation_old Array of old roation tensors - * - * Output: - * Scalar *mid_volume Compute element volume from the mid step coordinates - * Scalar *vorticity Asymmetric portion of the element stretch tensor - * Scalar *rotation_new Updated material rotation tensors - * Scalar *stretch New element stretch - * Real *rotated_stretching Rotated element stretching tensor - * - * ********************************************************************************************** - */ -TEMPLATE_SCALAR -INLINE Int elem_ug3dh8_mi_compute_stretch(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation_old, - Scalar *const mid_vol, - Scalar *const vorticity, - Scalar *const rotation_new, - Scalar *const stretch, - Scalar *const rotated_stretching, - Scalar *const mid_hgop) { - - // - // Extract pointers to the input variables, set up any required temporary variables. The temporaries will - // be reused by every element in the workset. - // - const Scalar * cordel_ptr (cordel ); - const Scalar * vel_ptr (vel ); - Scalar * mid_vol_ptr (mid_vol ); - Scalar * vorticity_ptr(vorticity); - const Scalar * rotation_old_ptr(rotation_old); - Scalar * rotation_new_ptr(rotation_new); - Scalar * stretch_ptr(stretch); - Scalar * rotated_stretching_ptr(rotated_stretching); - Scalar * mid_hgop_ptr(mid_hgop); - // - // Storage for the midstep gradient operator, 12x denotes that this will actually be the midstep gradient - // operator components. - // - Scalar mid_gradop12x[24]; - Scalar *const mid_gradop12x_ptr_x(mid_gradop12x); - Scalar *const mid_gradop12x_ptr_y(mid_gradop12x+8); - Scalar *const mid_gradop12x_ptr_z(mid_gradop12x+16); - // - // Midstep coordinates - // - Scalar mid_coords[24]; - Scalar *const x_ptr(mid_coords); - Scalar *const y_ptr(mid_coords+8); - Scalar *const z_ptr(mid_coords+16); - // - // Element stretching tensor - // - Scalar stretching_tensor[6]; - // - // Element velocity gradient - // - Scalar vel_grad[9]; - // - // Loop over all elements in the workset - // - Scalar dt_scale = -0.5 * dt; - - Int return_value = 0; - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Get current element coordinates and update them so that they reference the midstep - // configuration. Note, this routine changes the coordinate ordering from - // - // (x1, y1, z1, x2, y2, z2, ........) - // - // to - // - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3 ......) - // - // The array reordering allows better variable access later for optimization purposes - // - for(int i = 0; i < 8; ++i) { - x_ptr[i] = cordel_ptr[0] + dt_scale * vel_ptr[0]; - y_ptr[i] = cordel_ptr[1] + dt_scale * vel_ptr[1]; - z_ptr[i] = cordel_ptr[2] + dt_scale * vel_ptr[2]; - //std::cout << "KHP: x= " << x_ptr[i] << ", " << y_ptr[i] << ", " << z_ptr[i] << "\n"; - //std::cout << "KHP: C= " << cordel_ptr[0] << ", " << cordel_ptr[1] << ", " << cordel_ptr[2] << "\n"; - //std::cout << "KHP: V= " << vel_ptr[0] << ", " << vel_ptr[1] << ", " << vel_ptr[2] << "\n"; - cordel_ptr += 3; - vel_ptr += 3; - } - - vel_ptr -= 24; - // - // Do grad op in three seperate steps using the helper routine. - // NKC, I'm not positive what the helper is mathematically equivalent too, - // however, the combination of these three steps will compute the full gradient. - // Note, the comp12x routine actually calculates 12.0 times the gradient, this - // 12 will be factored out later. - // - comp_grad12x(mid_gradop12x, x_ptr, y_ptr, z_ptr); - - // - // Compute the midstep volume. Note that 12 times the volume is being calculated, - // The actually output value of volume is then multipled by one twelth - // - const Scalar volume12x = ddot8(x_ptr, mid_gradop12x_ptr_x); - *mid_vol_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the velocity gradients from the dot products of the input velocities with the - // relevant columns of the gradient operator. Note that the velocity gradient is calculated - // as Velocity * 12 * mid_gradop * volinv/12, the twelves cancel. - // - // 81 multiplications (9 tensor entries * (8 mults per dot + 1 mult for volinv)) - // - vel_grad[K_F_XX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr ) * volinv12th; - vel_grad[K_F_XY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr ) * volinv12th; - vel_grad[K_F_XZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr ) * volinv12th; - vel_grad[K_F_YZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+1) * volinv12th; - vel_grad[K_F_YY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+1) * volinv12th; - vel_grad[K_F_YX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+1) * volinv12th; - vel_grad[K_F_ZX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+2) * volinv12th; - // - // Compute the stretching tensors from the current velocity gradient - // - // Let G = Gradient (velocity gradient in this case). - // Let S = Stretch - // Let V = Vorticity - // - // Then: - // - // S = 0.5 * ( G + G'); // S = 0.5 * ( G + transpose(G)); - // V = 0.5 * ( G - G'); // V = 0.5 * ( G - transpose(G)); - // - APS::Hex::additive_decomp36(vel_grad, stretching_tensor, vorticity_ptr); - - polar_decomp33r2(dt, stretching_tensor, vorticity_ptr, rotation_old_ptr, stretch_ptr, rotation_new_ptr); - - rotate_tensor_forward(rotation_new_ptr, stretching_tensor, rotated_stretching_ptr); - - // - // Compute the midstep hourglass operator if needed. Here one 12th the volume is - // multiplied by 12 times the gradient operators, so the true hourglass operator - // is computed. - // - if (mid_hgop_ptr) { - comp_hgop(x_ptr, y_ptr, z_ptr, - mid_gradop12x_ptr_x, - mid_gradop12x_ptr_y, - mid_gradop12x_ptr_z, - volinv12th, mid_hgop_ptr); - mid_hgop_ptr += 32; - } - - } else { - return_value = -1; - } - ++mid_vol_ptr ; - vel_ptr += 24; - vorticity_ptr +=3; - rotation_old_ptr += 9; - stretch_ptr += 6; - rotation_new_ptr += 9; - rotated_stretching_ptr += 6; - } - return return_value; -} - -//*********************************************************************n -// -// STANDARD PRESTO VERSION -// -// description: -// This routine is implemented for the 8 node brick, uniform strain -// element. It is the divergence operator, hourglass force operator, -// and time step calcuator. Combination of multiple routines yields -// better cache usage. -// -// Input: -// nelem Number of elements in the workset -// -// dt Previous time step -// -// cordel(24,nelem) End of step element coordinates, orgainzied by (x1, y1, z1, x2, y2, z2, ......) -// -// vel(24,nelem) Element nodal velocity, orgainzied by (x1, y1, z1, x2, y2, z2, ......) -// -// rotated_stress(6,nelem) Element stress in the rotated configuration -// -// rotated_stretching(6,nelem) Element stretch rate tensor in rotated configuration -// -// spin_rate(3,nelem) Asymmetric portion of stretching rate, represents amount element is spinning -// about each axis. -// -// linBulkVisc Linear bulk viscosity material constant -// -// quadBulkVisc Quadradic bulk viscosity material constant -// -// elem_mass(nelem) Current element masses -// -// elem_dilmod(nelem) Current material dilitational modulus -// -// elem_shrmod(nelem) Current material shear modulus -// -// hg_stiffness Hourglass stiffness parameter -// -// hg_viscosity Hourglass viscosity parameter -// -// hg_resist_old(12,nelem) Old hourglass resistance -// -// Output: -// min_elem_time_step The computed mimimum stable element time step -// -// volume(nelem) The element end of step volume -// -// elem_time_step(nelem) Time steps on a per element basis -// -// hg_resist_new(12,nelem) New hourglass resistance -// -// force_new(24,nelem) New element total internal force -// -// hg_energy(nelem) New element total hourglass energy increment -// -// int_energy(ielem) New element internal energy increment -// -// Returns, 0 if no errors, -1 if any negative volume elements were found -// -//*********************************************************************** - -TEMPLATE_SCALAR -INLINE -Int elem_ug3dh8_mi_compute_divergence_presto(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation, - const Scalar *const stress_new, - const Scalar *const rotated_stretching, - const Scalar *const spin_rate, - const Scalar linBulkVisc, - const Scalar quadBulkVisc, - const Scalar *const elem_mass, - const Scalar *const elem_dilmod, - const Scalar *const elem_shrmod, - const Scalar hg_stiffness, - const Scalar hg_viscosity, - Scalar *const rotated_stress, - Scalar &min_elem_time_step, - Scalar *const volume, - Scalar *const elem_time_step, - Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - Scalar *const force_new, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const mid_hgop, - const bool scaleHGRotation) { - Int return_value = 0; - // - // Store pointers to the input variables - // - const Scalar * cordel_ptr(cordel); - const Scalar * vel_ptr(vel); - const Scalar * elem_mass_ptr(elem_mass); - const Scalar * elem_dilmod_ptr(elem_dilmod); - const Scalar * elem_shrmod_ptr(elem_shrmod); - const Scalar * rotated_stretching_ptr(rotated_stretching); - const Scalar * spin_rate_ptr(spin_rate); - const Scalar * stress_new_ptr(stress_new); - const Scalar * rotation_ptr(rotation); - - Scalar * rotated_stress_ptr(rotated_stress); - Scalar * volume_ptr(volume); - Scalar * elem_time_step_ptr(elem_time_step); - Scalar * hg_resist_old_ptr(hg_resist_old); - Scalar * hg_resist_new_ptr(hg_resist_new); - Scalar * force_new_ptr(force_new); - Scalar * hg_energy_ptr(hg_energy); - Scalar * int_energy_ptr(int_energy); - // - // Create temporaries to be reused by every element - // - Scalar gradop12x[24]; - Scalar * gradop12x_ptr_x(gradop12x); - Scalar * gradop12x_ptr_y(gradop12x+8); - Scalar * gradop12x_ptr_z(gradop12x+16); - - Scalar cur_coords[24]; - const Scalar *const x_ptr(cur_coords); - const Scalar *const y_ptr(cur_coords+8); - const Scalar *const z_ptr(cur_coords+16); - - Scalar total_stress12th[6]; - - Scalar hgop[32]; - const Scalar *const hgop_ptr0(hgop); - const Scalar *const hgop_ptr1(hgop+8); - const Scalar *const hgop_ptr2(hgop+16); - const Scalar *const hgop_ptr3(hgop+24); - Scalar * hgop_for_resist_calc(mid_hgop); - if (mid_hgop == NULL){ - hgop_for_resist_calc = hgop; - } - // - // This factor will be used in hourglass computations, however is a loop constant - // - const Scalar fac1_pre(dt * hg_stiffness * 0.0625); - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Store local coordintes, note this changes the way coordinates are stored from - // - // (x1, y1, z1, x2, y2, z2 .......) - // to - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3, .....) - // - transform_38_matrix_to_83_matrix(cordel_ptr, cur_coords); - // - // Compute 12 times the gradient operator in three seperate steps - // - comp_grad12x(gradop12x, x_ptr, y_ptr, z_ptr); - // - // calculate 12 times the element volume, store the actual element volume - // - const Scalar volume12x = ddot8(x_ptr, gradop12x); - *volume_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the aspect ratio. Aspect ratio is 0.5 * volume / (grad . grad) - // With the 12 factors this is actually 6.0 * 12 * volume / (12 * grad . 12 * grad) - // - const Scalar aspect = comp_aspect(gradop12x, volume12x); - const Scalar aspect_inv = 1.0/aspect; - // - // Compute the stable time step and bulk viscosity - // - const Scalar dtrial(sqrt(elem_mass_ptr[0] * aspect / elem_dilmod_ptr[0])); - - const Scalar traced(rotated_stretching_ptr[0] + rotated_stretching_ptr[1] + rotated_stretching_ptr[2]); - - const Scalar eps(linBulkVisc - quadBulkVisc * std::min(0.0, traced)*dtrial); - - const Scalar bulkq = eps * elem_dilmod_ptr[0] *dtrial *traced; - - const Scalar cur_time_step = dtrial * ( sqrt( 1.0 + eps * eps) - eps); - *elem_time_step_ptr = cur_time_step; - min_elem_time_step = std::min(min_elem_time_step, cur_time_step); - // - // Rotate the stress - // - rotate_tensor_backward(rotation_ptr, stress_new_ptr, rotated_stress_ptr); - // - // Compute the total stress (includes bulk viscosity terms) - // - total_stress12th[0] = ONE12TH*(rotated_stress_ptr[0] + bulkq); - total_stress12th[1] = ONE12TH*(rotated_stress_ptr[1] + bulkq); - total_stress12th[2] = ONE12TH*(rotated_stress_ptr[2] + bulkq); - total_stress12th[3] = ONE12TH*(rotated_stress_ptr[3]); - total_stress12th[4] = ONE12TH*(rotated_stress_ptr[4]); - total_stress12th[5] = ONE12TH*(rotated_stress_ptr[5]); - // - // Compute the hourglass operator. Here one 12th the volume is multiplied by - // 12 times the gradient operators, so the true hourglass operator is computed. - // - comp_hgop(x_ptr, y_ptr, z_ptr, - gradop12x_ptr_x, - gradop12x_ptr_y, - gradop12x_ptr_z, - volinv12th, hgop); - // - // Compute the hourglass resistance terms. These are based on the hourglass stiffness and hourglass viscosities - // - const Scalar fac1 = fac1_pre * elem_shrmod_ptr[0] * aspect_inv; - const Scalar fac2 = hg_viscosity * sqrt(elem_shrmod_ptr[0] * elem_mass_ptr[0] * aspect_inv); - comp_force(dt, - spin_rate_ptr, - hgop_for_resist_calc, - hgop_ptr0, hgop_ptr1, hgop_ptr2, hgop_ptr3, - vel_ptr, fac1, fac2, hg_resist_old_ptr, hg_resist_new_ptr, - total_stress12th, - gradop12x_ptr_x, gradop12x_ptr_y, gradop12x_ptr_z, - hg_energy_ptr, int_energy_ptr, force_new_ptr, scaleHGRotation); - } else { - return_value = -1; - } - - cordel_ptr += 24; - vel_ptr += 24; - ++volume_ptr ; - ++elem_mass_ptr ; - ++elem_dilmod_ptr ; - ++elem_shrmod_ptr ; - ++elem_time_step_ptr ; - rotation_ptr += 9; - stress_new_ptr += 6; - rotated_stress_ptr += 6; - rotated_stretching_ptr += 6; - spin_rate_ptr += 3; - hg_resist_old_ptr += 12; - hg_resist_new_ptr += 12; - ++hg_energy_ptr ; - ++int_energy_ptr ; - force_new_ptr += 24; - if (mid_hgop){ - hgop_for_resist_calc += 32; - } - } - return return_value; -} - -} // end namespace Hex -} // end namespace APS - - -/** - * This class defines the boundary conditions based on - * a deformation gradient. It puts an element into a - * state of uniform strain through the following displacement field: - * - * \f$ - * u_{i} = \left(F_{ij} - \delta_{ij}\right) X_{j} - * \f$ - */ -class DefGradBC -{ -public: - explicit DefGradBC(double * dg) : dgrad(dg) - {} - - ~DefGradBC() - {} - - void getDisplacment(double * coord, double * displ) { - for ( int i = 1 ; i < 8 ; i++ ){ - int k = 3*i; - - displ[k ] = ( dgrad[0] - 1.0 ) * coord[k] - + dgrad[1] * coord[k+1] - + dgrad[2] * coord[k+2]; - - displ[k+1] = ( dgrad[4] - 1.0 ) * coord[k] - + dgrad[5] * coord[k+1] - + dgrad[3] * coord[k+2]; - - displ[k+2] = ( dgrad[8] - 1.0 ) * coord[k] - + dgrad[6] * coord[k+1] - + dgrad[7] * coord[k+2]; - - } - } - -private: - DefGradBC& operator=(const DefGradBC& ); - DefGradBC(const DefGradBC& ); - double * dgrad; -}; - -void getVelocity(DefGradBC& dgbc, double dt, double * coord, double * vel) { - dgbc.getDisplacment(coord,vel); - - double dt_inv = (dt > 0.0) ? 1.0 / dt : 1.0; - - for ( int i = 0 ; i < 24 ; i++ ) { - vel[i] *= dt_inv; - } -} - -namespace lame { - -int -Material::initialize( - matParams * p) -{ - int npoints = p->nelements; - for( int index = 0 ; index < num_state_vars * npoints ; ++index) { - p->state_old[index] = 0.0; - p->state_new[index] = 0.0; - } - return 0; -} - - -double -Material::getMaterialProperty( - const std::string & name, - const MatProps & props) -{ - - MatProps::const_iterator itr = props.find(name); - - if (itr != props.end()){ - - const double p = itr->second[0]; - - return p ; - - } - else { - - std::string msg = " Material input "; - msg += name; - msg += " does not exist\n"; - msg += " Setting value of "; - msg += name; - msg += " to zero\n"; - - int code = 1; - - reportError(code,msg); - - return -1.0; - } -} - - -int -Elastic::initialize( - matParams * p) -{ - double youngs_modulus = properties[0]; - if ( youngs_modulus < 0.0 ) { - std::cout << "KHP: Negative young's modulus\n"; - } - - double poissons_ratio = properties[1]; - if ( poissons_ratio < -1.0 ) { - std::cout << "KHP: PR < -1.0\n"; - } - - if ( poissons_ratio > 0.5 ) { - std::cout << "KHP: PR > 0.5, PR= " << poissons_ratio << "\n"; - } - - return 0; -} - - -int -Elastic::getStress( - matParams * p ) -{ - double youngs_ = properties[0]; - double pr = properties[1]; - double twomu = youngs_/(1.0+pr); - double alambda = twomu*pr/(1.0-2.0*pr); - int num_element = p->nelements; - double dt = p->dt; - double twomu_dt = twomu * dt; - double * strain = p->strain_rate; - double * stress_new = p->stress_new; - double * stress_old = p->stress_old; - - for (int i = 0; i < num_element; ++i) { - double traced = dt * ( strain[0] + strain[1] + strain[2]); - stress_new[0] = stress_old[0] + alambda*traced + twomu_dt*strain[0]; - stress_new[1] = stress_old[1] + alambda*traced + twomu_dt*strain[1]; - stress_new[2] = stress_old[2] + alambda*traced + twomu_dt*strain[2]; - stress_new[3] = stress_old[3] + twomu_dt*strain[3]; - stress_new[4] = stress_old[4] + twomu_dt*strain[4]; - stress_new[5] = stress_old[5] + twomu_dt*strain[5]; - - strain += 6; - stress_new += 6; - stress_old += 6; - } - - return 0; -} - -} // namespace lame - - -int -APSHex8ug::internalForce( const int num_elements, - const double dt, - double current_stable_time_step, - double element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - std::vector &coordinates, - std::vector &velocity, - std::vector &rotation_old, std::vector &rotation_new, - std::vector &midstep_volume, - std::vector &vorticity_tensor, - std::vector &stretch, - std::vector &strain_rate, - std::vector &mid_hgop, - std::vector &stress_old, std::vector &stress_new, - std::vector &rotated_stress, - std::vector &material_eff_bulk_mod, - std::vector &material_eff_twomu, - std::vector &shrmod, - std::vector &dilmod, - std::vector &element_mass, - std::vector &force_new, - std::vector &hourglass_energy, - std::vector &internal_energy, - std::vector &hg_resistance_old, std::vector &hg_resistance_new - ) const -{ - - compute_stretch(num_elements, dt, &coordinates[0], &velocity[0], &rotation_old[0], &midstep_volume[0], &vorticity_tensor[0], &rotation_new[0], &stretch[0], &strain_rate[0], &mid_hgop[0]); - - Int err = material_model.getStress(&materialParameters); - - double dilatationalHGParam = 0.05; - double deviatoricHGParam = 0.0; - - for(int k=0; k -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -typedef stk_classic::mesh::Field ScalarField; -typedef stk_classic::mesh::Field CartesianField; -typedef stk_classic::mesh::Field SymmetricTensorField; -typedef stk_classic::mesh::Field FullTensorField; - -//-------------------------------------------------------------------- - -template< class FieldType > -void zero_field_data( stk_classic::mesh::BulkData & mesh , - stk_classic::mesh::EntityRank type , const FieldType & field ) -{ - typedef stk_classic::mesh::BucketArray< FieldType > array_type ; - - const std::vector & ks = mesh.buckets( type ); - - for ( std::vector::const_iterator ik = ks.begin() ; ik != ks.end() ; ++ik ) { - stk_classic::mesh::Bucket & bucket = **ik ; - array_type data( field , bucket ); - std::fill(data.contiguous_data(), data.contiguous_data() + data.size(), 0 ); - } -} - -//-------------------------------------------------------------------- - -using std::sqrt; - -#define INLINE /* inline */ - -#define TEMPLATE_SCALAR /* template */ - -typedef double Scalar; - -//---------------------------------------------------------------------- -// Tags for my special kinds of field types, -// which belong in a separate application-shared file... - -struct HourglassOp : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassOp & tag(); -private: - HourglassOp() {} - HourglassOp( const HourglassOp & ); - HourglassOp & operator = ( const HourglassOp & ); -}; - -inline -const HourglassOp & HourglassOp::tag() { - static const HourglassOp self ; - return self ; -} - -inline -const char * HourglassOp::name() const { - static const char n[] = "HourglassOp" ; - return n ; -} - -struct HourglassModes : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassModes & tag(); -private: - HourglassModes() {} - HourglassModes( const HourglassModes & ); - HourglassModes & operator = ( const HourglassModes & ); -}; - -inline -const HourglassModes & HourglassModes::tag() -{ static const HourglassModes self ; return self ; } - -inline -const char * HourglassModes::name() const -{ static const char n[] = "HourglassModes" ; return n ; } - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field HourglassOpField; -typedef stk_classic::mesh::Field HourglassArrayField; -typedef stk_classic::mesh::Field ElementNodeVectorField; - -enum { SpatialDim = 3 }; - - -// Specification for the aggressive gather pointer-field for elements. - -typedef stk_classic::mesh::Field ElementNodePointerField ; - -namespace lame { -typedef std::map > MatProps; - -/** - * The struture, matParams, has all of the information that - * might be passed back and forth from the application code - * and the constitutive model. This provides a very simple, - * easily modified interface between the application code - * and the constitutive model. - * - * The following are the more frequently used parameters. - * - * @param nelements is the number of material points sent - * to LAME for evaluation - * @param dt is the size of the current time step - * @param time is the current solution time - * @param dtrnew is the suggested ratio for the new time step - * @param energy_dep is the total ammount of energy deposited - * @param stress_old are the stress components at \f$t_{n}\f$ - * @param stress_new are the stress components at \f$t_{n+1}\f$ - * @param state_old are the state variables at \f$t_{n}\f$ - * @param state_new are the state variables at \f$t_{n+1}\f$ - * @param strain_rate are the components of the current rate - * of deformation - * @param left_stretch are the components of the left stretch - * tensor at \f$t_{n+1}\f$ - * @param rotation are the components of the rotation - * tensor at \f$t_{n+1}\f$ - * @param temp_old is the temperature at \f$t_{n}\f$ - * @param temp_new is the temperature at \f$t_{n+1}\f$ - */ -struct matParams { -public: - matParams() - : nelements (0), - nintg (0), - dt (0.0), - time (0.0), - dtrnew (1.0), - energy_dep (0.0), - strain_rate (NULL), - stress_old (NULL), - stress_new (NULL), - state_old (NULL), - state_new (NULL), - temp_old (NULL), - temp_new (NULL), - left_stretch (NULL), - rotation (NULL), - entropy (NULL), - energy_balance_term (NULL), - material_properties (NULL), - tangent_moduli (NULL), - ym_old (NULL), - ym_new (NULL), - nU_new (NULL), - nU_old (NULL), - bulk_scaling (NULL), - shear_scaling (NULL), - tangent_flag (true), - tangent_comp (true) - {} - - int nelements; - int nintg; - double dt; - double time; - double dtrnew; - double energy_dep; - double * strain_rate; - double * stress_old; - double * stress_new; - double * state_old; - double * state_new; - double * temp_old; - double * temp_new; - double * left_stretch; - double * rotation; - double * entropy; - double * energy_balance_term; - double * material_properties; - double * tangent_moduli; - double * ym_old; - double * ym_new; - double * nU_new; - double * nU_old; - double * bulk_scaling; - double * shear_scaling; - bool tangent_flag; - bool tangent_comp; -}; - - -class Material -{ -public: - static void reportError( int & int_val, std::string & message ){} - - explicit Material(const MatProps & props) - : properties() { - num_material_properties = 0; - num_state_vars = 0; - num_scratch_vars = 0; - - double lambda = getMaterialProperty("LAMBDA",props); - shrmod = getMaterialProperty("SHEAR_MODULUS",props); - datmod = lambda + 2.0*shrmod; - shrmod0 = shrmod; - datmod0 = datmod; - - double lPlusS = lambda + shrmod; - - if ( lPlusS > 0 ) { - youngs = shrmod*(3.0*lambda+2.0*shrmod)/lPlusS; - poissons = 0.5*lambda/lPlusS; - } else { - youngs = std::numeric_limits::quiet_NaN(); - poissons = std::numeric_limits::quiet_NaN(); - } - } - - virtual ~Material() - {} - - int getNumStateVars(){ - return num_state_vars; - } - - virtual int initialize( matParams * p ); - - virtual int getStress( matParams * p ) = 0; - - virtual int loadStepInit( matParams * p ) { - return 0; - } - -protected: - std::vector properties; - double shrmod; - double datmod; - double youngs; - double poissons; - double shrmod0; - double datmod0; - int num_material_properties; - int num_scratch_vars; - int num_state_vars; - - double getMaterialProperty( const std::string & name, const MatProps & props); - -private: - Material( const Material & ); - Material & operator= ( const Material & ); -}; - - -/** - * This is the class for the elastic constitutive model. The - * elastic model is a hypoelastic model with the following constitutive description - * - * \f$ - * \sigma_{ij}^{n+1} = \sigma_{ij}^{n} - * + \Delta t \left( \lambda \delta_{ij} D_{kk} - * + 2\mu D_{ij} \right) - * \f$ - */ -class Elastic: public Material -{ -public: - static Material *createMaterial(const MatProps & props ) { - return new Elastic(props); - } - - explicit Elastic( const MatProps & props ) - : Material(props) - { - num_material_properties = 2; - properties.resize(num_material_properties); - properties[0] = getMaterialProperty("YOUNGS_MODULUS",props); - properties[1] = getMaterialProperty("POISSONS_RATIO",props); - } - - ~Elastic() { - } - - virtual int initialize( matParams * p ); - - virtual int getStress( matParams * p ); - -private: - Elastic( const Elastic & ); - Elastic & operator= ( const Elastic & ); -}; - -} // namespace lame - -namespace APS { -namespace Hex { - -typedef int Int; -typedef double Real; - -TEMPLATE_SCALAR -Int elem_ug3dh8_mi_compute_stretch(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation_old, - Scalar *const mid_vol, - Scalar *const vorticity, - Scalar *const rotation_new, - Scalar *const stretch, - Scalar *const rotated_stretching, - Scalar *const mid_hgop); - -} // namespace Hex -} // namespace APS - - -class APSHex8ug -{ -public: - APSHex8ug() - {} - ~APSHex8ug() - {} - - int num_nodes() const { return 8; } - - int compute_stretch( const int num_elements, - const double dt, - const double *coordinates, - const double *velocity, - const double *rotation_old, - double *volume, - double *vorticity_tensor, - double *rotation_new, - double *stretch, - double *strain_rate, - double *mid_hgop, - bool debug = false - ) const { - int err = APS::Hex::elem_ug3dh8_mi_compute_stretch(num_elements, - dt, - coordinates, - velocity, - rotation_old, - volume, - vorticity_tensor, - rotation_new, - stretch, - strain_rate, - mid_hgop); - - return err; - } - - int internalForce( const int num_elements, - const double dt, - double current_stable_time_step, - double element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - std::vector &coordinates, - std::vector &velocity, - std::vector &rotation_old, std::vector &rotation_new, - std::vector &midstep_volume, - std::vector &vorticity_tensor, - std::vector &stretch, - std::vector &strain_rate, - std::vector &mid_hgop, - std::vector &stress_old, std::vector &stress_new, - std::vector &rotated_stress, - std::vector &material_eff_bulk_mod, - std::vector &material_eff_twomu, - std::vector &shrmod, - std::vector &dilmod, - std::vector &element_mass, - std::vector &force_new, - std::vector &hourglass_energy, - std::vector &internal_energy, - std::vector &hg_resistance_old, std::vector &hg_resistance_new - ) const; - - int internalForce( const int num_elements, - const double dt, - double current_stable_time_step, - double* const element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - double *const coordinates, - double *const velocity, - double *const rotation_old, double* const rotation_new, - double *const midstep_volume, - double *const vorticity_tensor, - double *const stretch, - double *const strain_rate, - double *const mid_hgop, - double *const stress_old, double *const stress_new, - double *const rotated_stress, - double *const material_eff_bulk_mod, - double *const material_eff_twomu, - double *const shrmod, - double *const dilmod, - double *const element_mass, - double *const force_new, - double *const hourglass_energy, - double *const internal_energy, - double *const hg_resistance_old, double* const hg_resistance_new - ) const; - private: - APSHex8ug& operator=(const APSHex8ug&); - APSHex8ug(const APSHex8ug&); -}; - -#endif diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.cpp deleted file mode 100644 index aeee778a7328..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -namespace { - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::MetaData& meta_data) -{ - const stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(meta_data); - return fem.element_rank(); -} - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::Part& part) -{ - return get_element_rank(stk_classic::mesh::MetaData::get(part)); -} - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() , n1 ); -} - - -CartesianField & -declare_vector_field_on_all_elements( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), - get_element_rank(meta_data), - meta_data.universal_part(), - n1); -} - - -ScalarField & -declare_scalar_field_on_all_elements( - stk_classic::mesh::MetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), - get_element_rank(meta_data), - meta_data.universal_part() ); -} - - -SymmetricTensorField & -declare_symmetric_tensor_field_on_all_elements( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field(meta_data.declare_field(s), - get_element_rank(meta_data), - meta_data.universal_part(), - n1); -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 ); - return f ; -} - - -template< typename Type , class T1 , class T2 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 , unsigned n2 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 , n2 ); - return f ; -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & put_field_on_all_elements( stk_classic::mesh::Field & f , unsigned n1 ) -{ - put_field_on_elements( f , stk_classic::mesh::MetaData::get(f).universal_part() , n1 ); - return f ; -} - -} // namespace - -void stk_classic::app::use_case_14_declare_fields(Fields &fields, stk_classic::mesh::MetaData &meta_data) -{ - // Nodal vector fields - fields.model_coordinates = &declare_vector_field_on_all_nodes(meta_data, "coordinates", SpatialDim); - fields.coordinates_field = &declare_vector_field_on_all_nodes(meta_data, "current_coordinates", SpatialDim); - fields.velocity_field = &declare_vector_field_on_all_nodes(meta_data, "velocity", SpatialDim); - fields.fint_field = &declare_vector_field_on_all_nodes(meta_data, "force_internal", SpatialDim); - - // Element vector fields: - fields.Vorticity = &declare_vector_field_on_all_elements(meta_data, "Vorticity" , SpatialDim); - - // Element scalar fields: - fields.Shear_Modulus = &declare_scalar_field_on_all_elements(meta_data, "shear_modulus" ); - fields.Dilatational_Modulus = &declare_scalar_field_on_all_elements(meta_data, "dilatational_modulus"); - fields.Material_eff_twomu = &declare_scalar_field_on_all_elements(meta_data, "material_effictive_two_mu"); - fields.Material_eff_bulk_mod = &declare_scalar_field_on_all_elements(meta_data, "material_effective_bulk_moduli"); - fields.Midstep_volume = &declare_scalar_field_on_all_elements(meta_data, "mid_step_volume"); - fields.Element_time_step = &declare_scalar_field_on_all_elements(meta_data, "element_time_step"); - fields.Element_mass = &declare_scalar_field_on_all_elements(meta_data, "element_mass"); - fields.Hourglass_energy = &declare_scalar_field_on_all_elements(meta_data, "hourglass_energy"); - fields.Internal_energy = &declare_scalar_field_on_all_elements(meta_data, "internal_energy"); - - // Element symmetric tensor fields: - fields.Stretch = &declare_symmetric_tensor_field_on_all_elements(meta_data, "stretch", 6 ); - fields.StrainRate = &declare_symmetric_tensor_field_on_all_elements(meta_data, "StrainRate", 6 ); - fields.RotatedStress = &declare_symmetric_tensor_field_on_all_elements(meta_data, "RotatedStress", 6 ); - - //-------------------------------- - // The multi-state fields don't have the 'declare and put' convenience functions (yet) - // - // For clarity declare a integer to used for the number of states arguments. - // - const unsigned two_states = 2 ; - - // Element two state symmetric tensor field, on all elements (as two function calls): - fields.StressNew = &meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states ); - put_field_on_all_elements( *fields.StressNew , 6 ); - - // Element two state full tensor field on all elements (as nested function calls): - fields.RotationNew = &put_field_on_all_elements( meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 ); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - fields.HourglassResistanceNew = - &put_field_on_all_elements( meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 ); - - fields.MidHourglassOp = - &put_field_on_all_elements( meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 ); - - //-------------------------------- - // Declare aggressive "gather" fields which are an array of - // pointers to the element's nodes' coordinate, velocity, and - // internal force field data. - // - // The declarations specify element fields of the following form: - // - // double * coord_gather [ nodes_per_element ] - // double * velocity_gather[ nodes_per_element ] - // - // where - // - // coord_gather[i] == field_data( coordinates_field , element_node[i] ) - // velocity_gather[i] == field_data( velocity , element_node[i] ) - // - // The number of nodes per element could vary, so the field is put - // on each element block with a size of the number of nodes per - // element in that element block. - - fields.coord_gather = &declare_element_node_pointer_field( meta_data , "coord_gather" , *fields.coordinates_field ); - fields.velocity_gather = &declare_element_node_pointer_field( meta_data , "velocity_gather" , *fields.velocity_field ); - - //---------------------------------- - // Declare an element field with one value per connected node in - // which to temporarily store nodal force that is calculated by - // the internal force algorithm. - - fields.force_new_field = &meta_data.declare_field( "force_new_field" , 1 /* 1 state */ ); - - // All parts of the meta data: - { - const mesh::PartVector & all_parts = meta_data.get_parts(); - for (mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - mesh::Part * const part = *i ; - if ( part->primary_entity_rank() == get_element_rank(meta_data) ) { - put_field_on_elements(*fields.coord_gather, *part, shards::Hexahedron<> ::node_count ); - put_field_on_elements(*fields.velocity_gather, *part, shards::Hexahedron<> ::node_count ); - put_field_on_elements(*fields.force_new_field, *part, SpatialDim, shards::Hexahedron<>::node_count ); - } - } - } -} - -void stk_classic::app::use_case_14_initialize_nodal_data(stk_classic::mesh::BulkData & mesh , - const CartesianField & model_coordinates , - const CartesianField & coordinates , - const CartesianField & velocity, - double dt) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - - double * X = stk_classic::mesh::field_data( model_coordinates , bucket.begin() ); - double * coord = stk_classic::mesh::field_data( coordinates , bucket.begin() ); - double * v = stk_classic::mesh::field_data( velocity , bucket.begin() ); - - for ( unsigned i = 0 ; i < length ; ++i ) { - v[0] = X[0]; - v[1] = X[1]; - v[2] = X[2]; - coord[0] = X[0] + dt * v[0]; - coord[1] = X[1] + dt * v[1]; - coord[2] = X[2] + dt * v[2]; - X += 3; - v += 3; - coord += 3; - } - } -} - -void stk_classic::app::use_case_14_initialize_element_fields( - Fields &fields, - const stk_classic::mesh::Selector & selector , - const std::vector< stk_classic::mesh::Bucket * > & element_buckets, - double YM, double PR) -{ - double element_mass_dummy_value = 1.0; - - // Need both the the old and new states of these two-state fields: - fields.HourglassResistanceOld = &fields.HourglassResistanceNew->field_of_state( stk_classic::mesh::StateOld ); - fields.StressOld = &fields.StressNew->field_of_state( stk_classic::mesh::StateOld ); - fields.RotationOld = &fields.RotationNew->field_of_state( stk_classic::mesh::StateOld ); - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); - k != element_buckets.end() ; ++k ) if ( selector( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - - double * stretch = stk_classic::mesh::field_data( *fields.Stretch, bucket.begin() ); - double * strain_rate = stk_classic::mesh::field_data( *fields.StrainRate, bucket.begin() ); - double * stress_new = stk_classic::mesh::field_data( *fields.StressNew, bucket.begin() ); - double * stress_old = stk_classic::mesh::field_data( *fields.StressOld , bucket.begin() ); - double * rotated_stress = stk_classic::mesh::field_data( *fields.RotatedStress , bucket.begin() ); - double * rotation_old = stk_classic::mesh::field_data( *fields.RotationOld , bucket.begin() ); - double * rotation_new = stk_classic::mesh::field_data( *fields.RotationNew , bucket.begin() ); - double * mass = stk_classic::mesh::field_data( *fields.Element_mass , bucket.begin() ); - double * hg_old = stk_classic::mesh::field_data( *fields.HourglassResistanceOld , bucket.begin() ); - double * hg_new = stk_classic::mesh::field_data( *fields.HourglassResistanceNew , bucket.begin() ); - double * vorticity_ptr = stk_classic::mesh::field_data( *fields.Vorticity, bucket.begin()); - double * mid_hg_op_ptr = stk_classic::mesh::field_data( *fields.MidHourglassOp, bucket.begin()); - - std::fill(strain_rate, strain_rate + 6*num_elements, 0.0); - std::fill(stress_new, stress_new + 6*num_elements, 0.0); - std::fill(stress_old, stress_old + 6*num_elements, 0.0); - std::fill(rotated_stress, rotated_stress + 6*num_elements, 0.0); - std::fill(mass, mass + num_elements, element_mass_dummy_value); - std::fill(hg_old, hg_old + 12*num_elements, 0.0); - std::fill(hg_new, hg_new + 12*num_elements, 0.0); - std::fill(vorticity_ptr, vorticity_ptr + 3*num_elements, 0.0); - std::fill(mid_hg_op_ptr, mid_hg_op_ptr + 32*num_elements, 0.0); - - for ( int i = 0 ; i < num_elements ; ++i ) { - // initialize stretch to identity. - stretch[0] = 1.0; - stretch[1] = 1.0; - stretch[2] = 1.0; - stretch[3] = 0.0; - stretch[4] = 0.0; - stretch[5] = 0.0; - stretch+=6; - - // initialize rotation to identity. - rotation_old[0] = 1.0; - rotation_old[1] = 1.0; - rotation_old[2] = 1.0; - rotation_old[3] = 0.0; - rotation_old[4] = 0.0; - rotation_old[5] = 0.0; - rotation_old[6] = 0.0; - rotation_old[7] = 0.0; - rotation_old[8] = 0.0; - rotation_old +=9; - - // initialize rotation to identity. - rotation_new[0] = 1.0; - rotation_new[1] = 1.0; - rotation_new[2] = 1.0; - rotation_new[3] = 0.0; - rotation_new[4] = 0.0; - rotation_new[5] = 0.0; - rotation_new[6] = 0.0; - rotation_new[7] = 0.0; - rotation_new[8] = 0.0; - rotation_new += 9; - } - } - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); - k != element_buckets.end() ; ++k ) if ( selector( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements = bucket.size(); - - double * const sm = stk_classic::mesh::field_data( *fields.Shear_Modulus , bucket.begin() ); - double * const dm = stk_classic::mesh::field_data( *fields.Dilatational_Modulus , bucket.begin() ); - double * const twomu = stk_classic::mesh::field_data( *fields.Material_eff_twomu , bucket.begin() ); - double * const bulk = stk_classic::mesh::field_data( *fields.Material_eff_bulk_mod , bucket.begin() ); - double * const mv = stk_classic::mesh::field_data( *fields.Midstep_volume , bucket.begin() ); - double * const hg_energy = stk_classic::mesh::field_data( *fields.Hourglass_energy , bucket.begin() ); - double * const internal_energy = stk_classic::mesh::field_data( *fields.Internal_energy , bucket.begin() ); - - std::fill(sm, sm+num_elements, SM); - std::fill(dm, dm+num_elements, DM); - std::fill(twomu, twomu+num_elements, TM); - std::fill(bulk, bulk+num_elements, BM); - std::fill(mv, mv+num_elements, 0.0); - std::fill(hg_energy, hg_energy+num_elements, 0.0); - std::fill(internal_energy, internal_energy+num_elements, 0.0); - } -} - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.hpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.hpp deleted file mode 100644 index 0102acbd5a2e..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_14_Fields.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef USECASE_14_FIELDS_HPP -#define USECASE_14_FIELDS_HPP - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { - namespace mesh { - class Bucket; - } - namespace app { - - struct Fields { - - // Nodal vector fields - CartesianField *model_coordinates; - CartesianField *coordinates_field; - CartesianField *velocity_field; - CartesianField *fint_field; - - // Element vector fields: - CartesianField *Vorticity; - - // Element scalar fields: - ScalarField *Shear_Modulus; - ScalarField *Dilatational_Modulus; - ScalarField *Material_eff_twomu; - ScalarField *Material_eff_bulk_mod; - ScalarField *Midstep_volume; - ScalarField *Element_time_step; - ScalarField *Element_mass; - ScalarField *Hourglass_energy; - ScalarField *Internal_energy; - - // Element symmetric tensor fields: - SymmetricTensorField *Stretch; - SymmetricTensorField *StrainRate; - SymmetricTensorField *RotatedStress; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField *StressNew; - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField *RotationNew; - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField *HourglassResistanceNew; - - HourglassOpField * MidHourglassOp; - - ElementNodePointerField * coord_gather; - ElementNodePointerField * velocity_gather; - - ElementNodeVectorField * force_new_field; - - HourglassArrayField * HourglassResistanceOld; - SymmetricTensorField * StressOld; - FullTensorField * RotationOld; - }; - - //-------------------------------------------------------------------- - void use_case_14_declare_fields(Fields &fields, stk_classic::mesh::MetaData &meta_data); - void use_case_14_initialize_element_fields( - Fields &fields, - const stk_classic::mesh::Selector & selector , - const std::vector< stk_classic::mesh::Bucket * > & element_buckets, - double YM, double PR); - - void use_case_14_initialize_nodal_data(stk_classic::mesh::BulkData & mesh , - const CartesianField & model_coordinates , - const CartesianField & coordinates , - const CartesianField & velocity, - double dt); - } -} -#endif diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_14a.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_14a.cpp deleted file mode 100644 index 62213556f68e..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_14a.cpp +++ /dev/null @@ -1,1223 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 14: internal force computation. -// The function 'use_case_14a_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace { - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::fem::FEMMetaData& meta_data) -{ - return meta_data.element_rank(); -} - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::Part& part) -{ - return get_element_rank(stk_classic::mesh::fem::FEMMetaData::get(part)); -} - -} - -namespace stk_classic { -namespace app { - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field ScalarIntField ; -typedef stk_classic::mesh::Field CartesianField ; -typedef stk_classic::mesh::Field FullTensorField ; -typedef stk_classic::mesh::Field SymmetricTensorField ; - -int g_lockCollision = 0; - -enum { SpatialDim = 3 }; - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() , n1 ); -} - - -CartesianField & -declare_vector_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -ScalarField & -declare_scalar_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() ); -} - - -ScalarIntField & -declare_scalar_int_field_on_all_nodes( stk_classic::mesh::MetaData & meta_data , const std::string & n ) -{ - return put_field( meta_data.declare_field(n) , stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta_data.universal_part() ); -} - - -SymmetricTensorField & -declare_symmetric_tensor_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s) , get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 ); - return f ; -} - - -template< typename Type , class T1 , class T2> -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 , unsigned n2 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 , n2); - return f ; -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & put_field_on_all_elements( stk_classic::mesh::Field & f , unsigned n1 ) -{ - put_field_on_elements( f , stk_classic::mesh::MetaData::get(f).universal_part() , n1 ); - return f ; -} - -// ------------------------------------------------------------------------ - -typedef stk_classic::mesh::Field ElementNodeLockField ; - -extern int g_lockCollision; - -inline -int -thread_lock(volatile int *addr) -{ -//This function is not portable, as evidenced by the following '#if'. -//The test which exercises this is stk_usecases_rtest/app/UseCase_14a. That test has -//been disabled since it was aborting on some supported platforms. - -#if (defined __i386__ || defined __x86_64__) && defined __GNUC__ - register int content = 1; - - asm volatile ("xchgl %0, %1\n\t" - : "=r" (content), - "=m" (*addr) - : "0" (content), - "m" (*addr)); - return content; -#else - std::abort(); - return 0; -#endif -} - -inline -void -lock( - int * addr) -{ - volatile int *x = addr; - - while (thread_lock(addr) != 0) { - ++g_lockCollision; - while (*x) - ; - } -} - -inline -void -unlock( - int * addr) -{ - *addr = 0; -} - -class Lock -{ -public: - explicit Lock(int *addr) - : m_addr(addr) - { - lock(m_addr); - } - - ~Lock() - { - try { - unlock(m_addr); - } - catch(...) {} - } - -private: - Lock& operator=(const Lock&); - Lock(const Lock&); - int * m_addr; -}; - - -class MyHexInternalForceAlg2 { -public: - MyHexInternalForceAlg2(lame::matParams& matParameters, lame::MatProps& matProperties, - lame::Material* matModel, - stk_classic::mesh::MetaData& md, int max_kernel_size) - : hex_element(), - materialParameters(matParameters), - materialProperties(matProperties), - matmodel(matModel) - { - std::cout << "Assembling MyHexInternalForceAlg2" << std::endl; - // Nodal vector fields - model_coordinates = md.get_field("model_coordinates"); - coordinates_field = md.get_field("coordinates"); - velocity_field = md.get_field("velocity"); - fint_field = md.get_field("force_internal"); - - // Element vector fields: - Vorticity = md.get_field("Vorticity"); - - // Element scalar fields: - Shear_Modulus = md.get_field("shear_modulus"); - Dilatational_Modulus = md.get_field("dilatational_modulus"); - Material_eff_twomu = md.get_field("material_effictive_two_mu"); - Material_eff_bulk_mod = md.get_field("material_effective_bulk_moduli"); - Midstep_volume = md.get_field("mid_step_volume"); - Element_time_step = md.get_field("element_time_step"); - Element_mass = md.get_field("element_mass"); - Hourglass_energy = md.get_field("hourglass_energy"); - Internal_energy = md.get_field("internal_energy"); - - // Element symmetric tensor fields: - Stretch = md.get_field("stretch"); - StrainRate = md.get_field("StrainRate"); - RotatedStress = md.get_field("RotatedStress"); - - // Element two state symmetric tensor field, on all elements (as two function calls): - StressNew = md.get_field("Stress"); - - // Element two state full tensor field on all elements (as nested function calls): - RotationNew = md.get_field("Rotation"); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassResistanceNew = md.get_field("HourglassResistance"); - - MidHourglassOp = md.get_field("mid_hourglass_operator"); - - coord_gather = md.get_field("coord_gather"); - velocity_gather = md.get_field("velocity_gather"); - fint_gather = md.get_field("fint_gather"); - fint_lock_gather = md.get_field("fint_lock_gather"); - - force_new_field = md.get_field("force_new_field"); - - HourglassResistanceOld = &HourglassResistanceNew->field_of_state( stk_classic::mesh::StateOld ); - StressOld = &StressNew->field_of_state( stk_classic::mesh::StateOld ); - RotationOld = &RotationNew->field_of_state( stk_classic::mesh::StateOld ); - } - - enum { maximum_entity_count = 1000 }; - - void apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const - { - enum { nodes_per_elem = 8, num_nodes_X_3 = 24 }; - - const int num_elements = iend - ibegin; - double *mid_hg_op_ptr = stk_classic::mesh::field_data( *MidHourglassOp, ibegin); - double *material_eff_twomu_ptr = stk_classic::mesh::field_data( *Material_eff_twomu, ibegin); - double *material_eff_bulk_modulus_ptr = stk_classic::mesh::field_data( *Material_eff_bulk_mod, ibegin); - double *mid_step_volume_ptr = stk_classic::mesh::field_data( *Midstep_volume, ibegin); - double *element_time_step_ptr = stk_classic::mesh::field_data( *Element_time_step, ibegin); - double *element_mass_ptr = stk_classic::mesh::field_data( *Element_mass, ibegin); - double *hg_energy_ptr = stk_classic::mesh::field_data( *Hourglass_energy, ibegin); - double *internal_energy_ptr = stk_classic::mesh::field_data (*Internal_energy, ibegin); - double *shear_modulus_ptr = stk_classic::mesh::field_data( *Shear_Modulus, ibegin); - double *dilatational_modulus_ptr = stk_classic::mesh::field_data( *Dilatational_Modulus, ibegin ); - - double *rotation_old_ptr = stk_classic::mesh::field_data( *RotationOld, ibegin); - double *rotation_new_ptr = stk_classic::mesh::field_data( *RotationNew, ibegin); - - double *stretch_ptr = stk_classic::mesh::field_data( *Stretch, ibegin); - double *strain_rate_ptr = stk_classic::mesh::field_data( *StrainRate, ibegin); - double *stress_old_ptr = stk_classic::mesh::field_data( *StressOld, ibegin); - double *stress_new_ptr = stk_classic::mesh::field_data( *StressNew, ibegin); - double *rotated_stress_ptr = stk_classic::mesh::field_data( *RotatedStress, ibegin); - - double *hg_resistance_old_ptr = stk_classic::mesh::field_data( *HourglassResistanceOld, ibegin); - double *hg_resistance_new_ptr = stk_classic::mesh::field_data( *HourglassResistanceNew, ibegin); - - double *vorticity_ptr = stk_classic::mesh::field_data( *Vorticity, ibegin); - - const double **coord = - (const double **) stk_classic::mesh::field_data( *coord_gather, ibegin); - const double **velocity = - (const double **) stk_classic::mesh::field_data( *velocity_gather, ibegin); - double* force_new = stk_classic::mesh::field_data( *force_new_field, ibegin); - double **fint = stk_classic::mesh::field_data( *fint_gather, ibegin); - int **fint_lock = stk_classic::mesh::field_data( *fint_lock_gather, ibegin); - - const int num_elem_nodes = nodes_per_elem * num_elements ; - - //-------------------------------- - - double elem_coord[ maximum_entity_count * num_nodes_X_3 ]; - double elem_vel[ maximum_entity_count * num_nodes_X_3 ]; - - { // Gather nodal data into contiguous arrays. - - // element-node pointer fields - const double ** field_coord = coord ; - const double ** vnodes = velocity ; - - double* elem_coord_ptr = &elem_coord[0]; - double* elem_vel_ptr = &elem_vel[0]; - - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - const double * const f_coord = *field_coord ; - const double * const f_vel = *vnodes ; - - elem_coord_ptr[0] = f_coord[0]; - elem_coord_ptr[1] = f_coord[1]; - elem_coord_ptr[2] = f_coord[2]; - - elem_vel_ptr[0] = f_vel[0]; - elem_vel_ptr[1] = f_vel[1]; - elem_vel_ptr[2] = f_vel[2]; - - ++field_coord ; - ++vnodes ; - elem_coord_ptr += 3 ; - elem_vel_ptr += 3 ; - } - } - - //-------------------------------- - - double dt = materialParameters.dt; - double current_stable_time_step = dt; - materialParameters.nelements = num_elements ; - materialParameters.strain_rate = strain_rate_ptr; - materialParameters.stress_old = stress_old_ptr; - materialParameters.stress_new = stress_new_ptr; - - hex_element.internalForce( num_elements , - dt, - current_stable_time_step, - element_time_step_ptr, - *matmodel, - materialParameters, - materialProperties, - &elem_coord[0], - &elem_vel[0], - rotation_old_ptr, - rotation_new_ptr, - mid_step_volume_ptr, - vorticity_ptr, - stretch_ptr, - strain_rate_ptr, - mid_hg_op_ptr, - stress_old_ptr, - stress_new_ptr, - rotated_stress_ptr, - material_eff_bulk_modulus_ptr, - material_eff_twomu_ptr, - shear_modulus_ptr, - dilatational_modulus_ptr, - element_mass_ptr, - & force_new[0], - hg_energy_ptr, - internal_energy_ptr, - hg_resistance_old_ptr, - hg_resistance_new_ptr - ); - - { // Scatter internal force values. - double ** f = fint ; - int ** f_lock = fint_lock ; - const double * f_new = & force_new[0] ; - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - double * const node_f = *f ; - { - int * const node_f_lock = *f_lock ; - Lock __lock(node_f_lock); - - node_f[0] += f_new[0]; - node_f[1] += f_new[1]; - node_f[2] += f_new[2]; - } - ++f ; - ++f_lock ; - f_new += 3 ; - } - } - } - -private: - MyHexInternalForceAlg2& operator=(const MyHexInternalForceAlg2&); - MyHexInternalForceAlg2(const MyHexInternalForceAlg2&); - - APSHex8ug hex_element; - lame::matParams& materialParameters; - lame::MatProps& materialProperties; - lame::Material* matmodel; - - // Nodal vector fields - CartesianField *model_coordinates; - CartesianField *coordinates_field; - CartesianField *velocity_field; - CartesianField *fint_field; - - // Element vector fields: - CartesianField *Vorticity; - - // Element scalar fields: - ScalarField *Shear_Modulus; - ScalarField *Dilatational_Modulus; - ScalarField *Material_eff_twomu; - ScalarField *Material_eff_bulk_mod; - ScalarField *Midstep_volume; - ScalarField *Element_time_step; - ScalarField *Element_mass; - ScalarField *Hourglass_energy; - ScalarField *Internal_energy; - - // Element symmetric tensor fields: - SymmetricTensorField *Stretch; - SymmetricTensorField *StrainRate; - SymmetricTensorField *RotatedStress; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField *StressNew; - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField *RotationNew; - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField *HourglassResistanceNew; - - HourglassOpField * MidHourglassOp; - - ElementNodePointerField * coord_gather; - ElementNodePointerField * velocity_gather; - ElementNodePointerField * fint_gather; - ElementNodeLockField * fint_lock_gather; - - ElementNodeVectorField * force_new_field; - - HourglassArrayField * HourglassResistanceOld; - SymmetricTensorField * StressOld; - FullTensorField * RotationOld; -}; - -class MyHexInternalForceAlg3 { -public: - MyHexInternalForceAlg3(lame::matParams& matParameters, lame::MatProps& matProperties, - lame::Material* matModel, - stk_classic::mesh::MetaData& md, int max_bucket_size) - : m_lock(0), - hex_element(), - materialParameters(matParameters), - materialProperties(matProperties), - matmodel(matModel) - { - std::cout << "Assembling MyHexInternalForceAlg3" << std::endl; - - // Nodal vector fields - model_coordinates = md.get_field("model_coordinates"); - coordinates_field = md.get_field("coordinates"); - velocity_field = md.get_field("velocity"); - fint_field = md.get_field("force_internal"); - - // Element vector fields: - Vorticity = md.get_field("Vorticity"); - - // Element scalar fields: - Shear_Modulus = md.get_field("shear_modulus"); - Dilatational_Modulus = md.get_field("dilatational_modulus"); - Material_eff_twomu = md.get_field("material_effictive_two_mu"); - Material_eff_bulk_mod = md.get_field("material_effective_bulk_moduli"); - Midstep_volume = md.get_field("mid_step_volume"); - Element_time_step = md.get_field("element_time_step"); - Element_mass = md.get_field("element_mass"); - Hourglass_energy = md.get_field("hourglass_energy"); - Internal_energy = md.get_field("internal_energy"); - - // Element symmetric tensor fields: - Stretch = md.get_field("stretch"); - StrainRate = md.get_field("StrainRate"); - RotatedStress = md.get_field("RotatedStress"); - - // Element two state symmetric tensor field, on all elements (as two function calls): - StressNew = md.get_field("Stress"); - - // Element two state full tensor field on all elements (as nested function calls): - RotationNew = md.get_field("Rotation"); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassResistanceNew = md.get_field("HourglassResistance"); - - MidHourglassOp = md.get_field("mid_hourglass_operator"); - - coord_gather = md.get_field("coord_gather"); - velocity_gather = md.get_field("velocity_gather"); - fint_gather = md.get_field("fint_gather"); - - force_new_field = md.get_field("force_new_field"); - - HourglassResistanceOld = &HourglassResistanceNew->field_of_state( stk_classic::mesh::StateOld ); - StressOld = &StressNew->field_of_state( stk_classic::mesh::StateOld ); - RotationOld = &RotationNew->field_of_state( stk_classic::mesh::StateOld ); - } - -// void run(const stk_classic::mesh::Bucket& bucket, int ibegin, int iend ) - void operator()(const stk_classic::mesh::Bucket::iterator & ibegin, const stk_classic::mesh::Bucket::iterator iend ) - { - enum { nodes_per_elem = 8, num_nodes_X_3 = 24 }; - - const int num_elements = iend - ibegin; - double *mid_hg_op_ptr = stk_classic::mesh::field_data( *MidHourglassOp, ibegin); - double *material_eff_twomu_ptr = stk_classic::mesh::field_data( *Material_eff_twomu, ibegin); - double *material_eff_bulk_modulus_ptr = stk_classic::mesh::field_data( *Material_eff_bulk_mod, ibegin); - double *mid_step_volume_ptr = stk_classic::mesh::field_data( *Midstep_volume, ibegin); - double *element_time_step_ptr = stk_classic::mesh::field_data( *Element_time_step, ibegin); - double *element_mass_ptr = stk_classic::mesh::field_data( *Element_mass, ibegin); - double *hg_energy_ptr = stk_classic::mesh::field_data( *Hourglass_energy, ibegin); - double *internal_energy_ptr = stk_classic::mesh::field_data (*Internal_energy, ibegin); - double *shear_modulus_ptr = stk_classic::mesh::field_data( *Shear_Modulus, ibegin); - double *dilatational_modulus_ptr = stk_classic::mesh::field_data( *Dilatational_Modulus, ibegin ); - - double *rotation_old_ptr = stk_classic::mesh::field_data( *RotationOld, ibegin); - double *rotation_new_ptr = stk_classic::mesh::field_data( *RotationNew, ibegin); - - double *stretch_ptr = stk_classic::mesh::field_data( *Stretch, ibegin); - double *strain_rate_ptr = stk_classic::mesh::field_data( *StrainRate, ibegin); - double *stress_old_ptr = stk_classic::mesh::field_data( *StressOld, ibegin); - double *stress_new_ptr = stk_classic::mesh::field_data( *StressNew, ibegin); - double *rotated_stress_ptr = stk_classic::mesh::field_data( *RotatedStress, ibegin); - - double *hg_resistance_old_ptr = stk_classic::mesh::field_data( *HourglassResistanceOld, ibegin); - double *hg_resistance_new_ptr = stk_classic::mesh::field_data( *HourglassResistanceNew, ibegin); - - double *vorticity_ptr = stk_classic::mesh::field_data( *Vorticity, ibegin); - - const double **coord = - (const double **) stk_classic::mesh::field_data( *coord_gather, ibegin); - const double **velocity = - (const double **) stk_classic::mesh::field_data( *velocity_gather, ibegin); - double* force_new = stk_classic::mesh::field_data( *force_new_field, ibegin); - double **fint = stk_classic::mesh::field_data( *fint_gather, ibegin); - - const int num_elem_nodes = nodes_per_elem * num_elements ; - - double elem_coord[24000]; - double elem_vel[24000]; - - if (iend - ibegin > 1000) - throw std::runtime_error("Must increase MyHexInternalForceAlg2 TLS size"); - - //-------------------------------- - { // Gather nodal data into contiguous arrays. - - // element-node pointer fields - const double ** field_coord = coord ; - const double ** vnodes = velocity ; - - double* elem_coord_ptr = &elem_coord[0]; - double* elem_vel_ptr = &elem_vel[0]; - - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - const double * const f_coord = *field_coord ; - const double * const f_vel = *vnodes ; - - elem_coord_ptr[0] = f_coord[0]; - elem_coord_ptr[1] = f_coord[1]; - elem_coord_ptr[2] = f_coord[2]; - - elem_vel_ptr[0] = f_vel[0]; - elem_vel_ptr[1] = f_vel[1]; - elem_vel_ptr[2] = f_vel[2]; - - ++field_coord ; - ++vnodes ; - elem_coord_ptr += 3 ; - elem_vel_ptr += 3 ; - } - } - - //-------------------------------- - - double dt = materialParameters.dt; - double current_stable_time_step = dt; - materialParameters.nelements = num_elements ; - materialParameters.strain_rate = strain_rate_ptr; - materialParameters.stress_old = stress_old_ptr; - materialParameters.stress_new = stress_new_ptr; - - hex_element.internalForce( num_elements , - dt, - current_stable_time_step, - element_time_step_ptr, - *matmodel, - materialParameters, - materialProperties, - &elem_coord[0], - &elem_vel[0], - rotation_old_ptr, - rotation_new_ptr, - mid_step_volume_ptr, - vorticity_ptr, - stretch_ptr, - strain_rate_ptr, - mid_hg_op_ptr, - stress_old_ptr, - stress_new_ptr, - rotated_stress_ptr, - material_eff_bulk_modulus_ptr, - material_eff_twomu_ptr, - shear_modulus_ptr, - dilatational_modulus_ptr, - element_mass_ptr, - & force_new[0], - hg_energy_ptr, - internal_energy_ptr, - hg_resistance_old_ptr, - hg_resistance_new_ptr - ); - - { // Scatter internal force values. - Lock __lock(&m_lock); - - double ** f = fint ; - const double * f_new = & force_new[0] ; - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - double * const node_f = *f ; - { - node_f[0] += f_new[0]; - node_f[1] += f_new[1]; - node_f[2] += f_new[2]; - } - ++f ; - f_new += 3 ; - } - } - } - -private: - MyHexInternalForceAlg3& operator=(const MyHexInternalForceAlg3&); - MyHexInternalForceAlg3(const MyHexInternalForceAlg3&); - - int m_lock; - - APSHex8ug hex_element; - lame::matParams& materialParameters; - lame::MatProps& materialProperties; - lame::Material* matmodel; - - // Nodal vector fields - CartesianField *model_coordinates; - CartesianField *coordinates_field; - CartesianField *velocity_field; - CartesianField *fint_field; - - // Element vector fields: - CartesianField *Vorticity; - - // Element scalar fields: - ScalarField *Shear_Modulus; - ScalarField *Dilatational_Modulus; - ScalarField *Material_eff_twomu; - ScalarField *Material_eff_bulk_mod; - ScalarField *Midstep_volume; - ScalarField *Element_time_step; - ScalarField *Element_mass; - ScalarField *Hourglass_energy; - ScalarField *Internal_energy; - - // Element symmetric tensor fields: - SymmetricTensorField *Stretch; - SymmetricTensorField *StrainRate; - SymmetricTensorField *RotatedStress; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField *StressNew; - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField *RotationNew; - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField *HourglassResistanceNew; - - HourglassOpField * MidHourglassOp; - - ElementNodePointerField * coord_gather; - ElementNodePointerField * velocity_gather; - ElementNodePointerField * fint_gather; - - ElementNodeVectorField * force_new_field; - - HourglassArrayField * HourglassResistanceOld; - SymmetricTensorField * StressOld; - FullTensorField * RotationOld; -}; - -bool use_case_14a_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int max_entity_per_bucket, - bool performance_test) -{ - bool output = !performance_test; // If running for performance measurements, turn off output - - if (stk_classic::parallel_machine_rank(comm) == 0) { - std::cout << " stk_mesh Use Case #14a - element internal force, begin" << std::endl ; - } - - std::cout << "Running '" << mesh_filename << "' case, num_trials = " - << num_trials << std::endl; - - const AlgorithmRunnerInterface* alg_runner = NULL ; - if ( thread_runner.empty() || - thread_runner == std::string("NonThreaded") ) { - alg_runner = stk_classic::algorithm_runner_non_thread(); - } - else if ( thread_runner == std::string("TPI") ) { - alg_runner = stk_classic::algorithm_runner_tpi(num_threads); - } - else if ( thread_runner == std::string("TBB") ) { - alg_runner = stk_classic::algorithm_runner_tbb(num_threads); - } - - if (alg_runner != NULL) { - if (stk_classic::parallel_machine_rank(comm) == 0) - std::cout << "Using " << thread_runner << " algorithm runner, num_threads = " << num_threads << std::endl; - } else { - std::cout << "ERROR, failed to obtain requested AlgorithmRunner '" << thread_runner << "'." << std::endl; - return false; - } - - double dt = 1.0e-03; - double YM = 1e7; // Young's Modulus - double PR = 0.33; // Poisson Ratio - double element_mass_dummy_value = 1.0; - std::string material_model_name("ELASTIC"); - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - lame::MatProps materialProperties; - - std::vector youngs_modulus; youngs_modulus.push_back(YM); - std::vector poissons_ratio; poissons_ratio.push_back(PR); - std::vector bulk_modulus; bulk_modulus.push_back(BM); - std::vector shear_modulus; shear_modulus.push_back(SM); - std::vector two_mu; two_mu.push_back(TM); - std::vector lambda; lambda.push_back(LAMBDA); - std::vector dilatational_modulus; dilatational_modulus.push_back(DM); - - materialProperties["YOUNGS_MODULUS"] = youngs_modulus; - materialProperties["POISSONS_RATIO"] = poissons_ratio; - materialProperties["BULK_MODULUS"] = bulk_modulus; - materialProperties["SHEAR_MODULUS"] = shear_modulus; - materialProperties["TWO_MU"] = two_mu; - materialProperties["LAMBDA"] = lambda; - materialProperties["DILATATIONAL_MODULUS"] = dilatational_modulus; - - lame::Material * matmodel = lame::Elastic::createMaterial( materialProperties ); - - //---------------------------------- - - APSHex8ug hex_element; - - lame::matParams materialParameters; - materialParameters.dt = dt; - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - // [4] = Parallel swap-add of internal force - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case #14a" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData meta_data( SpatialDim ); - stk_classic::io::MeshData mesh_data; - std::string filename = working_directory + mesh_filename; - stk_classic::io::create_input_mesh(mesh_type, filename, comm, - meta_data, mesh_data); - stk_classic::io::define_input_fields(mesh_data, meta_data); - - stk_classic::mesh::Part & universal = meta_data.universal_part(); - const stk_classic::mesh::EntityRank node_rank = meta_data.node_rank(); - const stk_classic::mesh::EntityRank element_rank = meta_data.element_rank(); - // Nodal vector fields - CartesianField &model_coordinates = stk_classic::mesh::put_field(meta_data.declare_field("coordinates"), - node_rank, universal, SpatialDim); - CartesianField &coordinates_field = stk_classic::mesh::put_field(meta_data.declare_field("current_coordinates"), - node_rank, universal, SpatialDim); - CartesianField &velocity_field = stk_classic::mesh::put_field(meta_data.declare_field("velocity"), - node_rank, universal, SpatialDim); - CartesianField &fint_field = stk_classic::mesh::put_field(meta_data.declare_field("force_internal"), - node_rank, universal, SpatialDim); - - ScalarIntField &fint_lock_field = stk_classic::mesh::put_field(meta_data.declare_field("force_internal_lock"), - node_rank, universal); - - // Element vector fields: - CartesianField &Vorticity = stk_classic::mesh::put_field(meta_data.declare_field("Vorticity"), - element_rank, universal, SpatialDim); - - // Element scalar fields: - ScalarField &Shear_Modulus = stk_classic::mesh::put_field(meta_data.declare_field("shear_modulus" ), element_rank, universal); - ScalarField &Dilatational_Modulus = stk_classic::mesh::put_field(meta_data.declare_field("dilatational_modulus"), element_rank, universal); - ScalarField &Material_eff_twomu = stk_classic::mesh::put_field(meta_data.declare_field("material_effictive_two_mu"), element_rank, universal); - ScalarField &Material_eff_bulk_mod = stk_classic::mesh::put_field(meta_data.declare_field("material_effective_bulk_moduli"), element_rank, universal); - ScalarField &Midstep_volume = stk_classic::mesh::put_field(meta_data.declare_field("mid_step_volume"), element_rank, universal); - stk_classic::mesh::put_field(meta_data.declare_field("element_time_step"), element_rank, universal); - ScalarField &Element_mass = stk_classic::mesh::put_field(meta_data.declare_field("element_mass"), element_rank, universal); - ScalarField &Hourglass_energy = stk_classic::mesh::put_field(meta_data.declare_field("hourglass_energy"), element_rank, universal); - ScalarField &Internal_energy = stk_classic::mesh::put_field(meta_data.declare_field("internal_energy"), element_rank, universal); - - // Element symmetric tensor fields: - SymmetricTensorField &Stretch = declare_symmetric_tensor_field_on_all_elements(meta_data, "stretch", 6 ); - SymmetricTensorField &StrainRate = declare_symmetric_tensor_field_on_all_elements(meta_data, "StrainRate", 6 ); - SymmetricTensorField &RotatedStress= declare_symmetric_tensor_field_on_all_elements(meta_data, "RotatedStress", 6 ); - - //-------------------------------- - // The multi-state fields don't have the 'declare and put' convenience functions (yet) - // - // For clarity declare a integer to used for the number of states arguments. - // - const unsigned two_states = 2 ; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField &StressNew = meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states ); - put_field_on_all_elements( StressNew , 6 ); - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField &RotationNew = - put_field_on_all_elements( meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 ); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField &HourglassResistanceNew = - put_field_on_all_elements( meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 ); - - HourglassOpField & MidHourglassOp = - put_field_on_all_elements( meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 ); - - //-------------------------------- - // Declare aggressive "gather" fields which are an array of - // pointers to the element's nodes' coordinate, velocity, and - // internal force field data. - // - // The declarations specify element fields of the following form: - // - // double * coord_gather [ nodes_per_element ] - // double * velocity_gather[ nodes_per_element ] - // - // where - // - // coord_gather[i] == field_data( coordinates_field , element_node[i] ) - // velocity_gather[i] == field_data( velocity , element_node[i] ) - // - // The number of nodes per element could vary, so the field is put - // on each element block with a size of the number of nodes per - // element in that element block. - - ElementNodePointerField & coord_gather = declare_element_node_pointer_field(meta_data.get_meta_data(meta_data) , "coord_gather" , coordinates_field ); - ElementNodePointerField & velocity_gather = declare_element_node_pointer_field(meta_data.get_meta_data(meta_data) , "velocity_gather" , velocity_field ); - ElementNodePointerField & fint_gather = declare_element_node_pointer_field(meta_data.get_meta_data(meta_data) , "fint_gather" , fint_field ); - ElementNodeLockField & fint_lock_gather = declare_element_node_lock_field(meta_data.get_meta_data(meta_data), "fint_lock_gather" , fint_lock_field ); - - //---------------------------------- - // Declare an element field with one value per connected node in - // which to temporarily store nodal force that is calculated by - // the internal force algorithm. - - ElementNodeVectorField & force_new_field = meta_data.declare_field( "force_new_field" , 1 /* 1 state */ ); - - // All parts of the meta data: - { - const mesh::PartVector & all_parts = meta_data.get_parts(); - for (mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - mesh::Part * const part = *i ; - if ( part->primary_entity_rank() == get_element_rank(meta_data) ) { - put_field_on_elements(coord_gather, *part, shards::Hexahedron<> ::node_count ); - put_field_on_elements(velocity_gather, *part, shards::Hexahedron<> ::node_count ); - put_field_on_elements( fint_gather , *part , shards::Hexahedron<> ::node_count ); - put_field_on_elements( fint_lock_gather , *part , shards::Hexahedron<> ::node_count ); - put_field_on_elements(force_new_field, *part, SpatialDim, shards::Hexahedron<>::node_count ); - } - } - } - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - stk_classic::mesh::BulkData bulk_data(meta_data.get_meta_data(meta_data) , comm, max_entity_per_bucket); - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - //------------------------------------------------------------------ - // Create output mesh... (input filename + ".out14") - if (output) { - filename = working_directory + mesh_filename + ".out14a"; - stk_classic::io::create_output_mesh(filename, comm, bulk_data, mesh_data); - stk_classic::io::define_output_fields(mesh_data, meta_data, true); - } - - stk_classic::app::use_case_14_initialize_nodal_data(bulk_data , - model_coordinates , - coordinates_field , - velocity_field, dt); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - const std::vector< stk_classic::mesh::Bucket * > - & element_buckets = bulk_data.buckets( get_element_rank(meta_data) ); - - stk_classic::mesh::Selector - select_owned_buckets( stk_classic::mesh::MetaData::get(bulk_data).locally_owned_part() ); - - size_t maximum_bucket_size = 0 ; - size_t minimum_bucket_size = INT_MAX ; - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) - if ( select_owned_buckets( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - if ( maximum_bucket_size < bucket.size() ) { maximum_bucket_size = bucket.size(); } - if ( minimum_bucket_size > bucket.size() ) { minimum_bucket_size = bucket.size(); } - } - - // Need both the the old and new states of these two-state fields: - - HourglassArrayField & HourglassResistanceOld = HourglassResistanceNew.field_of_state( stk_classic::mesh::StateOld ); - SymmetricTensorField & StressOld = StressNew.field_of_state( stk_classic::mesh::StateOld ); - FullTensorField & RotationOld = RotationNew.field_of_state( stk_classic::mesh::StateOld ); - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned_buckets( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - - double * stretch = stk_classic::mesh::field_data( Stretch, bucket.begin() ); - double * strain_rate = stk_classic::mesh::field_data( StrainRate, bucket.begin() ); - double * stress_new = stk_classic::mesh::field_data( StressNew, bucket.begin() ); - double * stress_old = stk_classic::mesh::field_data( StressOld , bucket.begin() ); - double * rotated_stress = stk_classic::mesh::field_data( RotatedStress , bucket.begin() ); - double * rotation_old = stk_classic::mesh::field_data( RotationOld , bucket.begin() ); - double * rotation_new = stk_classic::mesh::field_data( RotationNew , bucket.begin() ); - double * mass = stk_classic::mesh::field_data( Element_mass , bucket.begin() ); - double * hg_old = stk_classic::mesh::field_data( HourglassResistanceOld , bucket.begin() ); - double * hg_new = stk_classic::mesh::field_data( HourglassResistanceNew , bucket.begin() ); - double * vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - double * mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - - std::fill(strain_rate, strain_rate + 6*num_elements, 0.0); - std::fill(stress_new, stress_new + 6*num_elements, 0.0); - std::fill(stress_old, stress_old + 6*num_elements, 0.0); - std::fill(rotated_stress, rotated_stress + 6*num_elements, 0.0); - std::fill(mass, mass + num_elements, element_mass_dummy_value); - std::fill(hg_old, hg_old + 12*num_elements, 0.0); - std::fill(hg_new, hg_new + 12*num_elements, 0.0); - std::fill(vorticity_ptr, vorticity_ptr + 3*num_elements, 0.0); - std::fill(mid_hg_op_ptr, mid_hg_op_ptr + 32*num_elements, 0.0); - - for ( int i = 0 ; i < num_elements ; ++i ) { - // initialize stretch to identity. - stretch[0] = 1.0; - stretch[1] = 1.0; - stretch[2] = 1.0; - stretch[3] = 0.0; - stretch[4] = 0.0; - stretch[5] = 0.0; - stretch+=6; - - // initialize rotation to identity. - rotation_old[0] = 1.0; - rotation_old[1] = 1.0; - rotation_old[2] = 1.0; - rotation_old[3] = 0.0; - rotation_old[4] = 0.0; - rotation_old[5] = 0.0; - rotation_old[6] = 0.0; - rotation_old[7] = 0.0; - rotation_old[8] = 0.0; - rotation_old +=9; - - // initialize rotation to identity. - rotation_new[0] = 1.0; - rotation_new[1] = 1.0; - rotation_new[2] = 1.0; - rotation_new[3] = 0.0; - rotation_new[4] = 0.0; - rotation_new[5] = 0.0; - rotation_new[6] = 0.0; - rotation_new[7] = 0.0; - rotation_new[8] = 0.0; - rotation_new += 9; - } - } - if (stk_classic::parallel_machine_rank(comm) == 0) - std::cout << "KHP: Done element field init\n"; - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned_buckets( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements = bucket.size(); - - double * const sm = stk_classic::mesh::field_data( Shear_Modulus , bucket.begin() ); - double * const dm = stk_classic::mesh::field_data( Dilatational_Modulus , bucket.begin() ); - double * const twomu = stk_classic::mesh::field_data( Material_eff_twomu , bucket.begin() ); - double * const bulk = stk_classic::mesh::field_data( Material_eff_bulk_mod , bucket.begin() ); - double * const mv = stk_classic::mesh::field_data( Midstep_volume , bucket.begin() ); - double * const hg_energy = stk_classic::mesh::field_data( Hourglass_energy , bucket.begin() ); - double * const internal_energy = stk_classic::mesh::field_data( Internal_energy , bucket.begin() ); - - std::fill(sm, sm+num_elements, SM); - std::fill(dm, dm+num_elements, DM); - std::fill(twomu, twomu+num_elements, TM); - std::fill(bulk, bulk+num_elements, BM); - std::fill(mv, mv+num_elements, 0.0); - std::fill(hg_energy, hg_energy+num_elements, 0.0); - std::fill(internal_energy, internal_energy+num_elements, 0.0); - } - - zero_field_data( bulk_data , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , fint_lock_field ); - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - wtime = stk_classic::wall_time(); - - MyHexInternalForceAlg2 elem_alg(materialParameters, materialProperties, matmodel, - meta_data.get_meta_data(meta_data), maximum_bucket_size); -// MyHexInternalForceAlg3 elem_alg(materialParameters, materialProperties, matmodel, -// meta_data, maximum_bucket_size); - - for(int n=0; nrun( select_owned_buckets , empty_union_vector, element_buckets , elem_alg ); - - time_max[3] += stk_classic::wall_dtime( wtime ); - - stk_classic::mesh::parallel_reduce( bulk_data , stk_classic::mesh::sum(fint_field) ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - if (output) { - stk_classic::io::process_output_request(mesh_data, bulk_data, n); - } - - }//end for(..num_trials... - delete matmodel; - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation= " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Internal force = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Internal force (total) = " << time_min[3]*num_trials - << std::endl - << " Lock collisions = " << g_lockCollision - << std::endl - << " Swap-add = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace app -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_24.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_24.cpp deleted file mode 100644 index 3716f8051fa5..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_24.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { -namespace app { - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 13 -// The function 'use_case_24_driver' below is the equivalent of 'main'. -// The use case is to define some fields here and there and iterate -// elements to populate this data. -//---------------------------------------------------------------------- - -enum { SpatialDim = 3 }; - -//---------------------------------------------------------------------- - -typedef mesh::Field ScalarFieldType ; -typedef mesh::Field VectorFieldType ; -typedef mesh::Field ScalarIPFieldType ; -typedef mesh::Field VectorIPFieldType ; - -typedef mesh::EntityArray ScalarArray; -typedef mesh::EntityArray VectorArray; -typedef mesh::EntityArray ScalarIPArray; -typedef mesh::EntityArray VectorIPArray; - -// Specification for the aggressive gather pointer-field for elements. - -typedef mesh::Field ElementNodePointerFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_24_boundary_algorithm( - mesh::BulkData & bulkData , - mesh::Part & quad_block, - const ScalarIPFieldType & pressure_ip, - const VectorIPFieldType & mass_flux_ip, - const VectorIPFieldType & momentum_flux_bip, - const ScalarFieldType & pressure, - const VectorFieldType & velocity, - const VectorFieldType & nodal_momentum_flux ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 24: face:element looping -// - -bool use_case_24_driver( - MPI_Comm comm, - const std::string &working_directory, - const std::string &meshName, - const std::string &outputName ) -{ - const unsigned p_rank = parallel_machine_rank( comm ); - - //-------------------------------------------------------------------- - - if ( ! p_rank ) { - std::cout << "stk_mesh Use Case #24, begin" << std::endl - << " Number Processes = " << parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim); - const mesh::EntityRank element_rank = fem_meta.element_rank(); - const mesh::EntityRank side_rank = fem_meta.side_rank(); - const mesh::EntityRank edge_rank = fem_meta.edge_rank(); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - mesh::Part & allParts = fem_meta.universal_part(); - mesh::Part & hex_io1 = fem_meta.declare_part("block_1", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( hex_io1, hex_top ); - - //-------------------------------- - // Surface-block declarations - mesh::Part & quad_io1 = fem_meta.declare_part("surface_1", side_rank); - mesh::Part & quad_io2 = fem_meta.declare_part("surface_2", side_rank); - mesh::Part & quad_io3 = fem_meta.declare_part("surface_3", side_rank); - - //======================================== - // Define where the field lives and its' size; - //======================================== - - //----------------------------------------- - // coordinates_field, velocity and pressure - // live on all nodes in the domain - //----------------------------------------- - - VectorFieldType & coordinates_field = - fem_meta.declare_field< VectorFieldType >( "coordinates" ); - - VectorFieldType & velocity = - fem_meta.declare_field< VectorFieldType >( "velocity" ); - - ScalarFieldType & pressure = - fem_meta.declare_field< ScalarFieldType >( "pressure" ); - - // add these nodal fields to allParts that have nodes in the universe - - // NOTE SPD 10/24/2008 - // how about put_field_on_part() rather than put_field() - mesh::put_field( coordinates_field , mesh::fem::FEMMetaData::NODE_RANK , allParts , SpatialDim ); - mesh::put_field( velocity , mesh::fem::FEMMetaData::NODE_RANK , allParts , SpatialDim ); - mesh::put_field( pressure , mesh::fem::FEMMetaData::NODE_RANK , allParts ); - - //----------------------------------------- - // nodal_face_momentum_flux lives on all - // sideset nodes in the domain - //----------------------------------------- - - VectorFieldType & nodal_momentum_flux = - fem_meta.declare_field< VectorFieldType >( "nodal_momentum_flux" ); - - mesh::put_field( nodal_momentum_flux , mesh::fem::FEMMetaData::NODE_RANK , quad_io1 ); - mesh::put_field( nodal_momentum_flux , mesh::fem::FEMMetaData::NODE_RANK , quad_io2 ); - mesh::put_field( nodal_momentum_flux , mesh::fem::FEMMetaData::NODE_RANK , quad_io3 ); - - //======================================== - // hard code dimensions for now for ip - //======================================== - const int numBoundaryIps = 4; // valid for a linear Quad element - const int numElementSCSIps = 12; // valid for a linear hex CVFEM element - - // momentum_flux_bip lives only on the boundary points - - VectorIPFieldType & momentum_flux_bip = - fem_meta.declare_field< VectorIPFieldType >( "momentum_flux_bip" ); - - // NOTE SPD 10/22/2008 - // I am not sure that I like all of these specialty put_field() methods - // Perhaps it would be better to define a set of attributes that a field - // requires like dimension, and where it lives. Then, we can have some - // sort of method on the field that sets it... - // so, below would look like: - - /* - - mom_flux_bip.spatial_dimension(SpatialDim); - mom_flux_bip.size_of_where_it_lives(numBoundaryIps); - - */ - - // This would also help in extracting the size of things rather than remembering - // what index should be passed to dimension() - - mesh::put_field(momentum_flux_bip , side_rank , quad_io1 , SpatialDim, numBoundaryIps ); - mesh::put_field(momentum_flux_bip , side_rank , quad_io2 , SpatialDim, numBoundaryIps ); - mesh::put_field(momentum_flux_bip , side_rank , quad_io3 , SpatialDim, numBoundaryIps ); - - //----------------------------------------- - // pressure_ip lives both on boundary - // and interior integration points - //----------------------------------------- - - ScalarIPFieldType & pressure_ip = - fem_meta.declare_field< ScalarIPFieldType >( "pressure_ip" ); - - // first on boundary ips - mesh::put_field( pressure_ip , side_rank , quad_io1 , numBoundaryIps ); - mesh::put_field( pressure_ip , side_rank , quad_io2 , numBoundaryIps ); - mesh::put_field( pressure_ip , side_rank , quad_io3 , numBoundaryIps ); - - // second on all interior element ips - mesh::put_field( pressure_ip , element_rank , hex_io1 , numElementSCSIps ); - - //----------------------------------------- - // mass_flux_ip lives both on boundary - // and interior integration points - //----------------------------------------- - - VectorIPFieldType & mass_flux_ip = - fem_meta.declare_field< VectorIPFieldType >( "mass_flux_ip" ); - - // first on boundary ips - mesh::put_field(mass_flux_ip , side_rank , quad_io1 , SpatialDim, numBoundaryIps ); - mesh::put_field(mass_flux_ip , side_rank , quad_io2 , SpatialDim, numBoundaryIps ); - mesh::put_field(mass_flux_ip , side_rank , quad_io3 , SpatialDim, numBoundaryIps ); - - // second on all interior element ips - mesh::put_field(mass_flux_ip , element_rank , hex_io1 , SpatialDim, numElementSCSIps ); - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - //-------------------------------- Read the exodusII mesh file. - //Create parts and fields for all io parts, attributes, and fields - //found in the input mesh file. - - const std::string dbtype("exodusii"); - stk_classic::io::MeshData mesh_data; - stk_classic::mesh::MetaData & meta_data = - stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - std::string filename = working_directory + meshName; - stk_classic::io::create_input_mesh(dbtype, filename, comm, fem_meta, mesh_data); - - // Commit (finalize) the meta data (part and field definitions). - // Is now ready to be used in the creation and management of mesh bulk data. - - // Output the pressure and velocity fields... - stk_classic::io::set_field_role(pressure, Ioss::Field::TRANSIENT); - stk_classic::io::set_field_role(velocity, Ioss::Field::TRANSIENT); - - fem_meta.commit(); - - //------------------------------------------------------------------ - // mesh::BulkData bulk data (nodes, faces, node date, etc) - // conforming to the meta data. - - mesh::BulkData mesh_bulk_data( meta_data , comm ); - - // Read bulk data from mesh file - stk_classic::io::populate_bulk_data(mesh_bulk_data, mesh_data); - - { - std::vector count ; - mesh::Selector selector = fem_meta.locally_owned_part() | - fem_meta.globally_shared_part(); - count_entities( selector, mesh_bulk_data, count ); - - std::cout << " P" << p_rank << ": Uses {" ; - std::cout << " Node = " << count[ mesh::fem::FEMMetaData::NODE_RANK] ; - std::cout << " Edge = " << count[ edge_rank] ; - std::cout << " Face = " << count[ side_rank] ; - std::cout << " Elem = " << count[ element_rank] ; - std::cout << " }" << std::endl ; - std::cout.flush(); - } - - //------------------------------------------------------------------ - // process only two of the sidesets - use_case_24_boundary_algorithm( mesh_bulk_data , quad_io1, - pressure_ip, mass_flux_ip, - momentum_flux_bip, pressure, velocity, - nodal_momentum_flux ); - - use_case_24_boundary_algorithm( mesh_bulk_data , quad_io3, - pressure_ip, mass_flux_ip, - momentum_flux_bip, pressure, velocity, - nodal_momentum_flux ); - - stk_classic::io::create_output_mesh(outputName, comm, mesh_bulk_data, mesh_data); - stk_classic::io::define_output_fields(mesh_data, fem_meta); - stk_classic::io::process_output_request(mesh_data, mesh_bulk_data, 0.0); - - return true; -} - -//-------------------------------------------------------------------- - -void use_case_24_boundary_algorithm( - mesh::BulkData & bulkData , - mesh::Part & quad_block, - const ScalarIPFieldType & pressure_ip, - const VectorIPFieldType & mass_flux_ip, - const VectorIPFieldType & momentum_flux_bip, - const ScalarFieldType & pressure, - const VectorFieldType & velocity, - const VectorFieldType & nodal_momentum_flux ) -{ - mesh::fem::FEMMetaData &fem_meta = mesh::fem::FEMMetaData::get(bulkData); - const mesh::EntityRank element_rank = fem_meta.element_rank(); - const mesh::EntityRank side_rank = fem_meta.side_rank(); - - // create intersection of faces and locally owned - mesh::Selector select_owned_block = quad_block & fem_meta.locally_owned_part(); - - // Get vector of buckets ( entities and field data) - // for which the sides (quad_block) are all locally owned. - - const std::vector & buckets = bulkData.buckets( side_rank ); - - unsigned count = 0 ; - - for ( std::vector::const_iterator - ik = buckets.begin() ; ik != buckets.end() ; ++ik ) if ( select_owned_block( **ik ) ) { - - const mesh::Bucket & faceBucket = **ik ; - - // Number of sides in this bucket of sides and side field data - - const int number = faceBucket.size(); - - count += number ; - - for ( int i = 0 ; i < number ; ++i ) { - - mesh::Entity & face = faceBucket[i] ; - - const mesh::PairIterRelation face_elem = face.relations( element_rank ); - const mesh::PairIterRelation face_nodes = face.relations( mesh::fem::FEMMetaData::NODE_RANK); - - if ( face_elem.size() != 1 ) { - std::cout << " There appears to be more than one element connected to this boundary face.." << std::endl; - throw std::exception(); - } - else { - - mesh::Entity &elem = *face_elem[0].entity(); - - //======================================= - // populate face bip data with values - //======================================= - - // define some arrays for bip data - ScalarIPArray p_bip_array(pressure_ip, face); - VectorIPArray mf_bip_array(mass_flux_ip, face); - VectorIPArray mom_flux_bip(momentum_flux_bip, face); - - // FIXME SPD 10/22/2008 - // I do not like to remember specific indexes, e.g. what dimension(0), - // dimension(1), etc. means - // For example dimension(o) for ScalarIPFieldType provides numBoundaryIps - // whereas dimension(0) for a VectorIPFieldType, provides the SpatialDim.. - // Again, I might like to see some specific method off of the field that returns - // things such as SpatialDim, and HowManyThereAre, e.g., numBoundaryIps - const int numBoundaryIps = p_bip_array.dimension(0); - const int nDim = mom_flux_bip.dimension(0); - for ( int k = 0; k < numBoundaryIps; ++k ) - { - p_bip_array(k) = 1.0; - for (int j = 0; j < nDim; ++j){ - mf_bip_array(j,k) = 1.0; - mom_flux_bip(j,k) = 1.0; - } - - } - - //======================================= - // populate face nodal data with values - //======================================= - - for ( unsigned int k = 0; k < face_nodes.size(); ++k ) - { - mesh::Entity &node = *face_nodes[k].entity(); - - double * const pNode = field_data( pressure ,node ); - *pNode = 1.0; - - VectorArray v_face_node_array(velocity, node); - VectorArray mf_face_node_array(nodal_momentum_flux, node); - for ( int j = 0; j < nDim; ++j ){ - v_face_node_array(j) = 1.0; - mf_face_node_array(j) = 1.0; - } - - } - - - //======================================= - // populate element ip values - //======================================= - - // define some arrays for bip data - ScalarIPArray p_ip_array(pressure_ip, elem); - VectorIPArray mf_ip_array(mass_flux_ip, elem); - - // FIXME SPD 10/22/2008 - // I do not like to remember specific indexes, e.g. dimension(0) means, - // for a ScalarIPFieldType, numBoundaryIps whereas for a VectorIPFieldType, - // dimension(0) provides the SpatialDim.. - const int numInteriorIps = p_ip_array.dimension(0); - const int nnDim = mf_ip_array.dimension(0); - for ( int k = 0; k < numInteriorIps; ++k ) - { - p_ip_array(k) = 1.0; - for (int j = 0; j < nnDim; ++j){ - mf_ip_array(j,k) = 2.0; - } - - } - - //================================================ - // populate off elem nodes data with values - //================================================ - - const mesh::PairIterRelation elem_nodes = elem.relations( mesh::fem::FEMMetaData::NODE_RANK); - const int localFaceNumber = face_elem[0].identifier(); - const CellTopologyData *topo = mesh::fem::get_cell_topology(elem).getCellTopologyData(); - std::vector skipNode(elem_nodes.size(),0); - - for ( int j = 0; j < numBoundaryIps; ++j ) - { - const int faceNode = topo->side[localFaceNumber].node[j]; - skipNode[faceNode] = 1; - } - - // define some arrays for bip data - for ( unsigned int k = 0; k < elem_nodes.size(); ++k ) - { - mesh::Entity &node = *elem_nodes[k].entity(); - - double * const pNode = field_data( pressure ,node ); - VectorArray v_face_node_array(velocity, node); - - if ( !skipNode[k] ) - { - *pNode = 2.0; - - for ( int j = 0; j < nDim; ++j ) - v_face_node_array(j) = 2.0; - } - } - } - } - } - - std::cout << "use_case_24_boundary_algorithm applied to '" - << quad_block.name() - << "' processed " << count << " faces" << std::endl ; -} - -} // end namespace stk_classic -} // end namespace app - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_7.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_7.cpp deleted file mode 100644 index a4f6bdc1c939..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_7.cpp +++ /dev/null @@ -1,744 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 7: performance case. -// The function 'use_case_7_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -enum { SpatialDim = 3 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -// Specification for the aggressive gather pointer-field for elements. - -typedef stk_classic::mesh::Field ElementNodePointerFieldType ; - -// Centroid algorithm generic programming functions: - -#include - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_7_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const ElementNodePointerFieldType & elem_node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_7_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -bool use_case_7_driver( - MPI_Comm comm , - int num_threads , - const std::string& thread_runner , - const std::string & mesh_options , - const unsigned num_trials ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 7: heterogeneous element mesh. -// - -bool use_case_7_driver( MPI_Comm comm , - bool performance_test , - const std::string& mesh_options , - int num_threads , - const std::string& thread_runner ) -{ - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh Use Case #7, begin" << std::endl ; - } - - int num_trials = 1; - if ( performance_test ) num_trials = 100; - - return use_case_7_driver( comm , num_threads, thread_runner, mesh_options, num_trials ); - -//The following 3 cases are run by 3 different xml files in the -//stk_app_rtest/performance/use_case_7 regression test. -// -// 1000x1x1000 plate: 1M hex, 1M shells -// shells on min-y face -// -// 50x50x500 beam: 1.25M hex, 2.5K shells -// shells on min-z face -// -// 100x100x100 cube: 1M hex, 60K shells -// shells on all 6 faces -// -} - -//-------------------------------------------------------------------- - -bool use_case_7_driver( - MPI_Comm comm , - int num_threads , - const std::string& thread_runner , - const std::string & mesh_options , - const unsigned num_trials ) -{ - // stk_classic::mesh::BulkData bulk data CHUNK_SIZE = max entities per field data chunk. - // (CHUNK_SIZE is the application's preferred "workset" size.) - - // Timing: - // [0] = BulkData creation - // [1] = BulkData synchronization - // [2] = Element computation #1 - // [3] = Element computation #1 gathered - // [4] = Element computation #2 - // [5] = Element computation #2 gathered - // [6] = Node computation #1 - // [7] = Node computation #2 - // [8] = stk_classic::mesh::BulkData output - // [9] = stk_classic::mesh::BulkData destruction - - double time_min[10] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[10] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - double result_inner_product[2] = { 0 , 0 }; - std::vector hex_block_count ; - std::vector shell_block_count ; - - - const AlgorithmRunnerInterface* alg_runner = NULL ; - if (thread_runner.empty() || thread_runner == "NonThreaded") { - alg_runner = stk_classic::algorithm_runner_non_thread(); - } - else if (thread_runner == "TPI") { - alg_runner = stk_classic::algorithm_runner_tpi(num_threads); - } - else if ( thread_runner == std::string("TBB") ) { - alg_runner = stk_classic::algorithm_runner_tbb(num_threads); - } - - if (alg_runner != NULL) { - if (stk_classic::parallel_machine_rank(comm) == 0) - std::cout << "Using " << thread_runner - << " algorithm runner, num_threads = " << num_threads - << std::endl; - } else { - std::cout << "ERROR, failed to obtain requested AlgorithmRunner '" - << thread_runner << "'." << std::endl; - return false; - } - - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh use case 7" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - if ( num_threads ) { - std::cout << " Threads/process = " << num_threads << std::endl ; - } - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - { - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & universal = fem_meta.universal_part(); - stk_classic::mesh::Part & block_hex = fem_meta.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = fem_meta.declare_part("block_2", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field(fem_meta.declare_field< VectorFieldType >( "coordinates" ) , fem_meta.node_rank() , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field(fem_meta.declare_field< VectorFieldType >( "displacements" ) , fem_meta.node_rank() , universal , SpatialDim ); - - VectorFieldType & residual_field = - stk_classic::mesh::put_field(fem_meta.declare_field< VectorFieldType >( "residual" ) ,fem_meta.node_rank() , universal , SpatialDim ); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field(fem_meta.declare_field< VectorFieldType >( "rotation" ), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - //-------------------------------- - // Declare the coordinates field for all elements - for the centroid - - stk_classic::mesh::put_field(coordinates_field , element_rank , universal , SpatialDim ); - - // Declare rotation field on elements also - for the mean rotation. - - stk_classic::mesh::put_field(rotation_field , element_rank , block_quad_shell , SpatialDim ); - - //-------------------------------- - // Declare an aggressive "gather" field which is an - // array of pointers to the element's nodes' coordinate field data. - // The declaration specifies: - // - // double * elem_node_coord[number_of_nodes] - - ElementNodePointerFieldType & elem_node_coord = - fem_meta.declare_field< ElementNodePointerFieldType >( "elem_node_coord" ); - - ElementNodePointerFieldType & elem_node_rot = - fem_meta.declare_field< ElementNodePointerFieldType >( "elem_node_rot" ); - - // Declare that the 'elem_node_coord' pointer field data - // points to the 'coordinates_field' data on the nodes. - - fem_meta.declare_field_relation( - elem_node_coord , - stk_classic::mesh::fem::get_element_node_stencil(SpatialDim) , - coordinates_field ); - - fem_meta.declare_field_relation( - elem_node_rot , - stk_classic::mesh::fem::get_element_node_stencil(SpatialDim) , - rotation_field ); - - // Declare the size of the aggressive "gather" field - // double * elem_node_coord[ size = number_of_nodes ] - // is the number of nodes per element. - // This size is different for each element block. - - stk_classic::mesh::put_field(elem_node_coord , element_rank , block_hex , shards::Hexahedron<> ::node_count ); - - stk_classic::mesh::put_field(elem_node_coord, element_rank, block_quad_shell,shards::ShellQuadrilateral<> ::node_count ); - - stk_classic::mesh::put_field(elem_node_rot, element_rank, block_quad_shell,shards::ShellQuadrilateral<> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_7_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - elem_node_coord , - block_hex , - block_quad_shell ); - - use_case_7_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - time_max[0] = stk_classic::wall_dtime( wtime ); - - mesh_bulk_data.modification_end(); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (stk_classic::parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<& node_buckets = mesh_bulk_data.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - const std::vector< stk_classic::mesh::Bucket * >& elem_buckets = mesh_bulk_data.buckets( element_rank ); - - ElementMeanValue elem_mean_hex(coordinates_field, elem_node_coord); - ElementMeanValue_Gather elem_mean_gather_hex(coordinates_field, elem_node_coord); - - ElementMeanValue elem_mean_quad_shell(rotation_field, elem_node_rot); - ElementMeanValue_Gather elem_mean_gather_quad_shell(rotation_field, elem_node_rot); - - double a_scale = 0.5 ; - double b_scale = 0.5 ; - double c_scale = 0.5 ; - - NodeScaleSum node_scale_sum(a_scale, residual_field, - b_scale, displacements_field, - c_scale, rotation_field); - - //------------------------------------------------------------------ - // Timing tests: - - for ( unsigned i = 0 ; i < num_trials ; ++i ) { - - wtime = stk_classic::wall_time(); - - // None of these Selector usages have a union part vector so we - // pass in an empty union vector. - mesh::PartVector empty_union_vector; - - alg_runner->run( selector_hex , empty_union_vector, elem_buckets , elem_mean_hex ); - - time_max[2] += stk_classic::wall_dtime( wtime ); - - alg_runner->run( selector_hex , empty_union_vector, elem_buckets , elem_mean_gather_hex ); - - time_max[3] += stk_classic::wall_dtime( wtime ); - - // Mean rotation of shell elements: - - alg_runner->run( selector_quad_shell , empty_union_vector, elem_buckets , elem_mean_quad_shell ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - alg_runner->run( selector_quad_shell , empty_union_vector, elem_buckets , elem_mean_gather_quad_shell ); - - time_max[5] += stk_classic::wall_dtime( wtime ); - - alg_runner->run( selector_all , empty_union_vector, node_buckets , node_scale_sum ); - - time_max[6] += stk_classic::wall_dtime( wtime ); - - double result = dot(*alg_runner , mesh_bulk_data , stk_classic::mesh::fem::FEMMetaData::NODE_RANK , residual_field , displacements_field); - - time_max[7] += stk_classic::wall_dtime( wtime ); - - if ( ! i ) { result_inner_product[0] = result ; } - if ( i + 1 == num_trials ) { result_inner_product[1] = result ; } - } - - //------------------------------ - - wtime = stk_classic::wall_time(); - } - - time_max[9] = stk_classic::wall_dtime( wtime ); - - bool success = true; - - if (mesh_options == "1000x1x1000+shell:y" && num_trials == 100) { - double expected_final_inner_prod = 1.4035038e+10; - double err = std::abs(expected_final_inner_prod - result_inner_product[1])/expected_final_inner_prod; - success = err < 1.e-6; - if ( !success ) { - std::cout << "TEST FAILED: Inner-product Err="<( time_max ) & stk_classic::ReduceMin<10>( time_min ) ); - - time_max[2] /= num_trials ; - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - time_max[7] /= num_trials ; - - time_min[2] /= num_trials ; - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - time_min[7] /= num_trials ; - - double centroid_grind_time = 0 ; - double mean_rot_grind_time = 0 ; - - if ( hex_block_count[element_rank] + shell_block_count[element_rank] ) { - centroid_grind_time = 1e6 * - time_max[2] / ( hex_block_count[element_rank] + shell_block_count[element_rank] ); - } - - if ( shell_block_count[element_rank] ) { - mean_rot_grind_time = 1e6 * - time_max[4] / ( shell_block_count[element_rank] ); - } - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Mesh Options = '" << mesh_options << "', " << std::endl - << std::endl - << " Inner-prod trial #1 = " << result_inner_product[0] - << std::endl - << " Inner-prod trial #" << num_trials - << " = " << result_inner_product[1] - << std::endl - << " Mesh generation = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Mesh synchronization = " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Elem centroid = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Elem centroid gather= " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Elem centroid grind = " << centroid_grind_time - << " millisec / element" - << std::endl - << " Elem mean-rot = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Elem mean-rot gather= " << time_min[5] << " : " - << time_max[5] << " sec, min : max" - << std::endl - << " Elem mean-rot grind = " << mean_rot_grind_time - << " millisec / shell" - << std::endl - << " Node scaled sum = " << time_min[6] << " : " - << time_max[6] << " sec, min : max" - << std::endl - << " Node inner-prod = " << time_min[7] << " : " - << time_max[7] << " sec, min : max" - << std::endl - << " Mesh output = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[9] << " : " - << time_max[9] << " sec, min : max" - << std::endl - << std::endl ; - std::cout << "Output for wiki table:"< & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_classic { -namespace app { - -void use_case_7_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const ElementNodePointerFieldType & /*elem_node_coord */, - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - node_map[ local_node_id[0] - 1 ] , - node_map[ local_node_id[1] - 1 ] , - node_map[ local_node_id[2] - 1 ] , - node_map[ local_node_id[3] - 1 ] , - node_map[ local_node_id[4] - 1 ] , - node_map[ local_node_id[5] - 1 ] , - node_map[ local_node_id[6] - 1 ] , - node_map[ local_node_id[7] - 1 ] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - node_map[ local_node_id[0] - 1 ] , - node_map[ local_node_id[1] - 1 ] , - node_map[ local_node_id[2] - 1 ] , - node_map[ local_node_id[3] - 1 ] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace app -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_blas.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_blas.cpp deleted file mode 100644 index c2510205fe70..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_blas.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 14: internal force computation. -// The function 'use_case_14_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -static const size_t spatial_dimension = 3; - -bool use_case_blas_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int bucket_size, - bool performance_test) -{ - bool output = !performance_test; // If running for performance measurements, turn off output - - if (stk_classic::parallel_machine_rank(comm) == 0) { - std::cout << " stk_mesh Use Case Blas - fill, axpby, dot, norm , begin" << std::endl ; - std::cout << "Running '" << mesh_filename << "' case, num_trials = " - << num_trials << std::endl; - } - - - const AlgorithmRunnerInterface* alg_runner = NULL ; - if ( thread_runner.empty() || - thread_runner == std::string("NonThreaded") ) { - alg_runner = stk_classic::algorithm_runner_non_thread(); - } - else if ( thread_runner == std::string("TPI") ) { - alg_runner = stk_classic::algorithm_runner_tpi(num_threads); - } - else if ( thread_runner == std::string("TBB") ) { - alg_runner = stk_classic::algorithm_runner_tbb(num_threads); - } - - if (alg_runner != NULL) { - if (stk_classic::parallel_machine_rank(comm) == 0) - std::cout << "Using " << thread_runner - << " algorithm runner, num_threads = " << num_threads - << std::endl; - } else { - std::cout << "ERROR, failed to obtain requested AlgorithmRunner '" - << thread_runner << "'." << std::endl; - return false; - } - - //---------------------------------- - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = fill and axpby - // [4] = dot and norm2 - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case BLAS" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::io::MeshData mesh_data; - std::string filename = working_directory + mesh_filename; - stk_classic::io::create_input_mesh(mesh_type, filename, comm, - meta_data, mesh_data); - stk_classic::io::define_input_fields(mesh_data, meta_data); - - Fields fields; - use_case_14_declare_fields(fields, meta_data.get_meta_data(meta_data)); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - stk_classic::mesh::BulkData bulk_data(meta_data.get_meta_data(meta_data) , comm, bucket_size); - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - //------------------------------------------------------------------ - // Create output mesh... (input filename + ".out14") - if (output) { - filename = working_directory + mesh_filename + ".blas"; - stk_classic::io::create_output_mesh(filename, comm, bulk_data, mesh_data); - stk_classic::io::define_output_fields(mesh_data, meta_data, true); - } - - stk_classic::app::use_case_14_initialize_nodal_data(bulk_data , - *fields.model_coordinates , - *fields.coordinates_field , - *fields.velocity_field, - 1.0 /*dt*/); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - wtime = stk_classic::wall_time(); - - double dot1 = 0; - - for(int n=0; n( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number of trials = " << num_trials << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation = " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " fill & axpby (per-trial) = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " dot & norm2 (per-trial) = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } - - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace app -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_blas_algs.hpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_blas_algs.hpp deleted file mode 100644 index 6a96181f974a..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_blas_algs.hpp +++ /dev/null @@ -1,324 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef USECASE_BLAS_ALGS_HPP -#define USECASE_BLAS_ALGS_HPP - -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -/** AxpbyAlg calculates: y = alpha*x + beta*y -*/ -template< class field_type > -class AxpbyAlg { -public: - AxpbyAlg(double alpha, field_type& x, - double beta, field_type& y) - : alpha_(alpha), beta_(beta), x_(x), y_(y) - { - // put a test here to insist on compatibility of x and y fields... - } - - ~AxpbyAlg(){} - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator bucket_i , - stk_classic::mesh::Bucket::iterator bucket_j ) const - { - typedef typename stk_classic::mesh::FieldTraits::data_type scalar ; - - stk_classic::mesh::BucketArray xa( x_ , bucket_i , bucket_j ); - stk_classic::mesh::BucketArray ya( y_ , bucket_i , bucket_j ); - - scalar * xi = xa.contiguous_data(); - scalar * yi = ya.contiguous_data(); - scalar * ye = yi + ya.size(); - - //is it worthwhile to optimize by adding special loops for - //cases where alpha or beta equal 1.0 or 0.0, or where x==y? - - while(yi < ye) { - *yi = alpha_* *xi++ + beta_* *yi; - ++yi; - } - } - -private: - AxpbyAlg& operator=(const AxpbyAlg&); - AxpbyAlg(const AxpbyAlg&); - - double alpha_, beta_; - field_type& x_; - field_type& y_; -}; - -//---------------------------------------------------------------------- -/** FillAlg fills the specified field with the specified scalar... -*/ -template< class field_type > -class FillAlg { -public: - FillAlg(field_type& x, double scalar_value) - : x_(x), scalar_(scalar_value) {} - - ~FillAlg(){} - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator bucket_i , - stk_classic::mesh::Bucket::iterator bucket_j ) const - { - typedef typename stk_classic::mesh::FieldTraits::data_type scalar ; - - stk_classic::mesh::BucketArray xa( x_ , bucket_i , bucket_j ); - - scalar * xi = xa.contiguous_data(); - scalar * xe = xi + xa.size(); - - std::fill(xi, xe, scalar_); - } - -private: - FillAlg& operator=(const FillAlg&); - FillAlg(const FillAlg&); - - field_type& x_; - double scalar_; -}; - - -//---------------------------------------------------------------------- -//Below are some helper functions for running the above algorithms. -//Are these necessary? -//(they are currently called in UseCase_blas.cpp) - -template< class field_type > -inline -void axpby( const stk_classic::AlgorithmRunnerInterface& alg_runner, - stk_classic::mesh::BulkData& bulk, - stk_classic::mesh::EntityRank entitytype, - double alpha, - field_type& x, - double beta, - field_type& y) -{ - AxpbyAlg axpby_alg(alpha, x, beta, y); - - const std::vector - & all_entity_buckets = bulk.buckets( entitytype ); - - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Selector select_used = - meta.locally_owned_part() | - meta.globally_shared_part() ; - - stk_classic::mesh::PartVector empty_union_vector; - alg_runner.run( select_used , empty_union_vector, all_entity_buckets , axpby_alg ); -} - -template< class field_type > -inline -void fill( const stk_classic::AlgorithmRunnerInterface& alg_runner, - stk_classic::mesh::BulkData& bulk, - stk_classic::mesh::EntityRank entitytype, - field_type& x, - double value) -{ - FillAlg fillalg(x, value); - - const std::vector - & all_entity_buckets = bulk.buckets( entitytype ); - - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Selector select_used = - meta.locally_owned_part() | - meta.globally_shared_part() ; - - stk_classic::mesh::PartVector empty_union_vector; - alg_runner.run( select_used , empty_union_vector, all_entity_buckets , fillalg ); -} - -//---------------------------------------------------------------------- - -template< class field_type > -class DotAlg { -public: - const field_type & field_x ; - const field_type & field_y ; - - typedef typename stk_classic::mesh::FieldTraits::data_type scalar ; - - DotAlg( const field_type & x , const field_type & y ) - : field_x( x ), field_y( y ) {} - - /* Threaded-safe reduction */ - - typedef double reduce_type ; - enum { reduce_count = 1 }; - - void init( reduce_type * out ) const { *out = 0 ; } - void join( reduce_type * inout , const reduce_type * in ) const - { *inout += *in ; } - - /* Primary thread-safe operation */ - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator bucket_i , - stk_classic::mesh::Bucket::iterator bucket_j , - reduce_type * inout ) const - { - stk_classic::mesh::BucketArray xa( field_x , bucket_i , bucket_j ); - stk_classic::mesh::BucketArray ya( field_y , bucket_i , bucket_j ); - - scalar * xi = xa.contiguous_data(); - scalar * yi = ya.contiguous_data(); - scalar * ye = yi + ya.size(); - - scalar tmp = 0 ; - while ( yi != ye ) { tmp += *xi++ * *yi++ ; } - *inout += tmp ; - } - -private: - DotAlg& operator=(const DotAlg&); - DotAlg(const DotAlg&); -}; - - -template< class field_type > -typename stk_classic::mesh::FieldTraits::data_type -dot( const stk_classic::AlgorithmRunnerInterface & alg_runner , - const stk_classic::mesh::BulkData& bulk, - const stk_classic::mesh::EntityRank entitytype, - const field_type & x , - const field_type & y ) -{ - // Construct algorithm to hand to local parallel algorithm runner - - DotAlg alg_dot(x,y); - - const std::vector - & all_entity_buckets = bulk.buckets( entitytype ); - - stk_classic::mesh::Selector - select_owned( stk_classic::mesh::MetaData::get(bulk).locally_owned_part()); - - double local_dot = 0 ; - double global_dot = 0 ; - - // Local parallel execution of the algorithm - - stk_classic::mesh::PartVector empty_union_vector; - alg_runner.run( select_owned , empty_union_vector, all_entity_buckets , alg_dot , & local_dot ); - - // Global sum - -#if defined( STK_HAS_MPI ) - MPI_Comm comm = bulk.parallel(); - - MPI_Allreduce(& local_dot , & global_dot, 1, MPI_DOUBLE, MPI_SUM, comm); -#else - global_dot = local_dot; -#endif - - return global_dot ; -} - -//---------------------------------------------------------------------- - -template< class field_type > -class Norm2Alg { -public: - const field_type & field_x ; - - typedef typename stk_classic::mesh::FieldTraits::data_type scalar ; - - explicit Norm2Alg( const field_type & x ) : field_x( x ) {} - - /* Threaded-safe reduction */ - - typedef double reduce_type ; - enum { reduce_count = 1 }; - - void init( reduce_type * out ) const { *out = 0 ; } - void join( reduce_type * inout , const reduce_type * in ) const - { *inout += *in ; } - - /* Primary thread-safe operation */ - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator bucket_i , - stk_classic::mesh::Bucket::iterator bucket_j , - reduce_type * inout ) const - { - stk_classic::mesh::BucketArray xa( field_x , bucket_i , bucket_j ); - - scalar * xi = xa.contiguous_data(); - scalar * xe = xi + xa.size(); - - scalar tmp = 0 ; - while ( xi != xe ) { tmp += *xi * *xi ; ++xi; } - - *inout += tmp ; - } - -private: - Norm2Alg& operator=(const Norm2Alg&); - Norm2Alg(const Norm2Alg&); -}; - -template< class field_type > -typename stk_classic::mesh::FieldTraits::data_type -norm2( const stk_classic::AlgorithmRunnerInterface & alg_runner , - const stk_classic::mesh::BulkData & bulk , - const stk_classic::mesh::EntityRank entitytype , - const field_type & x ) -{ - // Construct algorithm to hand to local parallel algorithm runner - - Norm2Alg alg_norm2(x); - - const std::vector - & all_entity_buckets = bulk.buckets( entitytype ); - - stk_classic::mesh::Selector - select_owned(stk_classic::mesh::MetaData::get(bulk).locally_owned_part()); - - double local_dot = 0 ; - double global_dot = 0 ; - - // Local parallel execution of the algorithm - - stk_classic::mesh::PartVector empty_union_vector; - alg_runner.run( select_owned , empty_union_vector, all_entity_buckets , alg_norm2 , & local_dot ); - - // Global sum - -#if defined( STK_HAS_MPI ) - MPI_Comm comm = bulk.parallel(); - - MPI_Allreduce(& local_dot , & global_dot, 1, MPI_DOUBLE, MPI_SUM, comm); -#else - global_dot = local_dot; -#endif - - return std::sqrt( global_dot ) ; -} - -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/app/UseCase_driver.cpp b/packages/stk/stk_classic/stk_usecases/app/UseCase_driver.cpp deleted file mode 100644 index bfa5f9dcd38c..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/UseCase_driver.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace app { - -bool use_case_7_driver( MPI_Comm comm , - bool performance_test , - const std::string &mesh_filename , - int num_threads , - const std::string& thread_runner ); - -bool use_case_blas_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int chunk_size, - bool performance_test); - -bool use_case_14_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int chunk_size, - bool performance_test); - -bool use_case_14a_driver(MPI_Comm comm, - int num_threads, - int num_trials, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &mesh_type, - const std::string &thread_runner, - int chunk_size, - bool performance_test); - -bool use_case_24_driver( MPI_Comm comm, - const std::string &working_directory, - const std::string &mesh_filename, - const std::string &outputName ); - -} // namespace app -} // namespace stk_classic - - -namespace { - const char use_case_7[] = "use_case_7" ; - const char use_case_blas[] = "use_case_blas" ; - const char use_case_14[] = "use_case_14" ; - const char use_case_14a[] = "use_case_14a" ; - const char use_case_24[] = "use_case_24" ; -} - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - stk_classic::ParallelMachine comm = use_case_environment.m_comm; - - //---------------------------------- - // Broadcast argc and argv to all processors. - - stk_classic::BroadcastArg b_arg(comm, argc, argv); - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("options"); - - stk_classic::get_options_description().add(desc); - - int num_trials = 0; - int nthreads = 1; - int bucket_size = 1000; - - desc.add_options() - ("help,h", "produce help message") - ("performance", "run performance test [14/14a/blas only]") - ("mesh,m", bopt::value(), "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("directory,d", bopt::value(), "working directory with trailing '/'" ) - ("output-log,o", bopt::value(), "output log path" ) - ("runtest,r", bopt::value(), "runtest pid file" ) - ("threads", bopt::value(&nthreads)->default_value(1), "number of threads [14/14a/blas only]") - ("trials", bopt::value(&num_trials)->default_value(1), "number of trials (execute loops) [14/14a/blas only]") - ("bucket_size", bopt::value(&bucket_size)->default_value(1000), "size of buckets used internally in stk_classic::mesh [14/14a/blas only]") - ("tbb", "Use Threaded Building Blocks algorithm thread runner [14/14a/blas only]") - ("tpi", "Use Thread Pool Interface algorithm thread runner [14/14a/blas only]") - ("nonthreaded", "Run algorithms non-threaded [default] [14/14a/blas only]") - ( use_case_7 , "use case 7" ) - ( use_case_blas , "use case blas (fill, axpby, dot, norm)" ) - ( use_case_14 , "use case 14 (hex internal force algorithm)" ) - ( use_case_14a , "use case 14a (hex internal force algorithm)" ) - ( use_case_24 , "use case 24 " ); - - bopt::variables_map vm; - try { - bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm); - bopt::notify(vm); - } - catch (std::exception &x) { - std::cout << x.what() << std::endl; - std::exit(1); - } - - - //---------------------------------- - - if (vm.count("help")) { - std::cout << desc << "\n"; - std::exit(EXIT_SUCCESS); - } - - bool run_performance_test = vm.count( "performance" ) > 0; - - std::string thread_runner = "NonThreaded"; - if (vm.count("tbb")) - thread_runner = "TBB"; - if (vm.count("tpi")) - thread_runner = "TPI"; -// if (vm.count("dgb")) -// thread_runner = "DGB"; - if (vm.count("nonthreaded")) - thread_runner = "NonThreaded"; - - std::string working_directory = ""; - std::string in_filename = ""; - std::string in_filetype = "exodusii"; - if (vm.count("mesh")) { - in_filename = boost::any_cast(vm["mesh"].value()); - - if (strncasecmp("gen:", in_filename.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - in_filename = in_filename.substr(4, in_filename.size()); - in_filetype = "generated"; - } - - if (strncasecmp("gears:", in_filename.c_str(), 6) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - in_filename = in_filename.substr(6, in_filename.size()); - in_filetype = "gears"; - } - - if (vm.count("directory")) { - working_directory = boost::any_cast(vm["directory"].value()); - } - } else { - std::cout << "OPTION ERROR: The '--mesh ' option is required for all use cases!\n"; - std::exit(EXIT_FAILURE); - } - - bool success = false; - - if ( vm.count( use_case_7 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 7, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_classic::app::use_case_7_driver( comm , run_performance_test , in_filename , nthreads, thread_runner ); - } - - else if ( vm.count( use_case_blas ) ) { - success = stk_classic::app::use_case_blas_driver(comm, nthreads, num_trials, working_directory, - in_filename, in_filetype, thread_runner, bucket_size, - run_performance_test); - } - - else if ( vm.count( use_case_14 ) ) { - success = stk_classic::app::use_case_14_driver(comm, nthreads, num_trials, working_directory, - in_filename, in_filetype, thread_runner, bucket_size, - run_performance_test); - } - - else if ( vm.count( use_case_14a ) ) { - success = stk_classic::app::use_case_14a_driver(comm, nthreads, num_trials, working_directory, - in_filename, in_filetype, thread_runner, bucket_size, - run_performance_test); - } - - else if ( vm.count( use_case_24 ) ) { - if (in_filetype == "generated") { - std::cout << "OPTION ERROR: The 'generated mesh option' option is not supported for use case 24!\n"; - std::exit(EXIT_FAILURE); - } - - if (in_filetype == "gears") { - std::cout << "OPTION ERROR: The 'gears mesh option' option is not supported for use case 24!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_classic::app::use_case_24_driver( comm, working_directory, in_filename, "1mCube.e" ); - } - else { - std::cout << "OPTION ERROR: Missing a use case selection option. Use --help option to see valid options.\n"; - std::exit(EXIT_FAILURE); - } - - use_case::print_status(comm, success); - - return 0; -} - diff --git a/packages/stk/stk_classic/stk_usecases/app/examples/example_driver.cpp b/packages/stk/stk_classic/stk_usecases/app/examples/example_driver.cpp deleted file mode 100644 index 978c7586192c..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/examples/example_driver.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include -#include -#include -#include -#include - -namespace stk_examples { - - void example_io_1( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string & out_filename ); - - void example_io_2( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string & out_filename ); - - void use_case_5_write_mesh( stk_classic::ParallelMachine , - const std::string & out_filename ); -} // namespace stk_examples - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - //---------------------------------- - // Broadcast argc and argv to all processors. - - stk_classic::ParallelMachine comm = stk_classic::parallel_machine_init(&argc, &argv); - - stk_classic::BroadcastArg b_arg(comm, argc, argv); - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("options"); - - desc.add_options() - ("help,h", "produce help message") - ("usecase", bopt::value(), "use case, valid = all, 1, 2, requires -mesh option" ) - ("mesh", bopt::value(), "mesh file" ) - ("directory,d", bopt::value(), "working directory" ) - ("output-log,o", bopt::value(), "output log path" ) - ("runtest,r", bopt::value(), "runtest pid file" ); - - stk_classic::get_options_description().add(desc); - - bopt::variables_map &vm = stk_classic::get_variables_map(); - try { - bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm); - bopt::notify(vm); - } - catch (std::exception &x) { - stk_classic::RuntimeDoomedSymmetric() << x.what(); - std::exit(1); - } - - if (vm.count("help")) { - std::cout << desc << "\n"; - std::exit(EXIT_SUCCESS); - } - - //---------------------------------- - - std::string usecase = "all"; - if (vm.count("usecase")) { - usecase = boost::any_cast(vm["usecase"].value()); - } - - if ( vm.count("mesh") ) { - std::string in_filename = boost::any_cast(vm["mesh"].value()); - - if (usecase == "all" || usecase == "1") { - std::string out_filename = in_filename + ".out-1"; - stk_examples::example_io_1(comm, in_filename, out_filename ); - } - - if (usecase == "all" || usecase == "2") { - std::string out_filename = in_filename + ".out-2"; - stk_examples::example_io_2(comm, in_filename, out_filename ); - } - } - else { - std::string in_filename( "example_use_case_5.g" ); - - stk_examples::use_case_5_write_mesh( comm , in_filename ); - - std::string out_filename ; - out_filename.append( "out_" ); - out_filename.append( in_filename ); - - stk_examples::example_io_1(comm, in_filename, out_filename ); - } - - stk_classic::parallel_machine_finalize(); - - return 0; -} - diff --git a/packages/stk/stk_classic/stk_usecases/app/examples/example_io_1.cpp b/packages/stk/stk_classic/stk_usecases/app/examples/example_io_1.cpp deleted file mode 100644 index 6d6da20e2c10..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/examples/example_io_1.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -namespace stk_examples { - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field ScalarIntField ; -typedef stk_classic::mesh::Field CartesianField ; -typedef stk_classic::mesh::Field FullTensorField ; -typedef stk_classic::mesh::Field SymmetricTensorField ; - - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(meta_data); - return stk_classic::mesh::put_field( meta_data.declare_field(s), fem.node_rank() , meta_data.universal_part() , n1 ); -} - - -CartesianField & -declare_vector_field_on_all_elements( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(meta_data); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - - return stk_classic::mesh::put_field( meta_data.declare_field(s), element_rank , meta_data.universal_part() , n1 ); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Example reader / writer - -void example_io_1( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string& out_filename) -{ - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - static const size_t spatial_dimension = 3; - - std::cout - << "========================================================================\n" - << " Use Case 1: Simple mesh I/O \n" - << "========================================================================\n"; - - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - stk_classic::mesh::Part & universal = meta_data.universal_part(); - stk_classic::mesh::put_field(meta_data.declare_field< CartesianField >( "coordinates" ) , meta_data.node_rank() , universal , spatial_dimension ); - - //---------------------------------- - const std::string dbtype("exodusii"); - - // Open, read, filter meta data from the input mesh file: - // The coordinates field will be set to the correct dimension. - - stk_classic::io::MeshData mesh_data; - stk_classic::io::create_input_mesh(dbtype, in_filename, comm, meta_data, mesh_data); - - //---------------------------------- - // Print the parts that were read from the file: - - const stk_classic::mesh::PartVector & io_parts = meta_data.get_parts(); - for (stk_classic::mesh::PartVector::const_iterator i = io_parts.begin(); - i != io_parts.end(); ++i) { - stk_classic::mesh::Part & part = **i ; - - const CellTopologyData * const top = meta_data.get_cell_topology( part ).getCellTopologyData(); - - const unsigned num_subsets = part.subsets().size(); - - std::cout << " Part: " << part.name(); - if ( part.primary_entity_rank() < meta_data.entity_rank_count() ) { - std::cout << " " - << meta_data.entity_rank_name( part.primary_entity_rank() ); - } - if ( top ) { std::cout << " " << top->name ; } - if ( num_subsets ) { std::cout << " with " << num_subsets << " subsets" ; } - std::cout << std::endl ; - } - - //---------------------------------- - // Now I can process what was read from the mesh file to - // declare more parts and fields. - - meta_data.commit(); - - //---------------------------------- - // Create mesh bulk data conforming to the mesh meta data - // and distributed among the given parallel machine. - - stk_classic::mesh::BulkData bulk_data(meta_data.get_meta_data(meta_data), comm); - - // Read the model (topology, coordinates, attributes, etc) - // from the mesh-file into the mesh bulk data. - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - //---------------------------------- - // Create a mesh writer that will simply write out what was read. - // the parts, attributes, and transient arguments can be different - // that what was read. - - stk_classic::io::create_output_mesh(out_filename, comm, bulk_data, mesh_data); - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace stk_examples - - diff --git a/packages/stk/stk_classic/stk_usecases/app/examples/example_io_2.cpp b/packages/stk/stk_classic/stk_usecases/app/examples/example_io_2.cpp deleted file mode 100644 index 2cec96f3dc76..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/examples/example_io_2.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -static const size_t spatial_dimension = 3; - -namespace stk_examples { -namespace app { - - // ======================================================================== - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) - { - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - assert(nb->field_exists("mesh_model_coordinates")); - Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); - int spatial_dim = coordinates.transformed_storage()->component_count(); - - stk_classic::mesh::Field & coord_field = - meta.declare_field >("coordinates"); - - stk_classic::mesh::put_field( coord_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta.universal_part(), - spatial_dim); - - /// \todo IMPLEMENT truly handle fields... For this case we - /// are just defining a field for each transient field that is - /// present in the mesh... - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - } - - // ======================================================================== - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) - { - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - stk_classic::io::default_part_processing(elem_blocks, meta); - - // Parts were created above, now handle element block specific - // information (topology, attributes, ...); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Element Block attributes (if any)... - /// \todo IMPLEMENT truly handle attribute fields... For this case we - /// are just defining a field for each attribute field that - /// is present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::ATTRIBUTE, - *part, part_rank ); - - /// \todo IMPLEMENT truly handle fields... For this case we - /// are just defining a field for each transient field that is - /// present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, part_rank); - - std::cout << entity->type_string() << ": " << entity->name() - << " , celltop = " << meta.get_cell_topology(*part).getCellTopologyData()->name - << std::endl ; - } - } - } - - // ======================================================================== - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) - { - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - stk_classic::io::default_part_processing(node_sets, meta); - - /// \todo REFACTOR should "distribution_factor" be a default field - /// that is automatically declared on all objects that it exists - /// on as is done in current framework? - stk_classic::mesh::Field & distribution_factors_field = - meta.declare_field >("distribution_factors"); - - /// \todo REFACTOR How to associate distribution_factors field - /// with the nodeset part if a node is a member of multiple - /// nodesets - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - assert(entity->field_exists("distribution_factors")); - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - stk_classic::mesh::put_field(distribution_factors_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, *part); - - /// \todo IMPLEMENT truly handle fields... For this case we - /// are just defining a field for each transient field that is - /// present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, part_rank); - } - } - } - - // ======================================================================== - void process_surface_entity(Ioss::SideSet *sset, stk_classic::mesh::fem::FEMMetaData &meta) - { - assert(sset->type() == Ioss::SIDESET); - const Ioss::SideBlockContainer& blocks = sset->get_side_blocks(); - stk_classic::io::default_part_processing(blocks, meta); - - stk_classic::mesh::Part* const sideset_part = meta.get_part(sset->name()); - assert(sideset_part != NULL); - - stk_classic::mesh::Field *distribution_factors_field = NULL; - bool surface_df_defined = false; // Has the surface df field been defined yet? - - - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *sideblock = sset->get_block(i); - if (stk_classic::io::include_entity(sideblock)) { - std::cout << sideblock->type_string() << " " << sideblock->name() << "\n"; - stk_classic::mesh::Part * const sideblock_part = meta.get_part(sideblock->name()); - assert(sideblock_part != NULL); - meta.declare_part_subset(*sideset_part, *sideblock_part); - - const stk_classic::mesh::EntityRank part_rank = sideblock_part->primary_entity_rank(); - - /// \todo REFACTOR How to associate distribution_factors field - /// with the sideset part if a face is a member of multiple - /// sidesets - - if (sideblock->field_exists("distribution_factors")) { - if (!surface_df_defined) { - std::string field_name = sset->name() + "_distribution_factors"; - distribution_factors_field = - &meta.declare_field >(field_name); - stk_classic::io::set_distribution_factor_field(*sideset_part, *distribution_factors_field); - surface_df_defined = true; - } - stk_classic::io::set_distribution_factor_field(*sideblock_part, *distribution_factors_field); - int side_node_count = sideblock->topology()->number_nodes(); - stk_classic::mesh::put_field(*distribution_factors_field, - part_rank , - *sideblock_part, side_node_count); - } - - /// \todo IMPLEMENT truly handle fields... For this case we - /// are just defining a field for each transient field that is - /// present in the mesh... - stk_classic::io::define_io_fields(sideblock, Ioss::Field::TRANSIENT, - *sideblock_part, part_rank ); - } - } - } - - // ======================================================================== - void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::fem::FEMMetaData &meta) - { - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - stk_classic::io::default_part_processing(side_sets, meta); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, meta); - } - } - } - - // ======================================================================== - // Bulk Data - // ======================================================================== - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // This must be called after the "process_element_blocks" call - // since there may be nodes that exist in the database that are - // not part of the analysis mesh due to subsetting of the element - // blocks. - - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - std::vector nodes; - stk_classic::io::get_entity_list(nb, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, bulk, nodes); - - /// \todo REFACTOR Application would probably store this field - /// (and others) somewhere after the declaration instead of - /// looking it up each time it is needed. - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates"); - } - - // ======================================================================== - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string &name = entity->name(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - - const CellTopologyData* cell_topo = stk_classic::mesh::fem::FEMMetaData::get(bulk).get_cell_topology(*part).getCellTopologyData(); - assert(cell_topo != NULL); - - std::vector elem_ids ; - std::vector connectivity ; - std::vector connectivity2 ; - - entity->get_field_data("ids", elem_ids); - entity->get_field_data("connectivity", connectivity); - connectivity2.reserve(connectivity.size()); - std::copy(connectivity.begin(), connectivity.end(), std::back_inserter(connectivity2)); - - int element_count = elem_ids.size(); - int nodes_per_elem = cell_topo->node_count ; - - std::vector elements(element_count); - for(int i=0; ifield_describe(Ioss::Field::ATTRIBUTE, &names); - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if (*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = meta.get_field(*I); - stk_classic::io::field_data_from_ioss(field, elements, entity, *I); - - } - } - } - } - - // ======================================================================== - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // Should only process nodes that have already been defined via the element - // blocks connectivity lists. - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string & name = entity->name(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - stk_classic::mesh::PartVector add_parts( 1 , part ); - - std::vector node_ids ; - int node_count = entity->get_field_data("ids", node_ids); - - std::vector nodes(node_count); - for(int i=0; i *df_field = - meta.get_field >("distribution_factors"); - - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors"); - } - } - } - } - - // ======================================================================== - void process_surface_entity(const Ioss::SideSet* io, stk_classic::mesh::BulkData & bulk) - { - assert(io->type() == Ioss::SIDESET); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(meta); - - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - - int block_count = io->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *block = io->get_block(i); - if (stk_classic::io::include_entity(block)) { - std::vector side_ids ; - std::vector elem_side ; - - stk_classic::mesh::Part * const fb_part = meta.get_part(block->name()); - - block->get_field_data("ids", side_ids); - block->get_field_data("element_side", elem_side); - - assert(side_ids.size() * 2 == elem_side.size()); - stk_classic::mesh::PartVector add_parts( 1 , fb_part ); - - int side_count = side_ids.size(); - std::vector sides(side_count); - for(int is=0; is *df_field = - stk_classic::io::get_distribution_factor_field(*fb_part); - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors"); - } - } - } - } - - // ======================================================================== - void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } - } - - // ======================================================================== - // ======================================================================== - void get_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_from_ioss(f, entities, io_entity, f->name()); - } - } - } - - void process_input_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(bulk); - - // ??? Get field data from nodeblock... - app::get_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - assert(sset != NULL); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = sset->get_block(i); - /// \todo REFACTOR Need filtering mechanism. - app::get_field_data(bulk, *part, part_rank, - fb, Ioss::Field::TRANSIENT); - } - } else { - app::get_field_data(bulk, *part, part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - - region.end_state(step); - } - - void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role); - } - } - } - - void process_output_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(bulk); - - app::put_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - int block_count = sset->block_count(); - - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = sset->get_block(i); - /// \todo REFACTOR Need filtering mechanism. - app::put_field_data(bulk, *part, part_rank, - fb, Ioss::Field::TRANSIENT); - } - } else { - app::put_field_data(bulk, *part, part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - region.end_state(step); - } - -} // namespace application - - // ======================================================================== - //------------------------------------------------------------------------ - void example_io_2( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string& out_filename) - { - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - std::cout << "========================================================================\n" - << " Use Case 2: Subsetting with df and attribute field input/output \n" - << " (Also contains functionality of use case 1.5) \n" - << "========================================================================\n"; - - std::string dbtype("exodusII"); - MPI_Comm mpicomm = comm; - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(dbtype, in_filename, Ioss::READ_MODEL, - mpicomm); - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << in_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - Ioss::Region in_region(dbi, "input_model"); - - // SUBSETTING PARSING/PREPROCESSING... - // Just an example of how application could control whether an - // entity is subsetted or not... - - - // Example command line in current code corresponding to behavior below: - std::cout << "\nWhen processing file multi-block.g for use case 2, the blocks below will be omitted:\n"; - std::cout << "\tOMIT BLOCK Cblock Eblock I1 I2\n\n"; - Ioss::ElementBlock *eb = in_region.get_element_block("cblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("eblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i1"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i2"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - -#if 0 - // Example for subsetting -- omit "odd" blocks - if (entity->type() == Ioss::ELEMENTBLOCK) { - int id = entity->get_property("id").get_int(); - if (id % 2) { - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - std::cout << "Skipping " << entity->type_string() << ": " << entity->name() << "\n"; - } - } -#endif - - //---------------------------------- - // Process Entity Types. Subsetting is possible. - stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension ); - app::process_elementblocks(in_region, meta_data); - app::process_nodeblocks(in_region, meta_data); - app::process_sidesets(in_region, meta_data); - app::process_nodesets(in_region, meta_data); - - //---------------------------------- - // Done populating meta data, commit and create bulk data - meta_data.commit(); - - //---------------------------------- - // Process Bulkdata for all Entity Types. Subsetting is possible. - stk_classic::mesh::BulkData bulk_data(meta_data.get_meta_data(meta_data), comm); - bulk_data.modification_begin(); - app::process_elementblocks(in_region, bulk_data); - app::process_nodeblocks(in_region, bulk_data); - app::process_sidesets(in_region, bulk_data); - app::process_nodesets(in_region, bulk_data); - bulk_data.modification_end(); - - //---------------------------------- - // OUTPUT...Create the output "mesh" portion - - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create(dbtype, out_filename, - Ioss::WRITE_RESULTS, - mpicomm); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - Ioss::Region out_region(dbo, "results_output"); - - /// \todo REFACTOR Need better interface for passing application - /// fields to stk_classic::io. This maybe works with only a single field, - /// but adding attributes, distribution factors and perhaps other - /// fields will make this unwieldy. - stk_classic::io::define_output_db(out_region, bulk_data, &in_region); - stk_classic::io::write_output_db(out_region, bulk_data); - - // ------------------------------------------------------------------------ - /// \todo REFACTOR A real app would register a subset of the - /// fields on the mesh database as fields that the app would want - // read at one or all or specified steps. In this example, all - // fields existing on the input mesh database are defined on the - // parts in the stk_classic::mesh. - // - // The real app would also only register a subset of the stk_classic::mesh - // fields as output fields and would probably have a mapping from - // the internally used name to some name picked by the user. In - // this example, all TRANSIENT fields defined on the stk_classic::mesh are - // output to the results database and the internal stk_classic::mesh field - // name is used as the name on the database.... - - out_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields(meta_data.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - out_region.get_node_blocks()[0], - Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = out_region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = sset->get_block(i); - /// \todo REFACTOR Need filtering mechanism. - stk_classic::io::ioss_add_fields(*part, part_rank, - fb, Ioss::Field::TRANSIENT); - } - } else { - stk_classic::io::ioss_add_fields(*part, part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - out_region.end_mode(Ioss::STATE_DEFINE_TRANSIENT); - // ------------------------------------------------------------------------ - - // Read and Write transient fields... - out_region.begin_mode(Ioss::STATE_TRANSIENT); - int timestep_count = in_region.get_property("state_count").get_int(); - for (int step = 1; step <= timestep_count; step++) { - double time = in_region.get_state_time(step); - - // Read data from the io input mesh database into stk_classic::mesh fields... - app::process_input_request(in_region, bulk_data, step); - - // app::execute() - - // Write data from the stk_classic::mesh fields out to the output database.a - int out_step = out_region.add_state(time); - app::process_output_request(out_region, bulk_data, out_step); - } - out_region.end_mode(Ioss::STATE_TRANSIENT); - - } -} // namespace stk_examples - diff --git a/packages/stk/stk_classic/stk_usecases/app/examples/example_meshes.cpp b/packages/stk/stk_classic/stk_usecases/app/examples/example_meshes.cpp deleted file mode 100644 index 0bd5a5a454ec..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/examples/example_meshes.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -using namespace stk_classic ; - -namespace stk_examples { - -enum { SpatialDim = 3 }; - -//---------------------------------------------------------------------- - -typedef mesh::Field VectorFieldType ; - -//-------------------------------------------------------------------- -// -// main driver for use-case 5: heterogeneous element mesh. -// - -void use_case_5_generate_mesh_meta_data( - stk_classic::mesh::fem::FEMMetaData & meta_data , - VectorFieldType & node_coord ) -{ - const stk_classic::mesh::EntityRank element_rank = meta_data.element_rank(); - - mesh::Part & universal = meta_data.universal_part(); - mesh::Part & block_hex = meta_data.declare_part("hexes",element_rank); - mesh::Part & block_wedge = meta_data.declare_part("wedges",element_rank); - mesh::Part & block_tet = meta_data.declare_part("tets",element_rank); - mesh::Part & block_pyramid = meta_data.declare_part("pyramids",element_rank); - mesh::Part & block_quad_shell = meta_data.declare_part("quad_shells",element_rank); - mesh::Part & block_tri_shell = meta_data.declare_part("tri_shells",element_rank); - - stk_classic::io::put_io_part_attribute(block_hex); - stk_classic::io::put_io_part_attribute(block_wedge); - stk_classic::io::put_io_part_attribute(block_tet); - stk_classic::io::put_io_part_attribute(block_pyramid); - stk_classic::io::put_io_part_attribute(block_quad_shell); - stk_classic::io::put_io_part_attribute(block_tri_shell); - - stk_classic::mesh::fem::set_cell_topology(block_hex , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - stk_classic::mesh::fem::set_cell_topology(block_wedge , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - stk_classic::mesh::fem::set_cell_topology(block_tet , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - stk_classic::mesh::fem::set_cell_topology(block_pyramid , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - stk_classic::mesh::fem::set_cell_topology(block_quad_shell , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - stk_classic::mesh::fem::set_cell_topology(block_tri_shell , stk_classic::mesh::fem::CellTopology(shards::getCellTopologyData >())); - - const mesh::FieldBase::Restriction & res = - node_coord.restriction( mesh::fem::FEMMetaData::NODE_RANK , universal ); - - if ( res.stride(0) != 3 ) { - std::ostringstream msg ; - msg << "stk_examples::use_case_5_generate_mesh_meta_data FAILED, coordinate dimension must be 3 != " << res.stride(0) ; - throw std::runtime_error( msg.str() ); - } -} - -//-------------------------------------------------------------------- -/*---------------------------------------------------------------------- - * Internal use-case #5 mesh generation. - * - * Three hexes, three wedges, three tets, two pyramids, - * three quad shells, and three triangle shells. - * - * Z = 0 plane: - * - * Y - * ^ 9 10 - * ! *-------* - * ! / \ / \ - * ! / \ / \ - * / \ / \ - * *-------*-------*-------* - * 5| 6| 7| 8| - * | | | | - * | | | | - * *-------*-------*-------* ----> X - * 1 2 3 4 - * - * Z = -1 plane: - * - * Y - * ^ 19 20 - * ! *-------* - * ! / \ / \ - * ! / \ / \ - * / \ / \ - * *-------*-------*-------* - * 15| 16| 17| 18| - * | | | | - * | | | | - * *-------*-------*-------* ----> X - * 11 12 13 14 - * - * - * Last node (#21) at Z = -2, translated from node #16 - *----------------------------------------------------------------------*/ - -enum { node_count = 21 }; - -enum { number_hex = 3 }; -enum { number_wedge = 3 }; -enum { number_tetra = 3 }; -enum { number_pyramid = 2 }; -enum { number_shell_quad = 3 }; -enum { number_shell_tri = 3 }; - -namespace { - -static const double node_coord_data[ node_count ][ SpatialDim ] = { - { 0 , 0 , 0 } , { 1 , 0 , 0 } , { 2 , 0 , 0 } , { 3 , 0 , 0 } , - { 0 , 1 , 0 } , { 1 , 1 , 0 } , { 2 , 1 , 0 } , { 3 , 1 , 0 } , - { 0 , 2 , 0 } , { 1 , 2 , 0 } , - { 0 , 0 , -1 } , { 1 , 0 , -1 } , { 2 , 0 , -1 } , { 3 , 0 , -1 } , - { 0 , 1 , -1 } , { 1 , 1 , -1 } , { 2 , 1 , -1 } , { 3 , 1 , -1 } , - { 0 , 2 , -1 } , { 1 , 2 , -1 } , - { 1 , 1 , -2 } }; - -static const stk_classic::mesh::EntityId hex_node_ids[3][ shards::Hexahedron<8> ::node_count ] = { - { 1 , 2 , 12 , 11 , 5 , 6 , 16 , 15 } , - { 2 , 3 , 13 , 12 , 6 , 7 , 17 , 16 } , - { 3 , 4 , 14 , 13 , 7 , 8 , 18 , 17 } }; - -static const stk_classic::mesh::EntityId wedge_node_ids[3][ shards::Wedge<6> ::node_count ] = { - { 15 , 16 , 19 , 5 , 6 , 9 } , - { 10 , 9 , 6 , 20 , 19 , 16 } , - { 16 , 17 , 20 , 6 , 7 , 10 } }; - -static const stk_classic::mesh::EntityId tetra_node_ids[3][ shards::Tetrahedron<4> ::node_count ] = { - { 15 , 19 , 16 , 21 } , - { 19 , 20 , 16 , 21 } , - { 16 , 20 , 17 , 21 } }; - -static const stk_classic::mesh::EntityId pyramid_node_ids[2][ shards::Pyramid<5> ::node_count ] = { - { 11 , 15 , 16 , 12 , 21 } , - { 12 , 16 , 17 , 13 , 21 } }; - -static const stk_classic::mesh::EntityId shell_quad_node_ids[3][ shards::ShellQuadrilateral<4> ::node_count ]={ - { 9 , 6 , 16 , 19 } , - { 6 , 7 , 17 , 16 } , - { 7 , 8 , 18 , 17 } }; - -static const stk_classic::mesh::EntityId shell_tri_node_ids[3][ shards::ShellTriangle<3> ::node_count ] ={ - { 19 , 16 , 21 } , - { 16 , 17 , 21 } , - { 17 , 13 , 21 } }; - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_5_generate_mesh_bulk_data( - mesh::BulkData & bulk_data , - const VectorFieldType & node_coord ) -{ - static const char method[] = - "stk_examples::use_case_5_generate_mesh_bulk_data" ; - - bulk_data.modification_begin(); - - const mesh::fem::FEMMetaData & meta_data = stk_classic::mesh::fem::FEMMetaData::get(bulk_data); - - mesh::Part & hex_block = * meta_data.get_part("hexes",method); - mesh::Part & wedge_block = * meta_data.get_part("wedges",method); - mesh::Part & tetra_block = * meta_data.get_part("tets",method); - mesh::Part & pyramid_block = * meta_data.get_part("pyramids",method); - mesh::Part & quad_shell_block = * meta_data.get_part("quad_shells",method); - mesh::Part & tri_shell_block = * meta_data.get_part("tri_shells",method); - - unsigned elem_id = 1 ; - - for ( unsigned i = 0 ; i < number_hex ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, hex_block, elem_id, hex_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_wedge ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, wedge_block, elem_id, wedge_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_tetra ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, tetra_block, elem_id, tetra_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_pyramid ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, pyramid_block, elem_id, pyramid_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < number_shell_quad ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, quad_shell_block, elem_id, shell_quad_node_ids[i]); - } - - for ( unsigned i = 0 ; i < number_shell_tri ; ++i , ++elem_id ) { - mesh::fem::declare_element( bulk_data, tri_shell_block, elem_id, shell_tri_node_ids[i] ); - } - - for ( unsigned i = 0 ; i < node_count ; ++i ) { - - mesh::Entity * const node = bulk_data.get_entity( mesh::fem::FEMMetaData::NODE_RANK , i + 1 ); - - double * const coord = field_data( node_coord , *node ); - - coord[0] = node_coord_data[i][0] ; - coord[1] = node_coord_data[i][1] ; - coord[2] = node_coord_data[i][2] ; - } - - bulk_data.modification_end(); -} - - -void use_case_5_write_mesh( stk_classic::ParallelMachine comm , - const std::string & filename ) -{ - Ioss::Init::Initializer init_db; - stk_classic::mesh::fem::FEMMetaData meta_data(SpatialDim); - - VectorFieldType & node_coord = - meta_data.declare_field("coordinates"); - - mesh::put_field( node_coord , mesh::fem::FEMMetaData::NODE_RANK , - meta_data.universal_part() , SpatialDim ); - - use_case_5_generate_mesh_meta_data( meta_data , node_coord ); - - meta_data.commit(); - - mesh::BulkData bulk_data( meta_data.get_meta_data(meta_data) , comm ); - - use_case_5_generate_mesh_bulk_data( bulk_data , node_coord ); - - stk_classic::io::MeshData mesh; - stk_classic::io::create_output_mesh(filename, comm, bulk_data, mesh); -} - -} // namespace stk_examples - -//---------------------------------------------------------------------- - diff --git a/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.cpp b/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.cpp deleted file mode 100644 index 669509370cd5..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#define USE_HARDWIRED_NUMBER_NODES 1 - -namespace stk_classic { -namespace app { - -//---------------------------------------------------------------------- - -#if USE_HARDWIRED_NUMBER_NODES - -void element_mean_value_8x3( const unsigned num_elems , - const double * const * node_values , - double * elem_value ) -{ - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - elem_value[0] = ( node_values[0][0] + - node_values[1][0] + - node_values[2][0] + - node_values[3][0] + - node_values[4][0] + - node_values[5][0] + - node_values[6][0] + - node_values[7][0] ) / 8 ; - - elem_value[1] = ( node_values[0][1] + - node_values[1][1] + - node_values[2][1] + - node_values[3][1] + - node_values[4][1] + - node_values[5][1] + - node_values[6][1] + - node_values[7][1] ) / 8 ; - - elem_value[2] = ( node_values[0][2] + - node_values[1][2] + - node_values[2][2] + - node_values[3][2] + - node_values[4][2] + - node_values[5][2] + - node_values[6][2] + - node_values[7][2] ) / 8 ; - - node_values += 8 ; - elem_value += 3 ; - } -} - -void element_mean_value_4x3( const unsigned num_elems , - const double * const * node_values , - double * elem_value ) -{ - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - elem_value[0] = ( node_values[0][0] + - node_values[1][0] + - node_values[2][0] + - node_values[3][0] ) / 4 ; - - elem_value[1] = ( node_values[0][1] + - node_values[1][1] + - node_values[2][1] + - node_values[3][1] ) / 4 ; - - elem_value[2] = ( node_values[0][2] + - node_values[1][2] + - node_values[2][2] + - node_values[3][2] ) / 4 ; - - node_values += 4 ; - elem_value += 3 ; - } -} - -enum { GATHER_COUNT_SIZE = 1000 }; - -void element_gather_mean_value_8x3( const unsigned num_elems , - const double * const * node_values , - double * elem_value ) -{ - typedef double value_type[3] ; - value_type gathered_value[ GATHER_COUNT_SIZE * 8 ]; - - // Gather: - - { - value_type * gv = gathered_value ; - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - gv[0][0] = node_values[0][0]; - gv[0][1] = node_values[0][1]; - gv[0][2] = node_values[0][2]; - - gv[1][0] = node_values[1][0]; - gv[1][1] = node_values[1][1]; - gv[1][2] = node_values[1][2]; - - gv[2][0] = node_values[2][0]; - gv[2][1] = node_values[2][1]; - gv[2][2] = node_values[2][2]; - - gv[3][0] = node_values[3][0]; - gv[3][1] = node_values[3][1]; - gv[3][2] = node_values[3][2]; - - gv[4][0] = node_values[4][0]; - gv[4][1] = node_values[4][1]; - gv[4][2] = node_values[4][2]; - - gv[5][0] = node_values[5][0]; - gv[5][1] = node_values[5][1]; - gv[5][2] = node_values[5][2]; - - gv[6][0] = node_values[6][0]; - gv[6][1] = node_values[6][1]; - gv[6][2] = node_values[6][2]; - - gv[7][0] = node_values[7][0]; - gv[7][1] = node_values[7][1]; - gv[7][2] = node_values[7][2]; - - gv += 8 ; - node_values += 8 ; - } - } - - // Compute: - - { - value_type * gv = gathered_value ; - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - elem_value[0] = ( gv[0][0] + gv[1][0] + gv[2][0] + gv[3][0] + - gv[4][0] + gv[5][0] + gv[6][0] + gv[7][0] ) / 8 ; - - elem_value[1] = ( gv[0][1] + gv[1][1] + gv[2][1] + gv[3][1] + - gv[4][1] + gv[5][1] + gv[6][1] + gv[7][1] ) / 8 ; - - elem_value[2] = ( gv[0][2] + gv[1][2] + gv[2][2] + gv[3][2] + - gv[4][2] + gv[5][2] + gv[6][2] + gv[7][2] ) / 8 ; - - gv += 8 ; - elem_value += 3 ; - } - } -} - -void element_gather_mean_value_4x3( const unsigned num_elems , - const double * const * node_values , - double * elem_value ) -{ - typedef double value_type[3] ; - value_type gathered_value[ GATHER_COUNT_SIZE * 4 ]; - - // Gather: - - { - value_type * gv = gathered_value ; - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - gv[0][0] = node_values[0][0]; - gv[0][1] = node_values[0][1]; - gv[0][2] = node_values[0][2]; - - gv[1][0] = node_values[1][0]; - gv[1][1] = node_values[1][1]; - gv[1][2] = node_values[1][2]; - - gv[2][0] = node_values[2][0]; - gv[2][1] = node_values[2][1]; - gv[2][2] = node_values[2][2]; - - gv[3][0] = node_values[3][0]; - gv[3][1] = node_values[3][1]; - gv[3][2] = node_values[3][2]; - - gv += 4 ; - node_values += 4 ; - } - } - - // Compute: - - { - value_type * gv = gathered_value ; - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - elem_value[0] = ( gv[0][0] + gv[1][0] + gv[2][0] + gv[3][0] ) / 4 ; - elem_value[1] = ( gv[0][1] + gv[1][1] + gv[2][1] + gv[3][1] ) / 4 ; - elem_value[2] = ( gv[0][2] + gv[1][2] + gv[2][2] + gv[3][2] ) / 4 ; - - gv += 4 ; - elem_value += 3 ; - } - } -} - -//---------------------------------------------------------------------- -#else -//---------------------------------------------------------------------- - -void element_mean_value_3( const unsigned num_elems , - const unsigned nodes_per_elem , - const double * const * node_values , - double * elem_value ) -{ - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - - double tmp[3] = { 0 , 0 , 0 }; - - for ( unsigned j = 0 ; j < nodes_per_elem ; ++j ) { - const double * const value = * node_values ; ++node_values ; - tmp[0] += value[0] ; - tmp[1] += value[1] ; - tmp[2] += value[2] ; - } - - elem_value[0] = tmp[0] / nodes_per_elem ; - elem_value[1] = tmp[1] / nodes_per_elem ; - elem_value[2] = tmp[2] / nodes_per_elem ; - - elem_value += 3 ; - } -} - -//---------------------------------------------------------------------- - -enum { GATHER_BUFFER_SIZE = 1000 * 8 * 3 }; - -void element_gather_mean_value_3( const unsigned num_elems , - const unsigned nodes_per_elem , - const double * const * node_values , - double * elem_value ) -{ - double gathered_value[ GATHER_BUFFER_SIZE ]; - - // Gather: - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - const unsigned elem_offset = i * nodes_per_elem ; - - for ( unsigned j = 0 ; j < nodes_per_elem ; ++j ) { - - const unsigned node_offset = elem_offset + j ; - const unsigned node_value_offset = node_offset * 3 ; - - gathered_value[node_value_offset+0] = node_values[node_offset][0]; - gathered_value[node_value_offset+1] = node_values[node_offset][1]; - gathered_value[node_value_offset+2] = node_values[node_offset][2]; - } - } - - // Compute: - - for ( unsigned i = 0 ; i < num_elems ; ++i ) { - const unsigned elem_offset = i * nodes_per_elem ; - - double tmp[3] = { 0 , 0 , 0 }; - - for ( unsigned j = 0 ; j < nodes_per_elem ; ++j ) { - const unsigned node_offset = elem_offset + j ; - const double * const value = & gathered_value[ node_offset * 3 ]; - - tmp[0] += value[0] ; - tmp[1] += value[1] ; - tmp[2] += value[2] ; - } - - elem_value[0] = tmp[0] / nodes_per_elem ; - elem_value[1] = tmp[1] / nodes_per_elem ; - elem_value[2] = tmp[2] / nodes_per_elem ; - - elem_value += 3 ; - } -} - -//---------------------------------------------------------------------- -#endif -//---------------------------------------------------------------------- - -void scale_sum( const unsigned number , - const double a , - double * const X , - const double b , - const double * const Y , - const double c , - const double * const Z ) -{ -#if 0 - if ( Z ) { - for ( unsigned i = 0 ; i < number ; ++i ) { - X[i] = a * X[i] + b * Y[i] + c * Z[i] ; - } - } - else { - for ( unsigned i = 0 ; i < number ; ++i ) { - X[i] = a * X[i] + b * Y[i] ; - } - } -#else - double * const x_end = X + number ; - double * x = X ; - const double * y = Y ; - if ( Z ) { - const double * z = Z ; - for ( ; x < x_end ; ++x , ++y , ++z ) { - *x = a * *x + b * *y + c * *z ; - } - } - else { - for ( ; x < x_end ; ++x , ++y ) { - *x = a * *x + b * *y ; - } - } -#endif -} - -void ElementMeanValue::apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const -{ - const stk_classic::mesh::BucketArray< stk_classic::mesh::Field > - elem_node( elem_node_field , ibegin , iend ); - - const double * const * const node_ptr = elem_node.contiguous_data(); - - if ( node_ptr ) { - - const unsigned nodes_per_elem = elem_node.dimension<0>(); - const unsigned number_elem = elem_node.dimension<1>(); - - double * const elem_data = field_data( elem_field , ibegin ); - -#if USE_HARDWIRED_NUMBER_NODES - switch( nodes_per_elem ) { - case 8 : - element_mean_value_8x3( number_elem, node_ptr, elem_data ); - break ; - case 4 : - element_mean_value_4x3( number_elem, node_ptr, elem_data ); - break ; - default: - throw std::logic_error( std::string("BAD nodes-per-element" ) ); - } -#else - element_mean_value_3( number_elem, nodes_per_elem, node_ptr, elem_data ); -#endif - } -} - -void ElementMeanValue_Gather::apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const - -{ - const stk_classic::mesh::BucketArray< stk_classic::mesh::Field > - elem_node( elem_node_field , ibegin , iend ); - - const double * const * const node_ptr = elem_node.contiguous_data(); - - if ( node_ptr ) { - - const unsigned nodes_per_elem = elem_node.dimension<0>(); - const unsigned number_elem = elem_node.dimension<1>(); - - double * const elem_data = field_data( elem_field , ibegin ); - -#if USE_HARDWIRED_NUMBER_NODES - switch( nodes_per_elem ) { - case 8 : - for ( unsigned i = 0 ; i < number_elem ; ) { - unsigned n = GATHER_COUNT_SIZE < ( number_elem - i ) ? - GATHER_COUNT_SIZE : ( number_elem - i ); - - element_gather_mean_value_8x3( - n, node_ptr + i * 8 , elem_data + i * 3 ); - i += n ; - } - break ; - case 4 : - for ( unsigned i = 0 ; i < number_elem ; ) { - unsigned n = GATHER_COUNT_SIZE < ( number_elem - i ) ? - GATHER_COUNT_SIZE : ( number_elem - i ); - - element_gather_mean_value_4x3( - n, node_ptr + i * 4 , elem_data + i * 3 ); - i += n ; - } - break ; - default: - throw std::logic_error( std::string("BAD nodes-per-element" ) ); - } -#else - const unsigned num_elem_workset = - GATHER_BUFFER_SIZE / ( nodes_per_elem * 3 ); - - for ( unsigned i = 0 ; i < number_elem ; ) { - unsigned n = num_elem_workset < ( number_elem - i ) ? - num_elem_workset : ( number_elem - i ); - - element_gather_mean_value_3( - n, nodes_per_elem, node_ptr + i * nodes_per_elem , - elem_data + i * 3 ); - i += n ; - } -#endif - } -} - -//---------------------------------------------------------------------- - -void NodeScaleSum::apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const -{ - enum { SpaceDim = 3 }; - - double * x_val = field_data( X , ibegin ); - const double * y_val = field_data( Y , ibegin ); - const double * z_val = field_data( Z , ibegin ); - const int size = iend - ibegin ; - - scale_sum( size * SpaceDim , a , x_val , b , y_val , c , z_val ); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void verify_elem_node_coord( - stk_classic::mesh::BulkData & mesh , - const stk_classic::mesh::Field & elem_node_coord , - const stk_classic::mesh::Field & node_coord ) -{ - typedef stk_classic::mesh::Field ElemNodeFieldType ; - - const stk_classic::mesh::EntityRank element_rank = stk_classic::mesh::fem::FEMMetaData::get(mesh).element_rank(); - - const std::vector & buckets = mesh.buckets( element_rank ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - - stk_classic::mesh::BucketArray< ElemNodeFieldType > array( elem_node_coord , bucket ); - - const unsigned num_node = array.dimension<0>(); - const unsigned size = array.dimension<1>(); - - double * const * elem_data = array.contiguous_data(); - - for ( unsigned i = 0 ; i < size ; ++i ) { - stk_classic::mesh::Entity & elem = bucket[i] ; - - stk_classic::mesh::PairIterRelation rel = elem.relations( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( unsigned j = 0 ; j < num_node ; ++j , ++elem_data ) { - stk_classic::mesh::Entity & node = * rel[j].entity(); - - double * const node_data = field_data( node_coord , node ); - if ( *elem_data != node_data ) { - std::cout << "verify_elem_node_coord ERROR, *elem_data != node_data" << std::endl; - } - } - } - } -} - -}//namespace app -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.hpp b/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.hpp deleted file mode 100644 index c5c53f6728d5..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/performance_algorithms.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - */ - -#ifndef stk_mesh_use_cases_performance_algorithms_hpp -#define stk_mesh_use_cases_performance_algorithms_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace app { - -//---------------------------------------------------------------------- - -struct ElementMeanValue { - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const; - - ElementMeanValue( - const stk_classic::mesh::Field & arg_elem_field , - const stk_classic::mesh::Field & arg_node_field_ptr ) - : elem_field( arg_elem_field ), - elem_node_field( arg_node_field_ptr ) {} - - const stk_classic::mesh::Field & elem_field ; - const stk_classic::mesh::Field & elem_node_field ; -}; - -struct ElementMeanValue_Gather { - - enum { maximum_entity_count = 0 }; /* Don't slice buckets */ - - void apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const; - - ElementMeanValue_Gather( - const stk_classic::mesh::Field & arg_elem_field , - const stk_classic::mesh::Field & arg_node_field_ptr ) - : elem_field( arg_elem_field ), - elem_node_field( arg_node_field_ptr ) {} - - const stk_classic::mesh::Field & elem_field ; - const stk_classic::mesh::Field & elem_node_field ; -}; - -//---------------------------------------------------------------------- - -struct NodeScaleSum { - - enum { maximum_entity_count = 0 }; /* Don't slice buckets. */ - void apply( stk_classic::mesh::Bucket::iterator ibegin , - stk_classic::mesh::Bucket::iterator iend ) const; - - NodeScaleSum( - double arg_a , const stk_classic::mesh::Field & arg_X , - double arg_b , const stk_classic::mesh::Field & arg_Y , - double arg_c , const stk_classic::mesh::Field & arg_Z ) - : a( arg_a ), b( arg_b ), c( arg_c ), - X( arg_X ), Y( arg_Y ), Z( arg_Z ) {} - - const double a ; - const double b ; - const double c ; - const stk_classic::mesh::Field & X ; - const stk_classic::mesh::Field & Y ; - const stk_classic::mesh::Field & Z ; -}; - -//---------------------------------------------------------------------- - -void verify_elem_node_coord( - stk_classic::mesh::BulkData & mesh , - const stk_classic::mesh::Field & elem_node_coord , - const stk_classic::mesh::Field & node_coord ); - -}//namespace app -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/app/shared_fortran.F b/packages/stk/stk_classic/stk_usecases/app/shared_fortran.F deleted file mode 100644 index 5c0c0e66e94e..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/shared_fortran.F +++ /dev/null @@ -1,162 +0,0 @@ - subroutine asol_ug3d_so_ratedef( nelem,nint,dt, - * def_grad_inv, cg_left_inv, eval, evec, rate_def ) -c -c*********************************************************************** -c*********************************************************************** -c -c description: -c This routine computes the rate of deformation of the material using -c a "strong objectivity" approach. More description to follow. -c -c formal parameters - input: -c nelem int number of elements in the workset -c nint int number of integration stations for element -c dt Real time increment -c def_grad_inv Real velocity gradient -c -c formal parameters - workspace for computations: -c cg_left_inv Real inverse of left cauchy green tensor (B^-1) -c eval Real eigenvalues of B^-1 -c evec Real eigenvectors of B^-1 -c stretch_left_inv Real inverse of left stretch (V^-1) -c -c formal parameters - output: -c def_grad_inv Real inverse of incremental deformation gradient -c rate_def Real rate of deformation (D) -c -c*********************************************************************** -c -#include -#include -#include -#include -c -c mappings from sierra structure to local structure -c - parameter( iv_x = k_v3dx, - 2 iv_y = k_v3dy, - 2 iv_z = k_v3dz ) - parameter( is_xx = k_s33xx, - 2 is_yy = k_s33yy, - 2 is_zz = k_s33zz, - 2 is_xy = k_s33xy, - 2 is_yz = k_s33yz, - 2 is_zx = k_s33zx ) - parameter( if_xx = k_f36xx, - * if_yy = k_f36yy, - * if_zz = k_f36zz, - * if_xy = k_f36xy, - * if_yz = k_f36yz, - * if_zx = k_f36zx, - * if_yx = k_f36yx, - * if_zy = k_f36zy, - * if_xz = k_f36xz ) -c -c input parameters -c - dimension def_grad_inv(n_f36,nelem,nint), - * cg_left_inv(n_s33,nelem,nint), - * eval(n_v3d,nelem,nint),evec(n_f36,nelem,nint), - * rate_def(n_s33,nelem,nint) -c -c Convert velocity gradient into incremental rate of deformation -c ( F^-1 = I - du/dx ) -c - do j = 1, nint - do k = 1, nelem -c - def_grad_inv(if_xx,k,j)=-def_grad_inv(if_xx,k,j)*dt - & + ONE - def_grad_inv(if_yy,k,j)=-def_grad_inv(if_yy,k,j)*dt - & + ONE - def_grad_inv(if_zz,k,j)=-def_grad_inv(if_zz,k,j)*dt - & + ONE - def_grad_inv(if_xy,k,j)=-def_grad_inv(if_xy,k,j)*dt - def_grad_inv(if_yz,k,j)=-def_grad_inv(if_yz,k,j)*dt - def_grad_inv(if_zx,k,j)=-def_grad_inv(if_zx,k,j)*dt - def_grad_inv(if_yx,k,j)=-def_grad_inv(if_yx,k,j)*dt - def_grad_inv(if_zy,k,j)=-def_grad_inv(if_zy,k,j)*dt - def_grad_inv(if_xz,k,j)=-def_grad_inv(if_xz,k,j)*dt -c - enddo - enddo -c -c If dt is zero, then there is no rate of deformation for this -c loading increment. Set rate of deformation tensor to be zero. -c - if ( dt .eq. ZERO) then -c - do j = 1, nint - do k = 1, nelem -c - rate_def(is_xx,k,j) = ZERO - rate_def(is_yy,k,j) = ZERO - rate_def(is_zz,k,j) = ZERO - rate_def(is_xy,k,j) = ZERO - rate_def(is_yz,k,j) = ZERO - rate_def(is_zx,k,j) = ZERO -c - enddo - enddo - return -c - endif -c -c Compute inverse of left cauchy green tensor (B^-1) -c - call fmath_right_tensor_square36( nelem,nint,def_grad_inv, - & cg_left_inv) -c -c Get eigenvalues of B^-1 -c - call fmth_eigen( nelem,nint,cg_left_inv,eval,evec ) -c - do j = 1, nint - do k = 1, nelem -c - xlog = log(eval(iv_x,k,j)) - ylog = log(eval(iv_y,k,j)) - zlog = log(eval(iv_z,k,j)) -c - xinv = sqrt(eval(iv_x,k,j)) - yinv = sqrt(eval(iv_y,k,j)) - zinv = sqrt(eval(iv_z,k,j)) -c - rate_def(is_xx,k,j) = - (half/dt)*( - & xlog*evec(if_xx,k,j)*evec(if_xx,k,j) - & +ylog*evec(if_xy,k,j)*evec(if_xy,k,j) - & +zlog*evec(if_xz,k,j)*evec(if_xz,k,j)) -c - rate_def(is_yy,k,j) = - (half/dt)*( - & xlog*evec(if_yx,k,j)*evec(if_yx,k,j) - & +ylog*evec(if_yy,k,j)*evec(if_yy,k,j) - & +zlog*evec(if_yz,k,j)*evec(if_yz,k,j)) -c - rate_def(is_zz,k,j) = - (half/dt)*( - & xlog*evec(if_zx,k,j)*evec(if_zx,k,j) - & +ylog*evec(if_zy,k,j)*evec(if_zy,k,j) - & +zlog*evec(if_zz,k,j)*evec(if_zz,k,j)) -c - rate_def(is_xy,k,j) = - (half/dt)*( - & xlog*evec(if_xx,k,j)*evec(if_yx,k,j) - & +ylog*evec(if_xy,k,j)*evec(if_yy,k,j) - & +zlog*evec(if_xz,k,j)*evec(if_yz,k,j)) -c - rate_def(is_yz,k,j) = - (half/dt)*( - & xlog*evec(if_yx,k,j)*evec(if_zx,k,j) - & +ylog*evec(if_yy,k,j)*evec(if_zy,k,j) - & +zlog*evec(if_yz,k,j)*evec(if_zz,k,j)) -c - rate_def(is_zx,k,j) = - (half/dt)*( - & xlog*evec(if_zx,k,j)*evec(if_xx,k,j) - & +ylog*evec(if_zy,k,j)*evec(if_xy,k,j) - & +zlog*evec(if_zz,k,j)*evec(if_xz,k,j)) -c - enddo - enddo -c - return - end -c -c Copyright 2000 Sandia Corporation, Albuquerque, NM. -c diff --git a/packages/stk/stk_classic/stk_usecases/app/shared_fortran.hpp b/packages/stk/stk_classic/stk_usecases/app/shared_fortran.hpp deleted file mode 100644 index e83e322ba993..000000000000 --- a/packages/stk/stk_classic/stk_usecases/app/shared_fortran.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef SIERRA_shared_fortran_h -#define SIERRA_shared_fortran_h - -#include -#include - - -extern "C" void -SIERRA_FORTRAN(asol_ug3d_so_ratedef)( const Int& nelem, - const Int& nint, - const Real& dt, - const Real* def_grad_inv, - Real* lcg_inv, - Real* eigval, - Real* eigvec, - Real* rate_def ); - -#endif diff --git a/packages/stk/stk_classic/stk_usecases/common/gnu_malloc_hooks.cpp b/packages/stk/stk_classic/stk_usecases/common/gnu_malloc_hooks.cpp deleted file mode 100644 index d60f6a059577..000000000000 --- a/packages/stk/stk_classic/stk_usecases/common/gnu_malloc_hooks.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifdef USE_GNU_MALLOC_HOOKS - -#include - -#include -#include -#include - -//if USE_GNU_MALLOC_HOOKS is not defined, then -//the compiler won't see the rest of this file. - -enum { ALLOC_BYTES=0, - FREED_BYTES=1, - ALLOC_BLKS=2, - FREED_BLKS=3, - NUM_STATS=4}; - -static bool gnu_malloc_hooks_disabled = false; -static double my_stats[NUM_STATS]; - -typedef std::map size_map; - -size_map* my_sizes = NULL; - -const unsigned ONEMB = 1024*1024; - -/* Prototypes for our hooks. */ -static void my_init_hook (void); -static void *my_malloc_hook (size_t, const void *); -static void *(*old_malloc_hook)(size_t, const void*); -static void *my_realloc_hook (void*, size_t, const void *); -static void *(*old_realloc_hook)(void*, size_t, const void*); -static void my_free_hook (void*, const void *); -static void (*old_free_hook)(void*, const void*); - -/* Override initializing hook from the C library. */ -void (*__malloc_initialize_hook) (void) = my_init_hook; - -void -my_init_hook (void) -{ - my_sizes = new size_map; - old_malloc_hook = __malloc_hook; - old_realloc_hook = __realloc_hook; - old_free_hook = __free_hook; - __malloc_hook = my_malloc_hook; - __realloc_hook = my_realloc_hook; - __free_hook = my_free_hook; - for(unsigned i=0; ifind(ptr); - if (iter != my_sizes->end()) { - unsigned oldsize = iter->second; - my_stats[FREED_BYTES] += oldsize; - my_stats[FREED_BLKS] += 1; - my_sizes->erase(iter); - } - - /* Call recursively */ - result = realloc(ptr, size); - my_stats[ALLOC_BYTES] += size; - my_stats[ALLOC_BLKS] += 1; - (*my_sizes)[result] = size; - - /* Restore our own hooks */ - __malloc_hook = my_malloc_hook; - __realloc_hook = my_realloc_hook; - __free_hook = my_free_hook; - return result; -} - -void -my_free_hook (void *ptr, const void *caller) -{ - /* Restore all old hooks */ - __malloc_hook = old_malloc_hook; - __free_hook = old_free_hook; - - size_map::iterator iter = my_sizes->find(ptr); - if (iter != my_sizes->end()) { - unsigned size = iter->second; - my_stats[FREED_BYTES] += size; - my_stats[FREED_BLKS] += 1; - my_sizes->erase(iter); - } - - /* Call recursively */ - free(ptr); - - /* Restore our own hooks */ - __malloc_hook = my_malloc_hook; - __free_hook = my_free_hook; -} - -void disable_gnu_malloc_hooks() -{ - /* Restore all old hooks */ - __malloc_hook = old_malloc_hook; - __free_hook = old_free_hook; - gnu_malloc_hooks_disabled = true; -} - - -void reset_malloc_stats() -{ - for(unsigned i=0; i -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -/** \addtogroup stk_io_module - * \{ - */ - -/** - * Example code showing a basic, but complete, mesh to results output - * coding including subsetting and periodic field input and output. - * Includes handling of nodeblocks, element blocks, nodesets, and - * sidesets. Attribute fields and distribution factor fields are also - * supported. - * - * This example can serve as the basis for adding binary IO support to - * an application. The code here uses the Ioss to/from stk_classic::mesh - * bridge functions in the stk_classic::io namespace defined in IossBridge.hpp - * include file. - */ -namespace stk_example_io { - - /// Declare "coordinates" field and put it on the universal part. This - /// example also defines all Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::Nodeblock as fields on the universal part. - void process_nodeblocks (Ioss::Region ®ion, stk_classic::mesh::MetaData &meta); - - /// Declare a part for each element block on the Ioss::Region - /// 'region' unless the element block has the "omitted" property set - /// to the value 1. The example then iterates each element block and - /// defines any Ioss::Field::ATTRIBUTE and Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::ElementBlock as fields on the corresponding part. - void process_elementblocks (Ioss::Region ®ion, stk_classic::mesh::MetaData &meta); - - /// Declare a part for each Ioss::NodeSet on the Ioss::Region - /// 'region' unless the nodeset has the "omitted" property set - /// to the value 1. The example then iterates each nodeset and - /// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that - /// exist on the Ioss::NodeSet as fields on the corresponding - /// part. - void process_nodesets (Ioss::Region ®ion, stk_classic::mesh::MetaData &meta); - - /// Declare a part for each Ioss::SideSet on the Ioss::Region - /// 'region' unless the sideset has the "omitted" property set - /// to the value 1. The example then iterates each sideset and - /// defines any "distribution factor" and Ioss::Field::TRANSIENT fields that - /// exist on the Ioss::SideSet as fields on the corresponding - /// part. - /// - /// Each sideblock in the active sidesets is then processed by - /// defining a part for each Ioss::SideBlock on the Ioss::SideSet - /// unless the sideblock has the "omitted" property set to the value - /// 1. The example then iterates each sideblock and defines any - /// "distribution factor" and Ioss::Field::TRANSIENT fields that exist on the - /// Ioss::SideBlock as fields on the corresponding part. - void process_sidesets (Ioss::Region ®ion, stk_classic::mesh::MetaData &meta); - - /// NOTE: This must be called after the process_elementblocks() call - /// since there may be nodes that exist in the database that are - /// not part of the analysis mesh due to subsetting of the element - /// blocks. - /// - /// Populates the "coordinates" field for all active nodes in the model. - void process_nodeblocks (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// NOTE: This should be the first function called of any of the - /// "process_X" type functions that take an stk_classic::mesh::BulkData - /// argument, especially if the input Ioss::Region mesh is going to - /// be subsetted (have element blocks omitted). - /// - /// This function iterates all non-omitted element blocks and - /// declares each element (and the corresponding nodes) in the - /// element block. If there are any Ioss::Field::ATTRIBUTE fields on the element - /// block (for example, shell thickness or particle radius), then - /// that field data is alse read and the corresponding - /// stk_classic::mesh::Field populated. - void process_elementblocks (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// Iterates each non-omitted Ioss::NodeSet and then iterates each - /// node in the Ioss::NodeSet. If the node exists (that is, it is - /// connected to a non-omitted Ioss::ElementBlock), then that node - /// is associated with the part corresponding to this - /// Ioss::NodeSet. If the "distribution_factor" field exists, then - /// that data is also associated with the field. - void process_nodesets (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// Process each non-omitted Ioss::SideSet and the contained - /// non-omitted Ioss::SideBlock and associate each element-side pair with - /// the corresponding part if the underlying element is active. If - /// the "distribution_factor" field exists, then that data is also - /// associated with the corresponding field. - void process_sidesets (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk); - - /// A minimal example function showing how field data on the - /// Ioss::Region entities can be periodically transferred to the - /// corresponding field(s) on the stk_classic::mesh entities. This would be - /// used to bring in initial condition data or interpolation data or - /// any other scenario in which data on the mesh file needs to be - /// transferred to the stk_classic::mesh fields. - void process_input_request (Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - - /// A minimal example function showing how stk_classic::mesh field data can - /// periodically be output to a results, history, heartbeat, or - /// restart database. The scheduling would be done either in this - /// function or at a higher level and is not shown here. The - /// function iterates all parts and if there is a corresponding Ioss - /// part on the Ioss::Region, all fields defined to be output are - /// iterated and their data output to the corresponding - /// Ioss::Field. The function calls the - /// stk_classic::io::is_valid_part_field() function to determine whether the - /// field should be output and then calls the - /// stk_classic::io::field_data_to_ioss() function to do the actual output - /// of the field. - void process_output_request(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk, int step); - - /// This function shows the basic calls needed to perform definition - /// and input of the mesh model and definition and periodic output - /// of a results database. The function is given the mesh filename - /// and the output filename and goes through all steps of - /// associating the filename with an Ioss::DatabaseIO object of the - /// correct type ("exodusII" in this example); creating an - /// Ioss::Region and then defining an stk_classic::mesh corresponding to - /// this mesh. The function also provides an example of how - /// specific element blocks existing in the mesh database could be - /// omitted from the analysis model. - /// - /// The example then shows how to define a results database - /// corresponding to the analysis model and periodically output the - /// results in an execute loop. - /// - /// A true application would have to provide additional - /// functionality and robustness, but the example shows how the - /// basic functionality can be provided by an application. - /// - /// Note that the paradigm illustrated here is different than the - /// mesh input and output paradigm provided in the current - /// framework. In this case, the application is responsible for the - /// majority of the IO behavior and the toolkit only provides some - /// helper functions to bridge between the Ioss and the stk_classic::mesh. - /// It is hoped that this paradigm will result in more functionality - /// for the application with less complication and overhead. - void io_example( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string& out_filename, - const std::string& decomp_method) - { - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - std::cout << "========================================================================\n" - << " Copy input mesh to output mesh. \n" - << "========================================================================\n"; - - std::string dbtype("exodusII"); - Ioss::PropertyManager properties; - if (!decomp_method.empty()) { - properties.add(Ioss::Property("DECOMPOSITION_METHOD", Ioss::Utils::uppercase(decomp_method))); - } - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(dbtype, in_filename, Ioss::READ_MODEL, - comm, properties); - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << in_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - std::cout << "Reading input file: " << in_filename << "\n"; - // NOTE: 'in_region' owns 'dbi' pointer at this time... - Ioss::Region in_region(dbi, "input_model"); - - // SUBSETTING PARSING/PREPROCESSING... - // Just an example of how application could control whether an - // entity is subsetted or not... - - -#if 0 - // Example command line in current code corresponding to behavior below: - std::cout << "\nWhen processing file multi-block.g for use case 2, the blocks below will be omitted:\n"; - std::cout << "\tOMIT BLOCK Cblock Eblock I1 I2\n\n"; - Ioss::ElementBlock *eb = in_region.get_element_block("cblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("eblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i1"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i2"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); -#endif - -#if 0 - // Example for subsetting -- omit "odd" blocks - if (entity->type() == Ioss::ELEMENTBLOCK) { - int id = entity->get_property("id").get_int(); - if (id % 2) { - entity->property_add(Ioss::Property(std::string("omitted"), 1)); - std::cout << "Skipping " << entity->type_string() << ": " << entity->name() << "\n"; - } - } -#endif - - //---------------------------------- - // Process Entity Types. Subsetting is possible. - - static size_t spatial_dimension = in_region.get_property("spatial_dimension").get_int(); - - stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension ); - stk_classic::mesh::MetaData &meta_data = fem_meta_data.get_meta_data(fem_meta_data); - process_elementblocks(in_region, meta_data); - process_nodeblocks(in_region, meta_data); - process_sidesets(in_region, meta_data); - process_nodesets(in_region, meta_data); - - //---------------------------------- - // Done populating meta data, commit and create bulk data - meta_data.commit(); - - //---------------------------------- - // Process Bulkdata for all Entity Types. Subsetting is possible. - stk_classic::mesh::BulkData bulk_data(meta_data, comm); - - bulk_data.modification_begin(); - process_elementblocks(in_region, bulk_data); - process_nodeblocks(in_region, bulk_data); - process_sidesets(in_region, bulk_data); - process_nodesets(in_region, bulk_data); - bulk_data.modification_end(); - - //---------------------------------- - // OUTPUT...Create the output "mesh" portion - - std::cout << "Creating output file: " << out_filename << "\n"; - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create(dbtype, out_filename, - Ioss::WRITE_RESULTS, - comm); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - -#if 0 - { - // Code to test the remove_io_part_attribute functionality. - // Hook this up to a command line option at some point to test nightly... - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - stk_classic::mesh::Part * const part = *ip; - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - if (stk_classic::io::is_part_io_part(*part) && part_rank == 2) { - std::cout << "Removing part attribute from " << part->name() << "\n"; - stk_classic::io::remove_io_part_attribute(*part); - } - } - } -#endif - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - Ioss::Region out_region(dbo, "results_output"); - - stk_classic::io::define_output_db(out_region, bulk_data, &in_region); - stk_classic::io::write_output_db(out_region, bulk_data); - - // ------------------------------------------------------------------------ - /** \todo REFACTOR A real app would register a subset of the - * fields on the mesh database as fields that the app would want - * read at one or all or specified steps. In this example, all - * fields existing on the input mesh database are defined on the - * parts in the stk_classic::mesh. - * - * The real app would also only register a subset of the stk_classic::mesh - * fields as output fields and would probably have a mapping from - * the internally used name to some name picked by the user. In - * this example, all Ioss::Field::TRANSIENT fields defined on the stk_classic::mesh are - * output to the results database and the internal stk_classic::mesh field - * name is used as the name on the database.... - */ - - out_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields(meta_data.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - out_region.get_node_blocks()[0], - Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = out_region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - assert(sset != NULL); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *fb = sset->get_block(i); - stk_classic::io::ioss_add_fields(*part, part_rank, - fb, Ioss::Field::TRANSIENT); - } - } else { - stk_classic::io::ioss_add_fields(*part, part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - out_region.end_mode(Ioss::STATE_DEFINE_TRANSIENT); - // ------------------------------------------------------------------------ - - // Read and Write transient fields... - out_region.begin_mode(Ioss::STATE_TRANSIENT); - int timestep_count = in_region.get_property("state_count").get_int(); - for (int step = 1; step <= timestep_count; step++) { - double time = in_region.get_state_time(step); - - // Read data from the io input mesh database into stk_classic::mesh fields... - process_input_request(in_region, bulk_data, step); - - // execute() - - // Write data from the stk_classic::mesh fields out to the output database.a - int out_step = out_region.add_state(time); - process_output_request(out_region, bulk_data, out_step); - } - out_region.end_mode(Ioss::STATE_TRANSIENT); - } - - // ======================================================================== - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - assert(nb->field_exists("mesh_model_coordinates")); - Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); - int spatial_dim = coordinates.transformed_storage()->component_count(); - - stk_classic::mesh::Field & coord_field = - meta.declare_field >("coordinates"); - - stk_classic::mesh::put_field( coord_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta.universal_part(), - spatial_dim); - - /** \todo IMPLEMENT truly handle fields... For this case we are - * just defining a field for each transient field that is present - * in the mesh... - */ - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - } - - // ======================================================================== - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const stk_classic::mesh::fem::FEMMetaData &fem_meta_data = stk_classic::mesh::fem::FEMMetaData::get(meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank(); - - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - stk_classic::io::default_part_processing(elem_blocks, meta, element_rank); - - // Parts were created above, now handle element block specific - // information (topology, attributes, ...); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Element Block attributes (if any)... - /** \todo IMPLEMENT truly handle attribute fields... For this - * case we are just defining a field for each attribute field - * that is present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::ATTRIBUTE, - *part, - part_rank); - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, - part_rank); - - const CellTopologyData* cell_topo = fem_meta_data.get_cell_topology(*part).getCellTopologyData(); - std::string cell_topo_name = "UNKNOWN"; - if (cell_topo != NULL) - cell_topo_name = cell_topo->name; - } - } - } - - // ======================================================================== - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - stk_classic::io::default_part_processing(node_sets, meta, stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - /** \todo REFACTOR should "distribution_factor" be a default field - * that is automatically declared on all objects that it exists - * on as is done in current framework? - */ - stk_classic::mesh::Field & distribution_factors_field = - meta.declare_field >("distribution_factors"); - - /** \todo REFACTOR How to associate distribution_factors field - * with the nodeset part if a node is a member of multiple - * nodesets - */ - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - assert(entity->field_exists("distribution_factors")); - - stk_classic::mesh::put_field(distribution_factors_field, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, *part); - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, - part->primary_entity_rank() ) ; - } - } - } - - // ======================================================================== - void process_surface_entity(Ioss::SideSet *sset, stk_classic::mesh::MetaData &meta, - stk_classic::mesh::EntityRank sset_rank) - { - assert(sset->type() == Ioss::SIDESET); - Ioss::SideSet *fs = dynamic_cast(sset); - assert(fs != NULL); - const Ioss::SideBlockContainer& blocks = fs->get_side_blocks(); - stk_classic::io::default_part_processing(blocks, meta, sset_rank); - - stk_classic::mesh::Part* const fs_part = meta.get_part(sset->name()); - assert(fs_part != NULL); - - stk_classic::mesh::Field *distribution_factors_field = NULL; - bool surface_df_defined = false; // Has the surface df field been defined yet? - - - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *side_block = sset->get_block(i); - if (stk_classic::io::include_entity(side_block)) { - stk_classic::mesh::Part * const side_block_part = meta.get_part(side_block->name()); - assert(side_block_part != NULL); - meta.declare_part_subset(*fs_part, *side_block_part); - - const stk_classic::mesh::EntityRank part_rank = side_block_part->primary_entity_rank(); - - if (side_block->field_exists("distribution_factors")) { - if (!surface_df_defined) { - std::string field_name = sset->name() + "_distribution_factors"; - distribution_factors_field = - &meta.declare_field >(field_name); - stk_classic::io::set_distribution_factor_field(*fs_part, *distribution_factors_field); - surface_df_defined = true; - } - stk_classic::io::set_distribution_factor_field(*side_block_part, *distribution_factors_field); - int side_node_count = side_block->topology()->number_nodes(); - stk_classic::mesh::put_field(*distribution_factors_field, - part_rank, - *side_block_part, side_node_count); - } - - /** \todo IMPLEMENT truly handle fields... For this case we - * are just defining a field for each transient field that is - * present in the mesh... - */ - stk_classic::io::define_io_fields(side_block, Ioss::Field::TRANSIENT, - *side_block_part, - part_rank); - } - } - } - - // ======================================================================== - void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(meta); - const stk_classic::mesh::EntityRank side_rank = fem.side_rank(); - - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - stk_classic::io::default_part_processing(side_sets, meta, side_rank); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, meta, side_rank); - } - } - } - - // ======================================================================== - // Bulk Data - // ======================================================================== - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // This must be called after the "process_element_blocks" call - // since there may be nodes that exist in the database that are - // not part of the analysis mesh due to subsetting of the element - // blocks. - - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - std::vector nodes; - stk_classic::io::get_entity_list(nb, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, bulk, nodes); - - /** \todo REFACTOR Application would probably store this field - * (and others) somewhere after the declaration instead of - * looking it up each time it is needed. - */ - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates"); - } - - // ======================================================================== - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string &name = entity->name(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - const stk_classic::mesh::fem::FEMMetaData &fem_meta_data = stk_classic::mesh::fem::FEMMetaData::get(meta); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - - const CellTopologyData* cell_topo = fem_meta_data.get_cell_topology(*part).getCellTopologyData(); - if (cell_topo == NULL) { - std::ostringstream msg ; - msg << " INTERNAL_ERROR: Part " << part->name() << " returned NULL from get_cell_topology()"; - throw std::runtime_error( msg.str() ); - } - - std::vector elem_ids ; - std::vector connectivity ; - std::vector connectivity2 ; - - entity->get_field_data("ids", elem_ids); - entity->get_field_data("connectivity", connectivity); - connectivity2.reserve(connectivity.size()); - std::copy(connectivity.begin(), connectivity.end(), std::back_inserter(connectivity2)); - - size_t element_count = elem_ids.size(); - int nodes_per_elem = cell_topo->node_count ; - - std::vector elements(element_count); - for(size_t i=0; ifield_describe(Ioss::Field::ATTRIBUTE, &names); - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if (*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = meta.get_field(*I); - stk_classic::io::field_data_from_ioss(field, elements, entity, *I); - - } - } - } - } - - // ======================================================================== - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // Should only process nodes that have already been defined via the element - // blocks connectivity lists. - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string & name = entity->name(); - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - stk_classic::mesh::PartVector add_parts( 1 , part ); - - std::vector node_ids ; - int node_count = entity->get_field_data("ids", node_ids); - - std::vector nodes(node_count); - for(int i=0; i *df_field = - meta.get_field >("distribution_factors"); - - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors"); - } - } - } - } - - // ======================================================================== - void process_surface_entity(const Ioss::SideSet* sset , - stk_classic::mesh::BulkData & bulk) - { - assert(sset->type() == Ioss::SIDESET); - - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - const stk_classic::mesh::fem::FEMMetaData &fem_meta_data = stk_classic::mesh::fem::FEMMetaData::get(meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank(); - - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *block = sset->get_block(i); - if (stk_classic::io::include_entity(block)) { - std::vector side_ids ; - std::vector elem_side ; - - stk_classic::mesh::Part * const side_block_part = meta.get_part(block->name()); - stk_classic::mesh::EntityRank side_rank = side_block_part->primary_entity_rank(); - - block->get_field_data("ids", side_ids); - block->get_field_data("element_side", elem_side); - - assert(side_ids.size() * 2 == elem_side.size()); - stk_classic::mesh::PartVector add_parts( 1 , side_block_part ); - - size_t side_count = side_ids.size(); - std::vector sides(side_count); - for(size_t is=0; is *df_field = - stk_classic::io::get_distribution_factor_field(*side_block_part); - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors"); - } - } - } - } - - // ======================================================================== - void process_sidesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::SideSetContainer& side_sets = region.get_sidesets(); - - for(Ioss::SideSetContainer::const_iterator it = side_sets.begin(); - it != side_sets.end(); ++it) { - Ioss::SideSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } - } - - // ======================================================================== - // ======================================================================== - void get_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_from_ioss(f, entities, io_entity, f->name()); - } - } - } - - void process_input_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - - // ??? Get field data from nodeblock... - get_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - assert(sset != NULL); - int block_count = sset->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *side_block = sset->get_block(i); - /// \todo REFACTOR Need filtering mechanism. - get_field_data(bulk, *part, - part_rank, - side_block, Ioss::Field::TRANSIENT); - } - } else { - get_field_data(bulk, *part, - part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - - region.end_state(step); - } - - void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityRank part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role); - } - } - } - - void process_output_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData& meta = stk_classic::mesh::MetaData::get(bulk); - - put_field_data(bulk, meta.universal_part(), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - const stk_classic::mesh::EntityRank part_rank = part->primary_entity_rank(); - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - - if (entity->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(entity); - assert(sset != NULL); - int block_count = sset->block_count(); - - for (int i=0; i < block_count; i++) { - Ioss::SideBlock *side_block = sset->get_block(i); - /// \todo REFACTOR Need filtering mechanism. - put_field_data(bulk, *part, part_rank, - side_block, Ioss::Field::TRANSIENT); - } - } else { - put_field_data(bulk, *part, part_rank, - entity, Ioss::Field::TRANSIENT); - } - } else { - /// \todo IMPLEMENT handle error... Possibly an assert since - /// I think the corresponding entity should always exist... - } - } - } - region.end_state(step); - } -} - -// ======================================================================== -#include - -#include -#include - - namespace bopt = boost::program_options; - int main(int argc, char** argv) - { - //---------------------------------- - // Broadcast argc and argv to all processors. - - stk_classic::ParallelMachine comm = stk_classic::parallel_machine_init(&argc, &argv); - - stk_classic::BroadcastArg b_arg(comm, argc, argv); - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("options"); - - desc.add_options() - ("help,h", "produce help message") - ("mesh", bopt::value(), "mesh file" ) - ("decomposition,D", bopt::value(), "decomposition method" ) - ("directory,d", bopt::value(), "working directory" ) - ("output-log,o", bopt::value(), "output log path" ) - ("runtest,r", bopt::value(), "runtest pid file" ); - - stk_classic::get_options_description().add(desc); - - bopt::variables_map &vm = stk_classic::get_variables_map(); - try { - bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm); - bopt::notify(vm); - } - catch (std::exception & /* x */) { - std::exit(1); - } - - if (vm.count("help")) { - std::cout << desc << "\n"; - std::exit(EXIT_SUCCESS); - } - - //---------------------------------- - - if ( vm.count("mesh") ) { - std::string in_filename = boost::any_cast(vm["mesh"].value()); - std::string out_filename = in_filename + ".out"; - std::string decomp_method; - if (vm.count("decomposition")) { - decomp_method = boost::any_cast(vm["decomposition"].value()); - } - stk_example_io::io_example(comm, in_filename, out_filename, decomp_method ); - } else { - std::cout << "OPTION ERROR: The '--mesh ' option is required!\n"; - std::exit(EXIT_FAILURE); - } - stk_classic::parallel_machine_finalize(); - - return 0; - } - -/** - * \} - */ diff --git a/packages/stk/stk_classic/stk_usecases/io/io_example.dox b/packages/stk/stk_classic/stk_usecases/io/io_example.dox deleted file mode 100644 index c1e6418aeea9..000000000000 --- a/packages/stk/stk_classic/stk_usecases/io/io_example.dox +++ /dev/null @@ -1,804 +0,0 @@ -/** \defgroup stk_io_module Sierra Toolkit IO - * - * \anchor stk_io_example - * \section stk_io_example_code IO Example Code - * The code samples below should closely match the code in the example - * file stk_io/use_cases/io_example.cpp which is compilable and - * executable. It can be used to experiment with the stk_classic::io and Ioss - * functionality. If there is any discrepancy between the - * documentation below and the code found in io_example.cpp; trust the - * actual code. - * - * \subsection include_files Include Files - * The following include files are required for this example. - * \code - #include - #include - #include - - #include - #include - #include - #include - #include - #include - - #include - * \endcode - * \subsection main_io_control Main IO Control - * The io_example function provides all mesh input and results output - * functionality for this example application. It would most likely be - * split into multiple functions in a real application. - * The function - * takes as arguments an MPI communicator; the name of the mesh file - * to read from and the name of the results database to write to. - * \code - void io_example( stk_classic::ParallelMachine comm, - const std::string& in_filename, - const std::string& out_filename) - * \endcode - - * \subsection initialization Initialization - * The IO system must be initialized via a call to - * Ioss::Init::Initializer. This sets up which database types are - * supported and performs other behind the scenes initialization duties. - * \code - Ioss::Init::Initializer init_db; - * \endcode - * - * \subsection open_mesh_database Open Mesh Database - * The input mesh file must be associated with an Ioss::DatabaseIO - * object. The IO system must be told the type of the database to be - * opened; in this example, the type is "exodusII". If the file does - * not exist or could not be opened, the Ioss::IOFactory will return - * NULL; if the file does exist and can be opened, but has other - * problems, then the dbi->ok() function will return false. - * - * Once the datbase has been opened, it is then associated with an - * Ioss::Region which is the main interface to the mesh description - * stored in the mesh database. - * \code - std::string dbtype("exodusII"); - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(dbtype, in_filename, Ioss::READ_MODEL, - (MPI_Comm)comm); - if (dbi == NULL || !dbi->ok()) { - std::cerr << "ERROR: Could not open database '" << in_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'in_region' owns 'dbi' pointer at this time... - Ioss::Region in_region(dbi, "input_model"); - * \endcode - * - * \subsection optional_subsetting Optional Subsetting - * The stk_classic::io functions provide a basic subsetting capability. If an - * Ioss entity (Ioss::ElementBlock, Ioss::NodeSet, Ioss::FaceSet, - * Ioss::EdgeSet, ...) has the "omitted" property defined and the - * value of the property is "1", then the associated entity will be - * omitted from the stk_classic::mesh model. At any time prior to defining - * the stk_classic::mesh::MetaData, the application can set the property on - * any entities that should be omitted from the model. - * - * The following code example shows how this subsetting capability - * works by omitting the element blocks with names "cblock", "eblock", - * "i1", and "i2". These are element blocks in a file that is used in - * one of the stk_classic::io use cases. - *\code - // Example command line in current code corresponding to behavior below: - std::cout << "\nWhen processing file multi-block.g for use case 2, the blocks below will be omitted:\n"; - std::cout << "\tOMIT BLOCK Cblock Eblock I1 I2\n\n"; - Ioss::ElementBlock *eb = in_region.get_element_block("cblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("eblock"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i1"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - - eb = in_region.get_element_block("i2"); - if (eb != NULL) - eb->property_add(Ioss::Property(std::string("omitted"), 1)); - * \endcode - * - * \subsection define_metadata Define MetaData - * The following block of code shows how the Ioss metadata is - * queried and used to define the stk_classic::mesh::MetaData for the analysis - * model. Each of the process_* functions is described in more - * detail later on. - * \code - stk_classic::mesh::MetaData meta_data; - process_elementblocks(in_region, meta_data); - process_nodeblocks(in_region, meta_data); - process_facesets(in_region, meta_data); - process_edgesets(in_region, meta_data); - process_nodesets(in_region, meta_data); - * \endcode - * \subsection define_other_info Define Other Information - * At this point, the application would define other - * stk_classic::mesh::Field's that exist on the mesh parts or any other data - * that needs to be set before the meta data is comitted. Once this is - * done, the meta data can be commited. - * \code - meta_data.commit(); - * \endcode - * \subsection define_bulk_data Define Bulk Data - * The following block of code defines a stk_classic::mesh::BulkData object - * and populates it with the bulk data from the mesh database. Each of - * the process_* function is described in more detail later on. - * Following this, the analysis mesh is defined and ready for use. - * \code - stk_classic::mesh::BulkData bulk_data(meta_data, comm); - process_elementblocks(in_region, bulk_data); - process_nodeblocks(in_region, bulk_data); - process_facesets(in_region, bulk_data); - process_edgesets(in_region, bulk_data); - process_nodesets(in_region, bulk_data); - * \endcode - * - * \section Results Output - * Once the analysis mesh is defined, the application will typically - * want to define one or more output databases; for example, results, - * heartbeat, history, and/or restart. In the example below, a results - * database is defined and associated with an Ioss::Region. The - * define_output_db() function extracts the metadata from the - * stk_classic::mesh MetaData and BulkData so that the output region - * corresponds as much as possible to the input region. The - * "in_region" argument to the function is optional and if present - * will synchronize names and ids in the input mesh with the - * corresponding entities in the output mesh. - * - * Once the output database metadata is defined, the write_output_db() - * function is called to output the initial data to the file - * corresponding to this database. Following this call, the file - * should contain all of the non-transient data corresponding to the - * analysis mesh. - * \code - Ioss::DatabaseIO *dbo = Ioss::IOFactory::create(dbtype, out_filename, - Ioss::WRITE_RESULTS, - (MPI_Comm)comm); - if (dbo == NULL || !dbo->ok()) { - std::cerr << "ERROR: Could not open results database '" << out_filename - << "' of type '" << dbtype << "'\n"; - std::exit(EXIT_FAILURE); - } - - // NOTE: 'out_region' owns 'dbo' pointer at this time... - Ioss::Region out_region(dbo, "results_output"); - - stk_classic::io::define_output_db(out_region, bulk_data, &in_region); - stk_classic::io::write_output_db(out_region, bulk_data); - * \endcode - * \subsection define_transient Define Transient Output Fields - * At this time, the application would define what stk_classic::mesh::Field - * fields should be output to the results database and what they would - * be named. - * - * In this example, all fields existing on the input mesh database are - * defined on the parts in the stk_classic::mesh. - * - * The real app would also only register a subset of the stk_classic::mesh - * fields as output fields and would probably have a mapping from the - * internally used name to some name picked by the user. In this - * example, all Ioss::Field::TRANSIENT fields defined on the stk_classic::mesh - * are output to the results database and the internal stk_classic::mesh - * field name is used as the name on the database.... - * - * See ioss_add_fields() for more details on how to add a field. - * \code - out_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); - - // Special processing for nodeblock (all nodes in model)... - stk_classic::io::ioss_add_fields(meta_data.universal_part(), stk_classic::mesh::Node, - out_region.get_node_blocks()[0], - Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta_data.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = out_region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::FACESET || entity->type() == Ioss::EDGESET) { - int block_count = entity->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = entity->get_block(i); - stk_classic::io::ioss_add_fields(*part, part->primary_entity_type(), - fb, Ioss::Field::TRANSIENT); - } - } else { - stk_classic::io::ioss_add_fields(*part, part->primary_entity_type(), - entity, Ioss::Field::TRANSIENT); - } - } else { - /// ...handle error... - } - } - } - out_region.end_mode(Ioss::STATE_DEFINE_TRANSIENT); - * \endcode - * \subsection read_write_transient Read and Write Transient Fields (Execute Loop) - * At this time, the input and output databases are ready for reading - * and/or writing transient field data. This is where an application - * would typically have its execute loop which marches through time. - * - * In the example below, the code queries the input mesh region for - * the number of timesteps it contains and then simply reads all data - * on the input database for each timestep and writes the - * corresponding data to the results database. - * \code - // Read and Write transient fields... - out_region.begin_mode(Ioss::STATE_TRANSIENT); - int timestep_count = in_region.get_property("state_count").get_int(); - for (int step = 1; step <= timestep_count; step++) { - double time = in_region.get_state_time(step); - - // Read data from the io input mesh database into stk_classic::mesh fields... - process_input_request(in_region, bulk_data, step); - - // execute() - - // Write data from the stk_classic::mesh fields out to the output database.a - int out_step = out_region.add_state(time); - process_output_request(out_region, bulk_data, out_step); - } - out_region.end_mode(Ioss::STATE_TRANSIENT); - } - * \endcode - * \subsection end_app End of Application - * As the input and output Ioss::Region objects go out of scope, they - * will close the files associated with them and do all cleanup. - * - * \section processing_details_metadata Entity Processing Routine Details -- MetaData. - * \subsection process_nodeblocks - * \code - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - assert(nb->field_exists("mesh_model_coordinates")); - Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); - int spatial_dim = coordinates.transformed_storage()->component_count(); - - stk_classic::mesh::Field & coord_field = - meta.declare_field >("coordinates"); - - meta.put_field( coord_field, stk_classic::mesh::Node, meta.universal_part(), - spatial_dim); - - // For this case we are just defining a field for each - // transient field that is present in the mesh... - stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk_classic::mesh::Node); - } - * \endcode - * \subsection process_elementblocks - * \code - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - stk_classic::io::default_part_processing(elem_blocks, meta, stk_classic::mesh::Element); - - // Parts were created above, now handle element block specific - // information (topology, attributes, ...); - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - - // Element Block attributes (if any)... For this example - // we are just defining a field for each attribute field - // that is present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::ATTRIBUTE, - *part, part->primary_entity_type()); - - // For this case we are just defining a field for each - // transient field that is present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, part->primary_entity_type()); - - std::cout << entity->type_string() << ": " << entity->name() - << " , celltop = " << stk_classic::mesh::get_cell_topology(*part)->name - << std::endl ; - } - } - } - * \endcode - * \subsection process_nodesets - * \code - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - stk_classic::io::default_part_processing(node_sets, meta, stk_classic::mesh::Node); - - // In this example, "distribution_factor" is a default field that - // is automatically declared on all objects that it exists on as - // is done in current framework? - stk_classic::mesh::Field & distribution_factors_field = - meta.declare_field >("distribution_factors"); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - stk_classic::mesh::Part* const part = meta.get_part(entity->name()); - assert(part != NULL); - assert(entity->field_exists("distribution_factors")); - - meta.put_field(distribution_factors_field, stk_classic::mesh::Node, *part); - - // For this case we are just defining a field for each - // transient field that is present in the mesh... - stk_classic::io::define_io_fields(entity, Ioss::Field::TRANSIENT, - *part, part->primary_entity_type()); - } - } - } - - * \endcode - * \subsection process_surface_entity - * \code - void process_surface_entity(Ioss::GroupingEntity *entity, stk_classic::mesh::MetaData &meta, - stk_classic::mesh::EntityType entity_type) - { - assert(entity->type() == Ioss::FACESET || entity->type() == Ioss::EDGESET); - if (entity->type() == Ioss::FACESET) { - Ioss::FaceSet *fs = dynamic_cast(entity); - assert(fs != NULL); - const Ioss::FaceBlockContainer& blocks = fs->get_face_blocks(); - stk_classic::io::default_part_processing(blocks, meta, entity_type); - } else if (entity->type() == Ioss::EDGESET) { - Ioss::EdgeSet *es = dynamic_cast(entity); - assert(es != NULL); - const Ioss::EdgeBlockContainer& blocks = es->get_edge_blocks(); - stk_classic::io::default_part_processing(blocks, meta, entity_type); - } - - stk_classic::mesh::Part* const fs_part = meta.get_part(entity->name()); - assert(fs_part != NULL); - - stk_classic::mesh::Field *distribution_factors_field = NULL; - bool surface_df_defined = false; // Has the surface df field been defined yet? - - - int block_count = entity->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = entity->get_block(i); - if (stk_classic::io::include_entity(fb)) { - std::cout << fb->type_string() << " " << fb->name() << "\n"; - stk_classic::mesh::Part * const fb_part = meta.get_part(fb->name()); - assert(fb_part != NULL); - meta.declare_part_subset(*fs_part, *fb_part); - - if (fb->field_exists("distribution_factors")) { - if (!surface_df_defined) { - std::string field_name = entity->name() + "_distribution_factors"; - distribution_factors_field = - &meta.declare_field >(field_name); - stk_classic::io::set_distribution_factor_field(*fs_part, *distribution_factors_field); - surface_df_defined = true; - } - stk_classic::io::set_distribution_factor_field(*fb_part, *distribution_factors_field); - int face_node_count = fb->topology()->number_nodes(); - meta.put_field(*distribution_factors_field, fb_part->primary_entity_type(), - *fb_part, face_node_count); - } - - // For this case we are just defining a field for each - // transient field that is present in the mesh... - stk_classic::io::define_io_fields(fb, Ioss::Field::TRANSIENT, - *fb_part, fb_part->primary_entity_type()); - } - } - } - - * \endcode - * \subsection process_facesets - * \code - void process_facesets(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::FaceSetContainer& face_sets = region.get_facesets(); - stk_classic::io::default_part_processing(face_sets, meta, stk_classic::mesh::Face); - - for(Ioss::FaceSetContainer::const_iterator it = face_sets.begin(); - it != face_sets.end(); ++it) { - Ioss::FaceSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, meta, stk_classic::mesh::Face); - } - } - } - - * \endcode - * \subsection process_edgesets - * \code - void process_edgesets(Ioss::Region ®ion, stk_classic::mesh::MetaData &meta) - { - const Ioss::EdgeSetContainer& edge_sets = region.get_edgesets(); - stk_classic::io::default_part_processing(edge_sets, meta, stk_classic::mesh::Edge); - - for(Ioss::EdgeSetContainer::const_iterator it = edge_sets.begin(); - it != edge_sets.end(); ++it) { - Ioss::EdgeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, meta, stk_classic::mesh::Edge); - } - } - } - * \endcode - * \section processing_details_bulkdata Entity Processing Routine Details -- BulkData - * \subsection process_nodeblocks - * \code - void process_nodeblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // This must be called after the "process_element_blocks" call - // since there may be nodes that exist in the database that are - // not part of the analysis mesh due to subsetting of the element - // blocks. - - const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); - assert(node_blocks.size() == 1); - - Ioss::NodeBlock *nb = node_blocks[0]; - - std::vector nodes; - stk_classic::io::get_entity_list(nb, stk_classic::mesh::Node, bulk, nodes); - - const stk_classic::mesh::MetaData& meta = MetaData::get(bulk); - - // NOTE: Application would probably store this field (and others) - // somewhere after the declaration instead of looking it up each - // time it is needed. - stk_classic::mesh::Field *coord_field = - meta.get_field >("coordinates"); - - stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates"); - } - - * \endcode - * \subsection process_elementblocks - * \code - void process_elementblocks(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks(); - - for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); - it != elem_blocks.end(); ++it) { - Ioss::ElementBlock *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string &name = entity->name(); - const stk_classic::mesh::MetaData& meta = MetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - - const CellTopologyData* cell_topo = stk_classic::mesh::get_cell_topology(*part); - assert(cell_topo != NULL); - - std::vector elem_ids ; - std::vector connectivity ; - - entity->get_field_data("ids", elem_ids); - entity->get_field_data("connectivity", connectivity); - - int element_count = elem_ids.size(); - int nodes_per_elem = cell_topo->node_count ; - - std::vector elements(element_count); - for(int i=0; ifield_describe(Ioss::Field::ATTRIBUTE, &names); - for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) { - if (*I == "attribute" && names.size() > 1) - continue; - stk_classic::mesh::FieldBase *field = meta.get_field(*I); - stk_classic::io::field_data_from_ioss(field, elements, entity, *I); - - } - } - } - } - - * \endcode - * \subsection process_nodesets - * \code - void process_nodesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - // Should only process nodes that have already been defined via the element - // blocks connectivity lists. - const Ioss::NodeSetContainer& node_sets = region.get_nodesets(); - - for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin(); - it != node_sets.end(); ++it) { - Ioss::NodeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - const std::string & name = entity->name(); - const stk_classic::mesh::MetaData& meta = MetaData::get(bulk); - stk_classic::mesh::Part* const part = meta.get_part(name); - assert(part != NULL); - stk_classic::mesh::PartVector add_parts( 1 , part ); - - std::vector node_ids ; - int node_count = entity->get_field_data("ids", node_ids); - - std::vector nodes(node_count); - for(int i=0; i *df_field = - meta.get_field >("distribution_factors"); - - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors"); - } - } - } - } - - * \endcode - * \subsection process_surface_entity - * \code - void process_surface_entity(const Ioss::GroupingEntity* io , - stk_classic::mesh::BulkData & bulk) - { - assert(io->type() == Ioss::FACESET || io->type() == Ioss::EDGESET); - const stk_classic::mesh::MetaData& meta = MetaData::get(bulk); - - int block_count = io->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *block = io->get_block(i); - if (stk_classic::io::include_entity(block)) { - std::vector side_ids ; - std::vector elem_side ; - - stk_classic::mesh::Part * const fb_part = meta.get_part(block->name()); - - block->get_field_data("ids", side_ids); - block->get_field_data("element_side", elem_side); - - assert(side_ids.size() * 2 == elem_side.size()); - stk_classic::mesh::PartVector add_parts( 1 , fb_part ); - - int side_count = side_ids.size(); - std::vector sides(side_count); - for(int is=0; is *df_field = - stk_classic::io::get_distribution_factor_field(*fb_part); - if (df_field != NULL) { - stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors"); - } - } - } - } - - * \endcode - * \subsection process_facesets - * \code - void process_facesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::FaceSetContainer& face_sets = region.get_facesets(); - - for(Ioss::FaceSetContainer::const_iterator it = face_sets.begin(); - it != face_sets.end(); ++it) { - Ioss::FaceSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } - } - - * \endcode - * \subsection process_edgesets - * \code - void process_edgesets(Ioss::Region ®ion, stk_classic::mesh::BulkData &bulk) - { - const Ioss::EdgeSetContainer& edge_sets = region.get_edgesets(); - - for(Ioss::EdgeSetContainer::const_iterator it = edge_sets.begin(); - it != edge_sets.end(); ++it) { - Ioss::EdgeSet *entity = *it; - - if (stk_classic::io::include_entity(entity)) { - process_surface_entity(entity, bulk); - } - } - } - - * \endcode - * \section process_field_data Entity Processing Routine Details -- Field Data to/from Ioss - * \code - void get_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityType part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData & meta = MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_from_ioss(f, entities, io_entity, f->name()); - } - } - } - - void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part, - stk_classic::mesh::EntityType part_type, - Ioss::GroupingEntity *io_entity, - Ioss::Field::RoleType filter_role) - { - std::vector entities; - stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities); - - stk_classic::mesh::MetaData & meta = MetaData::get(part); - stk_classic::mesh::Part &universal = meta.universal_part(); - const std::vector &fields = meta.get_fields(); - - std::vector::const_iterator I = fields.begin(); - while (I != fields.end()) { - const stk_classic::mesh::FieldBase *f = *I; ++I; - if (stk_classic::io::is_valid_part_field(f, part_type, part, universal, filter_role)) { - stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name()); - } - } - } - - * \endcode - * \section input_request Entity Processing Routine Details -- Input Request - * \code - void process_input_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData & meta = MetaData::get(bulk); - - // Get field data from nodeblock... - get_field_data(bulk, meta.universal_part(), stk_classic::mesh::Node, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - if (entity->type() == Ioss::FACESET || entity->type() == Ioss::EDGESET) { - int block_count = entity->block_count(); - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = entity->get_block(i); - // Real application would have different filtering mechanism - get_field_data(bulk, *part, part->primary_entity_type(), - fb, Ioss::Field::TRANSIENT); - } - } else { - get_field_data(bulk, *part, part->primary_entity_type(), - entity, Ioss::Field::TRANSIENT); - } - } - } - } - - region.end_state(step); - } - - * \endcode - * \section output_request Entity Processing Routine Details -- Output Request - * \code - void process_output_request(Ioss::Region ®ion, - stk_classic::mesh::BulkData &bulk, - int step) - { - region.begin_state(step); - // Special processing for nodeblock (all nodes in model)... - const stk_classic::mesh::MetaData & meta = MetaData::get(bulk); - - put_field_data(bulk, meta.universal_part(), stk_classic::mesh::Node, - region.get_node_blocks()[0], Ioss::Field::TRANSIENT); - - const stk_classic::mesh::PartVector & all_parts = meta.get_parts(); - for ( stk_classic::mesh::PartVector::const_iterator - ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { - - stk_classic::mesh::Part * const part = *ip; - - // Check whether this part should be output to results database. - if (stk_classic::io::is_part_io_part(*part)) { - - // Get Ioss::GroupingEntity corresponding to this part... - Ioss::GroupingEntity *entity = region.get_entity(part->name()); - if (entity != NULL) { - - if (entity->type() == Ioss::FACESET || entity->type() == Ioss::EDGESET) { - int block_count = entity->block_count(); - - for (int i=0; i < block_count; i++) { - Ioss::EntityBlock *fb = entity->get_block(i); - // Real application would have different filtering mechanism - put_field_data(bulk, *part, part->primary_entity_type(), - fb, Ioss::Field::TRANSIENT); - } - } else { - put_field_data(bulk, *part, part->primary_entity_type(), - entity, Ioss::Field::TRANSIENT); - } - } - } - } - region.end_state(step); - } -} -\endcode - */ diff --git a/packages/stk/stk_classic/stk_usecases/io/io_generated.cpp b/packages/stk/stk_classic/stk_usecases/io/io_generated.cpp deleted file mode 100644 index c213c56caacc..000000000000 --- a/packages/stk/stk_classic/stk_usecases/io/io_generated.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -namespace { - void driver(stk_classic::ParallelMachine comm, - size_t dimension, - const std::string &working_directory, - const std::string &filename, - const std::string &type, - const std::string &decomp_method, - int compression_level, - bool compression_shuffle, - int db_integer_size); -} - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - std::string working_directory = ""; - std::string decomp_method = ""; - std::string mesh = ""; - std::string type = "exodusii"; - size_t spatial_dimension = 3; - int compression_level = 0; - bool compression_shuffle = false; - int db_integer_size = 4; - - - //---------------------------------- - // Process the broadcast command line arguments - bopt::options_description desc("options"); - - // NOTE: Options --directory --output-log --runtest are handled/defined in UseCaseEnvironment - desc.add_options() - ("directory,d", bopt::value(&working_directory), - "working directory with trailing '/'" ) - ("decomposition,D", bopt::value(&decomp_method), - "decomposition method" ) - ("mesh", bopt::value(&mesh), - "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Can also specify a filename. The generated mesh will be output to the file 'generated_mesh.out'" ) - ("dimension", bopt::value(&spatial_dimension), "problem spatial dimension" ) - ("compression_level", bopt::value(&compression_level), "compression level [1..9] to use" ) - ("shuffle", bopt::value(&compression_shuffle), "use shuffle filter prior to compressing data" ) - ("db_integer_size", bopt::value(&db_integer_size), "use 4 or 8-byte integers on output database" ); - - - stk_classic::get_options_description().add(desc); - - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - if (mesh.empty()) { - std::cerr << "\nERROR: The --mesh option is required\n"; - std::cerr << "\nApplication " << desc << "\n"; - std::exit(EXIT_FAILURE); - } - - type = "exodusii"; - if (strncasecmp("gen:", mesh.c_str(), 4) == 0) { - mesh = mesh.substr(4, mesh.size()); - type = "generated"; - } - if (strncasecmp("dof:", mesh.c_str(), 4) == 0) { - mesh = mesh.substr(4, mesh.size()); - type = "dof"; - } - driver(use_case_environment.m_comm, spatial_dimension, - working_directory, mesh, type, decomp_method, - compression_level, compression_shuffle, db_integer_size); - - return 0; -} - -namespace { - void driver(stk_classic::ParallelMachine comm, - size_t spatial_dimension, - const std::string &working_directory, - const std::string &filename, - const std::string &type, - const std::string &decomp_method, - int compression_level, - bool compression_shuffle, - int db_integer_size) - { - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension ); - stk_classic::mesh::MetaData &meta_data = fem_meta_data.get_meta_data( fem_meta_data ); - stk_classic::io::MeshData mesh_data; - - bool use_netcdf4 = false; - if (!decomp_method.empty()) { - mesh_data.m_property_manager.add(Ioss::Property("DECOMPOSITION_METHOD", decomp_method)); - } - - if (compression_level > 0) { - mesh_data.m_property_manager.add(Ioss::Property("COMPRESSION_LEVEL", compression_level)); - use_netcdf4 = true; - } - if (compression_shuffle) { - mesh_data.m_property_manager.add(Ioss::Property("COMPRESSION_SHUFFLE", 1)); - use_netcdf4 = true; - } - if (use_netcdf4) { - mesh_data.m_property_manager.add(Ioss::Property("FILE_TYPE", "netcdf4")); - } - if (db_integer_size == 8) { - mesh_data.m_property_manager.add(Ioss::Property("INTEGER_SIZE_DB", db_integer_size)); - } - - std::string file = working_directory; - file += filename; - stk_classic::io::create_input_mesh(type, file, comm, fem_meta_data, mesh_data); - stk_classic::io::define_input_fields(mesh_data, fem_meta_data); - - fem_meta_data.commit(); - stk_classic::mesh::BulkData bulk_data(meta_data , comm); - stk_classic::io::populate_bulk_data(bulk_data, mesh_data); - - //------------------------------------------------------------------ - // Create output mesh... ("generated_mesh.out") ("exodus_mesh.out") - std::string output_filename = working_directory + type + "_mesh.out"; - stk_classic::io::create_output_mesh(output_filename, comm, bulk_data, mesh_data); - stk_classic::io::define_output_fields(mesh_data, fem_meta_data); - - // Determine number of timesteps on input database... - int timestep_count = mesh_data.m_input_region->get_property("state_count").get_int(); - for (int step=1; step <= timestep_count; step++) { - double time = mesh_data.m_input_region->get_state_time(step); - stk_classic::io::process_input_request(mesh_data, bulk_data, step); - stk_classic::io::process_output_request(mesh_data, bulk_data, time); - } - } -} diff --git a/packages/stk/stk_classic/stk_usecases/linsys/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/linsys/CMakeLists.txt deleted file mode 100644 index 86dc39cb5e16..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../fei) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_io) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_linsys) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_use_cases_linsys - SOURCES ${SOURCES} - DEPLIBS stkclassic_linsys stkclassic_io - ARGS "--use_case_1 --mesh gen:10x10x10+shell:y" - COMM serial mpi - NUM_MPI_PROCS 3 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_1.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_1.cpp deleted file mode 100644 index 838d1abda660..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_1.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 1: DOF mapping use case. -// The function 'use_case_1_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_1_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_1_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 1: DOF mapping. -// - -bool use_case_1_driver( MPI_Comm comm , - const std::string& mesh_options ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 1" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & universal = fem_meta.universal_part(); - stk_classic::mesh::Part & block_hex = fem_meta.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = fem_meta.declare_part("block_2", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // Put a scalar "pressure" field on all elements, just to use in demonstrating - // DOF mappings below: - - ScalarFieldType & pressure_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< ScalarFieldType >("pressure"), - element_rank, universal); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_1_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_1_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - mesh_bulk_data.modification_end(); - - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - stk_classic::linsys::DofMapper dof_mapper(comm); - - if (myProc == 0) { - std::cout << "Adding DOF mappings for displacements field for all locally-used " - << "(owned and shared) nodes..." << std::endl; - } - - const stk_classic::mesh::Selector select_used = - fem_meta.locally_owned_part() | - fem_meta.globally_shared_part(); - - dof_mapper.add_dof_mappings(mesh_bulk_data, select_used, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, displacements_field); - - if (myProc == 0) { - std::cout << "Adding DOF mappings for pressure field for all locally-owned " - << " elements..." << std::endl; - } - - stk_classic::mesh::Selector select_owned = fem_meta.locally_owned_part(); - dof_mapper.add_dof_mappings(mesh_bulk_data, select_owned, - element_rank, pressure_field); - - dof_mapper.finalize(); - - if (myProc == 0) { - std::cout << "Global Number of Indices: " - << dof_mapper.get_fei_VectorSpace()->getGlobalNumIndices() << std::endl; - } - - std::vector nodes; - stk_classic::mesh::get_entities(mesh_bulk_data, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodes); - - std::vector elems; - stk_classic::mesh::get_entities(mesh_bulk_data, element_rank, elems); - - int global_index = 0; - - for(size_t i=0; ibucket())) continue; - - global_index = dof_mapper.get_global_index(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodes[i]->identifier(), displacements_field); - std::cout << "Proc " << myProc << ", global index for node " << nodes[i]->identifier() - << ", field '"<bucket().member(fem_meta.locally_owned_part())) continue; - - global_index = dof_mapper.get_global_index(element_rank, elems[i]->identifier(), pressure_field); - std::cout << "Proc " << myProc << ", global index for element " << elems[i]->identifier() - << ", field '"<getGlobalNumIndices() == 5093; - } - return true; - } -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_1_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_1_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_2.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_2.cpp deleted file mode 100644 index 17d9daf638f2..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_2.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 1: DOF mapping use case. -// The function 'use_case_2_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_2_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_2_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 1: DOF mapping. -// - -bool use_case_2_driver( MPI_Comm comm , - const std::string& mesh_options ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 1" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & universal = fem_meta.universal_part(); - stk_classic::mesh::Part & block_hex = fem_meta.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = fem_meta.declare_part("block_2", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // Put a scalar "pressure" field on all elements, just to use in demonstrating - // DOF mappings below: - - ScalarFieldType & pressure_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< ScalarFieldType >("pressure"), - element_rank, universal); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_2_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_2_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - mesh_bulk_data.modification_end(); - - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - stk_classic::linsys::DofMapper dof_mapper(comm); - - if (myProc == 0) { - std::cout << "Adding DOF mappings for displacements field for all locally-used " - << "(owned and shared) nodes..." << std::endl; - } - - stk_classic::mesh::Selector owned_and_shared = - fem_meta.locally_owned_part() | - fem_meta.globally_shared_part(); - - dof_mapper.add_dof_mappings(mesh_bulk_data, owned_and_shared, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, displacements_field); - - if (myProc == 0) { - std::cout << "Adding DOF mappings for pressure field for all locally-owned " - << " elements..." << std::endl; - } - - stk_classic::mesh::Selector select_owned = fem_meta.locally_owned_part(); - dof_mapper.add_dof_mappings(mesh_bulk_data, select_owned, - element_rank, pressure_field); - - dof_mapper.finalize(); - - if (myProc == 0) { - std::cout << "Global Number of Indices: " - << dof_mapper.get_fei_VectorSpace()->getGlobalNumIndices() << std::endl; - } - - std::vector nodes; - stk_classic::mesh::get_entities(mesh_bulk_data, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodes); - - std::vector elems; - stk_classic::mesh::get_entities(mesh_bulk_data, element_rank, elems); - - //The object of this use-case is to perform reverse-lookups. i.e., given a - //global_index, query to obtain entity type/id info. - //To verify correctness we will first query to obtain the global_index, then do - //the reverse-lookup and make sure we get back the right values. - - int global_index = 0; - - for(size_t i=0; ibucket())) continue; - - global_index = dof_mapper.get_global_index(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodes[i]->identifier(), displacements_field); - std::cout << "Proc " << myProc << ", global index for node " << nodes[i]->identifier() - << ", field '"<identifier() || - field->name() != displacements_field.name()) { - std::cout << "Reverse-lookup Test Failed" << std::endl; - } - } - - for(size_t i=0; ibucket().member(fem_meta.locally_owned_part())) continue; - - global_index = dof_mapper.get_global_index(element_rank, elems[i]->identifier(), pressure_field); - std::cout << "Proc " << myProc << ", global index for element " << elems[i]->identifier() - << ", field '"<identifier() || - field->name() != pressure_field.name()) { - std::cout << "Reverse-lookup Test Failed" << std::endl; - } - } - - if (mesh_options == "10x10x10+shell:y") { - return dof_mapper.get_fei_VectorSpace()->getGlobalNumIndices() == 5093; - } - return true; - } -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_2_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_2_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem, 0 ); - std::vector elem_conn( num_elem * top_info.second, 0 ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_3.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_3.cpp deleted file mode 100644 index 790e0852609b..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_3.cpp +++ /dev/null @@ -1,478 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 1: DOF mapping use case. -// The function 'use_case_3_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_3_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_3_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 1: DOF mapping. -// - -bool use_case_3_driver( MPI_Comm comm , - const std::string& mesh_options ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 3" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & universal = fem_meta.universal_part(); - stk_classic::mesh::Part & block_hex = fem_meta.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = fem_meta.declare_part("block_2", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // Put a scalar "pressure" field on all elements, just to use in demonstrating - // DOF mappings below: - - // ScalarFieldType & pressure_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< ScalarFieldType >("pressure"), - element_rank, universal); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_3_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_3_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - mesh_bulk_data.modification_end(); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( mesh_bulk_data ); - - - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - stk_classic::mesh::Selector select_owned = fem_meta.locally_owned_part(); - - fei::SharedPtr feifactory(new Factory_Trilinos(comm)); - stk_classic::linsys::LinearSystem ls(comm, feifactory); - - if (myProc == 0) { - std::cout << "Adding element-node connectivities for displacements field for all locally-owned " - << "elements..." << std::endl; - } - - stk_classic::linsys::add_connectivities(ls, element_rank, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, select_owned, mesh_bulk_data); - - ls.synchronize_mappings_and_structure(); - - ls.create_fei_LinearSystem(); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - fei::SharedPtr rhs = ls.get_fei_LinearSystem()->getRHS(); - - { - const std::vector& mesh_buckets = mesh_bulk_data.buckets(element_rank); - std::vector part_buckets; - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - int field_id = dof_mapper.get_field_id(displacements_field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - int pattern_id = matgraph->definePattern(num_nodes_per_elem, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix->sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs->sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } - } - - ls.finalize_assembly(); - - matrix->writeToFile("A.mtx"); - rhs->writeToFile("rhs.vec"); - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_3_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_3_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_4.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_4.cpp deleted file mode 100644 index fb510e40a29c..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_4.cpp +++ /dev/null @@ -1,500 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 1: DOF mapping use case. -// The function 'use_case_4_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_4_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_4_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 1: DOF mapping. -// - -bool use_case_4_driver( MPI_Comm comm , - const std::string& mesh_options ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 1" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData fem_meta; - fem_meta.FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - const stk_classic::mesh::EntityRank element_rank = fem_meta.element_rank(); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & universal = fem_meta.universal_part(); - stk_classic::mesh::Part & block_hex = fem_meta.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = fem_meta.declare_part("block_2", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // Put a scalar "pressure" field on all elements, just to use in demonstrating - // DOF mappings below: - -// ScalarFieldType & pressure_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< ScalarFieldType >("pressure"), - element_rank, universal); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - stk_classic::mesh::Part& bcpart = fem_meta.declare_part("bcpart"); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_4_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_4_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - //Add a node to our boundary-condition part 'bcpart'. - //let's choose the first locally-owned node. (This will produce a - //different boundary-condition for different numbers of processors... - //A more realistic case would simply pick a specific set of nodes - //regardless of which processors they are on.) - - mesh_bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(fem_meta.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - mesh_bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), - local_nodes); - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - mesh_bulk_data.change_entity_parts(*local_nodes[0], partvector); - } - - mesh_bulk_data.modification_end(); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( mesh_bulk_data ); - - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - fei::SharedPtr feifactory(new Factory_Trilinos(comm)); - stk_classic::linsys::LinearSystem ls(comm, feifactory); - - if (myProc == 0) { - std::cout << "Adding element-node connectivities for displacements field for all locally-owned " - << "elements..." << std::endl; - } - - stk_classic::linsys::add_connectivities(ls, element_rank, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, select_owned, mesh_bulk_data); - - ls.synchronize_mappings_and_structure(); - - ls.create_fei_LinearSystem(); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - fei::SharedPtr rhs = ls.get_fei_LinearSystem()->getRHS(); - - { - const std::vector& mesh_buckets = mesh_bulk_data.buckets(element_rank); - std::vector part_buckets; - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - int field_id = dof_mapper.get_field_id(displacements_field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - int pattern_id = matgraph->definePattern(num_nodes_per_elem, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix->sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs->sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } - - } - - stk_classic::linsys::dirichlet_bc(ls, mesh_bulk_data, bcpart, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, 0, 3.14159265); - - ls.finalize_assembly(); - - matrix->writeToFile("A.mtx"); - rhs->writeToFile("rhs.vec"); - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_4_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_4_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_5.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_5.cpp deleted file mode 100644 index 56c1ac2537dd..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_5.cpp +++ /dev/null @@ -1,557 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 5: Assemble & solve linear-system. -// The function 'use_case_5_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_5_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_5_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 5: Linear-system assemble & solve. -// - -bool use_case_5_driver( MPI_Comm comm , - const std::string& mesh_options, - const std::string& solver_params ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 5" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData fem_meta(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim) ) ; - Ioss::Init::Initializer init_db; - - stk_classic::mesh::MetaData & mesh_meta_data = stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta); - - { - const stk_classic::mesh::fem::FEMMetaData &fmd = fem_meta.get ( mesh_meta_data ); - std::cout < >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - stk_classic::io::put_io_part_attribute(block_hex); - stk_classic::io::put_io_part_attribute(block_quad_shell); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - fem_meta.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - stk_classic::mesh::Part& bcpart = fem_meta.declare_part("bcpart"); - - // Define the transient fields that will be output. - stk_classic::io::set_field_role(displacements_field, Ioss::Field::TRANSIENT); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - fem_meta.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_5_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_5_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - //Add a node to our boundary-condition part 'bcpart'. - //let's choose the first locally-owned node. (This will produce a - //different boundary-condition for different numbers of processors... - //A more realistic case would simply pick a specific set of nodes - //regardless of which processors they are on.) - - mesh_bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(fem_meta.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - mesh_bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), - local_nodes); - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - mesh_bulk_data.change_entity_parts(*local_nodes[0], partvector); - } - - mesh_bulk_data.modification_end(); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( mesh_bulk_data ); - - //Note: set_owners should throw an error if not done inside a modification_begin/end block. - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - //Now begin the use-case: - //Create a fei::Factory of type Factory_Trilinos, which will produce - //fei::Matrix and fei::Vector objects with run-time-type compatible with Trilinos. - - fei::SharedPtr feifactory(new Factory_Trilinos(comm)); - stk_classic::linsys::LinearSystem ls(comm, feifactory); - - if (myProc == 0) { - std::cout << "Adding element-node connectivities for displacements field for all locally-owned " - << "elements..." << std::endl; - } - - //Add connectivities for our mesh to the linsys::LinearSystem object. This - //will enable us to generate a matrix-graph: - - stk_classic::linsys::add_connectivities(ls, element_rank, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, select_owned, mesh_bulk_data); - - ls.synchronize_mappings_and_structure(); - - ls.create_fei_LinearSystem(); - - fei::SharedPtr matgraph = ls.get_fei_MatrixGraph(); - fei::SharedPtr matrix = ls.get_fei_LinearSystem()->getMatrix(); - fei::SharedPtr rhs = ls.get_fei_LinearSystem()->getRHS(); - fei::SharedPtr solution = ls.get_fei_LinearSystem()->getSolutionVector(); - - //Now we'll run through the mesh and load up dense element-matrices and element-vectors - //to assemble into the global sparse linear-system: - { - const std::vector& mesh_buckets = mesh_bulk_data.buckets(element_rank); - std::vector part_buckets; - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - int field_id = dof_mapper.get_field_id(displacements_field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - int pattern_id = matgraph->definePattern(num_nodes_per_elem, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix->sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs->sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } - - stk_classic::linsys::dirichlet_bc(ls, mesh_bulk_data, bcpart, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, 0, 3.14159265); - - ls.finalize_assembly(); - - //Read solver-parameters out of a file. In a real application this would - //be done during a parsing phase, *not* here in the assembly code. - - Teuchos::ParameterList params; - if (solver_params != "") { - Teuchos::ParameterXMLFileReader param_file(solver_params); - params = param_file.getParameters(); - } - - //Launch the linear-solver: - int status = 0, ret; - ret = ls.solve(status, params); - - if (ret != 0) { - throw std::runtime_error("Error in the linear solver."); - } - - //Copy the contents of the solution-vector back into our mesh-data: - copy_vector_to_mesh( *solution, dof_mapper, mesh_bulk_data); - } - - //This following section writes mesh data out to an exodus file: - { - const std::string out_filename("mesh.e"); - - stk_classic::io::MeshData mesh; - stk_classic::io::create_output_mesh(out_filename, comm, mesh_bulk_data, mesh); - stk_classic::io::define_output_fields(mesh, fem_meta); - - // Write the model to the mesh file (topology, coordinates, attributes, etc) - stk_classic::io::process_output_request(mesh, mesh_bulk_data, 0.0); - } - - //Write out our assembled linear-system to files: - - matrix->writeToFile("A.mtx"); - rhs->writeToFile("rhs.vec"); - solution->writeToFile("solution.vec"); - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_5_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_5_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_7.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_7.cpp deleted file mode 100644 index 2427a007a464..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_7.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 7: Assemble & solve linear-system -// which is a linear-combination of several separately-assembled matrices and vectors. -// The function 'use_case_7_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_linsys_usecases { - -enum { SpatialDim = 3 }; -enum { MaximumEntityRank = 6 }; - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field VectorFieldType ; -typedef stk_classic::mesh::Field ScalarFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_7_generate_mesh( - const std::string& mesh_options, - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ); - -void use_case_7_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ); - -void assemble_elem_matrices_and_vectors(stk_classic::mesh::BulkData& mesh, - stk_classic::mesh::FieldBase& field, - stk_classic::linsys::DofMapper& dof_mapper, - fei::Matrix& matrix, - fei::Vector& rhs); - -//-------------------------------------------------------------------- -// -// main driver for use-case 7: Aggregate Linear-system assemble & solve. -// - -bool use_case_7_driver( MPI_Comm comm , - const std::string& mesh_options, - const std::string& solver_params ) -{ - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_linsys use case 7" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data: element blocks and associated fields - - stk_classic::mesh::fem::FEMMetaData mesh_meta_data( SpatialDim ) ; - Ioss::Init::Initializer init_db; - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - const stk_classic::mesh::EntityRank element_rank = mesh_meta_data.element_rank(); - stk_classic::mesh::Part & universal = mesh_meta_data.universal_part(); - stk_classic::mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad_shell = mesh_meta_data.declare_part("block_2", element_rank); - - - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology qshell_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad_shell, qshell_top ); - - stk_classic::io::put_io_part_attribute(block_hex); - stk_classic::io::put_io_part_attribute(block_quad_shell); - - //-------------------------------- - // Declaring fields of specified types on all nodes: - - VectorFieldType & coordinates_field = - stk_classic::mesh::put_field( - mesh_meta_data.declare_field< VectorFieldType >( "coordinates" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - VectorFieldType & displacements_field = - stk_classic::mesh::put_field( - mesh_meta_data.declare_field< VectorFieldType >( "displacements" ) , - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - // rotation_field only exists on the shell-nodes: - - // NOTE: This isn't working; in use_case_7_initialize_data, 'rotat' is always null.... - VectorFieldType & rotation_field = - stk_classic::mesh::put_field( - mesh_meta_data.declare_field< VectorFieldType >( "rotation" ), - stk_classic::mesh::fem::FEMMetaData::NODE_RANK , block_quad_shell , SpatialDim ); - - stk_classic::mesh::Part& bcpart = mesh_meta_data.declare_part("bcpart"); - - // Define the transient fields that will be output. - stk_classic::io::set_field_role(displacements_field, Ioss::Field::TRANSIENT); - stk_classic::io::set_field_role(rotation_field, Ioss::Field::TRANSIENT); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - // stk_classic::mesh::BulkData bulk data conforming to the meta data. - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data.get_meta_data(mesh_meta_data) , comm ); - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_7_generate_mesh( - mesh_options , - mesh_bulk_data , - coordinates_field , - block_hex , - block_quad_shell ); - - use_case_7_initialize_data( - mesh_bulk_data , - coordinates_field , - displacements_field , - rotation_field ); - - //Add a node to our boundary-condition part 'bcpart'. - //let's choose the first locally-owned node. (This will produce a - //different boundary-condition for different numbers of processors... - //A more realistic case would simply pick a specific set of nodes - //regardless of which processors they are on.) - - mesh_bulk_data.modification_begin(); - - std::vector local_nodes; - stk_classic::mesh::Selector select_owned(mesh_meta_data.locally_owned_part()); - stk_classic::mesh::get_selected_entities(select_owned, - mesh_bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), - local_nodes); - - if (local_nodes.size() > 0) { - stk_classic::mesh::PartVector partvector; - partvector.push_back(&bcpart); - mesh_bulk_data.change_entity_parts(*local_nodes[0], partvector); - } - - mesh_bulk_data.modification_end(); - - //set owner-processors to lowest-sharing (stk_classic::mesh defaults to - //highest-sharing) If highest-sharing owns, then it isn't correct for the - //way the fei library sets ownership of shared nodes for vectors etc. - stk_classic::mesh::set_owners( mesh_bulk_data ); - -//Note: set_owners should throw an error if not done inside a modification_begin/end block. - //------------------------------------------------------------------ - - const unsigned myProc = mesh_bulk_data.parallel_rank(); - - //Now begin the use-case: - //Create a fei::Factory of type Factory_Trilinos, which will produce - //fei::Matrix and fei::Vector objects with run-time-type compatible with Trilinos. - - fei::SharedPtr feifactory(new Factory_Trilinos(comm)); - - size_t num_matrices = 2; - size_t num_rhsvectors = 2; - stk_classic::linsys::AggregateLinearSystem ls(comm, feifactory, num_matrices, num_rhsvectors); - - if (myProc == 0) { - std::cout << "Adding element-node connectivities for displacements field for all locally-owned " - << "elements..." << std::endl; - } - - //Add connectivities for our mesh to the linsys::LinearSystem object. This - //will enable us to generate a matrix-graph: - - stk_classic::linsys::add_connectivities(ls, element_rank, - stk_classic::mesh::fem::FEMMetaData::NODE_RANK, - displacements_field, select_owned, mesh_bulk_data); - - ls.synchronize_mappings_and_structure(); - - ls.create_fei_LinearSystem(); - stk_classic::linsys::DofMapper& dof_mapper = ls.get_DofMapper(); - - for(size_t i=0; i matrix = ls.get_matrix(i); - fei::SharedPtr rhs = ls.get_rhsvec(i); - - //assemble element sub-matrices and sub-vectors into the global sparse matrix "i" and - //rhs-vector "i". - assemble_elem_matrices_and_vectors(mesh_bulk_data, displacements_field, dof_mapper, *matrix, *rhs); - //Write out our assembled matrix and vector to files: - - //is there a better way to add an int to a string? - std::stringstream ssA; - ssA << "A_" << i << ".mtx"; - std::string Aname; - ssA >> Aname; - matrix->writeToFile(Aname.c_str()); - - std::stringstream ss_rhs; - ss_rhs << "rhs_" << i << ".vec"; - std::string rhsname; - ss_rhs >> rhsname; - rhs->writeToFile(rhsname.c_str()); - } - - //Read solver-parameters out of a file. In a real application this would - //be done during a parsing phase, *not* here in the assembly code. - - Teuchos::ParameterList params; - if (solver_params != "") { - Teuchos::ParameterXMLFileReader param_file(solver_params); - params = param_file.getParameters(); - } - - std::vector mat_scalars(num_matrices, 1.0); - std::vector rhs_scalars(num_rhsvectors, 1.0); - - size_t num_solves = 2; - for(size_t i=0; i solution = ls.get_fei_LinearSystem()->getSolutionVector(); - //Copy the contents of the solution-vector back into our mesh-data: - stk_classic::linsys::copy_vector_to_mesh( *solution, dof_mapper, mesh_bulk_data); - - std::stringstream sstr; - sstr << "solution_" << i << ".vec"; - std::string s; - sstr >> s; - solution->writeToFile(s.c_str()); - } - - //This following section writes mesh data out to an exodus file: - { - const std::string out_filename("mesh.e"); - - stk_classic::io::MeshData mesh; - stk_classic::io::create_output_mesh(out_filename, comm, mesh_bulk_data, mesh); - stk_classic::io::define_output_fields(mesh, mesh_meta_data); - stk_classic::io::process_output_request(mesh, mesh_bulk_data, 0.0); - } - } - return true; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_7_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - const VectorFieldType & node_displ , - const VectorFieldType & node_rotat ) -{ - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - const unsigned length_3 = length * 3 ; - - double * const coord = stk_classic::mesh::field_data( node_coord , bucket.begin() ); - double * const displ = stk_classic::mesh::field_data( node_displ , bucket.begin() ); - double * const rotat = stk_classic::mesh::field_data( node_rotat , bucket.begin() ); - - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - displ[i] = 0.1 * coord[i] ; - } - - if ( rotat ) { - for ( unsigned i = 0 ; i < length_3 ; ++i ) { - rotat[i] = 0.01 * coord[i] ; - } - } - } -} - -} // namespace stk_linsys_usecases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_linsys_usecases { - -void use_case_7_generate_mesh( - const std::string& mesh_options , - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & node_coord , - stk_classic::mesh::Part & hex_block , - stk_classic::mesh::Part & quad_shell_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.element_map( i, elem_map ); - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - else if ( top_info.second == 4 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 4 ] ; - - const stk_classic::mesh::EntityId node_id[4] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id ); - - ++num_shell ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -void assemble_elem_matrices_and_vectors(stk_classic::mesh::BulkData& mesh, - stk_classic::mesh::FieldBase& field, - stk_classic::linsys::DofMapper& dof_mapper, - fei::Matrix& matrix, - fei::Vector& rhs) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - - const std::vector& mesh_buckets = mesh.buckets(element_rank); - - std::vector part_buckets; - stk_classic::mesh::Selector select_owned(stk_classic::mesh::MetaData::get(mesh).locally_owned_part()); - stk_classic::mesh::get_buckets(select_owned, mesh_buckets, part_buckets); - - int field_id = dof_mapper.get_field_id(field); - - stk_classic::mesh::Entity& first_entity = *(part_buckets[0]->begin()); - stk_classic::mesh::PairIterRelation rel = first_entity.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - int num_nodes_per_elem = rel.second - rel.first; - - fei::SharedPtr matgraph = matrix.getMatrixGraph(); - int pattern_id = matgraph->definePattern(num_nodes_per_elem, stk_classic::mesh::fem::FEMMetaData::NODE_RANK, field_id); - - std::vector node_ids(num_nodes_per_elem); - - const int field_size = dof_mapper.get_fei_VectorSpace()->getFieldSize(field_id); - const int matsize = num_nodes_per_elem*field_size*num_nodes_per_elem*field_size; - const int vecsize = num_nodes_per_elem*field_size; - - std::vector elem_matrix_1d(matsize, 0); - std::vector elem_matrix_2d(vecsize); - - std::vector elem_vector(vecsize, 0); - - for(size_t i=0; i=1) row[i-1] = -1; - row[i] = 2; - if (i eqn_indices(vecsize); - - for(size_t i=0; ibegin(), - b_end = part_buckets[i]->end(); - for(; b_iter != b_end; ++b_iter) { - stk_classic::mesh::Entity& elem = *b_iter; - rel = elem.relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - for(int j=0; rel.first != rel.second; ++rel.first, ++j) { - node_ids[j] = rel.first->entity()->identifier(); - } - - matgraph->getPatternIndices(pattern_id, &node_ids[0], eqn_indices); - - matrix.sumIn(vecsize, &eqn_indices[0], vecsize, &eqn_indices[0], - &elem_matrix_2d[0]); - rhs.sumIn(vecsize, &eqn_indices[0], &elem_vector[0]); - } - } -} - -} // namespace stk_linsys_usecases - diff --git a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_driver.cpp b/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_driver.cpp deleted file mode 100644 index 4a91a47027c5..000000000000 --- a/packages/stk/stk_classic/stk_usecases/linsys/LinsysUseCase_driver.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include - -#include - -namespace stk_linsys_usecases { - -bool use_case_1_driver( MPI_Comm comm , - const std::string &mesh_filename ); - -bool use_case_2_driver( MPI_Comm comm , - const std::string &mesh_filename ); - -bool use_case_3_driver( MPI_Comm comm , - const std::string &mesh_filename ); - -bool use_case_4_driver( MPI_Comm comm , - const std::string &mesh_filename ); - -bool use_case_5_driver( MPI_Comm comm , - const std::string &mesh_filename, - const std::string & solver_params ); - -bool use_case_7_driver( MPI_Comm comm , - const std::string &mesh_filename, - const std::string & solver_params ); - -} // namespace stk_linsys_usecases - - -namespace { - const char use_case_1[] = "use_case_1" ; - const char use_case_2[] = "use_case_2" ; - const char use_case_3[] = "use_case_3" ; - const char use_case_4[] = "use_case_4" ; - const char use_case_5[] = "use_case_5" ; - const char use_case_7[] = "use_case_7" ; -} - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - stk_classic::ParallelMachine comm = use_case_environment.m_comm; - - //---------------------------------- - // Broadcast argc and argv to all processors. - - stk_classic::BroadcastArg b_arg(comm, argc, argv); - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("options"); - - stk_classic::get_options_description().add(desc); - - int nthreads = 1; - int bucket_size = 1000; - - desc.add_options() - ("help,h", "produce help message") - ("mesh,m", bopt::value(), "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("directory,d", bopt::value(), "working directory with trailing '/'" ) - ("output-log,o", bopt::value(), "output log path" ) - ("runtest,r", bopt::value(), "runtest pid file" ) - ("threads", bopt::value(&nthreads)->default_value(1), "number of threads") - ("bucket_size", bopt::value(&bucket_size)->default_value(1000), "size of buckets used internally in stk_classic::mesh") - ("tbb", "Use Threaded Building Blocks algorithm thread runner") - ("tpi", "Use Thread Pool Interface algorithm thread runner") - ("nonthreaded", "Run algorithms non-threaded [default]") - ("solver_params", "Teuchos parameter XML filename") - ( use_case_1 , "use case 1" ) - ( use_case_2 , "use case 2" ) - ( use_case_3 , "use case 3" ) - ( use_case_4 , "use case 4" ) - ( use_case_5 , "use case 5" ) - ( use_case_7 , "use case 7" ); - - bopt::variables_map vm; - try { - bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm); - bopt::notify(vm); - } - catch (std::exception &x) { - std::cout << x.what() << std::endl; - std::cout << "Test Failed" << std::endl; - stk_classic::parallel_machine_finalize(); - std::exit(1); - } - - - //---------------------------------- - - if (vm.count("help")) { - std::cout << desc << "\n"; - std::exit(EXIT_SUCCESS); - } - - std::string thread_runner = "NonThreaded"; - if (vm.count("tbb")) - thread_runner = "TBB"; - if (vm.count("tpi")) - thread_runner = "TPI"; - if (vm.count("nonthreaded")) - thread_runner = "NonThreaded"; - - // Used by multiple use cases. - std::string working_directory = ""; - std::string in_filename = ""; - std::string in_filetype = "exodusii"; - if (vm.count("mesh")) { - in_filename = boost::any_cast(vm["mesh"].value()); - - if (strncasecmp("gen:", in_filename.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - in_filename = in_filename.substr(4, in_filename.size()); - in_filetype = "generated"; - } - - if (strncasecmp("gears:", in_filename.c_str(), 6) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - in_filename = in_filename.substr(6, in_filename.size()); - in_filetype = "gears"; - } - - if (vm.count("directory")) { - working_directory = boost::any_cast(vm["directory"].value()); - } - } else { - std::cout << "OPTION ERROR: The '--mesh ' option is required for all use cases!\n"; - std::exit(EXIT_FAILURE); - } - - bool success = false; - - if ( vm.count( use_case_1 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 1, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_linsys_usecases::use_case_1_driver( comm , in_filename ); - } - else if ( vm.count( use_case_2 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 2, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_linsys_usecases::use_case_2_driver( comm , in_filename ); - } - else if ( vm.count( use_case_3 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 3, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_linsys_usecases::use_case_3_driver( comm , in_filename ); - } - else if ( vm.count( use_case_4 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 4, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - success = stk_linsys_usecases::use_case_4_driver( comm , in_filename ); - } - else if ( vm.count( use_case_5 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 5, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - std::string solver_params = ""; - - if( vm.count("solver_params")) { - solver_params = boost::any_cast(vm["solver_params"].value()); - } - - success = stk_linsys_usecases::use_case_5_driver( comm , in_filename, solver_params ); - } - else if ( vm.count( use_case_7 ) ) { - - if (in_filetype != "generated") { - std::cout << "OPTION ERROR: For use case 7, only the 'generated' mesh option is supported!\n"; - std::exit(EXIT_FAILURE); - } - - std::string solver_params = ""; - - if( vm.count("solver_params")) { - solver_params = boost::any_cast(vm["solver_params"].value()); - } - - success = stk_linsys_usecases::use_case_7_driver( comm , in_filename, solver_params ); - } - else { - std::cout << "OPTION ERROR: Missing a use case selection option. Use --help option to see valid options.\n"; - std::exit(EXIT_FAILURE); - } - - use_case::print_status(comm, success); - - return 0; -} - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/mesh/CMakeLists.txt deleted file mode 100644 index 50a8736be053..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_use_cases_mesh - SOURCES ${SOURCES} -# DEPLIBS stk_util_use_cases - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/MeshUseCaseMain.cpp b/packages/stk/stk_classic/stk_usecases/mesh/MeshUseCaseMain.cpp deleted file mode 100644 index 5531e299d39c..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/MeshUseCaseMain.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include - -// Prototypes for use-case driver functions -// (the functions live in UseCase_*.cpp). - -namespace stk_use_cases { -void use_case_13_driver( stk_classic::ParallelMachine ); -}//namespace stk_use_cases - -namespace stk_classic { -namespace app { - -void use_case_14_driver( stk_classic::ParallelMachine, bool run_performance_test ); -void use_case_23_driver( stk_classic::ParallelMachine, bool run_performance_test ); -void use_case_AD_driver( stk_classic::ParallelMachine, bool run_performance_test ); - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- - -int -main( - int argc, - char ** argv) -{ - // Add my command line options to the option descriptions. - boost::program_options::options_description desc("Use case options"); - desc.add_options() - ("performance", "run performance test") - ( "use_case_13" , "use case 13" ) - ( "use_case_14" , "use case 14" ) - ( "use_case_23" , "use case 23" ) - ( "use_case_AD" , "use case AD" ) - ("mesh", boost::program_options::value(), "run mesh file performance test"); - - stk_classic::get_options_description().add(desc); - - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - boost::program_options::variables_map &vm = stk_classic::get_variables_map(); - - stk_classic::ParallelMachine parallel_machine = use_case_environment.m_comm; - - // Now call the use-case drivers based on command line options - - bool run_performance_case = vm.count("performance") != 0; - - if (vm.count("use_case_13")) { - stk_use_cases::use_case_13_driver( parallel_machine ); - } - else if (vm.count("use_case_14")) { - stk_classic::app::use_case_14_driver( parallel_machine, run_performance_case ); - } - else if (vm.count("use_case_23")) { - stk_classic::app::use_case_23_driver( parallel_machine, run_performance_case ); - } - else if (vm.count("use_case_AD")) { - stk_classic::app::use_case_AD_driver( parallel_machine, run_performance_case ); - } - else { - stk_use_cases::use_case_13_driver( parallel_machine ); - stk_classic::app::use_case_14_driver( parallel_machine, run_performance_case ); - stk_classic::app::use_case_23_driver( parallel_machine, run_performance_case ); - stk_classic::app::use_case_AD_driver( parallel_machine, run_performance_case ); - } - - // If we've made it this far, the use-case has passed - use_case::print_status(parallel_machine, true); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_13.cpp b/packages/stk/stk_classic/stk_usecases/mesh/UseCase_13.cpp deleted file mode 100644 index 5144bb005271..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_13.cpp +++ /dev/null @@ -1,713 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -using namespace stk_classic ; - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 13 -// The function 'use_case_13_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_use_cases { - -enum { SpatialDim = 3 }; - -//---------------------------------------------------------------------- - -typedef mesh::Field ScalarFieldType ; -typedef mesh::Field VectorFieldType ; - -// Specification for the aggressive gather pointer-field for elements. - -typedef mesh::Field ElementNodePointerFieldType ; - -//-------------------------------- -// prototype for the function that will generate the use-case mesh. - -void use_case_13_generate_mesh( - mesh::BulkData & mesh , - const unsigned N[] , - const VectorFieldType & node_coord , - const ElementNodePointerFieldType & elem_node_coord , - mesh::Part & hex_block ); - -void use_case_13_generate_sides( - mesh::BulkData & mesh , const bool skin_only ); - -void use_case_13_algorithm( mesh::BulkData & , - const unsigned side_type , - const VectorFieldType & side_field , - const VectorFieldType & elem_field ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 13: heterogeneous element mesh. -// - -void use_case_13_driver( MPI_Comm comm ) -{ - const unsigned p_rank = parallel_machine_rank( comm ); - - reset_malloc_stats(); - - const unsigned box_size[3] = { 20 , 20 , 20 }; - - //-------------------------------------------------------------------- - - if ( ! p_rank ) { - std::cout << "stk_mesh Use Case #13, begin" << std::endl - << " Number Processes = " << parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - { - //------------------------------------------------------------------ - // Declare the mesh meta data and bulk data. - - mesh::fem::FEMMetaData mesh_meta_data( SpatialDim ); - const stk_classic::mesh::EntityRank element_rank = mesh_meta_data.element_rank(); - const stk_classic::mesh::EntityRank side_rank = mesh_meta_data.side_rank(); - const stk_classic::mesh::EntityRank edge_rank = mesh_meta_data.edge_rank(); - mesh::BulkData mesh_bulk_data( mesh_meta_data.get_meta_data(mesh_meta_data) , MPI_COMM_WORLD ); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - mesh::Part & universal = mesh_meta_data.universal_part(); - mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", element_rank); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - mesh::fem::set_cell_topology(block_hex, hex_top ); - - //-------------------------------- - // Declare coordinates field on all nodes with 3D: - - VectorFieldType & coordinates_field = - mesh_meta_data.declare_field< VectorFieldType >( "coordinates" ); - - stk_classic::mesh::put_field( - coordinates_field , mesh::fem::FEMMetaData::NODE_RANK , universal , SpatialDim ); - - //-------------------------------- - - VectorFieldType & face_field = - mesh_meta_data.declare_field< VectorFieldType >( "face_flux" ); - - VectorFieldType & elem_field = - mesh_meta_data.declare_field< VectorFieldType >( "elem_flux" ); - - stk_classic::mesh::put_field(elem_field , element_rank , block_hex , SpatialDim ); - - stk_classic::mesh::put_field(face_field , side_rank , universal , SpatialDim ); - - //-------------------------------- - // Declare an aggressive "gather" field which is an - // array of pointers to the element's nodes' coordinate field data. - // The declaration specifies: - // - // double * elem_node_coord[number_of_nodes] - - ElementNodePointerFieldType & elem_node_coord = - mesh_meta_data. - declare_field< ElementNodePointerFieldType >( "elem_node_coord" ); - - // Declare that the 'elem_node_coord' pointer field data - // points to the 'coordinates_field' data on the nodes. - - mesh_meta_data.declare_field_relation( - elem_node_coord , - mesh::fem::get_element_node_stencil(SpatialDim) , - coordinates_field ); - - // Declare the size of the aggressive "gather" field - // double * elem_node_coord[ size = number_of_nodes ] - // is the number of nodes of the elements. - // This size is different for each element block. - - stk_classic::mesh::put_field( - elem_node_coord , element_rank, block_hex , shards::Hexahedron<8> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - //------------------------------------------------------------------ - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_13_generate_mesh( - mesh_bulk_data , - box_size , - coordinates_field , - elem_node_coord , - block_hex ); - - use_case_13_generate_sides( mesh_bulk_data , false ); - - - { - std::vector count ; - mesh::Selector selector = mesh_meta_data.locally_owned_part() | - mesh_meta_data.globally_shared_part() ; - count_entities( selector, mesh_bulk_data, count ); - - std::cout << " P" << p_rank << ": Uses {" - << " Node = " << count[ stk_classic::mesh::fem::FEMMetaData::NODE_RANK ] - << " Edge = " << count[ edge_rank ] - << " Face = " << count[ side_rank ] - << " Elem = " << count[ element_rank ] - << " }" << std::endl ; - std::cout.flush(); - } - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<::const_iterator > - // - // Where PairIter is a wrapper for a pair of iterators. - - const CellTopologyData * const side_top = elem_top->side[ side_ord ].topology ; - const unsigned * const side_map = elem_top->side[ side_ord ].node ; - - bool good = true ; - for ( unsigned j = 0 ; good && j < side_top->node_count ; ++j ) { - good = side_nodes[j].entity() == elem_nodes[ side_map[j] ].entity(); - } - return good ; -} - -} - -void use_case_13_algorithm( - mesh::BulkData & M , - const unsigned side_type , - const VectorFieldType & side_field , - const VectorFieldType & elem_field ) -{ - const mesh::fem::FEMMetaData & meta_data = mesh::fem::FEMMetaData::get(M); - - const stk_classic::mesh::EntityRank element_rank = meta_data.element_rank(); - - { - // Communicate the element field data that we care about - // from the processor owners of the ghosted elements - // to the ghosted copies of the elements. - - std::vector< const mesh::FieldBase * > sync_fields( 1 , & elem_field ); - - mesh::communicate_field_data( M.shared_aura() , sync_fields ); - } - - // Get vector of buckets ( entities and field data) - // for which the sides are all locally owned. - - mesh::Selector select_owned( meta_data.locally_owned_part() ); - - const std::vector & buckets = M.buckets( side_type ); - - for ( std::vector::const_iterator - ik = buckets.begin() ; ik != buckets.end() ; ++ik ) if ( select_owned( **ik ) ) { - - const mesh::Bucket & bucket = **ik ; - - // Number of sides in this bucket of sides and side field data - - const int number = bucket.size(); - - double * side_data = field_data( side_field , bucket.begin() ); - - for ( int i = 0 ; i < number ; ++i , side_data += 3 ) { - - mesh::Entity & side = bucket[i] ; - - const mesh::PairIterRelation side_elems = side.relations(element_rank); - - if ( side_elems.size() == 2 ) { - mesh::Entity & elem1 = * side_elems[0].entity(); - mesh::Entity & elem2 = * side_elems[1].entity(); - - double * const elem1_data = field_data( elem_field , elem1 ); - double * const elem2_data = field_data( elem_field , elem2 ); - - // Which way is the side oriented, natural for #1 or #2 ? - - if ( outward_orientation( elem1, side, side_elems[0].identifier()) ){ - side_data[0] = elem2_data[0] - elem1_data[0] ; - side_data[1] = elem2_data[1] - elem1_data[1] ; - side_data[2] = elem2_data[2] - elem1_data[2] ; - } - else { - side_data[0] = elem1_data[0] - elem2_data[0] ; - side_data[1] = elem1_data[1] - elem2_data[1] ; - side_data[2] = elem1_data[2] - elem2_data[2] ; - } - } - else { - // Nothing happening with only one element? - side_data[0] = 0 ; - side_data[1] = 0 ; - side_data[2] = 0 ; - } - } - } -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -// Does not work for shells since side neighbor can be ambiguous... - -mesh::Entity * get_side_neighbor( - const CellTopologyData & elem_top , const mesh::Entity & elem , unsigned side_id ) -{ - const CellTopologyData & side_top = * elem_top.side[ side_id ].topology ; - const unsigned * const node_map = elem_top.side[ side_id ].node ; - const mesh::PairIterRelation elem_nodes = elem.relations( mesh::fem::FEMMetaData::NODE_RANK ); - - // Find other element that shares this side... - - mesh::Entity & node = * elem_nodes[ node_map[0] ].entity(); - - const mesh::PairIterRelation node_elems = node.relations(elem.entity_rank()); - - mesh::Entity * neighbor = NULL ; - - for ( unsigned i = 0 ; neighbor == NULL && i < node_elems.size() ; ++i ) { - - neighbor = node_elems[i].entity(); - - const mesh::PairIterRelation neighbor_nodes = neighbor->relations( mesh::fem::FEMMetaData::NODE_RANK ); - - if ( & elem == neighbor ) { neighbor = NULL ; } - - for ( unsigned j = 1 ; - neighbor != NULL && j < side_top.node_count ; ++j ) { - - mesh::Entity * const next_node = elem_nodes[ node_map[j] ].entity(); - - // If neighbor does not have node then not this element ... - - bool found = false ; - for ( unsigned k = 0 ; ! found && k < neighbor_nodes.size() ; ++k ) { - found = next_node == neighbor_nodes[k].entity(); - } - if ( ! found ) { neighbor = NULL ; } - } - -#if 0 - if ( NULL != neighbor ) { - std::cout << "neighbors( " ; - std::cout << " Element[ " ; - std::cout << elem.identifier(); - std::cout << " ]{" ; - for ( int i = 0 ; i < elem_nodes.size() ; ++i ) { - std::cout << " " << elem_nodes[i].entity()->identifier(); - } - std::cout << " } , Element[ " ; - std::cout << neighbor->identifier(); - std::cout << " ]{" ; - for ( int i = 0 ; i < neighbor_nodes.size() ; ++i ) { - std::cout << " " << neighbor_nodes[i].entity()->identifier(); - } - std::cout << " } , Share { " ; - for ( unsigned j = 0 ; j < side_top.node_count ; ++j ) { - mesh::Entity * const next_node = elem_nodes[ node_map[j] ].entity(); - std::cout << " " << next_node->identifier(); - } - std::cout << " } )" ; - std::cout << std::endl ; - std::cout.flush(); - } -#endif - } - - return neighbor ; -} - -unsigned determine_local_side_id( const mesh::Entity & elem , mesh::Entity & side ) -{ - const CellTopologyData * const elem_top = mesh::fem::get_cell_topology( elem ).getCellTopologyData(); - - const mesh::PairIterRelation elem_nodes = elem.relations( mesh::fem::FEMMetaData::NODE_RANK ); - const mesh::PairIterRelation side_nodes = side.relations( mesh::fem::FEMMetaData::NODE_RANK ); - - int side_id = -1 ; - - for ( unsigned i = 0 ; side_id == -1 && i < elem_top->side_count ; ++i ) { - const CellTopologyData & side_top = * elem_top->side[i].topology ; - const unsigned * side_map = elem_top->side[i].node ; - - if ( side_nodes.size() == side_top.node_count ) { - - side_id = i ; - - for ( unsigned j = 0 ; - side_id == static_cast(i) && j < side_top.node_count ; ++j ) { - - mesh::Entity * const elem_node = elem_nodes[ side_map[j] ].entity(); - - bool found = false ; - - for ( unsigned k = 0 ; ! found && k < side_top.node_count ; ++k ) { - found = elem_node == side_nodes[k].entity(); - } - - if ( ! found ) { side_id = -1 ; } - } - } - } - - if ( side_id < 0 ) { - std::ostringstream msg ; - msg << "determine_local_side_id( " ; - msg << elem_top->name ; - msg << " , Element[ " ; - msg << elem.identifier(); - msg << " ]{" ; - for ( unsigned i = 0 ; i < elem_nodes.size() ; ++i ) { - msg << " " << elem_nodes[i].entity()->identifier(); - } - msg << " } , Side[ " ; - msg << side.identifier(); - msg << " ]{" ; - for ( unsigned i = 0 ; i < side_nodes.size() ; ++i ) { - msg << " " << side_nodes[i].entity()->identifier(); - } - msg << " } ) FAILED" ; - throw std::runtime_error( msg.str() ); - } - - return static_cast(side_id) ; -} - -} - -void use_case_13_generate_sides( - mesh::BulkData & mesh , const bool skin_only ) -{ - const mesh::fem::FEMMetaData & meta_data = mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = meta_data.element_rank(); - const unsigned p_rank = mesh.parallel_rank(); - - mesh.modification_begin(); - - // For each element - // for each element face - // get the neighbor element - // if no neighbor and owned then generate the face - // else if element has smaller id and - // either element or neighbor is local - // then generate face and attach to neighbor - - const std::vector & es = mesh.buckets(element_rank); - - for ( std::vector::const_iterator - ie = es.begin() ; ie != es.end() ; ++ie ) { - - const mesh::Bucket & bucket = **ie; - size_t n = bucket.size(); - - for ( size_t j = 0; j < n; ++j) { - - // The const_cast indicates that there is an API issue to be addressed: - //mesh::Entity & element = const_cast( bucket[j] ); - mesh::Entity & element = bucket[j]; - - const CellTopologyData * const elem_top = mesh::fem::get_cell_topology( element ).getCellTopologyData(); - - if ( NULL == elem_top ) { - throw std::runtime_error( std::string("Element has no topology" ) ); - } - - // Generate if either the element or its neighbor is owned... - // Only generate if the element has a smaller identifier - - for ( unsigned i = 0 ; i < elem_top->side_count ; ++i ) { - - mesh::Entity * const elem_neighbor = get_side_neighbor(*elem_top,element,i); - - const bool element_owned = p_rank == element.owner_rank(); - const bool neighbor_owned = elem_neighbor && - elem_neighbor->owner_rank() == p_rank ; - - const bool create_side = - ( element_owned || neighbor_owned ) && - ( ! elem_neighbor || - ( ! skin_only && - element.identifier() < elem_neighbor->identifier() ) ); - - if ( create_side ) { - - const CellTopologyData * const side_top = elem_top->side[i].topology ; - const unsigned * const side_node = elem_top->side[i].node ; - const unsigned side_type = side_top->dimension ; - - const mesh::EntityId side_id = element.identifier() * 10 + i + 1; - - mesh::PartVector parts ; - - mesh::Entity & side = mesh.declare_entity( side_type, side_id , parts ); - - mesh::PairIterRelation rel = element.relations( mesh::fem::FEMMetaData::NODE_RANK ); - - for ( unsigned k = 0 ; k < side_top->node_count ; ++k ) { - mesh::Entity & node = * rel[ side_node[k] ].entity(); - mesh.declare_relation( side , node , k ); - } - - mesh.declare_relation( element , side , i ); - - if ( elem_neighbor ) { - - const unsigned other_side_id = - determine_local_side_id( *elem_neighbor , side ); - - mesh.declare_relation( *elem_neighbor , side , other_side_id ); - } - } - } - } - } - - mesh.modification_end(); -} - -} // namespace stk_use_cases - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_use_cases { - -void use_case_13_generate_mesh( - mesh::BulkData & mesh , - const unsigned N[] , - const VectorFieldType & node_coord , - const ElementNodePointerFieldType & /*elem_node_coord */, - mesh::Part & hex_block ) -{ - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_shell = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( N[0], N[1], N[2], parallel_size, parallel_rank ); - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - ThrowRequire( num_nodes == node_map.size() ); - - { - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - gmesh.element_map( i, elem_map ); - - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - mesh::Entity * const node = mesh.get_entity( mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, Node not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - all_reduce( mesh.parallel() , ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = wall_dtime( t ); - - all_reduce( mesh.parallel() , ReduceMax<1>( & dt ) ); - - std::cout << " P" << mesh.parallel_rank() - << ": Meshed Hex = " << num_hex - << " , Shell = " << num_shell - << " , Node = " << num_nodes - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); -} - -} // namespace stk_use_cases - -//---------------------------------------------------------------------- - - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_14.cpp b/packages/stk/stk_classic/stk_usecases/mesh/UseCase_14.cpp deleted file mode 100644 index 7645a1a9cbce..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_14.cpp +++ /dev/null @@ -1,1031 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -#include -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 14: internal force computation. -// The function 'use_case_14_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -enum { SpatialDim = 3 }; - -namespace { - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::fem::FEMMetaData& meta_data) -{ - return meta_data.element_rank(); -} - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::Part& part) -{ - return get_element_rank(stk_classic::mesh::fem::FEMMetaData::get(part)); -} - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK, meta_data.universal_part() , n1 ); -} - -CartesianField & -declare_vector_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data) , meta_data.universal_part() , n1 ); -} - -ScalarField & -declare_scalar_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() ); -} - - -SymmetricTensorField & -declare_symmetric_tensor_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 ); - return f ; -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & put_field_on_all_elements( stk_classic::mesh::Field & f , unsigned n1 ) -{ - put_field_on_elements( f , stk_classic::mesh::fem::FEMMetaData::get(f).universal_part() , n1 ); - return f ; -} - -} // namespace - -void use_case_14_driver( - MPI_Comm comm , - const std::string & file_name , - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 14: element internal force. -// - -void use_case_14_driver( MPI_Comm comm , bool performance_test ) -{ - int num_procs = stk_classic::parallel_machine_size( comm ); - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout << " stk_mesh Use Case #14 - element internal force, begin" << std::endl ; - } - - if ( ! performance_test ) { - // Quick & small test for correctness: - const unsigned a_box_size[3] = { 10 , 10 , 10*num_procs }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - int num_trials = 1; - use_case_14_driver( comm , "use_case_14.exo" , a_box_size , a_box_sides , num_trials ); - } - else { - int num_trials = 20 ; // 582 ; - - const unsigned a_box_size[3] = { 100 , 100 , 100 }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - std::cout << "Running 100x100x100 case, num_trials = " << num_trials << std::endl; - - use_case_14_driver( comm , "use_case_14a.exo" , a_box_size , a_box_sides , num_trials ); - -// const unsigned b_box_size[3] = { 100 , 125 , 10*num_procs }; -// const unsigned b_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - -// std::cout << "Running 100x125x10*nprocs case, num_trials = " << num_trials << std::endl; - -// use_case_14_driver( comm , "use_case_14b.exo" , b_box_size , b_box_sides , num_trials ); - } -} - -//-------------------------------------------------------------------- - -inline -void zero_data( double * beg , double * const end ) -{ while ( beg < end ) { *beg++ = 0 ; } } - -template< class FieldType > -void zero_field_data( stk_classic::mesh::BulkData & mesh , unsigned type , const FieldType & field ) -{ - typedef stk_classic::mesh::BucketArray< FieldType > array_type ; - - const std::vector & ks = mesh.buckets( type ); - - for ( std::vector::const_iterator ik = ks.begin() ; ik != ks.end() ; ++ik ) { - stk_classic::mesh::Bucket & bucket = **ik ; - array_type data( field , bucket ); - zero_data( data.contiguous_data() , data.contiguous_data() + data.size() ); - } -} - -//-------------------------------------------------------------------- - - -void use_case_14_driver( - MPI_Comm comm , - const std::string & /*file_name */, - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ) -{ - double dt = 1.0e-02; - double YM = 1e7; // Young's Modulus - double PR = 0.33; // Poisson Ratio - double element_mass_dummy_value = 1.0; - std::string material_model_name("ELASTIC"); - - double current_stable_time_step = dt; - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - lame::MatProps materialProperties; - - std::vector youngs_modulus; youngs_modulus.push_back(YM); - std::vector poissons_ratio; poissons_ratio.push_back(PR); - std::vector bulk_modulus; bulk_modulus.push_back(BM); - std::vector shear_modulus; shear_modulus.push_back(SM); - std::vector two_mu; two_mu.push_back(TM); - std::vector lambda; lambda.push_back(LAMBDA); - std::vector dilatational_modulus; dilatational_modulus.push_back(DM); - - materialProperties["YOUNGS_MODULUS"] = youngs_modulus; - materialProperties["POISSONS_RATIO"] = poissons_ratio; - materialProperties["BULK_MODULUS"] = bulk_modulus; - materialProperties["SHEAR_MODULUS"] = shear_modulus; - materialProperties["TWO_MU"] = two_mu; - materialProperties["LAMBDA"] = lambda; - materialProperties["DILATATIONAL_MODULUS"] = dilatational_modulus; - - lame::Material * matmodel = lame::Elastic::createMaterial( materialProperties ); - - //---------------------------------- - - APSHex8ug hex_element; - - lame::matParams materialParameters; - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - // [4] = Parallel swap-add of internal force - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case #14" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data and bulk data. - - stk_classic::mesh::fem::FEMMetaData mesh_meta_data( SpatialDim ); - - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data.get_meta_data(mesh_meta_data) , MPI_COMM_WORLD, 1000 ); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", mesh_meta_data.element_rank()); - - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - - //-------------------------------- - - // Nodal vector fields - CartesianField &model_coordinates = declare_vector_field_on_all_nodes( mesh_meta_data , "model_coordinates" , SpatialDim ); - CartesianField &coordinates_field = declare_vector_field_on_all_nodes( mesh_meta_data , "coordinates" , SpatialDim ); - CartesianField &velocity_field = declare_vector_field_on_all_nodes( mesh_meta_data , "velocity" , SpatialDim ); - CartesianField &fint_field = declare_vector_field_on_all_nodes( mesh_meta_data , "force_internal" , SpatialDim ); - - // Element vector fields: - CartesianField &Vorticity = declare_vector_field_on_all_elements( mesh_meta_data , "Vorticity" , SpatialDim ); - - // Element scalar fields: - ScalarField &Shear_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "shear_modulus" ); - ScalarField &Dilatational_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "dilatational_modulus"); - ScalarField &Material_eff_twomu = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effictive_two_mu"); - ScalarField &Material_eff_bulk_mod = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effective_bulk_moduli"); - ScalarField &Midstep_volume = declare_scalar_field_on_all_elements( mesh_meta_data , "mid_step_volume"); - ScalarField &Element_time_step = declare_scalar_field_on_all_elements( mesh_meta_data , "element_time_step"); - ScalarField &Element_mass = declare_scalar_field_on_all_elements( mesh_meta_data , "element_mass"); - ScalarField &Hourglass_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "hourglass_energy"); - ScalarField &Internal_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "internal_energy"); - - // Element symmetric tensor fields: - SymmetricTensorField &Stretch = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "stretch" , 6 ); - SymmetricTensorField &StrainRate = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "StrainRate" , 6 ); - SymmetricTensorField &RotatedStress = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "RotatedStress" , 6 ); - - //-------------------------------- - // We don't like specifying the template type TWICE! very error prone. - //-------------------------------- - // The multi-state fields don't have the 'declare and put' convenience functions (yet) - // - // For clarity declare a integer to used for the number of states arguments. - // - const unsigned two_states = 2 ; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField &StressNew = mesh_meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states ); - put_field_on_all_elements( StressNew , 6 ); - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField &RotationNew = - put_field_on_all_elements( mesh_meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 ); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField &HourglassResistanceNew = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 ); - - HourglassOpField & MidHourglassOp = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 ); - - //-------------------------------- - // Declare aggressive "gather" fields which are an array of - // pointers to the element's nodes' coordinate, velocity, and - // internal force field data. - // - // The declarations specify element fields of the following form: - // - // double * coord_gather [ nodes_per_element ] - // double * velocity_gather[ nodes_per_element ] - // double * fint_gather [ nodes_per_element ] - // - // where - // - // coord_gather[i] == field_data( coordinates_field , element_node[i] ) - // velocity_gather[i] == field_data( velocity , element_node[i] ) - // fint_gather[i] == field_data( fint , element_node[i] ) - // - // The number of nodes per element could vary, so the field is put on each element block - // with a size of the number of nodes per element in that element block. - - ElementNodePointerField & coord_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data) , "coord_gather" , coordinates_field ); - ElementNodePointerField & velocity_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data) , "velocity_gather" , velocity_field ); - ElementNodePointerField & fint_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data) , "fint_gather" , fint_field ); - - put_field_on_elements( coord_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( velocity_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( fint_gather , block_hex , shards::Hexahedron<> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_14_generate_mesh( - mesh_bulk_data , - box_size , - model_coordinates , - coord_gather , - block_hex , - box_sides ); - - use_case_14_initialize_data( - mesh_bulk_data , - model_coordinates , - coordinates_field , - velocity_field ); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - stk_classic::mesh::Selector select_owned( stk_classic::mesh::MetaData::get(mesh_bulk_data).locally_owned_part() ); - - const std::vector< stk_classic::mesh::Bucket * > & element_buckets = mesh_bulk_data.buckets(mesh_meta_data.element_rank()); - - unsigned maximum_bucket_size = 0 ; - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned(**k) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - if ( maximum_bucket_size < bucket.size() ) { maximum_bucket_size = bucket.size(); } - } - - // Need both the the old and new states of these two-state fields: - - HourglassArrayField & HourglassResistanceOld = HourglassResistanceNew.field_of_state( stk_classic::mesh::StateOld ); - SymmetricTensorField & StressOld = StressNew.field_of_state( stk_classic::mesh::StateOld ); - FullTensorField & RotationOld = RotationNew.field_of_state( stk_classic::mesh::StateOld ); - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - - double * stretch = stk_classic::mesh::field_data( Stretch, bucket.begin() ); - double * strain_rate = stk_classic::mesh::field_data( StrainRate, bucket.begin() ); - double * stress_new = stk_classic::mesh::field_data( StressNew, bucket.begin() ); - double * stress_old = stk_classic::mesh::field_data( StressOld , bucket.begin() ); - double * rotated_stress = stk_classic::mesh::field_data( RotatedStress , bucket.begin() ); - double * rotation_old = stk_classic::mesh::field_data( RotationOld , bucket.begin() ); - double * rotation_new = stk_classic::mesh::field_data( RotationNew , bucket.begin() ); - double * mass = stk_classic::mesh::field_data( Element_mass , bucket.begin() ); - double * hg_old = stk_classic::mesh::field_data( HourglassResistanceOld , bucket.begin() ); - double * hg_new = stk_classic::mesh::field_data( HourglassResistanceNew , bucket.begin() ); - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - - for ( int i = 0 ; i < num_elements ; ++i ) { - - stk_classic::Copy<32>( mid_hg_op_ptr , 0.0 ); mid_hg_op_ptr += 32 ; - stk_classic::Copy< 3>( vorticity_ptr , 0.0 ); vorticity_ptr += 3 ; - stk_classic::Copy< 6>( rotated_stress, 0.0 ); rotated_stress += 6 ; - stk_classic::Copy< 6>( strain_rate, 0.0 ); strain_rate += 6 ; - stk_classic::Copy<12>( hg_old, 0.0 ); hg_old += 12 ; - stk_classic::Copy<12>( hg_new, 0.0 ); hg_new += 12 ; - stk_classic::Copy< 6>( stress_new, 0.0 ); stress_new += 6 ; - stk_classic::Copy< 6>( stress_old, 0.0 ); stress_old += 6 ; - - mass[i] = element_mass_dummy_value; - - // initialize stretch to identity. - stretch[0] = 1.0; - stretch[1] = 1.0; - stretch[2] = 1.0; - stretch[3] = 0.0; - stretch[4] = 0.0; - stretch[5] = 0.0; - stretch+=6; - - // initialize rotation to identity. - rotation_old[0] = 1.0; - rotation_old[1] = 1.0; - rotation_old[2] = 1.0; - rotation_old[3] = 0.0; - rotation_old[4] = 0.0; - rotation_old[5] = 0.0; - rotation_old[6] = 0.0; - rotation_old[7] = 0.0; - rotation_old[8] = 0.0; - rotation_old +=9; - - // initialize rotation to identity. - rotation_new[0] = 1.0; - rotation_new[1] = 1.0; - rotation_new[2] = 1.0; - rotation_new[3] = 0.0; - rotation_new[4] = 0.0; - rotation_new[5] = 0.0; - rotation_new[6] = 0.0; - rotation_new[7] = 0.0; - rotation_new[8] = 0.0; - rotation_new += 9; - } - } - std::cout << "KHP: Done element field init\n"; - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements = bucket.size(); - - double * const sm = stk_classic::mesh::field_data( Shear_Modulus , bucket.begin() ); - double * const dm = stk_classic::mesh::field_data( Dilatational_Modulus , bucket.begin() ); - double * const twomu = stk_classic::mesh::field_data( Material_eff_twomu , bucket.begin() ); - double * const bulk = stk_classic::mesh::field_data( Material_eff_bulk_mod , bucket.begin() ); - double * const mv = stk_classic::mesh::field_data( Midstep_volume , bucket.begin() ); - double * const hg_energy = stk_classic::mesh::field_data( Hourglass_energy , bucket.begin() ); - double * const internal_energy = stk_classic::mesh::field_data( Internal_energy , bucket.begin() ); - - for ( unsigned i = 0 ; i < num_elements ; ++i ) { - sm[i] = SM; - dm[i] = DM; - twomu[i] = TM; - bulk[i] = BM; - mv[i] = 0.0; - hg_energy[i] = 0.0; - internal_energy[i] = 0.0; - } - } - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - // Scratch space - - enum { num_dof = 24 }; - const int num_dof_max_bucket = num_dof * maximum_bucket_size ; - std::vector< double > vel( num_dof_max_bucket ); - std::vector< double > element_coordinates( num_dof_max_bucket ); - std::vector< double > force_new( num_dof_max_bucket ); - - wtime = stk_classic::wall_time(); - - for(unsigned n=0; n::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - double *material_eff_twomu_ptr = stk_classic::mesh::field_data( Material_eff_twomu, bucket.begin()); - double *material_eff_bulk_modulus_ptr = stk_classic::mesh::field_data( Material_eff_bulk_mod, bucket.begin()); - double *mid_step_volume_ptr = stk_classic::mesh::field_data( Midstep_volume, bucket.begin()); - double *element_time_step_ptr = stk_classic::mesh::field_data( Element_time_step, bucket.begin()); - double *element_mass_ptr = stk_classic::mesh::field_data( Element_mass, bucket.begin()); - double *hg_energy_ptr = stk_classic::mesh::field_data( Hourglass_energy, bucket.begin()); - double *internal_energy_ptr = stk_classic::mesh::field_data (Internal_energy, bucket.begin()); - double *shear_modulus_ptr = stk_classic::mesh::field_data( Shear_Modulus, bucket.begin()); - double *dilatational_modulus_ptr = stk_classic::mesh::field_data( Dilatational_Modulus, bucket.begin() ); - - double *rotation_old_ptr = stk_classic::mesh::field_data( RotationOld, bucket.begin()); - double *rotation_new_ptr = stk_classic::mesh::field_data( RotationNew, bucket.begin()); - - double *stretch_ptr = stk_classic::mesh::field_data( Stretch, bucket.begin()); - double *strain_rate_ptr = stk_classic::mesh::field_data( StrainRate, bucket.begin()); - double *stress_old_ptr = stk_classic::mesh::field_data( StressOld, bucket.begin()); - double *stress_new_ptr = stk_classic::mesh::field_data( StressNew, bucket.begin()); - double *rotated_stress_ptr = stk_classic::mesh::field_data( RotatedStress, bucket.begin()); - - double *hg_resistance_old_ptr = stk_classic::mesh::field_data( HourglassResistanceOld, bucket.begin()); - double *hg_resistance_new_ptr = stk_classic::mesh::field_data( HourglassResistanceNew, bucket.begin()); - - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - - const double **coord = - (const double **) stk_classic::mesh::field_data( coord_gather, bucket.begin()); - const double **velocity = - (const double **) stk_classic::mesh::field_data( velocity_gather, bucket.begin()); - double **fint = stk_classic::mesh::field_data( fint_gather, bucket.begin()); - - const int num_elem_nodes = num_elements * 8 ; - - //-------------------------------- - { // Gather nodal data into contiguous arrays. - - // element-node pointer fields - const double ** field_coord = coord ; - const double ** vnodes = velocity ; - - // scratch space for gather: - double * elem_coord = & element_coordinates[0] ; - double * elem_vel = & vel[0] ; - - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - const double * const f_coord = *field_coord ; - const double * const f_vel = *vnodes ; - - elem_coord[0] = f_coord[0]; - elem_coord[1] = f_coord[1]; - elem_coord[2] = f_coord[2]; - - elem_vel[0] = f_vel[0]; - elem_vel[1] = f_vel[1]; - elem_vel[2] = f_vel[2]; - - ++field_coord ; - ++vnodes ; - elem_coord += 3 ; - elem_vel += 3 ; - } - } - - //-------------------------------- - - materialParameters.dt = dt; - materialParameters.nelements = num_elements ; - materialParameters.strain_rate = strain_rate_ptr; - materialParameters.stress_old = stress_old_ptr; - materialParameters.stress_new = stress_new_ptr; - - hex_element.internalForce( num_elements , - dt, - current_stable_time_step, - element_time_step_ptr, - *matmodel, - materialParameters, - materialProperties, - & element_coordinates[0], - & vel[0], - rotation_old_ptr, - rotation_new_ptr, - mid_step_volume_ptr, - vorticity_ptr, - stretch_ptr, - strain_rate_ptr, - mid_hg_op_ptr, - stress_old_ptr, - stress_new_ptr, - rotated_stress_ptr, - material_eff_bulk_modulus_ptr, - material_eff_twomu_ptr, - shear_modulus_ptr, - dilatational_modulus_ptr, - element_mass_ptr, - & force_new[0], - hg_energy_ptr, - internal_energy_ptr, - hg_resistance_old_ptr, - hg_resistance_new_ptr - ); - - { // Scatter internal force values. - double ** f = fint ; - const double * f_new = & force_new[0] ; - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - double * const node_f = *f ; - node_f[0] += f_new[0]; - node_f[1] += f_new[1]; - node_f[2] += f_new[2]; - ++f ; - f_new += 3 ; - } - } - } - - time_max[3] += stk_classic::wall_dtime( wtime ); - - stk_classic::mesh::parallel_reduce( mesh_bulk_data , stk_classic::mesh::sum(fint_field) ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - }//end for(..num_trials... - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Box size = { " << box_size[0] << " , " - << box_size[1] << " , " - << box_size[2] << " }" << std::endl - << " Box sides = { { " - << box_sides[0][0] << " , " - << box_sides[0][1] << " } , { " - << box_sides[1][0] << " , " - << box_sides[1][1] << " } , { " - << box_sides[2][0] << " , " - << box_sides[2][1] << " } }" - << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation= " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Internal force = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Internal force (total) = " << time_min[3]*num_trials - << std::endl - << " Swap-add = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } - delete matmodel; -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_14_initialize_data( - stk_classic::mesh::BulkData & mesh , - const CartesianField & node_model_coordinates , - const CartesianField & node_coordinates , - const CartesianField & node_velocity ) -{ - const double dt = 1.0e-2; - - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - - double * X = stk_classic::mesh::field_data( node_model_coordinates , bucket.begin() ); - double * coord = stk_classic::mesh::field_data( node_coordinates , bucket.begin() ); - double * v = stk_classic::mesh::field_data( node_velocity , bucket.begin() ); - - for ( unsigned i = 0 ; i < length ; ++i ) { - v[0] = X[0]; - v[1] = X[1]; - v[2] = X[2]; - coord[0] = X[0] + dt * v[0]; - coord[1] = X[1] + dt * v[1]; - coord[2] = X[2] + dt * v[2]; - //std::cout << "KHP: Xn= " << coord[0] << ", " << coord[1] << ", " << coord[2] << "\n"; - X += 3; - v += 3; - coord += 3; - } - } -} - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_classic { -namespace app { - -void use_case_14_generate_mesh( - stk_classic::mesh::BulkData & mesh , - const unsigned N[] , - const CartesianField & node_coord , - const ElementNodePointerField & /*coord_gather */, - stk_classic::mesh::Part & hex_block , - const unsigned shell_side[][2] ) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( N[0], N[1], N[2], parallel_size, parallel_rank ); - - if ( shell_side[0][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MX ); } - if ( shell_side[0][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PX ); } - if ( shell_side[1][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MY ); } - if ( shell_side[1][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PY ); } - if ( shell_side[2][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MZ ); } - if ( shell_side[2][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PZ ); } - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - gmesh.element_map( i, elem_map ); - - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, stk_classic::mesh::fem::FEMMetaData::NODE_RANK not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = stk_classic::mesh::field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - std::vector entity_count ; - - stk_classic::mesh::Selector selector(stk_classic::mesh::MetaData::get(mesh).locally_owned_part()); - stk_classic::mesh::count_entities( selector, mesh , entity_count ); - - stk_classic::all_reduce( mesh.parallel() , - stk_classic::ReduceSum( & entity_count[0] ) & - stk_classic::ReduceMax<1>( & dt ) ); - - if ( 0 == parallel_rank ) { - std::cout << "On " << parallel_size << " processors, meshed " - << entity_count[ element_rank ] << " elements and " - << entity_count[ stk_classic::mesh::fem::FEMMetaData::NODE_RANK ] << " nodes " - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); - } -} - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- - -int APSHex8ug::internalForce( - const int num_elements, - const double dt, - double current_stable_time_step, - double* const element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &/*materialProperties*/, - double * const coordinates, - double * const velocity, - double * const rotation_old, double* const rotation_new, - double * const midstep_volume, - double * const vorticity_tensor, - double * const stretch, - double * const strain_rate, - double * const mid_hgop, - double * const /*stress_old*/, double * const stress_new, - double * const rotated_stress, - double * const material_eff_bulk_mod, - double * const material_eff_twomu, - double * const shrmod, - double * const dilmod, - double * const element_mass, - double * const force_new, - double * const hourglass_energy, - double * const internal_energy, - double * const hg_resistance_old, double* const hg_resistance_new - ) const { - - compute_stretch(num_elements, dt, coordinates, velocity, rotation_old, midstep_volume, vorticity_tensor, rotation_new, stretch, strain_rate, mid_hgop); - - Int err = material_model.getStress(&materialParameters); - ThrowErrorMsgIf( err, "getStress failed" ); - - const double one_third = 1.0 / 3.0 ; - double dilatationalHGParam = 0.05; - double deviatoricHGParam = 0.0; - - for(int k=0; k -#include -#include -#include -#include -#include - -using std::sqrt; - -#define INLINE inline - -#define TEMPLATE_SCALAR /* template */ -#define Scalar double - -#include -#include - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field CartesianField ; -typedef stk_classic::mesh::Field FullTensorField ; -typedef stk_classic::mesh::Field SymmetricTensorField ; - -//---------------------------------------------------------------------- -// Tags for my special kinds of field types, -// which belong in a separate application-shared file... - -struct HourglassOp : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassOp & tag(); - private: - HourglassOp() {} - HourglassOp( const HourglassOp & ); - HourglassOp & operator = ( const HourglassOp & ); -}; - - inline -const HourglassOp & HourglassOp::tag() -{ static const HourglassOp self ; return self ; } - -inline -const char * HourglassOp::name() const -{ static const char n[] = "HourglassOp" ; return n ; } - -struct HourglassModes : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassModes & tag(); - private: - HourglassModes() {} - HourglassModes( const HourglassModes & ); - HourglassModes & operator = ( const HourglassModes & ); -}; - - inline -const HourglassModes & HourglassModes::tag() -{ static const HourglassModes self ; return self ; } - -inline -const char * HourglassModes::name() const -{ static const char n[] = "HourglassModes" ; return n ; } - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field HourglassOpField; -typedef stk_classic::mesh::Field HourglassArrayField; - -// Specification for the aggressive gather pointer-field for elements. - -typedef stk_classic::mesh::Field ElementNodePointerField ; - -//---------------------------------------------------------------------- -// prototype for the function that will generate the use-case mesh. - -namespace stk_classic { - namespace app { - - void use_case_14_generate_mesh( - stk_classic::mesh::BulkData & mesh , - const unsigned N[] , - const CartesianField & node_coord , - const stk_classic::mesh::ElementNodePointerField & coord_gather , - stk_classic::mesh::Part & hex_block , - const unsigned shell_side[][2] ); - - void use_case_14_initialize_data( - stk_classic::mesh::BulkData & mesh , - const CartesianField & node_model_coordinates , - const CartesianField & node_coordinates , - const CartesianField & node_velocity ); - - }//namespace app -}//namespace stk_classic - -namespace lame { - typedef std::map > MatProps; - - /** - * The struture, matParams, has all of the information that - * might be passed back and forth from the application code - * and the constitutive model. This provides a very simple, - * easily modified interface between the application code - * and the constitutive model. - * - * The following are the more frequently used parameters. - * - * @param nelements is the number of material points sent - * to LAME for evaluation - * @param dt is the size of the current time step - * @param time is the current solution time - * @param dtrnew is the suggested ratio for the new time step - * @param energy_dep is the total ammount of energy deposited - * @param stress_old are the stress components at \f$t_{n}\f$ - * @param stress_new are the stress components at \f$t_{n+1}\f$ - * @param state_old are the state variables at \f$t_{n}\f$ - * @param state_new are the state variables at \f$t_{n+1}\f$ - * @param strain_rate are the components of the current rate - * of deformation - * @param left_stretch are the components of the left stretch - * tensor at \f$t_{n+1}\f$ - * @param rotation are the components of the rotation - * tensor at \f$t_{n+1}\f$ - * @param temp_old is the temperature at \f$t_{n}\f$ - * @param temp_new is the temperature at \f$t_{n+1}\f$ - */ - struct matParams { - public: - matParams(){ - nelements = 0; - nintg = 0; - dt = 0.0; - time = 0.0; - dtrnew = 1.0; - energy_dep = 0.0; - strain_rate = NULL; - stress_old = NULL; - stress_new = NULL; - state_old = NULL; - state_new = NULL; - temp_old = NULL; - temp_new = NULL; - left_stretch = NULL; - rotation = NULL; - entropy = NULL; - energy_balance_term = NULL; - material_properties = NULL; - tangent_moduli = NULL; - ym_old = NULL; - ym_new = NULL; - nU_new = NULL; - nU_old = NULL; - bulk_scaling = NULL; - shear_scaling = NULL; - } - int nelements; - int nintg; - double dt; - double time; - double dtrnew; - double energy_dep; - double * strain_rate; - double * stress_old; - double * stress_new; - double * state_old; - double * state_new; - double * temp_old; - double * temp_new; - double * left_stretch; - double * rotation; - double * entropy; - double * energy_balance_term; - double * material_properties; - double * tangent_moduli; - double * ym_old; - double * ym_new; - double * nU_new; - double * nU_old; - double * bulk_scaling; - double * shear_scaling; - bool tangent_flag; - bool tangent_comp; - }; - - class Material { - public: - explicit Material(const MatProps & props) : - properties(NULL), - num_material_properties(0), - num_state_vars(0), - num_scratch_vars(0) - { - double lambda = getMaterialProperty("LAMBDA",props); - shrmod = getMaterialProperty("SHEAR_MODULUS",props); - datmod = lambda + 2.0*shrmod; - shrmod0 = shrmod; - datmod0 = datmod; - - double lPlusS = lambda + shrmod; - - if ( lPlusS > 0 ) { - youngs = shrmod*(3.0*lambda+2.0*shrmod)/lPlusS; - poissons = 0.5*lambda/lPlusS; - } else { - youngs = std::numeric_limits::quiet_NaN(); - poissons = std::numeric_limits::quiet_NaN(); - } - } - - virtual ~Material() - {} - - int getNumStateVars(){ - return num_state_vars; - } - - static void reportError( int & int_val, std::string & message ){} - - virtual int initialize( matParams * p ) { - int npoints = p->nelements; - for( int index = 0 ; index < num_state_vars * npoints ; ++index) { - p->state_old[index] = 0.0; - p->state_new[index] = 0.0; - } - return 0; - } - virtual int getStress( matParams * p ) = 0; - virtual int loadStepInit( matParams * p ) { - return 0; - } - protected: - double * properties; - int num_material_properties; - int num_state_vars; - int num_scratch_vars; - double shrmod; - double datmod; - double shrmod0; - double datmod0; - double youngs; - double poissons; - - double getMaterialProperty( const std::string & name, const MatProps & props) { - - MatProps::const_iterator itr = props.find(name); - - if (itr != props.end()){ - - const double p = itr->second[0]; - - return p ; - - } else { - - std::string msg = " Material input "; - msg += name; - msg += " does not exist\n"; - msg += " Setting value of "; - msg += name; - msg += " to zero\n"; - - int code = 1; - - reportError(code,msg); - - return -1.0; - } - - } - - private: - Material( const Material & ); - Material & operator= ( const Material & ); - }; - - /** - * This is the class for the elastic constitutive model. The - * elastic model is a hypoelastic model with the following constitutive description - * - * \f$ - * \sigma_{ij}^{n+1} = \sigma_{ij}^{n} - * + \Delta t \left( \lambda \delta_{ij} D_{kk} - * + 2\mu D_{ij} \right) - * \f$ - */ - class Elastic: public Material { - public: - - explicit Elastic( const MatProps & props ) : Material(props) { - num_material_properties = 2; - properties = new double[num_material_properties]; - properties[0] = getMaterialProperty("YOUNGS_MODULUS",props); - properties[1] = getMaterialProperty("POISSONS_RATIO",props); - } - - ~Elastic() { delete [] properties; properties = NULL; } - - static Material * createMaterial( const MatProps & props ) { - return new Elastic( props ); - } - - int initialize( matParams * p ) { - double youngs_modulus = properties[0]; - if ( youngs_modulus < 0.0 ) { - std::cout << "KHP: Negative young's modulus\n"; - } - double poissons_ratio = properties[1]; - if ( poissons_ratio < -1.0 ) { - std::cout << "KHP: PR < -1.0\n"; - } - if ( poissons_ratio > 0.5 ) { - std::cout << "KHP: PR > 0.5, PR= " << poissons_ratio << "\n"; - } - return 0; - } - - int getStress( matParams * p ) { - double youngs_ = properties[0]; - double pr = properties[1]; - double twomu = youngs_/(1.0+pr); - double alambda = twomu*pr/(1.0-2.0*pr); - int num_element = p->nelements; - double dt = p->dt; - double twomu_dt = twomu * dt; - for(int i=0; istrain_rate; - double traced = dt * ( strain[0] + strain[1] + strain[2]); - double *stress_new = p->stress_new; - double *stress_old = p->stress_old; - stress_new[0] = stress_old[0] + alambda*traced + twomu_dt*strain[0]; - stress_new[1] = stress_old[1] + alambda*traced + twomu_dt*strain[1]; - stress_new[2] = stress_old[2] + alambda*traced + twomu_dt*strain[2]; - stress_new[3] = stress_old[3] + twomu_dt*strain[3]; - stress_new[4] = stress_old[4] + twomu_dt*strain[4]; - stress_new[5] = stress_old[5] + twomu_dt*strain[5]; -#if defined(DEBUG_ELASTIC_MATERIAL_MODEL) - std::cout << "KHP: traced= " << traced << ", dt= " << dt << ", " << alambda << ", " << twomu_dt << "\n"; - std::cout << "KHP: s= " << stress_new[0] - << ", " << stress_new[1] - << ", " << stress_new[2] - << ", " << stress_new[3] - << ", " << stress_new[4] - << ", " << stress_new[5] << std::endl; - std::cout << "KHP: s= " << stress_old[0] - << ", " << stress_old[1] - << ", " << stress_old[2] - << ", " << stress_old[3] - << ", " << stress_old[4] - << ", " << stress_old[5] << std::endl; -#endif - - - } - return 0; - } - private: - Elastic( const Elastic & ); - Elastic & operator= ( const Elastic & ); - }; -} // lame - -typedef int Int; -typedef double Real; -// -// Defined numerical constants -// -const double ONE12TH = (1.0/12.0); -// -// Indexes into a 4 by 3 matrix of hourglass constants -// -const int HG_X1 = 0; -const int HG_Y1 = 1; -const int HG_Z1 = 2; -const int HG_X2 = 3; -const int HG_Y2 = 4; -const int HG_Z2 = 5; -const int HG_X3 = 6; -const int HG_Y3 = 7; -const int HG_Z3 = 8; -const int HG_X4 = 9; -const int HG_Y4 = 10; -const int HG_Z4 = 11; -// -// Indexes into a 3 by 3 symmetric tensor stored as a length 6 vector -// -const int K_S_XX = 0; -const int K_S_YY = 1; -const int K_S_ZZ = 2; -const int K_S_XY = 3; -const int K_S_YZ = 4; -const int K_S_ZX = 5; -const int K_S_YX = 3; -const int K_S_ZY = 4; -const int K_S_XZ = 5; -// -// Indexes into a full 3 by 3 tensor stored as a length 9 vector -// -const int K_F_XX = 0; -const int K_F_YY = 1; -const int K_F_ZZ = 2; -const int K_F_XY = 3; -const int K_F_YZ = 4; -const int K_F_ZX = 5; -const int K_F_YX = 6; -const int K_F_ZY = 7; -const int K_F_XZ = 8; -// -// Indexes into a 3 by 3 skew symmetric tensor stored as a length 9 vector -// -const int K_V_XY = 0; -const int K_V_YZ = 1; -const int K_V_ZX = 2; -// -// Indexes into a 2 by 2 symmetric tensor stored as a length 3 vector -// -const int K_S_21_XX = 0; -const int K_S_21_YY = 1; -const int K_S_21_XY = 2; -const int K_S_21_YX = 2; -// -// Indexes into a full 2 by 2 tensor stored as a length 3 vector -// -const int K_F_22_XX = 0; -const int K_F_22_YY = 1; -const int K_F_22_XY = 2; -const int K_F_22_YX = 3; - -namespace APS { - namespace Hex { - - //*************************************************************************************************************** - // - // Additive decomposition for a gradient operator - // - // Input: - // gradient(9) Input velocity gradient - // - // Output: - // stretching(6) - // vorticity(3) - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void additive_decomp36(const Scalar *const gradient, Scalar *const stretching, Scalar *const vorticity) { - // - // Symmetric part - // - stretching[K_S_XX] = gradient[K_F_XX]; - stretching[K_S_YY] = gradient[K_F_YY]; - stretching[K_S_ZZ] = gradient[K_F_ZZ]; - stretching[K_S_XY] = 0.5*(gradient[K_F_XY] + gradient[K_F_YX]); - stretching[K_S_YZ] = 0.5*(gradient[K_F_YZ] + gradient[K_F_ZY]); - stretching[K_S_ZX] = 0.5*(gradient[K_F_ZX] + gradient[K_F_XZ]); - // - // Skew Symmetric part - // - vorticity[K_V_XY] = 0.5*(gradient[K_F_XY] - gradient[K_F_YX]); - vorticity[K_V_YZ] = 0.5*(gradient[K_F_YZ] - gradient[K_F_ZY]); - vorticity[K_V_ZX] = 0.5*(gradient[K_F_ZX] - gradient[K_F_XZ]); - } - - //*************************************************************************************************************** - // - // Polar decomposition of a stretching tensor - // - // Input - // dt Time multiplication factor - // stretching(6) Current element stretching tensor - // vorticity(3) The skew symmetric portion of the velocity gradient - // rotation_old(9) Old element rotation tensor - // Output - // stretch(6) New calculated element stretch - // rotation_new(9) New element rotation tensor - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void polar_decomp33r2(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - const Scalar *const rotation_old, - Scalar *const stretch, - Scalar *const rotation_new) - { - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - - // - // forward elimination - // - const Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - - const Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - const Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - - const Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - const Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - const Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - Scalar r_XX = rotation_old[K_F_XX] + dt_half*( z3 * rotation_old[K_F_YX] - z2 * rotation_old[K_F_ZX] ); - Scalar r_YX = rotation_old[K_F_YX] + dt_half*( z1 * rotation_old[K_F_ZX] - z3 * rotation_old[K_F_XX] ); - Scalar r_ZX = rotation_old[K_F_ZX] + dt_half*( z2 * rotation_old[K_F_XX] - z1 * rotation_old[K_F_YX] ); - Scalar r_XY = rotation_old[K_F_XY] + dt_half*( z3 * rotation_old[K_F_YY] - z2 * rotation_old[K_F_ZY] ); - Scalar r_YY = rotation_old[K_F_YY] + dt_half*( z1 * rotation_old[K_F_ZY] - z3 * rotation_old[K_F_XY] ); - Scalar r_ZY = rotation_old[K_F_ZY] + dt_half*( z2 * rotation_old[K_F_XY] - z1 * rotation_old[K_F_YY] ); - Scalar r_XZ = rotation_old[K_F_XZ] + dt_half*( z3 * rotation_old[K_F_YZ] - z2 * rotation_old[K_F_ZZ] ); - Scalar r_YZ = rotation_old[K_F_YZ] + dt_half*( z1 * rotation_old[K_F_ZZ] - z3 * rotation_old[K_F_XZ] ); - Scalar r_ZZ = rotation_old[K_F_ZZ] + dt_half*( z2 * rotation_old[K_F_XZ] - z1 * rotation_old[K_F_YZ] ); - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - - Scalar a13a12 = a13*a12; - Scalar a23 = b32 + a13a12; - r_YX += r_XX * a12; - r_YY += r_XY * a12; - r_YZ += r_XZ * a12; - b32 = (b32 - a13a12) * a22inv; - r_ZX += r_XX * a13 + r_YX * b32; - r_ZY += r_XY * a13 + r_YY * b32; - r_ZZ += r_XZ * a13 + r_YZ * b32; - // - // backward substitution - - // - const Scalar a33inv = 1.0 / (1.0 + a13 * a13 + a23 * b32); - - rotation_new[K_F_ZX] = r_ZX * a33inv; - rotation_new[K_F_ZY] = r_ZY * a33inv; - rotation_new[K_F_ZZ] = r_ZZ * a33inv; - rotation_new[K_F_YX] = ( r_YX - rotation_new[K_F_ZX] * a23 ) * a22inv; - rotation_new[K_F_YY] = ( r_YY - rotation_new[K_F_ZY] * a23 ) * a22inv; - rotation_new[K_F_YZ] = ( r_YZ - rotation_new[K_F_ZZ] * a23 ) * a22inv; - rotation_new[K_F_XX] = r_XX - rotation_new[K_F_ZX] * a13 - rotation_new[K_F_YX] * a12; - rotation_new[K_F_XY] = r_XY - rotation_new[K_F_ZY] * a13 - rotation_new[K_F_YY] * a12; - rotation_new[K_F_XZ] = r_XZ - rotation_new[K_F_ZZ] * a13 - rotation_new[K_F_YZ] * a12; - // - // update stretch tensor in the new configuration - - // - const Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - const Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - const Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - const Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - const Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - const Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - const Scalar s_XX = stretch[K_S_XX]; - const Scalar s_YY = stretch[K_S_YY]; - const Scalar s_ZZ = stretch[K_S_ZZ]; - const Scalar s_XY = stretch[K_S_XY]; - const Scalar s_YZ = stretch[K_S_YZ]; - const Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } - - TEMPLATE_SCALAR - INLINE void polar_decomp33_nr(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - Scalar *const stretch) { - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - // - // forward elimination - // - Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - b32 = (b32-a12 * a13) * a22inv; - // - // update stretch tensor in the new configuration - - // - { - Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - Scalar s_XX = stretch[K_S_XX]; - Scalar s_YY = stretch[K_S_YY]; - Scalar s_ZZ = stretch[K_S_ZZ]; - Scalar s_XY = stretch[K_S_XY]; - Scalar s_YZ = stretch[K_S_YZ]; - Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor forward - // - // Input: - // rotation(9) Rotation tensor - // orig_tensor(6) Input symmetric tensor - // - // Output: - // rot_tensor(6) Output symmetric tensor - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void rotate_tensor_forward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_YX] + orig_tensor[K_S_XZ]*rotation[K_F_ZX]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_YX] + orig_tensor[K_S_YZ]*rotation[K_F_ZX]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_YX] + orig_tensor[K_S_ZZ]*rotation[K_F_ZX]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_XY] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_ZY]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_XY] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_ZY]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_XY] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZY]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_XZ] + orig_tensor[K_S_XY]*rotation[K_F_YZ] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_XZ] + orig_tensor[K_S_YY]*rotation[K_F_YZ] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_XZ] + orig_tensor[K_S_ZY]*rotation[K_F_YZ] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_YX]*t_const[1] + rotation[K_F_ZX]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_XY]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_ZY]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_XZ]*t_const[6] + rotation[K_F_YZ]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_YX]*t_const[4] + rotation[K_F_ZX]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_XY]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_ZY]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_XZ]*t_const[0] + rotation[K_F_YZ]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor backward - // - // Input: - // rotation(9) Rotation tensor - // orig_tensor(6) Input symmetric tensor - // - // Output: - // rot_tensor(6) Output symmetric tensor - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void rotate_tensor_backward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_XY] + orig_tensor[K_S_XZ]*rotation[K_F_XZ]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_XY] + orig_tensor[K_S_YZ]*rotation[K_F_XZ]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_XY] + orig_tensor[K_S_ZZ]*rotation[K_F_XZ]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_YX] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_YZ]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_YX] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_YZ]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_YX] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_YZ]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_ZX] + orig_tensor[K_S_XY]*rotation[K_F_ZY] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_ZX] + orig_tensor[K_S_YY]*rotation[K_F_ZY] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_ZX] + orig_tensor[K_S_ZY]*rotation[K_F_ZY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_XY]*t_const[1] + rotation[K_F_XZ]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_YX]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_YZ]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_ZX]*t_const[6] + rotation[K_F_ZY]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_XY]*t_const[4] + rotation[K_F_XZ]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_YX]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_YZ]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_ZX]*t_const[0] + rotation[K_F_ZY]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor forward - // - // Input: - // rotation(4) Rotation tensor - // orig_tensor(3) Input symmetric tensor - // - // Output: - // rot_tensor(3) Output symmetric tensor - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void rotate_tensor_21_forward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor){ - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YX]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YX]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_YX]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_XY]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_YX]*t_const[3]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor backward - // - // Input: - // rotation(4) Rotation tensor - // orig_tensor(3) Input symmetric tensor - // - // Output: - // rot_tensor(3) Output symmetric tensor - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE void rotate_tensor_21_backward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor) - { - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_XY]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_XY]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_XY]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_YX]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_XY]*t_const[3]; - } - - /** - * Compute the dot product of two length 8 vectors - * - * Input - * x1(8) first vector - * x2(8) second vector - */ - TEMPLATE_SCALAR - inline Scalar ddot8(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2] + - x1[3] * x2[3] + - x1[4] * x2[4] + - x1[5] * x2[5] + - x1[6] * x2[6] + - x1[7] * x2[7]); - } - - /** - * Compute the dot product of two length 3 vectors - * - * Input - * x1(3) first vector - * x2(3) second vector - */ - TEMPLATE_SCALAR - inline Scalar ddot3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2]); - } - - /** - * Compute the dot product of two length 8 vectors using vector striding - * - * Input - * x1(8) first vector - * x2(8) second vector - */ - TEMPLATE_SCALAR - inline Scalar ddot8_stride1_stride3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[ 0] + - x1[1] * x2[ 3] + - x1[2] * x2[ 6] + - x1[3] * x2[ 9] + - x1[4] * x2[12] + - x1[5] * x2[15] + - x1[6] * x2[18] + - x1[7] * x2[21]); - } - - /** - * Rotate a [3,8] matrix into a [8,3] matrix - * - * Input: - * cur_coords Old matrix - * - * Output: - * cordel_ptr New matrix - */ - TEMPLATE_SCALAR - INLINE void transform_38_matrix_to_83_matrix(const Scalar *cordel_ptr, Scalar *cur_coords) { - cur_coords[0] = cordel_ptr[0]; - cur_coords[1] = cordel_ptr[3]; - cur_coords[2] = cordel_ptr[6]; - cur_coords[3] = cordel_ptr[9]; - cur_coords[4] = cordel_ptr[12]; - cur_coords[5] = cordel_ptr[15]; - cur_coords[6] = cordel_ptr[18]; - cur_coords[7] = cordel_ptr[21]; - - cur_coords[8] = cordel_ptr[1]; - cur_coords[9] = cordel_ptr[4]; - cur_coords[10] = cordel_ptr[7]; - cur_coords[11] = cordel_ptr[10]; - cur_coords[12] = cordel_ptr[13]; - cur_coords[13] = cordel_ptr[16]; - cur_coords[14] = cordel_ptr[19]; - cur_coords[15] = cordel_ptr[22]; - - cur_coords[16] = cordel_ptr[2]; - cur_coords[17] = cordel_ptr[5]; - cur_coords[18] = cordel_ptr[8]; - cur_coords[19] = cordel_ptr[11]; - cur_coords[20] = cordel_ptr[14]; - cur_coords[21] = cordel_ptr[17]; - cur_coords[22] = cordel_ptr[20]; - cur_coords[23] = cordel_ptr[23]; - } - - /** - * Add bulk viscosity terms to a set of symmetric 3x3 tensors. Bulk viscosity terms - * will only be added to the terms on the diagonal of the tensor. - * - * Input: - * Int num_elements : Number of input tensors - * Real *bulkq : Bulk viscosity term to add - * Real *stress_in : Input set of tensors - * - * Output: - * Real *stress_out : Modified output tensors - */ - TEMPLATE_SCALAR - INLINE void add_bulk_visc(const Int num_elements, const Scalar * bulkq, const Scalar * stress_in, Scalar * stress_out) { - for(Int ielem = 0; ielem < num_elements; ++ielem) { - stress_out[K_S_XX] = stress_in[K_S_XX] + bulkq[ielem]; - stress_out[K_S_YY] = stress_in[K_S_YY] + bulkq[ielem]; - stress_out[K_S_ZZ] = stress_in[K_S_ZZ] + bulkq[ielem]; - stress_out[K_S_XY] = stress_in[K_S_XY]; - stress_out[K_S_XZ] = stress_in[K_S_XZ]; - stress_out[K_S_YZ] = stress_in[K_S_YZ]; - stress_out += 6; - stress_in += 6; - } - } - - /** - * Compute the aspect ratio for an element - * - * Input: - * gradop12x(24) 12 times the gradient operator - * volume12x 12 times the element volume - */ - TEMPLATE_SCALAR - INLINE Scalar comp_aspect(const Scalar *const gradop12x, const Scalar &volume12x) { - return 6.0 * volume12x / - (gradop12x[0] * gradop12x[0]+ - gradop12x[1] * gradop12x[1]+ - gradop12x[2] * gradop12x[2]+ - gradop12x[3] * gradop12x[3]+ - gradop12x[4] * gradop12x[4]+ - gradop12x[5] * gradop12x[5]+ - gradop12x[6] * gradop12x[6]+ - gradop12x[7] * gradop12x[7]+ - gradop12x[8] * gradop12x[8]+ - gradop12x[9] * gradop12x[9]+ - gradop12x[10] * gradop12x[10]+ - gradop12x[11] * gradop12x[11]+ - gradop12x[12] * gradop12x[12]+ - gradop12x[13] * gradop12x[13]+ - gradop12x[14] * gradop12x[14]+ - gradop12x[15] * gradop12x[15]+ - gradop12x[16] * gradop12x[16]+ - gradop12x[17] * gradop12x[17]+ - gradop12x[18] * gradop12x[18]+ - gradop12x[19] * gradop12x[19]+ - gradop12x[20] * gradop12x[20]+ - gradop12x[21] * gradop12x[21]+ - gradop12x[22] * gradop12x[22]+ - gradop12x[23] * gradop12x[23]); - } - - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations after the element stress calculation - * - * Input: - * Int nelem Number of elements in workset - * Int dt Last step time step - * Real *cordel Element nodal coordinates - * Real *vel Element nodal velocities - * Real *rotation elemetn rotation tensor - * Real *stress_new The new element stress - * Real *rotated_stretching The element stretching rate tensor - * Real *spin_rate rigid body elemetn spining rate - * Real linBulkVisc Linear artificial bulk viscosity parameter - * Real quadBulkVisc Quadradic bulk viscosity parameter - * Real *elem_mass The element mass - * Real *elem_dilmod Element dilatation modulus as computed by the effective modulus routine - * Real *elem_shrmod Element shear modulus as coputed by the effective modulus routine - * Real hg_stiffness Element hourglass stiffness scaling constant - * Real hg_viscosity Element hourglass viscosity scaling constant - * - * Output: - * Real *rotated_stress Element rotated stress tensor - * Real min_elem_time_step New mimumum element based time step - * Real *volume Element end of step volume - * Real *elem_time_step Element time steps on per element basis - * Real *hg_resist_old Old hourglass resitance rate - * Real *hg_resist_new New hourglass resistance rate - * Real *force_new Computed internal force - * Real *hg_energy Per element hourglass force energy - * Real *int_energy Per element internal energy - * - * ********************************************************************************************** - */ - - //*************************************************************************************************************** - // - // Compute a set of 8 components for a gradient operator. - // - // 48*3 = 144 multiplications. - // - // Input - // grad_ptr(24) Array in which to store the current gradient operator components - // x(8) X nodal coordinates - // y(8) Y nodal coorindates - // z(8) Z nodal coordinates - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE - void comp_grad12x( Scalar *const grad_ptr, const Scalar * const x, const Scalar *const y, const Scalar *const z) { - Scalar R42=(z[3] - z[1]); - Scalar R52=(z[4] - z[1]); - Scalar R54=(z[4] - z[3]); - - Scalar R63=(z[5] - z[2]); - Scalar R83=(z[7] - z[2]); - Scalar R86=(z[7] - z[5]); - - Scalar R31=(z[2] - z[0]); - Scalar R61=(z[5] - z[0]); - Scalar R74=(z[6] - z[3]); - - Scalar R72=(z[6] - z[1]); - Scalar R75=(z[6] - z[4]); - Scalar R81=(z[7] - z[0]); - - Scalar t1 =(R63 + R54); - Scalar t2 =(R61 + R74); - Scalar t3 =(R72 + R81); - Scalar t4 =(R86 + R42); - Scalar t5 =(R83 + R52); - Scalar t6 =(R75 + R31); - - grad_ptr[0] = (y[1] * t1) - (y[2] * R42) - (y[3] * t5) + (y[4] * t4) + (y[5] * R52) - (y[7] * R54); - grad_ptr[1] = (y[2] * t2) + (y[3] * R31) - (y[0] * t1) - (y[5] * t6) + (y[6] * R63) - (y[4] * R61); - grad_ptr[2] = (y[3] * t3) + (y[0] * R42) - (y[1] * t2) - (y[6] * t4) + (y[7] * R74) - (y[5] * R72); - grad_ptr[3] = (y[0] * t5) - (y[1] * R31) - (y[2] * t3) + (y[7] * t6) + (y[4] * R81) - (y[6] * R83); - grad_ptr[4] = (y[5] * t3) + (y[6] * R86) - (y[7] * t2) - (y[0] * t4) - (y[3] * R81) + (y[1] * R61); - grad_ptr[5] = (y[6] * t5) - (y[4] * t3) - (y[7] * R75) + (y[1] * t6) - (y[0] * R52) + (y[2] * R72); - grad_ptr[6] = (y[7] * t1) - (y[5] * t5) - (y[4] * R86) + (y[2] * t4) - (y[1] * R63) + (y[3] * R83); - grad_ptr[7] = (y[4] * t2) - (y[6] * t1) + (y[5] * R75) - (y[3] * t6) - (y[2] * R74) + (y[0] * R54); - - R42=(x[3] - x[1]); - R52=(x[4] - x[1]); - R54=(x[4] - x[3]); - - R63=(x[5] - x[2]); - R83=(x[7] - x[2]); - R86=(x[7] - x[5]); - - R31=(x[2] - x[0]); - R61=(x[5] - x[0]); - R74=(x[6] - x[3]); - - R72=(x[6] - x[1]); - R75=(x[6] - x[4]); - R81=(x[7] - x[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[8 ] = (z[1] * t1) - (z[2] * R42) - (z[3] * t5) + (z[4] * t4) + (z[5] * R52) - (z[7] * R54); - grad_ptr[9 ] = (z[2] * t2) + (z[3] * R31) - (z[0] * t1) - (z[5] * t6) + (z[6] * R63) - (z[4] * R61); - grad_ptr[10] = (z[3] * t3) + (z[0] * R42) - (z[1] * t2) - (z[6] * t4) + (z[7] * R74) - (z[5] * R72); - grad_ptr[11] = (z[0] * t5) - (z[1] * R31) - (z[2] * t3) + (z[7] * t6) + (z[4] * R81) - (z[6] * R83); - grad_ptr[12] = (z[5] * t3) + (z[6] * R86) - (z[7] * t2) - (z[0] * t4) - (z[3] * R81) + (z[1] * R61); - grad_ptr[13] = (z[6] * t5) - (z[4] * t3) - (z[7] * R75) + (z[1] * t6) - (z[0] * R52) + (z[2] * R72); - grad_ptr[14] = (z[7] * t1) - (z[5] * t5) - (z[4] * R86) + (z[2] * t4) - (z[1] * R63) + (z[3] * R83); - grad_ptr[15] = (z[4] * t2) - (z[6] * t1) + (z[5] * R75) - (z[3] * t6) - (z[2] * R74) + (z[0] * R54); - - R42=(y[3] - y[1]); - R52=(y[4] - y[1]); - R54=(y[4] - y[3]); - - R63=(y[5] - y[2]); - R83=(y[7] - y[2]); - R86=(y[7] - y[5]); - - R31=(y[2] - y[0]); - R61=(y[5] - y[0]); - R74=(y[6] - y[3]); - - R72=(y[6] - y[1]); - R75=(y[6] - y[4]); - R81=(y[7] - y[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[16] = (x[1] * t1) - (x[2] * R42) - (x[3] * t5) + (x[4] * t4) + (x[5] * R52) - (x[7] * R54); - grad_ptr[17] = (x[2] * t2) + (x[3] * R31) - (x[0] * t1) - (x[5] * t6) + (x[6] * R63) - (x[4] * R61); - grad_ptr[18] = (x[3] * t3) + (x[0] * R42) - (x[1] * t2) - (x[6] * t4) + (x[7] * R74) - (x[5] * R72); - grad_ptr[19] = (x[0] * t5) - (x[1] * R31) - (x[2] * t3) + (x[7] * t6) + (x[4] * R81) - (x[6] * R83); - grad_ptr[20] = (x[5] * t3) + (x[6] * R86) - (x[7] * t2) - (x[0] * t4) - (x[3] * R81) + (x[1] * R61); - grad_ptr[21] = (x[6] * t5) - (x[4] * t3) - (x[7] * R75) + (x[1] * t6) - (x[0] * R52) + (x[2] * R72); - grad_ptr[22] = (x[7] * t1) - (x[5] * t5) - (x[4] * R86) + (x[2] * t4) - (x[1] * R63) + (x[3] * R83); - grad_ptr[23] = (x[4] * t2) - (x[6] * t1) + (x[5] * R75) - (x[3] * t6) - (x[2] * R74) + (x[0] * R54); - } - - //*************************************************************************************************************** - // - // Compute the hourglass operator - // - // Input: - // x_ptr, y_ptr, z_ptr The x, y, and z nodal coordinates - // - // gradop12x_ptr_x 12 times the gradient operator components - // gradop12x_ptr_y 12 times the gradient operator components - // gradop12x_ptr_z 12 times the gradient operator components - // - // volinv12th The inverse of the element voluem, times one 12th - // - //*************************************************************************************************************** - TEMPLATE_SCALAR - INLINE - void comp_hgop(const Scalar *const x, const Scalar *const y, const Scalar * const z, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - const Scalar volinv12th, - Scalar *const hgop) { - - // - // KHP: Perhaps, this array should be passed in from the calling - // routine? - // - const Scalar hgop_arr[32] = { 1.0, 1.0,-1.0,-1.0,-1.0,-1.0, 1.0, 1.0, - 1.0,-1.0,-1.0, 1.0,-1.0, 1.0, 1.0,-1.0, - 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, - -1.0, 1.0,-1.0, 1.0, 1.0,-1.0, 1.0,-1.0}; - - // KHP: Alternatively, we could have - // hx0,hx1,hx2,hx3,...,hz0,hz1,hz2,hz3 - Scalar hgconst12th[12]; - - Scalar t0 = x[0] - x[1]; - Scalar t1 = x[2] - x[3]; - Scalar t2 = x[4] - x[5]; - Scalar t3 = x[6] - x[7]; - - hgconst12th[0] = ( (x[0]+x[1]) - (x[2]+x[3]) - (x[4]+x[5]) + (x[6]+x[7]) ) * volinv12th; - hgconst12th[1] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[2] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[3] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (y[0] - y[1]); - t1 = (y[2] - y[3]); - t2 = (y[4] - y[5]); - t3 = (y[6] - y[7]); - - hgconst12th[4] = ( (y[0]+y[1]) - (y[2]+y[3]) - (y[4]+y[5]) + (y[6]+y[7]) ) * volinv12th; - hgconst12th[5] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[6] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[7] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (z[0] - z[1]); - t1 = (z[2] - z[3]); - t2 = (z[4] - z[5]); - t3 = (z[6] - z[7]); - - hgconst12th[8] = ( (z[0]+z[1]) - (z[2]+z[3]) - (z[4]+z[5]) + (z[6]+z[7]) ) * volinv12th; - hgconst12th[9] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[10] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[11] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - // 8 times 12 = 96 + 12 = 108 multiplications. - for(int i = 0; i < 8; ++i) { - hgop[i ] = hgop_arr[i ] - (hgconst12th[0] * gradop12x_ptr_x[i] + hgconst12th[4] * gradop12x_ptr_y[i] + hgconst12th[8 ] * gradop12x_ptr_z[i]); - hgop[i+8 ] = hgop_arr[i+8 ] - (hgconst12th[1] * gradop12x_ptr_x[i] + hgconst12th[5] * gradop12x_ptr_y[i] + hgconst12th[9 ] * gradop12x_ptr_z[i]); - hgop[i+16] = hgop_arr[i+16] - (hgconst12th[2] * gradop12x_ptr_x[i] + hgconst12th[6] * gradop12x_ptr_y[i] + hgconst12th[10] * gradop12x_ptr_z[i]); - hgop[i+24] = hgop_arr[i+24] - (hgconst12th[3] * gradop12x_ptr_x[i] + hgconst12th[7] * gradop12x_ptr_y[i] + hgconst12th[11] * gradop12x_ptr_z[i]); - } - } - - //*************************************************************************************************************** - // - // Compute the new internal forces, hg resistances, and element energies - // - // Input: - // dt last time step - // spin_rate_ptr pointer into the spin rate array - // hgop element hourglass operator - // vel_ptr element velocity - // fac1 hourglass stiffness resitance factor - // fac2 hourglass viscosity resitance factor - // hg_resist_old_ptr Old hourglass resitances - // - // Output: - // hg_resist_new_ptr New hourglass resitances - // hg_resist_total_ptr Total hourglass resistance - // - //*************************************************************************************************************** - - TEMPLATE_SCALAR - INLINE - void comp_force(const Scalar &dt, - const Scalar *const spin_rate_ptr, - const Scalar *const hgop_for_resist_calc, - const Scalar *const hgop_ptr0, - const Scalar *const hgop_ptr1, - const Scalar *const hgop_ptr2, - const Scalar *const hgop_ptr3, - const Scalar *const vel, - const Scalar &fac1, - const Scalar &fac2, - const Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - const Scalar *const total_stress12th, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const force_new, - bool scaleHGRotation) { - - // - // NKC, does Presto Scalar need these spin rate terms? Pronto appears to have dumped them.... - // - const Scalar dwxy = dt * spin_rate_ptr[0]; - const Scalar dwyz = dt * spin_rate_ptr[1]; - const Scalar dwzx = dt * spin_rate_ptr[2]; - // - // Compute new hourglass resitance by the old rotated hourglass resitance plus a hourglass rate term - // - Scalar hg_resist_total[12]; - Scalar * hg_resist_total_ptr = hg_resist_total; - const Scalar * hgop_ptr = hgop_for_resist_calc; - const Scalar * vel_ptr = vel; - const Scalar * hg_resist_old_ptr = hg_resist_old; - Scalar * hg_resist_new_ptr = hg_resist_new; - Scalar * hg_energy_ptr = hg_energy; - Scalar * int_energy_ptr = int_energy; - Scalar * force_new_ptr = force_new; - - if (!scaleHGRotation){ - for(int i = 0; i < 4; ++i) { - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - hg_resist_new_ptr[0] = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2 + fac1* hg_rate_0 ; - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2* hg_rate_0 ; - - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - hg_resist_new_ptr[1] = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2 + fac1* hg_rate_1 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2* hg_rate_1 ; - - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - hg_resist_new_ptr[2] = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1 + fac1* hg_rate_2 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2* hg_rate_2 ; - - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } else { - for(int i = 0; i < 4; ++i) { - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar rot_hg_resist_old_0 = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2; - const Scalar rot_hg_resist_old_1 = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2; - const Scalar rot_hg_resist_old_2 = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1; - - Scalar fnorm = rot_hg_resist_old_0 *rot_hg_resist_old_0 + rot_hg_resist_old_1 *rot_hg_resist_old_1 + rot_hg_resist_old_2 *rot_hg_resist_old_2 ; - if (fnorm > 1.e-30){ - fnorm = sqrt ( (hg_resist_old_0*hg_resist_old_0 + - hg_resist_old_1*hg_resist_old_1 + - hg_resist_old_2*hg_resist_old_2) / fnorm ); - hg_resist_new_ptr[0] = fnorm*rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = fnorm*rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = fnorm*rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } else { - hg_resist_new_ptr[0] = rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2*hg_rate_0 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2*hg_rate_1 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2*hg_rate_2 ; - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } - - *hg_energy_ptr = 0.0; - *int_energy_ptr = 0.0; - for(int i = 0; i < 8; ++i) { - const Scalar hg_force_0 = - (hg_resist_total[HG_X1] * hgop_ptr0[i] + - hg_resist_total[HG_X2] * hgop_ptr1[i] + - hg_resist_total[HG_X3] * hgop_ptr2[i] + - hg_resist_total[HG_X4] * hgop_ptr3[i]); - - force_new_ptr[0] = - total_stress12th[K_S_XX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_XY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_XZ] * gradop12x_ptr_z[i] + hg_force_0 ; - - const Scalar hg_force_1 = - (hg_resist_total[HG_Y1] * hgop_ptr0[i] + - hg_resist_total[HG_Y2] * hgop_ptr1[i] + - hg_resist_total[HG_Y3] * hgop_ptr2[i] + - hg_resist_total[HG_Y4] * hgop_ptr3[i]); - - force_new_ptr[1] = - total_stress12th[K_S_YX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_YY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_YZ] * gradop12x_ptr_z[i] + hg_force_1 ; - - const Scalar hg_force_2 = - (hg_resist_total[HG_Z1] * hgop_ptr0[i] + - hg_resist_total[HG_Z2] * hgop_ptr1[i] + - hg_resist_total[HG_Z3] * hgop_ptr2[i] + - hg_resist_total[HG_Z4] * hgop_ptr3[i]); - - force_new_ptr[2] = - total_stress12th[K_S_ZX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_ZY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_ZZ] * gradop12x_ptr_z[i] + hg_force_2 ; - - *hg_energy_ptr += hg_force_0 *vel_ptr[0] + hg_force_1 *vel_ptr[1] + hg_force_2 *vel_ptr[2]; - *int_energy_ptr += force_new_ptr[0]*vel_ptr[0] + force_new_ptr[1]*vel_ptr[1] + force_new_ptr[2]*vel_ptr[2]; - - - force_new_ptr += 3; - vel_ptr += 3; - } - ++hg_energy_ptr ; - ++int_energy_ptr ; - } - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations required for the material stress calculations. - * - * Input: - * Int nelem Number of elements in workset - * Scalar dt_scale Should be -0.5*delta_t, describes how to move the coordinates - * from the end of step to the mid-step using the velocities. - * Scalar *cordel Array of element nodal coordinates - * Scalar *vel Array of element nodal velocities - * Scalar *rotation_old Array of old roation tensors - * - * Output: - * Scalar *mid_volume Compute element volume from the mid step coordinates - * Scalar *vorticity Asymmetric portion of the element stretch tensor - * Scalar *rotation_new Updated material rotation tensors - * Scalar *stretch New element stretch - * Real *rotated_stretching Rotated element stretching tensor - * - * ********************************************************************************************** - */ - TEMPLATE_SCALAR - INLINE Int elem_ug3dh8_mi_compute_stretch(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation_old, - Scalar *const mid_vol, - Scalar *const vorticity, - Scalar *const rotation_new, - Scalar *const stretch, - Scalar *const rotated_stretching, - Scalar *const mid_hgop) { - - // - // Extract pointers to the input variables, set up any required temporary variables. The temporaries will - // be reused by every element in the workset. - // - const Scalar * cordel_ptr (cordel ); - const Scalar * vel_ptr (vel ); - Scalar * mid_vol_ptr (mid_vol ); - Scalar * vorticity_ptr(vorticity); - const Scalar * rotation_old_ptr(rotation_old); - Scalar * rotation_new_ptr(rotation_new); - Scalar * stretch_ptr(stretch); - Scalar * rotated_stretching_ptr(rotated_stretching); - Scalar * mid_hgop_ptr(mid_hgop); - // - // Storage for the midstep gradient operator, 12x denotes that this will actually be the midstep gradient - // operator components. - // - Scalar mid_gradop12x[24]; - Scalar *const mid_gradop12x_ptr_x(mid_gradop12x); - Scalar *const mid_gradop12x_ptr_y(mid_gradop12x+8); - Scalar *const mid_gradop12x_ptr_z(mid_gradop12x+16); - // - // Midstep coordinates - // - Scalar mid_coords[24]; - Scalar *const x_ptr(mid_coords); - Scalar *const y_ptr(mid_coords+8); - Scalar *const z_ptr(mid_coords+16); - // - // Element stretching tensor - // - Scalar stretching_tensor[6]; - // - // Element velocity gradient - // - Scalar vel_grad[9]; - // - // Loop over all elements in the workset - // - Scalar dt_scale = -0.5 * dt; - - Int return_value = 0; - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Get current element coordinates and update them so that they reference the midstep - // configuration. Note, this routine changes the coordinate ordering from - // - // (x1, y1, z1, x2, y2, z2, ........) - // - // to - // - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3 ......) - // - // The array reordering allows better variable access later for optimization purposes - // - for(int i = 0; i < 8; ++i) { - x_ptr[i] = cordel_ptr[0] + dt_scale * vel_ptr[0]; - y_ptr[i] = cordel_ptr[1] + dt_scale * vel_ptr[1]; - z_ptr[i] = cordel_ptr[2] + dt_scale * vel_ptr[2]; - //std::cout << "KHP: x= " << x_ptr[i] << ", " << y_ptr[i] << ", " << z_ptr[i] << "\n"; - //std::cout << "KHP: C= " << cordel_ptr[0] << ", " << cordel_ptr[1] << ", " << cordel_ptr[2] << "\n"; - //std::cout << "KHP: V= " << vel_ptr[0] << ", " << vel_ptr[1] << ", " << vel_ptr[2] << "\n"; - cordel_ptr += 3; - vel_ptr += 3; - } - - vel_ptr -= 24; - // - // Do grad op in three seperate steps using the helper routine. - // NKC, I'm not positive what the helper is mathematically equivalent too, - // however, the combination of these three steps will compute the full gradient. - // Note, the comp12x routine actually calculates 12.0 times the gradient, this - // 12 will be factored out later. - // - comp_grad12x(mid_gradop12x, x_ptr, y_ptr, z_ptr); - - // - // Compute the midstep volume. Note that 12 times the volume is being calculated, - // The actually output value of volume is then multipled by one twelth - // - const Scalar volume12x = ddot8(x_ptr, mid_gradop12x_ptr_x); - *mid_vol_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the velocity gradients from the dot products of the input velocities with the - // relevant columns of the gradient operator. Note that the velocity gradient is calculated - // as Velocity * 12 * mid_gradop * volinv/12, the twelves cancel. - // - // 81 multiplications (9 tensor entries * (8 mults per dot + 1 mult for volinv)) - // - vel_grad[K_F_XX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr ) * volinv12th; - vel_grad[K_F_XY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr ) * volinv12th; - vel_grad[K_F_XZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr ) * volinv12th; - vel_grad[K_F_YZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+1) * volinv12th; - vel_grad[K_F_YY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+1) * volinv12th; - vel_grad[K_F_YX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+1) * volinv12th; - vel_grad[K_F_ZX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+2) * volinv12th; - // - // Compute the stretching tensors from the current velocity gradient - // - // Let G = Gradient (velocity gradient in this case). - // Let S = Stretch - // Let V = Vorticity - // - // Then: - // - // S = 0.5 * ( G + G'); // S = 0.5 * ( G + transpose(G)); - // V = 0.5 * ( G - G'); // V = 0.5 * ( G - transpose(G)); - // - APS::Hex::additive_decomp36(vel_grad, stretching_tensor, vorticity_ptr); - - polar_decomp33r2(dt, stretching_tensor, vorticity_ptr, rotation_old_ptr, stretch_ptr, rotation_new_ptr); - - rotate_tensor_forward(rotation_new_ptr, stretching_tensor, rotated_stretching_ptr); - - // - // Compute the midstep hourglass operator if needed. Here one 12th the volume is - // multiplied by 12 times the gradient operators, so the true hourglass operator - // is computed. - // - if (mid_hgop_ptr) { - comp_hgop(x_ptr, y_ptr, z_ptr, - mid_gradop12x_ptr_x, - mid_gradop12x_ptr_y, - mid_gradop12x_ptr_z, - volinv12th, mid_hgop_ptr); - mid_hgop_ptr += 32; - } - - } else { - return_value = -1; - } - ++mid_vol_ptr ; - vel_ptr += 24; - vorticity_ptr +=3; - rotation_old_ptr += 9; - stretch_ptr += 6; - rotation_new_ptr += 9; - rotated_stretching_ptr += 6; - } - return return_value; - } - - //*********************************************************************n - // - // STANDARD PRESTO VERSION - // - // description: - // This routine is implemented for the 8 node brick, uniform strain - // element. It is the divergence operator, hourglass force operator, - // and time step calcuator. Combination of multiple routines yields - // better cache usage. - // - // Input: - // nelem Number of elements in the workset - // - // dt Previous time step - // - // cordel(24,nelem) End of step element coordinates, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // vel(24,nelem) Element nodal velocity, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // rotated_stress(6,nelem) Element stress in the rotated configuration - // - // rotated_stretching(6,nelem) Element stretch rate tensor in rotated configuration - // - // spin_rate(3,nelem) Asymmetric portion of stretching rate, represents amount element is spinning - // about each axis. - // - // linBulkVisc Linear bulk viscosity material constant - // - // quadBulkVisc Quadradic bulk viscosity material constant - // - // elem_mass(nelem) Current element masses - // - // elem_dilmod(nelem) Current material dilitational modulus - // - // elem_shrmod(nelem) Current material shear modulus - // - // hg_stiffness Hourglass stiffness parameter - // - // hg_viscosity Hourglass viscosity parameter - // - // hg_resist_old(12,nelem) Old hourglass resistance - // - // Output: - // min_elem_time_step The computed mimimum stable element time step - // - // volume(nelem) The element end of step volume - // - // elem_time_step(nelem) Time steps on a per element basis - // - // hg_resist_new(12,nelem) New hourglass resistance - // - // force_new(24,nelem) New element total internal force - // - // hg_energy(nelem) New element total hourglass energy increment - // - // int_energy(ielem) New element internal energy increment - // - // Returns, 0 if no errors, -1 if any negative volume elements were found - // - //*********************************************************************** - - TEMPLATE_SCALAR - INLINE - Int elem_ug3dh8_mi_compute_divergence_presto(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation, - const Scalar *const stress_new, - const Scalar *const rotated_stretching, - const Scalar *const spin_rate, - const Scalar linBulkVisc, - const Scalar quadBulkVisc, - const Scalar *const elem_mass, - const Scalar *const elem_dilmod, - const Scalar *const elem_shrmod, - const Scalar hg_stiffness, - const Scalar hg_viscosity, - Scalar *const rotated_stress, - Scalar &min_elem_time_step, - Scalar *const volume, - Scalar *const elem_time_step, - Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - Scalar *const force_new, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const mid_hgop, - const bool scaleHGRotation) { - Int return_value = 0; - // - // Store pointers to the input variables - // - const Scalar * cordel_ptr(cordel); - const Scalar * vel_ptr(vel); - const Scalar * elem_mass_ptr(elem_mass); - const Scalar * elem_dilmod_ptr(elem_dilmod); - const Scalar * elem_shrmod_ptr(elem_shrmod); - const Scalar * rotated_stretching_ptr(rotated_stretching); - const Scalar * spin_rate_ptr(spin_rate); - const Scalar * stress_new_ptr(stress_new); - const Scalar * rotation_ptr(rotation); - - Scalar * rotated_stress_ptr(rotated_stress); - Scalar * volume_ptr(volume); - Scalar * elem_time_step_ptr(elem_time_step); - Scalar * hg_resist_old_ptr(hg_resist_old); - Scalar * hg_resist_new_ptr(hg_resist_new); - Scalar * force_new_ptr(force_new); - Scalar * hg_energy_ptr(hg_energy); - Scalar * int_energy_ptr(int_energy); - // - // Create temporaries to be reused by every element - // - Scalar gradop12x[24]; - Scalar * gradop12x_ptr_x(gradop12x); - Scalar * gradop12x_ptr_y(gradop12x+8); - Scalar * gradop12x_ptr_z(gradop12x+16); - - Scalar cur_coords[24]; - const Scalar *const x_ptr(cur_coords); - const Scalar *const y_ptr(cur_coords+8); - const Scalar *const z_ptr(cur_coords+16); - - Scalar total_stress12th[6]; - - Scalar hgop[32]; - const Scalar *const hgop_ptr0(hgop); - const Scalar *const hgop_ptr1(hgop+8); - const Scalar *const hgop_ptr2(hgop+16); - const Scalar *const hgop_ptr3(hgop+24); - Scalar * hgop_for_resist_calc(mid_hgop); - if (mid_hgop == NULL){ - hgop_for_resist_calc = hgop; - } - // - // This factor will be used in hourglass computations, however is a loop constant - // - const Scalar fac1_pre(dt * hg_stiffness * 0.0625); - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Store local coordintes, note this changes the way coordinates are stored from - // - // (x1, y1, z1, x2, y2, z2 .......) - // to - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3, .....) - // - transform_38_matrix_to_83_matrix(cordel_ptr, cur_coords); - // - // Compute 12 times the gradient operator in three seperate steps - // - comp_grad12x(gradop12x, x_ptr, y_ptr, z_ptr); - // - // calculate 12 times the element volume, store the actual element volume - // - const Scalar volume12x = ddot8(x_ptr, gradop12x); - *volume_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - if(volume12x > 0.0) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the aspect ratio. Aspect ratio is 0.5 * volume / (grad . grad) - // With the 12 factors this is actually 6.0 * 12 * volume / (12 * grad . 12 * grad) - // - const Scalar aspect = comp_aspect(gradop12x, volume12x); - const Scalar aspect_inv = 1.0/aspect; - // - // Compute the stable time step and bulk viscosity - // - const Scalar dtrial(sqrt(elem_mass_ptr[0] * aspect / elem_dilmod_ptr[0])); - - const Scalar traced(rotated_stretching_ptr[0] + rotated_stretching_ptr[1] + rotated_stretching_ptr[2]); - - const Scalar eps(linBulkVisc - quadBulkVisc * std::min(0.0, traced)*dtrial); - - const Scalar bulkq = eps * elem_dilmod_ptr[0] *dtrial *traced; - - const Scalar cur_time_step = dtrial * ( sqrt( 1.0 + eps * eps) - eps); - *elem_time_step_ptr = cur_time_step; - min_elem_time_step = std::min(min_elem_time_step, cur_time_step); - // - // Rotate the stress - // - rotate_tensor_backward(rotation_ptr, stress_new_ptr, rotated_stress_ptr); - // - // Compute the total stress (includes bulk viscosity terms) - // - total_stress12th[0] = ONE12TH*(rotated_stress_ptr[0] + bulkq); - total_stress12th[1] = ONE12TH*(rotated_stress_ptr[1] + bulkq); - total_stress12th[2] = ONE12TH*(rotated_stress_ptr[2] + bulkq); - total_stress12th[3] = ONE12TH*(rotated_stress_ptr[3]); - total_stress12th[4] = ONE12TH*(rotated_stress_ptr[4]); - total_stress12th[5] = ONE12TH*(rotated_stress_ptr[5]); - // - // Compute the hourglass operator. Here one 12th the volume is multiplied by - // 12 times the gradient operators, so the true hourglass operator is computed. - // - comp_hgop(x_ptr, y_ptr, z_ptr, - gradop12x_ptr_x, - gradop12x_ptr_y, - gradop12x_ptr_z, - volinv12th, hgop); - // - // Compute the hourglass resistance terms. These are based on the hourglass stiffness and hourglass viscosities - // - const Scalar fac1 = fac1_pre * elem_shrmod_ptr[0] * aspect_inv; - const Scalar fac2 = hg_viscosity * sqrt(elem_shrmod_ptr[0] * elem_mass_ptr[0] * aspect_inv); - comp_force(dt, - spin_rate_ptr, - hgop_for_resist_calc, - hgop_ptr0, hgop_ptr1, hgop_ptr2, hgop_ptr3, - vel_ptr, fac1, fac2, hg_resist_old_ptr, hg_resist_new_ptr, - total_stress12th, - gradop12x_ptr_x, gradop12x_ptr_y, gradop12x_ptr_z, - hg_energy_ptr, int_energy_ptr, force_new_ptr, scaleHGRotation); - } else { - return_value = -1; - } - - cordel_ptr += 24; - vel_ptr += 24; - ++volume_ptr ; - ++elem_mass_ptr ; - ++elem_dilmod_ptr ; - ++elem_shrmod_ptr ; - ++elem_time_step_ptr ; - rotation_ptr += 9; - stress_new_ptr += 6; - rotated_stress_ptr += 6; - rotated_stretching_ptr += 6; - spin_rate_ptr += 3; - hg_resist_old_ptr += 12; - hg_resist_new_ptr += 12; - ++hg_energy_ptr ; - ++int_energy_ptr ; - force_new_ptr += 24; - if (mid_hgop){ - hgop_for_resist_calc += 32; - } - } - return return_value; - } - - } // end namespace Hex -} // end namespace APS - -class APSHex8ug { - public: - APSHex8ug() - {} - ~APSHex8ug() - {} - - int num_nodes() const { return 8; } - - int compute_stretch( const int num_elements, - const double dt, - const double *coordinates, - const double *velocity, - const double *rotation_old, - double *volume, - double *vorticity_tensor, - double *rotation_new, - double *stretch, - double *strain_rate, - double *mid_hgop, - bool debug = false - ) const { - int err = APS::Hex::elem_ug3dh8_mi_compute_stretch(num_elements, - dt, - coordinates, - velocity, - rotation_old, - volume, - vorticity_tensor, - rotation_new, - stretch, - strain_rate, - mid_hgop); - - return err; - } - - int internalForce( const int num_elements, - const double dt, - double current_stable_time_step, - double element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - std::vector &coordinates, - std::vector &velocity, - std::vector &rotation_old, std::vector &rotation_new, - std::vector &midstep_volume, - std::vector &vorticity_tensor, - std::vector &stretch, - std::vector &strain_rate, - std::vector &mid_hgop, - std::vector &stress_old, std::vector &stress_new, - std::vector &rotated_stress, - std::vector &material_eff_bulk_mod, - std::vector &material_eff_twomu, - std::vector &shrmod, - std::vector &dilmod, - std::vector &element_mass, - std::vector &force_new, - std::vector &hourglass_energy, - std::vector &internal_energy, - std::vector &hg_resistance_old, std::vector &hg_resistance_new - ) const { - - compute_stretch(num_elements, dt, &coordinates[0], &velocity[0], &rotation_old[0], &midstep_volume[0], &vorticity_tensor[0], &rotation_new[0], &stretch[0], &strain_rate[0], &mid_hgop[0]); - - Int err = material_model.getStress(&materialParameters); - ThrowErrorMsgIf( err, "getStress failed" ); - - double dilatationalHGParam = 0.05; - double deviatoricHGParam = 0.0; - - for(int k=0; k 0.0) ? 1.0 / dt : 1.0; - - for ( int i = 0 ; i < 24 ; i++ ) { - vel[i] *= dt_inv; - } - } - private: - double * dgrad; - - DefGradBC(const DefGradBC &); - void operator = (const DefGradBC &); -}; - -int use_case_14(); - -#undef INLINE /* */ - -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_23.cpp b/packages/stk/stk_classic/stk_usecases/mesh/UseCase_23.cpp deleted file mode 100644 index dfa90aadba75..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_23.cpp +++ /dev/null @@ -1,779 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author H. Carter Edwards - * @date June 2008 - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case 23: internal force computation with -// a demonstration of part properties. -// The function 'use_case_23_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -enum { SpatialDim = 3 }; - -namespace { - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::fem::FEMMetaData& meta_data) -{ - return meta_data.element_rank(); -} - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::Part& part) -{ - return get_element_rank(stk_classic::mesh::fem::FEMMetaData::get(part)); -} - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() , n1 ); -} - - -CartesianField & -declare_vector_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -ScalarField & -declare_scalar_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() ); -} - - -SymmetricTensorField & -declare_symmetric_tensor_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 ); - return f ; -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & put_field_on_all_elements( stk_classic::mesh::Field & f , unsigned n1 ) -{ - put_field_on_elements( f , stk_classic::mesh::fem::FEMMetaData::get(f).universal_part() , n1 ); - return f ; -} - -} // namespace - -void use_case_23_driver( - MPI_Comm comm , - const std::string & file_name , - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ); - -//-------------------------------------------------------------------- -// -// main driver for use-case 23: element internal force with Property usage. -// - -void use_case_23_driver( MPI_Comm comm , bool performance_test ) -{ - int num_procs = stk_classic::parallel_machine_size( comm ); - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout << " stk_mesh Use Case #23 - element internal force with part properties, begin" << std::endl ; - } - - if ( ! performance_test ) { - // Quick & small test for correctness: - const unsigned a_box_size[3] = { 10 , 10 , 10*num_procs }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - int num_trials = 1; - use_case_23_driver( comm , "use_case_23.exo" , a_box_size , a_box_sides , num_trials ); - } - else { - int num_trials = 582 ; // 582 ; - - const unsigned a_box_size[3] = { 100 , 100 , 100 }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - std::cout << "Running 100x100x100 case, num_trials = " << num_trials << std::endl; - - use_case_23_driver( comm , "use_case_23a.exo" , a_box_size , a_box_sides , num_trials ); - - const unsigned b_box_size[3] = { 100 , 125 , 10*num_procs }; - const unsigned b_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - std::cout << "Running 100x125x10*nprocs case, num_trials = " << num_trials << std::endl; - - use_case_23_driver( comm , "use_case_23b.exo" , b_box_size , b_box_sides , num_trials ); - } -} - -//-------------------------------------------------------------------- - -inline -void zero_data( double * beg , double * const end ) -{ while ( beg < end ) { *beg++ = 0 ; } } - -template< class FieldType > -void zero_field_data( stk_classic::mesh::BulkData & mesh , unsigned type , const FieldType & field ) -{ - typedef stk_classic::mesh::BucketArray< FieldType > array_type ; - - const std::vector & ks = mesh.buckets( type ); - - for ( std::vector::const_iterator ik = ks.begin() ; ik != ks.end() ; ++ik ) { - stk_classic::mesh::Bucket & bucket = **ik ; - array_type data( field , bucket ); - zero_data( data.contiguous_data() , data.contiguous_data() + data.size() ); - } -} - -//-------------------------------------------------------------------- - - -void use_case_23_driver( - MPI_Comm comm , - const std::string & /*file_name */, - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ) -{ - //---------------------------------- - - APSHex8ug hex_element; - - lame::matParams materialParameters; - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - // [4] = Parallel swap-add of internal force - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case #23" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data and bulk data. - - stk_classic::mesh::fem::FEMMetaData mesh_meta_data( SpatialDim ); - const stk_classic::mesh::EntityRank element_rank = mesh_meta_data.element_rank(); - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data.get_meta_data(mesh_meta_data), MPI_COMM_WORLD, 1000 ); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", element_rank); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - - double dt = 1.0e-02; - double YM = 1e7; // Young's Modulus - double PR = 0.33; // Poisson Ratio - double element_mass_dummy_value = 1.0; - std::string material_model_name("ELASTIC"); - - double current_stable_time_step = dt; - - - //------------------------ - //store dt on the mesh_meta_data as a Part property on the part 'block_hex' - - stk_classic::mesh::Property& delta_t = mesh_meta_data.get_meta_data(mesh_meta_data).declare_property("dt"); - - mesh_meta_data.get_meta_data(mesh_meta_data).put_property( delta_t, block_hex ); - - double* delta_t_ptr = stk_classic::mesh::property_data(delta_t, block_hex); - - *delta_t_ptr = dt; - - - //------------------------ - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - lame::MatProps materialProperties; - - std::vector youngs_modulus; youngs_modulus.push_back(YM); - std::vector poissons_ratio; poissons_ratio.push_back(PR); - std::vector bulk_modulus; bulk_modulus.push_back(BM); - std::vector shear_modulus; shear_modulus.push_back(SM); - std::vector two_mu; two_mu.push_back(TM); - std::vector lambda; lambda.push_back(LAMBDA); - std::vector dilatational_modulus; dilatational_modulus.push_back(DM); - - materialProperties["YOUNGS_MODULUS"] = youngs_modulus; - materialProperties["POISSONS_RATIO"] = poissons_ratio; - materialProperties["BULK_MODULUS"] = bulk_modulus; - materialProperties["SHEAR_MODULUS"] = shear_modulus; - materialProperties["TWO_MU"] = two_mu; - materialProperties["LAMBDA"] = lambda; - materialProperties["DILATATIONAL_MODULUS"] = dilatational_modulus; - - lame::Material * matmodel = lame::Elastic::createMaterial( materialProperties ); - - - //------------------------ - //store materialProperties on the mesh_meta_data as a Part property on the part 'block_hex' - - stk_classic::mesh::Property& mprops = mesh_meta_data.get_meta_data(mesh_meta_data).declare_property("materialProperties"); - mesh_meta_data.get_meta_data(mesh_meta_data).put_property(mprops, block_hex); - - lame::MatProps* mprops_ptr = stk_classic::mesh::property_data(mprops, block_hex); - - *mprops_ptr = materialProperties; - - - //-------------------------------- - - // Nodal vector fields - CartesianField &model_coordinates = declare_vector_field_on_all_nodes( mesh_meta_data , "model_coordinates" , SpatialDim ); - CartesianField &coordinates_field = declare_vector_field_on_all_nodes( mesh_meta_data , "coordinates" , SpatialDim ); - CartesianField &velocity_field = declare_vector_field_on_all_nodes( mesh_meta_data , "velocity" , SpatialDim ); - CartesianField &fint_field = declare_vector_field_on_all_nodes( mesh_meta_data , "force_internal" , SpatialDim ); - - // Element vector fields: - CartesianField &Vorticity = declare_vector_field_on_all_elements( mesh_meta_data , "Vorticity" , SpatialDim ); - - // Element scalar fields: - ScalarField &Shear_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "shear_modulus" ); - ScalarField &Dilatational_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "dilatational_modulus"); - ScalarField &Material_eff_twomu = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effictive_two_mu"); - ScalarField &Material_eff_bulk_mod = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effective_bulk_moduli"); - ScalarField &Midstep_volume = declare_scalar_field_on_all_elements( mesh_meta_data , "mid_step_volume"); - ScalarField &Element_time_step = declare_scalar_field_on_all_elements( mesh_meta_data , "element_time_step"); - ScalarField &Element_mass = declare_scalar_field_on_all_elements( mesh_meta_data , "element_mass"); - ScalarField &Hourglass_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "hourglass_energy"); - ScalarField &Internal_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "internal_energy"); - - // Element symmetric tensor fields: - SymmetricTensorField &Stretch = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "stretch" , 6 ); - SymmetricTensorField &StrainRate = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "StrainRate" , 6 ); - SymmetricTensorField &RotatedStress = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "RotatedStress" , 6 ); - - //-------------------------------- - // We don't like specifying the template type TWICE! very error prone. - //-------------------------------- - // The multi-state fields don't have the 'declare and put' convenience functions (yet) - // - // For clarity declare a integer to used for the number of states arguments. - // - const unsigned two_states = 2 ; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField &StressNew = mesh_meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states ); - put_field_on_all_elements( StressNew , 6 ); - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField &RotationNew = - put_field_on_all_elements( mesh_meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 ); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField &HourglassResistanceNew = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 ); - - HourglassOpField & MidHourglassOp = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 ); - - //-------------------------------- - // Declare aggressive "gather" fields which are an array of - // pointers to the element's nodes' coordinate, velocity, and - // internal force field data. - // - // The declarations specify element fields of the following form: - // - // double * coord_gather [ nodes_per_element ] - // double * velocity_gather[ nodes_per_element ] - // double * fint_gather [ nodes_per_element ] - // - // where - // - // coord_gather[i] == field_data( coordinates_field , element_node[i] ) - // velocity_gather[i] == field_data( velocity , element_node[i] ) - // fint_gather[i] == field_data( fint , element_node[i] ) - // - // The number of nodes per element could vary, so the field is put on each element block - // with a size of the number of nodes per element in that element block. - - ElementNodePointerField & coord_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "coord_gather" , coordinates_field ); - ElementNodePointerField & velocity_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "velocity_gather" , velocity_field ); - ElementNodePointerField & fint_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "fint_gather" , fint_field ); - - put_field_on_elements( coord_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( velocity_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( fint_gather , block_hex , shards::Hexahedron<> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - stk_classic::app::use_case_14_generate_mesh( - mesh_bulk_data , - box_size , - model_coordinates , - coord_gather , - block_hex , - box_sides ); - - stk_classic::app::use_case_14_initialize_data( - mesh_bulk_data , - model_coordinates , - coordinates_field , - velocity_field ); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - - stk_classic::mesh::Selector select_owned( stk_classic::mesh::MetaData::get(mesh_bulk_data).locally_owned_part() ); - - const std::vector< stk_classic::mesh::Bucket * > & element_buckets = - mesh_bulk_data.buckets(element_rank); - - unsigned maximum_bucket_size = 0 ; - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - if ( maximum_bucket_size < bucket.size() ) { maximum_bucket_size = bucket.size(); } - } - - // Need both the the old and new states of these two-state fields: - - HourglassArrayField & HourglassResistanceOld = HourglassResistanceNew.field_of_state( stk_classic::mesh::StateOld ); - SymmetricTensorField & StressOld = StressNew.field_of_state( stk_classic::mesh::StateOld ); - FullTensorField & RotationOld = RotationNew.field_of_state( stk_classic::mesh::StateOld ); - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - - double * stretch = stk_classic::mesh::field_data( Stretch, bucket.begin() ); - double * strain_rate = stk_classic::mesh::field_data( StrainRate, bucket.begin() ); - double * stress_new = stk_classic::mesh::field_data( StressNew, bucket.begin() ); - double * stress_old = stk_classic::mesh::field_data( StressOld , bucket.begin() ); - double * rotated_stress = stk_classic::mesh::field_data( RotatedStress , bucket.begin() ); - double * rotation_old = stk_classic::mesh::field_data( RotationOld , bucket.begin() ); - double * rotation_new = stk_classic::mesh::field_data( RotationNew , bucket.begin() ); - double * mass = stk_classic::mesh::field_data( Element_mass , bucket.begin() ); - double * hg_old = stk_classic::mesh::field_data( HourglassResistanceOld , bucket.begin() ); - double * hg_new = stk_classic::mesh::field_data( HourglassResistanceNew , bucket.begin() ); - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - - for ( int i = 0 ; i < num_elements ; ++i ) { - - stk_classic::Copy<32>( mid_hg_op_ptr , 0.0 ); mid_hg_op_ptr += 32 ; - stk_classic::Copy< 3>( vorticity_ptr , 0.0 ); vorticity_ptr += 3 ; - stk_classic::Copy< 6>( rotated_stress, 0.0 ); rotated_stress += 6 ; - stk_classic::Copy< 6>( strain_rate, 0.0 ); strain_rate += 6 ; - stk_classic::Copy<12>( hg_old, 0.0 ); hg_old += 12 ; - stk_classic::Copy<12>( hg_new, 0.0 ); hg_new += 12 ; - stk_classic::Copy< 6>( stress_new, 0.0 ); stress_new += 6 ; - stk_classic::Copy< 6>( stress_old, 0.0 ); stress_old += 6 ; - - mass[i] = element_mass_dummy_value; - - // initialize stretch to identity. - stretch[0] = 1.0; - stretch[1] = 1.0; - stretch[2] = 1.0; - stretch[3] = 0.0; - stretch[4] = 0.0; - stretch[5] = 0.0; - stretch+=6; - - // initialize rotation to identity. - rotation_old[0] = 1.0; - rotation_old[1] = 1.0; - rotation_old[2] = 1.0; - rotation_old[3] = 0.0; - rotation_old[4] = 0.0; - rotation_old[5] = 0.0; - rotation_old[6] = 0.0; - rotation_old[7] = 0.0; - rotation_old[8] = 0.0; - rotation_old +=9; - - // initialize rotation to identity. - rotation_new[0] = 1.0; - rotation_new[1] = 1.0; - rotation_new[2] = 1.0; - rotation_new[3] = 0.0; - rotation_new[4] = 0.0; - rotation_new[5] = 0.0; - rotation_new[6] = 0.0; - rotation_new[7] = 0.0; - rotation_new[8] = 0.0; - rotation_new += 9; - } - } - std::cout << "KHP: Done element field init\n"; - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements = bucket.size(); - - double * const sm = stk_classic::mesh::field_data( Shear_Modulus , bucket.begin() ); - double * const dm = stk_classic::mesh::field_data( Dilatational_Modulus , bucket.begin() ); - double * const twomu = stk_classic::mesh::field_data( Material_eff_twomu , bucket.begin() ); - double * const bulk = stk_classic::mesh::field_data( Material_eff_bulk_mod , bucket.begin() ); - double * const mv = stk_classic::mesh::field_data( Midstep_volume , bucket.begin() ); - double * const hg_energy = stk_classic::mesh::field_data( Hourglass_energy , bucket.begin() ); - double * const internal_energy = stk_classic::mesh::field_data( Internal_energy , bucket.begin() ); - - for ( unsigned i = 0 ; i < num_elements ; ++i ) { - sm[i] = SM; - dm[i] = DM; - twomu[i] = TM; - bulk[i] = BM; - mv[i] = 0.0; - hg_energy[i] = 0.0; - internal_energy[i] = 0.0; - } - } - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - // Scratch space - - enum { num_dof = 24 }; - const int num_dof_max_bucket = num_dof * maximum_bucket_size ; - std::vector< double > vel( num_dof_max_bucket ); - std::vector< double > element_coordinates( num_dof_max_bucket ); - std::vector< double > force_new( num_dof_max_bucket ); - - wtime = stk_classic::wall_time(); - - for(unsigned n=0; n::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - double *material_eff_twomu_ptr = stk_classic::mesh::field_data( Material_eff_twomu, bucket.begin()); - double *material_eff_bulk_modulus_ptr = stk_classic::mesh::field_data( Material_eff_bulk_mod, bucket.begin()); - double *mid_step_volume_ptr = stk_classic::mesh::field_data( Midstep_volume, bucket.begin()); - double *element_time_step_ptr = stk_classic::mesh::field_data( Element_time_step, bucket.begin()); - double *element_mass_ptr = stk_classic::mesh::field_data( Element_mass, bucket.begin()); - double *hg_energy_ptr = stk_classic::mesh::field_data( Hourglass_energy, bucket.begin()); - double *internal_energy_ptr = stk_classic::mesh::field_data (Internal_energy, bucket.begin()); - double *shear_modulus_ptr = stk_classic::mesh::field_data( Shear_Modulus, bucket.begin()); - double *dilatational_modulus_ptr = stk_classic::mesh::field_data( Dilatational_Modulus, bucket.begin() ); - - double *rotation_old_ptr = stk_classic::mesh::field_data( RotationOld, bucket.begin()); - double *rotation_new_ptr = stk_classic::mesh::field_data( RotationNew, bucket.begin()); - - double *stretch_ptr = stk_classic::mesh::field_data( Stretch, bucket.begin()); - double *strain_rate_ptr = stk_classic::mesh::field_data( StrainRate, bucket.begin()); - double *stress_old_ptr = stk_classic::mesh::field_data( StressOld, bucket.begin()); - double *stress_new_ptr = stk_classic::mesh::field_data( StressNew, bucket.begin()); - double *rotated_stress_ptr = stk_classic::mesh::field_data( RotatedStress, bucket.begin()); - - double *hg_resistance_old_ptr = stk_classic::mesh::field_data( HourglassResistanceOld, bucket.begin()); - double *hg_resistance_new_ptr = stk_classic::mesh::field_data( HourglassResistanceNew, bucket.begin()); - - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - - const double **coord = - (const double **) stk_classic::mesh::field_data( coord_gather, bucket.begin()); - const double **velocity = - (const double **) stk_classic::mesh::field_data( velocity_gather, bucket.begin()); - double **fint = stk_classic::mesh::field_data( fint_gather, bucket.begin()); - - //-------------------------------- - { // Gather nodal data into contiguous arrays. - - // element-node pointer fields - const double ** field_coord = coord ; - const double ** vnodes = velocity ; - - // scratch space for gather: - double * elem_coord = & element_coordinates[0] ; - double * elem_vel = & vel[0] ; - - const int num_elem_nodes = num_elements * 8 ; - - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - const double * const f_coord = *field_coord ; - const double * const f_vel = *vnodes ; - - elem_coord[0] = f_coord[0]; - elem_coord[1] = f_coord[1]; - elem_coord[2] = f_coord[2]; - - elem_vel[0] = f_vel[0]; - elem_vel[1] = f_vel[1]; - elem_vel[2] = f_vel[2]; - - ++field_coord ; - ++vnodes ; - elem_coord += 3 ; - elem_vel += 3 ; - } - } - - //-------------------------------- - - double* dt_ptr = stk_classic::mesh::property_data(delta_t, block_hex); - materialParameters.dt = *dt_ptr; - materialParameters.nelements = num_elements ; - materialParameters.strain_rate = strain_rate_ptr; - materialParameters.stress_old = stress_old_ptr; - materialParameters.stress_new = stress_new_ptr; - - lame::MatProps* materialProperties_ptr = stk_classic::mesh::property_data(mprops, block_hex); - - hex_element.internalForce( num_elements , - *dt_ptr, - current_stable_time_step, - element_time_step_ptr, - *matmodel, - materialParameters, - *materialProperties_ptr, - & element_coordinates[0], - & vel[0], - rotation_old_ptr, - rotation_new_ptr, - mid_step_volume_ptr, - vorticity_ptr, - stretch_ptr, - strain_rate_ptr, - mid_hg_op_ptr, - stress_old_ptr, - stress_new_ptr, - rotated_stress_ptr, - material_eff_bulk_modulus_ptr, - material_eff_twomu_ptr, - shear_modulus_ptr, - dilatational_modulus_ptr, - element_mass_ptr, - & force_new[0], - hg_energy_ptr, - internal_energy_ptr, - hg_resistance_old_ptr, - hg_resistance_new_ptr - ); - - { // Scatter internal force values. - double ** f = fint ; - const double * f_new = & force_new[0] ; - const int num_elem_nodes = num_elements * 8 ; - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - double * const node_f = *f ; - node_f[0] += f_new[0]; - node_f[1] += f_new[1]; - node_f[2] += f_new[2]; - ++f ; - f_new += 3 ; - } - } - } - - time_max[3] += stk_classic::wall_dtime( wtime ); - - stk_classic::mesh::parallel_reduce( mesh_bulk_data , stk_classic::mesh::sum(fint_field) ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - }//end for(..num_trials... - - //------------------------------------------------------------------ - - delete matmodel; -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Box size = { " << box_size[0] << " , " - << box_size[1] << " , " - << box_size[2] << " }" << std::endl - << " Box sides = { { " - << box_sides[0][0] << " , " - << box_sides[0][1] << " } , { " - << box_sides[1][0] << " , " - << box_sides[1][1] << " } , { " - << box_sides[2][0] << " , " - << box_sides[2][1] << " } }" - << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation= " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Internal force = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Internal force (total) = " << time_min[3]*num_trials - << std::endl - << " Swap-add = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} // namespace app -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.cpp b/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.cpp deleted file mode 100644 index 851f4425dc2b..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.cpp +++ /dev/null @@ -1,965 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -/** - * @author K. H. Pierson - * @date April 2009 - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// #include -#include -#include -#include -#include - -#include -#include - -// -// How do I modify this code to find this header? -// -//#include - -// 2. Template the outer methods. -// -// 3. Write another driver to compute the derivative (vs. internal force -// call). -// -// 4. -// DFad -> dynamic FAD ( dynamic memory allocation) -// -// typedef Sacado::Fad::DFad FAD_Type; - -//---------------------------------------------------------------------- -// This file contains the implementation of use-case AD: internal force computation. -// The function 'use_case_AD_driver' below is the equivalent of 'main'. -//---------------------------------------------------------------------- - -namespace stk_classic { -namespace app { - -enum { SpatialDim = 3 }; - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::fem::FEMMetaData& meta_data) -{ - return meta_data.element_rank(); -} - -inline stk_classic::mesh::EntityRank get_element_rank(const stk_classic::mesh::Part& part) -{ - return get_element_rank(stk_classic::mesh::fem::FEMMetaData::get(part)); -} - -VectorField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() , n1 ); -} - - -VectorField & -declare_vector_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -ScalarField & -declare_scalar_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), get_element_rank(meta_data) , meta_data.universal_part() ); -} - - -SymmetricTensorField & -declare_symmetric_tensor_field_on_all_elements( - stk_classic::mesh::fem::FEMMetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return put_field( meta_data.declare_field(s), get_element_rank(meta_data), meta_data.universal_part() , n1 ); -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & -put_field_on_elements( stk_classic::mesh::Field & f , stk_classic::mesh::Part & p , unsigned n1 ) -{ - stk_classic::mesh::put_field( f , get_element_rank(p) , p , n1 ); - return f ; -} - - -template< typename Type , class T1 > -stk_classic::mesh::Field & put_field_on_all_elements( stk_classic::mesh::Field & f , unsigned n1 ) -{ - put_field_on_elements( f , stk_classic::mesh::MetaData::get(f).universal_part() , n1 ); - return f ; -} - -void use_case_AD_driver( - MPI_Comm comm , - const std::string & file_name , - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ); - -//-------------------------------------------------------------------- -// -// main driver for use-case AD: element internal force. -// - -void use_case_AD_driver( MPI_Comm comm , bool performance_test ) -{ - int num_procs = stk_classic::parallel_machine_size( comm ); - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout << " stk_mesh Use Case #AD - element internal force, begin" << std::endl ; - } - - if ( ! performance_test ) { - // Quick & small test for correctness: - const unsigned a_box_size[3] = { 10 , 10 , 10*num_procs }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - int num_trials = 1; - use_case_AD_driver( comm , "use_case_14.exo" , a_box_size , a_box_sides , num_trials ); - } - else { - int num_trials = 20 ; // 582 ; - - const unsigned a_box_size[3] = { 100 , 100 , 100 }; - const unsigned a_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - - std::cout << "Running 100x100x100 case, num_trials = " << num_trials << std::endl; - - use_case_AD_driver( comm , "use_case_14a.exo" , a_box_size , a_box_sides , num_trials ); - -// const unsigned b_box_size[3] = { 100 , 125 , 10*num_procs }; -// const unsigned b_box_sides[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } }; - -// std::cout << "Running 100x125x10*nprocs case, num_trials = " << num_trials << std::endl; - -// use_case_AD_driver( comm , "use_case_14b.exo" , b_box_size , b_box_sides , num_trials ); - } -} - -//-------------------------------------------------------------------- - -inline -void zero_data( double * beg , double * const end ) -{ while ( beg < end ) { *beg++ = 0 ; } } - -template< class FieldType > -void zero_field_data( stk_classic::mesh::BulkData & mesh , stk_classic::mesh::EntityRank type , const FieldType & field ) -{ - typedef stk_classic::mesh::BucketArray< FieldType > array_type ; - - const std::vector & ks = mesh.buckets( type ); - - for ( std::vector::const_iterator ik = ks.begin() ; ik != ks.end() ; ++ik ) { - stk_classic::mesh::Bucket & bucket = **ik ; - array_type data( field , bucket ); - zero_data( data.contiguous_data() , data.contiguous_data() + data.size() ); - } -} - -//-------------------------------------------------------------------- - - -void use_case_AD_driver( - MPI_Comm comm , - const std::string & /*file_name */, - const unsigned box_size[] , - const unsigned box_sides[][2] , - const unsigned num_trials ) -{ - double dt = 1.0e-02; - double YM = 1e7; // Young's Modulus - double PR = 0.33; // Poisson Ratio - double element_mass_dummy_value = 1.0; - std::string material_model_name("ELASTIC"); - - double current_stable_time_step = dt; - - //---------------------------------- - // Compute other material constants. - double BM = YM/(3.0-6.0*PR); // Bulk Modulus - double SM = YM/(2.0+2.0*PR); // Shear Modulus - double TM = 2.0 * SM; - double LAMBDA = YM*PR/((1.0+PR)*(1.0-2.0*PR)); - double DM = TM + LAMBDA; // Dilatational Modulus - - lame::MatProps materialProperties; - - std::vector youngs_modulus; youngs_modulus.push_back(YM); - std::vector poissons_ratio; poissons_ratio.push_back(PR); - std::vector bulk_modulus; bulk_modulus.push_back(BM); - std::vector shear_modulus; shear_modulus.push_back(SM); - std::vector two_mu; two_mu.push_back(TM); - std::vector lambda; lambda.push_back(LAMBDA); - std::vector dilatational_modulus; dilatational_modulus.push_back(DM); - - materialProperties["YOUNGS_MODULUS"] = youngs_modulus; - materialProperties["POISSONS_RATIO"] = poissons_ratio; - materialProperties["BULK_MODULUS"] = bulk_modulus; - materialProperties["SHEAR_MODULUS"] = shear_modulus; - materialProperties["TWO_MU"] = two_mu; - materialProperties["LAMBDA"] = lambda; - materialProperties["DILATATIONAL_MODULUS"] = dilatational_modulus; - - lame::Material * matmodel = lame::Elastic::createMaterial( materialProperties ); - - //---------------------------------- - - Hex8ug hex_element; - - lame::matParams materialParameters; - - // Timing: - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - // [4] = Parallel swap-add of internal force - - double time_min[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double time_max[9] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; - double wtime = 0 ; - - //-------------------------------------------------------------------- - - reset_malloc_stats(); - - if ( 0 == stk_classic::parallel_machine_rank( comm ) ) { - std::cout << "stk_mesh performance use case #AD" << std::endl - << " Number Processes = " << stk_classic::parallel_machine_size( comm ) - << std::endl ; - std::cout.flush(); - } - - //-------------------------------------------------------------------- - - { - wtime = stk_classic::wall_time(); - - //------------------------------------------------------------------ - // Declare the mesh meta data and bulk data - - stk_classic::mesh::fem::FEMMetaData mesh_meta_data( SpatialDim ); - const stk_classic::mesh::EntityRank element_rank = mesh_meta_data.element_rank(); - stk_classic::mesh::BulkData mesh_bulk_data( mesh_meta_data.get_meta_data(mesh_meta_data), MPI_COMM_WORLD, 1000 ); - - //-------------------------------- - // Element-block declarations typically occur when reading the - // mesh-file meta-data, and thus won't usually appear in application code. - // Declaring the element blocks and associating an element traits - // with each element block. - - stk_classic::mesh::Part & block_hex = mesh_meta_data.declare_part("block_1", element_rank); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - - //-------------------------------- - - // Nodal vector fields - VectorField &model_coordinates = declare_vector_field_on_all_nodes( mesh_meta_data , "model_coordinates" , SpatialDim ); - VectorField &coordinates_field = declare_vector_field_on_all_nodes( mesh_meta_data , "coordinates" , SpatialDim ); - VectorField &velocity_field = declare_vector_field_on_all_nodes( mesh_meta_data , "velocity" , SpatialDim ); - VectorField &fint_field = declare_vector_field_on_all_nodes( mesh_meta_data , "force_internal" , SpatialDim ); - - // Element vector fields: - VectorField &Vorticity = declare_vector_field_on_all_elements( mesh_meta_data , "Vorticity" , SpatialDim ); - - // Element scalar fields: - ScalarField &Shear_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "shear_modulus" ); - ScalarField &Dilatational_Modulus = declare_scalar_field_on_all_elements( mesh_meta_data , "dilatational_modulus"); - ScalarField &Material_eff_twomu = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effictive_two_mu"); - ScalarField &Material_eff_bulk_mod = declare_scalar_field_on_all_elements( mesh_meta_data , "material_effective_bulk_moduli"); - ScalarField &Midstep_volume = declare_scalar_field_on_all_elements( mesh_meta_data , "mid_step_volume"); - ScalarField &Element_time_step = declare_scalar_field_on_all_elements( mesh_meta_data , "element_time_step"); - ScalarField &Element_mass = declare_scalar_field_on_all_elements( mesh_meta_data , "element_mass"); - ScalarField &Hourglass_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "hourglass_energy"); - ScalarField &Internal_energy = declare_scalar_field_on_all_elements( mesh_meta_data , "internal_energy"); - - // Element symmetric tensor fields: - SymmetricTensorField &Stretch = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "stretch" , 6 ); - SymmetricTensorField &StrainRate = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "StrainRate" , 6 ); - SymmetricTensorField &RotatedStress = declare_symmetric_tensor_field_on_all_elements( mesh_meta_data , "RotatedStress" , 6 ); - - //-------------------------------- - // We don't like specifying the template type TWICE! very error prone. - //-------------------------------- - // The multi-state fields don't have the 'declare and put' convenience functions (yet) - // - // For clarity declare a integer to used for the number of states arguments. - // - const unsigned two_states = 2 ; - - // Element two state symmetric tensor field, on all elements (as two function calls): - SymmetricTensorField &StressNew = mesh_meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states ); - put_field_on_all_elements( StressNew , 6 ); - - // Element two state full tensor field on all elements (as nested function calls): - FullTensorField &RotationNew = - put_field_on_all_elements( mesh_meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 ); - - //-------------------------------- - // Hourglass fields, these don't have the convenience functions for 'declare and put' - - HourglassArrayField &HourglassResistanceNew = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 ); - - HourglassOpField & MidHourglassOp = - put_field_on_all_elements( mesh_meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 ); - - //-------------------------------- - // Declare aggressive "gather" fields which are an array of - // pointers to the element's nodes' coordinate, velocity, and - // internal force field data. - // - // The declarations specify element fields of the following form: - // - // double * coord_gather [ nodes_per_element ] - // double * velocity_gather[ nodes_per_element ] - // double * fint_gather [ nodes_per_element ] - // - // where - // - // coord_gather[i] == field_data( coordinates_field , element_node[i] ) - // velocity_gather[i] == field_data( velocity , element_node[i] ) - // fint_gather[i] == field_data( fint , element_node[i] ) - // - // The number of nodes per element could vary, so the field is put on each element block - // with a size of the number of nodes per element in that element block. - - ElementNodePointerField & coord_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "coord_gather" , coordinates_field ); - ElementNodePointerField & velocity_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "velocity_gather" , velocity_field ); - ElementNodePointerField & fint_gather = declare_element_node_pointer_field( mesh_meta_data.get_meta_data(mesh_meta_data), "fint_gather" , fint_field ); - - put_field_on_elements( coord_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( velocity_gather , block_hex , shards::Hexahedron<> ::node_count ); - put_field_on_elements( fint_gather , block_hex , shards::Hexahedron<> ::node_count ); - - //-------------------------------- - // Commit (finalize) the meta data. Is now ready to be used - // in the creation and management of mesh bulk data. - - mesh_meta_data.commit(); - - //------------------------------------------------------------------ - - time_max[0] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - - // In a typical app, the mesh would be read from file at this point. - // But in this use-case, we generate the mesh and initialize - // field data to use-case defined values. - - use_case_AD_generate_mesh( - mesh_bulk_data , - box_size , - model_coordinates , - coord_gather , - block_hex , - box_sides ); - - use_case_AD_initialize_data( - mesh_bulk_data , - model_coordinates , - coordinates_field , - velocity_field ); - - time_max[1] = stk_classic::wall_dtime( wtime ); - - //------------------------------------------------------------------ - // Ready to run the algorithms: - //------------------------------------------------------------------ - - stk_classic::mesh::Selector select_owned( stk_classic::mesh::MetaData::get(mesh_bulk_data).locally_owned_part() ); - - const std::vector< stk_classic::mesh::Bucket * > & element_buckets = - mesh_bulk_data.buckets(element_rank); - - unsigned maximum_bucket_size = 0 ; - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned(**k) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - if ( maximum_bucket_size < bucket.size() ) { maximum_bucket_size = bucket.size(); } - } - - // Need both the the old and new states of these two-state fields: - - HourglassArrayField & HourglassResistanceOld = HourglassResistanceNew.field_of_state( stk_classic::mesh::StateOld ); - SymmetricTensorField & StressOld = StressNew.field_of_state( stk_classic::mesh::StateOld ); - FullTensorField & RotationOld = RotationNew.field_of_state( stk_classic::mesh::StateOld ); - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - - double * stretch = stk_classic::mesh::field_data( Stretch, bucket.begin() ); - double * strain_rate = stk_classic::mesh::field_data( StrainRate, bucket.begin() ); - double * stress_new = stk_classic::mesh::field_data( StressNew, bucket.begin() ); - double * stress_old = stk_classic::mesh::field_data( StressOld , bucket.begin() ); - double * rotated_stress = stk_classic::mesh::field_data( RotatedStress , bucket.begin() ); - double * rotation_old = stk_classic::mesh::field_data( RotationOld , bucket.begin() ); - double * rotation_new = stk_classic::mesh::field_data( RotationNew , bucket.begin() ); - double * mass = stk_classic::mesh::field_data( Element_mass , bucket.begin() ); - double * hg_old = stk_classic::mesh::field_data( HourglassResistanceOld , bucket.begin() ); - double * hg_new = stk_classic::mesh::field_data( HourglassResistanceNew , bucket.begin() ); - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - - for ( int i = 0 ; i < num_elements ; ++i ) { - - stk_classic::Copy<32>( mid_hg_op_ptr , 0.0 ); mid_hg_op_ptr += 32 ; - stk_classic::Copy< 3>( vorticity_ptr , 0.0 ); vorticity_ptr += 3 ; - stk_classic::Copy< 6>( rotated_stress, 0.0 ); rotated_stress += 6 ; - stk_classic::Copy< 6>( strain_rate, 0.0 ); strain_rate += 6 ; - stk_classic::Copy<12>( hg_old, 0.0 ); hg_old += 12 ; - stk_classic::Copy<12>( hg_new, 0.0 ); hg_new += 12 ; - stk_classic::Copy< 6>( stress_new, 0.0 ); stress_new += 6 ; - stk_classic::Copy< 6>( stress_old, 0.0 ); stress_old += 6 ; - - mass[i] = element_mass_dummy_value; - - // initialize stretch to identity. - stretch[0] = 1.0; - stretch[1] = 1.0; - stretch[2] = 1.0; - stretch[3] = 0.0; - stretch[4] = 0.0; - stretch[5] = 0.0; - stretch+=6; - - // initialize rotation to identity. - rotation_old[0] = 1.0; - rotation_old[1] = 1.0; - rotation_old[2] = 1.0; - rotation_old[3] = 0.0; - rotation_old[4] = 0.0; - rotation_old[5] = 0.0; - rotation_old[6] = 0.0; - rotation_old[7] = 0.0; - rotation_old[8] = 0.0; - rotation_old +=9; - - // initialize rotation to identity. - rotation_new[0] = 1.0; - rotation_new[1] = 1.0; - rotation_new[2] = 1.0; - rotation_new[3] = 0.0; - rotation_new[4] = 0.0; - rotation_new[5] = 0.0; - rotation_new[6] = 0.0; - rotation_new[7] = 0.0; - rotation_new[8] = 0.0; - rotation_new += 9; - } - } - - for ( std::vector< stk_classic::mesh::Bucket * >::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const unsigned num_elements = bucket.size(); - - double * const sm = stk_classic::mesh::field_data( Shear_Modulus , bucket.begin() ); - double * const dm = stk_classic::mesh::field_data( Dilatational_Modulus , bucket.begin() ); - double * const twomu = stk_classic::mesh::field_data( Material_eff_twomu , bucket.begin() ); - double * const bulk = stk_classic::mesh::field_data( Material_eff_bulk_mod , bucket.begin() ); - double * const mv = stk_classic::mesh::field_data( Midstep_volume , bucket.begin() ); - double * const hg_energy = stk_classic::mesh::field_data( Hourglass_energy , bucket.begin() ); - double * const internal_energy = stk_classic::mesh::field_data( Internal_energy , bucket.begin() ); - - for ( unsigned i = 0 ; i < num_elements ; ++i ) { - sm[i] = SM; - dm[i] = DM; - twomu[i] = TM; - bulk[i] = BM; - mv[i] = 0.0; - hg_energy[i] = 0.0; - internal_energy[i] = 0.0; - } - } - - //------------------------------------------------------------------ - time_max[2] = stk_classic::wall_dtime( wtime ); - //------------------------------------------------------------------ - - // Scratch space - - enum { num_dof = 24 }; - const int num_dof_max_bucket = num_dof * maximum_bucket_size ; - std::vector< double > vel( num_dof_max_bucket ); - std::vector< double > element_coordinates( num_dof_max_bucket ); - std::vector< double > force_new( num_dof_max_bucket ); - - wtime = stk_classic::wall_time(); - - for(unsigned n=0; n::const_iterator - k = element_buckets.begin(); k != element_buckets.end() ; ++k ) if ( select_owned( **k ) ) { - const stk_classic::mesh::Bucket & bucket = **k ; - - const int num_elements = bucket.size(); - double *mid_hg_op_ptr = stk_classic::mesh::field_data( MidHourglassOp, bucket.begin()); - double *material_eff_twomu_ptr = stk_classic::mesh::field_data( Material_eff_twomu, bucket.begin()); - double *material_eff_bulk_modulus_ptr = stk_classic::mesh::field_data( Material_eff_bulk_mod, bucket.begin()); - double *mid_step_volume_ptr = stk_classic::mesh::field_data( Midstep_volume, bucket.begin()); - double *element_time_step_ptr = stk_classic::mesh::field_data( Element_time_step, bucket.begin()); - double *element_mass_ptr = stk_classic::mesh::field_data( Element_mass, bucket.begin()); - double *hg_energy_ptr = stk_classic::mesh::field_data( Hourglass_energy, bucket.begin()); - double *internal_energy_ptr = stk_classic::mesh::field_data (Internal_energy, bucket.begin()); - double *shear_modulus_ptr = stk_classic::mesh::field_data( Shear_Modulus, bucket.begin()); - double *dilatational_modulus_ptr = stk_classic::mesh::field_data( Dilatational_Modulus, bucket.begin() ); - - double *rotation_old_ptr = stk_classic::mesh::field_data( RotationOld, bucket.begin()); - double *rotation_new_ptr = stk_classic::mesh::field_data( RotationNew, bucket.begin()); - - double *stretch_ptr = stk_classic::mesh::field_data( Stretch, bucket.begin()); - double *strain_rate_ptr = stk_classic::mesh::field_data( StrainRate, bucket.begin()); - double *stress_old_ptr = stk_classic::mesh::field_data( StressOld, bucket.begin()); - double *stress_new_ptr = stk_classic::mesh::field_data( StressNew, bucket.begin()); - double *rotated_stress_ptr = stk_classic::mesh::field_data( RotatedStress, bucket.begin()); - - double *hg_resistance_old_ptr = stk_classic::mesh::field_data( HourglassResistanceOld, bucket.begin()); - double *hg_resistance_new_ptr = stk_classic::mesh::field_data( HourglassResistanceNew, bucket.begin()); - - double *vorticity_ptr = stk_classic::mesh::field_data( Vorticity, bucket.begin()); - - const double **coord = - (const double **) stk_classic::mesh::field_data( coord_gather, bucket.begin()); - const double **velocity = - (const double **) stk_classic::mesh::field_data( velocity_gather, bucket.begin()); - double **fint = stk_classic::mesh::field_data( fint_gather, bucket.begin()); - - const int num_elem_nodes = num_elements * 8 ; - - //-------------------------------- - { // Gather nodal data into contiguous arrays. - - // element-node pointer fields - const double ** field_coord = coord ; - const double ** vnodes = velocity ; - - // scratch space for gather: - double * elem_coord = & element_coordinates[0] ; - double * elem_vel = & vel[0] ; - - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - const double * const f_coord = *field_coord ; - const double * const f_vel = *vnodes ; - - elem_coord[0] = f_coord[0]; - elem_coord[1] = f_coord[1]; - elem_coord[2] = f_coord[2]; - - elem_vel[0] = f_vel[0]; - elem_vel[1] = f_vel[1]; - elem_vel[2] = f_vel[2]; - - ++field_coord ; - ++vnodes ; - elem_coord += 3 ; - elem_vel += 3 ; - } - } - - //-------------------------------- - - materialParameters.dt = dt; - materialParameters.nelements = num_elements ; - materialParameters.strain_rate = strain_rate_ptr; - materialParameters.stress_old = stress_old_ptr; - materialParameters.stress_new = stress_new_ptr; - - hex_element.internalForce( num_elements , - dt, - current_stable_time_step, - element_time_step_ptr, - *matmodel, - materialParameters, - materialProperties, - & element_coordinates[0], - & vel[0], - rotation_old_ptr, - rotation_new_ptr, - mid_step_volume_ptr, - vorticity_ptr, - stretch_ptr, - strain_rate_ptr, - mid_hg_op_ptr, - stress_old_ptr, - stress_new_ptr, - rotated_stress_ptr, - material_eff_bulk_modulus_ptr, - material_eff_twomu_ptr, - shear_modulus_ptr, - dilatational_modulus_ptr, - element_mass_ptr, - & force_new[0], - hg_energy_ptr, - internal_energy_ptr, - hg_resistance_old_ptr, - hg_resistance_new_ptr - ); - - { // Scatter internal force values. - double ** f = fint ; - const double * f_new = & force_new[0] ; - for ( int i = 0 ; i < num_elem_nodes ; ++i ) { - double * const node_f = *f ; - node_f[0] += f_new[0]; - node_f[1] += f_new[1]; - node_f[2] += f_new[2]; - ++f ; - f_new += 3 ; - } - } - } - - time_max[3] += stk_classic::wall_dtime( wtime ); - - stk_classic::mesh::parallel_reduce( mesh_bulk_data , stk_classic::mesh::sum(fint_field) ); - - time_max[4] += stk_classic::wall_dtime( wtime ); - - }//end for(..num_trials... - - //------------------------------------------------------------------ - -#ifdef USE_GNU_MALLOC_HOOKS - if (parallel_machine_rank(comm) == 0) { - double net_alloc = alloc_MB() - freed_MB(); - std::cout << "Mesh creation:" << "\n Total allocated: " - << alloc_MB()<<"MB in "<( time_max ) & stk_classic::ReduceMin<9>( time_min ) ); - - time_max[3] /= num_trials ; - time_max[4] /= num_trials ; - time_max[5] /= num_trials ; - time_max[6] /= num_trials ; - - time_min[3] /= num_trials ; - time_min[4] /= num_trials ; - time_min[5] /= num_trials ; - time_min[6] /= num_trials ; - - // [0] = stk_classic::mesh::MetaData creation - // [1] = stk_classic::mesh::BulkData creation - // [2] = Initialization - // [3] = Internal force - - if ( ! stk_classic::parallel_machine_rank( comm ) ) { - std::cout - << "stk_mesh performance use case results:" << std::endl - << " Number trials = " << num_trials << std::endl - << " Box size = { " << box_size[0] << " , " - << box_size[1] << " , " - << box_size[2] << " }" << std::endl - << " Box sides = { { " - << box_sides[0][0] << " , " - << box_sides[0][1] << " } , { " - << box_sides[1][0] << " , " - << box_sides[1][1] << " } , { " - << box_sides[2][0] << " , " - << box_sides[2][1] << " } }" - << std::endl - << " Meta-data setup = " << time_min[0] << " : " - << time_max[0] << " sec, min : max" - << std::endl - << " Bulk-data generation= " << time_min[1] << " : " - << time_max[1] << " sec, min : max" - << std::endl - << " Initialization = " << time_min[2] << " : " - << time_max[2] << " sec, min : max" - << std::endl - << " Internal force = " << time_min[3] << " : " - << time_max[3] << " sec, min : max" - << std::endl - << " Internal force (total) = " << time_min[3]*num_trials - << std::endl - << " Swap-add = " << time_min[4] << " : " - << time_max[4] << " sec, min : max" - << std::endl - << " Mesh destruction = " << time_min[8] << " : " - << time_max[8] << " sec, min : max" - << std::endl - << std::endl ; - } -} - -//-------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void use_case_AD_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorField & node_model_corrdinates , - const VectorField & node_coordinates , - const VectorField & node_velocity ) -{ - const double dt = 1.0e-2; - - const std::vector & buckets = mesh.buckets( stk_classic::mesh::fem::FEMMetaData::NODE_RANK ); - - for ( std::vector::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - const unsigned length = bucket.size(); - - double * X = stk_classic::mesh::field_data( node_model_corrdinates , bucket.begin() ); - double * coord = stk_classic::mesh::field_data( node_coordinates , bucket.begin() ); - double * v = stk_classic::mesh::field_data( node_velocity , bucket.begin() ); - - for ( unsigned i = 0 ; i < length ; ++i ) { - v[0] = X[0]; - v[1] = X[1]; - v[2] = X[2]; - coord[0] = X[0] + dt * v[0]; - coord[1] = X[1] + dt * v[1]; - coord[2] = X[2] + dt * v[2]; - //std::cout << "KHP: Xn= " << coord[0] << ", " << coord[1] << ", " << coord[2] << "\n"; - X += 3; - v += 3; - coord += 3; - } - } -} - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#include - -namespace stk_classic { -namespace app { - -void use_case_AD_generate_mesh( - stk_classic::mesh::BulkData & mesh , - const unsigned N[] , - const VectorField & node_coord , - const ElementNodePointerField & /*coord_gather */, - stk_classic::mesh::Part & hex_block , - const unsigned shell_side[][2] ) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - mesh.modification_begin(); - - const unsigned parallel_size = mesh.parallel_size(); - const unsigned parallel_rank = mesh.parallel_rank(); - - double t = 0 ; - size_t num_hex = 0 ; - size_t num_nodes = 0 ; - size_t num_block = 0 ; - int error_flag = 0 ; - - try { - - Iogn::GeneratedMesh gmesh( N[0], N[1], N[2], parallel_size, parallel_rank ); - - if ( shell_side[0][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MX ); } - if ( shell_side[0][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PX ); } - if ( shell_side[1][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MY ); } - if ( shell_side[1][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PY ); } - if ( shell_side[2][0] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::MZ ); } - if ( shell_side[2][1] ) { gmesh.add_shell_block( Iogn::GeneratedMesh::PZ ); } - - num_nodes = gmesh.node_count_proc(); - num_block = gmesh.block_count(); - - t = stk_classic::wall_time(); - - std::vector node_map( num_nodes , 0 ); - - gmesh.node_map( node_map ); - - { - - for ( size_t i = 1 ; i <= num_block ; ++i ) { - const size_t num_elem = gmesh.element_count_proc(i); - const std::pair top_info = gmesh.topology_type(i); - - std::vector elem_map( num_elem , 0 ); - gmesh.element_map( i, elem_map ); - - std::vector elem_conn( num_elem * top_info.second ); - - gmesh.connectivity( i , elem_conn ); - - if ( top_info.second == 8 ) { - - for ( size_t j = 0 ; j < num_elem ; ++j ) { - - const int * const local_node_id = & elem_conn[ j * 8 ] ; - - const stk_classic::mesh::EntityId node_id[8] = { - local_node_id[0] , - local_node_id[1] , - local_node_id[2] , - local_node_id[3] , - local_node_id[4] , - local_node_id[5] , - local_node_id[6] , - local_node_id[7] - }; - - const stk_classic::mesh::EntityId elem_id = elem_map[ j ]; - - stk_classic::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id ); - - ++num_hex ; - } - } - - } - } - - std::vector node_coordinates( 3 * node_map.size() ); - - gmesh.coordinates( node_coordinates ); - - if ( 3 * node_map.size() != node_coordinates.size() ) { - std::ostringstream msg ; - msg << " P" << mesh.parallel_rank() - << ": ERROR, node_map.size() = " - << node_map.size() - << " , node_coordinates.size() / 3 = " - << ( node_coordinates.size() / 3 ); - throw std::runtime_error( msg.str() ); - } - - for ( unsigned i = 0 ; i < node_map.size() ; ++i ) { - const unsigned i3 = i * 3 ; - - stk_classic::mesh::Entity * const node = mesh.get_entity( stk_classic::mesh::fem::FEMMetaData::NODE_RANK , node_map[i] ); - - if ( NULL == node ) { - std::ostringstream msg ; - msg << " P:" << mesh.parallel_rank() - << " ERROR, stk_classic::mesh::fem::FEMMetaData::NODE_RANK not found: " - << node_map[i] << " = node_map[" << i << "]" ; - throw std::runtime_error( msg.str() ); - } - - double * const data = stk_classic::mesh::field_data( node_coord , *node ); - data[0] = node_coordinates[ i3 + 0 ]; - data[1] = node_coordinates[ i3 + 1 ]; - data[2] = node_coordinates[ i3 + 2 ]; - } - } - catch ( const std::exception & X ) { - std::cout << " P:" << mesh.parallel_rank() << ": " << X.what() - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - catch( ... ) { - std::cout << " P:" << mesh.parallel_rank() - << " Caught unknown exception" - << std::endl ; - std::cout.flush(); - error_flag = 1 ; - } - - stk_classic::all_reduce( mesh.parallel() , stk_classic::ReduceMax<1>( & error_flag ) ); - - if ( error_flag ) { - std::string msg( "Failed mesh generation" ); - throw std::runtime_error( msg ); - } - - mesh.modification_end(); - - double dt = stk_classic::wall_dtime( t ); - - std::vector< unsigned > entity_count ; - - stk_classic::mesh::Selector selector(stk_classic::mesh::MetaData::get(mesh).locally_owned_part()); - stk_classic::mesh::count_entities( selector, mesh , entity_count ); - - stk_classic::all_reduce( mesh.parallel() , - stk_classic::ReduceSum( & entity_count[0] ) & - stk_classic::ReduceMax<1>( & dt ) ); - - if ( 0 == parallel_rank ) { - std::cout << "On " << parallel_size << " processors, meshed " - << entity_count[ element_rank ] << " elements and " - << entity_count[ stk_classic::mesh::fem::FEMMetaData::NODE_RANK ] << " nodes " - << " in " << dt << " sec" - << std::endl ; - std::cout.flush(); - } -} - -} // namespace app -} // namespace stk_classic - -//---------------------------------------------------------------------- - diff --git a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.hpp b/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.hpp deleted file mode 100644 index 21c9904512ef..000000000000 --- a/packages/stk/stk_classic/stk_usecases/mesh/UseCase_AD.hpp +++ /dev/null @@ -1,2086 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef APS_MAIN_KHP -#define APS_MAIN_KHP - -#include -#include -#include -#include -#include -#include - -using std::sqrt; - -#include -#include -#include - -typedef double FAD_Type; -typedef double Scalar; -typedef int Int; -typedef double Real; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; -typedef stk_classic::mesh::Field SymmetricTensorField ; -typedef stk_classic::mesh::Field FullTensorField ; - - -//---------------------------------------------------------------------- -// Tags for my special kinds of field types, -// which belong in a separate application-shared file... - -struct HourglassOp : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassOp & tag(); - private: - HourglassOp() {} - HourglassOp( const HourglassOp & ); - HourglassOp & operator = ( const HourglassOp & ); -}; - -inline -const HourglassOp & HourglassOp::tag() -{ static const HourglassOp self ; return self ; } - -inline -const char * HourglassOp::name() const -{ static const char n[] = "HourglassOp" ; return n ; } - -struct HourglassModes : public shards::ArrayDimTag { - const char * name() const ; - static const HourglassModes & tag(); - private: - HourglassModes() {} - HourglassModes( const HourglassModes & ); - HourglassModes & operator = ( const HourglassModes & ); -}; - -inline -const HourglassModes & HourglassModes::tag() -{ static const HourglassModes self ; return self ; } - -inline -const char * HourglassModes::name() const -{ static const char n[] = "HourglassModes" ; return n ; } - -//---------------------------------------------------------------------- - -typedef stk_classic::mesh::Field HourglassOpField; -typedef stk_classic::mesh::Field HourglassArrayField; - -// Specification for the aggressive gather pointer-field for elements. - -typedef stk_classic::mesh::Field ElementNodePointerField ; - -//---------------------------------------------------------------------- -// prototype for the function that will generate the use-case mesh. - -namespace stk_classic { - namespace app { - - void use_case_AD_generate_mesh( - stk_classic::mesh::BulkData & mesh , - const unsigned N[] , - const VectorField & node_coord , - const stk_classic::mesh::ElementNodePointerField & coord_gather , - stk_classic::mesh::Part & hex_block , - const unsigned shell_side[][2] ); - - void use_case_AD_initialize_data( - stk_classic::mesh::BulkData & mesh , - const VectorField & node_model_coordinates , - const VectorField & node_coordinates , - const VectorField & node_velocity ); - - }//namespace app -}//namespace stk_classic - -namespace lame { - typedef std::map > MatProps; - - /** - * The struture, matParams, has all of the information that - * might be passed back and forth from the application code - * and the constitutive model. This provides a very simple, - * easily modified interface between the application code - * and the constitutive model. - * - * The following are the more frequently used parameters. - * - * @param nelements is the number of material points sent - * to LAME for evaluation - * @param dt is the size of the current time step - * @param time is the current solution time - * @param dtrnew is the suggested ratio for the new time step - * @param energy_dep is the total ammount of energy deposited - * @param stress_old are the stress components at \f$t_{n}\f$ - * @param stress_new are the stress components at \f$t_{n+1}\f$ - * @param state_old are the state variables at \f$t_{n}\f$ - * @param state_new are the state variables at \f$t_{n+1}\f$ - * @param strain_rate are the components of the current rate - * of deformation - * @param left_stretch are the components of the left stretch - * tensor at \f$t_{n+1}\f$ - * @param rotation are the components of the rotation - * tensor at \f$t_{n+1}\f$ - * @param temp_old is the temperature at \f$t_{n}\f$ - * @param temp_new is the temperature at \f$t_{n+1}\f$ - */ - template - class matParams { - public: - matParams() { - const T zero(0.0); - const T one(1.0); - nelements = 0; - nintg = 0; - dt = zero; - time = zero; - dtrnew = one; - energy_dep = zero; - strain_rate = NULL; - stress_old = NULL; - stress_new = NULL; - state_old = NULL; - state_new = NULL; - temp_old = NULL; - temp_new = NULL; - left_stretch = NULL; - rotation = NULL; - entropy = NULL; - energy_balance_term = NULL; - material_properties = NULL; - tangent_moduli = NULL; - ym_old = NULL; - ym_new = NULL; - nU_new = NULL; - nU_old = NULL; - bulk_scaling = NULL; - shear_scaling = NULL; - } - int nelements; - int nintg; - T dt; - T time; - T dtrnew; - T energy_dep; - T * strain_rate; - T * stress_old; - T * stress_new; - T * state_old; - T * state_new; - T * temp_old; - T * temp_new; - T * left_stretch; - T * rotation; - T * entropy; - T * energy_balance_term; - T * material_properties; - T * tangent_moduli; - T * ym_old; - T * ym_new; - T * nU_new; - T * nU_old; - T * bulk_scaling; - T * shear_scaling; - bool tangent_flag; - bool tangent_comp; - }; - - template - class Material { - public: - explicit Material(const MatProps & props) : num_state_vars(0), num_scratch_vars(0) - { - const T two(2.0); - T lambda = getMaterialProperty("LAMBDA", props, lambda); - shrmod = getMaterialProperty("SHEAR_MODULUS",props, shrmod); - datmod = lambda + two*shrmod; - shrmod0 = shrmod; - datmod0 = datmod; - - T lPlusS = lambda + shrmod; - - if ( lPlusS > 0 ) { - const T three(3.0); - const T one_half(0.5); - youngs = shrmod*(three*lambda+two*shrmod)/lPlusS; - poissons = one_half*lambda/lPlusS; - } else { - youngs = std::numeric_limits::quiet_NaN(); - poissons = std::numeric_limits::quiet_NaN(); - } - } - - virtual ~Material() - {} - - int getNumStateVars(){ - return num_state_vars; - } - - virtual int initialize( matParams * p ) { - int npoints = p->nelements; - for( int index = 0 ; index < num_state_vars * npoints ; ++index) { - p->state_old[index] = 0.0; - p->state_new[index] = 0.0; - } - return 0; - } - virtual int getStress( matParams * p ) = 0; - virtual int loadStepInit( matParams * p ) { - return 0; - } - protected: - int num_state_vars; - int num_scratch_vars; - T shrmod; - T datmod; - T shrmod0; - T datmod0; - T youngs; - T poissons; - - T getMaterialProperty( const std::string & name, const MatProps & props, T &property_value) { - - MatProps::const_iterator itr = props.find(name); - - if (itr != props.end()){ - - const T p = itr->second[0]; - - property_value = p; - return p ; - - } else { - - std::string msg = " Material input "; - msg += name; - msg += " does not exist\n"; - msg += " Setting value of "; - msg += name; - msg += " to zero\n"; - - property_value = -1.0; - return -1.0; - } - - } - - private: - Material( const Material & ); - Material & operator= ( const Material & ); - }; - - /** - * This is the class for the elastic constitutive model. The - * elastic model is a hypoelastic model with the following constitutive description - * - * \f$ - * \sigma_{ij}^{n+1} = \sigma_{ij}^{n} - * + \Delta t \left( \lambda \delta_{ij} D_{kk} - * + 2\mu D_{ij} \right) - * \f$ - */ - template - class Elastic : public Material { - public: - - explicit Elastic( const MatProps & props ) : Material(props) - { - const int num_material_properties = 2; - properties = new T[num_material_properties]; - this->getMaterialProperty("YOUNGS_MODULUS",props, properties[0]); - this->getMaterialProperty("POISSONS_RATIO",props, properties[1]); - } - - ~Elastic() { delete [] properties; properties = NULL; } - - static Material * createMaterial( const MatProps & props ) { - return new Elastic( props ); - } - - int initialize( matParams *) { - return 0; - } - - int getStress( matParams * p ) { - T youngs_ = properties[0]; - T pr = properties[1]; - T twomu = youngs_/(1.0+pr); - T alambda = twomu*pr/(1.0-2.0*pr); - int num_element = p->nelements; - T dt = p->dt; - T twomu_dt = twomu * dt; - for(int i=0; istrain_rate; - T traced = dt * ( strain[0] + strain[1] + strain[2]); - T *stress_new = p->stress_new; - T *stress_old = p->stress_old; - stress_new[0] = stress_old[0] + alambda*traced + twomu_dt*strain[0]; - stress_new[1] = stress_old[1] + alambda*traced + twomu_dt*strain[1]; - stress_new[2] = stress_old[2] + alambda*traced + twomu_dt*strain[2]; - stress_new[3] = stress_old[3] + twomu_dt*strain[3]; - stress_new[4] = stress_old[4] + twomu_dt*strain[4]; - stress_new[5] = stress_old[5] + twomu_dt*strain[5]; -#if defined(DEBUG_ELASTIC_MATERIAL_MODEL) - std::cout << "KHP: traced= " << traced << ", dt= " << dt << ", " << alambda << ", " << twomu_dt << "\n"; - std::cout << "KHP: s= " << stress_new[0] - << ", " << stress_new[1] - << ", " << stress_new[2] - << ", " << stress_new[3] - << ", " << stress_new[4] - << ", " << stress_new[5] << std::endl; - std::cout << "KHP: s= " << stress_old[0] - << ", " << stress_old[1] - << ", " << stress_old[2] - << ", " << stress_old[3] - << ", " << stress_old[4] - << ", " << stress_old[5] << std::endl; -#endif - } - return 0; - } - public: - T * properties; - private: - Elastic( const Elastic & ); - Elastic & operator= ( const Elastic & ); - }; -} // lame - -// -// Defined numerical constants -// -// -// Indexes into a 4 by 3 matrix of hourglass constants -// -const int HG_X1 = 0; -const int HG_Y1 = 1; -const int HG_Z1 = 2; -const int HG_X2 = 3; -const int HG_Y2 = 4; -const int HG_Z2 = 5; -const int HG_X3 = 6; -const int HG_Y3 = 7; -const int HG_Z3 = 8; -const int HG_X4 = 9; -const int HG_Y4 = 10; -const int HG_Z4 = 11; -// -// Indexes into a 3 by 3 symmetric tensor stored as a length 6 vector -// -const int K_S_XX = 0; -const int K_S_YY = 1; -const int K_S_ZZ = 2; -const int K_S_XY = 3; -const int K_S_YZ = 4; -const int K_S_ZX = 5; -const int K_S_YX = 3; -const int K_S_ZY = 4; -const int K_S_XZ = 5; -// -// Indexes into a full 3 by 3 tensor stored as a length 9 vector -// -const int K_F_XX = 0; -const int K_F_YY = 1; -const int K_F_ZZ = 2; -const int K_F_XY = 3; -const int K_F_YZ = 4; -const int K_F_ZX = 5; -const int K_F_YX = 6; -const int K_F_ZY = 7; -const int K_F_XZ = 8; -// -// Indexes into a 3 by 3 skew symmetric tensor stored as a length 9 vector -// -const int K_V_XY = 0; -const int K_V_YZ = 1; -const int K_V_ZX = 2; -// -// Indexes into a 2 by 2 symmetric tensor stored as a length 3 vector -// -const int K_S_21_XX = 0; -const int K_S_21_YY = 1; -const int K_S_21_XY = 2; -const int K_S_21_YX = 2; -// -// Indexes into a full 2 by 2 tensor stored as a length 3 vector -// -const int K_F_22_XX = 0; -const int K_F_22_YY = 1; -const int K_F_22_XY = 2; -const int K_F_22_YX = 3; - -namespace APS { - namespace Hex { - - //*************************************************************************************************************** - // - // Additive decomposition for a gradient operator - // - // Input: - // gradient(9) Input velocity gradient - // - // Output: - // stretching(6) - // vorticity(3) - // - //*************************************************************************************************************** - template - inline void additive_decomp36(const Scalar *const gradient, Scalar *const stretching, Scalar *const vorticity) { - // - // Symmetric part - // - stretching[K_S_XX] = gradient[K_F_XX]; - stretching[K_S_YY] = gradient[K_F_YY]; - stretching[K_S_ZZ] = gradient[K_F_ZZ]; - const Real half = 0.5; - stretching[K_S_XY] = half*(gradient[K_F_XY] + gradient[K_F_YX]); - stretching[K_S_YZ] = half*(gradient[K_F_YZ] + gradient[K_F_ZY]); - stretching[K_S_ZX] = half*(gradient[K_F_ZX] + gradient[K_F_XZ]); - // - // Skew Symmetric part - // - vorticity[K_V_XY] = half*(gradient[K_F_XY] - gradient[K_F_YX]); - vorticity[K_V_YZ] = half*(gradient[K_F_YZ] - gradient[K_F_ZY]); - vorticity[K_V_ZX] = half*(gradient[K_F_ZX] - gradient[K_F_XZ]); - } - - //*************************************************************************************************************** - // - // Polar decomposition of a stretching tensor - // - // Input - // dt Time multiplication factor - // stretching(6) Current element stretching tensor - // vorticity(3) The skew symmetric portion of the velocity gradient - // rotation_old(9) Old element rotation tensor - // Output - // stretch(6) New calculated element stretch - // rotation_new(9) New element rotation tensor - // - //*************************************************************************************************************** - template - inline void polar_decomp33r2(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - const Scalar *const rotation_old, - Scalar *const stretch, - Scalar *const rotation_new) - { - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - - // - // forward elimination - // - const Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - - const Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - const Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - - const Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - const Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - const Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - Scalar r_XX = rotation_old[K_F_XX] + dt_half*( z3 * rotation_old[K_F_YX] - z2 * rotation_old[K_F_ZX] ); - Scalar r_YX = rotation_old[K_F_YX] + dt_half*( z1 * rotation_old[K_F_ZX] - z3 * rotation_old[K_F_XX] ); - Scalar r_ZX = rotation_old[K_F_ZX] + dt_half*( z2 * rotation_old[K_F_XX] - z1 * rotation_old[K_F_YX] ); - Scalar r_XY = rotation_old[K_F_XY] + dt_half*( z3 * rotation_old[K_F_YY] - z2 * rotation_old[K_F_ZY] ); - Scalar r_YY = rotation_old[K_F_YY] + dt_half*( z1 * rotation_old[K_F_ZY] - z3 * rotation_old[K_F_XY] ); - Scalar r_ZY = rotation_old[K_F_ZY] + dt_half*( z2 * rotation_old[K_F_XY] - z1 * rotation_old[K_F_YY] ); - Scalar r_XZ = rotation_old[K_F_XZ] + dt_half*( z3 * rotation_old[K_F_YZ] - z2 * rotation_old[K_F_ZZ] ); - Scalar r_YZ = rotation_old[K_F_YZ] + dt_half*( z1 * rotation_old[K_F_ZZ] - z3 * rotation_old[K_F_XZ] ); - Scalar r_ZZ = rotation_old[K_F_ZZ] + dt_half*( z2 * rotation_old[K_F_XZ] - z1 * rotation_old[K_F_YZ] ); - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - - Scalar a13a12 = a13*a12; - Scalar a23 = b32 + a13a12; - r_YX += r_XX * a12; - r_YY += r_XY * a12; - r_YZ += r_XZ * a12; - b32 = (b32 - a13a12) * a22inv; - r_ZX += r_XX * a13 + r_YX * b32; - r_ZY += r_XY * a13 + r_YY * b32; - r_ZZ += r_XZ * a13 + r_YZ * b32; - // - // backward substitution - - // - const Scalar a33inv = 1.0 / (1.0 + a13 * a13 + a23 * b32); - - rotation_new[K_F_ZX] = r_ZX * a33inv; - rotation_new[K_F_ZY] = r_ZY * a33inv; - rotation_new[K_F_ZZ] = r_ZZ * a33inv; - rotation_new[K_F_YX] = ( r_YX - rotation_new[K_F_ZX] * a23 ) * a22inv; - rotation_new[K_F_YY] = ( r_YY - rotation_new[K_F_ZY] * a23 ) * a22inv; - rotation_new[K_F_YZ] = ( r_YZ - rotation_new[K_F_ZZ] * a23 ) * a22inv; - rotation_new[K_F_XX] = r_XX - rotation_new[K_F_ZX] * a13 - rotation_new[K_F_YX] * a12; - rotation_new[K_F_XY] = r_XY - rotation_new[K_F_ZY] * a13 - rotation_new[K_F_YY] * a12; - rotation_new[K_F_XZ] = r_XZ - rotation_new[K_F_ZZ] * a13 - rotation_new[K_F_YZ] * a12; - // - // update stretch tensor in the new configuration - - // - const Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - const Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - const Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - const Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - const Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - const Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - const Scalar s_XX = stretch[K_S_XX]; - const Scalar s_YY = stretch[K_S_YY]; - const Scalar s_ZZ = stretch[K_S_ZZ]; - const Scalar s_XY = stretch[K_S_XY]; - const Scalar s_YZ = stretch[K_S_YZ]; - const Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } - - template - inline void polar_decomp33_nr(const Scalar dt, - const Scalar *const stretching, - const Scalar *const vorticity, - Scalar *const stretch) { - // - // calculate the rates of rotation via gauss elimination. - // - Scalar z1 = stretching[K_S_XY] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_XY] + stretching[K_S_YY] * stretch[K_S_YZ] - - stretching[K_S_YZ] * stretch[K_S_YY] + stretching[K_S_YZ] * stretch[K_S_ZZ] - stretching[K_S_ZZ] * stretch[K_S_YZ]; - Scalar z2 = stretching[K_S_ZX] * stretch[K_S_XX] - stretching[K_S_XX] * stretch[K_S_ZX] + stretching[K_S_YZ] * stretch[K_S_XY] - - stretching[K_S_XY] * stretch[K_S_YZ] + stretching[K_S_ZZ] * stretch[K_S_ZX] - stretching[K_S_ZX] * stretch[K_S_ZZ]; - Scalar z3 = stretching[K_S_XX] * stretch[K_S_XY] - stretching[K_S_XY] * stretch[K_S_XX] + stretching[K_S_XY] * stretch[K_S_YY] - - stretching[K_S_YY] * stretch[K_S_XY] + stretching[K_S_ZX] * stretch[K_S_YZ] - stretching[K_S_YZ] * stretch[K_S_ZX]; - // - // forward elimination - // - Scalar a1inv = 1.0 / (stretch[K_S_YY] + stretch[K_S_ZZ]); - Scalar a4BYa1 = -stretch[K_S_XY] * a1inv; - Scalar a2inv = 1.0 / (stretch[K_S_ZZ] + stretch[K_S_XX] + stretch[K_S_XY] * a4BYa1); - Scalar a5 = -stretch[K_S_YZ] + stretch[K_S_ZX] * a4BYa1; - z2 -= z1 * a4BYa1; - Scalar a6BYa1 = -stretch[K_S_ZX] * a1inv; - Scalar a5BYa2 = a5 * a2inv; - z3 -= z1 * a6BYa1 - z2 * a5BYa2; - // - // backward substitution - - // - z3 /= (stretch[K_S_XX] + stretch[K_S_YY] + stretch[K_S_ZX] * a6BYa1 + a5 * a5BYa2); - z2 = (z2 - a5 * z3) * a2inv; - z1 = (z1*a1inv - a6BYa1 * z3 -a4BYa1 * z2); - - // - // calculate rotation rates - recall that spin_rate is an asymmetric tensor, - // so compute spin rate vector as dual of spin rate tensor, - // i.e w_i = e_ijk * spin_rate_jk - // - z1 += vorticity[K_V_YZ]; - z2 += vorticity[K_V_ZX]; - z3 += vorticity[K_V_XY]; - // - // update rotation tensor: - // 1) premultiply old rotation tensor to get right-hand side. - // - const Scalar dt_half = 0.5 * dt; - // - // 2) solve for new rotation tensor via gauss elimination. - // forward elimination - - // - - Scalar a12 = - dt_half * z3; - Scalar a13 = dt_half * z2; - Scalar b32 = - dt_half * z1; - Scalar a22inv = 1.0 / (1.0 + a12 * a12); - b32 = (b32-a12 * a13) * a22inv; - // - // update stretch tensor in the new configuration - - // - { - Scalar a1 = stretching[K_S_XY] + vorticity[K_V_XY]; - Scalar a2 = stretching[K_S_YZ] + vorticity[K_V_YZ]; - Scalar a3 = stretching[K_S_ZX] + vorticity[K_V_ZX]; - Scalar b1 = stretching[K_S_ZX] - vorticity[K_V_ZX]; - Scalar b2 = stretching[K_S_XY] - vorticity[K_V_XY]; - Scalar b3 = stretching[K_S_YZ] - vorticity[K_V_YZ]; - - Scalar s_XX = stretch[K_S_XX]; - Scalar s_YY = stretch[K_S_YY]; - Scalar s_ZZ = stretch[K_S_ZZ]; - Scalar s_XY = stretch[K_S_XY]; - Scalar s_YZ = stretch[K_S_YZ]; - Scalar s_ZX = stretch[K_S_ZX]; - - stretch[K_S_XX] += dt * (stretching[K_S_XX] * s_XX + ( a1 + z3 ) * s_XY + ( b1 - z2 ) * s_ZX); - stretch[K_S_YY] += dt * (stretching[K_S_YY] * s_YY + ( a2 + z1 ) * s_YZ + ( b2 - z3 ) * s_XY); - stretch[K_S_ZZ] += dt * (stretching[K_S_ZZ] * s_ZZ + ( a3 + z2 ) * s_ZX + ( b3 - z1 ) * s_YZ); - stretch[K_S_XY] += dt * (stretching[K_S_XX] * s_XY + ( a1 ) * s_YY + ( b1 ) * s_YZ - z3 * s_XX + z1 * s_ZX); - stretch[K_S_YZ] += dt * (stretching[K_S_YY] * s_YZ + ( a2 ) * s_ZZ + ( b2 ) * s_ZX - z1 * s_YY + z2 * s_XY); - stretch[K_S_ZX] += dt * (stretching[K_S_ZZ] * s_ZX + ( a3 ) * s_XX + ( b3 ) * s_XY - z2 * s_ZZ + z3 * s_YZ); - } - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor forward - // - // Input: - // rotation(9) Rotation tensor - // orig_tensor(6) Input symmetric tensor - // - // Output: - // rot_tensor(6) Output symmetric tensor - // - //*************************************************************************************************************** - template - inline void rotate_tensor_forward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_YX] + orig_tensor[K_S_XZ]*rotation[K_F_ZX]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_YX] + orig_tensor[K_S_YZ]*rotation[K_F_ZX]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_YX] + orig_tensor[K_S_ZZ]*rotation[K_F_ZX]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_XY] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_ZY]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_XY] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_ZY]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_XY] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZY]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_XZ] + orig_tensor[K_S_XY]*rotation[K_F_YZ] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_XZ] + orig_tensor[K_S_YY]*rotation[K_F_YZ] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_XZ] + orig_tensor[K_S_ZY]*rotation[K_F_YZ] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_YX]*t_const[1] + rotation[K_F_ZX]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_XY]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_ZY]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_XZ]*t_const[6] + rotation[K_F_YZ]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_YX]*t_const[4] + rotation[K_F_ZX]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_XY]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_ZY]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_XZ]*t_const[0] + rotation[K_F_YZ]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor backward - // - // Input: - // rotation(9) Rotation tensor - // orig_tensor(6) Input symmetric tensor - // - // Output: - // rot_tensor(6) Output symmetric tensor - // - //*************************************************************************************************************** - template - inline void rotate_tensor_backward(const Scalar *const rotation, - const Scalar *const orig_tensor, - Scalar *const rot_tensor) { - Scalar t_const[9]; - - t_const[0] = orig_tensor[K_S_XX]*rotation[K_F_XX] + orig_tensor[K_S_XY]*rotation[K_F_XY] + orig_tensor[K_S_XZ]*rotation[K_F_XZ]; - t_const[1] = orig_tensor[K_S_YX]*rotation[K_F_XX] + orig_tensor[K_S_YY]*rotation[K_F_XY] + orig_tensor[K_S_YZ]*rotation[K_F_XZ]; - t_const[2] = orig_tensor[K_S_ZX]*rotation[K_F_XX] + orig_tensor[K_S_ZY]*rotation[K_F_XY] + orig_tensor[K_S_ZZ]*rotation[K_F_XZ]; - t_const[3] = orig_tensor[K_S_XX]*rotation[K_F_YX] + orig_tensor[K_S_XY]*rotation[K_F_YY] + orig_tensor[K_S_XZ]*rotation[K_F_YZ]; - t_const[4] = orig_tensor[K_S_YX]*rotation[K_F_YX] + orig_tensor[K_S_YY]*rotation[K_F_YY] + orig_tensor[K_S_YZ]*rotation[K_F_YZ]; - t_const[5] = orig_tensor[K_S_ZX]*rotation[K_F_YX] + orig_tensor[K_S_ZY]*rotation[K_F_YY] + orig_tensor[K_S_ZZ]*rotation[K_F_YZ]; - t_const[6] = orig_tensor[K_S_XX]*rotation[K_F_ZX] + orig_tensor[K_S_XY]*rotation[K_F_ZY] + orig_tensor[K_S_XZ]*rotation[K_F_ZZ]; - t_const[7] = orig_tensor[K_S_YX]*rotation[K_F_ZX] + orig_tensor[K_S_YY]*rotation[K_F_ZY] + orig_tensor[K_S_YZ]*rotation[K_F_ZZ]; - t_const[8] = orig_tensor[K_S_ZX]*rotation[K_F_ZX] + orig_tensor[K_S_ZY]*rotation[K_F_ZY] + orig_tensor[K_S_ZZ]*rotation[K_F_ZZ]; - - rot_tensor[K_S_XX] = rotation[K_F_XX]*t_const[0] + rotation[K_F_XY]*t_const[1] + rotation[K_F_XZ]*t_const[2]; - rot_tensor[K_S_YY] = rotation[K_F_YX]*t_const[3] + rotation[K_F_YY]*t_const[4] + rotation[K_F_YZ]*t_const[5]; - rot_tensor[K_S_ZZ] = rotation[K_F_ZX]*t_const[6] + rotation[K_F_ZY]*t_const[7] + rotation[K_F_ZZ]*t_const[8]; - - rot_tensor[K_S_XY] = rotation[K_F_XX]*t_const[3] + rotation[K_F_XY]*t_const[4] + rotation[K_F_XZ]*t_const[5]; - rot_tensor[K_S_YZ] = rotation[K_F_YX]*t_const[6] + rotation[K_F_YY]*t_const[7] + rotation[K_F_YZ]*t_const[8]; - rot_tensor[K_S_ZX] = rotation[K_F_ZX]*t_const[0] + rotation[K_F_ZY]*t_const[1] + rotation[K_F_ZZ]*t_const[2]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor forward - // - // Input: - // rotation(4) Rotation tensor - // orig_tensor(3) Input symmetric tensor - // - // Output: - // rot_tensor(3) Output symmetric tensor - // - //*************************************************************************************************************** - template - inline void rotate_tensor_21_forward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor){ - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YX]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YX]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XY] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_YX]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_XY]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_YX]*t_const[3]; - } - - //*************************************************************************************************************** - // - // Use a rotation matrix to rotate a given tensor backward - // - // Input: - // rotation(4) Rotation tensor - // orig_tensor(3) Input symmetric tensor - // - // Output: - // rot_tensor(3) Output symmetric tensor - // - //*************************************************************************************************************** - template - inline void rotate_tensor_21_backward(const Scalar *const rotation, const Scalar *const orig_tensor, Scalar *const rot_tensor) - { - Scalar t_const[4]; - - t_const[0] = orig_tensor[K_S_21_XX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_XY]; - t_const[1] = orig_tensor[K_S_21_YX]*rotation[K_F_22_XX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_XY]; - t_const[2] = orig_tensor[K_S_21_XX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_XY]*rotation[K_F_22_YY]; - t_const[3] = orig_tensor[K_S_21_YX]*rotation[K_F_22_YX] + orig_tensor[K_S_21_YY]*rotation[K_F_22_YY]; - - rot_tensor[K_S_21_XX] = rotation[K_F_22_XX]*t_const[0] + rotation[K_F_22_XY]*t_const[1]; - rot_tensor[K_S_21_YY] = rotation[K_F_22_YX]*t_const[2] + rotation[K_F_22_YY]*t_const[3]; - rot_tensor[K_S_21_XY] = rotation[K_F_22_XX]*t_const[2] + rotation[K_F_22_XY]*t_const[3]; - } - - /** - * Compute the dot product of two length 8 vectors - * - * Input - * x1(8) first vector - * x2(8) second vector - */ - template - inline Scalar ddot8(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2] + - x1[3] * x2[3] + - x1[4] * x2[4] + - x1[5] * x2[5] + - x1[6] * x2[6] + - x1[7] * x2[7]); - } - - /** - * Compute the dot product of two length 3 vectors - * - * Input - * x1(3) first vector - * x2(3) second vector - */ - template - inline Scalar ddot3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[0] + - x1[1] * x2[1] + - x1[2] * x2[2]); - } - - /** - * Compute the dot product of two length 8 vectors using vector striding - * - * Input - * x1(8) first vector - * x2(8) second vector - */ - template - inline Scalar ddot8_stride1_stride3(const Scalar *const x1, const Scalar *const x2) { - return (x1[0] * x2[ 0] + - x1[1] * x2[ 3] + - x1[2] * x2[ 6] + - x1[3] * x2[ 9] + - x1[4] * x2[12] + - x1[5] * x2[15] + - x1[6] * x2[18] + - x1[7] * x2[21]); - } - - /** - * Rotate a [3,8] matrix into a [8,3] matrix - * - * Input: - * cur_coords Old matrix - * - * Output: - * cordel_ptr New matrix - */ - template - inline void transform_38_matrix_to_83_matrix(const Scalar *cordel_ptr, Scalar *cur_coords) { - cur_coords[0] = cordel_ptr[0]; - cur_coords[1] = cordel_ptr[3]; - cur_coords[2] = cordel_ptr[6]; - cur_coords[3] = cordel_ptr[9]; - cur_coords[4] = cordel_ptr[12]; - cur_coords[5] = cordel_ptr[15]; - cur_coords[6] = cordel_ptr[18]; - cur_coords[7] = cordel_ptr[21]; - - cur_coords[8] = cordel_ptr[1]; - cur_coords[9] = cordel_ptr[4]; - cur_coords[10] = cordel_ptr[7]; - cur_coords[11] = cordel_ptr[10]; - cur_coords[12] = cordel_ptr[13]; - cur_coords[13] = cordel_ptr[16]; - cur_coords[14] = cordel_ptr[19]; - cur_coords[15] = cordel_ptr[22]; - - cur_coords[16] = cordel_ptr[2]; - cur_coords[17] = cordel_ptr[5]; - cur_coords[18] = cordel_ptr[8]; - cur_coords[19] = cordel_ptr[11]; - cur_coords[20] = cordel_ptr[14]; - cur_coords[21] = cordel_ptr[17]; - cur_coords[22] = cordel_ptr[20]; - cur_coords[23] = cordel_ptr[23]; - } - - /** - * Add bulk viscosity terms to a set of symmetric 3x3 tensors. Bulk viscosity terms - * will only be added to the terms on the diagonal of the tensor. - * - * Input: - * Int num_elements : Number of input tensors - * Real *bulkq : Bulk viscosity term to add - * Real *stress_in : Input set of tensors - * - * Output: - * Real *stress_out : Modified output tensors - */ - template - inline void add_bulk_visc(const Int num_elements, const Scalar * bulkq, const Scalar * stress_in, Scalar * stress_out) { - for(Int ielem = 0; ielem < num_elements; ++ielem) { - stress_out[K_S_XX] = stress_in[K_S_XX] + bulkq[ielem]; - stress_out[K_S_YY] = stress_in[K_S_YY] + bulkq[ielem]; - stress_out[K_S_ZZ] = stress_in[K_S_ZZ] + bulkq[ielem]; - stress_out[K_S_XY] = stress_in[K_S_XY]; - stress_out[K_S_XZ] = stress_in[K_S_XZ]; - stress_out[K_S_YZ] = stress_in[K_S_YZ]; - stress_out += 6; - stress_in += 6; - } - } - - /** - * Compute the aspect ratio for an element - * - * Input: - * gradop12x(24) 12 times the gradient operator - * volume12x 12 times the element volume - */ - template - inline Scalar comp_aspect(const Scalar *const gradop12x, const Scalar &volume12x) { - return 6.0 * volume12x / - (gradop12x[0] * gradop12x[0]+ - gradop12x[1] * gradop12x[1]+ - gradop12x[2] * gradop12x[2]+ - gradop12x[3] * gradop12x[3]+ - gradop12x[4] * gradop12x[4]+ - gradop12x[5] * gradop12x[5]+ - gradop12x[6] * gradop12x[6]+ - gradop12x[7] * gradop12x[7]+ - gradop12x[8] * gradop12x[8]+ - gradop12x[9] * gradop12x[9]+ - gradop12x[10] * gradop12x[10]+ - gradop12x[11] * gradop12x[11]+ - gradop12x[12] * gradop12x[12]+ - gradop12x[13] * gradop12x[13]+ - gradop12x[14] * gradop12x[14]+ - gradop12x[15] * gradop12x[15]+ - gradop12x[16] * gradop12x[16]+ - gradop12x[17] * gradop12x[17]+ - gradop12x[18] * gradop12x[18]+ - gradop12x[19] * gradop12x[19]+ - gradop12x[20] * gradop12x[20]+ - gradop12x[21] * gradop12x[21]+ - gradop12x[22] * gradop12x[22]+ - gradop12x[23] * gradop12x[23]); - } - - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations after the element stress calculation - * - * Input: - * Int nelem Number of elements in workset - * Int dt Last step time step - * Real *cordel Element nodal coordinates - * Real *vel Element nodal velocities - * Real *rotation elemetn rotation tensor - * Real *stress_new The new element stress - * Real *rotated_stretching The element stretching rate tensor - * Real *spin_rate rigid body elemetn spining rate - * Real linBulkVisc Linear artificial bulk viscosity parameter - * Real quadBulkVisc Quadradic bulk viscosity parameter - * Real *elem_mass The element mass - * Real *elem_dilmod Element dilatation modulus as computed by the effective modulus routine - * Real *elem_shrmod Element shear modulus as coputed by the effective modulus routine - * Real hg_stiffness Element hourglass stiffness scaling constant - * Real hg_viscosity Element hourglass viscosity scaling constant - * - * Output: - * Real *rotated_stress Element rotated stress tensor - * Real min_elem_time_step New mimumum element based time step - * Real *volume Element end of step volume - * Real *elem_time_step Element time steps on per element basis - * Real *hg_resist_old Old hourglass resitance rate - * Real *hg_resist_new New hourglass resistance rate - * Real *force_new Computed internal force - * Real *hg_energy Per element hourglass force energy - * Real *int_energy Per element internal energy - * - * ********************************************************************************************** - */ - - //*************************************************************************************************************** - // - // Compute a set of 8 components for a gradient operator. - // - // 48*3 = 144 multiplications. - // - // Input - // grad_ptr(24) Array in which to store the current gradient operator components - // x(8) X nodal coordinates - // y(8) Y nodal coorindates - // z(8) Z nodal coordinates - // - //*************************************************************************************************************** - template - inline - void comp_grad12x( Scalar *const grad_ptr, const Scalar * const x, const Scalar *const y, const Scalar *const z) { - Scalar R42=(z[3] - z[1]); - Scalar R52=(z[4] - z[1]); - Scalar R54=(z[4] - z[3]); - - Scalar R63=(z[5] - z[2]); - Scalar R83=(z[7] - z[2]); - Scalar R86=(z[7] - z[5]); - - Scalar R31=(z[2] - z[0]); - Scalar R61=(z[5] - z[0]); - Scalar R74=(z[6] - z[3]); - - Scalar R72=(z[6] - z[1]); - Scalar R75=(z[6] - z[4]); - Scalar R81=(z[7] - z[0]); - - Scalar t1 =(R63 + R54); - Scalar t2 =(R61 + R74); - Scalar t3 =(R72 + R81); - Scalar t4 =(R86 + R42); - Scalar t5 =(R83 + R52); - Scalar t6 =(R75 + R31); - - grad_ptr[0] = (y[1] * t1) - (y[2] * R42) - (y[3] * t5) + (y[4] * t4) + (y[5] * R52) - (y[7] * R54); - grad_ptr[1] = (y[2] * t2) + (y[3] * R31) - (y[0] * t1) - (y[5] * t6) + (y[6] * R63) - (y[4] * R61); - grad_ptr[2] = (y[3] * t3) + (y[0] * R42) - (y[1] * t2) - (y[6] * t4) + (y[7] * R74) - (y[5] * R72); - grad_ptr[3] = (y[0] * t5) - (y[1] * R31) - (y[2] * t3) + (y[7] * t6) + (y[4] * R81) - (y[6] * R83); - grad_ptr[4] = (y[5] * t3) + (y[6] * R86) - (y[7] * t2) - (y[0] * t4) - (y[3] * R81) + (y[1] * R61); - grad_ptr[5] = (y[6] * t5) - (y[4] * t3) - (y[7] * R75) + (y[1] * t6) - (y[0] * R52) + (y[2] * R72); - grad_ptr[6] = (y[7] * t1) - (y[5] * t5) - (y[4] * R86) + (y[2] * t4) - (y[1] * R63) + (y[3] * R83); - grad_ptr[7] = (y[4] * t2) - (y[6] * t1) + (y[5] * R75) - (y[3] * t6) - (y[2] * R74) + (y[0] * R54); - - R42=(x[3] - x[1]); - R52=(x[4] - x[1]); - R54=(x[4] - x[3]); - - R63=(x[5] - x[2]); - R83=(x[7] - x[2]); - R86=(x[7] - x[5]); - - R31=(x[2] - x[0]); - R61=(x[5] - x[0]); - R74=(x[6] - x[3]); - - R72=(x[6] - x[1]); - R75=(x[6] - x[4]); - R81=(x[7] - x[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[8 ] = (z[1] * t1) - (z[2] * R42) - (z[3] * t5) + (z[4] * t4) + (z[5] * R52) - (z[7] * R54); - grad_ptr[9 ] = (z[2] * t2) + (z[3] * R31) - (z[0] * t1) - (z[5] * t6) + (z[6] * R63) - (z[4] * R61); - grad_ptr[10] = (z[3] * t3) + (z[0] * R42) - (z[1] * t2) - (z[6] * t4) + (z[7] * R74) - (z[5] * R72); - grad_ptr[11] = (z[0] * t5) - (z[1] * R31) - (z[2] * t3) + (z[7] * t6) + (z[4] * R81) - (z[6] * R83); - grad_ptr[12] = (z[5] * t3) + (z[6] * R86) - (z[7] * t2) - (z[0] * t4) - (z[3] * R81) + (z[1] * R61); - grad_ptr[13] = (z[6] * t5) - (z[4] * t3) - (z[7] * R75) + (z[1] * t6) - (z[0] * R52) + (z[2] * R72); - grad_ptr[14] = (z[7] * t1) - (z[5] * t5) - (z[4] * R86) + (z[2] * t4) - (z[1] * R63) + (z[3] * R83); - grad_ptr[15] = (z[4] * t2) - (z[6] * t1) + (z[5] * R75) - (z[3] * t6) - (z[2] * R74) + (z[0] * R54); - - R42=(y[3] - y[1]); - R52=(y[4] - y[1]); - R54=(y[4] - y[3]); - - R63=(y[5] - y[2]); - R83=(y[7] - y[2]); - R86=(y[7] - y[5]); - - R31=(y[2] - y[0]); - R61=(y[5] - y[0]); - R74=(y[6] - y[3]); - - R72=(y[6] - y[1]); - R75=(y[6] - y[4]); - R81=(y[7] - y[0]); - - t1 =(R63 + R54); - t2 =(R61 + R74); - t3 =(R72 + R81); - t4 =(R86 + R42); - t5 =(R83 + R52); - t6 =(R75 + R31); - - grad_ptr[16] = (x[1] * t1) - (x[2] * R42) - (x[3] * t5) + (x[4] * t4) + (x[5] * R52) - (x[7] * R54); - grad_ptr[17] = (x[2] * t2) + (x[3] * R31) - (x[0] * t1) - (x[5] * t6) + (x[6] * R63) - (x[4] * R61); - grad_ptr[18] = (x[3] * t3) + (x[0] * R42) - (x[1] * t2) - (x[6] * t4) + (x[7] * R74) - (x[5] * R72); - grad_ptr[19] = (x[0] * t5) - (x[1] * R31) - (x[2] * t3) + (x[7] * t6) + (x[4] * R81) - (x[6] * R83); - grad_ptr[20] = (x[5] * t3) + (x[6] * R86) - (x[7] * t2) - (x[0] * t4) - (x[3] * R81) + (x[1] * R61); - grad_ptr[21] = (x[6] * t5) - (x[4] * t3) - (x[7] * R75) + (x[1] * t6) - (x[0] * R52) + (x[2] * R72); - grad_ptr[22] = (x[7] * t1) - (x[5] * t5) - (x[4] * R86) + (x[2] * t4) - (x[1] * R63) + (x[3] * R83); - grad_ptr[23] = (x[4] * t2) - (x[6] * t1) + (x[5] * R75) - (x[3] * t6) - (x[2] * R74) + (x[0] * R54); - } - - //*************************************************************************************************************** - // - // Compute the hourglass operator - // - // Input: - // x_ptr, y_ptr, z_ptr The x, y, and z nodal coordinates - // - // gradop12x_ptr_x 12 times the gradient operator components - // gradop12x_ptr_y 12 times the gradient operator components - // gradop12x_ptr_z 12 times the gradient operator components - // - // volinv12th The inverse of the element voluem, times one 12th - // - //*************************************************************************************************************** - template - inline - void comp_hgop(const Scalar *const x, const Scalar *const y, const Scalar * const z, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - const Scalar volinv12th, - Scalar *const hgop) { - - // - // KHP: Perhaps, this array should be passed in from the calling - // routine? - // - const Scalar hgop_arr[32] = { 1.0, 1.0,-1.0,-1.0,-1.0,-1.0, 1.0, 1.0, - 1.0,-1.0,-1.0, 1.0,-1.0, 1.0, 1.0,-1.0, - 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, 1.0,-1.0, - -1.0, 1.0,-1.0, 1.0, 1.0,-1.0, 1.0,-1.0}; - - // KHP: Alternatively, we could have - // hx0,hx1,hx2,hx3,...,hz0,hz1,hz2,hz3 - Scalar hgconst12th[12]; - - Scalar t0 = x[0] - x[1]; - Scalar t1 = x[2] - x[3]; - Scalar t2 = x[4] - x[5]; - Scalar t3 = x[6] - x[7]; - - hgconst12th[0] = ( (x[0]+x[1]) - (x[2]+x[3]) - (x[4]+x[5]) + (x[6]+x[7]) ) * volinv12th; - hgconst12th[1] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[2] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[3] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (y[0] - y[1]); - t1 = (y[2] - y[3]); - t2 = (y[4] - y[5]); - t3 = (y[6] - y[7]); - - hgconst12th[4] = ( (y[0]+y[1]) - (y[2]+y[3]) - (y[4]+y[5]) + (y[6]+y[7]) ) * volinv12th; - hgconst12th[5] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[6] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[7] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - t0 = (z[0] - z[1]); - t1 = (z[2] - z[3]); - t2 = (z[4] - z[5]); - t3 = (z[6] - z[7]); - - hgconst12th[8] = ( (z[0]+z[1]) - (z[2]+z[3]) - (z[4]+z[5]) + (z[6]+z[7]) ) * volinv12th; - hgconst12th[9] = ( t0 - t1 - t2 + t3 ) * volinv12th; - hgconst12th[10] = ( t0 + t1 + t2 + t3 ) * volinv12th; - hgconst12th[11] = ( -t0 - t1 + t2 + t3 ) * volinv12th; - - // 8 times 12 = 96 + 12 = 108 multiplications. - for(int i = 0; i < 8; ++i) { - hgop[i ] = hgop_arr[i ] - (hgconst12th[0] * gradop12x_ptr_x[i] + hgconst12th[4] * gradop12x_ptr_y[i] + hgconst12th[8 ] * gradop12x_ptr_z[i]); - hgop[i+8 ] = hgop_arr[i+8 ] - (hgconst12th[1] * gradop12x_ptr_x[i] + hgconst12th[5] * gradop12x_ptr_y[i] + hgconst12th[9 ] * gradop12x_ptr_z[i]); - hgop[i+16] = hgop_arr[i+16] - (hgconst12th[2] * gradop12x_ptr_x[i] + hgconst12th[6] * gradop12x_ptr_y[i] + hgconst12th[10] * gradop12x_ptr_z[i]); - hgop[i+24] = hgop_arr[i+24] - (hgconst12th[3] * gradop12x_ptr_x[i] + hgconst12th[7] * gradop12x_ptr_y[i] + hgconst12th[11] * gradop12x_ptr_z[i]); - } - } - - //*************************************************************************************************************** - // - // Compute the new internal forces, hg resistances, and element energies - // - // Input: - // dt last time step - // spin_rate_ptr pointer into the spin rate array - // hgop element hourglass operator - // vel_ptr element velocity - // fac1 hourglass stiffness resitance factor - // fac2 hourglass viscosity resitance factor - // hg_resist_old_ptr Old hourglass resitances - // - // Output: - // hg_resist_new_ptr New hourglass resitances - // hg_resist_total_ptr Total hourglass resistance - // - //*************************************************************************************************************** - - template - inline - void comp_force(const Scalar &dt, - const Scalar *const spin_rate_ptr, - const Scalar *const hgop_for_resist_calc, - const Scalar *const hgop_ptr0, - const Scalar *const hgop_ptr1, - const Scalar *const hgop_ptr2, - const Scalar *const hgop_ptr3, - const Scalar *const vel, - const Scalar &fac1, - const Scalar &fac2, - const Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - const Scalar *const total_stress12th, - const Scalar *const gradop12x_ptr_x, - const Scalar *const gradop12x_ptr_y, - const Scalar *const gradop12x_ptr_z, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const force_new, - bool scaleHGRotation) { - - // - // NKC, does Presto Scalar need these spin rate terms? Pronto appears to have dumped them.... - // - const Scalar dwxy = dt * spin_rate_ptr[0]; - const Scalar dwyz = dt * spin_rate_ptr[1]; - const Scalar dwzx = dt * spin_rate_ptr[2]; - // - // Compute new hourglass resitance by the old rotated hourglass resitance plus a hourglass rate term - // - Scalar hg_resist_total[12]; - Scalar * hg_resist_total_ptr = hg_resist_total; - const Scalar * hgop_ptr = hgop_for_resist_calc; - const Scalar * vel_ptr = vel; - const Scalar * hg_resist_old_ptr = hg_resist_old; - Scalar * hg_resist_new_ptr = hg_resist_new; - Scalar * hg_energy_ptr = hg_energy; - Scalar * int_energy_ptr = int_energy; - Scalar * force_new_ptr = force_new; - - if (!scaleHGRotation){ - for(int i = 0; i < 4; ++i) { - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - hg_resist_new_ptr[0] = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2 + fac1* hg_rate_0 ; - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2* hg_rate_0 ; - - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - hg_resist_new_ptr[1] = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2 + fac1* hg_rate_1 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2* hg_rate_1 ; - - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - hg_resist_new_ptr[2] = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1 + fac1* hg_rate_2 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2* hg_rate_2 ; - - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } else { - for(int i = 0; i < 4; ++i) { - const Scalar hg_rate_0 = ddot8_stride1_stride3(hgop_ptr, vel_ptr); - const Scalar hg_rate_1 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+1); - const Scalar hg_rate_2 = ddot8_stride1_stride3(hgop_ptr, vel_ptr+2); - - const Scalar hg_resist_old_0 = hg_resist_old_ptr[0]; - const Scalar hg_resist_old_1 = hg_resist_old_ptr[1]; - const Scalar hg_resist_old_2 = hg_resist_old_ptr[2]; - - const Scalar rot_hg_resist_old_0 = hg_resist_old_0 + dwxy*hg_resist_old_1 - dwzx*hg_resist_old_2; - const Scalar rot_hg_resist_old_1 = hg_resist_old_1 - dwxy*hg_resist_old_0 + dwyz*hg_resist_old_2; - const Scalar rot_hg_resist_old_2 = hg_resist_old_2 + dwzx*hg_resist_old_0 - dwyz*hg_resist_old_1; - - Scalar fnorm = rot_hg_resist_old_0 *rot_hg_resist_old_0 + rot_hg_resist_old_1 *rot_hg_resist_old_1 + rot_hg_resist_old_2 *rot_hg_resist_old_2 ; - const Scalar tolerance = 1.0e-30; - if (fnorm > tolerance ){ - fnorm = sqrt ( (hg_resist_old_0*hg_resist_old_0 + - hg_resist_old_1*hg_resist_old_1 + - hg_resist_old_2*hg_resist_old_2) / fnorm ); - hg_resist_new_ptr[0] = fnorm*rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = fnorm*rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = fnorm*rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } else { - hg_resist_new_ptr[0] = rot_hg_resist_old_0 + fac1*hg_rate_0 ; - hg_resist_new_ptr[1] = rot_hg_resist_old_1 + fac1*hg_rate_1 ; - hg_resist_new_ptr[2] = rot_hg_resist_old_2 + fac1*hg_rate_2 ; - } - hg_resist_total_ptr[0] = hg_resist_new_ptr[0] + fac2*hg_rate_0 ; - hg_resist_total_ptr[1] = hg_resist_new_ptr[1] + fac2*hg_rate_1 ; - hg_resist_total_ptr[2] = hg_resist_new_ptr[2] + fac2*hg_rate_2 ; - hgop_ptr += 8; - hg_resist_new_ptr+= 3; - hg_resist_old_ptr+=3; - hg_resist_total_ptr += 3; - } - } - - *hg_energy_ptr = 0.0; - *int_energy_ptr = 0.0; - for(int i = 0; i < 8; ++i) { - const Scalar hg_force_0 = - (hg_resist_total[HG_X1] * hgop_ptr0[i] + - hg_resist_total[HG_X2] * hgop_ptr1[i] + - hg_resist_total[HG_X3] * hgop_ptr2[i] + - hg_resist_total[HG_X4] * hgop_ptr3[i]); - - force_new_ptr[0] = - total_stress12th[K_S_XX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_XY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_XZ] * gradop12x_ptr_z[i] + hg_force_0 ; - - const Scalar hg_force_1 = - (hg_resist_total[HG_Y1] * hgop_ptr0[i] + - hg_resist_total[HG_Y2] * hgop_ptr1[i] + - hg_resist_total[HG_Y3] * hgop_ptr2[i] + - hg_resist_total[HG_Y4] * hgop_ptr3[i]); - - force_new_ptr[1] = - total_stress12th[K_S_YX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_YY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_YZ] * gradop12x_ptr_z[i] + hg_force_1 ; - - const Scalar hg_force_2 = - (hg_resist_total[HG_Z1] * hgop_ptr0[i] + - hg_resist_total[HG_Z2] * hgop_ptr1[i] + - hg_resist_total[HG_Z3] * hgop_ptr2[i] + - hg_resist_total[HG_Z4] * hgop_ptr3[i]); - - force_new_ptr[2] = - total_stress12th[K_S_ZX] * gradop12x_ptr_x[i] + - total_stress12th[K_S_ZY] * gradop12x_ptr_y[i] + - total_stress12th[K_S_ZZ] * gradop12x_ptr_z[i] + hg_force_2 ; - - *hg_energy_ptr += hg_force_0 *vel_ptr[0] + hg_force_1 *vel_ptr[1] + hg_force_2 *vel_ptr[2]; - *int_energy_ptr += force_new_ptr[0]*vel_ptr[0] + force_new_ptr[1]*vel_ptr[1] + force_new_ptr[2]*vel_ptr[2]; - - - force_new_ptr += 3; - vel_ptr += 3; - } - ++hg_energy_ptr ; - ++int_energy_ptr ; - } - - /** - * ********************************************************************************************** - * - * Purpose: Perform all element calculations required for the material stress calculations. - * - * Input: - * Int nelem Number of elements in workset - * Scalar dt_scale Should be -0.5*delta_t, describes how to move the coordinates - * from the end of step to the mid-step using the velocities. - * Scalar *cordel Array of element nodal coordinates - * Scalar *vel Array of element nodal velocities - * Scalar *rotation_old Array of old roation tensors - * - * Output: - * Scalar *mid_volume Compute element volume from the mid step coordinates - * Scalar *vorticity Asymmetric portion of the element stretch tensor - * Scalar *rotation_new Updated material rotation tensors - * Scalar *stretch New element stretch - * Real *rotated_stretching Rotated element stretching tensor - * - * ********************************************************************************************** - */ - template - inline Int elem_ug3dh8_mi_compute_stretch(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation_old, - Scalar *const mid_vol, - Scalar *const vorticity, - Scalar *const rotation_new, - Scalar *const stretch, - Scalar *const rotated_stretching, - Scalar *const mid_hgop) { - - // - // Extract pointers to the input variables, set up any required temporary variables. The temporaries will - // be reused by every element in the workset. - // - const Scalar * cordel_ptr (cordel ); - const Scalar * vel_ptr (vel ); - Scalar * mid_vol_ptr (mid_vol ); - Scalar * vorticity_ptr(vorticity); - const Scalar * rotation_old_ptr(rotation_old); - Scalar * rotation_new_ptr(rotation_new); - Scalar * stretch_ptr(stretch); - Scalar * rotated_stretching_ptr(rotated_stretching); - Scalar * mid_hgop_ptr(mid_hgop); - // - // Storage for the midstep gradient operator, 12x denotes that this will actually be the midstep gradient - // operator components. - // - Scalar mid_gradop12x[24]; - Scalar *const mid_gradop12x_ptr_x(mid_gradop12x); - Scalar *const mid_gradop12x_ptr_y(mid_gradop12x+8); - Scalar *const mid_gradop12x_ptr_z(mid_gradop12x+16); - // - // Midstep coordinates - // - Scalar mid_coords[24]; - Scalar *const x_ptr(mid_coords); - Scalar *const y_ptr(mid_coords+8); - Scalar *const z_ptr(mid_coords+16); - // - // Element stretching tensor - // - Scalar stretching_tensor[6]; - // - // Element velocity gradient - // - Scalar vel_grad[9]; - // - // Loop over all elements in the workset - // - Scalar dt_scale = -0.5 * dt; - - Int return_value = 0; - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Get current element coordinates and update them so that they reference the midstep - // configuration. Note, this routine changes the coordinate ordering from - // - // (x1, y1, z1, x2, y2, z2, ........) - // - // to - // - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3 ......) - // - // The array reordering allows better variable access later for optimization purposes - // - for(int i = 0; i < 8; ++i) { - x_ptr[i] = cordel_ptr[0] + dt_scale * vel_ptr[0]; - y_ptr[i] = cordel_ptr[1] + dt_scale * vel_ptr[1]; - z_ptr[i] = cordel_ptr[2] + dt_scale * vel_ptr[2]; - //std::cout << "KHP: x= " << x_ptr[i] << ", " << y_ptr[i] << ", " << z_ptr[i] << "\n"; - //std::cout << "KHP: C= " << cordel_ptr[0] << ", " << cordel_ptr[1] << ", " << cordel_ptr[2] << "\n"; - //std::cout << "KHP: V= " << vel_ptr[0] << ", " << vel_ptr[1] << ", " << vel_ptr[2] << "\n"; - cordel_ptr += 3; - vel_ptr += 3; - } - - vel_ptr -= 24; - // - // Do grad op in three seperate steps using the helper routine. - // NKC, I'm not positive what the helper is mathematically equivalent too, - // however, the combination of these three steps will compute the full gradient. - // Note, the comp12x routine actually calculates 12.0 times the gradient, this - // 12 will be factored out later. - // - comp_grad12x(mid_gradop12x, x_ptr, y_ptr, z_ptr); - - // - // Compute the midstep volume. Note that 12 times the volume is being calculated, - // The actually output value of volume is then multipled by one twelth - // - const Scalar volume12x = ddot8(x_ptr, mid_gradop12x_ptr_x); - static const Scalar ONE12TH = (1.0/12.0); - *mid_vol_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - const Scalar zero(0.0); - if(volume12x > zero) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the velocity gradients from the dot products of the input velocities with the - // relevant columns of the gradient operator. Note that the velocity gradient is calculated - // as Velocity * 12 * mid_gradop * volinv/12, the twelves cancel. - // - // 81 multiplications (9 tensor entries * (8 mults per dot + 1 mult for volinv)) - // - vel_grad[K_F_XX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr ) * volinv12th; - vel_grad[K_F_XY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr ) * volinv12th; - vel_grad[K_F_XZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr ) * volinv12th; - vel_grad[K_F_YZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+1) * volinv12th; - vel_grad[K_F_YY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+1) * volinv12th; - vel_grad[K_F_YX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+1) * volinv12th; - vel_grad[K_F_ZX] = ddot8_stride1_stride3(mid_gradop12x_ptr_x, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZZ] = ddot8_stride1_stride3(mid_gradop12x_ptr_z, vel_ptr+2) * volinv12th; - vel_grad[K_F_ZY] = ddot8_stride1_stride3(mid_gradop12x_ptr_y, vel_ptr+2) * volinv12th; - // - // Compute the stretching tensors from the current velocity gradient - // - // Let G = Gradient (velocity gradient in this case). - // Let S = Stretch - // Let V = Vorticity - // - // Then: - // - // S = 0.5 * ( G + G'); // S = 0.5 * ( G + transpose(G)); - // V = 0.5 * ( G - G'); // V = 0.5 * ( G - transpose(G)); - // - APS::Hex::additive_decomp36(vel_grad, stretching_tensor, vorticity_ptr); - - polar_decomp33r2(dt, stretching_tensor, vorticity_ptr, rotation_old_ptr, stretch_ptr, rotation_new_ptr); - - rotate_tensor_forward(rotation_new_ptr, stretching_tensor, rotated_stretching_ptr); - - // - // Compute the midstep hourglass operator if needed. Here one 12th the volume is - // multiplied by 12 times the gradient operators, so the true hourglass operator - // is computed. - // - if (mid_hgop_ptr) { - comp_hgop(x_ptr, y_ptr, z_ptr, - mid_gradop12x_ptr_x, - mid_gradop12x_ptr_y, - mid_gradop12x_ptr_z, - volinv12th, mid_hgop_ptr); - mid_hgop_ptr += 32; - } - - } else { - return_value = -1; - } - ++mid_vol_ptr ; - vel_ptr += 24; - vorticity_ptr +=3; - rotation_old_ptr += 9; - stretch_ptr += 6; - rotation_new_ptr += 9; - rotated_stretching_ptr += 6; - } - return return_value; - } - - //*********************************************************************n - // - // STANDARD PRESTO VERSION - // - // description: - // This routine is implemented for the 8 node brick, uniform strain - // element. It is the divergence operator, hourglass force operator, - // and time step calcuator. Combination of multiple routines yields - // better cache usage. - // - // Input: - // nelem Number of elements in the workset - // - // dt Previous time step - // - // cordel(24,nelem) End of step element coordinates, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // vel(24,nelem) Element nodal velocity, orgainzied by (x1, y1, z1, x2, y2, z2, ......) - // - // rotated_stress(6,nelem) Element stress in the rotated configuration - // - // rotated_stretching(6,nelem) Element stretch rate tensor in rotated configuration - // - // spin_rate(3,nelem) Asymmetric portion of stretching rate, represents amount element is spinning - // about each axis. - // - // linBulkVisc Linear bulk viscosity material constant - // - // quadBulkVisc Quadradic bulk viscosity material constant - // - // elem_mass(nelem) Current element masses - // - // elem_dilmod(nelem) Current material dilitational modulus - // - // elem_shrmod(nelem) Current material shear modulus - // - // hg_stiffness Hourglass stiffness parameter - // - // hg_viscosity Hourglass viscosity parameter - // - // hg_resist_old(12,nelem) Old hourglass resistance - // - // Output: - // min_elem_time_step The computed mimimum stable element time step - // - // volume(nelem) The element end of step volume - // - // elem_time_step(nelem) Time steps on a per element basis - // - // hg_resist_new(12,nelem) New hourglass resistance - // - // force_new(24,nelem) New element total internal force - // - // hg_energy(nelem) New element total hourglass energy increment - // - // int_energy(ielem) New element internal energy increment - // - // Returns, 0 if no errors, -1 if any negative volume elements were found - // - //*********************************************************************** - - template - inline - Int elem_ug3dh8_mi_compute_divergence_presto(const Int nelem, - const Scalar dt, - const Scalar *const cordel, - const Scalar *const vel, - const Scalar *const rotation, - const Scalar *const stress_new, - const Scalar *const rotated_stretching, - const Scalar *const spin_rate, - const Scalar linBulkVisc, - const Scalar quadBulkVisc, - const Scalar *const elem_mass, - const Scalar *const elem_dilmod, - const Scalar *const elem_shrmod, - const Scalar hg_stiffness, - const Scalar hg_viscosity, - Scalar *const rotated_stress, - Scalar &min_elem_time_step, - Scalar *const volume, - Scalar *const elem_time_step, - Scalar *const hg_resist_old, - Scalar *const hg_resist_new, - Scalar *const force_new, - Scalar *const hg_energy, - Scalar *const int_energy, - Scalar *const mid_hgop, - const bool scaleHGRotation) { - Int return_value = 0; - // - // Store pointers to the input variables - // - const Scalar * cordel_ptr(cordel); - const Scalar * vel_ptr(vel); - const Scalar * elem_mass_ptr(elem_mass); - const Scalar * elem_dilmod_ptr(elem_dilmod); - const Scalar * elem_shrmod_ptr(elem_shrmod); - const Scalar * rotated_stretching_ptr(rotated_stretching); - const Scalar * spin_rate_ptr(spin_rate); - const Scalar * stress_new_ptr(stress_new); - const Scalar * rotation_ptr(rotation); - - Scalar * rotated_stress_ptr(rotated_stress); - Scalar * volume_ptr(volume); - Scalar * elem_time_step_ptr(elem_time_step); - Scalar * hg_resist_old_ptr(hg_resist_old); - Scalar * hg_resist_new_ptr(hg_resist_new); - Scalar * force_new_ptr(force_new); - Scalar * hg_energy_ptr(hg_energy); - Scalar * int_energy_ptr(int_energy); - // - // Create temporaries to be reused by every element - // - Scalar gradop12x[24]; - Scalar * gradop12x_ptr_x(gradop12x); - Scalar * gradop12x_ptr_y(gradop12x+8); - Scalar * gradop12x_ptr_z(gradop12x+16); - - Scalar cur_coords[24]; - const Scalar *const x_ptr(cur_coords); - const Scalar *const y_ptr(cur_coords+8); - const Scalar *const z_ptr(cur_coords+16); - - Scalar total_stress12th[6]; - - Scalar hgop[32]; - const Scalar *const hgop_ptr0(hgop); - const Scalar *const hgop_ptr1(hgop+8); - const Scalar *const hgop_ptr2(hgop+16); - const Scalar *const hgop_ptr3(hgop+24); - Scalar * hgop_for_resist_calc(mid_hgop); - if (mid_hgop == NULL){ - hgop_for_resist_calc = hgop; - } - // - // This factor will be used in hourglass computations, however is a loop constant - // - const Scalar fac1_pre(dt * hg_stiffness * 0.0625); - - for(Int ielem(0); ielem < nelem; ++ielem) { - // - // Store local coordintes, note this changes the way coordinates are stored from - // - // (x1, y1, z1, x2, y2, z2 .......) - // to - // (x1, x2, x3, x4, x5, x6, x7, x8, y1, y2, y3, .....) - // - transform_38_matrix_to_83_matrix(cordel_ptr, cur_coords); - // - // Compute 12 times the gradient operator in three seperate steps - // - comp_grad12x(gradop12x, x_ptr, y_ptr, z_ptr); - // - // calculate 12 times the element volume, store the actual element volume - // - const Scalar volume12x = ddot8(x_ptr, gradop12x); - static const Scalar ONE12TH = 1.0/12.0; - *volume_ptr = volume12x * ONE12TH; - // - // if volume is <= 0.0, report an error, otherwise continue the calculation - // - const Scalar zero(0.0); - if(volume12x > zero) { - const Scalar volinv12th(1.0/volume12x); - // - // Compute the aspect ratio. Aspect ratio is 0.5 * volume / (grad . grad) - // With the 12 factors this is actually 6.0 * 12 * volume / (12 * grad . 12 * grad) - // - const Scalar aspect = comp_aspect(gradop12x, volume12x); - const Scalar aspect_inv = 1.0/aspect; - // - // Compute the stable time step and bulk viscosity - // - const Scalar dtrial(sqrt(elem_mass_ptr[0] * aspect / elem_dilmod_ptr[0])); - - const Scalar traced(rotated_stretching_ptr[0] + rotated_stretching_ptr[1] + rotated_stretching_ptr[2]); - - const Scalar eps(linBulkVisc - quadBulkVisc * std::min(zero, traced)*dtrial); - - const Scalar bulkq = eps * elem_dilmod_ptr[0] *dtrial *traced; - - const Scalar one(1.0); - const Scalar cur_time_step = dtrial * ( sqrt( one + eps * eps) - eps); - *elem_time_step_ptr = cur_time_step; - min_elem_time_step = std::min(min_elem_time_step, cur_time_step); - // - // Rotate the stress - // - rotate_tensor_backward(rotation_ptr, stress_new_ptr, rotated_stress_ptr); - // - // Compute the total stress (includes bulk viscosity terms) - // - total_stress12th[0] = ONE12TH*(rotated_stress_ptr[0] + bulkq); - total_stress12th[1] = ONE12TH*(rotated_stress_ptr[1] + bulkq); - total_stress12th[2] = ONE12TH*(rotated_stress_ptr[2] + bulkq); - total_stress12th[3] = ONE12TH*(rotated_stress_ptr[3]); - total_stress12th[4] = ONE12TH*(rotated_stress_ptr[4]); - total_stress12th[5] = ONE12TH*(rotated_stress_ptr[5]); - // - // Compute the hourglass operator. Here one 12th the volume is multiplied by - // 12 times the gradient operators, so the true hourglass operator is computed. - // - comp_hgop(x_ptr, y_ptr, z_ptr, - gradop12x_ptr_x, - gradop12x_ptr_y, - gradop12x_ptr_z, - volinv12th, hgop); - // - // Compute the hourglass resistance terms. These are based on the hourglass stiffness and hourglass viscosities - // - const Scalar fac1 = fac1_pre * elem_shrmod_ptr[0] * aspect_inv; - const Scalar fac2 = hg_viscosity * sqrt(elem_shrmod_ptr[0] * elem_mass_ptr[0] * aspect_inv); - comp_force(dt, - spin_rate_ptr, - hgop_for_resist_calc, - hgop_ptr0, hgop_ptr1, hgop_ptr2, hgop_ptr3, - vel_ptr, fac1, fac2, hg_resist_old_ptr, hg_resist_new_ptr, - total_stress12th, - gradop12x_ptr_x, gradop12x_ptr_y, gradop12x_ptr_z, - hg_energy_ptr, int_energy_ptr, force_new_ptr, scaleHGRotation); - } else { - return_value = -1; - } - - cordel_ptr += 24; - vel_ptr += 24; - ++volume_ptr ; - ++elem_mass_ptr ; - ++elem_dilmod_ptr ; - ++elem_shrmod_ptr ; - ++elem_time_step_ptr ; - rotation_ptr += 9; - stress_new_ptr += 6; - rotated_stress_ptr += 6; - rotated_stretching_ptr += 6; - spin_rate_ptr += 3; - hg_resist_old_ptr += 12; - hg_resist_new_ptr += 12; - ++hg_energy_ptr ; - ++int_energy_ptr ; - force_new_ptr += 24; - if (mid_hgop){ - hgop_for_resist_calc += 32; - } - } - return return_value; - } - - } // end namespace Hex -} // end namespace APS - -template -class Hex8ug { - public: - Hex8ug() - {} - - ~Hex8ug() - {} - - int num_nodes() const { return 8; } - - int compute_stretch( const int num_elements, - const T dt, - const T *coordinates, - const T *velocity, - const T *rotation_old, - T *volume, - T *vorticity_tensor, - T *rotation_new, - T *stretch, - T *strain_rate, - T *mid_hgop, - bool debug = false - ) const { - int err = APS::Hex::elem_ug3dh8_mi_compute_stretch(num_elements, - dt, - coordinates, - velocity, - rotation_old, - volume, - vorticity_tensor, - rotation_new, - stretch, - strain_rate, - mid_hgop); - - return err; - } - - int internalForce( const int num_elements, - const T dt, - T current_stable_time_step, - T* const element_time_step, - lame::Material &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - T *const coordinates, - T *const velocity, - T *const rotation_old, T* const rotation_new, - T *const midstep_volume, - T *const vorticity_tensor, - T *const stretch, - T *const strain_rate, - T *const mid_hgop, - T *const stress_old, T *const stress_new, - T *const rotated_stress, - T *const material_eff_bulk_mod, - T *const material_eff_twomu, - T *const shrmod, - T *const dilmod, - T *const element_mass, - T *const force_new, - T *const hourglass_energy, - T *const internal_energy, - T *const hg_resistance_old, T* const hg_resistance_new - ) const { - - compute_stretch(num_elements, dt, coordinates, velocity, rotation_old, midstep_volume, vorticity_tensor, rotation_new, stretch, strain_rate, mid_hgop); - - Int err = material_model.getStress(&materialParameters); - ThrowErrorMsgIf( err, "getStress failed" ); - - const T one_third = 1.0 / 3.0 ; - T dilatationalHGParam = 0.05; - T deviatoricHGParam = 0.0; - - for(int k=0; k &material_model, - lame::matParams &materialParameters, - lame::MatProps &materialProperties, - T *const coordinates, - T *const velocity, - T *const rotation_old, T* const rotation_new, - T *const midstep_volume, - T *const vorticity_tensor, - T *const stretch, - T *const strain_rate, - T *const mid_hgop, - T *const stress_old, T *const stress_new, - T *const rotated_stress, - T *const material_eff_bulk_mod, - T *const material_eff_twomu, - T *const shrmod, - T *const dilmod, - T *const element_mass, - T *const force_new, - T *const hourglass_energy, - T *const internal_energy, - T *const hg_resistance_old, T* const hg_resistance_new, - T *const jacobian - ) const { - - // INDEPENDENT VARIABLES - FAD_Type velocity_fad[24]; - for(int i=0; i<24; ++i) { - // 24 = number of derivatives. - // i -> indicates the ith independent variable (i.e. perturbation) - // actual value. - // - // Uncomment this line after I get Sacado to link in. - //velocity_fad[i] = FAD_Type(24, i, velocity[i]); - velocity_fad[i] = FAD_Type(velocity[i]); - } - - // DEPENDENT VARIABLES: Just copy in values, do not initialize derivatives. - FAD_Type coordinates_fad[24]; - for(int i=0; i<24; ++i) { - // copy actual value. - coordinates_fad[i] = FAD_Type(coordinates[i]); - } - - // DEPENDENT VARIABLES: Just copy in values, do not initialize derivatives. - FAD_Type rotation_old_fad[9]; - for(int i=0; i<9; ++i) { - // copy actual value. - rotation_old_fad[i] = FAD_Type(rotation_old[i]); - } - - FAD_Type dt_fad = dt; - FAD_Type current_stable_time_step_fad = current_stable_time_step; - - FAD_Type midstep_volume_fad[1]; - for(int i=0; i<1; ++i) { - // copy actual value. - midstep_volume_fad[i] = FAD_Type(midstep_volume[i]); - } - - FAD_Type vorticity_tensor_fad[6]; - for(int i=0; i<6; ++i) { - // copy actual value. - vorticity_tensor_fad[i] = FAD_Type(vorticity_tensor[i]); - } - - FAD_Type rotation_new_fad[6]; - for(int i=0; i<6; ++i) { - // copy actual value. - rotation_new_fad[i] = FAD_Type(rotation_new[i]); - } - - FAD_Type stretch_fad[6]; - for(int i=0; i<6; ++i) { - // copy actual value. - stretch_fad[i] = FAD_Type(stretch[i]); - } - - FAD_Type stress_new_fad[6]; - for(int i=0; i<6; ++i) { - // copy actual value. - stress_new_fad[i] = FAD_Type(stress_new[i]); - } - - FAD_Type strain_rate_fad[6]; - for(int i=0; i<6; ++i) { - // copy actual value. - strain_rate_fad[i] = FAD_Type(strain_rate[i]); - } - - // FIX this size later. - FAD_Type mid_hgop_fad[32]; - for(int i=0; i<32; ++i) { - // copy actual value. - mid_hgop_fad[i] = FAD_Type(mid_hgop[i]); - } - - FAD_Type force_new_fad[24]; - for(int i=0; i<24; ++i) { - // copy actual value. - force_new_fad[i] = FAD_Type(force_new[i]); - } - - std::vector element_mass_fad(num_elements); - for(int i=0; i shrmod_fad(num_elements); - std::vector dilmod_fad(num_elements); - for(int k=0; k - -namespace { - -//---------------------------------------------------------------------- -// An example of a trivial element-block algorithm -// that just works on element field data -// written with a "generic programming" flavor. - -template< class ElementTraits > -void centroid( unsigned number_elements , - double * elem_centroid , - double ** elem_node_coordinates ) -{ - enum { vertices_per_element = ElementTraits::vertex_count }; - enum { nodes_per_element = ElementTraits::node_count }; - - for ( unsigned j = 0 ; j < number_elements ; ++j ) { - - // Array is 'double * elem_node[ nodes_per_element * number_elements ] - // so get the node coordinate pointer for this element. - - double ** node_coordinates = elem_node_coordinates + j * nodes_per_element ; - - double tmp[3] = { 0 , 0 , 0 }; - - for ( unsigned i = 0 ; i < vertices_per_element ; ++i ) { - // Pointer to this node's coordinates, - // accessing this field data in-place - // as opposed to copying (a.k.a. gathering) - // it into a local temporary array. - - double * coord = node_coordinates[i] ; - - // Sum for the mean. - tmp[0] += coord[0] ; - tmp[1] += coord[1] ; - tmp[2] += coord[2] ; - } - - tmp[0] /= vertices_per_element ; - tmp[1] /= vertices_per_element ; - tmp[2] /= vertices_per_element ; - - // The centroid field data for this element. - - double * centroid = elem_centroid + j * 3 ; - - centroid[0] = tmp[0] ; - centroid[1] = tmp[1] ; - centroid[2] = tmp[2] ; - } -} - -//---------------------------------------------------------------------- -// An example of a trivial element-loop algorithm -// written with a "generic programming" flavor. -// -// Loop over all elements in the given 'elem_part'. -// Access the element-node coordinates. - -template< class ElementTraits > -void centroid_algorithm( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & elem_centroid , - const ElementNodePointerFieldType & elem_node_coord , - stk_classic::mesh::Part & elem_part ) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - - // The 'stk_mesh' implementation uses the - // "homogeneous subset" concept (see the Domain Model document) - // for field data storage. A "homogeneous subset" is called - // a 'Bucket'. - - // Iterate the set of element buckets: - - const std::vector & buckets = mesh.buckets(element_rank); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - stk_classic::mesh::Bucket & bucket = **k ; - - // If this bucket is a subset of the given elem_part - // then want to compute on it. - - if ( has_superset( bucket , elem_part ) ) { - - // Number of elements in the bucket: - - const unsigned size = bucket.size(); - - // Aggressive "gather" field data for the elements - // in the bucket. - // double * node_ptr[ nodes_per_element * number_of_elements ] - - double ** node_ptr = stk_classic::mesh::field_data( elem_node_coord , bucket.begin() ); - - // Element centroid field data - // double elem_ptr[ 3 * number_of_elements ] - - double * elem_ptr = stk_classic::mesh::field_data( elem_centroid , bucket.begin() ); - - // Call an element function to calculate centroid for - // contiguous arrays of element field data. - - centroid< ElementTraits >( size , elem_ptr , node_ptr ); - } - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template< class ElementTraits > -void centroid_algorithm_unit_test_dimensions( - stk_classic::mesh::BulkData & mesh , - const VectorFieldType & elem_centroid , - const ElementNodePointerFieldType & elem_node_coord , - stk_classic::mesh::Part & elem_part ) -{ - stk_classic::mesh::fem::FEMMetaData &fem = stk_classic::mesh::fem::FEMMetaData::get(mesh); - const stk_classic::mesh::EntityRank element_rank = fem.element_rank(); - - // Use the "homogeneous subset" concept (see the Domain Model document) - // for field data storage. A "homogeneous subset" is called - // a 'Bucket'. - - // Iterate the set of element buckets: - - const std::vector & buckets = mesh.buckets(element_rank); - - for ( std::vector::const_iterator - k = buckets.begin() ; k != buckets.end() ; ++k ) { - - stk_classic::mesh::Bucket & bucket = **k ; - - // If this bucket is a subset of the given elem_part - // then want to compute on it. - - if ( has_superset( bucket , elem_part ) ) { - - // Number of elements in the bucket: - - const size_t size = bucket.size(); - - // Unit testing the dimension feature - { - stk_classic::mesh::BucketArray< ElementNodePointerFieldType > array( elem_node_coord, bucket); - const size_t n1 = array.template dimension<0>(); - const size_t n2 = array.template dimension<1>(); - } - - { - stk_classic::mesh::BucketArray< VectorFieldType > array( elem_centroid , bucket ); - const size_t n1 = array.template dimension<0>(); - const size_t n2 = array.template dimension<1>(); - } - - } - } -} - -} - -#endif - diff --git a/packages/stk/stk_classic/stk_usecases/search/SearchUseCaseMain.cpp b/packages/stk/stk_classic/stk_usecases/search/SearchUseCaseMain.cpp deleted file mode 100644 index f3aef56fdc8a..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/SearchUseCaseMain.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -void use_case_1_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); -void use_case_4_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - - std::string working_directory = ""; - std::string range_mesh = ""; - std::string range_filetype = "exodusii"; - std::string range_entity = ""; - std::string domain_mesh = ""; - std::string domain_filetype = "exodusii"; - std::string domain_entity = ""; - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("Search use case options"); - - // NOTE: Options --directory --output-log --runtest are handled/defined in UseCaseEnvironment - desc.add_options() - ("range_mesh", bopt::value(&range_mesh), - "range mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("domain_mesh", bopt::value(&domain_mesh), - "domain mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("range_entity", bopt::value(&range_entity)->default_value("element"), - "node, edge, face, element") - ("domain_entity", bopt::value(&domain_entity)->default_value("element"), - "node, edge, face, element") - ("use_case_1", "search use case 1" ) - ("use_case_4", "search use case 4" ); - - stk_classic::get_options_description().add(desc); - - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - bopt::variables_map &vm = stk_classic::get_variables_map(); - - //---------------------------------- - - if (range_mesh.empty()) { - std::cerr << "OPTION ERROR: The '--range_mesh ' option is required for the use cases!\n"; - std::cerr << stk_classic::get_options_description() << std::endl; - std::exit(EXIT_FAILURE); - } - - if (domain_mesh.empty()) { - domain_mesh = range_mesh; - domain_filetype = range_filetype; - } - - if (strncasecmp("gen:", range_mesh.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - range_mesh = range_mesh.substr(4, range_mesh.size()); - range_filetype = "generated"; - } - - if (strncasecmp("gears:", range_mesh.c_str(), 5) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - range_mesh = range_mesh.substr(6, range_mesh.size()); - range_filetype = "gears"; - } - - if (strncasecmp("gen:", domain_mesh.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - domain_mesh = domain_mesh.substr(4, domain_mesh.size()); - domain_filetype = "generated"; - } - - if (strncasecmp("gears:", domain_mesh.c_str(), 6) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - domain_mesh = domain_mesh.substr(6, domain_mesh.size()); - domain_filetype = "gears"; - } - - if (!vm.count("use_case_1") && !vm.count("use_case_4")) { - std::cout << "OPTION ERROR: At least one of '--use_case_1' or '--use_case_4' must be specified.\n"; - std::exit(EXIT_FAILURE); - } - - if (vm.count("use_case_1")) { - use_case_1_driver(use_case_environment.m_comm, - working_directory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - - if (vm.count("use_case_4")) { - use_case_4_driver(use_case_environment.m_comm, - working_directory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - - // if we've made it this far, the use case has passed - use_case::print_status(use_case_environment.m_comm, true); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_1.cpp b/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_1.cpp deleted file mode 100644 index 1bc53a92ec5a..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_1.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -// ======================================================================== -// NOTE: The stk_mesh and stk_io dependencies are only here in order to -// build a geometry that the search product can search. -// ======================================================================== - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -using namespace stk_classic::diag; -using namespace stk_classic::search; -using namespace use_case; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -static const size_t spatial_dimension = 3; - -void -use_case_1_driver( - stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh_filename, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh_filename, - const std::string &domain_mesh_type, - const std::string &domain_entity) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - dw().m(LOG_SEARCH) << "Use case 1: Point (range) in Box (domain) Search" << stk_classic::diag::push << stk_classic::diag::dendl; - dw().m(LOG_SEARCH) << "Range Entity Type = " << range_entity << stk_classic::diag::dendl; - dw().m(LOG_SEARCH) << "Domain Entity Type = " << domain_entity << stk_classic::diag::dendl; - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - stk_classic::mesh::fem::FEMMetaData range_meta_data( spatial_dimension ); - stk_classic::io::MeshData range_mesh_data; - std::string filename = working_directory + range_mesh_filename; - stk_classic::io::create_input_mesh(range_mesh_type, filename, comm, - range_meta_data, range_mesh_data); - range_meta_data.commit(); - - stk_classic::mesh::BulkData range_bulk_data(range_meta_data.get_meta_data(range_meta_data) , comm); - stk_classic::io::populate_bulk_data(range_bulk_data, range_mesh_data); - - stk_classic::mesh::fem::FEMMetaData domain_meta_data( spatial_dimension ); - stk_classic::io::MeshData domain_mesh_data; - filename = working_directory + domain_mesh_filename; - stk_classic::io::create_input_mesh(domain_mesh_type, domain_mesh_filename, comm, - domain_meta_data, domain_mesh_data); - domain_meta_data.commit(); - - stk_classic::mesh::BulkData domain_bulk_data(domain_meta_data.get_meta_data(domain_meta_data) , comm); - stk_classic::io::populate_bulk_data(domain_bulk_data, domain_mesh_data); - - // For this use case, the domain consists of an axis-aligned - // bounding box for each 'domain_entity' in the mesh. The range is a - // PointBoundingBox3D at the centroid of each 'range_entity'. The id of the point - // will be the same as the id of the containing entity. If the - // mesh contains solid elements only, and the range_mesh matches the - // domain_mesh, then the search should return a single box for each - // point and the id of the box should match the id of the point. - - VectorField *range_coord_field = range_meta_data.get_field("coordinates"); - std::vector range_vector; - stk_classic::search_util::build_centroid_bbox(range_bulk_data, - range_meta_data.entity_rank(range_entity), - range_coord_field, range_vector); - - VectorField *domain_coord_field = domain_meta_data.get_field("coordinates"); - std::vector domain_vector; - stk_classic::search_util::build_axis_aligned_bbox(domain_bulk_data, - domain_meta_data.entity_rank(domain_entity), - domain_coord_field, domain_vector); - - // ======================================================================== - // NOTE: There should be no stk_classic::mesh dependencies below this point... - // ======================================================================== - if (range_vector.size() <= 100){ - dw().m(LOG_SEARCH) << "range " << range_vector << dendl; - } - else - dw().m(LOG_SEARCH) << "range vector size = " << range_vector.size() << dendl; - - if (domain_vector.size() <= 100) - dw().m(LOG_SEARCH) << "domain " << domain_vector << dendl; - else - dw().m(LOG_SEARCH) << "domain vector size = " << domain_vector.size() << dendl; - - FactoryOrder order; - order.m_communicator = comm; - //order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE; - - dw() << "Search algorithm " << order.m_algorithm << dendl; - // dw().m(LOG_SEARCH) << "Search tree " << *range_search << dendl; - - IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - - if (relation.size() <= 100) - dw().m(LOG_SEARCH) << "relation " << relation << dendl; - else - dw().m(LOG_SEARCH) << "relation size = " << relation.size() << dendl; - - dw().m(LOG_SEARCH) << stk_classic::diag::pop; -} - diff --git a/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_4.cpp b/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_4.cpp deleted file mode 100644 index 3d407b6de183..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/SearchUseCase_4.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -using namespace stk_classic::search; -using namespace use_case; - -using namespace stk_classic::diag; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -static const size_t spatial_dimension = 3; - -void -use_case_4_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh_filename, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh_filename, - const std::string &domain_mesh_type, - const std::string &domain_entity) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - dw().m(LOG_SEARCH) << "Use case 4" << stk_classic::diag::push << stk_classic::diag::dendl; - - // ======================================================================== - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - // Define range mesh... - stk_classic::mesh::fem::FEMMetaData range_meta_data( spatial_dimension ); - stk_classic::io::MeshData range_mesh_data; - std::string filename = working_directory + range_mesh_filename; - stk_classic::io::create_input_mesh(range_mesh_type, filename, comm, - range_meta_data, range_mesh_data); - range_meta_data.commit(); - - stk_classic::mesh::BulkData range_bulk_data(range_meta_data.get_meta_data(range_meta_data) , comm); - stk_classic::io::populate_bulk_data(range_bulk_data, range_mesh_data); - - - // Define domain mesh... - stk_classic::mesh::fem::FEMMetaData domain_meta_data( spatial_dimension ); - stk_classic::io::MeshData domain_mesh_data; - filename = working_directory + domain_mesh_filename; - stk_classic::io::create_input_mesh(domain_mesh_type, domain_mesh_filename, comm, - domain_meta_data, domain_mesh_data); - domain_meta_data.commit(); - - stk_classic::mesh::BulkData domain_bulk_data(domain_meta_data.get_meta_data(domain_meta_data) , comm); - stk_classic::io::populate_bulk_data(domain_bulk_data, domain_mesh_data); - - // ======================================================================== - // For this use case, the domain consists of an axis-aligned - // bounding box for each 'domain_entity' in the mesh. The range is also an - // axis-aligned bounding box of each 'range_entity'. - - VectorField *range_coord_field = range_meta_data.get_field("coordinates"); - std::vector range_vector; - stk_classic::search_util::build_axis_aligned_bbox(range_bulk_data, - range_meta_data.entity_rank(range_entity), - range_coord_field, range_vector); - - VectorField *domain_coord_field = domain_meta_data.get_field("coordinates"); - std::vector domain_vector; - stk_classic::search_util::build_axis_aligned_bbox(domain_bulk_data, - domain_meta_data.entity_rank(domain_entity), - domain_coord_field, domain_vector); - - if (range_vector.size() <= 100) - dw().m(LOG_SEARCH) << "range " << range_vector << dendl; - else - dw().m(LOG_SEARCH) << "range vector size = " << range_vector.size() << dendl; - - if (domain_vector.size() <= 100) - dw().m(LOG_SEARCH) << "domain " << domain_vector << dendl; - else - dw().m(LOG_SEARCH) << "domain vector size = " << domain_vector.size() << dendl; - - FactoryOrder order; - order.m_communicator = comm; - //order.m_algorithm = FactoryOrder::BIHTREE; - - dw() << "Search algorithm " << order.m_algorithm << dendl; -// dw().m(LOG_SEARCH) << "Search tree " << *range_search << dendl; - - IdentProcRelation relation; - - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - - if (relation.size() <= 100) - dw().m(LOG_SEARCH) << "relation " << relation << dendl; - else - dw().m(LOG_SEARCH) << "relation size = " << relation.size() << dendl; - - dw().m(LOG_SEARCH) << stk_classic::diag::pop; -} - diff --git a/packages/stk/stk_classic/stk_usecases/search/performance/Performance.hpp b/packages/stk/stk_classic/stk_usecases/search/performance/Performance.hpp deleted file mode 100644 index 2f8b716a4524..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/performance/Performance.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_search_use_cases_Performance_hpp -#define stk_search_use_cases_Performance_hpp - -#include -#include - -namespace stk_classic { -namespace search { -class Options -{ -public: - Options() - : mesh_filename(""), mesh_type("exodusii"), entity(""), - offset(0.0), scale(1.0) {} - std::string mesh_filename; - std::string mesh_type; - std::string entity; - double offset; - double scale; -private: - Options(const Options&); // Do not implement - Options& operator=(const Options&); // Do not implement -}; -} -} - -void performance_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &search_type, - const stk_classic::search::Options &range, - const stk_classic::search::Options &domain, - bool performance); - -#endif diff --git a/packages/stk/stk_classic/stk_usecases/search/performance/PerformanceMain.cpp b/packages/stk/stk_classic/stk_usecases/search/performance/PerformanceMain.cpp deleted file mode 100644 index 58013a77f994..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/performance/PerformanceMain.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - stk_classic::search::Options range; - stk_classic::search::Options domain; - - std::string working_directory = ""; - bool performance = false; - - /** \todo IMPLEMENT -- what should the syntax and options for this look like? */ - std::string search_type = ""; - - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("options"); - - // NOTE: Options --directory --output-log --runtest are handled/defined in UseCaseEnvironment - desc.add_options() - ("directory,d", bopt::value(&working_directory), - "working directory with trailing '/'" ) - ("search_type", bopt::value(&search_type), - "type of search to run. Valid options are:\n" - " point_in_box: \tdomain consists of an axis-aligned bounding box for each 'domain_entity' in the mesh," - "range is a PointBoundingBox3D at the centroid of each'range_entity'\n" - " overlap: \tdomain consists of an axis-aligned bounding box for each 'domain_entity' in the mesh," - "range is also an axis-aligned bounding box of each 'range_entity'.") - ("range_mesh", bopt::value(&range.mesh_filename), - "range mesh file.\n \tUse name of form 'gen:NxMxL' to generate a hex mesh of size N by M by L intervals.\n\tUse --helpmesh for more detailed help on the mesh options.") - ("range_entity", bopt::value(&range.entity)->default_value("element"), - "Entity type to use for range:\n" - " node: \tAll nodes in the model,\n" - " nodeset: \tAll nodes in a nodeset,\n" - " edge: \tAll edges in the model (probably none),\n" - " face: \tSkin the model and use all exposed faces,\n" - " faceset: \tFaces, but only those faces in a faceset,\n" - " element: \tAll elements in the model.") - ("range_offset", - bopt::value(&range.offset)->default_value(0.0), - "offset to be applied to domain axis-aligned bounding boxes. The bounding box extent will be increased by this amount in each direction." ) - ("range_scale", - bopt::value(&range.scale)->default_value(0.0), - "scale factor to be applied to domain axis-aligned bounding boxes. The bounding box extent will be increased by max_d*scale+offset where max_d is max of max_i-min_i for i=x,y,z)" ) - ("domain_mesh", bopt::value(&domain.mesh_filename), - "domain mesh file." - "\n \tUse name of form 'gen:NxMxL' to generate a hex mesh of size N by M by L intervals." - "\n \tUse --helpmesh for more detailed help on the mesh options." ) - ("domain_entity", bopt::value(&domain.entity)->default_value("element"), - "Entity type to use for domain:\n" - " node: \tAll nodes in the model,\n" - " nodeset: \tAll nodes in a nodeset,\n" - " edge: \tAll edges in the model (probably none),\n" - " face: \tSkin the model and use all exposed faces,\n" - " faceset: \tFaces, but only those faces in a faceset,\n" - " element: \tAll elements in the model.") - ("domain_offset", - bopt::value(&domain.offset)->default_value(0.0), - "offset to be applied to domain axis-aligned bounding boxes. The bounding box extent will be increased by this amount in each direction." ) - ("domain_scale", - bopt::value(&domain.scale)->default_value(0.0), - "scale factor to be applied to domain axis-aligned bounding boxes. The bounding box extent will be increased by max_d*scale+offset where max_d is max of max_i-min_i for i=x,y,z)" ) - ("performance", "Run to measure performance; disable output that may affect runtime.") - ("helpmesh", "Print detailed description of mesh options and then exit."); - stk_classic::get_options_description().add(desc); - - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - bopt::variables_map &vm = stk_classic::get_variables_map(); - - //---------------------------------- - - if (vm.count("helpmesh")) { - stk_classic::io::show_mesh_help(); - std::exit(EXIT_SUCCESS); - } - - if (vm.count("performance")) - performance = true; - - if (search_type.empty()) { - std::cerr << "\nOPTION ERROR: A --search_type must be specified.\n\n"; - std::cerr << stk_classic::get_options_description() << "\n"; - std::exit(EXIT_FAILURE); - } - - if (range.mesh_filename.empty()) { - std::cerr << "\nOPTION ERROR: The '--range_mesh ' option is required for the use cases!\n\n"; - std::cerr << stk_classic::get_options_description() << "\n"; - std::exit(EXIT_FAILURE); - } - - if (domain.mesh_filename.empty()) { - domain.mesh_filename = range.mesh_filename; - domain.mesh_type = range.mesh_type; - } - - if (strncasecmp("gen:", range.mesh_filename.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - range.mesh_filename = range.mesh_filename.substr(4, range.mesh_filename.size()); - range.mesh_type = "generated"; - } - - if (strncasecmp("gen:", domain.mesh_filename.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - domain.mesh_filename = domain.mesh_filename.substr(4, domain.mesh_filename.size()); - domain.mesh_type = "generated"; - } - - performance_driver(use_case_environment.m_comm, - working_directory, - search_type, - range, - domain, - performance); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/search/performance/Performance_1.cpp b/packages/stk/stk_classic/stk_usecases/search/performance/Performance_1.cpp deleted file mode 100644 index 1336bbd4a9e2..000000000000 --- a/packages/stk/stk_classic/stk_usecases/search/performance/Performance_1.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -using namespace stk_classic::diag; -using namespace use_case; - -typedef stk_classic::mesh::Field VectorField ; - -namespace { - void get_domain_range_used(const IdentProcRelation &relation, - std::vector &domain_used, - std::vector &range_used, - int &on_proc, int &off_proc, - unsigned int my_rank, - bool same_mesh); - - template - std::ostream& operator<<(std::ostream& ostr, const std::vector &v){ - std::copy(v.begin(), v.end(), std::ostream_iterator(ostr, ", ")); - return ostr; - } -} - - -void -performance_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &search_type, - const stk_classic::search::Options &range, - const stk_classic::search::Options &domain, - bool performance) -{ - static const size_t spatial_dimension = 3; - - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - stk_classic::diag::Timer timer("SearchPerformance", use_case::TIMER_SEARCH, use_case::timer()); - stk_classic::diag::Timer timer_search_performance(domain.mesh_filename + " to " + range.mesh_filename, timer); - stk_classic::diag::Timer timer_range_bb("Range bounding box", timer_search_performance); - stk_classic::diag::Timer timer_domain_bb("Domain bounding box", timer_search_performance); - stk_classic::diag::Timer timer_range_search("Search", timer_search_performance); - - stk_classic::diag::TimeBlock timer_search_performance_block(timer_search_performance); - - bool do_output = !performance; - - bool same_mesh = (range.mesh_filename == domain.mesh_filename); - - // For this use case, if 'node' is the range.entity_rank, then we - // want to use the universal set nodes, not a nodeset. - bool range_use_universal_set = true; - bool domain_use_universal_set = true; - if (range.entity == "nodeset") { - range_use_universal_set = false; - } - if (domain.entity == "nodeset") { - domain_use_universal_set = false; - } - - // If 'faceset' is specified, then use non-skin faceset faces; - // If 'face' is specified, then skin the model and use the faces in the 'skin' part. - if (range.entity == "faceset") { - range_use_universal_set = false; - } - if (domain.entity == "faceset") { - domain_use_universal_set = false; - } - - stk_classic::CommAll comm_all( comm ); - - dw() << "Performance use case: " << search_type << stk_classic::diag::dendl; - dw() << "Range Entity Type = " << range.entity << stk_classic::diag::dendl; - dw() << "Domain Entity Type = " << domain.entity << stk_classic::diag::dendl; - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - stk_classic::mesh::fem::FEMMetaData range_meta_data( spatial_dimension ); - stk_classic::io::MeshData range_mesh_data; - - dw() << "Build range metadata...\n"; - std::string filename = working_directory + range.mesh_filename; - stk_classic::io::create_input_mesh(range.mesh_type, filename, comm, range_meta_data, range_mesh_data); - - stk_classic::mesh::Part *range_skin_part = NULL; - stk_classic::mesh::Part *domain_skin_part = NULL; - stk_classic::mesh::fem::CellTopology skin_top(shards::getCellTopologyData >()); - - if ((range.entity == "face" && range_use_universal_set) || - (same_mesh && domain.entity == "face" && domain_use_universal_set)) { - range_skin_part = &range_meta_data.declare_part("skin", skin_top); - } - - range_meta_data.commit(); - - dw() << "Build range bulkdata...\n"; - stk_classic::mesh::BulkData range_bulk_data(range_meta_data.get_meta_data(range_meta_data) , comm); - stk_classic::io::populate_bulk_data(range_bulk_data, range_mesh_data); - - if ((range.entity == "face" && range_use_universal_set) || - (same_mesh && domain.entity == "face" && domain_use_universal_set)) { - stk_classic::mesh::skin_mesh( range_bulk_data, range_meta_data.element_rank(), range_skin_part); - } - - stk_classic::mesh::fem::FEMMetaData *domain_meta_data = NULL; - stk_classic::mesh::BulkData *domain_bulk_data = NULL; - - if (!same_mesh) { - stk_classic::io::MeshData domain_mesh_data; - dw() << "Build domain metadata...\n"; - domain_meta_data = new stk_classic::mesh::fem::FEMMetaData( spatial_dimension ); - filename = working_directory + domain.mesh_filename; - stk_classic::io::create_input_mesh(domain.mesh_type, filename, comm, *domain_meta_data, domain_mesh_data); - - if (domain.entity == "face" && domain_use_universal_set) { - domain_skin_part = &domain_meta_data->declare_part("skin", skin_top); - } - domain_meta_data->commit(); - - dw() << "Build domain bulkdata...\n"; - domain_bulk_data = new stk_classic::mesh::BulkData(domain_meta_data->get_meta_data(*domain_meta_data) , comm); - stk_classic::io::populate_bulk_data(*domain_bulk_data, domain_mesh_data); - - if (domain.entity == "face" && domain_use_universal_set) { - stk_classic::mesh::skin_mesh( *domain_bulk_data, domain_meta_data->element_rank(), domain_skin_part); - } - } else { - dw() << "Domain shares metadata and bulkdata with range...\n"; - domain_meta_data = &range_meta_data; - domain_bulk_data = &range_bulk_data; - domain_skin_part = range_skin_part; - } - - // ======================================================================== - // End of mesh/geometry generation. The remainder is related to - // searching on thie geometry... - // ======================================================================== - - - stk_classic::search::FactoryOrder order; - order.m_communicator = comm; - - VectorField *range_coord_field = range_meta_data.get_field("coordinates"); - VectorField *domain_coord_field = domain_meta_data->get_field("coordinates"); - - IdentProcRelation relation; - size_t domain_vector_size = 0; - size_t range_vector_size = 0; - - if (search_type == "point_in_box") { - dw() << "For the " << search_type << " use case:\n" - << "\t* domain consists of an axis-aligned bounding box for each " << domain.entity << " in the mesh.\n" - << "\t* range is a PointBoundingBox3D at the centroid of each " << range.entity << " in the mesh.\n\n"; - - std::vector range_vector; - - { - dw() << "Build range bbox...\n"; - stk_classic::diag::TimeBlock __timer_range_bb(timer_range_bb); - stk_classic::search_util::build_centroid_bbox(range_bulk_data, - range_meta_data.entity_rank(range.entity), - range_coord_field, range_vector, - range_use_universal_set); - } - - std::vector domain_vector; - { - dw() << "Build domain bbox...\n"; - stk_classic::diag::TimeBlock __timer_domain_bb(timer_domain_bb); - stk_classic::search_util::build_axis_aligned_bbox(*domain_bulk_data, - domain_meta_data->entity_rank(domain.entity), - domain_coord_field, domain_vector, - domain_use_universal_set, - stk_classic::search_util::OffsetScaleOp(domain.scale, - domain.offset)); - } - - { - stk_classic::diag::TimeBlock __timer_range_search(timer_range_search); - dw() << "Build search object...\n"; - - dw() << "Perform search...\n"; - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - } - - if (do_output) { - dw() << "Search algorithm " << order.m_algorithm << dendl; - dw() << "range " << range_vector << stk_classic::diag::dendl; - dw() << "domain " << domain_vector << stk_classic::diag::dendl; - stk_classic::search_util::print_stk_mesh_relation_map(dw(), stk_classic::mesh::fem::entity_rank_names(spatial_dimension), relation); - } - range_vector_size = range_vector.size(); - domain_vector_size = domain_vector.size(); - } - - else if (search_type == "overlap") { // NEED BETTER NAMES FOR SEARCHES? - dw() << "For the " << search_type << " use case:\n" - << "\t* domain consists of an axis-aligned bounding box for each " << domain.entity << " in the mesh.\n" - << "\t* range is also an axis-aligned bounding box for each " << range.entity << " in the mesh.\n\n"; - - std::vector range_vector; - { - stk_classic::diag::TimeBlock __timer_range_bb(timer_range_bb); - stk_classic::search_util::build_axis_aligned_bbox(range_bulk_data, - range_meta_data.entity_rank(range.entity), - range_coord_field, range_vector, - range_use_universal_set, - stk_classic::search_util::OffsetScaleOp(range.scale, - range.offset)); - } - - std::vector domain_vector; - { - stk_classic::diag::TimeBlock __timer_domain_bb(timer_domain_bb); - stk_classic::search_util::build_axis_aligned_bbox(*domain_bulk_data, - domain_meta_data->entity_rank(domain.entity), - domain_coord_field, domain_vector, - domain_use_universal_set, - stk_classic::search_util::OffsetScaleOp(domain.scale, - domain.offset)); - } - - { - stk_classic::diag::TimeBlock __timer_range_search(timer_range_search); - stk_classic::search::coarse_search(relation, range_vector, domain_vector, order); - } - - if (do_output) { - dw() << "Search algorithm " << order.m_algorithm << dendl; - dw() << "range " << range_vector << stk_classic::diag::dendl; - dw() << "domain " << domain_vector << stk_classic::diag::dendl; - stk_classic::search_util::print_stk_mesh_relation_map(dw(), stk_classic::mesh::fem::entity_rank_names(spatial_dimension), relation); - } - range_vector_size = range_vector.size(); - domain_vector_size = domain_vector.size(); - } - else { - std::cerr << "ERROR: Invalid search option '" << search_type << "'.\n"; - return; - } - - // Output metrics/timing information... - // -- Size of domain and range - // -- Percentage of domain objects matched with at least one range object - // -- Percentage of range objects matched with at least one domain object - // -- Need idea of false positives -- matches found in coarse that - // are filtered by the detailed... Also, cost of a detailed - // search/entity... - // - std::vector domain_used; - std::vector range_used; - int lsizes[] = {0,0,0,0,0,0,0}; - int gsizes[] = {0,0,0,0,0,0,0}; - - get_domain_range_used(relation, domain_used, range_used, lsizes[4], lsizes[5], - comm_all.parallel_rank(), same_mesh); - - lsizes[0] = static_cast(domain_used.size()); - lsizes[1] = static_cast(range_used.size()); - lsizes[2] = static_cast(domain_vector_size); - lsizes[3] = static_cast(range_vector_size); - lsizes[6] = static_cast(relation.size()); - - MPI_Allreduce(lsizes, gsizes, sizeof(lsizes)/sizeof(lsizes[0]), MPI_INT, MPI_SUM, comm); - - dw() << "\nSearch type = " << search_type << dendl - << "Domain Size = " << gsizes[2] << " " << domain.entity - << " Used = " << gsizes[0] << " (" << (100*static_cast(gsizes[0]))/(gsizes[2]) << "%)\n" - << "Range Size = " << gsizes[3] << " " << range.entity - << " Used = " << gsizes[1] << " (" << (100*static_cast(gsizes[1]))/(gsizes[3]) << "%)\n" - << "Total matches: " << gsizes[4] + gsizes[5]; - if (gsizes[4] + gsizes[5] > 0) { - dw() << " On processor: " << gsizes[4] << " (" << (101*static_cast(gsizes[4])-1)/(gsizes[4] + gsizes[5]) << "%)" - << " Off processor: " << gsizes[5] << " (" << (101*static_cast(gsizes[5])-1)/(gsizes[4] + gsizes[5]) << "%)"; - } - dw() << std::endl; - - // Different search types: - // -- expect one-to-one match - each domain object matches exactly - // one range object. - // -- expect few matches - // -- large domain/small range or vice-versa - - if (!same_mesh) { - delete domain_bulk_data; - delete domain_meta_data; - } -} - -namespace { - void uniqify(std::vector &vec) - { - std::sort(vec.begin(), vec.end()); - std::vector::iterator i = std::unique(vec.begin(), vec.end()); - vec.erase(i, vec.end()); - } - - void get_domain_range_used(const IdentProcRelation &relation, - std::vector &domain_used, - std::vector &range_used, - int &on_proc, int &off_proc, unsigned int my_rank, bool same_mesh) - { - IdentProcRelation::const_iterator i=relation.begin(), end=relation.end(); - for (;i!=end; ++i) { - if (same_mesh && i->first.ident == i->second.ident) - continue; - - std::size_t domain_owning_proc = i->first.proc; - std::size_t range_owning_proc = i->second.proc; - if (domain_owning_proc == my_rank) { - domain_used.push_back(i->first.ident); - if (range_owning_proc == my_rank) { - on_proc++; - } else { - off_proc++; - } - } - - if (range_owning_proc == my_rank) { - range_used.push_back(i->second.ident); - if (domain_owning_proc != my_rank) { - off_proc++; - } - } - } - uniqify(domain_used); - uniqify(range_used); - } -} - diff --git a/packages/stk/stk_classic/stk_usecases/transfer/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/transfer/CMakeLists.txt deleted file mode 100644 index 87b868618d2b..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_io) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_search) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_search_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stk_use_cases_transfer - SOURCES ${SOURCES} - DEPLIBS stkclassic_io stkclassic_search stkclassic_search_util - NAME stk_transfer_use_case_0 - ARGS "--pout log --dw=transfer --use_case_0 --domain_mesh \"gen:8x8x8|zdecomp:8" --range_mesh "gen:8x8x8|zdecomp:8\"" - COMM serial mpi - NUM_MPI_PROCS 1 - PASS_REGULAR_EXPRESSION "STK_USECASE_PASS" - ) - diff --git a/packages/stk/stk_classic/stk_usecases/transfer/TransferUseCaseMain.cpp b/packages/stk/stk_classic/stk_usecases/transfer/TransferUseCaseMain.cpp deleted file mode 100644 index 012a740b0078..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/TransferUseCaseMain.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include - -void use_case_1_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); -void use_case_0_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); -void use_case_2_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); -void use_case_3_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity, - double offset, - double scale); -void use_case_4_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh, - const std::string &domain_mesh_type, - const std::string &domain_entity); - -namespace bopt = boost::program_options; - -int main(int argc, char** argv) -{ - std::string range_mesh = ""; - std::string range_filetype = "exodusii"; - std::string range_entity = ""; - std::string domain_mesh = ""; - std::string domain_filetype = "exodusii"; - std::string domain_entity = ""; - - //---------------------------------- - // Process the broadcast command line arguments - - bopt::options_description desc("Transfer use case options"); - - // NOTE: Options --directory --output-log --runtest are handled/defined in UseCaseEnvironment - desc.add_options() - ("range_mesh", bopt::value(&range_mesh), - "range mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("domain_mesh", bopt::value(&domain_mesh), - "domain mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." ) - ("use_case_0", "transfer use case 0 -- node (range) to node (domain) copy search." ) - ("use_case_1", "transfer use case 1 -- node (range) in element (domain) detailed search." ) - ("use_case_2", "transfer use case 2 -- node (range) to node (domain) copy search." ) - ("use_case_3", "transfer use case 3 -- node (range) in face (domain) detailed search." ) - ("use_case_4", "transfer use case 4 -- node (range) in node (domain) copy transfer." ) - ("offset", bopt::value()->default_value(0.1), "transfer use case 3 offset" ) - ("scale", bopt::value()->default_value(0.0), "transfer use case 3 scale." ) - ; - - stk_classic::get_options_description().add(desc); - - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - bopt::variables_map &vm = stk_classic::get_variables_map(); - - //---------------------------------- - - if (range_mesh.empty()) { - std::cerr << "OPTION ERROR: The '--range_mesh ' option is required for the use cases!\n"; - std::cerr << "Application " << stk_classic::get_options_description() << "\n"; - std::exit(EXIT_FAILURE); - } - - if (domain_mesh.empty()) { - domain_mesh = range_mesh; - domain_filetype = range_filetype; - } - - if (strncasecmp("gen:", range_mesh.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - range_mesh = range_mesh.substr(4, range_mesh.size()); - range_filetype = "generated"; - } - - if (strncasecmp("gears:", range_mesh.c_str(), 6) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - range_mesh = range_mesh.substr(6, range_mesh.size()); - range_filetype = "gears"; - } - - if (strncasecmp("gen:", domain_mesh.c_str(), 4) == 0) { - // Strip off the 'gen:' prefix and set the type to "generated" - domain_mesh = domain_mesh.substr(4, domain_mesh.size()); - domain_filetype = "generated"; - } - - if (strncasecmp("gears:", domain_mesh.c_str(), 6) == 0) { - // Strip off the 'gears:' prefix and set the type to "gears" - domain_mesh = domain_mesh.substr(6, domain_mesh.size()); - domain_filetype = "gears"; - } - - if (!vm.count("use_case_0") && !vm.count("use_case_1") && !vm.count("use_case_2") && !vm.count("use_case_3") && !vm.count("use_case_4")) { - std::cout << "OPTION ERROR: At least one of '--use_case_0', '--use_case_1', '--use_case_2', '--use_case_3' or '--use_case_4' must be specified.\n"; - std::exit(EXIT_FAILURE); - } - - if (vm.count("use_case_0")) { - domain_entity = "node"; - range_entity = "node"; - - use_case_0_driver(use_case_environment.m_comm, - use_case_environment.m_workingDirectory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - if (vm.count("use_case_1")) { - domain_entity = "element"; - range_entity = "node"; - - use_case_1_driver(use_case_environment.m_comm, - use_case_environment.m_workingDirectory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - if (vm.count("use_case_2")) { - domain_entity = "face"; - range_entity = "node"; - - use_case_2_driver(use_case_environment.m_comm, - use_case_environment.m_workingDirectory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - if (vm.count("use_case_3")) { - domain_entity = "face"; - range_entity = "node"; - double offset = vm["offset"].as(); - double scale = vm["scale"].as(); - - use_case_3_driver(use_case_environment.m_comm, - use_case_environment.m_workingDirectory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity, - offset, scale); - } - - if (vm.count("use_case_4")) { - domain_entity = "node"; - range_entity = "node"; - - use_case_4_driver(use_case_environment.m_comm, - use_case_environment.m_workingDirectory, - range_mesh, range_filetype, range_entity, - domain_mesh, domain_filetype, domain_entity); - } - - // if we've made it this far, the use case has passed - use_case::print_status(use_case_environment.m_comm, true); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/transfer/UseCaseIsInElement.cpp b/packages/stk/stk_classic/stk_usecases/transfer/UseCaseIsInElement.cpp deleted file mode 100644 index a71b5ae6b040..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/UseCaseIsInElement.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace usecase { - -size_t is_in_element(VectorField *domain_coordinates, - VectorField *range_coordinates, - const std::vector > &entity_map, - std::vector ¬_in_element) -{ - // For each pair of mesh entities, determine if the second is contained in the first. - const std::size_t num_entities = entity_map.size(); - - for (std::size_t i = 0; i < num_entities; ++i) { - stk_classic::mesh::Entity* domain_entity = entity_map[i].first; - assert(domain_entity->entity_rank() > stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - stk_classic::mesh::Entity* range_entity = entity_map[i].second; - assert(range_entity->entity_rank() == stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - - const CellTopologyData * const cell_topo = stk_classic::mesh::fem::get_cell_topology(*domain_entity).getCellTopologyData(); - const int nodes_per_entity = cell_topo->node_count; - - const stk_classic::mesh::PairIterRelation entity_nodes = domain_entity->relations(stk_classic::mesh::fem::FEMMetaData::NODE_RANK); - double *domain_fld_data = static_cast(stk_classic::mesh::field_data(*domain_coordinates, *entity_nodes[0].entity())); - assert(domain_fld_data != NULL); - double xmin = domain_fld_data[0]; - double ymin = domain_fld_data[1]; - double zmin = domain_fld_data[2]; - - double xmax = domain_fld_data[0]; - double ymax = domain_fld_data[1]; - double zmax = domain_fld_data[2]; - - for (int j = 1; j < nodes_per_entity; ++j) { - domain_fld_data = static_cast(stk_classic::mesh::field_data(*domain_coordinates, *entity_nodes[j].entity())); - assert(domain_fld_data != NULL); - xmin = domain_fld_data[0] < xmin ? domain_fld_data[0] : xmin; - ymin = domain_fld_data[1] < ymin ? domain_fld_data[1] : ymin; - zmin = domain_fld_data[2] < zmin ? domain_fld_data[2] : zmin; - - xmax = domain_fld_data[0] > xmax ? domain_fld_data[0] : xmax; - ymax = domain_fld_data[1] > ymax ? domain_fld_data[1] : ymax; - zmax = domain_fld_data[2] > zmax ? domain_fld_data[2] : zmax; - } - double *range_fld_data = static_cast(stk_classic::mesh::field_data(*range_coordinates, *range_entity)); - assert(range_fld_data != NULL); - const double x=range_fld_data[0]; - const double y=range_fld_data[1]; - const double z=range_fld_data[2]; - if (x -#include -#include -#include -#include - -namespace stk_classic { -namespace usecase { - -typedef stk_classic::mesh::Field VectorField ; - -size_t is_in_element(VectorField *domain_coordinates, - VectorField *range_coordinates, - const std::vector > &entity_map, - std::vector ¬_in_element); -} -} diff --git a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_0.cpp b/packages/stk/stk_classic/stk_usecases/transfer/UseCase_0.cpp deleted file mode 100644 index ddb10828550f..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_0.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#define ct_assert(e) extern char (*ct_assert(void)) [sizeof(char[1 - 2*!(e)])] - -using namespace stk_classic::diag; -using namespace use_case; - -struct EntityKeyDecomp { - unsigned operator()( const unsigned p_size , - const stk_classic::mesh::EntityKey & key ) const - { return ( stk_classic::mesh::entity_id( key ) >> 8 ) % p_size ; } -}; - -typedef stk_classic::util::ParallelIndex ParallelIndex; - - -namespace { - -template static std::string to_string(const T & t) -{ - std::ostringstream os; - os << t; - return os.str(); -} - - -template -std::ostream& operator<<(std::ostream& ostr, const std::vector &v){ - std::copy(v.begin(), v.end(), std::ostream_iterator(ostr, ", ")); - return ostr; -} - - -std::ostream &operator<<(std::ostream &os, const stk_classic::mesh::EntityKey &entity_key) { - return os << "[" << entity_rank(entity_key) << ":" << entity_id(entity_key) << "]"; -} - - -void get_idents(stk_classic::mesh::BulkData &bulk_data, - std::vector &ident_vector) -{ - ct_assert(sizeof(ParallelIndex::Key) >= sizeof(stk_classic::mesh::EntityKey)); - ident_vector.clear(); - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = meta_data.locally_owned_part(); - get_selected_entities(selector, bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), entities); - const size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { -// const ParallelIndex::Key p = entities[i]->key().value(); - const ParallelIndex::Key p = entities[i]->key(); - ident_vector.push_back(p); - } -} - -void check_query( const std::vector &recv_global_id_vector, - const std::vector &processor_numbers) -{ - std::vector< ParallelIndex::Key>::const_iterator - r_i = recv_global_id_vector.begin(), - r_e = recv_global_id_vector.end(); - - std::vector::const_iterator - p_i = processor_numbers.begin(), - p_e = processor_numbers.end(); - - for (; r_e != r_i && p_e != p_i; ++r_i, ++p_i) { - const stk_classic::mesh::EntityKey ri = *r_i; - const stk_classic::mesh::EntityKey pi = p_i->first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - std::cout << pi; - - // TODO: These cerr statements should be changed to ThrowErrorMsgIf - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else if (ri < pi) { - std::cerr - << " An active and locally owned receiving mesh node with global id "<first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else { - std::cerr - << " The parallel global search returned an object with global id "< processor_numbers; - parallel_index.query( domain_global_id_vector, processor_numbers); - - check_query( domain_global_id_vector, processor_numbers); - - for (std::vector::const_iterator i=processor_numbers.begin(); - i != processor_numbers.end(); ++i) - { -// stk_classic::mesh::EntityKey entity_key; -// entity_key.value(i->first); - stk_classic::mesh::EntityKey entity_key(i->first); - - const unsigned entity_rank = stk_classic::mesh::entity_rank( entity_key); - const stk_classic::mesh::EntityId entity_id = stk_classic::mesh::entity_id( entity_key ); - const std::string & entity_rank_name = domain_meta_data.entity_rank_name( entity_rank ); - dw().m(LOG_TRANSFER)<<" contains "<<" "<second< -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -using namespace stk_classic::diag; -using namespace use_case; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void -use_case_1_driver( - stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh_filename, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh_filename, - const std::string &domain_mesh_type, - const std::string &domain_entity) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - stk_classic::diag::Timer timer("Transfer", use_case::TIMER_TRANSFER, use_case::timer()); - stk_classic::diag::Timer timer_transfer(domain_mesh_filename + " to " + range_mesh_filename, timer); - stk_classic::diag::Timer timer_range_bb("Range bounding box", timer_transfer); - stk_classic::diag::Timer timer_domain_bb("Domain bounding box", timer_transfer); - stk_classic::diag::Timer timer_range_search("Range search", timer_transfer); - stk_classic::diag::Timer timer_ghosting("Ghosting", timer_transfer); - - stk_classic::diag::TimeBlock __timer_transfer(timer_transfer); - - stk_classic::CommAll comm_all( comm ); - const unsigned my_rank = comm_all.parallel_rank(); - - dw().m(LOG_TRANSFER) << "Use case 1: Point (range) in Box (domain) Search" << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "Range Entity Type = " << range_entity << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "Domain Entity Type = " << domain_entity << stk_classic::diag::dendl; - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - static const size_t spatial_dimension = 3; - stk_classic::mesh::fem::FEMMetaData range_meta_data( spatial_dimension ); - stk_classic::io::MeshData range_mesh_data; - std::string filename = working_directory + range_mesh_filename; - stk_classic::io::create_input_mesh(range_mesh_type, filename, comm, - range_meta_data, range_mesh_data); - range_meta_data.commit(); - - stk_classic::mesh::BulkData range_bulk_data(range_meta_data.get_meta_data(range_meta_data) , comm); - stk_classic::io::populate_bulk_data(range_bulk_data, range_mesh_data); - - stk_classic::mesh::fem::FEMMetaData domain_meta_data( spatial_dimension ); - stk_classic::io::MeshData domain_mesh_data; - filename = working_directory + domain_mesh_filename; - stk_classic::io::create_input_mesh(domain_mesh_type, domain_mesh_filename, comm, - domain_meta_data, domain_mesh_data); - const stk_classic::mesh::EntityRank element_rank = domain_meta_data.element_rank(); - stk_classic::mesh::Part & block_hex = domain_meta_data.declare_part("block_1", element_rank); - stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - domain_meta_data.commit(); - - stk_classic::mesh::BulkData domain_bulk_data(domain_meta_data.get_meta_data(domain_meta_data) , comm); - stk_classic::io::populate_bulk_data(domain_bulk_data, domain_mesh_data); - - // For this use case, the domain consists of an axis-aligned - // bounding box for each 'domain_entity' in the mesh. The range is a - // PointBoundingBox3D at the centroid of each 'range_entity'. The id of the point - // will be the same as the id of the containing entity. If the - // mesh contains solid elements only, and the range_mesh matches the - // domain_mesh, then the search should return a single box for each - // point and the id of the box should match the id of the point. - - VectorField *range_coord_field = range_meta_data.get_field("coordinates"); - std::vector range_vector; - - { - stk_classic::diag::TimeBlock __timer_range_bb(timer_range_bb); - - // For this use case, if 'node' is the range_entity_rank, then we - // want to use the universal set nodes, not a nodeset. - bool node_use_universal_set = true; - stk_classic::search_util::build_centroid_bbox(range_bulk_data, - range_meta_data.entity_rank(range_entity), - range_coord_field, range_vector, - node_use_universal_set); - } - - VectorField *domain_coord_field = domain_meta_data.get_field("coordinates"); - std::vector domain_vector; - - { - stk_classic::diag::TimeBlock __timer_domain_bb(timer_domain_bb); - - stk_classic::search_util::build_axis_aligned_bbox(domain_bulk_data, - domain_meta_data.entity_rank(domain_entity), - domain_coord_field, domain_vector, - false, - stk_classic::search_util::NoOp()); - } - - dw().m(LOG_TRANSFER) << "range " << range_vector << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "domain " << domain_vector << stk_classic::diag::dendl; - - stk_classic::search::FactoryOrder order; - order.m_communicator = comm; - - - dw().m(LOG_TRANSFER) << "Search algorithm " << order.m_algorithm << dendl; - - IdentProcRelation relation; - - { - stk_classic::diag::TimeBlock __timer_range_search(timer_range_search); - stk_classic::search::coarse_search(relation, range_vector, domain_vector,order); - } - - dw().m(LOG_TRANSFER) << "relation :" << relation; - - dw().m(LOG_TRANSFER) << "Pre-Ghosting Info:" << stk_classic::diag::push << stk_classic::diag::dendl; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_bulk_data ); - dw().m(LOG_TRANSFER) << stk_classic::diag::pop; - - // Ghosting of range-mesh entity to bring it to the - // domain-mesh entity processor - - std::vector range_to_ghost ; - - IdentProcRelation::const_iterator i=relation.begin(), end=relation.end(); - - for (;i!=end; ++i) { - const std::size_t domain_owning_proc = i->first.proc; - const std::size_t range_owning_rank = i->second.proc; - if (domain_owning_proc != my_rank && range_owning_rank == my_rank) { - stk_classic::mesh::EntityKey entity_key(i->second.ident); - - stk_classic::mesh::Entity *r_entity = range_bulk_data.get_entity(stk_classic::mesh::entity_rank(entity_key), stk_classic::mesh::entity_id(entity_key)); - if (r_entity->owner_rank() == my_rank) { - stk_classic::mesh::EntityProc ep(r_entity, domain_owning_proc); - range_to_ghost.push_back(ep); - } - } - } - - dw().m(LOG_TRANSFER) << "Change ghosts to send:"; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_to_ghost, "Is ghosting ", " to "); - - { - stk_classic::diag::TimeBlock __timer_ghosting(timer_ghosting); - - // Reset the transfer range ghosting by adding the - // new to-ghost list and removing the old is-ghosted list. - // The 'change_ghosting' method will sort out if anything - // is removed and then added. - - range_bulk_data.modification_begin(); - - stk_classic::mesh::Ghosting & transfer_range_ghosting = - range_bulk_data.create_ghosting( std::string("transter_test") ); - - { - std::vector receive; - transfer_range_ghosting.receive_list( receive ); - range_bulk_data.change_ghosting( transfer_range_ghosting , - range_to_ghost , - receive ); - } - - range_bulk_data.modification_end(); - - dw().m(LOG_TRANSFER) << "Post-Ghosting Info" << stk_classic::diag::push << stk_classic::diag::dendl; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_bulk_data ); - dw().m(LOG_TRANSFER) << stk_classic::diag::pop; - - // Copy coordinates to the newly ghosted nodes - - std::vector fields ; - fields.push_back(range_coord_field); - - stk_classic::mesh::communicate_field_data( transfer_range_ghosting , fields); - } - - // Create the on-processor domain-to-range (range possibly ghosted) map. - std::vector > entity_map; - { - IdentProcRelation::const_iterator I=relation.begin(), rend=relation.end(); - for ( ; I!=rend; ++I) { - const std::size_t domain_owning_proc = I->first.proc; - if (domain_owning_proc == my_rank) { - stk_classic::mesh::EntityKey domain_entity_key(I->first.ident); - stk_classic::mesh::EntityKey range_entity_key(I->second.ident); - - stk_classic::mesh::Entity * const d_entity = domain_bulk_data.get_entity(stk_classic::mesh::entity_rank(domain_entity_key), stk_classic::mesh::entity_id(domain_entity_key)); - stk_classic::mesh::Entity * const r_entity = range_bulk_data.get_entity (stk_classic::mesh::entity_rank(range_entity_key), stk_classic::mesh::entity_id(range_entity_key)); - if ( d_entity == 0 || r_entity == 0 ) { - std::ostringstream msg ; - msg << "P" << my_rank << ": Ghosting failed for " ; - msg << "( " ; - stk_classic::mesh::print_entity_key( msg , range_meta_data.get_meta_data(range_meta_data) , domain_entity_key ); - if ( d_entity == NULL ) { msg << " -> NULL" ; } - msg << " , " << I->first.proc ; - msg << " ) ( " ; - stk_classic::mesh::print_entity_key( msg , range_meta_data.get_meta_data(range_meta_data) , range_entity_key ); - if ( r_entity == NULL ) { msg << " -> NULL" ; } - msg << " , " << I->second.proc ; - msg << " )" ; - throw std::runtime_error( msg.str() ); - } - std::pair e(d_entity, r_entity); - entity_map.push_back(e); - } - } - } - - std::sort(entity_map.begin(), entity_map.end()); - entity_map.erase(std::unique (entity_map.begin(), entity_map.end()), entity_map.end()); - - std::vector not_in_element; - stk_classic::usecase::is_in_element(domain_coord_field, range_coord_field, entity_map, not_in_element); - - dw().m(LOG_TRANSFER) << "[" << my_rank << "] Detailed search found " << not_in_element.size() - << " nodes that were not in the element following the detailed search."; - dw().m(LOG_TRANSFER) << not_in_element << stk_classic::diag::dendl; - - std::vector::reverse_iterator I=not_in_element.rbegin(); - for (; I!=not_in_element.rend(); ++I) - { - std::vector >::iterator del = entity_map.begin()+*I; - entity_map.erase(del); - } - - dw().m(LOG_TRANSFER) << "[" << my_rank << "] Detailed search found " << entity_map.size() - << " range nodes in the " << domain_vector.size() << " domain elements.\n"; - stk_classic::search_util::print_entity_map(dw().m(LOG_TRANSFER), entity_map, " contains "); -} - diff --git a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_2.cpp b/packages/stk/stk_classic/stk_usecases/transfer/UseCase_2.cpp deleted file mode 100644 index d2c30e9e0dea..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_2.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include - -#include - -#define ct_assert(e) extern char (*ct_assert(void)) [sizeof(char[1 - 2*!(e)])] - -using namespace stk_classic::diag; -using namespace stk_classic::search; -using namespace use_case; - -static const size_t spatial_dimension = 3; - -struct EntityKeyDecomp { - unsigned operator()( const unsigned p_size , - const stk_classic::mesh::EntityKey & key ) const - { return ( stk_classic::mesh::entity_id( key ) >> 8 ) % p_size ; } -}; - -typedef stk_classic::util::ParallelIndex ParallelIndex; - -namespace { - -template static std::string to_string(const T & t) -{ - std::ostringstream os; - os << t; - return os.str(); -} - - -template -std::ostream& operator<<(std::ostream& ostr, const std::vector &v){ - std::copy(v.begin(), v.end(), std::ostream_iterator(ostr, ", ")); - return ostr; -} - - -std::ostream &operator<<(std::ostream &os, const stk_classic::mesh::EntityKey &entity_key) { - return os << "[" << entity_rank(entity_key) << ":" << entity_id(entity_key) << "]"; -} - - -void get_idents(stk_classic::mesh::BulkData &bulk_data, - std::vector &ident_vector, - stk_classic::mesh::Part &skin_part) -{ - ct_assert(sizeof(ParallelIndex::Key) >= sizeof(stk_classic::mesh::EntityKey)); - ident_vector.clear(); - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = skin_part & meta_data.locally_owned_part(); - get_selected_entities(selector, bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), entities); - size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { -// const ParallelIndex::Key p = entities[i]->key().value(); - const ParallelIndex::Key p = entities[i]->key(); - ident_vector.push_back(p); - } -} - -void check_query( const std::vector< ParallelIndex::Key> &recv_global_id_vector, - const std::vector &processor_numbers) -{ - std::vector< ParallelIndex::Key>::const_iterator - r_i = recv_global_id_vector.begin(), - r_e = recv_global_id_vector.end(); - - std::vector::const_iterator - p_i = processor_numbers.begin(), - p_e = processor_numbers.end(); - - for (; r_e != r_i && p_e != p_i; ++r_i, ++p_i) { - const stk_classic::mesh::EntityKey ri = *r_i; - const stk_classic::mesh::EntityKey pi = p_i->first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - // TODO: These cerr statements should be changed to ThrowErrorMsgIf - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else if (ri < pi) { - std::cerr - << " An active and locally owned receiving mesh node with global id "<first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else { - std::cerr - << " The parallel global search returned an object with global id "< range_vector; - - std::vector< ParallelIndex::Key > range_global_id_vector; - std::vector< ParallelIndex::Key > domain_global_id_vector; - - get_idents(range_bulk_data, range_global_id_vector, *range_skin_part); - get_idents(domain_bulk_data, domain_global_id_vector, *domain_skin_part); - - dw().m(LOG_TRANSFER) << "range " << range_global_id_vector << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "domain " << domain_global_id_vector << stk_classic::diag::dendl; - - ParallelIndex parallel_index(comm, domain_global_id_vector); - std::vector processor_numbers; - parallel_index.query( range_global_id_vector, processor_numbers); - - check_query( range_global_id_vector, processor_numbers); - - for (std::vector::const_iterator i=processor_numbers.begin(); - i != processor_numbers.end(); ++i) - { - stk_classic::mesh::EntityKey entity_key(i->first); - - const unsigned entity_rank = stk_classic::mesh::entity_rank( entity_key); - const stk_classic::mesh::EntityId entity_id = stk_classic::mesh::entity_id( entity_key ); - const std::string & entity_rank_name = domain_meta_data.entity_rank_name( entity_rank ); - dw().m(LOG_TRANSFER)<<" contains "<<" "<second< -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -using namespace stk_classic::diag; -using namespace stk_classic::search; -using namespace use_case; - -static const size_t spatial_dimension = 3; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field VectorField ; - -void -use_case_3_driver(stk_classic::ParallelMachine comm, - const std::string &working_directory, - const std::string &range_mesh_filename, - const std::string &range_mesh_type, - const std::string &range_entity, - const std::string &domain_mesh_filename, - const std::string &domain_mesh_type, - const std::string &domain_entity, - double offset, - double scale) -{ - stk_classic::diag::WriterThrowSafe _write_throw_safe(dw()); - - stk_classic::diag::Timer timer("Transfer", use_case::TIMER_TRANSFER, use_case::timer()); - stk_classic::diag::Timer timer_transfer(domain_mesh_filename + " to " + range_mesh_filename, timer); - stk_classic::diag::Timer timer_range_bb("Range bounding box", timer_transfer); - stk_classic::diag::Timer timer_domain_bb("Domain bounding box", timer_transfer); - stk_classic::diag::Timer timer_range_search("Range search", timer_transfer); - stk_classic::diag::Timer timer_ghosting("Ghosting", timer_transfer); - - stk_classic::diag::TimeBlock __timer_transfer(timer_transfer); - - stk_classic::CommAll comm_all( comm ); - const unsigned my_rank = comm_all.parallel_rank(); - - dw().m(LOG_TRANSFER) << "Use case 3: Point (range) in Box (domain) Search" << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "Range Entity Type = " << range_entity << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "Domain Entity Type = " << domain_entity << stk_classic::diag::dendl; - - // Initialize IO system. Registers all element types and storage - // types and the exodusII default database type. - Ioss::Init::Initializer init_db; - - stk_classic::mesh::fem::FEMMetaData range_meta_data( spatial_dimension ); - stk_classic::io::MeshData range_mesh_data; - std::string filename = working_directory + range_mesh_filename; - stk_classic::io::create_input_mesh(range_mesh_type, filename, comm, - range_meta_data, range_mesh_data); - range_meta_data.commit(); - - stk_classic::mesh::BulkData range_bulk_data(range_meta_data.get_meta_data(range_meta_data) , comm); - stk_classic::io::populate_bulk_data(range_bulk_data, range_mesh_data); - - stk_classic::mesh::fem::FEMMetaData domain_meta_data( spatial_dimension ); - const stk_classic::mesh::EntityRank element_rank = domain_meta_data.element_rank(); - const stk_classic::mesh::EntityRank side_rank = domain_meta_data.side_rank(); - stk_classic::mesh::Part & block_hex = domain_meta_data.declare_part("block_1", element_rank); - stk_classic::mesh::Part & block_quad = domain_meta_data.declare_part("block_2", side_rank); - stk_classic::mesh::fem::CellTopology hex_top (shards::getCellTopologyData >()); - stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData >()); - stk_classic::mesh::fem::set_cell_topology( block_hex, hex_top ); - stk_classic::mesh::fem::set_cell_topology( block_quad, quad_top ); - - stk_classic::io::MeshData domain_mesh_data; - filename = working_directory + domain_mesh_filename; - stk_classic::io::create_input_mesh(domain_mesh_type, filename, comm, - domain_meta_data, domain_mesh_data); - - stk_classic::mesh::Part & block_skin = domain_meta_data.declare_part("skin", side_rank); - stk_classic::mesh::fem::set_cell_topology( block_skin, quad_top ); - domain_meta_data.commit(); - - stk_classic::mesh::BulkData domain_bulk_data(domain_meta_data.get_meta_data(domain_meta_data) , comm); - stk_classic::io::populate_bulk_data(domain_bulk_data, domain_mesh_data); - stk_classic::mesh::skin_mesh(domain_bulk_data, domain_meta_data.element_rank(), &block_skin); - - // For this use case, the domain consists of an axis-aligned - // bounding box for each 'domain_entity' in the mesh. The range is a - // PointBoundingBox3D at the centroid of each 'range_entity'. The id of the point - // will be the same as the id of the containing entity. If the - // mesh contains solid elements only, and the range_mesh matches the - // domain_mesh, then the search should return a single box for each - // point and the id of the box should match the id of the point. - - VectorField *range_coord_field = range_meta_data.get_field("coordinates"); - std::vector range_vector; - - { - stk_classic::diag::TimeBlock __timer_range_bb(timer_range_bb); - - // For this use case, if 'node' is the range_entity_rank, then we - // want to use the universal set nodes, not a nodeset. - bool use_universal_set = true; - stk_classic::search_util::build_centroid_bbox(range_bulk_data, - range_meta_data.entity_rank(range_entity), - range_coord_field, range_vector, - use_universal_set); - } - - VectorField *domain_coord_field = domain_meta_data.get_field("coordinates"); - std::vector domain_vector; - - { - stk_classic::diag::TimeBlock __timer_domain_bb(timer_domain_bb); - - bool use_universal_set = true; // Use the 'skin' part - stk_classic::search_util::build_axis_aligned_bbox(domain_bulk_data, - domain_meta_data.entity_rank(domain_entity), - domain_coord_field, domain_vector, - use_universal_set, - stk_classic::search_util::OffsetScaleOp(scale, offset)); - } - - dw().m(LOG_TRANSFER) << "range " << range_vector << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "domain " << domain_vector << stk_classic::diag::dendl; - - FactoryOrder order; - order.m_communicator = comm; - - - - dw().m(LOG_TRANSFER) << "Search algorithm " << order.m_algorithm << dendl; - - IdentProcRelation relation; - - { - stk_classic::diag::TimeBlock __timer_range_search(timer_range_search); - stk_classic::search::coarse_search(relation, range_vector, domain_vector, order); - } - - dw().m(LOG_TRANSFER) << "relation :" << relation; - - dw().m(LOG_TRANSFER) << "Pre-Ghosting Info:" << stk_classic::diag::push << stk_classic::diag::dendl; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_bulk_data ); - dw().m(LOG_TRANSFER) << stk_classic::diag::pop; - - std::vector range_to_ghost ; - - IdentProcRelation::const_iterator i=relation.begin(), end=relation.end(); - for (;i!=end; ++i) { - stk_classic::mesh::EntityKey domain_entity_key(i->first.ident); - stk_classic::mesh::EntityKey range_entity_key(i->second.ident); - - const std::size_t domain_owning_proc = i->first.proc; - const std::size_t range_owning_rank = i->second.proc; - if (domain_owning_proc != my_rank && range_owning_rank == my_rank) { - stk_classic::mesh::Entity *r_entity = range_bulk_data.get_entity(stk_classic::mesh::entity_rank(range_entity_key), stk_classic::mesh::entity_id(range_entity_key)); - if (r_entity->owner_rank() == my_rank) { - stk_classic::mesh::EntityProc ep(r_entity, domain_owning_proc); - range_to_ghost.push_back(ep); - } - } - } - - dw().m(LOG_TRANSFER) << "Change ghosts to send:"; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_to_ghost, "Is ghosting ", " to "); - - - { - stk_classic::diag::TimeBlock __timer_ghosting(timer_ghosting); - - range_bulk_data.modification_begin(); - - stk_classic::mesh::Ghosting & transfer_range_ghosting = - range_bulk_data.create_ghosting( std::string("transter_test") ); - - { - std::vector receive ; - transfer_range_ghosting.receive_list( receive ); - range_bulk_data.change_ghosting( transfer_range_ghosting , - range_to_ghost , - receive ); - } - - range_bulk_data.modification_end(); - - dw().m(LOG_TRANSFER) << "Post-Ghosting Info" << stk_classic::diag::push << stk_classic::diag::dendl; - stk_classic::search_util::print_entity_proc_map(dw().m(LOG_TRANSFER), range_bulk_data ); - dw().m(LOG_TRANSFER) << stk_classic::diag::pop; - - // Copy coordinates to the newly ghosted nodes - - std::vector fields ; - fields.push_back(range_coord_field); - - stk_classic::mesh::communicate_field_data( transfer_range_ghosting , fields); - } - - std::vector > entity_map; - { - IdentProcRelation::const_iterator I=relation.begin(), rend=relation.end(); - for ( ; I!=rend; ++I) { - const std::size_t domain_owning_proc = I->first.proc; - if (domain_owning_proc == my_rank) { - stk_classic::mesh::EntityKey domain_entity_key(I->first.ident); - stk_classic::mesh::EntityKey range_entity_key(I->second.ident); - - stk_classic::mesh::Entity *d_entity = domain_bulk_data.get_entity(stk_classic::mesh::entity_rank(domain_entity_key), stk_classic::mesh::entity_id(domain_entity_key)); - stk_classic::mesh::Entity *r_entity = range_bulk_data.get_entity (stk_classic::mesh::entity_rank(range_entity_key), stk_classic::mesh::entity_id(range_entity_key)); - assert(d_entity); - assert(r_entity); - std::pair e(d_entity, r_entity); - entity_map.push_back(e); - } - } - } - - std::sort(entity_map.begin(), entity_map.end()); - entity_map.erase(std::unique (entity_map.begin(), entity_map.end()), entity_map.end()); - - if (dw().shouldPrint(LOG_TRANSFER)) { - dw() << "[" << my_rank << "] Detailed search found " << entity_map.size() - << " range nodes in the " << domain_vector.size() << " domain faces." << stk_classic::diag::push << stk_classic::diag::dendl; - stk_classic::search_util::print_entity_map(dw().m(LOG_TRANSFER), entity_map, " may contain "); - dw() << stk_classic::diag::pop << stk_classic::diag::dendl; - } - - std::vector not_in_element; - stk_classic::usecase::is_in_element(domain_coord_field, range_coord_field, entity_map, not_in_element); - - dw().m(LOG_TRANSFER) << "[" << my_rank << "] Detailed search found " << not_in_element.size() - << " nodes that were not in the face following the detailed search."; - dw().m(LOG_TRANSFER) << not_in_element << stk_classic::diag::dendl; - - std::vector::reverse_iterator I=not_in_element.rbegin(); - for (; I!=not_in_element.rend(); ++I) - { - std::vector >::iterator del = entity_map.begin()+*I; - entity_map.erase(del); - } - - dw().m(LOG_TRANSFER) << "[" << my_rank << "] Detailed search found " << entity_map.size() - << " range nodes in the " << domain_vector.size() << " domain faces.\n"; - stk_classic::search_util::print_entity_map(dw().m(LOG_TRANSFER), entity_map, " contains "); -} diff --git a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_4.cpp b/packages/stk/stk_classic/stk_usecases/transfer/UseCase_4.cpp deleted file mode 100644 index 3d41af43a692..000000000000 --- a/packages/stk/stk_classic/stk_usecases/transfer/UseCase_4.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#define ct_assert(e) extern char (*ct_assert(void)) [sizeof(char[1 - 2*!(e)])] - -using namespace stk_classic::diag; -using namespace stk_classic::search; -using namespace use_case; - -typedef stk_classic::mesh::Field ScalarField ; -typedef stk_classic::mesh::Field CartesianField ; - -CartesianField & -declare_vector_field_on_all_nodes( - stk_classic::mesh::MetaData & meta_data , const std::string & s , unsigned n1 ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() , n1 ); -} - - -ScalarField & -declare_scalar_field_on_all_nodes( - stk_classic::mesh::MetaData & meta_data , const std::string & s ) -{ - return stk_classic::mesh::put_field( meta_data.declare_field(s), stk_classic::mesh::fem::FEMMetaData::NODE_RANK , meta_data.universal_part() ); -} - - -struct EntityKeyDecomp { - unsigned operator()( const unsigned p_size , - const stk_classic::mesh::EntityKey & key ) const - { return ( stk_classic::mesh::entity_id( key ) >> 8 ) % p_size ; } -}; - -typedef stk_classic::util::ParallelIndex ParallelIndex; - -namespace { - -template static std::string to_string(const T & t) -{ - std::ostringstream os; - os << t; - return os.str(); -} - - -template -std::ostream& operator<<(std::ostream& ostr, const std::vector &v){ - std::copy(v.begin(), v.end(), std::ostream_iterator(ostr, ", ")); - return ostr; -} - - -std::ostream &operator<<(std::ostream &os, const stk_classic::mesh::EntityKey &entity_key) { - return os << "[" << entity_rank(entity_key) << ":" << entity_id(entity_key) << "]"; -} - - -} - -namespace stk_classic { - -template<> -Marshal &operator<<(Marshal &mout, const stk_classic::mesh::EntityKey &t) { - return write(mout, t); -} - -template<> -Marshal &operator>>(Marshal &min, stk_classic::mesh::EntityKey &t) { - return read(min, t); -} - -} // namespace stk_classic - -namespace { - -void get_idents(stk_classic::mesh::BulkData &bulk_data, - std::vector &ident_vector) -{ - ct_assert(sizeof(ParallelIndex::Key) >= sizeof(stk_classic::mesh::EntityKey)); - ident_vector.clear(); - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = meta_data.locally_owned_part(); - get_selected_entities(selector, bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), entities); - const size_t num_entities = entities.size(); - - for (size_t i = 0; i < num_entities; ++i) { -// const ParallelIndex::Key p = entities[i]->key().value(); - const ParallelIndex::Key p = entities[i]->key(); - ident_vector.push_back(p); - } -} - -void check_query( const std::vector< ParallelIndex::Key> &recv_global_id_vector, - const std::vector &processor_numbers) -{ - std::vector< ParallelIndex::Key>::const_iterator - r_i = recv_global_id_vector.begin(), - r_e = recv_global_id_vector.end(); - - std::vector::const_iterator - p_i = processor_numbers.begin(), - p_e = processor_numbers.end(); - - for (; r_e != r_i && p_e != p_i; ++r_i, ++p_i) { - const stk_classic::mesh::EntityKey ri = *r_i; - const stk_classic::mesh::EntityKey pi = p_i->first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - // TODO: These cerr statements should be changed to ThrowErrorMsgIf - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else if (ri < pi) { - std::cerr - << " An active and locally owned receiving mesh node with global id "<first; - const stk_classic::mesh::EntityKey pi_p1 = (p_e == p_i + 1) ? stk_classic::mesh::EntityKey(entity_rank(pi), entity_id(pi) + 1) : (p_i+1)->first; - if (pi == pi_p1) { - std::cerr - << " A send mesh node with global id "<second<<" and on processor "<<(p_i+1)->second<<".\n" - << std::endl << StackTrace; - std::exit(EXIT_FAILURE); - } else { - std::cerr - << " The parallel global search returned an object with global id "< range_vector; - - std::vector< ParallelIndex::Key > range_global_id_vector; - std::vector< ParallelIndex::Key > domain_global_id_vector; - get_idents(range_bulk_data, range_global_id_vector); - get_idents(domain_bulk_data, domain_global_id_vector); - - dw().m(LOG_TRANSFER) << "range " << range_global_id_vector << stk_classic::diag::dendl; - dw().m(LOG_TRANSFER) << "domain " << domain_global_id_vector << stk_classic::diag::dendl; - - ParallelIndex parallel_index(comm, range_global_id_vector); - std::vector processor_map; - parallel_index.query( domain_global_id_vector, processor_map); - - check_query( domain_global_id_vector, processor_map); - - for (std::vector::const_iterator i = processor_map.begin(); i != processor_map.end(); ++i) { -// stk_classic::mesh::EntityKey entity_key; -// entity_key.value(i->first); - stk_classic::mesh::EntityKey entity_key(i->first); - - const unsigned entity_rank = stk_classic::mesh::entity_rank( entity_key); - const stk_classic::mesh::EntityId entity_id = stk_classic::mesh::entity_id( entity_key ); - const std::string & entity_rank_name = domain_meta_data.entity_rank_name( entity_rank ); - dw().m(LOG_TRANSFER)<<" contains "<<" "<second< mout(parallel_size); - for (std::vector::iterator it = mout.begin(); it != mout.end(); ++it) - (*it) = new stk_classic::Marshal; - - dw().m(LOG_TRANSFER) << "Sending" << push << dendl; - - for (size_t i = 0; i < processor_map.size(); ++i) { -// stk_classic::mesh::EntityKey entity_key; -// entity_key.value(processor_map[i].first); - stk_classic::mesh::EntityKey entity_key(processor_map[i].first); - int to_proc = processor_map[i].second; - - stk_classic::mesh::Entity *entity = domain_bulk_data.get_entity(stk_classic::mesh::entity_rank(entity_key), stk_classic::mesh::entity_id(entity_key)); - double *entity_coordinates = stk_classic::mesh::field_data(domain_coordinates_field, *entity); - - double coord_sum = entity_coordinates[0] + entity_coordinates[1] + entity_coordinates[2]; - - dw().m(LOG_TRANSFER) << "Entity " << stk_classic::mesh::entity_id(entity_key) << "," << stk_classic::mesh::entity_rank(entity_key) << " to proc " << to_proc << dendl; - - *mout[to_proc] << entity_key << coord_sum; - } - dw().m(LOG_TRANSFER) << pop << dendl; - - std::vector send_count(parallel_size); - int * const send_count_ptr = &send_count[0] ; - - for (size_t i = 0; i < send_count.size(); ++i) - send_count[i] = mout[i]->size(); - - std::vector recv_count(parallel_size); - int * const recv_count_ptr = &recv_count[0] ; - - int result = MPI_Alltoall(send_count_ptr, 1, MPI_INT, - recv_count_ptr, 1, MPI_INT, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::transfer FAILED: MPI_Gatherv = " << result ; - throw std::runtime_error(message.str()); - } - - - std::vector recv_displ(parallel_size + 1, 0); - - for (int i = 0 ; i < parallel_size ; ++i) { - recv_displ[i + 1] = recv_displ[i] + recv_count[i] ; - } - - const int recv_size = recv_displ[parallel_size] ; - - std::vector send_displ(parallel_size + 1, 0); - - for (int i = 0 ; i < parallel_size ; ++i) { - send_displ[i + 1] = send_displ[i] + send_count[i] ; - } - - const int send_size = send_displ[parallel_size] ; - - std::vector buffer(recv_size); - - { - std::vector send_string(send_size); - const char * const send_ptr = &send_string[0]; - - for (int i = 0; i < parallel_size; ++i) { - std::string s(mout[i]->str()); - std::copy(s.data(), s.data() + s.size(), &send_string[0] + send_displ[i]); - } - - char * const recv_ptr = recv_size ? & buffer[0] : 0; - int * const recv_displ_ptr = &recv_displ[0] ; - int * const send_displ_ptr = &send_displ[0] ; - - result = MPI_Alltoallv(const_cast(static_cast(send_ptr)), - send_count_ptr, send_displ_ptr, MPI_CHAR, - recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::stk_classic::transfer FAILED: MPI_Alltoallv = " << result ; - throw std::runtime_error(message.str()); - } - - for (int j = 0; j < parallel_size; ++j) { - if (recv_count[j] != 0) { - dw().m(LOG_TRANSFER) << "From processor " << j << push << dendl; - stk_classic::Marshal min(std::string(recv_ptr + recv_displ[j], recv_ptr + recv_displ[j + 1])); - - stk_classic::mesh::EntityKey entity_key; - double coord_sum(0); - - while (min >> entity_key >> coord_sum) { - dw().m(LOG_TRANSFER) << stk_classic::mesh::entity_id(entity_key) << "," << stk_classic::mesh::entity_rank(entity_key) << ": " << coord_sum << dendl; - - stk_classic::mesh::Entity *entity = range_bulk_data.get_entity(stk_classic::mesh::entity_rank(entity_key), stk_classic::mesh::entity_id(entity_key)); - - double *entity_coordinates = stk_classic::mesh::field_data(range_coordinates_field, *entity); - - if (coord_sum != entity_coordinates[0] + entity_coordinates[1] + entity_coordinates[2]) { - static stk_classic::MessageCode x; - - stk_classic::RuntimeDoomedDeferred(x) << "Incorrect range coordinate sum for entity " << stk_classic::mesh::entity_id(entity_key) << " do not sum to " << coord_sum; - } - else { - double *entity_coord_sum = stk_classic::mesh::field_data(range_coord_sum_field, *entity); - - *entity_coord_sum = coord_sum; - } - } - } - dw().m(LOG_TRANSFER) << pop << dendl; - } - - for (std::vector::iterator it = mout.begin(); it != mout.end(); ++it) - delete (*it); - } - - dw().m(LOG_TRANSFER) << "Verifying results" << dendl; - { - const stk_classic::mesh::MetaData& meta_data = stk_classic::mesh::MetaData::get(range_bulk_data); - - std::vector entities; - stk_classic::mesh::Selector selector = meta_data.locally_owned_part(); - get_selected_entities(selector, range_bulk_data.buckets(stk_classic::mesh::fem::FEMMetaData::NODE_RANK), entities); - const size_t num_entities = entities.size(); - for (size_t i = 0; i < num_entities; ++i) { - const stk_classic::mesh::Entity &entity = *entities[i]; - - double *entity_coordinates = stk_classic::mesh::field_data(range_coordinates_field, entity); - double *entity_coord_sum = stk_classic::mesh::field_data(range_coord_sum_field, entity); - if (*entity_coord_sum != entity_coordinates[0] + entity_coordinates[1] + entity_coordinates[2]) { - static stk_classic::MessageCode x; - - stk_classic::RuntimeDoomedDeferred(x) << "Incorrect or missing coordinate sum of entity " << stk_classic::mesh::entity_id(entity.key()) << " do not sum to " << entity_coord_sum; - } - } - } -} diff --git a/packages/stk/stk_classic/stk_usecases/util/CMakeLists.txt b/packages/stk/stk_classic/stk_usecases/util/CMakeLists.txt deleted file mode 100644 index 7595383f022a..000000000000 --- a/packages/stk/stk_classic/stk_usecases/util/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ - - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../stk_util) -#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../teuchos/src) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp) -FILE(GLOB SOURCES *.cpp) - - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - stkclassic_use_cases_util - SOURCES ${SOURCES} - DEPLIBS stkclassic_util_use_cases - ARGS "" - COMM serial mpi - NUM_MPI_PROCS 1 - PASS_REGULAR_EXPRESSION "Use Cases" - ) diff --git a/packages/stk/stk_classic/stk_usecases/util/UseCaseMessage.cpp b/packages/stk/stk_classic/stk_usecases/util/UseCaseMessage.cpp deleted file mode 100644 index 38e1381c1435..000000000000 --- a/packages/stk/stk_classic/stk_usecases/util/UseCaseMessage.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -using namespace use_case; - -int -use_case_message( - UseCaseEnvironment & use_case_environment) -{ - int proc_rank = stk_classic::parallel_machine_rank(use_case_environment.m_comm); -// int proc_size = stk_classic::parallel_machine_size(use_case_environment.m_comm); - -// Direct calls to report warning and doomeds - stk_classic::report_symmetric_warning("Direct call warning message"); - stk_classic::report_symmetric_doomed("Direct call doomed message"); - -// Single statement warning and doomeds reports - stk_classic::RuntimeWarningSymmetric() << "Single statement warning message"; - stk_classic::RuntimeDoomedSymmetric() << "Single statement doomed message"; - -// Multiple statement warning and doomeds reports - bool error = true; - if (error) { - stk_classic::RuntimeWarningSymmetric x; - - x << "Assembled warning message"; - for (int i = 0; i < 10; ++i) - x << " " << i; - } - - if (error) { - stk_classic::RuntimeDoomedSymmetric x; - - x << "Assembled doomed message"; - for (int i = 0; i < 10; ++i) - x << " " << i; - } - -// Message code for limited display - for (int i = 0; i < 100; ++i) { - static stk_classic::MessageCode code(2); - - stk_classic::RuntimeWarningSymmetric(code) << "Limited display warning, count = " << i; - } - -// Message code for limited display - for (int i = 0; i < 100; ++i) { - static stk_classic::MessageCode code(2); - - stk_classic::RuntimeDoomedSymmetric(code) << "Limited display doomed, count = " << i; - } - - if (proc_rank == 0) { - out() << "There were " << stk_classic::get_warning_count() << " warnings" << std::endl; - out() << "There were " << stk_classic::get_doomed_count() << " fatal errors" << std::endl << std::endl; - } - -// Doomed exception thrown when max exceeded (disabled. Is this the behavior we want?) - stk_classic::set_max_doomed_count(2); - stk_classic::reset_doomed_count(); - try { - for (int i = 0; i < 100; ++i) { - stk_classic::RuntimeDoomedSymmetric() << "Throw exception when doomed count is 2, count = " << i; - } - } - catch (std::exception &x) { - out() << "Caught exception: " << x.what() << std::endl; - } - -// Message aggregation with limited display - stk_classic::set_max_doomed_count(1000); - stk_classic::set_max_warning_count(1000); - stk_classic::reset_doomed_count(); - stk_classic::reset_warning_count(); - - for (int i = 0; i < 100; ++i) - if (error) { - static stk_classic::MessageCode code(2); - stk_classic::RuntimeWarningSymmetric x(code); - - x << "Every processor may have something to contribute: "; - - std::ostringstream s; - if (proc_rank%2) - s << proc_rank; - - stk_classic::aggregate_messages(use_case_environment.m_comm, s, ", "); - - x << s.str() << " contributed"; - } - -// Print summary - if (proc_rank == 0) { - out() << "There were " << stk_classic::get_warning_count() << " warnings" << std::endl; - out() << "There were " << stk_classic::get_doomed_count() << " fatal errors" << std::endl << std::endl; - } - -// Deferred message - stk_classic::set_max_doomed_count(1000); - stk_classic::set_max_warning_count(1000); - stk_classic::reset_doomed_count(); - stk_classic::reset_warning_count(); - - if (proc_rank%2) { - static stk_classic::MessageCode code(2); - stk_classic::RuntimeWarningDeferred x(code); - - x << "Deferred warnings from processor "; - x.aggregate << proc_rank; - - static stk_classic::MessageCode code2(2); - stk_classic::RuntimeDoomedDeferred x2(code2); - - x2 << "Deferred dooms from processor "; - x2.aggregate << proc_rank; - } - stk_classic::report_deferred_messages(use_case_environment.m_comm); - - if (proc_rank == 0) { - out() << "There were " << stk_classic::get_warning_count() << " warnings" << std::endl; - out() << "There were " << stk_classic::get_doomed_count() << " fatal errors" << std::endl << std::endl; - } - -// Deferred warning message with varying key - for (int i = 0; i < 100; ++i) { - if (proc_rank%2 == i%3) { - for (int j = 0; j < 7; ++j) { - - static stk_classic::MessageCode code(2); - stk_classic::RuntimeWarningDeferred x(code); - - x << "Deferred warnings with varying key " << i << " from processors "; - x.aggregate << proc_rank; - } - } - } - stk_classic::report_deferred_messages(use_case_environment.m_comm); - -// Deferred warning message with limited display - stk_classic::set_max_doomed_count(2); - stk_classic::set_max_warning_count(2); - stk_classic::reset_doomed_count(); - stk_classic::reset_warning_count(); - for (int i = 0; i < 100; ++i) { - if (proc_rank%2 == i%3) { - static stk_classic::MessageCode code(2); - stk_classic::RuntimeWarningDeferred x(code); - - x << "Deferred warnings with limited display from processors "; - x.aggregate << proc_rank; - } - stk_classic::report_deferred_messages(use_case_environment.m_comm); - } - - out() << "There were " << stk_classic::get_warning_count() << " warnings" << std::endl; - out() << "There were " << stk_classic::get_doomed_count() << " fatal errors" << std::endl; - out() << "Done" << std::endl; - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/util/UseCaseTimer.cpp b/packages/stk/stk_classic/stk_usecases/util/UseCaseTimer.cpp deleted file mode 100644 index e184eae29c84..000000000000 --- a/packages/stk/stk_classic/stk_usecases/util/UseCaseTimer.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -using namespace use_case; - -enum { - TIMER_DOMAIN = 0x00001000, ///< Enable domain timers - TIMER_REGION = 0x00002000, ///< Enable region timers - TIMER_PROCEDURE = 0x00004000, ///< Enable procedure timers - TIMER_MECHANICS = 0x00008000, ///< Enable mechanics timers - TIMER_ALGORITHM = 0x00010000, ///< Enable algorithm timers - TIMER_SOLVER = 0x00020000, ///< Enable solver timers - TIMER_CONTACT = 0x00040000, ///< Enable contact timers - TIMER_MATERIAL = 0x00080000, ///< Enable material timers - TIMER_SEARCH = 0x00100000, ///< Enable search timers - TIMER_TRANSFER = 0x00200000, ///< Enable transfer timers - TIMER_ADAPTIVITY = 0x00400000, ///< Enable adaptivity - TIMER_UNUSED_1 = 0x00800000, ///< Enable unused 1 - TIMER_PROFILE_1 = 0x01000000, ///< Enable profile 1 timers - TIMER_PROFILE_2 = 0x02000000, ///< Enable profile 2 timers - TIMER_PROFILE_3 = 0x04000000, ///< Enable profile 3 timers - TIMER_PROFILE_4 = 0x08000000, ///< Enable profile 4 timers - TIMER_APP_1 = 0x10000000, ///< Enable application defined 1 - TIMER_APP_2 = 0x20000000, ///< Enable application defined 2 - TIMER_APP_3 = 0x40000000, ///< Enable application defined 3 - TIMER_APP_4 = 0x80000000, ///< Enable application defined 4 - TIMER_ALL = 0xFFFFF000 ///< Enable all timers -}; - -namespace { - -double -work() -{ - double x = 1.0; - - for (int i = 0; i < 100000; ++i) -// for (int i = 0; i < 100; ++i) - x += std::sin((double) i); - - return x; -} - -stk_classic::diag::TimerSet & -unitTestTimerSet() -{ - static stk_classic::diag::TimerSet s_unitTestTimerSet(TIMER_REGION); - - return s_unitTestTimerSet; -} - - -struct UseCaseRootTimer : public stk_classic::diag::Timer -{ - UseCaseRootTimer() - : stk_classic::diag::Timer(stk_classic::diag::createRootTimer("Unit test timer", unitTestTimerSet())) - {} - - ~UseCaseRootTimer() { - stk_classic::diag::deleteRootTimer(*this); - } -}; - - -stk_classic::diag::Timer &unitTestTimer() { - static UseCaseRootTimer s_unitTestTimer; - - return s_unitTestTimer; -} - - -struct RootObject -{ - RootObject() - : m_timer("Root object", TIMER_REGION, unitTestTimer()) - {} - - stk_classic::diag::Timer m_timer; -}; - - -struct Object -{ - Object(const std::string &name, RootObject &root_object) - : m_id(0), - m_name(name), - m_timer(name, root_object.m_timer) - {} - - Object(int id, const Object &parent) - : m_id(id), - m_name(id_name(id)), - m_timer(m_name, parent.m_timer) - {} - - static std::string id_name(int id) { - std::ostringstream s; - s << "Object id " << id << " run"; - return s.str(); - } - - void run() { - stk_classic::diag::TimeBlock _time(m_timer); - m_x = work(); - } - - int m_id; - double m_x; - std::string m_name; - stk_classic::diag::Timer m_timer; -}; - -} // namespace - - -int -use_case_timer( - UseCaseEnvironment & use_case_environment) -{ - int parallel_rank = stk_classic::parallel_machine_rank(use_case_environment.m_comm); - - stk_classic::diag::TimeBlock root_time_block(unitTestTimer()); - - stk_classic::diag::updateRootTimer(unitTestTimer()); - - // Check lap count - { - stk_classic::diag::MetricTraits::Type lap_count = unitTestTimer().getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == 1); - } - - // Create subtimer and run 100 laps - { - static stk_classic::diag::Timer run_timer("Run 100 times twice", TIMER_REGION, unitTestTimer()); - - for (int i = 0; i < 100; ++i) { - stk_classic::diag::TimeBlock _time(run_timer); - work(); - } - - stk_classic::diag::MetricTraits::Type lap_count = run_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == 100); - } - - // Grab previous subtimer and run 100 laps - { - static stk_classic::diag::Timer run_timer("Run 100 times twice", TIMER_REGION, unitTestTimer()); - - for (int i = 0; i < 100; ++i) { - stk_classic::diag::TimeBlock _time(run_timer); - work(); - } - - stk_classic::diag::MetricTraits::Type lap_count = run_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == 200); - } - - // Create root object - RootObject root_object; - - { - stk_classic::diag::MetricTraits::Type lap_count = root_object.m_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == 0); - } - - // Create object - { - Object time_object("One object", root_object); - - for (int i = 0; i < 100; ++i) { - time_object.run(); - } - - stk_classic::diag::MetricTraits::Type lap_count = time_object.m_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == 100); - } - - // Create object tree - { - std::vector object_vector; - object_vector.push_back(Object("Object Tree", root_object)); - - int id = 0; - for (size_t i = 0; i < 2; ++i) { - size_t ix = object_vector.size(); - object_vector.push_back(Object(id++, object_vector[0])); - for (size_t j = 0; j < 2; ++j) { - size_t jx = object_vector.size(); - object_vector.push_back(Object(id++, object_vector[ix])); - for (int k = 0; k < 2; ++k) { - object_vector.push_back(Object(id++, object_vector[jx])); - } - } - } - - out() << "One object run 100 times" << std::endl; - - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - stk_classic::diag::MetricTraits::Type lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == stk_classic::diag::MetricTraits::Type(0)); - - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - out() << "Object tree run once" << std::endl; - - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == stk_classic::diag::MetricTraits::Type(object_vector.size())); - - for (size_t i = 1; i < 100; ++i) - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - out() << "Object tree 100 times (checkpointed)" << std::endl; - - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, true); - - lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - ThrowRequire(lap_count == stk_classic::diag::MetricTraits::Type(100*object_vector.size())); - - for (size_t i = 0; i < 100; ++i) - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - out() << "Object tree 100 more times (checkpointed)" << std::endl; - - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, true); - - out() << "Object tree (not checkpointed)" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - // Add a static function timer on odd processors - if (parallel_rank%2 == 1) { - static stk_classic::diag::Timer s_functionTimer("Odd processor function timer", TIMER_REGION, unitTestTimer()); - { - stk_classic::diag::TimeBlock _time(s_functionTimer); - work(); - } - if (parallel_rank%3 == 1) { - static stk_classic::diag::Timer s_functionTimer2("Odd processor function timer 2", TIMER_REGION, s_functionTimer); - { - stk_classic::diag::TimeBlock _time(s_functionTimer2); - work(); - } - } - } - - out() << "Add asymetric timers on odd processors, parallel collected output (checkpointed)" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, true); - - for (size_t i = 0; i < 100; ++i) - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - out() << "Object tree 100 more times, parallel collected output (checkpointed)" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, true, MPI_COMM_WORLD); - - out() << "Object tree, parallel collected output (not checkpointed)" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false, MPI_COMM_WORLD); - - stk_classic::diag::setTimerTimeFormat(stk_classic::TIMEFORMAT_SECONDS); - - out() << "Object tree, parallel collected output (not checkpointed), seconds" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false, MPI_COMM_WORLD); - - stk_classic::diag::setTimerTimeFormat(stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS); - - out() << "Object tree, parallel collected output (not checkpointed), seconds and milliseconds" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false, MPI_COMM_WORLD); - - stk_classic::diag::setTimerTimeFormat(stk_classic::TIMEFORMAT_HMS); - - out() << "Object tree, parallel collected output (not checkpointed), hh:mm:ss" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false, MPI_COMM_WORLD); - - stk_classic::diag::setTimerTimeFormat(stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS); - - out() << "Object tree, parallel collected output (not checkpointed), hh:mm:ss.mmm" << std::endl; - stk_classic::diag::printTimersTable(out(), unitTestTimer(), stk_classic::diag::METRICS_ALL, false, MPI_COMM_WORLD); - } - - return 0; -} diff --git a/packages/stk/stk_classic/stk_usecases/util/UtilUseCaseMain.cpp b/packages/stk/stk_classic/stk_usecases/util/UtilUseCaseMain.cpp deleted file mode 100644 index 99d6e74de518..000000000000 --- a/packages/stk/stk_classic/stk_usecases/util/UtilUseCaseMain.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -int use_case_message(use_case::UseCaseEnvironment &use_case_environment); -int use_case_timer(use_case::UseCaseEnvironment &use_case_environment); - -int -main( - int argc, - char ** argv) -{ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); - - use_case_message(use_case_environment); - use_case_timer(use_case_environment); -} diff --git a/packages/stk/stk_classic/stk_util/CMakeLists.txt b/packages/stk/stk_classic/stk_util/CMakeLists.txt deleted file mode 100644 index 82c349012262..000000000000 --- a/packages/stk/stk_classic/stk_util/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -ADD_SUBDIRECTORY(stk_util) - -#IF ( ${PACKAGE_NAME}_ENABLE_BoostLib ) -# TRIBITS_ADD_TEST_DIRECTORIES(unit_tests) -#ENDIF() - diff --git a/packages/stk/stk_classic/stk_util/doc/Doxyfile b/packages/stk/stk_classic/stk_util/doc/Doxyfile deleted file mode 120000 index 0904f0469caa..000000000000 --- a/packages/stk/stk_classic/stk_util/doc/Doxyfile +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_util/doc/Doxyfile.common.config b/packages/stk/stk_classic/stk_util/doc/Doxyfile.common.config deleted file mode 120000 index c8b1a5865860..000000000000 --- a/packages/stk/stk_classic/stk_util/doc/Doxyfile.common.config +++ /dev/null @@ -1 +0,0 @@ -../../doc/Doxyfile.common.config \ No newline at end of file diff --git a/packages/stk/stk_classic/stk_util/doc/Doxyfile.input b/packages/stk/stk_classic/stk_util/doc/Doxyfile.input deleted file mode 100644 index 072e54210dfb..000000000000 --- a/packages/stk/stk_classic/stk_util/doc/Doxyfile.input +++ /dev/null @@ -1,28 +0,0 @@ -#BANNER @copydoc stk_util_banner -#HOWTO @copydoc stk_util_howto - -# Note, any path you set here will have to be set twice; once for when doxygen -# is run from this directory, and once for when doxygen is run from the -# TPLs_src/Trilinos/packages/stk/doc directory. - -# Put local appends here! Note: Please only put append-type changes -# (IE, VAR += CHANGE) in this section. All the STK products must -# use the same configuration because, when doxygen is run from stk/doc -# to assemble HTML for the entire STK, any configuration overrides -# that happened here would affect the html generation for ALL the -# STK products. - -INPUT += ../stk_util/doc/index.dox \ - ../stk_util/stk_util \ - ../stk_util/stk_util/parallel \ - ../stk_util/stk_util/util \ - ../stk_util/stk_util/environment \ - ../stk_util/stk_util/diag - -# These were the variables that were being overwritten in the prior -# implementation. We'll keep these around in case we change to an -# implementation that supports unique configurations for each -# STK product. - -#ENUM_VALUES_PER_LINE = 4 -#PROJECT_NAME = "Sierra Toolkit Utilities" diff --git a/packages/stk/stk_classic/stk_util/doc/index.dox b/packages/stk/stk_classic/stk_util/doc/index.dox deleted file mode 100644 index df05d00cb537..000000000000 --- a/packages/stk/stk_classic/stk_util/doc/index.dox +++ /dev/null @@ -1,125 +0,0 @@ - -/** @brief Sierra Toolkit */ -namespace stk_classic { -}//namespace stk_classic - -/** - * - * \page stk_util_banner Sierra Toolkit Utilities - * - * \ref stk_util_module "Sierra Toolkit Utilities" - * - * The Sierra Toolkit Utility product provides many low level functions and classes which support - * the development of parallel applications. - * - * \addtogroup stk_util_module Sierra Toolkit Utilities Product - * - * The Sierra Toolkit Utility product provides many low level functions and classes which support - * the development of parallel applications. The utility product is divided into subdirectories - * and are included as - * - * \code - * #include - * \endcode - * - * where directory is one of the following: - * - *
    - *
  • \ref stk_util_environment_module "environment" - * - * functions and classes that support parallel output logging, - * product version reporting, and program command line option parsing - * - *
  • \ref stk_util_diagnostics_module "diag" - * - * functions and classes that support diagnostic output, traceback and runtime timing and metrics - * - *
  • \ref stk_util_parallel_module "parallel" - * - * functions and classes to enhance and simplify the usage of MPI. - * - *
  • \ref stk_util_module "util" - * - * functions and classes that are too broad and general to be located in a more identifying - * location and include typing checkin and conversion templates, stream buffers, and case - * insensitivy functions and classes. - * - *
- * - * Utilities How To ... - * - * \page stk_util_howto Utilities How To ... - * @ingroup stk_util_module - * - * Sierra Tookit Utilities - * - * - Sierra issues - * - \ref stk_util_output_log_howto_use_in_sierra_app "Control output logging from sierra command line"
- * - * - Output Streams - * - \ref stk_util_output_log_howto_register_streams "Register output and log streams"
- * - \ref stk_util_output_log_howto_bind_streams "Bind log streams to output streams"
- * - \ref stk_util_log_control_howto_control_output "Toggle log output based on step or other rule"
- * - * - Runtime Warnings and Errors - * - \ref stk_util_runtime_message_howto_assembly "Assemble warning and error messages"
- * - \ref stk_util_runtime_message_howto_symmetric "Write warnings and errors that always occurs on all processors (Symmetric Warning and Errors)"
- * - \ref stk_util_runtime_message_howto_deferred "Write warnings and errors that occur in an MPI unsafe location and must be deferred (Deferred Warnings and Errors)"
- * - \ref stk_util_runtime_message_howto_adhoc "Write adhoc warnings or errors (deprecated)"
- * - \ref stk_util_runtime_message_howto_throttle "Throttling the display of messages"
- * - * - User/Developer Runtime Selectable Diagnostic Messages (Diagnostic Writers) - * - \ref stk_util_diag_writer_howto_add_to_app "Add diagnostic writer to your application"
- * - \ref stk_util_diag_writer_howto_assign_new_log_bits "Adding additional LOG_mask"
- * - \ref stk_util_diag_writer_howto_add_dump_to_my_class "Adding diagnostic output to your classes"
- * - \ref stk_util_diag_writer_howto_add_dump_to_external_class "Adding diagnostic output to library classes"
- * - \ref stk_util_diag_writer_howto_write_messages "Writing to the appout writer"
- * - \ref stk_util_diag_writer_howto_throw_safe "Maintain indentation thru exception throws"
- * - * - User/Developer Runtime Selectable Timers (Diagnostic Timers) - * - \ref stk_util_diag_timer_howto_add_to_class "Add a timer to a class"
- * - \ref stk_util_diag_timer_howto_add_to_function "Add a timer to a function"
- * - \ref stk_util_diag_timer_howto_stop_watch "Using the diagnostic timers for examining execution times"
- * - * - Others - * - \ref stk_util_bootstrap_howto_bootstrap "Register a bootstrap function"
- * - * \defgroup stk_util_module_detail Sierra Toolkit Utilities - * @{ - * - * \defgroup stk_util_environment_module Run-time Environment - * - * The runtime environment include classes and function for MPI - * - * initialize/finalize, thread library initialize/finalize, command line handling, time and - * memory measurement functions, and signal management/handling. Possibly includes parallel - * exception handling and unified error, warning, and other diagnostic information reporting. - * - * @{ - * \defgroup stk_util_command_line_options_detail Command Line Options - * \defgroup stk_util_output_log_detail Output Logging - * \defgroup stk_util_log_control_detail Toggling Log Output - * \defgroup stk_util_runtime_message_detail Runtime Message Reporting, Warnings and Dooms (Errors) - * \defgroup - * @} - * - * \defgroup stk_util_diagnostics_module Runtime Diagnostics and Timers - * @{ - * \defgroup stk_util_diag_writer_detail User/Developer Runtime Selectable Diagnostic Messages - * \defgroup stk_util_diag_timer_detail User/Developer Runtime Selectable Timers and Metrics - * \defgroup - * @} - * - * \defgroup stk_util_parallel_module Parallel Services - * - * \defgroup stk_util_discrete_module Finite Element Topologies - * - * \defgroup stk_util_other_module Utilities - * @{ - * \defgroup stk_util_bootstrap_detail Bootstrapping - * \defgroup stk_util_cistring_detail Case Insensitive Template, Functions and Classes - * \defgroup - * @} - * - * @} - */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/CMakeLists.txt deleted file mode 100644 index 4a91d34e2b4b..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ - -ADD_SUBDIRECTORY(util) -ADD_SUBDIRECTORY(environment) -ADD_SUBDIRECTORY(diag) -ADD_SUBDIRECTORY(parallel) - -IF ( ${PACKAGE_NAME}_ENABLE_SEACASIoss ) - ADD_SUBDIRECTORY(unit_test_support) -ENDIF() - - -IF ( ${PACKAGE_NAME}_ENABLE_BoostLib ) - ADD_SUBDIRECTORY(use_cases) -ENDIF() - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -INSTALL(FILES stk_config.h DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/STKClassic_config.h DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}) diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/diag/CMakeLists.txt deleted file mode 100644 index 2c0dea4ee7e8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -FArray.hpp -PrintTimer.hpp -Timer.hpp -Trace.hpp -TimerMetricTraits.hpp -WriterExt.hpp -Writer_fwd.hpp -Writer.hpp -WriterManip.hpp -WriterOStream.hpp -WriterParser.hpp -Platform.hpp -Env.hpp -Option.hpp -Mapv.hpp -PrintTable.hpp -SlibDiagWriter.hpp -String.hpp -StringUtil.hpp -WriterRegistry.hpp - ) - -APPEND_SET(SOURCES -PrintTimer.cpp -Timer.cpp -Trace.cpp -TimerMetricTraits.cpp -Writer.cpp -WriterExt.cpp -WriterManip.cpp -WriterParser.cpp -Platform.cpp -Option.cpp -PrintTable.cpp -SlibDiagWriter.cpp -String.cpp -WriterRegistry.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_diag - DEPLIBS stkclassic_util_env - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/diag/) - diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Env.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Env.cpp deleted file mode 100644 index 1988817e7182..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Env.cpp +++ /dev/null @@ -1,1199 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2001 - 2010 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace sierra { -namespace Env { - -namespace { - -void bootstrap() -{ - // Add my command line options to the option descriptions. - boost::program_options::options_description desc("Runtime environment", 120); - desc.add_options() - ("help,h", "Display command line options") - ("directory,d", boost::program_options::value()->default_value("./"), "Set working directory") - ("output-log,o", boost::program_options::value()->default_value(""), "Output log file path, one of : 'cout', 'cerr', or a file path") - ("logfile,l", boost::program_options::value()->default_value(""), "Output log file path, one of : 'cout', 'cerr', or a file path") - ("pout", boost::program_options::value()->implicit_value("-"), "Per-processor log file path") - ("dout", boost::program_options::value()->implicit_value("out"), "Diagnostic output stream one of: 'cout', 'cerr', 'out' or a file path") -// ("timer", boost::program_options::value(), "Wall and CPU time options") // , &Diag::Timer::theTimerParser()) - ("version", "Display version information") - ("jamsub", boost::program_options::value(), "Display user subroutine build command") - ("runtest", boost::program_options::value()->implicit_value("pid"), "Record process host and pid to this file") - ("developer-mode", "Activate developer specific features") - ("architecture", boost::program_options::value(), "Specifies the architecture running the sierra application"); - - stk_classic::get_options_description().add(desc); -} - -stk_classic::Bootstrap x(&bootstrap); - -struct EnvData -{ - typedef std::map ExecMap; - - static EnvData &instance() { - static EnvData s_env; - - return s_env; - } - - EnvData() - : m_productName("not specified"), - m_vm(stk_classic::get_variables_map()), - m_nullBuf(), - m_outputNull(&m_nullBuf), - m_outputP0(&std::cout), - m_output(), - m_startTime((double) ::time(NULL)), - m_executablePath(), - m_shutdownRequested(false), - m_inputFileRequired(true), - m_checkSubCycle(false), - m_worldComm(MPI_COMM_NULL), - m_parallelComm(MPI_COMM_NULL), - m_parallelSize(-1), - m_parallelRank(-1), - m_emptyString(), - m_onString(PARAM_ON), - m_inputFile("") - { - m_execMap[EXEC_TYPE_LAG].m_master = -1; - m_execMap[EXEC_TYPE_LAG].m_groupComm = MPI_COMM_NULL; - m_execMap[EXEC_TYPE_LAG].m_interComm = MPI_COMM_NULL; - m_execMap[EXEC_TYPE_FLUID].m_master = -1; - m_execMap[EXEC_TYPE_FLUID].m_groupComm = MPI_COMM_NULL; - m_execMap[EXEC_TYPE_FLUID].m_interComm = MPI_COMM_NULL; - stk_classic::register_log_ostream(std::cout, "cout"); - stk_classic::register_log_ostream(std::cerr, "cerr"); - - stk_classic::register_ostream(sierra::out(), "out"); - stk_classic::register_ostream(sierra::pout(), "pout"); - stk_classic::register_ostream(sierra::dout(), "dout"); - stk_classic::register_ostream(sierra::tout(), "tout"); - - static_cast(sierra::dwout().rdbuf())->redirect(sierra::dout().rdbuf()); - } - - ~EnvData() - { - static_cast(sierra::dwout().rdbuf())->redirect(std::cout.rdbuf()); - - stk_classic::unregister_ostream(tout()); - stk_classic::unregister_ostream(dout()); - stk_classic::unregister_ostream(pout()); - stk_classic::unregister_ostream(out()); - - stk_classic::unregister_log_ostream(std::cerr); - stk_classic::unregister_log_ostream(std::cout); - } - - std::string m_productName; - - boost::program_options::variables_map & m_vm; - - null_streambuf m_nullBuf; - std::ostream m_outputNull; - std::ostream * m_outputP0; - std::ostringstream m_output; - - double m_startTime; - std::string m_executablePath; - - bool m_shutdownRequested; - bool m_inputFileRequired; - bool m_checkSubCycle; - - MPI_Comm m_worldComm; - - MPI_Comm m_parallelComm; - int m_parallelSize; - int m_parallelRank; - - ExecMap m_execMap; - - const std::string m_emptyString; - const std::string m_onString; - - std::string m_inputFile; -}; - -} // namespace - -const std::string & -product_name() -{ - return EnvData::instance().m_productName; -} - - -const std::string & -executable_file() -{ - return EnvData::instance().m_executablePath; -} - - -const std::string & -executable_date() -{ - static std::string executable_date; - - if (executable_date.empty()) - executable_date = ProductRegistry::instance().getProductAttribute(EnvData::instance().m_productName, ProductRegistry::BUILD_TIME); - - return executable_date; -} - - -const std::string & -startup_date() -{ - static std::string startup_date; - - if (startup_date.empty()) - startup_date = format_time(EnvData::instance().m_startTime).c_str(); - - return startup_date; -} - - -double -start_time() -{ - return EnvData::instance().m_startTime; -} - - -bool -developer_mode() -{ - return !get_param("developer-mode").empty(); -} - - -void setInputFileName(std::string name) { - EnvData::instance().m_inputFile = name; -} - -std::string getInputFileName() { - return EnvData::instance().m_inputFile; -} - -void set_input_file_required(bool value) -{ - EnvData::instance().m_inputFileRequired = value; -} - -void set_check_subcycle(bool value) -{ - EnvData::instance().m_checkSubCycle = value; -} - - -const std::string & -architecture() -{ - return get_param("architecture"); -} - - -const std::string -working_directory() { - char cwd[PATH_MAX]; - std::string directory = get_param("directory"); - if (directory[0] != '/' && getcwd(cwd, PATH_MAX) != NULL) { - directory = cwd; - directory += '/'; - } - return directory; -} - - -std::ostream & -output() -{ - return EnvData::instance().m_output; -} - - -std::ostream & -outputP0() -{ - return *EnvData::instance().m_outputP0; -} - - -std::ostream & -outputNull() { - return EnvData::instance().m_outputNull; -} - - -const char * -section_separator() -{ - static const char *s_sectionSeparator = "+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----"; - - return s_sectionSeparator; -} - - -const char * -subsection_separator() -{ - static const char *s_subsectionSeparator = "---------------------------------------------------"; - - return s_subsectionSeparator; -} - - -std::string -section_title( - const std::string & title) -{ - static size_t s_sectionSeparatorLength = std::strlen(section_separator()); - - std::ostringstream strout; - - strout << std::left << std::setw(s_sectionSeparatorLength - 20) << title << std::right << std::setw(20) << format_time(Env::wall_now()); - return strout.str(); -} - - -int parallel_size() { - return EnvData::instance().m_parallelSize; -} - -int parallel_rank() { - return EnvData::instance().m_parallelRank; -} - -MPI_Comm -parallel_comm() -{ - return EnvData::instance().m_parallelComm; -} - -MPI_Comm -parallel_world_comm() -{ - return EnvData::instance().m_worldComm; -} - -int parallel_lag_master() { - return EnvData::instance().m_execMap[EXEC_TYPE_LAG].m_master; -} - -int parallel_fluid_master() { - return EnvData::instance().m_execMap[EXEC_TYPE_FLUID].m_master; -} - -int peer_group() { - return EnvData::instance().m_execMap[EXEC_TYPE_PEER].m_master; -} - -std::string -get_program_path(const char *program) -{ - // If we already have the full path, just return it - if (program[0] == '/') - return program; - - char full_path[PATH_MAX]; - if (strchr(program, '/') != NULL) { - realpath(program, full_path); - return full_path; - } - - char *PATH = getenv("PATH"); - while (PATH && *PATH) { - // Get the character past the end of the next directory in PATH, i.e. - // either the '/' or the '\0' - char *end = strchr(PATH, ':'); - if (!end) { - end = PATH+strlen(PATH); - } - - // Set current = directory + '/' + program - strncpy(full_path, PATH, end-PATH); - full_path[end-PATH] = '/'; - strcpy(&full_path[end-PATH+1], program); - - // Check whether possible exists - if (access(full_path, X_OK) == 0) - return full_path; - - // Advance to the next directory - PATH = *end ? end+1 : end; - } - - // Not found; this shouldn't happen, but maybe the executable got deleted - // after it was invoked before we got here -- or we have some crazy - // parallel machine where the executable is inaccessible on the compute - // nodes despite it somehow having been loaded. No big deal, just return - // the non-absolute path. - return program; -} - -void parse_options(MPI_Comm comm, int *argc, char ***argv); -void startup_multi_exec(MPI_Comm world_comm, ExecType my_executable_type, const std::vector *peer_sizes); - - - -bool StartupSierra(int * argc, - char *** argv, - const char * product_name, - const char * build_time, - ExecType mpi_key, - const std::vector *peer_sizes) { - bool returnValue = false; - - stk_classic::Bootstrap::bootstrap(); - - EnvData &env_data = EnvData::instance(); - - env_data.m_executablePath = get_program_path(*argv[0]); - env_data.m_productName = product_name; - - ProductRegistry::instance().setProductName(product_name); - - ProductRegistry::AttributeMap &product_attributes = ProductRegistry::instance().getProductAttributeMap(product_name); - product_attributes[ProductRegistry::BUILD_TIME] = build_time; - product_attributes[ProductRegistry::EXECUTABLE] = env_data.m_executablePath; - - // Add Utility runtime library to the product registry - sierra::register_product(); - - // Add mpih to the product registry - sierra::mpih::register_product(); - - // Add operating system information to the product registry. - ProductRegistry::AttributeMap &attr_map = ProductRegistry::instance().addProduct(osname().c_str()); - attr_map[ProductRegistry::VERSION] = osversion().c_str(); - - // Process the broadcast command line arguments - namespace opt = boost::program_options; - - opt::variables_map &vm = stk_classic::get_variables_map(); - opt::options_description &od = stk_classic::get_options_description(); - { - boost::program_options::options_description desc("Diagnostic writers", 120); - - for (Diag::WriterRegistry::iterator it = Diag::getWriterRegistry().begin(); it != Diag::getWriterRegistry().end(); ++it) { - std::ostringstream str; - str << "Diagnostic writer " << (*it).first << std::endl; - (*it).second.second->describe(str); - desc.add_options()((*it).first.c_str(), boost::program_options::value(), str.str().c_str()); - } - - std::ostringstream str; - str << "Wall and CPU time options" << std::endl; - Diag::theTimerParser().describe(str); - desc.add_options()("timer", boost::program_options::value(), str.str().c_str()); - - od.add(desc); - } - - for (int i = 0; i < *argc; ++i) { - const std::string s((*argv)[i]); - if (s == "-h" || s == "-help" || s == "--help") { - std::cout << std::endl - << "Sierra Usage: sierra " << lower(product_name) << " [sierra-options...] -O \"[" << lower(product_name) << "-options...]\"" << std::endl << std::endl -// << "Usage: (MPI run) " << env_data.m_executablePath << " [options...]" << std::endl - << "For example:" << std::endl - << "" << std::endl - << " sierra " << lower(product_name) << " -i input_deck.i -o sierra.log" << std::endl - << " This creates the normal output file sierra.log" << std::endl - << "" << std::endl - << " sierra " << lower(product_name) << " -i input_deck.i -o sierra.log -O \"--pout=pp.log\"" << std::endl - << " The per-processor output is written to pp.log.n.r for each rank, r, of n processors." << std::endl - << "" << std::endl - << " sierra " << lower(product_name) << " -i input_deck.i -o sierra.log -O \"--fmwkout=field,parameters\"" << std::endl - << " Enable the framework field and parameter diagnostics" << std::endl - << "" << std::endl - << " sierra " << lower(product_name) << " -i input_deck.i -o sierra.log -O \"--timer=all\"" << std::endl - << " Enable the all timers" << std::endl - << std::endl - << " For additional information see:" << std::endl - << " http://sierra-dev.sandia.gov/stk/group__stk__util__output__log__detail.html#stk_util_output_log_howto_use_in_sierra_app" << std::endl << std::endl - << product_name << " options are:" << std::endl - << stk_classic::get_options_description() << std::endl; - std::exit(0); - } - } - - for (int i = 0; i < *argc; ++i) { - const std::string s((*argv)[i]); - if (s == "-jamsub" || s == "--jamsub") { - const char *t = (*argv)[i + 1]; - const char **symbol = sierra::Plugin::Registry::getsym(t); - if (symbol) { - std::cout << *symbol << std::endl; - std::exit(0); - } - else - std::exit(1); - } - } - - try { - startup_preparallel_platform(); - - // Communicator has not been set, initialize MPI if not already initialized - int mpi_init_val = 0 ; - if ( MPI_SUCCESS != MPI_Initialized( &mpi_init_val ) ) { - throw RuntimeError() << "MPI_Initialized failed"; - } - - // Default startup communicator - MPI_Comm startup_mpi_comm = MPI_COMM_WORLD; - - // If we are initializing the comm, see if there are differing - // executables running. If there are, find our partition and the - // leads of the other partitions. - if ( mpi_init_val == 0 ) { - if ( MPI_SUCCESS != MPI_Init( argc , argv ) ) { - throw RuntimeError() << "MPI_Init failed"; - } - - returnValue = true ; - - if (mpi_key != EXEC_TYPE_WORLD) startup_multi_exec(startup_mpi_comm, mpi_key, peer_sizes); - } - - // Ready to reset the environment from NULL, we are the Lagrangian application at this point. - MPI_Comm new_comm = mpi_key != EXEC_TYPE_WORLD ? env_data.m_execMap[mpi_key].m_groupComm : MPI_COMM_WORLD; - reset(new_comm); - } - catch (const std::exception &x) { - std::cerr << "SIERRA execution failed during mpi initialization with the following exception:" << std::endl - << x.what() << std::endl; - MPI_Abort(env_data.m_parallelComm , MPI_ERR_OTHER); - } - catch (...) { - std::cerr << "SIERRA execution failed during mpi initialization with unknown exception:" << std::endl; - - MPI_Abort(env_data.m_parallelComm, MPI_ERR_OTHER); - } - - parse_options(env_data.m_parallelComm, argc, argv); - - { - std::ostringstream output_description; - - // On processor 0: - // [outfile=path] [poutfile=path.n.r] [doutfile=path.n.r] out>{-|cout|cerr|outfile}+pout pout>{null|poutfile} dout>{out|doutfile} - - // On processor 1..n: - // [poutfile=path.n.r] [doutfile=path.n.r] out>pout pout>{null|poutfile} dout>{out|doutfile} - - std::string out_path1 = vm["output-log"].as(); - std::string out_path2 = vm["logfile"].as(); - - - - std::string originalFileName = Env::get_param("input-deck"); - std::string modifiedFileName = originalFileName; - - if(originalFileName == "") { - // - // If no input file specified, error out (unless just running the --version or --help option) - // - if ( get_param("version").empty() && get_param("help").empty() ) { - if (env_data.m_inputFileRequired) { - throw RuntimeError() << "No input file specified. An input file must be specified with the '-i' option"; - } else { - std::cerr << "WARNING: No input file specified. An input file should be specified with the '-i' option!" << std::endl; - } - } - } else if ( env_data.m_checkSubCycle ) { - // Alter input-deck if subcycle present - bool debugSubCycleSplit = false; - std::string subCycleRegexp("^\\s*subcycle\\s+blocks\\s*="); - bool subCycleSet = CaseInSensitiveRegexInFile(subCycleRegexp, originalFileName, debugSubCycleSplit); - std::string coarseRegionRegexp("^\\s*begin\\s+presto\\s+region\\s+\\w+_AutoCoarseRegion\\>"); - bool coarseRegionMade = CaseInSensitiveRegexInFile( coarseRegionRegexp, originalFileName, debugSubCycleSplit); - std::string fineRegionRegexp("^\\s*begin\\s+presto\\s+region\\s+\\w+_AutoFineRegion\\>"); - bool fineRegionMade = CaseInSensitiveRegexInFile( fineRegionRegexp, originalFileName, debugSubCycleSplit); - if ( subCycleSet ) { - if ( !coarseRegionMade && !fineRegionMade ) { - modifiedFileName = CreateSubCycleInputFile( originalFileName ); - } else { - if(Env::parallel_rank() == 0) { - std::cout<<"Input File: " << originalFileName << " Appears to have already been converted for subcycling. "; - std::cout<<"Skipping input conversion " << std::endl; - } - } - } - } - - setInputFileName(modifiedFileName); - - - std::string trueOut; - if(out_path2 != "") { - trueOut = out_path2; - } else if(out_path1 != "") { - // - // Old syntax compatibility, access the old output-file executable option if the logfile is not defined - // - trueOut = out_path1; - } else { - // - // If log file name is unspecified, default it to (Base Input File Name).log - // Use the following logic: - // If the input file has an extension, replace the last ".extension" with ".log" - // If the input file has no extension, append ".log" to the input file name - // If the input file contains the word '.aprepro', assume aprepro was used to convert and strip out the aprepro - // If the input file contains any directory movement (like ../) strip them out so log file is written to current director - // - - int dotPos = originalFileName.rfind("."); - - if(dotPos == -1) { //No extension - trueOut = originalFileName + ".log"; - } else { //Extension found - trueOut = originalFileName.substr(0, dotPos) + ".log"; - } - // - // If the output path contains a ".aprepro" tag get rid of it - // - int apreproPos = trueOut.rfind(".aprepro"); - if(apreproPos != -1) { - trueOut.erase(apreproPos, 8); - } - // - // If the output path contains a "aaa/input.i" pull off the initial directory redirects so that the log file is written int the current directory - // - int lastSlashPos = trueOut.rfind("/"); - - if(lastSlashPos != -1) { - trueOut.erase(0,lastSlashPos+1); - } - - - } - - std::string out_path = trueOut; - - if (out_path == "-") - out_path = "cout"; - - std::string out_ostream; - - if (!stk_classic::get_log_ostream(out_path)) - if (out_path.size() && out_path[0] != '/') - out_path = working_directory() + out_path; - - if (parallel_rank() == 0) { - if (!stk_classic::get_log_ostream(out_path)) { - output_description << "outfile=\"" << out_path << "\""; - out_ostream = "outfile"; - } - else { - out_ostream = out_path; - } - } - else - out_ostream = "null"; - - std::string pout_ostream = "null"; - if (vm.count("pout")) { - std::string pout_path = vm["pout"].as(); - if (pout_path == "-") { - std::ostringstream s; - - if (stk_classic::get_log_ostream(out_path)) - s << working_directory() << "sierra.log." << parallel_size() << "." << parallel_rank(); - else - s << out_path << "." << parallel_size() << "." << parallel_rank(); - pout_path = s.str(); - } - else if (pout_path.find("/") == std::string::npos && !stk_classic::get_log_ostream(pout_path)) { - std::ostringstream s; - - s << working_directory() << pout_path << "." << parallel_size() << "." << parallel_rank(); - pout_path = s.str(); - } - - if (!stk_classic::get_log_ostream(pout_path)) { - output_description << " poutfile=\"" << pout_path << "\""; - pout_ostream = "poutfile"; - } - else - pout_ostream = pout_path; - } - - - std::string dout_ostream; - if (vm.count("dout")) { - std::string dout_path = vm["dout"].as(); - if (!dout_path.empty() && stk_classic::is_registered_ostream(dout_path)) - dout_ostream = dout_path; - else { - std::ostringstream s; - if (dout_path.size() && dout_path[0] != '/') - s << working_directory() << dout_path << "." << parallel_size() << "." << parallel_rank(); - else - s << dout_path << parallel_size() << "." << parallel_rank(); - dout_path = s.str(); - output_description << " doutfile=\"" << dout_path << "\""; - dout_ostream = "doutfile"; - } - } - else - dout_ostream = "out"; - - if (parallel_rank() == 0) - output_description << " out>" << out_ostream << "+pout"; - else - output_description << " out>pout"; - - output_description << " pout>" << pout_ostream << " dout>" << dout_ostream; - - - stk_classic::bind_output_streams(output_description.str()); - } - - env_data.m_outputP0 = &sierra::out(); - -#ifdef SIERRA_EXPORT_CONTROL_EAR99 - // If you are using an EAR99 export controlled version of Sierra, - // any attempt to modify or bypass this section of code is a - // violation of U.S. Export Control Regulations and subject to - // criminal prosecution. - if (parallel_size() > SIERRA_EXPORT_CONTROL_EAR99) { - if (parallel_rank() == 0) { - std::cerr << "ERROR: You are running an EAR99 export controlled version of\n"; - std::cerr << " Sierra. For this export control level, a maximum of\n"; - std::cerr << " "< *peer_sizes) { - m_mpiInitFlag = StartupSierra(argc, argv, product_name, build_time, mpi_key, peer_sizes); -} - - -Startup::Startup( - int * argc, - char *** argv, - const char * product_name, - const char * build_date_time, - ExecType mpi_key, - const std::vector *peer_sizes) - : m_mpiInitFlag(false) -{ - startup(argc, argv, product_name, build_date_time, mpi_key, peer_sizes); -} - - -void ShutDownSierra(bool mpiInitFlag) { - if (get_param("nosignal").empty()) - deactivate_signals(); - - mpih::Delete_Handles(); - - EnvData &env_data = EnvData::instance(); - mpih::Keyval_delete(env_data.m_parallelComm); - - reset(MPI_COMM_NULL); - - if (mpiInitFlag) - MPI_Finalize(); -} - - - -Startup::~Startup() { - ShutDownSierra(m_mpiInitFlag); -} - - -void parse_options(MPI_Comm comm, - int * argc, - char *** argv) -{ - try { - char ** argv2 = new char *[*argc]; - for (int i = 0; i < *argc; ++i) { - if (std::strlen((*argv)[i]) > 2 && (*argv)[i][0] == '-' && (*argv)[i][1] != '-') { - argv2[i] = new char[std::strlen((*argv)[i]) + 2]; - argv2[i][0] = '-'; - std::strcpy(&argv2[i][1], (*argv)[i]); - } - else { - argv2[i] = new char[std::strlen((*argv)[i]) + 1]; - std::strcpy(argv2[i], (*argv)[i]); - } - } - - // Broadcast argc and argv to all processors. - stk_classic::BroadcastArg b_arg(comm, *argc, argv2); - - for (int i = 0; i < *argc; ++i) - delete[] argv2[i]; - delete[] argv2; - - namespace opt = boost::program_options; - opt::variables_map &vm = stk_classic::get_variables_map(); - opt::options_description &od = stk_classic::get_options_description(); - opt::store(opt::parse_command_line(b_arg.m_argc, b_arg.m_argv, od, opt::command_line_style::unix_style), vm); - opt::notify(vm); - - for (Diag::WriterRegistry::iterator it = Diag::getWriterRegistry().begin(); it != Diag::getWriterRegistry().end(); ++it) - if (vm.count((*it).first.c_str())) - (*it).second.second->parse(vm[(*it).first.c_str()].as().c_str()); - - - // Must have a working directory - const std::string &working_dir = get_param("directory"); - if ( working_dir.empty() || working_dir == PARAM_ON ) - throw RuntimeError() << "working directory must be specified"; - if (working_dir[working_dir.length() - 1] != '/') - const_cast(working_dir) += '/'; - - } - catch (const std::exception &x) { - std::cerr << "SIERRA execution failed during command line processing with the following exception:" << std::endl - << x.what() << std::endl; - MPI_Abort(comm, MPI_ERR_OTHER); - } - catch (...) { - std::cerr << "SIERRA execution failed during command line processing with unknown exception:" << std::endl; - - MPI_Abort(comm, MPI_ERR_OTHER); - } -} - -void -startup_multi_exec(MPI_Comm world_comm, - ExecType my_executable_type, - const std::vector *peer_sizes) // can be NULL. -{ - EnvData &env_data = EnvData::instance(); - - // MPI interface construction - int world_size = -1 ; - int world_rank = -1 ; - - if ( MPI_Comm_size(world_comm, &world_size) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Comm_size failed"; - - if ( MPI_Comm_rank(world_comm, &world_rank) != MPI_SUCCESS || -1 == world_rank ) - throw RuntimeError() << "MPI_Comm_rank failed"; - - if (my_executable_type == EXEC_TYPE_FLUID || my_executable_type == EXEC_TYPE_LAG) { - // This is specific for gemini. Gemini performs three broadcasts, one for the - // EXEC_TYPE_FLUID and one for the EXEC_TYPE_LAG. Also note that the ranks of processors must - // be ordered such that all gemini processors come first. Gemini mandates that it;s master is - // processor 0 and use ranks through its size. - int lag_master = 0; - int lag_rank_size = -1; - int fluid_master = 0; - - if (world_rank == 0) { - typedef std::map > ExecTypeRanks; - - ExecTypeRanks exec_type_ranks; - - exec_type_ranks[my_executable_type].push_back(0); - - for (int i = 1; i < world_size; ++i) { - MPI_Status status; - int proc_stat[2]; // rank, ExecType - if (MPI_Recv(proc_stat, 2, MPI_INTEGER, i, MPI_ANY_TAG, world_comm, &status) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Recv failed"; - - exec_type_ranks[(ExecType) proc_stat[1]].push_back(proc_stat[0]); - } - - std::vector &fluid_ranks = exec_type_ranks[EXEC_TYPE_FLUID]; - if (fluid_ranks.size()) - fluid_master = fluid_ranks.front(); - - if (MPI_Bcast(&fluid_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - - std::vector &lag_ranks = exec_type_ranks[EXEC_TYPE_LAG]; - if (lag_ranks.size()) - lag_master = lag_ranks.front(); - - if (MPI_Bcast(&lag_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - - lag_rank_size = lag_ranks.size(); - if (MPI_Bcast(&lag_rank_size, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - } - else { - int proc_stat[2]; - proc_stat[0] = world_rank; - proc_stat[1] = my_executable_type; - - if (MPI_Send(proc_stat, 2, MPI_INTEGER, 0, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Send failed"; - - if (MPI_Bcast(&fluid_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - - if (MPI_Bcast(&lag_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - - if (MPI_Bcast(&lag_rank_size, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Bcast failed"; - } - - MPI_Comm lag_comm = world_comm; - MPI_Comm fluid_comm = MPI_COMM_NULL; - const int fluid_rank_size = world_size - lag_rank_size; - if (fluid_rank_size) { - - MPI_Group world_group; - MPI_Group lag_group; - MPI_Group fluid_group; - - if (MPI_Comm_group(world_comm, &world_group) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Comm_group failed"; - - std::vector lag_ranks; - for (int i = 0; i < lag_rank_size; ++i) - lag_ranks.push_back(lag_master + i); - - if (MPI_Group_incl(world_group, lag_ranks.size(), &lag_ranks[0], &lag_group) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Group_incl failed"; - if (MPI_Comm_create(world_comm, lag_group, &lag_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Comm_create failed"; - - std::vector fluid_ranks; - for (int i = 0; i < fluid_rank_size; ++i) - fluid_ranks.push_back(fluid_master + i); - - if (MPI_Group_incl(world_group, fluid_ranks.size(), &fluid_ranks[0], &fluid_group) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Group_incl failed"; - if (MPI_Comm_create(world_comm, fluid_group, &fluid_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Comm_create failed"; - } - - env_data.m_worldComm = world_comm; - env_data.m_execMap[EXEC_TYPE_LAG].m_master = lag_master; - env_data.m_execMap[EXEC_TYPE_LAG].m_groupComm = lag_comm; - env_data.m_execMap[EXEC_TYPE_FLUID].m_master = fluid_master; - env_data.m_execMap[EXEC_TYPE_FLUID].m_groupComm = fluid_comm; - } - else if (my_executable_type == EXEC_TYPE_PEER) { - // This executable will run on 2 or more communicators. - - // NOTE: Only 2 communicators is currently supported... - - // If peer_sizes is NULL, then split world_comm into two equal - // size communicators (peer(1) is larger if world_comm size is - // odd) - // If peer_sizes is not NULL, then split world_comm into - // peer_sizes.size() sub communicators with peer(i) of size - // peer_sizes(i). - - // Sync 'peer_sizes' across all processors if non-null - // For now, we limit the number of peer applications to 2. - - if (peer_sizes != NULL && peer_sizes->size() > 2) { - throw RuntimeError() << "The total number of peer application processor sizes specfied is " - << peer_sizes->size() - << ", but the current limit is 2."; - } - - // Peer sizes is only set correctly on processor 0 since it was passed in by the - // main routine prior to MPI_Init being called. Broadcast the values to all processors. - int peers[2]; - if (world_rank == 0) { - if (peer_sizes != NULL) { - peers[0] = (*peer_sizes)[0]; - peers[1] = (*peer_sizes)[1]; - } else { - peers[0] = world_size / 2; - peers[1] = world_size - world_size/2; - } - } - if (MPI_Bcast(peers, 2, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS) - throw RuntimeError() << "MPI_Broadcast -- peers failed"; - - // Check that the number of processes specified is equal to the - // total number of processes - int peer_proc_count = peers[0] + peers[1]; - if (peer_proc_count != world_size) { - throw RuntimeError() << "The total number of peer processors specfied is " << peer_proc_count - << " which is not equal to the total number of processors (" << world_size << ")."; - } - - int my_peer_group = MPI_UNDEFINED; - int sum = 0; - for (size_t i=0; i < 2; i++) { - sum += peers[i]; - if (world_rank < sum) { - my_peer_group = i; - break; - } - } - - MPI_Comm peer_comm; - if (MPI_Comm_split(world_comm, my_peer_group, world_rank, &peer_comm) != MPI_SUCCESS) { - throw RuntimeError() << "MPI_Comm_split failed"; - } - env_data.m_worldComm = world_comm; - env_data.m_execMap[EXEC_TYPE_PEER].m_groupComm = peer_comm; - env_data.m_execMap[EXEC_TYPE_PEER].m_master = my_peer_group; // Overloading meaning to peer group. - } -} - -bool -is_comm_valid() -{ - EnvData &env_data = EnvData::instance(); - if (env_data.m_parallelComm == MPI_COMM_NULL) { - return false; - } else { - return true; - } -} - -void -reset( - MPI_Comm new_comm) -{ - EnvData &env_data = EnvData::instance(); - - // Destroy old comm - if (env_data.m_parallelComm != MPI_COMM_NULL) { - - if (new_comm != MPI_COMM_NULL) { - mpih::Sub_Communicator(env_data.m_parallelComm, new_comm); - } - - env_data.m_parallelComm = MPI_COMM_NULL ; - env_data.m_parallelSize = -1; - env_data.m_parallelRank = -1 ; - } - - setMpiCommunicator(new_comm); -} - -void setMpiCommunicator(MPI_Comm communicator) -{ - EnvData &env_data = EnvData::instance(); - if(communicator != MPI_COMM_NULL) - { - env_data.m_parallelComm = communicator; - - if(MPI_Comm_size(env_data.m_parallelComm, &env_data.m_parallelSize) != MPI_SUCCESS - || MPI_Comm_rank(env_data.m_parallelComm, &env_data.m_parallelRank) != MPI_SUCCESS - || env_data.m_parallelSize == -1 - || env_data.m_parallelRank == -1) - { - throw RuntimeError() << "reset given bad MPI communicator"; - } - } -} - -void -output_flush() -{ - EnvData &env_data = EnvData::instance(); - - stk_classic::report_deferred_messages(Env::parallel_comm()); - - stk_classic::all_write_string(Env::parallel_comm(), *env_data.m_outputP0, env_data.m_output.str()); - env_data.m_output.str(""); -} - - -void -request_shutdown(bool shutdown) -{ - EnvData::instance().m_shutdownRequested = shutdown; -} - - -bool -is_shutdown_requested() -{ - int shutdown_requested_in = EnvData::instance().m_shutdownRequested || Env::HUP_received(); - int shutdown_requested; - - MPI_Allreduce(&shutdown_requested_in, &shutdown_requested, 1, MPI_INT, MPI_SUM, Env::parallel_comm()); - - return shutdown_requested != 0; -} - - -void abort() { - EnvData &env_data = EnvData::instance(); - - // Cannot be sure of parallel synchronization status; therefore, no communications can - // occur. Grab and dump all pending output buffers to 'std::cerr'. - std::cerr << std::endl - << "*** SIERRA ABORT on P" << EnvData::instance().m_parallelRank << " ***" - << std::endl - << "*** check " << get_param("output-log") - << " file for more information ***" - << std::endl ; - - if (!env_data.m_output.str().empty()) { - std::cerr << "Buffer contents of deferred output stream on processor " << parallel_rank() - << std::endl ; - std::cerr << env_data.m_output.str(); - } - - std::cerr.flush(); - std::cout.flush(); - - ::sleep(1); // Give the other processors a chance at - // catching up, seems to help hanging problems. - MPI_Abort(env_data.m_parallelComm, MPI_ERR_OTHER); // First try to die - std::exit( EXIT_FAILURE ); // Second try to die -} - - -const std::string & -get_param( - const char * const option) -{ - if (EnvData::instance().m_vm.count(option)) { - if (EnvData::instance().m_vm[option].as().empty()) - return EnvData::instance().m_onString; - else - return EnvData::instance().m_vm[option].as(); - } - else - return EnvData::instance().m_emptyString; -} - - -void -set_param( - const char * option, - const std::string & value) { - - - namespace opt = boost::program_options; - - opt::variables_map &vm = stk_classic::get_variables_map(); - opt::options_description &od = stk_classic::get_options_description(); - - int argc = 1; - char *s = std::strcpy(new char[std::strlen(option) + 1], option); - - opt::store(opt::parse_command_line(argc, &s, od), vm); - opt::notify(vm); - - delete [] s; -} - -} // namespace Env -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Env.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Env.hpp deleted file mode 100644 index 5a41708a92ff..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Env.hpp +++ /dev/null @@ -1,601 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 - 2010 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_Env_h -#define STK_UTIL_DIAG_Env_h - -#include // #include // ios_base is not defined in the forward file -#include - -#include -#if defined( STK_HAS_MPI ) -#include -#endif -#include - -#include -#include - -#include -#include -#include - -namespace sierra { - -/// @brief Namespace Env contains the runtime environment bootstrap for the -/// MPI, logging, command line argument parsing, runtime information and signal handling. -/// -///

MPI Initialization

-/// -///

Output Log File

-/// -///

Command Line Options

-/// -///

Runtime Information

-/// -///

Signals and Long Jump

-/// -namespace Env { - -static const std::string PARAM_ON = "on"; ///< Option value when command line option specified without a parameter - -/// -/// @addtogroup EnvDetail -/// @{ -/// - -/** - * @brief Enumeration ExecutableType defines the known types of coordinated executables that operate - * with a sierra application. Unfortunately, this scheme for coordination is currently defined by - * Gemini whose implementation forces a limit of two executables, namely it and a fluid code. The - * startup_multi_exec() function handles the creation of groups which are contiguous processor - * groups, each with lead processor being the least ranked processor in the group. - * - * Modification of the startup_multi_exec() function would need to be made to enable more than the - * two executable types. - */ -enum ExecType { - EXEC_TYPE_WORLD = 0, ///< Generic application using entire communicator (MPI_COMM_WORLD) - EXEC_TYPE_FLUID = 1, ///< Gemini Euler application - EXEC_TYPE_LAG = 2, ///< Sierra Lagrangian application - EXEC_TYPE_PEER = 3 ///< Split communicator application; non-Gemini -}; - -struct ExecInfo -{ - MPI_Comm m_groupComm; - int m_master; -}; - - - - /** - * @brief Initialize MPI related operations for sierra, outputs banner, etc. - * returns 1 if MPI was initialized, 0 otherwise - * - * @param argc an int pointer to the main argc. - * - * @param argv a char pointer to the main argv. - * - * @param product_name a char const pointer to the name of the - * product. - * - * @param build_date_time a char const pointer to - * __DATE__ " " __TIME__ - * - * @param mpi_key an optional ExecType enumeration - * specifying the type of executable. - * Default is a single executable using - * MPI_COMM_WORLD. Other options result - * in a split communicator. - * - * @param peer_sizes an optional std::vector - * const pointer containing the number of - * processors that each peer communicator - * (\sa parrallel_peer_comm()) will - * support. The number of peers is - * determined by the size of the vector. - * Only used if mpi_key = EXEC_TYPE_PEER - */ - bool StartupSierra(int *argc, char ***argv, const char *product_name, const char *build_date_time, - ExecType mpi_key = EXEC_TYPE_WORLD, const std::vector *peer_sizes = NULL); - - // - // Cleanup any MPI stuff that was created from the startup sierra call, pass in the MPI initialization flag - // that StartupSierra generated - // - void ShutDownSierra(bool mpiInitFlag); - - -/** - * @ingroup EnvMPIDetail EnvOutputDetail EnvCommandLineDetail - * @brief Class Startup is a sentry class for starting the application. It - * ensures that the command line arguments, platform and MPI are ready to go at the start - * of the application. - * - */ -class Startup -{ -public: - - /** - * @brief Creates a new Startup instance. - * - * @param argc an int pointer to the main argc. - * - * @param argv a char pointer to the main argv. - * - * @param product_name a char const pointer to the name of the - * product. - * - * @param build_date_time a char const pointer to - * __DATE__ " " __TIME__ - * - * @param mpi_key an optional ExecType enumeration - * specifying the type of executable. - * Default is a single executable using - * MPI_COMM_WORLD. Other options result - * in a split communicator. - * - * @param peer_sizes an optional std::vector - * const pointer containing the number of - * processors that each peer communicator - * (\sa parrallel_peer_comm()) will - * support. The number of peers is - * determined by the size of the vector. - * Only used if mpi_key = EXEC_TYPE_PEER - */ - Startup(int *argc, char ***argv, const char *product_name, const char *build_date_time, - ExecType mpi_key = EXEC_TYPE_WORLD, const std::vector *peer_sizes = NULL); - - /** - * @brief Destroys a Startup instance. IT closes all logging output streams and - * will finalize MPI only if the Startup::Startup initialized the MPI. - * - */ - ~Startup(); - -private: - /** - * @brief Member function startup - * @li initializes MPI if not already initialized, - * @li queries the environment and command line for environment options, - * @li broadcasts the environment options from MPI_COMM_WORLD processor #0 to all other - * processors, - * @li opens the default parallel output stream. - * - * @param argc an int pointer to the main argc. - * - * @param argv a char pointer to the main argv. - * - * @param product_name a char const pointer to the name of the - * product. - * - * @param build_time a char const pointer to __DATE__ " " __TIME__ - * - * @param exec_options an OptionMap const reference to additional - * options available for the command line/environment. - * - */ - void startup(int *argc, char ***argv, const char *product_name, const char *build_time, - ExecType mpi_key, const std::vector *peer_sizes); - -private: - bool m_mpiInitFlag; ///< True if Startup initialized MPI -}; - - -/** - * @ingroup EnvMPIDetail - * @brief Function reset determines new parallel_size and parallel_rank. - * Flushes, closes, and reopens log files. - * - * This is a very dangerous method, if the previous communicator had been queried and - * given to an external library then Sierra and that external library will be out-of-sync. - * It is strongly recommended that parser-interface singletons do not query and save the - * communicator. - * - * This capability is provided to support dakota. - * - * @param mpi_comm a MPI_Comm value for the new mpi - * communicator. - * - * @param work_dir a char const pointer to the new working - * directory. - * - */ -void reset(MPI_Comm mpi_comm); // , const char * const work_dir = NULL); -void setMpiCommunicator(MPI_Comm communicator); -bool is_comm_valid(); - - -/** - * @ingroup EnvCommandLineDetail - * @brief Function query_env_param searches the command line options for the - * specified option. If not found, a const reference to an empty string is returned. - * - * @param option a char const pointer to the option to - * search for. - * - * @return a std::string const reference to the options value - * or an empty string if not found. - */ -const std::string &get_param(const char * const option); - - -/** - * @brief Member function set_param assigns the value to the parameter option. - * - * @param option a char const pointer to the option to - * search for. - * - * @param value a char const pointer to the value to assign to the - * param. - * - */ -void set_param(const char *option, const std::string &value); - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function product_name returns the product's name. This name is - * used to query the product registry for information concerning this product. - * - * @return a std::string const reference to the product's name. - */ -const std::string &product_name(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function developer_mode returns true if the - * --developer option was specified on the application command line. - * - * @return a std::string const reference to the applications - * operating platform string. - */ -bool developer_mode(); - -/** - * @brief Function set_input_file_required sets whether lack of an input - * file specification will automatically cause failure. The default behavior - * corresponds to true. - */ -void set_input_file_required(bool value); - -void setInputFileName(std::string value); -std::string getInputFileName(); - - -/** - * @brief Function set_check_subcycle sets whether to check input - * file for subcycling. The default behavior corresponds to false. - */ -void set_check_subcycle(bool value); - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function architecture returns the platform executing this product. - * This is obtained during startup by searching for a file which contains this - * information. - * - * @return a std::string const reference to the applications - * operating platform string. - */ -const std::string &architecture(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function executable_file returns the path of this executable file. - * information. - * - * @return a std::string const reference to the executable - * file path string. - */ -const std::string &executable_file(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function executable_date returns the build date of the executable - * file as a string in the form Mmm dd yyyy hh:mm::ss. - * - * @return a std::string const reference to the executable - * file's build date and time. - */ -const std::string &executable_date(); - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function startup_date returns the startup date of this application - * execution. - * - * @return a std::string const reference to the application - * execution start date and time. - */ -const std::string &startup_date(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function start_time returns the start time of this application - * execution. - * - * @return a double value of the application execution - * start time. - */ -double start_time(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Member function wall_now returns the epoch as a double precision - * value in seconds to "millisecond" accuracy. - * - * @return a double ... - */ -double wall_now(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Member function cpu_now returns the accumlated cpu time for the - * process as a double precision value in seconds to "millisecond" accuracy. - * - * @return a double ... - */ -double cpu_now(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Member function vm_now returns the virtual memory in use for the - * process as a double precision value in bytes. - * - * @return a double value of the number of bytes of virtual - * memory currently in use. - */ -double vm_now(); - - -/** - * @ingroup EnvRuntimeInformationDetail, EnvOutputDetail - * @brief Function working_directory returns the current working directory of - * this application execution. - * - * @return a std::string to the application - * execution working directory. - */ -const std::string working_directory(); - - -/** - * @ingroup EnvOutputDetail - * @brief Function output returns the processor output log stream. This - * stream is connected via an mpi_filebuf to processor 0. Upon - * output_flush() the output from all processors is collected on processor 0 - * in a sequential by process and is logged to output file in a non-jumbled manner. - * - * @return a std::ostream reference to the application - * log stream. - */ -std::ostream &output(); - - -/** - * @ingroup EnvOutputDetail - * @brief Function outputP0 returns the processor output log stream on - * processor 0 and the null log stream on all other processors. - * - * @return a std::ostream reference to the application - * log stream on processor 0 or null stream on the - * processors. - */ -std::ostream &outputP0(); - - -/** - * @ingroup EnvOutputDetail - * @brief Function outputNull returns the null output stream. All data is - * simply discarded by the buffer associated with this stream. - * - * @return a std::ostream reference to the null output - * stream. - */ -std::ostream &outputNull(); - - -/** - * @ingroup EnvOutputDetail - * @brief Function output_open opens an output file on processor zero for - * synchronous data output from all processors via the mpi_filebuf class. - * The output is synchronized via the output_flush() function and maintain in - * the output stream list so that it is flushed and closed on application rundown. - * - * Must be executed concurrently on all processor in the current - * Env::parallel_comm() group. - * - * @param filename a char const pointer to the path of file to - * open. - * - * @return a std::ostream reference to the newly opened - * output stream. - */ -//std::ostream &output_open(const char * const filename); - - -/** - * @brief Function section_separator returns a c-style string to be used as a - * output section separator. - * - * @return a char const pointer to the section separator - * string. - */ -const char *section_separator(); - - -/** - * @brief Function subsection_separator returns a c-style string to be used as a - * output subsection separator. - * - * @return a char const pointer to the subsection separator - */ -const char *subsection_separator(); - - -/** - * @brief Function section_title returns a section title. The title has date and - * time concatenated and right justified to the length of the section_separator. - * The date and time is 20 characters wide, so adjust your titles accordingly. - * - * @param title a std::string const reference to the title string. - * - * @return a std::string value with the date and time right - * justified to section_separator's length. - */ -std::string section_title(const std::string &title); - - -/** - * @ingroup EnvOutputDetail - * @brief Function output_flush flushes all output on all currently open - * synchronous outptu files which were opened via output_open. - * - * Must be executed concurrently on all processor in the current - * Env::parallel_comm() group. - * - */ -void output_flush(); - - -/** - * @ingroup EnvOutputDetail - * @brief Function output_flush synchronously flushes stream - * which was created using an mpi_filebuf. - * - * Must be executed concurrently on all processor in the current - * Env::parallel_comm() group. - * - * @param stream a std::ostream reference to the synchronous - * output stream to flush. - */ -void output_flush(std::ostream &stream); - -void request_shutdown(bool shutdown = true); - -bool is_shutdown_requested(); - -/** - * @ingroup EnvRuntimeInformationDetail EnvMPIDetail EnvOutputDetail - * @brief Function abort aborts the execution of the sierra application. - * - */ -void abort(); - - -/** - * @brief Function parallel_comm returns the current MPI communicator used by - * the sierra environment. - * - * @return a MPI_Comm value of the current MPI - * communicator. - */ -MPI_Comm parallel_comm(); - -/** - * @brief Function parallel_world_comm returns the MPI_COMM_WORLD communicator used by - * the sierra environment in a MPMD parallel application. - * - * @return a MPI_Comm value of the current MPI_COMM_WORLD - * communicator. - */ -MPI_Comm parallel_world_comm(); - - -/** - * @brief Function peer_group returns the peer group rank for an application of type - * EXEC_TYPE_PEER. - * - * @return a int value of the peer group for the peer application. - */ -int peer_group(); - - -/** - * @brief Function parallel_lag_master returns the global rank of the Gemini Euler application. - * - * @return a int value of the global rank of the Gemini Euler - * application. - */ -int parallel_fluid_master(); - - -/** - * @brief Function parallel_lag_master returns the global rank of the Sierra lagrangian application. - * - * @return a int value of the global rank of the Sierra lagrangian - * application. - */ -int parallel_lag_master(); - - -/** - * @ingroup EnvMPIDetail - * @brief function parallel_size returns the number of processors - * in the current mpi communicator. - * - * @return an int value of the number of processors in - * the current mpi communicator. - */ -int parallel_size(); - - -/** - * @ingroup EnvMPIDetail - * @brief function parallel_rank returns the rank of this processor - * in the current mpi communicator. - * - * @return an int value of the rank for this processors - * in the current mpi communicator. - */ -int parallel_rank(); - -// /** -// * @brief Function set_current_diag_stream set the diagnostic writer current out -// * put stream. The special names - and cout attach the diag stream to the std::cout -// * stream. The special name cerr attaches the stream to the std::cerr stream, output -// * attaches to the stream Env::output() and outputp0 to the stream outputP0(). Otherwise, -// * the file is opened with mode ios mode flags and attached to the diagnostic -// * stream. -// * -// * @param path a char const pointer to the file path to -// * open. -// * -// * @param mode a std::ios::openmode value of the ios mode to -// * open the file. -// * -// */ -// void set_current_diag_stream(const char *path, std::ios_base::openmode mode = std::ios_base::out); - -// /** -// * @brief Function getCurrentStream returns the current diagnostic stream. -// * -// * @return a std::ostream reference to the current diagnostic -// * stream. -// */ -// // Diag::Stream &get_current_diag_stream(); -// std::ostream &get_current_diag_stream(); - -/// -/// @} -/// - -} // namespace Env -} // namespace sierra - -#endif // STK_UTIL_DIAG_Env_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.cpp deleted file mode 100644 index c73df08c709a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -#include -#include - -namespace sierra { - -// Force inclusion of array_dimension_error by linker -FArrayBootstrap::~FArrayBootstrap() -{ - static void (*array_dimension_error_bootstrap)(const std::type_info &typeinfo, unsigned dimension, unsigned value, unsigned upper) = array_dimension_error; - - (void) array_dimension_error_bootstrap; // suppress compiler warning for unused variable -} - -namespace { - -const char *ordinal[] = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eight"}; - -} // namespace - - -void -array_dimension_error( - const std::type_info & type, - unsigned dimension, - unsigned value, - unsigned upper) -{ - std::ostringstream os ; - os << demangle(type.name()) << " "; - if (dimension > sizeof(ordinal)/sizeof(ordinal[0])) - os << dimension; - else - os << ordinal[dimension]; - os << " dimension value " << value - << " is out of bounds (0:" << upper - 1 << ")"; - - throw std::range_error(os.str().c_str()); -} - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.hpp deleted file mode 100644 index 3b361bb8b614..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/FArray.hpp +++ /dev/null @@ -1,1421 +0,0 @@ -/** - * Copyright 2005-2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - */ - -/** - * @file - * @author H. Carter Edwards - * @date August 2005 - */ - -#ifndef STK_UTIL_DIAG_FArray_h -#define STK_UTIL_DIAG_FArray_h - -#include -#include -#include -#include -#include -#include - -#include - -#ifndef NDEBUG -# define SIERRA_ARRAY_BOUNDS_CHECK -#endif - -namespace sierra { - -/// -/// @addtogroup FArrayDetail -/// @{ -/// - - -void -array_dimension_error( - const std::type_info & typeinfo, - unsigned dimension, - unsigned value, - unsigned upper); - - -/** - * @class FArray - * - * @brief Multidimensional array of contiguous memory. The memory is not owned by the - * array, but container access semantics are enforced, i.e. const Array<> elements cannot - * be assigned to. - * - * @par Indexing via 'operator()' - * - * Elements of an array can be accessed via the () operator, where an index is provided - * for each dimension of the array. The number of dimensions is enforced at compile - * time; however, enforcement of the range of the indices is only performed at runtime in - * debug mode, i.e. 'NDEBUG' is not defined. - * - * FArray a(mem, n0, n1, n2, n3); - * a(i0, i1, i2, i3) = 24 ; - * - * @par Construction with a block of memory - * - * An array is created by providing it with memory address and dimensions by which that - * memory is to be viewed. - * - * FArray(pointer, ndim0, ndim1, ndim2, ...); - * - * @par Shallow copy construction - * - * The copy constructor is a shallow copy. The constructed array is just another a view - * into the same memory as the input array. This is the preferred method of passing - * arrays as access required less memory indirection. - */ -template -class FArray; - -/** - * @class sierra::FArrayContainer - * - * @brief Extend FArray with deep copy assignment and resize operations. - */ -template > -class FArrayContainer; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Helpers - -template struct ArrayHelper; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template<> -struct ArrayHelper<0> -{ - template - inline static void fill(const T, T *) - {} - - template - inline static void copy(const T *, T *) - {} - - template - inline static void prefix(const T *, T *) - {} - - inline static void get_index(const unsigned * const, unsigned *index, int offset) { - index[0] = offset; - } - - template - inline static T *index(T * ptr, const unsigned * const, const unsigned * const, const unsigned * const index) { - return ptr + index[0]; - } -}; - -template<> -struct ArrayHelper<1> -{ - template - inline static bool equal(const T * x, const T * y) { - return *x == *y; - } - - template - inline static void fill(const T x, T * y) { - *y = x; - } - - template - inline static void copy(const T * x, T * y) { - *y = *x; - } - - template - inline static void prefix(const T * x, T * p) { - *(p+1) = *p * *x; - } - - template - static void copy(const unsigned * const dim, - T * a_ptr, const unsigned * const a_inc, - T const * b_ptr, const unsigned * const b_inc) - { - const unsigned ia = *a_inc; - const unsigned ib = *b_inc; - T * const a_end = a_ptr + *dim * ia; - while (a_end != a_ptr) { - *a_ptr = *b_ptr; - a_ptr += ia; - b_ptr += ib; - } - } - - template - static void fill(const unsigned * const dim, - T * a_ptr, const unsigned * const a_inc, - const T & value) - { - const unsigned ia = *a_inc; - T * const a_end = a_ptr + *dim * ia; - while (a_end != a_ptr) { - *a_ptr = value; - a_ptr += ia; - } - } - - template - static bool equal(const unsigned * const dim, - const T * a_ptr, const unsigned * const a_inc, - const T * b_ptr, const unsigned * const b_inc) - { - const unsigned ia = *a_inc; - const unsigned ib = *b_inc; - const T * const a_end = a_ptr + *dim * ia; - bool result = true; - while (a_end != a_ptr && (result = *a_ptr == *b_ptr)) { - a_ptr += ia; - b_ptr += ib; - } - return result; - } - - inline static void get_index(const unsigned * const inc, unsigned *index, int offset) { - index[1] = offset/inc[1]; - index[0] = offset%inc[1]; - } - - template - inline static T *index(T * ptr, const unsigned * const inc, const unsigned * const, const unsigned * const index) { - return ptr + index[0] + index[1]*inc[1]; - } -}; - - -template -struct ArrayHelper -{ -private: - typedef ArrayHelper M; - -public: - template - inline static bool equal(const T * x, const T * y) { - return *x == *y && M::equal(x + 1, y + 1); - } - - template - inline static void fill(const T x, T * y) { - *y = x; - M::fill(x, y+1); - } - - template - inline static void copy(const T * x, T * y) { - *y = *x; - M::copy(x+1, y+1); - } - - template - inline static void prefix(const T * x, T * p) { - *(p+1) = *p * *x; - M::prefix(x + 1, p + 1); - } - - template - static void copy(const unsigned * const dim, - T * a_ptr, const unsigned * const a_inc, - T const * b_ptr, const unsigned * const b_inc) - { - const unsigned ia = *a_inc; - const unsigned ib = *b_inc; - T * const a_end = a_ptr + *dim * ia; - while (a_end != a_ptr) { - M::copy(dim + 1, a_ptr, a_inc + 1, b_ptr, b_inc + 1); - a_ptr += ia; - b_ptr += ib; - } - } - - template - static void fill(const unsigned * const dim, - T * a_ptr, const unsigned * const a_inc, - const T & value) - { - const unsigned ia = *a_inc; - T * const a_end = a_ptr + *dim * ia; - while (a_end != a_ptr) { - M::fill(dim + 1, a_ptr, a_inc + 1, value); - a_ptr += ia; - } - } - - template - static bool equal(const unsigned * const dim, - const T * a_ptr, const unsigned * const a_inc, - const T * b_ptr, const unsigned * const b_inc) - { - const unsigned ia = *a_inc; - const unsigned ib = *b_inc; - const T * const a_end = a_ptr + *dim * ia; - bool result = true; - while (a_end != a_ptr && - (result = M::equal(dim+1, a_ptr, a_inc+1, b_ptr, b_inc+1))){ - a_ptr += ia; - b_ptr += ib; - } - return result; - } - - inline static void get_index(const unsigned * const inc, unsigned *index, int offset) { - index[N] = offset/inc[N]; - M::get_index(inc, index, offset%inc[N]); - } - - template - inline static T *index(T * ptr, const unsigned * const inc, const unsigned * const dim, const unsigned * const index) { - return M::index(ptr, inc, dim, index) + index[N]*inc[N]; - } -}; - -//---------------------------------------------------------------------- -// A typeless array is invalid... - -template -class FArray {}; - -template -class FArray -{ -public: - typedef ElementType value_type; - - typedef FArray SelfType; - - typedef FArray Const; - - enum { NumDim = 0}; -}; - -class FArrayBootstrap -{ -public: - ~FArrayBootstrap(); -}; - -template -class FArray : public FArrayBootstrap -{ -public: - enum { NumDim = Dimension }; - - typedef ElementType value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef value_type * pointer; - typedef const value_type * const_pointer; - typedef value_type & reference; - typedef const value_type & const_reference; - - typedef pointer iterator; - typedef const_pointer const_iterator; - typedef typename std::reverse_iterator reverse_iterator; - typedef typename std::reverse_iterator const_reverse_iterator; - - typedef FArray SelfType; - typedef FArrayContainer Container; - typedef FArray Trunc; - - class Index - { - public: - const unsigned &operator[](unsigned i) const { - return m_index[i]; - } - - unsigned &operator[](unsigned i) { - return m_index[i]; - } - - private: - unsigned m_index[NumDim]; - }; - - const unsigned * dimension() const { - return m_dim; - } - - const unsigned * stride() const { - return m_stride; - } - -#ifdef SIERRA_ARRAY_BOUNDS_CHECK - inline void array_dimension_verify(unsigned l_dimension, unsigned value, unsigned upper) const { - if (value >= upper) - { - array_dimension_error(typeid(*this), l_dimension, value, upper); - } - } -#else - inline void array_dimension_verify(unsigned, unsigned, unsigned) const {} -#endif - - template - unsigned dimension() const { - enum { ok = stk_classic::StaticAssert::OK }; - return m_dim[I]; - } - - template - unsigned stride() const { - enum { ok = stk_classic::StaticAssert::OK }; - return m_stride[I]; - } - - /** Dimensions defined at construction */ - unsigned dimension(const unsigned i) const { - array_dimension_verify(0, i, NumDim); - return m_dim[i]; - } - - unsigned stride(const unsigned i) const { - array_dimension_verify(0, i, NumDim); - return m_stride[i]; - } - - unsigned size() const { - return m_stride[NumDim]; - } - - //---------------------------------------- - - bool operator==(const SelfType & a) const { - return ArrayHelper::equal(m_dim, a.m_dim) && - ArrayHelper::equal(m_dim, m_ptr, m_stride, a.m_ptr, a.m_stride); - } - - template - bool operator==(const FArray & a) const { - return ArrayHelper::equal(m_dim, a.dimension()) && - ArrayHelper::equal(m_dim, m_ptr, m_stride, a.ptr(), a.stride()); - } - - bool operator!=(const SelfType & a) const { - return ! operator==(a); } - - template - bool operator!=(const FArray & a) const { - return ! operator==(a); - } - - value_type &operator()(const Index &index) { - for (unsigned i = 0; i < NumDim; ++i) - array_dimension_verify(i, index[i], m_dim[i]); - - value_type *l_ptr = ArrayHelper::index(m_ptr, m_stride, m_dim, &index[0]); - - return *l_ptr; - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5, - const unsigned i6, const unsigned i7) - { - enum { ok = stk_classic::StaticAssert<8 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - array_dimension_verify(6, i6, m_dim[6]); - array_dimension_verify(7, i7, m_dim[7]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5 + - m_stride[6] * i6 + m_stride[7] * i7); - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5, - const unsigned i6) - { - enum { ok = stk_classic::StaticAssert<7 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - array_dimension_verify(6, i6, m_dim[6]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5 + - m_stride[6] * i6); - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5) - { - enum { ok = stk_classic::StaticAssert<6 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5); - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4) - { - enum { ok = stk_classic::StaticAssert<5 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4); - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3) - { - enum { ok = stk_classic::StaticAssert<4 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3); - } - - value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2) - { - enum { ok = stk_classic::StaticAssert<3 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2); - } - - value_type & operator()(const unsigned i0, const unsigned i1) { - enum { ok = stk_classic::StaticAssert<2 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - - return *(m_ptr + i0 + m_stride[1] * i1); - } - - value_type & operator()(const unsigned i0) { - enum { ok = stk_classic::StaticAssert<1 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - - return *(m_ptr + i0); - } - - value_type * ptr() { - return m_ptr; - } - - value_type & operator[](unsigned i) { - array_dimension_verify(0, i, m_stride[NumDim]); - return m_ptr[i]; - } - - const value_type &operator()(const Index &index) const { - for (unsigned i = 0; i < NumDim; ++i) - array_dimension_verify(i, index[i], m_dim[i]); - - const value_type *l_ptr = ArrayHelper::index(m_ptr, m_stride, m_dim, &index[0]); - - return *l_ptr; - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5, - const unsigned i6, const unsigned i7) const - { - enum { ok = stk_classic::StaticAssert<8 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - array_dimension_verify(6, i6, m_dim[6]); - array_dimension_verify(7, i7, m_dim[7]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5 + - m_stride[6] * i6 + m_stride[7] * i7); - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5, - const unsigned i6) const - { - enum { ok = stk_classic::StaticAssert<7 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - array_dimension_verify(6, i6, m_dim[6]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5 + - m_stride[6] * i6); - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4, const unsigned i5) const - { - enum { ok = stk_classic::StaticAssert<6 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - array_dimension_verify(5, i5, m_dim[5]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4 + m_stride[5] * i5); - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3, - const unsigned i4) const - { - enum { ok = stk_classic::StaticAssert<5 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - array_dimension_verify(4, i4, m_dim[4]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3 + - m_stride[4] * i4); - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2, const unsigned i3) const - { - enum { ok = stk_classic::StaticAssert<4 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - array_dimension_verify(3, i3, m_dim[3]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2 + m_stride[3] * i3); - } - - const value_type & operator()(const unsigned i0, const unsigned i1, - const unsigned i2) const - { - enum { ok = stk_classic::StaticAssert<3 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - array_dimension_verify(2, i2, m_dim[2]); - - return *(m_ptr + i0 + m_stride[1] * i1 + - m_stride[2] * i2); - } - - const value_type & operator()(const unsigned i0, const unsigned i1) const { - enum { ok = stk_classic::StaticAssert<2 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - array_dimension_verify(1, i1, m_dim[1]); - - return *(m_ptr + i0 + m_stride[1] * i1); - } - - const value_type & operator()(const unsigned i0) const { - enum { ok = stk_classic::StaticAssert<1 == NumDim>::OK }; - - array_dimension_verify(0, i0, m_dim[0]); - - return *(m_ptr + i0); - } - - value_type * ptr() const { - return m_ptr; - } - - const value_type & operator[](unsigned i) const { - array_dimension_verify(0, i, m_stride[NumDim]); - return m_ptr[i]; - } - - //---------------------------------------- - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) const - { - enum { ok = stk_classic::StaticAssert<8 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2 && m_dim[3] == n3 && - m_dim[4] == n4 && m_dim[5] == n5 && - m_dim[6] == n6 && m_dim[7] == n7; - } - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) const - { - enum { ok = stk_classic::StaticAssert<7 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2 && m_dim[3] == n3 && - m_dim[4] == n4 && m_dim[5] == n5 && - m_dim[6] == n6; - } - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) const - { - enum { ok = stk_classic::StaticAssert<6 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2 && m_dim[3] == n3 && - m_dim[4] == n4 && m_dim[5] == n5; - } - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) const - { - enum { ok = stk_classic::StaticAssert<5 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2 && m_dim[3] == n3 && - m_dim[4] == n4; - } - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) const - { - enum { ok = stk_classic::StaticAssert<4 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2 && m_dim[3] == n3; - } - - bool verify_dimension(const unsigned n0, const unsigned n1, - const unsigned n2) const - { - enum { ok = stk_classic::StaticAssert<3 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1 && - m_dim[2] == n2; - } - - bool verify_dimension(const unsigned n0, const unsigned n1) const { - enum { ok = stk_classic::StaticAssert<2 == NumDim>::OK }; - return m_dim[0] == n0 && m_dim[1] == n1; - } - - bool verify_dimension(const unsigned n0) const { - enum { ok = stk_classic::StaticAssert<1 == NumDim>::OK }; - return m_dim[0] == n0; - } - - unsigned set_dim(const unsigned d[]) { - m_stride[0] = 1; - ArrayHelper::copy(d, m_dim); - ArrayHelper::prefix(d, m_stride); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) - { - enum { ok = stk_classic::StaticAssert<8 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - m_stride[4] = m_stride[3] * (m_dim[3] = n3); - m_stride[5] = m_stride[4] * (m_dim[4] = n4); - m_stride[6] = m_stride[5] * (m_dim[5] = n5); - m_stride[7] = m_stride[6] * (m_dim[6] = n6); - m_stride[8] = m_stride[7] * (m_dim[7] = n7); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) - { - enum { ok = stk_classic::StaticAssert<7 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - m_stride[4] = m_stride[3] * (m_dim[3] = n3); - m_stride[5] = m_stride[4] * (m_dim[4] = n4); - m_stride[6] = m_stride[5] * (m_dim[5] = n5); - m_stride[7] = m_stride[6] * (m_dim[6] = n6); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) - { - enum { ok = stk_classic::StaticAssert<6 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - m_stride[4] = m_stride[3] * (m_dim[3] = n3); - m_stride[5] = m_stride[4] * (m_dim[4] = n4); - m_stride[6] = m_stride[5] * (m_dim[5] = n5); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) - { - enum { ok = stk_classic::StaticAssert<5 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - m_stride[4] = m_stride[3] * (m_dim[3] = n3); - m_stride[5] = m_stride[4] * (m_dim[4] = n4); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) - { - enum { ok = stk_classic::StaticAssert<4 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - m_stride[4] = m_stride[3] * (m_dim[3] = n3); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1, - const unsigned n2) - { - enum { ok = stk_classic::StaticAssert<3 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - m_stride[3] = m_stride[2] * (m_dim[2] = n2); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0, const unsigned n1) - { - enum { ok = stk_classic::StaticAssert<2 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - m_stride[2] = m_stride[1] * (m_dim[1] = n1); - return m_stride[NumDim]; - } - - unsigned set_dim(const unsigned n0) - { - enum { ok = stk_classic::StaticAssert<1 == NumDim>::OK }; - - m_stride[0] = 1; - m_stride[1] = m_stride[0] * (m_dim[0] = n0); - return m_stride[NumDim]; - } - - unsigned set_dim(const SelfType & a) - { - ArrayHelper::copy(a.m_dim, m_dim); - ArrayHelper::copy(a.m_stride, m_stride); - return m_stride[NumDim]; - } - -public: - ~FArray() - { - m_ptr = NULL; - ArrayHelper::fill((unsigned) 0, m_dim); - ArrayHelper::fill((unsigned) 0, m_stride); - } - - FArray() - : m_ptr(NULL) - { - ArrayHelper::fill((unsigned) 0, m_dim); - ArrayHelper::fill((unsigned) 0, m_stride); - } - - FArray(const SelfType & a) - : m_ptr(a.m_ptr) - { - ArrayHelper::copy(a.m_dim, m_dim); - ArrayHelper::copy(a.m_stride, m_stride); - } - - SelfType & operator=(SelfType const & a) - { - if (this != &a) { - - m_ptr = a.m_ptr; - - ArrayHelper::copy(a.m_dim, m_dim); - ArrayHelper::copy(a.m_stride, m_stride); - } - return *this; - } - - template - FArray(const FArray & a) - : m_ptr(a.ptr()) - { - ArrayHelper::copy(a.dimension(), m_dim); - ArrayHelper::copy(a.stride(), m_stride); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2, n3, n4, n5, n6, n7); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2, n3, n4, n5, n6); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2, n3, n4, n5); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2, n3, n4); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2, n3); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2) - : m_ptr(l_ptr) - { - set_dim(n0, n1, n2); - } - - FArray(value_type * const l_ptr, - const unsigned n0, const unsigned n1) - : m_ptr(l_ptr) - { - set_dim(n0, n1); - } - - FArray(value_type * const l_ptr, - const unsigned n0) - : m_ptr(l_ptr) - { - set_dim(n0); - } - - FArray(value_type * const l_ptr, - const unsigned n[NumDim]) - : m_ptr(l_ptr) - { - set_dim(n); - } - - void set(const SelfType & a) { - m_ptr = a.m_ptr; - - ArrayHelper::copy(a.m_dim, m_dim); - ArrayHelper::copy(a.m_stride, m_stride); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) - { - m_ptr = l_ptr; - set_dim(n0, n1, n2, n3, n4, n5, n6, n7); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) - { - m_ptr = l_ptr; - set_dim(n0, n1, n2, n3, n4, n5, n6); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) - { - m_ptr = l_ptr; - set_dim(n0, n1, n2, n3, n4, n5); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) { - m_ptr = l_ptr; - set_dim(n0, n1, n2, n3, n4); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) - { - m_ptr = l_ptr; - set_dim(n0, n1, n2, n3); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2) - { - m_ptr = l_ptr; - set_dim(n0, n1, n2); - } - - void set(value_type * const l_ptr, - const unsigned n0, const unsigned n1) { - m_ptr = l_ptr; - set_dim(n0, n1); - } - - void set(value_type * const l_ptr, - const unsigned n0) { - m_ptr = l_ptr; - set_dim(n0); - } - - void set(value_type * const l_ptr, - const unsigned n[NumDim]) { - m_ptr = l_ptr; - set_dim(n); - } - - Trunc dive(int i) { - array_dimension_verify(0, i, m_dim[NumDim - 1]); - - value_type *l_ptr = m_ptr + i*m_stride[NumDim - 1]; - - return Trunc(l_ptr, m_dim); - } - - const Trunc dive(int i) const { - array_dimension_verify(0, i, m_dim[NumDim - 1]); - - value_type *l_ptr = m_ptr + i*m_stride[NumDim - 1]; - - return Trunc(l_ptr, m_dim); - } - - iterator begin() { - return m_ptr; - } - - iterator end() { - return m_ptr + m_stride[NumDim]; - } - - const_iterator begin() const { - return m_ptr; - } - - const_iterator end() const { - return m_ptr + m_stride[NumDim]; - } - - void dimensions(const_iterator it, Index &index) const { - ArrayHelper::get_index(m_stride, &index[0], it - m_ptr); - } - - //---------------------------------------- - // Copy contents of a compatible array - - template - void copy(const FArray & a) { - ArrayHelper::copy(m_dim, m_ptr, m_stride, a.ptr(), a.stride()); - } - - template - void fill(const T & value) { - ArrayHelper::fill(m_dim, m_ptr, m_stride, value); - } - -private: - // Mutation (non-const methods) is not allowed so as to - // provide derived classes with complete control over mutation. - -protected: - value_type * m_ptr; - unsigned m_dim[NumDim]; - unsigned m_stride[NumDim + 1]; -}; - - -template -class FArrayContainer - : public FArray -{ -public: -// typedef typename FArray::value_type value_type; - - typedef typename A::value_type value_type; - typedef typename A::size_type size_type; - typedef typename A::difference_type difference_type; - - typedef typename A::pointer pointer; - typedef typename A::const_pointer const_pointer; - typedef typename A::reference reference; - typedef typename A::const_reference const_reference; - - typedef typename A::pointer iterator; - typedef typename A::const_pointer const_iterator; - - typedef typename std::reverse_iterator reverse_iterator; - typedef typename std::reverse_iterator const_reverse_iterator; - - typedef FArrayContainer SelfType; - - typedef FArray BaseType; - -// typedef typename BaseType::value_type value_type; - - enum { NumDim = BaseType::NumDim }; - -private: - using BaseType::m_ptr; - using BaseType::m_dim; - using BaseType::m_stride; - - void resize_memory(const unsigned new_size) { - if (m_capacity < new_size) { - if ( m_capacity ) - m_allocator.deallocate(m_ptr, m_capacity); - m_capacity = new_size; - m_ptr = m_allocator.allocate(m_capacity); - } - } - -public: - ~FArrayContainer() { - if (m_capacity) { - m_allocator.deallocate(m_ptr, m_capacity); - m_capacity = 0; - } - } - - //---------------------------------------- - // Constructors for initial view of contiguous memory. - - FArrayContainer() - : BaseType(), - m_capacity(0) - {} - - FArrayContainer(const SelfType & a) - : BaseType(), - m_capacity(0) - { - resize_memory(BaseType::set_dim(a.m_dim)); - this->copy(a); - } - - template - FArrayContainer(const FArray & a) - : BaseType(), - m_capacity(0) - { - resize_memory(BaseType::set_dim(a.dimension())); - this->copy(a); - } - - SelfType & operator=(const SelfType & a) - { - resize_memory(BaseType::set_dim(a.dimension())); - this->copy(a); - return *this; - } - - template - SelfType & operator=(const FArray & a) - { - resize_memory(BaseType::set_dim(a.dimension())); - this->copy(a); - return *this; - } - - //---------------------------------------- - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) - : BaseType(NULL, n0, n1, n2, n3, n4, n5, n6, n7), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) - : BaseType(NULL, n0, n1, n2, n3, n4, n5, n6), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) - : BaseType(NULL, n0, n1, n2, n3, n4, n5), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) - : BaseType(NULL, n0, n1, n2, n3, n4), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) - : BaseType(NULL, n0, n1, n2, n3), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0, const unsigned n1, - const unsigned n2) - : BaseType(NULL, n0, n1, n2), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0, const unsigned n1) - : BaseType(NULL, n0, n1), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n0) - : BaseType(NULL, n0), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - FArrayContainer(const unsigned n[]) - : BaseType(NULL, n), - m_capacity(0) - { - resize_memory(m_stride[NumDim]); - std::fill(m_ptr, m_ptr + m_stride[NumDim], 0); - } - - - //---------------------------------------- - - template - SelfType & resize(const FArray & a) - { - resize_memory(BaseType::set_dim(a.dimension())); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6, n7)); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6)); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5)); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4)); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3)); - return *this; - } - - - SelfType & resize(const unsigned n0, const unsigned n1, - const unsigned n2) - { - resize_memory(BaseType::set_dim(n0, n1, n2)); - return *this; - } - - SelfType & resize(const unsigned n0, const unsigned n1) { - resize_memory(BaseType::set_dim(n0, n1)); - return *this; - } - - SelfType & resize(const unsigned n0) { - resize_memory(BaseType::set_dim(n0)); - return *this; - } - - SelfType & resize(const unsigned n[]) { - resize_memory(BaseType::set_dim(n)); - return *this; - } - -private: - A m_allocator; - unsigned m_capacity; -}; - -/// -/// @} -/// - -} // namespace sierra - -#endif // STK_UTIL_DIAG_FArray_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.cpp deleted file mode 100644 index 152709477616..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 1998-2007 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -// --------------------------------------------------------------------- -// Author: H. Carter Edwards -// -// Purpose: Associative container for allocated data objects -// --------------------------------------------------------------------- -// Acknowledgements: -// -// Most all of the algorithms in this class were obtained from -// the Hewlett-Packard source for the Standard Template Library, -// thus the inclusion of Hewlett-Packard's copyright notice. -// Some minor modifications were obtained from Silicon Graphics' -// Standard Template Library source. -// --------------------------------------------------------------------- -/* - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -/* -Red-black tree class, designed for use in implementing STL -associative containers (set, multiset, map, and multimap). The -insertion and deletion algorithms are based on those in Cormen, -Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), -except that - -(1) the header cell is maintained with links not only to the root -but also to the leftmost node of the tree, to enable constant time -begin(), and to the rightmost node of the tree, to enable linear time -performance when used with the generic set algorithms (set_union, -etc.); - -(2) when a node being deleted has two children its successor node is -relinked into its place, rather than copied, so that the only -iterators invalidated are those referring to the deleted node. -*/ -// --------------------------------------------------------------------- - -// The header - -#include - -#include -#if defined(SIERRA_IA64_OPTIMIZER_WARN) -#include -#endif -#include - -namespace sierra { - -// --------------------------------------------------------------------- - -inline -MapvNodeBase * MapvBase::minimum( MapvNodeBase * x ) - { while ( x->left ) x = x->left ; return x ; } - -inline -MapvNodeBase * MapvBase::maximum( MapvNodeBase * x ) - { while ( x->right ) x = x->right ; return x ; } - -// --------------------------------------------------------------------- - -inline void MapvBase::rotate_left( MapvNodeBase * x ) -{ - MapvNodeBase * y = x->right ; - - x->right = y->left ; - if ( y->left ) y->left->parent = x ; - y->parent = x->parent ; - - if ( x == nRoot() ) root(y); - else if ( x == x->parent->left ) x->parent->left = y ; - else x->parent->right = y ; - - y->left = x ; - x->parent = y ; -} - -inline void MapvBase::rotate_right( MapvNodeBase * x ) -{ - MapvNodeBase * y = x->left ; - - x->left = y->right ; - if ( y->right ) y->right->parent = x; - y->parent = x->parent ; - - if ( x == nRoot() ) root(y); - else if ( x == x->parent->right ) x->parent->right = y ; - else x->parent->left = y ; - - y->right = x; - x->parent = y; -} - -// --------------------------------------------------------------------- - -void MapvBase::insert( MapvNodeBase * y , MapvNodeBase * z , bool z_lt_y ) -{ - z->remove_from_container(); - - if ( y == nEnd() ) { // First node inserted - root(z); - leftmost(z); - rightmost(z); - z->parent = header() ; // header is 'super-root' - } - else { - if ( z_lt_y ) { - y->left = z ; - // maintain leftmost() pointing to minimum node - if ( y == leftmost() ) leftmost(z); - } - else { - y->right = z; - // maintain rightmost() pointing to maximum node - if ( y == rightmost() ) rightmost(z); - } - z->parent = y ; - } - z->left = 0 ; - z->right = 0 ; - z->color = red ; - ++Count ; - - // ------------------------------------------------------------------- - // Rebalance, 'y' and 'z' are reused as a local variable - - while ( z != nRoot() && z->parent->color == red ) { - if ( z->parent == z->parent->parent->left ) { - y = z->parent->parent->right ; - if ( y && y->color == red ) { - z->parent->color = black; - y->color = black; - z->parent->parent->color = red; - z = z->parent->parent ; - } - else { - if ( z == z->parent->right ) { - z = z->parent ; - rotate_left(z); - } - z->parent->color = black; - z->parent->parent->color = red; - rotate_right( z->parent->parent ); - } - } - else { - y = z->parent->parent->left ; - if ( y && y->color == red ) { - z->parent->color = black; - y->color = black; - z->parent->parent->color = red; - z = z->parent->parent ; - } - else { - if ( z == z->parent->left ) { - z = z->parent ; - rotate_right(z); - } - z->parent->color = black; - z->parent->parent->color = red; - rotate_left(z->parent->parent); - } - } - } - nRoot()->color = black; -} - -// --------------------------------------------------------------------- - -void MapvBase::remove( MapvNodeBase * node ) -{ - static const char method_name[] = "MapvBase::remove" ; - - if ( container(node) != this ) { - std::string msg(method_name); - msg.append(" given object not in this container"); - throw std::invalid_argument( msg ); - } - - if ( 1 == Count ) { // The last node ? - - if ( node != leftmost() || node != rightmost() || node != nRoot() ) { - std::string msg(method_name); - msg.append(" internal data structure corrupted" ); - throw std::runtime_error( msg ); - } - - leftmost( nREnd() ); - rightmost( nEnd() ); - root(0); - Count = 0 ; - header()->color = red ; - node->left = node->right = node->parent = 0 ; node->color = 0 ; - return ; - } - - MapvNodeBase * z = node ; - MapvNodeBase * y = node ; - MapvNodeBase * x = 0 ; - MapvNodeBase * x_parent = 0 ; - - // Ready to remove - - if ( y->left == 0 ) { // z has at most one non-null child. y == z - x = y->right ; // x might be null - } - else if ( y->right == 0 ) { // z has exactly one non-null child. y == z - x = y->left ; // z is not null - } - else { // z has two non-null children. - y = y->right ; // Set y to z's successor. - while ( y->left ) y = y->left ; - x = y->right ; // x might be null - } - - if ( y != z ) { // relink y in place of z. y is z's successor - z->left->parent = y ; - y->left = z->left ; - if ( y != z->right ) { - x_parent = y->parent ; - if ( x ) x->parent = x_parent ; - y->parent->left = x; // y must be a left child - y->right = z->right; - z->right->parent = y; - } else { - x_parent = y; // needed in case x == 0 - } - if ( nRoot() == z) { - root(y); - } - else if ( z->parent->left == z) { - z->parent->left = y; - } - else { - z->parent->right = y; - } - y->parent = z->parent; - { int c = y->color; y->color = z->color; z->color = c ; } - y = z; - // y points to node to be actually deleted - } - else { // y == z - x_parent = y->parent ; - if ( x ) x->parent = x_parent ; // possibly x == 0 - if ( nRoot() == z) { - root(x); - } - else if ( z->parent->left == z ) { - z->parent->left = x; - } - else { - z->parent->right = x; - } - if ( leftmost() == z ) { - if ( z->right == 0 ) { // z->left must be null also - // makes leftmost() == nEnd() if z == nRoot() - leftmost( z->parent ); - } - else { - leftmost( minimum(x) ); - } - } - if ( rightmost() == z ) { - if ( z->left == 0 ) { // z->right must be null also - // makes rightmost() == nEnd() if z == nRoot() - rightmost( z->parent ); - } - else { // x == z->left - rightmost( maximum(x) ); - } - } - } - if ( y->color != red ) { - while ( x != nRoot() && ( x == 0 || x->color == black ) ) { - if ( x == x_parent->left ) { - MapvNodeBase * w = x_parent->right ; - if ( w->color == red ) { - w->color = black; - x_parent->color = red; - rotate_left(x_parent); - w = x_parent->right ; - } - if ((w->left == 0 || w->left->color == black) && - (w->right == 0 || w->right->color == black)) { - w->color = red ; - x = x_parent ; - x_parent = x_parent->parent ; - } - else { - if (w->right == 0 || w->right->color == black) { - if ( w->left ) w->left->color = black; - w->color = red; - rotate_right(w); - w = x_parent->right ; - } - w->color = x_parent->color ; - x_parent->color = black; - if ( w->right ) w->right->color = black; - rotate_left(x_parent); - break; - } - } - else { // same as then clause with "right" and "left" exchanged - MapvNodeBase * w = x_parent->left ; - if ( w->color == red ) { - w->color = black; - x_parent->color = red; - rotate_right(x_parent); - w = x_parent->left ; - } - if ((w->right == 0 || w->right->color == black) && - (w->left == 0 || w->left->color == black)) { - w->color = red; - x = x_parent ; - x_parent = x_parent->parent ; - } - else { - if ( w->left == 0 || w->left->color == black ) { - if ( w->right ) w->right->color = black; - w->color = red; - rotate_left(w); - w = x_parent->left ; - } - w->color = x_parent->color ; - x_parent->color = black; - if ( w->left ) w->left->color = black; - rotate_right(x_parent); - break; - } - } - } - if ( x ) x->color = black; - } - - y->left = y->right = y->parent = 0 ; y->color = 0 ; - - --Count ; // Decrement the tree's count -} - -// --------------------------------------------------------------------- -// A reverse communicating method for deleting all entries - -MapvNodeBase * MapvBase::unbalancing_removal( MapvNodeBase ** n ) -{ - MapvNodeBase * t = *n ; - - while ( t != header() && t->parent ) { - if ( t->left ) { t = t->left ; } - else if ( t->right ) { t = t->right ; } - else { // Move to parent and remove this leaf - *n = t->parent ; t->parent = 0 ; - if ( (*n)->left == t ) (*n)->left = 0 ; - else (*n)->right = 0 ; - } - } - - if ( t == header() ) { - - header()->parent = 0 ; - header()->left = 0 ; - header()->right = 0 ; - header()->color = red ; /* Color the header node red */ - - Count = 0 ; - - left_end.parent = 0 ; - left_end.left = 0 ; - left_end.right = 0 ; - left_end.color = black ; - - right_end.parent = 0 ; - right_end.left = 0 ; - right_end.right = 0 ; - right_end.color = black ; - - leftmost( header()->left = nREnd() ); // left end of the tree - rightmost( header()->right = nEnd() ); // right end of the tree - - t = 0 ; - } - - return t ; -} - -// --------------------------------------------------------------------- -void MapvBase::WarnOptimize() -{ -#if defined(SIERRA_IA64_OPTIMIZER_WARN) && defined(NDEBUG) - static bool warn_once=true; - int my_proc=Env::parallel_rank(); - - if ( warn_once && my_proc==0){ - warn_once = false; - std::cerr << "Optimizing previous versions of the intel compiler " - << "caused errors in Mapv.\n" - << "Results may be suspect.\n"; - } -#endif -} - -// --------------------------------------------------------------------- -// Virtual destructor - -MapvBase::~MapvBase() -{ - if ( Count || nRoot() != 0 ) { - std::string msg("MapvBase destructor, container is not empty"); - throw std::logic_error( msg ); - } -} - -} diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.hpp deleted file mode 100644 index df5650722bf9..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Mapv.hpp +++ /dev/null @@ -1,739 +0,0 @@ -#ifndef STK_UTIL_DIAG_Mapv_h -#define STK_UTIL_DIAG_Mapv_h - -#include -#include - -// --------------------------------------------------------------------- -// Author: H. Carter Edwards -// -// Purpose: -// A map-style associative container for large allocated data objects. -// --------------------------------------------------------------------- -// Usage / Instantiation: -// -// Each node in a "virtual map" must be derived from the 'MapvNode' -// base class. Their should be only one 'MapvNode' base class. -// -// class MY_CLASS : public MapvNode , other_base_classes { -// // 'MY_CLASS' internal data & methods -// }; -// -// class MY_CLASS2 : MY_CLASS { -// -// }; -// -// The Key_Type template argument is the data type of the ordering key -// for the virtual map. The Key_Type must support the 'less' -// template function object. -// --------------------------------------------------------------------- -// Features and Limitations: -// -// The 'MapvNode' derived objects may be inserted into a 'Mapv' container -// without being copied. -// -// When a 'MapvNode' derived object is destroyed it is automatically -// removed from the 'Mapv' container. Destruction of a 'Mapv' container -// automatically invokes the 'delete' operator for each 'MapvNode' -// derived object that resides in the container at the time of its -// destruction. -// -// The 'insert' and 'remove' operations cause the 'Mapv' container to -// rebalance its binary tree. These rebalancing algorithms are lengthy. -// As such the majority of the 'insert' and 'remove' operations are -// implemented in the seperately compiled 'Mapv.C' file. The subprograms -// in 'Mapv.C' are shared by all instantiations of 'Mapv', thus -// "code bloat" is kept to a minimum. -// -// Alteration of a 'mavnode' derived objects 'key' value is likely -// to invalidate its position in the binary. Thus alteration of the -// 'key' value removes the object from its 'Mapv' container. -// -// --------------------------------------------------------------------- -// Acknowledgements: -// -// Most all of the algorithms in this class were obtained from -// the Hewlett-Packard source for the Standard Template Library, -// thus the inclusion of Hewlett-Packard's copyright notice. -// --------------------------------------------------------------------- -/* - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -/* -Red-black tree class, designed for use in implementing STL -associative containers (set, multiset, map, and multimap). -The insertion and deletion algorithms are based on those in Cormen, -Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), -except that - -(1) the header cell is maintained with links not only to the root -but also to the leftmost node of the tree, to enable constant time -begin(), and to the rightmost node of the tree, to enable linear time -performance when used with the generic set algorithms (set_union, -etc.); - -(2) when a node being deleted has two children its successor node is -relinked into its place, rather than copied, so that the only -iterators invalidated are those referring to the deleted node. -*/ -// --------------------------------------------------------------------- -// Don't force usage of 'assert', but if available then use it - -#ifdef MAPV_ASSERT_H -#define mapv_assert( expr ) assert( expr ) -#else -#define mapv_assert( expr ) /* do nothing */ -#endif - -// STL includes: - -#include -#include -#include - -#ifdef SIERRA_IA64_OPTIMIZER_FIX -#pragma optimize("", off) -#endif - -namespace sierra { - -// class MyType : public MapvNode { ... }; - -template < typename Key_Type , class Key_Compare > class MapvNode ; - -template < class Derived_Type , class Memory_Policy > class Mapv ; - -template < class Derived_Type , class Next , class Prev > class MapvIterator ; - -// --------------------------------------------------------------------- -// --------------------------------------------------------------------- -/** A very private base class for Mapv nodes */ - -class MapvIterNext ; -class MapvIterPrev ; - -class MapvNodeBase { -private: - - enum { black = 0 , red = 1 }; - - MapvNodeBase * parent ; // Binary tree node - MapvNodeBase * left ; // Binary tree node - MapvNodeBase * right ; // Binary tree node - unsigned color ; // Red-black color - - inline void remove_from_container(); - - /** Destructor removes the node from its container */ - virtual ~MapvNodeBase() { remove_from_container(); } - - MapvNodeBase() : parent(0), left(0), right(0), color(black) {} - - // Friends of this very private class - - friend class MapvBase ; - friend class MapvIterNext ; - friend class MapvIterPrev ; - template < class dType , class N, class P > friend class MapvIterator ; - template < class dType , class mPolicy > friend class Mapv ; - template < class kType , class kCompare > friend class MapvNode ; -}; - -// --------------------------------------------------------------------- -/** Base class for Mapv nodes. - * Objects stored in a Mapv container are derived from this - * template base class as follows. - * - * class Derived_Type : [ other classes , ] - * public MapvNode - * [ , other classes ] { ... }; - * - * OR - * class Derived_Type : [ other classes , ] - * public MapvNode - * [ , other classes ] { ... }; - */ - -template < typename Key_Type , class Key_Compare = std::less > -class MapvNode : private MapvNodeBase { -public: - - typedef Key_Type key_type ; - typedef Key_Compare key_compare ; - - bool mapv_valid() const { return this && MapvNodeBase::parent ; } - void mapv_remove() { MapvNodeBase::remove_from_container(); } - - /** Query key */ - const key_type & mapv_key() const { return Key ; } - - /** Set key, => forces removal of the node from its 'Mapv' container */ - const Key_Type & mapv_key( const key_type & K ) - { remove_from_container(); return Key = K ; } - - /** A destroyed node is automatically removed from its container */ - virtual ~MapvNode() {} - MapvNode() {} - MapvNode( const key_type & K ) : Key(K) {} - -private: - - Key_Type Key ; - - // Disallow copy constructor and assignment operator - - MapvNode( const MapvNode & ); - - MapvNode & - operator = ( const MapvNode & ); - - // friends to access the MapvNodeBase base class and Key member - template< class dType , class N , class P > friend class MapvIterator ; - template< class dType , class mPolicy > friend class Mapv ; -}; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -/** Iterators for Mapv containers are bidirectional */ - -class MapvIterNext { -public: - typedef MapvNodeBase * ptr ; - typedef const MapvNodeBase * cptr ; - static ptr op( cptr x ) - { - ptr y = x->right; - if ( y ) { - while ( y->left ) y = y->left ; - } - else { - mapv_assert( x->parent /* incrementing 'end()' iterator */ ); - y = x->parent ; - while ( x == y->right ) y = ( x = y )->parent ; - if ( x == y->parent ) y = y->right ; - } - return y ; - } -}; - -class MapvIterPrev { -public: - typedef MapvNodeBase * ptr ; - typedef const MapvNodeBase * cptr ; - static ptr op( cptr x ) - { - ptr y = x->left; - if ( y ) { - while ( y->right ) y = y->right ; - } - else { - mapv_assert( x->parent /* decrementing 'end()' iterator */ ); - y = x->parent ; - while ( x == y->left ) y = ( x = y )->parent ; - if ( x == y->parent ) y = y->left ; - } - return y ; - } -}; - -template < class Type , class Next , class Prev > -class MapvIterator : public std::iterator -{ -private: - template < class T , class M > friend class Mapv ; - template < class T , class N, class P > friend class MapvIterator ; - - Type * n ; - - /** Dereference of 'end()' or 'rend()' iterators - * is erroneous and can lead to corruption of the container - */ - Type * ptr() const { return n->MapvNodeBase::parent == 0 ? (Type*) 0 : n ; } - - MapvIterator( MapvNodeBase * x ) : n( static_cast(x) ) {} - MapvIterator( Type * x ) : n( x ) {} - MapvIterator( Type & x ) : n( &x ) {} - -public: - - typedef MapvIterator SelfType ; - - /** Construct iterator from other similar iterators. - * The contained pointer types must be compile-time compatible - * for correctness of the pointer copy-constructor. - */ - template - MapvIterator( const MapvIterator & x ) : n( x.n ) {} - - /** Assign iterator from other similar iterators. - * The contained pointer types must be compile-time compatible - * for correctness of the pointer assignment operator. - */ - template - SelfType & operator = ( const MapvIterator & x ) - { n = x.n ; return *this ; } - - /** Query if the iterator is valid to dereference - * 1) Is not NULL - * 2) Is not an 'end()' or 'rend()' iterator. - */ - bool valid_to_dereference() const { return n && n->MapvNodeBase::parent ; } - -// /** Conversion to bool: true for dereferenceable iterator */ -// operator bool () const { return valid_to_dereference(); } - - //-------------------------------------------------------------------- - - MapvIterator() : n(0) {} - MapvIterator( const SelfType & x ) : n( x.n ) {} - - SelfType & operator = ( const SelfType & x ) { n = x.n ; return *this ; } - - Type & operator * () const - { mapv_assert( valid_to_dereference() ); return *n ; } - Type * operator ->() const - { mapv_assert( valid_to_dereference() ); return n ; } - - SelfType & operator++(){ n = static_cast(Next::op(n)); return *this; } - SelfType & operator--(){ n = static_cast(Prev::op(n)); return *this; } - - SelfType operator++(int) - { Type * t = n ; n = static_cast(Next::op(n)); return SelfType(t); } - - SelfType operator--(int) - { Type * t = n ; n = static_cast(Prev::op(n)); return SelfType(t); } - - template - bool operator == ( const MapvIterator & y ) const - { return n == y.n ; } - - template - bool operator != ( const MapvIterator & y ) const - { return n != y.n ; } -}; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -/** Very private base class for Mapv container */ - -class MapvBase : private MapvNodeBase { -private: - - MapvNodeBase left_end ; // 'rend()' node - MapvNodeBase right_end ; // 'end()' node - - size_t Count ; - - //------------------------------------ - - typedef MapvNodeBase nType ; - typedef MapvNodeBase * pType ; - - static MapvBase * container( const nType * x ) - { - MapvBase * h = 0 ; - if ( x && x->parent ) { - // Search for root node, while loop breaks at root node - while ( x != x->parent->parent ) x = x->parent ; - // the root node's parent is the header - h = static_cast( x->parent ); - } - return h ; - } - -// --------------------------------------------------------------------- - - static nType * minimum( nType * ); - static nType * maximum( nType * ); - - void rotate_left( nType * x ); - void rotate_right( nType * x ); - - nType * header() const { return const_cast((const nType*)this); } - nType * rightmost() const { return right_end.left ; } - nType * leftmost() const { return left_end.right ; } - - void rightmost( nType * N ) { right_end.left = N ; } - void leftmost( nType * N ) { left_end.right = N ; } - void root( nType * N ) { header()->parent = N ; } - - //------------------------------------ - - virtual ~MapvBase(); - - void remove( MapvNodeBase * ); - - nType * nRoot() const { return header()->parent ; } - nType * nEnd() const { return const_cast( & right_end ); } - nType * nREnd() const { return const_cast( & left_end ); } - - nType * nBegin() const - { return ( left_end.right != nREnd() ) ? left_end.right : nEnd(); } - - nType * nRBegin() const - { return ( right_end.left != nEnd() ) ? right_end.left : nREnd(); } - - MapvBase() : MapvNodeBase(), left_end(), right_end(), Count(0) - { - header()->color = red ; /* Color the header node red */ - leftmost( header()->left = nREnd() ); // left end of the tree - rightmost( header()->right = nEnd() ); // right end of the tree - } - - void insert( nType * y , nType * z , bool z_lt_y ); - - nType * unbalancing_removal( nType ** n ); - static void WarnOptimize(); - - friend class MapvNodeBase ; - template< class dType , class mPolicy > friend class Mapv ; -}; - -inline void MapvNodeBase::remove_from_container() -{ - MapvBase * const c = MapvBase::container(this); - if ( c ) c->remove( this ); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template -struct MapvNewDeletePolicy { - typedef typename Derived_Type::key_type key_type ; - - Derived_Type * create( const key_type & K ) { return new Derived_Type(K); } - - void destroy( Derived_Type * p ) { delete p ; } -}; - -template -struct MapvDeleteOnlyPolicy { - typedef typename Derived_Type::key_type key_type ; - - Derived_Type * create( const key_type & K ) { return (Derived_Type*) 0 ; } - - void destroy( Derived_Type * p ) { delete p ; } -}; - -template -struct MapvNullPolicy { - typedef typename Derived_Type::key_type key_type ; - - Derived_Type * create( const key_type & K ) { return (Derived_Type*) 0 ; } - - void destroy( Derived_Type * p ) {} -}; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -template < class Derived_Type , - class Memory_Policy = MapvDeleteOnlyPolicy > -class Mapv : public MapvBase { -public: - - // 'self' type - typedef Mapv SelfType ; - - // NOTE: value_type == Derived_Type, the chain of - // typedefs insures the correct derivation has occured. - - typedef typename Derived_Type::key_type key_type ; - typedef typename Derived_Type::key_compare key_compare ; - typedef Derived_Type value_type ; - typedef size_t size_type ; - typedef ptrdiff_t difference_type ; - - typedef value_type * pointer ; - typedef const value_type * const_pointer ; - typedef value_type & reference ; - typedef const value_type & const_reference ; - - struct value_compare - : public std::binary_function - { - protected: - key_compare comp ; - public: - bool operator()(const value_type& x, const value_type& y) const - { return comp( x.mapv_key() , y.mapv_key() ); } - }; - - typedef MapvIterNext Next ; - typedef MapvIterPrev Prev ; - - typedef MapvIterator< Derived_Type,Next,Prev> iterator ; - typedef MapvIterator const_iterator ; - typedef MapvIterator< Derived_Type,Prev,Next> reverse_iterator ; - typedef MapvIterator const_reverse_iterator ; - - typedef std::pair pair_iterator_bool ; - -private: - - // Disallow copy and assignment - - Mapv( const SelfType & ); - - SelfType & operator = ( const SelfType & ); - - Memory_Policy memoryPolicy ; - key_compare key_less ; // An "abstract" object - value_compare value_less ; // An "abstract" object - - static const key_type & key( nType * const n ) - { return static_cast*>(n)->mapv_key(); } - - static value_type * cast( nType * n ) - { return static_cast(n); } - -// WORKAROUND: 4/7/2010 -- This works for our SGI Itanium Intel compiler on sasg1132 -#ifdef SIERRA_IA64_OPTIMIZER_FIX - Derived_Type * lb( const key_type & k ) const - { - volatile pType y = nEnd(); // [DGB] -- Altix intel-10.1 optimizer hack - volatile pType x = nRoot(); // [DGB] -- Altix intel-10.1 optimizer hack - while ( x ) { - bool go_right = key_less(key(x), k); - - if (go_right) { - x = x->right; - } - else { - y = x; - x = x->left; - } - } - return cast(y); - } - - Derived_Type * ub( const key_type & k ) const - { - pType y = nEnd(); - pType x = nRoot(); - while ( x ) x = key_less(k,key(x)) ? ( y = x )->left : x->right ; - return cast(y); - } - -#else - Derived_Type * lb( const key_type & k ) const - { - pType y = nEnd(); - pType x = nRoot(); - while ( x ) x = key_less(key(x),k) ? x->right : ( y = x )->left ; - return cast(y); - } - - Derived_Type * ub( const key_type & k ) const - { - pType y = nEnd(); - pType x = nRoot(); - while ( x ) x = key_less(k,key(x)) ? ( y = x )->left : x->right ; - return cast(y); - } -#endif // SIERRA_IA64_OPTIMIZER_FIX - - Derived_Type * f( const key_type & k ) const - { - nType * const e = nEnd(); - nType * const y = lb(k); // k <= y->mapv_key() - - // If 'end()' or k < y->mapv_key() then not found - return cast( ( y == e || key_less(k,key(y)) ) ? e : y ); - } - -public: - - static SelfType * container( const Derived_Type & n ) - { - MapvBase * const c = MapvBase::container(&n); - return c ? static_cast( c ) : (SelfType*) 0 ; - } - - static SelfType * container( const Derived_Type * n ) - { return n ? container( *n ) : (SelfType*) 0 ; } - - // ------------------------------------------------------------------- - - key_compare key_comp() const { return key_less ; } - value_compare value_comp() const { return value_less ; } - - const_iterator begin() const { return const_iterator(cast(nBegin())); } - const_iterator end() const { return const_iterator(cast(nEnd())); } - const_iterator rbegin() const { return const_iterator(cast(nRBegin())); } - const_iterator rend() const { return const_iterator(cast(nREnd())); } - - iterator begin() { return iterator(cast(nBegin())); } - iterator end() { return iterator(cast(nEnd())); } - iterator rbegin() { return iterator(cast(nRBegin())); } - iterator rend() { return iterator(cast(nREnd())); } - - bool empty() const { return MapvBase::Count == 0 ; } - size_type size() const { return MapvBase::Count ; } - - // ------------------------------------------------------------------- - // search operations: - - iterator lower_bound( const key_type & k ) { return iterator( lb(k) ); } - iterator upper_bound( const key_type & k ) { return iterator( ub(k) ); } - - const_iterator lower_bound( const key_type & k ) const - { return const_iterator( lb(k) ); } - - const_iterator upper_bound( const key_type & k ) const - { return const_iterator( ub(k) ); } - - iterator find( const key_type & k ) { return iterator( f(k) ); } - - const_iterator find( const key_type & k ) const - { return const_iterator( f(k) ); } - - // ------------------------------------------------------------------- - - /** Return member with the input key value. - * If does not already existing then create and insert. - */ - value_type & operator[]( const key_type & k ) - { - pType y = nEnd(); - pType x = nRoot(); - - bool flag = true ; - - while ( x ) - { y = x ; x = ( flag = key_less(k, key(x)) ) ? x->left : x->right ; } - - /* flag = k < y , check previous value if exists */ - - const bool k_lt_y = flag ; - - x = flag && y != nBegin() ? ( flag = false , MapvIterPrev::op(y) ) : y ; - - if ( flag || ( flag = key_less( key(x) , k ) ) ) { - x = memoryPolicy.create(k); - MapvBase::insert( y , x , k_lt_y ); - } - return *static_cast(x); - } - - /** Insert an object into this container. - * The input object is itself inserted, no copy is made. - * If the input object is already a member of a container - * then it is removed from that container. - * Return iterator to member with the key value, - * if already existing the (iterator,false) is returned. - */ - - pair_iterator_bool insert( const pointer v ) - { - WarnOptimize(); - pType y = nEnd(); - pType x = nRoot(); - - bool flag = true ; - - while ( x ) { - y = x ; - x = ( flag = key_less(v->mapv_key(), key(x)) ) ? x->left : x->right ; - } - - /* flag = k < y , check previous value if exists */ - - const bool k_lt_y = flag ; - - x = flag && y != nBegin() ? ( flag = false , MapvIterPrev::op(y) ) : y ; - - if ( flag || ( flag = key_less( key(x) , v->mapv_key() ) ) ) { - x = v ; - MapvBase::insert( y , x , k_lt_y ); - } - return pair_iterator_bool( iterator(x), flag ); - } - - pair_iterator_bool insert( reference v ) { return insert( &v ); } - - // ------------------------------------------------------------------- - // Remove & erase operations - - pointer remove( const key_type & k ) - { - pointer v = f(k); - return ( nEnd() != v ) ? ( MapvBase::remove(v) , v ) : (pointer) 0 ; - } - - pointer remove( iterator i ) - { MapvBase::remove( i.n ); return i.n ; } - - void erase( const key_type & K ) - { pointer v = remove(K); if ( v ) memoryPolicy.destroy(v); } - - void erase( iterator i ) - { pointer v = remove(i); if ( v ) memoryPolicy.destroy(v); } - - // ------------------------------------------------------------------- - // construction / destruction - // Destruction will apply the 'Derived_Type::destroy' - // method to each node in the tree. - - Mapv() {} - - void clear() - { - if ( Count ) { - nType * n = nBegin(); - nType * t ; - while ( ( t = unbalancing_removal( &n ) ) ) { - memoryPolicy.destroy( cast( t ) ); - } - } - } - - virtual ~Mapv() { clear(); } - - // ------------------------------------------------------------------- - // Verify the integrity of the tree - - bool verify() const - { - size_type count = 0 ; - const_iterator i = begin(); - const_iterator j ; - - while ( i != end() && - ( ++(j=i) == end() || key_less(i->mapv_key(), j->mapv_key()) ) - && --j == i ) - { ++i ; ++count ; } - - return ( i == end() && count == size() ); - } -}; - -// --------------------------------------------------------------------- - -// For the 'no_delete' operator. - -template < class Derived_Type > -class Mapv_no_delete - : public Mapv > {}; - -// --------------------------------------------------------------------- - -} -#ifdef SIERRA_IA64_OPTIMIZER_FIX -#pragma optimize("", on) -#endif - -#undef mapv_assert - -#endif // STK_UTIL_DIAG_Mapv_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Option.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Option.cpp deleted file mode 100644 index e650c35b2005..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Option.cpp +++ /dev/null @@ -1,131 +0,0 @@ - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace diag { - -OptionMaskParser::Mask -OptionMaskParser::parse( - const char * mask) const -{ - if (mask) { - const std::string mask_string(mask); - - m_status = true; - - std::string::const_iterator it0 = mask_string.begin(); - std::string::const_iterator it1; - std::string::const_iterator it2; - std::string::const_iterator it3; - do { - // Trim preceeding spaces - while (it0 != mask_string.end() && *it0 == ' ') - it0++; - - if (it0 == mask_string.end()) - break; - - for (it1 = it0; it1 != mask_string.end(); ++it1) { - if (*it1 == '(' || *it1 == ':' || *it1 == ',') - break; - } - - // Trim trailing spaces - it2 = it1; - while (it2 != it0 && *(it2 - 1) == ' ') - --it2; - - std::string name(it0, it2); - - // Get argument list - if (*it1 == '(') { - it2 = it1 + 1; - - // Trim preceeding spaces - while (it2 != mask_string.end() && *it2 == ' ') - ++it2; - - int paren_count = 0; - - for (; it1 != mask_string.end(); ++it1) { - if (*it1 == '(') - ++paren_count; - else if (*it1 == ')') { - --paren_count; - if (paren_count == 0) - break; - } - } - it3 = it1; - - // Trim trailing spaces - while (it3 != it2 && *(it3 - 1) == ' ') - --it3; - - // Find next argument start - for (; it1 != mask_string.end(); ++it1) - if (*it1 == ':' || *it1 == ',') - break; - } - else - it2 = it3 = it1; - - const std::string arg(it2, it3); - - parseArg(name, arg); - - it0 = it1 + 1; - } while (it1 != mask_string.end()); - } - - return m_optionMask; -} - - -void -OptionMaskParser::parseArg( - const std::string & name, - const std::string & arg) const -{ - OptionMaskNameMap::const_iterator mask_entry = m_optionMaskNameMap.find(name); - - if (mask_entry != m_optionMaskNameMap.end()) m_optionMask |= (*mask_entry).second.m_mask; - else { - Mask mask_hex = 0; - std::istringstream mask_hex_stream(name.c_str()); - if (mask_hex_stream >> std::resetiosflags(std::ios::basefield) >> mask_hex) - m_optionMask |= mask_hex; - else - m_status = false; - } -} - - -std::ostream & -OptionMaskParser::describe( - std::ostream & os) const -{ - os << "Specify a comma separated list of:" << std::endl; - for (OptionMaskNameMap::const_iterator it = m_optionMaskNameMap.begin(); it != m_optionMaskNameMap.end(); ++it) - (*it).second.describe(os); - - return os; -} - - -std::ostream & -OptionMaskName::describe( - std::ostream & os) const -{ - return os << " " << std::left << std::setw(20) << m_name << "\t" << m_description << std::endl; -} - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Option.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Option.hpp deleted file mode 100644 index 0b2645e85ee8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Option.hpp +++ /dev/null @@ -1,362 +0,0 @@ -#ifndef STK_UTIL_DIAG_Option_h -#define STK_UTIL_DIAG_Option_h - -#include - -namespace stk_classic { -namespace diag { - - - -typedef unsigned long OptionMask; - -/** - * @brief Class OptionDescription is an interface class for describing a - * command line option or option value. - * - */ -struct OptionDescription -{ - /** - * Destroys a OptionDescription instance. - * - */ - virtual ~OptionDescription() - {} - - /** - * @brief Member function describe prints a description of the option to - * the stream. - * - * @param os a std::ostream reference to print to - * description to. - * - * @return a std::ostream reference to the output - * stream. - */ - virtual std::ostream &describe(std::ostream &os) const = 0; -}; - - -/** - * @brief Class Option holds the command line name, environment variable name - * and the current value of an option. It implements the OptionDescription - * interface so that a help description may be generated. - * - */ -struct Option : public OptionDescription -{ - /** - * Creates a new Option instance. - * - */ - Option() - : m_name(""), - m_envName(""), - m_description(""), - m_value(""), - m_subOptionDescription(0) - {} - - /** - * Creates a new Option instance. - * - * @param name a std::string const reference to the name - * of the option. This is used for the command line - * option argument. - * - * @param env_name a std::string const reference to the - * environment variable name. - * - * @param value a std::string const reference to the - * default/initial value of the option. - * - * @param description a std::string const reference to the - * description of the option. This is printed when - * the -h option is parsed. - * - * @param sub_option_description an OptionDescription const pointer to sub - * options which are available for the option. - */ - Option(const std::string &name, const std::string &env_name, const std::string &value = std::string(), - const std::string &description = "No description available", - const OptionDescription *sub_option_description = 0) - : m_name(name), - m_envName(env_name), - m_description(description), - m_value(value), - m_subOptionDescription(sub_option_description) - {} - - /** - * Creates a new Option instance. - * - * @param option an Option const reference to the Option to - * copy. - * - */ - Option(const Option &option) - : m_name(option.m_name), - m_envName(option.m_envName), - m_description(option.m_description), - m_value(option.m_value), - m_subOptionDescription(option.m_subOptionDescription) - {} - - - /** - * @brief Member function operator= assigns an option from another option. - * - * @param option an Option const reference to the rhs option. - * - * @return an Option reference to the lhs option. - */ - Option &operator=(const Option &option) - { - m_name = option.m_name; - m_envName = option.m_envName; - m_description = option.m_description; - m_value = option.m_value; - m_subOptionDescription = option.m_subOptionDescription; - return *this; - } - - /** - * Destroys a Option instance. - * - */ - virtual ~Option() - {} - - const std::string &getName() const { - return m_name; - } - - const std::string &getValue() const { - return m_value; - } - - /** - * @brief Member function describe prints a description of the option to - * the stream. - * - * @param os a std::ostream reference to print to - * description to. - * - * @return a std::ostream reference to the output - * stream. - */ - virtual std::ostream &describe(std::ostream &os) const; - - operator std::string &() { - return m_value; - } - - std::string m_name; ///< Name/Command line option name - std::string m_envName; ///< Environment variable name - std::string m_description; ///< Brief '-h' description - std::string m_value; ///< Value of option - const OptionDescription * m_subOptionDescription; ///< Suboptions (used for '-h' parsing) -}; - - -/** - * @brief Class OptionMaskName ... - * - */ -struct OptionMaskName -{ - /** - * Creates a new OptionMaskName instance. - * - */ - OptionMaskName() - : m_name(""), - m_mask(0), - m_description("") - {} - - /** - * Creates a new OptionMaskName instance. - * - * @param name a std::string variable ... - * @param mask an OptionMask variable ... - * @param description a std::string variable ... - */ - OptionMaskName(const std::string &name, const OptionMask &mask, const std::string &description = "No description available") - : m_name(name), - m_mask(mask), - m_description(description) - {} - - /** - * Destroys a OptionMaskName instance. - * - */ - virtual ~OptionMaskName() - {} - - /** - * @brief Member function < ... - * - * @param o an OptionMaskName variable ... - * @return a bool ... - */ - bool operator<(const OptionMaskName &o) const { - return m_name < o.m_name; - } - - /** - * @brief Member function describe ... - * - * @param os a std::ostream variable ... - * @return a std::ostream ... - */ - virtual std::ostream &describe(std::ostream &os) const; - - std::string m_name; - OptionMask m_mask; - std::string m_description; -}; - - -/** - * @brief Class OptionMaskNameMap ... - * - */ -class OptionMaskNameMap: public std::map -{ -public: - /** - * @brief Member function mask ... - * - * @param name a std::string variable ... - * @param mask an OptionMask variable ... - * @param description a std::string variable ... - */ - void mask(const std::string &name, const OptionMask l_mask, const std::string &description) { - iterator it = find(name); - if (it == end()) - insert(std::make_pair(name, OptionMaskName(name, l_mask, description))); - else { - (*it).second.m_mask = l_mask; - (*it).second.m_description = description; - } - } -}; - - -/** - * Class OptionMaskParser defines a mapping between strings and bit masks and - * output streams. - * - * After populating a Parser object, parse() will parse the input string. The - * getMask() and virtual getOutputStream() functions will return the print parsed - * print mask and the selected output stream. - * - */ -class OptionMaskParser : public OptionDescription -{ -public: - typedef OptionMask Mask; ///< Mask for this option - -public: - /** - * Creates a new OptionMaskParser instance. - * - */ - OptionMaskParser() - : m_optionMaskNameMap(), - m_optionMask(0), - m_status(true) - {} - - /** - * Destroys a OptionMaskParser instance. - * - */ - virtual ~OptionMaskParser() - {} - - const OptionMaskNameMap &getOptionMaskNameMap() const { - return m_optionMaskNameMap; - } - - /** - * Member function parse parses the string - * - * @param mask a char const pointer of the string to parse. - * - * @return a Mask value of the parsed bitmask. - */ - virtual Mask parse(const char *mask) const; - - /** - * Member function parseArg parses the argument and its argument values. - * - * @param name a std::string const reference to the argument - * name. - * - * @param arg a std::string const reference to the argument - * values. - */ - virtual void parseArg(const std::string &name, const std::string &arg) const; - - /** - * Member function operator[] returns the print mask with the specified - * name. If the name is not found, a new entry is added. - * - * @param name a std::string const reference of the name of - * the mask. - * - * @return a Mask reference of the print - * mask associated with the print mask name. - */ - Mask &operator[](const std::string &name) { - return m_optionMaskNameMap[name].m_mask; - } - - /** - * Member function mask adds a named mask to the parser. The mask can also - * be given a description which is displayed using the describe() function. - * - * @param name a std::string const reference of the name of - * the mask. - * - * @param mask a Mask value to associate with the name - * - * @param description a std::string const reference which describes - * the mask. - * - */ - void mask(const std::string &name, const Mask l_mask, const std::string &description) { - m_optionMaskNameMap.mask(name, l_mask, description); - } - - /** - * Member function describe ... - * - * @param os a std::ostream variable ... - * @return a std::ostream ... - */ - std::ostream &describe(std::ostream &os) const; - -protected: - OptionMaskNameMap m_optionMaskNameMap; ///< Mask name vector - mutable OptionMask m_optionMask; ///< Most recently parsed mask - mutable bool m_status; ///< Result of most recent parse -}; - -} // namespace diag -} // namespace stk_classic - -namespace sierra { -typedef stk_classic::diag::OptionMask OptionMask; -typedef stk_classic::diag::OptionDescription OptionDescription; -typedef stk_classic::diag::Option Option; -typedef stk_classic::diag::OptionMaskName OptionMaskName; -typedef stk_classic::diag::OptionMaskNameMap OptionMaskNameMap; -typedef stk_classic::diag::OptionMaskParser OptionMaskParser; -} // namespace sierra - -#endif // STK_UTIL_DIAG_Option_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.cpp deleted file mode 100644 index 0d02653c74af..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.cpp +++ /dev/null @@ -1,765 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2005-2009, 2011 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#ifdef STK_BUILT_IN_SIERRA -# include -#endif -#include - -#include -#include -#include -#include - -#include - -#if defined(__GNUC__) -#include -#ifndef __APPLE__ -#include -#else -#include -#endif -#include -#include -#include -#if __GNUC__ == 3 || __GNUC__ == 4 -#include -#endif - -#elif defined(__PGI) -#include -#include -#include -#include -#include - -#elif defined(__sun) -#include -#include -#include -#include -#include -#include - -#elif defined(__SUNPRO_CC) -#include -#include -#include -#include -#endif - -#if defined(__PUMAGON__) -extern "C" { -#include -#include -} - -#elif defined(__sgi) -#include -#include - -#elif defined(REDS) -#include -#include -#include -#include -#include -#include -extern void *__heap_start; ///< Magic address of end of instruction/static data -extern void *__heap_end; ///< Magic address of end of heap - -#elif defined(__JVN) -#include -#include -#include -#include -#include -#include - -#elif defined(__IBMC__) || defined(__IBMCPP__) -#include -#include -#include -#include - -#else -#include -#include -#include -#endif - -#include - -// -// NKC 2/21/08 Some of the calls in this file bomb out purify. Uncomment the line below if trying -// to build a purify executable. -// -//#define PURIFY_BUILD - -#if defined(REDS) -namespace { - size_t get_redstorm_base_available_memory(); -} -#endif - -namespace sierra { - -#ifdef SIERRA_USE_PLATFORM_DEMANGLER - - -#if defined(__GNUC__) - -#if (__GNUC__ == 3) -std::string -demangle( - const char * symbol) -{ -#ifdef PURIFY_BUILD - return symbol; -#else - std::string s; - int status; - - // GR: PathScale versions 4.x.x attempt to write the length of the demangled - // string to the third argument of __cxa_demangle even if a NULL value is - // provided. This seems to be a compiler bug. The following code change - // provides a work around to prevent a segfault. - //char *demangled_symbol = abi::__cxa_demangle(symbol, 0, 0, &status); - size_t len = 0; - char *demangled_symbol = abi::__cxa_demangle(symbol, 0, &len, &status); - - if (demangled_symbol) { - s = std::string(demangled_symbol); - free(demangled_symbol); - } - - if (status != 0) - s = std::string(symbol); - - return s; -#endif -} - -#elif (__GNUC__ == 4) -std::string -demangle( - const char * symbol) -{ -#ifdef PURIFY_BUILD - return symbol; -#else - std::string s; - - int status; - - // GR: PathScale versions 4.x.x attempt to write the length of the demangled - // string to the third argument of __cxa_demangle even if a NULL value is - // provided. This seems to be a compiler bug. The following code change - // provides a work around to prevent a segfault. - //char *demangled_symbol = __cxxabiv1::__cxa_demangle(symbol, 0, 0, &status); - size_t len = 0; - char *demangled_symbol = __cxxabiv1::__cxa_demangle(symbol, 0, &len, &status); - - if (demangled_symbol) { - s = std::string(demangled_symbol); - free(demangled_symbol); - } - - if (status != 0) - s = std::string(symbol); - - return s; -#endif -} -#endif // (__GNUC__ == 3) - -#else -std::string demangle(const char *symbol) { - return symbol; -} -#endif // defined(__GNUC__) - -#else -const char *demangle(const char *symbol) { - return symbol; -} -#endif // SIERRA_USE_PLATFORM_DEMANGLER - - -namespace Env { - -#if defined(REDS) -// Manipulate standard output buffering -void -startup_preparallel_platform() -{ - static char redstorm_cout_buf[32678]; - std::cout.rdbuf()->pubsetbuf(redstorm_cout_buf, sizeof(redstorm_cout_buf)); - - static char redstorm_stdout_buf[32678]; - std::setvbuf(stdout, redstorm_stdout_buf, _IOFBF, sizeof(redstorm_stdout_buf)); - - static char redstorm_cerr_buf[32678]; - std::cerr.rdbuf()->pubsetbuf(redstorm_cerr_buf, sizeof(redstorm_cerr_buf)); - - static char redstorm_stderr_buf[32678]; - std::setvbuf(stderr, redstorm_stderr_buf, _IOFBF, sizeof(redstorm_stderr_buf)); - - get_available_memory(); -} - -#elif defined(_AIX) -// Cleanup AIX locale initialization problems -void -startup_preparallel_platform() -{ - std::locale loc("POSIX"); - - std::locale::global(loc); // std::locale::classic()); - std::cout.imbue(loc); // std::locale::classic()); - std::cin.imbue(loc); // std::locale::classic()); - - std::ostringstream strout; - strout << "Don't ask why the IBM locale works if I do this " << 10000000 << std::endl; -} - -#else -void -startup_preparallel_platform() -{} -#endif - - -double -wall_now() -{ - timeval tp; - struct timezone tz; - gettimeofday(&tp, &tz); - return (tp.tv_sec + (((double)(tp.tv_usec))/1000000.0)); -} - - -double -cpu_now() -{ -#if defined(REDS) - struct rusage my_rusage; - - getrusage(RUSAGE_SELF, &my_rusage); - - return (double) (my_rusage.ru_utime.tv_sec) - + ((double)(my_rusage.ru_utime.tv_usec))*1.0e-6; - -#elif ! defined(__PGI) - struct rusage my_rusage; - - getrusage(RUSAGE_SELF, &my_rusage); - - return (double) (my_rusage.ru_utime.tv_sec + my_rusage.ru_stime.tv_sec) - + ((double)(my_rusage.ru_utime.tv_usec + my_rusage.ru_stime.tv_usec))*1.0e-6; -#else - return 0; -#endif -} - - -void -get_heap_info( - size_t & heap_size, - size_t & largest_free) -{ - heap_size = 0; - largest_free = 0; - -#if defined(SIERRA_HEAP_INFO) - -# if defined(SIERRA_PTMALLOC3_ALLOCATOR) || defined(SIERRA_PTMALLOC2_ALLOCATOR) - heap_size = malloc_used(); - -# elif 0 // if defined(REDS) // Redstorm now links in gnu's malloc - static size_t reds_fragments; - static unsigned long reds_total_free; - static unsigned long reds_heap_size; - static unsigned long reds_largest_free; - - ::heap_info(&reds_fragments, &reds_total_free, &reds_largest_free, &reds_heap_size); - - heap_size = reds_heap_size; - largest_free = reds_largest_free; - - slibout.m(Slib::LOG_MEMORY) <<"reds_fragments " << reds_fragments - << ", reds_total_free " << reds_total_free - << ", reds_largest_free " << reds_largest_free - << ", reds_heap_size " << reds_heap_size << Diag::dendl; - -# elif ( defined(__linux__) || defined(REDS) ) && ! defined(__IBMCPP__) - static struct mallinfo minfo; - minfo = mallinfo(); - heap_size = (unsigned int) minfo.uordblks + (unsigned int) minfo.hblkhd; - largest_free = (unsigned int) minfo.fordblks; - - slibout.m(Slib::LOG_MEMORY) << "size_t size " << sizeof(size_t)*8 << " bits" - << ", heap size " << heap_size - << ", arena " << (unsigned int) minfo.arena - << ", ordblks " << minfo.ordblks - << ", smblks " << minfo.smblks - << ", hblks " << minfo.hblks - << ", hblkhd " << (unsigned int) minfo.hblkhd - << ", usmblks " << minfo.usmblks - << ", fsmblks " << minfo.fsmblks - << ", uordblks " << (unsigned int) minfo.uordblks - << ", fordblks " << (unsigned int) minfo.fordblks - << ", keepcost " << minfo.keepcost << Diag::dendl; - - -# elif defined(__sun) - pstatus_t proc_status; - - std::ifstream proc("/proc/self/status", std::ios_base::in|std::ios_base::binary); - if (proc) { - proc.read((char *)&proc_status, sizeof(proc_status)); - heap_size = proc_status.pr_brksize; - slibout.m(Slib::LOG_MEMORY) <<"pr_brksize " << proc_status.pr_brksize - << ", pr_stksize " << proc_status.pr_stksize << Diag::dendl; - } -# endif -#endif // defined(SIERRA_HEAP_INFO) -} - - -size_t get_available_memory() -{ -#if !defined(REDS) - // The value returned for _SC_AVPHYS_PAGES is the amount of memory - // the application can use without hindering any other process - // (given that no other process increases its memory usage). -#if !defined(__APPLE__) && !defined(__FreeBSD__) - static size_t pagesize = getpagesize(); - size_t avail = sysconf(_SC_AVPHYS_PAGES); - return avail * pagesize; -#else - // _SC_AVPHYS_PAGES does not exist on FreeBSD/Apple - return 0; -#endif -#else - // On redstorm, we get an estimate of the available memory at the - // time that the application starts up and then we get the currently - // available memory by subtracting the used memory from that initial - // value. - static size_t initial_memory_size = 0; - if (initial_memory_size == 0) { - initial_memory_size = get_redstorm_base_available_memory(); - } - return initial_memory_size - get_heap_usage(); -#endif -} - -void -get_memory_info( - size_t & memory_usage, - size_t & faults) -{ - memory_usage = 0; - faults = 0; - -#if defined(SIERRA_MEMORY_INFO) -# if defined(REDS) - memory_usage = (size_t) __heap_start + get_heap_usage(); - -# elif defined(__linux__) - std::ifstream proc("/proc/self/stat", std::ios_base::in|std::ios_base::binary); - if (proc) { - - std::string s; - int i; - for (i = 0; i < 11; ++i) - proc >> s; - - proc >> faults; - ++i; - - for (; i < 22; ++i) - proc >> s; - - proc >> memory_usage; - ++i; - } -# elif defined(__sun) - { - - psinfo_t proc_info; - - std::ifstream proc("/proc/self/psinfo", std::ios_base::in|std::ios_base::binary); - if (proc) { - proc.read((char *)&proc_info, sizeof(proc_info)); - memory_usage = proc_info.pr_size*1024; - } - } - - { - prusage_t proc_usage; - - std::ifstream proc("/proc/self/usage", std::ios_base::in|std::ios_base::binary); - if (proc) { - proc.read((char *)&proc_usage, sizeof(proc_usage)); - faults = proc_usage.pr_majf; - } - } -# endif -#endif // defined(SIERRA_MEMORY_INFO) -} - - -double -vm_now() -{ - size_t memory_usage; - size_t faults; - - get_memory_info(memory_usage, faults); - - return (double) memory_usage; -} - - -std::string -hostname() -{ - char buf[255]; - ::gethostname(buf, sizeof(buf)); - return std::string(buf); -} - - -std::string -domainname() -{ -#if defined(__PUMAGON__) || defined(REDS) - return std::string(".sandia.gov"); - -#elif defined(__sun) - std::string domain("."); - char buf[255]; - - ::sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf)); - if (std::strlen(buf)) { - domain += buf; - } - return domain; - -#else //#elif defined(__linux) || defined(__sgi) || defined(_AIX) - std::string domain("."); - char buf[255]; - - ::getdomainname(buf, sizeof(buf)); - if (::strlen(buf)) { - domain += buf; - } - return domain; - -#endif -} - - -std::string -username() -{ -#if defined(REDS) || defined(__CRAYXT_COMPUTE_LINUX_TARGET) - if (get_param("username").empty()) - return "unknown"; - else - return get_param("username"); -#else - struct passwd *user_info = ::getpwuid(::geteuid()); - - return (user_info ? user_info->pw_name : "unknown"); -#endif -} - - -std::string -hardware() -{ -#ifndef __sgi - struct utsname uts_name; - - uname(&uts_name); - - return uts_name.machine; -#else - std::string s; - return s; -#endif -} - - -std::string -osname() -{ -#ifndef __sgi - struct utsname uts_name; - - uname(&uts_name); - - return uts_name.sysname; -#else - std::string s; - return s; -#endif -} - - -std::string -osversion() -{ -#ifndef __sgi - struct utsname uts_name; - - uname(&uts_name); - - return uts_name.release; -#else - std::string s; - return s; -#endif -} - - -int -pid() -{ - return ::getpid(); -} - - -int -pgrp() -{ -#if defined(__PUMAGON__) || defined(REDS) - return 0; -#else - return ::getpgrp(); -#endif -} - - -bool -path_access( - const std::string & name, - int mode) - -{ - return !name.empty() && ::access(name.c_str(), mode) == 0; -} - - -bool -path_exists( - const std::string & name) -{ - return path_access(name, F_OK); -} - - -bool -path_read_access( - const std::string & name) -{ - return path_access(name, R_OK); -} - - -bool -path_write_access( - const std::string & name) -{ - return path_access(name, W_OK); -} - - -namespace { - -struct flock * -file_lock( - short type, - short whence) -{ -// /* %TRACE[SPEC]% */ Tracespec trace__("sierra::Fmwk::::file_lock( short type, short whence)"); /* %TRACE% */ - static struct flock ret; - ret.l_type = type; - ret.l_start = 0; - ret.l_whence = whence; - ret.l_len = 0; - ret.l_pid = 0; //getpid(); - return &ret; -} - -} // namespace - -bool -write_lock( - int fd) -{ - int i =::fcntl(fd, F_SETLK, file_lock(F_WRLCK, SEEK_SET)); -// if (i == -1) -// fmwkout << "Write lock failed " << errno << dendl; - - return i != -1; -} - - -bool -release_lock( - int fd) -{ - int i =::fcntl(fd, F_SETLK, file_lock(F_UNLCK, SEEK_SET)); -// if (i == -1) -// fmwkout << "Release lock failed " << errno << dendl; - - return i != -1; -} - - -bool -read_lock( - int fd) -{ - return ::fcntl(fd, F_SETLK, file_lock(F_RDLCK, SEEK_SET)) != -1; -} - - -bool -append_lock( - int fd) -{ - return ::fcntl(fd, F_SETLK, file_lock(F_WRLCK, SEEK_END)) != -1; -} - -} // namespace Env -} // namespace sierra - -#if defined(REDS) - -#if defined(__GNUC__) -namespace { - size_t get_redstorm_base_available_memory() - { - return 0; - } -} -#else -// Written by Mike Davis -#include -namespace { - - void stk_ptr (unsigned long *sp) { - asm ("movq %rsp, (%rdi)"); - } - - size_t get_redstorm_base_available_memory() - { - char *p1; - size_t stack_top; - size_t avail_mem; - size_t heap_base; - size_t stack_base; - size_t stack_size; - size_t unmapped_top = 4 * 1048576; - size_t os_foot = 140 * 1048576; - size_t avail_heap; - - /** - * Get the current stack pointer, - * and use that as an estimate of the stack top - */ - stk_ptr (&stack_top); - - /** - * Round stack_top up to the next multiple of 2 MB - */ - stack_top &= ~0x1fffff; - stack_top += 0x200000; - - /** - * Compute the available memory on the node, - * as the stack top plus the size of an unmapped region - * above the stack. - */ - avail_mem = stack_top + unmapped_top; - - /** - * Deduct the size of the OS footprint from available memory - */ - avail_mem -= os_foot; - - /** - * Divide the available memory among - * the number of processes running on the node - */ - avail_mem /= _my_pcb->upcb_vnm_degree; - - /** - * Determine the address of the base of the heap, - * estimated to be the address of an allocated test block - */ - p1 = (char *) malloc (1); - heap_base = (size_t) p1; - free (p1); - - /** - * Compute the available heap space as the difference between - * the available memory for the process - * and the base address of the heap - */ - avail_heap = avail_mem - heap_base; - - /** - * Determine the base address of the stack; - * the address of the PCB is in a 2 MB page below the stack - */ - stack_base = (size_t) _my_pcb; - stack_base &= ~0x1fffff; - stack_base += 0x400000; - - /** - * Deduct the size of the stack - * and the size of the unmapped region at the top of the stack - * from the available heap - */ - stack_size = stack_top - stack_base; - avail_heap -= unmapped_top; - avail_heap -= stack_size; - - return avail_heap; - } -} -#endif -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.hpp deleted file mode 100644 index a1aa1df8e993..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Platform.hpp +++ /dev/null @@ -1,300 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003, 2008 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_Platform_h -#define STK_UTIL_DIAG_Platform_h - -#include -#include -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include -#include - -namespace sierra { -namespace Env { - -/// -/// @addtogroup EnvDetail -/// @{ -/// - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function startup_preparallel_platform ... - * - */ -void startup_preparallel_platform(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function hostname returns the hostname of the host running the - * application. - * - * @return a String value of the host name obtained from - * the operating system. - */ -std::string hostname(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function domainname returns the domainname of the domain running the - * application. - * - * @return a String value of the domain name obtained from - * the operating system. - */ -std::string domainname(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function username returns the username of the user running the - * application. - * - * @return a String value of the username obtained from - * the operating system. - */ -std::string username(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function hardware returns the hardware type of the host running the - * application. - * - * @return a String value of the machine - * field of the uname system call or equivalent - * obtained from the operating system. - */ -std::string hardware(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function osname returns the operating system nameof the host running the - * application. - * - * @return a String value of the sysname - * field of the uname system call or equivalent - * obtained from the operating system. - */ -std::string osname(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function osversion returns the hardware type of the host running the - * application. - * - * @return a String value of the release - * field of the uname system call or equivalent - * obtained from the operating system. - */ -std::string osversion(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function pid returns the process id of the process running the - * application. - * - * @return a int value of the process id obtained from - * the operating system. - */ -int pid(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function pgrp returns the process group id of the process running - * the application. - * - * @return a int value of the process group id obtained from - * the operating system. - */ -int pgrp(); - - -/** - * @brief Member function get_heap_info returns the amount of heap - * memory used in bytes and the largest free block of memory in bytes. - * - * @param heap_size a size_t returns the amount of heap - * memory used in bytes. - * - * @param largest_free a size_t returns the largest free block - * of memory. - * - */ -void get_heap_info(size_t &heap_size, size_t &largest_free); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function get_heap_usage returns the number of bytes used by the heap. - * - * @return a size_t value of the number of bytes used by - * the heap. - */ -inline size_t get_heap_usage() { - size_t heap_size; - size_t largest_free; - get_heap_info(heap_size, largest_free); - - return heap_size; -} - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function get_available_memory returns an estimation of the amount of memory available to the process. - * - * @return a size_t value of the number of bytes available to the process. - */ -size_t get_available_memory(); - - -/** - * @ingroup EnvRuntimeInformationDetail - * @brief Function get_memory_info returns the total memory usage of the - * process and the number of page faults accumulated by the process. - * - * @param memory_usage a size_t reference to receive the number of - * bytes currently used by the process. - * - * @param faults a size_t reference to treceive the number of - * page faults incurred by the process. - * - */ -void get_memory_info(size_t &memory_usage, size_t &faults); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutput - * @brief Function path_exists returns true if the path exists. - * - * @param path a String const reference to the path to have - * existence tested. - * - * @return a bool value of true if the path exists. - */ -bool path_exists(const std::string &path); - - -/** - * @ingroup EnvRuntimeInformation EnvOutputDetail - * @brief Function path_access returns true if the process has permission to - * access path with the specified mode. - * - * @param path a String const reference to the path to check - * for mode access. - * - * @param mode an int value of the mode to test. - * - * @return a bool value of true of the process has - * permission to access the path with mode - * access. - */ -bool path_access(const std::string &path, int mode); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function path_read_access returns true if the process has read - * access to the path. - * - * @param path a String const reference to the path to check - * for read access. - * - * @return a bool value of true of the process has - * permission to access the path with read access. - */ -bool path_read_access(const std::string &path); - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function path_write_access returns true if the process has write - * access to the path. - * - * @param path a String const reference to the path to check - * for write access. - * - * @return a bool value of true of the process has - * permission to access the path with write access. - */ -bool path_write_access(const std::string &path); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function read_lock returns true if the process was able to place - * a shared lock on the specified file descriptor. - * - * @param fd an int value of the file description to - * attempt to lock. - * - * @return a bool value of true of the lock succeeded. - */ -bool read_lock(int fd); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function write_lock returns true if the process was able to place - * an exclusive lock on the specified file descriptor. - * - * @param fd an int value of the file description to - * attempt to lock. - * - * @return a bool value of true of the lock succeeded. - */ -bool write_lock(int fd); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function append_lock returns true if the process was able to place - * an exclusive lock on the end of the specified file descriptor. Existing records may - * still be accessed. - * - * @param fd an int value of the file description to - * attempt to lock. - * - * @return a bool value of true of the lock succeeded. - */ -bool append_lock(int fd); - - -/** - * @ingroup EnvRuntimeInformationDetail EnvOutputDetail - * @brief Function release_lock returns true if the process was able to - * release a lock previously palced on the specified file descriptor. - * - * @param fd an int value of the file description to have - * the lock released. - * - * @return a bool value of true of the lock release - * succeeded. - */ -bool release_lock(int fd); - -/// -/// @} -/// - -} // namespace Env -} // namespace sierra - -#endif // STK_UTIL_DIAG_Platform_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.cpp deleted file mode 100644 index 23f1fc56c1e4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.cpp +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace sierra { - - std::string CreateSubCycleInputFile( const std::string& ifile, bool debug ) { - - boost::regex reStripFileExtension; - std::string regionStripFileExtensionRegexp("\\.[^.]*$"); - reStripFileExtension.assign(regionStripFileExtensionRegexp); - std::string baseName = boost::regex_replace(ifile,reStripFileExtension,""); - std::string extension = ifile.substr(baseName.size(),ifile.size()); - if ( debug ) { - std::cout << "Input Base Name: " << baseName << " Extension: " << extension << std::endl; - } - std::string nfile = baseName; - nfile.append(".subcycle"); - nfile.append(extension); - - if(sierra::Env::parallel_rank() == 0) { // Write New File Only on processor 0 - - std::cout << "Input File: " << ifile << " Being Converted for Subcycling to: " << nfile << std::endl; - - boost::regex reName; - std::string regionNameRegexp("\\s+region\\s+\\w+"); - reName.assign(regionNameRegexp,boost::regex_constants::icase); - - std::string appendCoarseName("$MATCH_AutoCoarseRegion"); - std::string appendFineName("$MATCH_AutoFineRegion"); - - boost::regex reOutput; - std::string regionOutputRegexp("\\s*database\\s+name\\s*=\\s*"); - reOutput.assign(regionOutputRegexp,boost::regex_constants::icase); - - std::string prependCoarseName("$MATCHCoarse_"); - std::string prependFineName("$MATCHFine_"); - - boost::regex reBegin; - reBegin.assign("^\\s*begin\\>", boost::regex_constants::icase); - boost::regex reEnd; - reEnd.assign("^\\s*end\\>", boost::regex_constants::icase); - - boost::regex reRegion; - std::string regionRegexp("^\\s*begin\\s+presto\\s+region\\>"); - reRegion.assign(regionRegexp,boost::regex_constants::icase); - std::vector< std::vector< std::string > > extractedRegion = ExtractCommandBlocksInFile(regionRegexp, ifile, debug); - if (extractedRegion.size()!=1) throw RuntimeError() << "Subcycling currently supports only one region."; - - boost::regex reRegionParameters; - std::string regionParametersRegexp("^\\s*begin\\s+parameters\\s+for\\s+presto\\s+region\\>"); - reRegionParameters.assign(regionParametersRegexp,boost::regex_constants::icase); - std::vector< std::vector< std::string > > extractedRegionParameters = ExtractCommandBlocksInFile(regionParametersRegexp, ifile, debug); - - boost::regex reTimeStepIncrease; - std::string timeStepIncreaseRegexp("^\\s*time\\s+step\\s+increase\\s+factor\\s*=\\s*"); - reTimeStepIncrease.assign(timeStepIncreaseRegexp,boost::regex_constants::icase); - - std::ofstream nstream; - - nstream.open(nfile.c_str()); - - std::ifstream fileStream(ifile.c_str()); - if ( fileStream.bad() ) { - std::cerr << "Unable to open file " << ifile << std::endl; - } - std::string line; - int numOpen = 0; - int stopWriteCondition = -1; - std::vector stopWriteConditions; - stopWriteConditions.push_back(0); // Region - stopWriteConditions.push_back(0); // Region Parameters - int regionParamBlock = 0; - while( std::getline( fileStream, line ) ) { - // Monitor numOpen block commands - if ( boost::regex_search(line,reBegin) ) { - numOpen += 1; - } else if ( boost::regex_search(line,reEnd) ) { - numOpen -= 1; - } - if ( boost::regex_search(line,reRegion) ) { // Check For Region Block - stopWriteCondition = 0; - stopWriteConditions[stopWriteCondition] = numOpen - 1; - std::string newLine; - for( unsigned int i(0); i < extractedRegion[0].size(); ++i ) { - if ( i == 1 ) { - std::string levelLine = " subcycle region level = 0 #THIS IS COARSE REGION"; - nstream << levelLine << std::endl; - } - newLine = boost::regex_replace(extractedRegion[0][i],reName,appendCoarseName); - newLine = boost::regex_replace(newLine,reOutput,prependCoarseName); - nstream << newLine << std::endl; - } - for( unsigned int i(0); i < extractedRegion[0].size(); ++i ) { - if ( i == 1 ) { - std::string levelLine = " subcycle region level = 1 #THIS IS FINE REGION"; - nstream << levelLine << std::endl; - } - newLine = boost::regex_replace(extractedRegion[0][i],reName,appendFineName); - newLine = boost::regex_replace(newLine,reOutput,prependFineName); - nstream << newLine << std::endl; - } - } else if ( boost::regex_search(line,reRegionParameters) ) { // Check For Region Parameters - stopWriteCondition = 1; - stopWriteConditions[stopWriteCondition] = numOpen - 1; - bool needsTimeStepIncrease = true; - for( unsigned int i(0); i < extractedRegionParameters[regionParamBlock].size(); ++i ) { - nstream << boost::regex_replace(extractedRegionParameters[regionParamBlock][i],reName,appendCoarseName) << std::endl; - if ( boost::regex_search( extractedRegionParameters[regionParamBlock][i], reTimeStepIncrease ) ) { - needsTimeStepIncrease = false; - } - } - for( unsigned int i(0); i < extractedRegionParameters[regionParamBlock].size(); ++i ) { - if ( needsTimeStepIncrease && i == (extractedRegionParameters[regionParamBlock].size() - 1) ) { - nstream << " time step increase factor = 2.0" << std::endl; - } - nstream << boost::regex_replace(extractedRegionParameters[regionParamBlock][i],reName,appendFineName) << std::endl; - } - regionParamBlock++; - } - if ( stopWriteCondition < 0 ) { - nstream << line << std::endl; - } else { - if ( stopWriteConditions[stopWriteCondition] == numOpen ) { - stopWriteCondition = -1; - } - } - } - nstream.close(); - } - - MPI_Barrier( sierra::Env::parallel_comm() ); // Wait for proccessor to write new file - - return nfile; - - } - - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.hpp deleted file mode 100644 index c979ec09628f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PreParse.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef STK_UTIL_DIAG_PreParse_hpp -#define STK_UTIL_DIAG_PreParse_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace sierra { - - inline bool CaseInSensitiveRegexInFile( const std::string& regExp, const std::string& file, bool debug = false ) { - std::ifstream fileStream(file.c_str()); - if ( fileStream.bad() ) { - std::cerr << "Unable to open file " << file << std::endl; - } - std::string line; - boost::regex re; - re.assign(regExp, boost::regex_constants::icase); - while( std::getline( fileStream, line ) ) { - if ( boost::regex_search(line,re) ) { - if ( debug ) { - std::cout << "CaseInSensitiveRegexInFile() found: " << std::endl << line << std::endl; - std::cout << "CaseInSensitiveRegexInFile() with: " << std::endl << regExp << std::endl; - } - return true; - } - } - return false; - } - - inline std::vector< std::vector< std::string > > ExtractCommandBlocksInFile( const std::string& beginRegExp, const std::string& file, bool debug = false ) { - std::vector< std::vector< std::string > > extractedCommandBlocks; - std::vector< std::string > extractedCommandBlock; - std::ifstream fileStream(file.c_str()); - if ( fileStream.bad() ) { - std::cerr << "Unable to open file " << file << std::endl; - } - std::string line; - boost::regex reBeginStart; - reBeginStart.assign(beginRegExp, boost::regex_constants::icase); - boost::regex reBegin; - reBegin.assign("^\\s*begin\\>", boost::regex_constants::icase); - boost::regex reEnd; - reEnd.assign("^\\s*end\\>", boost::regex_constants::icase); - bool extract = false; - int numOpen = 0; - while( std::getline( fileStream, line ) ) { - if ( !extract && boost::regex_search(line,reBeginStart) ) { - extract = true; - if ( debug ) { - std::cout << "ExtractCommandBlocksInFile() started: " << std::endl << line << std::endl; - } - } - if ( extract ) { - extractedCommandBlock.push_back(line); - if ( boost::regex_search(line,reBegin) ) { - numOpen += 1; - } else if ( boost::regex_search(line,reEnd) ) { - numOpen -= 1; - } - if ( numOpen == 0 ) { - extract = false; - extractedCommandBlocks.push_back(extractedCommandBlock); - extractedCommandBlock.clear(); - if ( debug ) { - std::cout << "ExtractCommandBlocksInFile() stopped: " << std::endl << line << std::endl; - } - } - } - } - return extractedCommandBlocks; - } - - std::string CreateSubCycleInputFile( const std::string& ifile, bool debug = false ); - -} // namespace sierra - -#endif // STK_UTIL_DIAG_PreParse_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.cpp deleted file mode 100644 index ac372c3a5a46..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include -#include - -namespace stk_classic { - -void -PrintTable::transpose_table() const -{} - - -void -PrintTable::calculate_column_widths() const -{ - ColumnWidthVector column_width_set; - - // loop over the headers and find the longest field for each column by size and from m_columnWidth - for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { - if ((*row_it).size() > m_columnWidth.size()) - m_columnWidth.resize((*row_it).size(), 0); - if ((*row_it).size() > column_width_set.size()) - column_width_set.resize((*row_it).size(), 0); - - int i = 0; - for (Row::const_iterator cell_it = (*row_it).begin(); cell_it != (*row_it).end(); ++cell_it, ++i) { - m_columnWidth[i] = std::max(m_columnWidth[i], (*cell_it).m_string.size()); - column_width_set[i] = std::max(column_width_set[i], (*cell_it).m_width); - } - } - - // loop over the table and find the longest field for each column by size and from m_columnWidth - for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { - if ((*row_it).size() > m_columnWidth.size()) - m_columnWidth.resize((*row_it).size(), 0); - if ((*row_it).size() > column_width_set.size()) - column_width_set.resize((*row_it).size(), 0); - - int i = 0; - for (Row::const_iterator cell_it = (*row_it).begin(); cell_it != (*row_it).end(); ++cell_it, ++i) { - m_columnWidth[i] = std::max(m_columnWidth[i], (*cell_it).m_string.size()); - column_width_set[i] = std::max(column_width_set[i], (*cell_it).m_width); - } - } - - // choose m_width width over size() width for each column - m_tableWidth = 0; - for (ColumnWidthVector::size_type i = 0; i < m_columnWidth.size(); ++i) { - if (column_width_set[i] != 0) - m_columnWidth[i] = column_width_set[i]; - m_tableWidth += m_columnWidth[i] + 1; - } -} - - -PrintTable & -PrintTable::at( - size_t row, - size_t col) -{ - for (Table::size_type i = m_table.size(); i <= row; ++i) - m_table.push_back(Row()); - for (Row::size_type i = m_table[row].size(); i <= col; ++i) - m_table[row].push_back(Cell()); - - m_currentCell.m_string = std::string(m_currentCell.m_indent*2, ' ') + m_currentString.str(); - m_table[row][col] = m_currentCell; - - m_currentCell = Cell(); - m_currentString.str(""); - - return *this; -} - - -PrintTable & -PrintTable::end_col() -{ - m_currentCell.m_string = std::string(m_currentCell.m_indent*2, ' ') + m_currentString.str(); - m_table.back().push_back(m_currentCell); - if (m_table.size() > 1 && m_table[0].size() <= m_table.back().size()) { - m_currentCell.m_string = ""; - m_currentCell.m_flags = 0; - m_currentCell.m_justification = m_table[0][m_table[0].size() - 1].m_justification; - m_currentCell.m_width = m_table[0][m_table[0].size() - 1].m_width; - m_currentCell.m_indent = m_table[0][m_table[0].size() - 1].m_indent; - } - else { - m_currentCell = Cell(); - } - m_currentString.str(""); - - return *this; -} - - -PrintTable & -PrintTable::end_row() -{ - if (!m_currentString.str().empty()) - end_col(); - m_table.push_back(Row()); - return *this; -} - - -std::ostream & -PrintTable::print( - std::ostream & os) const -{ - if (m_flags & COMMA_SEPARATED_VALUES) - csvPrint(os); - - else { - if (m_flags & PRINT_TRANSPOSED) - transpose_table(); - - calculate_column_widths(); - - if (!m_title.empty()) { - int prespaces = 0; - - if(m_title.length() < m_tableWidth) - prespaces = (m_tableWidth - m_title.length())/2; - - os << m_commentPrefix; - os << std::left << std::setw(prespaces) << "" << m_title << '\n'; - } - - for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { - os << m_commentPrefix; - printRow(os, *row_it); - os << '\n'; - } - - if (m_header.size() > 0) { - os << m_commentPrefix; - printHeaderBar(os); - os << '\n'; - } - - for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { - os << std::left << std::setw(m_commentPrefix.size()) << ""; - printRow(os, *row_it); - os << '\n'; - } - } - - return os; -} - - -std::ostream & -PrintTable::printRow( - std::ostream & os, - const Row & row) const -{ - int i = 0; - int postspaces = 0; - for (Row::const_iterator cell_it = row.begin(); cell_it != row.end(); ++cell_it, ++i) { - os // << postspaces << ", " - << std::left << std::setw(postspaces) << ""; - postspaces = 0; - - if (cell_it != row.begin()) - os << " "; - - if ((*cell_it).m_flags & Cell::SPAN) - os << (*cell_it).m_string; - else if ((*cell_it).m_string.length() > m_columnWidth[i]) { - if ((*cell_it).m_justification & Cell::ENDS) { - int front_end = m_columnWidth[i]/4; - int back_begin = (*cell_it).m_string.size() - (m_columnWidth[i] - front_end); - os << (*cell_it).m_string.substr(0, front_end - 3) + "..." + (*cell_it).m_string.substr(back_begin, (*cell_it).m_string.size()); - } - else { // if ((*cell_it).m_justification & Cell::TRUNC) { - os << (*cell_it).m_string.substr(0, m_columnWidth[i]); - } - } - else { - if ((*cell_it).m_string.length() == 0) - postspaces = m_columnWidth[i]; - else if (((*cell_it).m_justification & Cell::JUSTIFY_MASK) == Cell::LEFT) { - postspaces = m_columnWidth[i] - (*cell_it).m_string.length(); - os // << m_columnWidth[i] << ", " << postspaces << ", " - << std::left << (*cell_it).m_string; - } - else if (((*cell_it).m_justification & Cell::JUSTIFY_MASK) == Cell::CENTER) { - int prespaces = (m_columnWidth[i] - (*cell_it).m_string.length())/2; - postspaces = m_columnWidth[i] - (*cell_it).m_string.length() - prespaces; - os // << prespaces << " " << postspaces << ", " - << std::left << std::setw(prespaces) << "" << (*cell_it).m_string; - } - else // if (((*cell_it).m_justification & Cell::JUSTIFY_MASK) == Cell::RIGHT) - os // << m_columnWidth[i] << ", " - << std::right << std::setw(m_columnWidth[i]) << (*cell_it).m_string; - } - } - - return os; -} - - -std::ostream & -PrintTable::printHeaderBar( - std::ostream & os) const -{ - os << std::setfill('-'); - - for (ColumnWidthVector::size_type i = 0; i < m_columnWidth.size(); ++i) { - if (i != 0) - os << " "; - os << std::setw(m_columnWidth[i]) << ""; - } - os << std::setfill(' '); - - return os; -} - - -std::ostream & -PrintTable::csvPrint( - std::ostream & os) const -{ - if (!m_title.empty()) - os << m_title << '\n'; - - for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { - const Row &row = (*row_it); - for (Row::const_iterator cell_it = row.begin(); cell_it != row.end(); ++cell_it) { - if (cell_it != row.begin()) - os << ","; - os << (*cell_it).m_string; - } - os << '\n'; - } - - for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { - const Row &row = (*row_it); - for (Row::const_iterator cell_it = row.begin(); cell_it != row.end(); ++cell_it) { - if (cell_it != row.begin()) - os << ","; - os << (*cell_it).m_string; - } - os << '\n'; - } - - return os; -} - - -diag::Writer & -PrintTable::verbose_print( - diag::Writer & dout) const -{ -// const ColumnWidthVector &column_width = calculate_column_widths(); - -// for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { -// printRow(os, *row_it); -// os << '\n'; -// } - -// if (m_header.size() > 0) -// printHeaderBar(os); - -// for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { -// int i = 0; -// for (Row::const_iterator cell_it = (*row_it).begin(); cell_it != (*row_it).end(); ++cell_it, ++i) -// if ((*cell_it).m_flags & Cell::SPAN) -// dout << (*cell_it).m_string; -// else -// dout << std::setw(column_width[i]) << (*cell_it).m_string; -// dout << dendl; -// } - - calculate_column_widths(); - - dout << m_title << std::endl; - - for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { - dout << ""; - printRow(dout.getStream(), *row_it); - dout << diag::dendl; - } - - if (m_header.size() > 0) { - dout << ""; - printHeaderBar(dout.getStream()); - dout << diag::dendl; - } - - for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { - dout << ""; - printRow(dout.getStream(), *row_it); - dout << diag::dendl; - } - - return dout; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.hpp deleted file mode 100644 index 8d8e5446dedf..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTable.hpp +++ /dev/null @@ -1,421 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_PrintTable_hpp -#define STK_UTIL_DIAG_PrintTable_hpp - -#include -#include -#include - -#include - -namespace stk_classic { - -class PrintTable -{ - template - friend PrintTable &operator<<(PrintTable &table, const T &t); - -public: - typedef std::string::size_type ColumnWidth; - typedef std::vector ColumnWidthVector; - - struct Cell - { - enum Flags { - SPAN = 0x01 - }; - - enum Justification { - LEFT = 1, - RIGHT = 2, - CENTER = 3, - JUSTIFY_MASK = 0x0F, - TRUNC = 0x10, - ENDS = 0x20 - }; - - Cell() - : m_string(), - m_flags(0), - m_justification(RIGHT | TRUNC), - m_indent(0), - m_width(0) - {} - - Cell(const Cell &cell) - : m_string(cell.m_string), - m_flags(cell.m_flags), - m_justification(cell.m_justification), - m_indent(cell.m_indent), - m_width(cell.m_width) - {} - - Cell &operator=(const Cell &cell) { - m_string = cell.m_string; - m_flags = cell.m_flags; - m_justification = cell.m_justification; - m_indent = cell.m_indent; - m_width = cell.m_width; - - return *this; - } - - std::string m_string; - int m_flags; - int m_justification; - ColumnWidth m_indent; - ColumnWidth m_width; - }; - - typedef std::vector Row; - typedef std::vector Table; - - enum Flags { - AUTO_END_COL = 0x01, - COMMA_SEPARATED_VALUES = 0x02, - PRINT_TRANSPOSED = 0x04 - }; - - PrintTable() - : m_ostream(0), - m_flags(AUTO_END_COL), - m_tableWidth(0) - { - m_table.push_back(Row()); - } - - explicit PrintTable(std::ostream &os) - : m_ostream(&os), - m_flags(AUTO_END_COL), - m_commentPrefix(), - m_tableWidth(0) - { - m_table.push_back(Row()); - } - -private: - PrintTable(const PrintTable &); - PrintTable &operator=(const PrintTable &); - -public: - ~PrintTable() - {} - - Row::size_type headerSize() const { - return m_header.empty() ? 0 : m_header.begin()->size(); - } - - inline Table::size_type size() const { - return m_table.size(); - } - - inline std::ostringstream &getCurrentString() { - return m_currentString; - } - - inline bool autoEndCol() const { - return m_flags & AUTO_END_COL; - } - - inline PrintTable &setAutoEndCol(bool auto_end_col = true) { - if (auto_end_col) - m_flags |= AUTO_END_COL; - else - m_flags &= ~AUTO_END_COL; - return *this; - } - - inline bool commaSeparatedValues() const { - return m_flags & COMMA_SEPARATED_VALUES; - } - - inline PrintTable &setCommaSeparatedValues(bool comma_separated_values = true) { - if (comma_separated_values) - m_flags |= COMMA_SEPARATED_VALUES; - else - m_flags &= ~COMMA_SEPARATED_VALUES; - return *this; - } - - inline PrintTable &setCommentPrefix(const std::string &comment_prefix) { - m_commentPrefix = comment_prefix; - return *this; - } - - inline const std::string &getCommentPrefix() const { - return m_commentPrefix; - } - - /** - * This function sets the title to the given new title. The title can also - * be accessed directly. - */ - inline PrintTable &setTitle(const std::string &title){ - m_title = title; - return *this; - } - - inline const std::string &getTitle() const { - return m_title; - } - - /** - * Member function operator<< is the manipulator instantiation - * function - * - * @return a PrintTable reference to this object - */ - inline PrintTable& operator<<(PrintTable& (*f)(PrintTable&)) { - f(*this); - return *this; - - } - - /** - * Member function operator<< passes the ios_base manipulator to the - * output stream. - * - * @return a PrintTable reference to this object - */ - inline PrintTable& operator<<(std::ios_base& (*f)(std::ios_base&)) { - f(m_currentString); - return *this; - } - - inline PrintTable &push() { - ++m_currentCell.m_indent; - return *this; - } - - inline PrintTable &span() { - m_currentCell.m_flags |= Cell::SPAN; - return *this; - } - - inline PrintTable &pop() { - if (m_currentCell.m_indent != 0) - --m_currentCell.m_indent; - - return *this; - } - - inline PrintTable &cell_width(ColumnWidth my_width) { - m_currentCell.m_width = my_width; - - return *this; - } - - inline PrintTable &indent(ColumnWidth my_indent) { - m_currentCell.m_indent = my_indent; - - return *this; - } - - inline PrintTable &justify(int justification) { - m_currentCell.m_justification = justification; - - return *this; - } - - PrintTable &end_col(); - - PrintTable &end_row(); - - PrintTable &at(size_t row, size_t col); - - PrintTable &end_header() { - m_header.push_back(m_table.back()); - m_table.pop_back(); - m_table.push_back(Row()); - return *this; - } - - PrintTable &end_format() { - m_format = m_table.back(); - m_table.pop_back(); - m_table.push_back(Row()); - return *this; - } - - void calculate_column_widths() const; - - void transpose_table() const; - - /** - * This function prints out the table to it's PrintTable - */ - std::ostream &print(std::ostream &os) const; - - /** - * This function prints out the table to it's PrintTable - */ - std::ostream &printRow(std::ostream &os, const Row &row) const; - - /** - * This function prints out the table to it's PrintTable - */ - std::ostream &printHeaderBar(std::ostream &os) const; - - /** - * This function prints out the table to it's PrintTable - */ - std::ostream &csvPrint(std::ostream &os) const; - - /** - * This function prints out the table to it's PrintTable - */ - diag::Writer & verbose_print(diag::Writer &dout) const; - -private: - /** - * Member function normalize_table makes sure that the table has a field at - * row and column. - * - * @param row an int value of the row to ensure existence. - * @param col an int value of the column to ensure existence. - */ - void normalize_table(int row, int col); - -private: - std::ostream * m_ostream; - std::string m_title; - Table m_header; - Row m_format; - Table m_table; - Cell m_currentCell; - std::ostringstream m_currentString; - int m_flags; - std::string m_commentPrefix; - mutable ColumnWidthVector m_columnWidth; - mutable ColumnWidth m_tableWidth; -}; - - -template -inline PrintTable &operator<<(PrintTable &table, const T &t) { - table.m_currentString << t; - if (table.autoEndCol()) - table.end_col(); - - return table; -} - - -struct cell_width -{ - cell_width(PrintTable::ColumnWidth width) - : m_width(width) - {} - - PrintTable::ColumnWidth m_width; -}; - - -struct at -{ - at(size_t row, size_t col) - : m_row(row), - m_col(col) - {} - - size_t m_row; - size_t m_col; -}; - - -struct indent -{ - indent(PrintTable::ColumnWidth my_indent) - : m_indent(my_indent) - {} - - PrintTable::ColumnWidth m_indent; -}; - - -struct justify -{ - justify(int my_justify) - : m_justify(my_justify) - {} - - int m_justify; -}; - - -inline PrintTable &operator<<(PrintTable &tout, const at &m) { - tout.at(m.m_row, m.m_col); - return tout; -} - -inline PrintTable &operator<<(PrintTable &tout, const cell_width &m) { - tout.cell_width(m.m_width); - return tout; -} - -inline PrintTable &operator<<(PrintTable &tout, const indent &m) { - tout.indent(m.m_indent); - return tout; -} - -inline PrintTable &operator<<(PrintTable &tout, const justify &m) { - tout.justify(m.m_justify); - return tout; -} - -inline PrintTable &end_col(PrintTable &tout) { - return tout.end_col(); -} - -inline PrintTable &end_row(PrintTable &tout) { - return tout.end_row(); -} - -inline PrintTable &end_header(PrintTable &tout) { - return tout.end_header(); -} - -inline PrintTable &end_format(PrintTable &tout) { - return tout.end_format(); -} - -inline PrintTable &push(PrintTable &tout) { - return tout.push(); -} - -inline PrintTable &pop(PrintTable &tout) { - return tout.pop(); -} - -inline PrintTable &span(PrintTable &tout) { - return tout.span(); -} - -inline std::ostream &operator<<(std::ostream &os, const PrintTable &table){ - return table.print(os); -} - -inline diag::Writer &operator<<(diag::Writer &dout, const PrintTable &table){ - return table.verbose_print(dout); -} - -} // namespace stk_classic - -//namespace sierra { -// -////typedef stk_classic::PrintTable PrintTable; -//using stk_classic::PrintTable; -//typedef stk_classic::cell_width cell_width; -//typedef stk_classic::at at; -//typedef stk_classic::justify justify; -// -//} // namespace sierra - -#endif // STK_UTIL_DIAG_PrintTable_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.cpp deleted file mode 100644 index 56631fa60ab4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.cpp +++ /dev/null @@ -1,754 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace diag { -namespace { -struct ParallelTimer; -}} - -template -Marshal &operator<<(Marshal &mout, const diag::Timer::Metric &t); - -Marshal &operator<<(Marshal &mout, const diag::Timer &t); - -Marshal &operator>>(Marshal &min, diag::ParallelTimer &t); -} - -namespace stk_classic { -namespace diag { - -namespace { - -/** - * Class Percent is a functor which display the percentage of the numerator - * to the denominator. The value is displayed at (xx.xx%) for values in the range 0.01 - * to 99.99, (0.00%) if zero, (<0.01%) is less than 0.01, and (100.0%) for 100 percent. - * - */ -struct Percent -{ - Percent(double numerator, double denominator) - : m_numerator(numerator), - m_denominator(denominator) - {} - - /** - * Member function operator() writes the percentage as a string to the - * output stream. - * - * @param os a std::ostream reference to the output stream - * to write to. - * - * @return a std::ostream reference to the output stream - * written to. - */ - std::ostream &operator()(std::ostream &os) const; - -private: - double m_numerator; - double m_denominator; -}; - - -std::ostream & -Percent::operator()( - std::ostream & os) const -{ - std::ostringstream strout; - - if (m_numerator == 0.0) - strout << "(0.00%)"; - else if (m_denominator == 0.0) - strout << "( NaN)"; - else { - double ratio = m_numerator/m_denominator*100.0; - if (ratio < 0.01) - strout << "(<0.01%)"; - else if (ratio >= 100.0) - strout << "(" << std::setw(5) << std::setprecision(1) << std::fixed << ratio << "%)"; - else - strout << "(" << std::setw(5) << std::setprecision(2) << std::fixed << ratio << "%)"; - } - - return os << strout.str(); -} - - -/** - * Member function operator<< ... - * - * @param os a std::ostream variable ... - * - * @param p a TimerImpl::Percent variable ... - * - * @return a std::ostream ... - */ -inline std::ostream &operator<<(std::ostream &os, const Percent &p) { - return p(os); -} - -struct ParallelTimer -{ - template - struct Metric - { - Metric() - : m_value(0), - m_sum(0.0), - m_min(std::numeric_limits::max()), - m_max(0.0) - {} - - typename MetricTraits::Type m_value; ///< Metric value - typename MetricTraits::Type m_checkpoint; ///< Metric checkpointed value - double m_sum; ///< Reduction sum - double m_min; ///< Reduction min - double m_max; ///< Reduction max - - void accumulate(const Metric &metric, bool checkpoint) { - double value = static_cast(metric.m_value); - if (checkpoint) - value -= static_cast(metric.m_checkpoint); - - m_sum += value; - m_min = std::min(m_min, value); - m_max = std::max(m_max, value); - } - - Writer &dump(Writer &dout) const { - if (dout.shouldPrint()) { - dout << "Metric<" << typeid(typename MetricTraits::Type) << ">" << push << dendl; - dout << "m_value " << m_value << dendl; - dout << "m_checkpoint " << m_value << dendl; - dout << "m_sum " << m_sum << dendl; - dout << "m_min " << m_min << dendl; - dout << "m_max " << m_max << dendl; - dout << pop; - } - return dout; - } - }; - - ParallelTimer() - : m_name(), - m_timerMask(0), - m_subtimerLapCount(0), - m_lapCount(), - m_cpuTime(), - m_wallTime(), - m_MPICount(), - m_MPIByteCount(), - m_heapAlloc(), - m_subtimerList() - {} - - ParallelTimer(const ParallelTimer ¶llel_timer) - : m_name(parallel_timer.m_name), - m_timerMask(parallel_timer.m_timerMask), - m_subtimerLapCount(parallel_timer.m_subtimerLapCount), - m_lapCount(parallel_timer.m_lapCount), - m_cpuTime(parallel_timer.m_cpuTime), - m_wallTime(parallel_timer.m_wallTime), - m_MPICount(parallel_timer.m_MPICount), - m_MPIByteCount(parallel_timer.m_MPIByteCount), - m_heapAlloc(parallel_timer.m_heapAlloc), - m_subtimerList(parallel_timer.m_subtimerList) - {} - - ParallelTimer &operator=(const ParallelTimer ¶llel_timer) { - m_name = parallel_timer.m_name; - m_timerMask = parallel_timer.m_timerMask; - m_subtimerLapCount = parallel_timer.m_subtimerLapCount; - m_lapCount = parallel_timer.m_lapCount; - m_cpuTime = parallel_timer.m_cpuTime; - m_wallTime = parallel_timer.m_wallTime; - m_MPICount = parallel_timer.m_MPICount; - m_heapAlloc = parallel_timer.m_heapAlloc; - m_subtimerList = parallel_timer.m_subtimerList; - - return *this; - } - - template - const Metric &getMetric() const; - - std::string m_name; ///< Name of the timer - TimerMask m_timerMask; - double m_subtimerLapCount; ///< Sum of subtimer lap counts and m_lapCount - - Metric m_lapCount; ///< Number of laps accumulated - Metric m_cpuTime; ///< CPU time - Metric m_wallTime; ///< Wall time - Metric m_MPICount; ///< MPI call count - Metric m_MPIByteCount; ///< MPI byte count - Metric m_heapAlloc; ///< MPI byte count - - std::list m_subtimerList; ///< Sub timers - - Writer &dump(Writer &dout) const; -}; - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_lapCount; -} - - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_cpuTime; -} - - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_wallTime; -} - - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_MPICount; -} - - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_MPIByteCount; -} - - -template<> -const ParallelTimer::Metric & -ParallelTimer::getMetric() const { - return m_heapAlloc; -} - - -template -Writer &operator<<(Writer &dout, const ParallelTimer::Metric &t) { - return t.dump(dout); -} - -Writer &operator<<(Writer &dout, const ParallelTimer ¶llel_timer) { - return parallel_timer.dump(dout); -} - -Writer & -ParallelTimer::dump(Writer &dout) const { - if (dout.shouldPrint()) { - dout << "ParallelTimer " << m_name << push << dendl; - dout << "m_name " << m_name << dendl; - dout << "m_timerMask " << hex << m_timerMask << dendl; - dout << "m_subtimerLapCount " << m_subtimerLapCount << dendl; - dout << "m_lapCount " << m_lapCount << dendl; - dout << "m_cpuTime " << m_cpuTime << dendl; - dout << "m_wallTime " << m_wallTime << dendl; - dout << "m_MPICount " << m_MPICount << dendl; - dout << "m_MPIByteCount " << m_MPIByteCount << dendl; - dout << "m_heapAlloc " << m_heapAlloc << dendl; - dout << "m_subtimerList " << m_subtimerList << dendl; - dout << pop; - } - return dout; -} - -#ifdef __INTEL_COMPILER -#pragma warning(push) -#pragma warning(disable: 444) -#endif -class finder : public std::unary_function -{ -public: - finder(const std::string &name) - : m_name(name) - {} - - bool operator()(const ParallelTimer ¶llel_timer) const { - return equal_case(parallel_timer.m_name, m_name); - } - -private: - std::string m_name; -}; -#ifdef __INTEL_COMPILER -#pragma warning(pop) -#endif - - -void -merge_parallel_timer( - ParallelTimer & p0, - const ParallelTimer & p1, - bool checkpoint) -{ - p0.m_timerMask = p1.m_timerMask; - p0.m_subtimerLapCount += p1.m_subtimerLapCount; - p0.m_lapCount.accumulate(p1.m_lapCount, checkpoint); - p0.m_cpuTime.accumulate(p1.m_cpuTime, checkpoint); - p0.m_wallTime.accumulate(p1.m_wallTime, checkpoint); - p0.m_MPICount.accumulate(p1.m_MPICount, checkpoint); - p0.m_MPIByteCount.accumulate(p1.m_MPIByteCount, checkpoint); - p0.m_heapAlloc.accumulate(p1.m_heapAlloc, checkpoint); - - - for (std::list::const_iterator p1_it = p1.m_subtimerList.begin(); p1_it != p1.m_subtimerList.end(); ++p1_it) { - std::list::iterator p0_it = std::find_if(p0.m_subtimerList.begin(), p0.m_subtimerList.end(), finder((*p1_it).m_name)); - if (p0_it == p0.m_subtimerList.end()) { - p0.m_subtimerList.push_back((*p1_it)); - p0_it = --p0.m_subtimerList.end(); - merge_parallel_timer(*p0_it, *p1_it, checkpoint); - } - else - merge_parallel_timer(*p0_it, *p1_it, checkpoint); - } -} - - -void -collect_timers( - Timer & root_timer, - ParallelTimer & parallel_timer, - bool checkpoint, - ParallelMachine comm) -{ - Marshal mout; - mout << root_timer; - -#ifdef STK_HAS_MPI - const int parallel_root = 0 ; - const int parallel_size = parallel_machine_size(comm); - const int parallel_rank = parallel_machine_rank(comm); - - // Gather the send counts on root processor - std::string send_string(mout.str()); - - ParallelTimer root_parallel_timer; - - //We need to gather the timer data in a number of 'cycles' where we - //only receive from a portion of the other processors each cycle. - //This is because buffer allocation-failures have been observed for - //runs on very large numbers of processors if the 'root' processor tries - //to allocate a buffer large enough to hold timing data from all other - //procesors. - int num_cycles = 16; - if (parallel_size < 1024) { - //If less than 1024 processors, just do them all at once. - num_cycles = 1; - } - - std::vector buffer; - - for(int ii=0; ii recv_count(parallel_size, 0); - int * const recv_count_ptr = &recv_count[0] ; - - //send_count is the amount of data this processor needs to send. - int send_count = send_string.size(); - - //should this processor send on the current cycle ? If not, set send_count to 0. - if ((parallel_rank+ii)%num_cycles!=0) { - send_count = 0; - } - - int result = MPI_Gather(&send_count, 1, MPI_INT, - recv_count_ptr, 1, MPI_INT, - parallel_root, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::diag::collect_timers FAILED: MPI_Gather = " << result ; - throw std::runtime_error(message.str()); - } - - // Receive counts are only non-zero on the root processor: - std::vector recv_displ(parallel_size + 1, 0); - - for (int i = 0 ; i < parallel_size ; ++i) { - recv_displ[i + 1] = recv_displ[i] + recv_count[i] ; - } - - const int recv_size = recv_displ[parallel_size] ; - - buffer.assign(recv_size, 0); - - { - const char * const send_ptr = send_string.data(); - char * const recv_ptr = recv_size ? & buffer[0] : 0; - int * const recv_displ_ptr = & recv_displ[0] ; - - result = MPI_Gatherv((void *) send_ptr, send_count, MPI_CHAR, - recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR, - parallel_root, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::diag::collect_timers FAILED: MPI_Gatherv = " << result ; - throw std::runtime_error(message.str()); - } - - std::vector parallel_timer_vector; - parallel_timer_vector.reserve(parallel_size); - - if (parallel_rank == parallel_root) { - for (int j = 0; j < parallel_size; ++j) { - int received_count = recv_displ[j+1] - recv_displ[j]; - if (received_count > 0) { - //grow parallel_timer_vector by 1: - parallel_timer_vector.resize(parallel_timer_vector.size()+1); - Marshal min(std::string(recv_ptr + recv_displ[j], recv_ptr + recv_displ[j + 1])); - //put this data into the last entry of parallel_timer_vector: - min >> parallel_timer_vector[parallel_timer_vector.size()-1]; - } - } - - if (parallel_rank==parallel_root && send_count>0) root_parallel_timer = parallel_timer_vector[0]; - - for (size_t j = 0; j < parallel_timer_vector.size(); ++j) - merge_parallel_timer(root_parallel_timer, parallel_timer_vector[j], checkpoint); - } - } - } - parallel_timer = root_parallel_timer; -#endif -} - -// PrintTable &printTable(PrintTable &table, MPI_Comm mpi_comm, MetricsMask metrics_mask) const; - -PrintTable & -printSubtable( - PrintTable & table, - const Timer & root_timer, - const Timer & timer, - MetricsMask metrics_mask, - int depth, - bool timer_checkpoint) -{ - if (timer.getSubtimerLapCount() != 0.0) { - if (timer.shouldRecord()) { - if (timer.getTimerMask() == 0 || timer.getMetric().getAccumulatedLap(timer_checkpoint) > 0) { - table << justify(PrintTable::Cell::LEFT) << indent(depth) << timer.getName() << end_col - << justify(PrintTable::Cell::RIGHT) << timer.getMetric().getAccumulatedLap(timer_checkpoint) << end_col; - - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().getAccumulatedLap(timer_checkpoint)) - << " " << std::setw(8) << Percent(timer.getMetric().getAccumulatedLap(timer_checkpoint), root_timer.getMetric().getAccumulatedLap(timer_checkpoint)) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().getAccumulatedLap(timer_checkpoint)) - << " " << std::setw(8) << Percent(timer.getMetric().getAccumulatedLap(timer_checkpoint), root_timer.getMetric().getAccumulatedLap(timer_checkpoint)) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().getAccumulatedLap(timer_checkpoint)) - << " " << std::setw(8) << Percent(timer.getMetric().getAccumulatedLap(timer_checkpoint), root_timer.getMetric().getAccumulatedLap(timer_checkpoint)) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().getAccumulatedLap(timer_checkpoint)) - << " " << std::setw(8) << Percent(timer.getMetric().getAccumulatedLap(timer_checkpoint), root_timer.getMetric().getAccumulatedLap(timer_checkpoint)) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().getAccumulatedLap(timer_checkpoint)) - << " " << std::setw(8) << Percent(timer.getMetric().getAccumulatedLap(timer_checkpoint), root_timer.getMetric().getAccumulatedLap(timer_checkpoint)) << end_col; - } - else - table << justify(PrintTable::Cell::LEFT) << indent(depth) << span << timer.getName() << end_col; - - table << end_row; - depth++; - } - - for (TimerList::const_iterator it = timer.begin(); it != timer.end(); ++it) - printSubtable(table, root_timer, *it, metrics_mask, depth, timer_checkpoint); - } - - return table; -} - - -PrintTable & -printSubtable( - PrintTable & table, - const ParallelTimer & root_timer, - const ParallelTimer & timer, - MetricsMask metrics_mask, - int depth, - bool timer_checkpoint) -{ - if (timer.m_subtimerLapCount != 0.0) { - if (timer.m_timerMask == 0 || timer.getMetric().m_sum > 0) { - table << justify(PrintTable::Cell::LEFT) << indent(depth) << timer.m_name << end_col - << justify(PrintTable::Cell::RIGHT) << timer.getMetric().m_sum << end_col; - - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_sum) - << " " << std::setw(8) << Percent(timer.getMetric().m_sum, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_min) - << " " << std::setw(8) << Percent(timer.getMetric().m_min, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_max) - << " " << std::setw(8) << Percent(timer.getMetric().m_max, root_timer.getMetric().m_sum) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_sum) - << " " << std::setw(8) << Percent(timer.getMetric().m_sum, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_min) - << " " << std::setw(8) << Percent(timer.getMetric().m_min, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_max) - << " " << std::setw(8) << Percent(timer.getMetric().m_max, root_timer.getMetric().m_sum) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_sum) - << " " << std::setw(8) << Percent(timer.getMetric().m_sum, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_min) - << " " << std::setw(8) << Percent(timer.getMetric().m_min, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_max) - << " " << std::setw(8) << Percent(timer.getMetric().m_max, root_timer.getMetric().m_sum) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_sum) - << " " << std::setw(8) << Percent(timer.getMetric().m_sum, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_min) - << " " << std::setw(8) << Percent(timer.getMetric().m_min, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_max) - << " " << std::setw(8) << Percent(timer.getMetric().m_max, root_timer.getMetric().m_sum) << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_sum) - << " " << std::setw(8) << Percent(timer.getMetric().m_sum, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_min) - << " " << std::setw(8) << Percent(timer.getMetric().m_min, root_timer.getMetric().m_sum) << end_col - << justify(PrintTable::Cell::RIGHT) << std::setw(12) << MetricTraits::format(timer.getMetric().m_max) - << " " << std::setw(8) << Percent(timer.getMetric().m_max, root_timer.getMetric().m_sum) << end_col; - } - else - table << justify(PrintTable::Cell::LEFT) << indent(depth) << span << timer.m_name << end_col; - - table << end_row; - depth++; - } - - for (std::list::const_iterator it = timer.m_subtimerList.begin(); it != timer.m_subtimerList.end(); ++it) - printSubtable(table, root_timer, *it, metrics_mask, depth, timer_checkpoint); - - return table; -} - - -PrintTable & -printTable( - PrintTable & table, - Timer & root_timer, - MetricsMask metrics_mask, - size_t name_width, - bool timer_checkpoint) -{ - updateRootTimer(root_timer); - - root_timer.accumulateSubtimerLapCounts(); - - if (metrics_mask & getEnabledTimerMetricsMask()) { - table.setAutoEndCol(false); - - table << cell_width(name_width) << justify(PrintTable::Cell::CENTER) << "Timer" << (timer_checkpoint ? " (delta time)" : "") << end_col - << justify(PrintTable::Cell::CENTER) << "Count" << end_col; - - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - - table << end_header; - - printSubtable(table, root_timer, root_timer, metrics_mask, 0, timer_checkpoint); - - if (timer_checkpoint) - root_timer.checkpoint(); - } - - return table; -} - - -PrintTable & -printTable( - PrintTable & table, - Timer & root_timer, - MetricsMask metrics_mask, - size_t name_width, - bool timer_checkpoint, - ParallelMachine parallel_machine) -{ - updateRootTimer(root_timer); - - root_timer.accumulateSubtimerLapCounts(); - - ParallelTimer parallel_timer; - - stk_classic::diag::collect_timers(root_timer, parallel_timer, timer_checkpoint, parallel_machine); - - int parallel_rank = parallel_machine_rank(parallel_machine); - if (parallel_rank == 0) { - if (metrics_mask & getEnabledTimerMetricsMask()) { - table.setAutoEndCol(false); - - table << end_col << end_col; - - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col - << justify(PrintTable::Cell::CENTER) << MetricTraits::table_header() << end_col; - - table << end_header; - table << cell_width(name_width) << justify(PrintTable::Cell::CENTER) << "Timer" << (timer_checkpoint ? " (delta time)" : "") << end_col - << justify(PrintTable::Cell::CENTER) << "Count" << end_col; - - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << "Sum (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Min (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Max (% of System)" << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << "Sum (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Min (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Max (% of System)" << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << "Sum (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Min (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Max (% of System)" << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << "Sum (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Min (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Max (% of System)" << end_col; - if (metrics_mask & getEnabledTimerMetricsMask() & MetricTraits::METRIC) - table << justify(PrintTable::Cell::CENTER) << "Sum (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Min (% of System)" << end_col - << justify(PrintTable::Cell::CENTER) << "Max (% of System)" << end_col; - - table << end_header; - - printSubtable(table, parallel_timer, parallel_timer, metrics_mask, 0, timer_checkpoint); - } - - if (timer_checkpoint) - root_timer.checkpoint(); - } - - return table; -} - -} // namespace - - -std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask, bool timer_checkpoint) -{ - stk_classic::PrintTable print_table; - - printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint); - - os << print_table; - - return os; -} - - -std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask, bool timer_checkpoint, ParallelMachine parallel_machine) -{ - stk_classic::PrintTable print_table; - - int parallel_size = parallel_machine_size(parallel_machine); - if (parallel_size == 1) - printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint); - else - printTable(print_table, root_timer, metrics_mask, 40, timer_checkpoint, parallel_machine); - - os << print_table; - - return os; -} - - -// std::ostream &printXML(std::ostream &os, MPI_Comm mpi_comm, MetricsMask metrics_mask) const; -std::ostream &printXML(std::ostream &os, MetricsMask metrics_mask, bool timer_checkpoint); - -std::ostream &printSubXML(std::ostream &os, MetricsMask metrics_mask, int depth, bool timer_checkpoint); - -} // namespace diag - -Marshal &operator<<(stk_classic::Marshal &mout, const diag::Timer &t); - -template -Marshal &operator<<(Marshal &mout, const diag::Timer::Metric &t) { - mout << t.getAccumulatedLap(false) << t.getAccumulatedLap(true); - - return mout; -} - -Marshal &operator<<(Marshal &mout, const diag::Timer &t) { - mout << t.getName() << t.getTimerMask() << t.getSubtimerLapCount() - << t.getMetric() << t.getMetric() << t.getMetric() - << t.getMetric() << t.getMetric() << t.getMetric(); - - mout << t.getTimerList(); - - return mout; -} - -Marshal &operator>>(Marshal &min, diag::ParallelTimer &t) { - min >> t.m_name >> t.m_timerMask >> t.m_subtimerLapCount - >> t.m_lapCount.m_value - >> t.m_lapCount.m_checkpoint - >> t.m_cpuTime.m_value - >> t.m_cpuTime.m_checkpoint - >> t.m_wallTime.m_value - >> t.m_wallTime.m_checkpoint - >> t.m_MPICount.m_value - >> t.m_MPICount.m_checkpoint - >> t.m_MPIByteCount.m_value - >> t.m_MPIByteCount.m_checkpoint - >> t.m_heapAlloc.m_value - >> t.m_heapAlloc.m_checkpoint; - - min >> t.m_subtimerList; - - return min; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.hpp deleted file mode 100644 index 324e2fa64157..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/PrintTimer.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_PrintTimer_hpp -#define STK_UTIL_DIAG_PrintTimer_hpp - -#include - -#include -#include - -namespace stk_classic { -namespace diag { - -std::ostream &printXML(std::ostream& os, MetricsMask metrics_mask, bool checkpoint); - -std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask, bool timer_checkpoint); - -std::ostream &printTimersTable(std::ostream& os, Timer root_timer, MetricsMask metrics_mask, bool timer_checkpoint, ParallelMachine parallel_machine); - -} // namespace diag -} // namespace stk_classic - -#endif // STK_UTIL_DIAG_PrintTimer_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.cpp deleted file mode 100644 index bff0a79462cd..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2006-2007, 2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include - -#include - -#include -#include -#include -#include -#include - -namespace sierra { -namespace Env { - -namespace { - -/** - * @brief Class EnvSignal ... - * - */ -class EnvSignal -{ -public: - static EnvSignal &instance() { - static EnvSignal env_signal; - - return env_signal; - } - -private: - EnvSignal() - : m_enabled(false), - m_hupReceived(false), - hupCallback(*this, &EnvSignal::hupHandler), - segvCallback(*this, &EnvSignal::segvHandler), - illCallback(*this, &EnvSignal::illHandler), - busCallback(*this, &EnvSignal::busHandler), - termCallback(*this, &EnvSignal::termHandler) - {} - -public: - /** - * @brief Member function getSigJmpBuf establishes the signal handling. - * - * This function returns false under normal execution. From that point forward, if any - * signal occurs, the execution returns to this statement and returns value of true. At - * that point, there is no hope of recovery, but the traceback information is still - * valid and, hopefully, the output streams are still functioning to receive the output. - * - * if (run_sierra.signalException()) - * throw run_sierra.faultMessage(); - * - * @return a bool of false during normal - * execution. Revisited and returns true when a signal - * occurs. - */ - inline sigjmp_buf *getSigJmpBuf() { - m_enabled = true; - - return &m_sigJmpBuf; - } - - /** - * @brief Member function disableSigLongJmp disables the returning of - * true to signalException when a signal is detected. - * - */ - void disableSigLongJmp() { - m_enabled = false; - } - - /** - * @brief Member function faultMessage returns a - * std::runtime_error with the message associated with the most recent - * signal. - * - * @return a std::runtime_error suitable for throwing. - */ - const std::string &message() const { - return m_message; - } - - /** - * @brief Member function getHUPReceived ... - * - */ - bool getHUPReceived() { - return m_hupReceived; - } - - /** - * @brief Member function activateSignals ... - * - */ - void activateSignals(); - - /** - * @brief Member function deactivateSignals ... - * - */ - void deactivateSignals(); - -private: - void doSignal(const char *message, int signal); - void hupHandler(); - void segvHandler(); - void illHandler(); - void busHandler(); - void termHandler(); - void intHandler(); - -private: - sigjmp_buf m_sigJmpBuf; ///< setjmp/longjmp buffer - bool m_enabled; ///< Signal handling enabled state - bool m_hupReceived; ///< HUP has been received via handler - std::string m_message; ///< Message generated from signal - - Callback hupCallback; - Callback segvCallback; - Callback illCallback; - Callback busCallback; - Callback termCallback; -// Callback intCallback; - -}; - - - void -EnvSignal::activateSignals() -{ - SignalHandler::instance().add_handler(SIGSEGV, EnvSignal::segvCallback); - SignalHandler::instance().add_handler(SIGILL, EnvSignal::illCallback); - SignalHandler::instance().add_handler(SIGBUS, EnvSignal::busCallback); -// SignalHandler::instance().add_handler(SIGINT, EnvSignal::intCallback); - -#if defined(SIERRA_USER_SHUTDOWN_SIGNAL) - SignalHandler::instance().add_handler(SIERRA_USER_SHUTDOWN_SIGNAL, EnvSignal::hupCallback); -#endif -#if defined(SIERRA_SHUTDOWN_SIGNAL) - SignalHandler::instance().add_handler(SIERRA_SHUTDOWN_SIGNAL, EnvSignal::hupCallback); -#endif -#if defined(SIERRA_MPI_ABORT_SIGNAL) - SignalHandler::instance().add_handler(SIERRA_MPI_ABORT_SIGNAL, EnvSignal::termCallback); -#endif -} - - -void -EnvSignal::deactivateSignals() -{ - SignalHandler::instance().remove_handler(SIGSEGV, EnvSignal::segvCallback); - SignalHandler::instance().remove_handler(SIGILL, EnvSignal::illCallback); - SignalHandler::instance().remove_handler(SIGBUS, EnvSignal::busCallback); -// SignalHandler::instance().add_handler(SIGINT, EnvSignal::intCallback); - -#if defined(SIERRA_USER_SHUTDOWN_SIGNAL) - SignalHandler::instance().remove_handler(SIERRA_USER_SHUTDOWN_SIGNAL, EnvSignal::hupCallback); -#endif -#if defined(SIERRA_SHUTDOWN_SIGNAL) - SignalHandler::instance().remove_handler(SIERRA_SHUTDOWN_SIGNAL, EnvSignal::hupCallback); -#endif -#if defined(SIERRA_MPI_ABORT_SIGNAL) - SignalHandler::instance().remove_handler(SIERRA_MPI_ABORT_SIGNAL, EnvSignal::termCallback); -#endif -} - - -void -EnvSignal::doSignal( - const char * message, - int signal) -{ - if (!m_enabled) { -// std::cout << message << std::endl << "Signal exception handling not enabled" << std::endl; - ::raise(signal); - return; - } - else { - m_enabled = false; - m_message = message; - ::siglongjmp(m_sigJmpBuf, signal); - } -} - - -void -EnvSignal::hupHandler() -{ - m_hupReceived = true; -} - - -void -EnvSignal::intHandler() -{ - m_hupReceived = true; -} - - -void -EnvSignal::segvHandler() -{ - SignalHandler::instance().remove_handler(SIGSEGV, EnvSignal::segvCallback); - doSignal("Segmentation violation error", SIGSEGV); -} - -void -EnvSignal::busHandler() -{ - SignalHandler::instance().remove_handler(SIGBUS, EnvSignal::busCallback); - doSignal("Bus error", SIGBUS); -} - - -void -EnvSignal::illHandler() -{ - SignalHandler::instance().remove_handler(SIGILL, EnvSignal::illCallback); - doSignal("Illegal instruction error", SIGILL); -} - - -void -EnvSignal::termHandler() -{ - SignalHandler::instance().remove_handler(SIGTERM, EnvSignal::termCallback); - doSignal("Terminate signal received, likely due to an abort on another processor\n" - "Refer to standard output log for more information", SIGTERM); -} - -} // namespace - - -void -activate_signals() -{ - EnvSignal::instance().activateSignals(); -} - - -void -deactivate_signals() -{ - EnvSignal::instance().deactivateSignals(); -} - - -sigjmp_buf * -get_sigjmpbuf() -{ - return EnvSignal::instance().getSigJmpBuf(); -} - - -void -disable_siglongjmp() -{ - return EnvSignal::instance().disableSigLongJmp(); -} - - -const std::string & -get_signal_message() -{ - return EnvSignal::instance().message(); -} - - -bool -HUP_received() -{ - return EnvSignal::instance().getHUPReceived(); -} - -} // namespace Env -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.hpp deleted file mode 100644 index 12b37526682c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Signal.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_Signal_hpp -#define STK_UTIL_DIAG_Signal_hpp - -#include - -#include - -/** - * @file - * - * Signal handling is enabled via the activate_signals() function. The - * following signal behaviors are actived: - * - * HUP Sets the shutdown_request flag. - * TERM Long jumps with Termiante signal received message. - * SEGV Long jumps with Segmentation violation error message. - * BUS Long jumps with Bus error message. - * ILL Long jumps with Illegal instruction error message. - * - * - */ - -namespace sierra { -namespace Env { - -/// -/// @addtogroup EnvDetail -/// @{ -/// - -/** - * @brief Function activate_signals enables the signal handlers. - * - */ -void activate_signals(); - -/** - * @brief Function deactivate_signals disables the signal handlers. - * - */ -void deactivate_signals(); - -/** - * @brief Function get_sigjmpbuf enables signal handling and returns a - * pointer to the jump buffer for ::sigsetjmp and - * ::siglongjmp(). - * - * if (::sigsetjmp(*sierra::Env::get_signalException(), 1)) - * throw sierra::RuntimeError(sierra::Env::get_signal_message()); - * - * @return a sigjmp_buf pointer to the jmp buffer. - */ -sigjmp_buf *get_sigjmpbuf(); - -// /** -// * @brief Function disable_siglongjmp disables the long jump buffer. When -// * signals are received, they return to the caller without long jumping to the set jump point. -// * -// */ -// void disable_siglongjmp(); - -/** - * @brief Function get_signal_message returns the message associated with the - * most recent signal. - * - * @return a std::string const reference to the most - * recent signal message. - */ -const std::string &get_signal_message(); - -/** - * @brief Function request_shutdown sets the shutdown requested flag so that - * future calls to shutdown_requested() return true; - * - */ -bool HUP_received(); - -/** - * @brief Function shutdown_requested returns true if an application shutdown - * has requested via the request_shutdown has been called. - * - * @return a bool value of true if application has been - * requested to shutdown. - */ -bool shutdown_requested(); - -/// -/// @} -/// - -} // namespace Env -} // namespace sierra - -#endif // STK_UTIL_DIAG_Signal_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.cpp deleted file mode 100644 index cecf210cdbbd..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2002-2007, 2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include - -#include - -#include -#include - -extern "C" { - static void signal_handler(int signal, siginfo_t *sip, void *ucp) - { - // This routine is called for all signals... - // Just a C-callable wrapper around a call to the true signal handler... - sierra::SignalHandler::instance().handle_signal(signal); - } -} - -namespace sierra { - -namespace { - -int -convert_name_to_signal( - const String & signal) -{ - if (signal == "SIGABRT" || signal == "SIGKILL") { - return -1; - } - -#if defined(SIGILL) - if (signal == "SIGILL") return SIGILL; -#endif -#if defined(SIGSEGV) - if (signal == "SIGSEGV") return SIGSEGV; -#endif -#if defined(SIGALRM) - if (signal == "SIGALRM") return SIGALRM; -#endif -#if defined(SIGFPE) - if (signal == "SIGFPE") return SIGFPE; -#endif -#if defined(SIGHUP) - if (signal == "SIGHUP") return SIGHUP; -#endif -#if defined(SIGINT) - if (signal == "SIGINT") return SIGINT; -#endif -#if defined(SIGPIPE) - if (signal == "SIGPIPE") return SIGPIPE; -#endif -#if defined(SIGQUIT) - if (signal == "SIGQUIT") return SIGQUIT; -#endif -#if defined(SIGTERM) - if (signal == "SIGTERM") return SIGTERM; -#endif -#if defined(SIGUSR1) - if (signal == "SIGUSR1") return SIGUSR1; -#endif -#if defined(SIGUSR2) - if (signal == "SIGUSR2") return SIGUSR2; -#endif - return -2; -} - -} // namespace - - -SignalHandler & -SignalHandler::instance() { - static SignalHandler signal_handler; - - return signal_handler; -} - - -void -SignalHandler::handle_signal( - int signal) -{ - typedef std::vector HandlerList; - - time_t now = ::time(NULL); - - std::cerr << "Sierra received signal " << signal << " at " << ::ctime(&now) << std::endl; - - HandlerList handlers; - - std::pair range = m_handlerMap.equal_range(signal); - - for (HandlerMap::const_iterator pos = range.first; pos != range.second; ++pos) - handlers.push_back(&*pos); - - for (HandlerList::const_iterator it = handlers.begin(); it != handlers.end(); ++it) { - CallbackBase &obj = *(*it)->second; - obj(); - } -} - - -bool -SignalHandler::check_signal_name( - const String & signal) -{ - int isignal = convert_name_to_signal(signal); - return (isignal >= 0); -} - - -void -SignalHandler::add_handler( - const String & signal, - CallbackBase & callback) -{ - int isignal = convert_name_to_signal(signal); - if (isignal >= 0) { - add_handler(isignal, callback); - } - else if (isignal == -1) - throw std::runtime_error("signal cannot be handled"); - else if (isignal == -2) - throw std::runtime_error("signal name invalid"); - else - throw std::logic_error("invalid value from convert_node_to_signal()"); -} - - -void -SignalHandler::add_handler( - int signal, - CallbackBase & callback) -{ - // See if already handling this signal... - if (m_handlerMap.find(signal) == m_handlerMap.end()) { - // Tell OS that we want to handle this signal... - struct sigaction action; - struct sigaction *old_action = new struct sigaction; - - action.sa_sigaction = signal_handler; - sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO; - ::sigaction(signal, &action, old_action); - m_oldActionMap.insert(OldActionMap::value_type(signal, old_action)); - } - m_handlerMap.insert(HandlerMap::value_type(signal, &callback)); -} - - -void -SignalHandler::remove_handler( - int signal, - CallbackBase & callback) -{ - typedef std::pair HandlerRange; - - HandlerRange handler_range = m_handlerMap.equal_range(signal); - for (HandlerMap::iterator it = handler_range.first; it != handler_range.second; ) - if ((*it).second == &callback) { - HandlerMap::iterator erase_it = it++; - m_handlerMap.erase(erase_it); - } - else - ++it; - - if (m_handlerMap.find(signal) == m_handlerMap.end()) { - OldActionMap::iterator it = m_oldActionMap.find(signal); - if (it != m_oldActionMap.end()) { - ::sigaction(signal, (*it).second, NULL); - delete (*it).second; - m_oldActionMap.erase(it); - } - } -} - - -void -SignalHandler::remove_handler( - const String & signal, - CallbackBase & callback) -{ - int isignal = convert_name_to_signal(signal); - if (isignal >= 0) { - remove_handler(isignal, callback); - } - else if (isignal == -1) - throw std::runtime_error("signal cannot be handled"); - else if (isignal == -2) - throw std::runtime_error("signal name invalid"); - else - throw std::logic_error("invalid value from convert_node_to_signal()"); -} - - -void -SignalHandler::remove_all_handlers() -{ - m_handlerMap.clear(); - - for (OldActionMap::iterator it = m_oldActionMap.begin(); it != m_oldActionMap.end(); ++it) { - ::sigaction((*it).first, (*it).second, NULL); - delete (*it).second; - } - m_oldActionMap.clear(); -} - - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.hpp deleted file mode 100644 index ea9723afa2e5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/SignalHandler.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_SignalHandler_hpp -#define STK_UTIL_DIAG_SignalHandler_hpp - -#include - -#include -#include - -struct sigaction; - -/** - * @file - * - * The signal handler - */ - -namespace sierra { - -/** - * @brief Class SignalHandler ... - * - */ -class SignalHandler -{ -public: - /** - * @brief Member function instance ... - * - * @return a Handler ... - */ - static SignalHandler &instance(); - - static bool check_signal_name(const sierra::String& signal); - - /** - * @brief Member function handle_signal ... - * - * @param signal an int variable ... - */ - void handle_signal(int signal); - - /** - * @brief Member function add_handler ... - * - * @param signal an int variable ... - * @param callback a CallbackBase variable ... - */ - void add_handler(int signal, CallbackBase &callback); - - /** - * @brief Member function add_handler ... - * - * @param signal_name a String variable ... - * @param callback a CallbackBase variable ... - */ - void add_handler(const String &signal_name, CallbackBase &callback); - - /** - * @brief Member function remove_handler ... - * - * @param signal an int variable ... - * @param callback a CallbackBase variable ... - */ - void remove_handler(int signal, CallbackBase &callback); - - /** - * @brief Member function remove_handler ... - * - * @param signal_name a String variable ... - * @param callback a CallbackBase variable ... - */ - void remove_handler(const String &signal_name, CallbackBase &callback); - - /** - * @brief Member function remove_all_handlers ... - * - */ - void remove_all_handlers(); - -private: - typedef std::multimap HandlerMap; - typedef std::multimap OldActionMap; - - HandlerMap m_handlerMap; - OldActionMap m_oldActionMap; -}; - -} // namespace sierra - -#endif // STK_UTIL_DIAG_SignalHandler_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.cpp deleted file mode 100644 index 63059a6d869f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2004 - 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include - -#include -#include - -#include - -namespace sierra { -namespace Slib { - -/** - * Class Parser defines a mapping between strings and bit masks. - * - * After populating a Parser object, Diag::WriterParser::setPrintMask() will parse the - * input string and return the corresponding print mask. - * - */ -class DiagWriterParser : public Diag::WriterParser -{ -public: - /** - * Creates a new DiagWriterParser instance. - * - */ - DiagWriterParser() { - /* %TRACE[NONE]% */ /* %TRACE% */ - - mask("resources", (Diag::PrintMask) (LOG_RESOURCE), "Display resource assignments"); - mask("plugins", (Diag::PrintMask) (LOG_PLUGIN), "Display plugin information"); - mask("global-variables", (Diag::PrintMask) (LOG_GLOBAL_VARIABLE), "Display global variable operations"); - mask("memory", (Diag::PrintMask) (LOG_MEMORY), "Display platform specific memory usage information"); - } -}; - -DiagWriterParser & -theDiagWriterParser() -{ - static DiagWriterParser parser; - - return parser; -} - -stk_classic::diag::Writer & -theDiagWriter() -{ - /* %TRACE[NONE]% */ /* %TRACE% */ - static stk_classic::diag::Writer s_diagWriter(sierra::dwout().rdbuf(), theDiagWriterParser().parse(std::getenv("SIERRA_SLIBOUT"))); - - return s_diagWriter; -} - - -namespace { - -void bootstrap() -{ - Diag::registerWriter("slibout", slibout, theDiagWriterParser()); -} - -stk_classic::Bootstrap x(&bootstrap); - -} // namespace - -} // namespace Slib -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.hpp deleted file mode 100644 index 2e6ccc09d47d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/SlibDiagWriter.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef STK_UTIL_DIAG_SlibDiagWriter_h -#define STK_UTIL_DIAG_SlibDiagWriter_h - -#include -#include -#include - -#include - -namespace sierra { -namespace Slib { - -stk_classic::diag::Writer &theDiagWriter(); - -/// Macro fmwkout makes the coding look nicer. -#define slibout sierra::Slib::theDiagWriter() - -/// Macro SLIB_TRACE_ENABLED enables the traceback and tracing when defined. -#define SLIB_TRACE_ENABLED - -#ifdef SLIB_TRACE_ENABLED -typedef Diag::Tracespec Tracespec; -typedef Diag::Traceback Traceback; - -class Trace : public Diag::Trace -{ -public: - explicit Trace(const char *message) - : Diag::Trace(slibout, message) - {} -}; -#else -typedef Diag::Tracespec Tracespec; -typedef Diag::Tracespec Traceback; -typedef Diag::Tracespec Trace; -#endif - -} // namespace Slib - -namespace Diag { -using stk_classic::diag::push; -using stk_classic::diag::pop; -using stk_classic::diag::dendl; -} // namespace Diag - -} // namespace sierra - -#endif // STK_UTIL_DIAG_SlibDiagWriter_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/String.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/String.cpp deleted file mode 100644 index f17d207f44b0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/String.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2002-2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -//---------------------------------------------------------------------- - -namespace sierra { - -namespace { - -static const char arraylower_t[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F -}; - -inline int arraylower(int c) { - return arraylower_t[c]; -} - -} // namespace - -int to_label( int c ) -{ - return isspace(c) ? '_' : c; -} - -size_t char_simple_traits::length( const char * c1 ) -{ - const char * c = c1 ; - if ( c ) while ( *c ) ++c ; - return c - c1 ; -} - -int char_simple_traits::compare( const char * c1 , const char * c2 ) -{ - for ( ; *c1 && arraylower(*c1) == arraylower(*c2); c1++, c2++) - ; - - return arraylower(*c1) - arraylower(*c2); -} - -size_t char_label_traits::length( const char * c1 ) -{ - const char * c = c1 ; - if ( c ) while ( *c ) ++c ; - return c - c1 ; -} - -void char_label_traits::convert( char * c , size_t n ) -{ - for ( char * const e = c + n ; c != e ; ++c ) - *c = to_label(*c); -} - -int char_label_traits::compare( const char * c1 , const char * c2 ) -{ - for ( ; *c1 && arraylower(to_label(*c1)) == arraylower(to_label(*c2)); c1++, c2++) - ; - - return arraylower(to_label(*c1)) - arraylower(to_label(*c2)); -} - -} // namespace sierra - -//---------------------------------------------------------------------- - -namespace sierra { - -namespace implementation { - -/** @union StringData - * @par Objectives: - * @li Don't allocate for short strings, strings <= max_len - * @li buf_len == sizeof(String) - * @li buf_len % sizeof(unsigned long) == 0 - * - * @par Limitations: - * @li sizeof(StringData::Large) + 2 <= buf_len < ( 127 == 0x7f ) - * - * @par Memory layout for short strings that are <= max_len - * @li buf[ 0 .. max_len - 1 ] = buffer for characters - * @li buf[ max_len ] = null - * @li buf[ off_len ] = length of string - * @li data = must not be used - * - * @par Memory layout for long strings that are > max_len - * @li data.ptr = pointer to allocated memory - * @li data.len = length of string - * @li data.siz = allocated size - * @li buf[ max_len ] != null - * @li buf[ 0 .. max_len - 1 ] = must not be used - */ - -// Manage memory but do not invalidate current memory -// until operation is complete. - -char * StringData::mem( const char * cs , size_t n ) -{ - enum { inc = 4 * sizeof(long) }; - static std::string::allocator_type a ; - - const bool is_allocated = small[ max_len ] == 1; - const bool to_allocated = max_len < n ; - - size_t new_alloc = 0 ; - - if ( to_allocated && ( ! is_allocated || large.siz <= n ) ) { - const size_t n_total = n + 1 ; - new_alloc = n_total % inc ? n_total + inc - n_total % inc : n_total ; - if ( new_alloc == 0 || new_alloc - 1 < n ) { - throw std::runtime_error("FAILED MEMORY ALLOCATION SIZING in sierra::String"); - } - } - - char * dst = NULL ; - char * del_ptr = NULL ; - size_t del_size = 0 ; - - if ( is_allocated && ( new_alloc || ! to_allocated ) ) { - // Deallocate currently allocated memory after copying input, - // input might be a subset of currently allocated memory. - del_ptr = large.ptr ; - del_size = large.siz ; - } - - if ( to_allocated ) { - // Needs to be allocated to hold input - - if ( new_alloc ) { - // New allocation or reallocation to increase size - - { //---------------------------------------- - // Verify memory layout - static bool first_pass = true ; - - if ( first_pass ) { - first_pass = false ; - - if ( buf_len % sizeof(long) || - sizeof(StringData) != buf_len || - small + max_len < (char*)(&(large)) + sizeof(Large) ) { - throw std::logic_error("StringData memory layout error"); - } - } - } //---------------------------------------- - - try { - large.siz = new_alloc ; - large.ptr = (char *) a.allocate( new_alloc ); -// std::cout << "String allocated at " << (void *)large.ptr << " for " << new_alloc << std::endl; - } - catch (...) { - throw std::runtime_error("FAILED MEMORY ALLOCATION in sierra::String"); - } - } - - small[max_len] = 1 ; - large.len = n ; - dst = large.ptr ; - } - else { - small[max_len] = 0 ; - small[off_len] = n ; - dst = small ; - } - - { - const char * const cs_e = cs + n ; - char * d = dst ; - while ( cs != cs_e ) *d++ = *cs++ ; - *d = 0 ; - } - - if ( del_ptr != NULL ) { - try { -// std::cout << "String deallocated at " << (void *)del_ptr << " for " << del_size << std::endl; - a.deallocate( del_ptr , del_size ); - } - catch (...) { - throw std::runtime_error("FAILED MEMORY DEALLOCATION in sierra::String"); - } - } - - return dst ; -} - -StringData::~StringData() -{ mem(NULL, 0); } - -StringData::StringData() -{ small[ max_len ] = small[ off_len ] = small[ 0 ] = 0 ; } - -size_t StringData::len() const -{ return small[ max_len ] ? large.len : small[ off_len ] ; } - -char * StringData::c_str() -{ return small[ max_len ] ? large.ptr : small ; } - -const char * StringData::c_str() const -{ return small[ max_len ] ? large.ptr : small ; } - -} // namespace internal - -std::ostream & -operator<<( std::ostream & os, const sierra::String & s) -{ return os << s.c_str(); } - -std::istream & -operator>>( std::istream & is, sierra::String & s ) -{ std::string tmp; is >> tmp; s.assign(tmp); return is; } - -std::ostream & -operator<<( std::ostream & os, const sierra::Identifier &s) -{ return os << s.c_str(); } - -std::istream & -operator>>( std::istream & is, sierra::Identifier &s ) -{ std::string tmp; is >> tmp; s.assign(tmp); return is; } - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/String.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/String.hpp deleted file mode 100644 index 5307663e3bb1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/String.hpp +++ /dev/null @@ -1,819 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 - 2008 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_String_h -#define STK_UTIL_DIAG_String_h - -#ifdef USE_CISTRING - -#include - -namespace sierra { - -typedef cistring String; -typedef cistring Identifier; -typedef cistring ParamId; - -} // namespace sierra - -#else - -/** - * @file - * @author H. Carter Edwards - * - * Simple string value classes that avoid allocation for small strings. - * - * @par Assumption/Issue - * - * The std::string class (typically) allocates memory to - * hold any non-zero length string. The ISO C++ interface - * requirements also define a 'capacity' for std::string - * that may be larger than the string length. Thus the - * std::string class must, at a minimum, have a pointer - * to the allocated memory, a length integer, and a capacity - * integer. Furthermore, the std::string class may also - * support reference counting which is another integer. - * In addition to the std::string overhead there will also - * be some amount of allocated-memory management overhead. - * Somewhere between one and four words. - * - * @par Objective/Policy - * - * In SIERRA numerous object types have 'name' members - * that are string labels for those objects. These - * names are typically small, e.g. "density" or "temperature". - * The objective of the sierra::String class is to minimize - * the allocated memory overhead associated with these 'name' - * members. - * - * @par Design - * - * The String type owns a character buffer that is used - * to store small strings. If the input string is larger - * than the buffer then memory is allocated with an - * allocator (e.g. std::string::allocator_type). - * - * @par Specification of "small" string - * - * The character buffer is sized to be (1) approximately - * equal to the overhead of an allocated std::string object - * and (2) have a 4word (16byte) alignment. - * - * @par std::string, Interoperability and Recommendations - * - * String constructors and other methods are defined so that - * objects of the String type can be interoperable with the - * std::string class. It is recommended that the a final - * string value for a 'name' or 'label' be stored in a - * sierra::String object. Long strings or strings that will - * be manipulated (e.g. insert or append) should use the - * std::string class. If a name is to be constructed via - * manipulation then generate the string via 'std::string' - * and assign the final result to the sierra::String. - * If string manipulation includes formatting operations - * then the std::ostringstream or std::istringstream classes - * should be used. - */ - -#include -#include - -namespace sierra { - -/// -/// @addtogroup StringDetail -/// @{ -/// - -struct char_simple_traits ; - -struct char_label_traits ; - -/** Define precedence between two types */ -template struct Precedence ; - -template struct Precedence { typedef T Type ; }; - -template<> -struct Precedence { - typedef char_label_traits Type ; -}; - -template<> -struct Precedence { - typedef char_label_traits Type ; -}; - -/** @class StringBase - * Template base class for don't allocate short strings class. - */ -template class StringBase ; - -/** @class String - * Ordinary characters. - */ -typedef StringBase< char_simple_traits > String ; -typedef StringBase< char_label_traits > Identifier ; -typedef StringBase< char_label_traits > ParamId ; - -} - -//---------------------------------------------------------------------- -// Binary Operators: - -namespace sierra { - -template -bool operator== ( const StringBase &, const StringBase & ); - -template -bool operator!= ( const StringBase &, const StringBase & ); - -template -bool operator< ( const StringBase &, const StringBase & ); - -template -bool operator> ( const StringBase &, const StringBase & ); - -template -bool operator<= ( const StringBase &, const StringBase & ); - -template -bool operator>= ( const StringBase &, const StringBase & ); - - -template -bool operator== ( const StringBase &, const std::string & ); - -template -bool operator!= ( const StringBase &, const std::string & ); - -template -bool operator< ( const StringBase &, const std::string & ); - -template -bool operator> ( const StringBase &, const std::string & ); - -template -bool operator<= ( const StringBase &, const std::string & ); - -template -bool operator>= ( const StringBase &, const std::string & ); - - -template -bool operator== ( const StringBase &, const char * ); - -template -bool operator!= ( const StringBase &, const char * ); - -template -bool operator< ( const StringBase &, const char * ); - -template -bool operator> ( const StringBase &, const char * ); - -template -bool operator<= ( const StringBase &, const char * ); - -template -bool operator>= ( const StringBase &, const char * ); - - -template -bool operator== (const char *, const StringBase & ); - -template -bool operator!= (const char *, const StringBase & ); - -template -bool operator< (const char *, const StringBase & ); - -template -bool operator> (const char *, const StringBase & ); - -template -bool operator<= (const char *, const StringBase & ); - -template -bool operator>= (const char *, const StringBase & ); - - -template -bool operator== (const std::string &, const StringBase &); - -template -bool operator!= (const std::string &, const StringBase &); - -template -bool operator< (const std::string &, const StringBase &); - -template -bool operator> (const std::string &, const StringBase &); - -template -bool operator<= (const std::string &, const StringBase &); - -template -bool operator>= (const std::string &, const StringBase &); - - - -std::ostream & -operator<<( std::ostream & os, const sierra::String &s); - -std::istream & -operator>>( std::istream & is, sierra::String &s ); - -std::ostream & -operator<<( std::ostream & os, const sierra::Identifier &s); - -std::istream & -operator>>( std::istream & is, sierra::Identifier &s ); - -} - -//---------------------------------------------------------------------- - -namespace sierra { - -namespace implementation { - -union StringData { - - // Required: buf_len % sizeof(long) == 0 && buf_len > sizeof(Large) - enum { buf_len = 32 }; - enum { off_len = buf_len - 1 }; - enum { max_len = buf_len - 2 }; - - struct Large { - char * ptr ; // Pointer to allocated memory - size_t len ; // Length of string - size_t siz ; // Allocated size - } large ; - - char small[ buf_len ]; - - StringData(); - ~StringData(); - - size_t len() const ; - const char * c_str() const ; - char * c_str(); - - /** Assigns memory and copy contents */ - char * mem( const char *, size_t n ); -}; - -} - -//---------------------------------------------------------------------- - -template -class StringBase { -public: - typedef const char * const_iterator; - typedef char * iterator; - - // Types: - typedef CT traits_type ; - typedef char value_type ; - typedef size_t size_type ; - - // Construct/copy/destroy: - - ~StringBase(); - - StringBase(); - explicit StringBase( const std::string &); - - StringBase( const_iterator ); - template - StringBase( It, It ); - StringBase( const char *, size_type ); - - StringBase( const StringBase & ); - StringBase & operator= ( const StringBase & ); - - template - StringBase( const StringBase & ); - - StringBase & operator= ( const char * ); - StringBase & operator= ( const std::string & ); - - template - StringBase & operator= ( const StringBase & ); - - StringBase & operator+= ( const char * ); - StringBase & operator+= ( const std::string & ); - - template - StringBase & operator+= ( const StringBase & ); - - // Capacity: - size_type size() const; - size_type length() const; - bool empty() const ; - - const_iterator begin() const; - iterator begin(); - const_iterator end() const; - iterator end(); - - // Modifiers: - - StringBase & assign( const char * ); - StringBase & assign( const char *, const size_type ); - StringBase & assign( const std::string& ); - - template - StringBase & assign( const StringBase & ); - - StringBase & append( const char * ); - StringBase & append( const char *, const typename StringBase::size_type ); - StringBase & append( const std::string& ); - - template - StringBase & append( const StringBase & ); - - void swap( StringBase & ); - - // string operations - const char* c_str() const; - std::string s_str() const ; - - int compare( const char * ) const ; - int compare( const std::string & ) const ; - - template - int compare( const StringBase & ) const ; - -private: - implementation::StringData data ; -}; - -/** @class char_simple_traits - * Minimalist subset of character traits. - */ -struct char_simple_traits { -public: - /** Length of null-terminated string */ - static size_t length( const char * c1 ); - - /** Convert 'n' characters, a no-op */ - static void convert( char *, size_t ) - {} - - /** Compare null-terminated strings */ - static int compare( const char * c1, const char * c2 ); -}; - -/** @class char_label_traits - * All upper case, spaces and control characters converted to '_'. - * Does not support eof, stream types, or state types. - */ -struct char_label_traits { -public: - /** Length of null-terminated string */ - static size_t length( const char * c1 ); - - /** Convert 'n' characters */ - static void convert( char * c, size_t n ); - - /** Compare null-terminated strings as per conversion */ - static int compare( const char * c1, const char * c2 ); -}; - -//---------------------------------------------------------------------- - -template -bool StringBase::empty() const -{ return data.len() == 0 ; } - -template -typename StringBase::size_type StringBase::length() const -{ return data.len(); } - -template -typename StringBase::size_type StringBase::size() const -{ return data.len(); } - -template -typename StringBase::iterator -StringBase::begin() -{ return data.c_str(); } - -template -typename StringBase::const_iterator -StringBase::begin() const -{ return data.c_str(); } - -template -typename StringBase::iterator -StringBase::end() -{ return data.c_str() + data.len(); } - -template -typename StringBase::const_iterator -StringBase::end() const -{ return data.c_str() + data.len(); } - - -template -const char* StringBase::c_str() const -{ return data.c_str(); } - -template -std::string StringBase::s_str() const -{ return std::string(c_str()) ; } - -template -StringBase::~StringBase() -{} - -//---------------------------------------------------------------------- - -template -StringBase::StringBase() {} - -template -template -StringBase::StringBase( const StringBase & cs ) -{ - const size_type n = cs.length(); - traits_type::convert( data.mem(cs.c_str(), n), n ); -} - -template -StringBase::StringBase( const std::string& cs ) -{ - const size_type n = cs.length(); - traits_type::convert( data.mem(cs.c_str(), n), n ); -} - -template -StringBase::StringBase( const char * cs, typename StringBase::size_type n ) -{ - traits_type::convert( data.mem(cs, n), n ); -} - -template -template -StringBase::StringBase( It l_begin, It l_end ) -{ - traits_type::convert( data.mem(&(*l_begin), l_end - l_begin), l_end - l_begin ); -} - -template -StringBase::StringBase( const char * cs ) -{ - const size_type n = traits_type::length(cs); - traits_type::convert( data.mem(cs, n), n ); -} - -template -StringBase::StringBase( const StringBase & cs ) -{ - data.mem(cs.c_str(), cs.size()); -} - -//---------------------------------------------------------------------- - -template -StringBase & -StringBase::assign( const char * cs, const typename StringBase::size_type n ) -{ - traits_type::convert( data.mem(cs, n), n ); - return *this ; -} - -template -StringBase & StringBase::assign( const char * cs ) -{ return assign( cs, traits_type::length(cs) ); } - -template -StringBase & StringBase::assign( const std::string & cs ) -{ return assign( cs.c_str(), cs.length() ); } - -template -template -StringBase & StringBase::assign( const StringBase & cs ) -{ return assign( cs.c_str(), cs.length() ); } - -template -StringBase& -StringBase::operator= ( const StringBase & cs ) { - if (this == &cs) - return *this; - return assign( cs.c_str(), cs.length() ); -} - -template -template -StringBase& -StringBase::operator= ( const StringBase & cs ) { - return assign( cs.c_str(), cs.length() ); -} - -template -StringBase& -StringBase::operator= ( const char * cs ) -{ return assign( cs, traits_type::length(cs) ); } - -template -StringBase& -StringBase::operator= ( const std::string& cs ) -{ return assign( cs.c_str(), cs.length() ); } - -//---------------------------------------------------------------------- - -template -StringBase & -StringBase::append( const char * cs, const typename StringBase::size_type n ) -{ - std::string t; - - t.reserve(data.len() + n); - t.append(data.c_str()) - .append(cs, n); - traits_type::convert( data.mem(t.data(), t.length()), t.length()); - return *this ; -} - -template<> -inline -StringBase & -StringBase::append( const char * cs, const StringBase::size_type n ) -{ - std::string t; - - if (n != 0) { - t.reserve(data.len() + n + 1); - t.append(data.c_str()) - .append(data.len() == 0 ? "" : "_") - .append(cs, n); - traits_type::convert( data.mem(t.data(), t.length()), t.length()); - } - return *this ; -} - -template -StringBase & StringBase::append( const char * cs ) -{ return append( cs, traits_type::length(cs) ); } - -template -StringBase & StringBase::append( const std::string & cs ) -{ return append( cs.data(), cs.length() ); } - -template -template -StringBase & StringBase::append( const StringBase & cs ) -{ return append( cs.c_str(), cs.length() ); } - - -template -template -StringBase& -StringBase::operator+= ( const StringBase & cs ) -{ return append( cs.c_str(), cs.length() ); } - -template -StringBase& -StringBase::operator+= ( const char * cs ) -{ return append( cs, traits_type::length(cs) ); } - -template -StringBase& -StringBase::operator+= ( const std::string& cs ) -{ return append( cs.data(), cs.length() ); } - -//---------------------------------------------------------------------- - -template -template -int StringBase::compare( const StringBase & cs ) const -{ - typedef typename Precedence::Type Traits ; - return Traits::compare( c_str(), cs.c_str() ); -} - -template -int StringBase::compare( const std::string & cs ) const -{ - return CT::compare( c_str(), cs.c_str() ); -} - -template -int StringBase::compare( const char * cs ) const -{ - return CT::compare( c_str(), cs ); -} - -template -bool operator== ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) == 0 ; } - -template -bool operator!= ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) != 0 ; } - -template -bool operator< ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) < 0 ; } - -template -bool operator<= ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) <= 0 ; } - -template -bool operator> ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) > 0 ; } - -template -bool operator>= ( const StringBase & lhs, - const StringBase & rhs ) -{ return lhs.compare(rhs) >= 0 ; } - - -template -bool operator== ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) == 0 ; } - -template -bool operator!= ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) != 0 ; } - -template -bool operator< ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) < 0 ; } - -template -bool operator<= ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) <= 0 ; } - -template -bool operator> ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) > 0 ; } - -template -bool operator>= ( const StringBase & lhs, - const std::string & rhs ) -{ return lhs.compare(rhs) >= 0 ; } - - -template -bool operator== ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) == 0 ; } - -template -bool operator!= ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) != 0 ; } - -template -bool operator< ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) < 0 ; } - -template -bool operator<= ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) <= 0 ; } - -template -bool operator> ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) > 0 ; } - -template -bool operator>= ( const StringBase & lhs, - const char * rhs ) -{ return lhs.compare(rhs) >= 0 ; } - - -template -bool operator== ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) == 0 ; } - -template -bool operator!= ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) != 0 ; } - -template -bool operator< ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) > 0 ; } - -template -bool operator<= ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) >= 0 ; } - -template -bool operator> ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) < 0 ; } - -template -bool operator>= ( const std::string & lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) <= 0 ; } - - -template -bool operator== ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) == 0 ; } - -template -bool operator!= ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) != 0 ; } - -template -bool operator< ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) > 0 ; } - -template -bool operator<= ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) >= 0 ; } - -template -bool operator> ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) < 0 ; } - -template -bool operator>= ( const char * lhs, - const StringBase & rhs) -{ return rhs.compare(lhs) <= 0 ; } - -//---------------------------------------------------------------------- - -template -StringBase -operator+( const StringBase &cs1, const StringBase &cs2) { - StringBase t(cs1); - t.append(cs2.c_str(), cs2.size()); - return t; -} - -template -StringBase -operator+( const StringBase &cs1, const char *cs2) { - StringBase t(cs1); - t.append(cs2); - return t; -} - -template -StringBase -operator+( const StringBase &cs1, const std::string &cs2) { - StringBase t(cs1); - t.append(cs2.c_str(), cs2.length()); - return t; -} - -template -StringBase -operator+ ( const char *cs1, const StringBase &cs2 ) { - StringBase t(cs1); - t.append(cs2.c_str(), cs2.length()); - return t; -} - -template -std::string operator+(const std::string & lhs, const StringBase & rhs ) { - std::string s( lhs ); return s.append( rhs.c_str(), rhs.length() ); -} - -/// -/// @} -/// - -} // namespace sierra - -#endif // USE_CISTRING - -#endif // STK_UTIL_DIAG_String_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.cpp deleted file mode 100644 index 0a189cf3dbe9..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2002 - 2008 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -// Set for unit testing - -#define SIERRA_STRING_UNIT_TEST 0 - -//---------------------------------------------------------------------- - -namespace sierra { - -std::istream & -getline( - std::istream & is, - sierra::String & s, - char eol) -{ - std::string std_string; - - getline(is, std_string, eol); - s = std_string.c_str(); - return is; -} - - -int -case_strcmp( - const char * c1, - const char * c2) -{ - for ( ; ; c1++, c2++) { - if ( std::tolower(*c1) != std::tolower(*c2) ) - return ( std::tolower(*c1) - std::tolower(*c2) ) ; - if (*c1 == '\0') - return 0 ; - } -} - - -int -case_strncmp( - const char * c1, - const char * c2, - size_t n) -{ - - if (n == 0) - return 0; - - do { - if (*c1 != *c2++) - return std::tolower(*c1) - std::tolower(*(c2 - 1)); - if (*c1++ == 0) - break; - } while (--n != 0); - return 0; -} - - -const char * -case_strstr( - const char * s, - const char * find) -{ - if (!*find) - return s; - - const char *cp = s; - while (*cp) { - const char *t1 = cp; - const char *t2 = find; - - for ( ; std::tolower(*t1) && std::tolower(*t2) && !(std::tolower(*t1) - std::tolower(*t2)); ++t1, ++t2) - ; - - if (!*t2) - return cp; - - cp++; - } - - return NULL; -} - - -std::string -title( - const std::string & s) -{ - std::string t(s); - - bool all_upper = true; - bool all_lower = true; - - bool next_upper = true; - for (std::string::iterator c = t.begin(); c != t.end(); ++c) { - all_upper &= (*c == std::toupper(*c)); - all_lower &= (*c == std::tolower(*c)); - if (next_upper) - *c = std::toupper(*c); - else - *c = std::tolower(*c); - next_upper = !isalpha(*c); - } - - if (all_upper || all_lower) - return t; - else - return s; -} - - -template -std::string -to_string( - const T & t) -{ - std::ostringstream os; - os << t; - return os.str(); -} - -template std::string to_string(const double &); -template std::string to_string(const float &); -template std::string to_string(const int &); -template std::string to_string(const unsigned &); -template std::string to_string(const long &); -template std::string to_string(const unsigned long &); - -std::string -to_string( - const double & r, - int precision) -{ - std::ostringstream os; - os << std::setprecision(precision) << r; - return std::string(os.str()); -} - - -std::string -to_string( - const float & r, - int precision) -{ - std::ostringstream os; - os << std::setprecision(precision) << r; - return std::string(os.str()); -} - - -std::string -format_time( - double t, - const char * format) -{ - time_t time = (time_t) t; - char s[128]; - - ::strftime(s, sizeof(s), format, ::localtime(&time)); - - return std::string(s); -} - - -std::ostream & -object_phrase::print( - std::ostream & os) const -{ - if (m_n == 0) - os << m_plural << " no " << m_noun << "s"; - else if (m_n == 1) - os << m_singular << " 1 " << m_noun; - else - os << m_plural << " " << m_n << " " << m_noun << "s"; - - return os; -} - - -object_phrase::operator std::string() const -{ - std::ostringstream strout; - strout << *this; - - return strout.str(); -} - - -namespace { - -std::string::const_iterator -find_next_char( - std::string::const_iterator p, - std::string::const_iterator end, - char c) -{ - while (p != end && *p != c) - p++; - return p; -} - -std::string::const_iterator -find_next_not_char( - std::string::const_iterator p, - std::string::const_iterator end, - char c) -{ - while (p != end && *p == c) - p++; - return p; -} - -inline std::string::const_iterator find_next_space(std::string::const_iterator p, std::string::const_iterator end) { - return find_next_char(p, end, ' '); -} - -inline std::string::const_iterator find_next_endl(std::string::const_iterator p, std::string::const_iterator end) { - return find_next_char(p, end, '\n'); -} - -inline std::string::const_iterator find_next_nonspace(std::string::const_iterator p, std::string::const_iterator end) { - return find_next_not_char(p, end, ' '); -} - -} // namespace - -std::string -word_wrap( - const std::string & s, - unsigned int line_length, - const std::string & prefix, - const std::string & prefix_first_line) -{ - std::string t; - const std::string *u = &prefix_first_line; - - std::string::const_iterator p0, p1, p2, p3; - p0 = p1 = p2 = s.begin(); - - while (p2 != s.end() ) { - - // skip preceeding whitespace - p1 = find_next_nonspace(p0, s.end()); - p3 = find_next_endl(p0, s.end()); - p2 = p1 = find_next_space(p1, s.end()); - do { - p1 = find_next_nonspace(p1, s.end()); - p1 = find_next_space(p1, s.end()); - if (p3 < p1) { - p2 = p3; - break; - } - if ((unsigned int) (p1 - p0) > (line_length - u->size())) - break; - p2 = p1; - } while (p2 != s.end()); - - t.append(*u).append(p0, p2).append("\n"); - - if (p2 == p3) - u = &prefix_first_line; - else - u = &prefix; - - p0 = p2 + 1; - } - - return t; -} - - -template -T convert_cast(const String &s) -{ - /* %TRACE% */ /* %TRACE% */ - std::istringstream is(s.c_str()); - T t = 0; - - is >> t; - - if (!is) { - std::ostringstream msg; - msg << "Unable to convert \"" << s << "\" to type " << typeid(T).name(); - throw std::runtime_error(msg.str().c_str()); - } - - - return t; -} - -template double convert_cast(const String &); -template float convert_cast(const String &); -template int convert_cast(const String &); -template unsigned convert_cast(const String &); -template long convert_cast(const String &); -template unsigned long convert_cast(const String &); - - -// void -// get_function_spec_parts( -// const std::string & spec, -// std::string & namespace_name, -// std::string & class_name, -// std::string & function_name, -// std::vector & arglist) -// { -// namespace_name.erase(namespace_name.begin(), namespace_name.end()); -// class_name.erase(class_name.begin(), class_name.end()); -// function_name.erase(function_name.begin(), function_name.end()); -// arglist.erase(arglist.begin(), arglist.end()); - -// std::string::const_iterator it_paren = find_next_open_paren(spec.begin(), spec.end()); -// std::string::const_iterator it_func_name = find_prev_double_colon(spec.begin(), it_paren); -// function_name = std::string(it_func_name, it_paren); -// if (it_func_name != spec.begin()) { -// it_func_name -= 2; -// std::string::const_iterator it_class_name = find_prev_double_colon(spec.begin(), it_func_name); -// class_name = std::string(it_class_name, it_func_name); -// if (it_class_name != spec.begin()) { -// it_class_name -= 2; -// namespace_name = std::string(spec.begin(), it_class_name); -// } -// } -// } - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.hpp deleted file mode 100644 index 9c3ba69209c1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/StringUtil.hpp +++ /dev/null @@ -1,860 +0,0 @@ -#ifndef STK_UTIL_DIAG_StringUtil_h -#define STK_UTIL_DIAG_StringUtil_h - -#include -#include -#include -#include -#include - -#include -#include - -namespace sierra { - -/// -/// @addtogroup StringUtilDetail -/// @{ -/// - -/** - * @brief Function case_strcmp compares two null terminated strings case - * insenstively. It returns zero if they are case insensitively equal, a negative value - * if c1 is case insensitively less than c2, or a positive value if - * c1 is case insensitively greater than c2 - * - * @param c1 a char const pointer to the first string. - * - * @param c2 a char const pointer to the second string. - * - * @return an int value of zero if they are equal, negative if - * c1 is less than c2, or positive if c1 is - * greater than c2, without regard to case. - */ -int case_strcmp(const char *c1, const char *c2); - -int case_strncmp(const char *c1, const char *c2, size_t n); - -/** - * @brief Function case_strcmp compares two null terminated strings case - * insenstively. It returns zero if they are case insensitively equal, a negative value - * if s1 is case insensitively less than s2, or a positive value if - * s1 is case insensitively greater than s2 - * - * @param s1 a std::string reference to the first string. - * - * @param s2 a std::string reference to the second string. - * - * @return an int value of zero if they are equal, negative if - * s1 is less than s2, or positive if s1 is - * greater than s2, without regard to case. - */ -inline int case_strcmp(const std::string &s1, const std::string &s2) { - return case_strcmp(s1.c_str(), s2.c_str()); -} - -/** - * @brief Function case_strcmp compares two null terminated strings case - * insenstively. It returns zero if they are case insensitively equal, a negative value - * if s1 is case insensitively less than s2, or a positive value if - * s1 is case insensitively greater than s2 - * - * @param s1 a String reference to the first string. - * - * @param s2 a String reference to the second string. - * - * @return an int value of zero if they are equal, negative if - * s1 is less than s2, or positive if s1 is - * greater than s2, without regard to case. - */ -inline int case_strcmp(const String &s1, const String &s2) { - return case_strcmp(s1.c_str(), s2.c_str()); -} - -const char *case_strstr(const char *t, const char *find); - -inline const char *case_strstr(const std::string &s1, const std::string &s2) { - return case_strstr(s1.c_str(), s2.c_str()); -} - -inline const char *case_strstr(const String &s1, const String &s2) { - return case_strstr(s1.c_str(), s2.c_str()); -} - - -/* - * @brief Member function undef_if_empty returns the string value - * "" if the string s is empty, otherwise it returns the string. - * - * @param s a String reference to the string to check if empty. - * - * @return a String value of "" if the string - * s is empty, otherwise the string. - */ -inline String undef_if_empty(const String &s) { - return s.empty() ? "" : s; -} - -/** - * @brief Function to_upper returns the value converted to upper case. - * - * @param c an int value to be converted. - * - * @return an int value converted to upper case. - */ -inline int to_upper(int c) { - return std::toupper(c); -} - -/** - * @brief Function to_lower returns the value converted to lower case. - * - * @param c an int value to be converted - * - * @return an int value converted to lower case. - */ -inline int to_lower(int c) { - return std::tolower(c); -} - -/** - * @brief Function to_identifier_upper returns the value converted to underscore if - * it is a space or to upper case. - * - * @param c an int value to be converted - * - * @return an int value converted to an underscore or upper case. - */ -inline int to_identifier_upper(int c) { - return std::isspace(c) ? '_' : std::toupper(c); -} - -/** - * @brief Function to_identifier_lower returns the value converted to underscore if - * it is a space or to lower case. - * - * @param c an int value to be converted - * - * @return an int value converted to an underscore or lower case. - */ -inline int to_identifier_lower(int c) { - return std::isspace(c) ? '_' : std::tolower(c); -} - -/** - * @brief Function make_upper converts strgin name to upper case. The - * conversion happens in place. - * - * @param name a T reference to convert to a upper case. - * - * @return an T reference to the converted upper case string. - */ -template -inline T &make_upper(T &name) { - std::transform(name.begin(), name.end(), name.begin(), to_upper); - - return name; -} - -/** - * @brief Function make_lower converts string name to lower case. The - * convertion happens in place. - * - * @param name a T reference to convert to an lower. - * - * @return an T reference to the converted lower case string. - */ -template -inline T &make_lower(T &name) { - std::transform(name.begin(), name.end(), name.begin(), to_lower); - - return name; -} - -/** - * @brief Function make_identifier converts string name to an identifier case. The - * convertion happens in place. - * - * @param name a T reference to convert to an identifier. - * - * @return an T reference to the converted identifier string. - */ -template -inline T &make_identifier(T &name) { - std::transform(name.begin(), name.end(), name.begin(), to_identifier_upper); - - return name; -} - -/** - * @brief Function make_lower_identifier converts string name to a lower - * case identifier case. The convertion happens in place. - * - * @param name a T reference to convert to a lower case identifier. - * - * @return an T reference to the converted lower case identifier - * string. - */ -template -inline T &make_lower_identifier(T &name) { - std::transform(name.begin(), name.end(), name.begin(), to_identifier_lower); - - return name; -} - -/** - * @brief Function make_identifier converts string name to an identifier - * case. The convertion happens in place. - * - * @param name a char pointer to convert to an identifier. - * - * @return an char pointer to the converted identifier string. - */ -inline char *make_identifier(char *name) { - for (char *c = name; *c != 0; ++c ) - *c = to_identifier_upper(*c); - - return name; -} - -/** - * @brief Function make_lower_identifier converts string name to a lower - * case identifier case. The convertion happens in place. - * - * @param name a char pointer to convert to a lower case identifier. - * - * @return an char pointer to the converted lower case identifier - * string. - */ -inline char *make_lower_identifier(char *name) { - for (char *c = name; *c != 0; ++c ) - *c = to_identifier_lower(*c); - - return name; -} - -/** - * @brief Function trim trims preceeding and trailing spaces from name. The - * convertion happens in place. - * - * @param name a T reference to trim. - * - * @return an T reference to the trimmed string. - */ -template -inline T & -trim( - T & name) -{ - typename T::iterator it0 = name.begin(); - while (it0 != name.end() && std::isspace(*it0)) - ++it0; - - typename T::iterator it1 = name.end(); - while (it1 != it0 && std::isspace(*(it1 - 1))) - --it1; - return name = T(it0, it1); -} - -/** - * @brief Function title returns a first letter of each word capitalized of the - * string. - * - * @param s a std::string const reference to be word capitalized. - * - * @return a std::string value of the word capitalized string. - */ -std::string title(const std::string &s); - -inline std::string title(const String &s) { - return title(std::string(s.c_str())); -} - - -/** - * @brief Function lower returns a lower case version of the string. - * - * @param s a String const reference to be lower cased. - * - * @return a String value of the lower cased string. - */ -inline String lower(const String &s) -{ - String t = s; - return make_lower(t); -} - -/** - * @brief Function to_string returns a string representation of r. - * - * @param r a double value to be stringized. - * - * @param precision an int value of the precision. - * - * @return a std::string value of the string representation of - * r. - */ -std::string to_string(const double &r, int precision = 4); - -/** - * @brief Function to_string returns a string representation of r. - * - * @param r a float value to be stringized. - * - * @param precision an int value of the precision. - * - * @return a std::string value of the string representation of - * r. - */ -std::string to_string(const float &r, int precision = 4); - -/** - * Template function to_string returns a string representation of - * r. - * - * @param t a T value to be stringized. - * - * @return a std::string value of the string representation of - * r. - */ -template -std::string to_string(const T &t); - -/** - * @brief Function demangle returns the demangled C++ symbol from the mangled - * C++ symbol. The mangled named is obtained from the type_info - * name() function. From some compilers, the name is already demangled. - * - * @param symbol a char const pointer to the symbol. - * - * @return a std::string value of the demangled name. - */ -#ifdef SIERRA_USE_PLATFORM_DEMANGLER -// Implement this is Slib_EnvPlatform.C -std::string demangle(const char *symbol); -#else -const char *demangle(const char *symbol); -#endif - -/** - * @brief Function format_time encodes the time using the format specified. - * The format is described in stdftime. - * - * @param t a time_t value of the time to format. - * - * @param format a char const pointer to the format. - * - * @return a String value of the encoded time. - */ -std::string format_time(double t, const char *format = "%b %e %Y %H:%M:%S"); - -/** - * @brief Function word_wrap reformats a string into multiple lines, none longer - * that line_length, the first line prefixed with prefix_first_line and the - * remaining lines prefixed with prefix. - * - * @param s a std::string const reference to the string - * to word wrap. - * - * @param line_length an unsigned int value of the line length. - * - * @param prefix a std::string const reference to a line - * prefix string. - * - * @param prefix_first_line a std::string const reference to a line - * prefix string for the first line. - * - * @return a std::string value of the word wrapped string. - */ -std::string word_wrap(const std::string &s, unsigned int line_length, - const std::string &prefix, const std::string &prefix_first_line); - -/** - * @brief Function word_wrap reformats a string into multiple lines, none longer - * that line_length and each line prefixed with prefix. - * - * @param s a std::string const reference to the string - * to word wrap. - * - * @param line_length an unsigned int value of the line length. - * - * @param prefix a std::string const reference to a line - * prefix string. - * - * @return a std::string value of the word wrapped string. - */ -inline std::string word_wrap(const std::string &s, unsigned int line_length = 72, const std::string &prefix = "") { - return word_wrap(s, line_length, prefix, prefix); -} - - -/** - * @brief Class object_phrase makes a pretty string for those annoying plural or - * singular noun/verb phrases. - * - * The output is plural no nouns, when n is zero,
- * singular 1 noun, when n is 1, or
- * plural n nouns, when n is greater than 1. - * - */ -class object_phrase -{ -public: - /** - * Creates a new object_phrase instance. - * - * @param n an int value of the quantity of objects - * - * @param noun a char const pointer to the name of the object. - * - * @param singlar a char singular form of the verb acting on the object. - * - * @param plural a char plural form of the verb acting on the object. - * - */ - object_phrase(int n, const char *noun, const char *singlar = "is", const char *plural = "are") - : m_n(n), - m_noun(noun), - m_singular(singlar), - m_plural(plural) - {} - - /** - * @brief Member function print writes the object phrase to the output stream. - * - * @param os a std::ostream reference to the output stream to write to. - * - * @return a std::ostream reference to the output stream. - */ - std::ostream &print(std::ostream &os) const; - - /** - * @brief Member function operator std::string returns a string of the object - * phrase. - * - * @return a std::string value of the object string. - */ - operator std::string () const; - -private: - int m_n; ///< Object count - const char * m_noun; ///< Object name - const char * m_singular; ///< Singular verb - const char * m_plural; ///< Plural verb -}; - -/** - * @brief Function operator<< writes an object phrase to the output stream. - * - * @param os a std::ostream reference to the output stream to write to. - * - * @param phrase an object_phrase const reference to the object phrase to be - * written. - * - * @return a std::ostream reference to the output stream. - */ -inline std::ostream &operator<<(std::ostream &os, const object_phrase &phrase) { - return phrase.print(os); -} - - -/** - * @brief Function getline returns a string from the input stream which has been - * terminated by the newline character. - * - * @param is a std::istream reference to the input stream. - * - * @param s a sierra::String reference to received the line. - * - * @param eol a char value to use of the newline character. - * - * @return a std::istream reference to the input stream. - */ -std::istream &getline(std::istream &is, sierra::String &s, char eol = '\n'); - -/** - * @brief Class less_nocase implements a case insensitive compare functor. - * - */ -template -struct less_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is less than - * rhs. - * - * @param lhs a T const reference to the left hand side value. - * - * @param rhs a T cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const T &lhs, const T &rhs) const { - typename T::const_iterator lhs_it = lhs.begin(); - typename T::const_iterator rhs_it = rhs.begin(); - typename T::const_iterator lhs_it_end = lhs.end(); - typename T::const_iterator rhs_it_end = rhs.end(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - int i = std::tolower(*lhs_it) - std::tolower(*rhs_it); - if (i != 0) - return i < 0; - } - - if (lhs_it == lhs_it_end) - return rhs_it != rhs_it_end; - else - return false; - } -}; - - -/** - * @brief Class specialization less_nocase for String. - * - */ -template <> -struct less_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is less than - * rhs. - * - * @param lhs a String const reference to the left hand side value. - * - * @param rhs a String cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const String &lhs, const String &rhs) const { - const char * lhs_it = lhs.c_str(); - const char * rhs_it = rhs.c_str(); - const char * lhs_it_end = lhs_it + lhs.length(); - const char * rhs_it_end = rhs_it + rhs.length(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - int i = std::tolower(*lhs_it) - std::tolower(*rhs_it); - if (i != 0) - return i < 0; - } - - if (lhs_it == lhs_it_end) - return rhs_it != rhs_it_end; - else - return false; - } -}; - - -/** - * @brief Class specialization less_nocase for std::string. - * - */ -template <> -struct less_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is less than - * rhs. - * - * @param lhs a std::string const reference to the left hand side value. - * - * @param rhs a std::string cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const std::string &lhs, const std::string &rhs) const { - const char * lhs_it = lhs.c_str(); - const char * rhs_it = rhs.c_str(); - const char * lhs_it_end = lhs_it + lhs.length(); - const char * rhs_it_end = rhs_it + rhs.length(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - int i = std::tolower(*lhs_it) - std::tolower(*rhs_it); - if (i != 0) - return i < 0; - } - - if (lhs_it == lhs_it_end) - return rhs_it != rhs_it_end; - else - return false; - } -}; - - -/** - * @brief Class specialization less_nocase for char const pointer. - * - */ -template<> -struct less_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is less than - * rhs. - * - * @param lhs a char const pointer to the left hand side value. - * - * @param rhs a char const pointer to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const char *lhs , const char *rhs) const { - bool result ; - if (NULL == lhs ) - result = NULL != rhs; - else { - for (; *lhs && *rhs && std::tolower(*lhs) == std::tolower(*rhs); ++lhs, ++rhs) - ; - result = std::tolower(*lhs) < std::tolower(*rhs); - } - return result ; - } -}; - - -/** - * @brief Class equal_nocase implements a case insensitive compare functor. - * - */ -template -struct equal_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is equal to - * rhs. - * - * @param lhs a T const reference to the left hand side value. - * - * @param rhs a T cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const T &lhs, const T &rhs) const { - typename T::const_iterator lhs_it = lhs.begin(); - typename T::const_iterator rhs_it = rhs.begin(); - typename T::const_iterator lhs_it_end = lhs.end(); - typename T::const_iterator rhs_it_end = rhs.end(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - if (std::tolower(*lhs_it) != std::tolower(*rhs_it)) - return false; - } - - return lhs_it == lhs_it_end && rhs_it == rhs_it_end; - } -}; - -/** - * @brief Class specialization equal_nocase for String. - * - */ -template <> -struct equal_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is equal to - * rhs. - * - * @param lhs a String const reference to the left hand side value. - * - * @param rhs a String cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const String &lhs, const String &rhs) const { - const char * lhs_it = lhs.c_str(); - const char * rhs_it = rhs.c_str(); - const char * lhs_it_end = lhs_it + lhs.length(); - const char * rhs_it_end = rhs_it + rhs.length(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - if (std::tolower(*lhs_it) != std::tolower(*rhs_it)) - return false; - } - - return lhs_it == lhs_it_end && rhs_it == rhs_it_end; - } -}; - -/** - * @brief Class specialization equal_nocase for std::string. - * - */ -template <> -struct equal_nocase : public std::binary_function -{ - /** - * @brief Member function operator() returns true if the lhs is equal to - * rhs. - * - * @param lhs a std::string const reference to the left hand side value. - * - * @param rhs a std::string cosnt reference to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const std::string &lhs, const std::string &rhs) const { - const char * lhs_it = lhs.c_str(); - const char * rhs_it = rhs.c_str(); - const char * lhs_it_end = lhs_it + lhs.length(); - const char * rhs_it_end = rhs_it + rhs.length(); - - for (; lhs_it != lhs_it_end && rhs_it != rhs_it_end; ++lhs_it, ++rhs_it) { - if (std::tolower(*lhs_it) != std::tolower(*rhs_it)) - return false; - } - - return lhs_it == lhs_it_end && rhs_it == rhs_it_end; - } -}; - -/** - * @brief Class specialization equal_nocase for char const pointer. - * - */ -template <> -struct equal_nocase : public std::binary_function { - /** - * @brief Member function operator() returns true if the lhs is equal to - * rhs. - * - * @param lhs a char const pointer to the left hand side value. - * - * @param rhs a char cosnt pointer to the right hand side value. - * - * @return a bool value of true if the lhs is less than - * rhs - */ - bool operator()(const char *lhs , const char *rhs) const { - bool result = lhs == rhs ; - if ( ! result && NULL != lhs && NULL != rhs ) { - for (; *lhs && *rhs && std::tolower(*lhs) == std::tolower(*rhs) ; ++lhs, ++rhs); - result = 0 == *lhs && 0 == *rhs ; - } - return result ; - } -}; - -/** - * @brief Class hash_nocase is a traits class for hash functions. - * - */ -template struct hash_nocase {}; - -/** - * @brief Function hash_string_nocase hash a character string case insensitively. - * - * @param p a char const pointer to a character string. - * - * @return a size_t value of the hashed string. - */ -inline -size_t hash_string_nocase( - const char * p) -{ - size_t h = 0; - const size_t sr = std::numeric_limits::digits * sizeof(size_t) - 8; - const size_t mask = ((size_t) 0xF) << (sr + 4); - while (*p) { - h = (h << 4) + std::tolower(*p++); - size_t g = h & mask; - h ^= g | (g >> sr); - } - return h; -} - -/** - * @brief Class specialization hash_nocase for std::string. - * - */ -template<> -struct hash_nocase -{ - /** - * @brief Member function operator() returns the hash value of the - * specified string. - * - * @param __s a std::stringsize_t value of the hash value of the specified - * string. - */ - size_t operator()(const std::string & __s) const { return hash_string_nocase(__s.c_str()); } -}; - -/** - * @brief Class specialization hash_nocase for String. - * - */ -template<> -struct hash_nocase -{ - /** - * @brief Member function operator() returns the hash value of the - * specified string. - * - * @param __s a std::stringsize_t value of the hash value of the specified - * string. - */ - size_t operator()(const String & __s) const { return hash_string_nocase(__s.c_str()); } -}; - -// /** -// * @brief Class specialization hash_nocase for std::string. -// * -// */ -// template<> -// struct hash_nocase -// { -// /** -// * @brief Member function operator() returns the hash value of the -// * specified string. -// * -// * @param __s a std::stringsize_t value of the hash value of the specified -// * string. -// */ -// size_t operator()(const std::string & __s) const { return hash_string_nocase(__s.c_str()); } -// }; - -// /** -// * @brief Class specialization hash_nocase for std::string. -// * -// */ -// template<> -// struct hash_nocase -// { -// /** -// * @brief Member function operator() returns the hash value of the -// * specified string. -// * -// * @param __s a std::stringsize_t value of the hash value of the specified -// * string. -// */ -// size_t operator()(const String & __s) const { return hash_string_nocase(__s.c_str()); } -// }; - -/// -/// @} -/// - -template -T convert_cast(const String &s); - -} // namespace sierra - -#endif // STK_UTIL_DIAG_StringUtil_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.cpp deleted file mode 100644 index 1d472f033950..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.cpp +++ /dev/null @@ -1,1206 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef __JVN -#include -#endif - -#include - -#ifdef SIERRA_INCLUDE_LIBPAPI -# include -# if defined(PAPI_VERSION) && (PAPI_VERSION_MAJOR(PAPI_VERSION) != 3) -# error "Compiling against an unknown PAPI version" -# endif -#endif - -// #include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -namespace stk_classic { -namespace diag { - -namespace { - -MetricsMask s_enabledMetricsMask = METRICS_LAP_COUNT | METRICS_CPU_TIME | METRICS_WALL_TIME; ///< Bit mask of enabled metrics - -template -typename MetricTraits::Type -value_now() { - if (MetricTraits::METRIC & getEnabledTimerMetricsMask()) - return MetricTraits::value_now(); - else - return 0; -} - -std::vector & -split( - const std::string & path, - char separator, - std::vector & path_vector) -{ - for (std::string::const_iterator it = path.begin(); ; ) { - std::string::const_iterator it2 = std::find(it, path.end(), separator); - path_vector.push_back(std::string(it, it2)); - if (it2 == path.end()) - break; - it = it2 + 1; - } - - return path_vector; -} - -} // namespace - - -MetricsMask getEnabledTimerMetricsMask() -{ - return s_enabledMetricsMask; -} - -void -setEnabledTimerMetricsMask( - MetricsMask timer_mask) -{ - s_enabledMetricsMask = timer_mask | METRICS_LAP_COUNT; -} - - -/** - * Class TimerImpl is the core timer class. The Timer class is a - * wrapper around TimerImpl so that the buried references can be constructed more easily. - * - * Each timer has a lap counter, cpu timer, wall timer and other metrics. Each time a timer is - * started, the cpu start time, wall start time and other metrics, set to the process' current - * values. When the timer is stopped, the lap counter is incremented, and the cpu, wall, and other - * values are accumulated with the difference between now and the start time. - * - * Each timer may have a list of subordinate timers. The relationship is purely - * hierarchical in that a there is no timing relationship assumed between the timers other - * than the grouping. There is no relation between the starting and stopping of parent - * and subordinate timers. - * - * The subordinate timers are stored as pointers to a new timer on the heap, since the - * calling function will be receiving a reference to this memory which can never change - * location. The subordinate timers are not sorted in the list as they should very - * rarely be created or looked up by name, rather the calling function stores the - * reference via the Timer class. - * - */ -class TimerImpl -{ - friend class Timer; - -public: - static void updateRootTimer(TimerImpl *root_timer); - - static Timer createRootTimer(const std::string &name, const TimerSet &timer_set); - - static void deleteRootTimer(TimerImpl *root_timer); - - static std::vector &findTimers(TimerImpl *root_timer, const std::string &path_tail, std::vector &found_timers); - - static void findTimer(TimerImpl *timer, std::vector &path_tail_vector, std::vector &found_timers); - -private: - /** - * Static function reg returns a reference to an existing timer or newly - * created timer of the specified name which is subordinate to the - * parent timer. - * - * @return a TimerImpl reference to the timer with the - * specified name that is subordinate to the - * parent timer. - */ - static TimerImpl *reg(const std::string &name, TimerMask timer_mask, TimerImpl *parent_timer, const TimerSet &timer_set) { - return parent_timer->addSubtimer(name, timer_mask, timer_set); - } - - /** - * Creates a new Timer instance. - * - * @param name a std::string const reference to the name of - * the timer. - * - */ - TimerImpl(const std::string &name, TimerMask timer_mask, TimerImpl *parent_timer, const TimerSet &timer_set); - - /** - * Destroys a TimerImpl instance. - * - */ - ~TimerImpl(); - - TimerImpl(const TimerImpl &TimerImpl); - TimerImpl &operator=(const TimerImpl &TimerImpl); - - /** - * Class finder is a binary predicate for finding a subordinate timer. - * - * Note that the subordinate timer is an unsorted list as there are very few timers - * created and should rarely be looked up by name. - */ -#ifdef __INTEL_COMPILER -#pragma warning(push) -#pragma warning(disable: 444) -#endif - class finder : private std::unary_function - { - public: - explicit finder(const std::string &name) - : m_name(name) - {} - - bool operator()(Timer timer) const { - return equal_case(timer.getName(), m_name); - } - - private: - std::string m_name; - }; -#ifdef __INTEL_COMPILER -#pragma warning(pop) -#endif - -public: - /** - * Member function getName returns the name of the timer. - * - * @return a std::string const reference to the timer's - * name. - */ - const std::string &getName() const { - return m_name; - } - - /** - * Member function getTimerMask returns the timer mask of the timer. - * - * @return a TimerMask value to the timer mask. - */ - TimerMask getTimerMask() const { - return m_timerMask; - } - - /** - * Member function getTimerSet returns the timer set of the timer. - * - * @return a TimerSet const reference to the timer set. - */ - const TimerSet &getTimerSet() const { - return m_timerSet; - } - - /** - * Member function shouldRecord returns true if any of the specified timer - * bit masks are set in the enable timer bit mask. - * - * @param timer_mask a TimerMask value to test the enable timer - * bit mask against. - * - */ - bool shouldRecord() const { - return m_timerSet.shouldRecord(m_timerMask) && s_enabledMetricsMask; - } - - /** - * Member function getSubtimerLapCount returns the subtimer lap counter. - * - * @return a Counter value of the subtimer lap - * counter. - */ - double getSubtimerLapCount() const { - return m_subtimerLapCount; - } - - void setSubtimerLapCount(double value) { - m_subtimerLapCount = value; - } - - /** - * Member function getLapCount returns the lap counter metric. The lap - * count metric is the number of times the stop function has been executed. - * - * @return a CounterMetric const reference of the lap counter - * metric. - */ - template - const Timer::Metric &getMetric() const; - - /** - * Member function getTimerList returns the subtimers associated with - * this timer. - * - * @return a TimerList const reference to the sub - * time list. - */ - const TimerList &getTimerList() const { - return m_subtimerList; - } - - TimerList::iterator begin() { - return m_subtimerList.begin(); - } - - TimerList::const_iterator begin() const { - return m_subtimerList.begin(); - } - - TimerList::iterator end() { - return m_subtimerList.end(); - } - - TimerList::const_iterator end() const { - return m_subtimerList.end(); - } - - /** - * Member function reset resets the accumulated time and lap times. - * - */ - void reset(); - - /** - * Member function checkpoint checkpoints the timer and all subtimers. - * - */ - void checkpoint() const; - - /** - * Member function start sets the start timer. - * - * @return a TimerImpl reference to the timer. - */ - TimerImpl &start(); - - /** - * Member function lap sets the stop timer. - * - * @return a TimerImpl reference to the timer. - */ - TimerImpl &lap(); - - /** - * Member function stop sets the stop timer and sums the just completed lap - * time to the timer. - * - * @return a TimerImpl reference to the timer. - */ - TimerImpl &stop(); - - /** - * Member function accumulateSubtimerLapCounts sums the lap counter of all - * subordinate timers. This is used to determin which timers have been activated at all. - * - * @return an int value of the number of subordinate - * timer laps. - */ - double accumulateSubtimerLapCounts() const; - - Timer getSubtimer(const std::string &name); - -public: - /** - * Member function dump writes the timer to the specified - * diagnostic writer. - * - * @param dout a Writer variable reference to write the timer to. - * - * @return a Writer reference to dout. - */ - Writer &dump(Writer &dout) const; - -private: - /** - * Member function addSubtimer returns a reference to an existing or new - * subtimer with the specified name. - * - * @param name a std::string value of the timer's name. - * - * @param timer_mask a TimerMask value of the class of the timer. - * - * @return a TimerImpl reference to the timer with - * specified name. - */ - TimerImpl *addSubtimer(const std::string &name, TimerMask timer_mask, const TimerSet &timer_set); - -private: - std::string m_name; ///< Name of the timer - TimerMask m_timerMask; ///< Bit mask to enable timer - TimerImpl * m_parentTimer; ///< Parent timer - mutable double m_subtimerLapCount; ///< Sum of subtimer lap counts and m_lapCount - unsigned m_lapStartCount; ///< Number of pending lap stops - - TimerList m_subtimerList; ///< List of subordinate timers - - const TimerSet & m_timerSet; ///< Timer enabled mask - Timer::Metric m_lapCount; ///< Number of laps accumulated - Timer::Metric m_cpuTime; ///< CPU time - Timer::Metric m_wallTime; ///< Wall time - Timer::Metric m_MPICount; ///< MPI call count - Timer::Metric m_MPIByteCount; ///< MPI byte count - Timer::Metric m_heapAlloc; ///< Heap allocated -}; - - -/** - * Member function operator<< ... - * - * @param dout a Writer variable ... - * - * @param timer a TimerImpl variable ... - * - * @return a Writer ... - */ -inline Writer &operator<<(Writer &dout, const TimerImpl &timer) { - return timer.dump(dout); -} - - -void -updateRootTimer( - Timer root_timer) -{ - TimerImpl::updateRootTimer(root_timer.m_timerImpl); -} - - -Timer -createRootTimer( - const std::string & name, - const TimerSet & timer_set) -{ - return TimerImpl::createRootTimer(name, timer_set); -} - - -void -deleteRootTimer( - Timer timer) -{ - TimerImpl::deleteRootTimer(timer.m_timerImpl); - timer.m_timerImpl = 0; -} - - -std::vector & -findTimers(Timer root_timer, const std::string &path_tail, std::vector &found_timers) { - TimerImpl::findTimers(root_timer.m_timerImpl, path_tail, found_timers); - return found_timers; -} - - -TimerImpl::TimerImpl( - const std::string & name, - TimerMask timer_mask, - TimerImpl * parent_timer, - const TimerSet & timer_set) - : m_name(name), - m_timerMask(timer_mask), - m_parentTimer(parent_timer), - m_subtimerLapCount(0.0), - m_lapStartCount(0), - m_subtimerList(), - m_timerSet(timer_set) -{} - - -TimerImpl::~TimerImpl() -{ - try { - for (TimerList::iterator it = m_subtimerList.begin(); it != m_subtimerList.end(); ++it) - delete (*it).m_timerImpl; - } - catch (std::exception &) { - } -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_lapCount; -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_cpuTime; -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_wallTime; -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_MPICount; -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_MPIByteCount; -} - - -template<> -const Timer::Metric & -TimerImpl::getMetric() const { - return m_heapAlloc; -} - - -void -TimerImpl::reset() -{ - m_lapStartCount = 0; - - m_lapCount.reset(); - m_cpuTime.reset(); - m_wallTime.reset(); - m_MPICount.reset(); - m_MPIByteCount.reset(); - m_heapAlloc.reset(); -} - - -Timer -TimerImpl::getSubtimer( - const std::string & name) -{ - TimerList::iterator it = std::find_if(m_subtimerList.begin(), m_subtimerList.end(), finder(name)); - - if (it == m_subtimerList.end()) - throw std::runtime_error("Timer not found"); - else - return *it; -} - - -TimerImpl * -TimerImpl::addSubtimer( - const std::string & name, - TimerMask timer_mask, - const TimerSet & timer_set) -{ - TimerList::iterator it = std::find_if(m_subtimerList.begin(), m_subtimerList.end(), finder(name)); - - if (it == m_subtimerList.end()) { - TimerImpl *timer_impl = new TimerImpl(name, timer_mask, this, timer_set); - m_subtimerList.push_back(Timer(timer_impl)); - return timer_impl; - } - else - return (*it).m_timerImpl; -} - - -TimerImpl & -TimerImpl::start() -{ - if (shouldRecord()) { - if (m_lapStartCount++ == 0) { - m_lapCount.m_lapStart = m_lapCount.m_lapStop; - - m_cpuTime.m_lapStop = m_cpuTime.m_lapStart = value_now(); - m_wallTime.m_lapStop = m_wallTime.m_lapStart = value_now(); - m_MPICount.m_lapStop = m_MPICount.m_lapStart = value_now(); - m_MPIByteCount.m_lapStop = m_MPIByteCount.m_lapStart = value_now(); - m_heapAlloc.m_lapStop = m_heapAlloc.m_lapStart = value_now(); - } - } - - return *this; -} - - -TimerImpl & -TimerImpl::lap() -{ - if (shouldRecord()) { - if (m_lapStartCount > 0) { - m_cpuTime.m_lapStop = value_now(); - m_wallTime.m_lapStop = value_now(); - m_MPICount.m_lapStop = value_now(); - m_MPIByteCount.m_lapStop = value_now(); - m_heapAlloc.m_lapStop = value_now(); - } - } - - return *this; -} - - -TimerImpl & -TimerImpl::stop() -{ - if (shouldRecord()) { - if (--m_lapStartCount <= 0) { - m_lapStartCount = 0; - m_lapCount.m_lapStop++; - - m_cpuTime.m_lapStop = value_now(); - m_wallTime.m_lapStop = value_now(); - m_MPICount.m_lapStop = value_now(); - m_MPIByteCount.m_lapStop = value_now(); - m_heapAlloc.m_lapStop = value_now(); - - m_lapCount.addLap(); - m_cpuTime.addLap(); - m_wallTime.addLap(); - m_MPICount.addLap(); - m_MPIByteCount.addLap(); - m_heapAlloc.addLap(); - } - } - - return *this; -} - - -double -TimerImpl::accumulateSubtimerLapCounts() const -{ - m_subtimerLapCount = m_lapCount.getAccumulatedLap(false); - - for (TimerList::const_iterator it = m_subtimerList.begin(); it != m_subtimerList.end(); ++it) - (*it).m_timerImpl->accumulateSubtimerLapCounts(); - - for (TimerList::const_iterator it = m_subtimerList.begin(); it != m_subtimerList.end(); ++it) - m_subtimerLapCount += (*it).m_timerImpl->m_subtimerLapCount; - - return m_subtimerLapCount; -} - - -void -TimerImpl::checkpoint() const -{ - m_lapCount.checkpoint(); - m_cpuTime.checkpoint(); - m_wallTime.checkpoint(); - m_MPICount.checkpoint(); - m_MPIByteCount.checkpoint(); - m_heapAlloc.checkpoint(); - - for (TimerList::const_iterator it = m_subtimerList.begin(); it != m_subtimerList.end(); ++it) - (*it).m_timerImpl->checkpoint(); -} - - -void -TimerImpl::updateRootTimer(TimerImpl *root_timer) -{ - root_timer->m_lapCount.m_lapStop = value_now(); - root_timer->m_cpuTime.m_lapStop = value_now(); - root_timer->m_wallTime.m_lapStop = value_now(); - root_timer->m_MPICount.m_lapStop = value_now(); - root_timer->m_MPIByteCount.m_lapStop = value_now(); - root_timer->m_heapAlloc.m_lapStop = value_now(); - - root_timer->m_lapCount.m_accumulatedLap = root_timer->m_lapCount.m_lapStop - root_timer->m_lapCount.m_lapStart; - root_timer->m_cpuTime.m_accumulatedLap = root_timer->m_cpuTime.m_lapStop - root_timer->m_cpuTime.m_lapStart; - root_timer->m_wallTime.m_accumulatedLap = root_timer->m_wallTime.m_lapStop - root_timer->m_wallTime.m_lapStart; - root_timer->m_MPICount.m_accumulatedLap = root_timer->m_MPICount.m_lapStop - root_timer->m_MPICount.m_lapStart; - root_timer->m_MPIByteCount.m_accumulatedLap = root_timer->m_MPIByteCount.m_lapStop - root_timer->m_MPIByteCount.m_lapStart; - root_timer->m_heapAlloc.m_accumulatedLap = root_timer->m_heapAlloc.m_lapStop - root_timer->m_heapAlloc.m_lapStart; -} - - - -Timer -TimerImpl::createRootTimer( - const std::string & name, - const TimerSet & timer_set) -{ - TimerImpl *timer_impl = new TimerImpl(name, 0, 0, timer_set); - return Timer(timer_impl); -} - - -void -TimerImpl::deleteRootTimer( - TimerImpl * root_timer) -{ - delete root_timer; -} - - -void -TimerImpl::findTimer( - TimerImpl * timer, - std::vector & path_tail_vector, - std::vector & found_timers) -{ - if (timer->begin() == timer->end()) { // at leaf - - } - else - for (TimerList::const_iterator it = timer->begin(); it != timer->end(); ++it) - findTimer((*it).m_timerImpl, path_tail_vector, found_timers); -} - - -std::vector & -TimerImpl::findTimers( - TimerImpl * root_timer, - const std::string & path_tail, - std::vector & found_timers) -{ - std::vector path_tail_vector; - - findTimer(root_timer, split(path_tail, '.', path_tail_vector), found_timers); - - return found_timers; -} - - - -Writer & -TimerImpl::dump( - Writer & dout) const -{ - if (dout.shouldPrint()) { - dout << "TimerImpl" << push << dendl; - dout << "m_name, " << m_name << dendl; - dout << "m_timerMask, " << m_timerMask << dendl; -// dout << "m_parentTimer, " << c_ptr_name(m_parentTimer) << dendl; - dout << "m_subtimerLapCount, " << m_subtimerLapCount << dendl; - dout << "m_lapStartCount, " << m_lapStartCount << dendl; - - dout << "m_lapCount, " << m_lapCount << dendl; - dout << "m_cpuTime, " << m_cpuTime << dendl; - dout << "m_wallTime, " << m_wallTime << dendl; - dout << "m_MPICount, " << m_MPICount << dendl; - dout << "m_MPIByteCount, " << m_MPIByteCount << dendl; - dout << "m_heapAlloc, " << m_heapAlloc << dendl; - - dout << "m_subtimerList, " << m_subtimerList << dendl; - dout << pop; - } - - return dout; -} - - -Timer::Timer(const std::string &name, const Timer parent) - : m_timerImpl(TimerImpl::reg(name, parent.getTimerMask(), parent.m_timerImpl, parent.getTimerSet())) -{} - -Timer::Timer(const std::string &name, TimerMask timer_mask, const Timer parent) - : m_timerImpl(TimerImpl::reg(name, timer_mask, parent.m_timerImpl, parent.getTimerSet())) -{} - -Timer::Timer(const std::string &name, const Timer parent, const TimerSet &timer_set) - : m_timerImpl(TimerImpl::reg(name, parent.getTimerMask(), parent.m_timerImpl, timer_set)) -{} - -Timer::Timer(const std::string &name, TimerMask timer_mask, const Timer parent, const TimerSet &timer_set) - : m_timerImpl(TimerImpl::reg(name, timer_mask, parent.m_timerImpl, timer_set)) -{} - - -const std::string & -Timer::getName() const { - return m_timerImpl->m_name; -} - -TimerMask -Timer::getTimerMask() const { - return m_timerImpl->getTimerMask(); -} - -const TimerSet & -Timer::getTimerSet() const { - return m_timerImpl->getTimerSet(); -} - -double -Timer::getSubtimerLapCount() const { - return m_timerImpl->getSubtimerLapCount(); -} - -const TimerList & -Timer::getTimerList() const { - return m_timerImpl->getTimerList(); -} - -template -const Timer::Metric & -Timer::getMetric() const { - return m_timerImpl->getMetric(); -} - -template const Timer::Metric &Timer::getMetric() const; -template const Timer::Metric &Timer::getMetric() const; -template const Timer::Metric &Timer::getMetric() const; -template const Timer::Metric &Timer::getMetric() const; -template const Timer::Metric &Timer::getMetric() const; -template const Timer::Metric &Timer::getMetric() const; - - -bool -Timer::shouldRecord() const -{ - return m_timerImpl->shouldRecord(); -} - -TimerList::iterator -Timer::begin() -{ - return m_timerImpl->begin(); -} - -TimerList::const_iterator -Timer::begin() const -{ - return m_timerImpl->begin(); -} - -TimerList::iterator -Timer::end() -{ - return m_timerImpl->end(); -} - -TimerList::const_iterator -Timer::end() const -{ - return m_timerImpl->end(); -} - -double -Timer::accumulateSubtimerLapCounts() const { - return m_timerImpl->accumulateSubtimerLapCounts(); -} - -Timer & -Timer::start() { - m_timerImpl->start(); - return *this; -} - -Timer & -Timer::lap() { - m_timerImpl->lap(); - return *this; -} - -Timer & -Timer::stop() { - m_timerImpl->stop(); - return *this; -} - -void -Timer::checkpoint() const { - m_timerImpl->checkpoint(); -} - -Writer & -Timer::dump(Writer& dout) const { - return m_timerImpl->dump(dout); -} - -template -Writer & -Timer::Metric::dump( - Writer & dout) const -{ - if (dout.shouldPrint()) { - dout << "Timer::Metric" << push << dendl; - dout << "m_lapStart, " << m_lapStart << dendl; - dout << "m_lapStop, " << m_lapStop << dendl; - dout << "m_accumulatedLap, " << m_accumulatedLap << dendl; - dout << "m_checkpoint, " << m_checkpoint << dendl; - dout << pop; - } - return dout; -} - -template Writer &Timer::Metric::dump(Writer &) const; -template Writer &Timer::Metric::dump(Writer &) const; -template Writer &Timer::Metric::dump(Writer &) const; -template Writer &Timer::Metric::dump(Writer &) const; -template Writer &Timer::Metric::dump(Writer &) const; -template Writer &Timer::Metric::dump(Writer &) const; - - -TimeBlockSynchronized::TimeBlockSynchronized( - Timer & timer, - MPI_Comm mpi_comm, - bool start_timer) - : m_timer(timer), - m_mpiComm(mpi_comm), - m_started(start_timer) -{ - if (m_timer.m_timerImpl->shouldRecord()) { -#ifdef STK_HAS_MPI - if (mpi_comm != MPI_COMM_NULL) - MPI_Barrier(mpi_comm); -#endif - - if (start_timer) - m_timer.start(); - } -} - - -TimeBlockSynchronized::~TimeBlockSynchronized() -{ - if (m_started) { - try { - m_timer.stop(); - } - catch (...) { - } - } -} - - -void -TimeBlockSynchronized::start() -{ - // Place barrier here - MPI_Barrier(m_mpiComm); - m_started = true; - m_timer.start(); -} - - -void -TimeBlockSynchronized::stop() -{ - m_started = false; - m_timer.stop(); - // Does a barrier need to be here? - // MPI_Barrier(Env::parallel_comm()); -} - -} // namespace diag -} // namespace stk_classic - - - -#ifdef SIERRA_INCLUDE_LIBPAPI -class PAPIRuntimeError : public std::runtime_error -{ -public: - PAPIRuntimeError(const char *message, int status) - : std::runtime_error(message), - m_status(status) - {} - - virtual const char *what() const throw() { - static std::string message; - static char papi_message[PAPI_MAX_STR_LEN]; - - PAPI_perror(m_status, papi_message, sizeof(papi_message)); - - message = std::runtime_error::what(); - message += papi_message; - - return message.c_str(); - } - -private: - int m_status; -}; -#endif - - -namespace sierra { -namespace Diag { - -namespace { - -size_t -s_timerNameMaxWidth = DEFAULT_TIMER_NAME_MAX_WIDTH; ///< Maximum width for names - -} // namespace - - -// -// SierraRootTimer member functions: -// -SierraRootTimer::SierraRootTimer() - : m_sierraTimer(stk_classic::diag::createRootTimer("Sierra", sierraTimerSet())) -{ } - - -SierraRootTimer::~SierraRootTimer() -{ - stk_classic::diag::deleteRootTimer(m_sierraTimer); -} - - -stk_classic::diag::Timer & SierraRootTimer::sierraTimer() -{ - return m_sierraTimer; -} - - -TimerSet & -sierraTimerSet() -{ - static TimerSet s_sierraTimerSet(TIMER_PROCEDURE | TIMER_REGION); - - return s_sierraTimerSet; -} - - -boost::shared_ptr sierraRootTimer() -{ - static boost::shared_ptr s_sierraRootTimer(new SierraRootTimer()); - if ( ! s_sierraRootTimer ) { - s_sierraRootTimer.reset(new SierraRootTimer()); - } - return s_sierraRootTimer; -} - - -Timer & -sierraTimer() -{ - return sierraRootTimer()->sierraTimer(); -} - -void -sierraTimerDestroy() -{ - sierraRootTimer().reset(); -} - - -void -setEnabledTimerMask( - TimerMask timer_mask) -{ - sierraTimerSet().setEnabledTimerMask(timer_mask); -} - - -TimerMask -getEnabledTimerMask() -{ - return sierraTimerSet().getEnabledTimerMask(); -} - - -void -setTimeFormat(int time_format) { - stk_classic::diag::setTimerTimeFormat(time_format); -} - - -void -setTimeFormatMillis() -{ - if ((getTimeFormat() & stk_classic::TIMEFORMAT_STYLE_MASK ) == stk_classic::TIMEFORMAT_HMS) { - if (getSierraWallTime() > 3600.0) - setTimeFormat(getTimeFormat() & ~stk_classic::TIMEFORMAT_MILLIS); - else - setTimeFormat(getTimeFormat() | stk_classic::TIMEFORMAT_MILLIS); - } - else if ((getTimeFormat() & stk_classic::TIMEFORMAT_STYLE_MASK ) == stk_classic::TIMEFORMAT_SECONDS) { - if (getSierraWallTime() > 1000.0) - setTimeFormat(getTimeFormat() & ~stk_classic::TIMEFORMAT_MILLIS); - else - setTimeFormat(getTimeFormat() | stk_classic::TIMEFORMAT_MILLIS); - } -} - - -int -getTimeFormat() -{ - return stk_classic::diag::getTimerTimeFormat(); -} - - -void -setTimerNameMaxWidth( - size_t width) -{ - s_timerNameMaxWidth = width; -} - - -size_t -getTimerNameMaxWidth() -{ - return s_timerNameMaxWidth; -} - - -stk_classic::diag::MetricTraits::Type -getSierraCPUTime() -{ - return sierraTimer().getMetric().getAccumulatedLap(false); -} - - -stk_classic::diag::MetricTraits::Type -getSierraWallTime() -{ - return sierraTimer().getMetric().getAccumulatedLap(false); -} - - -stk_classic::diag::MetricTraits::Type -getCPULapTime(Timer timer) { - return timer.getMetric().getLap(); -} - -stk_classic::diag::MetricTraits::Type -getCPUAccumulatedLapTime(Timer timer) { - return timer.getMetric().getAccumulatedLap(false); -} - - -TimerParser & -theTimerParser() -{ - static TimerParser parser; - - return parser; -} - - -TimerParser::TimerParser() - : sierra::OptionMaskParser() -{ - mask("cpu", 0, "Display CPU times"); - mask("wall", 0, "Display wall times"); - - mask("hms", 0, "Display times in HH:MM:SS format"); - mask("seconds", 0, "Display times in seconds"); - - -// mask("table", TIMER_TABLE, "Format output as a table"); -// mask("xml", TIMER_XML, "Format output as an XML file"); - - mask("all", TIMER_ALL, "Enable all metrics"); - mask("none", TIMER_NONE, "Disable all timers"); - - mask("domain", TIMER_DOMAIN, "Enable metrics on the domain"); - mask("region", TIMER_REGION, "Enable metrics on regions"); - mask("procedure", TIMER_PROCEDURE, "Enable metrics on procedures"); - mask("mechanics", TIMER_MECHANICS, "Enable metrics on mechanics"); - mask("algorithm", TIMER_ALGORITHM, "Enable metrics on algorithms"); - mask("solver", TIMER_SOLVER, "Enable metrics on solvers"); - mask("contact", TIMER_CONTACT, "Enable metrics on contact"); - mask("material", TIMER_MATERIAL, "Enable metrics on materials"); - mask("search", TIMER_SEARCH, "Enable metrics on searches"); - mask("transfer", TIMER_TRANSFER, "Enable metrics on user functions"); - mask("adaptivity", TIMER_ADAPTIVITY, "Enable metrics on adaptivity"); - mask("recovery", TIMER_RECOVERY, "Enable metrics on encore recovery"); - mask("profile1", TIMER_PROFILE_1, "Enable app defined profiling metrics"); - mask("profile2", TIMER_PROFILE_2, "Enable app defined profiling metrics"); - mask("profile3", TIMER_PROFILE_3, "Enable app defined profiling metrics"); - mask("profile4", TIMER_PROFILE_4, "Enable app defined profiling metrics"); - mask("app1", TIMER_APP_1, "Enable app defined metrics"); - mask("app2", TIMER_APP_2, "Enable app defined metrics"); - mask("app3", TIMER_APP_3, "Enable app defined metrics"); - mask("app4", TIMER_APP_4, "Enable app defined metrics"); -} - - -OptionMaskParser::Mask -TimerParser::parse( - const char * mask) const -{ - m_metricsSetMask = 0; - m_metricsMask = 0; - m_optionMask = getEnabledTimerMask(); - - m_optionMask = OptionMaskParser::parse(mask); - -// if ((m_optionMask & TIMER_FORMAT) == 0) -// m_optionMask |= TIMER_TABLE; - - setEnabledTimerMask(m_optionMask); - - if (m_metricsSetMask != 0) - stk_classic::diag::setEnabledTimerMetricsMask(m_metricsMask); - - return m_optionMask; -} - - -void -TimerParser::parseArg( - const std::string & name, - const std::string & arg) const -{ - if (name == "cpu") { - m_metricsMask |= stk_classic::diag::METRICS_CPU_TIME; - m_metricsSetMask |= stk_classic::diag::METRICS_CPU_TIME; - } - else if (name == "wall") { - m_metricsMask |= stk_classic::diag::METRICS_WALL_TIME; - m_metricsSetMask |= stk_classic::diag::METRICS_WALL_TIME; - } - else if (name == "heap") { - m_metricsMask |= stk_classic::diag::METRICS_HEAP_ALLOC; - m_metricsSetMask |= stk_classic::diag::METRICS_HEAP_ALLOC; - } - else if (name == "none") { - m_optionMask = 0; - m_metricsSetMask = stk_classic::diag::METRICS_WALL_TIME | stk_classic::diag::METRICS_CPU_TIME; - } - - else if (name == "hms") { - Diag::setTimeFormat(stk_classic::TIMEFORMAT_HMS); - } - else if (name == "seconds") { - Diag::setTimeFormat(stk_classic::TIMEFORMAT_SECONDS); - } - - else - OptionMaskParser::parseArg(name, arg); -} - -} // namespace Diag -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.dox b/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.dox deleted file mode 100644 index be2fb37bd5c6..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.dox +++ /dev/null @@ -1,140 +0,0 @@ -/// -/// \addtogroup stk_util_diag_timer_detail -/// @{ -/// -/// @brief Timers are part of the diagnostic subsystem. The allow easy block level and ad -/// hoc timing with hierarchical display. -/// -/// Lap time, accumulated time and checkpoint. -/// -/// The timers are best implemented within an application as a member of a class or a -/// static variable within a function. Each timer is created with a name and a parent. -/// This name is looked up within the parent to generate the display hierarchy. Due to -/// this overhead, the timer's should be mutable members of rarely created objects whose -/// timers are created during construction, or as static variables of functions whose -/// timers are created during the first function execution. Once created, the timer is -/// actually a reference to a separate timer container that lives until application shuts -/// down. -/// -/// When the timer is created, it is given a name, enable bits and a parent. If the enable -/// bits are not provided, they are inherited from the parent. If the parent is not -/// provided, it is assigned the root timer as a parent. When the timer is created, the -/// parent is searched for the timer's name, if found, then this timer is assigned to the -/// existing timer. If not found, a new timer is created. So, by assigning a unique name -/// to each class member timer, the hierarchy of object's timers is easily created. -/// -/// Class member timers should be declared mutable so that they may be update even in -/// const objects. -/// -/// Starting and stopping of timers is generally performed using the TimeBlock and -/// TimeBlockSynchronized sentries. By using sentry's, you are guaranteed that the timer -/// will be stopped if it has been started. The default behavior of the TimeBlock -/// sentries is to start the timer on construction and stop is on destruction. -/// Alternatively, you can not start the timer on construction, but start it at a later -/// time, rest assured that if started it will be stopped by the sentry destructor. -/// -/// It is not necessary that all timers be used to collect time, they may simply be used -/// as a timer container for establishing a display hierarchy. -/// -/// \anchor stk_util_diag_timer_howto_add_to_class -/// To time operations within an object:
-/// -/// \code -/// #include -/// -/// class AClass -/// { -/// public: -/// AClass(const std::string &name, ParentClass &parent) -/// : m_timerAClass(std::string("AClass ") + name, Diag::TIMER_REGION, parent.getParentTimer()), -/// m_timerInitialize("Initialize", m_timerAClass), -/// m_timerExecute("Execute", m_timerAClass) -/// {} -/// -/// void initialize() { -/// Diag::Timer::TimeBlock _timer(m_timerInitialize); -/// -/// ... -/// } -/// -/// void execute() { -/// Diag::Timer::TimeBlock _timer(m_timerExecute); -/// -/// ... -/// } -/// -/// private: -/// mutable Diag::Timer m_timerAClass; ///< AClass's root timer -/// mutable Diag::Timer m_timerInitialize; ///< Initialize timer -/// mutable Diag::Timer m_timerExecute; ///< Execute timer -/// }; -/// \endcode -/// -/// \anchor stk_util_diag_timer_howto_add_to_function -/// -/// To time functions:
-/// -/// \code -/// void -/// aFunction() -/// { -/// static Diag::Timer a_function_timer("aFunction", Diag::TIMER_PROFILE1); -/// -/// Diag::Timer::TimeBlock _timer(a_function_timer); -/// -/// ... -/// } -/// \endcode -/// -/// -/// \anchor stk_util_diag_timer_howto_checkpoint -/// \section stk_util_diag_timer_checkpoint Checkpointing an application timers -/// -/// Printing of the diagnostic timer's is generally performed by the framework. However -/// for non-Solution Control based applications, the following will enable the -/// checkpointed output from the timers. -/// -/// \code -/// Int step = (Int) parameters().value( "GLOBAL_TIMESTEP_COUNTER" ) + 1; -/// Fmwk::Domain::singleton()->print_timer_information(step); -/// \endcode -/// -/// \anchor stk_util_diag_timer_howto_stop_watch -/// \section stk_util_diag_timer_stop_watch Using the diagnostic timers for examining execution times -/// -/// The timers are similar to a stop watch. They maintain a lap timer and accumulated completed lap -/// time. Once a lap is started, retrieving the lap time will give you the time since the most -/// recent start. Once the lap is stopped, the completed lap time is accumulated to the timer. -/// Retrieving the lap time will give you the time of the most recent completed lap. Retrieving the -/// accumulated time does not include any time from a started lap, only laps which have been -/// completed. -/// -/// You can also checkpoint the timers by using the checkpoint() function. Calling -/// getAccumulatedLap(true) will provide you with the accumulated time since the last -/// checkpoint. -/// -/// For Example:
-/// -/// \code -/// { -/// { -/// Diag::Timer _timer(m_timerExecute); -/// for (int i = 0; i < some_silly_number; ++i) { -/// Do some heavy lifting -/// -/// std::cout << "This heavy lifing has taken " << m_timerExecute.getCpuTime().getLap(); -/// } -/// } -/// -/// std::cout << "This heavy lifting:" << std::endl -/// << "started at " << m_timerExecute.getCpuTime().getStart() << std::endl -/// << "took " << m_timerExecute.getCpuTime().getLap() << std::endl -/// << "stopped at " << m_timerExecute.getCpuTime().getStop() << std::endl -/// << "and has taken " << m_timerExecute.getCpuTime().getAccumulatedLap(false) << std::endl -/// << "and has taken " << m_timerExecute.getCpuTime().getAccumulatedLap(true) -/// << " since being checkpointed" << std::endl; -/// } -/// \endcode -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.hpp deleted file mode 100644 index 63ea99b55f8d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Timer.hpp +++ /dev/null @@ -1,844 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_Timer_hpp -#define STK_UTIL_DIAG_Timer_hpp - -#include -#include -#include -#include - -#include -#if defined( STK_HAS_MPI ) -#include -#endif - -#include -#include -#include -#include - -#include -#include -#include - - -/// -/// @addtogroup DiagTimerDetail -/// @{ -/// - -namespace stk_classic { -namespace diag { - -class Timer; -class TimerSet; -class TimerImpl; - -typedef unsigned TimerMask; ///< Timer classification mask - -/** - * Function getEnabledMetricsMask retruns the timer enable bit mask. - * - * @return a MetricsMask value of the timer enable bit - * mask. - */ -MetricsMask getEnabledTimerMetricsMask(); - -/** - * Function setEnabledMetricsMask set the timer enable bit mask to - * timer_mask. - * - * @param timer_mask a MetricsMask value to set the timer enable bit - * mask to. - * - */ -void setEnabledTimerMetricsMask(MetricsMask timer_mask); - -/** - * Function updateRootTimer updates the root timers stop and total - * metric values with the current time. - * - * @param root_timer a Timer reference to the root timer. - * - */ -void updateRootTimer(Timer root_timer); - -/** - * Function createRootTimer creates a root timer. Root timers are the root of a timer - * hierarchy. The timer_set specifies the timer groupings for this root timer. The percentage of a - * child timer is the ratio of that timer the its root. - * - * @param name a std::string const reference to the name of the new root - * timer. - * - * @param timer_set a TimerSet const reference of the timer set of the new root - * timer. - * - * @return a Timer value of the new root timer. - */ -Timer createRootTimer(const std::string &name, const TimerSet &timer_set); - -/** - * Function deleteRootTimer deletes a root timer and all of it's children timers. All - * children Timers are invalidated and can no longer be used. - * - * @param a Timer value of the root timer to delete. - */ -void deleteRootTimer(Timer timer); - -/** - * @brief Member function findTimer return a vector of timers whose tail of the dot - * separated name from root_time to leaf matches the specified path_tail. - * - * @param root_timer a Timer value of the root to begin search. - * - * @param path_tail a std::string const reference to the dot separated tail - * to match. - * - * @param found_timer a std::vector reference to the vector to store - * matching timers. - * - * @return a std::vector reference to found_timer. - */ -std::vector &findTimers(Timer root_timer, const std::string &path_tail, std::vector &found_timers); - -/** - * @brief Class TimerSet implements a set of timer classifications. A time classification - * consists of a bit mask set TimerMask - * - */ -class TimerSet -{ -public: - explicit TimerSet(TimerMask enabled_timer_mask) - : m_enabledTimerMask(enabled_timer_mask) - {} - -private: - TimerSet(const TimerSet &timer_set) - : m_enabledTimerMask(timer_set.m_enabledTimerMask) - {} - - TimerSet &operator=(TimerSet &timer_set) { - m_enabledTimerMask = timer_set.m_enabledTimerMask; - - return *this; - } - -public: - ~TimerSet() - {} - - /** - * Member function getEnabledTimerMask returns the timer enable bit mask. - * - * @return a TimerMask value of the timer enable bit - * mask. - */ - TimerMask getEnabledTimerMask() const { - return m_enabledTimerMask; - } - - /** - * Member function setEnabledTimerMask set the timer enable bit mask to - * timer_mask. - * - * @param timer_mask a TimerMask value to set the timer enable bit - * mask to. - * - */ - void setEnabledTimerMask(TimerMask timer_mask) { - m_enabledTimerMask = timer_mask; - } - - /** - * Member function shouldRecord returns true if any of the specified timer - * bit masks are set in the enable timer bit mask. - * - * @param timer_mask a TimerMask value to test the enable timer - * bit mask against. - * - */ - bool shouldRecord(TimerMask timer_mask) const { - return (timer_mask == 0 || (m_enabledTimerMask & timer_mask)); - } - -private: - TimerMask m_enabledTimerMask; ///< Bit mask of enabled timer -}; - - -typedef std::list TimerList; ///< A vector of subordinate timers. - -/** - * @brief Class Timer implements a diagnostic timer and timer container for the - * collection and display of execution times. - * - */ -class Timer -{ - friend class TimerImpl; - friend class TimeBlock; - friend class TimeBlockSynchronized; - friend void updateRootTimer(Timer); - friend Timer createRootTimer(const std::string &, const TimerSet &); - friend void deleteRootTimer(Timer); - friend std::vector &findTimers(Timer, const std::string &, std::vector &); - -public: - /** - * Class Metric maintains the metric data for the timer or counter. The - * start and stop times maintain the current lap time. When a lap completes, its - * time/count is accumlated to the total. The total time/count can be stored in the - * checkpoint member variable. The total can be retrieved as either absolute time/count - * the diffence from the checkpoint value. - * - */ - template - struct Metric - { - Metric() - : m_lapStart(0), - m_lapStop(0), - m_accumulatedLap(0), - m_checkpoint(0) - {} - - /** - * Member function reset resets the metric values to zero. - * - */ - void reset() { - m_lapStart = m_lapStop = m_accumulatedLap = m_checkpoint = 0; - } - - /** - * Member function addLap adds the most recently completed lap to the total. - * - * @return a T value of the total. - */ - typename MetricTraits::Type addLap() { - return m_accumulatedLap += m_lapStop - m_lapStart; - } - - /** - * Member function checkpoint checkpoints the metrics by storing the - * total time in the checkpoint value. - * - */ - void checkpoint() const { - m_checkpoint = m_accumulatedLap; - } - - /** - * Member function getLap returns the value of the most recently - * lap. - * - * @return a T value of the most recent lap. - */ - typename MetricTraits::Type getLap() const { - return m_lapStop - m_lapStart; - } - - /** - * Member function getStart returns the start value of the most recent lap. - * - * @return a T value of the start of the most recent lap. - */ - typename MetricTraits::Type getStart() const { - return m_lapStart; - } - - /** - * Member function getStop returns the stop value of the most recent lap. - * - * @return a T value of the stop of the most recent lap. - */ - typename MetricTraits::Type getStop() const { - return m_lapStop; - } - - /** - * Member function getAccumulatedLap returns the accumulated value of the metric. - * If the checkpoint parameter if true, the value returned is the - * difference between the accumulated value and the checkpointed value. - * - * @param checkpoint a bool value of true of the checkpointed - * value is to be returned. - * - * @return a T value of the accumulated or the - * checkpoint difference. - */ - typename MetricTraits::Type getAccumulatedLap(bool arg_checkpoint = false) const { - if (arg_checkpoint) - return m_accumulatedLap - m_checkpoint; - else - return m_accumulatedLap; - } - - /** - * Member function dump prints the value of the Metric to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic - * writer to write to. - * - * @return a Writer reference to the diagnostic - * writer. - */ - Writer &dump(Writer &dout) const; - - typename MetricTraits::Type m_lapStart; ///< Most recent start time/count - typename MetricTraits::Type m_lapStop; ///< Most recent stop or lap time/count - typename MetricTraits::Type m_accumulatedLap; ///< Accumulated time/count - mutable typename MetricTraits::Type m_checkpoint; ///< Checkpointed time/count - }; - - /** - * Creates a new Timer instance. - * - * @param name a std::string const reference to the name of - * the timer. - * - * @param parent a Timer value of the parent timer. - * - */ - Timer(const std::string &name, const Timer parent); - - /** - * Creates a new Timer instance. - * - * @param name a std::string const reference to the name of - * the timer. - * - * @param parent a Timer value of the parent timer. - * - * @param timer_set a TimerSet value of the timer set used to interpret the - * TimerMask's of this and children timers. - * - */ - Timer(const std::string &name, const Timer parent, const TimerSet &timer_set); - - /** - * Creates a new Timer instance. - * - * @param name a std::string const reference to the name of - * the timer. - * - * @param timer_mask a TimerMask value which enables this timer. - * - * @param parent a Timer value of the parent timer. - * - */ - Timer(const std::string &name, TimerMask timer_mask, const Timer parent); - - /** - * Creates a new Timer instance. - * - * @param name a std::string const reference to the name of - * the timer. - * - * @param timer_mask a TimerMask value which enables this timer. - * - * @param parent a Timer value of the parent timer. - * - * @param timer_set a TimerSet value of the timer set used to interpret the - * TimerMask's of this and children timers. - * - */ - Timer(const std::string &name, TimerMask timer_mask, const Timer parent, const TimerSet &timer_set); - - /** - * Creates the root Timer timer instance. - * - */ - explicit Timer(TimerImpl &timer_impl) - : m_timerImpl(&timer_impl) - {} - - explicit Timer(TimerImpl *timer_impl) - : m_timerImpl(timer_impl) - {} - - Timer(const Timer &timer) - : m_timerImpl(timer.m_timerImpl) - {} - - Timer &operator=(const Timer &timer) { - if (this != &timer) - m_timerImpl = timer.m_timerImpl; - - return *this; - } - - virtual ~Timer() - {} - - const TimerList &getTimerList() const; - - TimerList::iterator begin(); - TimerList::const_iterator begin() const; - TimerList::iterator end(); - TimerList::const_iterator end() const; - - /** - * Member function getName returns the name of the timer. - * - * @return a std::string const reference to the timer's - * name. - */ - const std::string &getName() const; - - - /** - * Member function getTimerMask returns the timer mask of the timer. - * - * @return a TimerMask value to the timer mask. - */ - const TimerSet &getTimerSet() const; - - /** - * Member function getTimerMask returns the timer mask of the timer. - * - * @return a TimerMask value to the timer mask. - */ - TimerMask getTimerMask() const; - - bool shouldRecord() const; - - /** - * Member function getSubtimerLapCount returns the subtimer lap counter. - * - * @return a Counter value of the subtimer lap - * counter. - */ - double getSubtimerLapCount() const; - - /** - * Member function getLapCount returns the lap counter metric. The lap - * count metric is the number of times the stop function has been executed. - * - * @return a CounterMetric const reference of the lap counter - * metric. - */ - template - const Metric &getMetric() const; - - /** - * Member function accumulateSubtimerLapCounts accumulates the subtimer la - * counts. - * - * @return an int value of the count. - */ - double accumulateSubtimerLapCounts() const; - - /** - * Member function start starts the lap timer. - * - * @return a Timer reference to this timer. - */ - Timer &start(); - - /** - * Member function lap sets the lap stop time. - * - * @return a Timer reference to the timer. - */ - Timer &lap(); - - /** - * Member function stop sets the lap stop time and sums the just completed - * lap time to the timer. - * - * @return a Timer reference to the timer. - */ - Timer &stop(); - - /** - * Member function checkpoint checkpoints the metrics by storing the - * total time in the checkpoint value. - * - */ - void checkpoint() const; - - /** - * Member function dump writes the timer to the specified - * diagnostic writer. - * - * @param dout a Writer variable reference to write the timer to. - * - * @return a Writer reference to dout. - */ - Writer &dump(Writer& dout) const; - -private: - TimerImpl * m_timerImpl; ///< Reference to the actual timer -}; - - - -/** - * Class TimeBlock is a time sentry for timing a statement block. The - * timer is generally started upon construction. But, the start is delayed if the second - * argument is false. In this case, manually start the timer by calling the start() - * function. This gives the safety of using a sentry, but does not force to awkwardness - * associated with local variables crossing the timed block. - * - */ -class TimeBlock -{ -public: - /** - * Creates a new TimeBlock instance. The newly created instance will - * start the timer if the start value is true, which is the default - * case. If the start value is false, the calling function is - * responsible for starting the timer at the appropriate time. - * - * @param timer a Timer reference to the timer accumulate - * block run times. - * - * @param start_timer a bool value to have the timer started on - * construction. - * - */ - explicit TimeBlock(Timer &timer, bool start_timer = true) - : m_timer(timer), - m_started(start_timer) - { - if (start_timer) - m_timer.start(); - } - -private: - TimeBlock(const TimeBlock &); - TimeBlock &operator=(const TimeBlock &); - -public: - /** - * Destroys a TimeBlock instance. Stops the timer if is has been started. - * - */ - ~TimeBlock() { - try { - if (m_started) - m_timer.stop(); - } - catch (...) { - } - } - - /** - * Member function start starts the timer associated with the time block. - * - */ - void start() { - m_started = true; - m_timer.start(); - } - - /** - * Member function lap sets the stop time of the timer associated with - * the time block. - * - */ - void lap() { - m_timer.lap(); - } - - /** - * Member function stop stops the timer associated with the time block. - * - */ - void stop() { - m_started = false; - m_timer.stop(); - } - -private: - Timer & m_timer; ///< Timer to accumulate block run times. - bool m_started; ///< Timer has been started -}; - -/** - * Class TimeBlockSynchronized is a time sentry for timing a statement - * block. The timer is generally started upon construction. But, the start is delayed - * if the second argument is false. In this case, manually start the timer by calling - * the start() function. This gives the safety of using a sentry, but does not force to - * awkwardness associated with local variables crossing the timed block. - * - * Prior to starting the timer, an MPI synchronization barrier is set so that the - * timing of routines which require MPI communication will all be at a known location - * prior to executing. - * - */ -class TimeBlockSynchronized -{ -public: - /** - * Creates a new TimeBlockSynchronized instance. If - * start_timer is true, then the timer is started using the - * start(). An MPI_Barrier is called to synchronize the - * start of the timer. The destructor will always stop a started timer. - * - * @param timer a Timer reference to the timer to start. - * - * @param mpi_comm a MPI_Comm value of the mpi communicator. - - * @param start_timer a bool value to start the timer on construction. - * - */ - TimeBlockSynchronized(Timer &timer, ParallelMachine mpi_comm, bool start_timer = true); - - /** - * Destroys a TimeBlockSynchronized instance. Stops the timer if it has - * been started. - * - */ - ~TimeBlockSynchronized(); - - /** - * Member function start starts the timer associated with the time block. - * An MPI_Barrier is executed prior to starting the timer. - * - */ - void start(); - - /** - * Member function stop stops the timer associated with the time block. - * - */ - void stop(); - -private: - Timer & m_timer; ////< Timer to accumulate block run times. - ParallelMachine m_mpiComm; ////< MPI comm to synchronize across - bool m_started; ////< Timer has been started -}; - - -/** - * @brief Function operator<< writes a timer to the diagnostic stream. - * - * @param dout a Writer reference to the diagnostic writer to print - * to. - * - * @param timer a Timer::Metric const reference to the timer - * to print. - * - * @return a Writer reference to dout. - */ -template -inline Writer &operator<<(Writer &dout, const Timer::Metric &timer) { - return timer.dump(dout); -} - -/** - * Function operator<< writes a timer metric to the diagnostic stream. - * - * @param dout a Writer reference to the diagnostic writer to print - * to. - * - * @param timer a Timer::Metric const reference to the timer - * to print. - * - * @return a Writer reference to dout. - */ -inline Writer &operator<<(Writer &dout, const Timer &timer) { - return timer.dump(dout); -} - -} // namespace diag -} // namespace stk_classic - - -namespace sierra { -namespace Diag { - -typedef stk_classic::diag::Timer Timer; -typedef stk_classic::diag::TimerSet TimerSet; -typedef stk_classic::TimeFormat TimeFormat; -typedef stk_classic::diag::TimeBlock TimeBlock; -typedef stk_classic::diag::TimeBlockSynchronized TimeBlockSynchronized; - -/** - * @brief Enumeration defines the bit mask values for the diagnostic - * timer's in the Diag namespace. - * - */ -enum TimerSetMask{ - TIMER_DOMAIN = 0x00000001, ///< Enable domain timers - TIMER_REGION = 0x00000002, ///< Enable region timers - TIMER_PROCEDURE = 0x00000004, ///< Enable procedure timers - TIMER_MECHANICS = 0x00000008, ///< Enable mechanics timers - TIMER_ALGORITHM = 0x00000010, ///< Enable algorithm timers - TIMER_SOLVER = 0x00000020, ///< Enable solver timers - TIMER_CONTACT = 0x00000040, ///< Enable contact timers - TIMER_MATERIAL = 0x00000080, ///< Enable material timers - TIMER_SEARCH = 0x00000100, ///< Enable search timers - TIMER_TRANSFER = 0x00000200, ///< Enable transfer timers - TIMER_ADAPTIVITY = 0x00000400, ///< Enable adaptivity - TIMER_RECOVERY = 0x00000800, ///< Enable recovery - TIMER_PROFILE_1 = 0x00001000, ///< Enable profile 1 timers - TIMER_PROFILE_2 = 0x00002000, ///< Enable profile 2 timers - TIMER_PROFILE_3 = 0x00004000, ///< Enable profile 3 timers - TIMER_PROFILE_4 = 0x00008000, ///< Enable profile 4 timers - TIMER_APP_1 = 0x00010000, ///< Enable application defined 1 - TIMER_APP_2 = 0x00020000, ///< Enable application defined 2 - TIMER_APP_3 = 0x00040000, ///< Enable application defined 3 - TIMER_APP_4 = 0x00080000, ///< Enable application defined 4 - TIMER_ALL = 0x000FFFFF, ///< Enable all timers - TIMER_NONE = 0x00000000, ///< Enable no timers - - TIMER_FORCE = 0x00000000 ///< Force timer to be active -}; - - -TimerSet &sierraTimerSet(); - -Timer &sierraTimer(); - -void sierraTimerDestroy(); - -class TimerParser; - -/** - * @brief Class Timer implements a diagnostic timer and timer container for the - * collection and display of execution times. - * - */ -typedef sierra::OptionMask TimerMask; ///< Bit mask for enabling timer - -/** - * @brief Enumeration defines some constants used for the - * indented display of the diagnostic timers. - * - */ -enum { - DEFAULT_TIMER_NAME_MAX_WIDTH = 40 ///< Width to truncate the name -}; - -/** - * @brief Member function theTimerParser returns a reference to the timer - * parser. - * - * @return a TimerParser reference to the timer parser. - */ -TimerParser &theTimerParser(); - -/** - * Function setEnabledTimerMask set the timer enable bit mask to - * timer_mask. - * - * @param timer_mask a TimerMask value to set the timer enable bit - * mask to. - * - */ -void setEnabledTimerMask(TimerMask timer_mask); - -/** - * Function getEnabledTimerMask retruns the timer enable bit mask. - * - * @return a TimerMask value of the timer enable bit - * mask. - */ -TimerMask getEnabledTimerMask(); - -void setTimeFormat(int time_format); - -void setTimeFormatMillis(); - -int getTimeFormat(); - -/** - * @brief Member function setTimerNameMaxWidth sets the maximum width for names - * displayed in the timer output table. - * - * @param width a size_t value to set for the maximum width for - * names displayed in the timer output table. - * - */ -void setTimerNameMaxWidth(size_t width); - -/** - * @brief Member function getTimeNameMaxWidth returns the width to use for the - * name cell of the table display. - * - * @return a size_t value of the width to use for the name - * cell of the table display. - */ -size_t getTimerNameMaxWidth(); - -stk_classic::diag::MetricTraits::Type getCPULapTime(Timer timer); - -stk_classic::diag::MetricTraits::Type getCPUAccumulatedLapTime(Timer timer); - -stk_classic::diag::MetricTraits::Type getSierraCPUTime(); -stk_classic::diag::MetricTraits::Type getSierraWallTime(); - - -/** - * @brief Class TimerParser implements the bit mask parser for the timer's bit masks. - * - */ -class TimerParser : public OptionMaskParser -{ -public: - /** - * Creates a new TimerParser instance. - * - */ - TimerParser(); - - /** - * @brief Member function parse parses the mask string and generates the - * corresponding bit mask. - * - * @param mask_string a std::string const reference to the mask string. - * - * @return a Mask value of the bitmask corresponding to the - * mask string. - */ - Mask parse(const char *mask_string) const; - - /** - * Member function parseArg parses the argument and its argument values. - * - * @param name a std::string const reference to the argument - * name. - * - * @param arg a std::string const reference to the argument - * values. - */ - virtual void parseArg(const std::string &name, const std::string &arg) const; - - mutable stk_classic::diag::MetricsMask m_metricsSetMask; - mutable stk_classic::diag::MetricsMask m_metricsMask; -}; - - -class SierraRootTimer -{ - public: - SierraRootTimer(); - virtual ~SierraRootTimer(); - stk_classic::diag::Timer & sierraTimer(); - - private: - stk_classic::diag::Timer m_sierraTimer; -}; - -} // namespace Diag -} // namespace sierra - -/// -/// @} -/// - -#endif // STK_UTIL_DIAG_Timer_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.cpp deleted file mode 100644 index 1609e9958604..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { -namespace diag { - -namespace { - -int s_timeFormat = TIMEFORMAT_HMS | TIMEFORMAT_MILLIS; - -} // namespace - - -int -getTimerTimeFormat() -{ - return s_timeFormat; -} - -void -setTimerTimeFormat( - int time_format) -{ - s_timeFormat = time_format; -} - - -MetricTraits::Type -MetricTraits::value_now() -{ - return 1; -} - -MetricTraits::Type -MetricTraits::value_now() -{ - return stk_classic::cpu_time(); -} - -MetricTraits::Type -MetricTraits::value_now() -{ - return stk_classic::wall_time(); -} - -MetricTraits::Type -MetricTraits::value_now() -{ - return 0; -} - -MetricTraits::Type -MetricTraits::value_now() -{ - return 0; -} - -MetricTraits::Type -MetricTraits::value_now() -{ - return ::malloc_used(); -} - -std::string -MetricTraits::table_header() { - return "Count"; -} - -std::string -MetricTraits::table_header() { - return "CPU Time"; -} - -std::string -MetricTraits::table_header() { - return "Wall Time"; -} - -std::string -MetricTraits::table_header() { - return "MPI Count"; -} - -std::string -MetricTraits::table_header() { - return "MPI Byte Count"; -} - -std::string -MetricTraits::table_header() { - return "Heap Allocated"; -} - - -std::string -MetricTraits::format( - MetricTraits::Type time) -{ - return formatTime(time, getTimerTimeFormat()); -} - - -std::string -MetricTraits::format( - MetricTraits::Type time) -{ - return formatTime(time, getTimerTimeFormat()); -} - - -std::string -MetricTraits::format( - MetricTraits::Type count) -{ - std::stringstream strout; - - strout << count; - - return strout.str(); -} - - -std::string -MetricTraits::format( - MetricTraits::Type count) -{ - std::stringstream strout; - - strout << count; - - return strout.str(); -} - -std::string -MetricTraits::format( - MetricTraits::Type count) -{ - return formatMemorySize(count); -} - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.hpp deleted file mode 100644 index f792f4478dd8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/TimerMetricTraits.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_diag_TimerMetricTraits_hpp -#define stk_util_diag_TimerMetricTraits_hpp - -#include - -namespace stk_classic { -namespace diag { - -typedef unsigned long MetricsMask; - -/** - * @brief Member function setTimerTimeFormat sets the display format of time in the - * output tables - * - * @param time_format a TimeFormat variable... - */ -void setTimerTimeFormat(int time_format); - -/** - * @brief Member function getTimerTimeFormat - * - */ -int getTimerTimeFormat(); - -/** - * @brief Enumeration Metrics assigns a unique but for each type of timer. The - * METRICS_FORCE type allows a timer to force itself to be active, even is not enabled. - * - */ -enum Metrics { - METRICS_LAP_COUNT = 0x0001, ///< Count of timer starts - METRICS_CPU_TIME = 0x0002, ///< CPU runtime - METRICS_WALL_TIME = 0x0004, ///< Wall clock time - METRICS_MPI_COUNT = 0x0008, ///< MPI class count - METRICS_MPI_BYTE_COUNT = 0x0010, ///< MPI byte count - METRICS_HEAP_ALLOC = 0x0020, ///< Heap allocation - METRICS_ALL = 0x7FFF, - - METRICS_FORCE = 0x8000 ///< Force metrics to be acquired -}; - - -struct LapCount {}; ///< Lap counter metric tag -struct CPUTime {}; ///< CPU runtime metric tag -struct WallTime {}; ///< Wall clock metric tag -struct MPICount {}; ///< MPI call count metric tag -struct MPIByteCount {}; ///< MPI byte count metric tag -struct HeapAlloc {}; ///< Heap allocation metric tag - -template -struct MetricTraits; - -template<> -struct MetricTraits -{ - typedef unsigned Type; - enum {METRIC = METRICS_LAP_COUNT}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type time); -}; - -template<> -struct MetricTraits -{ - typedef double Type; - enum {METRIC = METRICS_CPU_TIME}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type time); -}; - -template<> -struct MetricTraits -{ - typedef double Type; - enum {METRIC = METRICS_WALL_TIME}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type time); -}; - -template<> -struct MetricTraits -{ - typedef double Type; - enum {METRIC = METRICS_MPI_COUNT}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type count); -}; - -template<> -struct MetricTraits -{ - typedef double Type; - enum {METRIC = METRICS_MPI_BYTE_COUNT}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type count); -}; - - -template<> -struct MetricTraits -{ - typedef double Type; - enum {METRIC = METRICS_HEAP_ALLOC}; - static Type value_now(); - static std::string table_header(); - static std::string format(Type count); -}; - -template -typename MetricTraits::Type now() { - return MetricTraits::value_now(); -} - -} // namespace diag -} // namespace stk_classic - -#endif // stk_util_diag_TimerMetricTraits_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.cpp deleted file mode 100644 index fa163ecf34fb..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2003 - 2011 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace diag { - -Trace::ExtraFuncPtr -Trace::s_extra = 0; - -Trace::TraceList -Trace::s_traceList; - -bool -Trace::s_traceListExists = false; - -Traceback::stack_iterator -Traceback::s_top = s_stack; - -Traceback::stack_iterator -Traceback::s_storedTop = s_storedStack; - -Traceback::Stack -Traceback::s_stack; - -Traceback::Stack -Traceback::s_storedStack; - -Traceback::TracebackState -Traceback::s_tracebackState = Traceback::RUNNING; - -int -Traceback::s_tracebackPreserve = 0; - -int -Traceback::s_tracebackDisplay = 0; - -bool -Traceback::s_coverageEnabled = false; - -Traceback::Coverage -Traceback::s_coverage; - -namespace { - -bool -prefix_compare( - const char * prefix, - const char * name) -{ - for (; *prefix != 0 && *prefix == *name; ++prefix, ++name) - ; - return *prefix == 0; -} - - -bool -prefix_find( - const Trace::TraceList & trace_list, - const char * s) -{ - for (Trace::TraceList::const_iterator it = trace_list.begin(); it != trace_list.end(); ++it) - if (prefix_compare((*it), s)) - return true; - return false; -} - - -size_t -get_heap_used() -{ - return sierra::Env::get_heap_usage(); -} - -std::string::const_iterator -find_next_char( - std::string::const_iterator p, - std::string::const_iterator end, - char c) -{ - while (p != end && *p != c) - p++; - return p; -} - -std::string::const_iterator -find_prev_char( - std::string::const_iterator begin, - std::string::const_iterator p, - char c) -{ - while (p != begin && *p != c) - p--; - return p; -} - -std::string::const_iterator -find_prev_double_colon( - std::string::const_iterator begin, - std::string::const_iterator p) -{ - std::string::const_iterator it = p - 1; - - while ((it = find_prev_char(begin, it, ':')) != begin) { - if (*(it - 1) == ':') - return it + 1; - --it; - } - - return it; -} - - -inline std::string::const_iterator find_next_open_paren(std::string::const_iterator p, std::string::const_iterator end) { - return find_next_char(p, end, '('); -} - -/** - * Member function get_function_spec_parts parses spec into the - * components namespace, class, name and argument list. The name immediately proceeds the - * open parenthesis of the argument list; the class immediately proceeds the name - * separated by double colons; the namespace is everything which immediately proceeds the class. - * - * @param spec a std::string const reference to the function - * specification. - * - * @param namespace_name a std::string reference to receive the - * namespace part of the function specification. - * - * @param class_name a std::string reference to receive the - * class part of the function specification. - * - * @param name a std::string reference to receive the - * name part of the function specification. - * - * @param arglist a std::vector reference of strings to receive - * the function arguments. (not implemented) - */ -void -get_function_spec_parts( - const std::string & spec, - std::string & namespace_name, - std::string & class_name, - std::string & function_name, - std::vector & arglist) -{ - namespace_name.erase(namespace_name.begin(), namespace_name.end()); - class_name.erase(class_name.begin(), class_name.end()); - function_name.erase(function_name.begin(), function_name.end()); - arglist.erase(arglist.begin(), arglist.end()); - - std::string::const_iterator it_paren = find_next_open_paren(spec.begin(), spec.end()); - std::string::const_iterator it_func_name = find_prev_double_colon(spec.begin(), it_paren); - function_name = std::string(it_func_name, it_paren); - if (it_func_name != spec.begin()) { - it_func_name -= 2; - std::string::const_iterator it_class_name = find_prev_double_colon(spec.begin(), it_func_name); - class_name = std::string(it_class_name, it_func_name); - if (it_class_name != spec.begin()) { - it_class_name -= 2; - namespace_name = std::string(spec.begin(), it_class_name); - } - } -} - -std::string -format_memory( - int size) -{ - static const char *suffix[] = {" B", " KB", " MB", " GB"}; - - char sign = size < 0 ? '-' : '+'; - - size = size > 0 ? size : -size; - - int s = size/10240; - - unsigned int i; - for (i = 0; i < sizeof(suffix); i++) { - if (s == 0) - break; - size /= 1024; - s /= 1024; - } - - std::stringstream strout; - - strout << sign << size << suffix[i]; - - return strout.str(); -} - -} // namespace - - -std::string -Tracespec::getFunctionNamespace() const -{ - std::string namespace_name; - std::string class_name; - std::string function_name; - std::vector arglist; - - get_function_spec_parts(m_functionSpec, namespace_name, class_name, function_name, arglist); - - return namespace_name; -} - - -std::string -Tracespec::getFunctionClass() const -{ - std::string namespace_name; - std::string class_name; - std::string function_name; - std::vector arglist; - - get_function_spec_parts(m_functionSpec, namespace_name, class_name, function_name, arglist); - - return namespace_name + "::" + class_name; -} - - -std::string -Tracespec::getFunctionShortClass() const -{ - std::string namespace_name; - std::string class_name; - std::string function_name; - std::vector arglist; - - get_function_spec_parts(m_functionSpec, namespace_name, class_name, function_name, arglist); - - return class_name; -} - - -std::string -Tracespec::getFunctionName() const -{ - std::string namespace_name; - std::string class_name; - std::string function_name; - std::vector arglist; - - get_function_spec_parts(m_functionSpec, namespace_name, class_name, function_name, arglist); - - return namespace_name + "::" + class_name + "::" + function_name; -} - - -std::string -Tracespec::getFunctionShortName() const -{ - std::string namespace_name; - std::string class_name; - std::string function_name; - std::vector arglist; - - get_function_spec_parts(m_functionSpec, namespace_name, class_name, function_name, arglist); - - return function_name; -} - - -struct CoverageValueSort -{ - int operator()(const std::pair &s1, const std::pair &s2) { - return std::strcmp(s1.first, s2.first) < 0; - } -}; - -Trace::Trace( - Writer &dout, - const char *function_name, - int line_mask, - bool do_trace) - : Traceback(function_name), - m_diagWriter(dout), - m_startCpuTime(0.0), - m_startMemAlloc(0), - m_lineMask(line_mask), - m_do_trace(do_trace), - m_flags((dout.isTracing() - || (dout.shouldTrace(m_lineMask) - && (s_traceListExists && (s_traceList.empty() || prefix_find(s_traceList, m_functionSpec))))) ? IN_TRACE_LIST : 0) -{ - if (m_do_trace && (m_flags & IN_TRACE_LIST)) { - m_diagWriter.incTraceDepth(); - - m_diagWriter.m(m_lineMask) << m_functionSpec - << (std::uncaught_exception() ? " (throw unwinding) " : "") - << push << dendl; - - if (dout.shouldPrint(LOG_TRACE_STATS)) { - m_startCpuTime = sierra::Env::cpu_now(); - m_startMemAlloc = get_heap_used(); - } - } -} - - -Trace::~Trace() -{ - if (m_do_trace && (m_flags & IN_TRACE_LIST)) { - if (m_diagWriter.shouldPrint(LOG_TRACE_STATS)) { - m_startCpuTime = sierra::Env::cpu_now() - m_startCpuTime; - m_startMemAlloc = get_heap_used() - m_startMemAlloc; - } - - if (m_diagWriter.shouldPrint(LOG_TRACE_STATS)) { - m_diagWriter.m(m_lineMask) << "[" << stk_classic::formatTime(m_startCpuTime) - << "s, " << format_memory(m_startMemAlloc) << "]" << dendl; - } - - m_diagWriter.m(m_lineMask) << (std::uncaught_exception() ? " (throw unwinding) " : "") - << pop << dendl; - - m_diagWriter.decTraceDepth(); - } -} - - -Writer & -Trace::verbose_print( - Writer & dout) const -{ - dout << "Trace, " << m_functionSpec; - return dout; -} - - -TracebackStack -Traceback::snapshot() -{ - TracebackStack traceback_stack; - traceback_stack.reserve(s_top - s_stack); - - if (Traceback::getTracebackState() == Traceback::RUNNING) - for (const_stack_iterator it = s_top - 1; it >= s_stack; --it) - traceback_stack.push_back(*it); - else - for (const_stack_iterator it = s_storedTop - 1; it >= s_storedStack; --it) - traceback_stack.push_back(*it); - - return traceback_stack; -} - - -std::string -Traceback::printTraceback( - const TracebackStack & traceback_stack) -{ - std::ostringstream s; - if (traceback_stack.empty()) - s << " traceback not available" << std::endl; - else { - for (TracebackStack::const_iterator it = traceback_stack.begin(); it != traceback_stack.end(); ++it) - s << " from " << (*it) << std::endl; - } - - return s.str(); -} - -std::ostream & -Traceback::printCoverage( - std::ostream & os) -{ - std::vector > sorted_list; - sorted_list.reserve(s_coverage.size()); - - for (Coverage::const_iterator it = s_coverage.begin(); it != s_coverage.end(); ++it) - sorted_list.push_back(std::pair((*it).first, (*it).second)); - - std::sort(sorted_list.begin(), sorted_list.end(), CoverageValueSort()); - - for (std::vector >::const_iterator it = sorted_list.begin(); it != sorted_list.end(); ++it) - os << "" << std::endl; - - return os; -} - - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.hpp deleted file mode 100644 index 2409c6a560cb..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Trace.hpp +++ /dev/null @@ -1,526 +0,0 @@ -#ifndef STK_UTIL_SIERRA_TRACE_HPP -#define STK_UTIL_SIERRA_TRACE_HPP - -#include -#include -#include -#include -#include - -#include - -#include - -#define SLIB_TRACE_COVERAGE - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup DiagTraceDetail -/// @{ -/// - -/** - * @brief Class Tracespec dissects file specification strings. It - * contains a single char const pointer to a function specification string. - * Accessor functions can dissect the function specification string and return various - * components of it. - * - * @ref DiagTracingDetail - */ -class Tracespec -{ -public: - /** - * Creates a new Tracespec instance. - * - * @param function_spec a char const pointer to the function full - * specification. - */ - explicit Tracespec(const char *function_spec) - : m_functionSpec(function_spec) - {} - - /** - * @brief Member function getFunctionSpec returns the function's name. - * - * @return a char const pointer to the function's name. - */ - inline const char *getFunctionSpec() const { - return m_functionSpec; - } - - /** - * @brief Member function getFunctionName returns the function's name. - * - * @return a char const pointer to the function's name. - */ - std::string getFunctionName() const; - - /** - * @brief Member function getFunctionName returns the function's name. - * - * @return a char const pointer to the function's name. - */ - std::string getFunctionShortName() const; - - /** - * @brief Member function getFunctionName returns the function's name. - * - * @return a char const pointer to the function's name. - */ - std::string getFunctionClass() const; - - /** - * @brief Member function getFunctionName returns the function's name. - * - * @return a char const pointer to the function's name. - */ - std::string getFunctionNamespace() const; - - /** - * @brief Member function getFunctionName returns the function's name. - * - * @return a char const pointer to the function's name. - */ - std::string getFunctionShortClass() const; - -protected: - const char * m_functionSpec; ///< The member function specification -}; - -typedef std::vector TracebackStack; - -/** - * @brief Class Traceback is a stack of char constant - * pointers to function specifications which have been encounter by Traceback during - * exception stack unwind. - * - * @ref DiagTracingDetail - */ -class Traceback : public Tracespec -{ -public: - /** - * @brief Enumeration TracebackState lists the traceback execution states. - * - *
    - *
  • RUNNING - No throws are in progress. - *
  • THROWING - A throw is in progress. - *
- * - */ - enum TracebackState{RUNNING, THROWING}; - - enum {STACK_SIZE = 2048}; ///< Running function spec stack size - typedef const char *Stack[STACK_SIZE] ; ///< Stack type - typedef const char * const * const_stack_iterator; ///< const iterator thru stack - typedef const char ** stack_iterator; ///< iterator thru stack - - /** - * @brief Typedef Coverage declares the function usage coverage data type. - * - * NOTE: This does really want to use const char * as the key. I know, things could - * move, but the definition of a function spec is that it is a string literal only. So, - * let it go. - * - */ - typedef std::map Coverage; - - /** - * @brief Class Traceback::Preserve serves as a sentry for traceback - * stack preservation during additional extension and unwinding. - * - */ - class Preserve - { - public: - /** - * @brief Creates a new Traceback::Preserve sentry. When the sentry - * is in place, the traceback stack is preserved from extension and clearing. - * - */ - Preserve() { - Traceback::preserveStack(); - } - - /** - * @brief Destroys a Preserve sentry which allows traceback stack - * - */ - ~Preserve() { - Traceback::releaseStack(); - } - }; - - /** - * @brief Creates a new Trace instance, resulting in the printing of - * the member function name and pushing the depth. - * - * @param function_spec a char variable ... - */ - explicit Traceback(const char *function_spec) - : Tracespec(function_spec) - { - if (s_top >= &s_stack[STACK_SIZE - 1] || s_top == 0) - s_top = s_stack; - *s_top++ = function_spec; - - if (s_tracebackState == THROWING && !s_tracebackPreserve && !std::uncaught_exception()) - s_tracebackState = RUNNING; - -#ifdef SLIB_TRACE_COVERAGE - if (s_coverageEnabled) - ++s_coverage[function_spec]; -#endif - } - - - /** - * @brief Destroys a Traceback instance, resulting in the pushing of - * the function specification if unwinding the stack. - * - */ - ~Traceback() { - if (!s_tracebackPreserve && std::uncaught_exception() && s_tracebackState == RUNNING) { - s_tracebackState = THROWING; - s_storedTop = s_storedStack + (s_top - s_stack); - std::copy(s_stack, s_top, s_storedStack); - } - if (s_top > &s_stack[0]) - --s_top; - } - - static TracebackStack snapshot(); - - /** - * @brief Member function enableTracebackDisplay enables the display of the - * traceback. - * - */ - inline static void enableTracebackDisplay() { - --s_tracebackDisplay; - } - - /** - * @brief Member function disableTracebackDisplay disables the display of the - * traceback. - * - */ - inline static void disableTracebackDisplay() { - ++s_tracebackDisplay; - } - - /** - * @brief Member function displayEnabled returns true if display of the - * tracback stack has been enabled. - * - * @return a bool value of true if trackback display has - * been enabled. - */ - inline static bool displayTraceback() { - return s_tracebackDisplay == 0; - } - - /** - * @brief Member function preserveStack increments the traceback stack - * preservation counter. - * - */ - inline static void preserveStack() { - ++s_tracebackPreserve; - } - - /** - * @brief Member function releaseStack decrements the traceback stack - * preservation counter. - * - */ - inline static void releaseStack() { - --s_tracebackPreserve; - } - - /** - * @brief Member function enableCoverage enables the collection of function - * call coverage data. This is a very expensive operation, but allows function - * execution coverage data to be collected for testing. - * - * @param coverage_enabled a bool value to set the coverage enabled - * flag. - * - */ - inline static void enableCoverage(bool coverage_enabled = true) { - s_coverageEnabled = coverage_enabled; - } - - /** - * @brief Member function coverageEnabled returns true if coverage has been - * enabled. - * - * @return a bool value of true if coverage has been - * enabled. - */ - inline static bool coverageEnabled() { - return s_coverageEnabled; - } - - /** - * @brief Member function getTracebackState returns the value of the - * traceback state. - * - * @return an int ... - */ - inline static TracebackState getTracebackState() { - return s_tracebackState; - } - - /** - * @brief Class PrintCoverage is a type holder class for printing the stack. - * - */ - struct PrintCoverage - {}; - - /** - * @brief Member function printCoverage creates a - * PrintCoverage type holder class which enables - * operator<< to put an coverage to an ostream. - * - * @return a PrintCoverage object. - */ - static PrintCoverage printCoverage() { - return PrintCoverage(); - } - - /** - * @brief Member function printCoverage ... - * - * @param os a std::ostream variable ... - * @return a std::ostream ... - */ - static std::ostream &printCoverage(std::ostream &os); - - /** - * @brief Member function printTraceback writes the traceback stack - * function specifications to the output stream os. - * - * @param os a std::ostream reference to the output stream - * to write to. - * - * @return a std::ostream reference to the output stream. - */ - static std::string printTraceback(const TracebackStack &traceback_stack); - - /** - * @brief Member function verbose_print dumps the function specification - * stack to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic - * writer to write to. - * - * @return a Writer reference to the diagnostic - * writer. - */ - Writer &verbose_print(Writer &dout) const; - -private: - static TracebackState s_tracebackState; ///< State of the traceback system - static int s_tracebackPreserve; ///< Preserve traceback stack - static int s_tracebackDisplay; ///< Display traceback stack - static const char ** s_top; ///< Pointer to the top + 1 of the stack - static Stack s_stack; ///< Running functionspec stack - static const char ** s_storedTop; ///< Pointer to the top + 1 of the stored stack - static Stack s_storedStack; ///< Stored functionspec stored stack - static bool s_coverageEnabled; ///< Coverage is enabled - static Coverage s_coverage; ///< Function usage coverage -}; - - -/** - * @brief Class Trace serves as a sentry for entering routines. Creating a - * trace object prints the specified member function name to the specfied diag_writer and - * pushes the diag_writer depth. On destruction, it prints the member function name again - * and pops the depth. - * - * A tracing depth feature has been incorporated into the Writer which enables - * diagnostic output only when tracing is activated using a specific - * - * @ref DiagTracingDetail - */ -class Trace : public Traceback -{ -public: - /** - * @brief Typedef ExtraFuncPtr declares the extra function pointer - * signature. - * - */ - typedef Writer & (*ExtraFuncPtr)(Writer &); - - /** - * @brief Typedef TraceList declares the trace list data type. - * - */ - struct TraceList : public std::vector { - public: - TraceList() { - s_traceListExists = true; - } - - ~TraceList() { - s_traceListExists = false; - } - }; - - /** - * @brief Enumeration to describe the trace back flags. - * - */ - enum { - IN_TRACE_LIST = 0x01 ///< Tracing enabled by this function - }; - - /** - * @brief Creates a new Trace instance, resulting in the printing of - * the member function name and pushing the depth. - * - * @param dout a Writer reference to the diagnostic - * writer to send trace messages to. - * - * @param function_name a char const pointer to the function - * specification. THIS POINTER MUST CONTINUE TO EXIST. - * - * @param print_mask an int value of the diagnostic writer print - * mask to enable tracing. - * - * @param do_trace a bool that provide an extra dynamic means of - * turning off tracing. - * - */ - Trace(Writer &dout, const char *function_name, int print_mask = LOG_TRACE, bool do_trace = true); - - /** - * @brief Destroys a Trace instance, resulting in the printing of the - * member function name and popping the diag_writer depth. - * - */ - ~Trace(); - - /** - * @brief Member function setExtra sets the extra function which is called - * during each trace construction and destrution. (Not implemented) - * - * @param extra an ExtraFuncPtr to the new extra function. - * - * @return an ExtraFuncPtr to the previous extra - * function. - */ - inline static ExtraFuncPtr setExtra(ExtraFuncPtr extra) { - ExtraFuncPtr x = s_extra; - s_extra = extra; - return x; - } - - /** - * @brief Member function addTraceFunction adds a function prefix to the - * list of function prefixes search to enable tracing. - * - * @param function_prefix a std::string const reference to the function - * signature prefix. - */ - inline static void addTraceFunction(const std::string &function_prefix) { - char *s = std::strcpy(new char[function_prefix.length() + 1], function_prefix.c_str()); - - s_traceList.push_back(s); - } - - /** - * @brief Member function clearTraceFunctions removes all function prefixes - * from the function signature prefix list. - * - */ - inline static void clearTraceFunctions() { - for (std::vector::iterator it = s_traceList.begin(); it != s_traceList.end(); ++it) - delete[] (*it); - - s_traceList.clear(); - } - - /** - * @brief Member function dump writes the trace to the specified - * Writer. - * - * @param dout a Writer variable reference to write the trace to. - * - * @return a Writer reference to Writer. - */ - Writer &verbose_print(Writer &dout) const; - -private: - Writer & m_diagWriter; ///< The diagnostic writer to write to. - double m_startCpuTime; ///< Cpu time at trace start - size_t m_startMemAlloc; ///< Memory allocated at trace start - PrintMask m_lineMask; ///< Line mask of trace - bool m_do_trace; ///< Force trace off - int m_flags; ///< flags if trace enabled - - static ExtraFuncPtr s_extra; ///< Extra output on trace - static TraceList s_traceList; ///< List of functions to trace - static bool s_traceListExists; ///< Flag indicating that the tracelist has been constructed and not destructed -}; - -/** - * @brief Member function operator<< writes the trace data to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic - * writer to write to. - * - * @param diag_trace a Trace const reference to the trace - * object to write. - * - * @return a Writer reference to the diagnostic - * writer. - */ -inline Writer &operator<<(Writer &dout, const Trace &diag_trace) { - return diag_trace.verbose_print(dout); -} - -/** - * @brief Member function operator<< writes the coverage to the output - * stream. - * - * @param os a std::ostream reference to the output stream - * to write to. - * - * @param print_coverage a Coverage const reference to the coverage - * to write. - * - * @return a std::ostream reference to the output - * stream. - */ -inline std::ostream &operator<<(std::ostream &os, const Traceback::PrintCoverage &) { - return Traceback::printCoverage(os); -} - - -} // namespace diag -} // namespace stk_classic - -namespace sierra { -namespace Diag { - -typedef stk_classic::diag::Tracespec Tracespec; -typedef stk_classic::diag::Traceback Traceback; -typedef stk_classic::diag::Trace Trace; - -} // namespace sierra -} // namespace Diag - - -/// -/// @} -/// - -#endif // STK_UTIL_SIERRA_TRACE_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.cpp deleted file mode 100644 index 9fa85470dab9..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2004-2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include - -#include -#include - -#ifdef SIERRA_DLOPEN_ENABLED -#include -#endif - -namespace sierra { -namespace Plugin { - -std::string -derived_id_name( - int derived_id) -{ - std::ostringstream derived_name; - derived_name << "enum id " << derived_id; - return derived_name.str(); -} - - -Registry::RegistryMap & -Registry::getRegistryMap() -{ - static RegistryMap s_registryMap; - - return s_registryMap; -} - - -Registry & -Registry::rootInstance() -{ - static Registry registry; - - return registry; -} - - - -void -Registry::registerIt( - const NamePair & name_pair, - void * func_ptr) -{ - slibout.m(Slib::LOG_PLUGIN) << "Registering " << name_pair.second - << " of type " << demangle(name_pair.first->name()) - << " at " << func_ptr << stk_classic::diag::dendl; - - RegistryMap::const_iterator registry_entry = getRegistryMap().find(name_pair); - if (registry_entry != getRegistryMap().end() && (*registry_entry).second != func_ptr) { - std::ostringstream strout; - strout << "Function with signature " << demangle((*registry_entry).first.first->name()) - << " and derived name '" << (*registry_entry).first.second - << "' already registered to create function at address " << (*registry_entry).second; - throw std::invalid_argument(strout.str()); - } - getRegistryMap()[name_pair] = func_ptr; -} - - -void * -Registry::getPluginPtr( - const NamePair & name_pair) const -{ - void *creator_function = getFuncPtr(name_pair); - if (creator_function) - return creator_function; - else { - std::ostringstream strout; - - strout << "User plugin creator function with base class '" << demangle(name_pair.first->name()) - << "' and derived class name '" << name_pair.second - << "' not found in registry"; - throw std::invalid_argument(strout.str()); - } -} - - -void * -Registry::getFunctionPtr( - const NamePair & name_pair) const -{ - void *creator_function = getFuncPtr(name_pair); - if (creator_function) - return creator_function; - else { - std::ostringstream strout; - strout << "User subroutine " << name_pair.second << "\n" - << " with signature " << demangle(name_pair.first->name()) << "\n" - << " not found in registry"; - throw std::invalid_argument(strout.str()); - } -} - - -Registry * -Registry::getFactoryPtr( - const NamePair & name_pair) const -{ - Registry *creator_function = (Registry *) getFuncPtr(name_pair); - if (creator_function) - return creator_function; - else { - std::ostringstream strout; - strout << "Registry does not contain function with signature " << demangle(name_pair.first->name()) - << " and derived name '" << name_pair.second << "'"; - throw std::invalid_argument(strout.str()); - } -} - - -void * -Registry::getFuncPtr( - const NamePair & name_pair) const -{ - RegistryMap::const_iterator registry_entry = getRegistryMap().find(name_pair); - return registry_entry == getRegistryMap().end() ? NULL : (*registry_entry).second; -} - - -std::vector -Registry::getDerivedNames( - const std::type_info & type) const -{ - std::vector derived_names; - - for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it) - if (*(*it).first.first == type) - derived_names.push_back((*it).first.second); - - return derived_names; -} - - -typedef void (*dl_register_t)(); - -void -Registry::registerDL( - const char * so_path, - const char * function_name) -{ -#ifdef SIERRA_DLOPEN_ENABLED - slibout.m(Slib::LOG_PLUGIN) << "Loading dynamic library " << so_path << stk_classic::diag::dendl; - void *dl = dlopen(so_path, RTLD_NOW); - if (!dl){ - throw std::runtime_error(dlerror()); - } - - if (function_name) { - std::string s = std::strlen(function_name) ? function_name : "dl_register"; - - dl_register_t f = (dl_register_t) dlsym(dl, s.c_str()); - if (!f) { - s = s + SIERRA_FORTRAN_SUFFIX; - - f = (dl_register_t) dlsym(dl, s.c_str()); - } - - if (f) { - slibout.m(Slib::LOG_PLUGIN) << "Executing dynamic library " << so_path << " function " << s << "()" << stk_classic::diag::dendl; - (*f)(); - } - else { - if (std::strlen(function_name)) { - std::ostringstream str; - str << "Registration function " << function_name << " not found in " << so_path; - throw std::runtime_error(str.str().c_str()); - } - } - } - -#else - throw std::runtime_error("Dynamic linkage is not supported on this platform"); -#endif -} - - -template <> -void * -Registry::getsym( - const char * sym) -{ -#ifdef SIERRA_DLOPEN_ENABLED - void *s = NULL; - void *dl = dlopen(NULL, RTLD_LAZY); - if (dl) { - s = dlsym(dl, sym); - dlclose(dl); - } - - return s; -#else - return NULL; -#endif -} - - -std::ostream & -Registry::verbose_print( - std::ostream & os) const -{ - for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it) - os << (*it).first.second << " of type " << demangle((*it).first.first->name()) << " at " << (*it).second << std::endl; - return os; -} - - -stk_classic::diag::Writer & -Registry::verbose_print( - stk_classic::diag::Writer & dout) const -{ - if (dout.shouldPrint()) { - dout << "Registry, size " << getRegistryMap().size() << stk_classic::diag::push << stk_classic::diag::dendl; - - for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it) - dout << (*it).first.second << " of type " << demangle((*it).first.first->name()) << " at " << (*it).second << stk_classic::diag::dendl; - dout << stk_classic::diag::pop; - } - return dout; -} - - -extern "C" { - -void SIERRA_FORTRAN(register_user_subroutine)( - type_info_func * type_id, - void * user_subroutine, - const char * name, - int name_len) -{ - sierra::Plugin::Registry::rootInstance().registerIt(std::make_pair(type_id(), std::string(name, name_len)), user_subroutine); -} - -} // extern "C" - -} // namespace Plugin -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.hpp deleted file mode 100644 index 1ed968ee5a6b..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/UserPlugin.hpp +++ /dev/null @@ -1,685 +0,0 @@ -#ifndef STK_UTIL_DIAG_UserPlugin_h -#define STK_UTIL_DIAG_UserPlugin_h - -#include -#include -#include -#include -#include - -#include -#include -#include - -/** - * @file - * - * Historically, the term User Subroutine has referred to Fortran subroutines which are - * generally called from within a procedure, allowing the user to create or select a - * mathematical calculation to be applied to set of arguments. - * - * The purpose of this package is add User Plugins and User Functions as well as provide an - * analogous implementation of the traditional User Subroutine. - * - * A User Plugin is a C++ class in which the application developer designs and implements - * a base class that end users can create or select derivative classes to before the - * desired operations. - * - * A User Subroutine is a function with a specific calling signature allowing any - * registered subroutine with that signature to be called by its registered name. - * - * A User Function is a functional calculation which accepts one or more independent const - * variables and returns a single dependent variable. These variables may be of scalar, - * vector or object quantities. These functions can be created or selected by the end - * user. - * - */ - -namespace sierra { -namespace Plugin { - -std::string derived_id_name(int derived_id); - -/** - * Class Registry serves as a singleton for holding templatized - * createInstance and UserSubroutine function pointers and pointer to class factory objects. - * The registry is simply a mapping of name pairs to a void pointer. The name pair - * consists of the base class name and the derived class names. And, since the only legal - * way to get things into the registry is via the and UserSubroutine classes, there is no - * signature checking performed at this level - * - * There should never be a need to instantiate this singleton as the UserSubroutine - * registration process should perform that function when necessary. - */ - -class Registry -{ -public: - - /** - * @brief Typedef NamePair is the derived class key. - * - */ - typedef std::pair NamePair; - -// /** -// * @brief Class hash_nocase implements a hash, case insensitive NamePair -// * hash functor. -// * -// */ -// struct hash_nocase -// { -// size_t operator()(const NamePair &n) const { -// return sierra::hash_string_nocase(n.second.c_str()); -// } -// }; - -// /** -// * @brief Class hash_nocase implements a hash, case insensitive compare -// * equal NamePair functor. -// * -// */ -// struct equal_nocase : public std::binary_function -// { -// bool operator()(const NamePair &lhs, const NamePair &rhs) const { -// sierra::equal_nocase second_equal_nocase; - -// return *lhs.first == *rhs.first && second_equal_nocase(lhs.second, rhs.second); -// } -// }; - - /** - * @brief Class less_nocase implements a case insensitive NamePair compare - * less functor. - * - */ - struct less_nocase : public std::binary_function - { - bool operator()(const NamePair &lhs, const NamePair &rhs) const { - sierra::less_nocase second_less_nocase; - -#ifdef SIERRA_TYPE_INFO_BEFORE_EQUALITY_BUG - return (lhs.first->before(*rhs.first) && *lhs.first != *rhs.first) - || (*lhs.first == *rhs.first && second_less_nocase(lhs.second, rhs.second)); -#else - return lhs.first->before(*rhs.first) - || (*lhs.first == *rhs.first && second_less_nocase(lhs.second, rhs.second)); -#endif - } - }; - - /** - * @brief Typedef RegistryMap is the registration map. - * - */ - typedef std::map RegistryMap; - - static RegistryMap &getRegistryMap(); - - /** - * Creates a new Registry instance. - * - */ - Registry() - {} - - /** - * @brief Creates a new Registry instance and registers it, and more - * importantly the derived class factory with the specified name pair. - * - * @param name_pair a NamePair gives the name to the registry - * entry. - */ - explicit Registry(const NamePair &name_pair) { - registerIt(name_pair, this); - } - - /** - * Destructor ~Registry is virtual to fake polymorphism so that the registry class can - * utilize additional compiler/runtime checks that the registered class is indeed a class factory. - * - */ - virtual ~Registry() - {} - - /** - * @brief Member function rootInstance creates the singleton. - * - * @return a Registry reference to the - * Registry singleton. - */ - static Registry &rootInstance(); - - /** - * @brief Member function registerDL opens a dynamic library and optionally executes a "C" - * registration function. - * - * If function is specified, and not zero length, the function must exist. If the function name - * specified with zero length, the function "dl_register" is executed if it exists. If the - * function name is not found, if platform specific fortran suffix is appended and the function is - * searched again. - * - * If no function name is specified, no registration function is executed. - * - * NOTE: Loading C++ sharable objects results in static object construction upon load. - * - * @param so_path a char const pointer to the path of the - * shareable object file. If the path does not contains a - * '/' character, the file is searched for through the - * LD_LIBRARY_PATH envirnment variable. - * - * @param function_name a char const pointer to the name of a registration function - * which will be called immediately after loading the sharable object. - * - */ - static void registerDL(const char *so_path, const char *function_name = 0); - - template - static T getsym(const char *sym); - - /** - * @brief Member function registerIt registers a name pair with a void - * pointer. - * - * If the name pair already exists within the registry, a std::invalid_argument exception - * is thrown with the offending name pair called out. - * - * @param name_pair a NamePair const reference to the name pair - * to be registered. - * - * @param func_ptr a void pointer to the function to be - * registered. - * - * @throws a std::invalid_argument exception is thrown - * if there is an instance creation function already - * registered for the derived class. - * - */ - void registerIt(const NamePair &name_pair, void *func_ptr); - - /** - * @brief Member function getPluginPtr find the function with the name pair - * specified. - * - * If the name pair does not exist within the registry, a std::invalid_argument - * exception is thrown with the offending name pair called out. - * - * @param name_pair a NamePair const reference to the name pair - * to be retrieved. - * - * @throws a std::invalid_argument exception is thrown - * if the function is not found. - * - */ - void *getPluginPtr(const NamePair &name_pair) const; - - /** - * @brief Member function getFunctionPtr find the function with the name pair - * specified. - * - * If the name pair does not exist within the registry, a std::invalid_argument - * exception is thrown with the offending name pair called out. - * - * @param name_pair a NamePair const reference to the name pair - * to be retrieved. - * - * @throws a std::invalid_argument exception is thrown - * if the function is not found. - * - */ - void *getFunctionPtr(const NamePair &name_pair) const; - - /** - * @brief Member function getFuncPtr returns the function pointer with the - * specfied name_pair
. - * - * @param name_pair a NamePair const reference to the registered - * name pair. - * - * @returns a void function pointer with the specfied - * name_pair
. - */ - Registry *getFactoryPtr(const NamePair &name) const; - - /** - * @brief Member function getFuncPtr returns the function pointer with the - * specfied name_pair
. - * - * @param name_pair a NamePair const reference to the registered - * name pair. - * - * @returns a void function pointer with the specfied - * name_pair
. - */ - void *getFuncPtr(const NamePair &name_pair) const; - - /** - * @brief Member function getDerivedNames returns names assocaited with the - * function pointers of the specified type. - * - * @param type a std::type_info const reference to typeid to - * retrieve the derived names. - * - * @returns a std::vector value of the derived - * names. - */ - std::vector getDerivedNames(const std::type_info &type) const; - - /** - * Member template function create creates an instance of the desired - * object by providing the factory responsible for generating that object type. The - * create factory is retrieved using the base class name specified by the factory base - * class and the specified derived name. - * - * The derived factory is responsible for implementing the appropriate operator() - * functions to constuct the derived object. - * - * @param derived_name a std::string const reference to the derived - * object's name/ - * - * @return a T reference to the creation factory object. - */ - template - static T &create(const std::string &derived_name) { - return static_cast(*Registry::rootInstance().getFactoryPtr(std::make_pair(&typeid(T), derived_name))); - } - - /** - * @brief Member function dump dumps the registry. - * - * @param os a std::ostream reference to dump the registry - * to. - * - * @return a std::ostream reference to os
. - */ - std::ostream &verbose_print(std::ostream &os) const; - - /** - * @brief Member function verbose_print dumps the registry. - * - * @param os a std::ostream reference to dump the registry - * to. - * - * @return a std::ostream reference to os
. - */ - stk_classic::diag::Writer &verbose_print(stk_classic::diag::Writer &dout) const; -}; - -inline stk_classic::diag::Writer &operator<<(stk_classic::diag::Writer &dout, const Registry ®istry) { - return registry.verbose_print(dout); -} - - -/** - * Template class UserPlugin is a template used for the association of base - * and derived classed to be registered and created via the UserPlugin mechanism. The - * template traits enforces the signature matching of the base class constructor, derived class - * constructor, derived class creator static function and the usage of the creator static - * function. - * - * The registration requires a unique base class name for each base class type. And, - * since typeid is not reliable for that implementation, each base class is required to - * implement a traits class with a Base typedef which specifies the base class, a - * Signature typedef which specifies the signature of the create function and a static - * function named getUserPluginCreatorName() which returns a const std::string reference to - * the base classes name. This name must be unique across users of the registry. There - * is no way to enforce this programatically, so it is recommended that a application - * prefix be attached to the base class name. - * - */ -template -class UserPlugin -{ -public: - typedef S Signature; ///< Creator signature - -private: - UserPlugin(); ///< Not implemented - UserPlugin(const UserPlugin&); ///< Not implemented - UserPlugin &operator=(const UserPlugin&); ///< Not implemented - -public: - /** - * @brief Member function instance returns the instance of the registry, - * cast as a UserPlugin registry.. - * - * @return a UserPlugin reference to the registry - * singleton. - */ - static UserPlugin &instance() { - return (UserPlugin &) (Registry::rootInstance()); - } - - /** - * @brief Member function registerCreator registers the base class name and - * specified derived class name with the specified creator function. - * - * The base class name is determined by the BaseTraits template argument's - * getUserPluginCreatorName() static member function. The signature is defined by the - * BaseTraits template argument's Signature typedef. - * - * @param derived_name a std::string const reference to the derived - * class name. - * - * @param function a signature function pointer to the creator - * function. - * - */ - static void registerCreator(const std::string &derived_name, Signature function) { - Registry::rootInstance().registerIt(std::make_pair(&typeid(Signature), derived_name), (void *) function); - } - - /** - * @brief Member function create returns the createInstance() function - * associated with the specified base class and derived_name. - * - * @param derived_name a std::string const reference to the derived - * classes name. - * - * @throws a std::invalid_argument exception is thrown - * if there is no instance creation function registered for - * the specified name of the base class. - * - * @return a Signature function pointer to the instance - * create function. - */ - static Signature create(const std::string &derived_name) { - Signature creator_function = (Signature) Registry::rootInstance().getPluginPtr(std::make_pair(&typeid(Signature), derived_name)); - - return (*creator_function); - } - - /** - * @brief Member function create returns the createInstance() function - * associated with the specified base class and derived_name. - * - * @param derived_name a std::string const reference to the derived - * classes name. - * - * @throws a std::invalid_argument exception is thrown - * if there is no instance creation function registered for - * the specified name of the base class. - * - * @return a Signature function pointer to the instance - * create function. - */ - static Signature create(int derived_id) { - return create(derived_id_name(derived_id)); - } - - /** - * @brief Member function exists returns true if class of the type - * specified by derived_name exists in BaseClass. - * - * @param derived_name a std::string const reference to the derived - * classes name. - * - * @return a bool of true if class of the type specified by derived_name exists in BaseClass. - */ - static bool exists(const std::string &derived_name) { - return Registry::rootInstance().getFuncPtr(std::make_pair(&typeid(Signature), derived_name)) != NULL; - } - - static std::vector getDerivedNames() { - return Registry::rootInstance().getDerivedNames(typeid(Signature)); - } - - /** - * @brief Class template Register registers the createInstance() - * function with the derived_name on object creation. - * - * @param DerivedClass a class which specifies the derived class - * which holds the createInstance() function. - * - */ - template - class Register - { - public: - typedef DerivedClass XDerivedClass; - - /** - * @brief Creates a new Register instance. Upon creation, the - * DerivedClass::createInstance() instance creation function is registered - * with the derived_name. - * - * @param derived_name a std::string const reference to the derived - * class' name. - * - */ - explicit Register(const std::string &derived_name) - : m_function(DerivedClass::createInstance) - { - UserPlugin::instance().registerCreator(derived_name, m_function); - } - - /** - * @brief Creates a new Register instance. Upon creation, the - * DerivedClass::createInstance() instance creation function is registered - * with the derived_name. - * - * @param derived_name a std::string const reference to the derived - * class' name. - * - */ - Register(const std::string &derived_name, Signature create_instance) - : m_function(create_instance) - { - UserPlugin::instance().registerCreator(derived_name, m_function); - } - - /** - * @brief Creates a new Register instance. Upon creation, the - * DerivedClass::createInstance() instance creation function is registered - * with the derived_id and "enum id " derived_id. - * - * @param derived_id a int to the derived class' id. - * - */ - explicit Register(int derived_id) - : m_function(XDerivedClass::createInstance) - { - UserPlugin::instance().registerCreator(derived_id_name(derived_id), m_function); - } - - /** - * @brief Creates a new Register instance. Upon creation, the - * DerivedClass::createInstance() instance creation function is registered - * with the derived_id and "enum id " derived_id. - * - * @param derived_id a int to the derived class' id. - * - */ - Register(int derived_id, Signature create_instance) - : m_function(create_instance) - { - UserPlugin::instance().registerCreator(derived_id_name(derived_id), m_function); - } - - private: - Signature m_function; ///< Place to hold function pointer - }; -}; - - -/** - * Class template UserSubroutine is a template used for the association of - * user function to be registered and acquired via the UserSubroutine mechanism. The - * template traits enforces the signature matching of the user function and the its - * usage. - * - * The registration requires a unique function name and is required to implement a - * traits class with a Signature typedef which specifies the signature of the user - * function and a static function named getUserSubroutineName() which returns a const - * std::string reference to the user function's name. This name must be unique across users - * of the registry. There is no way to enforce this programatically, so it is recommended - * that a application prefix be attached to the function name. - * - */ -template -class UserSubroutine -{ -private: - UserSubroutine(); ///< Not implemented - UserSubroutine(const UserSubroutine&); ///< Not implemented - UserSubroutine &operator=(const UserSubroutine&); ///< Not implemented - -public: - typedef S Signature; ///< Subroutine call signature - - /** - * @brief Member function instance returns the instance of the registry, - * cast as a UserSubroutine registry.. - * - * @return a UserSubroutine reference to the registry - * singleton. - */ - inline static UserSubroutine &instance() { - return (UserSubroutine &) (Registry::rootInstance()); - } - - /** - * @brief Member function registerFunction registers the user function's - * name with the specified user function function pointer. - * - * The base class name is determined by the BaseClass template argument's - * getCreatorName() static member function. The signature is defined - * UserSubroutineTraits template argument's Signature typedef. - * - * @param function_name a std::string const reference to the user - * function's name. - * - * @param function a Signature function pointer to the user - * function. - * - */ - inline static void registerFunction(const std::string &function_name, Signature *function) { - Registry::rootInstance().registerIt(std::make_pair(&typeid(Signature), function_name), (void *) function); - } - - /** - * @brief Member function execute returns the user function function - * associated with the specified signature and derived_name. - * - * @param function_name a std::string const reference to the user - * function's name. - * - * @throws a std::invalid_argument exception is thrown - * if there is no user function registered for the - * specified name. - * - * @return a Signature user function. - */ - static Signature *execute(const std::string &function_name) { - Signature *user_function = (Signature *) Registry::rootInstance().getFunctionPtr(std::make_pair(&typeid(Signature), function_name)); - - return (*user_function); - } - - /** - * @brief Member function execute returns the user function function - * pointer associated with the specified signature and derived_name. - * - * @param function_name a std::string const reference to the user - * function's name. - * - * @throws a std::invalid_argument exception is thrown - * if there is no user function registered for the - * specified name. - * - * @return a Signature user function pointer. - */ - static Signature *getFunction(const std::string &function_name) { - Signature *user_function = (Signature *) Registry::rootInstance().getFunctionPtr(std::make_pair(&typeid(Signature), function_name)); - - return user_function; - } - - /** - * @brief Member function exists returns true if user function specified by - * derived_name exists. - * - * @param function_name a std::string const reference to the user - * function's name. - * - * @return a bool of true if user function specified - * signature and function_name exists in BaseClass. - */ - static bool exists(const std::string &derived_name) { - return Registry::rootInstance().getFuncPtr(std::make_pair(&typeid(Signature), derived_name)) != NULL; - } - - /** - * @brief Class template Register registers the user function function - * pointer with the function_name on object creation. - * - */ - class Register - { - public: - /** - * @brief Creates a new Register instance. Upon creation, the - * func_ptr() function is registered with the function_name. - * - * @param function_name a std::string const reference to the user - * function's name. - * - */ - Register(const std::string &function_name, Signature *function) - : m_function(function) - { - UserSubroutine::instance().registerFunction(function_name, *m_function); - } - - private: - Signature * m_function; ///< Holder of the function pointer - }; -}; - -template <> -void *Registry::getsym(const char *sym); - -template -inline T Registry::getsym(const char *sym) { - return static_cast(getsym(sym)); -} - -} // namespace Plugin -} // namespace sierra - -typedef std::type_info *type_info_func(); - -/** - * @brief FORTRAN compatible user subprogram registration routine. - * - * @par Description: - * The first argument is for an application declared subprogram - * that provides an example interface. This example subprogram - * is used to "type" the user-subprogram, e.g. the caller of - * the registration routine guarantees that the interface of - * the 'user_sub' exactly matches the interface of the 'type_sub'. - */ -extern "C" { - void SIERRA_FORTRAN(register_user_subroutine)( - type_info_func type_id, - void * user_subroutine, - const char * name, - int name_length ); -} - - -/** - * Macro FORTRAN_USER_SUBROUTINE generates a FortranFunctionTraits template - * specialization for the RETURN and SIGNATURE and creates a typedef - * referencing the user function factory of NAME. - * - * Note that the user function has extern "C" linkage. - * - * @param NAME name to be used by the Fortran EXTERNAL statement - * - * @param USER_SUB user subroutine factory - * - */ -#define FORTRAN_USER_SUBROUTINE(NAME, USER_SUB) extern "C" const std::type_info * SIERRA_FORTRAN(NAME)() {return &typeid(USER_SUB::Signature);} - -#endif // STK_UTIL_DIAG_UserPlugin_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.cpp deleted file mode 100644 index fb4ea5001682..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace diag { - -WriterThrowSafe::WriterThrowSafe( - Writer & writer) - : m_writer(writer), - m_depth(writer.getDepth()) -{} - - -WriterThrowSafe::~WriterThrowSafe() -{ - m_writer.restoreDepth(m_depth); -} - - -Writer::Writer( - std::streambuf * writer_streambuf, - PrintMask print_mask, - Flags flags) - : m_flags(flags), - m_printMask(print_mask), - m_lineMaskStack(), - m_traceDepth(0), - m_writerStream(writer_streambuf) -{} - - -Writer::~Writer() -{} - - -/** - * @brief Member function dflush flushes the output stream. - * - * @return a Writer reference to this object - */ -Writer & -Writer::dflush() { - getStream() << std::flush; - return *this; -} - -/** - * @brief Member function dendl is a manipulator which sets the output - * stream to a new line.

- * - * The std::endl manipulator is sent to the output stream. - * - * @return a Writer reference to this object - */ -Writer & -Writer::dendl() { - if (shouldPrint()) - getStream() << std::endl; - - m_lineMaskStack.resetDepth(); - - return *this; -} - -/** - * @brief Member function push is a manipulator which increases the line - * mask depth by one. - * - * @return a Writer reference to this object - */ -Writer & -Writer::push() { - if (shouldPrint()) { - m_lineMaskStack.pushDepth(); - getStream() << stk_classic::push; - } - - return *this; -} - -/** - * @brief Member function pop is a manipulator which decreases the line - * mask depth by one, but not less than zero(0). - * - * @return a Writer reference to this object - */ -Writer & -Writer::pop() { - if (shouldPrint()) { - getStream() << stk_classic::pop; - m_lineMaskStack.resetDepth().pop(); - } - - return *this; -} - -/** - * @brief Member function pop is a manipulator which decreases the line - * mask depth by one, but not less than zero(0). - * - * @return a Writer reference to this object - */ -Writer & -Writer::resetLineMask() { - m_lineMaskStack.popLineMask(); - - return *this; -} - -/** - * @brief Member function operator<< is the manipulator instantiation - * function - * - * @return a Writer reference to this object - */ -Writer & -Writer::operator<<(Writer& (*f)(Writer&)) { - f(*this); - return *this; -} - -Writer & -Writer::operator<<( - std::ios_base & (*f)(std::ios_base&)) -{ - if (shouldPrint()) - f(getStream()); - return *this; -} - - -Writer & -Writer::operator<<( - std::ostream & (*f)(std::ostream&)) -{ - if (shouldPrint()) - f(getStream()); - - return *this; -} - - -Writer & -operator<<( - Writer & dout, - const void * ptr) -{ - if (dout.shouldPrint()) - dout.getStream() << ptr; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const char * c_str) -{ - if (dout.shouldPrint()) { - std::ostream &os = dout.getStream(); - if (!c_str) - os << "(null)"; - else - os << c_str; - } - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const std::string & s) -{ - dout << s.c_str(); - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const float & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const double & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const long double & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const int & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const unsigned int & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const long & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const unsigned long & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - -Writer & -operator<<( - Writer & dout, - const long long & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - -Writer & -operator<<( - Writer & dout, - const unsigned long long & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - -Writer & -operator<<( - Writer & dout, - const short & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const unsigned short & x) -{ - if (dout.shouldPrint()) - dout.getStream() << x; - - return dout; -} - - -} // namespace diag -} // namespace stk_classic - -namespace sierra { -namespace Diag { - -Writer & -operator<<( - Writer & dout, - const String & str) -{ - if (dout.shouldPrint()) - dout.getStream() << str; - - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::Identifier & s) -{ - if (dout.shouldPrint()) - dout.getStream() << '\'' << s << '\''; - - return dout; -} - -} // namespace Diag -} // namespace sierra - diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.dox b/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.dox deleted file mode 100644 index 14968ae62590..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.dox +++ /dev/null @@ -1,442 +0,0 @@ -/// -/// \addtogroup stk_util_diag_writer_detail -/// @{ -/// -/// @brief The diagnostic writer provides features for the runtime selection of diagnostic output of -/// data and objects. -/// -/// The runtime diagnostic output selection is achieved utilizing message marking within the source -/// code and selection from the command line or input deck. -/// -/// The First, -/// -/// by implementing a dump member function and an operator<< free function, the class -/// may be easily dumped using the << operator. And, second, by assigning appropriate -/// bit masks, the diagnostic writer allows the diagnostic output to be selectively output by the -/// developer or user at runtime. -/// -/// For Example:
-/// -/// \code -/// class AnotherClass -/// { -/// public: -/// AnotherClass(int i) -/// {} -/// -/// double hairyCalc(int i) { -/// return sin((double) i); -/// } -/// -/// Writer &dump(Writer &dout) const { -/// if (dout.shouldPrint()) { -/// dout << "AnotherClass " << push << dendl; -/// -/// dout.m(LOG_MEMBERS) << "m_m1, " << m_m1 << dendl; -/// dout.m(LOG_MEMBERS) << "m_mem2, " << m_mem2 << dendl; -/// -/// if (dout.shouldPrint(LOG_MEMBERS)) { -/// dout << "hairyCalc" << push << dendl; -/// for (int i = 0; i < 1000; ++i) -/// dout << "hairyCalc(" << i << ") = " << hairyCalc(i) << dendl; -/// -/// dout << pop; -/// } -/// dout << pop; -/// } -/// return dout; -/// } -/// -/// private: -/// int m_m1; -/// int m_mem2; -/// }; -/// -/// inline Writer &operator<<(Writer &dout, const AnotherClass &another_class) { -/// return another_class.dump(dout); -/// } -/// -/// class ShowWriter -/// { -/// void Func() { -/// sierra::diag_writer dout(std::cout); -/// dout.setPrintMask(LOG_LIGHT | LOG_HEAVY | LOG_MEMBERS); -/// -/// int j = 7; -/// -/// m_anotherClassVector.push_back(AnotherClass(j)); -/// m_anotherClassVector.push_back(AnotherClass(j*2)); -/// m_anotherClassVector.push_back(AnotherClass(j*2 + 1)); -/// -/// -/// dout.m(LOG_LIGHT) << "Light weight diagnostic message, j is " << j << dendl; -/// dout.m(LOG_HEAVY) << "Heavy weight diagnostic message " << m_anotherClassVector << dendl; -/// } -/// -/// Writer &dump(Writer &dout) const { -/// if (dout.shouldPrint()) { -/// dout << "ShowWriter, " << push << dendl; -/// -/// dout.m(LOG_MEMBERS) << "m_anotherClassVector, " << m_anotherClassVector << dendl; -/// dout << pop; -/// } -/// -/// return dout; -/// } -/// -/// std::vector m_anotherClassVector; -/// }; -/// -/// inline Writer &operator<<(Writer &dout, const ShowWriter &show_diag_writer) { -/// return show_diag_writer.dump(dout); -/// } -/// \endcode -/// -/// -/// \anchor stk_util_diag_writer_howto_add_to_app -/// \section stk_util_diag_writer_add_to_app Adding diagnostic writer to your application -/// -/// Adding a diagnostic writer to your application allows you to leave diagnostic -/// code in your application which is only seen when desired. -/// -///

    -///
  • Create a App_DiagWriter_fwd.h -/// -/// The forward definition file defines the LOG_name bit masks which will be used -/// to select the messages to be written to the diagnostic stream. -/// -/// \code -/// #ifndef SIERRA_App_DiagWriter_fwd_h -/// #define SIERRA_App_DiagWriter_fwd_h -/// -/// #include -/// -/// namespace sierra { -/// namespace app { -/// -/// enum { -/// LOG_ALWAYS = sierra::LOG_ALWAYS, -/// LOG_TRACE = sierra::LOG_TRACE, -/// LOG_TRACE_STATS = sierra::LOG_TRACE_STATS, -/// LOG_TRACE_SUB_CALLS = sierra::LOG_TRACE_SUB_CALLS, -/// LOG_MEMBERS = sierra::LOG_MEMBERS, -/// -/// LOG_NOLOAD = 0x00000100, -/// LOG_NOEXECUTE = 0x00000200, -/// LOG_SYNTAX_CHECK = 0x00000400, -/// LOG_INPUT_CHECK = 0x00000800, -/// LOG_DUMP_SETUP = 0x00001000, -/// LOG_DUMP_LOAD = 0x00002000, -/// -/// LOG_CONTROL = 0x00003F00, -/// -/// LOG_COMM = 0x00010000, -/// LOG_CONTACT = 0x00020000, -/// LOG_GEOMETRY = 0x00040000, -/// LOG_APP04 = 0x00080000, -/// LOG_MATERIAL = 0x00100000, -/// LOG_MESH_MOD = 0x00200000, -/// LOG_PARAMS = 0x00400000, -/// LOG_PLUGINS = 0x00800000, -/// LOG_SCONTROL = 0x01000000, -/// LOG_SEARCH = 0x02000000, -/// LOG_SOLVER = 0x04000000, -/// LOG_XFER = 0x08000000, -/// LOG_FIELD = 0x10000000, -/// LOG_DIAGNOSTICS = 0xFFFF0000 -/// }; -/// -/// } // namespace app -/// } // namespace sierra -/// -/// #endif // SIERRA_App_DiagWriter_fwd_h -/// \endcode -/// -///
  • Create a App_DiagWriter.h -/// -/// The diagnostic writer header file defines the parser for parsing the command line and -/// line commands to produce the mask of bits which the user has selected. It also -/// implements the sentry which the application uses to bootstrap the diagnostic writer. -/// -/// \code -/// #ifndef SIERRA_App_DiagWriter_h -/// #define SIERRA_App_DiagWriter_h -/// -/// #include -/// #include -/// #include -/// -/// #include -/// -/// namespace sierra { -/// namespace app { -/// -/// class DiagWriterParser : public Diag::WriterParser -/// { -/// public: -/// DiagWriterParser(); -/// }; -/// -/// stk_classic::diag::Writer &theDiagWriter(); -/// -/// DiagWriterParser &theDiagWriterParser(); -/// -/// #define applog sierra::App::theDiagWriter() -/// } // namespace app -/// } // namespace sierra -/// -/// #endif // SIERRA_Aria_DiagWriter_h -/// \endcode -/// -///
  • Create a App_DiagWriter.C -/// -/// The implementation of the parser constructor adds the command line and line command -/// value used to generate the bit mask. Any combinations of bit masks can be given a -/// name. This will simplify specification of commonly grouped options for the user. -/// -/// \code -/// #include -/// -/// #include -/// #include -/// -/// #include -/// -/// namespace sierra { -/// namespace app { -/// -/// DiagWriterParser & -/// theDiagWriterParser() -/// { -/// /* %TRACE% */ /* %TRACE% */ -/// static DiagWriterParser parser; -/// -/// return parser; -/// } -/// -/// stk_classic::diag::Writer & -/// theDiagWriter() -/// { -/// /* %TRACE[NONE]% */ /* %TRACE% */ -/// static stk_classic::diag::Writer s_diagWriter(sierra::dwout().rdbuf(), theDiagWriterParser().parse(std::getenv("APPLOG"))); -/// -/// return s_diagWriter; -/// } -/// -/// -/// DiagWriterParser::DiagWriterParser() -/// : Diag::WriterParser() -/// { -/// /* %TRACE% */ /* %TRACE% */ -/// mask("bc", (unsigned long) (LOG_BC), "Display boundary condition information"); -/// mask("debug", (unsigned long) (LOG_DEBUG), "Display debug diagnostic information"); -/// mask("eq", (unsigned long) (LOG_EQ), "Display equation information"); -/// mask("expression", (unsigned long) (LOG_EXPRESSION), "Display expression information"); -/// mask("hadapt", (unsigned long) (LOG_HADAPT), "Display h_adapt diagnostic information"); -/// mask("finite_check", (unsigned long) (LOG_FINITE_CHECK), "Display warning messages about any non-finite expression values or sensitivities"); -/// mask("nonlinear", (unsigned long) (LOG_NONLINEAR), "Diaplay nonlinear solver information"); -/// mask("pp", (unsigned long) (LOG_PP), "Display postprocessor diagnostic information"); -/// mask("sens_check", (unsigned long) (LOG_SENS_CHECK), "Display messages generated by expression sensitivity checker"); -/// mask("fast_sens_check", (unsigned long) (LOG_FAST_SENS_CHECK), "Display messages generated by sensitivity checker (skipping FAD, element, and kernel expressions)"); -/// mask("species", (unsigned long) (LOG_SPECIES), "Display species information"); -/// mask("transfer", (unsigned long) (LOG_TRANSFER), "Display transfer information"); -/// mask("plugin", (unsigned long) (LOG_PLUGIN), "Display plugin information"); -/// mask("chaparral", (unsigned long) (LOG_CHAPARRAL), "Display chaparral information"); -/// mask("utility", (unsigned long) (LOG_UTILITY), "Display equation system utility information"); -/// mask("pre_assembly", (unsigned long) (LOG_PREASSEMBLY), "Display pre-assembly diagnostic information"); -/// mask("expression_dump", (unsigned long) (LOG_EXPRESSION_DUMP), "Display the values for every expression and its sensitivities"); -/// mask("calore", (unsigned long) (LOG_CALORE), "Display additional calore output (hack)"); -/// mask("ccfvm", (unsigned long) (LOG_CCFVM), "Display additional ccfvm output (hack)"); -/// mask("user-sub", (unsigned long) (LOG_USER_SUB), "Print user subroutine execution diagnostics"); -/// } -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// Diag::registerWriter("applog", applog, theDiagWriterParser()); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// } // namespace app -/// } // namespace sierra -/// \endcode -/// -///
-/// -/// -/// \anchor stk_util_diag_writer_howto_assign_new_log_bits -/// \section stk_util_diag_writer_assign_new_log_bits Adding additional LOG_mask -/// -/// Adding a new mask and option name requires only adding the new bit to the -/// enumeration in App_DiagWriter_fwd.h, where 0xmmmmmm00 is a previously -/// unusd bit: -/// -/// \code -/// #ifndef SIERRA_App_DiagWriter_fwd_h -/// #define SIERRA_App_DiagWriter_fwd_h -/// -/// #include -/// -/// namespace sierra { -/// namespace app { -/// -/// enum { -/// LOG_ALWAYS = sierra::LOG_ALWAYS, -/// LOG_TRACE = sierra::LOG_TRACE, -/// LOG_TRACE_STATS = sierra::LOG_TRACE_STATS, -/// LOG_TRACE_SUB_CALLS = sierra::LOG_TRACE_SUB_CALLS, -/// LOG_MEMBERS = sierra::LOG_MEMBERS, -/// -/// ... -/// LOG_NEWUNUSEDBIT = 0xmmmmmm00, -/// ... -/// -/// }; -/// -/// } // namespace app -/// } // namespace sierra -/// -/// #endif // SIERRA_App_DiagWriter_fwd_h -/// \endcode -/// -/// And, adding a mask function call in the parser constructor in the App_DiagWriter.C -/// file. -/// -/// \code -/// DiagWriterParser::DiagWriterParser() -/// : Diag::WriterParser() -/// { -/// /* %TRACE% */ /* %TRACE% */ -/// -/// ... -/// mask("new-bit-name", (Diag::PrintMask) (LOG_NEWUNUSEDBIT), "Some brief description"); -/// ... -/// } -/// \endcode -/// -/// -/// \anchor stk_util_diag_writer_howto_add_dump_to_my_class -/// \section stk_util_diag_writer_add_dump_to_my_class Adding diagnostic output to your classes -/// -/// To incorporate the diagnostic writer into a class or application, there are -/// only a few steps to follow. And, by following these guidelines, the newly created -/// class can fully participate is class data diagnostic output. -/// -/// In your class header: -///
    -///
  • Include your application's diagnostic writer forward header. -/// -/// \code -/// #include -/// \endcode -/// -///
  • Declare the dump member function. If this is a base class, be sure the -/// define this member function as virtual if inheritance may be in play. -/// -/// \code -/// Writer &dump(Writer &dout) const; -/// \endcode -/// -///
  • Define the output insertion operator, operator<< to call your member -/// function. -/// -/// \code -/// inline Writer &operator<<(Writer &dout, const MyClass &my_class) { -/// return my_class.dump(dout); -/// } -/// \endcode -///
-/// -/// In your class implementation: -///
    -///
  • Include your application's diagnostic writer header. -/// -/// \code -/// #include ; -/// \endcode -/// -///
  • Define your MyClass::dump(Writer &dout) const member function. I -/// suggest using the following as a start: -/// -/// \code -/// Writer & -/// MyClass::dump( -/// Writer & dout) const -/// { -/// if (dout.shouldPrint()) { -/// dout << demangle(typeid(MyClass).name()) << ", " << m_name << push << std::endl; -/// MyParentClass::dump(dout).dendl(); // If there is a base class -/// -/// dout.m(LOG_MEMBERS) << "m_information, " << m_information << std::endl; -/// dout << pop; -/// } -/// return dout; -/// } -/// \endcode -/// -///
-/// -/// -/// \anchor stk_util_diag_writer_howto_add_dump_to_external_class -/// \section stk_util_diag_writer_add_dump_to_external_class Adding diagnostic output to library classes -/// -/// \anchor stk_util_diag_writer_howto_write_messages -/// \section stk_util_diag_writer_write_messages Writing to the appout writer -/// -/// There are several functions and manipulators which control the selection and -/// formatting of the diagnostic output. -/// -///
    -///
  • The print mask and the line mask -/// -/// It is the interaction of the print mask and line mask which determines is the data is -/// to be written to the diagnostic stream. The print mask is set by the user on the -/// command line or in the input deck. The line mask is set by the developer using the -/// m member function and Diag::setlinemask and Diag::resetlinemask -/// manipulators. -/// -/// As each << operator is executed, the print mask and current line mask are bitwise -/// anded together. If the result of this is non zero, then the line is output. -/// -///
  • std::endl and Diag::dendl -/// -/// Be sure to include std::endl or Diag::dendl at the end of each output line. The end -/// line functions serve as a mask application terminator. In other word, the mask -/// specified using the m member function are in effect until the std::endl of Diag::dendl -/// functions are called on the diagnostic stream. Leaving one out can effect the what is -/// selected to be output. -/// -///
  • Diag::push and Diag::pop -/// -/// The push manipulator pushes the current LineMask onto a stack and the pop manipulator -/// restores the LineMask from the top element of the push stack. -/// -///
-/// -/// \anchor stk_util_diag_writer_howto_throw_safe -/// \section stk_util_diag_writer_throw_safe Indentation and exceptions -/// -/// When exception occur, the pops put-to the output stream are skipped by the exception catch -/// block. As a result, the indentation can start to march across the screen. To correct this -/// behavior, add a ThrowSafe sentry within your try block prior to any push operations. -/// -/// \code -/// try { // TimeStepError -/// stk_classic::diag::WriterThrowSafe throw_safe_sentry; -/// -/// appout.m(LOG_TEST) << "Executing run_it() on " << name() << push << dendl; -/// run_it(); -/// appout.m(LOG_TEST) << pop; /// Missed when run_it() throws -/// } -/// catch (std::exception &x) { -/// appout.m(LOG_TEST) << "Exception caught running run_it() on " << name() << dendl; -/// } -/// \endcode -/// -/// @} -/// - diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.hpp deleted file mode 100644 index 74f174a0f1e9..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer.hpp +++ /dev/null @@ -1,813 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_WRITER_HPP -#define STK_UTIL_DIAG_WRITER_HPP - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup diag_writer_detail -/// @{ -/// - -class WriterThrowSafe -{ -public: - explicit WriterThrowSafe(Writer &writer); - - ~WriterThrowSafe(); - -private: - Writer & m_writer; - int m_depth; - - WriterThrowSafe(const WriterThrowSafe &); - void operator = (const WriterThrowSafe &); -}; - - -/** - * @brief Class Writer implements a runtime selectable diagnostic output writer to aid in the - * development and diagnostics of massively parallel applications. - * - */ -class Writer -{ -public: - /** - * @brief Enumeration Flags. - * - *
    - *
  • DISABLED disables Writer output
    - *
  • ENABLED enabled Writer output
    - *
- */ - enum Flags { - DISABLED = 0x00, - ENABLED = 0x01 - }; - -private: - /** - * @brief Class LineMaskStack implements a special stack for maintaining the - * depth and line mask for the diagnostic stream. It has the following special - * properties: - * - *
    - *
  • Never pops the top element off. - *
  • Pushing a new depth increments the top depth and replicates the top print mask. - *
  • Pushing a line mask replicates the top depth and adds the new line mask. - *
  • Popping does not allow the last depth/line mask to be removed - *
  • Reseting the depth, pops from the stack leaving a the entry on the top which is - * greater in depth than the previous entry's depth. - *
- * - */ - struct LineMaskStack : public std::vector > - { - /** - * @brief Creates a new LineMaskStack instance, inserting the sentinel indentation - * level/line mask value. - * - */ - LineMaskStack() { - push_back(std::pair(0, LOG_ALWAYS)); - } - - /** - * @brief Member function pushDepth pushes the a new indentation level in the stack, - * replicating the line mask value. - * - * @return a LineMaskStack reference to the depth stack. - */ - LineMaskStack &pushDepth() { - push_back(std::make_pair(back().first + 1, back().second)); - return *this; - } - - /** - * @brief Member function push pushes a new line mask on the stack, replicating the - * current indentation level. - * - * @param line_mask a PrintMask value of the line mask. - * - * @return a LineMaskStack reference to the depth stack. - */ - LineMaskStack &push(PrintMask line_mask) { - push_back(std::make_pair(back().first, line_mask)); - return *this; - } - - /** - * @brief Member function pop pops the top entry from the stack, leaving the sentinel - * value if near the bottom. - * - * @return a LineMaskStack reference to the depth stack. - */ - LineMaskStack &pop() { - if (size() > 1) - pop_back(); - return *this; - } - - /** - * @brief Member function popLineMask removes the top line mask only if - * it is not the last one of the current depth. - * - * @return a LineMaskStack reference to the depth stack. - */ - LineMaskStack &popLineMask() { - if (size() > 1 && getNextDepth() == getDepth()) - pop_back(); - return *this; - } - - /** - * @brief Member function getDepth returns the depth from the top entry on the stack. - * - * @return an int value of the depth from the top entry - * on the stack. - */ - int getDepth() const { - return back().first; - } - - /** - * @brief Member function getLineMask returns the line mask from the top entry on the - * stack. - * - * @return an int value of the line mask from the top - * entry on the stack. - */ - int getLineMask() const { - return back().second; - } - - /** - * @brief Member function getNextDepth returns the depth from the entry immediately prior - * to the top entry on the stack. - * - * @return an int returns the depth from the entry - * immediately prior to the top entry on the stack. - */ - int getNextDepth() const { - return (end() - 2)->first; - } - - /** - * @brief Member function resetDepth resets the stack so that the depth of the top entry - * on the stack exceeds the depth of the entry prior to the top entry on the stack. - * - * @return a LineMaskStack reference to the depth stack. - */ - LineMaskStack &resetDepth() { - while (size() > 1 && getNextDepth() == getDepth()) - pop_back(); - return *this; - } - }; - -public: - /** - * @brief Creates a new Writer instance with the specified print mask and output - * flags. - * - * @param print_mask a PrintMask value of the print mask to apply - * to this writer. - * - * @param flags a Flags value of the selected output flags. - * - */ - explicit Writer(std::streambuf *streambuf, PrintMask print_mask = static_cast(LOG_MEMBERS), Flags flags = static_cast(ENABLED)); - - /** - * @brief Destroys a Writer instance. - * - */ - ~Writer(); - - /** - * @brief Member function getStream returns the output stream. - * - * @return a std::ostream reference to the output - * stream. - */ - std::ostream &getStream() { - return m_writerStream; - } - - /** - * @brief Member function setFlags sets the flags bitmask which describes - * the output line prefix content. - * - * @param flags an int of the bitmask of flags. - * - * @return a Writer reference to this object - */ - Writer &setFlags(int flags) { - m_flags = (Flags) flags; - return *this; - } - - /** - * @brief Member function getFlags returns the flags bitmask. - * - * @return an int of the flags bitmask. - */ - int getFlags() { - return m_flags; - } - - int getDepth() const { - return m_lineMaskStack.getDepth(); - } - - Writer &restoreDepth(int depth) { - while (m_lineMaskStack.getDepth() > depth) - pop(); - return *this; - } - - /** - * @brief Member function setPrintMask sets the print output mask. - * - * @param mask an PrintMask value of the new print - * mask. - * - * @return a Writer reference to this diagnostic - * writer. - */ - Writer &setPrintMask(PrintMask mask = 0) { - m_printMask = mask; - return *this; - } - - /** - * @brief Member function setPrintMask sets the print output mask. - * - * @param mask_string an PrintMask value of the new print - * mask. - * - * @return a Writer reference to this diagnostic - * writer. - */ - //Writer &setPrintMask(const char *mask_string); - - /** - * @brief Member function setLineMask sets the line mask of this line. - * - * @param line_mask an PrintMask of the mask for this - * line. - * - * @return a Writer reference to this diagnostic - * writer. - */ - Writer &setLineMask(PrintMask line_mask) { - m_lineMaskStack.push(line_mask); - - return *this; - } - - /** - * @brief Member function m sets the line mask of this line. - * - * @param line_mask an PrintMask of the mask for this - * line. - * - * @return a Writer reference to this object. - */ - Writer &m(PrintMask line_mask) { - setLineMask(line_mask); - - return *this; - } - - /** - * @brief Member function m sets the line mask of this line. - * - * @param line_mask an PrintMask of the mask for this - * line. - * - * @return a Writer reference to this object. - */ - Writer &w(bool on, PrintMask line_mask) { - setLineMask(on ? line_mask : 0x80000000); - - return *this; - } - - /** - * @brief Member function t sets the line mask of this line to line_make bitwise - * or'ed with LOG_TRACE. - * - * @param line_mask an PrintMask of the mask for this - * line. - * - * @return a Writer reference to this object. - */ - Writer &t(PrintMask line_mask = 0) { - setLineMask(line_mask | stk_classic::LOG_TRACE); - - return *this; - } - - /** - * @brief Member function getLineMask returns the current line mask. - * - * @return an int value of the current line mask. - */ - PrintMask getPrintMask() { - return m_printMask; - } - - /** - * @brief Member function isEnabled returns true if the ENABLED bit is set in the flags - * bitmask. - * - * @return a bool of true if the ENABLED bit is set in - * the flags bitmask. - */ - bool isEnabled() { - return (m_flags & ENABLED) != 0; - } - - /** - * @brief Member function isLoggable returns true if any corresponding bit in the line mask - * matches a bit in the print mask, except LOG_TRACE which also requires isTracing() to be true. - * - * @return a bool of true if any corresponding bit in - * the line mask matches a bit inthe print mask. - */ - bool isLoggable(PrintMask line_mask) { - return line_mask == 0 // Always - || ((line_mask & m_printMask & stk_classic::LOG_TRACE) // LOG_TRACE? - ? isTracing() // Yes, must be tracing -// : (line_mask & m_printMask) != 0); // No, any matching bits - : (line_mask & m_printMask) == line_mask); // No, all matching bits - } - - /** - * @brief Member function shouldPrint returns true if the line should print. - * - * @return a bool of true if this line should be printed. - */ - bool shouldPrint() { - return shouldPrint(m_lineMaskStack.getLineMask()); - } - - /** - * @brief Member function shouldPrint returns true if the line should print. - * - * @param line_mask a PrintMask value of the line mask. - * - * @return a bool of true if this line should be printed. - */ - bool shouldPrint(PrintMask line_mask) { - return isEnabled() && isLoggable(line_mask); - } - - /** - * @brief Member function shouldTrace returns true if any corresponding bit in the line - * mask matches a bit in the print mask, except LOG_TRACE which also requires isTracing() to be - * true. - * - * @return a bool of true if any corresponding bit in - * the line mask matches a bit in the print mask. - */ - bool shouldTrace(int line_mask) { - return line_mask == 0 // Always - || (line_mask & m_printMask) != 0; // Any set -// || (line_mask & m_printMask) == line_mask; // All set - } - - /** - * @brief Member function dflush flushes the output stream. - * - * @return a Writer reference to this object - */ - Writer &dflush(); - - /** - * @brief Member function dendl is a manipulator which sets the output - * stream to a new line.

- * - * The std::endl manipulator is sent to the output stream. - * - * @return a Writer reference to this object - */ - Writer &dendl(); - - /** - * @brief Member function push is a manipulator which increases the line - * mask depth by one. - * - * @return a Writer reference to this object - */ - Writer &push(); - - /** - * @brief Member function pop is a manipulator which decreases the line mask depth by one, - * but not less than zero(0). - * - * @return a Writer reference to this object - */ - Writer &pop(); - - /** - * @brief Member function pop is a manipulator which decreases the line mask depth by one, - * but not less than zero(0). - * - * @return a Writer reference to this object - */ - Writer &resetLineMask(); - -#ifndef SWIG - /** - * @brief Member function operator<< is the manipulator instantiation function - * - * @return a Writer reference to this object - */ - Writer& operator<<(Writer& (*f)(Writer&)); - - /** - * @brief Member function operator<< passes the ios_base manipulator function to the output - * stream. - * - * @return a Writer reference to this object - */ - Writer& operator<<(std::ios_base& (*f)(std::ios_base&)); - - /** - * @brief Member function operator<< passes the iostream manipulator function to the output - * stream. - * - * @return a Writer reference to this object - */ - Writer& operator<<(std::ostream& (*f)(std::ostream&)); -#endif // SWIG - /** - * @brief Member function incTraceDepth increments the tracing count. - * - * @return an int value of the new tracing count. - */ - int incTraceDepth() { - return ++m_traceDepth; - } - - /** - * @brief Member function decTraceDepth decrements the tracing count. - * - * @return an int value of the new tracing count. - */ - int decTraceDepth() { - return --m_traceDepth; - } - - /** - * @brief Member function isTracing returns true of the trace depth is greater than zero. - * The value of -1 is initially stored in the depth as a flag that the trace counters have never - * been called. (This may be and obsolete requirement). - * - * @return a bool value of true of the trace depth is greater - * than zero - */ - bool isTracing() { - return m_traceDepth <= 0 ? false - : (m_traceDepth == 1 || (m_traceDepth > 1 && (m_printMask & stk_classic::LOG_TRACE_SUB_CALLS))); - } - - /** - * @brief Member function isTraceable returns true if currently tracing or - * tracing is enabled. - * - * @return a bool of true if tracing is enabled and - * active, or if tracing is disabled. - */ - bool isTraceable() { - return isTracing() || (m_printMask & stk_classic::LOG_TRACE) != 0; // Currently in a trace or tracing bit set - } - -private: - Flags m_flags; ///< Describes the output and line prefix information to be printed. - PrintMask m_printMask; ///< Print mask that the line mask must the match to print - LineMaskStack m_lineMaskStack; ///< Stack of pushed line masks - int m_traceDepth; ///< Trace depth - std::ostream m_writerStream; -}; - -/** - * @brief Writer function dendl calls the Writer::dendl manipulator. - * - * @param dout a Writer reference to the diagnostic writer to dendl. - * - * @return a Writer reference to this object - */ -inline Writer &dendl(Writer &dout) { - return dout.dendl(); -} - -/** - * @brief Writer function dflush calls the Writer::dflush - * manipulator. - * - * @param dout a Writer reference to the diagnostic writer to flush. - * - * @return a Writer reference to this object - */ -inline Writer &dflush(Writer &dout) { - return dout.dflush(); -} - -/** - * @brief Function push calls the Writer::push manipulator. - * - * @param dout a Writer reference to the diagnostic writer to - * push. - * - * @return a Writer reference to this object - */ -inline Writer &push(Writer &dout) { - return dout.push(); -} - -/** - * @brief Member function pop calls the Writer::pop manipulator. - * - * @param dout a Writer reference to the diagnostic writer to - * pop. - * - * @return a Writer reference to this object - */ -inline Writer &pop(Writer &dout) { - return dout.pop(); -} - - -/** - * @brief Class _setlinemask is the line mask manipulator. - * - */ -struct _setlinemask -{ - /** - * @brief Creates a new setlinemask instance. - * - * @param line_mask an PrintMask value of the new line mask. - */ - _setlinemask(PrintMask line_mask) - : m_lineMask(line_mask) - {} - - PrintMask m_lineMask; -}; - -/** - * @brief Function setlinemask sets the active line mask bits as a manipulator. - * - * @param line_mask a PrintMask value of the bits to set. - * - */ -inline _setlinemask setlinemask(PrintMask line_mask) { - return _setlinemask(line_mask); -} - -/** - * @brief Function operator<< class the Writer::setLineMask manipulator. - * - * @param dout a Writer reference to the diagnostic writer to - * set the line mask. - * - * @param set_line_mask a _setlinemask value of the line mask to set. - * - * @return a Writer reference to this object - */ -#ifndef SWIG -inline Writer &operator<<(Writer &dout, _setlinemask set_line_mask) { - return dout.setLineMask(set_line_mask.m_lineMask); -} -#endif // SWIG - -/** - * @brief Function resetlinemask calls the Writer::resetLineMask manipulator. - * - * @param dout a Writer reference to the diagnostic writer to - * dendl. - * - * @return a Writer reference to this object - */ -inline Writer &resetlinemask(Writer &dout) { - return dout.resetLineMask(); -} - -/** - * @brief Function operator<< writes the c sytle string to the output stream. - * - * @param dout a Writer reference to the diagnostic writer to write the - * c style string to. - * - * @param c_str a char const pointer to the start of the c style - * string. - * - * @return a Writer reference to this object - */ -#ifndef SWIG -Writer &operator<<(Writer &dout, const char *c_str); -Writer &operator<<(Writer &dout, const std::string &str); -Writer &operator<<(Writer &dout, const void *ptr); -Writer &operator<<(Writer &dout, const float &x); -Writer &operator<<(Writer &dout, const double &x); -Writer &operator<<(Writer &dout, const long double &x); -Writer &operator<<(Writer &dout, const int &x); -Writer &operator<<(Writer &dout, const unsigned int &x); -Writer &operator<<(Writer &dout, const long &x); -Writer &operator<<(Writer &dout, const unsigned long &x); -Writer &operator<<(Writer &dout, const short &x); -Writer &operator<<(Writer &dout, const unsigned short &x); -Writer &operator<<(Writer &dout, const long long &x); -Writer &operator<<(Writer &dout, const unsigned long long &x); -#endif // SWIG -/** - * @brief Class c_ptr_ simply stores a pointer to an object of type T. This - * allows pointers which want to be deferenced if they are not null to be output using - * operator<< on a c_ptr function. - * - */ -template -class c_ptr_ -{ -public: - /** - * Creates a new c_ptr_ instance. - * - * @param t a T pointer to object - */ - explicit c_ptr_(const T *t) - : m_t(t) - {} - -public: - const T * m_t; ///< Pointer to object -}; - -/** - * Member function c_ptr creates a c_ptr_ object of type T ala std::make_pair. - * - * @param t a T pointer to an object that is to be dereferenced. - * - * @return a c_ptr_ object which contains the pointer t. - */ -template -c_ptr_ c_ptr(const T *t) { - return c_ptr_(t); -} - -/** - * @brief Class c_ptr_func_ simply stores a pointer to an object of type T. - * This allows pointers which want to call the specified member function if they are not - * null to be output using operator<< on a c_ptr_func function. - * - */ -template -class c_ptr_func_ -{ -public: - /** - * Creates a new c_ptr_func_ instance. - * - * @param t a T pointer to object - * - * @param pmf a T::* member function pointer to call - * - */ -#ifndef SWIG - explicit c_ptr_func_(const T *t, R (T::*pmf)() const) - : m_t(t), - m_pmf(pmf) - {} -public: - const T * m_t; ///< Pointer to object - R (T::*m_pmf)() const; ///< Function to call for dump -#endif // SWIG -}; - -/** - * @brief Template function c_ptr creates a c_ptr_func_ object of type T ala - * std::make_pair. This T must implement a member function which takes no arguments and - * returns a value of type R. - * - * @param t a T pointer to an object that is call the specified - * member function. - * - * - * @param pmf a T::* member function pointer to call - * - * @return a c_ptr_ object which contains the pointer t and a - * member function whch takes no arguments. - */ -#ifndef SWIG -template -c_ptr_func_ c_ptr_func(const T *t, R (T::*pmf)() const) { - return c_ptr_func_(t, pmf); -} - -/** - * @brief Template function operator<< dereferences the c_ptr_ object's member m_t if - * it is not null and writes that to the diagnostic writer. If the object's member is null, it - * writes "". - * - * @param dout a Writer reference to the diagnostic writer to - * write the object to if the pointer to it is not null. - * - * @param c a c_ptr_ reference with a member to dereference and - * write to ethe diagnostic writer if not null. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const c_ptr_ &c) { - dout << "(pointer " << (void *) c.m_t << "), "; - - if (c.m_t) - dout << *c.m_t; - else - dout << ""; - - return dout; -} - -/** - * @brief Template function operator<< dereferences the c_ptr_func_ - * object's member m_t if it is not null and calls the m_pmf member function and writes - * the result of that to the diagnostic writer. If the object's member is null, it writes - * "". - * - * @param dout a Writer reference to the diagnostic writer to - * write the T object to if the pointer to it is not null. - * - * @param c a c_ptr_func_ reference with a member to dereference - * and call the member function m_pmt if m_t is not null. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const c_ptr_func_ &c) { - if (c.m_t) - dout << "(pointer), " << (c.m_t->*c.m_pmf)(); - else - dout << "(pointer), "; - - return dout; -} -#endif // SWIG - -/// -/// @} -/// - -} // namespace diag -} // namespace stk_classic - -#include - -namespace sierra { - - -using stk_classic::diag::push; -using stk_classic::diag::pop; -using stk_classic::diag::dendl; -using stk_classic::diag::dflush; - -namespace Diag { - -using stk_classic::diag::push; -using stk_classic::diag::pop; -using stk_classic::diag::dendl; -using stk_classic::diag::dflush; -using stk_classic::diag::setlinemask; -using stk_classic::diag::resetlinemask; -using stk_classic::diag::c_ptr; -using stk_classic::diag::c_ptr_func; -using stk_classic::diag::c_ptr_func_; - -} - -} // namespace sierra - -#include - -#endif // STK_UTIL_DIAG_WRITER_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.cpp deleted file mode 100644 index 68118fa0fed4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace stk_classic { -namespace diag { - -Writer & -operator<<( - Writer & dout, - const std::type_info & t) -{ - if (dout.shouldPrint()) - dout << stk_classic::demangle(t.name()); - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::String & s) -{ - if (dout.shouldPrint()) - dout << s.c_str(); - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::Identifier & s) -{ - if (dout.shouldPrint()) - dout << s.c_str(); - return dout; -} - - -#if defined( STK_HAS_MPI ) -Writer & -operator<<( - Writer & dout, - const sierra::MPI::Loc & loc) -{ - if (dout.shouldPrint()) - dout << loc.m_value << "@" << loc.m_loc; - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::MPI::Loc & loc) -{ - if (dout.shouldPrint()) - dout << loc.m_value << "@" << loc.m_loc; - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::MPI::Loc & loc) -{ - if (dout.shouldPrint()) - dout << loc.m_value << "@" << loc.m_loc; - return dout; -} - - -Writer & -operator<<( - Writer & dout, - const sierra::MPI::TempLoc & loc) -{ - if (dout.shouldPrint()) - dout << loc.m_value << " " << loc.m_other << "@" << loc.m_loc; - return dout; -} - -#endif // if defined( STK_HAS_MPI ) - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.hpp deleted file mode 100644 index 3ab7b84e85d6..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterExt.hpp +++ /dev/null @@ -1,1164 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_WRITEREXT_HPP -#define STK_UTIL_DIAG_WRITEREXT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -#include -#include - -#include -#include -#include -#include -#include -#include - - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup diag_writer_detail -/// @{ -/// - -/** - * @brief Function operator<< wrties a std::type_info name to the diagnostic - * writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::type_info object to. - * - * @param t a std::type_info const reference to the std::typeinfo - * object. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const std::type_info &t); - -/** - * @brief Template function operator<< writes an std::auto_ptr object - * address and content to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::auto_ptr object. - * - * @param t a std::auto_ptr const reference to the object. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::auto_ptr &t) { - if (t.get()) - dout << " " << typeid(t) << ", " << t.get() << ", " << *t; - else - dout << " " << typeid(t) << ", "; - - return dout; -} - -/** - * @brief Template function operator<< writes the members of an arbitrary - * std::pair object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::pair members to. - * - * @param pair a std::pair const reference to the pair of objects. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer & dout, const std::pair &pair) { -// dout << typeid(pair) << "(" << pair.first << ":" << pair.second << ")"; - dout << "(" << pair.first << ":" << pair.second << ")"; - - return dout; -} - -/** - * @brief Template dump prints the object contained within a std::vector - * object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::vector to. - * - * @param t a std::vector of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::vector & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - if (t.size() <= 10) { - for (typename std::vector::const_iterator it = t.begin(); it != t.end(); ++it) - dout << (*it) << " "; - dout << dendl; - } - else { - int i = 0; - for (typename std::vector::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << (*it) << dendl; - } - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object pointed to that are - * contained within a std::vector object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::vector to. - * - * @param t a std::vector of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::vector & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - int i = 0; - for (typename std::vector::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << c_ptr_(*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::list object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::list to. - * - * @param t a std::list of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::list & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - int i = 0; - for (typename std::list::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << (*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object pointed to that are - * contained within a std::list object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::list to. - * - * @param t a std::list of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::list & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - int i = 0; - for (typename std::list::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << c_ptr_(*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::map object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::map to. - * - * @param t a std::map of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::map & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::map::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << (*it).second << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object pointed to that are - * contained within a std::map to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::map to. - * - * @param t a std::map of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::map & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::map::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << c_ptr_((*it).second) << std::endl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::multimap object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multimap to. - * - * @param t a std::multimap of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::multimap & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::multimap::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << (*it).second << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object pointed to that are - * contained within a std::multimap to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multimap to. - * - * @param t a std::multimap of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::multimap & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::multimap::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << c_ptr_((*it).second) << std::endl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::set object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::set to. - * - * @param t a std::set of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::set & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::set::const_iterator it = t.begin(); it != t.end(); ++it) - dout << (*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::set object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::set to. - * - * @param t a std::set of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::set & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::set::const_iterator it = t.begin(); it != t.end(); ++it) - dout << c_ptr_((*it)) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::multiset object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multiset to. - * - * @param t a std::multiset of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::multiset & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::multiset::const_iterator it = t.begin(); it != t.end(); ++it) - dout << (*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump prints the object contained within a - * std::multiset object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multiset to. - * - * @param t a std::multiset of objects. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const std::multiset & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename std::multiset::const_iterator it = t.begin(); it != t.end(); ++it) - dout << c_ptr_((*it)) << dendl; - - dout << pop; - } - - return dout; -} - -// /** -// * @brief Template dump prints the object contained within a -// * hash_map to the diagnostic writer. -// * -// * @param dout a Writer reference to the diagnostic writer to -// * write the hash_map to. -// * -// * @param t a hash_map of objects. -// * -// * @return a Writer reference to this object -// */ -// template -// Writer & -// dump( -// Writer & dout, -// const hash_map & t) -// { -// if (dout.shouldPrint()) { -// dout << typeid(t) << ", size " << t.size() << push << dendl; - -// for (typename hash_map::const_iterator it = t.begin(); it != t.end(); ++it) -// dout << "[" << (*it).first << "] " << (*it).second << dendl; - -// dout << pop; -// } - -// return dout; -// } - -// /** -// * @brief Template dump prints the object pointed to that are -// * contained within a hash_map to the diagnostic writer. -// * -// * @param dout a Writer reference to the diagnostic writer to -// * write the hash_map to. -// * -// * @param t a hash_map of objects. -// * -// * @return a Writer reference to this object -// */ -// template -// Writer & -// dump( -// Writer & dout, - -// const hash_map & t) -// { -// if (dout.shouldPrint()) { -// dout << typeid(t) << ", size " << t.size() << push << dendl; - -// for (typename hash_map::const_iterator it = t.begin(); it != t.end(); ++it) -// dout << "[" << (*it).first << "] " << (*it)->second << dendl; - -// dout << pop; -// } - -// return dout; -// } - - -template -Writer &operator<<(Writer &dout, const std::bitset &t) { - if (dout.shouldPrint()) - dout.getStream() << t; - - return dout; -} - - -/** - * @brief Member function operator<< write the std::vector object to - * the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::list to. - * - * @param t a std::vector const reference to the std::vector. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::vector &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< write the std::list object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::list to. - * - * @param t a std::list const reference to the std::list. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::list &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes the std::map object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::map to. - * - * @param t a std::map const reference to the std::map. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::map &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes the std::multimap object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multimap to. - * - * @param t a std::multimap const reference to the std::multimap. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::multimap &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes the std::set object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::set to. - * - * @param t a std::set const reference to the std::set. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::set &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes the std::multiset object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the std::multiset to. - * - * @param t a std::multiset const reference to the std::multiset. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const std::multiset &t) { - return dump(dout, t); -} - - -/** - * @brief Function operator<< writes a sierra String object to the diagnostic - * writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the sierra string to. - * - * @param s a sierra::String const reference to the sierra string to write. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::String &s); - -/** - * @brief Function operator<< writes a sierra Identifier object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the sierra identifier to. - * - * @param s a sierra::String const reference to the sierra identifier to write. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::Identifier &s); - -#if defined( STK_HAS_MPI ) -/** - * @brief Function operator<< writes the MPI::Loc type to the output stream. - * - * @param dout a Writer reference to the diagnostic writer to write the - * c style string to. - * - * @param loc a MPI::Loc const reference to the - * MPI::MaxLoc/MPI::MinLoc operator object. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::MPI::Loc &loc); - -/** - * @brief Function operator<< writes the sierra::MPI::Loc type to the output stream. - * - * @param dout a Writer reference to the diagnostic writer to write the - * c style string to. - * - * @param loc a sierra::MPI::Loc const reference to the - * sierra::MPI::MaxLoc/sierra::MPI::MinLoc operator object. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::MPI::Loc &loc); - -/** - * @brief Function operator<< writes the sierra::MPI::Loc type to the output stream. - * - * @param dout a Writer reference to the diagnostic writer to write the - * c style string to. - * - * @param loc a sierra::MPI::Loc const reference to the - * sierra::MPI::MaxLoc/sierra::MPI::MinLoc operator object. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::MPI::Loc &loc); - -/** - * @brief Function operator<< writes the TempLoc type to the output stream. - * - * @param dout a Writer reference to the diagnostic writer to write the - * c style string to. - * - * @param loc a sierra::MPI::Loc const reference to the - * sierra::MPI::MaxLoc/sierra::MPI::MinLoc operator object. - * - * @return a Writer reference to this object - */ -Writer &operator<<(Writer &dout, const sierra::MPI::TempLoc &loc); - -#endif // if defined( STK_HAS_MPI ) - -/** - * @brief Template function c_ptr_name implements c_ptr_func with the function - * 'name'. - * - * @param t a T pointer to an object that is call the name - * member function. - * - * @return a c_ptr_func_ object which contains a member function - * pointer to name(); - */ -template -c_ptr_func_ c_ptr_name(const T *t) { - return c_ptr_func_(t, &T::name); -} - -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7 > -Writer & -operator<<(Writer &dout, const sierra::Array &array) -{ - typedef sierra::Array X; - - if (dout.shouldPrint()) { - std::string type = sierra::demangle(typeid(X).name()); - dout << type.substr(0, type.find(", sierra::TypeListEnd")) << ">" << push << dendl; - dout.getStream() << array; // ArrayVerbosePrint::dump(dout, array.dimension(), array.ptr(), array.stride()); - dout << pop << dendl; - } - return dout; -} - - -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7 > -Writer & -operator<<(Writer &dout, const sierra::ArrayContainer &array) -{ - typedef sierra::ArrayContainer X; - - if (dout.shouldPrint()) { - std::string type = sierra::demangle(typeid(X).name()); - dout << type.substr(0, type.find(", sierra::TypeListEnd")) << ">" << push << dendl; - dout.getStream() << array; // ArrayVerbosePrint::dump(dout, array.dimension(), array.ptr(), array.stride()); - dout << pop << dendl; - } - return dout; -} - - -template< class ElementType, int Dimension> -Writer & -operator<<(Writer &dout, const sierra::FArray &array) -{ - typedef sierra::FArray X; - - if (dout.shouldPrint()) { - dout << sierra::demangle(typeid(X).name()) << push << dendl; - dout.getStream() << array; // ArrayVerbosePrint::dump(dout, array.dimension(), array.ptr(), array.stride()); - dout << pop << dendl; - } - return dout; -} - -template< class ElementType, int Dimension> -Writer & -operator<<(Writer &dout, const sierra::FArrayContainer &array) -{ - typedef sierra::FArrayContainer X; - - if (dout.shouldPrint()) { - dout << sierra::demangle(typeid(X).name()) << push << dendl; - dout.getStream() << array; // ArrayVerbosePrint::dump(dout, array.dimension(), array.ptr(), array.stride()); - dout << pop << dendl; - } - return dout; -} - -/** - * @brief Template function dump writes a Mapv_no_delete object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the Mapv_no_delete to. - * - * @param t a sierra::String const reference to the Mapv_no_delete to write. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::Mapv_no_delete & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename sierra::Mapv_no_delete::const_iterator it = t.begin(); it != t.end(); ++it) { - dout << "[" << (*it).mapv_key() << "] " << (*it) << dendl; - } - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump writes the vecmap object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap to. - * - * @param t a vecmap const reference to the vecmap. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::vecmap & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename sierra::vecmap::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << (*it).second << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump writes a vecmap of pointers object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap of pointers to. - * - * @param t a vecmap const reference to the vecmap of pointers. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::vecmap & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename sierra::vecmap::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << *(*it).second << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump writes a vecmap of pointers object to the - * dignostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap of pointers to. - * - * @param t a vecmap const reference to the vecmap of pointers. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::vecmap & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename sierra::vecmap::const_iterator it = t.begin(); it != t.end(); ++it) - dout << "[" << (*it).first << "] " << *(*it).second << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump writes a vecset object to the diagnostic - * writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecset to. - * - * @param t a vecset const reference to the vecset. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::vecset & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - int i = 0; - for (typename sierra::vecset::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << (*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template function dump writes a vecset of pointers object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecset of pointers to. - * - * @param t a vecset const reference to the vecset of pointers. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::vecset & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - int i = 0; - for (typename sierra:: vecset::const_iterator it = t.begin(); it != t.end(); ++it, ++i) - dout << "[" << i << "] " << *(*it) << dendl; - - dout << pop; - } - - return dout; -} - -/** - * @brief Template dump writes a MapvNode object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to write the - * Mapvnod to. - * - * @param t a MapvNode const reference to the MapvNode to write. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::MapvNode & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", " << t.mapv_key(); - } - - return dout; -} - -/** - * @brief Template function dump writes a Mapv object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to write the - * Mapv to. - * - * @param t a std::vector const reference to the Mapv to write. - * - * @return a Writer reference to this object - */ -template -Writer & -dump( - Writer & dout, - const sierra::Mapv & t) -{ - if (dout.shouldPrint()) { - dout << typeid(t) << ", size " << t.size() << push << dendl; - - for (typename sierra::Mapv::const_iterator it = t.begin(); it != t.end(); ++it) { - dout << "[" << (*it).mapv_key() << "] " << (*it) << dendl; - } - - dout << pop; - } - - return dout; -} - -/** - * @brief Member function operator<< writer a vecset object the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecset to. - * - * @param t a vecset const reference to the vecset. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::vecset &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes the vecmap object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap to. - * - * @param t a vecmap const reference to the vecmap. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::vecmap &t) { - return dump(dout, t); -} - -/** - * @brief Member function operator<< writes a vecset of pointers object to - * the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecset of pointers to. - * - * @param t a vecset const reference to the vecset of pointers. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::vecset &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writea a vecmap of pointers with key - * pointers object to the diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap of pointers to. - * - * @param t a vecmap const reference to the vecmap of pointers. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::vecmap &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes a Mpav_no_delete object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the Mapv_no_delete to. - * - * @param t a vecmap const reference to the Mapv_no_delete. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::Mapv_no_delete &t) { - return dump(dout, t); -} - -/** - * @brief Member function operator<< writes a Mapv object to the diagnostic - * writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the Mapv to. - * - * @param t a vecmap const reference to the Mapv. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::Mapv &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes a MapvNode object to the - * diagnostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the MapvNode to. - * - * @param t a MapvNode const reference to the MapvNode. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::MapvNode &t) { - return dump(dout, t); -} - -/** - * @brief Template function operator<< writes a vecmap of pointers object to - * the dignostic writer. - * - * @param dout a Writer reference to the diagnostic writer to - * write the vecmap of pointers to. - * - * @param t a vecmap const reference to the vecmap of pointers. - * - * @return a Writer reference to this object - */ -template -Writer &operator<<(Writer &dout, const sierra::vecmap &t) { - return dump(dout, t); -} - - -/// -/// @} -/// - -} // namespace diag -} // namespace stk_classic - -#endif // STK_UTIL_DIAG_WRITEREXT_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.cpp deleted file mode 100644 index b48429136b1a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -namespace stk_classic { -namespace diag { - -Writer &operator<<(Writer &dout, _setw set_width) { - if (dout.shouldPrint()) - dout.getStream().width(set_width.m_width); - return dout; -} - -Writer & -operator<<(Writer &dout, _setprecision set_precision) { - if (dout.shouldPrint()) - dout.getStream().precision(set_precision.m_precision); - return dout; -} - -Writer & -operator<<(Writer &dout, _setfill set_fill) { - if (dout.shouldPrint()) - dout.getStream().fill(set_fill.m_fill); - return dout; -} - -Writer & -operator<<(Writer &dout, _resetiosflags reset_flags) { - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::fmtflags(0), reset_flags.m_flags); - return dout; -} - -Writer & -operator<<(Writer &dout, _setiosflags set_flags) { - if (dout.shouldPrint()) - dout.getStream().setf(set_flags.m_flags); - return dout; -} - -Writer & -fixed( - Writer & dout) -{ - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::fixed, std::ios_base::floatfield); - return dout; -} - -Writer & -scientific( - Writer & dout) -{ - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::scientific, std::ios_base::floatfield); - return dout; -} - -Writer & -dec( - Writer & dout) -{ - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::dec, std::ios_base::basefield); - return dout; -} - -Writer & -hex( - Writer & dout) -{ - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::hex, std::ios_base::basefield); - return dout; -} - -Writer & -oct( - Writer & dout) -{ - if (dout.shouldPrint()) - dout.getStream().setf(std::ios_base::oct, std::ios_base::basefield); - return dout; -} - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.hpp deleted file mode 100644 index 2285be4903fc..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterManip.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_MANIP_HPP -#define STK_UTIL_DIAG_MANIP_HPP - -#include - -#include -#include - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup diag_writer_detail -/// @{ -/// - -/** - * @brief Class _setw is the width manipulator. - * - */ -struct _setw -{ - _setw(int width) - : m_width(width) - {} - - int m_width; -}; - -/** - * @brief Function setw sets the width for the next field as a manipulator. - * - * @param width a int value for the width of the next field. - * - */ -inline _setw setw(int width) { - return _setw(width); -} - -Writer &operator<<(Writer &dout, _setw set_width); - - -/** - * @brief Class _setprecision is the precision manipulator. - * - */ -struct _setprecision -{ - _setprecision(int precision) - : m_precision(precision) - {} - - int m_precision; -}; - -/** - * @brief Function setprecision sets the numeric precision as a manipulator. - * - * @param precision a int value of the precision. - * - */ -inline _setprecision setprecision(int precision) { - return _setprecision(precision); -} - -Writer &operator<<(Writer &dout, _setprecision set_precision); - - -/** - * @brief Class _setfill is the fill character manipulator. - * - */ -struct _setfill -{ - _setfill(char fill) - : m_fill(fill) - {} - - char m_fill; -}; - -/** - * @brief Function setfill sets the fill character as a manipulator. - * - * @param fill a char value of the fill character. - * - */ -inline _setfill setfill(char fill) { - return _setfill(fill); -} - -Writer &operator<<(Writer &dout, _setfill set_fill); - - -/** - * @brief Class _setiosflags is the flags manipulator. - * - */ -struct _setiosflags -{ - _setiosflags(std::ios_base::fmtflags flags) - : m_flags(flags) - {} - - std::ios_base::fmtflags m_flags; -}; - -/** - * @brief Function setiosflags sets the ios flags as a manipulator. - * - * @param flags a std::ios_base::fmtflags value of the flags. - * - */ -inline _setiosflags setiosflags(std::ios_base::fmtflags flags) { - return _setiosflags(flags); -} - -Writer &operator<<(Writer &dout, _setiosflags set_flags); - - -/** - * @brief Class _resetiosflags is the reset ios flags reset manipulator. - * - */ -struct _resetiosflags -{ - _resetiosflags(std::ios_base::fmtflags flags) - : m_flags(flags) - {} - - std::ios_base::fmtflags m_flags; -}; - -/** - * @brief Function resetiosflags clears the ios flags as a manipulator. - * - * @param flags a std::ios_base::fmtflags value of the flags. - * - */ -inline _resetiosflags resetiosflags(std::ios_base::fmtflags flags) { - return _resetiosflags(flags); -} - -Writer &operator<<(Writer &dout, _resetiosflags reset_flags); - -Writer &fixed(Writer &dout); -Writer &scientific(Writer &dout); -Writer &dec(Writer &dout); -Writer &hex(Writer &dout); -Writer &oct(Writer &dout); - -/// -/// @} -/// - -} // namespace diag -} // namespace stk_classic - -namespace sierra { -namespace Diag { - -using stk_classic::diag::setw; -using stk_classic::diag::setfill; -using stk_classic::diag::setprecision; - -} // namespace Diag -} // namespace sierra - -#endif // STK_UTIL_DIAG_MANIP_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterOStream.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterOStream.hpp deleted file mode 100644 index 6ff41c1bb650..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterOStream.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_WRITEROSTREAM_HPP -#define STK_UTIL_DIAG_WRITEROSTREAM_HPP - -#include - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup diag_writer_detail -/// @{ -/// - -/** - * @brief Function operator<< is the catch all std::ostream output put-to operator to - * Writer put-to operator. When using this, if you attempt to put and object that has no put-to - * operator to std::ostream, expect to get a list of all opt-to operator defined for the - * std::ostream. - * - * @param dout a Writer reference to the writer to put to. - * - * @param t a T const reference to the object to put. - * - */ -template -Writer &operator<<(Writer &dout, const T &t) { - if (dout.shouldPrint()) - dout.getStream() << t; - - return dout; -} - -/// -/// @} -/// - -} // namespace diag -} // namespace stk_classic - -#endif // STK_UTIL_DIAG_WRITEROSTREAM_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.cpp deleted file mode 100644 index a2f4b76157e4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.cpp +++ /dev/null @@ -1,101 +0,0 @@ - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace diag { - -WriterParser::WriterParser() - : OptionMaskParser() -{ - mask("coverage", 0, "Collect and display traceable function usage coverage"); - mask("members", LOG_MEMBERS, "Display data structure members messages"); - mask("trace", LOG_TRACE, "Display execution trace"); - mask("trace-stats", LOG_TRACE_STATS, "Display execution time and memory usage during trace"); - mask("trace-down", LOG_TRACE_SUB_CALLS, "Display subsequent calls after tracing is enabled"); -} - - -OptionMaskParser::Mask -WriterParser::parse( - const char * mask_string) const -{ - m_optionMask = LOG_MEMBERS; - return OptionMaskParser::parse(mask_string); -} - - -void -WriterParser::parseArg( - const std::string & name, - const std::string & arg) const -{ - if (name == "trace") { - m_optionMask |= LOG_TRACE; - if (!arg.empty()) { - std::string::const_iterator it0 = arg.begin(); - std::string::const_iterator it1; - std::string::const_iterator it2; - do { - // Trim preceeding spaces - while (it0 != arg.end() && *it0 == ' ') - it0++; - - if (it0 == arg.end()) - break; - - int paren_count = 0; - for (it1 = it0; it1 != arg.end(); ++it1) { - if (*it1 == '(') - ++paren_count; - else if (*it1 == ')') - --paren_count; - else if (*it1 == ',' && paren_count == 0) - break; - } - - - // Trim trailing spaces - it2 = it1; - while (it2 != it0 && *(it2 - 1) == ' ') - --it2; - - std::string function(it0, it2); - - Trace::addTraceFunction(function); - - it0 = it1 + 1; - } while (it1 != arg.end()); - } - else - m_optionMask |= LOG_TRACE_SUB_CALLS; - } - - else if (name == "coverage") { - Trace::enableCoverage(); - } - - else { - OptionMaskNameMap::const_iterator mask_entry = m_optionMaskNameMap.find(name.c_str()); - - if (mask_entry != m_optionMaskNameMap.end()) - m_optionMask |= (*mask_entry).second.m_mask; - else { - Mask mask_hex = 0; - std::istringstream mask_hex_stream(name.c_str()); - if (mask_hex_stream >> std::resetiosflags(std::ios::basefield) >> mask_hex) - m_optionMask |= mask_hex; - else - m_status = false; - } - } -} - -} // namespace diag -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.hpp deleted file mode 100644 index 104ed4b7bb6a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterParser.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef STK_UTIL_Diag_WriterParser_h -#define STK_UTIL_Diag_WriterParser_h - -#include - -namespace stk_classic { -namespace diag { - -/// -/// @addtogroup DiagWriterDetail -/// @{ -/// - -/** - * @brief Class WriterParser implements a parser a Writer PrintMask string. - * - */ -class WriterParser : public OptionMaskParser -{ -public: - /** - * @brief Typedef Mask bring the OptionMaskParser Mask definition into this - * namespace. - * - */ - typedef OptionMaskParser::Mask Mask; - -public: - /** - * @brief Creates a new WriterParser instance containing the lowerest - * level PrintMask names. - * - */ - WriterParser(); - - /** - * @brief Member function parse returns the mask which results from parsing the - * mask_string. - * - * @param mask_string a std::string const reference to the string to be - * parsed. - * - * @return a Mask value of the result from parsing the mask - * string. - */ - Mask parse(const char *mask_string) const; - - /** - * @brief Member function parseArg parses the argument and its argument - * values. - * - * @param name a std::string const reference to the argument - * name. - * - * @param arg a std::string const reference to the argument - * values. - */ - virtual void parseArg(const std::string &name, const std::string &arg) const; -}; - -/// -/// @} -/// - -} // namespace diag -} // namespace stk_classic - -namespace sierra { -namespace Diag { - -typedef stk_classic::diag::WriterParser WriterParser; - -} // namespace Diag -} // namespace sierra - -#endif // STK_UTIL_Diag_WriterParser_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.cpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.cpp deleted file mode 100644 index f3fe8a18ebbe..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -namespace sierra { -namespace Diag { - -WriterThrowSafe::WriterThrowSafe() -{ - for (Diag::WriterRegistry::iterator it = Diag::getWriterRegistry().begin(); it != Diag::getWriterRegistry().end(); ++it) - m_writerVector.push_back(new stk_classic::diag::WriterThrowSafe(*(*it).second.first)); -} - - -WriterThrowSafe::~WriterThrowSafe() -{ - for (std::vector::iterator it = m_writerVector.begin(); it != m_writerVector.end(); ++it) - delete (*it); -} - - -WriterRegistry::WriterRegistry() -{} - - -WriterRegistry::~WriterRegistry() -{} - - -WriterRegistry & -getWriterRegistry() -{ - static WriterRegistry s_writerRegistry; - - return s_writerRegistry; -} - - -void -registerWriter( - const std::string & name, - Writer & diag_writer, - OptionMaskParser & option_parser) -{ - getWriterRegistry().insert(std::make_pair(name, std::make_pair(&diag_writer, &option_parser))); -} - - -void -unregisterWriter( - const std::string & name, - Writer & writer) -{ - WriterRegistry::iterator it = getWriterRegistry().find(name); - if (it != getWriterRegistry().end() && (*it).second.first == &writer) - getWriterRegistry().erase(it); -} - -} // namespace Diag -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.hpp deleted file mode 100644 index c33308bb2bb6..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/WriterRegistry.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef STK_UTIL_DIAG_WriterRegsitry_h -#define STK_UTIL_DIAG_WriterRegsitry_h - -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace sierra { -namespace Diag { - -/// -/// @addtogroup DiagWriterDetail -/// @{ -/// - -/** - * @brief Typedef WriterRegistry is a mapping from name to diagnostic - * writer. - * - */ -class WriterRegistry : public std::map, stk_classic::LessCase> -{ -public: - WriterRegistry(); - - ~WriterRegistry(); -}; - -class WriterThrowSafe -{ -public: - WriterThrowSafe(); - - ~WriterThrowSafe(); - -private: - std::vector m_writerVector; -}; - -/** - * @brief Function getWriterRegistry returns a reference to the diagnostic - * writer registry. - * - * @return a WriterRegistry reference to the diagnostic writer - * registry. - */ -WriterRegistry &getWriterRegistry(); - -/** - * @brief Function registerWriter registers a diagnostic writer with the - * diagnostic writer registry. - * - * @param name a std::string const reference to the name to use for the - * diagnostic writer. - * - * @param diag_writer a Writer reference to the diagnostic writer. - * - */ -void registerWriter(const std::string &name, Writer &diag_writer, OptionMaskParser &option_parser); - -/** - * @brief Member function unregisterWriter unregisters a diagnostic writer - * from the diagnostic writer registry. - * - * @param name a std::string const reference to the name to use for the - * diagnostic writer. - * - * @param diag_writer a Writer reference to the diagnostic writer. - * - */ -void unregisterWriter(const std::string &name, Writer &diag_writer); - -/// -/// @} -/// - -} // namespace Diag -} // namespace sierra - -#include - -#endif // STK_UTIL_DIAG_WriterRegsitry_h - diff --git a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer_fwd.hpp b/packages/stk/stk_classic/stk_util/stk_util/diag/Writer_fwd.hpp deleted file mode 100644 index 7d7b5b16c52c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/diag/Writer_fwd.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_DIAG_WRITER_FWD_HPP -#define STK_UTIL_DIAG_WRITER_FWD_HPP - -namespace stk_classic { - -/// -/// @addtogroup diag_writer_detail -/// @{ -/// - -/** - * @brief Enumeration LogMask enumerates global bit assignments. - * - */ -enum LogMask { - LOG_ALWAYS = 0x00000000, - LOG_TRACE = 0x00000001, - LOG_TRACE_STATS = 0x00000002, - LOG_TRACE_SUB_CALLS = 0x00000004, - LOG_MEMBERS = 0x00000008, - - LOG_STREAM_COMMON = LOG_TRACE | LOG_TRACE_STATS, - LOG_PARAMETERS = 0x00000100 -}; - -/// -/// @} -/// - -namespace diag { - -class Writer; - -typedef unsigned long PrintMask; - -} // namespace diag -} // namespace stk_classic - -namespace sierra { - -enum LogMask { - LOG_ALWAYS = stk_classic::LOG_ALWAYS, - LOG_TRACE = stk_classic::LOG_TRACE, - LOG_TRACE_STATS = stk_classic::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = stk_classic::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = stk_classic::LOG_MEMBERS, - - LOG_STREAM_COMMON = stk_classic::LOG_STREAM_COMMON, - LOG_PARAMETERS = stk_classic::LOG_PARAMETERS -}; - -namespace Diag { - -typedef stk_classic::diag::Writer Writer; - -class PrintTable; - -typedef stk_classic::diag::PrintMask PrintMask; - -} // namespace Diag - -namespace Slib { -enum { - LOG_ALWAYS = sierra::LOG_ALWAYS, - LOG_TRACE = sierra::LOG_TRACE, - LOG_TRACE_STATS = sierra::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = sierra::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = sierra::LOG_MEMBERS, - - LOG_RESOURCE = 0x00000100, - LOG_PLUGIN = 0x00000200, - LOG_GLOBAL_VARIABLE = 0x00000400, - LOG_MEMORY = 0x00000800 -}; - -} // namespace Slib - -} // namespace sierra - - -#endif // STK_UTIL_DIAG_WRITER_FWD_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/.gitignore b/packages/stk/stk_classic/stk_util/stk_util/environment/.gitignore deleted file mode 100644 index 08b1b9c85b9e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -sierra_version.hpp -stk_version.hpp -version diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/environment/CMakeLists.txt deleted file mode 100644 index 93fc5a9462cb..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/..) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -CPUTime.hpp -Demangle.hpp -LogControl.hpp -OutputLog.hpp -ProductRegistry.hpp -ReportHandler.hpp -RuntimeDoomed.hpp -RuntimeMessage.hpp -RuntimeWarning.hpp -WallTime.hpp -FormatTime.hpp -FormatMemorySize.hpp - ) - -IF ( ${PACKAGE_NAME}_ENABLE_BoostLib ) - APPEND_SET(HEADERS ProgramOptions.hpp) -ENDIF() - -APPEND_SET(SOURCES -CPUTime.cpp -Demangle.cpp -LogControl.cpp -OutputLog.cpp -ProductRegistry.cpp -ReportHandler.cpp -RuntimeDoomed.cpp -RuntimeMessage.cpp -RuntimeWarning.cpp -WallTime.cpp -FormatTime.cpp -FormatMemorySize.cpp - ) - -IF ( ${PACKAGE_NAME}_ENABLE_BoostLib ) - APPEND_SET(SOURCES ProgramOptions.cpp) -ENDIF() - - -IF (${PACKAGE_NAME}_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_env - DEPLIBS stkclassic_util_util - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/environment/) diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.cpp deleted file mode 100644 index 09a6ab15e6d7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { - -double -cpu_time() -{ -#if defined(REDS) - struct rusage my_rusage; - - ::getrusage(RUSAGE_SELF, &my_rusage); - - double seconds = my_rusage.ru_utime.tv_sec; - double micro_seconds = my_rusage.ru_utime.tv_usec; - - return seconds + micro_seconds*1.0e-6; - -#else - struct rusage my_rusage; - - ::getrusage(RUSAGE_SELF, &my_rusage); - - double seconds = my_rusage.ru_utime.tv_sec + my_rusage.ru_stime.tv_sec; - double micro_seconds = my_rusage.ru_utime.tv_usec + my_rusage.ru_stime.tv_usec; - - return seconds + micro_seconds*1.0e-6; - -#endif -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.hpp deleted file mode 100644 index b8228daa3887..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/CPUTime.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_environment_CPUTime_hpp -#define stk_util_environment_CPUTime_hpp - -namespace stk_classic { - -/** - * @brief Member function cpu_time returns the accumulated cpu time for the process as a - * double precision value in seconds to "millisecond" accuracy. - * - * @return a double value of the accumulated process CPU runtime. - */ -double cpu_time(); - -} // namespace stk_classic - -#endif // stk_util_environment_CPUTime_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.cpp deleted file mode 100644 index 63c8f521aba4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#if __GNUC__ == 3 || __GNUC__ == 4 -#include -#endif - -// #if defined __xlC__ -// #include -// #endif - -namespace stk_classic { - -#ifdef STK_USE_PLATFORM_DEMANGLER - -#if defined(__GNUC__) - -#if (__GNUC__ == 3) -std::string -demangle( - const char * symbol) -{ -#ifdef PURIFY_BUILD - return symbol; -#else - std::string s; - int status = 0; - - char *demangled_symbol = abi::__cxa_demangle(symbol, 0, 0, &status); - - if (demangled_symbol) { - s = std::string(demangled_symbol); - free(demangled_symbol); - } - - if (status != 0) - s = std::string(symbol); - - return s; -#endif -} - -#elif (__GNUC__ == 4) -std::string -demangle( - const char * symbol) -{ -#ifdef PURIFY_BUILD - return symbol; -#else - std::string s; - - int status; - - char *demangled_symbol = __cxxabiv1::__cxa_demangle(symbol, 0, 0, &status); - - if (demangled_symbol) { - s = std::string(demangled_symbol); - free(demangled_symbol); - } - - if (status != 0) - s = std::string(symbol); - - return s; -#endif -} - -#endif // (__GNUC__ == 3) - -#elif defined __xlC__ -std::string -demangle( - const char * symbol) -{ - return symbol; -// #ifdef PURIFY_BUILD -// return symbol; -// #else -// char *rest; - -// Name *name = Demangle(symbol, rest) ; - -// std::string s(name ? name->Text() : symbol); - -// delete name; - -// return s; -// #endif -} - -#endif // defined __GNUC__ - -#else -const char *demangle(const char *symbol) { - return symbol; -} -#endif // STK_USE_PLATFORM_DEMANGLER - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.hpp deleted file mode 100644 index ce5be06650a0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/Demangle.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_environment_Demangle_hpp -#define stk_util_environment_Demangle_hpp - -#include - -#if __GNUC__ == 3 || __GNUC__ == 4 || defined __xlC__ -#define STK_USE_PLATFORM_DEMANGLER -#endif - -namespace stk_classic { - -/** - * @brief Function demangle returns the demangled C++ symbol from the mangled - * C++ symbol. The mangled named is obtained from the type_info - * name() function. From some compilers, the name is already demangled. - * - * @param symbol a char const pointer to the symbol. - * - * @return a std::string value of the demangled name. - */ -#ifdef STK_USE_PLATFORM_DEMANGLER -std::string demangle(const char *symbol); -#else -const char *demangle(const char *symbol); -#endif - -} // namespace stk_classic - -#endif // stk_util_environment_Demangle_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.cpp deleted file mode 100644 index c75809f5daab..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -namespace stk_classic { - -std::string -formatMemorySize( - double size) -{ - std::string result; - - static const double kb = 1024.0; - // static const double mb = kb * kb; - // static const double gb = kb * kb * kb; - - if (size < 0.0) { - result = "-"; - size = -size; - } - - // output size in kilo bytes - result += boost::lexical_cast(static_cast(size / kb)); - result += " KB"; - // if (size < kb) { - // // output size in bytes - // result += boost::lexical_cast(static_cast(size)); - // result += " B"; - // } - // else if (size < mb) { - // // output size in kilo bytes - // result += boost::lexical_cast(static_cast(size / kb)); - // result += " KB"; - // } - // else if (size < gb) { - // // output size in mega bytes - // result += boost::lexical_cast(static_cast(size / mb)); - // result += " MB"; - // } - // else { - // // everything else output in giga bytes - // result += boost::lexical_cast(static_cast(size / gb)); - // result += " GB"; - // } - - return result; -} - - -std::string -formatMemorySize( - MemorySize size) -{ - std::string result; - - static const MemorySize kb = 1024; - // static const MemorySize mb = kb * kb; - // static const MemorySize gb = kb * kb * kb; - - // output size in kilo bytes - result = boost::lexical_cast(size / kb); - result += " KB"; - - // if (size < kb) { - // // output size in bytes - // result = boost::lexical_cast(size); - // result += " B"; - // } - // else if (size < mb) { - // // output size in kilo bytes - // result = boost::lexical_cast(size / kb); - // result += " KB"; - // } - // else if (size < gb) { - // // output size in mega bytes - // result = boost::lexical_cast(size / mb); - // result += " MB"; - // } - // else { - // // everything else output in giga bytes - // result = boost::lexical_cast(size / gb); - // result += " GB"; - // } - - return result; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.hpp deleted file mode 100644 index 7dc1f070e9b2..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatMemorySize.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_environment_FormatMemorySize_hpp -#define stk_util_environment_FormatMemorySize_hpp - -#include - -namespace stk_classic { - -typedef size_t MemorySize; - -std::string formatMemorySize(double time); -std::string formatMemorySize(MemorySize time); - -} // namespace stk_classic - -#endif // stk_util_environment_FormatMemorySize_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.cpp deleted file mode 100644 index 836ebbb2ddd0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include - -namespace stk_classic { - -std::string -formatTime( - double time, - TimeFormat time_format) -{ - std::stringstream oss; - - if (time < 0.0) { - time = -time; - oss << "-"; - } - - if ((time_format & TIMEFORMAT_STYLE_MASK) == TIMEFORMAT_SECONDS) { - if (time_format & TIMEFORMAT_MILLIS) - oss << std::fixed << std::setprecision(3) << time; - else - oss << std::fixed << std::setprecision(0) << time; - } - else if ((time_format & TIMEFORMAT_STYLE_MASK) == TIMEFORMAT_HMS) { - int int_time = int(time); - - if (time >= 3600.0) - oss << (int_time)/3600 << ':' - << std::setw(2) << std::setfill('0') << (int_time/60)%60 << ':' - << std::setw(2) << std::setfill('0') << int_time%60; - - else if (time >= 60.0) - oss << ((int) (time)/60)%60 << ':' - << std::setw(2) << std::setfill('0') << int_time%60; - - - else - oss << ((int) time)%60; - - if (time_format & TIMEFORMAT_MILLIS) { - int milliseconds = int(std::fmod(time, 1.0)*1000.0 + 0.5); - - oss << '.' << std::setw(3) << std::setfill('0') << milliseconds; - } - } - else - oss << time; - - return oss.str(); -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.hpp deleted file mode 100644 index 9cb26cfd62cc..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/FormatTime.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_environment_FormatTime_hpp -#define stk_util_environment_FormatTime_hpp - -#include - -namespace stk_classic { - -typedef unsigned long TimeFormat; - -enum { - TIMEFORMAT_NONE = 0x00, - TIMEFORMAT_HMS = 0x01, - TIMEFORMAT_SECONDS = 0x02, - TIMEFORMAT_STYLE_MASK = 0x0F, - - TIMEFORMAT_MILLIS = 0x10 -}; - -std::string formatTime(double time, TimeFormat time_format = TIMEFORMAT_HMS | TIMEFORMAT_MILLIS); - -} // namespace stk_classic - -#endif // stk_util_environment_FormatTime_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.cpp deleted file mode 100644 index 600eed6076e5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { - -namespace { - -typedef std::map OStreamLogControlMap; - -OStreamLogControlMap & -get_ostream_log_control_map() -{ - static OStreamLogControlMap s_ostreamLogControlMap; - - return s_ostreamLogControlMap; -} - -} // namespace - - -LogControlRuleInterval::LogControlRuleInterval( - int interval) - : m_interval(interval), - m_count(-1) -{} - - -bool -LogControlRuleInterval::next() -{ - ++m_count; - - if (m_count < 0) { - return false; - } - - else if (m_count == 0) { - return true; - } - - else { - return m_count%m_interval == 0 ? true : false; - } -} - - -LogControl::LogControl( - std::ostream & log_ostream, - const LogControlRule & rule) - : m_parent(0), - m_rule(rule.clone()), - m_state(ON), - m_logStream(log_ostream), - m_logStreambuf(log_ostream.rdbuf()), - m_cacheStream() -{ - OStreamLogControlMap &ostream_log_control_map = get_ostream_log_control_map(); - - // Append this as tail of linked list of LogControl's sharing this ostream. - m_parent = ostream_log_control_map[&m_logStream]; - ostream_log_control_map[&m_logStream] = this; - - // Make sure log stream buffer is that of the root's. - for (LogControl *parent = m_parent; parent != 0; parent = parent->m_parent) - m_logStreambuf = parent->m_logStream.rdbuf(); -} - - -// LogControl::LogControl( -// std::ostream & log_ostream, -// const std::string & rule_name) -// : m_parent(0), -// m_rule(get_rule_map().getLogControlRule(rule_name)->clone()), -// m_state(ON), -// m_logStream(log_ostream), -// m_logStreambuf(log_ostream.rdbuf()), -// m_cacheStream() -// { -// OStreamLogControlMap &ostream_log_control_map = get_ostream_log_control_map(); - -// // Append this as tail of linked list of LogControl's sharing this ostream. -// m_parent = ostream_log_control_map[&m_logStream]; -// ostream_log_control_map[&m_logStream] = this; -// } - - -LogControl::~LogControl() -{ - OStreamLogControlMap &ostream_log_control_map = get_ostream_log_control_map(); - - // Reset tail pointer to this's parent. - ostream_log_control_map[&m_logStream] = m_parent; - - // Reset log stream to either the parent's cache or the original log stream buffer. And, - // concatenate cached text to the parent's cache or log stream. - if (!m_parent || m_parent->m_state == ON) { // Parent is writing - m_logStream.rdbuf(m_logStreambuf); // Set output stream back to real buffer - if (m_state == CACHE) // This is caching - m_logStream << m_cacheStream.str(); // Last cache is always written - } - else { // Parent is caching - m_logStream.rdbuf(m_parent->m_cacheStream.rdbuf()); // Set output to parent's cache - m_parent->m_cacheStream << m_cacheStream.str(); // Append our cache to parent's - } - - delete m_rule; -} - - -void -LogControl::fail() -{ - m_logStream.rdbuf(m_logStreambuf); - m_logStream << m_cacheStream.str(); - m_cacheStream.str(""); - m_state = ON; -} - - -void -LogControl::next() -{ - m_cacheStream.str(""); - - if (m_parent && m_parent->m_state == CACHE) - m_state = CACHE; - else - m_state = !m_rule || m_rule->next() ? ON : CACHE; - - if (m_state != CACHE) { - if (m_logStream.rdbuf() != m_logStreambuf) { - m_logStream.rdbuf(m_logStreambuf); - } - } - else { - if (m_logStream.rdbuf() != m_cacheStream.rdbuf()) - m_logStream.rdbuf(m_cacheStream.rdbuf()); - } -} - - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.dox b/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.dox deleted file mode 100644 index cd6e9149d77d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.dox +++ /dev/null @@ -1,114 +0,0 @@ -/// -/// \addtogroup stk_util_log_control_detail -/// @{ -/// -/// @brief Log control provides a mechanism reduce excessive log file output. -/// -/// During some runs, particularly explicit codes, writing to the log file generates excessive -/// output that is not needed. Once method of trimming this output is to only send it to the log -/// file at a specified interval. The LogControl subsystem provides a mechanism for the developer -/// to provide simple output rule and the user to specify the rule to control the desired output. -/// -/// The LogControl subsystem does this by directing the output to the log file stream buffer or -/// redirecting it to an in memory stream based on the evaluation of the rule. This in memory -/// stream can be discarded or can later be written to the log file if an error condition arises. -/// -/// By usong this technique, the statements which currently write to the log file are not effected -/// and if the system is not activated, the normal output is produced. -/// -/// \anchor stk_util_log_control_howto_control_output -/// \section stk_util_log_control_control_output Log Control Sentry -/// -/// A sentry class, LogControl takes an output stream and a rule as an argument. When the -/// LogControl's next() function is called, the output stream is directed to write to the log file -/// or to the cache based on the result of the evaluation of the rule. -/// -/// In the following example, the construction of the LogControl sentry stores the sierra::out() -/// stream, its stream buffer, and the rule associated with the m_name. A cache ostringstream is -/// also created to cache the potentially discarded output. Each time the log_control's next() -/// function is called, the rule is evaluated and the results determine which stream buffer to -/// attach to the sierra::out() stream; either sierra::out()'s original if the rule returns true or -/// the cache's. The previously cached text is discarded at each next() execution. -/// -/// If the execution fails, the cached stream buffer is written to the original output stream and -/// the cache is cleared. -/// -/// \code -/// -/// stk_classic::LogControl log_control(sierra::out(), m_name); -/// -/// while (!done) { -/// . -/// . -/// . -/// log_control.next(); -/// -/// try { -/// . -/// . -/// . -/// } -/// catch (std::exception &x) { -/// log_control.fail(); -/// } -/// } -/// -/// \endcode -/// -/// The LogControl's maintain a link to the parent LogControl for each stream. Therefore, each -/// shares the same log stream and original log stream buffer. On construction, the root LogControl -/// has the original stream buffer of the log stream, so the root's log stream buffer pointer is -/// copied to new LogControl sentry. On destruction, since the log streams are all shared, the -/// log stream must have it's stream buffer replaced with the original log stream or it's cache -/// stream depending upon it current state. -/// -/// \anchor stk_util_log_control_howto_rules -/// \section stk_util_log_control_register_rules Log Control Rules -/// -/// The logging or caching of a log stream is determined by a log rule. A log rule class consists -/// of a clone() function and a next() function and inherit from LogControlRule. -/// -/// \code -/// -/// struct LogControlRule -/// { -/// virtual LogControlRule *clone() const = 0; -/// virtual bool next() = 0; -/// }; -/// -/// \endcode -/// -/// The clone() pure virtual function allows the rule to be copied. And is implemented as -/// -/// \code -/// virtual LogControlRule *clone() const { -/// return new MyRuleClass(*this); -/// } -/// \endcode -/// -/// The next() function is used to determine the destination of the output stream. If the next -/// function returns true, the log stream write to its original stream buffer, which is generally -/// the log file. When it returns false, the output is written to the current log control sentry's -/// cache stream. -/// -/// \anchor stk_util_log_control_howto_rules -/// \section stk_util_log_control_rules Predefined Log Control Rules -/// -/// The LogControlRuleAlways and LogControlRuleInteval rules are predefined. The -/// LogControlRuleAlways' next() function always returns true resulting the output always going to -/// the log file. The LogControlRuleInteval is constructed with an interval and maintains a count. -/// The LogControlRuleInteval's next() function increments the count and returns true of the count -/// mod interval is zero. -/// -/// -/// \anchor stk_util_log_control_howto_rules_registration -/// \section stk_util_log_control_rules_registration Log Control Rule Registration -/// -/// To simplify the usage of rules, the LogControl subsystem maintains a mapping of named rules. -/// These rules are copied during the construction of the LogControl sentries when they are -/// constructed by passing a rule name. -/// -/// The addLogControlRule() function adds the rule to the map with specifed name. -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.hpp deleted file mode 100644 index ec2a7aa7ada4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/LogControl.hpp +++ /dev/null @@ -1,263 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_LOGCONTROL_HPP -#define STK_UTIL_ENVIRONMENT_LOGCONTROL_HPP - -#include -#include -#include -#include - -#include - -namespace stk_classic { - -/** - * @brief Interface LogControlRule describes the interface to a log control rule. - * - */ -struct LogControlRule -{ - /** - * Destroys a LogControlRule instance. - * - */ - virtual ~LogControlRule() - {} - - /** - * @brief Member function clone creates a clone of the rule. - * - * @return a LogControlRule pointer to newly created duplicate. - */ - virtual LogControlRule *clone() const = 0; - - /** - * @brief Member function next returns true if the log stream should write to the log - * file, and false if the log stream should write to the cache. - * - * @return a bool value of true if the log stream should write to - * the log file, and false if the log stream should write to the cache. - */ - virtual bool next() = 0; -}; - - -/** - * @brief Class LogControlRuleAlways is a log control rule that always wants to write to the log - * file. - * - */ -struct LogControlRuleAlways : public LogControlRule -{ - /** - * Destroys a LogControlRuleAlways instance. - * - */ - virtual ~LogControlRuleAlways() - {} - - /** - * Creates a new LogControlRuleAlways instance. - * - */ - LogControlRuleAlways() - {} - - /** - * @brief Member function clone creates a duplicate LogControlRuleAlways object. - * - * @return a LogControlRule pointer to the new duplicated always object. - */ - virtual LogControlRule *clone() const { - return new LogControlRuleAlways(*this); - } - - /** - * @brief Member function next returns true to indicate that the log stream should - * write to the log file. - * - * @return a bool returns true to indicate that the log stream - * should write to the log file. - */ - virtual bool next() { - return true; - } -}; - - -struct LogControlRuleInterval : public LogControlRule -{ - /** - * Creates a new LogControlRuleInterval instance. - * - * @param interval an int interval to enable log output. - * - */ - LogControlRuleInterval(int interval); - - /** - * Destroys a LogControlRuleInterval instance. - * - */ - virtual ~LogControlRuleInterval() - {} - - /** - * @brief Member function clone creates a duplicate LogControlRuleAlways object. - * - * @return a LogControlRule pointer to the new duplicated always object. - */ - virtual LogControlRule *clone() const { - return new LogControlRuleInterval(*this); - } - - /** - * @brief Member function next returns true when the current count modulo the interval is zero. - * whichs indicate that the log stream should write to the log file. - * - * @return a bool returns true when the current count modulo the - * interval is zero. whichs indicate that the log stream should write - * to the log file. - */ - virtual bool next(); - -private: - int m_interval; - int m_count; -}; - - -class RuleMap -{ -public: - typedef std::map Map; - - RuleMap() - : m_ruleMap() - {} - - ~RuleMap() { - for (Map::iterator it = m_ruleMap.begin(); it != m_ruleMap.end(); ++it) - delete (*it).second; - } - - void addLogControlRule(const std::string &rule_name, const LogControlRule &rule) { - Map::iterator it = m_ruleMap.find(rule_name); - if (it != m_ruleMap.end()) - m_ruleMap.erase(it); - - m_ruleMap[rule_name] = rule.clone(); - } - - LogControlRule *getLogControlRule(const std::string &rule_name) { - Map::iterator it = m_ruleMap.find(rule_name); - - if (it != m_ruleMap.end()) - return (*it).second; - - else { - std::pair result = m_ruleMap.insert(Map::value_type(rule_name, new LogControlRuleAlways)); - return (*result.first).second; - } - } - -private: - Map m_ruleMap; -}; - - -/** - * @brief Enumeration State describes the current state of the caching for this - * controller. - * - */ -enum State { - ON, ///< Output is to be written to the log stream - CACHE ///< Output is to be written to the cache stream -}; - -/** - * @brief Class LogControl provides a mechanism for reducing excessive output. The - * output is redirected to a cache where it can be written to the log stream where and error - * condition arises. - * - * The controlling of the log stream is handled by creating a sentry which controls the stream - * buffer of the specified stream using the specified rule. The next() function executes the rule - * and redirects the output to the log stream when the rule is true and to the cache when the rule - * is false. - * - * LogControl sentries can be nested. When nested, the current rule is if the parent is caching, - * then child is forced to cache. This behavior could change by passing parent state to next(). - * - * It's important to note that LogControl sentries nearly always shared the same output stream. So - * the parent's original output stream buffer - */ -class LogControl -{ -public: - /** - * Creates a new LogControl instance. - * - * @param log_stream a std::ostream reference to the log stream to control. - * - * @param rule a LogControlRule reference to the rule used to control the log - * stream. - * - */ - LogControl(std::ostream &log_stream, const LogControlRule &rule); - - /** - * Creates a new LogControl instance. - * - * @param log_stream a std::ostream reference to the log stream to control. - * - * @param rule_name a std::string constant reference to rule name used to - * control the log stream. - */ - LogControl(std::ostream &log_stream,const std::string &rule_name); - - /** - * Destroys a LogControl instance. - * - */ - ~LogControl(); - - /** - * @brief Member function next executes the rule and sets the log stream to write to - * the log file if true and to the cache if false. - * - */ - void next(); - - /** - * @brief Member function fail writes the cached output to the log stream due to an - * error. - * - */ - void fail(); - -private: - LogControl * m_parent; ///< Parent stream - LogControlRule * m_rule; ///< Rule to evaluate log destination - - State m_state; ///< Current caching state - - std::ostream & m_logStream; ///< Log stream under control - std::streambuf * m_logStreambuf; ///< Log stream original stream buffer - std::ostringstream m_cacheStream; ///< Cache stream - - // Do not implement... - LogControl(const LogControl&); - LogControl & operator = (const LogControl&); -}; - -} // namespace stk_classic - -#endif // STK_UTIL_ENVIRONMENT_LOGCONTROL_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.cpp deleted file mode 100644 index 884bdd8bee86..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.cpp +++ /dev/null @@ -1,700 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stk_classic { - -namespace { - -struct LogStream -{ - LogStream(const std::string &path, std::ostream *output_stream, std::ofstream *file_stream) - : m_path(path), - m_ostream(output_stream), - m_ofstream(file_stream) - {} - - ~LogStream(); - - std::string m_path; - std::ostream * m_ostream; - std::ofstream * m_ofstream; - - private: - LogStream(const LogStream &); - void operator = (const LogStream &); -}; - -#ifdef __INTEL_COMPILER -#pragma warning(push) -#pragma warning(disable: 444) -#endif -struct LogStreamMap : public std::map -{ - LogStreamMap() - {} - - ~LogStreamMap() { - while (!empty()) { - LogStream *log_stream = (*begin()).second; - erase(begin()); - delete log_stream; - } - } -}; -#ifdef __INTEL_COMPILER -#pragma warning(pop) -#endif - -struct OStreamTeeStreambuf -{ - OStreamTeeStreambuf(std::ostream &output_stream) - : m_ostream(&output_stream), - m_origRdbuf(output_stream.rdbuf()), - m_teeStreambuf(new tee_streambuf(&output_stream)) - { - m_ostream->rdbuf(m_teeStreambuf); - } - - ~OStreamTeeStreambuf(); - - std::ostream * m_ostream; - std::streambuf * m_origRdbuf; - tee_streambuf * m_teeStreambuf; - - private: - OStreamTeeStreambuf(const OStreamTeeStreambuf &); - void operator = (const OStreamTeeStreambuf &); -}; - -#ifdef __INTEL_COMPILER -#pragma warning(push) -#pragma warning(disable: 444) -#endif -struct OStreamTeeStreambufMap : public std::map -{ - OStreamTeeStreambufMap() - {} - - ~OStreamTeeStreambufMap() { - while (!empty()) { - OStreamTeeStreambuf *tee_streambuf = (*begin()).second; - erase(begin()); - delete tee_streambuf; - } - } -}; -#ifdef __INTEL_COMPILER -#pragma warning(pop) -#endif - -LogStreamMap & -get_file_stream_map() -{ - static LogStreamMap s_logFileStreamMap; - - return s_logFileStreamMap; -} - - -OStreamTeeStreambufMap & -get_ostream_tee_streambuf_map() -{ - static OStreamTeeStreambufMap s_ostreamTeeStreambufMap; - - return s_ostreamTeeStreambufMap; -} - - -LogStream::~LogStream() -{ - m_ostream->flush(); - - // If the output stream was created internally (via bind_output_stream), be sure to remove it from - // all OStreamTeeStreamBuf's - if (m_ofstream) { - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - for (OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.begin(); it != ostream_tee_streambuf_map.end(); ++it) - (*it).second->m_teeStreambuf->remove(m_ofstream); - - delete m_ofstream; - } -} - - -OStreamTeeStreambuf::~OStreamTeeStreambuf() -{ - if (m_ostream) { - m_ostream->flush(); - m_ostream->rdbuf(m_origRdbuf); - } - - // Be sure to remove this from all OStreamTeeStreamBuf's - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - for (OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.begin(); it != ostream_tee_streambuf_map.end(); ++it) - (*it).second->m_teeStreambuf->remove(m_ostream); - - delete m_teeStreambuf; -} - -} // namespace - - -void -create_log_file( - const std::string & name, - const std::string & path) -{ - LogStreamMap &file_stream_map = get_file_stream_map(); - - close_log_file(name); - - std::ofstream *file_stream = new std::ofstream(path.c_str()); - - if(!file_stream->good()) { - - std::ostringstream s; - s << "Cannot open output log file '" << path << "' directory does not exist or is write protected."; - - throw std::runtime_error(s.str()); - - } - - - file_stream_map[name] = new LogStream(path, file_stream, file_stream); -} - - -void -close_log_file( - const std::string & name) -{ - LogStreamMap &file_stream_map = get_file_stream_map(); - - LogStreamMap::iterator it = file_stream_map.find(name); - - if (it != file_stream_map.end()) { - delete (*it).second; - file_stream_map.erase(it); - } -} - - -void -register_log_ostream( - std::ostream & os, - const std::string & name) -{ - LogStreamMap &file_stream_map = get_file_stream_map(); - - LogStreamMap::iterator it = file_stream_map.find(name); - - if (it != file_stream_map.end()) { - std::ostringstream s; - s << "Log ostream " << name << " has already been registered"; - - //Do we really want to throw if a stream is registered multiple times? - //I don't think so... commenting this out. - //throw std::runtime_error(s.str()); - } - else { - file_stream_map[name] = new LogStream(name, &os, 0); - } -} - - -void -unregister_log_ostream( - std::ostream & os) -{ - LogStreamMap &file_stream_map = get_file_stream_map(); - - for (LogStreamMap::iterator it = file_stream_map.begin(); it != file_stream_map.end(); ++it) { - if ((*it).second->m_ostream == &os) { - delete (*it).second; - file_stream_map.erase(it); - break; - } - } - - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - for (OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.begin(); it != ostream_tee_streambuf_map.end(); ++it) - (*it).second->m_teeStreambuf->remove(&os); -} - - -const std::string & -get_log_path( - const std::string & name) -{ - static std::string not_found = ""; - - LogStreamMap &file_stream_map = get_file_stream_map(); - - LogStreamMap::iterator it = file_stream_map.find(name); - - return it == file_stream_map.end() ? not_found : (*it).second->m_path; -} - - -std::ostream * -get_log_ostream( - const std::string & name) -{ - LogStreamMap &file_stream_map = get_file_stream_map(); - - LogStreamMap::iterator it = file_stream_map.find(name); - - return it == file_stream_map.end() ? 0 : (*it).second->m_ostream; -} - - -void -register_ostream( - std::ostream & os, - const std::string & name) -{ - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - unregister_ostream(os); - - OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.find(name); - - if (it != ostream_tee_streambuf_map.end()) { -// delete (*it).second; -// ostream_tee_streambuf_map.erase(it); -// } - std::ostringstream s; - s << "Output stream " << name << " has already been registered"; - - throw std::runtime_error(s.str()); - } - - ostream_tee_streambuf_map[name] = new OStreamTeeStreambuf(os); -} - - -void -unregister_ostream( - std::ostream & os) -{ - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - for (OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.begin(); it != ostream_tee_streambuf_map.end(); ++it) - (*it).second->m_teeStreambuf->remove(&os); - - for (OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.begin(); it != ostream_tee_streambuf_map.end(); ++it) { - if ((*it).second->m_ostream == &os) { - delete (*it).second; - ostream_tee_streambuf_map.erase(it); - break; - } - } - -} - - -std::ostream * -get_ostream_ostream( - const std::string & name) -{ - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.find(name); - - return it == ostream_tee_streambuf_map.end() ? 0 : (*it).second->m_ostream; -} - - -tee_streambuf * -get_ostream_tee_streambuf( - const std::string & name) -{ - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.find(name); - - return it == ostream_tee_streambuf_map.end() ? 0 : (*it).second->m_teeStreambuf; -} - - -std::ostream * -get_ostream_tee_ostream( - const std::string & name) -{ - OStreamTeeStreambufMap &ostream_tee_streambuf_map = get_ostream_tee_streambuf_map(); - - OStreamTeeStreambufMap::iterator it = ostream_tee_streambuf_map.find(name); - - return it == ostream_tee_streambuf_map.end() ? 0 : (*it).second->m_ostream; -} - - -bool -is_registered_ostream( - const std::string & name) -{ - return get_ostream_ostream(name) != 0; -} - - -namespace { - -struct Command -{ - virtual ~Command() - {} - - virtual void execute() = 0; -}; - -#ifdef __INTEL_COMPILER -#pragma warning(push) -#pragma warning(disable: 444) -#endif -struct CommandList : public std::list -{ - CommandList() - : std::list() - {} - - ~CommandList() - { - for (std::list::iterator it = begin(); it != end(); ++it) - delete (*it); - } -}; -#ifdef __INTEL_COMPILER -#pragma warning(pop) -#endif - -namespace { - -tee_streambuf & -parse_tee_streambuf( - const std::string & tee_ostream_name) -{ - tee_streambuf *osb = get_ostream_tee_streambuf(tee_ostream_name); - - if (!osb) { - std::ostringstream s; - - s << "Output stream " << tee_ostream_name << " has not been registered for output logging"; - throw std::runtime_error(s.str()); - } - - return *osb; -} - - -std::ostream * -parse_ostream( - const std::string & ostream_name) -{ - std::ostream *os = get_log_ostream(ostream_name); - - if (!os) - os = get_ostream_tee_ostream(ostream_name); - - if (!os) { - std::ostringstream s; - - s << "Log file '" << ostream_name << "' has not been registered"; - throw std::runtime_error(s.str()); - } - - return os; -} - - -struct OpenLog : public Command -{ - OpenLog( - const std::string &name, - const std::string &path) - : m_name(name), - m_path(path) - {} - - virtual ~OpenLog() - {} - - virtual void execute() { - create_log_file(m_name, m_path); - } - - std::string m_name; - std::string m_path; -}; - - -struct CloseLog : public Command -{ - CloseLog( - const std::string &name) - : m_name(name) - {} - - virtual ~CloseLog() - {} - - virtual void execute() { - close_log_file(m_name); - } - - std::string m_name; -}; - - -struct ClearTeeOStream : public Command -{ - ClearTeeOStream( - const std::string & tee_ostream_name) - : m_teeOStreamName(tee_ostream_name) - {} - - virtual ~ClearTeeOStream() - {} - - virtual void execute() { - parse_tee_streambuf(m_teeOStreamName).clear(); - } - - std::string m_teeOStreamName; -}; - - -struct AddTeeOStream : public Command -{ - AddTeeOStream( - const std::string & tee_ostream_name, - const std::string & ostream_name) - : m_teeOStreamName(tee_ostream_name), - m_ostreamName(ostream_name) - {} - - virtual ~AddTeeOStream() - {} - - virtual void execute() { - if (m_ostreamName != "null") - parse_tee_streambuf(m_teeOStreamName).add(parse_ostream(m_ostreamName)); - } - - std::string m_teeOStreamName; - std::string m_ostreamName; -}; - - -struct RemoveTeeOStream : public Command -{ - RemoveTeeOStream( - const std::string & tee_ostream_name, - const std::string & ostream_name) - : m_teeOStreamName(tee_ostream_name), - m_ostreamName(ostream_name) - {} - - virtual ~RemoveTeeOStream() - {} - - virtual void execute() { - parse_tee_streambuf(m_teeOStreamName).remove(parse_ostream(m_ostreamName)); - } - - std::string m_teeOStreamName; - std::string m_ostreamName; -}; - -} // namespace - - -/* - * Startup: out > cout pout > cout dout > cout - * Normal: out > log-path+pout pout > null dout > out - * Diagnostic: out > out-path+pout pout > pout-path dout > out - * - * Modify: out > +pout - * out > -pout - */ -void -parse_output_description( - const std::string & output_description, - CommandList & command_list) -{ - typedef std::pair Token; - typedef std::list TokenList; - - command_list.clear(); - - TokenList tokens; - - for (const char *c = output_description.c_str(); *c; ) { - if (std::isspace(*c)) - ++c; - - else if (*c == '>' || *c == '+' || *c == '-' || *c == '=') { - tokens.push_back(Token(c, c + 1)); - ++c; - } - - else if (*c == '\"') { - const char *d = c + 1; - while (*d && *d != '\"') - ++d; - tokens.push_back(Token(c + 1, d)); - c = d + 1; - } - - else { - const char *d = c; - while (std::isgraph(*d) && *d != '+' && *d != '-' &&*d != '=' && *d != '>') - ++d; - tokens.push_back(Token(c, d)); - c = d; - } - } - - for (TokenList::iterator it = tokens.begin(); it != tokens.end(); ) { - std::string name((*it).first, (*it).second); - - ++it; if (it == tokens.end()) break; - std::string operation((*it).first, (*it).second); - - if (operation == "=") { - ++it; if (it == tokens.end()) break; - std::string path((*it).first, (*it).second); - if (!path.empty()) - command_list.push_back(new OpenLog(name, path)); - else - command_list.push_back(new CloseLog(name)); - ++it; if (it == tokens.end()) break; - } - - else if (operation == ">") { - parse_tee_streambuf(name); - - ++it; if (it == tokens.end()) break; - std::string token(std::string((*it).first, (*it).second)); - if (token != "+" && token != "-") { - std::string ostream_name(std::string((*it).first, (*it).second)); - - command_list.push_back(new ClearTeeOStream(name)); - command_list.push_back(new AddTeeOStream(name, ostream_name)); - ++it; if (it == tokens.end()) break; - } - - while (it != tokens.end()) { - token = std::string((*it).first, (*it).second); - if (token == "+") { - ++it; if (it == tokens.end()) break; - std::string ostream_name(std::string((*it).first, (*it).second)); - - command_list.push_back(new AddTeeOStream(name, ostream_name)); - ++it; if (it == tokens.end()) break; - } - - else if (token == "-") { - ++it; if (it == tokens.end()) break; - std::string ostream_name(std::string((*it).first, (*it).second)); - - command_list.push_back(new RemoveTeeOStream(name, ostream_name)); - ++it; if (it == tokens.end()) break; - } - else - break; - } - } - } -} - -void -execute( - const CommandList & command_list) -{ - for (CommandList::const_iterator it = command_list.begin(); it != command_list.end(); ++it) - (*it)->execute(); -} - -} // namespace - -void -bind_output_streams( - const std::string & output_description) -{ - stk_classic::CommandList command_list; - - parse_output_description(output_description, command_list); - execute(command_list); -} - -} // namespace stk_classic - -namespace sierra { - -std::ostream & -out() { - static std::ostream s_out(std::cout.rdbuf()); - - return s_out; -} - - -std::ostream & -pout() { - static std::ostream s_pout(std::cout.rdbuf()); - - return s_pout; -} - - -std::ostream & -dout() { - static std::ostream s_dout(std::cout.rdbuf()); - - return s_dout; -} - - -std::ostream & -tout() { - static std::ostream s_tout(std::cout.rdbuf()); - - return s_tout; -} - - -std::ostream & -dwout() { - static stk_classic::indent_streambuf s_dwoutStreambuf(std::cout.rdbuf()); - static std::ostream s_dwout(&s_dwoutStreambuf); - - return s_dwout; -} - -} // namespace sierra - - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.dox b/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.dox deleted file mode 100644 index 5a4173b961e0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.dox +++ /dev/null @@ -1,442 +0,0 @@ -/// -/// \addtogroup stk_util_output_log_detail -/// @{ -/// -/// @brief Output logging is responsible for connecting program's output streams (sierra::out(), -/// sierra::pout(), any std::ostream) to output log files (a disk file, stdout, etc). -/// -/// Output streams are std::ostream's that the developer's write logging information to within the -/// source code. Developers register the program's output stream using the register_ostream() -/// functions. Log streams are files or streams which are the destinations of those output streams. -/// -/// Log files each have a name and an std::ostream, and optionally a file path and std::ofstream. -/// Developers create log files using the create_log_file() or register_log_ostream() functions. -/// The create_log_file() function opens an std::ofstream to a file with the specified path and -/// inserts it into the log stream map using the name as the key. The register_log_ostream() -/// function registers a log stream using the the name as the key. -/// -/// The output streams are bound to log files passing a description string to the -/// bind_output_streams() function or by getting the streambuf's using the -/// get_ostream_tee_streambuf() function and adding and removing streams. By binding output streams -/// to log streams, the developer can control the destination of the data written to by any output -/// stream. Multiple log files may be bound to the same output stream and may be bound to multiple -/// output streams. Other registered output streams may also be destinations. -/// -/// This binding feature provides the developer with a great deal of output logging control with very -/// little programming effort. -/// -/// For example, if the developer creates a normal output stream, a diagnostic output stream and a -/// single log file, he can configure the normal output stream to go to the log file and the -/// diagnostic output stream to go to the bit bucket. If dire circumstances should arise, the -/// diagnostic output stream could be bound to the output stream, and from that point forward, the -/// diagnostic data would be properly interleaved with the normal output log. -/// -/// Another example for use with parallel systems, is to create a normal log file and a -/// per-processor log file. Processor zero's (0) normal output stream writes to the normal log file -/// and to its per-processor log file. The remaining processors each write to there per-processor -/// log file and diagnostic streams write to the per-processor log file. This provides detailed, -/// interleaved diagnostic for each processor for the developer to examine and normal looking output -/// for the analyst to view. -/// -/// This output logging scheme in tandem with the diagnostic writer selectable output provides the -/// developer with significant detailed output control with minimal coding and processing overhead. -/// -/// \anchor stk_util_output_log_howto_register_streams -/// \section stk_util_output_log_stream_registration Register Application Output Streams -/// -/// The program's output streams must be named and registered to participate in the output log -/// binding. For general parallel use, three streams are created, a regular output stream, out; a -/// per-processor output stream, pout; and a diagnostic output stream, dout. These can be static -/// objects as long as they are not written to prior to main(). These three streams are registered -/// with the output logging system at the start of the program execution. -/// -/// For example, the output streams header which would be included wherever output logging is desired. -/// -/// \code -/// #ifndef SIERRA_Slib_Output_Log_h -/// #define SIERRA_Slib_Output_Log_h -/// -/// #include -/// -/// namespace sierra { -/// -/// std::ostream &out(); ///< Normal output stream -/// std::ostream &dout(); ///< Diagnostic output stream -/// std::ostream &pout(); ///< Per-processor output stream (See RuntimeDeferredx) -/// std::ostream &tout(); ///< Regression test textual output stream -/// -/// std::ostream &dwout(); ///< Diagnostic writer stream -/// -/// } // namespace sierra -/// -/// #endif // SIERRA_Slib_Output_Log_h -/// \endcode -/// -/// The corresponding implementation file. -/// -/// \code -/// #include -/// -/// namespace sierra { -/// -/// std::ostream & -/// out() { -/// static std::ostream s_out(std::cout.rdbuf()); -/// -/// return s_out; -/// } -/// -/// std::ostream & -/// pout() { -/// static std::ostream s_pout(std::cout.rdbuf()); -/// -/// return s_pout; -/// } -/// -/// std::ostream & -/// dout() { -/// static std::ostream s_dout(std::cout.rdbuf()); -/// -/// return s_dout; -/// } -/// -/// std::ostream & -/// tout() { -/// static std::ostream s_tout(std::cout.rdbuf()); -/// -/// return s_tout; -/// } -/// -/// } // namespace sierra -/// \endcode -/// -/// And the registration in main(). -/// -/// \code -/// #include -/// -/// #include -/// -/// main() -/// { -/// stk_classic::register_log_ostream(std::cout, "cout"); // Make standard out available -/// stk_classic::register_log_ostream(std::cerr, "cerr"); // Make standard error available -/// -/// stk_classic::register_ostream(out(), "out"); -/// stk_classic::register_ostream(pout(), "pout"); -/// stk_classic::register_ostream(dout(), "dout", true); -/// stk_classic::register_ostream(tout(), "tout"); -/// -/// . . . -/// -/// stk_classic::unregister_ostream(out()); -/// stk_classic::unregister_ostream(pout()); -/// stk_classic::unregister_ostream(dout()); -/// stk_classic::unregister_ostream(tout()); -/// -/// stk_classic::unregister_log_ostream(std::cout); -/// stk_classic::unregister_log_ostream(std::cerr); -/// } -/// -/// \endcode -/// -/// \anchor stk_util_output_log_howto_bind_streams -/// \section stk_util_output_log_binding Binding Output Logs -/// -/// The output description is defined as a white space separated string of command phrases. There -/// are two types of command phrases, log file creation and output stream direction. -/// -/// The log file creation phrase consists of a name, and equal sign (=) and a file path. The file -/// path is opened and the log file stream is registered with the log streams. -/// -/// The output stream phrase consists of a name, a greater than sign (>) and a output stream -/// selector. The selector is a list of log streams or output streams which may be prefixed with a -/// plus sign (+) or a minus sign (-). No prefix removes all current log and output streams from -/// the named output stream before adding the new log or output stream. A plus prefix adds the new -/// log or output stream to the named output stream and a minus prefix removes the log or output -/// stream from the named output stream. Note that quotes must be used when meta-characters are -/// included as part of a file path. -/// -/// The following are examples of output stream descriptions: -/// -/// - To write output and diagnostic output to the sierra.log file (Normal for the root processor)
-/// logfile="sierra.log" out>logfile+pout pout>null dout>out" -/// -/// - To throw output and diagnostic output away (Normal for the non-root processors)
-/// out>pout pout>null dout>out" -/// -/// - To write output and diagnostic output to the sierra.log file and to write to the per-processor -/// log file. (Normal for per-processor debugging output on the root processor)
-/// logfile="sierra.log" plogfile="debug.log.4.0" out>logfile+pout pout>plogfile dout>out" -/// -/// - To write output and diagnostic output to the per-processor log file. (Normal for -/// per-processor debugging output on the non-root processors)
-/// plogfile="debug.log.4.1" out>pout pout>plogfile dout>out" -/// -/// - To write test output to testoutput.txt file.
-/// tlogfile="testoutput.txt" tout>tlogfile -/// -/// - Using these examples, to disengage the per-processor output at a later time
-/// pout>-plogfile -/// -/// - Using these examples, to engage the per-processor output at a later time
-/// pout>+plogfile -/// -/// The following is an example of a regular output log file when running on multiple processors: -/// -/// \code -/// -/// // On the root processor, create the regular log file sierra.log, send regular output to the -/// // regular log file and to the per-processor output stream, throw per-processor output away and -/// // send diagnostic output to the output stream. -/// -/// stk_classic::bind_output_streams("logfile=\"sierra.log\" " // Create sierra.log -/// "out>logfile+pout " // Send output to the log file and to the per-processor stream -/// "pout>null " // Throw per-processor output away -/// "dout>out"); // Send diagnostic output to the regular output stream -/// -/// // On other processors, send regular output to the per-processor output stream, throw -/// // per-processor output away, and send diagnostic output to the log file. -/// -/// stk_classic::bind_output_streams("out>pout " // Send output to the per-processor stream -/// "pout>null " // Throw per-processor output away -/// "dout>out"); // Send diagnostic output to the regular output stream -/// \endcode -/// -/// The following is an example of a regular output log file and a per-processor log file when -/// running on multiple processors: -/// -/// \code -/// -/// // On the root processor, send regular output to the file sierra.log and the per-processor -/// // output stream, send the per-processor output to the per-processor log file, and send -/// // diagnostic output to the log file. -/// -/// stk_classic::bind_output_streams("logfile=\"sierra.log\" " // Create sierra.log -/// "plogfile=\"debug.log.3.0\" " // Create per-processor debug.log -/// "out>logfile+pout " // Send output to the log file and to the per-processor stream -/// "pout>plogfile " // Send per-processor output to the per-processor log file -/// "dout>out"); // Send diagnostic output to the regular output stream -/// -/// // On the other processors, send regular output to the per-processor output stream, send the -/// // per-processor output to the per-processor log file, and send diagnostic output to the -/// // output stream. -/// -/// stk_classic::bind_output_streams("debug.log.3.1\" " // Create per-processor debug.log -/// "out>pout " // Send output to the per-processor stream -/// "pout>plogfile " // Send per-processor output to the per-processor log file -/// "dout>out"); // Send diagnostic output to the regular output stream -/// \endcode -/// -/// \anchor stk_util_output_log_howto_use_in_sierra_app -/// \section stk_util_output_log_use_in_sierra_app Usage in Sierra Application -/// -/// This section describes how to control the output logging for a sierra application and how to -/// enable diagnostic and timer output. It also describes the use of log control to remove excess -/// output caused by many time steps. -/// -/// To get the latest command line options for a sierra application, type -/// -/// \code -/// sierra application -O -h -/// \endcode -/// -/// The sierra applications have three command line arguments which control the log output: -/// -/// \code -/// Runtime environment options: -/// -o [ --output-log ] arg (=sierra.log) Output log file path, one of : 'cout', 'cerr', or a file path -/// --pout [=arg(=-)] Per-processor log file path -/// --dout [=arg(=out)] Diagnostic output stream one of: 'cout', 'cerr', 'out' or a file path -/// \endcode -/// -/// The -o option defines the location and filename of the log file. The --pout option directs -/// per-processor output to a specified set of files or standard output stream. And the --dout -/// option directs the diagnostic writer output to a specified set of files or standard output -/// stream. -/// -/// For example: -/// -/// - sierra application -i input_deck.i -o sierra.log
-/// This creates the normal output file sierra.log -/// -/// - sierra application -i input_deck.i -o sierra.log -O "--pout=pp.log"
-/// The per-processor output is written to pp.log.n.r for each rank, r, of n processors. -/// -/// - sierra application -i input_deck.i -o sierra.log -O "--fmwkout=field,parameters"
-/// Enable the framework field and parameter diagnostic output, see \ref stk_util_output_log_use_in_sierra_app_diag_writer -/// -/// - sierra application -i input_deck.i -o sierra.log -O "--timer=all"
-/// Enable all timers, see \ref stk_util_output_log_use_in_sierra_app_timers -/// -/// \subsection stk_util_output_log_use_in_sierra_app_diag_writer Diagnostic Writer Output -/// -/// Complementary to the output log is the diagnostic writer output. This output is enabled by a -/// variety of command line options. The diagnostic writers allow more detailed information to be -/// displayed during the execution. This extended log information is written to the diagnostic -/// stream which is defined by the --dout command line option. -/// -/// The diagnostic writer output can also be controlled from the input deck using: -/// -/// \code -/// Begin Diagnostic Control name -/// Enable option-list -/// End -/// \endcode -/// -/// where option-list is a command separated list of options specific for that diagnostic -/// writer. -/// -/// It is also possible to control the output of diagnostics based on time step or simulation time. -/// When the simulation is within the specified interval, the diagnostic writer has the specified -/// options enabled. Note that the definition of step and time is based on the regions current step -/// and time which may not be consistent across all regions. -/// -/// \code -/// Begin Diagnostic Control name -/// From Step n To m Enable option-list -/// From Time s To t Enable option-list -/// Enable option-list -/// End -/// \endcode -/// -/// where name is the specific diagnostic writer, n and m are steps -/// values, s and t are simulation times, and option-list is a comma -/// separated list of options specific for that diagnostic writer. Here is an example list of -/// options available to the adagio application: -/// -/// \code -/// Diagnostic writers: -/// --fmwkout arg Diagnostic writer fmwkout -/// Specify a comma separated list of: -/// comm Display mpi communication diagnostic information -/// contact Display contact diagnostic information -/// coverage Collect and display traceable function usage coverage -/// dump-load Dump domain atfer mesh load -/// dump-setup Dump domain after setup -/// event Display event information -/// field Display field registeration information -/// geometry Display geometry diagnostic information -/// input-check Check input deck and mesh load, does not execute -/// material Display material diagnostic information -/// members Display data structure members messages -/// mesh-mod Display mesh modification diagnostic information -/// parameters Display parameter diagnostic information -/// pretty-print Pretty print input deck and mesh data -/// relation Display connectivy, orientation and relation information -/// search Display search diagnostic information -/// solver Display linear and non-linear solver diagnostic information -/// syntax-check Check syntax of input deck, does not load mesh or execute -/// trace Display execution trace -/// trace-down Display subsequent calls after tracing is enabled -/// trace-stats Display execution time and memory usage during trace -/// transfer Display transfer diagnostic information -/// user-func Display user input function information -/// verbose Dump domain after setup, does not load mesh or execute -/// -/// --prsrout arg Diagnostic writer prsrout -/// Specify a comma separated list of: -/// command-spec Display command specs -/// coverage Collect and display traceable function usage coverage -/// enumeration Display enumerations -/// members Display data structure members messages -/// parse Display parser diagnostic information -/// tag-lists Display command specs -/// trace Display execution trace -/// trace-down Display subsequent calls after tracing is enabled -/// trace-stats Display execution time and memory usage during trace -/// -/// --sctlout arg Diagnostic writer sctlout -/// Specify a comma separated list of: -/// actions Display solution control actions -/// construction Display construction information -/// coverage Collect and display traceable function usage coverage -/// execution Display execution information -/// members Display data structure members messages -/// parameters Display solution control block parameters -/// time Display time calculation information -/// trace Display execution trace -/// trace-down Display subsequent calls after tracing is enabled -/// trace-stats Display execution time and memory usage during trace -/// validation Display validation settings -/// -/// --slibout arg Diagnostic writer slibout -/// Specify a comma separated list of: -/// coverage Collect and display traceable function usage coverage -/// global-variables Display global variable operations -/// members Display data structure members messages -/// memory Display platform specific memory usage information -/// plugins Display plugin information -/// resources Display resource assignments -/// trace Display execution trace -/// trace-down Display subsequent calls after tracing is enabled -/// trace-stats Display execution time and memory usage during trace -/// \endcode -/// -/// \subsection stk_util_output_log_use_in_sierra_app_timers Timer Output -/// -/// There are many timers embedded within the application to assist in determining application -/// performance. The --timer command line option activates these timers. -/// -/// The input deck may also use the Enable Timer line command in the Sierra command block can be -/// used to enable timers. Also, the Print Timer Information line command causes the timers to be -/// printed at the specified step interval. -/// -/// \code -/// Enable Timer timer-list -/// Print Timer Information Every interval Steps {Checkpointed|Accumulated} -/// \endcode -/// -/// where timer-list is a comma separated list of timers and interval is the -/// number steps between timer output. Accumulated displays the values since that start of -/// the application and Checkpointed displays the values since the last interval. -/// -/// Sample timers are listed below: -/// -/// \code -/// Runtime environment options: -/// --timer arg Wall and CPU time options -/// Specify a comma separated list of: -/// adaptivity Enable metrics on adaptivity -/// algorithm Enable metrics on algorithms -/// all Enable all metrics -/// app1 Enable app defined metrics -/// app2 Enable app defined metrics -/// app3 Enable app defined metrics -/// app4 Enable app defined metrics -/// contact Enable metrics on contact -/// cpu Display CPU times -/// domain Enable metrics on the domain -/// hms Display times in HH:MM:SS format -/// material Enable metrics on materials -/// mechanics Enable metrics on mechanics -/// none Disable all timers -/// procedure Enable metrics on procedures -/// profile1 Enable app defined profiling metrics -/// profile2 Enable app defined profiling metrics -/// profile3 Enable app defined profiling metrics -/// profile4 Enable app defined profiling metrics -/// recovery Enable metrics on encore recovery -/// region Enable metrics on regions -/// search Enable metrics on searches -/// seconds Display times in seconds -/// solver Enable metrics on solvers -/// transfer Enable metrics on user functions -/// wall Display wall times -/// \endcode -/// -/// \subsection stk_util_output_log_use_in_sierra_app_log_control Log Control -/// -/// Since explicit codes run many time steps, only occasional output to the log file is necessary. -/// The log control feature allows the output to appear in the log file on specified intervals or on -/// error. The Log line command in the Sierra command block is used to specify the output interval. -/// -/// \code -/// Log name Every n -/// \endcode -/// -/// When the last interval is reached or an error condition arises the output is written to the log -/// file. -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.hpp deleted file mode 100644 index 5f2a0401fcb5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/OutputLog.hpp +++ /dev/null @@ -1,222 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_OUTPUTLOG_HPP -#define STK_UTIL_ENVIRONMENT_OUTPUTLOG_HPP - -#include -#include - -// #include - -namespace stk_classic { - -template -class basic_tee_streambuf; - -/// Tee stream buffer for char -typedef stk_classic::basic_tee_streambuf > tee_streambuf; - -/// -/// @addtogroup output_log_detail -/// @{ -/// - -/** - * @file - * - * The logging is implemented using two maps. One maps names to log files and streams and one maps - * names to output streams. Log files and streams are the ultimate destinations for output. The - * output streams are the data providers. The output streams may also serve as destinations - * streams, passing stream data to their destinations. - * - * To implement this strategy, the output streams, once registered, create a tee streambuf and - * attach this as the rdbuf of the registered stream. The original streambuf becomes the - * destination of the tee streambuf. The tee streambuf sinks data from a stream and sources it to - * all of its destination streambufs just as the tee utility tees input from stdin to a file set and - * stdout. - * - * The tee streambuf class provides functions to add and remove destination streams. - * - * When a output stream is unregistered, the tee streambuf is destroyed and the streams original - * streambuf is restored. - * - * The bind_output_streams() function provides string commands to control the sinks and sources of - * the log file streams and the output streams. - * - * The functions using ostreams could be converted to templates of Ch and std::char_traits. - */ - -/** - * @brief Function register_ostream registers an output stream with the output stream - * registry. The registration process creates an intermediate tee streambuf. - * - * @param name a std::string const reference to the name of the output - * stream. - * - * @param output_stream a std::ostream reference to the output stream to register. - * - */ -void register_ostream(std::ostream &os, const std::string &name); - -/** - * @brief Function unregister_ostream unregisters an output stream. - * - * @param output_stream a std::ostream reference to the output stream to unregister. - * - */ -void unregister_ostream(std::ostream &os); - -/** - * @brief Function bind_output_streams parses the output_description and opens and registers - * the log streams and binds the registered output streams to the registered log streams. - * - * The output description is defined as a white space separated string of command phrases. There - * are two types of command phrases, log file creation and output stream direction. - * - * The log file creation phrase consists of a name, and equal sign (=) and a file path. The file - * path is opened and the log file stream is registered with the log streams. - * - * The output stream phrase consists of a name, a greater than sign (>) and a output stream - * selector. The selector is a list of log streams or output streams which may be prefixed with a - * plus sign (+) or a minus sign (-). No prefix removes all current log and output streams - * from the named output stream before adding the new log or output stream. A plus prefix adds the - * new log or output stream to the named output stream and a minus prefix removes the log or output - * stream from the named output stream. - * - * @param output_description a std::string const reference to the output desciption. - * - */ -void bind_output_streams(const std::string &output_description); - -/** - * @brief Function register_log_ostream takes an existing std::ostream and makes it available - * for output redirection. - * - * @param output_stream a std::ostream reference to the output stream to register. - * - * @param name a std::string const reference to the name of this log - * stream. - * - */ -void register_log_ostream(std::ostream &os, const std::string &name); - -/** - * @brief Function register_log_ostream takes an existing std::ostream and makes it available - * for output redirection. - * - * @param output_stream a std::ostream reference to the output stream to register. - * - */ -void unregister_log_ostream(std::ostream &os); - -/** - * @brief Function create_log_file opens a log file at the specified path and adds it to the - * registry of log files with the specified name. This name is be used at to locate the path of the - * file or it's output stream from the registry using the get_log_file_path() and - * get_log_file_ostream() functions. - * - * @param name a std::string const reference to the name to give the log - * file. - * - * @param path a std::string const reference to the path of the log file to - * create. - * - */ -void create_log_file(const std::string &name, const std::string &path); - -/** - * @brief Function close_log_file close the log file with the specified name and - * removes it from the registry of log files. - * - * @param name a std::string const reference to the name of the log file to - * close. - * - */ -void close_log_file(const std::string &name); - -/** - * @brief Function is_registered_ostream returns true if an output stream of the - * specified name is registered. - * - * @param name a std::string const reference to the output stream to test - * existence in the output stream registry. - * - * @return a bool value of true if the specified output stream is in the - * registry. - */ -bool is_registered_ostream(const std::string &name); - -/** - * @brief Function get_log_path returns the file path of the log file with the specified name - * from the log file registry. If the specified name does not exist in the registry, an empty - * string is returned. - * - * @param name a std::string const reference to the name of the log file to - * return its file path. - * - * @return a std::string const reference to the file path of the log - * file. - */ -const std::string &get_log_path(const std::string &name); - -/** - * @brief Function get_log_file_ostream return the output stream of the log file with the - * specified name from the log registry. If the specified name does not exist in the registry, a - * null pointer is returned. - * - * @param name a std::string const reference to the name of the log file to - * return its output stream. - * - * @return a std::ostream pointer to the output stream of the log file. - */ -std::ostream *get_log_ostream(const std::string &name); - -/** - * @brief Function get_ostream_streambuf locates the output stream registered with - * the specified name. If the specified output stream does not exist in the registry, a null - * pointer is returned. - * - * @param name a std::string const reference of the name of the outputstream - * to return its tee streambuf. - * - * @return a std::ostream pointer to the output stream. - */ -std::ostream *get_ostream_ostream(const std::string &name); - -/** - * @brief Function get_ostream_tee_streambuf locates the tee streambuf registered - * with the specified name. If the specified output stream does not exist in the registry, a null - * pointer is returned. - * - * @param name a std::string const reference of the name of the outputstream - * to return its tee streambuf. - * - * @return a tee_streambuf pointer to the tee streambuf. - */ -std::ostream *get_ostream_tee_ostream(const std::string &name); - -/// -/// @} -/// - -} // namespace stk_classic - -namespace sierra { - -std::ostream &out(); ///< Normal output stream -std::ostream &dout(); ///< Diagnostic output stream -std::ostream &pout(); ///< Per-processor output stream (See RuntimeDeferredx) -std::ostream &tout(); ///< Regression test textual output stream - -std::ostream &dwout(); ///< Diagnostic writer stream - -} // namespace sierra - - -#endif // STK_UTIL_ENVIRONMENT_OUTPUTLOG_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.cpp deleted file mode 100644 index 96d395ac7d80..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) 2013, Sandia Corporation. -// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, -// the U.S. Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of Sandia Corporation nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#include -#include -#ifdef STK_BUILT_IN_SIERRA -#include -#else -#define STK_VERSION "0.1a" -#endif - -namespace stk_classic { - -const std::string -ProductRegistry::NAME = "Name"; - -const std::string -ProductRegistry::TITLE = "Title"; - -const std::string -ProductRegistry::VERSION = "Version"; - -const std::string -ProductRegistry::QUALIFIER = "Qualifier"; - -const std::string -ProductRegistry::BUILD_TIME = "Build Time"; - -const std::string -ProductRegistry::EXECUTABLE = "Executable"; - -const std::string -ProductRegistry::CONTACT = "Contact"; - -const std::string -ProductRegistry::ERROR = "Error"; - -const std::string -ProductRegistry::PRODUCT_TYPE = "Type"; - -const std::string -ProductRegistry::REGION_TITLE = "Region Title"; - -const std::string -ProductRegistry::BANNER_DETAIL = "Banner Detail"; - -const std::string -ProductRegistry::COPYRIGHT = "Copyright"; - -const std::string -ProductRegistry::PRODUCT_TYPE_REGION = "Region"; - - -ProductRegistry & -ProductRegistry::instance() -{ - static ProductRegistry s_productRegistry; - - return s_productRegistry; -} - - -const char * -ProductRegistry::version() -{ - // STK_VERSION should be a build-time define (i.e. -D flag) passed on - // the compilation command line - static const char *s_version = STK_VERSION; - - return s_version; -} - - -ProductRegistry::AttributeMap & -ProductRegistry::addTPL( - const std::string & name, - const std::string & version, - const std::string & qualifier) -{ - std::pair iit = m_productMap.insert(std::make_pair(name, AttributeMap())); - ProductMap::iterator it = iit.first; - if (iit.second) { - (*it).second[NAME] = name.c_str(); - (*it).second[VERSION] = version; - (*it).second[QUALIFIER] = qualifier; - } - else { - std::string ¤t_version = (*it).second[VERSION]; - std::string ¤t_qualifer = (*it).second[QUALIFIER]; - if (current_version.empty()) - current_version = version; - if (current_qualifer.empty()) - current_qualifer = qualifier; - if (current_version != version || current_qualifer != qualifier) { - (*it).second[ERROR] = std::string("Product registration of ") + (*it).first + " version/qualifier conflict, " - + " initially " + (*it).second[VERSION] + "/" + (*it).second[QUALIFIER] - + " tried to change to " + version + "/" + qualifier; - setRegistryInvalid(); - } - } - - return (*it).second; -} - - -ProductRegistry::AttributeMap & -ProductRegistry::addProduct(const std::string & name) -{ - std::pair iit = m_productMap.insert(std::make_pair(name, AttributeMap())); - ProductMap::iterator it = iit.first; - if (iit.second) { - (*it).second[NAME] = name.c_str(); - } - - return (*it).second; -} - - -ProductRegistry::AttributeMap & -ProductRegistry::addRegion( - const std::string & name) -{ - AttributeMap &attribute_map = addProduct(name); - attribute_map[ProductRegistry::PRODUCT_TYPE] = ProductRegistry::PRODUCT_TYPE_REGION; - attribute_map[ProductRegistry::VERSION] = ProductRegistry::version(); - - return attribute_map; -} - - -ProductRegistry::AttributeMap & -ProductRegistry::getProductAttributeMap( - const std::string & name) -{ - return m_productMap[name]; -} - - -const std::string & -ProductRegistry::getProductAttribute( - const std::string & name, - const std::string & attribute) const -{ - return m_productMap[name][attribute]; -} - - -std::string & -ProductRegistry::getProductAttribute( - const std::string & name, - const std::string & attribute) -{ - return m_productMap[name][attribute]; -} - - -void -ProductRegistry::setProductAttribute( - const std::string & name, - const std::string & attribute, - const std::string & value) -{ - m_productMap[name][attribute] = value; -} - -} // namespace stk_classic - -extern "C" { - -void -product_registry_add( - const char * name ) -{ - stk_classic::ProductRegistry::instance().addProduct(name ? name : ""); -} - -void -product_registry_add_tpl( - const char * name, - const char * version, - const char * qualifier ) -{ - stk_classic::ProductRegistry::instance().addTPL(name ? name : "", version ? version : "", qualifier ? qualifier : ""); -} - -} // extern "C" diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.hpp deleted file mode 100644 index d38e2100a4a8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ProductRegistry.hpp +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright (c) 2013, Sandia Corporation. -// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, -// the U.S. Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of Sandia Corporation nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#ifndef STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP -#define STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP - -#include -#include - -namespace stk_classic { - -/** - * @brief Class ProductRegistry maps product names and attributes to - * brief descriptive values. Each added product has at a minimum the NAME - * value initialized. A region type product also has the PRODUCT_TYPE set to - * PRODUCT_TYPE_REGION. - * - * A product may have any other attribute keyword and value assocaited with it. In - * particular, the main execution product often has the /EXECUTABLE_FILE and - * BUILD_TIME attributes set. - * - * You may add any other attribute keyword and values to the product registry. - * - */ -class ProductRegistry -{ -public: - typedef std::map AttributeMap; ///< Map of attribute keyword to value - typedef std::map ProductMap; ///< Map of product name to attribute map - - /** - * @brief Member function instance returns a reference to the registry singleton. - * - * @return a ProductRegistry reference to the registry singleton - */ - static ProductRegistry &instance(); - -private: - /** - * Creates a new ProductRegistry instance. - * - */ - ProductRegistry() - : m_productMap(), - m_productName(), - m_registryOK(true) - {} - - ProductRegistry(const ProductRegistry &); - - ProductRegistry &operator=(const ProductRegistry &); - - ~ProductRegistry() - {} - - -public: - /** - * @brief Member function version returns the version number of the combined product. - * - * @return a ProductRegistry reference to the registry singleton - */ - static const char *version(); - - /** - * @brief Member function setRegistryInvalid marks th registry as contain a - * conflict of some sort. The ERROR attribute of each product describes - * each error. - * - */ - void setRegistryInvalid() { - m_registryOK = false; - } - - /** - * @brief Member function isRegistryOK returns true if the registry has not - * been flagged as having an error via setRegistryInvalid. - * - * @return a bool value of true of the registry has no - * conflicts. - */ - bool isRegistryOK() { - return m_registryOK; - } - - /** - * @brief Member function getProductName returns the product name. - * - * @return a string const reference to the product name. - */ - const std::string &getProductName() const { - return m_productName; - } - - /** - * @brief Member function setProductName sets the product name. - * - */ - void setProductName(const std::string &product_name) { - m_productName = product_name; - } - - /** - * @brief Member function getProductMap returns a reference to the map of - * all products. - * - * @return a ProductMap reference to the product map. - */ - ProductMap &getProductMap() const { - return m_productMap; - } - - /** - * @brief Member function addProduct adds a product to the registry. - * - * @param name a std::string const reference to the product's - * name. - * - * @return an AttributeMap reference to the attribute - * map of the newly added product. - */ - AttributeMap &addProduct(const std::string &name); - - /** - * @brief Member function addTPL adds a product to the registry. A - * product always has the VERSION and QUALIFIER attributes set. - * - * @param name a std::string const reference to the product's - * name. - * - * @param version a std::string const reference to the product's - * version string. - * - * @param qualifier a std::string const reference to the product's - * qualifier string. - * - * @return an AttributeMap reference to the attribute - * map of the newly added product. - */ - AttributeMap &addTPL(const std::string &name, const std::string &version, const std::string &qualifier = ""); - - /** - * @brief Member function addRegion add a region as a product to the - * registry. A region product is a product with the PRODUCT_TYPE set to - * PRODUCT_TYPE_REGION. - * - * @param name a std::string const reference to the product's - * name. - * - * @return an AttributeMap reference to the attribute - * map of the newly added region product. - */ - AttributeMap &addRegion(const std::string &name); - - /** - * @brief Member function getProduct returns a reference to the product - * attribute map. - * - * @param name a std::string const reference to the product's - * name. - * - * @return an AttributeMap reference to the attribute - * map of the newly added region product. - */ - AttributeMap &getProductAttributeMap(const std::string &name); - - /** - * @brief Member function getAttribute returns the - * attribute for the named product. - * - * @param name a std::string const reference to the product's - * name. - * - * @param attribute a std::string const reference to the product's - * attribute keyword. - * - * @return a std::string const reference to the value of - * product's attribute. - * - */ - const std::string &getProductAttribute(const std::string &name, const std::string &attribute) const; - - /** - * @brief Member function getAttribute returns the - * attribute for the named product. - * - * @param name a std::string const reference to the product's - * name. - * - * @param attribute a std::string const reference to the product's - * attribute keyword. - * - * @return a std::string const reference to the value of - * product's attribute. - * - */ - std::string &getProductAttribute(const std::string &name, const std::string &attribute); - - /** - * @brief Member function setAttribute sets the - * attribute for the named poduct to the specified value. - * - * @param name a std::string const reference to the product's - * name. - * - * @param attribute a std::string const reference to the product's - * attribute keyword. - * - * @param value a std::string const reference to the value of - * product's attribute. - * - */ - void setProductAttribute(const std::string &name, const std::string &attribute, const std::string &value); - -public: - static const std::string NAME; ///< Product's name attribute - static const std::string TITLE; ///< Product's title attribute - static const std::string VERSION; ///< TPL's version attribute - static const std::string QUALIFIER; ///< TPL's qualifier attribute - static const std::string CONTACT; ///< Product's contact attribute - static const std::string ERROR; ///< Product's error attribute - static const std::string PRODUCT_TYPE; ///< Product's product_type attribute - - static const std::string EXECUTABLE; ///< Product's executable attribute - static const std::string BUILD_TIME; ///< Product's build_time attribute - - static const std::string BANNER_DETAIL; ///< Product's additional banner info attribute - static const std::string COPYRIGHT; ///< Product's copyright information - - static const std::string REGION_TITLE; ///< Product's region_title attribute - - static const std::string PRODUCT_TYPE_REGION; ///< Region product_type value - -private: - mutable ProductMap m_productMap; ///< Product map - std::string m_productName; ///< Name of main product - bool m_registryOK; ///< Registry is OK -}; - -} // namespace stk_classic - -#ifdef STK_BUILT_IN_SIERRA -#undef VERSION // Nice, Trilinos leaves us this gem - -namespace sierra { - -typedef stk_classic::ProductRegistry ProductRegistry; - -} // namespace sierra -#endif // STK_BUILT_IN_SIERRA - - -#endif // STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.cpp deleted file mode 100644 index 192672d652c1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -namespace stk_classic { - -boost::program_options::options_description & -get_options_description() -{ - static boost::program_options::options_description s_optionsDescription; - - return s_optionsDescription; -} - -boost::program_options::variables_map & -get_variables_map() -{ - static boost::program_options::variables_map s_variablesMap; - - return s_variablesMap; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.dox b/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.dox deleted file mode 100644 index 583e23baa585..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.dox +++ /dev/null @@ -1,87 +0,0 @@ -/// -/// \addtogroup stk_util_command_line_options_detail -/// @{ -/// -/// @brief Parses command line options in a parallel environment. Also formats and writes --help -/// and -h command line option output. -/// -/// Each module can utilize the bootstrapping mechanism to add command line options to be -/// processed as application startup. Processing of command line options requries three -/// operations to be performed, the accumulation of command line option descriptions, the -/// broadcasting of the command line options (argc, argv) from the rank 0 processor to the -/// other processors and the actual parsing of the command line options. -/// -/// Refer to the boost program options library for details on utilizing the command line -/// option descriptions and variable map. -/// -/// Command line option descriptions describe the options available to the user from the -/// command line. These desciptions also provide help documentation and grouping. Since -/// many modules may be interested in adding command line option desciptions to the -/// system, the singleton stk_classic::env::get_options_description() provides the global command -/// line option descriptions. Each module utilizes the bootstrapping mechanism to add its -/// options to this description. -/// -/// For example: -/// -/// \code -/// -/// #include -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// boost::program_options::options_description desc("Use case options"); -/// desc.add_options() -/// ("performance", "run performance test") -/// ("mesh", boost::program_options::value(), "run mesh file performance test"); -/// -/// stk_classic::env::get_options_description().add(desc); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// \endcode -/// -/// -/// The applications main executes the bootstrap functions causing the command line -/// description to be fully populated. -/// -/// The parsing of the command line options requires that the arguments specified on the -/// command line on processor zero be broadcast to the remaining processors (some MPI's -/// seem to not handle this properly). The BroadcastArg class takes argc and -/// argv and broadcasts to all of the processors. These broadcast arguments are -/// then provided to the boost::parse_command_line() function. -/// -/// For example: -/// -/// \code -/// -/// int -/// main( -/// int argc, -/// char ** argv) -/// { -///  // Execute product bootstraps -/// stk_classic::Bootstrap::bootstrap(); -/// -///  // Initialize parallel machine -/// stk_classic::ParallelMachine parallel_machine; -/// parallel_machine = stk_classic::parallel_machine_init(&argc, &argv); -/// -///  // Broadcast argc and argv to all processors. -/// stk_classic::BroadcastArg b_arg(parallel_machine, argc, argv); -/// -///  // Process the broadcast command line arguments -/// namespace opt = boost::program_options; -/// -/// opt::variables_map vm; -/// opt::store(opt::parse_command_line(b_arg.m_argc, b_arg.m_argv, stk_classic::env::get_options_description()), vm); -/// opt::notify(vm); -/// -/// \endcode -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.hpp deleted file mode 100644 index a3415c1b84f6..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ProgramOptions.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_PROGRAMOPTIONS_HPP -#define STK_UTIL_ENVIRONMENT_PROGRAMOPTIONS_HPP - -#include - -namespace stk_classic { - -/// -/// @addtogroup command_line_options_detail -/// @{ -/// - -/** - * @brief Function get_options_description is a singleton used to store the command - * line option descriptions for the boost::program_options library. This option - * descriptions should be populated with options by each module using Bootstrap - * object callback functions. This allows modules to populate these prior to main's - * execution of the boost::parse_command_line() functions. - * - * @return an boost::program_options::options_description reference to the - * program options to be used for all command line option descriptions. - */ -boost::program_options::options_description &get_options_description(); - -/** - * @brief Function get_variabel_map is a singleton used to store the variables parsed from - * the line option descriptions. - * - * @return an boost::program_options::variable_map reference to the - * program options to be used for all command line option descriptions. - */ -boost::program_options::variables_map &get_variables_map(); - -/// -/// @} -/// - -} // namespace stk_classic - -#endif // STK_UTIL_ENVIRONMENT_PROGRAMOPTIONS_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.cpp deleted file mode 100644 index 9ba2c646a605..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2002-2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include - -#include - -namespace sierra { - -const char * -get_product_name() -{ - return "UtilityLib"; -} - -void -register_product() -{ - // Register utility - ProductRegistry::AttributeMap &attr_map = ProductRegistry::instance().addProduct(get_product_name()); - attr_map[ProductRegistry::VERSION] = ProductRegistry::version(); - attr_map[ProductRegistry::TITLE] = "Utility library routines"; - attr_map[ProductRegistry::CONTACT] = "framework-developers@sourceforge.sandia.gov"; - - // Register TPL's and other things which may not be properly registered but used directly. - -} - -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.hpp deleted file mode 100644 index bb1e9a78e976..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RegisterProduct.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef STK_UTIL_ENVIRONMENT_RegisterProduct_hpp -#define STK_UTIL_ENVIRONMENT_RegisterProduct_hpp - -namespace sierra { - -void -register_product(); - -} // namespace sierra - -#endif // STK_UTIL_ENVIRONMENT_RegisterProduct_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.cpp deleted file mode 100644 index dcd3521e3c44..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -namespace stk_classic { - -namespace { - -// Global variables used to store the current handlers. We do not want direct -// external access to this state, so we put these in an empty namespace. -ErrorHandler s_assert_handler = &default_assert_handler; -ErrorHandler s_error_handler = &default_error_handler; -ErrorHandler s_invalid_arg_handler = &default_invalid_arg_handler; -REH s_reportHandler = &default_report_handler; - -template -void default_handler_req(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - std::string error_msg = ""; - if (message.str() != "") { - error_msg = std::string("Error: ") + message.str() + "\n"; - } - - throw EXCEPTION( - std::string("Requirement( ") + expr + " ) FAILED\n" + - "Error occured at: " + source_relative_path(location) + "\n" + - error_msg); -} - -template -void default_handler_exc(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - std::string error_msg = ""; - if (message.str() != "") { - error_msg = std::string("Error: ") + message.str() + "\n"; - } - - std::string expr_msg = ""; - if (expr != std::string("")) { - expr_msg = std::string("Expr '") + expr + "' eval'd to true, throwing.\n"; - } - - throw EXCEPTION( - expr_msg + - "Error occured at: " + source_relative_path(location) + "\n" + - error_msg); -} - -} - -void -default_report_handler( - const char * message, - int type) -{ - std::cout << "Message type " << type << ": " << message << std::endl; -} - -void -report( - const char * message, - int type) -{ - (*s_reportHandler)(message, type); -} - - -REH -set_report_handler( - REH reh) -{ - /* %TRACE[ON]% */ /* %TRACE% */ - if (!reh) - throw std::runtime_error("Cannot set report handler to NULL"); - - REH prev_reh = s_reportHandler; - s_reportHandler = reh; - - return prev_reh; -} - - -std::string -source_relative_path( - const std::string & path) -{ - static const char *prefix[] = {"/src/", "/include/", "/Apps_", "/stk_"}; - - for (unsigned int i = 0; i < sizeof(prefix)/sizeof(prefix[0]); ++i) { - std::string::size_type j = path.rfind(prefix[i], path.length()); - if (j != std::string::npos) { - j = path.rfind("/", j - 1); - if (j != std::string::npos) - return path.substr(j + 1, path.length()); - else - return path; - } - } - return path; -} - -void default_assert_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - default_handler_req(expr, location, message); -} - -void default_error_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - default_handler_exc(expr, location, message); -} - -void default_invalid_arg_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - default_handler_exc(expr, location, message); -} - -ErrorHandler set_assert_handler(ErrorHandler handler) -{ - if (!handler) - throw std::runtime_error("Cannot set assert handler to NULL"); - - ErrorHandler prev_handler = s_assert_handler; - s_assert_handler = handler; - - return prev_handler; -} - -ErrorHandler set_error_handler(ErrorHandler handler) -{ - if (!handler) - throw std::runtime_error("Cannot set error handler to NULL"); - - ErrorHandler prev_handler = s_error_handler; - s_error_handler = handler; - - return prev_handler; -} - -ErrorHandler set_invalid_arg_handler(ErrorHandler handler) -{ - if (!handler) - throw std::runtime_error("Cannot set invalid_arg handler to NULL"); - - ErrorHandler prev_handler = s_invalid_arg_handler; - s_invalid_arg_handler = handler; - - return prev_handler; -} - -void handle_assert(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - (*s_assert_handler)(expr, location, message); -} - -void handle_error(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - (*s_error_handler)(expr, location, message); -} - -void handle_invalid_arg(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - (*s_invalid_arg_handler)(expr, location, message); -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.hpp deleted file mode 100644 index 269871c6ffb8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/ReportHandler.hpp +++ /dev/null @@ -1,291 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP -#define STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP - -#include -#include -#include - -namespace stk_classic { - -/// -/// @addtogroup runtime_message_detail -/// @{ -/// - -/** - * @brief Type definition REH is a pointer to a function of type void that takes a const - * std::exception reference as a parameter. - * - */ -typedef void (*REH)(const char *message, int type); - -/** - * @brief ErrorHandler defines the signature of functions that can be used - * to handle errors. expr is the expression of the failing error-check, - * location is a raw code location (something like file:line, no prose), - * and message is the error message. - */ -typedef void (*ErrorHandler)(const char* expr, const std::string& location, std::ostringstream& message); - -/** - * @brief Function default_report_handler is the default - * error reporter for sierra exceptions. Note that it is implemented in Fmwk_sierra.C so - * that it can participate - * - * @param message a char const pointer to the message to be - * displayed. - * - * @param type an int value of the type of message from the - * enumeration type - * - */ -void default_report_handler(const char *message, int type); - -/** - * @brief Function set_report_handler sets the exception report function to be called when an - * report_exception() is called. - * - * @param reh a REH of the new exception reporter. - * - * @return a REH to the previous exception reporter. - */ -REH set_report_handler(REH reh); - -/** - * @brief Function report calls the current exception reporter to report the message in - * x. - * - * @param message a char const pointer to the message to report. - * - * @param type an int value of the type of message. - * - */ -void report(const char *message, int type); - -/** - * @brief Function source_relative_path strips everything through - * "/src/", "/include/", "/App_", or "/stk_" so that error message output - * doesn't mention names. - * - * @param path a std::string const reference to the original path. - * - * @return a std::string value of the stripped path. - */ -std::string source_relative_path(const std::string &path); - -/** - * A function used to create and throw nice-looking exceptions for assertion - * failures. - */ -void default_assert_handler(const char* expr, - const std::string& location, - std::ostringstream& message); - -/** - * A function used to create and throw nice-looking exceptions for runtime - * errors. - */ -void default_error_handler(const char* expr, - const std::string& location, - std::ostringstream& message); - -/** - * A function used to create and throw nice-looking exceptions for invalid - * argument errors. - */ -void default_invalid_arg_handler(const char* expr, - const std::string& location, - std::ostringstream& message); - -/** - * Change the error handler for ThrowAssert and ThrowRequire. - * - * @return The previous error handler (useful if you want to restore it later) - */ -ErrorHandler set_assert_handler(ErrorHandler handler); - -/** - * Change the error handler for ThrowError. - * - * @return The previous error handler (useful if you want to restore it later) - */ -ErrorHandler set_error_handler(ErrorHandler handler); - -/** - * Change the error handler for ThrowInvalidArg. - * - * @return The previous error handler (useful if you want to restore it later) - */ -ErrorHandler set_invalid_arg_handler(ErrorHandler handler); - -/** - * Makes the call to the current assert handler - */ -void handle_assert(const char* expr, - const std::string& location, - std::ostringstream& message); - -/** - * Makes the call to the current error handler - */ -void handle_error(const char* expr, - const std::string& location, - std::ostringstream& message); - -/** - * Makes the call to the current invalid_arg handler - */ -void handle_invalid_arg(const char* expr, - const std::string& location, - std::ostringstream& message); - - -/// -/// @} -/// - -} // namespace stk_classic - -/// -/// @addtogroup runtime_message_detail -/// @{ -/// - -/** - * @brief Define statements to add __FILE___ and __LINE__. - * - * These just make it a little easier to add the __FILE__ and __LINE__ macros into the traceback - * functions. Inline functions do not work because the __FILE__ and __LINE__ expansions take place - * before the compiler inlining. - */ -#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s) -#define STR_TRACE_LINE(s) #s - -#ifdef __PRETTY_FUNCTION__ - -#define COUT_TRACE " Function::Line="<<__PRETTY_FUNCTION__<<":"<<__LINE__ -#define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__) + " in " + std::string(__PRETTY_FUNCTION__)) - -#else - -#define COUT_TRACE " File::Line="<<__FILE__<<":"<<__LINE__ -#define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__)) - -#endif - -#define StackTrace std::string(std::string(" exception thrown from ") + stk_classic::source_relative_path(STR_TRACE)) - -// The do-while is necessary to prevent usage of this macro from changing -// program semantics (e.g. dangling-else problem). The obvious implementation: -// if (expr) ; else throw ... -// is not adequate because it causes ambiguous else statements in this context: -// if (something) -// ThrowRequire(foo); -// The compiler does not know whether the else statement that the macro inserts -// applies to the "if (something) " or the "if (expr)". -#define ThrowGenericCond(expr, message, handler) \ - do { \ - if ( !(expr) ) { \ - std::ostringstream stk_util_internal_throw_require_oss; \ - stk_util_internal_throw_require_oss << message; \ - stk_classic::handler( #expr, \ - STR_TRACE, \ - stk_util_internal_throw_require_oss ); \ - } \ - } while (false) - -// This generic macro is for unconditional throws. We pass "" as the expr -// string, the handler should be smart enough to realize that this means there -// was not expression checked, AKA, this throw was unconditional. -#define ThrowGeneric(message, handler) \ - do { \ - std::ostringstream stk_util_internal_throw_require_oss; \ - stk_util_internal_throw_require_oss << message; \ - stk_classic::handler( "", \ - STR_TRACE, \ - stk_util_internal_throw_require_oss ); \ -} while (false) - -// The macros below define the exceptions that we want to support within -// STK. The intent is that STK developers will never call throw XXX -// directly. This will give us full control over the exceptions being generated -// by STK and how they are handled. These macros are also designed to make -// it as easy as possible for developers to throw exceptions that have good -// error messages and to reduce the volume of coded needed for error handling. -// -// We currently support the following exceptions in STK: -// logic_error <-> ThrowAssert, ThrowAsserMsg, ThrowRequire, ThrowRequireMsg -// runtime_error <-> ThrowErrorMsgIf, ThrowErrorMsg -// invalid_argument <-> ThrowInvalidArgMsgIf, ThrowInvalidArgIf -// -// Please note the logic of the errors is the opposite of the asserts. The -// asserts will throw exceptions if the given expression is false; for the -// error macros, exceptions will be thrown if the given expression is true. -// -// USE: -// All of the following have versions that do not require a message, but -// we strongly encourage developers to use the versions that take the -// message. -// -// ASSERTS: -// ThrowAssertMsg(expr, message); -// If NDEBUG is not defined, throw a logic error if expr evaluates to -// false, adding message to the error message . Use this for expensive -// logic-mistake checks that could impact performance. -// -// ThrowRequireMsg(code, message); -// Always throw a logic error if expr evaluates to false, adding message -// to error message. Use this for inexpensive logic-mistake checks -// that do not impact performance. -// -// ERRORS: -// ThrowErrorMsgIf(expr, message); -// Throw a runtime error if expr evaluates to true, adding message to -// the error message. Use this to generate errors dealing with system -// errors or other errors that do not involve invalid parameters being -// passed to functions. -// -// ThrowInvalidArgMsgIf(expr, message); -// Throw an invalid_argument error if expr evaluates to true, adding -// message to the error message. Use this to generate errors dealing with -// users passing invalid arguments to functions in the API. -// -// EXAMPLES: -// -// 1) Require that i equals j, demonstate use of put-tos in the message arg -// ThrowRequireMsg(i == j, "i(" << i << ") != j(" << j << ")"); -// -// 2) Check method argument foo is not NULL -// ThrowInvalidArgMsgIf(foo != NULL, "Arg foo is NULL"); - -#define ThrowRequireMsg(expr,message) ThrowGenericCond(expr, message, handle_assert) -#define ThrowRequire(expr) ThrowRequireMsg(expr, "") - -#ifdef NDEBUG -# define ThrowAssert(expr) ((void) (0)) -# define ThrowAssertMsg(expr,message) ((void) (0)) -#else -# define ThrowAssert(expr) ThrowRequire(expr) -# define ThrowAssertMsg(expr,message) ThrowRequireMsg(expr,message) -#endif - -#define ThrowErrorMsgIf(expr, message) ThrowGenericCond( !(expr), message, handle_error) -#define ThrowErrorIf(expr) ThrowErrorMsgIf(expr, "") -#define ThrowErrorMsg(message) ThrowGeneric( message, handle_error ) - -#define ThrowInvalidArgMsgIf(expr, message) ThrowGenericCond( !(expr), message, handle_invalid_arg) -#define ThrowInvalidArgIf(expr) ThrowInvalidArgMsgIf(expr, "") - -/// -/// @} -/// - -#endif // STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.cpp deleted file mode 100644 index 215981a7d39e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -namespace stk_classic { - -unsigned int -get_doomed_count() -{ - return get_message_count(MSG_DOOMED); -} - - -void -reset_doomed_count() -{ - reset_message_count(MSG_DOOMED); -} - - -void -set_max_doomed_count( - unsigned int max_messages) -{ - set_max_message_count(MSG_DOOMED, max_messages); -} - - -unsigned -get_max_doomed_count() -{ - return get_max_message_count(MSG_DOOMED); -} - - -void -report_doomed( - const char * message, - const MessageCode & message_code) -{ - report_message(message, MSG_DOOMED, message_code); -} - - -void -report_symmetric_doomed( - const char * message, - const MessageCode & message_code) -{ - report_message(message, MSG_SYMMETRIC | MSG_DOOMED, message_code); -} - - -void -report_deferred_doomed( - const char * message, - const char * aggregate, - const MessageCode & message_code) -{ - add_deferred_message(MSG_DOOMED, message_code.m_id, message_code.m_throttle.m_cutoff, message_code.m_throttle.m_group, message, aggregate); -} - - -RuntimeDoomedAdHoc::RuntimeDoomedAdHoc( - const MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeDoomedAdHoc::~RuntimeDoomedAdHoc() -{ - try { - report_doomed(message.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - - -RuntimeDoomedSymmetric::RuntimeDoomedSymmetric( - const MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeDoomedSymmetric::~RuntimeDoomedSymmetric() -{ - try { - report_symmetric_doomed(message.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - - -RuntimeDoomedDeferred::RuntimeDoomedDeferred( - const MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeDoomedDeferred::~RuntimeDoomedDeferred() -{ - try { - report_deferred_doomed(message.str().c_str(), aggregate.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - -} // namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.hpp deleted file mode 100644 index 7aa8e1192a25..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeDoomed.hpp +++ /dev/null @@ -1,406 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP -#define STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP - -#include - -#include - -namespace stk_classic { - -typedef std::ostream &(*OStreamFunctionPtr)(std::ostream &); -typedef std::ios_base &(*IOSBaseFunctionPtr)(std::ios_base &); - -/// -/// @addtogroup runtime_message_detail -/// @{ -/// - -/** - * @brief Function get_doomed_count returns the accumulated doomed count. - * - */ -unsigned get_doomed_count(); - -/** - * @brief Function is_doomed returns true if get_doomed_count() > 0. - * - * @return a bool value of true if get_doomed_count() > 0. - */ -inline bool is_doomed() { - return get_doomed_count() > 0; -} - -/** - * @brief Function reset_doomed_count sets the accumulated doomed count to zero. - * - */ -void reset_doomed_count(); - -/** - * @brief Function set_max_messages sets the maximum number of doomed before no more doomed - * will be displayed. - * - * @param max_messages an int variable ... - * - */ -void set_max_doomed_count(unsigned int max_messages); - -/** - * @brief Function set_max_messages sets the maximum number of doomed - * and doomed messages displayed before the message is thrown as a RuntimeError exception. - * - */ -unsigned get_max_doomed_count(); - -/** - * @brief Function report_symmetric_doomed sends a doomed message to the reporter. - * - * Since the issue causing the doomed error may occur thousands of times during a run, it is - * desirable to throttle the number of times that a message is displayed. If you desire to limit - * the number of times a message is displayed, obtain a unique id via the get_next_message_id() - * function. This function allows you to assign the maximum display count. When the count of - * messages reported with this message id exceeds the display count, it is no longer displayed. The - * default id zero (0) is assigned which has an extremely large display count. - * - * @param message a char const pointer to a message that is to be displayed. - * - * @param message_code a MessageCode const pointer to a cross-processor unique - * identification of this message. - * - */ -void report_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); - -/** - * @brief Function report_symmetric_doomed sends a doomed message to the reporter. - * - * Since the issue causing the doomed error may occur thousands of times during a run, it is - * desirable to throttle the number of times that a message is displayed. If you desire to limit - * the number of times a message is displayed, obtain a unique id via the get_next_message_id() - * function. This function allows you to assign the maximum display count. When the count of - * messages reported with this message id exceeds the display count, it is no longer displayed. The - * default id zero (0) is assigned which has an extremely large display count. - * - * @param message a char const pointer to a message that is to be displayed. - * - * @param message_code a MessageCode const pointer to a cross-processor unique - * identification of this message. - * - */ -void report_symmetric_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); - -/** - * @brief Member function report_deferred_doomed ... - * - * @param message a std::string const ... - * - * @param aggregate a std::string const ... - * - * @param message_code a MessageCode const ... - * - */ -void report_deferred_doomed(const char *message, const char *aggregate, const MessageCode &message_code); - -/** - * @brief Class RuntimeDoomedAdHoc reports an ad hoc doomed message to the report system. - * - * For example: - * - *

- *     if (adhoc_runtime_doomed_condition)
- *       RuntimeDoomedAdHoc() << "My useful message about " << some_data;
- *
- *     if (adhoc_runtime_doomed_condition) {
- *       static MessageCode mc;
- *       RuntimeDoomedAdHoc(mc) << "My useful message about " << some_data;
- *     }
- * 
- */ -class RuntimeDoomedAdHoc -{ -public: - /** - * @brief Creates a new RuntimeDoomedAdHoc instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeDoomedAdHoc(const MessageCode &message_code = MessageCode::s_defaultMessageCode); - - /** - * @brief Destroys a RuntimeDoomedAdHoc instance. - * - * The message is displayed by calling the report_doomed() function. However, if the count of - * remaining messages for this message id is zero, the message is not displayed. - * - */ - ~RuntimeDoomedAdHoc(); - -private: - /** - * @brief Make copy of RuntimeDoomedAdHoc invalid. - * - */ - RuntimeDoomedAdHoc(const RuntimeDoomedAdHoc &); - - /** - * @brief Make assignment of RuntimeDoomedAdHoc invalid. - * - */ - RuntimeDoomedAdHoc &operator=(const RuntimeDoomedAdHoc &); - -public: - /** - * @brief Member function operator<< passes the output stream manipulator to the - * output stream. - * - * @return a RuntimeDoomedAdHoc reference to this object - */ - RuntimeDoomedAdHoc &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator to the output - * stream. - * - * @return a RuntimeDoomedAdHoc reference to this object - */ - RuntimeDoomedAdHoc &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeDoomedAdHoc reference to this object; - */ - template - RuntimeDoomedAdHoc &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - - -/** - * @brief Class RuntimeDoomedSymmetric reports a fatal error message to the report system. - * - * For example: - * - *
- *     if (symmetric_runtime_doomed_condition)
- *       RuntimeDoomedSymmetric() << "My useful message about " << some_data;
- *
- *     if (symmetric_runtime_doomed_condition) {
- *       static MessageCode mc;
- *       RuntimeDoomedSymmetric(mc) << "My useful message about " << some_data;
- *     }
- * 
- */ -class RuntimeDoomedSymmetric -{ -public: - /** - * @brief Creates a new RuntimeDoomedSymmetric instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeDoomedSymmetric(const MessageCode &message_code = MessageCode::s_defaultMessageCode); - - /** - * @brief Destroys a RuntimeDoomedSymmetric instance. - * - * The message is displayed by calling the report_doomed() function. However, if the count of - * remaining messages for this message id is zero, the message is not displayed. - * - */ - ~RuntimeDoomedSymmetric(); - -private: - /** - * @brief Make copy of RuntimeDoomedSymmetric invalid. - * - */ - RuntimeDoomedSymmetric(const RuntimeDoomedSymmetric &); - - /** - * @brief Make assignment of RuntimeDoomedSymmetric invalid. - * - */ - RuntimeDoomedSymmetric &operator=(const RuntimeDoomedSymmetric &); - -public: - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeDoomedSymmetric reference to this object - */ - RuntimeDoomedSymmetric &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeDoomedSymmetric reference to this object - */ - RuntimeDoomedSymmetric &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeDoomedSymmetric reference to this object; - */ - template - RuntimeDoomedSymmetric &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - - -/** - * @brief Class RuntimeDoomedDeferred reports a deferred fatal error message to the report - * system. - * - * For example: - * - *
- *     if (deferred_runtime_doomed_condition) {
- *       static MessageCode mc;
- *       RuntimeDoomedDeferred(mc) << "My useful message about " << some_data;
- *     }
- *
- *     if (deferred_runtime_doomed_condition) {
- *       static MessageCode mc;
- *       RuntimeDoomedDeferred x;
- *       x << "My useful message about " << some_data;
- *       x.aggregate << proc_specific_data;
- *     }
- * 
- */ -class RuntimeDoomedDeferred -{ -public: - /** - * @brief Creates a new RuntimeDoomedDeferred instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeDoomedDeferred(const MessageCode &message_code); - - /** - * @brief Destroys a RuntimeDoomed instance. - * - * The message is displayed by calling the add_deferred_message() function. - * - */ - ~RuntimeDoomedDeferred(); - -private: - /** - * @brief Make copy of RuntimeDoomedDeferred invalid. - * - */ - RuntimeDoomedDeferred(const RuntimeDoomedDeferred &); - - /** - * @brief Make assignment of RuntimeDoomedDeferred invalid. - * - */ - RuntimeDoomedDeferred &operator=(const RuntimeDoomedDeferred &); - -public: - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeDoomedDeferred reference to this object - */ - RuntimeDoomedDeferred &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeDoomedDeferred reference to this object - */ - RuntimeDoomedDeferred &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeDoomedDeferred reference to this object; - */ - template - RuntimeDoomedDeferred &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message header content - std::ostringstream aggregate; ///< Stream to receive message aggregate content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - -/// -/// @} -/// - -} // namespace stk_classic - -#endif // STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.cpp deleted file mode 100644 index f9b88e9e6697..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { - -MessageCode -MessageCode::s_defaultMessageCode(100000000); - -namespace { - -void bootstrap() -{ - register_message_type(MSG_WARNING, 10000000, "warning"); - register_message_type(MSG_DOOMED, 10000000, "error"); - register_message_type(MSG_EXCEPTION, 1000000, "exception"); - register_message_type(MSG_INFORMATION, 1000000, "informational"); -} - -stk_classic::Bootstrap x(bootstrap); - -typedef std::pair MessageKey; - -typedef boost::unordered_map MessageIdMap; - -MessageIdMap s_messageIdMap; - -MessageIdMap s_deferredMessageIdMap; - -struct DeferredMessage -{ - DeferredMessage() - {} - - DeferredMessage( - size_t type, - MessageId message_id, - size_t throttle_cutoff, - int throttle_group, - const std::string & header, - const std::string & aggregate) - : m_type(type), - m_messageId(message_id), - m_rank(0), - m_throttleCutoff(throttle_cutoff), - m_throttleGroup(throttle_group), - m_header(header), - m_aggregate(aggregate) - {} - - size_t m_type; - MessageId m_messageId; - int m_rank; - size_t m_throttleCutoff; - int m_throttleGroup; - std::string m_header; - std::string m_aggregate; -}; - -typedef std::vector DeferredMessageVector; - -struct DeferredMessageLess : public std::binary_function -{ - bool operator()(const DeferredMessage &key_1, const DeferredMessage &key_2) const { - return (key_1.m_type < key_2.m_type) - || (!(key_2.m_type < key_1.m_type) && key_1.m_messageId < key_2.m_messageId) - || (!(key_2.m_type < key_1.m_type) && !(key_2.m_messageId < key_1.m_messageId) && key_1.m_header < key_2.m_header); - } -}; - -DeferredMessageVector s_deferredMessageVector; - -struct MessageTypeInfo -{ - MessageTypeInfo() - : m_count(0), - m_maxCount(10000000), - m_name("unknown") - {} - - unsigned m_count; - unsigned m_maxCount; - std::string m_name; -}; - -typedef boost::unordered_map MessageTypeInfoMap; - -MessageTypeInfoMap s_messageTypeInfo; - -MessageTypeInfo & -get_message_type_info( - unsigned type) -{ - MessageTypeInfoMap::iterator it = s_messageTypeInfo.find(type & MSG_TYPE_MASK); - if (it != s_messageTypeInfo.end()) - return (*it).second; - else - return s_messageTypeInfo[type & MSG_TYPE_MASK]; -} - - -enum CutoffStatus { - MSG_DISPLAY = 0, - MSG_CUTOFF = 1, - MSG_CUTOFF_EXCEEDED = 2 -}; - - -CutoffStatus -count_message( - MessageId message_id, - const char * message, - const Throttle & throttle) -{ - std::pair res = s_messageIdMap.insert(MessageIdMap::value_type(MessageIdMap::key_type(message_id, message), throttle)); - size_t count = ++(*res.first).second.m_count; - - if (count < (*res.first).second.m_cutoff) - return MSG_DISPLAY; - else if (count == (*res.first).second.m_cutoff) - return MSG_CUTOFF; - else - return MSG_CUTOFF_EXCEEDED; -} - -Marshal &operator<<(Marshal &mout, const DeferredMessage &s) { - mout << s.m_type << s.m_messageId << s.m_rank << s.m_throttleGroup << s.m_throttleCutoff << s.m_header << s.m_aggregate; - return mout; -} - -Marshal &operator>>(Marshal &min, DeferredMessage &s) { - min >> s.m_type >> s.m_messageId >> s.m_rank >> s.m_throttleGroup >> s.m_throttleCutoff >> s.m_header >> s.m_aggregate; - return min; -} - -} // namespace - - -void -register_message_type( - unsigned message_type, - unsigned max_count, - const char * name) -{ - MessageTypeInfo &message_info = get_message_type_info(message_type); - - message_info.m_maxCount = max_count; - message_info.m_name = name; -} - - -unsigned -get_message_count( - unsigned message_type) -{ - return get_message_type_info(message_type).m_count; -} - - -unsigned -increment_message_count( - unsigned message_type) -{ - return ++get_message_type_info(message_type).m_count; -} - - -void -reset_message_count( - unsigned message_type) -{ - get_message_type_info(message_type).m_count = 0; -} - - -const std::string & -get_message_name( - unsigned message_type) -{ - return get_message_type_info(message_type).m_name; -} - - -void -set_max_message_count( - unsigned message_type, - unsigned max_count) -{ - get_message_type_info(message_type).m_maxCount = max_count; -} - - -unsigned -get_max_message_count( - unsigned message_type) -{ - return get_message_type_info(message_type).m_maxCount; -} - - -void -report_message( - const char * message, - unsigned message_type, - const MessageCode & message_code) -{ - if (message_type & MSG_DEFERRED) - report(message, message_type); - - else { - unsigned count = increment_message_count(message_type); - unsigned max_count = get_max_message_count(message_type); - - if (count == max_count) { - report(message, message_type); - - std::ostringstream s; - s << "Maximum " << get_message_name(message_type) << " count has been exceeded and will no longer be displayed"; - report(s.str().c_str(), MSG_WARNING | MSG_SYMMETRIC); - } - - else if (count < max_count) { - CutoffStatus cutoff = count_message(message_code.m_id, "", message_code.m_throttle); - - if (cutoff == MSG_CUTOFF) { - report(message, message_type); - - std::ostringstream s; - s << "Maximum count for this " << get_message_name(message_type) << " has been exceeded and will no longer be displayed"; - report(s.str().c_str(), MSG_WARNING | MSG_SYMMETRIC); - } - - else if (cutoff == MSG_DISPLAY) - report(message, message_type); - } - } -} - - -void -reset_throttle_group( - int throttle_group) -{ - for (MessageIdMap::iterator it = s_messageIdMap.begin(); it != s_messageIdMap.end(); ++it) - if ((*it).second.m_group == throttle_group) - (*it).second.m_count = 0; -} - - -void -add_deferred_message( - int message_type, - MessageId message_id, - size_t throttle_cutoff, - int throttle_group, - const char * header, - const char * aggegrate) -{ - std::ostringstream s; - s << header << " " << aggegrate; - - report(s.str().c_str(), message_type | MSG_DEFERRED); - - std::pair res = s_deferredMessageIdMap.insert(MessageIdMap::value_type(MessageIdMap::key_type(message_id, header), Throttle(throttle_cutoff, throttle_group))); - size_t count = ++(*res.first).second.m_count; - - if (count <= throttle_cutoff) - s_deferredMessageVector.push_back(DeferredMessage(message_type, message_id, throttle_cutoff, throttle_group, header, aggegrate)); -} - - -/// @todo REFACTOR Should the message counts be broadcast to the other processors? - -void -report_deferred_messages( - ParallelMachine comm) -{ -#ifdef STK_HAS_MPI - const int p_root = 0 ; - const int p_size = parallel_machine_size(comm); - const int p_rank = parallel_machine_rank(comm); - - for (DeferredMessageVector::iterator it = s_deferredMessageVector.begin(); it != s_deferredMessageVector.end(); ++it) - (*it).m_rank = p_rank; - - Marshal mout; - mout << s_deferredMessageVector; - - DeferredMessageVector deferred_message_vector; - - // Gather the send counts on root processor - std::string send_string(mout.stream.str()); - int send_count = send_string.size(); - std::vector recv_count(p_size, 0); - int * const recv_count_ptr = &recv_count[0] ; - - int result = MPI_Gather(&send_count, 1, MPI_INT, - recv_count_ptr, 1, MPI_INT, - p_root, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::report_deferred_messages FAILED: MPI_Gather = " << result ; - throw std::runtime_error(message.str()); - } - - // Receive counts are only non-zero on the root processor: - std::vector recv_displ(p_size + 1, 0); - - for (int i = 0 ; i < p_size ; ++i) { - recv_displ[i + 1] = recv_displ[i] + recv_count[i] ; - } - - const int recv_size = recv_displ[p_size] ; - - std::vector buffer(recv_size); - - { - const char * const send_ptr = send_string.data(); - char * const recv_ptr = recv_size ? & buffer[0] : (char *) NULL ; - int * const recv_displ_ptr = & recv_displ[0] ; - - result = MPI_Gatherv((void *) send_ptr, send_count, MPI_CHAR, - recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR, - p_root, comm); - if (MPI_SUCCESS != result) { - std::ostringstream message ; - message << "stk_classic::report_deferred_messages FAILED: MPI_Gatherv = " << result ; - throw std::runtime_error(message.str()); - } - - - if (p_rank == p_root) { - for (int i = 0; i < p_size; ++i) { - Marshal min(std::string(recv_ptr + recv_displ[i], recv_ptr + recv_displ[i + 1])); - min >> deferred_message_vector; - } - - std::stable_sort(deferred_message_vector.begin(), deferred_message_vector.end(), DeferredMessageLess()); - - DeferredMessageVector::const_iterator current_message_it = deferred_message_vector.begin(); - while (current_message_it != deferred_message_vector.end()) { - const DeferredMessage ¤t_message = (*current_message_it); - - DeferredMessageVector::const_iterator end = current_message_it + 1; - while (end != deferred_message_vector.end() - && current_message.m_messageId == (*end).m_messageId - && current_message.m_header == (*end).m_header) - ++end; - - std::ostringstream s; - - s << current_message.m_header << current_message.m_aggregate; - - for (DeferredMessageVector::const_iterator it1 = current_message_it + 1; it1 != end; ++it1) { - bool print = true; - for (DeferredMessageVector::const_iterator it2 = current_message_it; it2 != it1; ++it2) - if ((*it1).m_aggregate == (*it2).m_aggregate) { - print = false; - break; - } - if (print) { - if (!(*it1).m_aggregate.find('\n')) - s << ", "; - s << (*it1).m_aggregate; - } - } - - report_message(s.str().c_str(), current_message.m_type | stk_classic::MSG_SYMMETRIC, MessageCode(current_message.m_messageId, current_message.m_throttleCutoff, current_message.m_throttleGroup)); - - current_message_it = end; - } - } - } - - s_deferredMessageIdMap.clear(); - s_deferredMessageVector.clear(); -#endif -} - - -void -aggregate_messages( - ParallelMachine comm, - std::ostringstream & os, - const char * separator) -{ -#ifdef STK_HAS_MPI - std::string message = os.str(); - os.str(""); - - const int p_root = 0 ; - const int p_size = parallel_machine_size(comm); - const int p_rank = parallel_machine_rank(comm); - - int result ; - - // Gather the send counts on root processor - - int send_count = message.size(); - - std::vector recv_count(p_size, 0); - - int * const recv_count_ptr = & recv_count[0] ; - - result = MPI_Gather(& send_count, 1, MPI_INT, - recv_count_ptr, 1, MPI_INT, - p_root, comm); - - if (MPI_SUCCESS != result) { - std::ostringstream s; - s << "stk_classic::all_write FAILED: MPI_Gather = " << result ; - throw std::runtime_error(s.str()); - } - - // Receive counts are only non-zero on the root processor: - std::vector recv_displ(p_size + 1, 0); - - for (int i = 0 ; i < p_size ; ++i) { - recv_displ[i + 1] = recv_displ[i] + recv_count[i] ; - } - - const int recv_size = recv_displ[ p_size ] ; - - std::vector buffer(recv_size); - - { - const char * const send_ptr = message.c_str(); - char * const recv_ptr = recv_size ? & buffer[0] : (char *) NULL ; - int * const recv_displ_ptr = & recv_displ[0] ; - - result = MPI_Gatherv((void*) send_ptr, send_count, MPI_CHAR, - recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR, - p_root, comm); - } - - if (MPI_SUCCESS != result) { - std::ostringstream s ; - s << "stk_classic::all_write FAILED: MPI_Gatherv = " << result ; - throw std::runtime_error(s.str()); - } - - if (p_root == (int) p_rank) { - bool first = true; - for (int i = 0 ; i < p_size ; ++i) { - if (recv_count[i]) { - if (!first) - os << separator; - first = false; - char * const ptr = & buffer[ recv_displ[i] ]; - os.write(ptr, recv_count[i]); - } - } - os.flush(); - } - else - os << message; -#endif -} - - -std::ostream & -operator<<( - std::ostream & os, - const MessageType & message_type) -{ -// if (message_type & MSG_SYMMETRIC) -// os << "parallel "; - os << get_message_type_info(message_type).m_name; - - return os; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.dox b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.dox deleted file mode 100644 index f2421b0f399f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.dox +++ /dev/null @@ -1,259 +0,0 @@ -/// -/// \addtogroup stk_util_runtime_message_detail -/// @{ -/// -/// @brief Runtime messages are warning and errors which may occur in parallel that need to be -/// reported to the anaylst which may need to be collected to a root processor and written with -/// greater emphasis than regular output. -/// -/// Parallel system architectures greatly complicate the reporting of warning and fatal error -/// messages. To simplify this, messages are categorized by their generation mechanism. Some -/// messages are generated symmetrically, meaning that all processors contain the exact same -/// information and the root processor may simply write it's message to the log file and the -/// remaining may simple ignore it. Some messages are generated in an ad hoc manner, meaning that -/// some processors may generate them at any time, and the output can simply be collected to the root -/// processor at a later time and reported. And some are generated by several processors with -/// related information and deferred until they should be aggregated to the root processor written -/// as an assembled condensed message. -/// -/// The message is displayed prominently by the report_handler() via the report() function. Each -/// application registers a report_handler with the set_report_handler() function. The report() -/// accepts two arguments, the message string and a message type. The message types MSG_WARNING, -/// MSG_ERROR, MSG_INFORMATION and MSG_EXCEPTION are currently defined as well as two type flags, -/// MSG_SYMMETRIC and MSG_DEFERRED. These flags indicate the category of the message. Generally, -/// symmetric messages are written to the output log by the root processor and to the per-processor -/// log by the remaining processors, see \ref stk_util_runtime_message_symmetric. Ad hoc message are -/// collected at a parallel safe time and written to the output log by the root processor, see \ref -/// stk_util_runtime_message_adhoc. And, deferred message are written immediately to per-processors log and -/// aggregated to the root processors at a parallel safe time, see \ref stk_util_runtime_message_deferred. -/// -/// The messages are counted by the underlying message reporting functions and are limited by -/// message code and content and message occurance type. -/// -/// \anchor stk_util_runtime_message_howto_throttle -/// \section stk_util_runtime_message_counts Message Throttling and Counting -/// -/// The messages of each type are counted. Once the display count for a particular message has been -/// exceeded, that message will no longer be displayed. However, it continues to be counted. -/// Deferred messages are counted once for each aggregated message. -/// -/// By constructing a static MessageCode object, you can throttle the display of messages. These -/// must be static objects for the counting to function properly. See \ref MessageCode::MessageCode -/// MessageCode for details. When constructed, a max display count and a display group may be -/// provided. The count limits the number of times that the message is displayed. Once this count -/// has been exceeded, the message is no longer displayed. The group may be MSG_APPLICATION or -/// MSG_TIME_STEP. The display count for each group may be reset so allow messages to be display -/// for each time step, for instance, even if exceeded by the previous time step. -/// -/// The functions get_message_count(), get_warning_count() and get_doomed_count() return the current -/// accumulated counts. The root processor has the official count. Other processors counts may be -/// different. -/// -/// The maximum number of messages to be displayed during the execution of an application can be set -/// using the set_max_message_count(), set_max_warning_count() and set_max_doomed_count() functions. -/// -/// It may be important to count message during various points in the programs execution. So, to -/// reset the counts back to zero, use the reset_message_count(), reset_warning_count() and -/// reset_doomed_count() functions. -/// -/// For example: -/// -/// \code -/// -/// if (symmetric_handler_doomed_condition) { // limited to 5 fatal error messages -/// static MessageCode message_code(5); -/// RuntimeDoomedSymmetric(message_code) << "My useful message about " << some_data; -/// } -/// -/// if (symmetric_runtime_warning_condition) { // Limited to 5 warning messages on each time step -/// static MessageCode message_code(5, stk_classic::MSG_TIME_STEP); -/// RuntimeWarningSymmetric(message_code) << "My useful message about " << some_data; -/// } -/// -/// \endcode -/// -/// \anchor stk_util_runtime_message_howto_symmetric -/// \section stk_util_runtime_message_symmetric Symmetric Messages -/// -/// Since these messages are generated symmetrically across all processors, only the root processor -/// needs to send the output to the log. A message generated exclusively on the roor processor -/// could also be written symmetrically as this just relieves the other processors from ignoring the -/// message. These message often occur during input deck parsing and initialization. These -/// messages are counted and throttled on all processors, but have the same throttle count on all -/// processors. The functions report_message(), report_symmetric_warning() and -/// report_symmetric_doomed() send a message string and message type to the report() function. -/// -/// The sentry classes RuntimeWarningSymmetric and RuntimeDoomedSymmetric may be used to simplify -/// the coding of the messages. -/// -/// For example: -/// -/// \code -/// -/// if (symmetric_runtime_warning_condition) // Unlimited warning output -/// RuntimeWarningSymmetric() << "My useful message about " << some_data; -/// -/// if (symmetric_runtime_doomed_condition) // Unlimited doomed output -/// RuntimeDoomedSymmetric() << "My useful message about " << some_data; -/// -/// if (root_processor_runtime_warning_condition) // Unlimited warning output -/// RuntimeWarningSymmetric() << "My useful message about " << some_data; -/// -/// if (symmetric_handler_doomed_condition) { // limited to 5 fatal error messages -/// static MessageCode message_code(5); -/// RuntimeDoomedSymmetric(message_code) << "My useful message about " << some_data; -/// } -/// -/// if (symmetric_runtime_warning_condition) { // Limited to 5 warning messages on each time step -/// static MessageCode message_code(5, stk_classic::MSG_TIME_STEP); -/// RuntimeWarningSymmetric(message_code) << "My useful message about " << some_data; -/// } -/// -/// \endcode -/// -/// \anchor stk_util_runtime_message_howto_adhoc -/// \section stk_util_runtime_message_adhoc Ad hoc Messages -/// -/// Deprecated. Use deferred warnings and dooms. -/// -/// This is the old style message collection technique. Since the messages are not generated in a -/// parallel safe environment, they are buffered into a seperate output stream that is aggregated -/// and written when the main output stream is flushed at a parallel safe time. These message are -/// counted and throttles on each processor and therefore throttled on a per-processor basis. -/// -/// The sentry classes RuntimeWarningAdHoc and RuntimeDoomedAdHoc may be used to simplify the coding -/// of the messages. -/// -/// For example (deprecated): -/// -/// \code -/// -/// if (runtime_warning_condition) // Unlimited warning output -/// RuntimeWarning() << "My useful message about " << some_data; -/// -/// if (runtime_doomed_condition) // Unlimited doomed output -/// RuntimeDoomed() << "My useful message about " << some_data; -/// -/// if (root_processor_runtime_warning_condition) // Unlimited warning output -/// RuntimeWarning() << "My useful message about " << some_data; -/// -/// if (handler_doomed_condition) { // limited to 5 fatal error messages on this processor -/// static MessageCode message_code(5); -/// RuntimeDoomed(message_code) << "My useful message about " << some_data; -/// } -/// -/// if (runtime_warning_condition) { // Limited to 5 warning messages on each time step on this processor -/// static MessageCode message_code(5, stk_classic::MSG_TIME_STEP); -/// RuntimeWarning(message_code) << "My useful message about " << some_data; -/// } -/// -/// \endcode -/// -/// \anchor stk_util_runtime_message_howto_deferred -/// \section stk_util_runtime_message_deferred Deferred Messages -/// -/// This is the new style of message collection. These messages are also not generated in a -/// parallel safe environment but are buffered to the deferred message queue. When the main output -/// stream is flushed at a parallel safe time, the messages are collected to the root processor and -/// aggregated by message id and message content. All messages which are aggregated are counted as -/// singly and reported in the aggregated form. -/// -/// For deferred messages, the message is keyed by the message code and the non-aggregate message -/// content. This allows additional aggregation possibilities. -/// -/// The sentry classes RuntimeWarningDeferred and RuntimeDoomedDeferred may be used to simplify the -/// coding of the messages. -/// -/// For example: -/// -/// \code -/// -/// if (handler_doomed_condition) { // limited to 5 fatal error messages -/// static MessageCode message_code(5); -/// RuntimeDoomedDeferred(message_code) << "My useful message about " << some_data; -/// } -/// -/// if (runtime_warning_condition) { // Limited to 5 warning messages on each time step -/// static MessageCode message_code(5, stk_classic::MSG_TIME_STEP); -/// RuntimeWarningDeferred(message_code) << "My useful message about " << some_data; -/// } -/// -/// if (handler_doomed_condition) { // limited to 5 fatal error messages -/// static MessageCode message_code(5); -/// RuntimeDoomedDeferred x(message_code); -/// x << "My useful message about " << some_data; -/// x.aggregate << "my proc info"; -/// } -/// -/// if (runtime_warning_condition) { // Limited to 5 warning messages on each time step -/// static MessageCode message_code(5, stk_classic::MSG_TIME_STEP); -/// RuntimeWarningDeferred x(message_code); -/// x << "My useful message about " << some_data; -/// x.aggregate << "my proc info"; -/// } -/// -/// \endcode -/// -/// -/// \section stk_util_runtime_message_assembly Message Assembly -/// -/// Messages are generally assembled into a string output stream and this string is reported via the -/// report() mechanism. You may select to use a variety of interfaces to accomplish this. -/// -/// The lowest level functions are the report_warning(), report_symmetric_warning() and -/// report_deferred_warning() functions. These functions are counted by message code and write the -/// message based on the category, ad hoc, symmetric or deferred. -/// -/// There are three convenience classes that make the assembly easier for a developer to identify -/// and simpler to code. The RuntimeWarning, RuntimeWarningSymmetric and RuntimeWarningDeferred -/// sentry classes are constructed with an optional message code, accept additional data via the -/// put-to (<<) operator and report the message upon destruction. All of these classes present the -/// output string stream as the public member variable 'message'. And, the RuntimeWarningDeferred -/// class presents the 'aggregate' public member variable to be written to with aggregation text. -/// -/// \anchor stk_util_runtime_message_howto_assembly -/// For example: -/// -/// \code -/// -/// if (runtime_doomed_condition) // Unlimited fatal error output -/// RuntimeDoomedSymmetric() << "My useful message about " << some_data << " and will die soon"; -/// -/// if (runtime_doomed_condition) { // Unlimited fatal error output -/// RuntimeDoomedSymmetric x; -/// x << "My useful message about " << some_data << " and will die soon"; -/// for (int i = 0; i < 10; ++i) -/// x << " " << i; -/// } -/// -/// if (runtime_doomed_condition) { // Unlimited fatal error output -/// RuntimeDoomedSymmetric x; -/// x.message << "My useful message about " << some_data << " and will die soon"; -/// for (int i = 0; i < 10; ++i) -/// x.message << " " << i; -/// } -/// -/// if (runtime_doomed_condition) { // Unlimited fatal error output -/// std::ostringstream s; -/// x << "My useful message about " << some_data << " and will die soon"; -/// stk_classic::report_symmetic_warning(s.str()); -/// } -/// -/// \endcode -/// -/// \section stk_util_runtime_message_reporting Message Reporting -/// -/// The report functions send the assembled message string and message type to the registered -/// report_handler() function. The report handler function has the signature: -/// -/// \code -/// report_handler(const char *message, int type) -/// \endcode -/// -/// and is set with set_report_handler(). -/// -/// If you want special decorations around your messages during execution, you can change the -/// reporter. -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.hpp deleted file mode 100644 index 8961849bb5d5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeMessage.hpp +++ /dev/null @@ -1,308 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP -#define STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP - -#include -#include -#include - -#include - -namespace stk_classic { - -/// -/// @addtogroup runtime_message_detail -/// @{ -/// - -/** - * @file - */ - -/** - * @brief Typedef MessageId defines a message identifier. - * - * Message identifiers must be consist from reference to reference, unique for each instance, and - * yet consist within each instance across multiple processors. To meet these criteria, the message - * identifier is implemented as a static memory location. It must be declared by the application - * developer as static. This results in the linker selecting an address for each instance, which - * never changes from reference to reference, is unique for each instance and the same regardless of - * executable (assuming the executable is mapped into the same memory location for each process). - * In order to remove the pointer-ness of the static memory location, the address is cast to a - * pointer difference type which is an integral type by subtracting the zero pointer from it. - * - */ -typedef ptrdiff_t MessageId; -// typedef std::vector::difference_type MessageId; - -/** - * @brief Enumeration MessageType declares the global message types. - * - * Currently warning and doomed (error) message types are defined. Additional type may be added - * after MSG_DOOMED. The MSG_SYMMETRIC bit indicates that the message was generated identically - * across all processors. - * - */ -enum MessageType { - MSG_WARNING = 0, ///< Message is a warning - MSG_DOOMED = 1, ///< Message is a fatal error - MSG_EXCEPTION = 2, ///< Message is an exception - MSG_INFORMATION = 3, ///< Message is informational - - MSG_TYPE_MASK = 0x0FFFFFFF, ///< Mask of levels - MSG_SYMMETRIC = 0x80000000, ///< Message is symmetrical - MSG_DEFERRED = 0x40000000, ///< Message is deferred - MSG_UNUSED0 = 0x20000000, - MSG_UNUSED1 = 0x10000000 -}; - -/** - * @brief Enumeration ThrottleGroup lists defined throttling groups. - * - * When messages are throttled, the throttle count may be reset at varior points during an - * application run. Some throttles defined for the application, while other may be reset at each - * time step or other interval. This allows warnings to be repeated at each time step rather than - * cut off. - * - */ -enum ThrottleGroup { - MSG_APPLICATION = 0, - MSG_TIME_STEP = 1 -}; - -/** - * @brief Class Throttle describes the cutoff limits for a message throttle. - * - */ -struct Throttle -{ - /** - * Creates a new Throttle instance. - * - * @param cutoff a size_t value to display before the message is no longer - * displayed. - * - * @param group an int value to identify the throttle group that this message - * belongs to. - * - */ - Throttle(size_t cutoff, int group) - : m_cutoff(cutoff), - m_group(group), - m_count(0) - {} - - size_t m_cutoff; ///< Maximum number to display - int m_group; ///< Throttle group of message - size_t m_count; ///< Number which have been displayed -}; - -/** - * @brief Class MessageCode declares a message identifier and throttle characteristics for a - * message. THESE MUST BE DECLARED STATIC. - * - * All messages have an associated message code. This message code is used to identify a message - * for throttling and aggregation. - * - * Message identifiers must be consist from reference to reference, unique for each instance, and - * yet consist within each instance across multiple processors. To meet these criteria, the message - * identifier is implemented as a static memory location. It must be declared by the application - * developer as static. This results in the linker selecting an address for each instance, which - * never changes from reference to reference, is unique for each instance and the same regardless of - * executable (assuming the executable is mapped into the same memory location for each process). - * In order to remove the pointer-ness of the static memory location, the address is cast to a - * pointer difference type which is an integral type by subtracting the zero pointer from it. - * - */ -struct MessageCode -{ - /** - * Creates a new MessageCode instance. - * - * @param throttle_cutoff a size_t value to display before the message is no longer - * displayed. - * - * @param throttle_group an int value to identify the throttle group that this message - * belongs to. - * - */ - MessageCode(size_t throttle_cutoff = 5, int throttle_group = MSG_APPLICATION) - : m_id(&m_id - (MessageId *) 0), - m_throttle(throttle_cutoff, throttle_group) - {} - - /** - * Creates a new MessageCode instance. Be particularly careful when usnig this - * constructor. The message_id value must be the same on all processors for deferred message - * reporting to work properly. - * - * @param message_id a MessageId value of the message id. This value must be the - * same for each message across all processors. - * - * @param throttle_cutoff a size_t value to display before the message is no longer - * displayed. - * - * @param throttle_group an int value to identify the throttle group that this message - * belongs to. - * - */ - MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group) - : m_id(message_id), - m_throttle(throttle_cutoff, throttle_group) - {} - - static MessageCode s_defaultMessageCode; ///< Default message code - - MessageId m_id; ///< Message identifier - Throttle m_throttle; ///< Throttle characteristics -}; - -/** - * @brief Member function get_message_count ... - * - * @param message_type an unsigned int ... - * - * @return an unsigned int ... - */ -unsigned get_message_count(unsigned message_type); - -/** - * @brief Member function reset_message_count ... - * - * @param message_type an unsigned int ... - * - */ -void reset_message_count(unsigned message_type); - -/** - * @brief Member function set_max_message_count ... - * - * @param message_type an unsigned int ... - * - * @param max_count an unsigned int ... - * - */ -void set_max_message_count(unsigned message_type, unsigned max_count); - -/** - * @brief Member function get_max_message_count ... - * - * @param message_type an unsigned int ... - * - * @return an unsigned int ... - */ -unsigned get_max_message_count(unsigned message_type); - -/** - * @brief Member function get_message_name ... - * - * @param message_type an unsigned int ... - * - * @return a std::string ... - */ -const std::string &get_message_name(unsigned message_type); - -/** - * @brief Member function set_message_name ... - * - * @param message_type an unsigned int ... - * - * @param max_count an unsigned int ... - * - * @param name a std::string const ... - * - */ -void register_message_type(unsigned message_type, unsigned max_count, const char *name); - -/** - * @brief Function reset_message_group sets the count to zero of all messages in the - * specified throttle group. - * - * @param throttle_group an int value of the throttle group to reset. - * - */ -void reset_throttle_group(int throttle_group); - -/** - * @brief Member function report_message ... - * - * @param message an char const pointer ... - * - * @param message_type an unsigned int ... - * - * @param message_code a MessageCode ... - * - * @return an unsigned int ... - */ -void report_message(const char *message, unsigned message_type, const MessageCode &message_code); - -/** - * @brief Function add_deferred_message adds a message to the deferred message queue. - * - * @param message_type an int value of the message type, usually WARNING or DOOMED - * - * @param message_id a MessageId value of the message identifier - * - * @param throttle_cutoff a size_t value to display before the message is no longer - * displayed. - * - * @param throttle_group an int value to identify the throttle group that this message - * belongs to. - * - * @param header a char const pointer to the message header string. - * - * @param aggegrate a char const pointer to the message aggregation string. - * - */ -void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate); - -/** - * @brief Function report_deferred_messages aggregates and reports the message on the root - * processor. - * - * @param comm a ParallelMachine communicator. - * - */ -void report_deferred_messages(ParallelMachine comm); - -/** - * @brief Function aggregate_messages writes a message message to the output string by - * joining the messages from each processor, in order. Each message is separated by the specified - * separation string. - * - * @param comm a ParallelMachine communicator. - * - * @param os a std::ostream reference to the output stream to receive the - * aggregated message. - * - * @param separator a char const pointer to the separation string. - * - */ -void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator = ", "); - -/** - * @brief Function operator<< writes the message type name to the output stream. If the - * symmetric bit is set, "parallel" is prefixed to the name. - * - * @param os a std::ostream reference to the output stream. - * - * @param message_type a MessageType const reference to write the name of. - * - * @return a std::ostream reference to os - */ -std::ostream &operator<<(std::ostream &os, const MessageType &message_type); - -/// -/// @} -/// - -} // namespace stk_classic - -#endif // STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.cpp deleted file mode 100644 index 02be36302c67..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -namespace stk_classic { - -unsigned -get_warning_count() -{ - return get_message_count(MSG_WARNING); -} - - -void -reset_warning_count() -{ - reset_message_count(MSG_WARNING); -} - - -void -set_max_warning_count( - unsigned int max_warnings) -{ - set_max_message_count(MSG_WARNING, max_warnings); -} - - -unsigned -get_max_warning_count() -{ - return get_max_message_count(MSG_WARNING); -} - - -void -report_warning( - const char * message, - const MessageCode & message_code) -{ - report_message(message, MSG_WARNING, message_code); -} - - -void -report_symmetric_warning( - const char * message, - const MessageCode & message_code) -{ - report_message(message, MSG_SYMMETRIC | MSG_WARNING, message_code); -} - - -void -report_deferred_warning( - const char * message, - const char * aggregate, - const MessageCode & message_code) -{ - add_deferred_message(MSG_WARNING, message_code.m_id, message_code.m_throttle.m_cutoff, message_code.m_throttle.m_group, message, aggregate); -} - - -RuntimeWarningAdHoc::RuntimeWarningAdHoc( - MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeWarningAdHoc::~RuntimeWarningAdHoc() -{ - try { - report_warning(message.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - - -RuntimeWarningSymmetric::RuntimeWarningSymmetric( - MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeWarningSymmetric::~RuntimeWarningSymmetric() -{ - try { - report_symmetric_warning(message.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - - -RuntimeWarningDeferred::RuntimeWarningDeferred( - const MessageCode & message_code) - : m_messageCode(message_code) -{} - - -RuntimeWarningDeferred::~RuntimeWarningDeferred() -{ - try { - report_deferred_warning(message.str().c_str(), aggregate.str().c_str(), m_messageCode); - } - catch (std::exception &) - {} -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.hpp deleted file mode 100644 index 9352b6312a1f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/RuntimeWarning.hpp +++ /dev/null @@ -1,390 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP -#define STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP - -#include - -#include - -namespace stk_classic { - -typedef std::ostream &(*OStreamFunctionPtr)(std::ostream &); -typedef std::ios_base &(*IOSBaseFunctionPtr)(std::ios_base &); - -/// -/// @addtogroup runtime_message_detail -/// @{ -/// - -/** - * @brief Function get_warning_count returns the accumulated warning count. - * - */ -unsigned get_warning_count(); - -/** - * @brief Function reset_warning_count sets the accumulated warning count to zero. - * - */ -void reset_warning_count(); - -/** - * @brief Function set_max_messages sets the maximum number of warning before no more warning - * will be displayed. - * - * @param max_messages an int variable ... - * - */ -void set_max_warning_count(unsigned int max_messages); - -/** - * @brief Function set_max_messages sets the maximum number of warning - * and doomed messages displayed before the message is thrown as a RuntimeError exception. - * - */ -unsigned get_max_warning_count(); - -/** - * @brief Member function report_warning ... - * - * @param message a char const pointer ... - * - * @param message_code a MessageCode const ... - * - */ -void report_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); - -/** - * @brief Function report_symmetric_warning sends a warning message to the reporter. - * - * Since the issue causing the warnign may occure thousands of times during a run, it is desirable - * to throttle the number of times that a message is displayed. If you desire to limit the number - * of times a message is displayed, obtain a unique id via the get_next_message_id() function. This - * function allows you to assign the maximum display count. When the count of messages reported - * with this message id exceeds the display count, it is no longer displayed. The default id zero - * (0) is assigned which has an extremely large display count. - * - * @param message a char const pointer to a message that is to be displayed. - * - * @param message_code a size_t value of the message id for the message. - * - */ -void report_symmetric_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); - -/** - * @brief Member function report_deferred_warning ... - * - * @param message a std::string const ... - * - * @param aggregate a std::string const ... - * - * @param message_code a MessageCode const ... - * - */ -void report_deferred_warning(const char *message, const char *aggregate, const MessageCode &message_code); - -/** - * @brief Class RuntimeWarningAdHoc reports an ad hoc warning message to the - * report system. - * - * - * For example: - * - *
- *     if (adhoc_runtime_warning_condition)
- *       RuntimeWarningAdHoc() << "My useful message about " << some_data;
- *
- *     if (adhoc_runtime_warning_condition) {
- *       static MessageCode mc;
- *       RuntimeWarningAdHoc(mc) << "My useful message about " << some_data;
- *     }
- * 
- */ -class RuntimeWarningAdHoc -{ -public: - /** - * @brief Creates a new RuntimeWarningAdHoc instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeWarningAdHoc(MessageCode &message_code = MessageCode::s_defaultMessageCode); - - /** - * @brief Destroys a RuntimeWarningAdHoc instance. - * - * The message is displayed by calling the report_warning() function. However, if the count of - * remaining messages for this message id is zero, the message is not displayed. - * - */ - ~RuntimeWarningAdHoc(); - -private: - /** - * @brief Make copy of RuntimeWarningAdHoc invalid. - * - */ - RuntimeWarningAdHoc(const RuntimeWarningAdHoc &); - - /** - * @brief Make assignment of RuntimeWarningAdHoc invalid. - * - */ - RuntimeWarningAdHoc &operator=(const RuntimeWarningAdHoc &); - -public: - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningAdHoc reference to this object - */ - RuntimeWarningAdHoc &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningAdHoc reference to this object - */ - RuntimeWarningAdHoc &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeWarningAdHoc reference to this object; - */ - template - RuntimeWarningAdHoc &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - - -/** - * @brief Class RuntimeWarningSymmetric reports a symmetric warning message to the report system. - * - * For example: - * - *
- *     if (symmetric_runtime_warning_condition)
- *       RuntimeWarningSymmetric() << "My useful message about " << some_data;
- *
- *     if (symmetric_runtime_warning_condition) {
- *       static MessageCode mc;
- *       RuntimeWarningSymmetric(mc) << "My useful message about " << some_data;
- *     }
- * 
- */ -class RuntimeWarningSymmetric -{ -public: - /** - * @brief Creates a new RuntimeWarning instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeWarningSymmetric(MessageCode &message_code = MessageCode::s_defaultMessageCode); - - /** - * @brief Destroys a RuntimeWarningSymmetric instance. - * - * The message is displayed by calling the report_symmetric_warning() function. However, if the count of - * remaining messages for this message id is zero, the message is not displayed. - * - */ - ~RuntimeWarningSymmetric(); - -private: - /** - * @brief Make copy of RuntimeWarningSymmetric invalid. - * - */ - RuntimeWarningSymmetric(const RuntimeWarningSymmetric &); - - /** - * @brief Make assignment of RuntimeWarningSymmetric invalid. - * - */ - RuntimeWarningSymmetric &operator=(const RuntimeWarningSymmetric &); - -public: - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningSymmetric reference to this object - */ - RuntimeWarningSymmetric &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningSymmetric reference to this object - */ - RuntimeWarningSymmetric &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeWarningSymmetric reference to this object; - */ - template - RuntimeWarningSymmetric &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - - -/** - * @brief Class RuntimeWarningDeferred reports a deferred warning message to the report - * system. - * - * For example: - * - *
- *     if (deferred_runtime_warning_condition) {
- *       static MessageCode mc;
- *       RuntimeWarningDeferred(mc) << "My useful message about " << some_data;
- *     }
- *
- *     if (deferred_runtime_warning_condition) {
- *       static MessageCode mc;
- *       RuntimeWarningDeferred x;
- *       x << "My useful message about " << some_data;
- *       x.aggregate << proc_specific_data;
- *     }
- * 
- */ -class RuntimeWarningDeferred -{ -public: - /** - * @brief Creates a new RuntimeWarningDeferred instance, setting the message code. - * - * @param message_code an MessageCode const reference to the message code associated - * with this message. - * - */ - explicit RuntimeWarningDeferred(const MessageCode &message_code); - - /** - * @brief Destroys a RuntimeWarning instance. - * - * The message is displayed by calling the add_deferred_message() function. - * - */ - ~RuntimeWarningDeferred(); - -private: - /** - * @briefMake copy of RuntimeWarningDeferred invalid. - * - */ - RuntimeWarningDeferred(const RuntimeWarningDeferred &); - - /** - * @brief Make assignment of RuntimeWarningDeferred invalid. - * - */ - RuntimeWarningDeferred &operator=(const RuntimeWarningDeferred &); - -public: - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningDeferred reference to this object - */ - RuntimeWarningDeferred &operator<<(OStreamFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes the ios_base manipulator - * to the output stream. - * - * @return a RuntimeWarningDeferred reference to this object - */ - RuntimeWarningDeferred &operator<<(IOSBaseFunctionPtr f) { - f(message); - return *this; - } - - /** - * @brief Member function operator<< passes any data type to the - * exception string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a RuntimeWarningDeferred reference to this object; - */ - template - RuntimeWarningDeferred &operator<<(const T &t) { - message << t; - return *this; - } - -public: - std::ostringstream message; ///< Stream to receive message header content - std::ostringstream aggregate; ///< Stream to receive message aggregate content - -private: - const MessageCode m_messageCode; ///< Message id and uninitialized throttle -}; - -/// -/// @} -/// - -} // namespace stk_classic - -#endif // STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.cpp b/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.cpp deleted file mode 100644 index 3fcf08b69d61..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { - -double -wall_time() -{ - timeval tp; - struct timezone tz; - ::gettimeofday(&tp, &tz); - - double seconds = tp.tv_sec; - double milliseconds = tp.tv_usec*1.0e-6; - - return seconds + milliseconds; -} - - -double -wall_dtime(double &t) -{ - const double tnew = wall_time(); - - const double dt = tnew - t; - - t = tnew ; - - return dt ; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.hpp b/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.hpp deleted file mode 100644 index ee3b2f7e3d63..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/WallTime.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_environment_WallTime_hpp -#define stk_util_environment_WallTime_hpp - -namespace stk_classic { - -/** - * @brief Member function wall_time returns the epoch as a double precision value in seconds - * to "millisecond" accuracy. - * - * @return a double value of the seconds since the 1/1/1970 epoch. - */ -double wall_time(); - -double wall_dtime(double &t); - -} // namespace stk_classic - -#endif // stk_util_environment_WallTime_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/product_registry.h b/packages/stk/stk_classic/stk_util/stk_util/environment/product_registry.h deleted file mode 100644 index b7a22135f00e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/product_registry.h +++ /dev/null @@ -1,66 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date October 2002 - * - * @par Product Registry - * These 'C' functions support a registry of products - * that are linked into an application. Each product - * has a name, version, and optional qualifier. - * Re-registration of products is permitted; however, - * the second and subsequent registrations must be - * identical to the first registration. The product - * registry may be searched and iterated. - * - * @par Why 'C' instead of 'C++' - * As a general utility this simple product registry may - * be called from C++, C, or even FORTRAN. - */ - -#ifndef STK_UTIL_ENVIRONMENT_PRODUCT_REGISTRY_H -#define STK_UTIL_ENVIRONMENT_PRODUCT_REGISTRY_H -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -/** - * @brief Extern "C" function product_registry_add provides a means for c - * programs to register a product. The arguments are passed on to - * ProductRegistry::addProduct()/ - * - * @param name a char const pointer to the product's - * name. - */ -extern void product_registry_add(const char *name); - -/** - * @brief Extern "C" function product_registry_add_tpl provides a means for c - * programs to register a tpl. The arguments are passed on to - * ProductRegistry::addTpl()/ - * - * @param name a char const pointer to the product's - * name. - * - * @param version a char const pointer to the product's - * version string. - * - * @param qualifier a char const pointer to the product's - * qualifier string. - */ -extern void product_registry_add_tpl(const char *name, const char *version, const char *qualifier); - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - - -#endif /* STK_UTIL_ENVIRONMENT_PRODUCT_REGISTRY_H */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/environment/stk_version_gen.sh b/packages/stk/stk_classic/stk_util/stk_util/environment/stk_version_gen.sh deleted file mode 100755 index 854928264f9d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/environment/stk_version_gen.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -DIR=$(dirname $0) - -# The current working directory might not be the source tree, so go there -# so that the git commands will work (if the source tree is a git repository.) -# Note that it seems a bad assumption that this script will also be in -# the source tree, but I'm not going to change that now. -cd ${DIR} - -# Don't prepend DIR here, since we are now in that directory. -STK_HEADER_FILE=stk_version.hpp -OVERRIDE_FILE="version" - -RECORD= -while test "$#" -ne 0 -do - case "$1" in - --record) - RECORD=1; shift ;; - *) - echo "Invalid argument: $1" - exit 1 - esac -done - -LF=' -' - -# First see if the source tree is a git project. If not then -# see if there is a version file (included in release tarballs). -# Finally, default. -if test $(git rev-parse --git-dir 2>/dev/null) && - NEW_VERSION=$(git describe --abbrev=8 HEAD 2>/dev/null) && - case "$NEW_VERSION" in - *$LF*) (exit 1) ;; - [0-9]*) - git update-index -q --refresh > /dev/null - test -z "$(git diff-index --name-only HEAD --)" || - NEW_VERSION="${NEW_VERSION}-modified" ;; - esac -then - # PKN: leaving this here in case we want to muck - # with the formatting later. - #NEW_VERSION=$(echo "$NEW_VERSION" | sed -e 's/-/./g'); - NEW_VERSION=$NEW_VERSION - -# If there's no git version, try the override file. -elif test -f "$OVERRIDE_FILE" -then - NEW_VERSION=$(cat ${OVERRIDE_FILE}) || - { - echo >&2 "stk_version_gen.sh: Unable to read file $(pwd)/${OVERRIDE_FILE}" - exit 1 - } - test "$NEW_VERSION" != 'ERROR' || - { - echo >&2 "stk_version_gen.sh: Invalid version 'ERROR' in $(pwd)/${OVERRIDE_FILE}. Deleting that file." - rm -f $(pwd)/${OVERRIDE_FILE} - exit 2 - } -else - # Give up (with an appropriate message.) - type -p git >/dev/null && - echo >&2 "stk_version_gen.sh: No .git repository to determine git version and $(pwd)/${OVERRIDE_FILE} file not found." || - echo >&2 "stk_version_gen.sh: No git binary in PATH and $(pwd)/${OVERRIDE_FILE} file not found." - exit 3 -fi - -# Trim the 'v' from the beginning of the version (why is it there in the first place?) -NEW_VERSION=$(expr "$NEW_VERSION" : v*'\(.*\)') - -if test -r $STK_HEADER_FILE -then - CURRENT_VERSION=$(cat $STK_HEADER_FILE) -else - CURRENT_VERSION=unset -fi -# Don't touch the header if it already contains this version (to prevent unwanted recompilation.) -test "// $NEW_VERSION" = "$CURRENT_VERSION" || - echo "// $NEW_VERSION" > $STK_HEADER_FILE - -# Echo out so build system can use as macro definition, but only if --record was not passed. -test -z "$RECORD" && - echo -n "$NEW_VERSION" || - echo -n "$NEW_VERSION" > $OVERRIDE_FILE diff --git a/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_functions.hpp b/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_functions.hpp deleted file mode 100644 index 755d2b0ab782..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_functions.hpp +++ /dev/null @@ -1,271 +0,0 @@ -#ifndef STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP -#define STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP - -namespace stk_classic { - -// Generic API: add_entity that uses default constructable entity_value type. -template -inline typename generic_mesh_traits::entity_local_id -add_entity( Mesh & mesh ); - -// Generic API: Generic add_entity that takes a pre-constructed entity_value type. -template -inline typename generic_mesh_traits::entity_local_id -add_entity( const typename generic_mesh_traits::entity_value & entity_value, - Mesh & mesh ); - - -// Convenience function that also adds the entity to the range of parts. -template -inline typename generic_mesh_traits::entity_local_id -add_entity( PartInputIterator first, PartInputIterator last, - Mesh & mesh ); - - -// Convenience function that also adds the entity to the range of parts. -template -inline typename generic_mesh_traits::entity_local_id -add_entity( const typename generic_mesh_traits::entity_value & entity_value, - PartInputIterator first, PartInputIterator last, - Mesh & mesh ); - - - -// Generic API: remove this entity from the Mesh. -template -inline void -remove_entity( typename generic_mesh_traits::entity_local_id entity_lid, - Mesh & mesh ); - -// Generic API: add this relation to the Mesh with default-constructed relation_value type. -template -inline generic_mesh_traits::relation_descriptor add_relation( - generic_mesh_traits::entity_local_id entity_from, - generic_mesh_traits::entity_local_id entity_to, - Mesh & mesh - ); - -// Generic API: add this relation to the Mesh with pre-constructed relation_value type. -template -inline generic_mesh_traits::relation_descriptor add_relation( - generic_mesh_traits::entity_local_id entity_from, - generic_mesh_traits::entity_local_id entity_to, - const generic_mesh_traits::relation_value & relation, - Mesh & mesh - ); - - -// Generic API: Remove this relation from the mesh. -template -inline void remove_relation( generic_mesh_traits::relation_descriptor relation_d, Mesh & mesh ); - - -// Generic API: Get a const reference to the Entity from the entity_local_id. -template -inline const generic_mesh_traits::entity_value & get_entity( - generic_mesh_traits::entity_local_id entity_lid, - const Mesh & Mesh - ); - - -// Generic API: Get a const reference to the Entity from the entity_descriptor. -template -inline const generic_mesh_traits::entity_value & get_entity( - generic_mesh_traits::entity_descriptor entity_d, - const Mesh & Mesh - ); - - -// Generic API: Get an entity_descriptor from an entity_local_id -template -inline typename generic_mesh_traits::entity_local_id entity_descriptor_to_local_id( - typename generic_mesh_traits::entity_descriptor entity_d, - const Mesh & mesh - ); - - -// Generic API: Get an entity_local_id from an entity_descriptor. -template -inline typename generic_mesh_traits::entity_descriptor entity_local_id_to_descriptor( - typename generic_mesh_traits::entity_local_id entity_lid, - const Mesh & mesh - ); - - - -// Generic API: Get a range to all entities in the mesh. -template -inline std::pair< - typename generic_mesh_traits::entity_descriptor_iterator, - typename generic_mesh_traits::entity_descriptor_iterator - > - get_entities(Mesh & mesh); - - -// Generic API: -template -inline -std::pair< - typename generic_mesh_traits::bucket_entity_descriptor_iterator, - typename generic_mesh_traits::bucket_entity_descriptor_iterator - > - get_entities( typename generic_mesh_traits::bucket_descriptor bucket_descriptor, - Mesh & mesh - ); - - - -// Generic API: Get a range to all the relations for this entity_local_id -template -inline std::pair< - typename generic_mesh_traits::relation_descriptor_iterator, - typename generic_mesh_traits::relation_descriptor_iterator - > - get_relations( generic_mesh_traits::entity_local_id entity_lid, Mesh & mesh ); - - -// Generic API: Get a range to all the relations for this entity_descriptor -template -inline std::pair::relation_descriptor_iterator, generic_mesh_traits::relation_descriptor_iterator> - get_relations( generic_mesh_traits::entity_descriptor entity_d, Mesh & mesh ); - - - -// Generic API: Get a range to selected relations for this entity_local_id -// Selector is a unary-predicate that takes a relation_descriptor and returns true/false -template -inline std::pair::selected_relation_descriptor_iterator,generic_mesh_traits::selected_relation_descriptor_iterator> - get_relations( - generic_mesh_traits::entity_local_id entity_lid, - Selector & selector, - Mesh & mesh - ); - - -// Generic API: Get a range to selected relations for this entity_descriptor -// Selector is a unary-predicate that takes a relation_descriptor and returns true/false -template -inline std::pair::selected_relation_descriptor_iterator,generic_mesh_traits::selected_relation_descriptor_iterator> - get_relations( - generic_mesh_traits::entity_descriptor entity_d, - Selector & selector, - Mesh & mesh - ); - - -// Generic API: Get a bucket for an entity_descriptor -template -inline typename generic_mesh_traits::bucket_descriptor -get_bucket( typename generic_mesh_traits::entity_descriptor entity, - Mesh & mesh ); - - -// Generic API: Get all buckets for the mesh -template -inline -std::pair< - typename generic_mesh_traits::bucket_descriptor_iterator, - typename generic_mesh_traits::bucket_descriptor_iterator - > -get_buckets( const Mesh & mesh ); - - -// Generic API: Get buckets associated with a Selector. -// Selector is a unary-predicate that takes a bucket_descriptor and returns true/false -template -inline -std::pair< - typename generic_mesh_traits::selected_bucket_descriptor_iterator, - typename generic_mesh_traits::selected_bucket_descriptor_iterator - > -get_buckets( const Selector & selector, Mesh & mesh ); - - -// Generic API: Get buckets for a particular part_descriptor. -template -inline -std::pair< - typename generic_mesh_traits::part_bucket_descriptor_iterator, - typename generic_mesh_traits::part_bucket_descriptor_iterator - > -get_buckets( typename generic_mesh_traits::part_descriptor part_descriptor, - Mesh & mesh ); - - - -// Generic API: add this part to the Mesh. -template -inline typename generic_mesh_traits::part_descriptor -add_part( const typename generic_mesh_traits::part_value & part_value, - Mesh & mesh ); - - -// Generic API: remove this part from the Mesh. -template -inline void -remove_part( typename generic_mesh_traits::part_descriptor part_descriptor, - Mesh & mesh ); - - - -// Generic API: Move entity so it -// sits in Parts defined by AddPartInputIterator and -// so it does not sit in Parts defined by RemovePartInputIterator -template -inline typename generic_mesh_traits::bucket_descriptor -move_entity( typename generic_mesh_traits::entity_descriptor entity_descriptor, - AddPartInputIterator add_first, AddPartInputIterator add_last, - RemovePartInputIterator remove_first, RemovePartInputIterator remove_last, - Mesh & mesh ); - - - -// Generic API: Get all parts on the mesh. -template -inline -std::pair< - typename generic_mesh_traits::part_descriptor_iterator, - typename generic_mesh_traits::part_descriptor_iterator - > -get_parts( const Mesh & mesh ); - - -// Generic API: Get all Parts associated with a bucket. -template -inline -std::pair< - typename generic_mesh_traits::bucket_part_descriptor_iterator, - typename generic_mesh_traits::bucket_part_descriptor_iterator - > -get_parts( - typename generic_mesh_traits::bucket_descriptor bucket_descriptor, - Mesh & mesh - ); - -// Generic API: Begin modification cycle. Returns true if cycle was not already in progress -template -inline -bool -modification_begin( Mesh & mesh ); - -// Generic API: End modification cycle. Returns true if cycle was in progress. -template -inline -bool -modification_end( Mesh & mesh ); - -// Generic API: Query if we are in a modification cycle -template -inline -bool -is_modifiable( const Mesh & mesh ); - -// Generic API: Rotate the field data of multistate fields. -template -inline -void -rotate_multistate_fields( Mesh & mesh ); - -} // namespace stk_classic - -#endif // STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_traits.hpp b/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_traits.hpp deleted file mode 100644 index 892bae606390..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/generic_mesh/generic_mesh_traits.hpp +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef STK_UTIL_GENERIC_MESH_TRAITS_HPP -#define STK_UTIL_GENERIC_MESH_TRAITS_HPP - - -namespace stk_classic { - -template -struct generic_mesh_traits { - // persistant through modifications (up to change owner): - //typedef typename Mesh::entity_global_id entity_global_id; - - // persistant through modifications (up to change owner): - typedef typename Mesh::entity_local_id entity_local_id; - // not-persistant through modifications (up to change owner): - typedef typename Mesh::entity_descriptor entity_descriptor; - // entity_descriptor_iterator de-references to an entity_descriptor: - typedef typename Mesh::entity_descriptor_iterator entity_descriptor_iterator; - typedef typename Mesh::entity_value entity_value; - typedef typename Mesh::entity_size_type entity_size_type; // not used yet - - - typedef typename Mesh::part_descriptor part_descriptor; - // part_descriptor_iterator de-references to a part_descriptor: - typedef typename Mesh::part_descriptor_iterator part_descriptor_iterator; - typedef typename Mesh::part_value part_value; - typedef typename Mesh::part_size_type part_size_type; // not used yet - - typedef typename Mesh::bucket_descriptor bucket_descriptor; - // bucket_descriptor_iterator de-references to a bucket_descriptor: - typedef typename Mesh::bucket_descriptor_iterator bucket_descriptor_iterator; - typedef typename Mesh::bucket_value bucket_value; // not used yet - typedef typename Mesh::bucket_size_type bucket_size_type; // not used yet - // potentially heavy bucket_descriptor_iterator: - typedef typename Mesh::selected_bucket_descriptor_iterator selected_bucket_descriptor_iterator; - - // potentially heavy bucket_descriptor_iterator: - typedef typename Mesh::part_bucket_descriptor_iterator part_bucket_descriptor_iterator; - typedef typename Mesh::part_bucket_size_type part_bucket_size_type; // not used yet - - // potentially heavy part_descriptor_iterator: - typedef typename Mesh::bucket_part_descriptor_iterator bucket_part_descriptor_iterator; - typedef typename Mesh::bucket_part_size_type bucket_part_size_type; // not used yet - - // potentially heavy entity_descriptor_iterator: - typedef typename Mesh::bucket_entity_descriptor_iterator bucket_entity_descriptor_iterator; - typedef typename Mesh::bucket_entity_size_type bucket_entity_size_type; // not used yet - - inline part_descriptor universal_part(); - - static inline part_descriptor null_part(); - static inline bucket_descriptor null_bucket(); - static inline entity_local_id null_entity(); - static inline relation_descriptor null_relation(); - - typedef typename Mesh::relation_descriptor relation_descriptor; - typedef typename Mesh::relation_descriptor_iterator relation_descriptor_iterator; - typedef typename Mesh::selected_relation_descriptor_iterator selected_relation_descriptor_iterator - typedef typename Mesh::relation_value relation_value; // not used yet - typedef typename Mesh::relation_size_type relation_size_type; // not used yet -}; - - -// Note: A Selector is a unary-predicate that accepts the appropriate type -// for the function being used and returns a boolean. - -template -inline typename generic_mesh_traits::part_descriptor -generic_mesh_traits::universal_part() -{ return Mesh::universal_part(); } - -template -inline typename generic_mesh_traits::part_descriptor -generic_mesh_traits::null_part() -{ return Mesh::null_part(); } - -template -inline typename generic_mesh_traits::bucket_descriptor -generic_mesh_traits::null_bucket() -{ return Mesh::null_bucket(); } - -template -inline typename generic_mesh_traits::entity_local_id -generic_mesh_traits::null_entity() -{ return Mesh::null_entity(); } - -template -inline typename generic_mesh_traits::relation_descriptor -generic_mesh_traits::null_relation() -{ return Mesh::null_relation(); } - - -} // namespace stk_classic - - -#endif // STK_UTIL_GENERIC_MESH_TRAITS_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.cpp deleted file mode 100644 index 78d33adb3b41..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { - -BroadcastArg::BroadcastArg( - stk_classic::ParallelMachine parallel_machine, - int argc, - char ** argv) -{ -#ifdef STK_HAS_MPI - int rank = stk_classic::parallel_machine_rank(parallel_machine); -#else - int rank = 0; -#endif - - size_t buffer_length = 0; - char * buffer = 0; - -// Populate m_argc, m_buffer and buffer_length on rank 0 or !STK_HAS_MPI - if (rank == 0) { - m_argc = argc; - - std::string s; - for (int i = 0; i < argc; ++i) { - s += argv[i]; - s += '\0'; - } - - buffer_length = s.size(); - buffer = new char[buffer_length]; - - std::copy(s.begin(), s.end(), buffer); - } - -// if STK_HAS_MPI, broadcast m_argc, buffer and buffer_length to processors -#ifdef STK_HAS_MPI - if (rank == 0) { - int lengths_buffer[2]; - lengths_buffer[0] = m_argc; - lengths_buffer[1] = buffer_length; - - MPI_Bcast(lengths_buffer, 2, MPI_INT, 0, parallel_machine); - - MPI_Bcast(buffer, buffer_length, MPI_BYTE, 0, parallel_machine); - } - else { - int lengths_buffer[2]; - MPI_Bcast(lengths_buffer, 2, MPI_INT, 0, parallel_machine); - - m_argc = lengths_buffer[0]; - buffer_length = lengths_buffer[1]; - buffer = new char[buffer_length]; - - MPI_Bcast(buffer, buffer_length, MPI_BYTE, 0, parallel_machine); - } -#endif - -// Populate the m_argv - m_argv = new char *[m_argc]; - -// argv[0] will always point to buffer, so argv[0] needs to be deleted by the destructor - char *c = &buffer[0]; - for (int i = 0; i < argc; ++i) { - m_argv[i] = c; - while (*c) - ++c; - ++c; - } -} - - -BroadcastArg::~BroadcastArg() -{ - delete[] m_argv[0]; - delete[] m_argv; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.hpp deleted file mode 100644 index 77b38bac5bb1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/BroadcastArg.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_PARALLEL_BROADCASTARG_HPP -#define STK_UTIL_PARALLEL_BROADCASTARG_HPP - -#include - -namespace stk_classic { - -/** - * @brief Class BroadcastArg creates a copy of argc and argv after broadcasting - * them from processor 0. - * - */ -struct BroadcastArg -{ - /** - * Creates a new BroadcastArg instance. - * - * @param parallel_machine a ParallelMachine value that species the - * parallel machine from performing the broadcast. - * - * @param argc an int value of argc from main - * - * @param argv a char pointer pointer of argv from main - * - */ - BroadcastArg(ParallelMachine parallel_machine, int argc, char **argv); - - /** - * Destroys a BroadcastArg instance. - * - */ - ~BroadcastArg(); - - int m_argc; ///< The broadcasted argc - char ** m_argv; ///< The broadcasted argv - -private: - BroadcastArg(const BroadcastArg &argv); - BroadcastArg &operator=(const BroadcastArg &argv); -}; - -} // namespace stk_classic - -#endif // STK_UTIL_PARALLEL_BROADCASTARG_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/parallel/CMakeLists.txt deleted file mode 100644 index 1640ef503f70..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -BroadcastArg.hpp -DistributedIndex.hpp -MPI.hpp -ParallelComm.hpp -Parallel.hpp -ParallelIndex.hpp -ParallelInputStream.hpp -ParallelReduce.hpp - ) - -APPEND_SET(SOURCES -BroadcastArg.cpp -DistributedIndex.cpp -ParallelComm.cpp -Parallel.cpp -ParallelIndex.cpp -ParallelInputStream.cpp -ParallelReduce.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_parallel - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/parallel/) diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.cpp deleted file mode 100644 index 44a38e76f777..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.cpp +++ /dev/null @@ -1,1030 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include -#include - -#include - -namespace stk_classic { -namespace parallel { - -//---------------------------------------------------------------------- - -namespace { - -struct KeyProcLess { - - bool operator()( const DistributedIndex::KeyProc & lhs , - const DistributedIndex::KeyType & rhs ) const - { return lhs.first < rhs ; } - -}; - -void sort_unique( std::vector & key_usage ) -{ - std::vector::iterator - i = key_usage.begin() , - j = key_usage.end() ; - - std::sort( i , j ); - - i = std::unique( i , j ); - - key_usage.erase( i , j ); -} - -void sort_unique( std::vector & keys ) -{ - stk_classic::util::radix_sort_unsigned((keys.empty() ? NULL : &keys[0]), keys.size()); - - std::vector::iterator - i = keys.begin() , - j = keys.end() ; - - i = std::unique( i , j ); - keys.erase( i , j ); -} - -// reserve vector size (current size + rev_buffer remaining) -template < class T > -inline void reserve_for_recv_buffer( const CommAll& all, const DistributedIndex::ProcType& comm_size, std::vector& v) -{ - unsigned num_remote = 0; - for (DistributedIndex::ProcType p = 0 ; p < comm_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - num_remote += buf.remaining() / sizeof(T); - } - v.reserve(v.size() + num_remote); -} - -// unpack buffer into vector -template < class T > -inline void unpack_recv_buffer( const CommAll& all, const DistributedIndex::ProcType& comm_size, std::vector& v) -{ - reserve_for_recv_buffer(all, comm_size, v); - for (DistributedIndex::ProcType p = 0 ; p < comm_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - while ( buf.remaining() ) { - T kp; - buf.unpack( kp ); - v.push_back( kp ); - } - } -} - -// unpack buffer into vector, where pair.second is the processor -template < class T > -inline void unpack_with_proc_recv_buffer( const CommAll& all, const DistributedIndex::ProcType& comm_size, std::vector >& v) -{ - reserve_for_recv_buffer(all, comm_size, v); - for ( DistributedIndex::ProcType p = 0 ; p < comm_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - std::pair kp; - kp.second = p; - while ( buf.remaining() ) { - buf.unpack( kp.first ); - v.push_back( kp ); - } - } -} - -} // namespace - -//---------------------------------------------------------------------- - -enum { DISTRIBUTED_INDEX_CHUNK_BITS = 12 }; ///< Each chunk is 4096 keys - -enum { DISTRIBUTED_INDEX_CHUNK_SIZE = - size_t(1) << DISTRIBUTED_INDEX_CHUNK_BITS }; - -DistributedIndex::ProcType -DistributedIndex::to_which_proc( const DistributedIndex::KeyType & key ) const -{ - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - if ( m_key_span[i].first <= key && key <= m_key_span[i].second ) { - const KeyType offset = key - m_key_span[i].first ; - return ( offset >> DISTRIBUTED_INDEX_CHUNK_BITS ) % m_comm_size ; - } - } - return m_comm_size ; -} - -//---------------------------------------------------------------------- - -DistributedIndex::~DistributedIndex() {} - -DistributedIndex::DistributedIndex ( - ParallelMachine comm , - const std::vector & partition_bounds ) - : m_comm( comm ), - m_comm_rank( parallel_machine_rank( comm ) ), - m_comm_size( parallel_machine_size( comm ) ), - m_span_count(0), - m_key_span(), - m_key_usage() -{ - unsigned info[2] ; - info[0] = partition_bounds.size(); - info[1] = 0 ; - - // Check each span for validity - - for ( std::vector::const_iterator - i = partition_bounds.begin() ; i != partition_bounds.end() ; ++i ) { - if ( i->second < i->first || - ( i != partition_bounds.begin() && i->first <= (i-1)->second ) ) { - info[1] = 1 ; - } - } - -#if defined( STK_HAS_MPI ) - if (m_comm_size > 1) { - MPI_Bcast( info , 2 , MPI_UNSIGNED , 0 , comm ); - } - - if ( 0 < info[0] ) { - m_key_span.resize( info[0] ); - if ( 0 == parallel_machine_rank( comm ) ) { - m_key_span = partition_bounds ; - } - if (m_comm_size > 1) { - MPI_Bcast( (m_key_span.empty() ? NULL : & m_key_span[0]), info[0] * sizeof(KeySpan), MPI_BYTE, 0, comm ); - } - } -#else - m_key_span = partition_bounds ; -#endif - - if ( info[1] ) { - std::ostringstream msg ; - msg << "sierra::parallel::DistributedIndex ctor( comm , " ; - - for ( std::vector::const_iterator - i = partition_bounds.begin() ; i != partition_bounds.end() ; ++i ) { - msg << " ( min = " << i->first << " , max = " << i->second << " )" ; - } - msg << " ) contains invalid span of keys" ; - throw std::runtime_error( msg.str() ); - } - - m_span_count = info[0] ; - - if ( 0 == m_span_count ) { - m_key_span.push_back( - KeySpan( std::numeric_limits::min(), - std::numeric_limits::max() ) ); - m_span_count = 1 ; - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -bool is_sorted_and_unique( const std::vector & key_usage ) -{ - std::vector::const_iterator itr = key_usage.begin(); - std::vector::const_iterator end = key_usage.end(); - for ( ; itr != end; ++itr ) { - if ( itr + 1 != end && *itr >= *(itr + 1) ) { - return false; - } - } - return true; -} - -void query_pack_to_usage( - const std::vector & key_usage , - const std::vector & request , - CommAll & all ) -{ - std::vector::const_iterator i = key_usage.begin(); - std::vector::const_iterator k = request.begin(); - - for ( ; k != request.end() && i != key_usage.end() ; ++k ) { - - for ( ; i != key_usage.end() && i->first < *k ; ++i ); - - std::vector::const_iterator j = i ; - for ( ; j != key_usage.end() && j->first == *k ; ++j ); - - for ( std::vector::const_iterator - jsend = i ; jsend != j ; ++jsend ) { - - for ( std::vector::const_iterator - jinfo = i ; jinfo != j ; ++jinfo ) { - - all.send_buffer( jsend->second ) - .pack( *jinfo ); - } - } - } -} - -void query_pack( const std::vector & key_usage , - const std::vector & request , - CommAll & all ) -{ - std::vector::const_iterator i = key_usage.begin(); - - for ( std::vector::const_iterator - k = request.begin() ; - k != request.end() && - i != key_usage.end() ; ++k ) { - - for ( ; i != key_usage.end() && i->first < k->first ; ++i ); - - for ( std::vector::const_iterator j = i ; - j != key_usage.end() && j->first == k->first ; ++j ) { - all.send_buffer( k->second ).pack( *j ); - } - } -} - -} - -void DistributedIndex::query( - const std::vector & request , - std::vector & sharing_of_keys ) const -{ - sharing_of_keys.clear(); - - CommAll all( m_comm ); - - query_pack( m_key_usage , request , all ); // Sizing - - all.allocate_buffers( m_comm_size / 4 , false ); - - query_pack( m_key_usage , request , all ); // Packing - - all.communicate(); - - unpack_recv_buffer(all, m_comm_size, sharing_of_keys); - - std::sort( sharing_of_keys.begin() , sharing_of_keys.end() ); -} - -void DistributedIndex::query( - std::vector & sharing_of_local_keys ) const -{ - query( m_key_usage , sharing_of_local_keys ); -} - -void DistributedIndex::query( - const std::vector & keys , - std::vector & sharing_keys ) const -{ - std::vector request ; - - { - bool bad_key = false ; - CommAll all( m_comm ); - - for ( std::vector::const_iterator - k = keys.begin() ; k != keys.end() ; ++k ) { - const ProcType p = to_which_proc( *k ); - - if ( p < m_comm_size ) { - all.send_buffer( p ).pack( *k ); - } - else { - bad_key = true ; - } - } - - // Error condition becomes global: - - bad_key = all.allocate_buffers( m_comm_size / 4 , false , bad_key ); - - if ( bad_key ) { - throw std::runtime_error("stk_classic::parallel::DistributedIndex::query given a key which is out of range"); - } - - for ( std::vector::const_iterator - k = keys.begin() ; k != keys.end() ; ++k ) { - all.send_buffer( to_which_proc( *k ) ).pack( *k ); - } - - all.communicate(); - - unpack_with_proc_recv_buffer(all, m_comm_size, request); - } - - sort_unique( request ); - - query( request , sharing_keys ); -} - -void DistributedIndex::query_to_usage( - const std::vector & keys , - std::vector & sharing_keys ) const -{ - std::vector request ; - - { - bool bad_key = false ; - CommAll all( m_comm ); - - for ( std::vector::const_iterator - k = keys.begin() ; k != keys.end() ; ++k ) { - const ProcType p = to_which_proc( *k ); - - if ( p < m_comm_size ) { - all.send_buffer( p ).pack( *k ); - } - else { - bad_key = true ; - } - } - - // Error condition becomes global: - - bad_key = all.allocate_buffers( m_comm_size / 4 , false , bad_key ); - - if ( bad_key ) { - throw std::runtime_error("stk_classic::parallel::DistributedIndex::query given a key which is out of range"); - } - - for ( std::vector::const_iterator - k = keys.begin() ; k != keys.end() ; ++k ) { - all.send_buffer( to_which_proc( *k ) ).pack( *k ); - } - - all.communicate(); - - unpack_recv_buffer(all, m_comm_size, request); - } - - sort_unique( request ); - - { - CommAll all( m_comm ); - - query_pack_to_usage( m_key_usage , request , all ); // Sizing - - all.allocate_buffers( m_comm_size / 4 , false ); - - query_pack_to_usage( m_key_usage , request , all ); // Packing - - all.communicate(); - - unpack_recv_buffer(all, m_comm_size, sharing_keys); - - std::sort( sharing_keys.begin() , sharing_keys.end() ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace { - -struct RemoveKeyProc { - - bool operator()( const DistributedIndex::KeyProc & kp ) const - { return kp.second < 0 ; } - - static void mark( std::vector & key_usage , - const DistributedIndex::KeyProc & kp ) - { - std::vector::iterator - i = std::lower_bound( key_usage.begin(), - key_usage.end(), kp.first, KeyProcLess() ); - - // Iterate over the span of KeyProcs with matching key until an exact match - // is found. We have to do it this way because marking a KeyProc unsorts it - // in the key_usage vector, so we cannot look up KeyProcs directly once marking - // has begun. - while ( i != key_usage.end() && kp.first == i->first && kp.second != i->second) { ++i ; } - - if ( i != key_usage.end() && kp == *i ) { - i->second = -1 ; - } - } - - static void clean( std::vector & key_usage ) - { - std::vector::iterator end = - std::remove_if( key_usage.begin() , key_usage.end() , RemoveKeyProc() ); - key_usage.erase( end , key_usage.end() ); - } -}; - -} - -void DistributedIndex::update_keys( - const std::vector & add_new_keys , - const std::vector & remove_existing_keys ) -{ - std::vector count_remove( m_comm_size , (unsigned long)0 ); - std::vector count_add( m_comm_size , (unsigned long)0 ); - - size_t local_bad_input = 0 ; - - // Iterate over keys being removed and keep a count of keys being removed - // from other processes - for ( std::vector::const_iterator - i = remove_existing_keys.begin(); - i != remove_existing_keys.end(); ++i ) { - const ProcType p = to_which_proc( *i ); - if ( m_comm_size <= p ) { - // Key is not within one of the span: - ++local_bad_input ; - } - else if ( p != m_comm_rank ) { - ++( count_remove[ p ] ); - } - } - - // Iterate over keys being added and keep a count of keys being added - // to other processes - for ( std::vector::const_iterator - i = add_new_keys.begin(); - i != add_new_keys.end(); ++i ) { - const ProcType p = to_which_proc( *i ); - if ( p == m_comm_size ) { - // Key is not within one of the span: - ++local_bad_input ; - } - else if ( p != m_comm_rank ) { - ++( count_add[ p ] ); - } - } - - CommAll all( m_comm ); - - // Sizing and add_new_keys bounds checking: - - // For each process, we are going to send the number of removed keys, - // the removed keys, and the added keys. It will be assumed that any keys - // beyond the number of removed keys will be added keys. - for ( int p = 0 ; p < m_comm_size ; ++p ) { - if ( count_remove[p] || count_add[p] ) { - CommBuffer & buf = all.send_buffer( p ); - buf.skip( 1 ); - buf.skip( count_remove[p] ); - buf.skip( count_add[p] ); - } - } - - // Allocate buffers and perform a global OR of error_flag - const bool symmetry_flag = false ; - const bool error_flag = 0 < local_bad_input ; - - bool global_bad_input = - all.allocate_buffers( m_comm_size / 4, symmetry_flag , error_flag ); - - if ( global_bad_input ) { - std::ostringstream msg ; - - if ( 0 < local_bad_input ) { - msg << "stk_classic::parallel::DistributedIndex::update_keys ERROR Given " - << local_bad_input << " of " << add_new_keys.size() - << " add_new_keys outside of any span" ; - } - - throw std::runtime_error( msg.str() ); - } - - // Packing: - - // Pack the remove counts for each process - for ( int p = 0 ; p < m_comm_size ; ++p ) { - if ( count_remove[p] || count_add[p] ) { - all.send_buffer( p ).pack( count_remove[p] ); - } - } - - // Pack the removed keys for each process - for ( std::vector::const_iterator - i = remove_existing_keys.begin(); - i != remove_existing_keys.end(); ++i ) { - const ProcType p = to_which_proc( *i ); - if ( p != m_comm_rank ) { - all.send_buffer( p ).pack( *i ); - } - } - - // Pack the added keys for each process - for ( std::vector::const_iterator - i = add_new_keys.begin(); - i != add_new_keys.end(); ++i ) { - const ProcType p = to_which_proc( *i ); - if ( p != m_comm_rank ) { - all.send_buffer( p ).pack( *i ); - } - } - - // Communicate keys - all.communicate(); - - //------------------------------ - // Remove for local keys - - for ( std::vector::const_iterator - i = remove_existing_keys.begin(); - i != remove_existing_keys.end(); ++i ) { - const ProcType p = to_which_proc( *i ); - if ( p == m_comm_rank ) { - RemoveKeyProc::mark( m_key_usage , KeyProc( *i , p ) ); - } - } - - // Unpack the remove key and find it. - // Set the process to a negative value for subsequent removal. - - for ( int p = 0 ; p < m_comm_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - if ( buf.remaining() ) { - unsigned long remove_count = 0 ; - - KeyProc kp ; - - kp.second = p ; - - buf.unpack( remove_count ); - - for ( ; 0 < remove_count ; --remove_count ) { - buf.unpack( kp.first ); - - RemoveKeyProc::mark( m_key_usage , kp ); - } - } - } - - RemoveKeyProc::clean( m_key_usage ); - - //------------------------------ - // Append for local keys - - // Add new_keys going to this proc to local_key_usage - std::vector local_key_usage ; - local_key_usage.reserve(add_new_keys.size()); - for ( std::vector::const_iterator - i = add_new_keys.begin(); - i != add_new_keys.end(); ++i ) { - - const ProcType p = to_which_proc( *i ); - if ( p == m_comm_rank ) { - local_key_usage.push_back( KeyProc( *i , p ) ); - } - } - - // Merge local_key_usage and m_key_usage into temp_key - std::vector temp_key ; - temp_key.reserve(local_key_usage.size() + m_key_usage.size()); - std::sort( local_key_usage.begin(), local_key_usage.end() ); - std::merge( m_key_usage.begin(), - m_key_usage.end(), - local_key_usage.begin(), - local_key_usage.end(), - std::back_inserter(temp_key) ); - - // Unpack and append for remote keys: - std::vector remote_key_usage ; - - unpack_with_proc_recv_buffer(all, m_comm_size, remote_key_usage); - - std::sort( remote_key_usage.begin(), remote_key_usage.end() ); - - m_key_usage.clear(); - m_key_usage.reserve(temp_key.size() + remote_key_usage.size()); - - // Merge temp_key and remote_key_usage into m_key_usage, so... - // m_key_usage = local_key_usage + remote_key_usage + m_key_usage(orig) - std::merge( temp_key.begin(), - temp_key.end(), - remote_key_usage.begin(), - remote_key_usage.end(), - std::back_inserter(m_key_usage) ); - - // Unique m_key_usage - m_key_usage.erase(std::unique( m_key_usage.begin(), - m_key_usage.end()), - m_key_usage.end() ); - - // Check invariant that m_key_usage is sorted - if (!is_sorted_and_unique(m_key_usage)) { - throw std::runtime_error( "Sorted&unique invariant violated!" ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void DistributedIndex::generate_new_global_key_upper_bound( - const std::vector & requests , - std::vector & global_key_upper_bound ) const -{ - bool bad_request = m_span_count != requests.size(); - - std::ostringstream error_msg ; - - error_msg - << "sierra::parallel::DistributedIndex::generate_new_keys_global_counts( " ; - - std::vector - local_counts( m_span_count + 1 , (unsigned long) 0 ), - global_counts( m_span_count + 1 , (unsigned long) 0 ); - - // Count unique keys in each span and add requested keys for - // final total count of keys needed. - - // Append the error check to this communication to avoid - // and extra reduction operation. - local_counts[ m_span_count ] = m_span_count != requests.size(); - - if ( m_span_count == requests.size() ) { - - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - local_counts[i] = requests[i] ; - } - - std::vector::const_iterator j = m_key_usage.begin(); - - for ( size_t i = 0 ; i < m_span_count && j != m_key_usage.end() ; ++i ) { - const KeyType key_span_last = m_key_span[i].second ; - size_t count = 0 ; - while ( j != m_key_usage.end() && j->first <= key_span_last ) { - const KeyType key = j->first ; - while ( j != m_key_usage.end() && key == j->first ) { ++j ; } - ++count ; - } - local_counts[i] += count ; - } - } - -#if defined( STK_HAS_MPI ) - if (m_comm_size > 1) { - MPI_Allreduce( (local_counts.empty() ? NULL : & local_counts[0]) , (global_counts.empty() ? NULL : & global_counts[0]) , - m_span_count + 1 , MPI_UNSIGNED_LONG , - MPI_SUM , m_comm ); - } - else { - global_counts = local_counts ; - } -#else - global_counts = local_counts ; -#endif - - bad_request = global_counts[m_span_count] != 0 ; - - if ( bad_request ) { - if ( m_span_count != requests.size() ) { - error_msg << " requests.size() = " << requests.size() - << " != " << m_span_count << " )" ; - } - } - - if ( ! bad_request ) { - for ( unsigned i = 0 ; i < m_span_count ; ++i ) { - const size_t span_available = - ( 1 + m_key_span[i].second - m_key_span[i].first ); - - const size_t span_requested = global_counts[i]; - - if ( span_available < span_requested ) { - bad_request = true ; - error_msg << " global_sum( (existing+request)[" << i << "] ) = " - << span_requested - << " > global_sum( span_available ) = " - << span_available ; - } - } - } - - if ( bad_request ) { - throw std::runtime_error( error_msg.str() ); - } - - // Determine the maximum generated key - - global_key_upper_bound.resize( m_span_count ); - - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - global_key_upper_bound[i] = m_key_span[i].first + global_counts[i] - 1 ; - } -} - -//-------------------------------------------------------------------- -//-------------------------------------------------------------------- - -void DistributedIndex::generate_new_keys_local_planning( - const std::vector & key_global_upper_bound , - const std::vector & requests_local , - std::vector & new_request , - std::vector & requested_keys , - std::vector & contrib_keys ) const -{ - new_request.assign( m_span_count , long(0) ); - - contrib_keys.clear(); - - std::vector::const_iterator j = m_key_usage.begin(); - - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - // The maximum generated key from any process will - // not exceed this value. - const KeyType key_upper_bound = key_global_upper_bound[i] ; - - const size_t init_size = contrib_keys.size(); - - const size_t chunk_inc = m_comm_size * DISTRIBUTED_INDEX_CHUNK_SIZE ; - - const size_t chunk_rsize = m_comm_rank * DISTRIBUTED_INDEX_CHUNK_SIZE ; - - for ( KeyType key_begin = m_key_span[i].first + - chunk_rsize ; - key_begin <= key_upper_bound ; key_begin += chunk_inc ) { - - // What is the first key of the chunk - KeyType key_iter = key_begin ; - - // What is the last key belonging to this process' chunk - const KeyType key_last = - std::min( key_begin + DISTRIBUTED_INDEX_CHUNK_SIZE - 1 , key_upper_bound ); - - // Jump into the sorted used key vector to - // the key which may be contributed - - j = std::lower_bound( j, m_key_usage.end(), key_iter, KeyProcLess() ); - // now know: j == m_key_usage.end() OR - // key_iter <= j->first - - for ( ; key_iter <= key_last ; ++key_iter ) { - if ( j == m_key_usage.end() || key_iter < j->first ) { - // The current attempt 'key_iter' is not used, contribute it. - contrib_keys.push_back( key_iter ); - } - else { // j != m_key_usage.end() && key_iter == j->first - // The current attempt 'key_iter' is already used, - // increment the used-iterator to its next key value. - while ( j != m_key_usage.end() && key_iter == j->first ) { - ++j ; - } - } - } - } - - // Determine which local keys will be contributed, - // keeping what this process could use from the contribution. - // This can reduce the subsequent communication load when - // donating keys to another process. - - const size_t this_contrib = contrib_keys.size() - init_size ; - - // How many keys will this process keep: - const size_t keep = std::min( requests_local[i] , this_contrib ); - - // Take the kept keys from the contributed key vector. - requested_keys.insert( requested_keys.end() , - contrib_keys.end() - keep , - contrib_keys.end() ); - - contrib_keys.erase( contrib_keys.end() - keep , - contrib_keys.end() ); - - // New request is positive for needed keys or negative for donated keys - new_request[i] = requests_local[i] - this_contrib ; - } -} - -//---------------------------------------------------------------------- - -void DistributedIndex::generate_new_keys_global_planning( - const std::vector & new_request , - std::vector & my_donations ) const -{ - my_donations.assign( m_comm_size * m_span_count , long(0) ); - - // Gather the global request plan for receiving and donating keys - // Positive values for receiving, negative values for donating. - - std::vector new_request_global( m_comm_size * m_span_count ); - -#if defined( STK_HAS_MPI ) - - if (m_comm_size > 1) { // Gather requests into per-process spans - - // There is a possible bug in MPI_Allgather, for Intel 12; use MPI_Gather instead -#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200) - { - // MPI doesn't do 'const' in its interface, but the send buffer is const - void * send_buf = const_cast( (void *)( (new_request.empty() ? NULL : & new_request[0]) )); - void * recv_buf = (new_request_global.empty() ? NULL : & new_request_global[0]) ; - for (int root = 0; root < m_comm_size; ++root) - { - MPI_Gather( send_buf , m_span_count , MPI_LONG , - recv_buf , m_span_count , MPI_LONG , root, m_comm ); - } - } -#else - { - // MPI doesn't do 'const' in its interface, but the send buffer is const - void * send_buf = const_cast( (void *)( (new_request.empty() ? NULL : & new_request[0]) )); - void * recv_buf = (new_request_global.empty() ? NULL : & new_request_global[0]) ; - MPI_Allgather( send_buf , m_span_count , MPI_LONG , - recv_buf , m_span_count , MPI_LONG , m_comm ); - } -#endif - - } - else { - new_request_global = new_request ; - } -#else - new_request_global = new_request ; -#endif - - // Now have the global receive & donate plan. - //-------------------------------------------------------------------- - // Generate my donate plan from the global receive & donate plan. - - for ( unsigned i = 0 ; i < m_span_count ; ++i ) { - - if ( new_request[i] < 0 ) { // This process is donating on this span - long my_total_donate = - new_request[i] ; - - long previous_donate = 0 ; - - // Count what previous processes have donated: - for ( int p = 0 ; p < m_comm_rank ; ++p ) { - const long new_request_p = new_request_global[ p * m_span_count + i ] ; - if ( new_request_p < 0 ) { - previous_donate -= new_request_p ; - } - } - - // What the donation count will be with my donation: - long end_donate = previous_donate + my_total_donate ; - - long previous_receive = 0 ; - - // Determine my donation to other processes (one to many). - - for ( int p = 0 ; p < m_comm_size && 0 < my_total_donate ; ++p ) { - - const long new_request_p = new_request_global[ p * m_span_count + i ]; - - if ( 0 < new_request_p ) { // Process 'p' receives keys - - // Accumulation of requests: - - previous_receive += new_request_p ; - - if ( previous_donate < previous_receive ) { - // I am donating to process 'p' - const long n = std::min( previous_receive , end_donate ) - - previous_donate ; - - my_donations[ p * m_span_count + i ] = n ; - previous_donate += n ; - my_total_donate -= n ; - } - } - } - } - } -} - -//-------------------------------------------------------------------- - -void DistributedIndex::generate_new_keys( - const std::vector & requests , - std::vector< std::vector > & requested_keys ) -{ - //-------------------------------------------------------------------- - // Develop the plan: - - std::vector global_key_upper_bound ; - std::vector new_request ; - std::vector my_donations ; - std::vector contrib_keys ; - std::vector new_keys ; - - // Verify input and generate global sum of - // current key usage and requested new keys. - // Throw a parallel consistent exception if the input is bad. - - generate_new_global_key_upper_bound( requests , global_key_upper_bound ); - - // No exception thrown means all inputs are good and parallel consistent - - // Determine which local keys will be contributed, - // keeping what this process could use from the contribution. - // This can reduce the subsequent communication load when - // donating keys to another process. - - generate_new_keys_local_planning( global_key_upper_bound , - requests , - new_request , - new_keys , - contrib_keys ); - - // Determine where this process will be donating 'contrib_keys' - generate_new_keys_global_planning( new_request, my_donations ); - - // Due to using an upper bound as opposed to an exact maximum - // the contrib_keys is likely to contain more keys that are needed. - // Remove unneeded keys. - - // Backwards to erase from the end - for ( size_t i = m_span_count ; 0 < i ; ) { - --i ; - size_t count = 0 ; - for ( int p = 0 ; p < m_comm_size ; ++p ) { - count += my_donations[ p * m_span_count + i ]; - } - std::vector::iterator j_beg = contrib_keys.begin(); - std::vector::iterator j_end = contrib_keys.end(); - j_beg = std::lower_bound( j_beg , j_end , m_key_span[i].first ); - j_end = std::upper_bound( j_beg , j_end , m_key_span[i].second ); - const size_t n = std::distance( j_beg , j_end ); - if ( count < n ) { - contrib_keys.erase( j_beg + count , j_end ); - } - } - - // Plan is done, communicate the new keys. - //-------------------------------------------------------------------- - // Put key this process is keeping into the index. - m_key_usage.reserve(m_key_usage.size() + new_keys.size()); - for ( std::vector::iterator i = new_keys.begin(); - i != new_keys.end() ; ++i ) { - m_key_usage.push_back( KeyProc( *i , m_comm_rank ) ); - } - - //-------------------------------------------------------------------- - - CommAll all( m_comm ); - - // Sizing - - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - for ( int p = 0 ; p < m_comm_size ; ++p ) { - const size_t n_to_p = my_donations[ p * m_span_count + i ]; - if ( 0 < n_to_p ) { - all.send_buffer(p).skip( n_to_p ); - } - } - } - - all.allocate_buffers( m_comm_size / 4 , false ); - - // Packing - - { - size_t n = 0 ; - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - for ( int p = 0 ; p < m_comm_size ; ++p ) { - const size_t n_to_p = my_donations[ p * m_span_count + i ]; - if ( 0 < n_to_p ) { - all.send_buffer(p).pack( & contrib_keys[n] , n_to_p ); - for ( size_t k = 0 ; k < n_to_p ; ++k , ++n ) { - m_key_usage.push_back( KeyProc( contrib_keys[n] , p ) ); - } - } - } - } - } - - std::sort( m_key_usage.begin() , m_key_usage.end() ); - - all.communicate(); - - // Unpacking - unpack_recv_buffer( all, m_comm_size, new_keys); - - stk_classic::util::radix_sort_unsigned((new_keys.empty() ? NULL : &new_keys[0]), new_keys.size()); - - requested_keys.resize( m_span_count ); - - { - std::vector::iterator i_beg = new_keys.begin(); - for ( size_t i = 0 ; i < m_span_count ; ++i ) { - std::vector::iterator i_end = i_beg + requests[i] ; - requested_keys[i].assign( i_beg , i_end ); - i_beg = i_end ; - } - } -} - -//---------------------------------------------------------------------- - -} // namespace util -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.hpp deleted file mode 100644 index 6c9c65c6befe..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/DistributedIndex.hpp +++ /dev/null @@ -1,178 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_DistributedIndex_hpp -#define stk_util_parallel_DistributedIndex_hpp - -#include -#include -#include -#include -#include - -class UnitTestSTKParallelDistributedIndex ; - -namespace stk_classic { -namespace parallel { - -/** \brief Parallel cross-reference index for a collection of keys. - * - * \section Parallel operations - * - * All methods use parallel collective communication operations. - * - * Each processor constructs a DistributedIndex with its - * local collection of keys. - * The resulting DistributedIndex may be queried for - * - which other processors input the same local keys or - * - which processors submitted an arbitrary set of keys. - * - * \section Partitioned key space - * - * When construction the key space is partitioned into N spans - * defined by a minimum and maximum key value for each span. - */ -class DistributedIndex { -public: - typedef uint64_t KeyType ; - typedef int ProcType ; - typedef std::pair KeySpan ; - typedef std::pair KeyProc ; - - /*----------------------------------------*/ - - ~DistributedIndex(); - - /** \brief Construct a parallel index with a parititioning of the key space. - * - * To guarantee parallel consistency process zero broadcasts - * the partition bounds and all other processes accept those bounds. - * - * The vector of spans must be well-ordered and not overlap; e.g., - * partition_spans[i].first <= partition_spans[i].second - * partition_spans[i].second < partition_spans[i+1].first - */ - DistributedIndex( ParallelMachine comm , - const std::vector & partition_spans ); - - /*----------------------------------------*/ - /** \brief Query with which process the local added keys are shared. */ - void query( std::vector & sharing_of_local_keys ) const ; - - /** \brief Query which processors added the given keys. - * The local processor is in the output if it - * submitted a queried key. - */ - void query( const std::vector & keys , - std::vector & sharing_of_keys ) const ; - - /** \brief Query which processors added the given keys. - * The results of the query are pushed to the processes - * on which the keys are used. - */ - void query_to_usage( const std::vector & keys , - std::vector & sharing_of_keys ) const ; - - /*------------------------------------------------------------------*/ - /** \brief Update a parallel index with new and changed keys. - * FIRST: Remove this process' participation in the existing keys. - * SECOND: Add this process' participation in the new keys. - */ - void update_keys( const std::vector & add_new_keys , - const std::vector & remove_existing_keys ); - - /** \brief Request a collection of unused keys. - * - * Each process inputs its independent request for keys which - * do not currenly appear in the distributed index. - * The output keys are grouped by partition_spans. - * The output keys are guaranteed to be unique among all processes. - * The output keys are added into the distributed index. - * - * Multiple request should be bundled to reduce - * parallel communication costs. - * The output 'requested_keys' are sorted according to the policy. - * - * The the 'first' member of the requests are the lower bound - * value for the keys. - * - * \throw Throw an exception on all process if any request - * cannot be satisfied. - */ - void generate_new_keys( - const std::vector & requests , - std::vector< std::vector > & requested_keys ); - -private: - - /*------------------------------------------------------------------*/ - /** \brief An internally used method to count communication needs. - */ - void generate_new_global_key_upper_bound( - const std::vector & requests , - std::vector & global_key_upper_bound ) const; - - - /** \brief An internally used method to determine which - * keys will be kept and which will be donated. - */ - void generate_new_keys_local_planning( - const std::vector & global_key_upper_bound , - const std::vector & requests_local , - std::vector & new_requests , - std::vector & requested_keys , - std::vector & contrib_keys ) const ; - - /** \brief An internally used method to determine to which - * other processes keys will be donated. - */ - void generate_new_keys_global_planning( - const std::vector & new_request , - std::vector & my_donations ) const ; - - /** \brief An internally used method to query usage of keys. */ - void query( const std::vector & request , - std::vector & sharing_of_keys ) const ; - - /*------------------------------------------------------------------*/ - /** \brief An internally used method to determine to which - * process is responsible for knowing about the key's usage. - */ - ProcType to_which_proc( const KeyType & key ) const ; - - /*------------------------------------------------------------------*/ - /* Disable default construction and copies. */ - - DistributedIndex(); - DistributedIndex( const DistributedIndex & ); - DistributedIndex & operator = ( const DistributedIndex & ); - - /*------------------------------------------------------------------*/ - - ParallelMachine m_comm ; ///< Distributed communicator - ProcType m_comm_rank ; ///< This process' rank - ProcType m_comm_size ; ///< The number of processes - size_t m_span_count ;///< Number of spans of keys - std::vector m_key_span ; ///< (min,max) for N span - std::vector m_key_usage ; ///< Index for all key usage - - /* Unit testing of internal methods requires the unit test to have - * access to those internal methods. - */ - friend class ::UnitTestSTKParallelDistributedIndex ; -}; - -//---------------------------------------------------------------------- - -} // namespace parallel -} // namespace stk_classic - -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/Exception.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/Exception.cpp deleted file mode 100644 index 4fe99db7957f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/Exception.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2003 - 2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace sierra { - -void -sierra_exception_throw() -{} - - -ParallelThrowRegistry & -ParallelThrowRegistry::instance() -{ - static ParallelThrowRegistry s_parallelThrowRegistry; - - return s_parallelThrowRegistry; -} - - -ParallelThrowRegistry::Registry::Registry() -{} - - -ParallelThrowRegistry::Registry::~Registry() -{ - // Truely sick. Each is registered twice, once for the parallel version of the - // exception and once for the base class version. The double increment - // keeps from deleting it twice. See ParallelThrowRegistry::registerException. - for (iterator it = begin(); it != end(); ++it, ++it) - delete (*it).second; -} - - -ExParallel & -ParallelThrowRegistry::register_exception_a( - const std::type_info & exception_type, - ExParallel * exception) -{ - if (!findException(exception_type)) { - m_registry.push_back(Registry::value_type(&exception_type, exception)); - mpih::Add_Handle(*exception); - } - return *exception; -} - -ExParallel * -ParallelThrowRegistry::findException( - const std::type_info & exception_type) -{ - for (Registry::iterator it = m_registry.begin(); it != m_registry.end(); ++it) - if (*(*it).first == exception_type) - return (*it).second; - - return NULL; -} - - -void -ExParallel::parallel_handler() -{} - - -void -throw_copy( - const std::exception & x, - const std::string & append_message) -{ - ExParallel *exception = ParallelThrowRegistry::instance().findException(typeid(x)); - if (!exception) - exception = ParallelThrowRegistry::instance().findException(typeid(Exception)); - - exception->clear(); - *exception << x.what() << append_message; - - exception->throw_copy(); -} - - -void -set_exception() -{ - BadException x; - x << "Unknown exception"; - set_exception(static_cast(x)); -} - - -void -set_exception( - std::exception & x) -{ - ExParallel *registered_exception = ParallelThrowRegistry::instance().findException(typeid(x)); - - if (!registered_exception) - registered_exception = ParallelThrowRegistry::instance().findException(typeid(Exception)); - - registered_exception->setDescription(x.what()); - registered_exception->setTraceback(Diag::Traceback::printTraceback(Diag::Traceback::snapshot())); - -// std::cerr << "Exception " << demangle(typeid(*registered_exception).name()) << " will be thrown from processor " << Env::parallel_rank() << " on the next MPIH function:" << std::endl -// << registered_exception->getDescription() << std::endl -// << registered_exception->getTraceback() << std::endl; - - mpih::Set_Local_Handle(const_cast(*registered_exception)); -} - - -void -set_exception( - ExParallel & x) -{ - ExParallel *registered_exception = ParallelThrowRegistry::instance().findException(typeid(x)); - - if (!registered_exception) - registered_exception = ParallelThrowRegistry::instance().findException(typeid(Exception)); - - registered_exception->setDescription(x.getDescription()); - registered_exception->setTraceback(Diag::Traceback::printTraceback(Diag::Traceback::snapshot())); - -// std::cerr << "Exception " << demangle(typeid(*registered_exception).name()) << " will be thrown from processor " << Env::parallel_rank() << " on the next MPIH function:" << std::endl -// << registered_exception->getDescription() << std::endl -// << registered_exception->getTraceback() << std::endl; - - mpih::Set_Local_Handle(const_cast(*registered_exception)); -} - - -void -register_stl_parallel_exceptions() -{ - mpih::Enable(); - - Exception::registerException(); - BadAlloc::registerException(); - BadCast::registerException(); - BadTypeid::registerException(); - LogicError::registerException(); - DomainError::registerException(); - InvalidArgument::registerException(); - LengthError::registerException(); - OutOfRange::registerException(); - RuntimeError::registerException(); - RangeError::registerException(); - OverflowError::registerException(); - UnderflowError::registerException(); - BadException::registerException(); - - mpih::Activate_Handles(); -} - - -void -parallel_throw( - MPI_Comm mpi_comm) -{ - int nprocs; - MPI_Comm_size(mpi_comm, &nprocs); - - ExParallel **handles = new ExParallel* [nprocs]; - - mpih::Get_Global_Handles(handles); - - MPIH_Handler_compete handler_compete_fn; - MPIH_Handler_execute handler_execute_fn; - mpih::Get_Functions(&handler_compete_fn , - &handler_execute_fn); - - /* Now that we have the handles, - * reset the handles so we don't throw again. This way - * whatever function catches the exception we are about to - * throw can call mpih and mpih will not just throw again. - */ - mpih::Reset_Local_Handle(); - - /* First iterate through all of the exceptions thrown on all of - * the processors, and if any of them were thrown on this - * processor, print an error message and a traceback. - * only the owning processor will have the traceback information. - */ - /* Iterate through all of the exceptions thrown on all of the processors - * and call the parallel_handler() function defined by any derived from - * ExParallel. This is done across all processors so that - * it is valid to do collective communication inside of parallel_handler() - */ - for (int i = 0; i < nprocs; ++i) { - if (handles[i]) { - ExParallel *x = dynamic_cast(handles[i]); - if (x) - x->parallel_handler(); - } - } - - /* Iterate through all of the exceptions thrown on all of the processors - * and select the one to throw in parallel on all processors. We would - * like to find one derived from ExParallel. - */ - - ExParallel *the_exception = NULL; - int originating_processor = -1; - - for (int i = 0; i < nprocs; ++i) { - if (handles[i]) { - ExParallel *x = dynamic_cast(handles[i]); - if (x) { - if (handler_compete_fn) - (handler_compete_fn) (reinterpret_cast(&handles[i]), the_exception); - if ( handles[i] != the_exception ) { - the_exception = x; - originating_processor = i; - } - } - } - } - - delete [] handles; - - /* Since this function is called in parallel, it is possible - * to perform collective communication. Here the traceback - * and error messages are broadcast and set on all processors. - * These are the only two fields that are guarenteeded to be - * in each exception class. Other data stored in specialized - * derived classes will have to be communicated seperately. - * If needed this communication could be added to a virtual - * base class. That is a future enhancements depending on - * the demand. - */ - if (the_exception) { - // Copy the description from the originating process to everywhere. - std::string description(the_exception->getDescriptionStream().str()); - int description_len = description.length(); - MPI_Bcast(&description_len, - 1, - MPI_INT, - originating_processor, - mpi_comm); - - char *description_buf = new char[description_len]; - description.copy(description_buf, description_len); - - MPI_Bcast(description_buf, - description_len, - MPI_CHAR, - originating_processor, - mpi_comm); - - // Copy the traceback stack from the originating process to everywhere. - const std::string &traceback(the_exception->getTraceback()); - int traceback_len = traceback.length(); - MPI_Bcast(&traceback_len, - 1, - MPI_INT, - originating_processor, - mpi_comm); - - char *traceback_buf = new char[traceback_len]; - traceback.copy(traceback_buf, traceback_len); - - MPI_Bcast(traceback_buf, - traceback_len, - MPI_CHAR, - originating_processor, - mpi_comm); - - // Rebuild the exception from the broadcasted data - the_exception->setDescription(std::string(description_buf, description_len)); - the_exception->setTraceback(std::string(traceback_buf, traceback_len)); - the_exception->setParallel(originating_processor); - -// std::cerr << "Throwing exception " << demangle(typeid(*the_exception).name()) << " in parallel" << std::endl -// << the_exception->getDescription() << std::endl -// << the_exception->getTraceback() << std::endl; - -#ifdef SIERRA_MPIH_VERBOSE - Env::outputP0() - <<"*************** Exception handling ***************"<throw_copy(); - } - else { -#ifdef SIERRA_MPIH_VERBOSE - Env::outputP0() - <<"*************** Exception handling ***************"< header file. - * - * The SIERRA exception types, their corresponding standard - * exception base type, and source of that standard exception - * base type are as follows. - * - * It is important to note that the sierra exceptions do not follow the - * same hierachy as the std exceptions. All the sierra execeptions are - * derived from ExParallel and not from each other. Therefore, it is - * suggested that you catch only the std::exception & to catch all std - * and sierra or catch ExParallel & to catch all sierra exceptions. The - * throw_copy() function promotes std exceptions to the corresponding - * sierra exception. - * - * @li sierra::Exception std::exception - * @li sierra::BadException std::bad_exception - * @li sierra::BadAlloc std::bad_alloc - * @li sierra::BadCast std::bad_cast - * @li sierra::BadTypeid std::bad_typeid - * @li sierra::LogicError std::logic_error - * @li sierra::DomainError std::domain_error - * @li sierra::InvalidArgument std::invalid_argument - * @li sierra::LengthError std::length_error - * @li sierra::OutOfRange std::out_of_range - * @li sierra::RuntimeError std::runtime_error - * @li sierra::RangeError std::range_error - * @li sierra::OverflowError std::overflow_error - * @li sierra::UnderflowError std::underflow_error - * - * @li typedef ExTemp1< std::ios_base::failure > IosBaseFailure; - * IosBaseFailure is declared in ExceptionIos.h in order to - * avoid including the ios header file in this header. - * - * Any additional exception types should be derived from one of the - * above SIERRA exception classes. - * - * To create a new exception, DO NOT subclass from a parallel exception. - * Create your new exception from derived from the STL exception class, - * then typedef your new exception to a parallel exception using the - * ExTemp or ExTemp1 template. Then, be sure to call the - * MyException::registerException() during application initialization. - */ - -#include -#include -#include -#include -#include -#include -// #include // for std::cerr -#include - -#include -#if defined( STK_HAS_MPI ) -#include -#endif - -#include - -#include -#include -#include -#include - -namespace sierra { - -/// -/// @addtogroup ExceptionDetail -/// @{ -/// - -class ExParallel; - -/** - * @brief Member function register_stl_parallel_exceptions registers the stl - * exceptions with the parallel exception handler. - * - */ -void register_stl_parallel_exceptions(); - -/** - * @brief Function set_exception is called on a single processor when an - * exception is caught. The next collective communication will propogate the exception to - * all processors. This flavor is called when an unknown exception (...) is caught. - * - */ -void set_exception(); - -/** - * @brief Function set_exception is called on a single processor when an - * exception is caught. The next collective communication will propogate the exception to - * all processors. - * - * @param x a std::exception reference to the base exception. - */ -void set_exception(std::exception &x); - -/** - * @brief Function set_exception is called on a single processor when an - * exception is caught. The next collective communication will propogate the exception to - * all processors. - * - * @param x a std::exception reference to the parallel - * exception. - */ -void set_exception(ExParallel &x); - -/** - * @brief Member function sierra_exception_throw is called whenever a - * parallel exception is constructed. This acn be used as a breakpoint in a debugger if - * finding the magic throw symbol is too tricky. - * - */ -void sierra_exception_throw(); - -/** - * @brief Function throw_copy throws a copy of the exception. The exception - * is located in the parallel exception registry. This exception is cloned and thrown - * using the parallel exception's throw_copy member function. - * - * If the exception cannot be located, an Exception parallel exception is - * thrown instead contained the message from the original exception from - * what(). - * - * @param x a std::exception reference to the exception to be - * copied and thrown. - * - * @param message a std::string const reference to a message to be - * appended to the exception's description. - * - */ -void throw_copy(const std::exception &x, const std::string &message); - -/** - * @brief Function parallel_throw throws a consistant exception in - * parallel. parallel_throw is called after the exception has been propagated to all - * processors. parallel_throw will decide which exception to rethrow in parallel on all - * processors. - * - * @param mpi_comm a MPI_Comm value of the communicator to talk over. - * - */ -void parallel_throw(MPI_Comm mpi_comm); - - -/** - * @brief Class ParallelThrowRegistry is a registry of known parallel - * exceptions. For the negotiation of parallel exceptions, each parallel exception must - * be registered. The class serves as the registry and registrar for the exceptions. - * - * When an exception is registered, a new exception of that type is provided which is - * cloned whenever and exception of that type is required. - * - * Two different exception types are registered. The parallel exception type and the base - * exception type which is discovered using the BaseExceptionType type of the parallel - * exception class. When the parallel exception registry is searched, the parallel - * exception to be cloned is returned when either type is found. - * - * During parallel exception processing, the information from exception to be thrown in - * parallel is stored in the registered exception object. - * - */ -class ParallelThrowRegistry -{ -public: - /** - * @brief Member function instance returns the singleton instance for the - * parallel exception registry. - * - * @return a ParallelThrowRegistry ... - */ - static ParallelThrowRegistry &instance(); - - /** - * @brief Static member function setExceptionsRegistered sets the - * exceptions have been registered flag. This flag is used to control the calling of - * the function sierra_exception_thrown when a parallel exception is - * created. - * - */ - static bool areExceptionsRegistered() { - return !ParallelThrowRegistry::instance().m_registry.empty(); - } - - /** - * @brief Member template function registerException registers an exception - * of the specified type with the parallel registry. An exception is provided which is - * to be cloned whenever a parallel exception of that type is the be created for - * parallel throwing. - * - * @return an ExParallel reference to the - * x_to_clone exception. - */ - template - ExParallel ®isterException() { - T *x = new T(); - register_exception_a(typeid(T), x); - register_exception_a(typeid(typename T::BaseExceptionType), x); - return *x; - } - - /** - * @brief Member function findException returns a pointer to the matching exception - * in parallel exception registry. - * - * @param exception_type a std::type_info reference to the exception - * type being searched. - * - * @return an ExParallel pointer to the exception to be cloned. - */ - ExParallel *findException(const std::type_info &exception_type); - -private: - /** - * @brief Member function register_exception_a performs the actual registration. - * - * @param exception_type a std::type_info reference of the - * base exception type obtained via typeid of the - * BaseExceptionType type of the parallel exception type. - * - * @param exception an ExParallel pointer to the parallel - * exception to be cloned. - * - */ - ExParallel ®ister_exception_a(const std::type_info ¶llel_exception_type, ExParallel *exception); - -private: - /** - * @brief Typedef Registry is a registry of pairing of each exception type - * to its registered parallel throw exception to be cloned. - * - */ - class Registry : public std::vector > - { - public: - Registry(); - - ~Registry(); - }; - - Registry m_registry; ///< Registry of exceptions -}; - - -/** - * @brief Class ExParallel implements the features of a parallel exception. - * It is a std::string which stores the exception description. It also - * provides "put to" (operator;lt&;lt&) functions for appending the description with - * information. - * - */ -class ExParallel -{ -protected: - /** - * Creates a new ExParallel instance which is not about to be thrown in - * parallel and has no description. - * - */ - ExParallel() - : m_descriptionStream(), - m_whatBuffer(), - m_traceback(Diag::Trace::printTraceback(Diag::Trace::Traceback::snapshot())), - m_parallel(-1) - { - if (ParallelThrowRegistry::areExceptionsRegistered()) - sierra_exception_throw(); - } - - /** - * Creates a new ExParallel instance with an initial description and may be - * about to be thrown in parallel. - * - * @param message an std::string const reference to the initial - * description. - * - * @param parallel an bool value of true if this exception is - * about to be thrown in parallel. - */ - explicit ExParallel(const std::string & message, int parallel = -1) - : m_descriptionStream(), - m_whatBuffer(), - m_traceback(Diag::Trace::printTraceback(Diag::Trace::Traceback::snapshot())), - m_parallel(parallel) - { - m_descriptionStream << message; - if (ParallelThrowRegistry::areExceptionsRegistered()) - sierra_exception_throw(); - } - - /** - * Creates a new ExParallel copy. - * - * @param x an ExParallel const reference to the - * exception to copy. - */ - ExParallel(const ExParallel &x) - : m_descriptionStream(), - m_whatBuffer(), - m_traceback(x.m_traceback), - m_parallel(x.m_parallel) - { - m_descriptionStream << x.m_descriptionStream.str(); - } - -public: - /** - * Destroys a ExBase instance. - * - */ - virtual ~ExParallel() - {} - - /** - * @brief Member function what returns the exception's description. - * - * @return a char const pointer to the exception's - * description. - */ - virtual const char *what() const throw() { - try { - m_whatBuffer = m_descriptionStream.str(); - return m_whatBuffer.c_str(); - } - catch(...) { - return NULL; - } - } - - /** - * @brief Member function clear clears the contents of the exception. - * - * @return an ExParallel reference to the exception. - */ - ExParallel &clear() { - m_descriptionStream.str(""); - m_traceback.clear(); - m_parallel = -1; - return *this; - } - - /** - * @brief Member function setDescription sets the value of the exception's - * description. - * - * @param description a std::string const reference to the - * description. - * - * @return an ExParallel reference to the exception. - */ - ExParallel &setDescription(const std::string &description) { - clear(); - m_descriptionStream << description; - return *this; - } - - /** - * @brief Member function getDescription returns the exception's - * description. - * - * @return a std::string value of the exception's - * description. - */ - std::string getDescription() const{ - return m_descriptionStream.str(); - } - - /** - * @brief Member function getDescriptionStream returns the stream used to - * assemble the description. - * - * @return a std::ostringstream reference to the - * exception's description stream. - */ - std::ostringstream &getDescriptionStream() { - return m_descriptionStream; - } - - /** - * @brief Member function getDescriptionStream returns the stream used to - * assemble the description. - * - * @return a std::ostringstream const reference to the - * exception's description stream. - */ - const std::ostringstream &getDescriptionStream() const { - return m_descriptionStream; - } - - /** - * @brief Member function setTraceback sets the exception's traceback - * to the caller generating the exception. - * - * @param traceback a std::string const reference to the - * traceback. - * - * @return an ExParallel reference to the exception. - */ - ExParallel &setTraceback(const std::string &traceback) { - m_traceback = traceback; - return *this; - } - - /** - * @brief Member function getTraceback returns the exception's traceback string. - * - * @return a std::string const reference to the - * exception's traceback string. - */ - const std::string &getTraceback() const { - return m_traceback; - } - - /** - * @brief Member function setParallel sets the originating processor for an - * exception that is being thrown in parallel. - * - * @param parallel a int value to set the originating - * processor for this parallel exception. - * - * @return an ExParallel reference to this - * parallel exception. - */ - ExParallel &setParallel(int parallel) { - m_parallel = parallel; - return *this; - } - - /** - * @brief Member function getParallel returns the originating processor for - * a parallel exception or -1 if the exception was not thrown in parallel. - * - * @return a int value of the originating processor - * for the parallel exception or -1. - */ - int getParallel() const { - return m_parallel; - } - - - /** - * @brief Member function isParallel returns true if the exception is - * being thrown in parallel. - * - * @return a bool value of true if the exception - * is being thrown in parallel. - */ - bool isParallel() const { - return m_parallel != -1; - } - - /** - * @brief Member function operator<< passes the std manipilator - * functions to the ExParallel object. This allows the manipulators to - * modify the description. (Currently in a limited fashion). - * - * @return an ExParallel reference to this - * parallel exception. - */ - ExParallel &operator<<(std::ostream& (*f)(std::ostream&)) { - f(m_descriptionStream); - return *this; - } - - /** - * Member function operator<< passes any data type to the exception - * string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a ExParallel reference to this object; - */ - template - ExParallel &operator<<(const U &t) { - m_descriptionStream << t; - return *this; - } - - /** - * @brief Member function throw_copy is a pure virtual function which is allows - * the copying and throwing of the parallel exception using a pointer to the base - * exception object. This function should never return, it should throw the copied - * exception. - * - * The exception is being throw in parallel so be sure to set the parallel thrown - * processor via setParallel(int) before throwing the copy. - * - */ - virtual void throw_copy() const = 0; - - /** - * @brief Member function parallel_handler is called just before a parallel - * exception is thrown. It is guaranteed to be called in parallel on all processors, so - * collective communication is allowed inside Parallel_Handler. This function might be - * used to copy information to all processors. The default is to do nothing. - * - */ - virtual void parallel_handler(); - -private: - std::ostringstream m_descriptionStream; ///< Description from original throw - mutable std::string m_whatBuffer; ///< what() buffer - std::string m_traceback; ///< Traceback from original throw - int m_parallel; ///< True if being thrown in parallel -}; - - -/** - * @brief Template ExTemp takes a zero argument exception and makes it into a - * parallel throwable and put-to-able (<<) exception. This exception may be caught with - * either the base class T type or the template ExTemp<T> - * type. - * - */ -template -class ExTemp : public ExParallel, public T -{ -public: - typedef ExTemp ParallelExceptionType; ///< Parallel exception type - typedef T BaseExceptionType; ///< Base exception type - - /** - * Creates a new ExTemp instance. - * - */ - ExTemp() - : ExParallel(), - T() - {} - - /** - * Creates a new ExTemp instance with an initial description. - * - * @param message a std::string const reference to the initial - * exception description. - */ - explicit ExTemp(const std::string &message) - : ExParallel(message), - T() - {} - - /** - * Creates a new ExTemp copy. - * - * @param x an ExTemp variable ... - */ - ExTemp(const ExTemp & x) - : ExParallel(static_cast(x)), - T(static_cast(x)) - {} - - /** - * Destroys a ExTemp instance. - * - */ - virtual ~ExTemp() throw() - {} - - /** - * @brief Member function what returns the exception's description. - * - * @return a char const pointer to the exception's - * description. - */ - virtual const char *what() const throw() { - return ExParallel::what(); - } - - /** - * @brief Member function operator<< passes the std manipilator - * functions to the ExTemp object. This allows the manipulators to modify the - * description. (Currently in a limited fashion). - * - * @return an ExParallel reference to this - * parallel exception. - */ - ExTemp &operator<<(std::ostream& (*f)(std::ostream&)) { - f(getDescriptionStream()); - return *this; - } - - /** - * Member function operator<< passes any data type to the exception - * string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a ExTemp reference to this object; - */ - template - ExTemp &operator<<(const U &t) { - getDescriptionStream() << t; - return *this; - } - - /** - * @brief Member function copy throws a copy of the original exception. It - * copies the original message, sets the parallel thrown flag and throws the new - * exception. - * - */ - virtual void throw_copy() const { - ParallelExceptionType t(*this); - -// std::cerr << "throwing " << this->what() << std::endl -// << " as " << t.what(); - throw t; - } - - /** - * @brief Member function registerException registers the exception with - * the parallel exception registry. - * - * @return an ExParallel reference to the exception to - * be cloned when thrown. - */ - static void registerException() { -#ifdef SIERRA_TEMPLATE_CALL_BUG - ParallelThrowRegistry::instance().template registerException(); -#else - ParallelThrowRegistry::instance().registerException(); -#endif - } -}; - - -template -class ExTemp1 : public ExParallel, public T -{ -public: - typedef ExTemp1 ParallelExceptionType; ///< Parallel exception type - typedef T BaseExceptionType; ///< Base exception type - - /** - * Creates a new ExTemp1 instance. - * - */ - ExTemp1() - : ExParallel(), - T(std::string()) - {} - - /** - * Creates a new ExTemp1 instance with an initial description. - * - * @param message a std::string const reference to the initial - * exception description. - */ - explicit ExTemp1(const std::string & message) - : ExParallel(message), - T(message) - {} - - /** - * Creates a new ExTemp copy. - * - * @param x an ExTemp variable ... - */ - ExTemp1(const ExTemp1 & x) - : ExParallel(static_cast(x)), - T(static_cast(x)) - {} - - /** - * Destroys a ExTemp1 instance. - * - */ - virtual ~ExTemp1() throw() - {} - - /** - * @brief Member function what returns the exception's description. - * - * @return a char const pointer to the exception's - * description. - */ - virtual const char *what() const throw() { - return ExParallel::what(); - } - - /** - * @brief Member function operator<< passes the std manipilator - * functions to the ExTemp1 object. This allows the manipulators to modify the - * description. (Currently in a limited fashion). - * - * @return an ExParallel reference to this - * parallel exception. - */ - ExTemp1 &operator<<(std::ostream& (*f)(std::ostream&)) { - f(getDescriptionStream()); - return *this; - } - - - /** - * Member function operator<< passes any data type to the exception - * string class for conversion to a string. - * - * @param t a T const reference that is to be converted - * to a string. - * - * @return a ExTemp1 reference to this object; - */ - template - ExTemp1 &operator<<(const U &t) { - getDescriptionStream() << t; - return *this; - } - - /** - * @brief Member function throw_copy throws a copy of the original - * exception. It copies the original message, appends the message to the exception - * description, sets the parallel thrown flag and throws the new exception. - * - * @param message a std::string const reference to a message to - * be appended to the exception's description prior to being - * thrown. - */ - virtual void throw_copy() const { - ParallelExceptionType t(*this); - -// std::cerr << "throwing " << this->what() << std::endl -// << " as " << t.what(); - throw t; - } - - /** - * @brief Member function registerException registers the exception with - * the parallel exception registry. - * - * @return an ExParallel reference to the exception to - * be cloned when thrown. - */ - static ExParallel ®isterException() { -#ifdef SIERRA_TEMPLATE_CALL_BUG - return ParallelThrowRegistry::instance().template registerException(); -#else - return ParallelThrowRegistry::instance().registerException(); -#endif - } -}; - -typedef ExTemp Exception; ///< Defined in -typedef ExTemp BadException; ///< Defined in -typedef ExTemp BadAlloc; ///< Defined in -typedef ExTemp BadTypeid; ///< Defined in -typedef ExTemp BadCast; ///< Defined in -typedef ExTemp1 IosBaseFailure; ///< Defined in -typedef ExTemp1 LogicError; ///< Defined in -typedef ExTemp1 DomainError; ///< Defined in -typedef ExTemp1 InvalidArgument; ///< Defined in -typedef ExTemp1 LengthError; ///< Defined in -typedef ExTemp1 OutOfRange; ///< Defined in -typedef ExTemp1 RuntimeError; ///< Defined in -typedef ExTemp1 RangeError; ///< Defined in -typedef ExTemp1 OverflowError; ///< Defined in -typedef ExTemp1 UnderflowError; ///< Defined in - -//---------------------------------------------------------------------- - -/** - * @brief Class runtime_user_error ... - * - */ -class runtime_user_error : public std::runtime_error -{ -public: - explicit runtime_user_error(const std::string &message) throw() - : std::runtime_error(message) - {} - - runtime_user_error(const runtime_user_error &x) throw() - : std::runtime_error(x) - {} - - virtual ~runtime_user_error() throw () - {} -}; - -typedef ExTemp1 RuntimeUserError; - -/// -/// @} -/// - -} // namepace sierra - -// DO NOT USE ParallelStackTrace, unless you know that the exception will be thrown in -// parallel. This is a magic string used by the parallel_throw routine that makes -// sure the printout will only be done on processor 0. Since the exception is -// parallel there is no reason to print the same message many times. -#define StackTraceMessage " exception thrown from " -#define ParallelStackTraceMessage " parallel exception thrown from " -#define ParallelStackTrace std::string(std::string(ParallelStackTraceMessage) + stk_classic::source_relative_path(STR_TRACE)) - -#endif // STK_UTIL_PARALLEL_Exception_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionIos.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionIos.hpp deleted file mode 100644 index 704ab4cc6a29..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionIos.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2003 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef STK_UTIL_PARALLEL_ExceptionIos_hpp -#define STK_UTIL_PARALLEL_ExceptionIos_hpp - -/*--------------------------------------------------------------------*/ -/** @file - * Lightweight Io Exception Classes for SIERRA that includes - * heavyweight header ios. - * - * See Exception.h for the usage of this header file. - */ - -/* Standard Library Classes containing Exceptions */ -#include -#include - -#endif // STK_UTIL_PARALLEL_ExceptionIos_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.cpp deleted file mode 100644 index 1e7eece3cd93..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2003-2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -namespace sierra { - - - -// int get_next_message_id(int max_id_messages) { -// if(max_id_messages == -1) max_id_messages = get_default_max_message_id_displayed(); -// return stk_classic::stk_get_next_message_id(max_id_messages); -// } - -namespace { - -std::ofstream *s_testErrorMessagesFile = NULL; - -bool s_dieOnFirstWarning = false; -bool s_dieOnFirstError = false; - -std::string s_testErrorMessagesPath; - -} // namespace - -void -test_error_messages_to_file_report_handler(const char * message, int type) { - - std::string new_message(message); - std::string::size_type start_pos; - // - // Strip out platform dependent exception related messages. - // - start_pos = new_message.find("exception thrown from"); - if(start_pos != std::string::npos) { - int end_pos = new_message.find('\n'); - new_message.erase(start_pos, (end_pos - start_pos) + 1); - } - start_pos = new_message.find("error thrown from"); - if(start_pos != std::string::npos) { - int end_pos = new_message.find('\n'); - new_message.erase(start_pos, (end_pos - start_pos) + 1); - } - start_pos = new_message.find("warning thrown from"); - if(start_pos != std::string::npos) { - int end_pos = new_message.find('\n'); - new_message.erase(start_pos, (end_pos - start_pos) + 1); - } - start_pos = new_message.find("Exception of type"); - if(start_pos != std::string::npos) { - int end_pos = new_message.find('\n'); - new_message.erase(start_pos, (end_pos - start_pos) + 1); - } - start_pos = new_message.find("with signature"); - if(start_pos != std::string::npos) { - int end_pos = new_message.find('\n', start_pos); - new_message.erase(start_pos, (end_pos - start_pos) + 1); - } - - *s_testErrorMessagesFile << "********************************************************************************" << std::endl - << word_wrap(new_message.c_str(), 80, "** ") - << "********************************************************************************" << std::endl; - *s_testErrorMessagesFile << "===== ENDING ERROR FILE \"" << s_testErrorMessagesPath << "\" =====" << std::endl; - - - - int msgType = (type & stk_classic::MSG_TYPE_MASK); - - - bool dieNow = false; - - if((msgType == stk_classic::MSG_WARNING) && s_dieOnFirstWarning) { - dieNow = true; - } - - if((msgType == stk_classic::MSG_DOOMED) && s_dieOnFirstError) { - dieNow = true; - } - - if((msgType == stk_classic::MSG_EXCEPTION) && s_dieOnFirstError) { - dieNow = true; - } - - if(dieNow) { - delete s_testErrorMessagesFile; - MPI_Finalize(); - std::exit(0); - } - - - -} - - -void -set_test_error_messages_file( - const std::string & test_error_messages_path) -{ - s_testErrorMessagesPath = test_error_messages_path; - - s_testErrorMessagesFile = new std::ofstream(s_testErrorMessagesPath.c_str(), std::ios::out); - *s_testErrorMessagesFile << "===== STARTING ERROR FILE \"" << s_testErrorMessagesPath << "\" =====" << std::endl; - - stk_classic::set_report_handler(test_error_messages_to_file_report_handler); -} - - -std::ofstream * -get_test_error_messages_file() -{ - return s_testErrorMessagesFile; -} - - - void set_test_error_messages_die_on_first_message(std::vector errorTypes) { - for(unsigned int ierr=0; ierr< errorTypes.size(); ++ierr) { - if(errorTypes[ierr] == DIE_ON_WARN) { - s_dieOnFirstWarning = true; - } - if(errorTypes[ierr] == DIE_ON_ERROR) { - s_dieOnFirstError = true; - } - if(errorTypes[ierr] == DIE_ON_MESSAGE) { - s_dieOnFirstWarning = true; - s_dieOnFirstError = true; - } - } - - -} - - -bool get_test_error_messages_die_on_first_warning() { - return s_dieOnFirstWarning; -} - -bool get_test_error_messages_die_on_first_error() { - return s_dieOnFirstError; -} - -} // namespace sierra - -extern "C" { - void SIERRA_FORTRAN(report_error)(int &int_val, const char *message, const int message_length) { - switch (int_val) { - case 1: - sierra::Env::outputP0() << " " << std::string(message, message + message_length) << std::endl; - break; - - case 2: - sierra::RuntimeWarning() << "In Fmwk, " << std::string(message, message + message_length) << std::endl << WarnTrace; - break; - - case 3: - throw sierra::RuntimeError() << "In Fmwk, " << std::string(message, message + message_length) << std::endl << ErrorTrace; - } - } -} diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.hpp deleted file mode 100644 index fd7fa6b92665..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ExceptionReport.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef STK_UTIL_PARALLEL_ExceptionReport_hpp -#define STK_UTIL_PARALLEL_ExceptionReport_hpp - -#include -#include -#include - -#include -#include - - -/** - * @ingroup Exception - * @brief Macro WarnTrace makes a pretty warning message with file and line number. - * - */ -#define WarnTrace std::string(std::string(" warning at ") + stk_classic::source_relative_path(STR_TRACE)) - -/** - * @ingroup Exception - * @brief Macro ErrorTrace makes a pretty error message with file and line number. - * - */ -#define ErrorTrace std::string(std::string(" error thrown from ") + stk_classic::source_relative_path(STR_TRACE)) - -namespace sierra { - - enum ErrorDieEnum{DIE_ON_WARN=0, DIE_ON_ERROR=1, DIE_ON_MESSAGE=2}; - -typedef stk_classic::MessageCode MessageCode; - -typedef stk_classic::RuntimeWarningAdHoc RuntimeWarning; ///< Deprecated -typedef stk_classic::RuntimeWarningSymmetric RuntimeWarningP0; ///< Deprecated - -typedef stk_classic::RuntimeWarningAdHoc RuntimeWarningAdHoc; -typedef stk_classic::RuntimeWarningSymmetric RuntimeWarningSymmetric; -typedef stk_classic::RuntimeWarningDeferred RuntimeWarningDeferred; - -typedef stk_classic::RuntimeDoomedAdHoc RuntimeDoomed; ///< Deprecated -typedef stk_classic::RuntimeDoomedSymmetric RuntimeDoomedP0; ///< Deprecated - -typedef stk_classic::RuntimeDoomedAdHoc RuntimeDoomedAdHoc; -typedef stk_classic::RuntimeDoomedSymmetric RuntimeDoomedSymmetric; -typedef stk_classic::RuntimeDoomedDeferred RuntimeDoomedDeferred; - -void set_test_error_messages_file(const std::string &test_error_messages_path); - -std::ofstream *get_test_error_messages_file(); - - void set_test_error_messages_die_on_first_message(std::vector errorTypes); - -bool get_test_error_messages_die_on_first_warning(); -bool get_test_error_messages_die_on_first_error(); - - -/// -/// @} -/// - -} // namespace sierra - -/** - * @ingroup Exception - * @brief Function report_error reports a message from a Fortran function to - * the exception reporting system. If the int_val is 1, the message is printed - * to sierra::Env::outputP0(). If it is 2, a sierra::RuntimeWarning is issued. And, if - * it is 3, a sierra::RuntimeError is thrown. - * - * @param int_val a int value of the type of message to - * report. - * - * @param message a char const pointer to the start of the - * message. - * - * @param message_length a int const value the length of the message. - * - */ -extern "C" - void SIERRA_FORTRAN(report_error)(int &int_val, const char *message, const int message_length); - -#endif // STK_UTIL_PARALLEL_ExceptionReport_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.cpp deleted file mode 100644 index 5d4645f984d7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2005 - 2009 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include - -#include -#include - -namespace sierra { -namespace MPI { - -template struct Loc; -template struct Loc; -template struct Loc; - -MPI_Datatype -double_complex_type() -{ - static MPI_Datatype s_mpi_double_complex; - static bool initialized = false; - - if (!initialized) { - initialized = true; - - MPI_Type_contiguous(2, MPI_DOUBLE, &s_mpi_double_complex); - MPI_Type_commit(&s_mpi_double_complex); - } - return s_mpi_double_complex; -} - -MPI_Datatype -float_complex_type() -{ - static MPI_Datatype s_mpi_float_complex; - static bool initialized = false; - - if (!initialized) { - initialized = true; - - MPI_Type_contiguous(2, MPI_FLOAT, &s_mpi_float_complex); - MPI_Type_commit(&s_mpi_float_complex); - } - return s_mpi_float_complex; -} - - -// #ifdef MPI_LONG_LONG_INT -// MPI_Datatype -// long_long_int_int_type() -// { -// static MPI_Datatype s_mpi_long_long_int_int; -// static bool initialized = false; - -// int B[] = {2, 1}; -// MPI_Aint D[] = {0, 8}; -// MPI_Datatype T[] = {MPI_LONG_LONG_INT, MPI_INT}; - -// if (!initialized) { -// initialized = true; - -// MPI_Type_struct(2, B, D, T, &s_mpi_long_long_int_int); -// MPI_Type_commit(&s_mpi_long_long_int_int); -// } -// return s_mpi_long_long_int_int; -// } -// #endif - - -MPI_Datatype -double_double_int_type() -{ - static MPI_Datatype s_mpi_double_double_int; - static bool initialized = false; - - int B[] = {2, 1}; - MPI_Aint D[] = {0, 16}; - MPI_Datatype T[] = {MPI_DOUBLE, MPI_INT}; - - - if (!initialized) { - initialized = true; - - MPI_Type_struct(2, B, D, T, &s_mpi_double_double_int); - MPI_Type_commit(&s_mpi_double_double_int); - } - return s_mpi_double_double_int; -} - - -namespace { - -extern "C" { - void - mpi_double_complex_sum( - void * invec, - void * inoutvec, - int * len, - MPI_Datatype * datatype) - { - std::complex *complex_in = static_cast *>(invec); - std::complex *complex_inout = static_cast *>(inoutvec); - - for (int i = 0; i < *len; ++i) - complex_inout[i] += complex_in[i]; - } -} // extern "C" - -} // namespace - - -MPI_Op -double_complex_sum_op() -{ - static MPI_Op s_mpi_double_complex_sum; - static bool initialized = false; - - if (!initialized) { - initialized = true; - - MPI_Op_create(mpi_double_complex_sum, true, &s_mpi_double_complex_sum); - } - return s_mpi_double_complex_sum; -} - -namespace { - -const MPI::ReduceSet *s_currentReduceSet = 0; - -extern "C" { - typedef void (*ParallelReduceOp) - (void * inv, void * outv, int *, MPI_Datatype *); -} - - -void -all_reduce( - MPI_Comm arg_comm, - ParallelReduceOp arg_op, - void * arg_in, - void * arg_out, - unsigned arg_len) -{ - MPI_Op mpi_op = MPI_OP_NULL ; - - MPI_Op_create(arg_op, 0, & mpi_op); - - // The SUN was buggy when combinng an - // MPI_Allreduce with a user defined operator, - // use reduce/broadcast instead. - -#ifdef SIERRA_MPI_ALLREDUCE_USER_FUNCTION_BUG - const int result_reduce = MPI_Reduce(arg_in,arg_out,arg_len,MPI_BYTE,mpi_op,0,arg_comm); - const int result_bcast = MPI_Bcast(arg_out,arg_len,MPI_BYTE,0,arg_comm); - - MPI_Op_free(& mpi_op); - - if (MPI_SUCCESS != result_reduce || MPI_SUCCESS != result_bcast) { - std::ostringstream msg ; - msg << "sierra::MPI::all_reduce FAILED: MPI_Reduce = " << result_reduce - << " MPI_Bcast = " << result_bcast ; - throw std::runtime_error(msg.str()); - } -#else - const int result = MPI_Allreduce(arg_in,arg_out,arg_len,MPI_BYTE,mpi_op,arg_comm); - - MPI_Op_free(& mpi_op); - - if (MPI_SUCCESS != result) { - std::ostringstream msg ; - msg << "sierra::MPI::all_reduce FAILED: MPI_Allreduce = " << result; - throw std::runtime_error(msg.str()); - } -#endif -} - -struct ReduceCheck : public ReduceInterface -{ - ReduceCheck() - {} - - void setSize(unsigned size) { - m_size = size; - } - - virtual void size(void *&inbuf) const { - unsigned *t = align_cast(inbuf); - t += sizeof(unsigned); - inbuf = t; - } - - virtual void copyin(void *&inbuf) const { - unsigned *t = align_cast(inbuf); - *t++ = m_size; - inbuf = t; - } - - virtual void copyout(void *&outbuf) const { - unsigned *t = align_cast(outbuf); - - unsigned size = *t++; - if (m_size != size) - throw std::runtime_error("size mismatch"); - - outbuf = t; - } - - virtual void op(void *&inbuf, void *&outbuf) const { - unsigned *tin = align_cast(inbuf); - unsigned *tout = align_cast(outbuf); - - *tout = std::min(*tout, *tin); - - inbuf = ++tin; - outbuf = ++tout; - } - -private: - unsigned m_size; -}; - -} // namespace - - -ReduceSet::ReduceSet() -{ - add(new ReduceCheck); -} - - -ReduceSet::~ReduceSet() -{ - for (ReduceVector::const_iterator it = m_reduceVector.begin(); it != m_reduceVector.end(); ++it) - delete (*it); -} - - -size_t -ReduceSet::size() const { - void *buffer_end = 0; - - for (ReduceVector::const_iterator it = m_reduceVector.begin(); it != m_reduceVector.end(); ++it) - (*it)->size(buffer_end); - - ReduceCheck *reduce_check = static_cast(m_reduceVector.front()); - reduce_check->setSize(reinterpret_cast(buffer_end) - (char *) 0); - - return reinterpret_cast(buffer_end) - (char *) 0; -} - -void -ReduceSet::copyin(void * const buffer_in) const { - void *inbuf = buffer_in; - - for (ReduceVector::const_iterator it = m_reduceVector.begin(); it != m_reduceVector.end(); ++it) - (*it)->copyin(inbuf); -} - -void -ReduceSet::copyout(void * const buffer_out) const { - void *outbuf = buffer_out; - - for (ReduceVector::const_iterator it = m_reduceVector.begin(); it != m_reduceVector.end(); ++it) - (*it)->copyout(outbuf); -} - -void -ReduceSet::op(void * const buffer_in, void * const buffer_out) const { - void *inbuf = buffer_in; - void *outbuf = buffer_out; - - for (ReduceVector::const_iterator it = m_reduceVector.begin(); it != m_reduceVector.end(); ++it) - (*it)->op(inbuf, outbuf); -} - -void ReduceSet::void_op(void * inv, void * outv, int *, MPI_Datatype *) { - s_currentReduceSet->op(inv, outv); -} - - -void -ReduceSet::add( - ReduceInterface * reduce_interface) -{ - m_reduceVector.push_back(reduce_interface); -} - - -void -AllReduce( - MPI_Comm comm, - const ReduceSet & reduce_set) -{ - size_t size = reduce_set.size(); - - if (size) { - char *input_buffer = new char[size]; - char *output_buffer = new char[size]; - void *inbuf = (void *) input_buffer; - void *outbuf = (void *) output_buffer; - - s_currentReduceSet = &reduce_set; - - ParallelReduceOp f = reinterpret_cast(& ReduceSet::void_op); - - reduce_set.copyin(inbuf); - all_reduce(comm, f, inbuf, outbuf, size); - reduce_set.copyout(outbuf); - delete [] output_buffer; - delete [] input_buffer; - } -} - - -} // namespace MPI -} // namespace sierra diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.hpp deleted file mode 100644 index b118668779c0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/MPI.hpp +++ /dev/null @@ -1,1033 +0,0 @@ -#ifndef STK_UTIL_PARALLEL_MPI_hpp -#define STK_UTIL_PARALLEL_MPI_hpp - -#include -#if defined( STK_HAS_MPI ) - -#include -#include -#include -#include -#include - -namespace sierra { -namespace MPI { - -template -inline -void - mpi_real_complex_sum( - void * invec, - void * inoutvec, - int * len, - MPI_Datatype * datatype) - { - std::complex *complex_in = static_cast *>(invec); - std::complex *complex_inout = static_cast *>(inoutvec); - - for (int i = 0; i < *len; ++i) - complex_inout[i] += complex_in[i]; - } - -/// -/// @addtogroup MPIDetail -/// @{ -/// - - -/** - * @brief Function float_complex_type returns an MPI complex data type for - * C++. - * - * @return a MPI_Datatype value of the C++ complex MPI data type. - */ -MPI_Datatype float_complex_type(); - -/** - * @brief Function double_complex_type returns an MPI complex data type for - * C++. - * - * @return a MPI_Datatype value of the C++ complex MPI data type. - */ -MPI_Datatype double_complex_type(); - -/** - * @brief Function double_complex_sum_op returns a sum operation for the C++ - * complex MPI data type. - * - * @return a MPI_Op ... - */ -MPI_Op double_complex_sum_op(); - -/** - * @brief Function real_complex_sum_op returns a sum operation for the C++ - * complex MPI data type. - * - * @return a MPI_Op ... - */ -template -inline -MPI_Op real_complex_sum_op() -{ - static MPI_Op s_mpi_real_complex_sum; - static bool initialized = false; - - if (!initialized) { - initialized = true; - - MPI_Op_create(mpi_real_complex_sum, true, &s_mpi_real_complex_sum); - } - return s_mpi_real_complex_sum; -} - -/** - * @brief Member function double_double_int_type ... - * - * @return a MPI_Datatype ... - */ -MPI_Datatype long_long_int_int_type(); - - -/** - * @brief Member function double_double_int_type ... - * - * @return a MPI_Datatype ... - */ -MPI_Datatype double_double_int_type(); - - -/** - * @brief Template class loc implements the data structure for the MINLOC and - * MAXLOC data types. - * - */ -template -struct Loc -{ - Loc() - : m_value(), - m_loc(0) - {} - - Loc(const T &value, int loc) - : m_value(value), - m_loc(loc) - {} - - T m_value; - int m_loc; -}; - -struct TempLoc -{ - TempLoc() - : m_value(), - m_other(), - m_loc(0) - {} - - TempLoc(double value, double other, int loc) - : m_value(value), - m_other(other), - m_loc(loc) - {} - - double m_value; - double m_other; - int m_loc; -}; - - -/** - * @brief Traits class Datatype implements a traits class containing two - * static member functions which return the appropriate MPI data type for the C++ data - * type. - * - * The type() function returns the MPI data type. - * - */ -template -struct Datatype; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_CHAR; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_CHAR; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_BYTE; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_INT; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_UNSIGNED; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_SHORT; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_UNSIGNED_SHORT; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_LONG; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_UNSIGNED_LONG; - } -}; - -// #ifdef MPI_LONG_LONG_INT -// template <> -// struct Datatype -// { -// static MPI_Datatype type() { -// return MPI_LONG_LONG_INT; -// } -// }; -// #endif - -// #ifdef MPI_UNSIGNED_LONG_LONG_INT -// template <> -// struct Datatype -// { -// static MPI_Datatype type() { -// return MPI_UNSIGNED_LONG_LONG_INT; -// } -// }; -// #endif - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_FLOAT; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return MPI_DOUBLE; - } -}; - - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return float_complex_type(); - } -}; - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return double_complex_type(); - } -}; - - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_2INT; - } -}; - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_SHORT_INT; - } -}; - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_LONG_INT; - } -}; - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_LONG_INT; - } -}; - -// #ifdef MPI_LONG_LONG_INT -// template <> -// struct Datatype > -// { -// static MPI_Datatype type() { -// return long_long_int_int_type(); -// } -// }; -// #endif - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_FLOAT_INT; - } -}; - -template <> -struct Datatype > -{ - static MPI_Datatype type() { - return MPI_DOUBLE_INT; - } -}; - -template <> -struct Datatype -{ - static MPI_Datatype type() { - return double_double_int_type(); - } -}; - - -/** - * @brief Function AllReduce copies the source/destination array into a - * temporary vector and then executed the MPI operation using the temporary as the source. - * - * @param mpi_comm a MPI_Comm value of the MPI communicator. - * - * @param op a MPI_Op value of the MPI operation. - * - * @param src_dest a T pointer to an array to be copied for the source - * and used as the destination. - * - * @param size a size_t value of the length of the array pointed to - * by src_dest - * - */ -template -inline void -AllReduce(MPI_Comm mpi_comm, MPI_Op op, T *src_dest, size_t size) -{ - std::vector source(src_dest, src_dest + size); - - if (MPI_Allreduce(&source[0], &src_dest[0], (int) size, Datatype::type(), op, mpi_comm) != MPI_SUCCESS ) - throw std::runtime_error("MPI_Allreduce failed"); -} - -/** - * @brief Function AllReduce copies the source/destination vector into a - * temporary vector and then executed the MPI operation using the temporary as the source. - * - * @param mpi_comm a MPI_Comm value of the MPI communicator. - * - * @param op a MPI_Op value of the MPI operation. - * - * @param src_dest a std::vector reference to be copied for the - * source and used as the destination. - * - * @param size a size_t value of the length of the array pointed to - * by src_dest - * - */ -template -inline void -AllReduce(MPI_Comm mpi_comm, MPI_Op op, std::vector &dest) -{ - std::vector source(dest); - - if (MPI_Allreduce(&source[0], &dest[0], (int) dest.size(), Datatype::type(), op, mpi_comm) != MPI_SUCCESS ) - throw std::runtime_error("MPI_Allreduce failed"); -} - -/** - * @brief Function AllReduce copies the source/destination vector into a - * temporary vector and then executed the MPI operation using the temporary as the source. - * - * @param mpi_comm a MPI_Comm value of the MPI communicator. - * - * @param op a MPI_Op value of the MPI operation. - * - * @param src a std::vector reference to the source data for the - * MPI op. - * - * @param dest a std::vector reference to the destination data - * for the MPI op. - * - * @param size a size_t value of the length of the array pointed to - * by src_dest - * - */ -template -inline void -AllReduce(MPI_Comm mpi_comm, MPI_Op op, std::vector &source, std::vector &dest) -{ - if (source.size() != dest.size()) - throw std::runtime_error("sierra::MPI::AllReduce(MPI_Comm mpi_comm, MPI_Op op, std::vector &source, std::vector &dest) vector lengths not equal"); - - if (MPI_Allreduce(&source[0], &dest[0], (int) dest.size(), Datatype::type(), op, mpi_comm) != MPI_SUCCESS ) - throw std::runtime_error("MPI_Allreduce failed"); -} - - -template -inline void -AllGather(MPI_Comm mpi_comm, std::vector &source, std::vector &dest) -{ - int nproc = 1; - MPI_Comm_size(mpi_comm,&nproc); - if (source.size()*nproc != dest.size()) - throw std::runtime_error("sierra::MPI::AllReduce(MPI_Comm mpi_comm, MPI_Op op, std::vector &source, std::vector &dest) vector lengths not equal"); - - if (MPI_Allgather(&source[0], (int)source.size(), Datatype::type(), - &dest[0], (int)source.size(), Datatype::type(), - mpi_comm) != MPI_SUCCESS ){ - throw std::runtime_error("MPI_Allreduce failed"); - } -} - -/** - * @brief Function align_cast returns a pointer that has been aligned to the - * specified alignment or double if the alignment if greater than that of double. - * - * @param p a void pointer of the address to align. - * - * @return a T pointer which is an alignment of p to the - * lesser of the type specified or double. - */ -template -T *align_cast(void *p) -{ - enum {alignment = (sizeof(T) > sizeof(double) ? sizeof(double) : sizeof(T))}; - enum {mask = alignment - 1}; - - char * c = reinterpret_cast(p); - size_t front_misalign = (c - (char *)0) & mask; - if (front_misalign > 0) { - size_t correction = alignment - front_misalign; - T *q = reinterpret_cast((c - (char *)0) + correction); - return q; - } - - return reinterpret_cast(p); -} - -/** - * @brief Interface class ReduceInterface specifies the required virtual - * functions for the aggregated type and operation operator. The aggregated reduction - * operator allows a single MPI operation to perform many operations on many types. - * - * This is accomplished by the creation of a user MPI op, which consists of a vector of - * this interface. This vector is used to first size the data, then to create source and - * destination buffers, copy the source data into the source buffer, perform the operation - * on each piece of data from the source to the destination buffer and finally copy the - * destination buffer to destination data. - * - */ -struct ReduceInterface { - /** - * Creates a new ReduceInterface instance. - * - */ - ReduceInterface() - {} - - /** - * Destroys a ReduceInterface instance. - * - */ - virtual ~ReduceInterface() - {} - - /** - * @brief Member function size returns the size in bytes needed to store the data for - * the reduction operation of this interface. The inbuf parameter should be - * advanced to provide enough aligned space for the data of the reduction. - * - * @param inbuf a void reference to a pointer to the be advanced by - * the size needed to store the data for the reduction. - * - */ - virtual void size(void *&inbuf) const = 0; - - /** - * @brief Member function copyin copies the data from the reduction interface to - * the inbuf pointer reference. The pointer should be advanced to point just - * beyond the space of the data. Be sure to align the pointer before storing the first - * element of data. - * - * @param inbuf a void reference to a pointer to start placing data - * after alignment and should be advance to just beyond the - * last element of stored data. - * - */ - virtual void copyin(void *&inbuf) const = 0; - - /** - * @brief Member function copyin copies the data from outbuf pointer - * reference to the reduction interface data. The pointer should be advanced to point - * just beyond the space of the data. Be sure to align the pointer before retrieving - * the first element of data. - * - * @param outbuf a void reference to a pointer to start retrieving - * data after alignment and should be advance to just beyond - * the last element of retrieved data. - * - */ - virtual void copyout(void *&outbuf) const = 0; - - /** - * @brief Member function op executes the operation on the data at inbuf - * pointer reference and outbuf pointer reference and placing the result in - * outbuf pointer reference. The pointers should be advanced to point just - * beyond the space of the correspondingdata. Be sure to align the pointer before - * retrieving the first element of data. - * - * @param inbuf a void reference to a pointer to start retrieving data - * after alignment and should be advance to just beyond the - * last element of stored data. - * - * @param outbuf a void reference to a pointer to start retrieving - * and storing data after alignment and should be advance to - * just beyond the last element of retrieved data. - * - */ - virtual void op(void *&inbuf, void *&outbuf) const = 0; -}; - - -/** - * @brief Template class Reduce implements the ReduceInterface interface for - * any operator and type. The operator is a functor and the iterator specifies the access - * to the data and its type. - * - * The operator Op is a functor that accepts two pointers, one to the destination - * object of the iterator's value type and one to the source object of the iterator's - * value type. The It is an iterator for accessing the data. Remember that a - * pointer is an iterator, so using plain arrays, even of length one as in a pointer to a - * scalar meets the criteria. - * - */ -template -struct Reduce : public ReduceInterface -{ - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::difference_type difference_type; - - Reduce(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) - : m_localBegin(local_begin), - m_localEnd(local_end), - m_globalBegin(global_begin), - m_globalEnd(global_end), - m_length(local_end - local_begin) - { - if (global_end - global_begin != m_length) - throw std::runtime_error("sierra::MPI::Reduce::Reduce(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) local and global lengths not equal"); - } - - virtual ~Reduce() - {} - - virtual void size(void *&inbuf) const { - value_type *t = align_cast(inbuf); - t += m_length; - inbuf = t; - } - - virtual void copyin(void *&inbuf) const { - value_type *t = align_cast(inbuf); - for (LocalIt it = m_localBegin; it != m_localEnd; ++it) - *t++ = (*it); - inbuf = t; - } - - virtual void copyout(void *&outbuf) const { - value_type *t = align_cast(outbuf); - for (GlobalIt it = m_globalBegin; it != m_globalEnd; ++it) - (*it) = *t++; - outbuf = t; - } - - virtual void op(void *&inbuf, void *&outbuf) const { - value_type *tin = align_cast(inbuf); - value_type *tout = align_cast(outbuf); - - for (size_t i = m_length; i; --i) - Op(tout++, tin++); - inbuf = tin; - outbuf = tout; - } - - LocalIt m_localBegin; - LocalIt m_localEnd; - GlobalIt m_globalBegin; - GlobalIt m_globalEnd; - difference_type m_length; -}; - - -/** - * @brief Class ReduceSet ... - * - */ -class ReduceSet -{ -public: - typedef std::vector ReduceVector; - - ReduceSet(); - - virtual ~ReduceSet(); - - void add(ReduceInterface *reduce_interface); - - size_t size() const; - - void copyin(void * const buffer_in) const; - - void copyout(void * const buffer_out) const; - - void op(void * const buffer_in, void * const buffer_out) const; - - static void void_op(void * inv, void * outv, int *n, MPI_Datatype *datatype); - -private: - ReduceVector m_reduceVector; -}; - -/** - * @brief Member function AllReduce ... - * - * @param comm a MPI_Comm variable ... - * - * @param reduce_set a ReduceSet variable ... - * - */ -void AllReduce(MPI_Comm comm, const ReduceSet &reduce_set); - -/** - * @brief Class Sum ... - * - */ -struct Sum -{ - template - inline Sum(T * dest, const T *source) { - *dest += *source; - } -}; - -/** - * @brief Class Prod ... - * - */ -struct Prod -{ - template - inline Prod(T * dest, const T *source) { - *dest *= *source; - } -}; - -/** - * @brief Class Min ... - * - */ -struct Min -{ - template - inline Min(T * dest, const T *source) { - *dest = std::min(*dest, *source); - } -}; - -/** - * @brief Class Max ... - * - */ -struct Max -{ - template - inline Max(T * dest, const T *source) { - *dest = std::max(*dest, *source); - } -}; - -/** - * @brief Class MinLoc ... - * - */ -struct MinLoc -{ - template - inline MinLoc(Loc * dest, const Loc *source) { - if (source->m_value < dest->m_value) { - dest->m_value = source->m_value; - dest->m_loc = source->m_loc; - } - else if (source->m_value == dest->m_value) - dest->m_loc = std::min(dest->m_loc, source->m_loc); - } -}; - -/** - * @brief Class MaxLoc ... - * - */ -struct MaxLoc -{ - template - inline MaxLoc(Loc * dest, const Loc *source) { - if (source->m_value > dest->m_value) { - dest->m_value = source->m_value; - dest->m_loc = source->m_loc; - } - else if (source->m_value == dest->m_value) - dest->m_loc = std::min(dest->m_loc, source->m_loc); - } -}; - - -struct MaxTempLoc -{ - inline MaxTempLoc(TempLoc * dest, const TempLoc *source) { - if (source->m_value > dest->m_value) { - dest->m_value = source->m_value; - dest->m_other = source->m_other; - dest->m_loc = source->m_loc; - } - else if (source->m_value == dest->m_value) { - if (dest->m_loc > source->m_loc) { - dest->m_other = source->m_other; - dest->m_loc = source->m_loc; - } - } - } -}; - -struct MinTempLoc -{ - inline MinTempLoc(TempLoc * dest, const TempLoc *source) { - if (source->m_value < dest->m_value) { - dest->m_value = source->m_value; - dest->m_other = source->m_other; - dest->m_loc = source->m_loc; - } - else if (source->m_value == dest->m_value) { - if (dest->m_loc > source->m_loc) { - dest->m_other = source->m_other; - dest->m_loc = source->m_loc; - } - } - } -}; - -/** - * @brief Member function ReduceSum ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @param length a size_t variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceSum(T *t, T *u, size_t length) { - return new Reduce(t, t + length, u, u + length); -} - -/** - * @brief Member function ReduceProd ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @param length a size_t variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceProd(T *t, T *u, size_t length) { - return new Reduce(t, t + length, u, u + length); -} - -/** - * @brief Member function ReduceMax ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @param length a size_t variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMax(T *t, T *u, size_t length) { - return new Reduce(t, t + length, u, u + length); -} - -/** - * @brief Member function ReduceMin ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @param length a size_t variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMin(T *t, T *u, size_t length) { - return new Reduce(t, t + length, u, u + length); -} - - -/** - * @brief Member function ReduceSum ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceSum(T &t, T &u) { - return new Reduce(&t, &t + 1, &u, &u + 1); -} - -/** - * @brief Member function ReduceProd ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceProd(T &t, T &u) { - return new Reduce(&t, &t + 1, &u, &u + 1); -} - -/** - * @brief Member function ReduceMax ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMax(T &t, T &u) { - return new Reduce(&t, &t + 1, &u, &u + 1); -} - -/** - * @brief Member function ReduceMin ... - * - * @param t a T variable ... - * - * @param u a T variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMin(T &t, T &u) { - return new Reduce(&t, &t + 1, &u, &u + 1); -} - - -/** - * @brief Member function ReduceSum ... - * - * @param local_begin an LocalIt variable ... - * - * @param local_end an LocalIt variable ... - * - * @param global_begin an GlobalIt variable ... - * - * @param global_end an GlobalIt variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceSum(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) { - return new Reduce(local_begin, local_end, global_begin, global_end); -} - -/** - * @brief Member function ReduceProd ... - * - * @param local_begin an LocalIt variable ... - * - * @param local_end an LocalIt variable ... - * - * @param global_begin an GlobalIt variable ... - * - * @param global_end an GlobalIt variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceProd(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) { - return new Reduce(local_begin, local_end, global_begin, global_end); -} - -/** - * @brief Member function ReduceMin ... - * - * @param local_begin an LocalIt variable ... - * - * @param local_end an LocalIt variable ... - * - * @param global_begin an GlobalIt variable ... - * - * @param global_end an GlobalIt variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMin(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) { - return new Reduce(local_begin, local_end, global_begin, global_end); -} - -/** - * @brief Member function ReduceMax ... - * - * @param local_begin an LocalIt variable ... - * - * @param local_end an LocalIt variable ... - * - * @param global_begin an GlobalIt variable ... - * - * @param global_end an GlobalIt variable ... - * - * @return a Reduce ... - */ -template -Reduce *ReduceMax(LocalIt local_begin, LocalIt local_end, GlobalIt global_begin, GlobalIt global_end) { - return new Reduce(local_begin, local_end, global_begin, global_end); -} - -/** - * @brief Member function AllReduceCollected ... - * - * @param mpi_comm a MPI_Comm variable ... - * - * @param op a MPI_Op variable ... - * - * @param collector an U variable ... - * - */ -template -inline void -AllReduceCollected(MPI_Comm mpi_comm, MPI_Op op, U collector) -{ - std::vector source; - - std::back_insert_iterator > source_inserter(source); - collector.gather(op, source_inserter); - - int size = source.size(); - -#ifdef SIERRA_DEBUG - // - // Check that the array lengths being reduces are all the same - // - int num_proc; - int my_proc; - MPI_Comm_size(mpi_comm, &num_proc); - MPI_Comm_rank(mpi_comm, &my_proc); - - - std::vector local_array_len(num_proc, 0); - local_array_len[my_proc] == size; - std::vector global_array_len(num_proc, 0); - - MPI_Allreduce(&local_array_len[0], &global_array_len[0], num_proc, MPI_INT, MPI_SUM, mpi_comm); - - for(unsigned i = 0; i < num_proc; ++i) { - if(global_array_len[i] != size) { - throw std::runtime_error("Slib_MPI.h::AllReduceCollected, not all processors have the same length array"); - } - } -#endif - - if (source.empty()) return; - std::vector dest(size); - - if (MPI_Allreduce(&source[0], &dest[0], size, Datatype::type(), op, mpi_comm) != MPI_SUCCESS ) - throw std::runtime_error("MPI_Allreduce failed"); - - typename std::vector::iterator dest_getter = dest.begin(); - collector.scatter(op, dest_getter); -} - -/// -/// @} -/// - -} // namespace MPI -} // namespace sierra - -#endif // if defined( STK_HAS_MPI ) -#endif // STK_UTIL_PARALLEL_MPI_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.cpp deleted file mode 100644 index d9f5100fd6a7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -/*--------------------------------------------------------------------*/ -/* Parallel operations */ - -#if defined( STK_HAS_MPI ) - -namespace stk_classic { - -unsigned parallel_machine_size( ParallelMachine parallel_machine ) -{ - int value = 1 ; - if (parallel_machine != MPI_COMM_NULL) { - if ( MPI_SUCCESS != MPI_Comm_size( parallel_machine , &value ) ) { - value = 1 ; - } - } - return value ; -} - -unsigned parallel_machine_rank( ParallelMachine parallel_machine ) -{ - int value = 0 ; - if (parallel_machine != MPI_COMM_NULL) { - if ( MPI_SUCCESS != MPI_Comm_rank( parallel_machine , &value ) ) { - value = 0 ; - } - } - return value ; -} - -void parallel_machine_barrier( ParallelMachine parallel_machine ) -{ - if (parallel_machine != MPI_COMM_NULL) { - MPI_Barrier( parallel_machine ); - } -} - -} - -#else - -namespace stk_classic { - -unsigned parallel_machine_size( ParallelMachine parallel_machine) { return 1 ; } - -unsigned parallel_machine_rank( ParallelMachine parallel_machine) { return 0 ; } - -void parallel_machine_barrier( ParallelMachine parallel_machine) {} - -} - -#endif - -/*--------------------------------------------------------------------*/ - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.hpp deleted file mode 100644 index e3eae1501892..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/Parallel.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_Parallel_hpp -#define stk_util_parallel_Parallel_hpp - -// stk_config.h resides in the build directory and contains the -// complete set of #define macros for build-dependent features. - -#include - -//---------------------------------------------------------------------- -// Parallel machine - -#if defined( STK_HAS_MPI ) - -#include - -namespace stk_classic { - -/** \addtogroup parallel_module - * @{ - */ - -/// \todo REFACTOR: Figure out a better way to typedef for non-MPI builds - -typedef MPI_Comm ParallelMachine ; - -/// \todo REFACTOR: Figure out a better way to typedef for non-MPI builds - -typedef MPI_Datatype ParallelDatatype ; - -/** - * @brief parallel_machine_null returns MPI_COMM_NULL if MPI is enabled. - * - * @return a ParallelMachine ... - */ -inline ParallelMachine parallel_machine_null() { return MPI_COMM_NULL ; } - -/** - * @brief parallel_machine_init calls MPI_Init. - * - * @param argc - * - * @param argv - * - * @return ParallelMachine (MPI_COMM_WORLD) - */ -inline ParallelMachine parallel_machine_init( int * argc , char *** argv ) -{ - MPI_Init( argc , argv ); - return MPI_COMM_WORLD ; -} - -/** - * @brief parallel_machine_finalize calls MPI_Finalize. - * - */ -inline void parallel_machine_finalize() -{ - MPI_Finalize(); -} - -/** \} */ - -} - -//---------------------------------------- -// Other parallel communication machines go here -// as '#elif defined( STK_HAS_ )' - -//---------------------------------------- -// Stub for non-parallel - -#else - -// Some needed stubs -#define MPI_Comm int -#define MPI_COMM_WORLD 0 -#define MPI_COMM_SELF 0 -#define MPI_Barrier( a ) (void)a - -namespace stk_classic { - -typedef int ParallelMachine ; -typedef int ParallelDatatype ; - -inline ParallelMachine parallel_machine_null() { return 0 ; } - -inline ParallelMachine parallel_machine_init( int * , char *** ) -{ return 0 ; } - -inline void parallel_machine_finalize() -{} - -} - -#endif - -//---------------------------------------------------------------------- -// Common parallel machine needs. - -namespace stk_classic { - -/** - * @brief Member function parallel_machine_size ... - * - * @param m a ParallelMachine ... - * - * @return an unsigned int ... - */ -unsigned parallel_machine_size( ParallelMachine parallel_machine ); - -/** - * @brief Member function parallel_machine_rank ... - * - * @param m a ParallelMachine ... - * - * @return an unsigned int ... - */ -unsigned parallel_machine_rank( ParallelMachine parallel_machine ); - -/** - * @brief Member function parallel_machine_barrier ... - * - */ -void parallel_machine_barrier( ParallelMachine parallel_machine); -} - -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.cpp deleted file mode 100644 index 26817c5ec4e5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.cpp +++ /dev/null @@ -1,1040 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include - -namespace stk_classic { - -//----------------------------------------------------------------------- - -#if defined( STK_HAS_MPI ) - -enum { STK_MPI_TAG_SIZING = 0 , STK_MPI_TAG_DATA = 1 }; - -// Communicate in sparse or dense mode, as directed during allocation - -namespace { - -bool all_to_all_dense( ParallelMachine p_comm , - const CommBuffer * const send , - const CommBuffer * const recv , - std::ostream & msg ) -{ - typedef unsigned char * ucharp ; - - static const char method[] = "stk_classic::CommAll::communicate" ; - - int result ; - - { - const unsigned p_size = parallel_machine_size( p_comm ); - - std::vector tmp( p_size * 4 ); - - int * const send_counts = (tmp.empty() ? NULL : & tmp[0]) ; - int * const send_displs = send_counts + p_size ; - int * const recv_counts = send_displs + p_size ; - int * const recv_displs = recv_counts + p_size ; - - unsigned char * const ps = static_cast(send[0].buffer()); - unsigned char * const pr = static_cast(recv[0].buffer()); - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - const CommBuffer & send_buf = send[i] ; - const CommBuffer & recv_buf = recv[i] ; - - send_counts[i] = send_buf.capacity(); - recv_counts[i] = recv_buf.capacity(); - - send_displs[i] = static_cast(send_buf.buffer()) - ps ; - recv_displs[i] = static_cast(recv_buf.buffer()) - pr ; - } - - result = MPI_Alltoallv( ps , send_counts , send_displs , MPI_BYTE , - pr , recv_counts , recv_displs , MPI_BYTE , - p_comm ); - - if ( MPI_SUCCESS != result ) { - msg << method << " GLOBAL ERROR: " << result << " == MPI_Alltoallv" ; - } - } - - return MPI_SUCCESS == result ; -} - -bool all_to_all_sparse( ParallelMachine p_comm , - const CommBuffer * const send , - const CommBuffer * const recv , - std::ostream & msg ) -{ - static const char method[] = "stk_classic::CommAll::communicate" ; - static const int mpi_tag = STK_MPI_TAG_DATA ; - - int result = MPI_SUCCESS ; - - { - const unsigned p_size = parallel_machine_size( p_comm ); - const unsigned p_rank = parallel_machine_rank( p_comm ); - - //------------------------------ - // Receive count - - unsigned num_recv = 0 ; - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - if ( recv[i].capacity() ) { ++num_recv ; } - } - - //------------------------------ - // Post receives for specific processors with specific sizes - - MPI_Request request_null = MPI_REQUEST_NULL ; - std::vector request( num_recv , request_null ); - std::vector status( num_recv ); - - unsigned count = 0 ; - - for ( unsigned i = 0 ; result == MPI_SUCCESS && i < p_size ; ++i ) { - const unsigned recv_size = recv[i].capacity(); - void * const recv_buf = recv[i].buffer(); - if ( recv_size ) { - result = MPI_Irecv( recv_buf , recv_size , MPI_BYTE , - i , mpi_tag , p_comm , & request[count] ); - ++count ; - } - } - - if ( MPI_SUCCESS != result ) { - msg << method << " LOCAL[" << p_rank << "] ERROR: " - << result << " == MPI_Irecv , " ; - } - - //------------------------------ - // Sync to allow ready sends and for a potential error - - int local_error = MPI_SUCCESS == result ? 0 : 1 ; - int global_error = 0 ; - - result = MPI_Allreduce( & local_error , & global_error , - 1 , MPI_INT , MPI_SUM , p_comm ); - - if ( MPI_SUCCESS != result ) { - msg << method << " GLOBAL ERROR: " << result << " == MPI_Allreduce" ; - } - else if ( global_error ) { - result = MPI_ERR_UNKNOWN ; - } - else { - // Everything is local from here on out, no more syncs - - //------------------------------ - // Ready-send the buffers, rotate the send processor - // in a simple attempt to smooth out the communication traffic. - - for ( unsigned i = 0 ; MPI_SUCCESS == result && i < p_size ; ++i ) { - const int dst = ( i + p_rank ) % p_size ; - const unsigned send_size = send[dst].capacity(); - void * const send_buf = send[dst].buffer(); - if ( send_size ) { - result = MPI_Rsend( send_buf , send_size , MPI_BYTE , - dst , mpi_tag , p_comm ); - } - } - - if ( MPI_SUCCESS != result ) { - msg << method << " LOCAL ERROR: " << result << " == MPI_Rsend , " ; - } - else { - MPI_Request * const p_request = (request.empty() ? NULL : & request[0]) ; - MPI_Status * const p_status = (status.empty() ? NULL : & status[0]) ; - - result = MPI_Waitall( num_recv , p_request , p_status ); - } - - if ( MPI_SUCCESS != result ) { - msg << method << " LOCAL[" << p_rank << "] ERROR: " - << result << " == MPI_Waitall , " ; - } - else { - - for ( unsigned i = 0 ; i < num_recv ; ++i ) { - MPI_Status * const recv_status = & status[i] ; - const int recv_proc = recv_status->MPI_SOURCE ; - const int recv_tag = recv_status->MPI_TAG ; - const int recv_plan = recv[recv_proc].capacity(); - int recv_count = 0 ; - - MPI_Get_count( recv_status , MPI_BYTE , & recv_count ); - - if ( recv_tag != mpi_tag || recv_count != recv_plan ) { - msg << method << " LOCAL[" << p_rank << "] ERROR: Recv[" - << recv_proc << "] Size( " - << recv_count << " != " << recv_plan << " ) , " ; - result = MPI_ERR_UNKNOWN ; - } - } - } - } - } - - return MPI_SUCCESS == result ; -} - -} - -#else - -// Not parallel - -namespace { - -bool all_to_all_dense( ParallelMachine , - const CommBuffer * const send , - const CommBuffer * const recv , - std::ostream & ) -{ return send == recv ; } - -bool all_to_all_sparse( ParallelMachine , - const CommBuffer * const send , - const CommBuffer * const recv , - std::ostream & ) -{ return send == recv ; } - -} - -#endif - -//---------------------------------------------------------------------- - -namespace { - -inline -size_t align_quad( size_t n ) -{ - enum { Size = 4 * sizeof(int) }; - return n + CommBufferAlign::align(n); -} - -} - -//---------------------------------------------------------------------- - -void CommBuffer::pack_overflow() const -{ - std::ostringstream os ; - os << "stk_classic::CommBuffer::pack(...){ overflow by " ; - os << remaining() ; - os << " bytes. }" ; - throw std::overflow_error( os.str() ); -} - -void CommBuffer::unpack_overflow() const -{ - std::ostringstream os ; - os << "stk_classic::CommBuffer::unpack(...){ overflow by " ; - os << remaining(); - os << " bytes. }" ; - throw std::overflow_error( os.str() ); -} - -void CommAll::rank_error( const char * method , unsigned p ) const -{ - std::ostringstream os ; - os << "stk_classic::CommAll::" << method - << "(" << p << ") ERROR: Not in [0:" << m_size << ")" ; - throw std::range_error( os.str() ); -} - -//---------------------------------------------------------------------- - -CommBuffer::CommBuffer() - : m_beg(NULL), m_ptr(NULL), m_end(NULL) -{ } - -CommBuffer::~CommBuffer() -{ } - -void CommBuffer::deallocate( const unsigned number , CommBuffer * buffers ) -{ - if ( NULL != buffers ) { - for ( unsigned i = 0 ; i < number ; ++i ) { - ( buffers + i )->~CommBuffer(); - } - free( buffers ); - } -} - -CommBuffer * CommBuffer::allocate( - const unsigned number , const unsigned * const size ) -{ - const size_t n_base = align_quad( number * sizeof(CommBuffer) ); - size_t n_size = n_base ; - - if ( NULL != size ) { - for ( unsigned i = 0 ; i < number ; ++i ) { - n_size += align_quad( size[i] ); - } - } - - // Allocate space for buffers - - void * const p_malloc = malloc( n_size ); - - CommBuffer * const b_base = - p_malloc != NULL ? reinterpret_cast(p_malloc) - : reinterpret_cast( NULL ); - - if ( p_malloc != NULL ) { - - for ( unsigned i = 0 ; i < number ; ++i ) { - new( b_base + i ) CommBuffer(); - } - - if ( NULL != size ) { - - ucharp ptr = reinterpret_cast( p_malloc ); - - ptr += n_base ; - - for ( unsigned i = 0 ; i < number ; ++i ) { - CommBuffer & b = b_base[i] ; - b.m_beg = ptr ; - b.m_ptr = ptr ; - b.m_end = ptr + size[i] ; - ptr += align_quad( size[i] ); - } - } - } - - return b_base ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -CommAll::~CommAll() -{ - try { - CommBuffer::deallocate( m_size , m_send ); - if ( 1 < m_size ) { CommBuffer::deallocate( m_size , m_recv ); } - } catch(...){} - m_comm = parallel_machine_null(); - m_size = 0 ; - m_rank = 0 ; - m_send = NULL ; - m_recv = NULL ; -} - -CommAll::CommAll() - : m_comm( parallel_machine_null() ), - m_size( 0 ), m_rank( 0 ), - m_bound( 0 ), - m_max( 0 ), - m_send(NULL), - m_recv(NULL) -{} - -CommAll::CommAll( ParallelMachine comm ) - : m_comm( comm ), - m_size( parallel_machine_size( comm ) ), - m_rank( parallel_machine_rank( comm ) ), - m_bound( 0 ), - m_max( 0 ), - m_send(NULL), - m_recv(NULL) -{ - m_send = CommBuffer::allocate( m_size , NULL ); - - if ( NULL == m_send ) { - std::string msg("stk_classic::CommAll::CommAll FAILED malloc"); - throw std::runtime_error(msg); - } -} - -bool CommAll::allocate_buffers( const unsigned num_msg_bounds , - const bool symmetric , - const bool local_flag ) -{ - const unsigned zero = 0 ; - std::vector tmp( m_size , zero ); - - for ( unsigned i = 0 ; i < m_size ; ++i ) { - tmp[i] = m_send[i].size(); - } - - const unsigned * const send_size = (tmp.empty() ? NULL : & tmp[0]) ; - const unsigned * const recv_size = symmetric ? (tmp.empty() ? NULL : & tmp[0]) : NULL ; - - return allocate_buffers( m_comm, num_msg_bounds, - send_size, recv_size, local_flag ); -} - -//---------------------------------------------------------------------- - -void CommAll::reset_buffers() -{ - if ( m_send ) { - CommBuffer * m = m_send ; - CommBuffer * const me = m + m_size ; - for ( ; m != me ; ++m ) { m->reset(); } - } - if ( m_recv && 1 < m_size ) { - CommBuffer * m = m_recv ; - CommBuffer * const me = m + m_size ; - for ( ; m != me ; ++m ) { m->reset(); } - } -} - -//---------------------------------------------------------------------- - -void CommAll::swap_send_recv() -{ - if ( m_recv == NULL ) { - // ERROR - std::string - msg("stk_classic::CommAll::swap_send_recv(){ NULL recv buffers }" ); - throw std::logic_error( msg ); - } - - CommBuffer * tmp_msg = m_send ; - m_send = m_recv ; - m_recv = tmp_msg ; -} - -//---------------------------------------------------------------------- - -bool CommAll::allocate_buffers( ParallelMachine comm , - const unsigned num_msg_bounds , - const unsigned * const send_size , - const unsigned * const recv_size , - const bool local_flag ) -{ - static const char method[] = "stk_classic::CommAll::allocate_buffers" ; - const unsigned uzero = 0 ; - - CommBuffer::deallocate( m_size , m_send ); - CommBuffer::deallocate( m_size , m_recv ); - - m_comm = comm ; - m_size = parallel_machine_size( comm ); - m_rank = parallel_machine_rank( comm ); - m_bound = num_msg_bounds ; - - std::ostringstream msg ; - - //-------------------------------- - // Buffer allocation - - { - const bool send_none = NULL == send_size ; - - std::vector tmp_send ; - - if ( send_none ) { tmp_send.resize( m_size , uzero ); } - - const unsigned * const send = send_none ? (tmp_send.empty() ? NULL : & tmp_send[0]) : send_size ; - - m_send = CommBuffer::allocate( m_size , send ); - - if ( 1 < m_size ) { - - std::vector tmp_recv ; - - const bool recv_tbd = NULL == recv_size ; - - if ( recv_tbd ) { // Had better be globally consistent. - - tmp_recv.resize( m_size , uzero ); - - unsigned * const r = (tmp_recv.empty() ? NULL : & tmp_recv[0]) ; - - comm_sizes( m_comm , m_bound , m_max , send , r ); - } - - const unsigned * const recv = recv_tbd ? (tmp_recv.empty() ? NULL : & tmp_recv[0]) : recv_size ; - - m_recv = CommBuffer::allocate( m_size , recv ); - } - else { - m_recv = m_send ; - } - } - - bool error_alloc = m_send == NULL || m_recv == NULL ; - - //-------------------------------- - // Propogation of error flag, input flag, and quick/cheap/approximate - // verification of send and receive messages. - // Is the number and total size of messages consistent? - // Sum message counts and sizes for grouped processors. - // Sent are positive and received are negative. - // Should finish with all total counts of zero. - - enum { NPSum = 7 }; - enum { Length = 2 + 2 * NPSum }; - - int local_result[ Length ]; - int global_result[ Length ]; - - Copy( local_result , 0 ); - - local_result[ Length - 2 ] = error_alloc ; - local_result[ Length - 1 ] = local_flag ; - - if ( ! error_alloc ) { - - const unsigned r = 2 * ( m_rank % NPSum ); - - for ( unsigned i = 0 ; i < m_size ; ++i ) { - const unsigned n_send = m_send[i].capacity(); - const unsigned n_recv = m_recv[i].capacity(); - - const unsigned s = 2 * ( i % NPSum ); - - local_result[s] += n_send ? 1 : 0 ; - local_result[s+1] += n_send ; - - local_result[r] -= n_recv ? 1 : 0 ; - local_result[r+1] -= n_recv ; - } - } - - if (m_size > 1) { - all_reduce_sum( m_comm , local_result , global_result , Length ); - } - else { - Copy(global_result, local_result); - } - - bool global_flag ; - - error_alloc = global_result[ Length - 2 ] ; - global_flag = global_result[ Length - 1 ] ; - - bool ok = true ; - - for ( unsigned i = 0 ; ok && i < 2 * NPSum ; ++i ) { - ok = 0 == global_result[i] ; - } - - if ( error_alloc || ! ok ) { - msg << method << " ERROR:" ; - if ( error_alloc ) { msg << " Failed memory allocation ," ; } - if ( ! ok ) { msg << " Parallel inconsistent send/receive ," ; } - throw std::runtime_error( msg.str() ); - } - - return global_flag ; -} - -//---------------------------------------------------------------------- - -void CommAll::communicate() -{ - static const char method[] = "stk_classic::CommAll::communicate" ; - - std::ostringstream msg ; - - // Verify the send buffers have been filled, reset the buffer pointers - - for ( unsigned i = 0 ; i < m_size ; ++i ) { - - if ( m_send[i].remaining() ) { - msg << method << " LOCAL[" << m_rank << "] ERROR: Send[" << i - << "] Buffer not filled." ; - throw std::underflow_error( msg.str() ); - } -/* - m_send[i].reset(); -*/ - m_recv[i].reset(); - } - - if ( 1 < m_size ) { - bool ok ; - - if ( m_bound < m_max ) { - ok = all_to_all_dense( m_comm , m_send , m_recv , msg ); - } - else { - ok = all_to_all_sparse( m_comm , m_send , m_recv , msg ); - } - - if ( ! ok ) { throw std::runtime_error( msg.str() ); } - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -CommBroadcast::CommBroadcast( ParallelMachine comm , unsigned root_rank ) - : m_comm( comm ), - m_size( parallel_machine_size( comm ) ), - m_rank( parallel_machine_rank( comm ) ), - m_root_rank( root_rank ), - m_buffer() -{} - -bool CommBroadcast::allocate_buffer( const bool local_flag ) -{ - static const char method[] = "stk_classic::CommBroadcast::allocate_buffer" ; - - unsigned root_rank_min = m_root_rank ; - unsigned root_rank_max = m_root_rank ; - unsigned root_send_size = m_root_rank == m_rank ? m_buffer.size() : 0 ; - unsigned flag = local_flag ; - - all_reduce( m_comm , ReduceMin<1>( & root_rank_min ) & - ReduceMax<1>( & root_rank_max ) & - ReduceMax<1>( & root_send_size ) & - ReduceBitOr<1>( & flag ) ); - - if ( root_rank_min != root_rank_max ) { - std::string msg ; - msg.append( method ); - msg.append( " FAILED: inconsistent root processor" ); - throw std::runtime_error( msg ); - } - - m_buffer.m_beg = static_cast( malloc( root_send_size ) ); - m_buffer.m_ptr = m_buffer.m_beg ; - m_buffer.m_end = m_buffer.m_beg + root_send_size ; - - return flag ; -} - -CommBroadcast::~CommBroadcast() -{ - try { - if ( m_buffer.m_beg ) { free( static_cast( m_buffer.m_beg ) ); } - } catch(...) {} - m_buffer.m_beg = NULL ; - m_buffer.m_ptr = NULL ; - m_buffer.m_end = NULL ; -} - -CommBuffer & CommBroadcast::recv_buffer() -{ - return m_buffer ; -} - -CommBuffer & CommBroadcast::send_buffer() -{ - static const char method[] = "stk_classic::CommBroadcast::send_buffer" ; - - if ( m_root_rank != m_rank ) { - std::string msg ; - msg.append( method ); - msg.append( " FAILED: is not root processor" ); - throw std::runtime_error( msg ); - } - - return m_buffer ; -} - -void CommBroadcast::communicate() -{ -#if defined( STK_HAS_MPI ) - { - const int count = m_buffer.capacity(); - void * const buf = m_buffer.buffer(); - - const int result = MPI_Bcast( buf, count, MPI_BYTE, m_root_rank, m_comm); - - if ( MPI_SUCCESS != result ) { - std::ostringstream msg ; - msg << "stk_classic::CommBroadcast::communicate ERROR : " - << result << " == MPI_Bcast" ; - throw std::runtime_error( msg.str() ); - } - } -#endif - - m_buffer.reset(); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -CommGather::~CommGather() -{ - try { - free( static_cast( m_send.m_beg ) ); - - if ( NULL != m_recv_count ) { free( static_cast( m_recv_count ) ); } - - if ( NULL != m_recv ) { CommBuffer::deallocate( m_size , m_recv ); } - } catch(...){} -} - -void CommGather::reset() -{ - m_send.reset(); - - if ( NULL != m_recv ) { - for ( unsigned i = 0 ; i < m_size ; ++i ) { m_recv[i].reset(); } - } -} - -CommBuffer & CommGather::recv_buffer( unsigned p ) -{ - static CommBuffer empty ; - - return m_size <= p ? empty : ( - m_size <= 1 ? m_send : m_recv[p] ); -} - -//---------------------------------------------------------------------- - -CommGather::CommGather( ParallelMachine comm , - unsigned root_rank , unsigned send_size ) - : m_comm( comm ), - m_size( parallel_machine_size( comm ) ), - m_rank( parallel_machine_rank( comm ) ), - m_root_rank( root_rank ), - m_send(), - m_recv(NULL), - m_recv_count(NULL), - m_recv_displ(NULL) -{ - m_send.m_beg = static_cast( malloc( send_size ) ); - m_send.m_ptr = m_send.m_beg ; - m_send.m_end = m_send.m_beg + send_size ; - -#if defined( STK_HAS_MPI ) - - if ( 1 < m_size ) { - - const bool is_root = m_rank == m_root_rank ; - - if ( is_root ) { - m_recv_count = static_cast( malloc(2*m_size*sizeof(int)) ); - m_recv_displ = m_recv_count + m_size ; - } - - MPI_Gather( & send_size , 1 , MPI_INT , - m_recv_count , 1 , MPI_INT , - m_root_rank , m_comm ); - - if ( is_root ) { - m_recv = CommBuffer::allocate( m_size , - reinterpret_cast( m_recv_count ) ); - - for ( unsigned i = 0 ; i < m_size ; ++i ) { - m_recv_displ[i] = m_recv[i].m_beg - m_recv[0].m_beg ; - } - } - } - -#endif - -} - - -void CommGather::communicate() -{ -#if defined( STK_HAS_MPI ) - - if ( 1 < m_size ) { - - const int send_count = m_send.capacity(); - - void * const send_buf = m_send.buffer(); - void * const recv_buf = m_rank == m_root_rank ? m_recv->buffer() : NULL ; - - MPI_Gatherv( send_buf , send_count , MPI_BYTE , - recv_buf , m_recv_count , m_recv_displ , MPI_BYTE , - m_root_rank , m_comm ); - } - -#endif - - reset(); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#if defined( STK_HAS_MPI ) - -bool comm_dense_sizes( ParallelMachine comm , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag ) -{ - static const char method[] = "stk_classic::comm_dense_sizes" ; - - const unsigned zero = 0 ; - const unsigned p_size = parallel_machine_size( comm ); - - std::vector send_buf( p_size * 2 , zero ); - std::vector recv_buf( p_size * 2 , zero ); - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - const unsigned i2 = i * 2 ; - send_buf[i2] = send_size[i] ; - send_buf[i2+1] = local_flag ; - } - - { - unsigned * const ps = (send_buf.empty() ? NULL : & send_buf[0]) ; - unsigned * const pr = (recv_buf.empty() ? NULL : & recv_buf[0]) ; - const int result = - MPI_Alltoall( ps , 2 , MPI_UNSIGNED , pr , 2 , MPI_UNSIGNED , comm ); - - if ( MPI_SUCCESS != result ) { - std::string msg ; - msg.append( method ); - msg.append( " FAILED: MPI_SUCCESS != MPI_Alltoall" ); - throw std::runtime_error( msg ); - } - } - - bool global_flag = false ; - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - const unsigned i2 = i * 2 ; - recv_size[i] = recv_buf[i2] ; - if ( recv_buf[i2+1] ) { global_flag = true ; } - } - - return global_flag ; -} - -//---------------------------------------------------------------------- - -namespace { - -extern "C" { - -void sum_np_max_2_op( - void * inv , void * outv , int * len , ParallelDatatype * ) -{ - const int np = *len - 2 ; - unsigned * ind = (unsigned *) inv ; - unsigned * outd = (unsigned *) outv ; - - // Sum all but the last two - // the last two are maximum - - for ( int i = 0 ; i < np ; ++i ) { - *outd += *ind ; - ++outd ; - ++ind ; - } - if ( outd[0] < ind[0] ) { outd[0] = ind[0] ; } - if ( outd[1] < ind[1] ) { outd[1] = ind[1] ; } -} - -} - -} - -bool comm_sizes( ParallelMachine comm , - const unsigned num_msg_bound , - unsigned & num_msg_maximum , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag ) -{ - static const char method[] = "stk_classic::comm_unknown_sizes" ; - const unsigned uzero = 0 ; - - static MPI_Op mpi_op = MPI_OP_NULL ; - - if ( mpi_op == MPI_OP_NULL ) { - // Is fully commutative - MPI_Op_create( sum_np_max_2_op , 1 , & mpi_op ); - } - - const unsigned p_size = parallel_machine_size( comm ); - const unsigned p_rank = parallel_machine_rank( comm ); - - int result ; - - std::ostringstream msg ; - - num_msg_maximum = 0 ; - - unsigned num_recv = 0 ; - unsigned max_msg = 0 ; - bool global_flag = false ; - - { - std::vector send_buf( p_size + 2 , uzero ); - std::vector recv_buf( p_size + 2 , uzero ); - - unsigned * const p_send = (send_buf.empty() ? NULL : & send_buf[0]) ; - unsigned * const p_recv = (recv_buf.empty() ? NULL : & recv_buf[0]) ; - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - recv_size[i] = 0 ; // Zero output - if ( send_size[i] ) { - send_buf[i] = 1 ; - ++max_msg ; - } - } - send_buf[p_size] = max_msg ; - send_buf[p_size+1] = local_flag ; - - result = MPI_Allreduce(p_send,p_recv,p_size+2,MPI_UNSIGNED,mpi_op,comm); - - if ( result != MPI_SUCCESS ) { - // PARALLEL ERROR - msg << method << " ERROR: " << result << " == MPI_AllReduce" ; - throw std::runtime_error( msg.str() ); - } - - num_recv = recv_buf[ p_rank ] ; - max_msg = recv_buf[ p_size ] ; - global_flag = recv_buf[ p_size + 1 ] ; - - // max_msg is now the maximum send count, - // Loop over receive counts to determine - // if a receive count is larger. - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - if ( max_msg < recv_buf[i] ) { max_msg = recv_buf[i] ; } - } - } - - num_msg_maximum = max_msg ; - - if ( num_msg_bound < max_msg ) { - // Dense, pay for an all-to-all - - result = - MPI_Alltoall( (void*) send_size , 1 , MPI_UNSIGNED , - recv_size , 1 , MPI_UNSIGNED , comm ); - - if ( MPI_SUCCESS != result ) { - // LOCAL ERROR ? - msg << method << " ERROR: " << result << " == MPI_Alltoall" ; - throw std::runtime_error( msg.str() ); - } - } - else if ( max_msg ) { - // Sparse, just do point-to-point - - const int mpi_tag = STK_MPI_TAG_SIZING ; - - MPI_Request request_null = MPI_REQUEST_NULL ; - std::vector request( num_recv , request_null ); - std::vector status( num_recv ); - std::vector buf( num_recv ); - - // Post receives for point-to-point message sizes - - for ( unsigned i = 0 ; i < num_recv ; ++i ) { - unsigned * const p_buf = & buf[i] ; - MPI_Request * const p_request = & request[i] ; - result = MPI_Irecv( p_buf , 1 , MPI_UNSIGNED , - MPI_ANY_SOURCE , mpi_tag , comm , p_request ); - if ( MPI_SUCCESS != result ) { - // LOCAL ERROR - msg << method << " ERROR: " << result << " == MPI_Irecv" ; - throw std::runtime_error( msg.str() ); - } - } - - // Send the point-to-point message sizes, - // rotate the sends in an attempt to balance the message traffic. - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - int dst = ( i + p_rank ) % p_size ; - unsigned value = send_size[dst] ; - if ( value ) { - result = MPI_Send( & value , 1 , MPI_UNSIGNED , dst , mpi_tag , comm ); - if ( MPI_SUCCESS != result ) { - // LOCAL ERROR - msg << method << " ERROR: " << result << " == MPI_Send" ; - throw std::runtime_error( msg.str() ); - } - } - } - - // Wait for all receives - - { - MPI_Request * const p_request = (request.empty() ? NULL : & request[0]) ; - MPI_Status * const p_status = (status.empty() ? NULL : & status[0]) ; - result = MPI_Waitall( num_recv , p_request , p_status ); - } - if ( MPI_SUCCESS != result ) { - // LOCAL ERROR ? - msg << method << " ERROR: " << result << " == MPI_Waitall" ; - throw std::runtime_error( msg.str() ); - } - - // Set the receive message sizes - - for ( unsigned i = 0 ; i < num_recv ; ++i ) { - MPI_Status * const recv_status = & status[i] ; - const int recv_proc = recv_status->MPI_SOURCE ; - const int recv_tag = recv_status->MPI_TAG ; - int recv_count = 0 ; - - MPI_Get_count( recv_status , MPI_UNSIGNED , & recv_count ); - - if ( recv_tag != mpi_tag || recv_count != 1 ) { - msg << method << " ERROR: Received buffer mismatch " ; - msg << "P" << p_rank << " <- P" << recv_proc ; - msg << " " << 1 << " != " << recv_count ; - throw std::runtime_error( msg.str() ); - } - - const unsigned r_size = buf[i] ; - recv_size[ recv_proc ] = r_size ; - } - } - - return global_flag ; -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#else - - -bool comm_sizes( ParallelMachine , - const unsigned , - unsigned & num_msg_maximum , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag ) -{ - num_msg_maximum = send_size[0] ? 1 : 0 ; - - recv_size[0] = send_size[0] ; - - return local_flag ; -} - -bool comm_dense_sizes( ParallelMachine , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag ) -{ - recv_size[0] = send_size[0] ; - - return local_flag ; -} - -//---------------------------------------------------------------------- - -#endif - -} - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.hpp deleted file mode 100644 index 753c02a053c8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelComm.hpp +++ /dev/null @@ -1,465 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_ParallelComm_hpp -#define stk_util_parallel_ParallelComm_hpp - -#include -#include -#include - -//------------------------------------------------------------------------ - -namespace stk_classic { - -/** Perform collective all-to-all communication with individually - * varying message sizes. The collective operation uses an - * all-to-all if the maximum number of sends or receives from - * any one processor is greater than the given bounds. - * - * This is a work-horse communication for mesh data structures - * with parallel domain decomposition. - */ -class CommAll ; - -/** Pack and unpack buffers for the sparse all-to-all communication. - */ -class CommBuffer ; - -/** Given the send sizes determine the receive sizes. - * Send and receive size arrays are dimensioned to - * the size of the parallel machine. - * Return global parallel logical OR of the input local flag. - * This parallel reduction is aggregated into the required - * communication for determining the sparse sizes. - * Output the receive sizes and maximum number of send or - * receive messages for a single processor. - * A dense all-to-all communication is used if: - * num_msg_bound < num_msg_maximum - * otherwise a set of point-to-point messages are used. - */ -bool comm_sizes( ParallelMachine , - const unsigned num_msg_bound , - unsigned & num_msg_maximum , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag = false ); - -/** If the communication is known to be dense. - */ -bool comm_dense_sizes( ParallelMachine , - const unsigned * const send_size , - unsigned * const recv_size , - bool local_flag = false ); - -//------------------------------------------------------------------------ - -class CommBuffer { -public: - - /** Pack a value to be sent: buf.pack( value ) */ - template CommBuffer &pack( const T & value ); - - /** Pack an array of values to be sent: buf.pack( ptr , num ) */ - template CommBuffer &pack( const T * value , size_t number ); - - /** Unpack a received value: buf.unpack( value ) */ - template CommBuffer &unpack( T & value ); - - /** Unpack an array of received values: buf.unpack( ptr , num ) */ - template CommBuffer &unpack( T * value , size_t number ); - - /** Peek at a received value (don't advance buffer): buf.peek(value) */ - template CommBuffer &peek( T & value ); - - /** Peek at an array of received values: buf.peek( ptr , num ) */ - template CommBuffer &peek( T * value , size_t number ); - - /** Skip buffer ahead by a number of values. */ - template CommBuffer &skip( size_t number ); - - /** Reset the buffer to the beginning so that size() == 0 */ - void reset(); - - /** Size, in bytes, of the buffer. - * If the buffer is not yet allocated this is zero. - */ - size_t capacity() const ; - - /** Size, in bytes, of the buffer that has been processed. - * If the buffer is not yet allocated then this is the - * number of bytes that has been attempted to pack. - */ - size_t size() const ; - - /** Size, in bytes, of the buffer remaining to be processed. - * Equal to 'capacity() - size()'. A negative result - * indicates either the buffer is not allocated or an - * overflow has occured. An overflow will have thrown - * an exception. - */ - ptrdiff_t remaining() const ; - - /** Pointer to base of buffer. */ - void * buffer() const ; - - ~CommBuffer(); - CommBuffer(); - -private: - friend class CommAll ; - friend class CommGather ; - friend class CommBroadcast ; - - static CommBuffer * allocate( const unsigned, const unsigned * const ); - static void deallocate( const unsigned , CommBuffer * ); - - void pack_overflow() const ; - void unpack_overflow() const ; - - CommBuffer( const CommBuffer & ); - CommBuffer & operator = ( const CommBuffer & ); - - typedef unsigned char * ucharp ; - - ucharp m_beg ; - ucharp m_ptr ; - ucharp m_end ; -}; - -//------------------------------------------------------------------------ - -class CommAll { -public: - - ParallelMachine parallel() const { return m_comm ; } - unsigned parallel_size() const { return m_size ; } - unsigned parallel_rank() const { return m_rank ; } - - /** Obtain the message buffer for a given processor */ - CommBuffer & send_buffer( unsigned ) const ; - - /** Obtain the message buffer for a given processor */ - CommBuffer & recv_buffer( unsigned ) const ; - - //---------------------------------------- - /** Construct for undefined communication. - * No buffers are allocated. - */ - CommAll(); - - /** Allocate send and receive buffers based upon input sizes. - * If recv_size == NULL then the receive size - * is determined by communicating the send sizes. - * Symmetry is given by passing the same data for both - * send and receive sizes. - * Return global parallel OR of local flags. - */ - bool allocate_buffers( ParallelMachine , - const unsigned num_msg_bounds , - const unsigned * const send_size , - const unsigned * const recv_size , - const bool local_flag = false ); - - //---------------------------------------- - /** Construct for a to-be-sized communication. - * Allocate surrogate send buffers to enable - * no-op packing for the purpose of send sizing. - * Surrogate send scenario: - * 1) Surrogate send buffers are "packed" for sizing where - * packing sizes are recorded but no data is copied. - * 2) 'allocate_buffers(symmetric,flag)' is called to allocate - * buffers. The symmetric flag guarantees that the send - * sizes matches the receive sizes. - * 3) Send buffers are identically packed; however, this - * packing copies data into the send buffers. - */ - explicit CommAll( ParallelMachine ); - - /** Allocate asymmetric communication based upon - * sizing from the surrogate send buffer packing. - * If symmetric then the receive sizes are guaranteed - * to be identical to the send sizes. - * Return global parallel OR of local flags. - */ - bool allocate_buffers( const unsigned num_msg_bounds , - const bool symmetric = false , - const bool local_flag = false ); - - //---------------------------------------- - /** Communicate send buffers to receive buffers. */ - void communicate(); - - //---------------------------------------- - /** Swap send and receive buffers leading to reversed communication. */ - void swap_send_recv(); - - /** Reset, but do not reallocate, message buffers for reprocessing. - * Sets 'size() == 0' and 'remaining() == capacity()'. - */ - void reset_buffers(); - - ~CommAll(); - -private: - - CommAll( const CommAll & ); - CommAll & operator = ( const CommAll & ); - - void rank_error( const char * , unsigned ) const ; - - bool allocate_buffers( const unsigned * const send_size , - const unsigned * const recv_size , - bool local_flag ); - - ParallelMachine m_comm ; - unsigned m_size ; - unsigned m_rank ; - unsigned m_bound ; - unsigned m_max ; - CommBuffer * m_send ; - CommBuffer * m_recv ; -}; - -//------------------------------------------------------------------------ - -class CommBroadcast { -public: - - ParallelMachine parallel() const { return m_comm ; } - unsigned parallel_size() const { return m_size ; } - unsigned parallel_rank() const { return m_rank ; } - - /** Obtain the message buffer for the root_rank processor */ - CommBuffer & send_buffer(); - - /** Obtain the message buffer for the local processor */ - CommBuffer & recv_buffer(); - - //---------------------------------------- - - CommBroadcast( ParallelMachine , unsigned root_rank ); - - void communicate(); - - bool allocate_buffer( const bool local_flag = false ); - - ~CommBroadcast(); - -private: - - CommBroadcast(); - CommBroadcast( const CommBroadcast & ); - CommBroadcast & operator = ( const CommBroadcast & ); - - ParallelMachine m_comm ; - unsigned m_size ; - unsigned m_rank ; - unsigned m_root_rank ; - CommBuffer m_buffer ; -}; - -//---------------------------------------------------------------------- - -class CommGather { -public: - - ParallelMachine parallel() const { return m_comm ; } - unsigned parallel_size() const { return m_size ; } - unsigned parallel_rank() const { return m_rank ; } - - ~CommGather(); - - CommGather( ParallelMachine , unsigned root_rank , unsigned send_size ); - - CommBuffer & send_buffer() { return m_send ; } - - void communicate(); - - CommBuffer & recv_buffer( unsigned ); - - void reset(); - -private: - - CommGather(); - CommGather( const CommBroadcast & ); - CommGather & operator = ( const CommBroadcast & ); - - ParallelMachine m_comm ; - unsigned m_size ; - unsigned m_rank ; - unsigned m_root_rank ; - CommBuffer m_send ; - CommBuffer * m_recv ; - int * m_recv_count ; - int * m_recv_displ ; -}; - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Inlined template implementations for the CommBuffer - -namespace stk_classic { - -template struct CommBufferAlign ; - -template<> -struct CommBufferAlign<1> { - static size_t align( size_t ) { return 0 ; } -}; - -template -struct CommBufferAlign { - static size_t align( size_t i ) { i %= N ; return i ? ( N - i ) : 0 ; } -}; - -template -inline -CommBuffer &CommBuffer::pack( const T & value ) -{ - enum { Size = sizeof(T) }; - size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - if ( m_beg ) { - if ( m_end < m_ptr + nalign + Size ) { pack_overflow(); } - while ( nalign ) { --nalign ; *m_ptr = 0 ; ++m_ptr ; } - T * tmp = reinterpret_cast(m_ptr); - *tmp = value ; - m_ptr = reinterpret_cast( ++tmp ); - } - else { - m_ptr += nalign + Size ; - } - return *this; -} - -template -inline -CommBuffer &CommBuffer::pack( const T * value , size_t number ) -{ - enum { Size = sizeof(T) }; - size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - if ( m_beg ) { - if ( m_end < m_ptr + nalign + number * Size ) { pack_overflow(); } - while ( nalign ) { --nalign ; *m_ptr = 0 ; ++m_ptr ; } - T * tmp = reinterpret_cast(m_ptr); - while ( number ) { --number ; *tmp = *value ; ++tmp ; ++value ; } - m_ptr = reinterpret_cast( tmp ); - } - else { - m_ptr += nalign + number * Size ; - } - return *this; -} - -template -inline -CommBuffer &CommBuffer::skip( size_t number ) -{ - enum { Size = sizeof(T) }; - m_ptr += CommBufferAlign::align( m_ptr - m_beg ) + Size * number ; - if ( m_beg && m_end < m_ptr ) { unpack_overflow(); } - return *this; -} - -template -inline -CommBuffer &CommBuffer::unpack( T & value ) -{ - enum { Size = sizeof(T) }; - const size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - T * tmp = reinterpret_cast( m_ptr + nalign ); - value = *tmp ; - m_ptr = reinterpret_cast( ++tmp ); - if ( m_end < m_ptr ) { unpack_overflow(); } - return *this; -} - -template -inline -CommBuffer &CommBuffer::unpack( T * value , size_t number ) -{ - enum { Size = sizeof(T) }; - const size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - T * tmp = reinterpret_cast( m_ptr + nalign ); - while ( number ) { --number ; *value = *tmp ; ++tmp ; ++value ; } - m_ptr = reinterpret_cast( tmp ); - if ( m_end < m_ptr ) { unpack_overflow(); } - return *this; -} - -template -inline -CommBuffer &CommBuffer::peek( T & value ) -{ - enum { Size = sizeof(T) }; - const size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - T * tmp = reinterpret_cast( m_ptr + nalign ); - value = *tmp ; - if ( m_end < reinterpret_cast(++tmp) ) { unpack_overflow(); } - return *this; -} - -template -inline -CommBuffer &CommBuffer::peek( T * value , size_t number ) -{ - enum { Size = sizeof(T) }; - const size_t nalign = CommBufferAlign::align( m_ptr - m_beg ); - T * tmp = reinterpret_cast( m_ptr + nalign ); - while ( number ) { --number ; *value = *tmp ; ++tmp ; ++value ; } - if ( m_end < reinterpret_cast(tmp) ) { unpack_overflow(); } - return *this; -} - -inline -void CommBuffer::reset() -{ m_ptr = m_beg ; } - -inline -size_t CommBuffer::capacity() const -{ return m_end - m_beg ; } - -inline -size_t CommBuffer::size() const -{ return m_ptr - m_beg ; } - -inline -ptrdiff_t CommBuffer::remaining() const -{ return m_end - m_ptr ; } - -inline -void * CommBuffer::buffer() const -{ return static_cast( m_beg ); } - -//---------------------------------------------------------------------- -// Inline implementations for the CommAll - -inline -CommBuffer & CommAll::send_buffer( unsigned p ) const -{ - if ( m_size <= p ) { rank_error("send_buffer",p); } - return m_send[p] ; -} - -inline -CommBuffer & CommAll::recv_buffer( unsigned p ) const -{ - if ( m_size <= p ) { rank_error("recv_buffer",p); } - return m_recv[p] ; -} - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.cpp deleted file mode 100644 index 93387b0f94e7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -//add a dummy symbol to keep certain linkers from warning about -//this file having no symbols. -int dummy_parallelindex_symbol(){return 0;} - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.hpp deleted file mode 100644 index d76e92d7b552..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelIndex.hpp +++ /dev/null @@ -1,305 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_ParallelIndex_hpp -#define stk_util_parallel_ParallelIndex_hpp - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace util { - -template -struct ParallelIndexDecomp -{ - typedef K Key ; - typedef P Proc ; - - Proc operator()( const Proc proc_size, const Key key ) const { - return ( key >> 8 ) % proc_size ; - }; -}; - - -/** \brief Parallel cross-reference index for a collection of - * 'Key' keys. - * - * Each processor constructs a ParallelIndex with its - * local collection of keys. - * The resulting ParallelIndex may be queried for - * - which other processors input the same local keys or - * - which processors submitted an arbitrary set of keys. - */ -template > -class ParallelIndex { -public: - typedef K Key ; - typedef P Proc ; - typedef D Decomp ; - typedef std::pair KeyProc ; - -#ifndef DOXYGEN_COMPILE - struct LessKeyProc { - bool operator()( const KeyProc & lhs, const KeyProc & rhs ) const { - return lhs < rhs ; - } - - bool operator()( const KeyProc & lhs, const Key rhs ) const { - return lhs.first < rhs ; - } - }; - - struct EqualKeyProc { - bool operator()( const KeyProc & lhs, const KeyProc & rhs ) const { - return lhs == rhs ; - } - }; -#endif /* DOXYGEN_COMPILE */ - - - /** \brief Construct with locally-submitted keys */ - ParallelIndex( ParallelMachine comm, - const std::vector & local ) - : m_comm( comm ), - m_key_proc(), - m_decomp() - { - const unsigned p_size = parallel_machine_size( comm ); - - CommAll all( comm ); - - pack_map( all, local ); - - all.allocate_buffers( p_size / 4, false ); - - pack_map( all, local ); - - all.communicate(); - - unpack_map( all, m_key_proc ); - - sort_unique( m_key_proc ); - } - - ~ParallelIndex() - {} - - - /** \brief Query which other processors submitted the - * same keys that the local processor submitted. - */ - void query(std::vector & global ) const - { - const unsigned p_size = parallel_machine_size( m_comm ); - - CommAll all( m_comm ); - - pack_query( all, m_key_proc ); - - all.allocate_buffers( p_size / 4, false ); - - pack_query( all, m_key_proc ); - - all.communicate(); - - unpack_query( all, global ); - - sort_unique( global ); - } - - - /** \brief Query which processors submitted the given keys. - * The local processor is in the output if it - * submitted a queried key. - */ - void query(const std::vector & local, - std::vector & global ) const - { - const unsigned p_size = parallel_machine_size( m_comm ); - - std::vector tmp ; - - { - CommAll all( m_comm ); - - pack_map( all, local ); - - all.allocate_buffers( p_size / 4, false ); - - pack_map( all, local ); - - all.communicate(); - - unpack_map( all, tmp ); // { ( key, querying_processor ) } - - sort_unique( tmp ); - } - - { - CommAll all( m_comm ); - - pack_query( all, m_key_proc, tmp ); - - all.allocate_buffers( p_size / 4, false ); - - pack_query( all, m_key_proc, tmp ); - - all.communicate(); - - unpack_query( all, global ); - - sort_unique( global ); - } - } - -private: - void sort_unique( std::vector & key_proc ) const - { - typename std::vector::iterator i = key_proc.begin(); - typename std::vector::iterator j = key_proc.end(); - - std::sort( i, j, LessKeyProc() ); - i = std::unique( i, j, EqualKeyProc() ); - key_proc.erase( i, j ); - } - - void pack_map( CommAll & all, const std::vector & local ) const - { - const unsigned p_size = all.parallel_size(); - - typename std::vector::const_iterator i ; - - for ( i = local.begin() ; i != local.end() ; ++i ) { - const Key value = *i ; - const unsigned proc = m_decomp( p_size, value ); - CommBuffer & buf = all.send_buffer(proc); - buf.pack( value ); - } - } - - void unpack_map( CommAll & all, std::vector< KeyProc > & key_proc ) const - { - const unsigned p_size = all.parallel_size(); - - unsigned count = 0 ; - for ( unsigned p = 0 ; p < p_size ; ++p ) { - count += all.recv_buffer( p ).capacity() / sizeof(Key); - } - - key_proc.clear(); - key_proc.reserve( count ); - - KeyProc value ; - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - value.second = p ; - while ( buf.remaining() ) { - buf.unpack( value.first ); - key_proc.push_back( value ); - } - } - } - - void pack_query( CommAll & all, const std::vector< KeyProc > & key_proc ) const - { - KeyProc value ; - - typename std::vector< KeyProc >::const_iterator i ; - - for ( i = key_proc.begin() ; i != key_proc.end() ; ) { - value.first = i->first ; - - const typename std::vector< KeyProc >::const_iterator i_beg = i ; - - for ( ; i != key_proc.end() && value.first == i->first ; ++i ) - ; - - const typename std::vector< KeyProc >::const_iterator i_end = i ; - - for ( i = i_beg ; i != i_end ; ++i ) { - CommBuffer & buf = all.send_buffer( i->second ); - - typename std::vector< KeyProc >::const_iterator j ; - - for ( j = i_beg ; j != i_end ; ++j ) { - if ( j != i ) { - value.second = j->second ; - buf.pack( value ); - } - } - } - } - } - - void pack_query( CommAll & all, - const std::vector< KeyProc > & key_proc_map, - const std::vector< KeyProc > & query ) const - { - KeyProc value ; - - for (typename std::vector< KeyProc >::const_iterator i = query.begin() ; i != query.end() ; ) { - value.first = i->first ; - - typename std::vector< KeyProc >::const_iterator key_begin = std::lower_bound( key_proc_map.begin(), key_proc_map.end(), value.first, LessKeyProc() ); - - typename std::vector< KeyProc >::const_iterator key_end = key_begin; - while ( key_end != key_proc_map.end() && key_end->first == value.first) - ++key_end; - - for ( ; i != query.end() && value.first == i->first ; ++i ) { - CommBuffer & buf = all.send_buffer( i->second ); - - for ( typename std::vector< KeyProc >::const_iterator j = key_begin ; j != key_end ; ++j ) { - value.second = j->second ; - buf.pack( value ); - } - } - } - } - - void unpack_query( CommAll & all, std::vector< KeyProc > & key_proc ) const - { - const unsigned p_size = all.parallel_size(); - - KeyProc entry ; - - for ( unsigned p = 0 ; p < p_size ; ++p ) { - CommBuffer & buf = all.recv_buffer( p ); - while ( buf.remaining() ) { - buf.unpack( entry ); - key_proc.push_back( entry ); - } - } - } - -private: - ParallelIndex(); - ParallelIndex( const ParallelIndex & ); - ParallelIndex & operator = ( const ParallelIndex & ); - -private: - ParallelMachine m_comm ; - std::vector m_key_proc ; - Decomp m_decomp; -}; - -} // namespace util -} // namespace stk_classic - -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.cpp deleted file mode 100644 index 99415b891453..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -/*--------------------------------------------------------------------*/ - -namespace stk_classic { -namespace { - -#if defined( STK_HAS_MPI ) - -void broadcast( ParallelMachine comm , void * buf , int n ) -{ MPI_Bcast( buf , n , MPI_BYTE , 0 , comm ); } - -#else - -void broadcast( ParallelMachine , void * , int ) {} - -#endif - -} -} - -/*--------------------------------------------------------------------*/ - -namespace stk_classic { -namespace { - -//---------------------------------------------------------------------- - -class ParInBuf : public std::streambuf { -public: - enum { BUFFER_LENGTH = 0x010000 /* 64k bytes */ }; - enum { BUFFER_PUTBACK = 0x000010 /* 16 bytes */ }; - enum { MAX_READ = BUFFER_LENGTH - BUFFER_PUTBACK }; - ParInBuf( ParallelMachine , const char * const ); - virtual ~ParInBuf(); - -protected: - virtual int underflow(); // refill the input buffer - virtual int overflow( int c = EOF ); // Not called - virtual int sync(); // No-op - virtual std::streambuf * setbuf( char * , std::streamsize ); // No-op - -private: - void close(); - - ParallelMachine m_comm ; - /// \todo REFACTOR: Investigate using C++ IO - std::FILE * m_root_fp ; - char m_buffer[ BUFFER_LENGTH ]; -}; - -ParInBuf::ParInBuf( ParallelMachine comm , const char * const file_name ) - : m_comm( comm ), m_root_fp( NULL ) -{ - int result = 1 ; - - if ( 0 == parallel_machine_rank( comm ) && NULL != file_name ) { - result = NULL != ( m_root_fp = std::fopen( file_name , "r" ) ); - } - - broadcast( m_comm , & result , sizeof(int) ); - - if ( ! result ) { - std::string msg; - msg.append("stk_classic::ParallelInputStream( " ); - if ( 0 == parallel_machine_rank( comm ) && NULL != file_name ) { - msg.append( file_name ); - } - else { - msg.append( "" ); - } - msg.append( " ) FAILED" ); - throw std::runtime_error(msg); - } -} - -void ParInBuf::close() -{ - if ( NULL != m_root_fp ) { std::fclose( m_root_fp ); m_root_fp = NULL ; } - setg(NULL,NULL,NULL); -} - -ParInBuf::~ParInBuf() -{ close(); } - -int ParInBuf::underflow() -{ - char * const buf = m_buffer + BUFFER_PUTBACK ; - int nread = 0 ; - - if ( gptr() == NULL || egptr() <= gptr() ) { - if ( NULL != m_root_fp ) { nread = std::fread(buf,1,MAX_READ,m_root_fp); } - broadcast( m_comm , & nread , sizeof(int) ); - } - - if ( 0 < nread ) { - broadcast( m_comm , buf , nread ); - setg( m_buffer , buf , buf + nread ); - } - else { - close(); - } - - return 0 < nread ? *buf : EOF ; -} - -namespace { - -void throw_overflow() -{ - std::string msg ; - msg.append("stk_classic::ParallelInputStream::overflow CALL IS ERRONEOUS" ); - throw std::runtime_error(msg); -} - -} - -int ParInBuf::overflow( int ) -{ throw_overflow(); return EOF ; } - -int ParInBuf::sync() -{ return 0 ; } - -std::streambuf * ParInBuf::setbuf( char * , std::streamsize ) -{ - return this ; -} - -//---------------------------------------------------------------------- - -} // namespace - - -ParallelInputStream::ParallelInputStream( - ParallelMachine comm , - const char * const file_name ) - : std::istream( new ParInBuf( comm , file_name ) ) -{} - -ParallelInputStream::~ParallelInputStream() -{ delete rdbuf(); } - -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.hpp deleted file mode 100644 index 4e9d3d323128..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelInputStream.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_ParallelInputStream_hpp -#define stk_util_parallel_ParallelInputStream_hpp - -#include -#include - -namespace stk_classic { - -class ParallelInputStream : public std::istream { -public: - ParallelInputStream( ParallelMachine comm , const char * const file_name ); - virtual ~ParallelInputStream(); -}; - -} - -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.cpp deleted file mode 100644 index 65bac141a77c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include - -namespace stk_classic { - -#if defined( STK_HAS_MPI ) - -/// @todo REFACTOR The per-processor separator needs to be addressed. Already created a duplicate -/// for deferred error messages which could be replacement. - -void all_write_string( ParallelMachine arg_comm , - std::ostream & arg_root_os , - const std::string & arg_msg ) -{ - const int i_zero = 0 ; - const int p_root = 0 ; - const unsigned p_size = parallel_machine_size( arg_comm ); - const unsigned p_rank = parallel_machine_rank( arg_comm ); - - int result ; - - // Gather the send counts on root processor - - int send_count = arg_msg.size(); - - std::vector recv_count( p_size , i_zero ); - - int * const recv_count_ptr = & recv_count[0] ; - - result = MPI_Gather( & send_count , 1 , MPI_INT , - recv_count_ptr , 1 , MPI_INT , - p_root , arg_comm ); - - if ( MPI_SUCCESS != result ) { - std::ostringstream msg ; - msg << "stk_classic::all_write FAILED: MPI_Gather = " << result ; - throw std::runtime_error( msg.str() ); - } - - // Receive counts are only non-zero on the root processor: - - std::vector recv_displ( p_size + 1 , i_zero ); - - for ( unsigned i = 0 ; i < p_size ; ++i ) { - recv_displ[i+1] = recv_displ[i] + recv_count[i] ; - } - - const unsigned recv_size = (unsigned) recv_displ[ p_size ] ; - - std::vector buffer( recv_size ); - - { - const char * const send_ptr = arg_msg.c_str(); - char * const recv_ptr = recv_size ? & buffer[0] : (char *) NULL ; - int * const recv_displ_ptr = & recv_displ[0] ; - - result = MPI_Gatherv( (void*) send_ptr, send_count, MPI_CHAR , - recv_ptr, recv_count_ptr, recv_displ_ptr, MPI_CHAR, - p_root, arg_comm ); - } - - if ( MPI_SUCCESS != result ) { - std::ostringstream msg ; - msg << "stk_classic::all_write FAILED: MPI_Gatherv = " << result ; - throw std::runtime_error( msg.str() ); - } - - if ( p_root == (int) p_rank ) { -// arg_root_os << std::endl ; - for ( unsigned i = 0 ; i < p_size ; ++i ) { - if ( recv_count[i] ) { - char * const ptr = & buffer[ recv_displ[i] ]; - arg_root_os.write( ptr , recv_count[i] ); - arg_root_os << std::endl ; - } - } - arg_root_os.flush(); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void all_reduce( ParallelMachine arg_comm , - ParallelReduceOp arg_op , - void * arg_in , - void * arg_out , - unsigned arg_len ) -{ - MPI_Op mpi_op = MPI_OP_NULL ; - - MPI_Op_create( arg_op , 0 , & mpi_op ); - - // The SUN was buggy when combining an - // MPI_Allreduce with a user defined operator, - // use reduce/broadcast instead. -/* - const int result = - MPI_Allreduce(arg_in,arg_out,arg_len,MPI_BYTE,mpi_op,arg_comm); -*/ - - const int result_reduce = - MPI_Reduce(arg_in,arg_out,arg_len,MPI_BYTE,mpi_op,0,arg_comm); - - const int result_bcast = - MPI_Bcast(arg_out,arg_len,MPI_BYTE,0,arg_comm); - - MPI_Op_free( & mpi_op ); - - if ( MPI_SUCCESS != result_reduce || MPI_SUCCESS != result_bcast ) { - std::ostringstream msg ; - msg << "stk_classic::all_reduce FAILED: MPI_Reduce = " << result_reduce - << " MPI_Bcast = " << result_bcast ; - throw std::runtime_error( msg.str() ); - } -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -void all_reduce_sum( ParallelMachine comm , - const double * local , double * global , unsigned count ) -{ - double * tmp = const_cast( local ); - MPI_Allreduce( tmp , global , count , MPI_DOUBLE , MPI_SUM , comm ); -} - -void all_reduce_sum( ParallelMachine comm , - const float * local , float * global , unsigned count ) -{ - float * tmp = const_cast( local ); - MPI_Allreduce( tmp , global , count , MPI_FLOAT , MPI_SUM , comm ); -} - -void all_reduce_sum( ParallelMachine comm , - const int * local , int * global , unsigned count ) -{ - int * tmp = const_cast( local ); - MPI_Allreduce( tmp , global , count , MPI_INT , MPI_SUM , comm ); -} - -void all_reduce_sum( ParallelMachine comm , - const size_t * local , size_t * global , unsigned count ) -{ - size_t * tmp = const_cast( local ); - - if ( sizeof(size_t) == sizeof(unsigned) ) { - MPI_Allreduce( tmp , global , count , MPI_UNSIGNED , MPI_SUM , comm ); - } - else if ( sizeof(size_t) == sizeof(unsigned long) ) { - MPI_Allreduce( tmp , global , count , MPI_UNSIGNED_LONG , MPI_SUM , comm ); - } - else { - unsigned long * const in = new unsigned long[ count ]; - unsigned long * const out = new unsigned long[ count ]; - - for ( unsigned i = 0 ; i < count ; ++i ) { in[i] = local[i] ; } - MPI_Allreduce( in , out , count , MPI_UNSIGNED_LONG , MPI_SUM , comm ); - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = out[i] ; } - - delete[] in ; - delete[] out ; - } -} - -void all_reduce_bor( ParallelMachine comm , - const unsigned * local , - unsigned * global , unsigned count ) -{ - unsigned * tmp = const_cast( local ); - MPI_Allreduce( tmp , global , count , MPI_UNSIGNED , MPI_BOR , comm ); -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#else - -void all_write_string( ParallelMachine , - std::ostream & arg_root_os , - const std::string & arg_msg ) -{ - arg_root_os << arg_msg ; -} - -void all_reduce_sum( ParallelMachine , - const double * local , double * global , unsigned count ) -{ - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = local[i] ; } -} - -void all_reduce_sum( ParallelMachine , - const float * local , float * global , unsigned count ) -{ - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = local[i] ; } -} - -void all_reduce_sum( ParallelMachine , - const int * local , int * global , unsigned count ) -{ - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = local[i] ; } -} - -void all_reduce_sum( ParallelMachine , - const size_t * local , size_t * global , unsigned count ) -{ - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = local[i] ; } -} - -void all_reduce_bor( ParallelMachine , - const unsigned * local , - unsigned * global , unsigned count ) -{ - for ( unsigned i = 0 ; i < count ; ++i ) { global[i] = local[i] ; } -} - -//---------------------------------------------------------------------- - -void all_reduce( ParallelMachine , - ParallelReduceOp , - void * arg_in , - void * arg_out , - unsigned arg_len ) -{ - unsigned char * i = reinterpret_cast( arg_in ); - unsigned char * o = reinterpret_cast( arg_out ); - for ( unsigned char * const e = i + arg_len ; e != i ; ++i , ++o ) { - *o = *i ; - } -} - -#endif - -} - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.hpp deleted file mode 100644 index a30a8e2fab80..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/ParallelReduce.hpp +++ /dev/null @@ -1,232 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_parallel_ParallelReduce_hpp -#define stk_util_parallel_ParallelReduce_hpp - -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------ - -namespace stk_classic { - -/** \addtogroup parallel_module - * \{ - */ - -// REFACTOR: Replace ReduceSum with Sum?, etc... Should be possible - -/** \brief Write string from any or all processors - * to the ostream on the root processor. - */ -void all_write_string( ParallelMachine , - std::ostream & , - const std::string & ); - -/** \brief Parallel summation to all processors */ -void all_reduce_sum( ParallelMachine , - const double * local , double * global , unsigned count ); - -/** \brief Parallel summation to all processors */ -void all_reduce_sum( ParallelMachine , - const float * local , float * global , unsigned count ); - -/** \brief Parallel summation to all processors */ -void all_reduce_sum( ParallelMachine , - const int * local , int * global , unsigned count ); - -/** \brief Parallel summation to all processors */ -void all_reduce_sum( ParallelMachine , - const size_t * local , size_t * global , unsigned count ); - -/** \brief Parallel bitwise-or to all processors */ -void all_reduce_bor( ParallelMachine , - const unsigned * local , - unsigned * global , unsigned count ); - -/** Aggregated parallel in-place reduce-to-all-processors operations. - * - * example: - *
- *    ParallelMachine comm = ... ;
- *    double a[5] ;
- *    int    b[3] ;
- *    all_reduce( comm , ReduceSum < 5 >( a ) & ReduceMax < 3 >( b ) );
- *
- *  Reduction options include:
- *    ReduceSum    < N > ( T * )   // Summation
- *    ReduceProd   < N > ( T * )   // Product
- *    ReduceMax    < N > ( T * )   // Maximum
- *    ReduceMin    < N > ( T * )   // Minimum
- *    ReduceBitOr  < N > ( T * )   // Bit-wise OR
- *    ReduceBitAnd < N > ( T * )   // Bit-wise AND
- * 
- */ -template < class ReduceOp > -void all_reduce( ParallelMachine , const ReduceOp & ); - -/** \} */ - -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -#ifndef DOXYGEN_COMPILE - -namespace stk_classic { -namespace { -// Blank namespace so that this class produces local symbols, -// avoiding complaints from a linker of multiple-define symbols. - -struct ReduceEnd { - struct WorkType {}; - void copyin( WorkType & ) const {} - void copyout( WorkType & ) const {} - static void op( WorkType & , WorkType & ) {} -}; - -// Workhorse class for aggregating reduction operations. - -template -struct Reduce { - - typedef T Type ; - enum { N = Op::N }; - - struct WorkType { - typename Next::WorkType m_next ; - Type m_value[N]; - }; - - Next m_next ; - Type * m_value ; - - // Copy values into buffer: - void copyin( WorkType & w ) const - { Copy( w.m_value , m_value ); m_next.copyin( w.m_next ); } - - // Copy value out from buffer: - void copyout( WorkType & w ) const - { Copy( m_value , w.m_value ); m_next.copyout( w.m_next ); } - - // Reduction function - static void op( WorkType & out , WorkType & in ) - { Op( out.m_value , in.m_value ); Next::op( out.m_next , in.m_next ); } - - // Aggregate reduction operations, use '&' for left-to-right evaluation - template - Reduce > - operator & ( const Reduce & rhs ) - { return Reduce >( rhs , *this ); } - - // Constructor for aggregation: - Reduce( const Reduce & arg_val , const Next & arg_next ) - : m_next( arg_next ), m_value( arg_val.m_value ) {} - - // Constructor for aggregate member: - explicit Reduce( Type * arg_value ) - : m_next(), m_value( arg_value ) {} - - static void void_op( void*inv, void*inoutv, int*, ParallelDatatype*); -}; - -template -void Reduce::void_op( void*inv, void*inoutv,int*,ParallelDatatype*) -{ - op( * reinterpret_cast( inoutv ) , - * reinterpret_cast( inv ) ); -} - -} -} - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -namespace stk_classic { - -template -inline -Reduce< Sum , T, ReduceEnd> ReduceSum( T * value ) -{ return Reduce< Sum, T, ReduceEnd >( value ); } - -template -inline -Reduce< Prod, T, ReduceEnd > ReduceProd( T * value ) -{ return Reduce< Prod, T, ReduceEnd >( value ); } - -template -inline -Reduce< Max, T, ReduceEnd> ReduceMax( T * value ) -{ return Reduce< Max, T, ReduceEnd>( value ); } - -template -inline -Reduce< Min, T, ReduceEnd> ReduceMin( T * value ) -{ return Reduce, T, ReduceEnd>( value ); } - -template -inline -Reduce< BitOr, T, ReduceEnd> ReduceBitOr( T * value ) -{ return Reduce< BitOr, T, ReduceEnd>( value ); } - -template -inline -Reduce< BitAnd, T, ReduceEnd> ReduceBitAnd( T * value ) -{ return Reduce< BitAnd, T, ReduceEnd>( value ); } - -//---------------------------------------------------------------------- -// all_reduce( comm , ReduceSum<5>( A ) & ReduceMax<3>( B ) ); - -extern "C" { -typedef void (*ParallelReduceOp) - ( void * inv , void * outv , int * , ParallelDatatype * ); -} - -void all_reduce( ParallelMachine arg_comm , - ParallelReduceOp arg_op , - void * arg_in , - void * arg_out , - unsigned arg_len ); - -namespace { - -template < class ReduceOp > -void all_reduce_driver( ParallelMachine comm , const ReduceOp & op ) -{ - typedef typename ReduceOp::WorkType WorkType ; - - WorkType inbuf , outbuf ; - - ParallelReduceOp f = - reinterpret_cast( & ReduceOp::void_op ); - op.copyin( inbuf ); - all_reduce( comm , f , & inbuf, & outbuf, sizeof(WorkType) ); - op.copyout( outbuf ); -} - -} - -template < class ReduceOp > -inline -void all_reduce( ParallelMachine comm , const ReduceOp & op ) -{ all_reduce_driver( comm , op ); } - -} - -#endif /* DOXYGEN_COMPILE */ - -//---------------------------------------------------------------------- - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.cpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.cpp deleted file mode 100644 index 5dc52b60a479..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.cpp +++ /dev/null @@ -1,475 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2000-2007 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include -#include -#include - -enum { buffer_default_length = 4096 }; -enum { buffer_putback_length = 16 }; - -/*--------------------------------------------------------------------*/ - -mpi_filebuf::mpi_filebuf() - : std::streambuf(), - comm( MPI_COMM_NULL ), - comm_root( -1 ), - comm_root_fp( NULL ), - comm_output( 0 ), - comm_buffer( NULL ), - comm_buffer_len( buffer_default_length ), - comm_time(0.0) -{} - -mpi_filebuf::~mpi_filebuf() -{ - close(); -} - -/*--------------------------------------------------------------------*/ - -mpi_filebuf * mpi_filebuf::set_buffer_length( const size_t len ) -{ - // If already open then abort - if ( NULL != comm_buffer ) return (mpi_filebuf *) NULL ; - - // Wait and verify upon the attempt to open - comm_buffer_len = buffer_putback_length < len ? len : buffer_putback_length ; - - return this ; -} - -/*--------------------------------------------------------------------*/ - -mpi_filebuf * mpi_filebuf::open( - MPI_Comm communicator , - const int root_processor , - const std::ios_base::openmode file_mode , - const char * const file_name ) -{ - const double start_time = MPI_Wtime(); - - // If already open then abort - if ( NULL != comm_buffer ) return (mpi_filebuf *) NULL ; - - const int mode = - ( std::ios::in == file_mode ) ? 'r' : ( - ( std::ios::out == file_mode ) ? 'w' : ( - ( std::ios::app == file_mode ) ? 'a' : -1 ) ); - - int err ; - int rank ; - int local, global ; - int data[3] ; - - // Broadcast the selected root processor and 'C' file mode - - data[0] = root_processor ; - data[1] = mode ; - data[2] = comm_buffer_len ; - - if ( MPI_SUCCESS != ( err = MPI_Bcast(data,3,MPI_INT,0,communicator) ) ) - MPI_Abort( communicator , err ); - - // Verify that all processors have the same root, mode, and buffer length: - - local = data[0] != root_processor || data[1] != mode || data[2] != (signed) comm_buffer_len ; - - if ( MPI_SUCCESS != ( err = - MPI_Allreduce(&local,&global,1,MPI_INT,MPI_BOR,communicator) ) ) - MPI_Abort( communicator , err ); - - if ( global ) { - comm_time += MPI_Wtime() - start_time ; - return (mpi_filebuf *) NULL ; - } - - //-------------------------------------------------------------------- - // Root processor and mode are consistent. - // All processors try to allocate buffers and the - // root processor tries to open the file. - - if ( MPI_SUCCESS != ( err = MPI_Comm_rank( communicator , &rank ) ) ) - MPI_Abort( communicator , err ); - - char * const tmp_buf = (char *) std::malloc( comm_buffer_len ); - std::FILE * tmp_fp = NULL ; - - local = tmp_buf == NULL ; // Failed allocation ? - - if ( root_processor == rank && ! local ) { - tmp_fp = std::fopen( file_name , ( ( ( mode == 'r' ) ? "r" : - ( mode == 'w' ) ? "w" : "a" ) ) ); -#ifdef REDSTORM_SETVBUF - if (tmp_fp) { - if (std::setvbuf(tmp_fp, NULL, _IOFBF, 32768) != 0) { - std::fclose(tmp_fp); - tmp_fp = 0; - } - } -#endif - local = NULL == tmp_fp ; - } - - if ( MPI_SUCCESS != ( err = - MPI_Allreduce(&local,&global,1,MPI_INT,MPI_BOR,communicator) ) ) - MPI_Abort( communicator , err ); - - if ( global ) { - if ( NULL != tmp_buf ) std::free( tmp_buf ); // Deallocate - if ( NULL != tmp_fp ) std::fclose( tmp_fp ); // Close the file - comm_time += MPI_Wtime() - start_time ; - return (mpi_filebuf *) NULL ; - } - - //-------------------------------------------------------------------- - // All memory allocated and root processor openned the file - // Update the internal members accordingly. - - comm = communicator ; - comm_root = root_processor ; - comm_root_fp = tmp_fp ; - comm_buffer = tmp_buf ; - comm_output = mode != 'r' ; - - // If output then set up put-buffer - - if ( comm_output ) setp( comm_buffer, comm_buffer + comm_buffer_len ); - - comm_time += MPI_Wtime() - start_time ; - - return this ; -} - -/*--------------------------------------------------------------------*/ - -mpi_filebuf * mpi_filebuf::close() -{ - mpi_filebuf * tmp = NULL ; - - if ( NULL != comm_buffer ) { - - flush(); // Flush the buffers - - if ( NULL != comm_root_fp ) std::fclose( comm_root_fp ); // Close the file - - std::free( comm_buffer ); // Free the buffer - - if ( comm_output ) setp(NULL,NULL); - else setg(NULL,NULL,NULL); - - // Reset the members: - - comm = MPI_COMM_NULL ; - comm_root = -1 ; - comm_root_fp = NULL ; - comm_output = 0 ; - comm_buffer = NULL ; - - tmp = this ; - } - - return tmp ; -} - -/*--------------------------------------------------------------------*/ -/* Underflow, a global call. - Read more data from the root processor's file and - broadcast it to all processors. -*/ - -int mpi_filebuf::underflow() -{ - const double start_time = MPI_Wtime(); - - if ( NULL != comm_buffer && ! comm_output && // Open for read - ( gptr() == NULL || gptr() >= egptr() ) ) { // valid get buffer - - - // Length of the buffer, consistent on all processors - // Entire buffer is offset to accomodate putbacks - - const size_t size = comm_buffer_len - buffer_putback_length ; - char * const buf = comm_buffer + buffer_putback_length ; - - int nread ; - int err ; - - // Root processor reads from the file and broadcasts the result - - if ( NULL != comm_root_fp ) nread = std::fread(buf,1,size,comm_root_fp); - - if ( MPI_SUCCESS != ( err = - MPI_Bcast( &nread, 1, MPI_INT, comm_root, comm ) ) ) - MPI_Abort(comm,err); - - // If the read is successfull then update the get buffer pointers: - - if ( 0 < nread ) { - - // Broadcast the read buffer to all processors: - - if ( MPI_SUCCESS != ( err = - MPI_Bcast( buf, nread, MPI_BYTE, comm_root, comm ) ) ) - MPI_Abort(comm,err); - - // Set the get buffer: - - setg( comm_buffer, buf, buf + nread ); - - // Return the next character from the file: - - comm_time += MPI_Wtime() - start_time ; - - return *buf ; - } - } - - // Failed: set the get buffer to NULL and return EOF - setg(NULL, NULL, NULL); - - comm_time += MPI_Wtime() - start_time ; - - return EOF; -} - -/*--------------------------------------------------------------------*/ -/* Overflow, a local call. - Output complete lines of data on the root processor. - Increase the buffer size on all other processors. -*/ - -int mpi_filebuf::overflow( int c ) -{ - if ( NULL != comm_buffer && comm_output ) { // open for write - - // Determine current offset and length: - char * cur_buffer = comm_buffer ; - size_t cur_offset = pptr() - cur_buffer ; - size_t cur_length = epptr() - cur_buffer ; - - assert( cur_offset <= cur_length /* detecting abuse by 'ostream' */ ); - - if ( NULL != comm_root_fp ) { - if ( std::fwrite(cur_buffer,1,cur_offset,comm_root_fp) != cur_offset ) { - return EOF ; // Write failed - } - cur_offset = 0 ; - } - else if ( cur_length <= cur_offset ) { - // Not root processor, ran out of buffer space and - // cannot write so increase the buffer size: - cur_buffer = (char *) std::realloc( cur_buffer , cur_length *= 2 ); - } - - // If buffer is still good then reset the put-buffer - - if ( NULL != cur_buffer ) { - - comm_buffer = cur_buffer ; - - setp( cur_buffer + cur_offset, cur_buffer + cur_length ); - - if ( c != EOF ) { - - sputc(c); - return c; - } - else { - return 0; - } - } - } - return EOF ; -} - -/*--------------------------------------------------------------------*/ -/* Send output buffers to root processor and - write them to the output file. -*/ - -mpi_filebuf * mpi_filebuf::flush() -{ - const double start_time = MPI_Wtime(); - - int result = -1 ; // Failure return value - - if ( NULL != comm_buffer && comm_output ) { // Open for write - - int err ; - - result = 0 ; - - // Determine the local length: - - char * cur_buf = comm_buffer ; - unsigned int cur_len = pptr() - cur_buf ; - - // Determine the global lengths - - char * recv_buf = NULL ; - int * recv_len = NULL ; - int * recv_disp = NULL ; - - int nproc = 0 ; - - -// if ( NULL != comm_root_fp ) { - -// It should no be neccessary to allocate recv_len on non-root -// nodes, but the MPI_Gatherv on Janus always accesses recv_len -// even on non-root processors which causes a segmentaion -// violation if recv_len is set to NULL. - - if ( MPI_SUCCESS != ( err = MPI_Comm_size(comm,&nproc) ) ) - MPI_Abort( comm , err ); - - recv_len = (int*) std::malloc( sizeof(int) * nproc ); - - if ( NULL == recv_len ) MPI_Abort( comm , MPI_ERR_UNKNOWN ); - - for (int j = 0 ; j < nproc ; ++j ) - recv_len[j] = 0; -// } - - // Gather buffer lengths on the root processor - - if ( MPI_SUCCESS != ( err = - MPI_Gather(&cur_len,1,MPI_INT,recv_len,1,MPI_INT,comm_root,comm))) - MPI_Abort( comm , err ); - - // Root processor must allocate enough buffer space: - - if ( NULL != comm_root_fp ) { - - recv_len[ comm_root ] = 0 ; // Don't send to self - - int i ; - - if ( NULL == ( recv_disp = (int*) std::malloc( sizeof(int) * (nproc + 1) ) ) ) - result = -1 ; - - if ( 0 == result ) { // Allocation succeeded - - recv_disp[0] = 0 ; - - for ( i = 0 ; i < nproc ; ++i ) - recv_disp[i+1] = recv_disp[i] + recv_len[i] ; - - if ( 0 < recv_disp[nproc] ) { - if ( NULL == ( recv_buf = (char*) std::malloc( recv_disp[nproc] ) ) ) - result = -1 ; - } - else { - result = 1 ; // No need to gather! - } - - if ( -1 != result ) { - - // Write the root processor's buffer - - if ( 0 < cur_len ) { - if ( std::fwrite(cur_buf,1,cur_len,comm_root_fp) != cur_len ) - result = -1 ; // Write failed - - cur_len = 0 ; // Wrote this buffer - } - } - } - std::fflush( comm_root_fp ); - } - - // Root process broadcasts that all is well with the allocation - - if ( MPI_SUCCESS != ( err = MPI_Bcast(&result,1,MPI_INT,comm_root,comm))) - MPI_Abort( comm , err ); - - if ( 0 == result ) { // All-is-well, need to gather and write - - // Gather the buffers to the root processor - - if ( MPI_SUCCESS != ( err = - MPI_Gatherv(cur_buf, cur_len, MPI_BYTE, - recv_buf, recv_len, recv_disp, MPI_BYTE, - comm_root, comm ) ) ) - MPI_Abort( comm , err ); - - // Output the buffers, beginning with 'comm_root' - - if ( NULL != comm_root_fp ) { - - int i ; - - for ( i = 1 ; i < nproc && 0 == result ; ++i ) { - const int j = ( i + comm_root ) % nproc ; - const unsigned int len = recv_len[j] ; - - if ( 0 < len ) - if ( std::fwrite(recv_buf+recv_disp[j],1,len,comm_root_fp) != len ) - result = -1 ; // Write failed - } - - std::fflush( comm_root_fp ); - } - - // Broadcast that the write succeeded - - if ( MPI_SUCCESS != ( err = MPI_Bcast(&result,1,MPI_INT,comm_root,comm))) - MPI_Abort( comm , err ); - } - else if ( 1 == result ) { - // Did not need to gather - - result = 0 ; - } - - // Reset the output buffer - - setp( comm_buffer , epptr() ); - - // Clean up allocated memory - - if ( NULL != recv_buf ) std::free( recv_buf ); - if ( NULL != recv_len ) std::free( recv_len ); - if ( NULL != recv_disp ) std::free( recv_disp ); - } - - comm_time += MPI_Wtime() - start_time ; - - return -1 == result ? (mpi_filebuf *) NULL : this ; -} - -/*--------------------------------------------------------------------*/ - -int mpi_filebuf::sync() -{ - // The root processor will push to file, all others ignore - - if ( NULL != comm_root_fp ) { - - // Determine the local length: - - char * cur_buf = comm_buffer ; - int cur_len = pptr() - cur_buf ; - - if ( 0 < cur_len ) std::fwrite(cur_buf,1,cur_len,comm_root_fp); - - std::fflush( comm_root_fp ); - - setp( comm_buffer , epptr() ); - } - - return 0 ; -} - - -std::streambuf * mpi_filebuf::setbuf( char * s , std::streamsize n ) -{ - return this ; -} diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.hpp deleted file mode 100644 index 2cdcd06b8a09..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpi_filebuf.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* ------------------------------------------------------------------ */ -/* Copyright 2000 Sandia Corporation, Albuquerque, NM. */ -/* ------------------------------------------------------------------ */ - -#ifndef STK_UTIL_PARALLEL_mpi_filebuf_hpp -#define STK_UTIL_PARALLEL_mpi_filebuf_hpp - -#include -#include -#include -#include - -//: Specialize the ANSI Standard C++ streambuf class -//: for a parallel file buffer. The actual file is -//: only touched by the root processor. -// -// READ MODE: The file is read on the root processor and -// broadcast one buffer at a time to the remaining processors. -// -// WRITE MODE: Each processor has a buffer that is locally -// filled. When the buffer is full on the root processor the -// buffer is written to the output file. When the buffer is -// full on any other processor the size of the buffer is doubled. -// The 'mpi_filebuf::flush' method gathers all buffers on the -// root processor and writes the buffers to the output file. -// -// GLOBAL: Calls to the 'open', 'flush', 'close', destructor, -// and 'underflow' methods are global; these calls must be -// made on all processors. The 'underflow' method is called -// by the 'istream' that uses the 'mpi_filebuf' object when -// ever the input buffer is empty. Thus reading from an 'istream' -// that uses an 'mpi_filebuf' must be globally consistent. - -class mpi_filebuf : public std::streambuf { -public: - - //: Construct an MPI-parallel input/output file buffer - mpi_filebuf(); - - //: GLOBAL: Open a file. - // The file name is only significant on the root processsor. - // May only be opened as ios::in, ios::out, ios:app. - mpi_filebuf * open( - MPI_Comm communicator , /* All processors */ - const int root_processor , /* All processors */ - const std::ios_base::openmode file_mode , /* All processors */ - const char * const file_name = NULL ); /* Root processor */ - - //: GLOBAL: Close the file. - // If output mode then flush the output. - mpi_filebuf * close(); - - //: GLOBAL: Flush the buffered output to the file. - // Sends all buffers to the root processor, - // write to the file, and flushes the file. - mpi_filebuf * flush(); - - //: GLOBAL: Destructor - // Close and then reclaim memory. - virtual ~mpi_filebuf(); - - //: Query if open, a local operations - int is_open() const ; - - //: When the file buffer is in the 'closed' state set the buffer length, - // The input argument must be consistent on all processors; however, - // this condition is not checked until the next 'open' operation. - mpi_filebuf * set_buffer_length( const size_t buffer_length ); - - //: Query the current buffer - void get_buffer( const char * & , size_t & ) const ; - - //: Query wall-clock time spent communicating. - double wtime() const ; - -protected: - - //: Called to refill the input buffer - virtual int underflow(); - - //: Called when output buffer is filled - virtual int overflow( int c = EOF ); - - //: Sync is a no-op - virtual int sync(); - - //: Setbuf is a no-op - virtual std::streambuf * setbuf( char * s , std::streamsize n ); - -private: - - mpi_filebuf( const mpi_filebuf & ); // Not allowed - mpi_filebuf & operator = ( const mpi_filebuf & ); // Not allowed - - MPI_Comm comm ; // Communicator - int comm_root ; // Rank of root processor - std::FILE * comm_root_fp ; // Root processor's file - int comm_output ; // Output file - char * comm_buffer ; // local buffer - size_t comm_buffer_len ; // length of buffer - double comm_time ; // wall-time spent communicating -}; - -/*--------------------------------------------------------------------*/ - -inline int mpi_filebuf::is_open() const { return NULL != comm_buffer ; } - -/* The SUN has the 'streambuf::pptr()' as a non-const method, - which violates the ISO/ANSI standard specification. - Therefore, must cast away the const. */ - -inline void mpi_filebuf::get_buffer( const char * & b , size_t & n ) const - { b = comm_buffer ; n = ((mpi_filebuf*)this)->pptr() - comm_buffer ; } - -inline double mpi_filebuf::wtime() const { return comm_time ; } - -#endif // STK_UTIL_PARALLEL_mpi_filebuf_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpih.hpp b/packages/stk/stk_classic/stk_util/stk_util/parallel/mpih.hpp deleted file mode 100644 index 4a45145d7656..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/parallel/mpih.hpp +++ /dev/null @@ -1,260 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002, 2009 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -/** \file - Framework interface to MPIH system. - - sierra::mpih provides a C++ interface to the C based MPIH system. - It handles all of the explicit exception handling and run time - type identification that is not possible in C. Sierra applications - should not have to call MPIH directly, but should call sierra::mpih. - -*/ - -#ifndef STK_UTIL_PARALLEL_mpih_h -#define STK_UTIL_PARALLEL_mpih_h - -#include -#include - -#include - -#include - -namespace sierra { -namespace mpih { - -/** - * @brief Member function Enable initializes exception handling. - * - * Enable() wraps the MPIH_enable fuction call, defaulting all of the parameters. - * Enable() should be called after MPI_Init and before Register_Handles. - * - * @see MPIH_Comm_Enable - */ -void Enable(); - -void Keyval_delete(MPI_Comm comm); - -/** - * @brief Member function Sub_Communicator initialize a new communicator from - * an old one. This is an unusual call in that the communicators have to be explicitly - * passed. Normally the default communicator is taken as sierra::Fmwk::Env::comm(). - * Sub_Communicator is used when Env is reset with a partition of communicators. Each of - * the new sub communicators need to be initialized from the old one. This avoids having - * to register all of the exception handlers again. The new communicator will inherit - * everything from the old and even use the same memory to store flags and such. - * - * @param old_comm a MPI_Comm value of the old MPI communicator. - * - * @param new_comm a MPI_Comm value of the new MPI communicator. - * - */ -void Sub_Communicator (MPI_Comm old_comm, - MPI_Comm new_comm); - -/** - * @brief Member function Register_Handles is called during creation of this - * singleton. All of the exception subclasses that can be thrown by Fmwk are registered - * as handles with the MPIH subsystem. \see Register_Handles - * - */ -void Register_Handles (); - -/** - * @brief Member function Add_Handle additional exceptions can be added with - * Add_Handle. This would be neccessary if an application defined its own exception - * classes. - * - * @see MPIH_Comm_add_handle - * - * @param X an ExParallel reference to the exception singleton to - * add to the registered exceptions list. - */ -void Add_Handle (const ExParallel &X); - -/** - * @brief Member function Delete_Handles deletes all exception handles. - * Should only be called in destructor. - * - */ -void Delete_Handles (); - -/** Collective Communication routine. - * Bcast, Allreduce, ... are the standard collective - * communication calls. These are simple wrappers - * that default the communicator to sierra::Env::mpi::comm() - * and check for error return codes. All of these - * functions sierra::Env::abort() on error, so there is - * no return code to check. If an exception has - * been thrown, that is automatically handled also. - * \see MPIH_Allreduce MPIH_Bcast - * MPIH_Gather MPIH_Reduce MPIH_Reduce_scatter - * MPIH_Scatter - */ -void Bcast(void * buffer, - int count, - MPI_Datatype datatype, - int root); - -void Allreduce( void * in_buffer, - void * out_buffer, - int count, - MPI_Datatype datatype, - MPI_Op op ); - -void Gather( void * send_buf, - int send_size, - MPI_Datatype send_datatype, - void * recv_buf, - int recv_size, - MPI_Datatype recv_datatype, - int root); - -void Reduce( void * in_buffer, - void * out_buffer, - int count, - MPI_Datatype datatype, - MPI_Op op, - int root); - -void Reduce_Scatter( void * in_buffer, - void * out_buffer, - int recv_count, - MPI_Datatype datatype, - MPI_Op op); - -void Scatter( void * send_buf, - int send_size, - MPI_Datatype send_datatype, - void * recv_buf, - int recv_size, - MPI_Datatype recv_datatype, - int root); - -void Map_Free(MPIH_Map * map); - -void Map_Query -(MPIH_Map map /* in: Map for the sparse operation */, - int *symmetric /* out: */, - size_t *nsend /* out: Number of sends */, - std::vector *sendlist /* out: List of destinations */, - std::vector *sendlength /* out: */, - std::vector *sendbuflen /* out: */, - size_t *nrecv /* out: Number of receives */, - std::vector *recvlist /* out: List of destinations */, - std::vector *recvlength /* out: */, - std::vector *recvbuflen /* out: */ ); - -void Sparse -(void * sendbuf /* in: address of send buffer */ , - MPI_Datatype sendtype /* in: datatype of the send messages */ , - void * recvbuf /* in: address of receive buffer */ , - MPI_Datatype recvtype /* in: datatype of the recv messages */ , - int transpose /* in: whether to reverse communic. */ , - MPIH_Map map /* in: communication map */ ); - -/* The Sparse is a combination of Initialize_Sparse and Wait_Sparse. - * This allows computation to happen while the communication is - * begin processed. After the call to Initialize_Sparse the - * buffers should NOT be reused until the completion of the - * corresponding Wait_Sparse call. The map passed to Wait_Sparse - * must be the same map that was used in Initialize_Sparse. - * Also, it is not possible to call Initialize_Sparse twice followed - * by two calls to Wait_Sparse. Because MPI does not guarentee - * the order that messages are received, the first Wait_Sparse - * could get the messages from the second Initialize_Sparse. - */ -void Initialize_Sparse -(void * sendbuf /* in: address of send buffer */ , - MPI_Datatype sendtype /* in: datatype of the send messages */ , - void * recvbuf /* in: address of receive buffer */ , - MPI_Datatype recvtype /* in: datatype of the recv messages */ , - int transpose /* in: whether to reverse communic. */ , - MPIH_Map map /* in: communication map */ ); - -void Wait_Sparse -(MPIH_Map map /* in: communication map */ ); - -void Sparse_Map -(const std::vector &lengths /* in: Byte length of each message */ , - const std::vector &buflens /* in: Byte length of each message buffer */ , - const std::vector &sendlist /* in: Destination processors */ , - MPIH_Map * map /* out: Map for the sparse operation */ ); - -void Sparse_Symmetric_Map -(const std::vector &lengths /* in: Length of each message */ , - const std::vector &buflens /* in: Length of each message buffe */ , - const std::vector &sendlist /* in: Destination processors */ , - MPIH_Map * map /* out: Map for the sparse operation */ ); - -inline void ParallelExceptionCheck() -{ - int dummy = 0; - Bcast(&dummy, 0, MPI_INT, 0); -} - - -/* - * The rest of the functions are unlikely to be used - * outside of mpih.C. - */ - -/* Local handle, Global handles, and just plain handles: - * - * Just plain handles are the handles that are registered - * on this processor. The number of them is unknown - * in advance. These are required to be consistant - * across all processors. - * - * local_handle is singular, it refers to the exception - * handle that has been set on the local processor. - * This is the handle that will be propagated on - * the next collective communication. - * - * Global handles is the collection of local handles - * from all of the processors after the collective - * communication. There will be one for each - * processor, but some will be NULL if there was not - * a local handle set for that processor. - */ -void Activate_Handles (); -void Deactivate_Handles (); -int Get_Nhandles (); -void Get_Handles (ExParallel **handles); - -ExParallel *Get_Local_Handle (); -void Set_Local_Handle (ExParallel &handle); -void Reset_Local_Handle (); - -void Get_Global_Handles (ExParallel ** handles); -int Get_Global_Status (); - -void Set_Status_Check (); -void Reset_Status_Check (); -int Get_Status_Check (); - -void Get_Tags (int *active, - int *tag_sparse, - int *tag_normal, - int *tag_message); - -void Get_Functions (MPIH_Handler_compete *handler_compete_fn , - MPIH_Handler_execute *handler_execute_fn ); - -int Get_Control_Message(); - -/* interface for the product versioning. */ -const char *get_product_name(); -const char *get_product_version(); -const char *get_product_qualifier(); -void register_product(); - -} // namespace mpih -} // namespace sierra - -#endif // STK_UTIL_PARALLEL_mpih_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/stk_config.h b/packages/stk/stk_classic/stk_util/stk_util/stk_config.h deleted file mode 100644 index 8557d1dcd72a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/stk_config.h +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_config_h -#define stk_util_config_h - -#ifdef STK_BUILT_IN_SIERRA -#define STK_HAS_MPI -#else -// This file gets created by cmake during a Trilinos build -// and will not be present in a sierra build using bjam or associated wrappers -#include -#ifdef HAVE_MPI -#define STK_HAS_MPI -#endif -#endif - -#define STK_PACKAGE stk -#define STK_HAS_SNL_EXODUSII - -#endif /* stk_util_config_h */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/CMakeLists.txt deleted file mode 100644 index 769bd69f5ac1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -GeneratedMesh.hpp -stk_utest_macros.hpp -) - -APPEND_SET(SOURCES -GeneratedMesh.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_unit_test_support - NOINSTALLHEADERS ${HEADERS} - DEPLIBS - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/unit_test_support/) diff --git a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.cpp b/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.cpp deleted file mode 100644 index b153c7ffe2a4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.cpp +++ /dev/null @@ -1,1227 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace stk_classic { - namespace io { - namespace util { - GeneratedMesh::GeneratedMesh(int num_x, int num_y, int num_z, - int proc_count, int my_proc) : - numX(num_x), numY(num_y), numZ(num_z), myNumZ(num_z), myStartZ(0), - processorCount(proc_count), myProcessor(my_proc), - offX(0), offY(0), offZ(0), - sclX(1), sclY(1), sclZ(1), - doRotation(false) - { - initialize(); - } - - GeneratedMesh::GeneratedMesh(const std::string ¶meters, - int proc_count, int my_proc) : - numX(0), numY(0), numZ(0), myNumZ(0), myStartZ(0), - processorCount(proc_count), myProcessor(my_proc), - offX(0), offY(0), offZ(0), - sclX(1), sclY(1), sclZ(1), - doRotation(false) - { - std::vector groups; - stk_classic::util::tokenize(parameters, "|+", groups); - - // First 'group' is the interval specification -- IxJxK - std::vector tokens; - stk_classic::util::tokenize(groups[0], "x", tokens); - assert(tokens.size() == 3); - numX = std::strtol(tokens[0].c_str(), NULL, 10); - numY = std::strtol(tokens[1].c_str(), NULL, 10); - numZ = std::strtol(tokens[2].c_str(), NULL, 10); - - initialize(); - parse_options(groups); - - } - - GeneratedMesh::~GeneratedMesh() {} - - void GeneratedMesh::initialize() - { - assert(numZ >= processorCount); - if (processorCount > 1) { - myNumZ = numZ / processorCount; - if (myProcessor < (numZ % processorCount)) myNumZ++; - - // Determine myStartZ for this processor... - size_t extra = numZ % processorCount; - if (extra > myProcessor) - extra = myProcessor; - size_t per_proc = numZ / processorCount; - myStartZ = myProcessor * per_proc + extra; - } else { - myNumZ = numZ; - } - - for (int i=0; i < 3; i++) { - for (int j=0; j < 3; j++) { - rotmat[i][j] = 0.0; - } - rotmat[i][i] = 1.0; - } - } - - size_t GeneratedMesh::add_shell_block(ShellLocation loc) - { - shellBlocks.push_back(loc); - return shellBlocks.size(); - } - - size_t GeneratedMesh::add_nodeset(ShellLocation loc) - { - nodesets.push_back(loc); - return nodesets.size(); - } - - size_t GeneratedMesh::add_sideset(ShellLocation loc) - { - sidesets.push_back(loc); - return sidesets.size(); - } - - void GeneratedMesh::set_bbox(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) - { - // NOTE: All calculations are based on the currently - // active interval settings. If scale or offset or zdecomp - // specified later in the option list, you may not get the - // desired bounding box. - double x_range = xmax - xmin; - double y_range = ymax - ymin; - double z_range = zmax - zmin; - - sclX = x_range / static_cast(numX); - sclY = y_range / static_cast(numY); - sclZ = z_range / static_cast(numZ); - - offX = xmin; - offY = ymin; - offZ = zmin; - } - - void GeneratedMesh::set_scale(double scl_x, double scl_y, double scl_z) - { - sclX = scl_x; - sclY = scl_y; - sclZ = scl_z; - } - - void GeneratedMesh::set_offset(double off_x, double off_y, double off_z) - { - offX = off_x; - offY = off_y; - offZ = off_z; - } - - void GeneratedMesh::parse_options(const std::vector &groups) - { - for (size_t i=1; i < groups.size(); i++) { - std::vector option; - stk_classic::util::tokenize(groups[i], ":", option); - // option[0] is the type of the option and option[1] is the argument to the option. - - if (option[0] == "shell") { - // Option of the form "shell:xXyYzZ" - // The argument specifies whether there is a shell block - // at the location. 'x' is minX, 'X' is maxX, etc. - size_t length = option[1].size(); - for (size_t j=0; j < length; j++) { - switch (option[1][j]) { - case 'x': - add_shell_block(MX); - break; - case 'X': - add_shell_block(PX); - break; - case 'y': - add_shell_block(MY); - break; - case 'Y': - add_shell_block(PY); - break; - case 'z': - add_shell_block(MZ); - break; - case 'Z': - add_shell_block(PZ); - break; - default: - std::cerr << "ERROR: Unrecognized shell location option '" - << option[1][j] - << "'."; - } - } - } - else if (option[0] == "nodeset") { - // Option of the form "nodeset:xXyYzZ" - // The argument specifies whether there is a nodeset - // at the location. 'x' is minX, 'X' is maxX, etc. - size_t length = option[1].size(); - for (size_t j=0; j < length; j++) { - switch (option[1][j]) { - case 'x': - add_nodeset(MX); - break; - case 'X': - add_nodeset(PX); - break; - case 'y': - add_nodeset(MY); - break; - case 'Y': - add_nodeset(PY); - break; - case 'z': - add_nodeset(MZ); - break; - case 'Z': - add_nodeset(PZ); - break; - default: - std::cerr << "ERROR: Unrecognized nodeset location option '" - << option[1][j] - << "'."; - } - } - } - else if (option[0] == "sideset") { - // Option of the form "sideset:xXyYzZ" - // The argument specifies whether there is a sideset - // at the location. 'x' is minX, 'X' is maxX, etc. - size_t length = option[1].size(); - for (size_t j=0; j < length; j++) { - switch (option[1][j]) { - case 'x': - add_sideset(MX); - break; - case 'X': - add_sideset(PX); - break; - case 'y': - add_sideset(MY); - break; - case 'Y': - add_sideset(PY); - break; - case 'z': - add_sideset(MZ); - break; - case 'Z': - add_sideset(PZ); - break; - default: - std::cerr << "ERROR: Unrecognized sideset location option '" - << option[1][j] - << "'."; - } - } - } - else if (option[0] == "scale") { - // Option of the form "scale:xs,ys,zs - std::vector tokens; - stk_classic::util::tokenize(option[1], ",", tokens); - assert(tokens.size() == 3); - sclX = std::strtod(tokens[0].c_str(), NULL); - sclY = std::strtod(tokens[1].c_str(), NULL); - sclZ = std::strtod(tokens[2].c_str(), NULL); - } - - else if (option[0] == "offset") { - // Option of the form "offset:xo,yo,zo - std::vector tokens; - stk_classic::util::tokenize(option[1], ",", tokens); - assert(tokens.size() == 3); - offX = std::strtod(tokens[0].c_str(), NULL); - offY = std::strtod(tokens[1].c_str(), NULL); - offZ = std::strtod(tokens[2].c_str(), NULL); - } - - else if (option[0] == "zdecomp") { - // Option of the form "zdecomp:1,1,2,2,1,2,... - // Specifies the number of intervals in the z direction - // for each processor. The number of tokens must match - // the number of processors. Note that the new numZ will - // be the sum of the intervals specified in this command. - std::vector tokens; - stk_classic::util::tokenize(option[1], ",", tokens); - assert(tokens.size() == processorCount); - std::vector Zs; - numZ = 0; - for (size_t j = 0; j < processorCount; j++) { - Zs.push_back(std::strtol(tokens[j].c_str(), NULL, 10)); - numZ += Zs[j]; - } - myNumZ = Zs[myProcessor]; - myStartZ = 0; - for (size_t j=0; j < myProcessor; j++) { - myStartZ += Zs[j]; - } - } - - else if (option[0] == "bbox") { - // Bounding-Box Option of the form "bbox:xmin,ymin,zmin,xmax,ymax,zmaxo - std::vector tokens; - stk_classic::util::tokenize(option[1], ",", tokens); - assert(tokens.size() == 6); - double xmin = std::strtod(tokens[0].c_str(), NULL); - double ymin = std::strtod(tokens[1].c_str(), NULL); - double zmin = std::strtod(tokens[2].c_str(), NULL); - double xmax = std::strtod(tokens[3].c_str(), NULL); - double ymax = std::strtod(tokens[4].c_str(), NULL); - double zmax = std::strtod(tokens[5].c_str(), NULL); - - set_bbox(xmin, ymin, zmin, xmax, ymax, zmax); - } - - else if (option[0] == "rotate") { - // Rotate Option of the form "rotate:axis,angle,axis,angle,... - std::vector tokens; - stk_classic::util::tokenize(option[1], ",", tokens); - assert(tokens.size() %2 == 0); - for (size_t ir=0; ir < tokens.size();) { - std::string axis = tokens[ir++]; - double angle_degree = std::strtod(tokens[ir++].c_str(), NULL); - set_rotation(axis, angle_degree); - } - } - - else if (option[0] == "help") { - std::cerr << "\nValid Options for GeneratedMesh parameter string:\n" - << "\tIxJxK -- specifies intervals; must be first option. Ex: 4x10x12\n" - << "\toffset:xoff, yoff, zoff\n" - << "\tscale: xscl, yscl, zscl\n" - << "\tzdecomp:n1,n2,n3,...,n#proc\n" - << "\tbbox: xmin, ymin, zmin, xmax, ymax, zmax\n" - << "\trotate: axis,angle,axis,angle,...\n" - << "\tshell:xXyYzZ (specifies which plane to apply shell)\n" - << "\tnodeset:xXyXzZ (specifies which plane to apply nodeset)\n" - << "\tsideset:xXyXzZ (specifies which plane to apply sideset)\n" - << "\tshow -- show mesh parameters\n" - << "\thelp -- show this list\n\n"; - } - - else if (option[0] == "show") { - show_parameters(); - } - - else { - std::cerr << "ERROR: Unrecognized option '" << option[0] - << "'. It will be ignored.\n"; - } - } - } - - void GeneratedMesh::show_parameters() const - { - if (myProcessor == 0) { - std::cerr << "\nMesh Parameters:\n" - << "\tIntervals: " << numX << " by " << numY << " by " << numZ << "\n" - << "\tX = " << sclX << " * (0.." << numX << ") + " << offX - << "\tRange: " << offX << " <= X <= " << offX + numX * sclX << "\n" - << "\tY = " << sclY << " * (0.." << numY << ") + " << offY - << "\tRange: " << offY << " <= Y <= " << offY + numY * sclY << "\n" - << "\tZ = " << sclZ << " * (0.." << numZ << ") + " << offZ - << "\tRange: " << offZ << " <= Z <= " << offZ + numZ * sclZ << "\n\n" - << "\tNode Count (total) = " << std::setw(9) << node_count() << "\n" - << "\tElement Count (total) = " << std::setw(9) << element_count() << "\n" - << "\tBlock Count = " << std::setw(9) << block_count() << "\n" - << "\tNodeset Count = " << std::setw(9) << nodeset_count() << "\n" - << "\tSideset Count = " << std::setw(9) << sideset_count() << "\n\n"; - if (doRotation) { - std::cerr << "\tRotation Matrix: \n\t" << std::scientific ; - for (int ii=0; ii < 3; ii++) { - for (int jj=0; jj < 3; jj++) { - std::cerr << std::setw(14) << rotmat[ii][jj] << "\t"; - } - std::cerr << "\n\t"; - } - std::cerr << std::fixed << "\n"; - } - } - } - - size_t GeneratedMesh::node_count() const - { - return (numX+1) * (numY+1) * (numZ+1); - } - - size_t GeneratedMesh::node_count_proc() const - { - return (numX+1) * (numY+1) * (myNumZ+1); - } - - size_t GeneratedMesh::block_count() const - { - return shellBlocks.size() + 1; - } - - size_t GeneratedMesh::nodeset_count() const - { - return nodesets.size(); - } - - size_t GeneratedMesh::sideset_count() const - { - return sidesets.size(); - } - - size_t GeneratedMesh::element_count() const - { - size_t count = element_count(1); - for (size_t i=0; i < shellBlocks.size(); i++) { - count += element_count(i+2); - } - return count; - } - - size_t GeneratedMesh::element_count_proc() const - { - size_t count = 0; - for (size_t i=0; i < block_count(); i++) { - count += element_count_proc(i+1); - } - return count; - } - - size_t GeneratedMesh::element_count(size_t block_number) const - { - assert(block_number <= block_count()); - - if (block_number == 1) { - return numX * numY * numZ; - } else { - ShellLocation loc = shellBlocks[block_number-2]; - return shell_element_count(loc); - } - } - - size_t GeneratedMesh::shell_element_count(ShellLocation loc) const - { - switch (loc) { - case MX: - case PX: - return numY * numZ; - case MY: - case PY: - return numX * numZ; - case MZ: - case PZ: - return numX * numY; - } - return 0; - } - - size_t GeneratedMesh::element_count_proc(size_t block_number) const - { - assert(block_number <= block_count()); - - if (block_number == 1) { - return numX * numY * myNumZ; - } else { - ShellLocation loc = shellBlocks[block_number-2]; - return shell_element_count_proc(loc); - } - } - - size_t GeneratedMesh::shell_element_count_proc(ShellLocation loc) const - { - switch (loc) { - case MX: - case PX: - return numY * myNumZ; - case MY: - case PY: - return numX * myNumZ; - case MZ: - if (myProcessor == 0) - return numX * numY; - else - return 0; - case PZ: - if (myProcessor == processorCount -1) - return numX * numY; - else - return 0; - } - return 0; - } - - size_t GeneratedMesh::nodeset_node_count(size_t id) const - { - // id is position in nodeset list + 1 - assert(id > 0 && id <= nodesets.size()); - ShellLocation loc = nodesets[id-1]; - switch (loc) { - case MX: - case PX: - return (numY+1) * (numZ+1); - case MY: - case PY: - return (numX+1) * (numZ+1); - case MZ: - case PZ: - return (numX+1) * (numY+1); - } - return 0; - } - - size_t GeneratedMesh::nodeset_node_count_proc(size_t id) const - { - // id is position in nodeset list + 1 - assert(id > 0 && id <= nodesets.size()); - ShellLocation loc = nodesets[id-1]; - switch (loc) { - case MX: - case PX: - return (numY+1) * (myNumZ+1); - case MY: - case PY: - return (numX+1) * (myNumZ+1); - case MZ: - if (myProcessor == 0) - return (numX+1) * (numY+1); - else - return 0; - case PZ: - if (myProcessor == processorCount -1) - return (numX+1) * (numY+1); - else - return 0; - } - return 0; - } - - size_t GeneratedMesh::sideset_side_count(size_t id) const - { - // id is position in sideset list + 1 - assert(id > 0 && id <= sidesets.size()); - ShellLocation loc = sidesets[id-1]; - switch (loc) { - case MX: - case PX: - return numY * numZ; - case MY: - case PY: - return numX * numZ; - case MZ: - case PZ: - return numX * numY; - } - return 0; - } - - size_t GeneratedMesh::sideset_side_count_proc(size_t id) const - { - // id is position in sideset list + 1 - assert(id > 0 && id <= sidesets.size()); - ShellLocation loc = sidesets[id-1]; - switch (loc) { - case MX: - case PX: - return numY * myNumZ; - case MY: - case PY: - return numX * myNumZ; - case MZ: - if (myProcessor == 0) - return numX * numY; - else - return 0; - case PZ: - if (myProcessor == processorCount -1) - return numX * numY; - else - return 0; - } - return 0; - } - - std::pair GeneratedMesh::topology_type(size_t block_number) const - { - assert(block_number <= block_count() && block_number > 0); - - if (block_number == 1) { - return std::make_pair(std::string("hex8"), 8); - } else { - return std::make_pair(std::string("shell4"), 4); - } - } - - void GeneratedMesh::node_map(std::vector &map) - { - size_t count = node_count_proc(); - map.resize(count); - size_t offset = myStartZ * (numX+1) * (numY+1); - for (size_t i=0; i < count; i++) { - map[i] = static_cast(offset + i + 1); - } - } - - size_t GeneratedMesh::communication_node_count_proc() const - { - size_t count = (numX+1) * (numY+1); - if (myProcessor != 0 && myProcessor != processorCount-1) - count *= 2; - - return count; - } - - void GeneratedMesh::node_communication_map(std::vector &map, std::vector &proc) - { - size_t count = (numX+1) * (numY+1); - size_t slab = count; - if (myProcessor != 0 && myProcessor != processorCount-1) - count *= 2; - - map.resize(count); - proc.resize(count); - size_t j = 0; - if (myProcessor != 0) { - size_t offset = myStartZ * (numX+1) * (numY+1); - for (size_t i=0; i < slab; i++) { - map[j] = static_cast(offset + i + 1); - proc[j++] = static_cast(myProcessor-1); - } - } - if (myProcessor != processorCount-1) { - size_t offset = (myStartZ + myNumZ) * (numX+1) * (numY+1); - for (size_t i=0; i < slab; i++) { - map[j] = static_cast(offset + i + 1); - proc[j++] = static_cast(myProcessor+1); - } - } - } - - void GeneratedMesh::element_map(size_t block_number, std::vector &map) const - { - assert(block_number <= block_count() && block_number > 0); - - size_t count = element_count_proc(block_number); - map.resize(count); - - if (block_number == 1) { - // Hex block... - count = element_count_proc(1); - size_t offset = myStartZ * numX * numY; - for (size_t i=0; i < count; i++) { - map[i] = static_cast(offset + i + 1); - } - } else { - size_t start = element_count(1); - - // Shell blocks... - for (size_t ib=0; ib < shellBlocks.size(); ib++) { - count = element_count_proc(ib+2); - if (static_cast(block_number) == ib + 2) { - size_t offset = 0; - ShellLocation loc = shellBlocks[ib]; - - switch (loc) { - case MX: - case PX: - offset = myStartZ * numY; - break; - - case MY: - case PY: - offset = myStartZ * numX; - break; - - case MZ: - case PZ: - offset = 0; - break; - } - for (size_t i=0; i < count; i++) { - map[i] = static_cast(start + offset + i + 1); - } - } else { - start += element_count(ib+2); - } - } - } - } - - void GeneratedMesh::element_map(std::vector &map) const - { - size_t count = element_count_proc(); - map.resize(count); - - size_t k = 0; - // Hex block... - count = element_count_proc(1); - size_t offset = myStartZ * numX * numY; - for (size_t i=0; i < count; i++) { - map[k++] = static_cast(offset + i + 1); - } - - size_t start = element_count(1); - - // Shell blocks... - for (size_t ib=0; ib < shellBlocks.size(); ib++) { - count = element_count_proc(ib+2); - offset = 0; - ShellLocation loc = shellBlocks[ib]; - - switch (loc) { - case MX: - case PX: - offset = myStartZ * numY; - break; - - case MY: - case PY: - offset = myStartZ * numX; - break; - - case MZ: - case PZ: - offset = 0; - break; - } - for (size_t i=0; i < count; i++) { - map[k++] = static_cast(start + offset + i + 1); - } - start += element_count(ib+2); - } - } - - void GeneratedMesh::element_surface_map(ShellLocation loc, std::vector &map) const - { - size_t count = shell_element_count_proc(loc); - map.resize(2*count); - - size_t index = 0; - size_t offset = 0; - - switch (loc) { - case MX: - offset = myStartZ * numX * numY + 1; // 1-based elem id - for (size_t k = 0; k < myNumZ; ++k) { - for (size_t j = 0; j < numY; ++j) { - map[index++] = offset; - map[index++] = 3; // 0-based local face id - offset += numX; - } - } - break; - - case PX: - offset = myStartZ * numX * numY + numX; - for (size_t k = 0; k < myNumZ; ++k) { - for (size_t j = 0; j < numY; ++j) { - map[index++] = offset; // 1-based elem id - map[index++] = 1; // 0-based local face id - offset += numX; - } - } - break; - - case MY: - offset = myStartZ * numX * numY + 1; - for (size_t k = 0; k < myNumZ; ++k) { - for (size_t i = 0; i < numX; ++i) { - map[index++] = offset++; - map[index++] = 0; // 0-based local face id - } - offset+= numX * (numY-1); - } - break; - - case PY: - offset = myStartZ * numX * numY + numX * (numY-1) +1; - for (size_t k = 0; k < myNumZ; ++k) { - for (size_t i = 0; i < numX; ++i) { - map[index++] = offset++; - map[index++] = 2; // 0-based local face id - } - offset+= numX * (numY-1); - } - break; - - case MZ: - if (myProcessor == 0) { - offset = 1; - for (size_t i=0; i < numY; i++) { - for (size_t j=0; j < numX; j++) { - map[index++] = offset++; - map[index++] = 4; - } - } - } - break; - - case PZ: - if (myProcessor == processorCount-1) { - offset = (numZ-1)*numX*numY + 1; - for (size_t i=0, k=0; i < numY; i++) { - for (size_t j=0; j < numX; j++, k++) { - map[index++] = offset++; - map[index++] = 5; - } - } - } - break; - } - } - - void GeneratedMesh::coordinates(std::vector &coord) const - { - /* create global coordinates */ - size_t count = node_count_proc(); - coord.resize(count * 3); - - size_t k = 0; - for (size_t m=myStartZ; m < myStartZ+myNumZ+1; m++) { - for (size_t i=0; i < numY+1; i++) { - for (size_t j=0; j < numX+1; j++) { - coord[k++] = sclX * static_cast(j) + offX; - coord[k++] = sclY * static_cast(i) + offY; - coord[k++] = sclZ * static_cast(m) + offZ; - } - } - } - - if (doRotation) { - for (size_t i=0; i < count*3; i+=3) { - double xn = coord[i+0]; - double yn = coord[i+1]; - double zn = coord[i+2]; - coord[i+0] = xn * rotmat[0][0] + yn * rotmat[1][0] + zn * rotmat[2][0]; - coord[i+1] = xn * rotmat[0][1] + yn * rotmat[1][1] + zn * rotmat[2][1]; - coord[i+2] = xn * rotmat[0][2] + yn * rotmat[1][2] + zn * rotmat[2][2]; - } - } - } - - void GeneratedMesh::coordinates(std::vector &x, - std::vector &y, - std::vector &z) const - { - /* create global coordinates */ - size_t count = node_count_proc(); - x.resize(count); - y.resize(count); - z.resize(count); - - size_t k = 0; - for (size_t m=myStartZ; m < myStartZ+myNumZ+1; m++) { - for (size_t i=0; i < numY+1; i++) { - for (size_t j=0; j < numX+1; j++) { - x[k] = sclX * static_cast(j) + offX; - y[k] = sclY * static_cast(i) + offY; - z[k] = sclZ * static_cast(m) + offZ; - ++k; - } - } - } - if (doRotation) { - for (size_t i=0; i < count; i++) { - double xn = x[i]; - double yn = y[i]; - double zn = z[i]; - x[i] = xn * rotmat[0][0] + yn * rotmat[1][0] + zn * rotmat[2][0]; - y[i] = xn * rotmat[0][1] + yn * rotmat[1][1] + zn * rotmat[2][1]; - z[i] = xn * rotmat[0][2] + yn * rotmat[1][2] + zn * rotmat[2][2]; - } - } - } - - void GeneratedMesh::connectivity(size_t block_number, std::vector &connect) const - { - assert(block_number <= block_count()); - - size_t xp1yp1 = (numX+1) * (numY+1); - - /* build connectivity array (node list) for mesh */ - if (block_number == 1) { // HEX Element Block - connect.resize(element_count_proc(block_number)*8); - - size_t cnt = 0; - for (size_t m=myStartZ; m < myNumZ+myStartZ; m++) { - for (size_t i=0, k=0; i < numY; i++) { - for (size_t j=0; j < numX; j++, k++) { - size_t base = (m*xp1yp1) + k + i + 1; - ; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base+1); - connect[cnt++] = static_cast(base+numX+2); - connect[cnt++] = static_cast(base+numX+1); - - connect[cnt++] = static_cast(xp1yp1 + base); - connect[cnt++] = static_cast(xp1yp1 + base+1); - connect[cnt++] = static_cast(xp1yp1 + base+numX+2); - connect[cnt++] = static_cast(xp1yp1 + base+numX+1); - } - } - } - } else { // Shell blocks.... - ShellLocation loc = shellBlocks[block_number-2]; - connect.resize(element_count_proc(block_number)*4); - - size_t cnt = 0; - switch (loc) { - case MX: // Minumum X Face - for (size_t i=0; i < myNumZ; i++) { - size_t layer_off = i * xp1yp1; - for (size_t j=0; j < numY; j++) { - size_t base = layer_off + j * (numX+1) + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base + xp1yp1); - connect[cnt++] = static_cast(base + xp1yp1 + (numX+1)); - connect[cnt++] = static_cast(base + (numX+1)); - } - } - break; - case PX: // Maximum X Face - for (size_t i=0; i < myNumZ; i++) { - size_t layer_off = i * xp1yp1; - for (size_t j=0; j < numY; j++) { - size_t base = layer_off + j * (numX+1) + numX + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base + (numX+1)); - connect[cnt++] = static_cast(base + xp1yp1 + (numX+1)); - connect[cnt++] = static_cast(base + xp1yp1); - } - } - break; - case MY: // Minumum Y Face - for (size_t i=0; i < myNumZ; i++) { - size_t layer_off = i * xp1yp1; - for (size_t j=0; j < numX; j++) { - size_t base = layer_off + j + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base + 1); - connect[cnt++] = static_cast(base + xp1yp1 + 1); - connect[cnt++] = static_cast(base + xp1yp1); - } - } - break; - case PY: // Maximum Y Face - for (size_t i=0; i < myNumZ; i++) { - size_t layer_off = i * xp1yp1; - for (size_t j=0; j < numX; j++) { - size_t base = layer_off + (numX+1)*(numY) + j + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base + xp1yp1); - connect[cnt++] = static_cast(base + xp1yp1 + 1); - connect[cnt++] = static_cast(base + 1); - } - } - break; - case MZ: // Minumum Z Face - if (myProcessor == 0) { - for (size_t i=0, k=0; i < numY; i++) { - for (size_t j=0; j < numX; j++, k++) { - size_t base = i + k + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base+numX+1); - connect[cnt++] = static_cast(base+numX+2); - connect[cnt++] = static_cast(base+1); - } - } - } - break; - case PZ: // Maximum Z Face - if (myProcessor == processorCount-1) { - for (size_t i=0, k=0; i < numY; i++) { - for (size_t j=0; j < numX; j++, k++) { - size_t base = xp1yp1 * (numZ - myStartZ) + k + i + 1 + myStartZ * xp1yp1; - connect[cnt++] = static_cast(base); - connect[cnt++] = static_cast(base+1); - connect[cnt++] = static_cast(base+numX+2); - connect[cnt++] = static_cast(base+numX+1); - } - } - } - break; - } - assert(cnt == 4 * element_count_proc(block_number)); - } - return; - } - - void GeneratedMesh::nodeset_nodes(size_t id, std::vector &nodes) const - { - // id is position in nodeset list + 1 - assert(id > 0 && id <= nodesets.size()); - ShellLocation loc = nodesets[id-1]; - nodes.resize(nodeset_node_count_proc(id)); - - size_t xp1yp1 = (numX+1) * (numY+1); - size_t k = 0; - - switch (loc) { - case MX: // Minumum X Face - for (size_t i=0; i < myNumZ+1; i++) { - size_t layer_off = myStartZ * xp1yp1 + i * xp1yp1; - for (size_t j=0; j < numY+1; j++) { - nodes[k++] = layer_off + j * (numX+1) + 1; - } - } - break; - case PX: // Maximum X Face - for (size_t i=0; i < myNumZ+1; i++) { - size_t layer_off = myStartZ * xp1yp1 + i * xp1yp1; - for (size_t j=0; j < numY+1; j++) { - nodes[k++] = layer_off + j * (numX+1) + numX + 1; - } - } - break; - case MY: // Minumum Y Face - for (size_t i=0; i < myNumZ+1; i++) { - size_t layer_off = myStartZ * xp1yp1 + i * xp1yp1; - for (size_t j=0; j < numX+1; j++) { - nodes[k++] = layer_off + j + 1; - } - } - break; - case PY: // Maximum Y Face - for (size_t i=0; i < myNumZ+1; i++) { - size_t layer_off = myStartZ * xp1yp1 + i * xp1yp1; - for (size_t j=0; j < numX+1; j++) { - nodes[k++] = layer_off + (numX+1)*(numY) + j + 1; - } - } - break; - case MZ: // Minumum Z Face - if (myProcessor == 0) { - for (size_t i=0; i < (numY+1) * (numX+1); i++) { - nodes[i] = i+1; - } - } - break; - case PZ: // Maximum Z Face - if (myProcessor == processorCount-1) { - size_t offset = (numY+1) * (numX+1) * numZ; - for (size_t i=0; i < (numY+1) * (numX+1); i++) { - nodes[i] = offset + i+1; - } - } - break; - } - } - - void GeneratedMesh::sideset_elem_sides(size_t id, std::vector &elem_sides) const - { - // id is position in sideset list + 1 - assert(id > 0 && id <= sidesets.size()); - ShellLocation loc = sidesets[id-1]; - - // If there is a shell block on this face, then the sideset is - // applied to the shell block; if not, it is applied to the - // underlying hex elements. - bool underlying_shell = false; - size_t shell_block = 0; - for (size_t i = 0; i < shellBlocks.size(); i++) { - if (shellBlocks[i] == loc) { - underlying_shell = true; - shell_block = i+2; - break; - } - } - - if (underlying_shell) { - // Get ids of shell elements at this location... - element_map(shell_block, elem_sides); - - // Insert face_ordinal in between each entry in elem_sides... - // Face will be 0 for all shells... - elem_sides.resize(2*sideset_side_count_proc(id)); - int face_ordinal = 0; - int i = 2* (int)sideset_side_count_proc(id) - 1; - int j = (int)sideset_side_count_proc(id) - 1; - while (i >= 0) { - elem_sides[i--] = face_ordinal; - elem_sides[i--] = elem_sides[j--]; - } - } else { - element_surface_map(loc, elem_sides); - } - } - - void GeneratedMesh::set_rotation(const std::string &axis, double angle_degrees) - { - // PI / 180. Used in converting angle in degrees to radians - static double degang = std::atan2(0.0, -1.0) / 180.0; - - doRotation = true; - - int n1 = -1; - int n2 = -1; - int n3 = -1; - - if (axis == "x" || axis == "X") { - n1 = 1; n2 = 2; n3 = 0; - } else if (axis == "y" || axis == "Y") { - n1 = 2; n2 = 0; n3 = 1; - } else if (axis == "z" || axis == "Z") { - n1 = 0; n2 = 1; n3 = 2; - } else { - std::cerr << "\nInvalid axis specification '" << axis << "'. Valid options are 'x', 'y', or 'z'\n"; - return; - } - - double ang = angle_degrees * degang; // Convert angle in degrees to radians - double cosang = std::cos(ang); - double sinang = std::sin(ang); - - assert(n1 >= 0 && n2 >= 0 && n3 >= 0); - double by[3][3]; - by[n1][n1] = cosang; - by[n2][n1] = -sinang; - by[n1][n3] = 0.0; - by[n1][n2] = sinang; - by[n2][n2] = cosang; - by[n2][n3] = 0.0; - by[n3][n1] = 0.0; - by[n3][n2] = 0.0; - by[n3][n3] = 1.0; - - double res[3][3]; - for (size_t i=0; i < 3; i++) { - res[i][0] = rotmat[i][0]*by[0][0] + rotmat[i][1]*by[1][0] + rotmat[i][2]*by[2][0]; - res[i][1] = rotmat[i][0]*by[0][1] + rotmat[i][1]*by[1][1] + rotmat[i][2]*by[2][1]; - res[i][2] = rotmat[i][0]*by[0][2] + rotmat[i][1]*by[1][2] + rotmat[i][2]*by[2][2]; - } - -#if 1 - std::memcpy(rotmat, res, 9*sizeof(double)); -#else - for (int i=0; i < 3; i++) { - for (int j=0; j < 3; j++) { - rotmat[i][j] = res[i][j]; - } - } -#endif - } - } - } -} - -#if defined(DEBUG) -#include - std::string ToString(size_t t) { - std::ostringstream os; - os << t; - return os.str(); - } - -#include - - int main() { - int num_processors = 8; - for (int proc = 0; proc < num_processors; proc++) { - - stk_classic::GeneratedMesh mesh(100, 125, 10*num_processors, num_processors, proc); - - std::cerr << "Node Count (total) = " << mesh.node_count() << "\n"; - std::cerr << "Node Count (proc) = " << mesh.node_count_proc() << "\n"; - std::cerr << "Element Count (total) = " << mesh.element_count() << "\n"; - std::cerr << "Element Count (proc) = " << mesh.element_count_proc() << "\n"; - std::cerr << "Block Count = " << mesh.block_count() << "\n"; - - int CPU_word_size = 8; /* sizeof(float) */ - int IO_word_size = 8; /* (4 bytes) */ - std::string name = "test-scale.e"; - if (num_processors > 1) { - name += "." + ToString(num_processors) + "." + ToString(proc); - } - int exoid = ex_create (name.c_str(), EX_CLOBBER, &CPU_word_size, &IO_word_size); - - int num_nodes = mesh.node_count_proc(); - int num_elems = mesh.element_count_proc(); - int num_elem_blk = mesh.block_count(); - int error = ex_put_init (exoid, "title", 3, num_nodes, num_elems, - num_elem_blk, 0, 0); - - if (num_processors > 1) { - std::vector nodes; - std::vector procs; - mesh.node_communication_map(nodes, procs); - - int node_map_ids[1] = {1}; - int node_map_node_cnts[1] = {procs.size()}; - ex_put_init_info(exoid, num_processors, 1, "p"); - ex_put_loadbal_param(exoid, 0, 0, 0, 0, 0, 1, 0, proc); - ex_put_cmap_params(exoid, node_map_ids, node_map_node_cnts, 0, 0, proc); - ex_put_node_cmap(exoid, 1, &nodes[0], &procs[0], proc); - } - - for (int i=1; i < mesh.block_count(); i++) { - std::cerr << "Block " << i+1 << " has " << mesh.element_count_proc(i+1) << " " - << mesh.topology_type(i+1).first <<" elements\n"; - - std::string btype = mesh.topology_type(i+1).first; - error = ex_put_elem_block(exoid, i+1, btype.c_str(), - mesh.element_count_proc(i+1), - mesh.topology_type(i+1).second, 0); - } - { - std::cerr << "Block " << 1 << " has " << mesh.element_count_proc(1) << " " - << mesh.topology_type(1).first <<" elements\n"; - - std::string btype = mesh.topology_type(1).first; - error = ex_put_elem_block(exoid, 1, btype.c_str(), - mesh.element_count_proc(1), - mesh.topology_type(1).second, 0); - } - - if (num_processors > 1) { - std::vector map; - mesh.node_map(map); - ex_put_id_map(exoid, EX_NODE_MAP, &map[0]); - - mesh.element_map(map); - ex_put_id_map(exoid, EX_ELEM_MAP, &map[0]); - } - - std::cerr << "Outputting connectivity...\n"; - for (int i=1; i < mesh.block_count(); i++) { - if (mesh.element_count_proc(i+1) > 0) { - std::vector connectivity; - mesh.connectivity(i+1, connectivity); - ex_put_elem_conn(exoid, i+1, &connectivity[0]); - } - } - { - std::vector connectivity; - mesh.connectivity(1, connectivity); - ex_put_elem_conn(exoid, 1, &connectivity[0]); - } - - { - std::vector x; - std::vector y; - std::vector z; - mesh.coordinates(x, y, z); - error = ex_put_coord (exoid, &x[0], &y[0], &z[0]); - } - - ex_close(exoid); - } - } -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.hpp b/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.hpp deleted file mode 100644 index 84d0cce9a0fc..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/GeneratedMesh.hpp +++ /dev/null @@ -1,435 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_IO_UTIL_GENERATEDMESH_HPP -#define STK_IO_UTIL_GENERATEDMESH_HPP -#include -#include - -namespace stk_classic { - namespace io { - namespace util { - class GeneratedMesh - { - public: - enum ShellLocation {MX = 0, PX = 1, - MY = 2, PY = 3, - MZ = 4, PZ = 5}; - - /** - Generate a cube mesh of size 'num_x' by 'num_y' by 'num_z' elements. - By default, the mesh is generated on a single processor. If 'proc_count' is - greater than 1, then the mesh will be distributed over 'proc_count' processors - and this process will get the portion of the mesh for 'my_proc'. - The mesh will be decomposed along the 'Z' axis so 'num_z' must be greater than - or equal to 'proc_count' and for even distribution of the hexes 'num_z' mod 'proc_count' - should be zero. - - The mesh can optionally include shell elements along each face of the cube mesh. - These are specified via the 'add_shell_block' function. - - The mesh can optionally include nodesets/sidesets along each - face of the cube mesh. These are specified via the - 'add_nodesets' and 'add_sidesets' functions. - - If the 'parameters' string constructor is used, the string - is parsed to determine the intervals in each direction and, - optionally, additional information. The form of the string - is "IxJxK" where I, J, and K are the number of intervals - in the X, Y, and Z directions respectively and the "x" are - literal 'x' characters. For example, the constructor - GeneratedMesh("10x12x14") will create the same mesh as - GeneratedMesh(10,12,14) - - Additional valid options are: - - help -- no argument, shows valid options - - show -- no argument, prints out a summary of the - GeneratedMesh() parameters. The output will look similar - to: - \code - "10x12x8|shell:xX|bbox:-10,-10,-10,10,10,10|nodeset:xyz|sideset:XYZ|show" - - Mesh Parameters: - Intervals: 10 by 12 by 8 - X = 2 * (0..10) + -10 Range: -10 <= X <= 10 - Y = 1.66667 * (0..12) + -10 Range: -10 <= Y <= 10 - Z = 2.5 * (0..8) + -10 Range: -10 <= Z <= 10 - Node Count (total) = 1287 - Element Count (total) = 1152 - Block Count = 3 - Nodeset Count = 3 - Sideset Count = 3 - \endcode - - - shell -- argument = xXyYzZ which specifies whether there is a shell - block at that location. 'x' is minimum x face, 'X' is maximum x face, - similarly for y and z. Note that the argument string is a single - multicharacter string. You can add multiple shell blocks to a face, - for example, shell:xxx would add three layered shell blocks on the - minimum x face. An error is output if a non xXyYzZ character is - found, but execution continues. - - - nodeset -- argument = xXyYzZ which specifies whether there is - a nodeset at that location. 'x' is minimum x face, 'X' is - maximum x face, similarly for y and z. Note that the argument - string is a single multicharacter string. You can add multiple - nodesets to a face, for example, nodeset:xxx would add three - nodesets on the minimum x face. An error is output if a non - xXyYzZ character is found, but execution continues. - - - sideset -- argument = xXyYzZ which specifies whether there is - a sideset at that location. 'x' is minimum x face, 'X' is - maximum x face, similarly for y and z. Note that the argument - string is a single multicharacter string. You can add multiple - sidesets to a face, for example, sideset:xxx would add three - sidesets on the minimum x face. An error is output if a non - xXyYzZ character is found, but execution continues. If there - is a shell block specified on that face, then the sideset will - be on the shell elements; else the sideset will be on the hex - elements. - - - zdecomp -- argument = n0, n1, n2, ..., n#proc-1 which are the number - of intervals in the z direction for each processor in a pallel run. - If this option is specified, then the total number of intervals in the - z direction is the sum of the n0, n1, ... An interval count must be - specified for each processor. If this option is not specified, then - the number of intervals on each processor in the z direction is - numZ/numProc with the extras added to the lower numbered processors. - - - scale -- argument = xs, ys, zs which are the scale factors in the x, - y, and z directions. All three must be specified if this option is - present. - - - offset -- argument = xoff, yoff, zoff which are the offsets in the - x, y, and z directions. All three must be specified if this option - is present. - - - bbox -- argument = xmin, ymin, zmin, xmax, ymax, zmax - which specify the lower left and upper right corners of - the bounding box for the generated mesh. This will - calculate the scale and offset which will fit the mesh in - the specified box. All calculations are based on the currently - active interval settings. If scale or offset or zdecomp - specified later in the option list, you may not get the - desired bounding box. - - - rotate -- argument = axis,angle,axis,angle,... - where axis is 'x', 'y', or 'z' and angle is the rotation angle in - degrees. Multiple rotations are cumulative. The composite rotation - matrix is applied at the time the coordinates are retrieved after - scaling and offset are applied. - - The unrotated coordinate of a node at grid location i,j,k is: - \code - x = x_scale * i + x_off, - y = z_scale * j + y_off, - z = z_scale * k + z_off, - \endcode - - The extent of the unrotated mesh will be: - \code - x_off <= x <= x_scale * numX + x_off - y_off <= y <= y_scale * numY + y_off - z_off <= z <= z_scale * numZ + z_off - \endcode - - If an unrecognized option is specified, an error message will be - output and execution will continue. - - An example of valid input is: - \code - "10x20x40|scale:1,0.5,0.25|offset:-5,-5,-5|shell:xX" - \endcode - - This would create a mesh with 10 intervals in x, 20 in y, 40 in z - The mesh would be centered on 0,0,0 with a range of 10 in each - direction. There would be a shell layer on the min and max - x faces. - - NOTE: All options are processed in the order they appear in - the parameters string (except rotate which is applied at the - time the coordinates are generated/retrieved) - */ - explicit GeneratedMesh(const std::string ¶meters, int proc_count = 1, int my_proc = 0); - GeneratedMesh(int num_x, int num_y, int num_z, int proc_count = 1, int my_proc = 0); - ~GeneratedMesh(); - - /** - * Add a shell block along the specified face of the hex mesh. - * The shell blocks will maintain the order of definition. The - * first shell block defined will be block 2; the hex block has id - * 1. The loc options are: - * - MX = add shell layer on the face with minimum X - * - PX = add shell layer on the face with maximum X - * - MY = add shell layer on the face with minimum Y - * - PY = add shell layer on the face with maximum Y - * - MZ = add shell layer on the face with minimum Z - * - PZ = add shell layer on the face with maximum Z - * - */ - size_t add_shell_block(ShellLocation loc); - - /** - * Add a nodeset along the specified face of the hex mesh. - * The nodesets will maintain the order of definition. The - * first nodeset defined will be nodeset 1. - * The loc options are: - * - MX = add nodeset on the face with minimum X - * - PX = add nodeset on the face with maximum X - * - MY = add nodeset on the face with minimum Y - * - PY = add nodeset on the face with maximum Y - * - MZ = add nodeset on the face with minimum Z - * - PZ = add nodeset on the face with maximum Z - * - */ - size_t add_nodeset(ShellLocation loc); - - /** - * Add a sideset along the specified face of the hex mesh. - * The sidesets will maintain the order of definition. The - * first sideset defined will be sideset 1. If there is a shell - * block specified on that face, then the sideset will be on the - * shell elements; otherwise the sideset will be on the hex - * elements. - * The loc options are: - * - MX = add sideset on the face with minimum X - * - PX = add sideset on the face with maximum X - * - MY = add sideset on the face with minimum Y - * - PY = add sideset on the face with maximum Y - * - MZ = add sideset on the face with minimum Z - * - PZ = add sideset on the face with maximum Z - * - */ - size_t add_sideset(ShellLocation loc); - - /** - * Specify the coordinate scaling and offset in all three - * spatial dimensions. - * - * node location of node at (i,j,k) is - * \code - * X = scale X * i + offset X - * Y = scale Y * i + offset Y - * Z = scale Z * i + offset Z - * \endcode - * - * WARNING: Should be called before retrieving node - * coordinates. - */ - void set_scale(double scl_x, double scl_y, double scl_z); - void set_offset(double off_x, double off_y, double off_z); - void set_bbox(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax); - - /** - * Set rotation. Multiple calls are cumulative. - * Rotate 'angle_degrees' degrees about the axis 'axis' - * Center of rotation is about the origin and operates - * on the scaled/offset coordinates of the mesh. - */ - void set_rotation(const std::string &axis, double angle_degrees); - - /** - * Return number of nodes in the entire model. - */ - size_t node_count() const; - - /** - * Return number of nodes on this processor. - */ - size_t node_count_proc() const; - - /** - * Return number of element blocks in the entire model. - */ - size_t block_count() const; - - /** - * Return number of nodesets in the entire model. - */ - size_t nodeset_count() const; - - /** - * Return number of nodeset nodes on nodeset 'id' - */ - size_t nodeset_node_count(size_t id) const; - - /** - * Return number of nodeset nodes on nodeset 'id' on the current processor - */ - size_t nodeset_node_count_proc(size_t id) const; - - /** - * Return number of sidesets in the entire model. - */ - size_t sideset_count() const; - - /** - * Return number of sideset 'sides' on sideset 'id' - */ - size_t sideset_side_count(size_t id) const; - - /** - * Return number of sideset 'sides' on sideset 'id' on the current - * processor. - */ - size_t sideset_side_count_proc(size_t id) const; - - /** - * Return number of elements in all element blocks in the model. - */ - size_t element_count() const; - - /** - * Return number of shell elements in all element blocks in the model. - */ - size_t shell_element_count(ShellLocation) const; - - /** - * Return number of elements in all element blocks on this processor. - */ - size_t element_count_proc() const; - - /** - * Return number of shell elements in all element blocks on this processor. - */ - size_t shell_element_count_proc(ShellLocation) const; - - /** - * Return number of elements in the element block with id - * 'block_number'. The 'block_number' ranges from '1' to - * 'block_count()'. - */ - size_t element_count(size_t block_number) const; - - /** - * Return number of elements on this processor in the element - * block with id 'block_number'. The 'block_number' ranges from - * '1' to 'block_count()'. - */ - size_t element_count_proc(size_t block_number) const; - - /** - * Returns pair containing "topology type string" and "number of - * nodes / element". The topology type string will be "hex8" for - * the hex element block and "shell4" for the shell element blocks. - */ - std::pair topology_type(size_t block_number) const; - - size_t communication_node_count_proc() const; - void node_communication_map(std::vector &map, std::vector &proc); - - /** - * Fill the passed in 'map' argument with the node map - * "map[local_position] = global_id" for the nodes on this - * processor. - */ - void node_map(std::vector &map); - - /** - * Fill the passed in 'map' argument with the element map - * "map[local_position] = global_id" for the elements on this - * processor in block "block_number". - */ - void element_map(size_t block_number, std::vector &map) const; - - /** - * Fill the passed in 'map' argument with the element map - * "map[local_position] = global_id" for all elements on this - * processor - */ - void element_map(std::vector &map) const; - - /** - * Fill the passed in 'map' argument with the element map pair - * "map[local_position] = element global_id" and - * "map[local_position+1] = element local face id (0-based)" for - * all elements on the current processor having a face on the - * surface defined by ShellLocation. - */ - void element_surface_map(ShellLocation loc, std::vector &map) const; - - /** - * Return the connectivity for the elements on this processor in - * the block with id 'block_number'. If the elements in this block - * have 'npe' nodes per element, then the first 'npe' entries in - * the 'conn' vector will be the nodal connectivity for the first - * element; the next 'npe' entries are the nodal connectivity for - * the second element. The 'connect' vector will be resized to the - * size required to contain the nodal connectivity for the - * specified block; all information in 'connect' will be overwritten. - */ - void connectivity(size_t block_number, std::vector &connect) const; - - /** - * Return the coordinates for all nodes on this processor. The - * first 3 entries in the 'coord' vector are the x, y, and z - * coordinates of the first node, etc. The 'coord' vector will be - * resized to the size required to contain the nodal coordinates; - * all information in 'coord' will be overwritten. - */ - void coordinates(std::vector &coord) const; - - /** - * Return the coordinates for all nodes on this processor in - * separate vectors. The vectors will be resized to the size - * required to contain the nodal coordinates; all information in - * the vectors will be overwritten. - */ - void coordinates(std::vector &x, - std::vector &y, - std::vector &z) const; - - /** - * Return the list of nodes in nodeset 'id' on this processor. - * The 'nodes' vector will be resized to the size required to - * contain the node list. The ids are global ids. - */ - void nodeset_nodes(size_t nset_id, std::vector &nodes) const; - - /** - * Return the list of the face/ordinal pairs - * "elem_sides[local_position] = element global_id" and - * "elem_sides[local_position+1] = element local face id (0-based)" - * for the faces in sideset 'id' on this - * processor. The 'elem_sides' vector will be resized to the size - * required to contain the list. The element ids are global ids, - * the side ordinal is 0-based. - */ - void sideset_elem_sides(size_t nset_id, std::vector &elem_sides) const; - - private: - - GeneratedMesh( const GeneratedMesh & ); - GeneratedMesh & operator = ( const GeneratedMesh & ); - - void parse_options(const std::vector &groups); - void show_parameters() const; - void initialize(); - - std::vector shellBlocks; - std::vector nodesets; - std::vector sidesets; - double rotmat[3][3]; - size_t numX, numY, numZ; - size_t myNumZ, myStartZ; - - size_t processorCount; - size_t myProcessor; - - double offX, offY, offZ; /** Offsets in X, Y, and Z directions */ - double sclX, sclY, sclZ; /** Scale in X, Y, and Z directions - * location of node at (i,j,k) - * position is (sclX*i+offX, - * sclY*i+offY, sclZ*i+offZ) */ - bool doRotation; - }; - } - } -} -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/stk_utest_macros.hpp b/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/stk_utest_macros.hpp deleted file mode 100644 index 83cb71d2653c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/unit_test_support/stk_utest_macros.hpp +++ /dev/null @@ -1,201 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_mesh_unit_tests_stk_utest_macros_hpp -#define stk_mesh_unit_tests_stk_utest_macros_hpp - -#ifndef STK_BUILT_IN_SIERRA -#include -#else -#define HAVE_MPI -#endif -#if defined(HAVE_MPI) -#include -#endif -// -//This file is kind of like a unit-test abstraction layer: -//A series of STKUNIT_* macros are defined in terms of either -//gtest macros, or trilinos/teuchos unit-test macros, depending -//on whether stk_mesh is being built as a sierra product or Trilinos package. -// -#ifdef HAVE_MPI -#define RUN_TEST_REDUCE(error) \ - int tmp_error = error; \ - int reduce_result = MPI_Allreduce ( &tmp_error, &error, 1 /*count*/, \ - MPI_INT, MPI_MAX, MPI_COMM_WORLD ); \ - if (reduce_result != MPI_SUCCESS) { \ - std::cerr << "MPI_Allreduce FAILED" << std::endl; \ - error = true; \ - } \ - if ( !error ) \ - std::cout << "STKUNIT_ALL_PASS" << std::endl; -#else -#define RUN_TEST_REDUCE(error) \ - if (error != 0) { \ - std::cerr << "Test FAILED" << std::endl; \ - error = true; \ - } \ - if ( !error ) \ - std::cout << "STKUNIT_ALL_PASS" << std::endl; -#endif - - -#ifdef HAVE_STK_Trilinos -//If we're building as a Trilinos package, then we'll use the Teuchos unit-test macros. - -#include -#include -#include - -#define STKUNIT_UNIT_TEST(testclass,testmethod) TEUCHOS_UNIT_TEST(testclass,testmethod) - -#define STKUNIT_ASSERT(A) \ - {bool success = true; TEUCHOS_TEST_ASSERT(A,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_EQUAL(A,B) \ - {bool success = true; TEUCHOS_TEST_EQUALITY(B,A,std::cout,success); if (!success) throw 1;} -#define STKUNIT_EXPECT_EQUAL(A,B) STKUNIT_ASSERT_EQUAL(A,B) -#define STKUNIT_ASSERT_EQ(A,B) STKUNIT_ASSERT_EQUAL(A,B) -#define STKUNIT_ASSERT_NE(A,B) \ - {bool success = true; TEUCHOS_TEST_INEQUALITY(B,A,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_LE(A,B) \ - {bool success = true; TEUCHOS_TEST_COMPARE(A,<=,B,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_LT(A,B) \ - {bool success = true; TEUCHOS_TEST_COMPARE(A,<,B,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_GE(A,B) \ - {bool success = true; TEUCHOS_TEST_COMPARE(A,>=,B,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_GT(A,B) \ - {bool success = true; TEUCHOS_TEST_COMPARE(A,>,B,std::cout,success); if (!success) throw 1;} -#define STKUNIT_EXPECT_EQ(A,B) STKUNIT_ASSERT_EQ(A,B) -#define STKUNIT_EXPECT_NE(A,B) STKUNIT_ASSERT_NE(A,B) -#define STKUNIT_EXPECT_LE(A,B) STKUNIT_ASSERT_LE(A,B) -#define STKUNIT_EXPECT_LT(A,B) STKUNIT_ASSERT_LT(A,B) -#define STKUNIT_EXPECT_GE(A,B) STKUNIT_ASSERT_GE(A,B) -#define STKUNIT_EXPECT_GT(A,B) STKUNIT_ASSERT_GT(A,B) -#define STKUNIT_ASSERT_STREQ(A,B) STKUNIT_ASSERT_EQ(A,B) -#define STKUNIT_ASSERT_STRNE(A,B) STKUNIT_ASSERT_NE(A,B) -#define STKUNIT_ASSERT_STRCASEEQ(A,B) STKUNIT_ASSERT_STREQ(toupper(A),toupper(B)) -#define STKUNIT_ASSERT_STRCASENE(A,B) STKUNIT_ASSERT_STRNE(toupper(A),toupper(B)) -#define STKUNIT_EXPECT_STREQ(A,B) STKUNIT_EXPECT_EQ(A,B) -#define STKUNIT_EXPECT_STRNE(A,B) STKUNIT_EXPECT_NE(A,B) -#define STKUNIT_EXPECT_STRCASEEQ(A,B) STKUNIT_EXPECT_STREQ(toupper(A),toupper(B)) -#define STKUNIT_EXPECT_STRCASENE(A,B) STKUNIT_EXPECT_STRNE(toupper(A),toupper(B)) -#define STKUNIT_ASSERT_THROW(A,B) \ - {bool success = true; TEUCHOS_TEST_THROW(A,B,std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_NO_THROW(A) \ - {TEUCHOS_TEST_NOTHROW(A,out,success)} -#define STKUNIT_EXPECT_TRUE(A) \ - {bool success = true; TEUCHOS_TEST_ASSERT(A,std::cout,success); if (!success) throw 1;} -#define STKUNIT_EXPECT_FALSE(A) \ - {bool success = true; TEUCHOS_TEST_ASSERT(!(A),std::cout,success); if (!success) throw 1;} -#define STKUNIT_ASSERT_TRUE(A) STKUNIT_EXPECT_TRUE(A) -#define STKUNIT_ASSERT_FALSE(A) STKUNIT_EXPECT_FALSE(A) -#define STKUNIT_ASSERT_DOUBLE_EQ(A,B) \ - {bool success = true; TEUCHOS_TEST_EQUALITY(B,A,std::cout,success); if (!success) throw 1;} -#define STKUNIT_EXPECT_DOUBLE_EQ(A,B) STKUNIT_ASSERT_DOUBLE_EQ(A,B) -#define STKUNIT_ASSERT_NEAR(A,B, tol) \ - {bool success = true; TEUCHOS_TEST_FLOATING_EQUALITY(B,A,tol,std::cout,success); if (!success) throw 1;} -#define STKUNIT_EXPECT_NEAR(A,B, tol) STKUNIT_ASSERT_NEAR(A, B, tol) - -#define STKUNIT_MAIN(argc,argv) \ -int* STKUNIT_ARGC; \ -char** STKUNIT_ARGV; \ -int main(int argc,char**argv) {\ -STKUNIT_ARGC = &argc; \ -STKUNIT_ARGV = argv; \ - Teuchos::GlobalMPISession mpiSession(&argc, &argv); \ - int error = Teuchos::UnitTestRepository::runUnitTestsFromMain(argc, argv); \ - RUN_TEST_REDUCE(error); \ - return error; \ -} - -#else // HAVE_STK_GTEST - -#include - -#define STKUNIT_ASSERT(A) ASSERT_TRUE(A) -#define STKUNIT_ASSERT_EQUAL(A,B) ASSERT_EQ(A,B) -#define STKUNIT_EXPECT_EQUAL(A,B) EXPECT_EQ(A,B) -#define STKUNIT_ASSERT_EQ(A,B) ASSERT_EQ(A,B) -#define STKUNIT_ASSERT_NE(A,B) ASSERT_NE(A,B) -#define STKUNIT_ASSERT_LE(A,B) ASSERT_LE(A,B) -#define STKUNIT_ASSERT_LT(A,B) ASSERT_LT(A,B) -#define STKUNIT_ASSERT_GE(A,B) ASSERT_GE(A,B) -#define STKUNIT_ASSERT_GT(A,B) ASSERT_GT(A,B) -#define STKUNIT_EXPECT_EQ(A,B) EXPECT_EQ(A,B) -#define STKUNIT_EXPECT_NE(A,B) EXPECT_NE(A,B) -#define STKUNIT_EXPECT_LE(A,B) EXPECT_LE(A,B) -#define STKUNIT_EXPECT_LT(A,B) EXPECT_LT(A,B) -#define STKUNIT_EXPECT_GE(A,B) EXPECT_GE(A,B) -#define STKUNIT_EXPECT_GT(A,B) EXPECT_GT(A,B) -#define STKUNIT_ASSERT_STREQ(A,B) ASSERT_STREQ(A,B) -#define STKUNIT_ASSERT_STRNE(A,B) ASSERT_STRNE(A,B) -#define STKUNIT_ASSERT_STRCASEEQ(A,B) ASSERT_STRCASEEQ(A,B) -#define STKUNIT_ASSERT_STRCASENE(A,B) ASSERT_STRCASENE(A,B) -#define STKUNIT_EXPECT_STREQ(A,B) EXPECT_STREQ(A,B) -#define STKUNIT_EXPECT_STRNE(A,B) EXPECT_STRNE(A,B) -#define STKUNIT_EXPECT_STRCASEEQ(A,B) EXPECT_STRCASEEQ(A,B) -#define STKUNIT_EXPECT_STRCASENE(A,B) EXPECT_STRCASENE(A,B) -#define STKUNIT_ASSERT_THROW(A,B) ASSERT_THROW(A,B) -#define STKUNIT_ASSERT_NO_THROW(A) ASSERT_NO_THROW(A) -#define STKUNIT_EXPECT_TRUE(A) EXPECT_TRUE(A) -#define STKUNIT_EXPECT_FALSE(A) EXPECT_FALSE(A) -#define STKUNIT_ASSERT_TRUE(A) ASSERT_TRUE(A) -#define STKUNIT_ASSERT_FALSE(A) ASSERT_FALSE(A) -#define STKUNIT_ASSERT_DOUBLE_EQ(A,B) ASSERT_DOUBLE_EQ(A,B) -#define STKUNIT_EXPECT_DOUBLE_EQ(A,B) EXPECT_DOUBLE_EQ(A,B) -#define STKUNIT_ASSERT_NEAR(A,B,tol) ASSERT_NEAR(A,B,tol) -#define STKUNIT_EXPECT_NEAR(A,B,tol) EXPECT_NEAR(A,B,tol) - -#define STKUNIT_UNIT_TEST(testclass,testmethod) TEST(testclass,testmethod) - -#define STKUNIT_MAIN(argc,argv) \ -int* STKUNIT_ARGC; \ -char** STKUNIT_ARGV; \ -int main(int argc, char **argv) { \ - if ( MPI_SUCCESS != MPI_Init( & argc , & argv ) ) { \ - std::cerr << "MPI_Init FAILED" << std::endl ; \ - std::abort(); \ - } \ - STKUNIT_ARGC = &argc; \ - STKUNIT_ARGV = argv; \ - std::cout << "Running main() from gtest_main.cc\n"; \ - testing::InitGoogleTest(&argc, argv); \ - int error = RUN_ALL_TESTS(); \ - RUN_TEST_REDUCE(error); \ - MPI_Finalize(); \ - return error; \ -} - -#define STKUNIT_WITH_TRACING_MAIN(argc, argv) \ -int* STKUNIT_ARGC; \ -char** STKUNIT_ARGV; \ -int main(int argc, char **argv) { \ - use_case::UseCaseEnvironment use_case_environment(&argc, &argv); \ - std::cout << "Running main() from gtest_main.cc\n"; \ - testing::InitGoogleTest(&argc, argv); \ - STKUNIT_ARGC = &argc; \ - STKUNIT_ARGV = argv; \ - int error = RUN_ALL_TESTS(); \ - RUN_TEST_REDUCE(error); \ - return error; \ -} - -#define STKUNIT_WITH_SIERRA_MAIN(argc,argv,prod) \ -int main(int argc, char **argv) { \ - sierra::Env::set_input_file_required(false); \ - testing::InitGoogleTest(&argc, argv); \ - sierra::Env::Startup startup__(&argc, &argv, sierra::prod::get_product_name(), __DATE__ " " __TIME__); \ - int error = RUN_ALL_TESTS(); \ - RUN_TEST_REDUCE(error); \ - return error; \ -} - -#endif // HAVE_STK_Trilinos - -#endif // stk_mesh_unit_tests_stk_utest_macros_hpp - diff --git a/packages/stk/stk_classic/stk_util/stk_util/use_cases/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/use_cases/CMakeLists.txt deleted file mode 100644 index 4585b226e8f0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/use_cases/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -APPEND_SET(HEADERS -UseCaseEnvironment.hpp - ) - -APPEND_SET(SOURCES -UseCaseEnvironment.cpp - ) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_use_cases - DEPLIBS stkclassic_util_diag - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - -#INSTALL(FILES ${HEADERS} DESTINATION -# ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/use_cases/) diff --git a/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.cpp b/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.cpp deleted file mode 100644 index e3d4faed7a03..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include -#include - -#include -#include - -#include - -#include - -namespace { - -namespace bopt = boost::program_options; - -// Parse command line bit masks and produce -h documentation. (Probably moved to Util at some point) -typedef unsigned long OptionMask; - -struct OptionMaskName -{ - OptionMaskName() - : m_name(""), - m_mask(0), - m_description("") - {} - - OptionMaskName(const std::string &name, const OptionMask &mask, const std::string &description = "No description available") - : m_name(name), - m_mask(mask), - m_description(description) - {} - - virtual ~OptionMaskName() - {} - - std::string m_name; - OptionMask m_mask; - std::string m_description; -}; - - -class OptionMaskNameMap: public std::map -{ -public: - void mask(const std::string &name, const OptionMask mask, const std::string &description) { - iterator it = find(name); - if (it == end()) - insert(std::make_pair(name, OptionMaskName(name, mask, description))); - else { - (*it).second.m_mask = mask; - (*it).second.m_description = description; - } - } -}; - -class OptionMaskParser -{ -public: - typedef OptionMask Mask; ///< Mask for this option - -public: - /** - * Creates a new OptionMaskParser instance. - * - */ - OptionMaskParser(const std::string &description) - : m_optionMaskNameMap(), - m_description(description), - m_optionMask(0), - m_status(true) - {} - - virtual ~OptionMaskParser() - {} - - Mask parse(const char *mask) const; - - virtual void parseArg(const std::string &name) const; - - std::string describe() const { - std::ostringstream strout; - strout << m_description << std::endl; - for (OptionMaskNameMap::const_iterator it = m_optionMaskNameMap.begin(); it != m_optionMaskNameMap.end(); ++it) - strout << " " << (*it).first << std::setw(14 - (*it).first.size()) << " " << (*it).second.m_description << std::endl; - return strout.str(); - } - - void mask(const std::string &name, const Mask mask, const std::string &description) { - m_optionMaskNameMap.mask(name, mask, description); - } - -protected: - OptionMaskNameMap m_optionMaskNameMap; ///< Mask name vector - std::string m_description; ///< Help description - mutable OptionMask m_optionMask; ///< Most recently parsed mask - mutable bool m_status; ///< Result of most recent parse -}; - - -OptionMaskParser::Mask -OptionMaskParser::parse( - const char * mask) const -{ - if (mask) { - const std::string mask_string(mask); - - m_status = true; - - std::string::const_iterator it0 = mask_string.begin(); - std::string::const_iterator it1; - std::string::const_iterator it2; - std::string::const_iterator it3; - do { - // Trim preceeding spaces - while (it0 != mask_string.end() && *it0 == ' ') - it0++; - - if (it0 == mask_string.end()) - break; - - for (it1 = it0; it1 != mask_string.end(); ++it1) { - if (*it1 == '(' || *it1 == ':' || *it1 == ',') - break; - } - - // Trim trailing spaces - it2 = it1; - while (it2 != it0 && *(it2 - 1) == ' ') - --it2; - - std::string name(it0, it2); - - // Get argument list - if (*it1 == '(') { - it2 = it1 + 1; - - // Trim preceeding spaces - while (it2 != mask_string.end() && *it2 == ' ') - ++it2; - - int paren_count = 0; - - for (; it1 != mask_string.end(); ++it1) { - if (*it1 == '(') - ++paren_count; - else if (*it1 == ')') { - --paren_count; - if (paren_count == 0) - break; - } - } - it3 = it1; - - // Trim trailing spaces - while (it3 != it2 && *(it3 - 1) == ' ') - --it3; - - // Find next argument start - for (; it1 != mask_string.end(); ++it1) - if (*it1 == ':' || *it1 == ',') - break; - } - else - it2 = it3 = it1; - - const std::string arg(it2, it3); - - parseArg(name); - - it0 = it1 + 1; - } while (it1 != mask_string.end()); - } - - return m_optionMask; -} - - -void -OptionMaskParser::parseArg( - const std::string & name) const -{ - OptionMaskNameMap::const_iterator mask_entry = m_optionMaskNameMap.find(name); - - if (mask_entry != m_optionMaskNameMap.end()) m_optionMask |= (*mask_entry).second.m_mask; - else { - Mask mask_hex = 0; - std::istringstream mask_hex_stream(name.c_str()); - if (mask_hex_stream >> std::resetiosflags(std::ios::basefield) >> mask_hex) - m_optionMask |= mask_hex; - else - m_status = false; - } -} - -// Build output logging description for binding output streams -std::string -build_log_description( - const bopt::variables_map & vm, - const std::string & working_directory, - int parallel_rank, - int parallel_size) -{ - std::ostringstream output_description; - - // On processor 0: - // [outfile=path] [poutfile=path.n.r] [doutfile=path.n.r] out>{-|cout|cerr|outfile}+pout pout>{null|poutfile} dout>{out|doutfile} - - // On processor 1..n: - // [poutfile=path.n.r] [doutfile=path.n.r] out>pout pout>{null|poutfile} dout>{out|doutfile} - - std::string out_path = "-"; - if (vm.count("output-log")) - out_path = vm["output-log"].as(); - if (out_path == "-") - out_path = "cout"; - - std::string out_ostream; - - if (!stk_classic::get_log_ostream(out_path)) - if (out_path.size() && out_path[0] != '/') - out_path = working_directory + out_path; - - if (parallel_rank == 0) { - if (!stk_classic::get_log_ostream(out_path)) { - output_description << "outfile=\"" << out_path << "\""; - out_ostream = "outfile"; - } - else - out_ostream = out_path; - } - else - out_ostream = "null"; - - std::string pout_ostream = "null"; - if (vm.count("pout")) { - std::string pout_path = vm["pout"].as(); - if (pout_path == "-") { - std::ostringstream s; - - if (stk_classic::get_log_ostream(out_path)) - s << working_directory << "sierra.log." << parallel_size << "." << parallel_rank; - else - s << out_path << "." << parallel_size << "." << parallel_rank; - pout_path = s.str(); - } - else if (pout_path.find("/") == std::string::npos && !stk_classic::get_log_ostream(pout_path)) { - std::ostringstream s; - - s << working_directory << pout_path << "." << parallel_size << "." << parallel_rank; - pout_path = s.str(); - } - - if (!stk_classic::get_log_ostream(pout_path)) { - output_description << " poutfile=\"" << pout_path << "\""; - pout_ostream = "poutfile"; - } - else - pout_ostream = pout_path; - } - - std::string dout_ostream; - if (vm.count("dout")) { - std::string dout_path = vm["dout"].as(); - if (!dout_path.empty() && stk_classic::is_registered_ostream(dout_path)) - dout_ostream = dout_path; - else { - std::ostringstream s; - if (dout_path.size() && dout_path[0] != '/') - s << working_directory << dout_path << "." << parallel_size << "." << parallel_rank; - else - s << dout_path << parallel_size << "." << parallel_rank; - dout_path = s.str(); - output_description << " doutfile=\"" << dout_path << "\""; - dout_ostream = "doutfile"; - } - } - else - dout_ostream = "out"; - - if (parallel_rank == 0) - output_description << " out>" << out_ostream << "+pout"; - else - output_description << " out>pout"; - - output_description << " pout>" << pout_ostream << " dout>" << dout_ostream; - - return output_description.str(); -} - -OptionMaskParser dw_option_mask("use case diagnostic writer"); -OptionMaskParser timer_option_mask("use case timers"); - -void -bootstrap() -{ - /// \todo REFACTOR Put these program_options in a function - /// that can be called without the bootstrapping. - dw_option_mask.mask("search", use_case::LOG_SEARCH, "log search diagnostics"); - dw_option_mask.mask("transfer", use_case::LOG_TRANSFER, "log transfer diagnostics"); - dw_option_mask.mask("timer", use_case::LOG_TIMER, "log timer diagnostics"); - - timer_option_mask.mask("mesh", use_case::TIMER_MESH, "mesh operations timers"); - timer_option_mask.mask("meshio", use_case::TIMER_MESH_IO, "mesh I/O timers"); - timer_option_mask.mask("transfer", use_case::TIMER_TRANSFER, "transfer timers"); - timer_option_mask.mask("search", use_case::TIMER_SEARCH, "search timers"); - - boost::program_options::options_description desc("Use case environment options"); - desc.add_options() - ("help,h", "produce help message") - ("directory,d", boost::program_options::value(), "working directory") - ("output-log,o", boost::program_options::value(), "output log path") - ("pout", boost::program_options::value()->implicit_value("-"), "per-processor log file path") - ("dout", boost::program_options::value()->implicit_value("out"), "diagnostic output stream one of: 'cout', 'cerr', 'out' or a file path") - ("dw", boost::program_options::value(), dw_option_mask.describe().c_str()) - ("timer", boost::program_options::value(), timer_option_mask.describe().c_str()) - ("runtest,r", boost::program_options::value(), "runtest pid file"); - - stk_classic::get_options_description().add(desc); -} - -stk_classic::Bootstrap x(bootstrap); - -} // namespace - -namespace use_case { - -// Output streams -std::ostream & -out() { - static std::ostream s_out(std::cout.rdbuf()); - - return s_out; -} - - -std::ostream & -pout() { - static std::ostream s_pout(std::cout.rdbuf()); - - return s_pout; -} - - -std::ostream & -dout() { - static std::ostream s_dout(std::cout.rdbuf()); - - return s_dout; -} - - -std::ostream & -tout() { - static std::ostream s_tout(std::cout.rdbuf()); - - return s_tout; -} - - -std::ostream & -dwout() { - static stk_classic::indent_streambuf s_dwoutStreambuf(std::cout.rdbuf()); - static std::ostream s_dwout(&s_dwoutStreambuf); - - return s_dwout; -} - - -// Diagnostic writer -stk_classic::diag::Writer & -dw() -{ - static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - - return s_diagWriter; -} - - -// Message reporting -std::ostream & -operator<<( - std::ostream & os, - message_type type) -{ - switch (type & stk_classic::MSG_TYPE_MASK) { - case MSG_WARNING: - os << "Warning"; - break; - case MSG_FATAL: - os << "Fatal error"; - break; - case MSG_INFORMATION: - os << "Information"; - break; - case MSG_EXCEPTION: - os << "Exception"; - break; - case MSG_PARALLEL_EXCEPTION: - os << "Parallel exception"; - break; - } - return os; -} - - -void -report_handler( - const char * message, - int type) -{ - if (type & stk_classic::MSG_DEFERRED) - pout() << "Deferred " << (message_type) type << ": " << message << std::endl; - - else - out() << (message_type) type << ": " << message << std::endl; -} - - -// Timers -stk_classic::diag::TimerSet & -timerSet() -{ - static stk_classic::diag::TimerSet s_timerSet(TIMER_ALL); - - return s_timerSet; -} - - -stk_classic::diag::Timer &timer() { - static stk_classic::diag::Timer s_timer = stk_classic::diag::createRootTimer("Use Cases", timerSet()); - - return s_timer; -} - - -UseCaseEnvironment::UseCaseEnvironment( - int * argc, - char *** argv) - : m_comm(stk_classic::parallel_machine_init(argc, argv)), - m_need_to_finalize(true) -{ - initialize(argc, argv); -} - -UseCaseEnvironment::UseCaseEnvironment( - int * argc, - char *** argv, - stk_classic::ParallelMachine comm) - : m_comm(comm), - m_need_to_finalize(false) -{ - initialize(argc, argv); -} - -void UseCaseEnvironment::initialize(int* argc, char*** argv) -{ - stk_classic::register_log_ostream(std::cout, "cout"); - stk_classic::register_log_ostream(std::cerr, "cerr"); - - stk_classic::register_ostream(out(), "out"); - stk_classic::register_ostream(pout(), "pout"); - stk_classic::register_ostream(dout(), "dout"); - stk_classic::register_ostream(tout(), "tout"); - - static_cast(dwout().rdbuf())->redirect(dout().rdbuf()); - - stk_classic::set_report_handler(report_handler); - - stk_classic::Bootstrap::bootstrap(); - - for (int i = 0; i < *argc; ++i) { - const std::string s((*argv)[i]); - if (s == "-h" || s == "-help" || s == "--help") { - std::cout << "Usage: " << (*argv)[0] << " [options...]" << std::endl; - std::cout << stk_classic::get_options_description() << std::endl; - return; // So application can handle app-specific options. - } - } - - // Broadcast argc and argv to all processors. - int parallel_rank = stk_classic::parallel_machine_rank(m_comm); - int parallel_size = stk_classic::parallel_machine_size(m_comm); - - stk_classic::BroadcastArg b_arg(m_comm, *argc, *argv); - - // Parse broadcast arguments - bopt::variables_map &vm = stk_classic::get_variables_map(); - try { - bopt::store(bopt::command_line_parser(b_arg.m_argc, b_arg.m_argv).options(stk_classic::get_options_description()).allow_unregistered().run(), vm); - bopt::notify(vm); - } - catch (std::exception &x) { - stk_classic::RuntimeDoomedSymmetric() << x.what(); - } - - // Parse diagnostic messages to display - if (vm.count("dw")) - dw().setPrintMask(dw_option_mask.parse(vm["dw"].as().c_str())); - - // Parse timer metrics and classes to display - stk_classic::diag::setEnabledTimerMetricsMask(stk_classic::diag::METRICS_CPU_TIME | stk_classic::diag::METRICS_WALL_TIME); - if (vm.count("timer")) - timerSet().setEnabledTimerMask(timer_option_mask.parse(vm["timer"].as().c_str())); - - // Set working directory - m_workingDirectory = "./"; - if (vm.count("directory")) - m_workingDirectory = vm["directory"].as(); - if (m_workingDirectory.length() && m_workingDirectory[m_workingDirectory.length() - 1] != '/') - m_workingDirectory += "/"; - - std::string output_description = build_log_description(vm, m_workingDirectory, parallel_rank, parallel_size); - - stk_classic::bind_output_streams(output_description); - - dout() << "Output log binding: " << output_description << std::endl; - - // Start use case root timer - timer().start(); -} - -UseCaseEnvironment::~UseCaseEnvironment() -{ - stk_classic::report_deferred_messages(m_comm); - -// Stop use case root timer - timer().stop(); - - stk_classic::diag::printTimersTable(out(), timer(), stk_classic::diag::METRICS_CPU_TIME | stk_classic::diag::METRICS_WALL_TIME, false, m_comm); - - stk_classic::diag::deleteRootTimer(timer()); - - static_cast(dwout().rdbuf())->redirect(std::cout.rdbuf()); - - stk_classic::unregister_ostream(tout()); - stk_classic::unregister_ostream(dout()); - stk_classic::unregister_ostream(pout()); - stk_classic::unregister_ostream(out()); - - stk_classic::unregister_log_ostream(std::cerr); - stk_classic::unregister_log_ostream(std::cout); - - if (m_need_to_finalize) { - stk_classic::parallel_machine_finalize(); - } -} - -bool print_status(stk_classic::ParallelMachine comm, bool success) -{ - int error_flag = success ? 0 : 1; - stk_classic::all_reduce( comm , stk_classic::ReduceMax<1>( & error_flag ) ); - bool all_success = !error_flag; - - int rank = stk_classic::parallel_machine_rank(comm); - if (rank == 0) { - std::cout << ( all_success ? "STK_USECASE_PASS" : "Use case failed.") << std::endl; - } - - return all_success; -} - -} // namespace use_case diff --git a/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.hpp b/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.hpp deleted file mode 100644 index 798f575197ea..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/use_cases/UseCaseEnvironment.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_use_cases_UseCaseEnvironement_hpp -#define stk_util_use_cases_UseCaseEnvironement_hpp - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace use_case { - -enum LogMask { - LOG_ALWAYS = stk_classic::LOG_ALWAYS, - LOG_TRACE = stk_classic::LOG_TRACE, - LOG_TRACE_STATS = stk_classic::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = stk_classic::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = stk_classic::LOG_MEMBERS, - - LOG_SEARCH = 0x0000010, - LOG_TRANSFER = 0x0000020, - LOG_TIMER = 0x0000040 -}; - -/** - * @brief Class message_type ... - * - */ -enum message_type { - MSG_WARNING = stk_classic::MSG_WARNING, - MSG_FATAL = stk_classic::MSG_DOOMED, - MSG_INFORMATION, - MSG_EXCEPTION, - MSG_PARALLEL_EXCEPTION -}; - - -/** - * @brief Class type ... - * - */ -enum message_throttle_type { - MSG_APPLICATION = stk_classic::MSG_APPLICATION, - MSG_TIME_STEP -}; - -enum TimerSetMask { - TIMER_MESH = 0x00000001, ///< Enable mesh timers - TIMER_MESH_IO = 0x00000002, ///< Enable mesh I/O timers - TIMER_SEARCH = 0x00000004, ///< Enable search timers - TIMER_TRANSFER = 0x00000008, ///< Enable transfer timers - TIMER_ALL = 0xFFFFFFFF, ///< Force timer to be active - - TIMER_FORCE = 0x00000000 ///< Force timer to be active -}; - -std::ostream &out(); ///< Normal output stream -std::ostream &dout(); ///< Diagnostic output stream -std::ostream &pout(); ///< Per-processor output stream (See RuntimeDeferredx) -std::ostream &tout(); ///< Regression test textual output stream - -std::ostream &dwout(); ///< Diagnostic writer stream - -stk_classic::diag::Writer &dw(); - -stk_classic::diag::TimerSet &timerSet(); - -stk_classic::diag::Timer &timer(); - -void my_report_handler(const char *message, int type); - -/** - * Print the sucess or failure of a use_case by combining the success - * flags for all procs in comm. Prints a string that should be grepped for - * in the test XML files. - * - * Returns true if all procs passed. - */ -bool print_status(stk_classic::ParallelMachine comm, bool success); - -struct UseCaseEnvironment -{ - // Will initialize a comm - UseCaseEnvironment(int *argc, char ***argv); - - // Assumes already-initialized comm - UseCaseEnvironment(int *argc, char ***argv, stk_classic::ParallelMachine comm); - - // shared constructor implementation; do not call directly - void initialize(int* argc, char ***argv); - - ~UseCaseEnvironment(); - - const stk_classic::ParallelMachine m_comm; - std::string m_workingDirectory; - bool m_need_to_finalize; -}; - -} // namespace use_case - -#endif // stk_util_use_cases_UseCaseEnvironement_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Array.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Array.hpp deleted file mode 100644 index 78e0c7d6b090..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Array.hpp +++ /dev/null @@ -1,673 +0,0 @@ -/** - * Copyright 2005 - 2008 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - */ - -/** - * @file - * @author H. Carter Edwards - * @date August 2005 - */ - -#ifndef STK_UTIL_UTIL_Array_h -#define STK_UTIL_UTIL_Array_h - -#include -#include -#include -#include -#include -#include - -namespace sierra { - -/// -/// @addtogroup ArrayDetail -/// @{ -/// - -/** - * @class Array - * - * @brief Multidimensional array view of contiguous memory. - * - * @par Dimension tagging - * - * @brief Multidimensional array of contiguous memory. The memory is not owned by the - * array, but container access semantics are enforced, i.e. const Array<> elements cannot - * be assigned to. - * - * class X {}; class Y {}; class Z {}; - * Array grid; - * - * describes a three dimensional array with the three indices associated with 'X', 'Y', - * and 'Z' respectively. - * - * @par Indexing via 'operator()' - * - * Elements of an array can be accessed via the () operator, where an index is provided - * for each dimension of the array. The number of dimensions is enforced at compile time; - * however, enforcement of the range of the indices is only performed at runtime in debug - * mode, i.e. 'NDEBUG' is not defined. - * - * FArray a(mem, n0, n1, n2, n3); - * a(i0, i1, i2, i3) = 24; - * - * @par Construction with a block of memory - * - * An array is created by providing it with memory and dimensions by which that memory is - * to be viewed. - * - * FArray(pointer, ndim0, ndim1, ndim2, ...); - * - * @par Shallow copy construction - * - * The copy constructor is a shallow copy. The constructed array is just another a view - * into the same memory as the input array. This is the preferred method of passing - * arrays as access required less memory indirection. - */ - -template< class ElementType, - class Tag0, - class Tag1 = TypeListEnd, - class Tag2 = TypeListEnd, - class Tag3 = TypeListEnd, - class Tag4 = TypeListEnd, - class Tag5 = TypeListEnd, - class Tag6 = TypeListEnd, - class Tag7 = TypeListEnd> -class Array; - -//---------------------------------------------------------------------- -/** - * @class sierra::ArrayContainer - * - * @brief Extend Array with deep copy assignment and resize operations. - */ - -template< class ElementType, - class Tag0, - class Tag1 = TypeListEnd, - class Tag2 = TypeListEnd, - class Tag3 = TypeListEnd, - class Tag4 = TypeListEnd, - class Tag5 = TypeListEnd, - class Tag6 = TypeListEnd, - class Tag7 = TypeListEnd, - class A = std::allocator > -class ArrayContainer; - - -//---------------------------------------------------------------------- -// A typeless array is invalid... - -template< class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7> -class Array {}; - -template -class Array -{ -public: - typedef ElementType element_type; - - typedef Array< element_type, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd> SelfType; - -// typedef Array< const element_type, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd, TypeListEnd > Const; - - typedef typename MakeTypeList::type TagList; - - /** Number of dimensions */ - - enum { NumDim = 0 }; -}; - - - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7> -class Array : public FArray::type>::value> -{ -public: - typedef ElementType element_type; - - typedef Array< element_type, Tag0, Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7> SelfType; - - typedef Array< const element_type, Tag0, Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7 > Const; - - typedef typename MakeTypeList::type TagList; - - typedef FArray::type>::value> BaseType; - - /** Number of dimensions */ - - enum { NumDim = TypeListLength::value }; - - typedef Array< ElementType, - typename TypeListAt::list_type, 0>::type, - typename TypeListAt::list_type, 1>::type, - typename TypeListAt::list_type, 2>::type, - typename TypeListAt::list_type, 3>::type, - typename TypeListAt::list_type, 4>::type, - typename TypeListAt::list_type, 5>::type, - typename TypeListAt::list_type, 6>::type, - TypeListEnd> Trunc; - - //---------------------------------------- - /** Dimensions defined at contruction */ - - const unsigned * dimension() const { - return BaseType::dimension(); - } - - const unsigned * stride() const { - return BaseType::stride(); - } - - template - unsigned dimension() const { - enum { ok = stk_classic::StaticAssert< I < NumDim >::OK }; - - return BaseType::m_dim[I]; - } - - unsigned dimension( const unsigned i ) const { - this->array_dimension_verify(0, i, NumDim ); - return BaseType::m_dim[i]; - } - - unsigned stride( const unsigned i ) const { - this->array_dimension_verify(0, i, NumDim ); - return BaseType::m_stride[i]; - } - - template - unsigned stride() const { - enum { ok = stk_classic::StaticAssert< I < NumDim >::OK }; - return BaseType::m_stride[I]; - } - - template - unsigned dimension() const{ - enum { I = TypeListIndex::value }; - enum { ok = stk_classic::StaticAssert< 0 <= I >::OK }; - return BaseType::m_dim[I]; - } - - template - unsigned dimension() const { - enum { I = TypeListIndex::value }; - enum { ok = stk_classic::StaticAssert< 0 <= I >::OK }; - return BaseType::m_dim[I]; - } - - template - unsigned stride() const { - enum { I = TypeListIndex::value }; - enum { ok = stk_classic::StaticAssert< 0 <= I >::OK }; - return BaseType::m_stride[I]; - } - - template - unsigned stride() const { - enum { I = TypeListIndex::value }; - enum { ok = stk_classic::StaticAssert< 0 <= I >::OK }; - return BaseType::m_stride[I]; - } - - bool operator == ( const SelfType & a ) const { - return ArrayHelper::equal( BaseType::m_dim, a.m_dim ) && - ArrayHelper::equal(BaseType::m_dim, BaseType::m_ptr, BaseType::m_stride, a.m_ptr, a.m_stride); - } - - template - bool operator == (const Array & a) const { - return ArrayHelper::equal( BaseType::m_dim, a.dimension() ) && - ArrayHelper::equal(BaseType::m_dim, BaseType::m_ptr, BaseType::m_stride, a.ptr(), a.stride()); - } - - bool operator != ( const SelfType & a ) const { - return ! operator == ( a ); - } - - template - bool operator != ( const Array & a ) const { - return ! operator == ( a ); - } - -public: - ~Array() - {} - - Array() : BaseType() - {} - - Array( const SelfType & a ) - : BaseType( a ) - {} - - template - Array( const Array & a ) - : BaseType( a ) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7 ) - : BaseType( in_ptr, n0, n1, n2, n3, n4, n5, n6, n7) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6 ) - : BaseType( in_ptr, n0, n1, n2, n3, n4, n5, n6) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5 ) - : BaseType( in_ptr, n0, n1, n2, n3, n4, n5) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4 ) - : BaseType( in_ptr, n0, n1, n2, n3, n4) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3 ) - : BaseType( in_ptr, n0, n1, n2, n3) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2 ) - : BaseType( in_ptr, n0, n1, n2) - {} - - Array( element_type * const in_ptr, - const unsigned n0, const unsigned n1 ) - : BaseType( in_ptr, n0, n1) - {} - - Array( element_type * const in_ptr, - const unsigned n0 ) - : BaseType( in_ptr, n0) - {} - - Array( element_type * const in_ptr, - const unsigned n[NumDim] ) - : BaseType( in_ptr, n){} - - void set( const SelfType & a ) { - BaseType::m_ptr = a.m_ptr; - - ArrayHelper::copy( a.m_dim, BaseType::m_dim ); - ArrayHelper::copy( a.m_stride, BaseType::m_stride ); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7 ) { - BaseType::set(in_ptr, n0, n1, n2, n3, n4, n5, n6, n7); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6 ) { - BaseType::set(in_ptr, n0, n1, n2, n3, n4, n5, n6); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5 ) { - BaseType::set(in_ptr, n0, n1, n2, n3, n4, n5); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4 ) { - BaseType::set(in_ptr, n0, n1, n2, n3, n4); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3 ) { - BaseType::set(in_ptr, n0, n1, n2, n3); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1, - const unsigned n2 ) { - BaseType::set(in_ptr, n0, n1, n2); - } - - void set( element_type * const in_ptr, - const unsigned n0, const unsigned n1 ) { - BaseType::set(in_ptr, n0, n1); - } - - void set( element_type * const in_ptr, - const unsigned n0 ) { - BaseType::set(in_ptr, n0); - } - - void set( element_type * const in_ptr, - const unsigned n[NumDim] ) { - BaseType::set(in_ptr, n); - } - - Trunc dive(int i) { - this->array_dimension_verify(0, i, BaseType::m_dim[NumDim - 1] ); - - element_type *calc_ptr = BaseType::m_ptr + i*BaseType::m_stride[NumDim - 1]; - - return Trunc(calc_ptr, BaseType::m_dim); - } - - const Trunc dive(int i) const { - this->array_dimension_verify(0, i, BaseType::m_dim[NumDim - 1] ); - - element_type *calc_ptr = BaseType::m_ptr + i*BaseType::m_stride[NumDim - 1]; - - return Trunc(calc_ptr, BaseType::m_dim); - } - - template - void copy( const Array & a ) { - ArrayHelper::copy(BaseType::m_dim, BaseType::m_ptr, BaseType::m_stride, a.ptr(), a.stride() ); - } - - template - void fill( const T & value ) { - ArrayHelper::fill(BaseType::m_dim, BaseType::m_ptr, BaseType::m_stride, value); - } - -private: - // Mutation (non-const methods) is not allowed so as to - // provide derived classes with complete control over mutation. - - SelfType & operator = ( SelfType const & a ); -}; - -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7, - class A> -class ArrayContainer - : public Array -{ -public: - typedef ArrayContainer SelfType; - - typedef Array BaseType; - - typedef typename BaseType::element_type element_type; - - typedef typename BaseType::TagList TagList; - - enum { NumDim = BaseType::NumDim }; - -private: - using BaseType::m_ptr; - using BaseType::m_dim; - using BaseType::m_stride; - - void resize_memory( const unsigned new_size ) { - if ( m_capacity < new_size ) { - if ( m_capacity ) - m_allocator.deallocate(m_ptr, m_capacity); - m_capacity = new_size; - m_ptr = m_allocator.allocate(m_capacity); - } - } - -public: - ~ArrayContainer() { - if ( m_capacity ) { - m_allocator.deallocate(m_ptr, m_capacity); - m_capacity = 0; - } - } - - //---------------------------------------- - // Constructors for initial view of contiguous memory. - - ArrayContainer( ) - : BaseType( ), - m_capacity(0) - {} - - ArrayContainer( const SelfType & a ) - : BaseType(), - m_capacity(0) - { - resize_memory( BaseType::set_dim( a.m_dim ) ); - this->copy(a); - } - - template - ArrayContainer( const Array & a ) - : BaseType(), m_capacity(0) - { - resize_memory( BaseType::set_dim( a.dimension() ) ); - this->copy(a); - } - - SelfType & operator = ( const SelfType & a ) { - resize_memory( BaseType::set_dim( a.dimension() ) ); - this->copy(a); - return *this; - } - - template - SelfType & operator =( const Array & a ) { - resize_memory( BaseType::set_dim( a.dimension() ) ); - this->copy(a); - return *this; - } - - //---------------------------------------- - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7 ) - : BaseType(NULL, n0, n1, n2, n3, n4, n5, n6, n7 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6 ) - : BaseType( NULL, n0, n1, n2, n3, n4, n5, n6 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5 ) - : BaseType( NULL, n0, n1, n2, n3, n4, n5 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4 ) - : BaseType( NULL, n0, n1, n2, n3, n4 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3 ) - : BaseType( NULL, n0, n1, n2, n3 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1, - const unsigned n2 ) - : BaseType( NULL, n0, n1, n2 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0, const unsigned n1 ) - : BaseType( NULL, n0, n1 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n0 ) - : BaseType( NULL, n0 ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - ArrayContainer( const unsigned n[] ) - : BaseType( NULL, n ), - m_capacity(0) - { - resize_memory( m_stride[NumDim] ); - } - - //---------------------------------------- - - template - SelfType & resize( const Array & a ) { - resize_memory( BaseType::set_dim( a.dimension() ) ); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6, const unsigned n7 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6, n7)); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5, - const unsigned n6 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5, n6)); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4, const unsigned n5 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4, n5)); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3, - const unsigned n4 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3, n4)); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2, const unsigned n3 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2, n3)); - return *this; - } - - - SelfType & resize( const unsigned n0, const unsigned n1, - const unsigned n2 ) - { - resize_memory(BaseType::set_dim(n0, n1, n2)); - return *this; - } - - SelfType & resize( const unsigned n0, const unsigned n1 ) - { - resize_memory(BaseType::set_dim(n0, n1)); - return *this; - } - - SelfType & resize( const unsigned n0 ) - { - resize_memory(BaseType::set_dim(n0)); - return *this; - } - - SelfType & resize( const unsigned n[] ) - { - resize_memory( BaseType::set_dim(n) ); - return *this; - } - - //---------------------------------------- - -private: - A m_allocator; - unsigned m_capacity; -}; - -/// -/// @} -/// - -} // namespace sierra - -#endif // STK_UTIL_UTIL_Array_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.cpp deleted file mode 100644 index 51bf2ba034fd..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -namespace stk_classic { - -Bootstrap * -Bootstrap::s_front = 0; - -bool -Bootstrap::s_bootstrapped = false; - - -void -Bootstrap:: bootstrap() -{ - s_bootstrapped = true; - for (Bootstrap *f = s_front; f; f = f->m_next) - (*f->m_f)(); -} - - -Bootstrap::Bootstrap( - FunctionPtr f) - : m_next(s_front), - m_f(f) -{ - s_front = this; - - // IF already bootstrapped, execute immediately - if (s_bootstrapped) - (*f)(); -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.dox b/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.dox deleted file mode 100644 index 832530792b96..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.dox +++ /dev/null @@ -1,62 +0,0 @@ -/// -/// \addtogroup stk_util_bootstrap_detail -/// @{ -/// -/// @brief Allows object modules included in the application to perform various registration -/// operations after main() has been called. -/// -/// Most products need to register with other products to provide information such as product -/// version, command line option, and diagnostic writers. The Bootstrap class provides a safe -/// mechanism for these registrations to occur. -/// -/// Bootstrapping occurs in two steps and requires two components, a callback function and a static -/// bootstrap object. The construction of the static bootstrap object registers the callback -/// function for later execution by main() and the callback function performs registrations such as -/// registering product information, command line options and diagnostics writers. -/// -/// By utilizing this mechanism, any modules which need to be bootstrapped can do so by being linked -/// into the executable. -/// -/// \anchor stk_util_bootstrap_howto_bootstrap -/// For example: -/// -/// \code -/// #include -/// -/// namespace { -/// -/// void bootstrap() -/// { -/// boost::program_options::options_description desc("Use case options"); -/// desc.add_options() -/// ("performance", "run performance test") -/// ("mesh", boost::program_options::value(), "run mesh file performance test"); -/// -/// stk_classic::env::get_options_description().add(desc); -/// } -/// -/// stk_classic::Bootstrap x(&bootstrap); -/// -/// } // namespace -/// -/// \endcode -/// -/// Main contains the following function which executes the registered bootstrap functions. -/// -/// \code -/// -/// int -/// main() -/// { -/// stk_classic::Boostrap::bootstrap(); -/// -/// } -/// -/// \endcode -/// -/// -/// The applications main executes the bootstrap functions causing the command line -/// description to be fully populated. -/// -/// @} -/// diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.hpp deleted file mode 100644 index a2a71689f206..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Bootstrap.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_BOOTSTRAP_HPP -#define STK_UTIL_UTIL_BOOTSTRAP_HPP - -namespace stk_classic { - -/// -/// @addtogroup bootstrap_detail -/// @{ -/// - -/** - * @brief Class Bootstrap serves as a bootstrapping mechanism for products in the - * sierra toolkit and elsewhere. - * - * Often, it is convenient to have a product perform registrations and other operations - * when linked into an application. One method of accomplishing this is to utilize a - * static object whose constructor perform these operations. However, static - * constructions are executed prior to main and in non-deterministc order. The later is - * particularly problematic if the constructor results in the usage of another static - * object which may not have been constructed yet. - * - * So, the Bootstrap class creates a stack of callback functions that are executed, by - * main(), when Bootstrap::bootstrap() is called. These functions are still executed in a - * non-deterministic order, but all static constructions have occurred. - * - */ -class Bootstrap -{ -public: - - typedef void (*FunctionPtr)(); - - /** - * @brief Member function bootstrap runs through the stored bootstrap function - * pointers and executes each function. - * - */ - static void bootstrap(); - - /** - * @brief Creates a new Bootstrap instance. - * - * The instance serves only to insert the specified function pointer to the bootstrap - * function list. If the bootstrapper has already been executed, the function is added - * to the list and executed immediately. - * - */ - Bootstrap(void (*f)()); - -private: - Bootstrap(const Bootstrap &); - Bootstrap &operator=(const Bootstrap &); - -public: - ~Bootstrap() - {} - -private: - static Bootstrap * s_front; ///< Front of bootstrap registry - static bool s_bootstrapped; ///< Bootstart::bootstrap has been called - - Bootstrap * m_next; ///< Next bootstrap object - FunctionPtr m_f; ///< Function to call during bootstrap() -}; - -/// -/// @} -/// - -} // namespace stk_classic - -#endif // STK_UTIL_UTIL_BOOTSTRAP_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/CMakeLists.txt b/packages/stk/stk_classic/stk_util/stk_util/util/CMakeLists.txt deleted file mode 100644 index b49c92e7b7a7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ - - -# -# A) Package-specific configuration options -# - -# TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -# -# B) Define the header and source files (and directories) -# - -# -# src -# - -SET(HEADERS "") -SET(SOURCES "") - -FILE(GLOB HEADERS *.hpp *.h) -FILE(GLOB SOURCES *.cpp) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/../) -INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/detail/) - -# -# Core headers -# - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -IF (TPL_ENABLE_MPI) -ENDIF() - -# -# C) Define the targets for package's library(s) -# - -TRIBITS_ADD_LIBRARY( - stkclassic_util_util - NOINSTALLHEADERS ${HEADERS} - SOURCES ${SOURCES} - ) - -INSTALL(FILES ${HEADERS} DESTINATION - ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/stk_util/util/) diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/CSet.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/CSet.cpp deleted file mode 100644 index 200614a35876..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/CSet.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include - -namespace stk_classic { - -namespace { - -typedef void (* DeleteFunction )( void * ); - -typedef std::pair< const std::type_info * , DeleteFunction > Manager ; - -// Comparison for sorted vector - -struct less_cset { - bool operator()( const Manager & lhs , - const std::type_info & rhs ) const ; - bool operator()( const std::type_info & lhs , - const Manager & rhs ) const ; -}; - -// On some systems, namely AIX, std::type_info::before(...) -// has a bug where it returns true instead of false for equality. -// Thus we pay a small price on all systems to specifically -// test for and eliminate equality. - -bool less_cset::operator()( const Manager & lhs , - const std::type_info & rhs ) const -{ return lhs.first->before( rhs ) && * lhs.first != rhs ; } - -bool less_cset::operator()( const std::type_info & lhs , - const Manager & rhs ) const -{ return lhs.before( *rhs.first ) && lhs != *rhs.first ; } - - -std::vector< Manager >::iterator -lower_bound( std::vector< Manager > & v , const std::type_info & t ) -{ - std::vector< Manager >::iterator i = v.begin(); - std::vector< Manager >::iterator j = v.end(); - - return std::lower_bound( i , j , t , less_cset() ); -} - -} - -struct equal_cset { - bool operator()(const Manager& lhs, const std::type_info& rhs) const - { return *lhs.first == rhs; } - bool operator()(const std::type_info& lhs, const Manager& rhs) const - { return lhs == *rhs.first; } -}; - -//---------------------------------------------------------------------- - -const void * CSet::p_get( const std::type_info & t ) const -{ - for(std::vector::const_iterator it=m_manager.begin(), end=m_manager.end(); it!=end; ++it) { - if (*it->first == t) return m_value[it-m_manager.begin()]; - } - - return NULL ; -} - -const void * -CSet::p_insert( const Manager & m , const void * v ) -{ - std::vector< Manager >::iterator im = lower_bound( m_manager , * m.first ); - - const size_t offset = im - m_manager.begin(); - - assert(m_value.size() == m_manager.size()); - std::vector::iterator iv = m_value.begin(); - std::advance( iv , offset ); - - if ( im == m_manager.end() || * m.first != * im->first ) { - im = m_manager.insert( im , m ); - iv = m_value .insert( iv , v ); - } - - assert(iv != m_value.end()); - return *iv ; -} - -bool CSet::p_remove( const std::type_info & t , const void * v ) -{ - bool result = false; - const std::vector< Manager >::iterator im = lower_bound( m_manager , t ); - - if (im != m_manager.end()) { - const size_t offset = im - m_manager.begin(); - - if (offset <= m_value.size()) { - std::vector::iterator iv = m_value.begin(); - std::advance( iv , offset ); - - result = t == * im->first && v == * iv ; - - if ( result ) { - m_manager.erase( im ); - m_value .erase( iv ); - } - } - } - return result ; -} - -//---------------------------------------------------------------------- - -CSet::~CSet() -{ - try { - const size_t n = m_manager.size(); - for ( size_t i = 0 ; i < n ; ++i ) { - try { - if ( m_manager[i].second ) { - (*m_manager[i].second)( const_cast( m_value[i] ) ); - } - } catch(...) {} - } - } catch(...) {} -} - -CSet::CSet() : m_manager(), m_value() {} - -} // namespace stk_classic - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/CSet.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/CSet.hpp deleted file mode 100644 index 2b09ad01c486..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/CSet.hpp +++ /dev/null @@ -1,147 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_CSet_hpp -#define stk_util_util_CSet_hpp - -#include -#include - -namespace stk_classic { - -//---------------------------------------------------------------------- -/** \ingroup util_module - * \class CSet - * \brief Set of entities of arbitrary types. - * - * @todo REFACTOR Use smart pointers to avoid destruction issue. - * - * Example usage of the three methods: - * - *
- *  class A { ... };
- *  class B { ... };
- *
- *  CSet cset ;
- *
- *  // Insert pointers to objects:
- *
- *  cset.insert( new A ); // Do not delete on destruction
- *  cset.insert( new B , true ); // Delete on destruction
- *
- *  // Query the collection of objects of a given type:
- *
- *  const A * sa = cset.get();
- *  const B * sb = cset.get();
- *
- *  // Remove a member:
- *
- *  {
- *    B * b = ... ;
- *    cset.remove( b ); // Remove never deletes
- *    delete b ;
- *  }
- * 
- */ -class CSet { -public: - - /** Get member conforming to the given type. */ - template const T * get() const ; - - /** Insert a new member. Invoke 'delete' upon destruction. - * If already exists then return existing member, insert fails. - */ - template const T * insert_with_delete( const T *); - - /** Insert a new member. Do nothing to it upon destruction. - * If already exists then return existing member, insert fails. - */ - template const T * insert_no_delete( const T * ); - - /** Erase a member without deleting. - * Return if the remove operation was successful. - */ - template bool remove( const T * ); - - //-------------------------------- - - ~CSet(); - CSet(); - -private: - - typedef void (*DeleteFunction)(void *); - - typedef std::pair< const std::type_info * , DeleteFunction > Manager ; - - const void * p_get( const std::type_info & ) const ; - - const void * p_insert( const Manager & , const void * ); - - bool p_remove( const std::type_info & , const void * ); - - std::vector< Manager > m_manager ; - std::vector< const void * > m_value ; - - CSet( const CSet & ); - CSet & operator = ( const CSet & ); -}; - -} // namespace stk_classic - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Inlined template methods have casting. - -#ifndef DOXYGEN_COMPILE - -namespace stk_classic { - -namespace { -template -void cset_member_delete( void * v ) { delete reinterpret_cast( v ); } -} - -template -inline -const T * CSet::get() const -{ return (const T*) p_get( typeid(T) ); } - -template -inline -const T * CSet::insert_with_delete( const T * arg_value) -{ - Manager m ; - m.first = & typeid(T); - m.second = & cset_member_delete ; - - return (const T *) p_insert( m , arg_value ); -} - -template -inline -const T * CSet::insert_no_delete( const T * arg_value) -{ - Manager m ; - m.first = & typeid(T); - m.second = 0 ; - - return (const T *) p_insert( m , arg_value ); -} - -template -inline -bool CSet::remove( const T * arg_value ) -{ return p_remove( typeid(T) , arg_value ); } - -} // namespace stk_classic - -#endif /* DOXYGEN_COMPILE */ - -#endif // stk_util_util_CSet_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Callback.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Callback.hpp deleted file mode 100644 index 407e6f94898e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Callback.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -// Callback class basics from Herb Sutter, http://www.gotw.ca, GOTW #83. - -#ifndef STK_UTIL_UTIL_Callback_hpp -#define STK_UTIL_UTIL_Callback_hpp - -/** - * @file - * - * Callback implements a functor to call a member function of an object. - * - */ - -namespace sierra { - -template -class Callback; - -/** - * @brief Class Callback ... - * - */ -template<> -class Callback -{ -public: - /** - * @brief Member function operator() calls the member function on the - * object. - * - */ - virtual void operator()() const = 0; - - /** - * Destroys a Callback instance. - * - */ - virtual ~Callback() - {} -}; - -typedef Callback CallbackBase; ///< Shorthand for Callback - -/** - * @brief Class Callback ... - * - */ -template -class Callback : public Callback -{ -public: - typedef void (T::*F)(); ///< Member function signature - - /** - * Creates a new Callback instance. - * - * @param t a T reference to the object. - * - * @param f a F pointer to member function to call. - * - */ - Callback(T &t, F f) - : m_t(&t), - m_f(f) - {} - - /** - * Destroys a Callback instance. - * - */ - virtual ~Callback() - {} - - /** - * @brief Member function operator() calls the member function on the - * object. - * - */ - virtual void operator()() const { - (m_t->*m_f)(); - } - -private: - T * m_t; ///< Pointer to object - F m_f; ///< Member function to call -}; - -/** - * @brief Member function create_callback creates a new callback object which - * calls the member function f on the object t. - * - * @param t a T reference to the object that wishes to be - * called back. - * - * @return a CallbackBase pointer to the newly created - * callback object. - */ -template -CallbackBase * -create_callback( - T & t, - void (T::*f)()) -{ - return new Callback(t, f); -} - -} // namespace sierra - -#endif // STK_UTIL_UTIL_Callback_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/FArrayPrint.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/FArrayPrint.hpp deleted file mode 100644 index 015ba241aaf3..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/FArrayPrint.hpp +++ /dev/null @@ -1,244 +0,0 @@ -#ifndef STK_UTIL_UTIL_FArrayPrint_h -#define STK_UTIL_UTIL_FArrayPrint_h - -#include -#include - -#include - - -namespace sierra { - -namespace { - -template struct ArrayVerbosePrint ; - -template<> -struct ArrayVerbosePrint<0> -{ - template - static std::ostream &dump(std::ostream &os, const unsigned * const, const T *, const unsigned * const) - { - return os; - } -}; - -template<> -struct ArrayVerbosePrint<1> -{ - template - static std::ostream &dump(std::ostream &os, const unsigned * const dim, - const T *a_ptr, const unsigned * const a_inc) - { - const unsigned inc = *a_inc ; - const T * ptr = a_ptr; - const T * const end = ptr + *dim * inc ; - os << "("; - while ( ptr != end ) { - if (ptr != a_ptr) - os << " "; - os << *ptr; - ptr += inc ; - } - os << ")"; - - return os; - } -}; - -template<> -struct ArrayVerbosePrint<2> -{ -public: - template - static std::ostream &dump(std::ostream &os, const unsigned * const dim, - const T *a_ptr, const unsigned * const a_inc) - { - if (dim[0] < 8) { // less than 8 columns wide - const unsigned inc = a_inc[1] ; - const T * r_ptr = a_ptr; - const T * const end = r_ptr + dim[1] * inc ; - os << "+-\n"; - while ( r_ptr != end ) { - { - const unsigned inner_inc = *a_inc ; - const T * c_ptr = r_ptr; - const T * const inner_end = c_ptr + dim[0] * inner_inc ; - os << "| "; - while ( c_ptr != inner_end ) { - if (c_ptr != r_ptr) - os << " "; - os << *c_ptr; - c_ptr += inner_inc ; - } - os << "\n"; - } - - r_ptr += inc ; - } - os << "+-\n"; - } - else { - const unsigned inc = a_inc[1] ; - const T * ptr = a_ptr; - const T * const end = ptr + dim[1] * inc ; - while ( ptr != end ) { - ArrayVerbosePrint<1>::dump(os, dim, ptr, a_inc ); - os << std::endl; - ptr += inc ; - } - } - - return os; - } -}; - -template<> -struct ArrayVerbosePrint<3> -{ -public: - template - static std::ostream &dump(std::ostream &os, const unsigned * const dim, - const T *a_ptr, const unsigned * const a_inc) - { -// if (a_inc[3] < 50) { -// const unsigned ia = a_inc[2] ; -// unsigned index = 0; -// const T * ptr = a_ptr; -// const T * const end = ptr + a_inc[3]; -// while ( ptr != end ) { -// if (ptr != a_ptr) -// os << ","; -// os << "("; -// ArrayVerbosePrint<2>::dump(os, dim, ptr, a_inc ); -// os << ")"; -// ptr += ia ; -// ++index; -// } -// } -// else { - const unsigned ia = a_inc[2] ; - unsigned index = 0; - const T * const a_end = a_ptr + a_inc[3]; - while ( a_end != a_ptr ) { - os << "("; - for (unsigned i = 0; i < 2; ++i) - os << "0:" << dim[i] - 1 << ", "; - os << index << ")" << std::endl; - ArrayVerbosePrint<2>::dump(os, dim, a_ptr, a_inc ); - os << std::endl << std::endl; - a_ptr += ia ; - ++index; - } -// } - - return os; - } -}; - -template -struct ArrayVerbosePrint -{ -public: - template - static std::ostream &dump(std::ostream &os, const unsigned * const dim, - const T *a_ptr, const unsigned * const a_inc) - { - const unsigned ia = a_inc[N - 1] ; - unsigned index = 0; - const T * const a_end = a_ptr + a_inc[N]; - while ( a_end != a_ptr ) { - os << "("; - for (unsigned i = 0; i < N - 1; ++i) - os << "0:" << dim[i] - 1 << ", "; - os << index << ")" << std::endl; - ArrayVerbosePrint::dump(os, dim, a_ptr, a_inc ); - os << std::endl << std::endl; - a_ptr += ia ; - ++index; - } - - return os; - } -}; - -} // namespace - -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7 > -std::ostream & -operator<<( - std::ostream & os, - const sierra::Array &array) -{ - typedef sierra::Array X; - - ArrayVerbosePrint::dump(os, array.dimension(), array.ptr(), array.stride()); - os << std::endl; - - return os; -} - - -template< class ElementType, - class Tag0, - class Tag1, - class Tag2, - class Tag3, - class Tag4, - class Tag5, - class Tag6, - class Tag7 > -std::ostream & -operator<<( - std::ostream & os, - const sierra::ArrayContainer &array) -{ - typedef sierra::ArrayContainer X; - - ArrayVerbosePrint::dump(os, array.dimension(), array.ptr(), array.stride()); - os << std::endl; - - return os; -} - - -template< class ElementType, int Dimension> -std::ostream & -operator<<( - std::ostream & os, - const sierra::FArray &array) -{ - typedef sierra::FArray X; - - ArrayVerbosePrint::dump(os, array.dimension(), array.ptr(), array.stride()); - os << std::endl; - - return os; -} - - -template< class ElementType, int Dimension> -std::ostream & -operator<<( - std::ostream & os, - const sierra::FArrayContainer &array) -{ - typedef sierra::FArrayContainer X; - - ArrayVerbosePrint::dump(os, array.dimension(), array.ptr(), array.stride()); - os << std::endl; - - return os; -} - -} // namespace sierra - -#endif // STK_UTIL_UTIL_FArrayPrint_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/FeatureTest.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/FeatureTest.hpp deleted file mode 100644 index 83a2bfed4a1d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/FeatureTest.hpp +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef STK_UTIL_UTIL_FeatureTest_h -# define STK_UTIL_UTIL_FeatureTest_h - -// #include - -/// -/// @addtogroup FeatureTestDetail -/// @{ -/// -/// The following feature test and bug macros been defined to conditionally compile in -/// specific features and compile workarounds for known bugs. -/// -/// Bugs and workarounds: -/// -/// @def SIERRA_TYPE_INFO_BEFORE_EQUALITY_BUG -/// SIERRA_TYPE_INFO_BEFORE_EQUALITY_BUG -- The before() function of the std::type_info -/// class has been implemented improperly, resulting in type_info which are equal to -/// always return true. Equal std::type_info objects should alway return false. Define -/// this is type_info::before() is not implemented properly. -/// -/// @def SIERRA_AUTO_PTR_ASSIGNMENT_BUG -/// SIERRA_AUTO_PTR_ASSIGNMENT_BUG -- The assignment operator of an std::auto_ptr object -/// does not properly pass the ownership token to the lhs object. This results in the -/// object being deleted, resulting on heap corruption. The reset() function should be -/// used rather that assignement. Define this if the auto_ptr assign function does not -/// work properly. -/// -/// @def SIERRA_TEMPLATE_CALL_BUG -/// SIERRA_TEMPLATE_CALL_BUG -- The calling of a template member function erroneously -/// requires a "template" specified on GNU 3.2 and 3.3 compilers which is invalid for -/// other compilers. Define this use the erroneous implementation. -/// -/// @def SIERRA_TEMPLATE_FUNCTION_SELECT_BUG -/// SIERRA_TEMPLATE_FUNCTION_SELECT_BUG -- The function selection algorithm is broken and -/// special workaround code must included to allow the compile to complete. -/// -/// @def SIERRA_SRAND_PARALLEL_IO_BUG -/// SIERRA_SRAND_PARALLEL_IO_BUG -- There is some kind of bug in the Redstorm I/O subsystem -/// that reveals itself when the random sequence is seeded. Define this to disable the -/// seeding of the random number generator. -/// -/// @def SIERRA_MPI_ALLREDUCE_USER_FUNCTION_BUG -/// SIERRA_MPI_ALLREDUCE_USER_FUNCTION_BUG -- The platforms MPI_Allreduce function does -/// not behave properly when using a user defined function. -/// -/// @def SIERRA_SETVBUF_OUTPUT -/// SIERRA_SETVBUF_OUTPUT -- The output buffering on Redstorm significantly degrades -/// performance due to buffering issues. This macro causes the opening of log files to -/// set the size of the C++ output buffer to be large. Define this if you want the large -/// log output buffers defined. -/// -/// @def SIERRA_DIAG_ENDL_NOFLUSH -/// SIERRA_DIAG_ENDL_NOFLUSH -- The output buffering on Redstorm significantly degrades -/// performance due to buffering issues. This macro causes the diagnostic writer to not -/// flush the output buffer when writing newlines. Define this if you want output buffer -/// flushing to not occur on every diagnostic output line. -/// -/// @def SIERRA_USE_PLATFORM_DEMANGLER -/// SIERRA_USE_PLATFORM_DEMANGLER -- The platform type_info::name() function returns a -/// mangled name which needs to be demangled. Implement the platform specific function -/// in Slib_EnvPlatform.C -/// -/// -/// Features: -/// -/// @def SIERRA_DLOPEN_ENABLED -/// SIERRA_DLOPEN_ENABLED -- The dlopen functionality is built into the sierra -/// applications. However it may not function on all platforms or be desired on all -/// distributions. Define this macro if you wish to implement this functionality. -/// -/// @def SIERRA_MEMORY_INFO -/// SIERRA_MEMORY_INFO -- The platform supports memory usage information. -/// -/// @def SIERRA_HEAP_INFO -/// SIERRA_HEAP_INFO -- The platform supports heap usage information. -/// -/// @def SIERRA_MPI_ABORT_SIGNAL -/// SIERRA_MPI_ABORT_SIGNAL -- The MPI sends this signal to abort the processes. -/// -/// @def SIERRA_USER_SHUTDOWN_SIGNAL -/// SIERRA_USER_SHUTDOWN_SIGNAL -- The user sends this signal to tell the application to -/// exit gracefully at it earliest convenience. -/// -/// @def SIERRA_SHUTDOWN_SIGNAL -/// SIERRA_SHUTDOWN_SIGNAL -- The platform sends this signal to tell the application to -/// exit gracefully at it earliest convenience. -/// -/// @def SIERRA_INCLUDE_LIBPAPI -/// SIERRA_INCLUDE_LIBPAPI -- The Performance API can be utilized for timing and operation -/// counting. Define this macro if you wish to enable the high accuracy timing and -/// operation counting. (NOT IMPLEMENTED) -/// - -// Platform/operating system based features and bugs -#if defined(REDS) // Redstorm -# define SIERRA_SETVBUF_OUTPUT 1 -# define SIERRA_DIAG_ENDL_NOFLUSH -# define SIERRA_SRAND_PARALLEL_IO_BUG -# define SIERRA_HEAP_INFO -# define SIERRA_MEMORY_INFO -# define SIERRA_USER_SHUTDOWN_SIGNAL SIGUSR1 -# define SIERRA_SHUTDOWN_SIGNAL SIGTERM - -#elif defined(_CRAYXE) // Cray -# define SIERRA_SETVBUF_OUTPUT 1 -# define SIERRA_DIAG_ENDL_NOFLUSH -# define SIERRA_SRAND_PARALLEL_IO_BUG -# define SIERRA_HEAP_INFO -# define SIERRA_MEMORY_INFO -# define SIERRA_SHUTDOWN_SIGNAL SIGTERM -# define SIERRA_USER_SHUTDOWN_SIGNAL SIGURG - -#elif defined(__sun) // sass8000/sass9000 -# define SIERRA_HEAP_INFO -# define SIERRA_MEMORY_INFO -# define SIERRA_MPI_ABORT_SIGNAL SIGTERM -# define SIERRA_USER_SHUTDOWN_SIGNAL SIGHUP - -#elif defined(__linux__) // Generic linux -# define SIERRA_USE_PLATFORM_DEMANGLER -# define SIERRA_HEAP_INFO -# define SIERRA_MEMORY_INFO -# define SIERRA_MPI_ABORT_SIGNAL SIGTERM -# define SIERRA_USER_SHUTDOWN_SIGNAL SIGUSR1 - -#elif defined(__APPLE__) // MacOS -# define SIERRA_USE_PLATFORM_DEMANGLER -# define SIERRA_HEAP_INFO -# define SIERRA_MEMORY_INFO -# define SIERRA_MPI_ABORT_SIGNAL SIGTERM -# define SIERRA_USER_SHUTDOWN_SIGNAL SIGUSR1 - -#else // Unknown platform -# warning Could not determine platform/operating system -#endif - - -// Compiler/runtime specific features and bugs - -#if defined(__xlC__) // IBM compiler -# if __xlC__ < 0x0800 -# define SIERRA_TEMPLATE_FUNCTION_SELECT_BUG -# endif -# define SIERRA_TYPE_INFO_BEFORE_EQUALITY_BUG -# define SIERRA_AUTO_PTR_ASSIGNMENT_BUG - -#elif defined(__sun) || defined(__SUNPRO_CC) // Sun spro compiler -# define SIERRA_MPI_ALLREDUCE_USER_FUNCTION_BUG - -#elif defined(__INTEL_COMPILER) // Intel compiler -# if __INTEL_COMPILER/100 == 10 && defined(__ia64) // Version 10 Intel compiler on ia64 -# define SIERRA_IA64_OPTIMIZER_FIX -# elif __INTEL_COMPILER/100 == 11 && defined(__ia64) // Version 11 Intel compiler on ia64 -# define SIERRA_IA64_OPTIMIZER_FIX -# elif __INTEL_COMPILER/100 >= 12 && defined(__ia64) // Version 12+ Intel compiler on ia64 -# define SIERRA_IA64_OPTIMIZER_WARN -# endif - -#elif defined(__PGI) // PGI compiler - -#elif defined(_CRAYC) // CRAY compiler - -#elif defined(__APPLE_CC__) // Apple compiler - -#elif defined(__PATHSCALE__) // Pathscale compiler -# if (__GNUC__ > 3) || defined(PATHSCALE_GNU4) // Only with gcc3 front-end -# define NO_SIERRA_TEMPLATE_CALL_BUG -# else -# define SIERRA_TEMPLATE_CALL_BUG -# endif - -#elif defined(__GNUC__) // GNU compiler, do this last since *every* compiler thinks its gcc -# if __GNUC__ == 3 && __GNUC_MINOR__ < 4 -# define SIERRA_TEMPLATE_CALL_BUG -# endif - -#else // Unknown compiler -# warning Could not determine compiler/runtime -#endif - -/// -/// @} -/// - -#endif // STK_UTIL_UTIL_FeatureTest_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Foreach.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Foreach.hpp deleted file mode 100644 index 77bafde69717..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Foreach.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_FOREACH_HPP -#define STK_UTIL_UTIL_FOREACH_HPP - -#include - -#define stk_foreach BOOST_FOREACH -#define stk_reverse_foreach BOOST_REVERSE_FOREACH - -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Fortran.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Fortran.hpp deleted file mode 100644 index 5aa7a7e4d533..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Fortran.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef STK_UTIL_UTIL_Fortran_h -#define STK_UTIL_UTIL_Fortran_h - -#if ! defined(SIERRA_FORTRAN) && ! defined(SIERRAFORTRAN) - -#if defined(FORTRAN_NO_UNDERSCORE) -# define SIERRA_FORTRAN(subname) subname -# define SIERRAFORTRAN(subname) subname -# define SIERRA_FORTRAN_SUFFIX "" -#elif defined(FORTRAN_ONE_UNDERSCORE) -# define SIERRA_FORTRAN(subname) subname##_ -# define SIERRAFORTRAN(subname) subname##_ -# define SIERRA_FORTRAN_SUFFIX "_" -#elif defined(FORTRAN_TWO_UNDERSCORES) -# define SIERRA_FORTRAN(subname) subname##__ -# define SIERRAFORTRAN(subname) subname##__ -# define SIERRA_FORTRAN_SUFFIX "__" -#endif - -#endif // SIERRA_FORTRAN - -#endif // STK_UTIL_UTIL_Fortran_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.cpp deleted file mode 100644 index b88e2a4de5e3..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -namespace stk_classic { - -namespace { - -int -compare( - const char * s1, - const size_t s1_length, - const char * s2, - const size_t s2_length) -{ - const size_t length = std::min(s1_length, s2_length); - int result = ignorecase_traits::compare(s1, s2, length); - if (!result) - result = s1_length - s2_length; - return result; -} - -} // namespace - - -int -IdentifierA::compare( - const char * s1, - const size_t s1_length, - const char * s2, - const size_t s2_length) -{ - const size_t length = std::min(s1_length, s2_length); - int result = ignorecase_traits::compare(s1, s2, length); - if (!result) - result = s1_length - s2_length; - return result; -} - - -IdentifierA operator+(const IdentifierA &identifier1, const IdentifierA &identifier2) { - IdentifierA identifier(identifier1); - - return identifier += identifier2; -} - -IdentifierA operator+(const IdentifierA &identifier1, const std::string &string2) { - IdentifierA identifier(identifier1); - - return identifier += IdentifierA(string2); -} - -std::string operator+(const std::string &string1, const IdentifierA &identifier2) { - std::string string(string1); - - return string += identifier2; -} - -std::ostream &operator<<(std::ostream &os, const IdentifierA &identifier) { - return os << identifier.c_str(); -} - -std::istream &operator>>(std::istream &is, IdentifierA &identifier) { - std::string s; - - is >> s; - identifier = s; - - return is; -} - -bool operator<(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) < 0; -} - -bool operator<(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) < 0; -} - -bool operator<(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) < 0; -} - -bool operator<(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) < 0; -} - -bool operator==(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator==(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator==(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) == 0; -} - -bool operator==(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator<=(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator<=(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator<=(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) <= 0; -} - -bool operator<=(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator>(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) > 0; -} - -bool operator>(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>=(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator>=(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator>=(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) >= 0; -} - -bool operator>=(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator!=(const std::string &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - -bool operator!=(const IdentifierA &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - -bool operator!=(const IdentifierA &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) != 0; -} - -bool operator!=(const IdentifierA &s1, const IdentifierA &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - - - -int -IdentifierB::compare( - const char * s1, - const size_t s1_length, - const char * s2, - const size_t s2_length) -{ - const size_t length = std::min(s1_length, s2_length); - int result = ignorecase_traits::compare(s1, s2, length); - if (!result) - result = s1_length - s2_length; - return result; -} - - -std::ostream &operator<<(std::ostream &os, const IdentifierB &identifier) { - return os << identifier.c_str(); -} - -std::istream &operator>>(std::istream &is, IdentifierB &identifier) { - std::string s; - - is >> s; - identifier = s; - - return is; -} - -IdentifierB operator+(const IdentifierB &identifier1, const IdentifierB &identifier2) { - std::string identifier(identifier1); - - return IdentifierB(identifier += identifier2); -} - -IdentifierB operator+(const IdentifierB &identifier1, const std::string &string2) { - std::string identifier(identifier1); - - return IdentifierB(identifier += string2); -} - -IdentifierB operator+(const IdentifierB &identifier1, const char *string2) { - IdentifierB identifier(identifier1); - - return IdentifierB(identifier += string2); -} - -std::string operator+(const std::string &string1, const IdentifierB &identifier2) { - std::string string(string1); - - return string += identifier2; -} - -bool operator<(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) < 0; -} - -bool operator<(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) < 0; -} - -bool operator<(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) < 0; -} - -bool operator==(const std::string &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator==(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator==(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) == 0; -} - -bool operator==(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) == 0; -} - -bool operator<=(const std::string &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator<=(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator<=(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) <= 0; -} - -bool operator<=(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) <= 0; -} - -bool operator>(const std::string &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) > 0; -} - -bool operator>(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) > 0; -} - -bool operator>=(const std::string &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator>=(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator>=(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) >= 0; -} - -bool operator>=(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) >= 0; -} - -bool operator!=(const std::string &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - -bool operator!=(const IdentifierB &s1, const std::string &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - -bool operator!=(const IdentifierB &s1, const char *s2) { - return compare(s1.c_str(), s1.length(), s2, std::strlen(s2)) != 0; -} - -bool operator!=(const IdentifierB &s1, const IdentifierB &s2) { - return compare(s1.c_str(), s1.length(), s2.c_str(), s2.length()) != 0; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.hpp deleted file mode 100644 index 6c68549493da..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Identifier.hpp +++ /dev/null @@ -1,258 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_IDENTIFIER_H -#define STK_UTIL_UTIL_IDENTIFIER_H - -#include -#include - -#include // boost 1.36.0 unordered_set not in the tr1 - -namespace std { -namespace tr1 { - using ::boost::unordered_set; -} -} - -namespace stk_classic { - -class IdentifierA -{ -public: - static int compare(const char *s1, const size_t s1_length, const char *s2, const size_t s2_length); - - IdentifierA() - {} - - IdentifierA(const IdentifierA &identifier) - : m_string(identifier.m_string) - {} - - explicit IdentifierA(const std::string &string) - : m_string(string) - {} - - explicit IdentifierA(const char *string) - : m_string(string) - {} - - IdentifierA &operator=(const IdentifierA &identifier) { - if (&identifier != this) - m_string = identifier.m_string; - return *this; - } - - IdentifierA &operator=(const std::string &string) { - m_string = string; - return *this; - } - - IdentifierA &operator+=(const IdentifierA &identifier) { - m_string.append(identifier.m_string); - return *this; - } - - IdentifierA &operator+=(const std::string &string) { - m_string.append(string); - return *this; - } - - const char *c_str() const { - return m_string.c_str(); - } - - const size_t length() const { - return m_string.length(); - } - - operator const std::string &() const { - return m_string; - } - -private: - std::string m_string; -}; - - -IdentifierA operator+(const IdentifierA &identifier1, const IdentifierA &identifier2); - -IdentifierA operator+(const IdentifierA &identifier1, const std::string &string2); - -std::string operator+(const std::string &string1, const IdentifierA &identifier2); - -std::ostream &operator<<(std::ostream &os, const IdentifierA &identifier); - -std::istream &operator>>(std::istream &is, IdentifierA &identifier); - -bool operator<(const std::string &s1, const IdentifierA &s2); - -bool operator<(const IdentifierA &s1, const std::string &s2); - -bool operator<(const IdentifierA &s1, const IdentifierA &s2); - -bool operator<(const IdentifierA &s1, const char *s2); - -bool operator==(const std::string &s1, const IdentifierA &s2); - -bool operator==(const IdentifierA &s1, const std::string &s2); - -bool operator==(const IdentifierA &s1, const IdentifierA &s2); - -bool operator==(const IdentifierA &s1, const char *s2); - -bool operator<=(const std::string &s1, const IdentifierA &s2); - -bool operator<=(const IdentifierA &s1, const std::string &s2); - -bool operator<=(const IdentifierA &s1, const IdentifierA &s2); - -bool operator<=(const IdentifierA &s1, const char *s2); - -bool operator>(const std::string &s1, const IdentifierA &s2); - -bool operator>(const IdentifierA &s1, const std::string &s2); - -bool operator>(const IdentifierA &s1, const IdentifierA &s2); - -bool operator>(const IdentifierA &s1, const char *s2); - -bool operator>=(const std::string &s1, const IdentifierA &s2); - -bool operator>=(const IdentifierA &s1, const std::string &s2); - -bool operator>=(const IdentifierA &s1, const IdentifierA &s2); - -bool operator>=(const IdentifierA &s1, const char *s2); - -bool operator!=(const std::string &s1, const IdentifierA &s2); - -bool operator!=(const IdentifierA &s1, const std::string &s2); - -bool operator!=(const IdentifierA &s1, const IdentifierA &s2); - -bool operator!=(const IdentifierA &s1, const char *s2); - - - - -class IdentifierB : public std::string -{ -public: - static int compare(const char *s1, const size_t s1_length, const char *s2, const size_t s2_length); - - IdentifierB() - {} - - IdentifierB(const IdentifierB &identifier) - : std::string(static_cast(identifier)) - {} - - explicit IdentifierB(const std::string &string) - : std::string(string) - {} - - explicit IdentifierB(const char *string) - : std::string(string) - {} - - IdentifierB &operator=(const IdentifierB &identifier) { - std::string::operator=(identifier); - return *this; - } - - IdentifierB &operator=(const std::string &string) { - std::string::operator=(string); - return *this; - } - - IdentifierB &operator=(const char *string) { - std::string::operator=(string); - return *this; - } -}; - -IdentifierB operator+(const IdentifierB &identifier1, const IdentifierB &identifier2); - -IdentifierB operator+(const IdentifierB &identifier1, const std::string &string2); - -IdentifierB operator+(const IdentifierB &identifier1, const char *string2); - -std::string operator+(const std::string &string1, const IdentifierB &identifier2); - -std::ostream &operator<<(std::ostream &os, const IdentifierB &identifier); - -std::istream &operator>>(std::istream &is, IdentifierB &identifier); - -bool operator<(const std::string &s1, const IdentifierB &s2); - -bool operator<(const IdentifierB &s1, const std::string &s2); - -bool operator<(const IdentifierB &s1, const IdentifierB &s2); - -bool operator<(const IdentifierB &s1, const char *s2); - -bool operator==(const std::string &s1, const IdentifierB &s2); - -bool operator==(const IdentifierB &s1, const std::string &s2); - -bool operator==(const IdentifierB &s1, const IdentifierB &s2); - -bool operator==(const IdentifierB &s1, const char *s2); - -bool operator<=(const std::string &s1, const IdentifierB &s2); - -bool operator<=(const IdentifierB &s1, const std::string &s2); - -bool operator<=(const IdentifierB &s1, const IdentifierB &s2); - -bool operator<=(const IdentifierB &s1, const char *s2); - -bool operator>(const std::string &s1, const IdentifierB &s2); - -bool operator>(const IdentifierB &s1, const std::string &s2); - -bool operator>(const IdentifierB &s1, const IdentifierB &s2); - -bool operator>(const IdentifierB &s1, const char *s2); - -bool operator>=(const std::string &s1, const IdentifierB &s2); - -bool operator>=(const IdentifierB &s1, const std::string &s2); - -bool operator>=(const IdentifierB &s1, const IdentifierB &s2); - -bool operator>=(const IdentifierB &s1, const char *s2); - -bool operator!=(const std::string &s1, const IdentifierB &s2); - -bool operator!=(const IdentifierB &s1, const std::string &s2); - -bool operator!=(const IdentifierB &s1, const IdentifierB &s2); - -bool operator!=(const IdentifierB &s1, const char *s2); - -} // namespace stk_classic - -namespace boost { - -template <> -struct hash -{ - std::size_t operator()(const stk_classic::IdentifierA &s) const; -}; - -template <> -struct hash -{ - std::size_t operator()(const stk_classic::IdentifierB &s) const; -}; - -} // namespace boost - -#endif // STK_UTIL_UTIL_IDENTIFIER_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/IndentStreambuf.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/IndentStreambuf.hpp deleted file mode 100644 index d131ab7e181f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/IndentStreambuf.hpp +++ /dev/null @@ -1,388 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_INDENTSTREAMBUF_HPP -#define STK_UTIL_UTIL_INDENTSTREAMBUF_HPP - -#include -#include - -namespace stk_classic { - -static const char PUSH = '\016'; ///< Meta-character to increase indentation -static const char POP = '\017'; ///< Meta-character to decrease indentation -static const char LEFT = '\021'; ///< Meta-character to force left justification - -/** - * @brief Class basic_indent_streambuf implements a output streambuf that performs - * indentation, blank line removal and outline bracing, sending the result character stream to - * another output stream buffer. - * - * When, the meta-characters PUSH, POP, and LEFT are inserted into the stream buffer, the characters - * is discarded and the appropriate operation occurs. In the case of PUSH, the next line will - * indented by an additional m_indentSize spaces and the currently line will end with an - * open brace ({) is BRACES are enabled. In the case of POP, the next line will be indented by - * m_indentSize spaces, it may be preceeded by a line containing a properly indented close - * brace (}). In the case of LEFT, the next line (current line if at the start), will not be - * indented. - * - * The stream bufer can be created with BRACES and BLANK_LINES enabled or disabled. When BRACE is - * enabled, then indentation will be produces braces which allows editors to traverse blocks. Blank - * lines are normally eliminated, but may be allowed if BLANK_LINES is specified. - * - */ -template > -class basic_indent_streambuf : public std::basic_streambuf -{ -public: - enum { - MAX_INDENT_LEVEL = 50 ///< Maximum indentation level - }; - - /** - * @brief Class Flags ... - * - */ - enum Flags { - NO_BRACES = 0x00, ///< No braces on indentation shift - NO_BLANK_LINES = 0x00, ///< No blank line are written - BRACES = 0x01, ///< Braces on indentation shift - BLANK_LINES = 0x02 ///< Blank line are written - }; - - /** - * Creates a new basic_indent_streambuf instance. - * - * @param indent_size a size_t value of the number of spaces for each indentation - * level. - * - * @param flags an unsigned int value of Flags to enable or disable - * BLANK_LINES and BRACES. - * - */ - explicit basic_indent_streambuf(std::basic_streambuf *stream_buffer, size_t indent_size = 2, unsigned flags = BRACES) - : m_streamBuffer(stream_buffer), - m_atLineBegin(true), - m_leftJustify(false), - m_indentLevel(0), - m_nextIndentLevel(0), - m_indentSize(indent_size), - m_flags((Flags) flags), - m_indentString(0) - { - set_indent_size(indent_size); - } - - /** - * Destroys a basic_indent_streambuf instance. - * - */ - virtual ~basic_indent_streambuf() { - delete[] m_indentString; - } - - /** - * @brief Member function redirect sets the destination output stream buffer. - * - */ - void redirect(std::basic_streambuf *stream_buffer) { - m_streamBuffer = stream_buffer; - } - - /** - * @brief Member function get_stream_buffer returns the current destination output stream - * buffer. - * - * @return a std::streambuf pointer to the current destination output - * stream buffer. - */ - std::streambuf *get_stream_buffer() { - return m_streamBuffer; - } - - /** - * @brief Member function set_indent_size set the number of spaces to write for each - * indentation level. - * - * @param indent_size a size_t value of the number of spaces for each indentation - * level. - * - */ - void set_indent_size(size_t indent_size) { - m_indentSize = indent_size; - - delete[] m_indentString; - m_indentString = new Ch[MAX_INDENT_LEVEL*m_indentSize]; - std::fill(m_indentString, m_indentString + MAX_INDENT_LEVEL*m_indentSize, static_cast(' ')); - } - - /** - * @brief Member function set_flags enables or disables the BLANK_LINES and BRACES written - * to the destination stream. - * - * @param flags an unsigned int value of the Flags to enable/disable. - * - */ - void set_flags(unsigned flags) { - m_flags = (Flags) flags; - } - - -private: - /** - * @brief Member function indent_level returns the current indentation level. - * - * @return a size_t value of the current indentation level. - */ - size_t indent_level() { - return std::min(m_indentLevel*m_indentSize, (size_t) MAX_INDENT_LEVEL*m_indentSize); - } - - /** - * @brief Member function prefix prints the indentation spaces only at the beginning of the - * line and no left justification. - * - */ - void prefix() { - if (m_atLineBegin) { - if (!m_leftJustify) - m_streamBuffer->sputn(m_indentString, indent_level()); - m_leftJustify = false; - m_atLineBegin = false; - } - } - - /** - * @brief Member function next_line prints the braces for indentation. - * - */ - void next_line() { - if (m_nextIndentLevel > m_indentLevel) { - if (m_flags & BRACES) - m_streamBuffer->sputn(" {", 2); - m_streamBuffer->sputc(Tr::to_int_type('\n')); - } - else if (m_nextIndentLevel < m_indentLevel) { - m_indentLevel = m_nextIndentLevel; - if (!m_atLineBegin) - m_streamBuffer->sputc(Tr::to_int_type('\n')); - if (m_flags & BRACES) { - m_streamBuffer->sputn(m_indentString, indent_level()); - m_streamBuffer->sputc(Tr::to_int_type('}')); - m_streamBuffer->sputc(Tr::to_int_type('\n')); - } - } - else if (!m_atLineBegin || (m_flags & BLANK_LINES)) - m_streamBuffer->sputc(Tr::to_int_type('\n')); - - m_indentLevel = m_nextIndentLevel; - m_atLineBegin = true; - } - -public: - /** - * @brief Member function overflow interprets a meta-character or writes the specified - * character to the destination output stream buffer. If the character is a meta-character, the - * aproprate action is performed. - * - * @param c an int value of the character to write. - * - * @return an int value of the character written. - */ - virtual typename std::basic_streambuf::int_type overflow(typename std::basic_streambuf::int_type c) { - if (c == Tr::to_int_type('\n')) - next_line(); - else if (c == Tr::to_int_type(POP)) { - if (m_nextIndentLevel != m_indentLevel) - next_line(); - if (m_indentLevel > 0) - m_nextIndentLevel = m_indentLevel - 1; - } - else if (c == Tr::to_int_type(PUSH)) { - if (m_nextIndentLevel != m_indentLevel) - next_line(); - m_nextIndentLevel = m_indentLevel + 1; - } - else if (c == Tr::to_int_type(LEFT)) { - m_leftJustify = true; - } - else { - prefix(); - m_streamBuffer->sputc(c); - } - - return c; - } - - /** - * @brief Member function xsputn interprets the meta-characters or writes the specified - * characters to the destination output stream buffer. If a character is a meta-character, the - * aproprate action is performed. - * - * @param p a Ch const pointer to the character string to write. - * - * @param n a std::streamsize value of the number of characters in the - * string. - * - * @return a std::streamsize value of the number of characters os the - * string which were interpreted or written. - */ - virtual std::streamsize xsputn(const Ch *p, std::streamsize n) { - const Ch *p_end = p + n; - for (const Ch *q = p; q != p_end; ++q) { - -// If at start of line, PUSH and POP have immediate effect - if (p == q && m_atLineBegin) { - if (Tr::to_int_type(*p) == Tr::to_int_type('\n')) { - next_line(); - ++p; - } - else if (Tr::to_int_type(*p) == Tr::to_int_type(POP)) { - ++p; - if (m_nextIndentLevel != m_indentLevel) - next_line(); - if (m_indentLevel > 0) - m_nextIndentLevel = m_indentLevel - 1; - } - else if (Tr::to_int_type(*p) == Tr::to_int_type(PUSH)) { - ++p; - if (m_nextIndentLevel != m_indentLevel) - next_line(); - m_nextIndentLevel = m_indentLevel + 1; - } - else if (Tr::to_int_type(*p) == Tr::to_int_type(LEFT)) { - ++p; - m_leftJustify = true; - } - } - -// If not at start, PUSH and POP are for the next line. - else { - if (Tr::to_int_type(*q) == Tr::to_int_type('\n')) { - prefix(); - m_streamBuffer->sputn(p, q - p); - next_line(); - p = q + 1; - } - else if (Tr::to_int_type(*q) == Tr::to_int_type(POP)) { - prefix(); - m_streamBuffer->sputn(p, q - p); - p = q + 1; - if (m_nextIndentLevel != m_indentLevel) - next_line(); - if (m_indentLevel > 0) - m_nextIndentLevel = m_indentLevel - 1; - } - else if (Tr::to_int_type(*q) == Tr::to_int_type(PUSH)) { - prefix(); - m_streamBuffer->sputn(p, q - p); - p = q + 1; - if (m_nextIndentLevel != m_indentLevel) - next_line(); - m_nextIndentLevel = m_indentLevel + 1; - } - else if (Tr::to_int_type(*q) == Tr::to_int_type(LEFT)) { - m_leftJustify = true; - p = q + 1; - } - } - } - if (p != p_end) { - prefix(); - m_streamBuffer->sputn(p, p_end - p); - m_atLineBegin = false; - } - - return n; - } - - /** - * @brief Member function sync syncs the destination output stream buffer. - * - * @return an int value result of the pub sync operation. - */ - virtual int sync() { - return m_streamBuffer->pubsync(); - } - -private: - basic_indent_streambuf(const basic_indent_streambuf &); - basic_indent_streambuf &operator=(const basic_indent_streambuf &); - -private: - std::streambuf * m_streamBuffer; ///< Pointer to destination output stream buffer - bool m_atLineBegin; ///< Flag indicating at beginning of line - bool m_leftJustify; ///< Flag indicating next (current) line is to be left justified - size_t m_indentLevel; ///< Current indentation level - size_t m_nextIndentLevel; ///< Next line indentation level - size_t m_indentSize; ///< Number of characters to print for each indentation level - Flags m_flags; ///< BLANK_LINES and BRACES flags - Ch * m_indentString; ///< Character string used to write indentation spaces -}; - -template -std::basic_ostream &push(std::basic_ostream &os) { - os.put(PUSH); -// os.put('\n'); - os.flush(); - return os; -} - -template -std::basic_ostream &pop(std::basic_ostream &os) { - os.put(POP); -// os.put('\n'); - os.flush(); - return os; -} - - -template -class indent_streambuf_throwsafe -{ - explicit indent_streambuf_throwsafe(basic_indent_streambuf &sb) - : m_indentStreambuf(sb), - m_indentLevel(sb.indent_level()) - {} - - ~indent_streambuf_throwsafe() { - while (m_indentStreambuf.indent_level() > m_indentLevel) - m_indentStreambuf.pop(); - } - -private: - basic_indent_streambuf & m_indentStreambuf; - size_t m_indentLevel; -}; - - -struct IndentFlags { - int m_flags; -}; - -inline IndentFlags indent_flags(int flags) { - IndentFlags f; - f.m_flags = flags; - return f; -} - -template -std::basic_ostream & -operator<<(std::basic_ostream &os, IndentFlags indent_flags) { - basic_indent_streambuf *osb = dynamic_cast *>(os.rdbuf()); - if (osb) - osb->set_flags(indent_flags.m_flags); - - return os; -} - -typedef stk_classic::basic_indent_streambuf indent_streambuf; - -} // namespace stk_classic - -#endif // STK_UTIL_UTIL_INDENTSTREAMBUF_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/IndexList.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/IndexList.hpp deleted file mode 100644 index 3c6f7e6f01f3..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/IndexList.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_util_util_IndexList_h -#define stk_util_util_IndexList_h - -namespace stk_classic { - -/** \brief Compile-time list of indices. - * \ingroup util_module - */ -template< unsigned I0 = 0 , unsigned I1 = 0 , - unsigned I2 = 0 , unsigned I3 = 0 , - unsigned I4 = 0 , unsigned I5 = 0 , - unsigned I6 = 0 , unsigned I7 = 0 , - unsigned I8 = 0 , unsigned I9 = 0 , - unsigned I10 = 0 , unsigned I11 = 0 , - unsigned I12 = 0 , unsigned I13 = 0 , - unsigned I14 = 0 , unsigned I15 = 0 , - unsigned I16 = 0 , unsigned I17 = 0 , - unsigned I18 = 0 , unsigned I19 = 0 , - unsigned I20 = 0 , unsigned I21 = 0 , - unsigned I22 = 0 , unsigned I23 = 0 , - unsigned I24 = 0 , unsigned I25 = 0 , - unsigned I26 = 0 , unsigned I27 = 0 , - unsigned I28 = 0 , unsigned I29 = 0 , - unsigned I30 = 0 , unsigned I31 = 0 > -struct IndexList {}; - -/** \brief Access member of compile-time list of indices.
- * Defines enum { value = index_at_J }; - * \ingroup util_module - */ -template< class List , unsigned J > struct IndexListAt {}; - -#define INDEX_LIST_AT_SPECIALIZATION( J , K ) \ - template< unsigned I0 , unsigned I1 , \ - unsigned I2 , unsigned I3 , \ - unsigned I4 , unsigned I5 , \ - unsigned I6 , unsigned I7 , \ - unsigned I8 , unsigned I9 , \ - unsigned I10 , unsigned I11 , \ - unsigned I12 , unsigned I13 , \ - unsigned I14 , unsigned I15 , \ - unsigned I16 , unsigned I17 , \ - unsigned I18 , unsigned I19 , \ - unsigned I20 , unsigned I21 , \ - unsigned I22 , unsigned I23 , \ - unsigned I24 , unsigned I25 , \ - unsigned I26 , unsigned I27 , \ - unsigned I28 , unsigned I29 , \ - unsigned I30 , unsigned I31 > \ -struct IndexListAt< \ - IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 , \ - I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 , \ - I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \ - I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , J > \ -{ enum { value = K }; }; - -INDEX_LIST_AT_SPECIALIZATION( 0 , I0 ) -INDEX_LIST_AT_SPECIALIZATION( 1 , I1 ) -INDEX_LIST_AT_SPECIALIZATION( 2 , I2 ) -INDEX_LIST_AT_SPECIALIZATION( 3 , I3 ) -INDEX_LIST_AT_SPECIALIZATION( 4 , I4 ) -INDEX_LIST_AT_SPECIALIZATION( 5 , I5 ) -INDEX_LIST_AT_SPECIALIZATION( 6 , I6 ) -INDEX_LIST_AT_SPECIALIZATION( 7 , I7 ) -INDEX_LIST_AT_SPECIALIZATION( 8 , I8 ) -INDEX_LIST_AT_SPECIALIZATION( 9 , I9 ) -INDEX_LIST_AT_SPECIALIZATION( 10 , I10 ) -INDEX_LIST_AT_SPECIALIZATION( 11 , I11 ) -INDEX_LIST_AT_SPECIALIZATION( 12 , I12 ) -INDEX_LIST_AT_SPECIALIZATION( 13 , I13 ) -INDEX_LIST_AT_SPECIALIZATION( 14 , I14 ) -INDEX_LIST_AT_SPECIALIZATION( 15 , I15 ) -INDEX_LIST_AT_SPECIALIZATION( 16 , I16 ) -INDEX_LIST_AT_SPECIALIZATION( 17 , I17 ) -INDEX_LIST_AT_SPECIALIZATION( 18 , I18 ) -INDEX_LIST_AT_SPECIALIZATION( 19 , I19 ) -INDEX_LIST_AT_SPECIALIZATION( 20 , I20 ) -INDEX_LIST_AT_SPECIALIZATION( 21 , I21 ) -INDEX_LIST_AT_SPECIALIZATION( 22 , I22 ) -INDEX_LIST_AT_SPECIALIZATION( 23 , I23 ) -INDEX_LIST_AT_SPECIALIZATION( 24 , I24 ) -INDEX_LIST_AT_SPECIALIZATION( 25 , I25 ) -INDEX_LIST_AT_SPECIALIZATION( 26 , I26 ) -INDEX_LIST_AT_SPECIALIZATION( 27 , I27 ) -INDEX_LIST_AT_SPECIALIZATION( 28 , I28 ) -INDEX_LIST_AT_SPECIALIZATION( 29 , I29 ) -INDEX_LIST_AT_SPECIALIZATION( 30 , I30 ) -INDEX_LIST_AT_SPECIALIZATION( 31 , I31 ) - -#undef INDEX_LIST_AT_SPECIALIZATION - -} // namespace stk_classic - -#endif // stk_util_util_IndexList_h - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/MallocUsed.h b/packages/stk/stk_classic/stk_util/stk_util/util/MallocUsed.h deleted file mode 100644 index 9b58b67d2d0b..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/MallocUsed.h +++ /dev/null @@ -1,38 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_MALLOCUSED_H -#define STK_UTIL_UTIL_MALLOCUSED_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR -size_t malloc_used(); -size_t malloc_footprint(); -size_t malloc_max_footprint(); -#else -inline size_t malloc_used() { - return 0; -} -inline size_t malloc_footprint() { - return 0; -} -inline size_t malloc_max_footprint() { - return 0; -} -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* STK_UTIL_UTIL_MALLOCUSED_H */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.cpp deleted file mode 100644 index 6766ec50fe16..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include - -namespace stk_classic { - -namespace { - -typedef std::map TypeNameMap; - -bool s_crcInitialized = false; ///< CRC table has been initialized -uint32_t s_crcTable[256]; ///< CRC lookup table -TypeNameMap s_typeNameMap; ///< CRC'd type name map - -uint32_t -crc32_reflect( - uint32_t seed, - const char c) -{ - uint32_t value = 0; - - // Swap bit 0 for bit 7, bit 1 For bit 6, etc.... - for(int i = 1; i < (c + 1); i++) { - if (seed & 1) - value |= (1 << (c - i)); - seed >>= 1; - } - - return value; -} - - -void -crc32_initialize() -{ - s_crcInitialized = true; - - //0x04C11DB7 is the official polynomial used by PKZip, WinZip and Ethernet. - uint32_t polynomial = 0x04C11DB7; - - std::fill(s_crcTable, s_crcTable + 256, 0); - - // 256 values representing ASCII character codes. - for (int i = 0; i <= 0xFF; i++) { - s_crcTable[i] = crc32_reflect(i, 8) << 24; - - for (int j = 0; j < 8; j++) - s_crcTable[i] = (s_crcTable[i] << 1) ^ ((s_crcTable[i] & (1u << 31)) ? polynomial : 0); - - s_crcTable[i] = crc32_reflect(s_crcTable[i], 32); - } -} - - -void -crc32_part( - uint32_t & crc, - const unsigned char * s, - unsigned l) -{ - while (l--) - crc = (crc >> 8)^s_crcTable[(crc & 0xFF)^*s++]; -} - - -uint32_t -crc32( - const unsigned char * s, - unsigned l) -{ - uint32_t crc = 0xffffffff; - crc32_part(crc, s, l); - return crc ^ 0xffffffff; -} - - -void -crc32_write( - std::stringstream & os, - const std::type_info & typeinfo) -{ - if (!s_crcInitialized) - crc32_initialize(); - - const char *name = typeinfo.name(); - unsigned length = std::strlen(name); - - uint32_t crc = crc32((const unsigned char *) name, length); - - TypeNameMap::iterator it = s_typeNameMap.find(crc); - if (it == s_typeNameMap.end()) - s_typeNameMap.insert(std::make_pair(crc, std::string(name))); - - os.write((const char *) &crc, sizeof(uint32_t)); -} - - -void -crc32_check( - std::stringstream & is, - const std::type_info & typeinfo) -{ - if (!s_crcInitialized) - crc32_initialize(); - - const char *name = typeinfo.name(); - unsigned length = std::strlen(name); - - uint32_t crc_check = crc32((const unsigned char *) name, length); - uint32_t crc = 0; - - { - TypeNameMap::iterator it = s_typeNameMap.find(crc_check); - if (it == s_typeNameMap.end()) - s_typeNameMap.insert(std::make_pair(crc_check, std::string(name))); - } - - is.read((char *) &crc, sizeof(uint32_t)); - - if (crc_check != crc) { - std::ostringstream ss; - ss << "Marshaller encountered type "; - TypeNameMap::const_iterator it = s_typeNameMap.find(crc); - if (it == s_typeNameMap.end()) - ss << "code " << std::hex << crc; - else - ss << (*it).second; - - ss << " when expecting type "; - it = s_typeNameMap.find(crc_check); - if (it == s_typeNameMap.end()) - ss << "code " << std::hex << crc_check; - else - ss << (*it).second; - - throw std::runtime_error(ss.str()); - } -} - -} // namespace - -Marshal::Marshal( - unsigned type_check) - : stream(std::ios_base::out), - m_typeCheck(TYPE_CHECK_NONE) -{ - (*this) << type_check; - m_typeCheck = type_check; -} - - -Marshal::Marshal( - const std::string & s) - : stream(s, std::ios_base::in), - m_typeCheck(TYPE_CHECK_NONE) -{ - (*this) >> m_typeCheck; -} - - -std::string -Marshal::str() const -{ - return stream.str(); -} - - -size_t -Marshal::size() const -{ - return stream.str().size(); -} - - -Marshal::operator void * () const -{ - return static_cast(const_cast(&stream)); -} - - -void -Marshal::write( - const char * address, - size_t byte_count) -{ - stream.write(address, byte_count); -} - - -void -Marshal::read( - char * address, - size_t byte_count) -{ - stream.read(address, byte_count); -} - - -template<> -Marshal &operator<<(Marshal &mout, const std::type_info &t) { - crc32_write(mout.stream, t); - return mout; -} - -template<> -Marshal &operator>>(Marshal &min, const std::type_info &t) { - crc32_check(min.stream, t); - return min; -} - -template<> -Marshal &operator<<(Marshal &mout, const signed char &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const unsigned char &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const char &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const short &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const unsigned short &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const int &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const unsigned int &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const long &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const unsigned long &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const long long &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const unsigned long long &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const float &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const double &t) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(t); - return write(mout, t); -} - -template<> -Marshal &operator<<(Marshal &mout, const std::string &s) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_POD) - mout << typeid(s); - - size_t ul = s.size(); - mout << ul; - mout.stream.write(s.data(), s.size()); - return mout; -} - - -template<> -Marshal &operator>>(Marshal &min, signed char &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, unsigned char &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, char &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, short &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, unsigned short &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, int &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, unsigned int &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, long &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, unsigned long &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, long long &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, unsigned long long &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, float &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, double &t) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(t); - return read(min, t); -} - -template<> -Marshal &operator>>(Marshal &min, std::string &s) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_POD) - min >> typeid(s); - - size_t size = 0; - min >> size; - std::vector c(size); - - min.stream.read(&c[0], size); - s.assign(&c[0], size); - - return min; -} - -} // namespace stk_classic diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.hpp deleted file mode 100644 index 176f3c9b877c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Marshal.hpp +++ /dev/null @@ -1,324 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_MARSHAL_HPP -#define STK_UTIL_UTIL_MARSHAL_HPP - -#include - -#include -#include -#include -#include -#include - -namespace stk_classic { - -/** - * @brief Struct Marshal is a data packer for sending and receiving parallel messages. - * The data put-to (<<) is appended to the stream as a string of bytes, likewise data gotten-from - * (>>) is extracted from the stream into the object as a string of bytes. - * - * The write() and read() functions perform the data movements to and from the packed stream. - * - * The common implementation is the create a << and >> operator for an object which properly appends - * and extracts the object's members. - * - * The object can put-to and get-from it's typeid() to add type checking. This operation ensures - * that the data types being read was the data type written before the data is extracted. This type - * checking can be disabled since it may be desired to put-to an object of one type, but get-from - * into an object of an extractable but different type. - * - * The TYPE_CHECK bit masks can be provided at put-to Marshal construction to activate the type - * checking. The Marshaller send the type check code as the first message to allow the get-from to - * initialize properly. - * - * The put-to operator and get-from operators for plain old data, std::string, std::vector and - * std::list have been implemented. Additional ones could be added here, or left to the developer - * using the marshaller. - * - * The stream and type_check members were left as public due to the extensive use. If this proves - * bothersome, getter/setter methods could be introduced. - * - */ -struct Marshal -{ - /** - * @brief Enumeration to activate type checking for std classes and plain old data. - * - */ - enum { - TYPE_CHECK_NONE = 0x00000000, - TYPE_CHECK_POD = 0x00000001, - TYPE_CHECK_LIST = 0x00000002, - TYPE_CHECK_VECTOR = 0x00000004, - TYPE_CHECK_ALL = 0xFFFFFFFF - }; - - /** - * Creates a new Marshal instance for put-to operations. - * - */ - Marshal(unsigned type_check = TYPE_CHECK_NONE); - - /** - * Creates a new Marshal instance for get-from operations. - * - * @param s a std::string constant variable of packed bytes to - * extract using the get-from operators. - */ - explicit Marshal(const std::string &s); - - /** - * @brief Member function str returns the string of packed bytes created by put-to - * operations to the stream. - * - * @return a std::string created from the packed byte stream. - */ - std::string str() const; - - /** - * @brief Member function size returns the byte count of the string of packed bytes - * creates by put-to operations to the stream. - * - * @return a size_t in bytes of the packed byte stream. - */ - size_t size() const; - - /** - * @brief Member function write writer bytes to the packed byte stream. - * - * @param byte_count a size_t value of the number of packed bytes to write. - * - * @param address a char constant pointer to get the bytes from. - * - */ - void write(const char *address, size_t byte_count); - - /** - * @brief Member function read reads bytes from the packed byte stream. - * - * @param byte_count a size_t value of the number of packed bytes to read. - * - * @param address a char constant pointer to put the bytes to. - * - */ - void read(char *address, size_t byte_count); - - /** - * @brief Member function operator void * returns the state of the packed byte stream. - * - * @return a void const pointer which is non-zero if status is - * good. - */ - operator void * () const; - -private: - Marshal(const Marshal &marshal); ///< Not copyable - Marshal &operator=(const Marshal &); ///< Not assignable - -public: - std::stringstream stream; ///< Packed byte stream to put-to or get-from - unsigned m_typeCheck; ///< Type checking to activate -}; - - -/** - * @brief Function operator<< writes the object to the packed byte stream. This is - * the template class and has no implementation. You must specialize this class to write an - * object. - * - * @param mout a Marshal reference to the marshaller. - * - * @param t a T const reference to the object to write. - * - * @return a Marshal reference to the marhsaller. - */ -template -Marshal &operator<<(Marshal &mout, const T &t); - -/** - * @brief Function operator>> reads the object from the packed byte stream. This is - * the template class and has no implementation. You must specialize this class to read an object. - * - * @param min a Marshal reference to the marshaller. - * - * @param t a T const reference to the object to read. - * - * @return a Marshal reference to the marhsaller. - */ -template -Marshal &operator>>(Marshal &min, T &t); - -/** - * @brief Function operator<< write the crc32 encoding of the name from the type - * information to the packed byte stream. When the bytes are read, the crc32 encoding of the type - * being read is varified. - * - * @param mout a Marshal reference to the marshaller. - * - * @param t a std::type_info const reference to the type - * information to write for verification when read on extraction. - * - * @return a Marshal reference to the marhsaller. - */ -template<> -Marshal &operator<<(Marshal &mout, const std::type_info &t); - -/** - * @brief Function operator<< reads the crc32 encoding of the name from the type - * information from the packed byte stream. The read crc32 is compared to the crc32 encoding of the - * name from the type information passed. If the two are different and exception is thrown. - * - * @param min a Marshal reference to the marshaller. - * - * @param t a std::type_info const reference to the type - * information to compare with the what was read from the packed byte - * stream. - * - * @return a Marshal reference to the marhsaller. - */ -template<> -Marshal &operator>>(Marshal &min, const std::type_info &t); - -template<> -Marshal &operator<<(Marshal &mout, const signed char &t); -template<> -Marshal &operator<<(Marshal &mout, const unsigned char &t); -template<> -Marshal &operator<<(Marshal &mout, const char &t); -template<> -Marshal &operator<<(Marshal &mout, const short &t); -template<> -Marshal &operator<<(Marshal &mout, const unsigned short &t); -template<> -Marshal &operator<<(Marshal &mout, const int &t); -template<> -Marshal &operator<<(Marshal &mout, const unsigned int &t); -template<> -Marshal &operator<<(Marshal &mout, const long &t); -template<> -Marshal &operator<<(Marshal &mout, const unsigned long &t); -template<> -Marshal &operator<<(Marshal &mout, const long long &t); -template<> -Marshal &operator<<(Marshal &mout, const unsigned long long &t); -template<> -Marshal &operator<<(Marshal &mout, const float &t); -template<> -Marshal &operator<<(Marshal &mout, const double &t); -template<> -Marshal &operator<<(Marshal &mout, const std::string &s); - -template<> -Marshal &operator>>(Marshal &min, signed char &t); -template<> -Marshal &operator>>(Marshal &min, unsigned char &t); -template<> -Marshal &operator>>(Marshal &min, char &t); -template<> -Marshal &operator>>(Marshal &min, short &t); -template<> -Marshal &operator>>(Marshal &min, unsigned short &t); -template<> -Marshal &operator>>(Marshal &min, int &t); -template<> -Marshal &operator>>(Marshal &min, unsigned int &t); -template<> -Marshal &operator>>(Marshal &min, long &t); -template<> -Marshal &operator>>(Marshal &min, unsigned long &t); -template<> -Marshal &operator>>(Marshal &min, long long &t); -template<> -Marshal &operator>>(Marshal &min, unsigned long long &t); -template<> -Marshal &operator>>(Marshal &min, float &t); -template<> -Marshal &operator>>(Marshal &min, double &t); -template<> -Marshal &operator>>(Marshal &min, std::string &s); - - -template -Marshal &operator<<(Marshal &mout, const std::vector &v) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_VECTOR) - mout << typeid(v); - - size_t size = v.size(); - mout << size; - for (typename std::vector::const_iterator it = v.begin(); it != v.end(); ++it) - mout << (*it); - - return mout; -} - -template -Marshal &operator>>(Marshal &min, std::vector &v) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_VECTOR) - min >> typeid(v); - - size_t size = 0; - min >> size; - v.reserve(size); - for (size_t i = 0; i < size; ++i) { - T t; - min >> t; - v.push_back(t); - } - - return min; -} - -template -Marshal &operator<<(Marshal &mout, const std::list &l) { - if (mout.m_typeCheck & Marshal::TYPE_CHECK_LIST) - mout << typeid(l); - - size_t size = l.size(); - mout << size; - for (typename std::list::const_iterator it = l.begin(); it != l.end(); ++it) - mout << (*it); - - return mout; -} - -template -Marshal &operator>>(Marshal &min, std::list &l) { - if (min.m_typeCheck & Marshal::TYPE_CHECK_LIST) - min >> typeid(l); - - size_t size; - min >> size; - for (size_t i = 0; i < size; ++i) { - T t; - min >> t; - l.push_back(t); - } - - return min; -} - -template -Marshal &write(Marshal &mout, const T &t) { - mout.write((const char *) &t, sizeof(T)); - - return mout; -} - -template -Marshal &read(Marshal &min, T &t) { - t = T(); - - min.read((char *) &t, sizeof(T)); - return min; -} - -} // namespace stk_classic - -#endif // STK_UTIL_UTIL_MARSHAL_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/NamedPair.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/NamedPair.hpp deleted file mode 100644 index 51611371ddc6..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/NamedPair.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_NamedPair_hpp -#define stk_util_util_NamedPair_hpp - -#define NAMED_PAIR( STRUCT_NAME , FIRST_TYPE , FIRST_NAME , SECOND_TYPE , SECOND_NAME ) \ -struct STRUCT_NAME { \ - typedef FIRST_TYPE first_type; \ - typedef SECOND_TYPE second_type; \ - \ - first_type FIRST_NAME ; \ - second_type SECOND_NAME ; \ - \ - STRUCT_NAME ( const first_type & arg_ ## FIRST_NAME , \ - const second_type & arg_ ## SECOND_NAME ) \ - : FIRST_NAME ( arg_ ## FIRST_NAME ) , \ - SECOND_NAME ( arg_ ## SECOND_NAME ) {} \ - \ - ~ STRUCT_NAME () {} \ - STRUCT_NAME () {} \ - STRUCT_NAME ( const STRUCT_NAME & arg_rhs ) \ - : FIRST_NAME ( arg_rhs. FIRST_NAME ) , \ - SECOND_NAME ( arg_rhs. SECOND_NAME ) {} \ - STRUCT_NAME & operator = ( const STRUCT_NAME & arg_rhs ) \ - { FIRST_NAME = arg_rhs. FIRST_NAME ; \ - SECOND_NAME = arg_rhs. SECOND_NAME ; \ - return *this ; } \ -}; \ -\ -inline \ -bool operator == ( const STRUCT_NAME & arg_lhs , \ - const STRUCT_NAME & arg_rhs ) \ - { return arg_lhs. FIRST_NAME == arg_rhs. FIRST_NAME && \ - arg_lhs. SECOND_NAME == arg_rhs. SECOND_NAME ; } \ -\ -inline \ -bool operator != ( const STRUCT_NAME & arg_lhs , \ - const STRUCT_NAME & arg_rhs ) \ - { return arg_lhs. FIRST_NAME != arg_rhs. FIRST_NAME || \ - arg_lhs. SECOND_NAME != arg_rhs. SECOND_NAME ; } \ -\ -inline \ -bool operator < ( const STRUCT_NAME & arg_lhs , \ - const STRUCT_NAME & arg_rhs ) \ - { return arg_lhs. FIRST_NAME < arg_rhs. FIRST_NAME || \ - ( ! ( arg_rhs. FIRST_NAME < arg_lhs. FIRST_NAME ) && \ - arg_lhs. SECOND_NAME < arg_rhs. SECOND_NAME ) ; } \ -\ -inline \ -bool operator > ( const STRUCT_NAME & arg_lhs , \ - const STRUCT_NAME & arg_rhs ) \ - { return operator < ( arg_rhs , arg_lhs ); } \ - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.cpp deleted file mode 100644 index 9bedf78b603f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** ------------------------------------------------------------ - * Copyright 2000-2008 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a - * non-exclusive license for use of this work by or on behalf - * of the U.S. Government. Export of this program may require - * a license from the United States Government. - * ------------------------------------------------------------ - */ - -#include - -/*--------------------------------------------------------------------*/ - -null_streambuf::null_streambuf() : std::streambuf() -{ - setp( buf , buf + sizeof(buf) ); -} - -null_streambuf::~null_streambuf() {} - -/*--------------------------------------------------------------------*/ -/* Overflow */ - -int null_streambuf::overflow( int c ) -{ - setp( buf , buf + sizeof(buf) ); - - return c ; -} - -/*--------------------------------------------------------------------*/ - -int null_streambuf::sync() -{ - return 0 ; -} - -std::streambuf * null_streambuf::setbuf( char * s , std::streamsize n ) -{ - return this ; -} - - - - -/*--------------------------------------------------------------------*/ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.hpp deleted file mode 100644 index b0ee6cad930c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Null_Streambuf.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------------------------------ */ -/* Copyright 2000 Sandia Corporation, Albuquerque, NM. */ -/* ------------------------------------------------------------------ */ - -#ifndef STK_UTIL_UTIL_null_streambuf_hpp -#define STK_UTIL_UTIL_null_streambuf_hpp - -#include -#include /* Defines EOF */ - -//: Specialize the ANSI Standard C++ streambuf class -//: that throws away everything given to it without -//: generating an error. - -class null_streambuf : public std::streambuf { -public: - - //: Constructor - null_streambuf(); - - //: Destructor - virtual ~null_streambuf(); - -protected: - - //: Called when output buffer is filled - virtual int overflow( int c = EOF ); - - //: Sync is a no-op - virtual int sync(); - - //: Setbuf is a no-op - virtual std::streambuf * setbuf( char * s , std::streamsize n ); - -private: - - null_streambuf( const null_streambuf & ); // Not allowed - null_streambuf & operator = ( const null_streambuf & ); // Not allowed - - char buf[64]; // Throw away buffer -}; - -/*--------------------------------------------------------------------*/ - -#endif // STK_UTIL_UTIL_null_streambuf_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/PairIter.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/PairIter.hpp deleted file mode 100644 index 3047c315d1e2..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/PairIter.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_PairIter_hpp -#define stk_util_util_PairIter_hpp - -#include -#include - -namespace stk_classic { - - -template< class IterType , - class IterCategory = - typename std::iterator_traits< IterType >::iterator_category > -class PairIter ; - -//---------------------------------------------------------------------- -// Specialized for random access iterators, others TBD. - -/// -/// @addtogroup util_module -/// @{ - -/** @class PairIter - * Iterate a span of a container defined by begin and end iterators. - * Provides forward iterator and const container-like functionality. - */ -template< class IterType > -class PairIter< IterType , std::random_access_iterator_tag > - : public std::pair< IterType , IterType > -{ -private: - typedef std::pair< IterType , IterType > Pair ; - typedef PairIter< IterType , std::random_access_iterator_tag > Self ; - typedef std::iterator_traits< IterType > Traits ; -public: - - //-------------------------------- - - typedef IterType iterator ; - typedef typename Traits::value_type value_type ; - typedef typename Traits::pointer pointer ; - typedef typename Traits::reference reference ; - typedef typename Traits::difference_type difference_type ; - typedef size_t size_type ; - - //-------------------------------- - - /** @brief Destructor - */ - ~PairIter() {} - - /** Constructor */ - PairIter() : Pair() { Pair::second = Pair::first ; } - - PairIter( const Self & rhs ) : Pair( rhs ) {} - - PairIter( const Pair & rhs ) : Pair( rhs ) {} - - Self & operator = ( const Self & rhs ) - { Pair::first = rhs.first ; Pair::second = rhs.second ; return *this ; } - - Self & operator = ( const Pair & rhs ) - { Pair::first = rhs.first ; Pair::second = rhs.second ; return *this ; } - - //-------------------------------- - - bool operator == ( const Self & rhs ) const - { return Pair::first == rhs.first && Pair::second == rhs.second ; } - - bool operator != ( const Self & rhs ) const - { return Pair::first != rhs.first || Pair::second != rhs.second ; } - - bool operator == ( const Pair & rhs ) const - { return Pair::first == rhs.first && Pair::second == rhs.second ; } - - bool operator != ( const Pair & rhs ) const - { return Pair::first != rhs.first || Pair::second != rhs.second ; } - - //-------------------------------- - - Self & operator ++ () { ++ Pair::first ; return *this ; } - - Self operator ++ (int) { Self tmp(*this); ++ Pair::first ; return tmp ; } - - reference operator * () const { return * Pair::first ; } - pointer operator -> () const { return & * Pair::first ; } - - //-------------------------------- - // Container-like functionality for random access iterators. - - reference front() const { return * Pair::first ; } - reference back() const { return Pair::second[-1] ; } - - iterator begin() const { return Pair::first ; } - iterator end() const { return Pair::second ; } - - template - PairIter( Iterator i , Iterator e ) : Pair(i,e) {} - - template - explicit - PairIter( const Container & c ) : Pair( c.begin() , c.end() ) {} - - template - explicit - PairIter( Container & c ) : Pair( c.begin() , c.end() ) {} - - bool empty () const { return ! ( Pair::first < Pair::second ) ; } - - reference operator [] ( size_t n ) const { return Pair::first[n] ; } - - size_t size() const - { - const difference_type d = std::distance( Pair::first , Pair::second ); - return d < 0 ? 0 : (size_t) d ; - } -}; - -/// -/// @} -/// - -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Pool.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/Pool.cpp deleted file mode 100644 index a4e34bf986d5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Pool.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2005 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#include - -namespace stk_classic { -namespace util { - -Pool::Pool(unsigned int sz) - : chunks(NULL), - esize(sznext; - delete p; - } -} - -void -Pool::grow() -{ - //allocate new chunk, organize it as a linked list of elements of size 'esize' - Chunk* n = new Chunk; - n->next = chunks; - chunks = n; - - const int nelem = Chunk::size/esize; - char* start = n->mem; - char* last = &start[ (nelem-1)*esize ]; - for(char* p=start; p(p)->next = reinterpret_cast(p+esize); - } - reinterpret_cast(last)->next = NULL; - head = reinterpret_cast(start); -} - -}//namespace util -}//namespace stk_classic - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Pool.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Pool.hpp deleted file mode 100644 index 7165c203c899..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Pool.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2005 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - -#ifndef _stk_util_util_Pool_hpp_ -#define _stk_util_util_Pool_hpp_ - -#include - -#ifndef STK_UTIL_POOL_ALLOC_CHUNK_SIZE_K -#define STK_UTIL_POOL_ALLOC_CHUNK_SIZE_K 512 -#endif - -//The macro STK_UTIL_POOL_ALLOC_CHUNK_SIZE_K determines the number -//of kilobytes that each internally-allocated chunk of memory will -//occupy. The Pool object will then dispense "sub-chunks" -//of memory having size determined by the argument to the class -//constructor. - -namespace stk_classic { -namespace util { -class Pool { - public: - Pool(unsigned int nbytes); // nbytes is the size of elements - ~Pool(); - - void* alloc(); //allocate one element - void free(void* b); //put an element back into the pool - struct Link { Link* next; }; - - private: - struct Chunk { - //Stroustrup's comment: - //slightly less than specified K so that a chunk will fit in - //allocation area first to get stringent alignment - enum { size = STK_UTIL_POOL_ALLOC_CHUNK_SIZE_K*1024-16 }; - char mem[size]; - Chunk* next; - }; - - Chunk* chunks; - const unsigned int esize; - Link* head; - - Pool(const Pool&);//private copy constructor - Pool& operator=(const Pool&);//private assignment operator - void grow(); //make pool larger -}; - -inline void* Pool::alloc() -{ - if (head == NULL) { - grow(); - } - Link* p = head; //return first element - head = p->next; - return p; -} - -inline void Pool::free(void* b) -{ - Link* p = static_cast(b); - p->next = head; //put b back as first element - head = p; -} - -}//namespace util -}//namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/RadixSort.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/RadixSort.hpp deleted file mode 100644 index 64d1a5420b9e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/RadixSort.hpp +++ /dev/null @@ -1,347 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -// Portions of this source code file are: -// Copyright (c) 2010, Victor J. Duvanenko. -// All rights reserved. -// Used with permission. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * The name of Victor J. Duvanenko may not be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef STK_UTIL_UTIL_RADIXSORT_HPP -#define STK_UTIL_UTIL_RADIXSORT_HPP - -// -// Internal implementation -// -namespace { // anonymous namespace - -// Swap that does not check for self-assignment. -template< class T > -inline void swap_impl( T& a, T& b ) -{ - T tmp = a; - a = b; - b = tmp; -} - -// insertion sort similar to STL with no self-assignment -template -inline void insertion_sort_impl( T* a, size_t a_size ) -{ - for ( size_t i = 1; i < a_size; ++i ) - { - if ( a[ i ] < a[ i - 1 ] ) // no need to do (j > 0) compare for the first iteration - { - T currentElement = a[ i ]; - a[ i ] = a[ i - 1 ]; - size_t j; - for ( j = i - 1; j > 0 && currentElement < a[ j - 1 ]; --j ) - { - a[ j ] = a[ j - 1 ]; - } - a[ j ] = currentElement; // always necessary work/write - } - // Perform no work at all if the first comparison fails - i.e. never assign an element to itself! - } -} - -// Recursive implementation of radix sort for unsigned integer types only. -// -// PowerOfTwoRadix - must be a power of 2, 256 is suggested for current hardware as of 03/20/2011. -// Log2ofPowerOfTwoRadix - for example log( 256 ) = 8 -// Threshold - length below which array sections are sorted with an insertion sort -// a - pointer to start of an array of integer type -// last - one less than the length of the a array -// bitMask - controls how many and which bits we process at a time -// shiftRightAmount - sizeof(T) * 8 - Log2ofPowerOfTwoRadix -template< class T, unsigned long PowerOfTwoRadix, unsigned long Log2ofPowerOfTwoRadix, long Threshold > -inline void radix_sort_unsigned_impl( T* a, long last, T bitMask, unsigned long shiftRightAmount ) -{ - unsigned long count[ PowerOfTwoRadix ]; - for( unsigned long i = 0; i < PowerOfTwoRadix; ++i ) count[ i ] = 0; - for ( long _current = 0; _current <= last; ++_current ) count[ (unsigned long)(( a[ _current ] & bitMask ) >> shiftRightAmount ) ]++; // Scan the array and count the number of times each value appears - - long startOfBin[ PowerOfTwoRadix + 1 ], endOfBin[ PowerOfTwoRadix ], nextBin = 1; - startOfBin[ 0 ] = endOfBin[ 0 ] = 0; startOfBin[ PowerOfTwoRadix ] = -1; // sentinel - for( unsigned long i = 1; i < PowerOfTwoRadix; ++i ) - startOfBin[ i ] = endOfBin[ i ] = startOfBin[ i - 1 ] + count[ i - 1 ]; - - for ( long _current = 0; _current <= last; ) - { - unsigned long digit; - T _current_element = a[ _current ]; // get the compiler to recognize that a register can be used for the loop instead of a[_current] memory location - while( endOfBin[ digit = (unsigned long)(( _current_element & bitMask ) >> shiftRightAmount )] != _current ) swap_impl( _current_element, a[ endOfBin[ digit ]++ ] ); - a[ _current ] = _current_element; - - endOfBin[ digit ]++; - while( endOfBin[ nextBin - 1 ] == startOfBin[ nextBin ] ) ++nextBin; // skip over empty and full bins, when the end of the current bin reaches the start of the next bin - _current = endOfBin[ nextBin - 1 ]; - } - bitMask >>= Log2ofPowerOfTwoRadix; - if ( bitMask != 0 ) // end recursion when all the bits have been processes - { - if ( shiftRightAmount >= Log2ofPowerOfTwoRadix ) shiftRightAmount -= Log2ofPowerOfTwoRadix; - else shiftRightAmount = 0; - - for( unsigned long i = 0; i < PowerOfTwoRadix; ++i ) - { - long numberOfElements = endOfBin[ i ] - startOfBin[ i ]; - if ( numberOfElements >= Threshold ) // endOfBin actually points to one beyond the bin - radix_sort_unsigned_impl< T, PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( &a[ startOfBin[ i ]], numberOfElements - 1, bitMask, shiftRightAmount ); - else if ( numberOfElements >= 2 ) - insertion_sort_impl( &a[ startOfBin[ i ]], numberOfElements ); - } - } -} - -} // end anonymous namespace - -// -// Public API -// -namespace stk_classic { -namespace util { - -/** - * Sort a contiguous array of unsigned 8-, 16-, 32- or 64-bit integers in place, - * using an unstable MSD radix sort algorithm. - *

- * This MSD radix sort algorithm is O(N k/d), where N is the number of items to be sorted, - * k, the size of each key, and d, the digit size used by the implementation. Additional - * memory used is (k/d 2^d) (k/d recursion levels, 2^d for count array). - *

- *

- * For comparison, the std::sort algorithm is O(N logN), and uses (log N) additional memory. - * The MSD radix sort on unsigned integers typically outperforms the std::sort by using less - * than half the CPU time for 64-bit integers. - *

- *

- * TODO: Also consider the threaded TBB implementation below of the MSD radix sort. - *

- * - * @param a pointer to the start of a contiguous array of unsigned or signed type - * @param a_size length of the array (must be less than MAX_LONG) - */ -template< class T > -void radix_sort_unsigned( T* a, size_t a_size ) -{ - const long Threshold = 25; // smaller array sections sorted by insertion sort - const unsigned long PowerOfTwoRadix = 256; // Radix - must be a power of 2 - const unsigned long Log2ofPowerOfTwoRadix = 8; // log( 256 ) = 8 - - if ( a_size >= (size_t)Threshold ) { - if (a_size > (size_t)std::numeric_limits::max()) { - std::ostringstream msg ; - msg << "stk_classic::utility::radix_sort() exceeded allowable array size ("; - msg << a_size << " < " << std::numeric_limits::max() << ")"; - throw std::runtime_error( msg.str() ); - } - unsigned long shiftRightAmount = sizeof(T) * 8 - Log2ofPowerOfTwoRadix; - T bitMask = (T)( ((T)( PowerOfTwoRadix - 1 )) << shiftRightAmount ); // bitMask controls/selects how many and which bits we process at a time - radix_sort_unsigned_impl< T, PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( a, a_size - 1, bitMask, shiftRightAmount ); - } - else - insertion_sort_impl( a, a_size ); -} - -} // namespace util -} // namespace stk_classic - - -//-------------------------------------- -// PARALLEL RADIX SORT using TBB library -//-------------------------------------- - -/* TODO: this code works with TBB, it just needs minor modifications and some renaming -template< unsigned long PowerOfTwoRadix, unsigned long Log2ofPowerOfTwoRadix, long Threshold, class T > -class RadixInPlaceOperation_3 -{ - T* my_a; // a local copy to the input array to provide a pointer to each parallel task - long* my_startOfBin; - long* my_endOfBin; - T my_bitMask; // a local copy of the bitMask - unsigned long my_shiftRightAmount; - static const unsigned long Threshold_P = 10000; // threshold when to switch between parallel and non-parallel implementations -public: - static const unsigned long numberOfBins = PowerOfTwoRadix; - unsigned long my_count[ numberOfBins ]; // the count for this task - - RadixInPlaceOperation_3( T a[], long* startOfBin, long* endOfBin, T bitMask, unsigned long shiftRightAmount ) : - my_a( a ), my_startOfBin( startOfBin ), my_endOfBin( endOfBin ), - my_bitMask( bitMask ), my_shiftRightAmount( shiftRightAmount ) - {} - void operator()( const blocked_range< long >& r ) const - { - for( long i = r.begin(); i != r.end(); ++i ) - { - long numOfElements = my_endOfBin[ i ] - my_startOfBin[ i ]; - if ( numOfElements >= Threshold_P ) - _RadixSort_Unsigned_PowerOf2Radix_3< PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( &my_a[ my_startOfBin[ i ]], numOfElements - 1, my_bitMask, my_shiftRightAmount ); - else if ( numOfElements >= Threshold ) - _RadixSort_Unsigned_PowerOf2Radix_1< PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( &my_a[ my_startOfBin[ i ]], numOfElements - 1, my_bitMask, my_shiftRightAmount ); - else if ( numOfElements >= 2 ) - insertion_sort_impl( &my_a[ my_startOfBin[ i ]], numOfElements ); - } - } -}; - -template< unsigned long PowerOfTwoRadix, unsigned long Log2ofPowerOfTwoRadix, long Threshold, class T > -inline void _RadixSort_Unsigned_PowerOf2Radix_3( T* a, long last, T bitMask, unsigned long shiftRightAmount ) -{ - const unsigned long numberOfBins = PowerOfTwoRadix; - - CountingType_1< PowerOfTwoRadix, T > count( a, bitMask, shiftRightAmount ); // contains the count array, which is initialized to all zeros - // Scan the array and count the number of times each value appears - parallel_reduce( blocked_range< unsigned long >( 0, last + 1, 1000 ), count ); - - long startOfBin[ numberOfBins ], endOfBin[ numberOfBins ], nextBin; - startOfBin[ 0 ] = endOfBin[ 0 ] = nextBin = 0; - for( unsigned long i = 1; i < numberOfBins; i++ ) - startOfBin[ i ] = endOfBin[ i ] = startOfBin[ i - 1 ] + count.my_count[ i - 1 ]; - - for ( long _current = 0; _current <= last; ) - { - unsigned long digit; - T tmp = a[ _current ]; // get the compiler to recognize that a register can be used for the loop instead of a[_current] memory location - while ( true ) { - digit = (unsigned long)(( tmp & bitMask ) >> shiftRightAmount ); // extract the digit we are sorting based on - if ( endOfBin[ digit ] == _current ) - break; - swap_impl( tmp, a[ endOfBin[ digit ] ] ); - endOfBin[ digit ]++; - } - a[ _current ] = tmp; - - endOfBin[ digit ]++; // leave the element at its location and grow the bin - _current++; // advance the current pointer to the next element - while( _current >= startOfBin[ nextBin ] && nextBin < numberOfBins ) - nextBin++; - while( endOfBin[ nextBin - 1 ] == startOfBin[ nextBin ] && nextBin < numberOfBins ) - nextBin++; - if ( _current < endOfBin[ nextBin - 1 ] ) - _current = endOfBin[ nextBin - 1 ]; - } - bitMask >>= Log2ofPowerOfTwoRadix; - if ( bitMask != 0 ) // end recursion when all the bits have been processes - { - if ( shiftRightAmount >= Log2ofPowerOfTwoRadix ) shiftRightAmount -= Log2ofPowerOfTwoRadix; - else shiftRightAmount = 0; - - RadixInPlaceOperation_3< PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold, T > radixOp( a, startOfBin, endOfBin, bitMask, shiftRightAmount ); - parallel_for( blocked_range< long >( 0, numberOfBins ), radixOp ); - } -} - -template< unsigned long PowerOfTwoRadix, unsigned long Log2ofPowerOfTwoRadix, long Threshold, class T > -inline void _RadixSort_Unsigned_PowerOf2Radix_1( T* a, long last, T bitMask, unsigned long shiftRightAmount ) -{ - const unsigned long numberOfBins = PowerOfTwoRadix; - unsigned long count[ numberOfBins ]; -// Counting occurrence of digits within the array (related to Counting Sort) - for( unsigned long i = 0; i < numberOfBins; i++ ) - count[ i ] = 0; - - for ( long _current = 0; _current <= last; _current++ ) // Scan the array and count the number of times each value appears - { - unsigned long digit = (unsigned long)(( a[ _current ] & bitMask ) >> shiftRightAmount ); // extract the digit we are sorting based on - count[ digit ]++; - } -// Moving array elements into their bins - long startOfBin[ numberOfBins ], endOfBin[ numberOfBins ], nextBin; - startOfBin[ 0 ] = endOfBin[ 0 ] = nextBin = 0; - for( unsigned long i = 1; i < numberOfBins; i++ ) - startOfBin[ i ] = endOfBin[ i ] = startOfBin[ i - 1 ] + count[ i - 1 ]; - - for ( long _current = 0; _current <= last; ) - { - unsigned long digit; - T tmp = a[ _current ]; // get the compiler to recognize that a register can be used for the loop instead of a[_current] memory location - while ( true ) { - digit = (unsigned long)(( tmp & bitMask ) >> shiftRightAmount ); // extract the digit we are sorting based on - if ( endOfBin[ digit ] == _current ) - break; - swap_impl( tmp, a[ endOfBin[ digit ] ] ); - endOfBin[ digit ]++; - } - a[ _current ] = tmp; - - endOfBin[ digit ]++; // leave the element at its location and grow the bin - _current++; // advance the current pointer to the next element - while( _current >= startOfBin[ nextBin ] && nextBin < numberOfBins ) - nextBin++; - while( endOfBin[ nextBin - 1 ] == startOfBin[ nextBin ] && nextBin < numberOfBins ) - nextBin++; - if ( _current < endOfBin[ nextBin - 1 ] ) - _current = endOfBin[ nextBin - 1 ]; - } -// Recursion for each bin - bitMask >>= Log2ofPowerOfTwoRadix; - if ( bitMask != 0 ) // end recursion when all the bits have been processes - { - if ( shiftRightAmount >= Log2ofPowerOfTwoRadix ) shiftRightAmount -= Log2ofPowerOfTwoRadix; - else shiftRightAmount = 0; - - for( unsigned long i = 0; i < numberOfBins; i++ ) - { - long numberOfElements = endOfBin[ i ] - startOfBin[ i ]; - if ( numberOfElements >= Threshold ) { // endOfBin actually points to one beyond the bin - _RadixSort_Unsigned_PowerOf2Radix_1< T, PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( &a[ startOfBin[ i ]], numberOfElements - 1, bitMask, shiftRightAmount ); - } - else if ( numberOfElements >= 2 ) { - insertion_sort_impl( &a[ startOfBin[ i ]], numberOfElements ); - } - } - } -} - -// Top-level template function -template< class T > -inline void RadixSortParallel( T* a, unsigned long a_size ) -{ - if ( a_size < 2 ) return; - - const unsigned long Threshold = 32; // Threshold of when to switch to using Insertion Sort - const unsigned long PowerOfTwoRadix = 256; // Radix - must be a power of 2 - const unsigned long Log2ofPowerOfTwoRadix = 8; - unsigned long shiftRightAmount = sizeof( T ) * 8 - Log2ofPowerOfTwoRadix; // Create bit-mask and shift right amount - T bitMask = (T)( ((T)( PowerOfTwoRadix - 1 )) << shiftRightAmount ); // bitMask controls/selects how many and which bits we process at a time - - if ( a_size >= Threshold ) - _RadixSort_Unsigned_PowerOf2Radix_3< PowerOfTwoRadix, Log2ofPowerOfTwoRadix, Threshold >( a, a_size - 1, bitMask, shiftRightAmount ); - else - insertion_sort_impl( a, a_size ); -} - -*/ - - - -#endif /* STK_UTIL_UTIL_RADIXSORT_HPP */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/Range.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/Range.hpp deleted file mode 100644 index 3641ae99f51d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/Range.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 - 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_RANGE_HPP -#define STK_UTIL_UTIL_RANGE_HPP - -#include - -namespace stk_classic { - -template -inline -typename boost::iterator_range::const_iterator const_begin(const boost::iterator_range &range) { - return boost::begin(range); -} - -template -inline -typename boost::iterator_range::const_iterator const_end(const boost::iterator_range &range) { - return boost::end(range); -} - -template -inline -typename boost::iterator_range::iterator begin(const boost::iterator_range &range) { - return boost::begin(range); -} - -template -inline -typename boost::iterator_range::iterator end(const boost::iterator_range &range) { - return boost::end(range); -} - -template -inline -typename boost::iterator_range::const_iterator const_begin(const boost::sub_range &range) { - return boost::begin(range); -} - -template -inline -typename boost::iterator_range::const_iterator const_end(const boost::sub_range &range) { - return boost::end(range); -} - -template -inline -typename boost::iterator_range::iterator begin(const boost::sub_range &range) { - return boost::begin(range); -} - -template -inline -typename boost::iterator_range::iterator end(const boost::sub_range &range) { - return boost::end(range); -} - -} // namespace stk_classic - -#endif // STK_UTIL_UTIL_RANGE_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/SameType.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/SameType.hpp deleted file mode 100644 index 4cce78010b0c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/SameType.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_SameType_hpp -#define stk_util_util_SameType_hpp - -namespace stk_classic { - -//---------------------------------------------------------------------- -/** \class SameType - * \brief Member enum { value = ... }; - * is true if T1 and T2 are the same type. - * \ingroup typelist_module - */ -template -struct SameType -{ enum { value = false }; }; - -template -struct SameType -{ enum { value = true }; }; - -//---------------------------------------------------------------------- - -} //namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/SimpleArrayOps.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/SimpleArrayOps.hpp deleted file mode 100644 index d52bf4661589..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/SimpleArrayOps.hpp +++ /dev/null @@ -1,381 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef stk_util_util_SimpleArrayOps_hpp -#define stk_util_util_SimpleArrayOps_hpp - -namespace stk_classic { - - /// \todo REFACTOR: Add a sub-namespace? - -// Basic operations for compile-time fixed length arrays -// -// Example: Sum<5>(x,y) results in x[i] += y[i] for i=0..4 - -template< unsigned n, int i=0> struct Copy ; -template< unsigned n, int i=0> struct Sum ; -template< unsigned n, int i=0> struct Prod ; -template< unsigned n, int i=0> struct Max ; -template< unsigned n, int i=0> struct Min ; -template< unsigned n, int i=0> struct BitOr ; -template< unsigned n, int i=0> struct BitAnd ; -template< unsigned n, int i=0> struct InnerProduct ; -template< unsigned n, int i=0> struct Compare ; - -//---------------------------------------------------------------------- - -template -struct Copy<0,i> { - enum { N = 0 }; - Copy() {} - template inline Copy( T * const , const T * const ) {} - template inline Copy( T * const , const T ) {} -}; - -template -struct Sum<0,i> { - enum { N = 0 }; - Sum() {} - template inline Sum( T * const , const T * const ) {} - template inline Sum( T * const , const T , const T * const ) {} -}; - -template -struct Prod<0,i> { - enum { N = 0 }; - Prod() {} - template inline Prod( T * const , const T * const ) {} -}; - -template -struct Max<0,i> { - enum { N = 0 }; - Max() {} - template inline Max( T * const , const T * const ) {} -}; - -template -struct Min<0,i> { - enum { N = 0 }; - Min() {} - template inline Min( T * const , const T * const ) {} -}; - -template -struct BitOr<0,i> { - enum { N = 0 }; - BitOr() {} - template inline BitOr( T * const , const T * const ) {} -}; - -template -struct BitAnd<0,i> { - enum { N = 0 }; - BitAnd() {} - template inline BitAnd( T * const , const T * const ) {} -}; - -template -struct InnerProduct<0,i> { - enum { N = 0 }; - InnerProduct() {} - template - inline InnerProduct( T & value , const T * const x , const T * const y ) {} -}; - -template -struct Compare<0,i> { - enum { N = 0 }; - Compare() {} - - template - inline static bool equal( const T * const , const T * const ) - { return true ; } - - template - inline static bool not_equal( const T * const , const T * const ) - { return false ; } - - template - inline static bool less( const T * const , const T * const ) - { return false ; } - - template - inline static bool less_equal( const T * const , const T * const ) - { return true ; } - - template - inline static bool greater( const T * const , const T * const ) - { return false ; } - - template - inline static bool greater_equal( const T * const , const T * const ) - { return true ; } -}; - - -template -struct Copy { - enum { N = n }; - Copy() {} - - template - inline Copy( T * const dst , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] = src[i]; } } - - template - inline Copy( T * const dst , const T src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] = src ; } } -}; - -template -struct Sum { - enum { N = n }; - Sum() {} - - template - inline Sum( T * const dst , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] += src[i]; } } - - template - inline Sum( T * const dst , const T a , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] += a * src[i]; } } -}; - -template -struct Prod { - enum { N = n }; - Prod() {} - template - inline Prod( T * const dst , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] *= src[i]; } } -}; - -template -struct BitOr { - enum { N = n }; - BitOr() {} - template - inline BitOr( T * const dst , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] |= src[i]; } } -}; - -template -struct BitAnd { - enum { N = n }; - BitAnd() {} - template - inline BitAnd( T * const dst , const T * const src ) - { for ( unsigned i = 0 ; i < N ; ++i ) { dst[i] &= src[i]; } } -}; - -template -struct Max { - enum { N = n }; - Max() {} - template - inline Max( T * const dst , const T * const src ) - { - for ( unsigned i = 0 ; i < N ; ++i ) - { if ( dst[i] < src[i] ) { dst[i] = src[i] ; } } - } -}; - -template -struct Min { - enum { N = n }; - Min() {} - template - inline Min( T * const dst , const T * const src ) - { - for ( unsigned i = 0 ; i < N ; ++i ) - { if ( src[i] < dst[i] ) { dst[i] = src[i] ; } } - } -}; - -template -struct InnerProduct { - enum { N = n }; - InnerProduct() {} - template - inline InnerProduct( T & value , const T * const x , const T * const y ) - { for ( unsigned i = 0 ; i < N ; ++i ) { value += x[i] * y[i] ; } } -}; - - -template -struct Compare { - enum { N = n }; - Compare() {} - - template - inline static bool equal( const T * const dst , const T * const src ) - { - bool result = true ; - for ( unsigned i = 0 ; result && i < N ; ++i ) - { result = dst[i] == src[i] ; } - return result ; - } - - template - inline static bool not_equal( const T * const dst , const T * const src ) - { return ! equal( dst , src ); } - - template - inline static bool less( const T * const dst , const T * const src ) - { - unsigned i = 0 ; - for ( ; i < N && dst[i] == src[i] ; ++i ); - return i < N && dst[i] < src[i] ; - } - - template - inline static bool less_equal( const T * const dst , const T * const src ) - { return ! less( src , dst ); } - - template - inline static bool greater( const T * const dst , const T * const src ) - { return less( src , dst ); } - - template - inline static bool greater_equal( const T * const dst , const T * const src ) - { return ! less( dst , src ); } -}; - - -template -struct Copy { - enum { N = n , I = i }; - Copy() {} - - template - inline Copy( T * const dst , const T * const src ) - { dst[I] = src[I] ; Copy(dst,src); } - - template - inline Copy( T * const dst , const T src ) - { dst[I] = src ; Copy(dst,src); } -}; - -template -struct Sum { - enum { N = n , I = i }; - Sum() {} - - template - inline Sum( T * const dst , const T * const src ) - { dst[I] += src[I] ; Sum(dst,src); } - - template - inline Sum( T * const dst , const T a , const T * const src ) - { dst[I] += a * src[I] ; Sum(dst,a,src); } -}; - -template -struct Prod { - enum { N = n , I = i }; - Prod() {} - template - inline Prod( T * const dst , const T * const src ) - { dst[I] *= src[I] ; Prod(dst,src); } -}; - -template -struct BitOr { - enum { N = n , I = i }; - BitOr() {} - template - inline BitOr( T * const dst , const T * const src ) - { dst[I] |= src[I] ; BitOr(dst,src); } -}; - -template -struct BitAnd { - enum { N = n , I = i }; - BitAnd() {} - template - inline BitAnd( T * const dst , const T * const src ) - { dst[I] &= src[I] ; BitAnd(dst,src); } -}; - -template -struct Max { - enum { N = n , I = i }; - Max() {} - template - inline Max( T * const dst , const T * const src ) - { if ( dst[I] < src[I] ) { dst[I] = src[I] ; } Max(dst,src); } -}; - -template -struct Min { - enum { N = n , I = i }; - Min() {} - template - inline Min( T * const dst , const T * const src ) - { if ( src[I] < dst[I] ) { dst[I] = src[I] ; } Min(dst,src); } -}; - -template -struct InnerProduct { - enum { N = n , I = i }; - InnerProduct() {} - template - inline InnerProduct( T & value , const T * const x , const T * const y ) - { value += x[I] * y[I] ; InnerProduct( value , x , y ); } -}; - - -template -struct Compare { - enum { N = n , I = i }; - Compare() {} - - template - inline static bool equal( const T * const dst , const T * const src ) - { return dst[I] == src[I] && Compare::equal(dst,src); } - - template - inline static bool not_equal( const T * const dst , const T * const src ) - { return dst[I] != src[I] || Compare::not_equal(dst,src); } - - template - inline static bool less( const T * const dst , const T * const src ) - { - return dst[I] != src[I] ? dst[I] < src[I] - : Compare::less(dst,src); - } - - template - inline static bool less_equal( const T * const dst , const T * const src ) - { - return dst[I] != src[I] ? dst[I] < src[I] - : Compare::less_equal(dst,src); - } - - template - inline static bool greater( const T * const dst , const T * const src ) - { - return dst[I] != src[I] ? dst[I] > src[I] - : Compare::greater(dst,src); - } - - template - inline static bool greater_equal( const T * const dst , const T * const src ) - { - return dst[I] != src[I] ? dst[I] > src[I] - : Compare::greater_equal(dst,src); - } -}; - -//----------------------------------- - -} // namespace stk_classic - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/StaticAssert.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/StaticAssert.hpp deleted file mode 100644 index ec646bc9f3b0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/StaticAssert.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_StaticAssert_hpp -#define STK_UTIL_UTIL_StaticAssert_hpp - -namespace stk_classic { - -//---------------------------------------------------------------------- -/** \brief Compile-time assertion - * \ingroup util_module - * If the compile-time expression is true then defines - * - enum { OK = true }; - * - static bool ok() { return true ; } - * - * \todo REFACTOR Does StaticAssert belong here? Anywhere? - */ -template struct StaticAssert {}; - -template<> struct StaticAssert { - enum { OK = true }; - static bool ok() { return true ; } -}; - -//---------------------------------------------------------------------- - -} //namespace stk_classic - -#endif // STK_UTIL_UTIL_StaticAssert_hpp - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/TeeStreambuf.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/TeeStreambuf.hpp deleted file mode 100644 index 7693677c7a88..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/TeeStreambuf.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_TEESTREAMBUF_HPP -#define STK_UTIL_UTIL_TEESTREAMBUF_HPP - -#include -#include -#include -#include -#include - -namespace stk_classic { - -/** - * @brief Class basic_tee_streambuf maintains a list of destination output stream buffers to - * send written characters to. Many destination output stream buffers may be added. For each - * character written to this stream buffer, the same character is written to each destination stream - * buffer. - * - */ -template > -class basic_tee_streambuf : public std::basic_streambuf -{ - typedef std::set StreamSet; - typedef std::map StreamErrorMap; - -public: - /** - * Creates a new basic_tee_streambuf instance. - * - */ - basic_tee_streambuf() - {} - - /** - * Creates a new basic_tee_streambuf instance and adds the specified destination output - * stream buffer. - * - */ - explicit basic_tee_streambuf(std::basic_ostream *os) { - add(os); - } - - /** - * Destroys a basic_tee_streambuf instance. - * - */ - virtual ~basic_tee_streambuf() - {} - - /** - * @brief Member function eof returns the current end-of-file status. - * - * @return an int value of the current end-of-file status. - */ - int eof() { - return std::basic_streambuf::traits_type::eof(); - } - - /** - * @brief Member function add adds the specified destination output stream buffer. - * - * @param sb a std::streambuf pointer to the output strema buffer to add. - * - */ - void add(std::ostream *os) { - m_destinations.insert(os); - } - - /** - * @brief Member function remove removes the specified destination output stream buffer. - * - * @param sb a std::streambuf pointer to the output strema buffer to - * remove. - * - */ - void remove(std::ostream *os) { - m_destinations.erase(os); - } - - /** - * @brief Member function clear removes are destination output stream buffers. - * - */ - void clear() { - m_destinations.clear(); - } - -private: - /** - * @brief Member function sync syncs the destination output stream buffer. - * - * @return an int value of 1 if successful. - */ - virtual int sync() { - if (m_destinations.empty()) - return 1; - - StreamErrorMap return_code; - - for (StreamSet::const_iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) { - if ((*it)->rdbuf() != this) { - int ret = (*it)->rdbuf()->pubsync(); - return_code[*it] = ret; - } - } - - // Remove streambufs with errors - for (StreamSet::iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) - if (return_code[*it] == eof()) - m_destinations.erase(it); - - if (m_destinations.empty()) - return 1; - - return 1; - } - - /** - * @brief Member function overflow writes the specified character to all the destination - * outptu strema buffers. - * - * @param c an int const value of the character to write. - * - * @return an int value of the character written. - */ - virtual typename std::basic_streambuf::int_type overflow(const int c) { - if (m_destinations.empty()) - return 1; - - StreamErrorMap return_code; - - for (StreamSet::const_iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) { - int ret = (*it)->rdbuf()->sputc(c); - return_code[*it] = ret; - } - - // Remove streambufs with errors - for (StreamSet::iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) - if (return_code[*it] == eof()) - m_destinations.erase(it); - - if (m_destinations.empty()) - return 1; - - return 1; - } - - /** - * @brief Member function xsputn writes the specified characters to all the destination - * - * @param buffer a char const pointer to the character string to write. - * - * @param n a std::streamsize value of the number of characters to write. - * - * @return a std::streamsize value of the number of characters written. - */ - virtual std::streamsize xsputn(char const *buffer, std::streamsize n) { - if (m_destinations.empty()) - return n; - - StreamErrorMap return_code; - - for (StreamSet::const_iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) { - std::ostream *os = (*it); - int ret = os->rdbuf()->sputn(buffer,n); - return_code[*it] = ret; - } - - // Remove ostreams with errors - for (StreamSet::iterator it = m_destinations.begin(); it != m_destinations.end(); ++it) { - if (return_code[*it] < 0) { - m_destinations.erase(it); - } - } - - if (m_destinations.empty()) - return n; - - return n; - } - -private: - StreamSet m_destinations; ///< Destination output stream buffers to write to -}; - -typedef stk_classic::basic_tee_streambuf tee_streambuf; - -} // namespace stk_classic - -#endif // STK_UTIL_UTIL_TEESTREAMBUF_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/TypeList.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/TypeList.hpp deleted file mode 100644 index 831b7d0e0887..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/TypeList.hpp +++ /dev/null @@ -1,1063 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_util_util_TypeList_h -#define stk_util_util_TypeList_h - -#include -#include - -namespace stk_classic { - -/** \ingroup util_module - * \defgroup typelist_module TypeList: linked list of types - * \brief Linked-list of compile-time types and - * supporting compile-time linked list operations. - * \author H. Carter Edwards - * - * 'TypeList' templates significantly enhanced from - * Alexandrescu's "Modern C++ Design" book. - */ - -//---------------------------------------------------------------------- - -struct TypeListEnd {}; - -/** \class TypeList - * \brief A link within a linked list of types. - * \ingroup typelist_module - * - * A linked list of types where Tail is required to either - * terminate the list with TypeListEnd or continue the list - * with another instantiation of TypeList . - */ -template< typename Value , class Tail = TypeListEnd > struct TypeList {}; - -//---------------------------------------------------------------------- -/** \class TypeListLength - * \brief Member enum { value = ... }; - * is the length of the type list. - * \ingroup typelist_module - */ -template< class ListType > struct TypeListLength {}; - -template<> -struct TypeListLength< TypeListEnd > -{ enum { value = 0 }; }; - -template< typename Value , class Tail > -struct TypeListLength< TypeList< Value , Tail > > -{ enum { value = 1 + TypeListLength< Tail >::value }; }; - -//---------------------------------------------------------------------- -/** \class TypeListAt - * \brief Member typedef ... type ; is the type of the member - * of ListType at location ordinal - * if ordinal is less than the type list length. - * \ingroup typelist_module - */ -template< class ListType, unsigned ordinal > struct TypeListAt {}; - -template< unsigned ordinal > -struct TypeListAt< TypeListEnd , ordinal > -{ typedef TypeListEnd type ; }; - -template< typename Value , class Tail > -struct TypeListAt< TypeList< Value , Tail > , 0 > -{ typedef Value type ; }; - -template< typename Value , class Tail , unsigned ordinal > -struct TypeListAt< TypeList< Value , Tail > , ordinal > -{ typedef typename TypeListAt< Tail , ordinal - 1 >::type type ; }; - -//---------------------------------------------------------------------- -/** \class TypeListIndex - * \brief Member enum { value = ... }; - * is the location within ListType - * of occurance I of type TestValue . - * If this occurance does not exist then value = -1 . - * \ingroup typelist_module - */ -template< class ListType , typename TestValue , unsigned ordinal = 0 > -struct TypeListIndex {}; - -template< typename TestValue , unsigned ordinal > -struct TypeListIndex< TypeListEnd , TestValue , ordinal > -{ - enum { value = -1 }; -}; - -template< typename Value , class Tail , typename TestValue , unsigned ordinal > -struct TypeListIndex< TypeList< Value , Tail > , TestValue , ordinal > -{ -private: - enum { match = stk_classic::SameType< Value , TestValue >::value }; - enum { J = match && 0 < ordinal ? ordinal - 1 : ordinal }; - enum { N = TypeListIndex< Tail , TestValue , J >::value }; -public: - enum { value = match && 0 == ordinal ? 0 : ( -1 == N ? -1 : N + 1 ) }; -}; - -//---------------------------------------------------------------------- -/** \class TypeListCount - * \brief Member enum { value = ... }; - * is the number of occurances of TestValue - * within ListType . - * \ingroup typelist_module - */ -template< class ListType , typename TestValue > -struct TypeListCount {}; - -template< typename TestValue > -struct TypeListCount< TypeListEnd , TestValue > -{ enum { value = 0 }; }; - -template< typename Value , class Tail , typename TestValue > -struct TypeListCount< TypeList< Value , Tail > , TestValue > -{ - enum { value = TypeListCount< Tail , TestValue >::value + - ( stk_classic::SameType< Value , TestValue >::value ? 1 : 0 ) }; -}; - -//---------------------------------------------------------------------- -/** \class TypeListMember - * \brief Member enum { value = ... }; is true - * if TestValue is a member of ListType . - * \ingroup typelist_module - */ -template< class ListType , typename TestValue > struct TypeListMember {}; - -template< typename TestValue > -struct TypeListMember< TypeListEnd , TestValue > -{ enum { value = false }; }; - -template< typename Value , class Tail , typename TestValue > -struct TypeListMember< TypeList< Value , Tail > , TestValue > -{ - enum { value = stk_classic::SameType< Value , TestValue >::value || - TypeListMember< Tail , TestValue >::value }; -}; - -//---------------------------------------------------------------------- -/** \class TypeListUnique - * \brief Member enum { value = ... }; is true - * if each member of ListType appears exactly once. - * \ingroup typelist_module - */ -template< class ListType > struct TypeListUnique {}; - -template<> -struct TypeListUnique< TypeListEnd > -{ enum { value = true }; }; - -template< typename Value , class Tail > -struct TypeListUnique< TypeList< Value , Tail > > -{ - enum { value = ! TypeListMember< Tail , Value >::value && - TypeListUnique< Tail >::value }; -}; - -//---------------------------------------------------------------------- -/** \class TypeListDisjoint - * \brief Member enum { value = ... }; is true - * if all members of ListA - * are not a member ListB . - * \ingroup typelist_module - */ -template< class ListA , class ListB > struct TypeListDisjoint {}; - -template< class ListB > -struct TypeListDisjoint< TypeListEnd , ListB > -{ enum { value = true }; }; - -template< typename Value , class Tail , class ListB > -struct TypeListDisjoint< TypeList< Value , Tail > , ListB > -{ - enum { value = ! TypeListMember< ListB , Value >::value && - TypeListDisjoint< Tail , ListB >::value }; -}; - -//---------------------------------------------------------------------- -/** \class TypeListFirst - * \brief Member typedef ... type ; is the first member - * of ListType . - * \ingroup typelist_module - */ -template< class ListType > struct TypeListFirst {}; - -template<> -struct TypeListFirst< TypeListEnd > -{ typedef TypeListEnd type ; }; - -template< typename Value , class Tail > -struct TypeListFirst< TypeList< Value , Tail > > -{ typedef Value type ; }; - -//---------------------------------------------------------------------- -/** \class TypeListLast - * \brief Member typedef ... type ; is the last member - * of ListType . - * \ingroup typelist_module - */ -template< class ListType > struct TypeListLast {}; - -template<> -struct TypeListLast< TypeListEnd > -{ typedef TypeListEnd type ; }; - -template< typename Value > -struct TypeListLast< TypeList< Value , TypeListEnd > > -{ typedef Value type ; }; - -template< typename Value , class Tail > -struct TypeListLast< TypeList< Value , Tail > > -{ typedef typename TypeListLast< Tail >::type type ; }; - -//---------------------------------------------------------------------- -/** \class TypeListAppend - * \brief Member typedef ... type ; is defined - * by appending T to the end of ListA . - * \ingroup typelist_module - */ -template< class ListA , typename T > struct TypeListAppend {}; - -template<> -struct TypeListAppend< TypeListEnd , TypeListEnd > -{ typedef TypeListEnd type ; }; - -template< typename T > -struct TypeListAppend< TypeListEnd , T > -{ typedef TypeList< T > type ; }; - -template< typename Value , class Tail , typename T > -struct TypeListAppend< TypeList< Value , Tail > , T > -{ - typedef TypeList< Value , typename TypeListAppend< Tail , T >::type > type ; -}; - -//---------------------------------------------------------------------- -/** \class TypeListJoin - * \brief Member typedef ... type ; is defined - * by joining ListB to the end of ListA . - * \ingroup typelist_module - */ -template< class ListA , class ListB > struct TypeListJoin {}; - -template<> -struct TypeListJoin< TypeListEnd , TypeListEnd > -{ typedef TypeListEnd type ; }; - -template< typename Value , class Tail > -struct TypeListJoin< TypeListEnd , TypeList< Value , Tail > > -{ typedef TypeList< Value , Tail > type ; }; - -template< typename ValueA , class TailA , typename ValueB , class TailB > -struct TypeListJoin< TypeList< ValueA , TailA > , - TypeList< ValueB , TailB > > -{ -private: - typedef typename - TypeListJoin< TailA , TypeList< ValueB , TailB > >::type Tail ; -public: - typedef TypeList< ValueA , Tail > type ; -}; - -//---------------------------------------------------------------------- -/** \class TypeListEraseAt - * \brief Member typedef ... type ; is defined - * by erasing member at ordinal from ListType . - * \ingroup typelist_module - */ -template< class ListType, unsigned ordinal > struct TypeListEraseAt {}; - -template< typename Value , class Tail > -struct TypeListEraseAt< TypeList< Value , Tail > , 0 > -{ typedef Tail type ; }; - -template< typename Value , class Tail , unsigned ordinal > -struct TypeListEraseAt< TypeList< Value , Tail > , ordinal > -{ - typedef TypeList< Value , - typename TypeListEraseAt::type > type ; -}; - - -//---------------------------------------------------------------------- -/** \class TypeListClean - * \brief Member typedef ... type ; is defined - * by truncating ListType at the first - * occurance of TypeListEnd . - * Used by MakeTypeList to generate a clean type list. - */ -template< class ListType > struct TypeListClean {}; - -template<> -struct TypeListClean< TypeListEnd > -{ typedef TypeListEnd type ; }; - -template< class Tail > -struct TypeListClean< TypeList< TypeListEnd , Tail > > -{ typedef TypeListEnd type ; }; - -template< typename Value , class Tail > -struct TypeListClean< TypeList< Value , Tail > > -{ - typedef TypeList< Value , typename TypeListClean< Tail >::type > type ; -}; - -//---------------------------------------------------------------------- -/** \class MakeTypeList - * \brief Member typedef ... type ; - * is a type list constructed from the template arguments. - * \ingroup typelist_module - */ -template< typename T00 = TypeListEnd , - typename T01 = TypeListEnd , - typename T02 = TypeListEnd , - typename T03 = TypeListEnd , - typename T04 = TypeListEnd , - typename T05 = TypeListEnd , - typename T06 = TypeListEnd , - typename T07 = TypeListEnd , - typename T08 = TypeListEnd , - typename T09 = TypeListEnd , - typename T10 = TypeListEnd , - typename T11 = TypeListEnd , - typename T12 = TypeListEnd , - typename T13 = TypeListEnd , - typename T14 = TypeListEnd , - typename T15 = TypeListEnd , - typename T16 = TypeListEnd , - typename T17 = TypeListEnd , - typename T18 = TypeListEnd , - typename T19 = TypeListEnd , - typename T20 = TypeListEnd , - typename T21 = TypeListEnd , - typename T22 = TypeListEnd , - typename T23 = TypeListEnd , - typename T24 = TypeListEnd , - typename T25 = TypeListEnd , - typename T26 = TypeListEnd , - typename T27 = TypeListEnd , - typename T28 = TypeListEnd , - typename T29 = TypeListEnd , - typename T30 = TypeListEnd , - typename T31 = TypeListEnd , - typename T32 = TypeListEnd , - typename T33 = TypeListEnd , - typename T34 = TypeListEnd , - typename T35 = TypeListEnd , - typename T36 = TypeListEnd , - typename T37 = TypeListEnd , - typename T38 = TypeListEnd , - typename T39 = TypeListEnd , - typename T40 = TypeListEnd , - typename T41 = TypeListEnd , - typename T42 = TypeListEnd , - typename T43 = TypeListEnd , - typename T44 = TypeListEnd , - typename T45 = TypeListEnd , - typename T46 = TypeListEnd , - typename T47 = TypeListEnd , - typename T48 = TypeListEnd , - typename T49 = TypeListEnd , - typename T50 = TypeListEnd , - typename T51 = TypeListEnd , - typename T52 = TypeListEnd , - typename T53 = TypeListEnd , - typename T54 = TypeListEnd , - typename T55 = TypeListEnd , - typename T56 = TypeListEnd , - typename T57 = TypeListEnd , - typename T58 = TypeListEnd , - typename T59 = TypeListEnd , - typename T60 = TypeListEnd , - typename T61 = TypeListEnd , - typename T62 = TypeListEnd , - typename T63 = TypeListEnd > -struct MakeTypeList -{ -#ifndef DOXYGEN_COMPILE -private: - typedef TypeList< T00 , - TypeList< T01 , - TypeList< T02 , - TypeList< T03 , - TypeList< T04 , - TypeList< T05 , - TypeList< T06 , - TypeList< T07 , - TypeList< T08 , - TypeList< T09 , - TypeList< T10 , - TypeList< T11 , - TypeList< T12 , - TypeList< T13 , - TypeList< T14 , - TypeList< T15 , - TypeList< T16 , - TypeList< T17 , - TypeList< T18 , - TypeList< T19 , - TypeList< T20 , - TypeList< T21 , - TypeList< T22 , - TypeList< T23 , - TypeList< T24 , - TypeList< T25 , - TypeList< T26 , - TypeList< T27 , - TypeList< T28 , - TypeList< T29 , - TypeList< T30 , - TypeList< T31 , - TypeList< T32 , - TypeList< T33 , - TypeList< T34 , - TypeList< T35 , - TypeList< T36 , - TypeList< T37 , - TypeList< T38 , - TypeList< T39 , - TypeList< T40 , - TypeList< T41 , - TypeList< T42 , - TypeList< T43 , - TypeList< T44 , - TypeList< T45 , - TypeList< T46 , - TypeList< T47 , - TypeList< T48 , - TypeList< T49 , - TypeList< T50 , - TypeList< T51 , - TypeList< T52 , - TypeList< T53 , - TypeList< T54 , - TypeList< T55 , - TypeList< T56 , - TypeList< T57 , - TypeList< T58 , - TypeList< T59 , - TypeList< T60 , - TypeList< T61 , - TypeList< T62 , - TypeList< T63 , - TypeListEnd > > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > > dirty_type ; -#endif /* DOXYGEN_COMPILE */ -public: - - /** \brief The constructed type list. */ - typedef typename TypeListClean< dirty_type >::type type ; - - /** \brief Length of the constructed type list. */ - enum { length = TypeListLength::value }; - - /** \brief If every member of the constructed type list is unique. */ - enum { unique = TypeListUnique::value }; -}; - -} // namespace stk_classic - -namespace sierra { - -//---------------------------------------------------------------------- - -/** @class sierra::TypeList - * @brief Linked list of types. - */ -template -struct TypeList { - /** Value for the current entry */ - typedef ValueType TypeListValue ; - - /** Remainder of the list */ - typedef ListType TypeListTail ; -}; - -/** The end of a TypeList is the first encounter with an entry of TypeListEnd. - * Thus all entries after a TypeListEnd entry are ignored. This allows - * The MakeTypeList<...> template to define TypeLists of the desired length. - */ -struct TypeListEnd {}; - -//---------------------------------------------------------------------- - -/** Length of a TypeList */ -template< class ListType> -struct TypeListLength /* { enum { value = <> }; } */ ; - -/** Location of a ValueType in the TypeList */ -template< class ListType, typename ValueType, unsigned Ordinal = 0> -struct TypeListIndex /* { enum { value = <> }; } */ ; - -/** Count of appearances of ValueType in the TypeList */ -template< class ListType, typename ValueType> -struct TypeListCount /* { enum { value = <> }; } */ ; - -/** Last ValueType in the TypeList */ -template< class ListType > -struct TypeListLast /* { typedef <> type ; } */ ; - -/** ValueType and sub-ListType at a location in a TypeList */ -template< class ListType, unsigned I> -struct TypeListAt /* { typedef <> type ; typedef <> list_type ; } */ ; - -/** TypeList member of a ValueType in a TypeList */ -template< class ListType, typename ValueType> -struct TypeListMember /* { typedef <> list_type ; } */ ; - -/** Erase type from TypeList at I */ -template< class ListType, unsigned I > -struct TypeListEraseAt /* { typedef <> list_type ; } */ ; - -// /** Erase type from TypeList at I */ -// template< class ListType, int I > -// struct TypeListErase /* { typedef <> list_type ; } */ ; - -/** Check for uniqueness of a TypeList */ -template< class ListType > -struct TypeListUnique /* { enum { value = <> }; } */ ; - -/** Check if SuperList contains SubList */ -template< class SuperList , class SubList > -struct TypeListContains /* { enum { value = <> }; } */ ; - -/** Check if ListA is disjoint from ListB */ -template< class ListA , class ListB > -struct TypeListDisjoint /* { enum { value = <> }; } */ ; - -/** Truncate a TypeList at the first appearance of TypeListEnd */ -template -struct TypeListClean /* { typedef <> list_type ; } */ ; - -/** Make a TypeList from a sequence of type entries. - * Implemented to support list of up to thirtytwo (32) types. - */ -template< typename T0 = TypeListEnd , - typename T1 = TypeListEnd , - typename T2 = TypeListEnd , - typename T3 = TypeListEnd , - typename T4 = TypeListEnd , - typename T5 = TypeListEnd , - typename T6 = TypeListEnd , - typename T7 = TypeListEnd , - typename T8 = TypeListEnd , - typename T9 = TypeListEnd , - typename T10 = TypeListEnd , - typename T11 = TypeListEnd , - typename T12 = TypeListEnd , - typename T13 = TypeListEnd , - typename T14 = TypeListEnd , - typename T15 = TypeListEnd , - typename T16 = TypeListEnd , - typename T17 = TypeListEnd , - typename T18 = TypeListEnd , - typename T19 = TypeListEnd , - typename T20 = TypeListEnd , - typename T21 = TypeListEnd , - typename T22 = TypeListEnd , - typename T23 = TypeListEnd , - typename T24 = TypeListEnd , - typename T25 = TypeListEnd , - typename T26 = TypeListEnd , - typename T27 = TypeListEnd , - typename T28 = TypeListEnd , - typename T29 = TypeListEnd , - typename T30 = TypeListEnd , - typename T31 = TypeListEnd > -struct MakeTypeList -/* { typedef <> type ; enum { length = <> , unique = <> }; } */ ; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- -// Clean: End -> End -// Clean: -> End -// Clean: -> < Value , Clean > - -template<> -struct TypeListClean { - typedef TypeListEnd list_type ; -}; - -template -struct TypeListClean< TypeList< TypeListEnd , Tail > > { - typedef TypeListEnd list_type ; -}; - -template -struct TypeListClean { -private: - typedef typename ListType::TypeListValue ValueType ; - typedef typename ListType::TypeListTail InputTailType ; - typedef typename TypeListClean::list_type TailType ; -public: - typedef TypeList< ValueType , TailType > list_type ; -}; - -//---------- -// Length: End -> 0 -// Length: -> 0 -// Length: -> 1 + Length - -template<> struct TypeListLength -{ enum { value = 0 }; }; - -template -struct TypeListLength< TypeList > -{ enum { value = 0 }; }; - -template -struct TypeListLength -{ -private: typedef typename ListType::TypeListTail TailType ; -public: enum { value = 1 + TypeListLength::value }; -}; - -//---------- -// Index: < End , ValueType > -> -1 -// Index: < List , End > -> -1 -// Index: < < End , Tail > , ValueType > -> -1 -// Index: < < ValueType , Tail > , ValueType > -> 0 -// Index: < < OtherType , Tail > , ValueType > -> -// ( I = Index , I == -1 ? -1 : I + 1 ) - -template -struct TypeListIndex< TypeListEnd , ValueType , Ordinal> { - enum { value = -1 }; - typedef TypeListEnd tail_type ; -}; - -template -struct TypeListIndex< ListType , TypeListEnd , Ordinal > { - enum { value = -1 }; - typedef TypeListEnd tail_type ; -}; - -template -struct TypeListIndex< TypeList , ValueType, Ordinal > -{ - enum { value = -1 }; - typedef TypeListEnd tail_type ; -}; - -template -struct TypeListIndex< TypeList , ValueType , 0 > -{ - enum { value = 0 }; - typedef Tail tail_type ; -}; - -// Condition: ValueType == ListType::TypeListValue && Ordinal matches - -template -struct TypeListIndex -{ -private: - enum { same = stk_classic::SameType::value }; - enum { ord = Ordinal == 0 ? 0 : ( same ? Ordinal - 1 : Ordinal ) }; - typedef typename ListType::TypeListTail TailType ; - typedef TypeListIndex< TailType , ValueType , ord > type_list_index ; - enum { temp = type_list_index::value }; -public: - enum { value = temp == -1 ? -1 : 1 + temp }; - typedef typename type_list_index::tail_type tail_type ; -}; - -//---------- -// Count : < End , ValueType > -> 0 -// Count : < List , End > -> 0 -// Count : < < End , Tail > , ValueType > -> 0 -// Count : < < ValueType , Tail > , ValueType > -> Count + 1 -// Count : < < OtherType , Tail > , ValueType > -> Count - -template -struct TypeListCount< TypeListEnd , ValueType > { enum { value = 0 }; }; - -template -struct TypeListCount< ListType , TypeListEnd > { enum { value = 0 }; }; - -template -struct TypeListCount< TypeList,ValueType> -{ enum { value = 0 }; }; - -template -struct TypeListCount< TypeList , ValueType> -{ enum { value = 1 + TypeListCount< Tail , ValueType >::value }; }; - -template -struct TypeListCount -{ -private: typedef typename ListType::TypeListTail TailType ; -public: enum { value = TypeListCount< TailType , ValueType >::value }; -}; - -//---------- -// At : < End , 0 > -> { End , End } -// At : < End , I > -> { End , End } -// At : < < End , Tail > , I > -> { End , End } -// At : < < ValueType , Tail > , 0 > -> { ValueType , < ValueType , Tail > } -// At : < < ValueType , Tail > , I > -> At< Tail , I - 1 > - -template<> -struct TypeListAt< TypeListEnd, 0> -{ - typedef TypeListEnd type ; - typedef TypeListEnd list_type ; -}; - -template -struct TypeListAt< TypeListEnd, I> -{ - typedef TypeListEnd type ; - typedef TypeListEnd list_type ; -}; - -template< class ListType > -struct TypeListAt< ListType , 0 > -{ -private: - typedef typename ListType::TypeListTail Tail ; -public: - typedef typename ListType::TypeListValue type ; - typedef TypeList< type , Tail > list_type ; -}; - -template -struct TypeListAt< TypeList, I> -{ - typedef TypeListEnd type ; - typedef TypeListEnd list_type ; -}; - -template -struct TypeListAt -{ -private: - typedef typename ListType::TypeListTail Tail ; - typedef TypeListAt AtType ; -public: - typedef typename AtType::type type ; - typedef typename AtType::list_type list_type ; -}; - -//---------- -// Last : End -> End -// Last : < ValueType , End > -> ValueType -// Last : < ValueType , < End , Tail > > -> ValueType -// Last : < ValueType , Tail > -> Last< Tail > - -template<> -struct TypeListLast< TypeListEnd > -{ typedef TypeListEnd type ; }; - -template -struct TypeListLast< TypeList > -{ typedef ValueType type ; }; - -template -struct TypeListLast< TypeList > > -{ typedef ValueType type ; }; - -template -struct TypeListLast< TypeList > -{ typedef typename TypeListLast::type type ; }; - -//---------- -// Member : -// Member : -// Member : -// - -template< typename ValueType > -struct TypeListMember< TypeListEnd , ValueType > -{ typedef TypeListEnd list_type ; }; - -template< class Tail , typename ValueType > -struct TypeListMember< TypeList , ValueType > -{ typedef TypeListEnd list_type ; }; - -template< typename ValueType , class ListType> -struct TypeListMember< TypeList , ValueType > -{ typedef TypeList list_type ; }; - -template< class ListType, typename ValueType> -struct TypeListMember -{ - private: typedef typename ListType::TypeListTail Tail ; - public: typedef typename TypeListMember::list_type list_type; -}; - -// //---------- -// // Erase : -// // Erase : -// // Erase : -// // - -// template< class ValueType> -// struct TypeListErase -// { typedef TypeListEnd list_type ; }; - -// template< class ValueType, class Tail> -// struct TypeListErase< TypeList , ValueType > -// { typedef Tail list_type ; }; - -// template< class ListType, class ValueType> -// struct TypeListErase< TypeList, ValueType> -// { -// private: typedef typename ListType::TypeListTail Tail ; -// public: typedef TypeList::list_type> list_type; -// }; - -//---------- -// EraseAt : < End , 0 > -> { End , End } -// EraseAt : < End , I > -> { End , End } -// EraseAt : < < End , Tail > , I > -> { End , End } -// EraseAt : < < ListType , 0 > -> { TypeList < ValueType , Tail > } -// EraseAt : < < ListType , Tail > , I > -> { EraseAt< Tail , I - 1 > } - -template<> -struct TypeListEraseAt< TypeListEnd, 0> -{ - typedef TypeListEnd list_type ; -}; - -template -struct TypeListEraseAt< TypeListEnd, I> -{ - typedef TypeListEnd list_type ; -}; - -template -struct TypeListEraseAt< TypeList, I> -{ - typedef TypeListEnd list_type ; -}; - -template< class ListType > -struct TypeListEraseAt< ListType , 0 > -{ -private: - typedef typename ListType::TypeListTail Tail ; -public: - typedef Tail list_type ; -}; - -template -struct TypeListEraseAt -{ -private: - typedef typename ListType::TypeListTail Tail ; - typedef TypeListEraseAt EraseAtType ; -public: - typedef TypeList list_type ; -}; - -//---------- -// Unique : End -> true -// Unique : < End , Tail > -> true -// Unique : < ValueType , Tail > -> -// Index == -1 && Unique - -template<> -struct TypeListUnique { enum { value = true }; }; - -template -struct TypeListUnique< TypeList > -{ enum { value = true }; }; - -template< class ListType > -struct TypeListUnique -{ -private: - typedef typename ListType::TypeListValue ValueType ; - typedef typename ListType::TypeListTail TailType ; -public: - // This ValueType does not appear in the remainder of the TypeList and - // the remainder of the TypeList is also unique. - enum { value = ( TypeListIndex::value == -1 ) && - TypeListUnique::value }; -}; - -//---------- -// Contains : < SuperList , End > -> true -// Contains : < SuperList , < End , Tail > > -> true -// Contains : < SuperList , SubList > -> -// Index< SuperList,SubList::Value> != -1 && -// Contains - -template -struct TypeListContains -{ enum { value = true }; }; - -template -struct TypeListContains > -{ enum { value = true }; }; - -template -struct TypeListContains -{ -private: - typedef typename SubList::TypeListValue ValueType ; - typedef typename SubList::TypeListTail TailType ; -public: - // The SuperList contains this ValueType and the remainder of the SubList - enum { value = ( TypeListIndex::value != -1 ) && - TypeListContains::value }; -}; - -//---------- -// Disjoint : < ListA , End > -> true -// Disjoint : < ListA , < End , Tail > > -> true -// Disjoint : < ListA , ListB > -> -// Index< ListA,ListB::Value> == -1 && -// Disjoint - -template -struct TypeListDisjoint -{ enum { value = true }; }; - -template -struct TypeListDisjoint > -{ enum { value = true }; }; - -template -struct TypeListDisjoint -{ -private: - typedef typename ListB::TypeListValue ValueType ; - typedef typename ListB::TypeListTail TailType ; -public: - // ListA does not contain this ValueType and does not contain the remainder - enum { value = ( TypeListIndex::value == -1 ) && - TypeListDisjoint::value }; -}; - -//---------------------------------------------------------------------- - -template< typename T1 , - typename T2 , - typename T3 , - typename T4 , - typename T5 , - typename T6 , - typename T7 , - typename T8 , - typename T9 , - typename T10 , - typename T11 , - typename T12 , - typename T13 , - typename T14 , - typename T15 , - typename T16 , - typename T17 , - typename T18 , - typename T19 , - typename T20 , - typename T21 , - typename T22 , - typename T23 , - typename T24 , - typename T25 , - typename T26 , - typename T27 , - typename T28 , - typename T29 , - typename T30 , - typename T31 > -struct MakeTypeList { - typedef TypeListEnd type ; - enum { length = 0 }; - enum { unique = true }; -}; - -template< typename T0 , - typename T1 , - typename T2 , - typename T3 , - typename T4 , - typename T5 , - typename T6 , - typename T7 , - typename T8 , - typename T9 , - typename T10 , - typename T11 , - typename T12 , - typename T13 , - typename T14 , - typename T15 , - typename T16 , - typename T17 , - typename T18 , - typename T19 , - typename T20 , - typename T21 , - typename T22 , - typename T23 , - typename T24 , - typename T25 , - typename T26 , - typename T27 , - typename T28 , - typename T29 , - typename T30 , - typename T31 > -struct MakeTypeList { - typedef typename TypeListClean< - TypeList< T0 , - TypeList< T1, - TypeList< T2 , - TypeList< T3 , - TypeList< T4 , - TypeList< T5 , - TypeList< T6 , - TypeList< T7 , - TypeList< T8 , - TypeList< T9 , - TypeList< T10 , - TypeList< T11 , - TypeList< T12 , - TypeList< T13 , - TypeList< T14 , - TypeList< T15 , - TypeList< T16 , - TypeList< T17 , - TypeList< T18 , - TypeList< T19 , - TypeList< T20 , - TypeList< T21 , - TypeList< T22 , - TypeList< T23 , - TypeList< T24 , - TypeList< T25 , - TypeList< T26 , - TypeList< T27 , - TypeList< T28 , - TypeList< T29 , - TypeList< T30 , - TypeList< T31 , - TypeListEnd > > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > > - >::list_type type ; - enum { length = TypeListLength::value }; - enum { unique = TypeListUnique::value }; -}; - -} // namespace sierra - -#endif // stk_util_util_TypeList_h - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/TypeListMap.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/TypeListMap.hpp deleted file mode 100644 index 39b0e4a76c35..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/TypeListMap.hpp +++ /dev/null @@ -1,215 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2005 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ - - -#ifndef STK_UTIL_UTIL_TypeListMap_h -#define STK_UTIL_UTIL_TypeListMap_h - -/** - * @file - * @author H. Carter Edwards - * @date August 2005 - */ - -#include - -/** - * @file - * - */ - -namespace sierra { - -/** Map of 'class Tag' to 'Tag::type' value. - * The 'class Tag' should be a 'tag'; i.e., it - * a) not be virtual, - * b) not contain any member data, - * c) have a no-op default constructor, - * d) have a no-op destructor, and - * e) contain a 'typedef <...> type ;' statement. - */ -template< class ListType > class TypeListMap ; - -//---------------------------------------------------------------------- - -template class TypeListMapValue ; - -template -class TypeListMapValue -{ -private: - T const * x ; -public: - typedef TypeListMapValue SelfType ; - typedef T const & const_reference_type ; - typedef T const & reference_type ; - - TypeListMapValue() : x(0) {} - TypeListMapValue( SelfType const & v ) : x( v.x ) {} - explicit TypeListMapValue( T const & v ) : x( & v ) {} - - SelfType & operator = ( SelfType const & v ) { x = v.x ; return *this ; } - SelfType & operator = ( T const & v ) { x = &v ; return *this ; } - - operator T const & () const { return *x ; } - T const & get() const { return *x ; } -}; - -template -class TypeListMapValue -{ -private: - T * x ; -public: - typedef TypeListMapValue SelfType ; - typedef T & const_reference_type ; - typedef T & reference_type ; - - TypeListMapValue() : x(0) {} - TypeListMapValue( const SelfType & v ) : x( v.x ) {} - explicit TypeListMapValue( T & v ) : x( & v ) {} - - SelfType & operator = ( SelfType const & v ) { x = v.x ; return *this ; } - SelfType & operator = ( T & v ) { x = &v ; return *this ; } - - operator T & () const { return *x ; } - T & get() const { return *x ; } -}; - -template -class TypeListMapValue -{ -private: - T x ; -public: - typedef TypeListMapValue SelfType ; - typedef T const & const_reference_type ; - typedef T const & reference_type ; - - TypeListMapValue() {} - TypeListMapValue( SelfType const & v ) : x( v.x ) {} - explicit TypeListMapValue( T const & v ) : x( v ) {} - - SelfType & operator = ( SelfType const & v ) { x = v.x ; return *this ; } - SelfType & operator = ( T const & v ) { x = v ; return *this ; } - - operator T const & () const { return x ; } - T const & get() const { return x ; } -}; - -template -class TypeListMapValue -{ -private: - T x ; -public: - typedef TypeListMapValue SelfType ; - typedef T const & const_reference_type ; - typedef T & reference_type ; - - TypeListMapValue() {} - TypeListMapValue( SelfType const & v ) : x( v.x ) {} - explicit TypeListMapValue( T const & v ) : x( v ) {} - - SelfType & operator = ( SelfType const & v ) { x = v.x ; return *this ; } - SelfType & operator = ( T const & v ) { x = v ; return *this ; } - - operator T const & () const { return x ; } - T const & get() const { return x ; } -}; - -//---------------------------------------------------------------------- - -template<> -class TypeListMap {}; - -template -class TypeListMap< TypeList > {}; - -template -class TypeListMap : public TypeListMap -{ -private: - template friend class TypeListMap ; - - typedef typename ListType::TypeListTail TailType ; - typedef typename ListType::TypeListValue TagType ; - typedef typename TagType::type type ; - TypeListMapValue m_value ; - -public: - - typedef TypeListMap SelfType ; - - //---------- - - template - typename TypeListMapValue::const_reference_type - get() const - { - typedef typename TypeListMember::list_type MemberListType ; - return ((TypeListMap const &) *this).m_value.get(); - } - - template - void - set( typename TypeListMapValue::const_reference_type v ) - { - typedef typename TypeListMember::list_type MemberListType ; - ((TypeListMap &) *this).m_value.operator=( v ); - } - - //---------- - - TypeListMap & operator << - ( typename TypeListMapValue::const_reference_type v ) - { m_value = v ; return *this ; } - - TypeListMap const & operator >> - ( typename TypeListMapValue::reference_type v ) const - { v = m_value ; return *this ; } - - //---------- - - void copy( TypeListMap const & ) {} - - template - void copy( TypeListMap > const & b ) {} - - template - void copy( TypeListMap const & b ) - { - typedef typename ListB::TypeListValue TagB ; - typedef typename ListB::TypeListTail TailB ; - this->template set( b.template get() ); - copy( (TypeListMap const &) b ); - } - - //---------- - - ~TypeListMap() {} - - TypeListMap() {} - - TypeListMap( const SelfType & m ) - : TypeListMap( m ), m_value( m.m_value ) {} - - SelfType & operator = ( const SelfType & m ) - { - TypeListMap::operator=( m ); - m_value = m.m_value ; - return *this ; - } -}; - -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- - -} - -#endif // STK_UTIL_UTIL_TypeListMap_h diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/TypeUtil.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/TypeUtil.hpp deleted file mode 100644 index 4d0f1c1096b0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/TypeUtil.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2006 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date January 2006 - * - * Templates for static / compile-time checking - */ - -#ifndef STK_UTIL_UTIL_TypeUtil_hpp -#define STK_UTIL_UTIL_TypeUtil_hpp - -/** - * @file - * - */ - -namespace sierra { - -//----------------------------------- - -template struct IsFundamentalType ; - -template<> struct IsFundamentalType< char> { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; - -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; - -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; - -template<> struct IsFundamentalType { enum { value = true }; }; -template<> struct IsFundamentalType { enum { value = true }; }; - -template struct IsFundamentalType { enum { value = false }; }; - -//----------------------------------- - -template -class TypeTraits -{ -public: //private: - template struct Traits - { - enum {is_pointer = false}; - enum {is_reference = false}; - typedef U Type; - }; - - template struct Traits - { - enum {is_pointer = true}; - enum {is_reference = false}; - typedef U Type; - }; - - template struct Traits - { - enum {is_pointer = false}; - enum {is_reference = true}; - typedef U Type; - }; - - template struct ConstTraits - { - enum {is_const = false}; - typedef U Type; - }; - - template struct ConstTraits - { - enum {is_const = true}; - typedef U Type; - }; - -public: - enum {isPointer = Traits::is_pointer}; - enum {isReference = Traits::is_reference}; - enum {isConst = ConstTraits::is_const}; - typedef typename Traits::Type BaseType; -}; - -} // namespace sierra - -#endif // STK_UTIL_UTIL_TypeUtil_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/VecMap.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/VecMap.hpp deleted file mode 100644 index ca58e8f85f1b..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/VecMap.hpp +++ /dev/null @@ -1,380 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date October 2002 - */ - -#ifndef STK_UTIL_UTIL_vecmap_hpp -#define STK_UTIL_UTIL_vecmap_hpp - -#include -#include -#include -#include - -namespace sierra { - -/** - * @class vecmap - * @brief Vector-based std::map functionality - * - * @par Purpose: Mimic the 'std::map' interface - * - * This template class mimics the 'std::map' - * associative container interface; however, - * its semantics are significantly different. - * Storage for the map-lite class is provided - * by the std::vector class where the entries - * are sorted by key value. - * - * @par Domain of Applicability - * - * Light weight associative container functionality - * for small keys and values, e.g. key = integer - * and value = pointer. - * - * @par Associative container violations - * - * Modifications to the vecmap contents are linear - * complexity in violation of the associative - * container requirement for logarithmic complexity. - * Furthermore, modification operations are guaranteed - * to invalidate all iterators after the insert/erase - * point. Insertion operations may also invalidate - * all iterators if the storage is reallocated. - * - * @par Associative container compliance - * - * All non-modifying query operations conform to - * either the constant or logarithmic complexity. - */ - -template > -class vecmap { -public: - typedef Key key_type ; - typedef T mapped_type ; - typedef Compare key_compare ; - -private: // Hidden storage type - typedef std::vector< std::pair > storage ; - -public: - typedef typename storage::value_type value_type ; - typedef typename storage::allocator_type allocator_type ; - typedef typename allocator_type::reference reference ; - typedef typename allocator_type::const_reference const_reference ; - typedef typename allocator_type::pointer pointer ; - typedef typename allocator_type::const_pointer const_pointer ; - typedef typename storage::size_type size_type ; - typedef typename storage::difference_type difference_type ; - typedef typename storage::iterator iterator ; - typedef typename storage::const_iterator const_iterator ; - typedef typename storage::reverse_iterator reverse_iterator ; - typedef typename storage::const_reverse_iterator const_reverse_iterator ; - - typedef std::pair value_type_unconst_key ; - -private: // key compare functors - class value_compare - : public std::binary_function { - private: - key_compare comp ; - public: - bool operator ()( const value_type & RHS , const value_type & LHS ) const - { return comp( RHS.first , LHS.first ); } - }; - - class value_compare_key - : public std::binary_function { - private: - key_compare comp ; - public: - bool operator()( const value_type & RHS , const key_type & LHS ) const - { return comp( RHS.first , LHS ); } - }; - - class value_compare_unconst_key - : public std::binary_function { - private: - key_compare comp ; - public: - bool operator()( const value_type_unconst_key & RHS , const key_type & LHS ) const - { return comp( RHS.first , LHS ); } - }; - -private: // Object data - std::vector Storage; - value_compare ValueComp ; - value_compare_key ValueKeyComp ; - value_compare_unconst_key UnconstValueKeyComp ; - key_compare KeyComp ; - -private: - storage & pub() { - char &i = reinterpret_cast(Storage); - return reinterpret_cast(i); - } - - const storage & pub() const { - const char &i = reinterpret_cast(Storage); - return reinterpret_cast(i); - } - - typedef typename std::vector::iterator iterator_private ; - - static iterator_private & castit( iterator & i ) - { return reinterpret_cast(i); } - - static iterator & castit( iterator_private & i ) - { return reinterpret_cast(i); } - -public: - ~vecmap() {} - - vecmap() : Storage() {} - - vecmap( const vecmap & rhs ) : Storage(rhs.Storage) {} - - vecmap & operator = ( const vecmap & rhs ) { - Storage = rhs.Storage ; - return *this ; - } - - void swap( vecmap & v ) { - Storage.swap( v.Storage ); - } - - iterator begin() { return pub().begin(); } - iterator end() { return pub().end(); } - const_iterator begin() const { return pub().begin(); } - const_iterator end() const { return pub().end(); } - reverse_iterator rbegin() { return pub().rbegin(); } - reverse_iterator rend() { return pub().rend(); } - const_reverse_iterator rbegin() const { return pub().rbegin(); } - const_reverse_iterator rend() const { return pub().rend(); } - bool empty() const { return Storage.empty(); } - size_type size() const { return Storage.size(); } - size_type max_size() const { return Storage.max_size(); } - - - typename std::vector::iterator lower_bound_private_comp_( const key_type & k ) { - typename std::vector::iterator __first = Storage.begin(); - typename std::vector::iterator __last = Storage.end(); - -// difference_type __len = std::distance(__first, __last); - difference_type __len = __last - __first; - difference_type __half; - typename std::vector::iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; -// std::advance(__middle, __half); - __middle += __half; - if (UnconstValueKeyComp(*__middle, k)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - - std::pair insert( const value_type & v ) { - typename std::vector::iterator ip = - lower_bound_private_comp_(v.first); - // (ip-1)->first < v.first <= ip->first - const bool b = Storage.end() == ip || KeyComp( v.first , ip->first ); - // b = v.first != ip->first - if ( b ) ip = Storage.insert(ip,value_type_unconst_key(v.first,v.second)); - return std::pair( castit(ip), b ); - } - - mapped_type & operator[]( const key_type & k ) { - typename std::vector::iterator ip = - lower_bound_private_comp_(k); - - // (ip-1)->first < k <= ip->first - if ( Storage.end() == ip || KeyComp(k,ip->first) ) { - // k != ip->first => insert - ( ip = Storage.insert(ip,value_type_unconst_key()) )->first = k ; - } - return ip->second ; - } - - void erase( iterator i ) { - Storage.erase( castit(i) ); - } - - void erase( iterator first , iterator last ) { - Storage.erase( castit(first), castit(last) ); - } - - size_type erase( const key_type & k ) { - const typename std::vector::iterator i = - lower_bound_private_comp_(k); - return KeyComp( k , i->first ) ? 0 : ( Storage.erase(i) , 1 ); - } - - void clear() { - Storage.clear(); - } - - key_compare key_comp() const { return KeyComp ; } - - value_compare value_comp() const { return ValueComp ; } - - iterator lower_bound( const key_type & k ) { - iterator __first = begin(); - iterator __last = end(); - -// difference_type __len = std::distance(__first, __last); - difference_type __len = __last - __first; - difference_type __half; - iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; -// std::advance(__middle, __half); - __middle += __half; - if (ValueKeyComp(*__middle, k)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - - const_iterator lower_bound( const key_type & k ) const { - const_iterator __first = begin(); - const_iterator __last = end(); - -// difference_type __len = std::distance(__first, __last); - difference_type __len = __last - __first; - difference_type __half; - const_iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; -// std::advance(__middle, __half); - __middle += __half; - if (ValueKeyComp(*__middle, k)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - - iterator upper_bound( const key_type & k ) { - iterator __first = begin(); - iterator __last = end(); - -// difference_type __len = std::distance(__first, __last); - difference_type __len = __last - __first; - difference_type __half; - iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; -// std::advance(__middle, __half); - __middle += __half; - if (__comp(k, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; - } - - - const_iterator upper_bound( const key_type & k ) const { - const_iterator __first = begin(); - const_iterator __last = end(); - -// difference_type __len = std::distance(__first, __last); - difference_type __len = __last - __first; - difference_type __half; - const_iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; -// std::advance(__middle, __half); - __middle += __half; - if (__comp(k, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; - } - - - iterator find( const key_type & k ) { - const iterator i = lower_bound(k); - return end() == i || KeyComp( k , i->first ) ? end() : i ; - } - - const_iterator find( const key_type & k ) const { - const const_iterator i = lower_bound(k); - return end() == i || KeyComp( k , i->first ) ? end() : i ; - } - - size_type count( const key_type & k ) const { - const const_iterator i = lower_bound(k); - return end() == i || KeyComp( k , i->first ) ? 0 : 1 ; - } - - //-------------------------------------------------------------------- - // Is ok to get constant versions of the underlyingstorage - - operator const std::vector & () const { - return * reinterpret_cast*>( &Storage ); - } - - operator const std::vector< std::pair > & () const { - return Storage ; - } - - void reserve( size_type n ) { - Storage.reserve(n); - } - - bool operator == ( const vecmap & rhs ) const { - return Storage == rhs.Storage ; - } - - bool operator != ( const vecmap & rhs ) const { - return Storage != rhs.Storage ; - } -}; - -} // namespace sierra - -#endif // STK_UTIL_UTIL_vecmap_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/VecSet.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/VecSet.hpp deleted file mode 100644 index aeefc082ad01..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/VecSet.hpp +++ /dev/null @@ -1,298 +0,0 @@ -/*--------------------------------------------------------------------*/ -/* Copyright 2002 Sandia Corporation. */ -/* Under the terms of Contract DE-AC04-94AL85000, there is a */ -/* non-exclusive license for use of this work by or on behalf */ -/* of the U.S. Government. Export of this program may require */ -/* a license from the United States Government. */ -/*--------------------------------------------------------------------*/ -/** - * @file - * @author H. Carter Edwards - * @date October 2002 - */ - -#ifndef STK_UTIL_UTIL_vecset_hpp -#define STK_UTIL_UTIL_vecset_hpp - -#include -#include -#include - -namespace sierra { - -/** - * @class vecset - * @brief Vector-based std::set functionality - * - * @par Purpose: Mimic the 'std::set' interface - * - * This template class mimics the 'std::set' - * associative container interface; however, - * its semantics are significantly different. - * Storage for the set-lite class is provided - * by the std::vector class where the entries - * are sorted by key value. - * - * @par Domain of Applicability - * - * Light weight associative container functionality - * for small keys and values, e.g. key = integer - * and value = pointer. - * - * @par Associative container violations - * - * Modifications to the vecset contents are linear - * complexity in violation of the associative - * container requirement for logarithmic complexity. - * Furthermore, modification operations are guaranteed - * to invalidate all iterators after the insert/erase - * point. Insertion operations may also invalidate - * all iterators if the storage is reallocated. - * - * @par Associative container compliance - * - * All non-modifying query operations conform to - * either the constant or logarithmic complexity. - */ - -template > -class vecset { -private: - template - struct const_key_type_meta_func - { - typedef const T type; - }; - - template - struct const_key_type_meta_func - { - typedef const T* const type; - }; - -public: - - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Compare value_compare; - typedef typename const_key_type_meta_func::type const_key_type; - -private: - - typedef std::vector storage ; - -public: - - typedef typename storage::allocator_type allocator_type ; - typedef typename allocator_type::reference reference ; - typedef typename allocator_type::const_reference const_reference ; - typedef typename allocator_type::pointer pointer ; - typedef typename allocator_type::const_pointer const_pointer ; - typedef typename storage::size_type size_type ; - typedef typename storage::difference_type difference_type ; - typedef typename storage::iterator iterator ; - typedef typename storage::const_iterator const_iterator ; - typedef typename storage::reverse_iterator reverse_iterator ; - typedef typename storage::const_reverse_iterator const_reverse_iterator ; - - //-------------------------------------------------------------------- -private: - - key_compare KeyComp ; - storage Storage ; - -public: - //-------------------------------------------------------------------- - - ~vecset() - {} - - vecset() : Storage() - {} - - vecset( const vecset & rhs ) : Storage(rhs.Storage) - {} - - vecset & operator = ( const vecset & rhs ) { - Storage = rhs.Storage ; - return *this ; - } - - void swap( vecset & v ) { - Storage.swap( v.Storage ); - } - - iterator begin() { return Storage.begin(); } - iterator end() { return Storage.end(); } - const_iterator begin() const { return Storage.begin(); } - const_iterator end() const { return Storage.end(); } - reverse_iterator rbegin() { return Storage.rbegin(); } - reverse_iterator rend() { return Storage.rend(); } - const_reverse_iterator rbegin() const { return Storage.rbegin(); } - const_reverse_iterator rend() const { return Storage.rend(); } - bool empty() const { return Storage.empty(); } - size_type size() const { return Storage.size(); } - size_type max_size() const { return Storage.max_size(); } - - iterator lower_bound( const_key_type & k ) { - iterator __first = begin(); - iterator __last = end(); - - difference_type __len = __last - __first; - difference_type __half; - iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - __middle += __half; - if (KeyComp(*__middle, k)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - - const_iterator lower_bound( const_key_type & k ) const { - const_iterator __first = begin(); - const_iterator __last = end(); - - difference_type __len = __last - __first; - difference_type __half; - const_iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - __middle += __half; - if (KeyComp(*__middle, k)) { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - - iterator upper_bound( const_key_type & k ) { - iterator __first = begin(); - iterator __last = end(); - - difference_type __len = __last - __first; - difference_type __half; - iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - __middle += __half; - if (__comp(k, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; - } - - - const_iterator upper_bound( const_key_type & k ) const { - const_iterator __first = begin(); - const_iterator __last = end(); - - difference_type __len = __last - __first; - difference_type __half; - const_iterator __middle; - - while (__len > 0) { - __half = __len >> 1; - __middle = __first; - __middle += __half; - if (__comp(k, *__middle)) - __len = __half; - else { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - } - return __first; - } - - std::pair insert( const value_type & v ) { - typename storage::iterator ip = lower_bound(v); - // (ip-1)->first < v <= ip->first - const bool b = Storage.end() == ip || KeyComp( v , *ip ); - // b = v != *ip - if ( b ) ip = Storage.insert(ip,v); - return std::pair( ip, b ); - } - - void erase( iterator i ) { - Storage.erase( Storage.begin() + ( i - begin() ) ); - } - - void erase( iterator first , iterator last ) { - Storage.erase( Storage.begin() + ( first - begin() ) , - Storage.begin() + ( last - begin() ) ); - } - - size_type erase( const_key_type & k ) { - typename storage::iterator i = lower_bound(k ); - return KeyComp( k , *i ) ? 0 : ( Storage.erase(i) , 1 ); - } - - void clear() { - Storage.clear(); - } - - key_compare key_comp() const { return KeyComp ; } - value_compare value_comp() const { return KeyComp ; } - - iterator find( const_key_type & k ) { - const iterator i = lower_bound(k); - return end() == i || KeyComp( k , *i ) ? end() : i ; - } - - const_iterator find( const_key_type & k ) const { - const const_iterator i = lower_bound(k); - return end() == i || KeyComp( k , *i ) ? end() : i ; - } - - size_type count( const_key_type & k ) const { - const const_iterator i = lower_bound(k); - return end() == i || KeyComp( k , *i ) ? 0 : 1 ; - } - - //-------------------------------------------------------------------- - // Allow conversion to constant vector - - operator const storage & () const { - return Storage ; - } - - void reserve( size_type n ) { - Storage.reserve( n ); - } - - bool operator == ( const vecset & rhs ) const { - return Storage == rhs.Storage ; - } - - bool operator != ( const vecset & rhs ) const { - return Storage != rhs.Storage ; - } -}; - -} - -#endif // STK_UTIL_UTIL_vecset_hpp diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.cpp deleted file mode 100644 index c0a671002d92..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -std::ostream & -operator<<( - std::ostream & os, - const ci_string & s) -{ - return os << std::string(s.data(),s.length()); -} - - -std::istream & -operator>>( - std::istream & is, - ci_string & s) -{ - std::string t; - is >> t; - s = ci_string(t.begin(), t.end()); - - return is; -} - -std::string -operator+( - const std::string & s1, - const ci_string & s2) -{ - std::string s(s1); - - return s.append(s2.begin(), s2.end()); -} - - -ci_string -operator+( - const char * s1, - const ci_string & s2) -{ - ci_string s(s1); - - return s.append(s2.begin(), s2.end()); -} - - -ci_string -operator+( - const ci_string & s1, - const std::string & s2) -{ - ci_string s(s1); - - return s.append(s2.begin(), s2.end()); -} - - -// namespace boost { - -// std::size_t -// hash::operator()( -// const ci_string & s) const -// { -// std::size_t seed = 0; - -// for(ci_string::const_iterator first = s.begin(); first != s.end(); ++first) { -// std::tr1::hash hasher; -// seed ^= hasher(std::tolower(*first)) + 0x9e3779b9 + (seed<<6) + (seed>>2); -// } - -// return seed; -// } - -// } // namespace boost diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.hpp deleted file mode 100644 index afb77eccfc62..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/ci_string.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_CI_STRING_H -#define STK_UTIL_UTIL_CI_STRING_H - -#include -#include - -// #include // boost 1.36.0 unordered_set not in the tr1 - -// namespace std { -// namespace tr1 { -// using ::boost::unordered_set; -// } -// } - -typedef std::basic_string ci_string; - -std::ostream &operator<<(std::ostream &os, const ci_string &s); - -std::istream &operator>>(std::istream &is, ci_string &s); - -std::string operator+(const std::string &s1, const ci_string &s2); - -ci_string operator+(const ci_string &s1, const std::string &s2); - -ci_string operator+(const char *cs1, const ci_string &cs2); - -// namespace boost { - -// template <> -// struct hash -// { -// std::size_t operator()(const ci_string &s) const; -// }; - -// } // namespace boost - -#endif // STK_UTIL_UTIL_CI_STRING_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.cpp deleted file mode 100644 index 3b8447c2efec..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -int -ignorecase_traits::compare( - const char * s1, - const char * s2, - std::size_t n) -{ - for (std::size_t i = 0; i < n; ++i) - if (!eq(s1[i], s2[i])) - return lt(s1[i], s2[i]) ? -1 : 1; - - return 0; -} - -const char * -ignorecase_traits::find( - const char * s, - std::size_t n, - const char & c) -{ - for (std::size_t i = 0; i < n; ++i) - if (eq(s[i], c)) - return &(s[i]); - - return 0; -} diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.hpp deleted file mode 100644 index e0257406ad7f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/ci_traits.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#ifndef STK_UTIL_UTIL_CI_TRAITS_H -#define STK_UTIL_UTIL_CI_TRAITS_H - -#include -#include - -/** - * @brief Class ignorecase_traits is a character traits class that ignores case during compares. - * - * Replace functions of the standard char_traits so that strings behave in a case-insensitive - * way. - * - */ -struct ignorecase_traits : public std::char_traits -{ - /** - * @brief Member function eq return true is c1 and c2 are equal. - * - * @param c1 a char const reference to character to compare. - * - * @param c2 a char const reference to character to compare. - * - * @return a bool of true if c1 and c2 are equal - */ - static bool eq(const char &c1, const char &c2) { - return std::toupper(c1) == std::toupper(c2); - } - - /** - * @brief Member function lt return true is c1 less than c2. - * - * @param c1 a char const ... - * - * @param c2 a char const ... - * - * @return a bool ... - */ - static bool lt(const char &c1, const char &c2) { - return std::toupper(c1) < std::toupper(c2); - } - - /** - * @brief Member function compare compares up to n characters of s1 and s2 and returns -1 if - * s1 is less then s2, 0 if they are equal, and 1 if s1 is greater than s2. - * - * @param s1 a char const pointer to string to compare. - * - * @param s2 a char const pointer to string to compare. - * - * @param n a std::size_t maxiumum number of character to compare. - * - * @return an int value of -1 if s1 is less then s2, 0 if they are - * equal, and 1 if s1 is greater than s2. - */ - static int compare(const char *s1, const char *s2, std::size_t n); - - /** - * @brief Member function find returns char pointer to first occurrence of character - * c in first n characters of string s or 0 if not found. - * - * @param s a char const pointer to string to search in. - * - * @param n a std::size_t value of the maximum number of characters to - * compare. - * - * @param c a char const reference to the character to search. - * - * @return a char pointer to first occurrence or 0 is not found. - */ - static const char *find(const char *s, std::size_t n, const char &c); -}; - -#endif // STK_UTIL_UTIL_CI_TRAITS_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/config_google.h b/packages/stk/stk_classic/stk_util/stk_util/util/config_google.h deleted file mode 100644 index 8e326a90fea4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/config_google.h +++ /dev/null @@ -1,135 +0,0 @@ -/* src/config.h. Generated from config.h.in by configure. */ -/* src/config.h.in. Generated from configure.ac by autoheader. */ - -/* Namespace for Google classes */ -#define GOOGLE_NAMESPACE ::google - -/* the location of the header defining hash functions */ -//CB20_05_11#define HASH_FUN_H - -/* the location of or */ -#define HASH_MAP_H - -/* the namespace of the hash<> function */ -#define HASH_NAMESPACE std::tr1 - -/* the location of or */ -#define HASH_SET_H - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_GOOGLE_MALLOC_EXTENSION_H */ - -/* define if the compiler has hash_map */ -#define HAVE_HASH_MAP 1 - -/* define if the compiler has hash_set */ -#define HAVE_HASH_SET 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if the system has the type `long long'. */ -#define HAVE_LONG_LONG 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* define if the compiler implements namespaces */ -//CB 20_05_11#define HAVE_NAMESPACES 1 - -/* Define if you have POSIX threads libraries and header files. */ -/* #undef HAVE_PTHREAD */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define to 1 if the system has the type `uint16_t'. */ -#define HAVE_UINT16_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* define if the compiler supports unordered_{map,set} */ -#define HAVE_UNORDERED_MAP 1 - -/* Define to 1 if the system has the type `u_int16_t'. */ -#define HAVE_U_INT16_T 1 - -/* Define to 1 if the system has the type `__uint16'. */ -/* #undef HAVE___UINT16 */ - -/* Name of package */ -#define PACKAGE "sparsehash" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "opensource@google.com" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "sparsehash" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "sparsehash 1.10" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "sparsehash" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.10" - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -/* #undef PTHREAD_CREATE_JOINABLE */ - -/* The system-provided hash function including the namespace. */ -#define SPARSEHASH_HASH HASH_NAMESPACE::hash - -/* The system-provided hash function, in namespace HASH_NAMESPACE. */ -#define SPARSEHASH_HASH_NO_NAMESPACE hash - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* the namespace where STL code like vector<> is defined */ -#define STL_NAMESPACE std - -/* Version number of package */ -#define VERSION "1.10" - -/* Stops putting the code inside the Google namespace */ -#define _END_GOOGLE_NAMESPACE_ } - -/* Puts following code inside the Google namespace */ -#define _START_GOOGLE_NAMESPACE_ namespace google { diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/dense_hash_map b/packages/stk/stk_classic/stk_util/stk_util/util/dense_hash_map deleted file mode 100644 index 788fcefcd11f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/dense_hash_map +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: Craig Silverstein -// -// This is just a very thin wrapper over densehashtable.h, just -// like sgi stl's stl_hash_map is a very thin wrapper over -// stl_hashtable. The major thing we define is operator[], because -// we have a concept of a data_type which stl_hashtable doesn't -// (it only has a key and a value). -// -// NOTE: this is exactly like sparse_hash_map.h, with the word -// "sparse" replaced by "dense", except for the addition of -// set_empty_key(). -// -// YOU MUST CALL SET_EMPTY_KEY() IMMEDIATELY AFTER CONSTRUCTION. -// -// Otherwise your program will die in mysterious ways. (Note if you -// use the constructor that takes an InputIterator range, you pass in -// the empty key in the constructor, rather than after. As a result, -// this constructor differs from the standard STL version.) -// -// In other respects, we adhere mostly to the STL semantics for -// hash-map. One important exception is that insert() may invalidate -// iterators entirely -- STL semantics are that insert() may reorder -// iterators, but they all still refer to something valid in the -// hashtable. Not so for us. Likewise, insert() may invalidate -// pointers into the hashtable. (Whether insert invalidates iterators -// and pointers depends on whether it results in a hashtable resize). -// On the plus side, delete() doesn't invalidate iterators or pointers -// at all, or even change the ordering of elements. -// -// Here are a few "power user" tips: -// -// 1) set_deleted_key(): -// If you want to use erase() you *must* call set_deleted_key(), -// in addition to set_empty_key(), after construction. -// The deleted and empty keys must differ. -// -// 2) resize(0): -// When an item is deleted, its memory isn't freed right -// away. This allows you to iterate over a hashtable, -// and call erase(), without invalidating the iterator. -// To force the memory to be freed, call resize(0). -// For tr1 compatibility, this can also be called as rehash(0). -// -// 3) min_load_factor(0.0) -// Setting the minimum load factor to 0.0 guarantees that -// the hash table will never shrink. -// -// Roughly speaking: -// (1) dense_hash_map: fastest, uses the most memory unless entries are small -// (2) sparse_hash_map: slowest, uses the least memory -// (3) hash_map / unordered_map (STL): in the middle -// -// Typically I use sparse_hash_map when I care about space and/or when -// I need to save the hashtable on disk. I use hash_map otherwise. I -// don't personally use dense_hash_set ever; some people use it for -// small sets with lots of lookups. -// -// - dense_hash_map has, typically, about 78% memory overhead (if your -// data takes up X bytes, the hash_map uses .78X more bytes in overhead). -// - sparse_hash_map has about 4 bits overhead per entry. -// - sparse_hash_map can be 3-7 times slower than the others for lookup and, -// especially, inserts. See time_hash_map.cc for details. -// -// See /usr/(local/)?doc/sparsehash-*/dense_hash_map.html -// for information about how to use this class. - -#ifndef _DENSE_HASH_MAP_H_ -#define _DENSE_HASH_MAP_H_ - -#include -#include // for FILE * in read()/write() -#include // for the default template args -#include // for equal_to -#include // for alloc<> -#include // for pair<> -//CB20_05_11#include HASH_FUN_H // defined in config.h -#include -#include - - -_START_GOOGLE_NAMESPACE_ - -using STL_NAMESPACE::pair; - -template , // defined in sparseconfig.h - class EqualKey = STL_NAMESPACE::equal_to, - class Alloc = libc_allocator_with_realloc > > -class dense_hash_map { - private: - // Apparently select1st is not stl-standard, so we define our own - struct SelectKey { - typedef const Key& result_type; - const Key& operator()(const pair& p) const { - return p.first; - } - }; - struct SetKey { - void operator()(pair* value, const Key& new_key) const { - *const_cast(&value->first) = new_key; - // It would be nice to clear the rest of value here as well, in - // case it's taking up a lot of memory. We do this by clearing - // the value. This assumes T has a zero-arg constructor! - value->second = T(); - } - }; - // For operator[]. - struct DefaultValue { - STL_NAMESPACE::pair operator()(const Key& key) { - return STL_NAMESPACE::make_pair(key, T()); - } - }; - - // The actual data - typedef dense_hashtable, Key, HashFcn, SelectKey, - SetKey, EqualKey, Alloc> ht; - ht rep; - - public: - typedef typename ht::key_type key_type; - typedef T data_type; - typedef T mapped_type; - typedef typename ht::value_type value_type; - typedef typename ht::hasher hasher; - typedef typename ht::key_equal key_equal; - typedef Alloc allocator_type; - - typedef typename ht::size_type size_type; - typedef typename ht::difference_type difference_type; - typedef typename ht::pointer pointer; - typedef typename ht::const_pointer const_pointer; - typedef typename ht::reference reference; - typedef typename ht::const_reference const_reference; - - typedef typename ht::iterator iterator; - typedef typename ht::const_iterator const_iterator; - typedef typename ht::local_iterator local_iterator; - typedef typename ht::const_local_iterator const_local_iterator; - - // Iterator functions - iterator begin() { return rep.begin(); } - iterator end() { return rep.end(); } - const_iterator begin() const { return rep.begin(); } - const_iterator end() const { return rep.end(); } - - - // These come from tr1's unordered_map. For us, a bucket has 0 or 1 elements. - local_iterator begin(size_type i) { return rep.begin(i); } - local_iterator end(size_type i) { return rep.end(i); } - const_local_iterator begin(size_type i) const { return rep.begin(i); } - const_local_iterator end(size_type i) const { return rep.end(i); } - - // Accessor functions - allocator_type get_allocator() const { return rep.get_allocator(); } - hasher hash_funct() const { return rep.hash_funct(); } - hasher hash_function() const { return hash_funct(); } - key_equal key_eq() const { return rep.key_eq(); } - - - // Constructors - explicit dense_hash_map(size_type expected_max_items_in_table = 0, - const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) - : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) { - } - - template - dense_hash_map(InputIterator f, InputIterator l, - const key_type& empty_key_val, - size_type expected_max_items_in_table = 0, - const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) - : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) { - set_empty_key(empty_key_val); - rep.insert(f, l); - } - // We use the default copy constructor - // We use the default operator=() - // We use the default destructor - - void clear() { rep.clear(); } - // This clears the hash map without resizing it down to the minimum - // bucket count, but rather keeps the number of buckets constant - void clear_no_resize() { rep.clear_no_resize(); } - void swap(dense_hash_map& hs) { rep.swap(hs.rep); } - - - // Functions concerning size - size_type size() const { return rep.size(); } - size_type max_size() const { return rep.max_size(); } - bool empty() const { return rep.empty(); } - size_type bucket_count() const { return rep.bucket_count(); } - size_type max_bucket_count() const { return rep.max_bucket_count(); } - - // These are tr1 methods. bucket() is the bucket the key is or would be in. - size_type bucket_size(size_type i) const { return rep.bucket_size(i); } - size_type bucket(const key_type& key) const { return rep.bucket(key); } - float load_factor() const { - return size() * 1.0f / bucket_count(); - } - float max_load_factor() const { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - return grow; - } - void max_load_factor(float new_grow) { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - rep.set_resizing_parameters(shrink, new_grow); - } - // These aren't tr1 methods but perhaps ought to be. - float min_load_factor() const { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - return shrink; - } - void min_load_factor(float new_shrink) { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - rep.set_resizing_parameters(new_shrink, grow); - } - // Deprecated; use min_load_factor() or max_load_factor() instead. - void set_resizing_parameters(float shrink, float grow) { - rep.set_resizing_parameters(shrink, grow); - } - - void resize(size_type hint) { rep.resize(hint); } - void rehash(size_type hint) { resize(hint); } // the tr1 name - - // Lookup routines - iterator find(const key_type& key) { return rep.find(key); } - const_iterator find(const key_type& key) const { return rep.find(key); } - - data_type& operator[](const key_type& key) { // This is our value-add! - // If key is in the hashtable, returns find(key)->second, - // otherwise returns insert(value_type(key, T()).first->second. - // Note it does not create an empty T unless the find fails. - return rep.template find_or_insert(key).second; - } - - size_type count(const key_type& key) const { return rep.count(key); } - - pair equal_range(const key_type& key) { - return rep.equal_range(key); - } - pair equal_range(const key_type& key) const { - return rep.equal_range(key); - } - - // Insertion routines - pair insert(const value_type& obj) { return rep.insert(obj); } - template - void insert(InputIterator f, InputIterator l) { rep.insert(f, l); } - void insert(const_iterator f, const_iterator l) { rep.insert(f, l); } - // required for std::insert_iterator; the passed-in iterator is ignored - iterator insert(iterator, const value_type& obj) { return insert(obj).first; } - - - // Deletion and empty routines - // THESE ARE NON-STANDARD! I make you specify an "impossible" key - // value to identify deleted and empty buckets. You can change the - // deleted key as time goes on, or get rid of it entirely to be insert-only. - void set_empty_key(const key_type& key) { // YOU MUST CALL THIS! - rep.set_empty_key(value_type(key, data_type())); // rep wants a value - } - key_type empty_key() const { - return rep.empty_key().first; // rep returns a value - } - - void set_deleted_key(const key_type& key) { rep.set_deleted_key(key); } - void clear_deleted_key() { rep.clear_deleted_key(); } - key_type deleted_key() const { return rep.deleted_key(); } - - // These are standard - size_type erase(const key_type& key) { return rep.erase(key); } - void erase(iterator it) { rep.erase(it); } - void erase(iterator f, iterator l) { rep.erase(f, l); } - - - // Comparison - bool operator==(const dense_hash_map& hs) const { return rep == hs.rep; } - bool operator!=(const dense_hash_map& hs) const { return rep != hs.rep; } - - - // I/O -- this is an add-on for writing metainformation to disk - bool write_metadata(FILE *fp) { return rep.write_metadata(fp); } - bool read_metadata(FILE *fp) { return rep.read_metadata(fp); } - bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); } - bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); } -}; - -// We need a global swap as well -template -inline void swap(dense_hash_map& hm1, - dense_hash_map& hm2) { - hm1.swap(hm2); -} - -_END_GOOGLE_NAMESPACE_ - -#endif /* _DENSE_HASH_MAP_H_ */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/densehashtable.h b/packages/stk/stk_classic/stk_util/stk_util/util/densehashtable.h deleted file mode 100644 index d5ea438f73c4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/densehashtable.h +++ /dev/null @@ -1,1268 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Craig Silverstein -// -// A dense hashtable is a particular implementation of -// a hashtable: one that is meant to minimize memory allocation. -// It does this by using an array to store all the data. We -// steal a value from the key space to indicate "empty" array -// elements (ie indices where no item lives) and another to indicate -// "deleted" elements. -// -// (Note it is possible to change the value of the delete key -// on the fly; you can even remove it, though after that point -// the hashtable is insert_only until you set it again. The empty -// value however can't be changed.) -// -// To minimize allocation and pointer overhead, we use internal -// probing, in which the hashtable is a single table, and collisions -// are resolved by trying to insert again in another bucket. The -// most cache-efficient internal probing schemes are linear probing -// (which suffers, alas, from clumping) and quadratic probing, which -// is what we implement by default. -// -// Type requirements: value_type is required to be Copy Constructible -// and Default Constructible. It is not required to be (and commonly -// isn't) Assignable. -// -// You probably shouldn't use this code directly. Use -// or instead. - -// You can change the following below: -// HT_OCCUPANCY_PCT -- how full before we double size -// HT_EMPTY_PCT -- how empty before we halve size -// HT_MIN_BUCKETS -- default smallest bucket size -// -// You can also change enlarge_factor (which defaults to -// HT_OCCUPANCY_PCT), and shrink_factor (which defaults to -// HT_EMPTY_PCT) with set_resizing_parameters(). -// -// How to decide what values to use? -// shrink_factor's default of .4 * OCCUPANCY_PCT, is probably good. -// HT_MIN_BUCKETS is probably unnecessary since you can specify -// (indirectly) the starting number of buckets at construct-time. -// For enlarge_factor, you can use this chart to try to trade-off -// expected lookup time to the space taken up. By default, this -// code uses quadratic probing, though you can change it to linear -// via _JUMP below if you really want to. -// -// From http://www.augustana.ca/~mohrj/courses/1999.fall/csc210/lecture_notes/hashing.html -// NUMBER OF PROBES / LOOKUP Successful Unsuccessful -// Quadratic collision resolution 1 - ln(1-L) - L/2 1/(1-L) - L - ln(1-L) -// Linear collision resolution [1+1/(1-L)]/2 [1+1/(1-L)2]/2 -// -// -- enlarge_factor -- 0.10 0.50 0.60 0.75 0.80 0.90 0.99 -// QUADRATIC COLLISION RES. -// probes/successful lookup 1.05 1.44 1.62 2.01 2.21 2.85 5.11 -// probes/unsuccessful lookup 1.11 2.19 2.82 4.64 5.81 11.4 103.6 -// LINEAR COLLISION RES. -// probes/successful lookup 1.06 1.5 1.75 2.5 3.0 5.5 50.5 -// probes/unsuccessful lookup 1.12 2.5 3.6 8.5 13.0 50.0 5000.0 - -#ifndef _DENSEHASHTABLE_H_ -#define _DENSEHASHTABLE_H_ - -// The probing method -// Linear probing -// #define JUMP_(key, num_probes) ( 1 ) -// Quadratic probing -#define JUMP_(key, num_probes) ( num_probes ) - - -#include -#include -#include -#include // for abort() -#include // For swap(), eg -#include // For length_error -#include // For cerr -#include // For uninitialized_fill, uninitialized_copy -#include // for pair<> -#include // for facts about iterator tags -#include // for numeric_limits<> -#include -#include -#include // for true_type, integral_constant, etc. - -_START_GOOGLE_NAMESPACE_ - -using STL_NAMESPACE::pair; - -// Hashtable class, used to implement the hashed associative containers -// hash_set and hash_map. - -// Value: what is stored in the table (each bucket is a Value). -// Key: something in a 1-to-1 correspondence to a Value, that can be used -// to search for a Value in the table (find() takes a Key). -// HashFcn: Takes a Key and returns an integer, the more unique the better. -// ExtractKey: given a Value, returns the unique Key associated with it. -// Must inherit from unary_function, or at least have a -// result_type enum indicating the return type of operator(). -// SetKey: given a Value* and a Key, modifies the value such that -// ExtractKey(value) == key. We guarantee this is only called -// with key == deleted_key or key == empty_key. -// EqualKey: Given two Keys, says whether they are the same (that is, -// if they are both associated with the same Value). -// Alloc: STL allocator to use to allocate memory. - -template -class dense_hashtable; - -template -struct dense_hashtable_iterator; - -template -struct dense_hashtable_const_iterator; - -// We're just an array, but we need to skip over empty and deleted elements -template -struct dense_hashtable_iterator { - private: - typedef typename A::template rebind::other value_alloc_type; - - public: - typedef dense_hashtable_iterator iterator; - typedef dense_hashtable_const_iterator const_iterator; - - typedef STL_NAMESPACE::forward_iterator_tag iterator_category; - typedef V value_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::pointer pointer; - - // "Real" constructor and default constructor - dense_hashtable_iterator(const dense_hashtable *h, - pointer it, pointer it_end, bool advance) - : ht(h), pos(it), end(it_end) { - if (advance) advance_past_empty_and_deleted(); - } - dense_hashtable_iterator() { } - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *pos; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic. The only hard part is making sure that - // we're not on an empty or marked-deleted array element - void advance_past_empty_and_deleted() { - while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) ) - ++pos; - } - iterator& operator++() { - assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - - // Comparison. - bool operator==(const iterator& it) const { return pos == it.pos; } - bool operator!=(const iterator& it) const { return pos != it.pos; } - - - // The actual data - const dense_hashtable *ht; - pointer pos, end; -}; - - -// Now do it all again, but with const-ness! -template -struct dense_hashtable_const_iterator { - private: - typedef typename A::template rebind::other value_alloc_type; - - public: - typedef dense_hashtable_iterator iterator; - typedef dense_hashtable_const_iterator const_iterator; - - typedef STL_NAMESPACE::forward_iterator_tag iterator_category; - typedef V value_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::const_reference reference; - typedef typename value_alloc_type::const_pointer pointer; - - // "Real" constructor and default constructor - dense_hashtable_const_iterator( - const dense_hashtable *h, - pointer it, pointer it_end, bool advance) - : ht(h), pos(it), end(it_end) { - if (advance) advance_past_empty_and_deleted(); - } - dense_hashtable_const_iterator() - : ht(NULL), pos(pointer()), end(pointer()) { } - // This lets us convert regular iterators to const iterators - dense_hashtable_const_iterator(const iterator &it) - : ht(it.ht), pos(it.pos), end(it.end) { } - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *pos; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic. The only hard part is making sure that - // we're not on an empty or marked-deleted array element - void advance_past_empty_and_deleted() { - while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) ) - ++pos; - } - const_iterator& operator++() { - assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this; - } - const_iterator operator++(int) { const_iterator tmp(*this); ++*this; return tmp; } - - // Comparison. - bool operator==(const const_iterator& it) const { return pos == it.pos; } - bool operator!=(const const_iterator& it) const { return pos != it.pos; } - - - // The actual data - const dense_hashtable *ht; - pointer pos, end; -}; - -template -class dense_hashtable { - private: - typedef typename Alloc::template rebind::other value_alloc_type; - - public: - typedef Key key_type; - typedef Value value_type; - typedef HashFcn hasher; - typedef EqualKey key_equal; - typedef Alloc allocator_type; - - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::const_reference const_reference; - typedef typename value_alloc_type::pointer pointer; - typedef typename value_alloc_type::const_pointer const_pointer; - typedef dense_hashtable_iterator - iterator; - - typedef dense_hashtable_const_iterator - const_iterator; - - // These come from tr1. For us they're the same as regular iterators. - typedef iterator local_iterator; - typedef const_iterator const_local_iterator; - - // How full we let the table get before we resize, by default. - // Knuth says .8 is good -- higher causes us to probe too much, - // though it saves memory. - static const int HT_OCCUPANCY_PCT; // = 50 (out of 100) - - // How empty we let the table get before we resize lower, by default. - // (0.0 means never resize lower.) - // It should be less than OCCUPANCY_PCT / 2 or we thrash resizing - static const int HT_EMPTY_PCT; // = 0.4 * HT_OCCUPANCY_PCT; - - // Minimum size we're willing to let hashtables be. - // Must be a power of two, and at least 4. - // Note, however, that for a given hashtable, the initial size is a - // function of the first constructor arg, and may be >HT_MIN_BUCKETS. - static const size_type HT_MIN_BUCKETS = 4; - - // By default, if you don't specify a hashtable size at - // construction-time, we use this size. Must be a power of two, and - // at least HT_MIN_BUCKETS. - static const size_type HT_DEFAULT_STARTING_BUCKETS = 32; - - // ITERATOR FUNCTIONS - iterator begin() { return iterator(this, table, - table + num_buckets, true); } - iterator end() { return iterator(this, table + num_buckets, - table + num_buckets, true); } - const_iterator begin() const { return const_iterator(this, table, - table+num_buckets,true);} - const_iterator end() const { return const_iterator(this, table + num_buckets, - table+num_buckets,true);} - - // These come from tr1 unordered_map. They iterate over 'bucket' n. - // We'll just consider bucket n to be the n-th element of the table. - local_iterator begin(size_type i) { - return local_iterator(this, table + i, table + i+1, false); - } - local_iterator end(size_type i) { - local_iterator it = begin(i); - if (!test_empty(i) && !test_deleted(i)) - ++it; - return it; - } - const_local_iterator begin(size_type i) const { - return const_local_iterator(this, table + i, table + i+1, false); - } - const_local_iterator end(size_type i) const { - const_local_iterator it = begin(i); - if (!test_empty(i) && !test_deleted(i)) - ++it; - return it; - } - - // ACCESSOR FUNCTIONS for the things we templatize on, basically - hasher hash_funct() const { return settings; } - key_equal key_eq() const { return key_info; } - allocator_type get_allocator() const { - return allocator_type(val_info); - } - - // Accessor function for statistics gathering. - int num_table_copies() const { return settings.num_ht_copies(); } - - private: - // Annoyingly, we can't copy values around, because they might have - // const components (they're probably pair). We use - // explicit destructor invocation and placement new to get around - // this. Arg. - void set_value(pointer dst, const_reference src) { - dst->~value_type(); // delete the old value, if any - new(dst) value_type(src); - } - - void destroy_buckets(size_type first, size_type last) { - for ( ; first != last; ++first) - table[first].~value_type(); - } - - // DELETE HELPER FUNCTIONS - // This lets the user describe a key that will indicate deleted - // table entries. This key should be an "impossible" entry -- - // if you try to insert it for real, you won't be able to retrieve it! - // (NB: while you pass in an entire value, only the key part is looked - // at. This is just because I don't know how to assign just a key.) - private: - void squash_deleted() { // gets rid of any deleted entries we have - if ( num_deleted ) { // get rid of deleted before writing - dense_hashtable tmp(*this); // copying will get rid of deleted - swap(tmp); // now we are tmp - } - assert(num_deleted == 0); - } - - bool test_deleted_key(const key_type& key) const { - // The num_deleted test is crucial for read(): after read(), the ht values - // are garbage, and we don't want to think some of them are deleted. - // Invariant: !use_deleted implies num_deleted is 0. - assert(settings.use_deleted() || num_deleted == 0); - return num_deleted > 0 && equals(key_info.delkey, key); - } - - public: - void set_deleted_key(const key_type &key) { - // the empty indicator (if specified) and the deleted indicator - // must be different - assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval))) - && "Passed the empty-key to set_deleted_key"); - // It's only safe to change what "deleted" means if we purge deleted guys - squash_deleted(); - settings.set_use_deleted(true); - key_info.delkey = key; - } - void clear_deleted_key() { - squash_deleted(); - settings.set_use_deleted(false); - } - key_type deleted_key() const { - assert(settings.use_deleted() - && "Must set deleted key before calling deleted_key"); - return key_info.delkey; - } - - // These are public so the iterators can use them - // True if the item at position bucknum is "deleted" marker - bool test_deleted(size_type bucknum) const { - return test_deleted_key(get_key(table[bucknum])); - } - bool test_deleted(const iterator &it) const { - return test_deleted_key(get_key(*it)); - } - bool test_deleted(const const_iterator &it) const { - return test_deleted_key(get_key(*it)); - } - - private: - // Set it so test_deleted is true. true if object didn't used to be deleted. - bool set_deleted(iterator &it) { - assert(settings.use_deleted()); - bool retval = !test_deleted(it); - // &* converts from iterator to value-type. - set_key(&(*it), key_info.delkey); - return retval; - } - // Set it so test_deleted is false. true if object used to be deleted. - bool clear_deleted(iterator &it) { - assert(settings.use_deleted()); - // Happens automatically when we assign something else in its place. - return test_deleted(it); - } - - // We also allow to set/clear the deleted bit on a const iterator. - // We allow a const_iterator for the same reason you can delete a - // const pointer: it's convenient, and semantically you can't use - // 'it' after it's been deleted anyway, so its const-ness doesn't - // really matter. - bool set_deleted(const_iterator &it) { - assert(settings.use_deleted()); - bool retval = !test_deleted(it); - set_key(const_cast(&(*it)), key_info.delkey); - return retval; - } - // Set it so test_deleted is false. true if object used to be deleted. - bool clear_deleted(const_iterator &it) { - assert(settings.use_deleted()); - return test_deleted(it); - } - - // EMPTY HELPER FUNCTIONS - // This lets the user describe a key that will indicate empty (unused) - // table entries. This key should be an "impossible" entry -- - // if you try to insert it for real, you won't be able to retrieve it! - // (NB: while you pass in an entire value, only the key part is looked - // at. This is just because I don't know how to assign just a key.) - public: - // These are public so the iterators can use them - // True if the item at position bucknum is "empty" marker - bool test_empty(size_type bucknum) const { - assert(settings.use_empty()); // we always need to know what's empty! - return equals(get_key(val_info.emptyval), get_key(table[bucknum])); - } - bool test_empty(const iterator &it) const { - assert(settings.use_empty()); // we always need to know what's empty! - return equals(get_key(val_info.emptyval), get_key(*it)); - } - bool test_empty(const const_iterator &it) const { - assert(settings.use_empty()); // we always need to know what's empty! - return equals(get_key(val_info.emptyval), get_key(*it)); - } - - private: - void fill_range_with_empty(pointer table_start, pointer table_end) { - STL_NAMESPACE::uninitialized_fill(table_start, table_end, val_info.emptyval); - } - - public: - // TODO(csilvers): change all callers of this to pass in a key instead, - // and take a const key_type instead of const value_type. - void set_empty_key(const_reference val) { - // Once you set the empty key, you can't change it - assert(!settings.use_empty() && "Calling set_empty_key multiple times"); - // The deleted indicator (if specified) and the empty indicator - // must be different. - assert((!settings.use_deleted() || !equals(get_key(val), key_info.delkey)) - && "Setting the empty key the same as the deleted key"); - settings.set_use_empty(true); - set_value(&val_info.emptyval, val); - - assert(!table); // must set before first use - // num_buckets was set in constructor even though table was NULL - table = val_info.allocate(num_buckets); - assert(table); - fill_range_with_empty(table, table + num_buckets); - } - // TODO(sjackman): return a key_type rather than a value_type - value_type empty_key() const { - assert(settings.use_empty()); - return val_info.emptyval; - } - - // FUNCTIONS CONCERNING SIZE - public: - size_type size() const { return num_elements - num_deleted; } - size_type max_size() const { return val_info.max_size(); } - bool empty() const { return size() == 0; } - size_type bucket_count() const { return num_buckets; } - size_type max_bucket_count() const { return max_size(); } - size_type nonempty_bucket_count() const { return num_elements; } - // These are tr1 methods. Their idea of 'bucket' doesn't map well to - // what we do. We just say every bucket has 0 or 1 items in it. - size_type bucket_size(size_type i) const { - return begin(i) == end(i) ? 0 : 1; - } - - private: - // Because of the above, size_type(-1) is never legal; use it for errors - static const size_type ILLEGAL_BUCKET = size_type(-1); - - // Used after a string of deletes. Returns true if we actually shrunk. - // TODO(csilvers): take a delta so we can take into account inserts - // done after shrinking. Maybe make part of the Settings class? - bool maybe_shrink() { - assert(num_elements >= num_deleted); - assert((bucket_count() & (bucket_count()-1)) == 0); // is a power of two - assert(bucket_count() >= HT_MIN_BUCKETS); - bool retval = false; - - // If you construct a hashtable with < HT_DEFAULT_STARTING_BUCKETS, - // we'll never shrink until you get relatively big, and we'll never - // shrink below HT_DEFAULT_STARTING_BUCKETS. Otherwise, something - // like "dense_hash_set x; x.insert(4); x.erase(4);" will - // shrink us down to HT_MIN_BUCKETS buckets, which is too small. - const size_type num_remain = num_elements - num_deleted; - const size_type shrink_threshold = settings.shrink_threshold(); - if (shrink_threshold > 0 && num_remain < shrink_threshold && - bucket_count() > HT_DEFAULT_STARTING_BUCKETS) { - const float shrink_factor = settings.shrink_factor(); - size_type sz = bucket_count() / 2; // find how much we should shrink - while (sz > HT_DEFAULT_STARTING_BUCKETS && - num_remain < sz * shrink_factor) { - sz /= 2; // stay a power of 2 - } - dense_hashtable tmp(*this, sz); // Do the actual resizing - swap(tmp); // now we are tmp - retval = true; - } - settings.set_consider_shrink(false); // because we just considered it - return retval; - } - - // We'll let you resize a hashtable -- though this makes us copy all! - // When you resize, you say, "make it big enough for this many more elements" - // Returns true if we actually resized, false if size was already ok. - bool resize_delta(size_type delta) { - bool did_resize = false; - if ( settings.consider_shrink() ) { // see if lots of deletes happened - if ( maybe_shrink() ) - did_resize = true; - } - if (num_elements >= (STL_NAMESPACE::numeric_limits::max)() - delta) - throw std::length_error("resize overflow"); - if ( bucket_count() >= HT_MIN_BUCKETS && - (num_elements + delta) <= settings.enlarge_threshold() ) - return did_resize; // we're ok as we are - - // Sometimes, we need to resize just to get rid of all the - // "deleted" buckets that are clogging up the hashtable. So when - // deciding whether to resize, count the deleted buckets (which - // are currently taking up room). But later, when we decide what - // size to resize to, *don't* count deleted buckets, since they - // get discarded during the resize. - const size_type needed_size = settings.min_buckets(num_elements + delta, 0); - if ( needed_size <= bucket_count() ) // we have enough buckets - return did_resize; - - size_type resize_to = - settings.min_buckets(num_elements - num_deleted + delta, bucket_count()); - - if (resize_to < needed_size && // may double resize_to - resize_to < (STL_NAMESPACE::numeric_limits::max)() / 2) { - // This situation means that we have enough deleted elements, - // that once we purge them, we won't actually have needed to - // grow. But we may want to grow anyway: if we just purge one - // element, say, we'll have to grow anyway next time we - // insert. Might as well grow now, since we're already going - // through the trouble of copying (in order to purge the - // deleted elements). - const size_type target = - static_cast(settings.shrink_size(resize_to*2)); - if (num_elements - num_deleted + delta >= target) { - // Good, we won't be below the shrink threshhold even if we double. - resize_to *= 2; - } - } - dense_hashtable tmp(*this, resize_to); - swap(tmp); // now we are tmp - return true; - } - - // We require table be not-NULL and empty before calling this. - void resize_table(size_type /*old_size*/, size_type new_size, - true_type) { - table = val_info.realloc_or_die(table, new_size); - } - - void resize_table(size_type old_size, size_type new_size, false_type) { - val_info.deallocate(table, old_size); - table = val_info.allocate(new_size); - } - - // Used to actually do the rehashing when we grow/shrink a hashtable - void copy_from(const dense_hashtable &ht, size_type min_buckets_wanted) { - clear_to_size(settings.min_buckets(ht.size(), min_buckets_wanted)); - - // We use a normal iterator to get non-deleted bcks from ht - // We could use insert() here, but since we know there are - // no duplicates and no deleted items, we can be more efficient - assert((bucket_count() & (bucket_count()-1)) == 0); // a power of two - for ( const_iterator it = ht.begin(); it != ht.end(); ++it ) { - size_type num_probes = 0; // how many times we've probed - size_type bucknum; - const size_type bucket_count_minus_one = bucket_count() - 1; - for (bucknum = hash(get_key(*it)) & bucket_count_minus_one; - !test_empty(bucknum); // not empty - bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one) { - ++num_probes; - assert(num_probes < bucket_count() - && "Hashtable is full: an error in key_equal<> or hash<>"); - } - set_value(&table[bucknum], *it); // copies the value to here - num_elements++; - } - settings.inc_num_ht_copies(); - } - - // Required by the spec for hashed associative container - public: - // Though the docs say this should be num_buckets, I think it's much - // more useful as num_elements. As a special feature, calling with - // req_elements==0 will cause us to shrink if we can, saving space. - void resize(size_type req_elements) { // resize to this or larger - if ( settings.consider_shrink() || req_elements == 0 ) - maybe_shrink(); - if ( req_elements > num_elements ) - resize_delta(req_elements - num_elements); - } - - // Get and change the value of shrink_factor and enlarge_factor. The - // description at the beginning of this file explains how to choose - // the values. Setting the shrink parameter to 0.0 ensures that the - // table never shrinks. - void get_resizing_parameters(float* shrink, float* grow) const { - *shrink = settings.shrink_factor(); - *grow = settings.enlarge_factor(); - } - void set_resizing_parameters(float shrink, float grow) { - settings.set_resizing_parameters(shrink, grow); - settings.reset_thresholds(bucket_count()); - } - - // CONSTRUCTORS -- as required by the specs, we take a size, - // but also let you specify a hashfunction, key comparator, - // and key extractor. We also define a copy constructor and =. - // DESTRUCTOR -- needs to free the table - explicit dense_hashtable(size_type expected_max_items_in_table = 0, - const HashFcn& hf = HashFcn(), - const EqualKey& eql = EqualKey(), - const ExtractKey& ext = ExtractKey(), - const SetKey& set = SetKey(), - const Alloc& alloc = Alloc()) - : settings(hf), - key_info(ext, set, eql), - num_deleted(0), - num_elements(0), - num_buckets(expected_max_items_in_table == 0 - ? HT_DEFAULT_STARTING_BUCKETS - : settings.min_buckets(expected_max_items_in_table, 0)), - val_info(alloc_impl(alloc)), - table(NULL) { - // table is NULL until emptyval is set. However, we set num_buckets - // here so we know how much space to allocate once emptyval is set - settings.reset_thresholds(bucket_count()); - } - - // As a convenience for resize(), we allow an optional second argument - // which lets you make this new hashtable a different size than ht - dense_hashtable(const dense_hashtable& ht, - size_type min_buckets_wanted = HT_DEFAULT_STARTING_BUCKETS) - : settings(ht.settings), - key_info(ht.key_info), - num_deleted(0), - num_elements(0), - num_buckets(0), - val_info(ht.val_info), - table(NULL) { - if (!ht.settings.use_empty()) { - // If use_empty isn't set, copy_from will crash, so we do our own copying. - assert(ht.empty()); - num_buckets = settings.min_buckets(ht.size(), min_buckets_wanted); - settings.reset_thresholds(bucket_count()); - return; - } - settings.reset_thresholds(bucket_count()); - copy_from(ht, min_buckets_wanted); // copy_from() ignores deleted entries - } - - dense_hashtable& operator= (const dense_hashtable& ht) { - if (&ht == this) return *this; // don't copy onto ourselves - if (!ht.settings.use_empty()) { - assert(ht.empty()); - dense_hashtable empty_table(ht); // empty table with ht's thresholds - this->swap(empty_table); - return *this; - } - settings = ht.settings; - key_info = ht.key_info; - set_value(&val_info.emptyval, ht.val_info.emptyval); - // copy_from() calls clear and sets num_deleted to 0 too - copy_from(ht, HT_MIN_BUCKETS); - // we purposefully don't copy the allocator, which may not be copyable - return *this; - } - - ~dense_hashtable() { - if (table) { - destroy_buckets(0, num_buckets); - val_info.deallocate(table, num_buckets); - } - } - - // Many STL algorithms use swap instead of copy constructors - void swap(dense_hashtable& ht) { - STL_NAMESPACE::swap(settings, ht.settings); - STL_NAMESPACE::swap(key_info, ht.key_info); - STL_NAMESPACE::swap(num_deleted, ht.num_deleted); - STL_NAMESPACE::swap(num_elements, ht.num_elements); - STL_NAMESPACE::swap(num_buckets, ht.num_buckets); - { value_type tmp; // for annoying reasons, swap() doesn't work - set_value(&tmp, val_info.emptyval); - set_value(&val_info.emptyval, ht.val_info.emptyval); - set_value(&ht.val_info.emptyval, tmp); - } - STL_NAMESPACE::swap(table, ht.table); - settings.reset_thresholds(bucket_count()); // this also resets consider_shrink - ht.settings.reset_thresholds(bucket_count()); - // we purposefully don't swap the allocator, which may not be swap-able - } - - private: - void clear_to_size(size_type new_num_buckets) { - if (!table) { - table = val_info.allocate(new_num_buckets); - } else { - destroy_buckets(0, num_buckets); - if (new_num_buckets != num_buckets) { // resize, if necessary - typedef integral_constant >::value> - realloc_ok; - resize_table(num_buckets, new_num_buckets, realloc_ok()); - } - } - assert(table); - fill_range_with_empty(table, table + new_num_buckets); - num_elements = 0; - num_deleted = 0; - num_buckets = new_num_buckets; // our new size - settings.reset_thresholds(bucket_count()); - } - - public: - // It's always nice to be able to clear a table without deallocating it - void clear() { - // If the table is already empty, and the number of buckets is - // already as we desire, there's nothing to do. - const size_type new_num_buckets = settings.min_buckets(0, 0); - if (num_elements == 0 && new_num_buckets == num_buckets) { - return; - } - clear_to_size(new_num_buckets); - } - - // Clear the table without resizing it. - // Mimicks the stl_hashtable's behaviour when clear()-ing in that it - // does not modify the bucket count - void clear_no_resize() { - if (num_elements > 0) { - assert(table); - destroy_buckets(0, num_buckets); - fill_range_with_empty(table, table + num_buckets); - } - // don't consider to shrink before another erase() - settings.reset_thresholds(bucket_count()); - num_elements = 0; - num_deleted = 0; - } - - // LOOKUP ROUTINES - private: - // Returns a pair of positions: 1st where the object is, 2nd where - // it would go if you wanted to insert it. 1st is ILLEGAL_BUCKET - // if object is not found; 2nd is ILLEGAL_BUCKET if it is. - // Note: because of deletions where-to-insert is not trivial: it's the - // first deleted bucket we see, as long as we don't find the key later - pair find_position(const key_type &key) const { - size_type num_probes = 0; // how many times we've probed - const size_type bucket_count_minus_one = bucket_count() - 1; - size_type bucknum = hash(key) & bucket_count_minus_one; - size_type insert_pos = ILLEGAL_BUCKET; // where we would insert - while ( 1 ) { // probe until something happens - if ( test_empty(bucknum) ) { // bucket is empty - if ( insert_pos == ILLEGAL_BUCKET ) // found no prior place to insert - return pair(ILLEGAL_BUCKET, bucknum); - else - return pair(ILLEGAL_BUCKET, insert_pos); - - } else if ( test_deleted(bucknum) ) {// keep searching, but mark to insert - if ( insert_pos == ILLEGAL_BUCKET ) - insert_pos = bucknum; - - } else if ( equals(key, get_key(table[bucknum])) ) { - return pair(bucknum, ILLEGAL_BUCKET); - } - ++num_probes; // we're doing another probe - bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one; - assert(num_probes < bucket_count() - && "Hashtable is full: an error in key_equal<> or hash<>"); - } - } - - public: - iterator find(const key_type& key) { - if ( size() == 0 ) return end(); - pair pos = find_position(key); - if ( pos.first == ILLEGAL_BUCKET ) // alas, not there - return end(); - else - return iterator(this, table + pos.first, table + num_buckets, false); - } - - const_iterator find(const key_type& key) const { - if ( size() == 0 ) return end(); - pair pos = find_position(key); - if ( pos.first == ILLEGAL_BUCKET ) // alas, not there - return end(); - else - return const_iterator(this, table + pos.first, table+num_buckets, false); - } - - // This is a tr1 method: the bucket a given key is in, or what bucket - // it would be put in, if it were to be inserted. Shrug. - size_type bucket(const key_type& key) const { - pair pos = find_position(key); - return pos.first == ILLEGAL_BUCKET ? pos.second : pos.first; - } - - // Counts how many elements have key key. For maps, it's either 0 or 1. - size_type count(const key_type &key) const { - pair pos = find_position(key); - return pos.first == ILLEGAL_BUCKET ? 0 : 1; - } - - // Likewise, equal_range doesn't really make sense for us. Oh well. - pair equal_range(const key_type& key) { - iterator pos = find(key); // either an iterator or end - if (pos == end()) { - return pair(pos, pos); - } else { - const iterator startpos = pos++; - return pair(startpos, pos); - } - } - pair equal_range(const key_type& key) const { - const_iterator pos = find(key); // either an iterator or end - if (pos == end()) { - return pair(pos, pos); - } else { - const const_iterator startpos = pos++; - return pair(startpos, pos); - } - } - - - // INSERTION ROUTINES - private: - // Private method used by insert_noresize and find_or_insert. - iterator insert_at(const_reference obj, size_type pos) { - if (size() >= max_size()) - throw std::length_error("insert overflow"); - if ( test_deleted(pos) ) { // just replace if it's been del. - // shrug: shouldn't need to be const. - const_iterator delpos(this, table + pos, table + num_buckets, false); - clear_deleted(delpos); - assert( num_deleted > 0); - --num_deleted; // used to be, now it isn't - } else { - ++num_elements; // replacing an empty bucket - } - set_value(&table[pos], obj); - return iterator(this, table + pos, table + num_buckets, false); - } - - // If you know *this is big enough to hold obj, use this routine - pair insert_noresize(const_reference obj) { - // First, double-check we're not inserting delkey or emptyval - assert((!settings.use_empty() || !equals(get_key(obj), - get_key(val_info.emptyval))) - && "Inserting the empty key"); - assert((!settings.use_deleted() || !equals(get_key(obj), key_info.delkey)) - && "Inserting the deleted key"); - const pair pos = find_position(get_key(obj)); - if ( pos.first != ILLEGAL_BUCKET) { // object was already there - return pair(iterator(this, table + pos.first, - table + num_buckets, false), - false); // false: we didn't insert - } else { // pos.second says where to put it - return pair(insert_at(obj, pos.second), true); - } - } - - // Specializations of insert(it, it) depending on the power of the iterator: - // (1) Iterator supports operator-, resize before inserting - template - void insert(ForwardIterator f, ForwardIterator l, STL_NAMESPACE::forward_iterator_tag) { - size_t dist = STL_NAMESPACE::distance(f, l); - if (dist >= (std::numeric_limits::max)()) - throw std::length_error("insert-range overflow"); - resize_delta(static_cast(dist)); - for ( ; dist > 0; --dist, ++f) { - insert_noresize(*f); - } - } - - // (2) Arbitrary iterator, can't tell how much to resize - template - void insert(InputIterator f, InputIterator l, STL_NAMESPACE::input_iterator_tag) { - for ( ; f != l; ++f) - insert(*f); - } - - public: - // This is the normal insert routine, used by the outside world - pair insert(const_reference obj) { - resize_delta(1); // adding an object, grow if need be - return insert_noresize(obj); - } - - // When inserting a lot at a time, we specialize on the type of iterator - template - void insert(InputIterator f, InputIterator l) { - // specializes on iterator type - insert(f, l, typename STL_NAMESPACE::iterator_traits::iterator_category()); - } - - // DefaultValue is a functor that takes a key and returns a value_type - // representing the default value to be inserted if none is found. - template - value_type& find_or_insert(const key_type& key) { - // First, double-check we're not inserting emptykey or delkey - assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval))) - && "Inserting the empty key"); - assert((!settings.use_deleted() || !equals(key, key_info.delkey)) - && "Inserting the deleted key"); - const pair pos = find_position(key); - DefaultValue default_value; - if ( pos.first != ILLEGAL_BUCKET) { // object was already there - return table[pos.first]; - } else if (resize_delta(1)) { // needed to rehash to make room - // Since we resized, we can't use pos, so recalculate where to insert. - return *insert_noresize(default_value(key)).first; - } else { // no need to rehash, insert right here - return *insert_at(default_value(key), pos.second); - } - } - - // DELETION ROUTINES - size_type erase(const key_type& key) { - // First, double-check we're not trying to erase delkey or emptyval. - assert((!settings.use_empty() || !equals(key, get_key(val_info.emptyval))) - && "Erasing the empty key"); - assert((!settings.use_deleted() || !equals(key, key_info.delkey)) - && "Erasing the deleted key"); - const_iterator pos = find(key); // shrug: shouldn't need to be const - if ( pos != end() ) { - assert(!test_deleted(pos)); // or find() shouldn't have returned it - set_deleted(pos); - ++num_deleted; - settings.set_consider_shrink(true); // will think about shrink after next insert - return 1; // because we deleted one thing - } else { - return 0; // because we deleted nothing - } - } - - // We return the iterator past the deleted item. - void erase(iterator pos) { - if ( pos == end() ) return; // sanity check - if ( set_deleted(pos) ) { // true if object has been newly deleted - ++num_deleted; - settings.set_consider_shrink(true); // will think about shrink after next insert - } - } - - void erase(iterator f, iterator l) { - for ( ; f != l; ++f) { - if ( set_deleted(f) ) // should always be true - ++num_deleted; - } - settings.set_consider_shrink(true); // will think about shrink after next insert - } - - // We allow you to erase a const_iterator just like we allow you to - // erase an iterator. This is in parallel to 'delete': you can delete - // a const pointer just like a non-const pointer. The logic is that - // you can't use the object after it's erased anyway, so it doesn't matter - // if it's const or not. - void erase(const_iterator pos) { - if ( pos == end() ) return; // sanity check - if ( set_deleted(pos) ) { // true if object has been newly deleted - ++num_deleted; - settings.set_consider_shrink(true); // will think about shrink after next insert - } - } - void erase(const_iterator f, const_iterator l) { - for ( ; f != l; ++f) { - if ( set_deleted(f) ) // should always be true - ++num_deleted; - } - settings.set_consider_shrink(true); // will think about shrink after next insert - } - - - // COMPARISON - bool operator==(const dense_hashtable& ht) const { - if (size() != ht.size()) { - return false; - } else if (this == &ht) { - return true; - } else { - // Iterate through the elements in "this" and see if the - // corresponding element is in ht - for ( const_iterator it = begin(); it != end(); ++it ) { - const_iterator it2 = ht.find(get_key(*it)); - if ((it2 == ht.end()) || (*it != *it2)) { - return false; - } - } - return true; - } - } - bool operator!=(const dense_hashtable& ht) const { - return !(*this == ht); - } - - - // I/O - // We support reading and writing hashtables to disk. Alas, since - // I don't know how to write a hasher or key_equal, you have to make - // sure everything but the table is the same. We compact before writing - // - // NOTE: These functions are currently TODO. They've not been implemented. - bool write_metadata(FILE * /*fp*/) { - squash_deleted(); // so we don't have to worry about delkey - return false; // TODO - } - - bool read_metadata(FILE* /*fp*/) { - num_deleted = 0; // since we got rid before writing - assert(settings.use_empty() && "empty_key not set for read_metadata"); - if (table) val_info.deallocate(table, num_buckets); // we'll make our own - // TODO: read magic number - // TODO: read num_buckets - settings.reset_thresholds(bucket_count()); - table = val_info.allocate(num_buckets); - assert(table); - fill_range_with_empty(table, table + num_buckets); - // TODO: read num_elements - for ( size_type i = 0; i < num_elements; ++i ) { - // TODO: read bucket_num - // TODO: set with non-empty, non-deleted value - } - return false; // TODO - } - - // If your keys and values are simple enough, we can write them to - // disk for you. "simple enough" means value_type is a POD type - // that contains no pointers. However, we don't try to normalize - // endianness - bool write_nopointer_data(FILE *fp) const { - for ( const_iterator it = begin(); it != end(); ++it ) { - // TODO: skip empty/deleted values - if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false; - } - return false; - } - - // When reading, we have to override the potential const-ness of *it - bool read_nopointer_data(FILE *fp) { - for ( iterator it = begin(); it != end(); ++it ) { - // TODO: skip empty/deleted values - if ( !fread(reinterpret_cast(&(*it)), sizeof(*it), 1, fp) ) - return false; - } - return false; - } - - private: - template - class alloc_impl : public A { - public: - typedef typename A::pointer pointer; - typedef typename A::size_type size_type; - - // Convert a normal allocator to one that has realloc_or_die() - alloc_impl(const A& a) : A(a) { } - - // realloc_or_die should only be used when using the default - // allocator (libc_allocator_with_realloc). - pointer realloc_or_die(pointer /*ptr*/, size_type /*n*/) { - fprintf(stderr, "realloc_or_die is only supported for " - "libc_allocator_with_realloc"); - exit(1); - return NULL; - } - }; - - // A template specialization of alloc_impl for - // libc_allocator_with_realloc that can handle realloc_or_die. - template - class alloc_impl > - : public libc_allocator_with_realloc
{ - public: - typedef typename libc_allocator_with_realloc::pointer pointer; - typedef typename libc_allocator_with_realloc::size_type size_type; - - alloc_impl(const libc_allocator_with_realloc& a) - : libc_allocator_with_realloc(a) { } - - pointer realloc_or_die(pointer ptr, size_type n) { - pointer retval = this->reallocate(ptr, n); - if (retval == NULL) { - // We really should use PRIuS here, but I don't want to have to add - // a whole new configure option, with concomitant macro namespace - // pollution, just to print this (unlikely) error message. So I cast. - fprintf(stderr, "sparsehash: FATAL ERROR: failed to reallocate " - "%lu elements for ptr %p", - static_cast(n), ptr); - exit(1); - } - return retval; - } - }; - - // Package allocator with emptyval to eliminate memory needed for - // the zero-size allocator. - // If new fields are added to this class, we should add them to - // operator= and swap. - class ValInfo : public alloc_impl { - public: - typedef typename alloc_impl::value_type value_type; - - ValInfo(const alloc_impl& a) - : alloc_impl(a), emptyval() { } - ValInfo(const ValInfo& v) - : alloc_impl(v), emptyval(v.emptyval) { } - - value_type emptyval; // which key marks unused entries - }; - - - // Package functors with another class to eliminate memory needed for - // zero-size functors. Since ExtractKey and hasher's operator() might - // have the same function signature, they must be packaged in - // different classes. - struct Settings : - sh_hashtable_settings { - explicit Settings(const hasher& hf) - : sh_hashtable_settings( - hf, HT_OCCUPANCY_PCT / 100.0f, HT_EMPTY_PCT / 100.0f) {} - }; - - // Packages ExtractKey and SetKey functors. - class KeyInfo : public ExtractKey, public SetKey, public key_equal { - public: - KeyInfo(const ExtractKey& ek, const SetKey& sk, const key_equal& eq) - : ExtractKey(ek), - SetKey(sk), - key_equal(eq) { - } - - // We want to return the exact same type as ExtractKey: Key or const Key& - typename ExtractKey::result_type get_key(const_reference v) const { - return ExtractKey::operator()(v); - } - void set_key(pointer v, const key_type& k) const { - SetKey::operator()(v, k); - } - bool equals(const key_type& a, const key_type& b) const { - return key_equal::operator()(a, b); - } - - // Which key marks deleted entries. - // TODO(csilvers): make a pointer, and get rid of use_deleted (benchmark!) - typename remove_const::type delkey; - }; - - // Utility functions to access the templated operators - size_type hash(const key_type& v) const { - return settings.hash(v); - } - bool equals(const key_type& a, const key_type& b) const { - return key_info.equals(a, b); - } - typename ExtractKey::result_type get_key(const_reference v) const { - return key_info.get_key(v); - } - void set_key(pointer v, const key_type& k) const { - key_info.set_key(v, k); - } - - private: - // Actual data - Settings settings; - KeyInfo key_info; - - size_type num_deleted; // how many occupied buckets are marked deleted - size_type num_elements; - size_type num_buckets; - ValInfo val_info; // holds emptyval, and also the allocator - pointer table; -}; - - -// We need a global swap as well -template -inline void swap(dense_hashtable &x, - dense_hashtable &y) { - x.swap(y); -} - -#undef JUMP_ - -template -const typename dense_hashtable::size_type - dense_hashtable::ILLEGAL_BUCKET; - -// How full we let the table get before we resize. Knuth says .8 is -// good -- higher causes us to probe too much, though saves memory. -// However, we go with .5, getting better performance at the cost of -// more space (a trade-off densehashtable explicitly chooses to make). -// Feel free to play around with different values, though. -template -const int dense_hashtable::HT_OCCUPANCY_PCT = 50; - -// How empty we let the table get before we resize lower. -// It should be less than OCCUPANCY_PCT / 2 or we thrash resizing -template -const int dense_hashtable::HT_EMPTY_PCT - = static_cast(0.4 * - dense_hashtable::HT_OCCUPANCY_PCT); - -_END_GOOGLE_NAMESPACE_ - -#endif /* _DENSEHASHTABLE_H_ */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/hashtable-common.h b/packages/stk/stk_classic/stk_util/stk_util/util/hashtable-common.h deleted file mode 100644 index e823b1242903..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/hashtable-common.h +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Giao Nguyen - -#ifndef UTIL_GTL_HASHTABLE_COMMON_H_ -#define UTIL_GTL_HASHTABLE_COMMON_H_ - -#include - -// Settings contains parameters for growing and shrinking the table. -// It also packages zero-size functor (ie. hasher). - -template -class sh_hashtable_settings : public HashFunc { - public: - typedef Key key_type; - typedef HashFunc hasher; - typedef SizeType size_type; - - public: - sh_hashtable_settings(const hasher& hf, - const float ht_occupancy_flt, - const float ht_empty_flt) - : hasher(hf), - enlarge_threshold_(0), - shrink_threshold_(0), - consider_shrink_(false), - use_empty_(false), - use_deleted_(false), - num_ht_copies_(0) { - set_enlarge_factor(ht_occupancy_flt); - set_shrink_factor(ht_empty_flt); - } - - size_type hash(const key_type& v) const { - return hasher::operator()(v); - } - - float enlarge_factor() const { - return enlarge_factor_; - } - void set_enlarge_factor(float f) { - enlarge_factor_ = f; - } - float shrink_factor() const { - return shrink_factor_; - } - void set_shrink_factor(float f) { - shrink_factor_ = f; - } - - size_type enlarge_threshold() const { - return enlarge_threshold_; - } - void set_enlarge_threshold(size_type t) { - enlarge_threshold_ = t; - } - size_type shrink_threshold() const { - return shrink_threshold_; - } - void set_shrink_threshold(size_type t) { - shrink_threshold_ = t; - } - - size_type enlarge_size(size_type x) const { - return static_cast(x * enlarge_factor_); - } - size_type shrink_size(size_type x) const { - return static_cast(x * shrink_factor_); - } - - bool consider_shrink() const { - return consider_shrink_; - } - void set_consider_shrink(bool t) { - consider_shrink_ = t; - } - - bool use_empty() const { - return use_empty_; - } - void set_use_empty(bool t) { - use_empty_ = t; - } - - bool use_deleted() const { - return use_deleted_; - } - void set_use_deleted(bool t) { - use_deleted_ = t; - } - - size_type num_ht_copies() const { - return static_cast(num_ht_copies_); - } - void inc_num_ht_copies() { - ++num_ht_copies_; - } - - // Reset the enlarge and shrink thresholds - void reset_thresholds(size_type num_buckets) { - set_enlarge_threshold(enlarge_size(num_buckets)); - set_shrink_threshold(shrink_size(num_buckets)); - // whatever caused us to reset already considered - set_consider_shrink(false); - } - - // Caller is resposible for calling reset_threshold right after - // set_resizing_parameters. - void set_resizing_parameters(float shrink, float grow) { - assert(shrink >= 0.0); - assert(grow <= 1.0); - if (shrink > grow/2.0f) - shrink = grow / 2.0f; // otherwise we thrash hashtable size - set_shrink_factor(shrink); - set_enlarge_factor(grow); - } - - // This is the smallest size a hashtable can be without being too crowded - // If you like, you can give a min #buckets as well as a min #elts - size_type min_buckets(size_type num_elts, size_type min_buckets_wanted) { - float enlarge = enlarge_factor(); - size_type sz = HT_MIN_BUCKETS; // min buckets allowed - while ( sz < min_buckets_wanted || - num_elts >= static_cast(sz * enlarge) ) { - // This just prevents overflowing size_type, since sz can exceed - // max_size() here. - if (static_cast(sz * 2) < sz) { - throw std::length_error("resize overflow"); // protect against overflow - } - sz *= 2; - } - return sz; - } - - private: - size_type enlarge_threshold_; // table.size() * enlarge_factor - size_type shrink_threshold_; // table.size() * shrink_factor - float enlarge_factor_; // how full before resize - float shrink_factor_; // how empty before resize - // consider_shrink=true if we should try to shrink before next insert - bool consider_shrink_; - bool use_empty_; // used only by densehashtable, not sparsehashtable - bool use_deleted_; // false until delkey has been set - // num_ht_copies is a counter incremented every Copy/Move - unsigned int num_ht_copies_; -}; - -#endif // UTIL_GTL_HASHTABLE_COMMON_H_ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/libc_allocator_with_realloc.h b/packages/stk/stk_classic/stk_util/stk_util/util/libc_allocator_with_realloc.h deleted file mode 100644 index d725310e396c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/libc_allocator_with_realloc.h +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2010, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Guilin Chen - -#ifndef UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ -#define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ - -#include - -#include // for malloc/realloc/free -#include // for ptrdiff_t - - -_START_GOOGLE_NAMESPACE_ - -template -class libc_allocator_with_realloc { - public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - - libc_allocator_with_realloc() {} - libc_allocator_with_realloc(const libc_allocator_with_realloc&) {} - ~libc_allocator_with_realloc() {} - - pointer address(reference r) const { return &r; } - const_pointer address(const_reference r) const { return &r; } - - pointer allocate(size_type n, const_pointer = 0) { - return static_cast(malloc(n * sizeof(value_type))); - } - void deallocate(pointer p, size_type) { - free(p); - } - pointer reallocate(pointer p, size_type n) { - return static_cast(realloc(p, n * sizeof(value_type))); - } - - size_type max_size() const { - return static_cast(-1) / sizeof(value_type); - } - - void construct(pointer p, const value_type& val) { - new(p) value_type(val); - } - void destroy(pointer p) { p->~value_type(); } - - template - libc_allocator_with_realloc(const libc_allocator_with_realloc&) {} - - template - struct rebind { - typedef libc_allocator_with_realloc other; - }; -}; - -// libc_allocator_with_realloc specialization. -template<> -class libc_allocator_with_realloc { - public: - typedef void value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - - template - struct rebind { - typedef libc_allocator_with_realloc other; - }; -}; - -template -inline bool operator==(const libc_allocator_with_realloc&, - const libc_allocator_with_realloc&) { - return true; -} - -template -inline bool operator!=(const libc_allocator_with_realloc&, - const libc_allocator_with_realloc&) { - return false; -} - -_END_GOOGLE_NAMESPACE_ - -#endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/nested_iterator.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/nested_iterator.hpp deleted file mode 100644 index 6ee09eb88754..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/nested_iterator.hpp +++ /dev/null @@ -1,271 +0,0 @@ -#ifndef STK_UTIL_STK_UTIL_UTIL_NESTED_ITERATOR_HPP -#define STK_UTIL_STK_UTIL_UTIL_NESTED_ITERATOR_HPP - -#include -#include -#include - -#include -#include -#include -#include - -namespace stk_classic { -namespace util { - -/** nested_iterator is a forward iterator that flattens iteration over ranges of ranges - * - * Both OuterIterator and InnerIterator must support forward_traversal. - * - * iterator_value::type is convertible to - * OuterValueToInnerRange::value_type - * - */ -template -class nested_iterator - : public boost::iterator_facade< - nested_iterator - , typename boost::range_value::type //value - , boost::forward_traversal_tag // traversal tag - > -{ - public: - typedef typename boost::range_iterator::type outer_iterator; - typedef typename boost::range_iterator::type inner_iterator; - - typedef OuterRange outer_range_type; - typedef InnerRange inner_range_type; - - typedef OuterToInnerConverter converter_type; - - private: - typedef nested_iterator self; - - typedef typename boost::range_value::type outer_value; - - - public: - nested_iterator() - : m_outer_current() - , m_outer_end() - , m_inner_current() - , m_inner_end() - , m_converter() - {} - - nested_iterator( outer_range_type & outer_range, converter_type converter = converter_type() ) - : m_outer_current(boost::begin(outer_range)) - , m_outer_end(boost::end(outer_range)) - , m_inner_current() - , m_inner_end() - , m_converter(converter) - { - if ( boost::empty(outer_range) ) { - m_outer_current = boost::none; - m_outer_end = boost::none; - } - else { - find_inner_range_helper(); - } - } - - friend class nested_iterator::type, - inner_range_type,converter_type>; - - - // - private: - friend class boost::iterator_core_access; - - //functions necessary to implement core operations - // increment - // equal - // dereference - - void increment() - { - if (m_inner_current) { - ++(*m_inner_current); - //at end of current inner range - if (m_inner_current == m_inner_end) { - ++(*m_outer_current); - find_inner_range_helper(); - } - } - } - - bool equal( const self & rhs ) const - { - return (m_outer_current == rhs.m_outer_current) - && (m_inner_current == rhs.m_inner_current); - } - - typename boost::iterator_reference::type dereference() const - { - return **m_inner_current; - } - - void find_inner_range_helper() - { - // find the next none-empty inner_range - while ( (m_outer_current != m_outer_end) && boost::empty((*m_converter)(**m_outer_current)) ) - { - ++(*m_outer_current); - } - - if (m_outer_current != m_outer_end) { - m_inner_current = boost::begin((*m_converter)(**m_outer_current)); - m_inner_end = boost::end((*m_converter)(**m_outer_current)); - } - else { //at end of outer range - m_outer_current = boost::none; - m_outer_end = boost::none; - - m_inner_current = boost::none; - m_inner_end = boost::none; - } - } - - - private: - boost::optional m_outer_current; - boost::optional m_outer_end; - - boost::optional m_inner_current; - boost::optional m_inner_end; - - boost::optional m_converter; -}; - -template -class nested_iterator - : public boost::iterator_facade< - nested_iterator - , typename boost::add_const::type>::type //value - , boost::forward_traversal_tag // traversal tag - > -{ - public: - typedef typename boost::range_iterator::type outer_iterator; - typedef typename boost::range_iterator::type inner_iterator; - - typedef const OuterRange outer_range_type; - typedef InnerRange inner_range_type; - - typedef OuterToInnerConverter converter_type; - - private: - typedef nested_iterator self; - - typedef typename boost::range_value::type outer_value; - - - public: - nested_iterator() - : m_outer_current() - , m_outer_end() - , m_inner_current() - , m_inner_end() - , m_converter() - {} - - nested_iterator( outer_range_type & outer_range, converter_type converter = converter_type() ) - : m_outer_current(boost::begin(outer_range)) - , m_outer_end(boost::end(outer_range)) - , m_inner_current() - , m_inner_end() - , m_converter(converter) - { - if ( boost::empty(outer_range) ) { - m_outer_current = boost::none; - m_outer_end = boost::none; - } - else { - find_inner_range_helper(); - } - } - - nested_iterator( nested_iterator::type, - inner_range_type,converter_type> const & itr) - : m_outer_current(itr.m_outer_current) - , m_outer_end(itr.m_outer_end) - , m_inner_current(itr.m_inner_current) - , m_inner_end(itr.m_inner_end) - , m_converter(itr.m_converter) - {} - - // - private: - friend class boost::iterator_core_access; - - //functions necessary to implement core operations - // increment - // equal - // dereference - - void increment() - { - if (m_inner_current) { - ++(*m_inner_current); - //at end of current inner range - if (m_inner_current == m_inner_end) { - ++(*m_outer_current); - find_inner_range_helper(); - } - } - } - - bool equal( const self & rhs ) const - { - return (m_outer_current == rhs.m_outer_current) - && (m_inner_current == rhs.m_inner_current); - } - - typename boost::iterator_reference::type dereference() const - { - return **m_inner_current; - } - - void find_inner_range_helper() - { - // find the next none-empty inner_range - while ( (m_outer_current != m_outer_end) && boost::empty((*m_converter)(**m_outer_current)) ) - { - ++(*m_outer_current); - } - - if (m_outer_current != m_outer_end) { - m_inner_current = boost::begin((*m_converter)(**m_outer_current)); - m_inner_end = boost::end((*m_converter)(**m_outer_current)); - } - else { //at end of outer range - m_outer_current = boost::none; - m_outer_end = boost::none; - - m_inner_current = boost::none; - m_inner_end = boost::none; - } - } - - private: - boost::optional m_outer_current; - boost::optional m_outer_end; - - boost::optional m_inner_current; - boost::optional m_inner_end; - - boost::optional m_converter; -}; - - -} // util -} // stk - - -#endif //STK_UTIL_STK_UTIL_UTIL_NESTED_ITERATOR_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/nested_range.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/nested_range.hpp deleted file mode 100644 index 85ae6402b9c5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/nested_range.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef STK_UTIL_STK_UTIL_UTIL_NESTED_RANGE_HPP -#define STK_UTIL_STK_UTIL_UTIL_NESTED_RANGE_HPP - -#include - -#include -#include -#include - -#include -#include - -namespace stk_classic { -namespace util { - -namespace details { - -template -struct identity { - typedef T result_type; - - result_type& operator()(result_type& r) const { return r; } - const result_type& operator()(const result_type& r) const { return r; } -}; - -} - -/** nested_range is a forward range that flattens iteration over ranges of ranges - */ -template < typename OuterRange, - typename InnerRange=typename boost::range_value::type, - typename OuterToInnerConverter= - details::identity< - typename boost::mpl::if_< - typename boost::is_same::type>, - InnerRange, - void - >::type - > - > -class nested_range; - -template < typename OuterRange, typename InnerRange, typename OuterToInnerConverter > -class nested_range -{ - public: - typedef OuterRange outer_range; - typedef InnerRange inner_range; - BOOST_MPL_ASSERT((boost::has_range_iterator)); - BOOST_MPL_ASSERT((boost::has_range_iterator)); - - typedef OuterToInnerConverter converter_type; - - typedef nested_iterator iterator; - typedef nested_iterator::type,inner_range,converter_type> const_iterator; - - nested_range() : m_outer(), m_converter() {} - - nested_range(outer_range& outer, converter_type converter=converter_type()) : m_outer(outer), m_converter(converter) {} - - iterator begin() { return iterator(*m_outer, *m_converter); } - const_iterator begin() const { return const_iterator(*m_outer, *m_converter); } - - iterator end() { return iterator(); } - const_iterator end() const { return const_iterator(); } - - private: - boost::optional m_outer; - boost::optional m_converter; -}; - -//template < typename OuterRange> -//class nested_range::type, void> -//{ -// public: -// typedef OuterRange outer_range; -// typedef InnerRange inner_range; -// BOOST_MPL_ASSERT((boost::has_range_iterator)); -// -// typedef nested_iterator iterator; -// typedef nested_iterator::type,inner_range> const_iterator; -// -// nested_range() : m_outer() {} -// -// nested_range(outer_range& outer) : m_outer(outer) {} -// -// iterator begin() { return iterator(*m_outer); } -// const_iterator begin() const { return const_iterator(*m_outer); } -// -// iterator end() { return iterator(); } -// const_iterator end() const { return const_iterator(); } -// -// private: -// boost::optional m_outer; -//}; - - -} // util -} // stk - - -#endif //STK_UTIL_STK_UTIL_UTIL_NESTED_RANGE_HPP diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/random_access_iterator_wrapper.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/random_access_iterator_wrapper.hpp deleted file mode 100644 index 46492ea8080e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/random_access_iterator_wrapper.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef stk_util_util_random_access_iterator_wrapper_hpp -#define stk_util_util_random_access_iterator_wrapper_hpp - -#include - -#ifndef BOOST_NO_SFINAE -# include -# include -#endif - -namespace stk_util { - - -template -class random_access_iterator_wrapper - : public boost::iterator_adaptor< - random_access_iterator_wrapper // Derived - , Value* // Base - , boost::use_default // Value - , boost::random_access_traversal_tag // CategoryOrTraversal - > -{ - private: - - typedef boost::iterator_adaptor< - random_access_iterator_wrapper, - Value*, - boost::use_default, - boost::random_access_traversal_tag - > base_type; - - struct enabler {}; // used to enable coversion constructor (if SFINAE) - - public: - random_access_iterator_wrapper() - : base_type(0) {} - - explicit random_access_iterator_wrapper(Value* p) - : base_type(p) {} - - Value& operator[] (ptrdiff_t index) - { return *(*this + index); } - - template - random_access_iterator_wrapper( - random_access_iterator_wrapper const& other -# ifndef BOOST_NO_SFINAE - , typename boost::enable_if< - boost::is_convertible - , enabler - >::type = enabler() -# endif - ) - : base_type(other.base()) {} -}; - -}//namespace stk_util - -#endif - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/sparse_hash_map b/packages/stk/stk_classic/stk_util/stk_util/util/sparse_hash_map deleted file mode 100644 index 4f99fd4770b5..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/sparse_hash_map +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Craig Silverstein -// -// This is just a very thin wrapper over sparsehashtable.h, just -// like sgi stl's stl_hash_map is a very thin wrapper over -// stl_hashtable. The major thing we define is operator[], because -// we have a concept of a data_type which stl_hashtable doesn't -// (it only has a key and a value). -// -// We adhere mostly to the STL semantics for hash-map. One important -// exception is that insert() may invalidate iterators entirely -- STL -// semantics are that insert() may reorder iterators, but they all -// still refer to something valid in the hashtable. Not so for us. -// Likewise, insert() may invalidate pointers into the hashtable. -// (Whether insert invalidates iterators and pointers depends on -// whether it results in a hashtable resize). On the plus side, -// delete() doesn't invalidate iterators or pointers at all, or even -// change the ordering of elements. -// -// Here are a few "power user" tips: -// -// 1) set_deleted_key(): -// Unlike STL's hash_map, if you want to use erase() you -// *must* call set_deleted_key() after construction. -// -// 2) resize(0): -// When an item is deleted, its memory isn't freed right -// away. This is what allows you to iterate over a hashtable -// and call erase() without invalidating the iterator. -// To force the memory to be freed, call resize(0). -// For tr1 compatibility, this can also be called as rehash(0). -// -// 3) min_load_factor(0.0) -// Setting the minimum load factor to 0.0 guarantees that -// the hash table will never shrink. -// -// Roughly speaking: -// (1) dense_hash_map: fastest, uses the most memory unless entries are small -// (2) sparse_hash_map: slowest, uses the least memory -// (3) hash_map / unordered_map (STL): in the middle -// -// Typically I use sparse_hash_map when I care about space and/or when -// I need to save the hashtable on disk. I use hash_map otherwise. I -// don't personally use dense_hash_map ever; some people use it for -// small maps with lots of lookups. -// -// - dense_hash_map has, typically, about 78% memory overhead (if your -// data takes up X bytes, the hash_map uses .78X more bytes in overhead). -// - sparse_hash_map has about 4 bits overhead per entry. -// - sparse_hash_map can be 3-7 times slower than the others for lookup and, -// especially, inserts. See time_hash_map.cc for details. -// -// See /usr/(local/)?doc/sparsehash-*/sparse_hash_map.html -// for information about how to use this class. - -#ifndef _SPARSE_HASH_MAP_H_ -#define _SPARSE_HASH_MAP_H_ - -#include -#include // for FILE * in read()/write() -#include // for the default template args -#include // for equal_to -#include // for alloc<> -#include // for pair<> -//#include HASH_FUN_H // defined in config.h -#include -#include - - -_START_GOOGLE_NAMESPACE_ - -using STL_NAMESPACE::pair; - -template , // defined in sparseconfig.h - class EqualKey = STL_NAMESPACE::equal_to, - class Alloc = libc_allocator_with_realloc > > -class sparse_hash_map { - private: - // Apparently select1st is not stl-standard, so we define our own - struct SelectKey { - typedef const Key& result_type; - const Key& operator()(const pair& p) const { - return p.first; - } - }; - struct SetKey { - void operator()(pair* value, const Key& new_key) const { - *const_cast(&value->first) = new_key; - // It would be nice to clear the rest of value here as well, in - // case it's taking up a lot of memory. We do this by clearing - // the value. This assumes T has a zero-arg constructor! - value->second = T(); - } - }; - // For operator[]. - struct DefaultValue { - STL_NAMESPACE::pair operator()(const Key& key) { - return STL_NAMESPACE::make_pair(key, T()); - } - }; - - // The actual data - typedef sparse_hashtable, Key, HashFcn, SelectKey, - SetKey, EqualKey, Alloc> ht; - ht rep; - - public: - typedef typename ht::key_type key_type; - typedef T data_type; - typedef T mapped_type; - typedef typename ht::value_type value_type; - typedef typename ht::hasher hasher; - typedef typename ht::key_equal key_equal; - typedef Alloc allocator_type; - - typedef typename ht::size_type size_type; - typedef typename ht::difference_type difference_type; - typedef typename ht::pointer pointer; - typedef typename ht::const_pointer const_pointer; - typedef typename ht::reference reference; - typedef typename ht::const_reference const_reference; - - typedef typename ht::iterator iterator; - typedef typename ht::const_iterator const_iterator; - typedef typename ht::local_iterator local_iterator; - typedef typename ht::const_local_iterator const_local_iterator; - - // Iterator functions - iterator begin() { return rep.begin(); } - iterator end() { return rep.end(); } - const_iterator begin() const { return rep.begin(); } - const_iterator end() const { return rep.end(); } - - // These come from tr1's unordered_map. For us, a bucket has 0 or 1 elements. - local_iterator begin(size_type i) { return rep.begin(i); } - local_iterator end(size_type i) { return rep.end(i); } - const_local_iterator begin(size_type i) const { return rep.begin(i); } - const_local_iterator end(size_type i) const { return rep.end(i); } - - // Accessor functions - allocator_type get_allocator() const { return rep.get_allocator(); } - hasher hash_funct() const { return rep.hash_funct(); } - hasher hash_function() const { return hash_funct(); } - key_equal key_eq() const { return rep.key_eq(); } - - - // Constructors - explicit sparse_hash_map(size_type expected_max_items_in_table = 0, - const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) - : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) { - } - - template - sparse_hash_map(InputIterator f, InputIterator l, - size_type expected_max_items_in_table = 0, - const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& alloc = allocator_type()) - : rep(expected_max_items_in_table, hf, eql, SelectKey(), SetKey(), alloc) { - rep.insert(f, l); - } - // We use the default copy constructor - // We use the default operator=() - // We use the default destructor - - void clear() { rep.clear(); } - void swap(sparse_hash_map& hs) { rep.swap(hs.rep); } - - - // Functions concerning size - size_type size() const { return rep.size(); } - size_type max_size() const { return rep.max_size(); } - bool empty() const { return rep.empty(); } - size_type bucket_count() const { return rep.bucket_count(); } - size_type max_bucket_count() const { return rep.max_bucket_count(); } - - // These are tr1 methods. bucket() is the bucket the key is or would be in. - size_type bucket_size(size_type i) const { return rep.bucket_size(i); } - size_type bucket(const key_type& key) const { return rep.bucket(key); } - float load_factor() const { - return size() * 1.0f / bucket_count(); - } - float max_load_factor() const { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - return grow; - } - void max_load_factor(float new_grow) { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - rep.set_resizing_parameters(shrink, new_grow); - } - // These aren't tr1 methods but perhaps ought to be. - float min_load_factor() const { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - return shrink; - } - void min_load_factor(float new_shrink) { - float shrink, grow; - rep.get_resizing_parameters(&shrink, &grow); - rep.set_resizing_parameters(new_shrink, grow); - } - // Deprecated; use min_load_factor() or max_load_factor() instead. - void set_resizing_parameters(float shrink, float grow) { - rep.set_resizing_parameters(shrink, grow); - } - - void resize(size_type hint) { rep.resize(hint); } - void rehash(size_type hint) { resize(hint); } // the tr1 name - - // Lookup routines - iterator find(const key_type& key) { return rep.find(key); } - const_iterator find(const key_type& key) const { return rep.find(key); } - - data_type& operator[](const key_type& key) { // This is our value-add! - // If key is in the hashtable, returns find(key)->second, - // otherwise returns insert(value_type(key, T()).first->second. - // Note it does not create an empty T unless the find fails. - return rep.template find_or_insert(key).second; - } - - size_type count(const key_type& key) const { return rep.count(key); } - - pair equal_range(const key_type& key) { - return rep.equal_range(key); - } - pair equal_range(const key_type& key) const { - return rep.equal_range(key); - } - - // Insertion routines - pair insert(const value_type& obj) { return rep.insert(obj); } - template - void insert(InputIterator f, InputIterator l) { rep.insert(f, l); } - void insert(const_iterator f, const_iterator l) { rep.insert(f, l); } - // required for std::insert_iterator; the passed-in iterator is ignored - iterator insert(iterator, const value_type& obj) { return insert(obj).first; } - - - // Deletion routines - // THESE ARE NON-STANDARD! I make you specify an "impossible" key - // value to identify deleted buckets. You can change the key as - // time goes on, or get rid of it entirely to be insert-only. - void set_deleted_key(const key_type& key) { - rep.set_deleted_key(key); - } - void clear_deleted_key() { rep.clear_deleted_key(); } - key_type deleted_key() const { return rep.deleted_key(); } - - // These are standard - size_type erase(const key_type& key) { return rep.erase(key); } - void erase(iterator it) { rep.erase(it); } - void erase(iterator f, iterator l) { rep.erase(f, l); } - - - // Comparison - bool operator==(const sparse_hash_map& hs) const { return rep == hs.rep; } - bool operator!=(const sparse_hash_map& hs) const { return rep != hs.rep; } - - - // I/O -- this is an add-on for writing metainformation to disk - bool write_metadata(FILE *fp) { return rep.write_metadata(fp); } - bool read_metadata(FILE *fp) { return rep.read_metadata(fp); } - bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); } - bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); } -}; - -// We need a global swap as well -template -inline void swap(sparse_hash_map& hm1, - sparse_hash_map& hm2) { - hm1.swap(hm2); -} - -_END_GOOGLE_NAMESPACE_ - -#endif /* _SPARSE_HASH_MAP_H_ */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/sparseconfig.h b/packages/stk/stk_classic/stk_util/stk_util/util/sparseconfig.h deleted file mode 100644 index 1efa313a1256..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/sparseconfig.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * NOTE: This file is for internal use only. - * Do not use these #defines in your own program! - */ - -/* Namespace for Google classes */ -#define GOOGLE_NAMESPACE ::google - -/* the location of the header defining hash functions */ -#define HASH_FUN_TR1H - -/* the namespace of the hash<> function */ -#define HASH_NAMESPACE std::tr1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if the system has the type `long long'. */ -#define HAVE_LONG_LONG 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if the system has the type `uint16_t'. */ -#define HAVE_UINT16_T 1 - -/* Define to 1 if the system has the type `u_int16_t'. */ -#define HAVE_U_INT16_T 1 - -/* Define to 1 if the system has the type `__uint16'. */ -/* #undef HAVE___UINT16 */ - -/* The system-provided hash function including the namespace. */ -#define SPARSEHASH_HASH HASH_NAMESPACE::hash - -/* the namespace where STL code like vector<> is defined */ -#define STL_NAMESPACE std - -/* Stops putting the code inside the Google namespace */ -#define _END_GOOGLE_NAMESPACE_ } - -/* Puts following code inside the Google namespace */ -#define _START_GOOGLE_NAMESPACE_ namespace google { diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/sparsehashtable.h b/packages/stk/stk_classic/stk_util/stk_util/util/sparsehashtable.h deleted file mode 100644 index be245e1a76e3..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/sparsehashtable.h +++ /dev/null @@ -1,1190 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Craig Silverstein -// -// A sparse hashtable is a particular implementation of -// a hashtable: one that is meant to minimize memory use. -// It does this by using a *sparse table* (cf sparsetable.h), -// which uses between 1 and 2 bits to store empty buckets -// (we may need another bit for hashtables that support deletion). -// -// When empty buckets are so cheap, an appealing hashtable -// implementation is internal probing, in which the hashtable -// is a single table, and collisions are resolved by trying -// to insert again in another bucket. The most cache-efficient -// internal probing schemes are linear probing (which suffers, -// alas, from clumping) and quadratic probing, which is what -// we implement by default. -// -// Deleted buckets are a bit of a pain. We have to somehow mark -// deleted buckets (the probing must distinguish them from empty -// buckets). The most principled way is to have another bitmap, -// but that's annoying and takes up space. Instead we let the -// user specify an "impossible" key. We set deleted buckets -// to have the impossible key. -// -// Note it is possible to change the value of the delete key -// on the fly; you can even remove it, though after that point -// the hashtable is insert_only until you set it again. -// -// You probably shouldn't use this code directly. Use -// or instead. -// -// You can modify the following, below: -// HT_OCCUPANCY_PCT -- how full before we double size -// HT_EMPTY_PCT -- how empty before we halve size -// HT_MIN_BUCKETS -- smallest bucket size -// HT_DEFAULT_STARTING_BUCKETS -- default bucket size at construct-time -// -// You can also change enlarge_factor (which defaults to -// HT_OCCUPANCY_PCT), and shrink_factor (which defaults to -// HT_EMPTY_PCT) with set_resizing_parameters(). -// -// How to decide what values to use? -// shrink_factor's default of .4 * OCCUPANCY_PCT, is probably good. -// HT_MIN_BUCKETS is probably unnecessary since you can specify -// (indirectly) the starting number of buckets at construct-time. -// For enlarge_factor, you can use this chart to try to trade-off -// expected lookup time to the space taken up. By default, this -// code uses quadratic probing, though you can change it to linear -// via _JUMP below if you really want to. -// -// From http://www.augustana.ca/~mohrj/courses/1999.fall/csc210/lecture_notes/hashing.html -// NUMBER OF PROBES / LOOKUP Successful Unsuccessful -// Quadratic collision resolution 1 - ln(1-L) - L/2 1/(1-L) - L - ln(1-L) -// Linear collision resolution [1+1/(1-L)]/2 [1+1/(1-L)2]/2 -// -// -- enlarge_factor -- 0.10 0.50 0.60 0.75 0.80 0.90 0.99 -// QUADRATIC COLLISION RES. -// probes/successful lookup 1.05 1.44 1.62 2.01 2.21 2.85 5.11 -// probes/unsuccessful lookup 1.11 2.19 2.82 4.64 5.81 11.4 103.6 -// LINEAR COLLISION RES. -// probes/successful lookup 1.06 1.5 1.75 2.5 3.0 5.5 50.5 -// probes/unsuccessful lookup 1.12 2.5 3.6 8.5 13.0 50.0 5000.0 -// -// The value type is required to be copy constructible and default -// constructible, but it need not be (and commonly isn't) assignable. - -#ifndef _SPARSEHASHTABLE_H_ -#define _SPARSEHASHTABLE_H_ - -#ifndef SPARSEHASH_STAT_UPDATE -#define SPARSEHASH_STAT_UPDATE(x) ((void) 0) -#endif - -// The probing method -// Linear probing -// #define JUMP_(key, num_probes) ( 1 ) -// Quadratic probing -#define JUMP_(key, num_probes) ( num_probes ) - -#include -#include -#include // For swap(), eg -#include // For length_error -#include // for facts about iterator tags -#include // for numeric_limits<> -#include // for pair<> -#include -#include // Since that's basically what we are - -_START_GOOGLE_NAMESPACE_ - -using STL_NAMESPACE::pair; - -// The smaller this is, the faster lookup is (because the group bitmap is -// smaller) and the faster insert is, because there's less to move. -// On the other hand, there are more groups. Since group::size_type is -// a short, this number should be of the form 32*x + 16 to avoid waste. -static const u_int16_t DEFAULT_GROUP_SIZE = 48; // fits in 1.5 words - -// Hashtable class, used to implement the hashed associative containers -// hash_set and hash_map. -// -// Value: what is stored in the table (each bucket is a Value). -// Key: something in a 1-to-1 correspondence to a Value, that can be used -// to search for a Value in the table (find() takes a Key). -// HashFcn: Takes a Key and returns an integer, the more unique the better. -// ExtractKey: given a Value, returns the unique Key associated with it. -// Must inherit from unary_function, or at least have a -// result_type enum indicating the return type of operator(). -// SetKey: given a Value* and a Key, modifies the value such that -// ExtractKey(value) == key. We guarantee this is only called -// with key == deleted_key. -// EqualKey: Given two Keys, says whether they are the same (that is, -// if they are both associated with the same Value). -// Alloc: STL allocator to use to allocate memory. - -template -class sparse_hashtable; - -template -struct sparse_hashtable_iterator; - -template -struct sparse_hashtable_const_iterator; - -// As far as iterating, we're basically just a sparsetable -// that skips over deleted elements. -template -struct sparse_hashtable_iterator { - private: - typedef typename A::template rebind::other value_alloc_type; - - public: - typedef sparse_hashtable_iterator iterator; - typedef sparse_hashtable_const_iterator const_iterator; - typedef typename sparsetable::nonempty_iterator - st_iterator; - - typedef STL_NAMESPACE::forward_iterator_tag iterator_category; - typedef V value_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::pointer pointer; - - // "Real" constructor and default constructor - sparse_hashtable_iterator(const sparse_hashtable *h, - st_iterator it, st_iterator it_end) - : ht(h), pos(it), end(it_end) { advance_past_deleted(); } - sparse_hashtable_iterator() { } // not ever used internally - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *pos; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic. The only hard part is making sure that - // we're not on a marked-deleted array element - void advance_past_deleted() { - while ( pos != end && ht->test_deleted(*this) ) - ++pos; - } - iterator& operator++() { - assert(pos != end); ++pos; advance_past_deleted(); return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - - // Comparison. - bool operator==(const iterator& it) const { return pos == it.pos; } - bool operator!=(const iterator& it) const { return pos != it.pos; } - - - // The actual data - const sparse_hashtable *ht; - st_iterator pos, end; -}; - -// Now do it all again, but with const-ness! -template -struct sparse_hashtable_const_iterator { - private: - typedef typename A::template rebind::other value_alloc_type; - - public: - typedef sparse_hashtable_iterator iterator; - typedef sparse_hashtable_const_iterator const_iterator; - typedef typename sparsetable::const_nonempty_iterator - st_iterator; - - typedef STL_NAMESPACE::forward_iterator_tag iterator_category; - typedef V value_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::const_reference reference; - typedef typename value_alloc_type::const_pointer pointer; - - // "Real" constructor and default constructor - sparse_hashtable_const_iterator(const sparse_hashtable *h, - st_iterator it, st_iterator it_end) - : ht(h), pos(it), end(it_end) { advance_past_deleted(); } - // This lets us convert regular iterators to const iterators - sparse_hashtable_const_iterator() { } // never used internally - sparse_hashtable_const_iterator(const iterator &it) - : ht(it.ht), pos(it.pos), end(it.end) { } - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *pos; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic. The only hard part is making sure that - // we're not on a marked-deleted array element - void advance_past_deleted() { - while ( pos != end && ht->test_deleted(*this) ) - ++pos; - } - const_iterator& operator++() { - assert(pos != end); ++pos; advance_past_deleted(); return *this; - } - const_iterator operator++(int) { const_iterator tmp(*this); ++*this; return tmp; } - - // Comparison. - bool operator==(const const_iterator& it) const { return pos == it.pos; } - bool operator!=(const const_iterator& it) const { return pos != it.pos; } - - - // The actual data - const sparse_hashtable *ht; - st_iterator pos, end; -}; - -// And once again, but this time freeing up memory as we iterate -template -struct sparse_hashtable_destructive_iterator { - private: - typedef typename A::template rebind::other value_alloc_type; - - public: - typedef sparse_hashtable_destructive_iterator iterator; - typedef typename sparsetable::destructive_iterator - st_iterator; - - typedef STL_NAMESPACE::forward_iterator_tag iterator_category; - typedef V value_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::pointer pointer; - - // "Real" constructor and default constructor - sparse_hashtable_destructive_iterator(const - sparse_hashtable *h, - st_iterator it, st_iterator it_end) - : ht(h), pos(it), end(it_end) { advance_past_deleted(); } - sparse_hashtable_destructive_iterator() { } // never used internally - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *pos; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic. The only hard part is making sure that - // we're not on a marked-deleted array element - void advance_past_deleted() { - while ( pos != end && ht->test_deleted(*this) ) - ++pos; - } - iterator& operator++() { - assert(pos != end); ++pos; advance_past_deleted(); return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - - // Comparison. - bool operator==(const iterator& it) const { return pos == it.pos; } - bool operator!=(const iterator& it) const { return pos != it.pos; } - - - // The actual data - const sparse_hashtable *ht; - st_iterator pos, end; -}; - - -template -class sparse_hashtable { - private: - typedef typename Alloc::template rebind::other value_alloc_type; - - public: - typedef Key key_type; - typedef Value value_type; - typedef HashFcn hasher; - typedef EqualKey key_equal; - typedef Alloc allocator_type; - - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::const_reference const_reference; - typedef typename value_alloc_type::pointer pointer; - typedef typename value_alloc_type::const_pointer const_pointer; - typedef sparse_hashtable_iterator - iterator; - - typedef sparse_hashtable_const_iterator - const_iterator; - - typedef sparse_hashtable_destructive_iterator - destructive_iterator; - - // These come from tr1. For us they're the same as regular iterators. - typedef iterator local_iterator; - typedef const_iterator const_local_iterator; - - // How full we let the table get before we resize, by default. - // Knuth says .8 is good -- higher causes us to probe too much, - // though it saves memory. - static const int HT_OCCUPANCY_PCT; // = 80 (out of 100); - - // How empty we let the table get before we resize lower, by default. - // (0.0 means never resize lower.) - // It should be less than OCCUPANCY_PCT / 2 or we thrash resizing - static const int HT_EMPTY_PCT; // = 0.4 * HT_OCCUPANCY_PCT; - - // Minimum size we're willing to let hashtables be. - // Must be a power of two, and at least 4. - // Note, however, that for a given hashtable, the initial size is a - // function of the first constructor arg, and may be >HT_MIN_BUCKETS. - static const size_type HT_MIN_BUCKETS = 4; - - // By default, if you don't specify a hashtable size at - // construction-time, we use this size. Must be a power of two, and - // at least HT_MIN_BUCKETS. - static const size_type HT_DEFAULT_STARTING_BUCKETS = 32; - - // ITERATOR FUNCTIONS - iterator begin() { return iterator(this, table.nonempty_begin(), - table.nonempty_end()); } - iterator end() { return iterator(this, table.nonempty_end(), - table.nonempty_end()); } - const_iterator begin() const { return const_iterator(this, - table.nonempty_begin(), - table.nonempty_end()); } - const_iterator end() const { return const_iterator(this, - table.nonempty_end(), - table.nonempty_end()); } - - // These come from tr1 unordered_map. They iterate over 'bucket' n. - // For sparsehashtable, we could consider each 'group' to be a bucket, - // I guess, but I don't really see the point. We'll just consider - // bucket n to be the n-th element of the sparsetable, if it's occupied, - // or some empty element, otherwise. - local_iterator begin(size_type i) { - if (table.test(i)) - return local_iterator(this, table.get_iter(i), table.nonempty_end()); - else - return local_iterator(this, table.nonempty_end(), table.nonempty_end()); - } - local_iterator end(size_type i) { - local_iterator it = begin(i); - if (table.test(i) && !test_deleted(i)) - ++it; - return it; - } - const_local_iterator begin(size_type i) const { - if (table.test(i)) - return const_local_iterator(this, table.get_iter(i), - table.nonempty_end()); - else - return const_local_iterator(this, table.nonempty_end(), - table.nonempty_end()); - } - const_local_iterator end(size_type i) const { - const_local_iterator it = begin(i); - if (table.test(i) && !test_deleted(i)) - ++it; - return it; - } - - // This is used when resizing - destructive_iterator destructive_begin() { - return destructive_iterator(this, table.destructive_begin(), - table.destructive_end()); - } - destructive_iterator destructive_end() { - return destructive_iterator(this, table.destructive_end(), - table.destructive_end()); - } - - - // ACCESSOR FUNCTIONS for the things we templatize on, basically - hasher hash_funct() const { return settings; } - key_equal key_eq() const { return key_info; } - allocator_type get_allocator() const { return table.get_allocator(); } - - // Accessor function for statistics gathering. - int num_table_copies() const { return settings.num_ht_copies(); } - - private: - // We need to copy values when we set the special marker for deleted - // elements, but, annoyingly, we can't just use the copy assignment - // operator because value_type might not be assignable (it's often - // pair). We use explicit destructor invocation and - // placement new to get around this. Arg. - void set_value(pointer dst, const_reference src) { - dst->~value_type(); // delete the old value, if any - new(dst) value_type(src); - } - - // This is used as a tag for the copy constructor, saying to destroy its - // arg We have two ways of destructively copying: with potentially growing - // the hashtable as we copy, and without. To make sure the outside world - // can't do a destructive copy, we make the typename private. - enum MoveDontCopyT {MoveDontCopy, MoveDontGrow}; - - // DELETE HELPER FUNCTIONS - // This lets the user describe a key that will indicate deleted - // table entries. This key should be an "impossible" entry -- - // if you try to insert it for real, you won't be able to retrieve it! - // (NB: while you pass in an entire value, only the key part is looked - // at. This is just because I don't know how to assign just a key.) - private: - void squash_deleted() { // gets rid of any deleted entries we have - if ( num_deleted ) { // get rid of deleted before writing - sparse_hashtable tmp(MoveDontGrow, *this); - swap(tmp); // now we are tmp - } - assert(num_deleted == 0); - } - - bool test_deleted_key(const key_type& key) const { - // The num_deleted test is crucial for read(): after read(), the ht values - // are garbage, and we don't want to think some of them are deleted. - // Invariant: !use_deleted implies num_deleted is 0. - assert(settings.use_deleted() || num_deleted == 0); - return num_deleted > 0 && equals(key_info.delkey, key); - } - - public: - void set_deleted_key(const key_type &key) { - // It's only safe to change what "deleted" means if we purge deleted guys - squash_deleted(); - settings.set_use_deleted(true); - key_info.delkey = key; - } - void clear_deleted_key() { - squash_deleted(); - settings.set_use_deleted(false); - } - key_type deleted_key() const { - assert(settings.use_deleted() - && "Must set deleted key before calling deleted_key"); - return key_info.delkey; - } - - // These are public so the iterators can use them - // True if the item at position bucknum is "deleted" marker - bool test_deleted(size_type bucknum) const { - if (num_deleted == 0 || !table.test(bucknum)) return false; - return test_deleted_key(get_key(table.unsafe_get(bucknum))); - } - bool test_deleted(const iterator &it) const { - if (!settings.use_deleted()) return false; - return test_deleted_key(get_key(*it)); - } - bool test_deleted(const const_iterator &it) const { - if (!settings.use_deleted()) return false; - return test_deleted_key(get_key(*it)); - } - bool test_deleted(const destructive_iterator &it) const { - if (!settings.use_deleted()) return false; - return test_deleted_key(get_key(*it)); - } - - private: - // Set it so test_deleted is true. true if object didn't used to be deleted. - // TODO(csilvers): make these private (also in densehashtable.h) - bool set_deleted(iterator &it) { - assert(settings.use_deleted()); - bool retval = !test_deleted(it); - // &* converts from iterator to value-type. - set_key(&(*it), key_info.delkey); - return retval; - } - // Set it so test_deleted is false. true if object used to be deleted. - bool clear_deleted(iterator &it) { - assert(settings.use_deleted()); - // Happens automatically when we assign something else in its place. - return test_deleted(it); - } - - // We also allow to set/clear the deleted bit on a const iterator. - // We allow a const_iterator for the same reason you can delete a - // const pointer: it's convenient, and semantically you can't use - // 'it' after it's been deleted anyway, so its const-ness doesn't - // really matter. - bool set_deleted(const_iterator &it) { - assert(settings.use_deleted()); // bad if set_deleted_key() wasn't called - bool retval = !test_deleted(it); - set_key(const_cast(&(*it)), key_info.delkey); - return retval; - } - // Set it so test_deleted is false. true if object used to be deleted. - bool clear_deleted(const_iterator &it) { - assert(settings.use_deleted()); // bad if set_deleted_key() wasn't called - return test_deleted(it); - } - - // FUNCTIONS CONCERNING SIZE - public: - size_type size() const { return table.num_nonempty() - num_deleted; } - size_type max_size() const { return table.max_size(); } - bool empty() const { return size() == 0; } - size_type bucket_count() const { return table.size(); } - size_type max_bucket_count() const { return max_size(); } - // These are tr1 methods. Their idea of 'bucket' doesn't map well to - // what we do. We just say every bucket has 0 or 1 items in it. - size_type bucket_size(size_type i) const { - return begin(i) == end(i) ? 0 : 1; - } - - private: - // Because of the above, size_type(-1) is never legal; use it for errors - static const size_type ILLEGAL_BUCKET = size_type(-1); - - // Used after a string of deletes. Returns true if we actually shrunk. - // TODO(csilvers): take a delta so we can take into account inserts - // done after shrinking. Maybe make part of the Settings class? - bool maybe_shrink() { - assert(table.num_nonempty() >= num_deleted); - assert((bucket_count() & (bucket_count()-1)) == 0); // is a power of two - assert(bucket_count() >= HT_MIN_BUCKETS); - bool retval = false; - - // If you construct a hashtable with < HT_DEFAULT_STARTING_BUCKETS, - // we'll never shrink until you get relatively big, and we'll never - // shrink below HT_DEFAULT_STARTING_BUCKETS. Otherwise, something - // like "dense_hash_set x; x.insert(4); x.erase(4);" will - // shrink us down to HT_MIN_BUCKETS buckets, which is too small. - const size_type num_remain = table.num_nonempty() - num_deleted; - const size_type shrink_threshold = settings.shrink_threshold(); - if (shrink_threshold > 0 && num_remain < shrink_threshold && - bucket_count() > HT_DEFAULT_STARTING_BUCKETS) { - const float shrink_factor = settings.shrink_factor(); - size_type sz = bucket_count() / 2; // find how much we should shrink - while (sz > HT_DEFAULT_STARTING_BUCKETS && - num_remain < static_cast(sz * shrink_factor)) { - sz /= 2; // stay a power of 2 - } - sparse_hashtable tmp(MoveDontCopy, *this, sz); - swap(tmp); // now we are tmp - retval = true; - } - settings.set_consider_shrink(false); // because we just considered it - return retval; - } - - // We'll let you resize a hashtable -- though this makes us copy all! - // When you resize, you say, "make it big enough for this many more elements" - // Returns true if we actually resized, false if size was already ok. - bool resize_delta(size_type delta) { - bool did_resize = false; - if ( settings.consider_shrink() ) { // see if lots of deletes happened - if ( maybe_shrink() ) - did_resize = true; - } - if (table.num_nonempty() >= - (STL_NAMESPACE::numeric_limits::max)() - delta) - throw std::length_error("resize overflow"); - if ( bucket_count() >= HT_MIN_BUCKETS && - (table.num_nonempty() + delta) <= settings.enlarge_threshold() ) - return did_resize; // we're ok as we are - - // Sometimes, we need to resize just to get rid of all the - // "deleted" buckets that are clogging up the hashtable. So when - // deciding whether to resize, count the deleted buckets (which - // are currently taking up room). But later, when we decide what - // size to resize to, *don't* count deleted buckets, since they - // get discarded during the resize. - const size_type needed_size = - settings.min_buckets(table.num_nonempty() + delta, 0); - if ( needed_size <= bucket_count() ) // we have enough buckets - return did_resize; - - size_type resize_to = - settings.min_buckets(table.num_nonempty() - num_deleted + delta, - bucket_count()); - if (resize_to < needed_size && // may double resize_to - resize_to < (STL_NAMESPACE::numeric_limits::max)() / 2) { - // This situation means that we have enough deleted elements, - // that once we purge them, we won't actually have needed to - // grow. But we may want to grow anyway: if we just purge one - // element, say, we'll have to grow anyway next time we - // insert. Might as well grow now, since we're already going - // through the trouble of copying (in order to purge the - // deleted elements). - const size_type target = - static_cast(settings.shrink_size(resize_to*2)); - if (table.num_nonempty() - num_deleted + delta >= target) { - // Good, we won't be below the shrink threshhold even if we double. - resize_to *= 2; - } - } - - sparse_hashtable tmp(MoveDontCopy, *this, resize_to); - swap(tmp); // now we are tmp - return true; - } - - // Used to actually do the rehashing when we grow/shrink a hashtable - void copy_from(const sparse_hashtable &ht, size_type min_buckets_wanted) { - clear(); // clear table, set num_deleted to 0 - - // If we need to change the size of our table, do it now - const size_type resize_to = - settings.min_buckets(ht.size(), min_buckets_wanted); - if ( resize_to > bucket_count() ) { // we don't have enough buckets - table.resize(resize_to); // sets the number of buckets - settings.reset_thresholds(bucket_count()); - } - - // We use a normal iterator to get non-deleted bcks from ht - // We could use insert() here, but since we know there are - // no duplicates and no deleted items, we can be more efficient - assert((bucket_count() & (bucket_count()-1)) == 0); // a power of two - for ( const_iterator it = ht.begin(); it != ht.end(); ++it ) { - size_type num_probes = 0; // how many times we've probed - size_type bucknum; - const size_type bucket_count_minus_one = bucket_count() - 1; - for (bucknum = hash(get_key(*it)) & bucket_count_minus_one; - table.test(bucknum); // not empty - bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one) { - ++num_probes; - assert(num_probes < bucket_count() - && "Hashtable is full: an error in key_equal<> or hash<>"); - } - table.set(bucknum, *it); // copies the value to here - } - settings.inc_num_ht_copies(); - } - - // Implementation is like copy_from, but it destroys the table of the - // "from" guy by freeing sparsetable memory as we iterate. This is - // useful in resizing, since we're throwing away the "from" guy anyway. - void move_from(MoveDontCopyT mover, sparse_hashtable &ht, - size_type min_buckets_wanted) { - clear(); // clear table, set num_deleted to 0 - - // If we need to change the size of our table, do it now - size_type resize_to; - if ( mover == MoveDontGrow ) - resize_to = ht.bucket_count(); // keep same size as old ht - else // MoveDontCopy - resize_to = settings.min_buckets(ht.size(), min_buckets_wanted); - if ( resize_to > bucket_count() ) { // we don't have enough buckets - table.resize(resize_to); // sets the number of buckets - settings.reset_thresholds(bucket_count()); - } - - // We use a normal iterator to get non-deleted bcks from ht - // We could use insert() here, but since we know there are - // no duplicates and no deleted items, we can be more efficient - assert( (bucket_count() & (bucket_count()-1)) == 0); // a power of two - // THIS IS THE MAJOR LINE THAT DIFFERS FROM COPY_FROM(): - for ( destructive_iterator it = ht.destructive_begin(); - it != ht.destructive_end(); ++it ) { - size_type num_probes = 0; // how many times we've probed - size_type bucknum; - for ( bucknum = hash(get_key(*it)) & (bucket_count()-1); // h % buck_cnt - table.test(bucknum); // not empty - bucknum = (bucknum + JUMP_(key, num_probes)) & (bucket_count()-1) ) { - ++num_probes; - assert(num_probes < bucket_count() - && "Hashtable is full: an error in key_equal<> or hash<>"); - } - table.set(bucknum, *it); // copies the value to here - } - settings.inc_num_ht_copies(); - } - - - // Required by the spec for hashed associative container - public: - // Though the docs say this should be num_buckets, I think it's much - // more useful as num_elements. As a special feature, calling with - // req_elements==0 will cause us to shrink if we can, saving space. - void resize(size_type req_elements) { // resize to this or larger - if ( settings.consider_shrink() || req_elements == 0 ) - maybe_shrink(); - if ( req_elements > table.num_nonempty() ) // we only grow - resize_delta(req_elements - table.num_nonempty()); - } - - // Get and change the value of shrink_factor and enlarge_factor. The - // description at the beginning of this file explains how to choose - // the values. Setting the shrink parameter to 0.0 ensures that the - // table never shrinks. - void get_resizing_parameters(float* shrink, float* grow) const { - *shrink = settings.shrink_factor(); - *grow = settings.enlarge_factor(); - } - void set_resizing_parameters(float shrink, float grow) { - settings.set_resizing_parameters(shrink, grow); - settings.reset_thresholds(bucket_count()); - } - - // CONSTRUCTORS -- as required by the specs, we take a size, - // but also let you specify a hashfunction, key comparator, - // and key extractor. We also define a copy constructor and =. - // DESTRUCTOR -- the default is fine, surprisingly. - explicit sparse_hashtable(size_type expected_max_items_in_table = 0, - const HashFcn& hf = HashFcn(), - const EqualKey& eql = EqualKey(), - const ExtractKey& ext = ExtractKey(), - const SetKey& set = SetKey(), - const Alloc& alloc = Alloc()) - : settings(hf), - key_info(ext, set, eql), - num_deleted(0), - table((expected_max_items_in_table == 0 - ? HT_DEFAULT_STARTING_BUCKETS - : settings.min_buckets(expected_max_items_in_table, 0)), - alloc) { - settings.reset_thresholds(bucket_count()); - } - - // As a convenience for resize(), we allow an optional second argument - // which lets you make this new hashtable a different size than ht. - // We also provide a mechanism of saying you want to "move" the ht argument - // into us instead of copying. - sparse_hashtable(const sparse_hashtable& ht, - size_type min_buckets_wanted = HT_DEFAULT_STARTING_BUCKETS) - : settings(ht.settings), - key_info(ht.key_info), - num_deleted(0), - table(0, ht.get_allocator()) { - settings.reset_thresholds(bucket_count()); - copy_from(ht, min_buckets_wanted); // copy_from() ignores deleted entries - } - sparse_hashtable(MoveDontCopyT mover, sparse_hashtable& ht, - size_type min_buckets_wanted = HT_DEFAULT_STARTING_BUCKETS) - : settings(ht.settings), - key_info(ht.key_info), - num_deleted(0), - table(0, ht.get_allocator()) { - settings.reset_thresholds(bucket_count()); - move_from(mover, ht, min_buckets_wanted); // ignores deleted entries - } - - sparse_hashtable& operator= (const sparse_hashtable& ht) { - if (&ht == this) return *this; // don't copy onto ourselves - settings = ht.settings; - key_info = ht.key_info; - num_deleted = ht.num_deleted; - // copy_from() calls clear and sets num_deleted to 0 too - copy_from(ht, HT_MIN_BUCKETS); - // we purposefully don't copy the allocator, which may not be copyable - return *this; - } - - // Many STL algorithms use swap instead of copy constructors - void swap(sparse_hashtable& ht) { - STL_NAMESPACE::swap(settings, ht.settings); - STL_NAMESPACE::swap(key_info, ht.key_info); - STL_NAMESPACE::swap(num_deleted, ht.num_deleted); - table.swap(ht.table); - } - - // It's always nice to be able to clear a table without deallocating it - void clear() { - if (!empty() || (num_deleted != 0)) { - table.clear(); - } - settings.reset_thresholds(bucket_count()); - num_deleted = 0; - } - - // LOOKUP ROUTINES - private: - // Returns a pair of positions: 1st where the object is, 2nd where - // it would go if you wanted to insert it. 1st is ILLEGAL_BUCKET - // if object is not found; 2nd is ILLEGAL_BUCKET if it is. - // Note: because of deletions where-to-insert is not trivial: it's the - // first deleted bucket we see, as long as we don't find the key later - pair find_position(const key_type &key) const { - size_type num_probes = 0; // how many times we've probed - const size_type bucket_count_minus_one = bucket_count() - 1; - size_type bucknum = hash(key) & bucket_count_minus_one; - size_type insert_pos = ILLEGAL_BUCKET; // where we would insert - SPARSEHASH_STAT_UPDATE(total_lookups += 1); - while ( 1 ) { // probe until something happens - if ( !table.test(bucknum) ) { // bucket is empty - SPARSEHASH_STAT_UPDATE(total_probes += num_probes); - if ( insert_pos == ILLEGAL_BUCKET ) // found no prior place to insert - return pair(ILLEGAL_BUCKET, bucknum); - else - return pair(ILLEGAL_BUCKET, insert_pos); - - } else if ( test_deleted(bucknum) ) {// keep searching, but mark to insert - if ( insert_pos == ILLEGAL_BUCKET ) - insert_pos = bucknum; - - } else if ( equals(key, get_key(table.unsafe_get(bucknum))) ) { - SPARSEHASH_STAT_UPDATE(total_probes += num_probes); - return pair(bucknum, ILLEGAL_BUCKET); - } - ++num_probes; // we're doing another probe - bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one; - assert(num_probes < bucket_count() - && "Hashtable is full: an error in key_equal<> or hash<>"); - } - } - - public: - iterator find(const key_type& key) { - if ( size() == 0 ) return end(); - pair pos = find_position(key); - if ( pos.first == ILLEGAL_BUCKET ) // alas, not there - return end(); - else - return iterator(this, table.get_iter(pos.first), table.nonempty_end()); - } - - const_iterator find(const key_type& key) const { - if ( size() == 0 ) return end(); - pair pos = find_position(key); - if ( pos.first == ILLEGAL_BUCKET ) // alas, not there - return end(); - else - return const_iterator(this, - table.get_iter(pos.first), table.nonempty_end()); - } - - // This is a tr1 method: the bucket a given key is in, or what bucket - // it would be put in, if it were to be inserted. Shrug. - size_type bucket(const key_type& key) const { - pair pos = find_position(key); - return pos.first == ILLEGAL_BUCKET ? pos.second : pos.first; - } - - // Counts how many elements have key key. For maps, it's either 0 or 1. - size_type count(const key_type &key) const { - pair pos = find_position(key); - return pos.first == ILLEGAL_BUCKET ? 0 : 1; - } - - // Likewise, equal_range doesn't really make sense for us. Oh well. - pair equal_range(const key_type& key) { - iterator pos = find(key); // either an iterator or end - if (pos == end()) { - return pair(pos, pos); - } else { - const iterator startpos = pos++; - return pair(startpos, pos); - } - } - pair equal_range(const key_type& key) const { - const_iterator pos = find(key); // either an iterator or end - if (pos == end()) { - return pair(pos, pos); - } else { - const const_iterator startpos = pos++; - return pair(startpos, pos); - } - } - - - // INSERTION ROUTINES - private: - // Private method used by insert_noresize and find_or_insert. - iterator insert_at(const_reference obj, size_type pos) { - if (size() >= max_size()) - throw std::length_error("insert overflow"); - if ( test_deleted(pos) ) { // just replace if it's been deleted - // The set() below will undelete this object. We just worry about stats - assert(num_deleted > 0); - --num_deleted; // used to be, now it isn't - } - table.set(pos, obj); - return iterator(this, table.get_iter(pos), table.nonempty_end()); - } - - // If you know *this is big enough to hold obj, use this routine - pair insert_noresize(const_reference obj) { - // First, double-check we're not inserting delkey - assert((!settings.use_deleted() || !equals(get_key(obj), key_info.delkey)) - && "Inserting the deleted key"); - const pair pos = find_position(get_key(obj)); - if ( pos.first != ILLEGAL_BUCKET) { // object was already there - return pair(iterator(this, table.get_iter(pos.first), - table.nonempty_end()), - false); // false: we didn't insert - } else { // pos.second says where to put it - return pair(insert_at(obj, pos.second), true); - } - } - - // Specializations of insert(it, it) depending on the power of the iterator: - // (1) Iterator supports operator-, resize before inserting - template - void insert(ForwardIterator f, ForwardIterator l, STL_NAMESPACE::forward_iterator_tag) { - size_t dist = STL_NAMESPACE::distance(f, l); - if (dist >= (std::numeric_limits::max)()) - throw std::length_error("insert-range overflow"); - resize_delta(static_cast(dist)); - for ( ; dist > 0; --dist, ++f) { - insert_noresize(*f); - } - } - - // (2) Arbitrary iterator, can't tell how much to resize - template - void insert(InputIterator f, InputIterator l, STL_NAMESPACE::input_iterator_tag) { - for ( ; f != l; ++f) - insert(*f); - } - - public: - // This is the normal insert routine, used by the outside world - pair insert(const_reference obj) { - resize_delta(1); // adding an object, grow if need be - return insert_noresize(obj); - } - - // When inserting a lot at a time, we specialize on the type of iterator - template - void insert(InputIterator f, InputIterator l) { - // specializes on iterator type - insert(f, l, typename STL_NAMESPACE::iterator_traits::iterator_category()); - } - - // DefaultValue is a functor that takes a key and returns a value_type - // representing the default value to be inserted if none is found. - template - value_type& find_or_insert(const key_type& key) { - // First, double-check we're not inserting delkey - assert((!settings.use_deleted() || !equals(key, key_info.delkey)) - && "Inserting the deleted key"); - const pair pos = find_position(key); - DefaultValue default_value; - if ( pos.first != ILLEGAL_BUCKET) { // object was already there - return *table.get_iter(pos.first); - } else if (resize_delta(1)) { // needed to rehash to make room - // Since we resized, we can't use pos, so recalculate where to insert. - return *insert_noresize(default_value(key)).first; - } else { // no need to rehash, insert right here - return *insert_at(default_value(key), pos.second); - } - } - - // DELETION ROUTINES - size_type erase(const key_type& key) { - // First, double-check we're not erasing delkey. - assert((!settings.use_deleted() || !equals(key, key_info.delkey)) - && "Erasing the deleted key"); - assert(!settings.use_deleted() || !equals(key, key_info.delkey)); - const_iterator pos = find(key); // shrug: shouldn't need to be const - if ( pos != end() ) { - assert(!test_deleted(pos)); // or find() shouldn't have returned it - set_deleted(pos); - ++num_deleted; - // will think about shrink after next insert - settings.set_consider_shrink(true); - return 1; // because we deleted one thing - } else { - return 0; // because we deleted nothing - } - } - - // We return the iterator past the deleted item. - void erase(iterator pos) { - if ( pos == end() ) return; // sanity check - if ( set_deleted(pos) ) { // true if object has been newly deleted - ++num_deleted; - // will think about shrink after next insert - settings.set_consider_shrink(true); - } - } - - void erase(iterator f, iterator l) { - for ( ; f != l; ++f) { - if ( set_deleted(f) ) // should always be true - ++num_deleted; - } - // will think about shrink after next insert - settings.set_consider_shrink(true); - } - - // We allow you to erase a const_iterator just like we allow you to - // erase an iterator. This is in parallel to 'delete': you can delete - // a const pointer just like a non-const pointer. The logic is that - // you can't use the object after it's erased anyway, so it doesn't matter - // if it's const or not. - void erase(const_iterator pos) { - if ( pos == end() ) return; // sanity check - if ( set_deleted(pos) ) { // true if object has been newly deleted - ++num_deleted; - // will think about shrink after next insert - settings.set_consider_shrink(true); - } - } - void erase(const_iterator f, const_iterator l) { - for ( ; f != l; ++f) { - if ( set_deleted(f) ) // should always be true - ++num_deleted; - } - // will think about shrink after next insert - settings.set_consider_shrink(true); - } - - - // COMPARISON - bool operator==(const sparse_hashtable& ht) const { - if (size() != ht.size()) { - return false; - } else if (this == &ht) { - return true; - } else { - // Iterate through the elements in "this" and see if the - // corresponding element is in ht - for ( const_iterator it = begin(); it != end(); ++it ) { - const_iterator it2 = ht.find(get_key(*it)); - if ((it2 == ht.end()) || (*it != *it2)) { - return false; - } - } - return true; - } - } - bool operator!=(const sparse_hashtable& ht) const { - return !(*this == ht); - } - - - // I/O - // We support reading and writing hashtables to disk. NOTE that - // this only stores the hashtable metadata, not the stuff you've - // actually put in the hashtable! Alas, since I don't know how to - // write a hasher or key_equal, you have to make sure everything - // but the table is the same. We compact before writing. - bool write_metadata(FILE *fp) { - squash_deleted(); // so we don't have to worry about delkey - return table.write_metadata(fp); - } - - bool read_metadata(FILE *fp) { - num_deleted = 0; // since we got rid before writing - bool result = table.read_metadata(fp); - settings.reset_thresholds(bucket_count()); - return result; - } - - // Only meaningful if value_type is a POD. - bool write_nopointer_data(FILE *fp) { - return table.write_nopointer_data(fp); - } - - // Only meaningful if value_type is a POD. - bool read_nopointer_data(FILE *fp) { - return table.read_nopointer_data(fp); - } - - private: - // Table is the main storage class. - typedef sparsetable Table; - - // Package templated functors with the other types to eliminate memory - // needed for storing these zero-size operators. Since ExtractKey and - // hasher's operator() might have the same function signature, they - // must be packaged in different classes. - struct Settings : - sh_hashtable_settings { - explicit Settings(const hasher& hf) - : sh_hashtable_settings( - hf, HT_OCCUPANCY_PCT / 100.0f, HT_EMPTY_PCT / 100.0f) {} - }; - - // KeyInfo stores delete key and packages zero-size functors: - // ExtractKey and SetKey. - class KeyInfo : public ExtractKey, public SetKey, public key_equal { - public: - KeyInfo(const ExtractKey& ek, const SetKey& sk, const key_equal& eq) - : ExtractKey(ek), - SetKey(sk), - key_equal(eq) { - } - // We want to return the exact same type as ExtractKey: Key or const Key& - typename ExtractKey::result_type get_key(const_reference v) const { - return ExtractKey::operator()(v); - } - void set_key(pointer v, const key_type& k) const { - SetKey::operator()(v, k); - } - bool equals(const key_type& a, const key_type& b) const { - return key_equal::operator()(a, b); - } - - // Which key marks deleted entries. - // TODO(csilvers): make a pointer, and get rid of use_deleted (benchmark!) - typename remove_const::type delkey; - }; - - // Utility functions to access the templated operators - size_type hash(const key_type& v) const { - return settings.hash(v); - } - bool equals(const key_type& a, const key_type& b) const { - return key_info.equals(a, b); - } - typename ExtractKey::result_type get_key(const_reference v) const { - return key_info.get_key(v); - } - void set_key(pointer v, const key_type& k) const { - key_info.set_key(v, k); - } - - private: - // Actual data - Settings settings; - KeyInfo key_info; - size_type num_deleted; // how many occupied buckets are marked deleted - Table table; // holds num_buckets and num_elements too -}; - - -// We need a global swap as well -template -inline void swap(sparse_hashtable &x, - sparse_hashtable &y) { - x.swap(y); -} - -#undef JUMP_ - -template -const typename sparse_hashtable::size_type - sparse_hashtable::ILLEGAL_BUCKET; - -// How full we let the table get before we resize. Knuth says .8 is -// good -- higher causes us to probe too much, though saves memory -template -const int sparse_hashtable::HT_OCCUPANCY_PCT = 80; - -// How empty we let the table get before we resize lower. -// It should be less than OCCUPANCY_PCT / 2 or we thrash resizing -template -const int sparse_hashtable::HT_EMPTY_PCT - = static_cast(0.4 * - sparse_hashtable::HT_OCCUPANCY_PCT); - -_END_GOOGLE_NAMESPACE_ - -#endif /* _SPARSEHASHTABLE_H_ */ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/sparsetable b/packages/stk/stk_classic/stk_util/stk_util/util/sparsetable deleted file mode 100644 index fccf53670a11..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/sparsetable +++ /dev/null @@ -1,1598 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// Author: Craig Silverstein -// -// A sparsetable is a random container that implements a sparse array, -// that is, an array that uses very little memory to store unassigned -// indices (in this case, between 1-2 bits per unassigned index). For -// instance, if you allocate an array of size 5 and assign a[2] = , then a[2] will take up a lot of memory but a[0], a[1], -// a[3], and a[4] will not. Array elements that have a value are -// called "assigned". Array elements that have no value yet, or have -// had their value cleared using erase() or clear(), are called -// "unassigned". -// -// Unassigned values seem to have the default value of T (see below). -// Nevertheless, there is a difference between an unassigned index and -// one explicitly assigned the value of T(). The latter is considered -// assigned. -// -// Access to an array element is constant time, as is insertion and -// deletion. Insertion and deletion may be fairly slow, however: -// because of this container's memory economy, each insert and delete -// causes a memory reallocation. -// -// See doc/sparsetable.html for information about how to use this class. - -#ifndef _SPARSETABLE_H_ -#define _SPARSETABLE_H_ - -#include -#include // for malloc/free -#include // to read/write tables -#ifdef HAVE_STDINT_H -#include // the normal place uint16_t is defined -#endif -#ifdef HAVE_SYS_TYPES_H -#include // the normal place u_int16_t is defined -#endif -#ifdef HAVE_INTTYPES_H -#include // a third place for uint16_t or u_int16_t -#endif -#include // for bounds checking -#include // to define reverse_iterator for me -#include // equal, lexicographical_compare, swap,... -#include // uninitialized_copy -#include // a sparsetable is a vector of groups -#include -#include // for true_type, integral_constant, etc. - -#if STDC_HEADERS -#include // for memcpy -#else -#if !HAVE_MEMCPY -#define memcpy(d, s, n) bcopy ((s), (d), (n)) -#endif -#endif - -#ifndef HAVE_U_INT16_T -# if defined HAVE_UINT16_T - typedef uint16_t u_int16_t; // true on solaris, possibly other C99 libc's -# elif defined HAVE___UINT16 - typedef __int16 int16_t; // true on vc++7 - typedef unsigned __int16 u_int16_t; -# else - // Cannot find a 16-bit integer type. Hoping for the best with "short"... - typedef short int int16_t; - typedef unsigned short int u_int16_t; -# endif -#endif - -_START_GOOGLE_NAMESPACE_ - -using STL_NAMESPACE::vector; -using STL_NAMESPACE::uninitialized_copy; - -// The smaller this is, the faster lookup is (because the group bitmap is -// smaller) and the faster insert is, because there's less to move. -// On the other hand, there are more groups. Since group::size_type is -// a short, this number should be of the form 32*x + 16 to avoid waste. -static const u_int16_t DEFAULT_SPARSEGROUP_SIZE = 48; // fits in 1.5 words - - -// A NOTE ON ASSIGNING: -// A sparse table does not actually allocate memory for entries -// that are not filled. Because of this, it becomes complicated -// to have a non-const iterator: we don't know, if the iterator points -// to a not-filled bucket, whether you plan to fill it with something -// or whether you plan to read its value (in which case you'll get -// the default bucket value). Therefore, while we can define const -// operations in a pretty 'normal' way, for non-const operations, we -// define something that returns a helper object with operator= and -// operator& that allocate a bucket lazily. We use this for table[] -// and also for regular table iterators. - -template -class table_element_adaptor { - public: - typedef typename tabletype::value_type value_type; - typedef typename tabletype::size_type size_type; - typedef typename tabletype::reference reference; - typedef typename tabletype::pointer pointer; - - table_element_adaptor(tabletype *tbl, size_type p) - : table(tbl), pos(p) { } - table_element_adaptor& operator= (const value_type &val) { - table->set(pos, val); - return *this; - } - operator value_type() { return table->get(pos); } // we look like a value - pointer operator& () { return &table->mutating_get(pos); } - - private: - tabletype* table; - size_type pos; -}; - -// Our iterator as simple as iterators can be: basically it's just -// the index into our table. Dereference, the only complicated -// thing, we punt to the table class. This just goes to show how -// much machinery STL requires to do even the most trivial tasks. -// -// By templatizing over tabletype, we have one iterator type which -// we can use for both sparsetables and sparsebins. In fact it -// works on any class that allows size() and operator[] (eg vector), -// as long as it does the standard STL typedefs too (eg value_type). - -template -class table_iterator { - public: - typedef table_iterator iterator; - - typedef STL_NAMESPACE::random_access_iterator_tag iterator_category; - typedef typename tabletype::value_type value_type; - typedef typename tabletype::difference_type difference_type; - typedef typename tabletype::size_type size_type; - typedef table_element_adaptor reference; - typedef table_element_adaptor* pointer; - - // The "real" constructor - table_iterator(tabletype *tbl, size_type p) - : table(tbl), pos(p) { } - // The default constructor, used when I define vars of type table::iterator - table_iterator() : table(NULL), pos(0) { } - // The copy constructor, for when I say table::iterator foo = tbl.begin() - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // The main thing our iterator does is dereference. If the table entry - // we point to is empty, we return the default value type. - // This is the big different function from the const iterator. - reference operator*() { - return table_element_adaptor(table, pos); - } - pointer operator->() { return &(operator*()); } - - // Helper function to assert things are ok; eg pos is still in range - void check() const { - assert(table); - assert(pos <= table->size()); - } - - // Arithmetic: we just do arithmetic on pos. We don't even need to - // do bounds checking, since STL doesn't consider that its job. :-) - iterator& operator+=(size_type t) { pos += t; check(); return *this; } - iterator& operator-=(size_type t) { pos -= t; check(); return *this; } - iterator& operator++() { ++pos; check(); return *this; } - iterator& operator--() { --pos; check(); return *this; } - iterator operator++(int) { iterator tmp(*this); // for x++ - ++pos; check(); return tmp; } - iterator operator--(int) { iterator tmp(*this); // for x-- - --pos; check(); return tmp; } - iterator operator+(difference_type i) const { iterator tmp(*this); - tmp += i; return tmp; } - iterator operator-(difference_type i) const { iterator tmp(*this); - tmp -= i; return tmp; } - difference_type operator-(iterator it) const { // for "x = it2 - it" - assert(table == it.table); - return pos - it.pos; - } - reference operator[](difference_type n) const { - return *(*this + n); // simple though not totally efficient - } - - // Comparisons. - bool operator==(const iterator& it) const { - return table == it.table && pos == it.pos; - } - bool operator<(const iterator& it) const { - assert(table == it.table); // life is bad bad bad otherwise - return pos < it.pos; - } - bool operator!=(const iterator& it) const { return !(*this == it); } - bool operator<=(const iterator& it) const { return !(it < *this); } - bool operator>(const iterator& it) const { return it < *this; } - bool operator>=(const iterator& it) const { return !(*this < it); } - - // Here's the info we actually need to be an iterator - tabletype *table; // so we can dereference and bounds-check - size_type pos; // index into the table -}; - -// support for "3 + iterator" has to be defined outside the class, alas -template -table_iterator operator+(typename table_iterator::difference_type i, - table_iterator it) { - return it + i; // so people can say it2 = 3 + it -} - -template -class const_table_iterator { - public: - typedef table_iterator iterator; - typedef const_table_iterator const_iterator; - - typedef STL_NAMESPACE::random_access_iterator_tag iterator_category; - typedef typename tabletype::value_type value_type; - typedef typename tabletype::difference_type difference_type; - typedef typename tabletype::size_type size_type; - typedef typename tabletype::const_reference reference; // we're const-only - typedef typename tabletype::const_pointer pointer; - - // The "real" constructor - const_table_iterator(const tabletype *tbl, size_type p) - : table(tbl), pos(p) { } - // The default constructor, used when I define vars of type table::iterator - const_table_iterator() : table(NULL), pos(0) { } - // The copy constructor, for when I say table::iterator foo = tbl.begin() - // Also converts normal iterators to const iterators - const_table_iterator(const iterator &from) - : table(from.table), pos(from.pos) { } - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // The main thing our iterator does is dereference. If the table entry - // we point to is empty, we return the default value type. - reference operator*() const { return (*table)[pos]; } - pointer operator->() const { return &(operator*()); } - - // Helper function to assert things are ok; eg pos is still in range - void check() const { - assert(table); - assert(pos <= table->size()); - } - - // Arithmetic: we just do arithmetic on pos. We don't even need to - // do bounds checking, since STL doesn't consider that its job. :-) - const_iterator& operator+=(size_type t) { pos += t; check(); return *this; } - const_iterator& operator-=(size_type t) { pos -= t; check(); return *this; } - const_iterator& operator++() { ++pos; check(); return *this; } - const_iterator& operator--() { --pos; check(); return *this; } - const_iterator operator++(int) { const_iterator tmp(*this); // for x++ - ++pos; check(); return tmp; } - const_iterator operator--(int) { const_iterator tmp(*this); // for x-- - --pos; check(); return tmp; } - const_iterator operator+(difference_type i) const { const_iterator tmp(*this); - tmp += i; return tmp; } - const_iterator operator-(difference_type i) const { const_iterator tmp(*this); - tmp -= i; return tmp; } - difference_type operator-(const_iterator it) const { // for "x = it2 - it" - assert(table == it.table); - return pos - it.pos; - } - reference operator[](difference_type n) const { - return *(*this + n); // simple though not totally efficient - } - - // Comparisons. - bool operator==(const const_iterator& it) const { - return table == it.table && pos == it.pos; - } - bool operator<(const const_iterator& it) const { - assert(table == it.table); // life is bad bad bad otherwise - return pos < it.pos; - } - bool operator!=(const const_iterator& it) const { return !(*this == it); } - bool operator<=(const const_iterator& it) const { return !(it < *this); } - bool operator>(const const_iterator& it) const { return it < *this; } - bool operator>=(const const_iterator& it) const { return !(*this < it); } - - // Here's the info we actually need to be an iterator - const tabletype *table; // so we can dereference and bounds-check - size_type pos; // index into the table -}; - -// support for "3 + iterator" has to be defined outside the class, alas -template -const_table_iterator operator+(typename - const_table_iterator::difference_type i, - const_table_iterator it) { - return it + i; // so people can say it2 = 3 + it -} - - -// --------------------------------------------------------------------------- - - -/* -// This is a 2-D iterator. You specify a begin and end over a list -// of *containers*. We iterate over each container by iterating over -// it. It's actually simple: -// VECTOR.begin() VECTOR[0].begin() --------> VECTOR[0].end() ---, -// | ________________________________________________/ -// | \_> VECTOR[1].begin() --------> VECTOR[1].end() -, -// | ___________________________________________________/ -// v \_> ...... -// VECTOR.end() -// -// It's impossible to do random access on one of these things in constant -// time, so it's just a bidirectional iterator. -// -// Unfortunately, because we need to use this for a non-empty iterator, -// we use nonempty_begin() and nonempty_end() instead of begin() and end() -// (though only going across, not down). -*/ - -#define TWOD_BEGIN_ nonempty_begin -#define TWOD_END_ nonempty_end -#define TWOD_ITER_ nonempty_iterator -#define TWOD_CONST_ITER_ const_nonempty_iterator - -template -class two_d_iterator { - public: - typedef two_d_iterator iterator; - - typedef STL_NAMESPACE::bidirectional_iterator_tag iterator_category; - // apparently some versions of VC++ have trouble with two ::'s in a typename - typedef typename containertype::value_type _tmp_vt; - typedef typename _tmp_vt::value_type value_type; - typedef typename _tmp_vt::difference_type difference_type; - typedef typename _tmp_vt::reference reference; - typedef typename _tmp_vt::pointer pointer; - - // The "real" constructor. begin and end specify how many rows we have - // (in the diagram above); we always iterate over each row completely. - two_d_iterator(typename containertype::iterator begin, - typename containertype::iterator end, - typename containertype::iterator curr) - : row_begin(begin), row_end(end), row_current(curr), col_current() { - if ( row_current != row_end ) { - col_current = row_current->TWOD_BEGIN_(); - advance_past_end(); // in case cur->begin() == cur->end() - } - } - // If you want to start at an arbitrary place, you can, I guess - two_d_iterator(typename containertype::iterator begin, - typename containertype::iterator end, - typename containertype::iterator curr, - typename containertype::value_type::TWOD_ITER_ col) - : row_begin(begin), row_end(end), row_current(curr), col_current(col) { - advance_past_end(); // in case cur->begin() == cur->end() - } - // The default constructor, used when I define vars of type table::iterator - two_d_iterator() : row_begin(), row_end(), row_current(), col_current() { } - // The default destructor is fine; we don't define one - // The default operator= is fine; we don't define one - - // Happy dereferencer - reference operator*() const { return *col_current; } - pointer operator->() const { return &(operator*()); } - - // Arithmetic: we just do arithmetic on pos. We don't even need to - // do bounds checking, since STL doesn't consider that its job. :-) - // NOTE: this is not amortized constant time! What do we do about it? - void advance_past_end() { // used when col_current points to end() - while ( col_current == row_current->TWOD_END_() ) { // end of current row - ++row_current; // go to beginning of next - if ( row_current != row_end ) // col is irrelevant at end - col_current = row_current->TWOD_BEGIN_(); - else - break; // don't go past row_end - } - } - - iterator& operator++() { - assert(row_current != row_end); // how to ++ from there? - ++col_current; - advance_past_end(); // in case col_current is at end() - return *this; - } - iterator& operator--() { - while ( row_current == row_end || - col_current == row_current->TWOD_BEGIN_() ) { - assert(row_current != row_begin); - --row_current; - col_current = row_current->TWOD_END_(); // this is 1 too far - } - --col_current; - return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - iterator operator--(int) { iterator tmp(*this); --*this; return tmp; } - - - // Comparisons. - bool operator==(const iterator& it) const { - return ( row_begin == it.row_begin && - row_end == it.row_end && - row_current == it.row_current && - (row_current == row_end || col_current == it.col_current) ); - } - bool operator!=(const iterator& it) const { return !(*this == it); } - - - // Here's the info we actually need to be an iterator - // These need to be public so we convert from iterator to const_iterator - typename containertype::iterator row_begin, row_end, row_current; - typename containertype::value_type::TWOD_ITER_ col_current; -}; - -// The same thing again, but this time const. :-( -template -class const_two_d_iterator { - public: - typedef const_two_d_iterator iterator; - - typedef STL_NAMESPACE::bidirectional_iterator_tag iterator_category; - // apparently some versions of VC++ have trouble with two ::'s in a typename - typedef typename containertype::value_type _tmp_vt; - typedef typename _tmp_vt::value_type value_type; - typedef typename _tmp_vt::difference_type difference_type; - typedef typename _tmp_vt::const_reference reference; - typedef typename _tmp_vt::const_pointer pointer; - - const_two_d_iterator(typename containertype::const_iterator begin, - typename containertype::const_iterator end, - typename containertype::const_iterator curr) - : row_begin(begin), row_end(end), row_current(curr), col_current() { - if ( curr != end ) { - col_current = curr->TWOD_BEGIN_(); - advance_past_end(); // in case cur->begin() == cur->end() - } - } - const_two_d_iterator(typename containertype::const_iterator begin, - typename containertype::const_iterator end, - typename containertype::const_iterator curr, - typename containertype::value_type::TWOD_CONST_ITER_ col) - : row_begin(begin), row_end(end), row_current(curr), col_current(col) { - advance_past_end(); // in case cur->begin() == cur->end() - } - const_two_d_iterator() - : row_begin(), row_end(), row_current(), col_current() { - } - // Need this explicitly so we can convert normal iterators to const iterators - const_two_d_iterator(const two_d_iterator& it) : - row_begin(it.row_begin), row_end(it.row_end), row_current(it.row_current), - col_current(it.col_current) { } - - typename containertype::const_iterator row_begin, row_end, row_current; - typename containertype::value_type::TWOD_CONST_ITER_ col_current; - - - // EVERYTHING FROM HERE DOWN IS THE SAME AS THE NON-CONST ITERATOR - reference operator*() const { return *col_current; } - pointer operator->() const { return &(operator*()); } - - void advance_past_end() { // used when col_current points to end() - while ( col_current == row_current->TWOD_END_() ) { // end of current row - ++row_current; // go to beginning of next - if ( row_current != row_end ) // col is irrelevant at end - col_current = row_current->TWOD_BEGIN_(); - else - break; // don't go past row_end - } - } - iterator& operator++() { - assert(row_current != row_end); // how to ++ from there? - ++col_current; - advance_past_end(); // in case col_current is at end() - return *this; - } - iterator& operator--() { - while ( row_current == row_end || - col_current == row_current->TWOD_BEGIN_() ) { - assert(row_current != row_begin); - --row_current; - col_current = row_current->TWOD_END_(); // this is 1 too far - } - --col_current; - return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - iterator operator--(int) { iterator tmp(*this); --*this; return tmp; } - - bool operator==(const iterator& it) const { - return ( row_begin == it.row_begin && - row_end == it.row_end && - row_current == it.row_current && - (row_current == row_end || col_current == it.col_current) ); - } - bool operator!=(const iterator& it) const { return !(*this == it); } -}; - -// We provide yet another version, to be as frugal with memory as -// possible. This one frees each block of memory as it finishes -// iterating over it. By the end, the entire table is freed. -// For understandable reasons, you can only iterate over it once, -// which is why it's an input iterator -template -class destructive_two_d_iterator { - public: - typedef destructive_two_d_iterator iterator; - - typedef STL_NAMESPACE::input_iterator_tag iterator_category; - // apparently some versions of VC++ have trouble with two ::'s in a typename - typedef typename containertype::value_type _tmp_vt; - typedef typename _tmp_vt::value_type value_type; - typedef typename _tmp_vt::difference_type difference_type; - typedef typename _tmp_vt::reference reference; - typedef typename _tmp_vt::pointer pointer; - - destructive_two_d_iterator(typename containertype::iterator begin, - typename containertype::iterator end, - typename containertype::iterator curr) - : row_begin(begin), row_end(end), row_current(curr), col_current() { - if ( curr != end ) { - col_current = curr->TWOD_BEGIN_(); - advance_past_end(); // in case cur->begin() == cur->end() - } - } - destructive_two_d_iterator(typename containertype::iterator begin, - typename containertype::iterator end, - typename containertype::iterator curr, - typename containertype::value_type::TWOD_ITER_ col) - : row_begin(begin), row_end(end), row_current(curr), col_current(col) { - advance_past_end(); // in case cur->begin() == cur->end() - } - destructive_two_d_iterator() - : row_begin(), row_end(), row_current(), col_current() { - } - - typename containertype::iterator row_begin, row_end, row_current; - typename containertype::value_type::TWOD_ITER_ col_current; - - // This is the part that destroys - void advance_past_end() { // used when col_current points to end() - while ( col_current == row_current->TWOD_END_() ) { // end of current row - row_current->clear(); // the destructive part - // It would be nice if we could decrement sparsetable->num_buckets here - ++row_current; // go to beginning of next - if ( row_current != row_end ) // col is irrelevant at end - col_current = row_current->TWOD_BEGIN_(); - else - break; // don't go past row_end - } - } - - // EVERYTHING FROM HERE DOWN IS THE SAME AS THE REGULAR ITERATOR - reference operator*() const { return *col_current; } - pointer operator->() const { return &(operator*()); } - - iterator& operator++() { - assert(row_current != row_end); // how to ++ from there? - ++col_current; - advance_past_end(); // in case col_current is at end() - return *this; - } - iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; } - - bool operator==(const iterator& it) const { - return ( row_begin == it.row_begin && - row_end == it.row_end && - row_current == it.row_current && - (row_current == row_end || col_current == it.col_current) ); - } - bool operator!=(const iterator& it) const { return !(*this == it); } -}; - -#undef TWOD_BEGIN_ -#undef TWOD_END_ -#undef TWOD_ITER_ -#undef TWOD_CONST_ITER_ - - - - -// SPARSE-TABLE -// ------------ -// The idea is that a table with (logically) t buckets is divided -// into t/M *groups* of M buckets each. (M is a constant set in -// GROUP_SIZE for efficiency.) Each group is stored sparsely. -// Thus, inserting into the table causes some array to grow, which is -// slow but still constant time. Lookup involves doing a -// logical-position-to-sparse-position lookup, which is also slow but -// constant time. The larger M is, the slower these operations are -// but the less overhead (slightly). -// -// To store the sparse array, we store a bitmap B, where B[i] = 1 iff -// bucket i is non-empty. Then to look up bucket i we really look up -// array[# of 1s before i in B]. This is constant time for fixed M. -// -// Terminology: the position of an item in the overall table (from -// 1 .. t) is called its "location." The logical position in a group -// (from 1 .. M ) is called its "position." The actual location in -// the array (from 1 .. # of non-empty buckets in the group) is -// called its "offset." - -// The weird mod in the offset is entirely to quiet compiler warnings -// as is the cast to int after doing the "x mod 256" -#define PUT_(take_from, offset) do { \ - if (putc(static_cast(((take_from) >> ((offset) % (sizeof(take_from)*8)))\ - % 256), fp) \ - == EOF) \ - return false; \ -} while (0) - -#define GET_(add_to, offset) do { \ - if ((x=getc(fp)) == EOF) \ - return false; \ - else \ - add_to |= (static_cast(x) << ((offset) % (sizeof(add_to)*8))); \ -} while (0) - -template -class sparsegroup { - private: - typedef typename Alloc::template rebind::other value_alloc_type; - - public: - // Basic types - typedef T value_type; - typedef Alloc allocator_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::const_reference const_reference; - typedef typename value_alloc_type::pointer pointer; - typedef typename value_alloc_type::const_pointer const_pointer; - - typedef table_iterator > iterator; - typedef const_table_iterator > - const_iterator; - typedef table_element_adaptor > - element_adaptor; - typedef u_int16_t size_type; // max # of buckets - typedef int16_t difference_type; - typedef STL_NAMESPACE::reverse_iterator const_reverse_iterator; - typedef STL_NAMESPACE::reverse_iterator reverse_iterator; - - // These are our special iterators, that go over non-empty buckets in a - // group. These aren't const-only because you can change non-empty bcks. - typedef pointer nonempty_iterator; - typedef const_pointer const_nonempty_iterator; - typedef STL_NAMESPACE::reverse_iterator reverse_nonempty_iterator; - typedef STL_NAMESPACE::reverse_iterator const_reverse_nonempty_iterator; - - // Iterator functions - iterator begin() { return iterator(this, 0); } - const_iterator begin() const { return const_iterator(this, 0); } - iterator end() { return iterator(this, size()); } - const_iterator end() const { return const_iterator(this, size()); } - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - - // We'll have versions for our special non-empty iterator too - nonempty_iterator nonempty_begin() { return group; } - const_nonempty_iterator nonempty_begin() const { return group; } - nonempty_iterator nonempty_end() { - return group + settings.num_buckets; - } - const_nonempty_iterator nonempty_end() const { - return group + settings.num_buckets; - } - reverse_nonempty_iterator nonempty_rbegin() { - return reverse_nonempty_iterator(nonempty_end()); - } - const_reverse_nonempty_iterator nonempty_rbegin() const { - return const_reverse_nonempty_iterator(nonempty_end()); - } - reverse_nonempty_iterator nonempty_rend() { - return reverse_nonempty_iterator(nonempty_begin()); - } - const_reverse_nonempty_iterator nonempty_rend() const { - return const_reverse_nonempty_iterator(nonempty_begin()); - } - - - // This gives us the "default" value to return for an empty bucket. - // We just use the default constructor on T, the template type - const_reference default_value() const { - static value_type defaultval = value_type(); - return defaultval; - } - - - private: - // We need to do all this bit manipulation, of course. ick - static size_type charbit(size_type i) { return i >> 3; } - static size_type modbit(size_type i) { return 1 << (i&7); } - int bmtest(size_type i) const { return bitmap[charbit(i)] & modbit(i); } - void bmset(size_type i) { bitmap[charbit(i)] |= modbit(i); } - void bmclear(size_type i) { bitmap[charbit(i)] &= ~modbit(i); } - - pointer allocate_group(size_type n) { - pointer retval = settings.allocate(n); - if (retval == NULL) { - // We really should use PRIuS here, but I don't want to have to add - // a whole new configure option, with concomitant macro namespace - // pollution, just to print this (unlikely) error message. So I cast. - fprintf(stderr, "sparsehash: FATAL ERROR: " - "failed to allocate %lu groups\n", - static_cast(n)); - exit(1); - } - return retval; - } - - void free_group() { - if (!group) return; - pointer end_it = group + settings.num_buckets; - for (pointer p = group; p != end_it; ++p) - p->~value_type(); - settings.deallocate(group, settings.num_buckets); - group = NULL; - } - - public: // get_iter() in sparsetable needs it - // We need a small function that tells us how many set bits there are - // in positions 0..i-1 of the bitmap. It uses a big table. - // We make it static so templates don't allocate lots of these tables. - // There are lots of ways to do this calculation (called 'popcount'). - // The 8-bit table lookup is one of the fastest, though this - // implementation suffers from not doing any loop unrolling. See, eg, - // http://www.dalkescientific.com/writings/diary/archive/2008/07/03/hakmem_and_other_popcounts.html - // http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ - static size_type pos_to_offset(const unsigned char *bm, size_type pos) { - // We could make these ints. The tradeoff is size (eg does it overwhelm - // the cache?) vs efficiency in referencing sub-word-sized array elements - static const char bits_in[256] = { // # of bits set in one char - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, - }; - size_type retval = 0; - - // [Note: condition pos > 8 is an optimization; convince yourself we - // give exactly the same result as if we had pos >= 8 here instead.] - for ( ; pos > 8; pos -= 8 ) // bm[0..pos/8-1] - retval += bits_in[*bm++]; // chars we want *all* bits in - return retval + bits_in[*bm & ((1 << pos)-1)]; // the char that includes pos - } - - size_type pos_to_offset(size_type pos) const { // not static but still const - return pos_to_offset(bitmap, pos); - } - - - public: - // Constructors -- default and copy -- and destructor - sparsegroup(allocator_type& a) : - group(0), settings(alloc_impl(a)) { - memset(bitmap, 0, sizeof(bitmap)); - } - sparsegroup(const sparsegroup& x) : group(0), settings(x.settings) { - if ( settings.num_buckets ) { - group = allocate_group(x.settings.num_buckets); - uninitialized_copy(x.group, x.group + x.settings.num_buckets, group); - } - memcpy(bitmap, x.bitmap, sizeof(bitmap)); - } - ~sparsegroup() { free_group(); } - - // Operator= is just like the copy constructor, I guess - // TODO(austern): Make this exception safe. Handle exceptions in value_type's - // copy constructor. - sparsegroup &operator=(const sparsegroup& x) { - if ( &x == this ) return *this; // x = x - if ( x.settings.num_buckets == 0 ) { - free_group(); - } else { - pointer p = allocate_group(x.settings.num_buckets); - uninitialized_copy(x.group, x.group + x.settings.num_buckets, p); - free_group(); - group = p; - } - memcpy(bitmap, x.bitmap, sizeof(bitmap)); - settings.num_buckets = x.settings.num_buckets; - return *this; - } - - // Many STL algorithms use swap instead of copy constructors - void swap(sparsegroup& x) { - STL_NAMESPACE::swap(group, x.group); - for ( int i = 0; i < sizeof(bitmap) / sizeof(*bitmap); ++i ) - STL_NAMESPACE::swap(bitmap[i], x.bitmap[i]); // swap not defined on arrays - STL_NAMESPACE::swap(settings.num_buckets, x.settings.num_buckets); - // we purposefully don't swap the allocator, which may not be swap-able - } - - // It's always nice to be able to clear a table without deallocating it - void clear() { - free_group(); - memset(bitmap, 0, sizeof(bitmap)); - settings.num_buckets = 0; - } - - // Functions that tell you about size. Alas, these aren't so useful - // because our table is always fixed size. - size_type size() const { return GROUP_SIZE; } - size_type max_size() const { return GROUP_SIZE; } - bool empty() const { return false; } - // We also may want to know how many *used* buckets there are - size_type num_nonempty() const { return settings.num_buckets; } - - - // get()/set() are explicitly const/non-const. You can use [] if - // you want something that can be either (potentially more expensive). - const_reference get(size_type i) const { - if ( bmtest(i) ) // bucket i is occupied - return group[pos_to_offset(bitmap, i)]; - else - return default_value(); // return the default reference - } - - // TODO(csilvers): make protected + friend - // This is used by sparse_hashtable to get an element from the table - // when we know it exists. - const_reference unsafe_get(size_type i) const { - assert(bmtest(i)); - return group[pos_to_offset(bitmap, i)]; - } - - // TODO(csilvers): make protected + friend - reference mutating_get(size_type i) { // fills bucket i before getting - if ( !bmtest(i) ) - set(i, default_value()); - return group[pos_to_offset(bitmap, i)]; - } - - // Syntactic sugar. It's easy to return a const reference. To - // return a non-const reference, we need to use the assigner adaptor. - const_reference operator[](size_type i) const { - return get(i); - } - - element_adaptor operator[](size_type i) { - return element_adaptor(this, i); - } - - private: - // Create space at group[offset], assuming value_type has trivial - // copy constructor and destructor, and the allocator_type is - // the default libc_allocator_with_alloc. (Really, we want it to have - // "trivial move", because that's what realloc and memmove both do. - // But there's no way to capture that using type_traits, so we - // pretend that move(x, y) is equivalent to "x.~T(); new(x) T(y);" - // which is pretty much correct, if a bit conservative.) - void set_aux(size_type offset, true_type) { - group = settings.realloc_or_die(group, settings.num_buckets+1); - // This is equivalent to memmove(), but faster on my Intel P4, - // at least with gcc4.1 -O2 / glibc 2.3.6. - for (size_type i = settings.num_buckets; i > offset; --i) - memcpy(group + i, group + i-1, sizeof(*group)); - } - - // Create space at group[offset], without special assumptions about value_type - // and allocator_type. - void set_aux(size_type offset, false_type) { - // This is valid because 0 <= offset <= num_buckets - pointer p = allocate_group(settings.num_buckets + 1); - uninitialized_copy(group, group + offset, p); - uninitialized_copy(group + offset, group + settings.num_buckets, - p + offset + 1); - free_group(); - group = p; - } - - public: - // This returns a reference to the inserted item (which is a copy of val). - // TODO(austern): Make this exception safe: handle exceptions from - // value_type's copy constructor. - reference set(size_type i, const_reference val) { - size_type offset = pos_to_offset(bitmap, i); // where we'll find (or insert) - if ( bmtest(i) ) { - // Delete the old value, which we're replacing with the new one - group[offset].~value_type(); - } else { - typedef integral_constant::value && - has_trivial_destructor::value && - is_same >::value)> - realloc_and_memmove_ok; // we pretend mv(x,y) == "x.~T(); new(x) T(y)" - set_aux(offset, realloc_and_memmove_ok()); - ++settings.num_buckets; - bmset(i); - } - // This does the actual inserting. Since we made the array using - // malloc, we use "placement new" to just call the constructor. - new(&group[offset]) value_type(val); - return group[offset]; - } - - // We let you see if a bucket is non-empty without retrieving it - bool test(size_type i) const { - return bmtest(i) != 0; - } - bool test(iterator pos) const { - return bmtest(pos.pos) != 0; - } - - private: - // Shrink the array, assuming value_type has trivial copy - // constructor and destructor, and the allocator_type is the default - // libc_allocator_with_alloc. (Really, we want it to have "trivial - // move", because that's what realloc and memmove both do. But - // there's no way to capture that using type_traits, so we pretend - // that move(x, y) is equivalent to ""x.~T(); new(x) T(y);" - // which is pretty much correct, if a bit conservative.) - void erase_aux(size_type offset, true_type) { - // This isn't technically necessary, since we know we have a - // trivial destructor, but is a cheap way to get a bit more safety. - group[offset].~value_type(); - // This is equivalent to memmove(), but faster on my Intel P4, - // at lesat with gcc4.1 -O2 / glibc 2.3.6. - assert(settings.num_buckets > 0); - for (size_type i = offset; i < settings.num_buckets-1; ++i) - memcpy(group + i, group + i+1, sizeof(*group)); // hopefully inlined! - group = settings.realloc_or_die(group, settings.num_buckets-1); - } - - // Shrink the array, without any special assumptions about value_type and - // allocator_type. - void erase_aux(size_type offset, false_type) { - // This is valid because 0 <= offset < num_buckets. Note the inequality. - pointer p = allocate_group(settings.num_buckets - 1); - uninitialized_copy(group, group + offset, p); - uninitialized_copy(group + offset + 1, group + settings.num_buckets, - p + offset); - free_group(); - group = p; - } - - public: - // This takes the specified elements out of the group. This is - // "undefining", rather than "clearing". - // TODO(austern): Make this exception safe: handle exceptions from - // value_type's copy constructor. - void erase(size_type i) { - if ( bmtest(i) ) { // trivial to erase empty bucket - size_type offset = pos_to_offset(bitmap,i); // where we'll find (or insert) - if ( settings.num_buckets == 1 ) { - free_group(); - group = NULL; - } else { - typedef integral_constant::value && - has_trivial_destructor::value && - is_same< - allocator_type, - libc_allocator_with_realloc >::value)> - realloc_and_memmove_ok; // pretend mv(x,y) == "x.~T(); new(x) T(y)" - erase_aux(offset, realloc_and_memmove_ok()); - } - --settings.num_buckets; - bmclear(i); - } - } - - void erase(iterator pos) { - erase(pos.pos); - } - - void erase(iterator start_it, iterator end_it) { - // This could be more efficient, but to do so we'd need to make - // bmclear() clear a range of indices. Doesn't seem worth it. - for ( ; start_it != end_it; ++start_it ) - erase(start_it); - } - - - // I/O - // We support reading and writing groups to disk. We don't store - // the actual array contents (which we don't know how to store), - // just the bitmap and size. Meant to be used with table I/O. - // Returns true if all was ok - bool write_metadata(FILE *fp) const { - // we explicitly set to u_int16_t - assert(sizeof(settings.num_buckets) == 2); - PUT_(settings.num_buckets, 8); - PUT_(settings.num_buckets, 0); - if ( !fwrite(bitmap, sizeof(bitmap), 1, fp) ) - return false; - return true; - } - - // Reading destroys the old group contents! Returns true if all was ok - bool read_metadata(FILE *fp) { - clear(); - - int x; // the GET_ macro requires an 'int x' to be defined - GET_(settings.num_buckets, 8); - GET_(settings.num_buckets, 0); - - if ( !fread(bitmap, sizeof(bitmap), 1, fp) ) return false; - - // We'll allocate the space, but we won't fill it: it will be - // left as uninitialized raw memory. - group = allocate_group(settings.num_buckets); - return true; - } - - // If your keys and values are simple enough, we can write them - // to disk for you. "simple enough" means POD and no pointers. - // However, we don't try to normalize endianness - bool write_nopointer_data(FILE *fp) const { - for ( const_nonempty_iterator it = nonempty_begin(); - it != nonempty_end(); ++it ) { - if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false; - } - return true; - } - - // When reading, we have to override the potential const-ness of *it. - // Again, only meaningful if value_type is a POD. - bool read_nopointer_data(FILE *fp) { - for ( nonempty_iterator it = nonempty_begin(); - it != nonempty_end(); ++it ) { - if ( !fread(reinterpret_cast(&(*it)), sizeof(*it), 1, fp) ) - return false; - } - return true; - } - - // Comparisons. Note the comparisons are pretty arbitrary: we - // compare values of the first index that isn't equal (using default - // value for empty buckets). - bool operator==(const sparsegroup& x) const { - return ( settings.num_buckets == x.settings.num_buckets && - memcmp(bitmap, x.bitmap, sizeof(bitmap)) == 0 && - STL_NAMESPACE::equal(begin(), end(), x.begin()) ); // from algorithm - } - bool operator<(const sparsegroup& x) const { // also from algorithm - return STL_NAMESPACE::lexicographical_compare(begin(), end(), - x.begin(), x.end()); - } - bool operator!=(const sparsegroup& x) const { return !(*this == x); } - bool operator<=(const sparsegroup& x) const { return !(x < *this); } - bool operator>(const sparsegroup& x) const { return x < *this; } - bool operator>=(const sparsegroup& x) const { return !(*this < x); } - - private: - template - class alloc_impl : public A { - public: - typedef typename A::pointer pointer; - typedef typename A::size_type size_type; - - // Convert a normal allocator to one that has realloc_or_die() - alloc_impl(const A& a) : A(a) { } - - // realloc_or_die should only be used when using the default - // allocator (libc_allocator_with_realloc). - pointer realloc_or_die(pointer /*ptr*/, size_type /*n*/) { - fprintf(stderr, "realloc_or_die is only supported for " - "libc_allocator_with_realloc"); - exit(1); - return NULL; - } - }; - - // A template specialization of alloc_impl for - // libc_allocator_with_realloc that can handle realloc_or_die. - template - class alloc_impl > - : public libc_allocator_with_realloc { - public: - typedef typename libc_allocator_with_realloc::pointer pointer; - typedef typename libc_allocator_with_realloc::size_type size_type; - - alloc_impl(const libc_allocator_with_realloc& a) - : libc_allocator_with_realloc(a) { } - - pointer realloc_or_die(pointer ptr, size_type n) { - pointer retval = this->reallocate(ptr, n); - if (retval == NULL) { - // We really should use PRIuS here, but I don't want to have to add - // a whole new configure option, with concomitant macro namespace - // pollution, just to print this (unlikely) error message. So I cast. - fprintf(stderr, "sparsehash: FATAL ERROR: failed to reallocate " - "%lu elements for ptr %p", - static_cast(n), ptr); - exit(1); - } - return retval; - } - }; - - // Package allocator with num_buckets to eliminate memory needed for the - // zero-size allocator. - // If new fields are added to this class, we should add them to - // operator= and swap. - class Settings : public alloc_impl { - public: - Settings(const alloc_impl& a, u_int16_t n = 0) - : alloc_impl(a), num_buckets(n) { } - Settings(const Settings& s) - : alloc_impl(s), num_buckets(s.num_buckets) { } - - u_int16_t num_buckets; // limits GROUP_SIZE to 64K - }; - - // The actual data - pointer group; // (small) array of T's - Settings settings; // allocator and num_buckets - unsigned char bitmap[(GROUP_SIZE-1)/8 + 1]; // fancy math is so we round up -}; - -// We need a global swap as well -template -inline void swap(sparsegroup &x, - sparsegroup &y) { - x.swap(y); -} - -// --------------------------------------------------------------------------- - - -template > -class sparsetable { - private: - typedef typename Alloc::template rebind::other value_alloc_type; - typedef typename Alloc::template rebind< - sparsegroup >::other vector_alloc; - - public: - // Basic types - typedef T value_type; // stolen from stl_vector.h - typedef Alloc allocator_type; - typedef typename value_alloc_type::size_type size_type; - typedef typename value_alloc_type::difference_type difference_type; - typedef typename value_alloc_type::reference reference; - typedef typename value_alloc_type::const_reference const_reference; - typedef typename value_alloc_type::pointer pointer; - typedef typename value_alloc_type::const_pointer const_pointer; - typedef table_iterator > iterator; - typedef const_table_iterator > - const_iterator; - typedef table_element_adaptor > - element_adaptor; - typedef STL_NAMESPACE::reverse_iterator const_reverse_iterator; - typedef STL_NAMESPACE::reverse_iterator reverse_iterator; - - // These are our special iterators, that go over non-empty buckets in a - // table. These aren't const only because you can change non-empty bcks. - typedef two_d_iterator< vector< sparsegroup, - vector_alloc> > - nonempty_iterator; - typedef const_two_d_iterator< vector< sparsegroup, - vector_alloc> > - const_nonempty_iterator; - typedef STL_NAMESPACE::reverse_iterator reverse_nonempty_iterator; - typedef STL_NAMESPACE::reverse_iterator const_reverse_nonempty_iterator; - // Another special iterator: it frees memory as it iterates (used to resize) - typedef destructive_two_d_iterator< vector< sparsegroup, - vector_alloc> > - destructive_iterator; - - // Iterator functions - iterator begin() { return iterator(this, 0); } - const_iterator begin() const { return const_iterator(this, 0); } - iterator end() { return iterator(this, size()); } - const_iterator end() const { return const_iterator(this, size()); } - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - - // Versions for our special non-empty iterator - nonempty_iterator nonempty_begin() { - return nonempty_iterator(groups.begin(), groups.end(), groups.begin()); - } - const_nonempty_iterator nonempty_begin() const { - return const_nonempty_iterator(groups.begin(),groups.end(), groups.begin()); - } - nonempty_iterator nonempty_end() { - return nonempty_iterator(groups.begin(), groups.end(), groups.end()); - } - const_nonempty_iterator nonempty_end() const { - return const_nonempty_iterator(groups.begin(), groups.end(), groups.end()); - } - reverse_nonempty_iterator nonempty_rbegin() { - return reverse_nonempty_iterator(nonempty_end()); - } - const_reverse_nonempty_iterator nonempty_rbegin() const { - return const_reverse_nonempty_iterator(nonempty_end()); - } - reverse_nonempty_iterator nonempty_rend() { - return reverse_nonempty_iterator(nonempty_begin()); - } - const_reverse_nonempty_iterator nonempty_rend() const { - return const_reverse_nonempty_iterator(nonempty_begin()); - } - destructive_iterator destructive_begin() { - return destructive_iterator(groups.begin(), groups.end(), groups.begin()); - } - destructive_iterator destructive_end() { - return destructive_iterator(groups.begin(), groups.end(), groups.end()); - } - - typedef sparsegroup group_type; - typedef vector group_vector_type; - - typedef typename group_vector_type::reference GroupsReference; - typedef typename group_vector_type::const_reference GroupsConstReference; - typedef typename group_vector_type::iterator GroupsIterator; - typedef typename group_vector_type::const_iterator GroupsConstIterator; - - // How to deal with the proper group - static size_type num_groups(size_type num) { // how many to hold num buckets - return num == 0 ? 0 : ((num-1) / GROUP_SIZE) + 1; - } - - u_int16_t pos_in_group(size_type i) const { - return static_cast(i % GROUP_SIZE); - } - size_type group_num(size_type i) const { - return i / GROUP_SIZE; - } - GroupsReference which_group(size_type i) { - return groups[group_num(i)]; - } - GroupsConstReference which_group(size_type i) const { - return groups[group_num(i)]; - } - - public: - // Constructors -- default, normal (when you specify size), and copy - sparsetable(size_type sz = 0, Alloc alloc = Alloc()) - : groups(vector_alloc(alloc)), settings(alloc, sz) { - groups.resize(num_groups(sz), group_type(settings)); - } - // We can get away with using the default copy constructor, - // and default destructor, and hence the default operator=. Huzzah! - - // Many STL algorithms use swap instead of copy constructors - void swap(sparsetable& x) { - STL_NAMESPACE::swap(groups, x.groups); - STL_NAMESPACE::swap(settings.table_size, x.settings.table_size); - STL_NAMESPACE::swap(settings.num_buckets, x.settings.num_buckets); - } - - // It's always nice to be able to clear a table without deallocating it - void clear() { - GroupsIterator group; - for ( group = groups.begin(); group != groups.end(); ++group ) { - group->clear(); - } - settings.num_buckets = 0; - } - - // ACCESSOR FUNCTIONS for the things we templatize on, basically - allocator_type get_allocator() const { - return allocator_type(settings); - } - - - // Functions that tell you about size. - // NOTE: empty() is non-intuitive! It does not tell you the number - // of not-empty buckets (use num_nonempty() for that). Instead - // it says whether you've allocated any buckets or not. - size_type size() const { return settings.table_size; } - size_type max_size() const { return settings.max_size(); } - bool empty() const { return settings.table_size == 0; } - // We also may want to know how many *used* buckets there are - size_type num_nonempty() const { return settings.num_buckets; } - - // OK, we'll let you resize one of these puppies - void resize(size_type new_size) { - groups.resize(num_groups(new_size), group_type(settings)); - if ( new_size < settings.table_size) { - // lower num_buckets, clear last group - if ( pos_in_group(new_size) > 0 ) // need to clear inside last group - groups.back().erase(groups.back().begin() + pos_in_group(new_size), - groups.back().end()); - settings.num_buckets = 0; // refigure # of used buckets - GroupsConstIterator group; - for ( group = groups.begin(); group != groups.end(); ++group ) - settings.num_buckets += group->num_nonempty(); - } - settings.table_size = new_size; - } - - - // We let you see if a bucket is non-empty without retrieving it - bool test(size_type i) const { - return which_group(i).test(pos_in_group(i)); - } - bool test(iterator pos) const { - return which_group(pos.pos).test(pos_in_group(pos.pos)); - } - bool test(const_iterator pos) const { - return which_group(pos.pos).test(pos_in_group(pos.pos)); - } - - // We only return const_references because it's really hard to - // return something settable for empty buckets. Use set() instead. - const_reference get(size_type i) const { - assert(i < settings.table_size); - return which_group(i).get(pos_in_group(i)); - } - - // TODO(csilvers): make protected + friend - // This is used by sparse_hashtable to get an element from the table - // when we know it exists (because the caller has called test(i)). - const_reference unsafe_get(size_type i) const { - assert(i < settings.table_size); - assert(test(i)); - return which_group(i).unsafe_get(pos_in_group(i)); - } - - // TODO(csilvers): make protected + friend element_adaptor - reference mutating_get(size_type i) { // fills bucket i before getting - assert(i < settings.table_size); - size_type old_numbuckets = which_group(i).num_nonempty(); - reference retval = which_group(i).mutating_get(pos_in_group(i)); - settings.num_buckets += which_group(i).num_nonempty() - old_numbuckets; - return retval; - } - - // Syntactic sugar. As in sparsegroup, the non-const version is harder - const_reference operator[](size_type i) const { - return get(i); - } - - element_adaptor operator[](size_type i) { - return element_adaptor(this, i); - } - - // Needed for hashtables, gets as a nonempty_iterator. Crashes for empty bcks - const_nonempty_iterator get_iter(size_type i) const { - assert(test(i)); // how can a nonempty_iterator point to an empty bucket? - return const_nonempty_iterator( - groups.begin(), groups.end(), - groups.begin() + group_num(i), - (groups[group_num(i)].nonempty_begin() + - groups[group_num(i)].pos_to_offset(pos_in_group(i)))); - } - // For nonempty we can return a non-const version - nonempty_iterator get_iter(size_type i) { - assert(test(i)); // how can a nonempty_iterator point to an empty bucket? - return nonempty_iterator( - groups.begin(), groups.end(), - groups.begin() + group_num(i), - (groups[group_num(i)].nonempty_begin() + - groups[group_num(i)].pos_to_offset(pos_in_group(i)))); - } - - - // This returns a reference to the inserted item (which is a copy of val) - // The trick is to figure out whether we're replacing or inserting anew - reference set(size_type i, const_reference val) { - assert(i < settings.table_size); - size_type old_numbuckets = which_group(i).num_nonempty(); - reference retval = which_group(i).set(pos_in_group(i), val); - settings.num_buckets += which_group(i).num_nonempty() - old_numbuckets; - return retval; - } - - // This takes the specified elements out of the table. This is - // "undefining", rather than "clearing". - void erase(size_type i) { - assert(i < settings.table_size); - size_type old_numbuckets = which_group(i).num_nonempty(); - which_group(i).erase(pos_in_group(i)); - settings.num_buckets += which_group(i).num_nonempty() - old_numbuckets; - } - - void erase(iterator pos) { - erase(pos.pos); - } - - void erase(iterator start_it, iterator end_it) { - // This could be more efficient, but then we'd need to figure - // out if we spanned groups or not. Doesn't seem worth it. - for ( ; start_it != end_it; ++start_it ) - erase(start_it); - } - - - // We support reading and writing tables to disk. We don't store - // the actual array contents (which we don't know how to store), - // just the groups and sizes. Returns true if all went ok. - - private: - // Every time the disk format changes, this should probably change too - static const unsigned long MAGIC_NUMBER = 0x24687531; - - // Old versions of this code write all data in 32 bits. We need to - // support these files as well as having support for 64-bit systems. - // So we use the following encoding scheme: for values < 2^32-1, we - // store in 4 bytes in big-endian order. For values > 2^32, we - // store 0xFFFFFFF followed by 8 bytes in big-endian order. This - // causes us to mis-read old-version code that stores exactly - // 0xFFFFFFF, but I don't think that is likely to have happened for - // these particular values. - static bool write_32_or_64(FILE* fp, size_type value) { - if ( value < 0xFFFFFFFFULL ) { // fits in 4 bytes - PUT_(value, 24); - PUT_(value, 16); - PUT_(value, 8); - PUT_(value, 0); - } else if ( value == 0xFFFFFFFFUL ) { // special case in 32bit systems - PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); // marker - PUT_(0, 0); PUT_(0, 0); PUT_(0, 0); PUT_(0, 0); - PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); - } else { - PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); PUT_(0xFF, 0); // marker - PUT_(value, 56); - PUT_(value, 48); - PUT_(value, 40); - PUT_(value, 32); - PUT_(value, 24); - PUT_(value, 16); - PUT_(value, 8); - PUT_(value, 0); - } - return true; - } - - static bool read_32_or_64(FILE* fp, size_type *value) { // reads into value - size_type first4 = 0; - int x; - GET_(first4, 24); - GET_(first4, 16); - GET_(first4, 8); - GET_(first4, 0); - if ( first4 < 0xFFFFFFFFULL ) { - *value = first4; - } else { - GET_(*value, 56); - GET_(*value, 48); - GET_(*value, 40); - GET_(*value, 32); - GET_(*value, 24); - GET_(*value, 16); - GET_(*value, 8); - GET_(*value, 0); - } - return true; - } - - public: - bool write_metadata(FILE *fp) const { - if ( !write_32_or_64(fp, MAGIC_NUMBER) ) return false; - if ( !write_32_or_64(fp, settings.table_size) ) return false; - if ( !write_32_or_64(fp, settings.num_buckets) ) return false; - - GroupsConstIterator group; - for ( group = groups.begin(); group != groups.end(); ++group ) - if ( group->write_metadata(fp) == false ) return false; - return true; - } - - // Reading destroys the old table contents! Returns true if read ok. - bool read_metadata(FILE *fp) { - size_type magic_read = 0; - if ( !read_32_or_64(fp, &magic_read) ) return false; - if ( magic_read != MAGIC_NUMBER ) { - clear(); // just to be consistent - return false; - } - - if ( !read_32_or_64(fp, &settings.table_size) ) return false; - if ( !read_32_or_64(fp, &settings.num_buckets) ) return false; - - resize(settings.table_size); // so the vector's sized ok - GroupsIterator group; - for ( group = groups.begin(); group != groups.end(); ++group ) - if ( group->read_metadata(fp) == false ) return false; - return true; - } - - // This code is identical to that for SparseGroup - // If your keys and values are simple enough, we can write them - // to disk for you. "simple enough" means no pointers. - // However, we don't try to normalize endianness - bool write_nopointer_data(FILE *fp) const { - for ( const_nonempty_iterator it = nonempty_begin(); - it != nonempty_end(); ++it ) { - if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false; - } - return true; - } - - // When reading, we have to override the potential const-ness of *it - bool read_nopointer_data(FILE *fp) { - for ( nonempty_iterator it = nonempty_begin(); - it != nonempty_end(); ++it ) { - if ( !fread(reinterpret_cast(&(*it)), sizeof(*it), 1, fp) ) - return false; - } - return true; - } - - // Comparisons. Note the comparisons are pretty arbitrary: we - // compare values of the first index that isn't equal (using default - // value for empty buckets). - bool operator==(const sparsetable& x) const { - return ( settings.table_size == x.settings.table_size && - settings.num_buckets == x.settings.num_buckets && - groups == x.groups ); - } - bool operator<(const sparsetable& x) const { // also from algobase.h - return STL_NAMESPACE::lexicographical_compare(begin(), end(), - x.begin(), x.end()); - } - bool operator!=(const sparsetable& x) const { return !(*this == x); } - bool operator<=(const sparsetable& x) const { return !(x < *this); } - bool operator>(const sparsetable& x) const { return x < *this; } - bool operator>=(const sparsetable& x) const { return !(*this < x); } - - - private: - // Package allocator with table_size and num_buckets to eliminate memory - // needed for the zero-size allocator. - // If new fields are added to this class, we should add them to - // operator= and swap. - class Settings : public allocator_type { - public: - typedef typename allocator_type::size_type size_type; - - Settings(const allocator_type& a, size_type sz = 0, size_type n = 0) - : allocator_type(a), table_size(sz), num_buckets(n) { } - - Settings(const Settings& s) - : allocator_type(s), - table_size(s.table_size), num_buckets(s.num_buckets) { } - - size_type table_size; // how many buckets they want - size_type num_buckets; // number of non-empty buckets - }; - - // The actual data - group_vector_type groups; // our list of groups - Settings settings; // allocator, table size, buckets -}; - -// We need a global swap as well -template -inline void swap(sparsetable &x, - sparsetable &y) { - x.swap(y); -} - -#undef GET_ -#undef PUT_ - -_END_GOOGLE_NAMESPACE_ - -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/string_case_compare.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/string_case_compare.hpp deleted file mode 100644 index 37ee8d4e7f7d..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/string_case_compare.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#ifndef stk_util_string_case_compare_hpp -#define stk_util_string_case_compare_hpp - -#include -#include -#include - -namespace stk_classic { - -/** \addtogroup util_module - * \{ - */ - -//---------------------------------------------------------------------- - -/** \brief Case-insensitive equality compare */ -inline -bool equal_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) == 0 ; } - -/** \brief Case-insensitive inequality compare */ -inline -bool not_equal_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) != 0 ; } - -/** \brief Case-insensitive less-than compare */ -inline -bool less_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) < 0 ; } - -/** \brief Case-insensitive less-than-or-equal-to compare */ -inline -bool less_equal_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) <= 0 ; } - -/** \brief Case-insensitive greater-than compare */ -inline -bool greater_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) > 0 ; } - -/** \brief Case-insensitive greater-than-or-equal-to compare */ -inline -bool greater_equal_case( const char * lhs , const char * rhs ) -{ return strcasecmp( lhs , rhs ) >= 0 ; } - -//---------------------------------------------------------------------- - -/** \brief Case-insensitive equality compare */ -inline -bool equal_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) == 0 ; } - -/** \brief Case-insensitive inequality compare */ -inline -bool not_equal_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) != 0 ; } - -/** \brief Case-insensitive less-than compare */ -inline -bool less_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) < 0 ; } - -/** \brief Case-insensitive less-than-or-equal-to compare */ -inline -bool less_equal_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) <= 0 ; } - -/** \brief Case-insensitive greater-than compare */ -inline -bool greater_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) > 0 ; } - -/** \brief Case-insensitive greater-than-or-equal-to compare */ -inline -bool greater_equal_case( const std::string & lhs , const std::string & rhs ) -{ return strcasecmp( lhs.c_str() , rhs.c_str() ) >= 0 ; } - -//---------------------------------------------------------------------- - -/** \brief Case-insensitive equality compare binary function object. */ -struct EqualCase : public std::binary_function { - /** \brief Case-insensitive equality compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return equal_case( lhs , rhs ); } -}; - -/** \brief Case-insensitive inequality compare binary function object. */ -struct NotEqualCase : public std::binary_function { - /** \brief Case-insensitive inequality compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return not_equal_case( lhs , rhs ); } -}; - -/** \brief Case-insensitive less-than compare binary function object. */ -struct LessCase : public std::binary_function { - /** \brief Case-insensitive less-than compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return less_case( lhs , rhs ); } -}; - -/** \brief Case-insensitive less-than-or-equal-to compare binary function object. */ -struct LessEqualCase : public std::binary_function { - /** \brief Case-insensitive less-than-or-equal-to compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return less_equal_case( lhs , rhs ); } -}; - -/** \brief Case-insensitive greater-than compare binary function object. */ -struct GreaterCase : public std::binary_function { - /** \brief Case-insensitive greater-than compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return greater_case( lhs , rhs ); } -}; - -/** \brief Case-insensitive greater-than-or-equal-to compare binary function object. */ -struct GreaterEqualCase : public std::binary_function { - /** \brief Case-insensitive greater-than-or-equal-to compare binary function object. */ - bool operator()( const std::string & lhs , const std::string & rhs ) const - { return greater_equal_case( lhs , rhs ); } -}; - -//---------------------------------------------------------------------- - -/** \} */ - -} // namespace stk_classic - -#endif /* stk_util_string_case_compare_hpp */ - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.cpp deleted file mode 100644 index 89678497e619..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "tokenize.hpp" - -void stk_classic::util::tokenize(const std::string& str, const std::string& separators, - std::vector& tokens) -{ - std::string curr_token = ""; - for (size_t i = 0; i < str.length(); ++i) { - char curr_char = str[i]; - - // determine if current character is a separator - bool is_separator = false; - for (size_t j = 0; j < separators.length(); ++j) { - if (curr_char == separators[j]) { - is_separator = true; - break; - } - } - - if (is_separator && curr_token != "") { - // we just completed a token - tokens.push_back(curr_token); - curr_token.clear(); - } - else if (!is_separator) { - curr_token += curr_char; - } - } - if (curr_token != "") { - tokens.push_back(curr_token); - } -} diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.hpp deleted file mode 100644 index d1d7e086bcb2..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/tokenize.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef STK_UTIL_UTIL_TOKENIZE_H -#define STK_UTIL_UTIL_TOKENIZE_H - -#include -#include - -namespace stk_classic { -namespace util { - -/** - * Take the 'str' argument and split it using the list of characters - * in separators as separators. Use tokens to return the result. - */ -void tokenize(const std::string& str, const std::string& separators, - std::vector& tokens); - -} -} - -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/type_traits_google.h b/packages/stk/stk_classic/stk_util/stk_util/util/type_traits_google.h deleted file mode 100644 index b9364952f592..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/type_traits_google.h +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright (c) 2006, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: Matt Austern -// -// Define a small subset of tr1 type traits. The traits we define are: -// is_integral -// is_floating_point -// is_pointer -// is_enum -// is_reference -// is_pod -// has_trivial_constructor -// has_trivial_copy -// has_trivial_assign -// has_trivial_destructor -// remove_const -// remove_volatile -// remove_cv -// remove_reference -// add_reference -// remove_pointer -// is_same -// is_convertible -// We can add more type traits as required. - -#ifndef BASE_TYPE_TRAITS_H_ -#define BASE_TYPE_TRAITS_H_ - -#include -#include // For pair - -_START_GOOGLE_NAMESPACE_ - -// integral_constant, defined in tr1, is a wrapper for an integer -// value. We don't really need this generality; we could get away -// with hardcoding the integer type to bool. We use the fully -// general integer_constant for compatibility with tr1. - -template -struct integral_constant { - static const T value = v; - typedef T value_type; - typedef integral_constant type; -}; - -template const T integral_constant::value; - -// Abbreviations: true_type and false_type are structs that represent -// boolean true and false values. -typedef integral_constant true_type; -typedef integral_constant false_type; - -// Types small_ and big_ are guaranteed such that sizeof(small_) < -// sizeof(big_) -typedef char small_; - -struct big_ { - char dummy[2]; -}; - -template struct is_integral; -template struct is_floating_point; -template struct is_pointer; -// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least) -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -// is_enum uses is_convertible, which is not available on MSVC. -template struct is_enum; -#endif -template struct is_reference; -template struct is_pod; -template struct has_trivial_constructor; -template struct has_trivial_copy; -template struct has_trivial_assign; -template struct has_trivial_destructor; -template struct remove_const; -template struct remove_volatile; -template struct remove_cv; -template struct remove_reference; -template struct add_reference; -template struct remove_pointer; -template struct is_same; -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -template struct is_convertible; -#endif - -// is_integral is false except for the built-in integer types. -template struct is_integral : false_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#if defined(_MSC_VER) -// wchar_t is not by default a distinct type from unsigned short in -// Microsoft C. -// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx -template<> struct is_integral<__wchar_t> : true_type { }; -#else -template<> struct is_integral : true_type { }; -#endif -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#ifdef HAVE_LONG_LONG -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#endif - - -// is_floating_point is false except for the built-in floating-point types. -template struct is_floating_point : false_type { }; -template<> struct is_floating_point : true_type { }; -template<> struct is_floating_point : true_type { }; -template<> struct is_floating_point : true_type { }; - - -// is_pointer is false except for pointer types. -template struct is_pointer : false_type { }; -template struct is_pointer : true_type { }; - -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - -namespace internal { - -template struct is_class_or_union { - template static small_ tester(void (U::*)()); - template static big_ tester(...); - static const bool value = sizeof(tester(0)) == sizeof(small_); -}; - -// is_convertible chokes if the first argument is an array. That's why -// we use add_reference here. -template struct is_enum_impl - : is_convertible::type, int> { }; - -template struct is_enum_impl : false_type { }; - -} // namespace internal - -// Specified by TR1 [4.5.1] primary type categories. - -// Implementation note: -// -// Each type is either void, integral, floating point, array, pointer, -// reference, member object pointer, member function pointer, enum, -// union or class. Out of these, only integral, floating point, reference, -// class and enum types are potentially convertible to int. Therefore, -// if a type is not a reference, integral, floating point or class and -// is convertible to int, it's a enum. -// -// Is-convertible-to-int check is done only if all other checks pass, -// because it can't be used with some types (e.g. void or classes with -// inaccessible conversion operators). -template struct is_enum - : internal::is_enum_impl< - is_same::value || - is_integral::value || - is_floating_point::value || - is_reference::value || - internal::is_class_or_union::value, - T> { }; - -template struct is_enum : is_enum { }; -template struct is_enum : is_enum { }; -template struct is_enum : is_enum { }; - -#endif - -// is_reference is false except for reference types. -template struct is_reference : false_type {}; -template struct is_reference : true_type {}; - - -// We can't get is_pod right without compiler help, so fail conservatively. -// We will assume it's false except for arithmetic types, enumerations, -// pointers and const versions thereof. Note that std::pair is not a POD. -template struct is_pod - : integral_constant::value || - is_floating_point::value || -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - // is_enum is not available on MSVC. - is_enum::value || -#endif - is_pointer::value)> { }; -template struct is_pod : is_pod { }; - - -// We can't get has_trivial_constructor right without compiler help, so -// fail conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial -// constructors. (3) array of a type with a trivial constructor. -// (4) const versions thereof. -template struct has_trivial_constructor : is_pod { }; -template struct has_trivial_constructor > - : integral_constant::value && - has_trivial_constructor::value)> { }; -template struct has_trivial_constructor - : has_trivial_constructor { }; -template struct has_trivial_constructor - : has_trivial_constructor { }; - -// We can't get has_trivial_copy right without compiler help, so fail -// conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial copy -// constructors. (3) array of a type with a trivial copy constructor. -// (4) const versions thereof. -template struct has_trivial_copy : is_pod { }; -template struct has_trivial_copy > - : integral_constant::value && - has_trivial_copy::value)> { }; -template struct has_trivial_copy - : has_trivial_copy { }; -template struct has_trivial_copy : has_trivial_copy { }; - -// We can't get has_trivial_assign right without compiler help, so fail -// conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial copy -// constructors. (3) array of a type with a trivial assign constructor. -template struct has_trivial_assign : is_pod { }; -template struct has_trivial_assign > - : integral_constant::value && - has_trivial_assign::value)> { }; -template struct has_trivial_assign - : has_trivial_assign { }; - -// We can't get has_trivial_destructor right without compiler help, so -// fail conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial -// destructors. (3) array of a type with a trivial destructor. -// (4) const versions thereof. -template struct has_trivial_destructor : is_pod { }; -template struct has_trivial_destructor > - : integral_constant::value && - has_trivial_destructor::value)> { }; -template struct has_trivial_destructor - : has_trivial_destructor { }; -template struct has_trivial_destructor - : has_trivial_destructor { }; - -// Specified by TR1 [4.7.1] -template struct remove_const { typedef T type; }; -template struct remove_const { typedef T type; }; -template struct remove_volatile { typedef T type; }; -template struct remove_volatile { typedef T type; }; -template struct remove_cv { - typedef typename remove_const::type>::type type; -}; - - -// Specified by TR1 [4.7.2] Reference modifications. -template struct remove_reference { typedef T type; }; -template struct remove_reference { typedef T type; }; - -template struct add_reference { typedef T& type; }; -template struct add_reference { typedef T& type; }; - -// Specified by TR1 [4.7.4] Pointer modifications. -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { - typedef T type; }; - -// Specified by TR1 [4.6] Relationships between types -template struct is_same : public false_type { }; -template struct is_same : public true_type { }; - -// Specified by TR1 [4.6] Relationships between types -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -namespace internal { - -// This class is an implementation detail for is_convertible, and you -// don't need to know how it works to use is_convertible. For those -// who care: we declare two different functions, one whose argument is -// of type To and one with a variadic argument list. We give them -// return types of different size, so we can use sizeof to trick the -// compiler into telling us which function it would have chosen if we -// had called it with an argument of type From. See Alexandrescu's -// _Modern C++ Design_ for more details on this sort of trick. - -template -struct ConvertHelper { - static small_ Test(To); - static big_ Test(...); - static From Create(); -}; -} // namespace internal - -// Inherits from true_type if From is convertible to To, false_type otherwise. -template -struct is_convertible - : integral_constant::Test( - internal::ConvertHelper::Create())) - == sizeof(small_)> { -}; -#endif - -_END_GOOGLE_NAMESPACE_ - -#endif // BASE_TYPE_TRAITS_H_ diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_eastl.h deleted file mode 100644 index fffdd59c00e4..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_eastl.h +++ /dev/null @@ -1,2964 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/algorithm.h -// -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file implements some of the primary algorithms from the C++ STL -// algorithm library. These versions are just like that STL versions and so -// are redundant. They are provided solely for the purpose of projects that -// either cannot use standard C++ STL or want algorithms that have guaranteed -// identical behaviour across platforms. -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Definitions -// -// You will notice that we are very particular about the templated typenames -// we use here. You will notice that we follow the C++ standard closely in -// these respects. Each of these typenames have a specific meaning; -// this is why we don't just label templated arguments with just letters -// such as T, U, V, A, B. Here we provide a quick reference for the typenames -// we use. See the C++ standard, section 25-8 for more details. -// -------------------------------------------------------------- -// typename Meaning -// -------------------------------------------------------------- -// T The value type. -// Compare A function which takes two arguments and returns the lesser of the two. -// Predicate A function which takes one argument returns true if the argument meets some criteria. -// BinaryPredicate A function which takes two arguments and returns true if some criteria is met (e.g. they are equal). -// StrickWeakOrdering A BinaryPredicate that compares two objects, returning true if the first precedes the second. Like Compare but has additional requirements. Used for sorting routines. -// Function A function which takes one argument and applies some operation to the target. -// Size A count or size. -// Generator A function which takes no arguments and returns a value (which will usually be assigned to an object). -// UnaryOperation A function which takes one argument and returns a value (which will usually be assigned to second object). -// BinaryOperation A function which takes two arguments and returns a value (which will usually be assigned to a third object). -// InputIterator An input iterator (iterator you read from) which allows reading each element only once and only in a forward direction. -// ForwardIterator An input iterator which is like InputIterator except it can be reset back to the beginning. -// BidirectionalIterator An input iterator which is like ForwardIterator except it can be read in a backward direction as well. -// RandomAccessIterator An input iterator which can be addressed like an array. It is a superset of all other input iterators. -// OutputIterator An output iterator (iterator you write to) which allows writing each element only once in only in a forward direction. -// -// Note that with iterators that a function which takes an InputIterator will -// also work with a ForwardIterator, BidirectionalIterator, or RandomAccessIterator. -// The given iterator type is merely the -minimum- supported functionality the -// iterator must support. -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Optimizations -// -// There are a number of opportunities for opptimizations that we take here -// in this library. The most obvious kinds are those that subsitute memcpy -// in the place of a conventional loop for data types with which this is -// possible. The algorithms here are optimized to a higher level than currently -// available C++ STL algorithms from vendors. This is especially -// so for game programming on console devices, as we do things such as reduce -// branching relative to other STL algorithm implementations. However, the -// proper implementation of these algorithm optimizations is a fairly tricky -// thing. -// -// The various things we look to take advantage of in order to implement -// optimizations include: -// - Taking advantage of random access iterators. -// - Taking advantage of POD (plain old data) data types. -// - Taking advantage of type_traits in general. -// - Reducing branching and taking advantage of likely branch predictions. -// - Taking advantage of issues related to pointer and reference aliasing. -// - Improving cache coherency during memory accesses. -// - Making code more likely to be inlinable by the compiler. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ALGORITHM_H -#define EASTL_ALGORITHM_H - - -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#ifdef __MWERKS__ - #include <../Include/string.h> // Force the compiler to use the std lib header. -#else - #include // memcpy, memcmp, memmove -#endif -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// min/max workaround -// -// MSVC++ has #defines for min/max which collide with the min/max algorithm -// declarations. The following may still not completely resolve some kinds of -// problems with MSVC++ #defines, though it deals with most cases in production -// game code. -// -#if EASTL_NOMINMAX - #ifdef min - #undef min - #endif - #ifdef max - #undef max - #endif -#endif - - - - -namespace eastl -{ - #if EASTL_MINMAX_ENABLED - - /// min - /// - /// Min returns the lesser of its two arguments; it returns the first - /// argument if neither is less than the other. The two arguments are - /// compared with operator <. - /// - /// This min and our other min implementations are defined as returning: - /// b < a ? b : a - /// which for example may in practice result in something different than: - /// b <= a ? b : a - /// in the case where b is different from a (though they compare as equal). - /// We choose the specific ordering here because that's the ordering - /// done by other STL implementations. - /// - template - inline const T& - min(const T& a, const T& b) - { - return b < a ? b : a; - } - #endif // EASTL_MINMAX_ENABLED - - - /// min_alt - /// - /// This is an alternative version of min that avoids any possible - /// collisions with Microsoft #defines of min and max. - /// - /// See min(a, b) for detailed specifications. - /// - template - inline const T& - min_alt(const T& a, const T& b) - { - return b < a ? b : a; - } - - #if EASTL_MINMAX_ENABLED - /// min - /// - /// Min returns the lesser of its two arguments; it returns the first - /// argument if neither is less than the other. The two arguments are - /// compared with the Compare function (or function object), which - /// takes two arguments and returns true if the first is less than - /// the second. - /// - /// See min(a, b) for detailed specifications. - /// - /// Example usage: - /// struct A{ int a; }; - /// struct Struct{ bool operator()(const A& a1, const A& a2){ return a1.a < a2.a; } }; - /// - /// A a1, a2, a3; - /// a3 = min(a1, a2, Struct()); - /// - /// Example usage: - /// struct B{ int b; }; - /// inline bool Function(const B& b1, const B& b2){ return b1.b < b2.b; } - /// - /// B b1, b2, b3; - /// b3 = min(b1, b2, Function); - /// - template - inline const T& - min(const T& a, const T& b, Compare compare) - { - return compare(b, a) ? b : a; - } - - #endif // EASTL_MINMAX_ENABLED - - - /// min_alt - /// - /// This is an alternative version of min that avoids any possible - /// collisions with Microsoft #defines of min and max. - /// - /// See min(a, b) for detailed specifications. - /// - template - inline const T& - min_alt(const T& a, const T& b, Compare compare) - { - return compare(b, a) ? b : a; - } - - - #if EASTL_MINMAX_ENABLED - /// max - /// - /// Max returns the greater of its two arguments; it returns the first - /// argument if neither is greater than the other. The two arguments are - /// compared with operator < (and not operator >). - /// - /// This min and our other min implementations are defined as returning: - /// a < b ? b : a - /// which for example may in practice result in something different than: - /// a <= b ? b : a - /// in the case where b is different from a (though they compare as equal). - /// We choose the specific ordering here because that's the ordering - /// done by other STL implementations. - /// - template - inline const T& - max(const T& a, const T& b) - { - return a < b ? b : a; - } - #endif // EASTL_MINMAX_ENABLED - - - /// max_alt - /// - /// This is an alternative version of max that avoids any possible - /// collisions with Microsoft #defines of min and max. - /// - template - inline const T& - max_alt(const T& a, const T& b) - { - return a < b ? b : a; - } - - #if EASTL_MINMAX_ENABLED - /// max - /// - /// Min returns the lesser of its two arguments; it returns the first - /// argument if neither is less than the other. The two arguments are - /// compared with the Compare function (or function object), which - /// takes two arguments and returns true if the first is less than - /// the second. - /// - template - inline const T& - max(const T& a, const T& b, Compare compare) - { - return compare(a, b) ? b : a; - } - - #endif - - - /// max_alt - /// - /// This is an alternative version of max that avoids any possible - /// collisions with Microsoft #defines of min and max. - /// - template - inline const T& - max_alt(const T& a, const T& b, Compare compare) - { - return compare(a, b) ? b : a; - } - - - - /// min_element - /// - /// min_element finds the smallest element in the range [first, last). - /// It returns the first iterator i in [first, last) such that no other - /// iterator in [first, last) points to a value smaller than *i. - /// The return value is last if and only if [first, last) is an empty range. - /// - /// Returns: The first iterator i in the range [first, last) such that - /// for any iterator j in the range [first, last) the following corresponding - /// condition holds: !(*j < *i). - /// - /// Complexity: Exactly 'max((last - first) - 1, 0)' applications of the - /// corresponding comparisons. - /// - template - ForwardIterator min_element(ForwardIterator first, ForwardIterator last) - { - if(first != last) - { - ForwardIterator currentMin = first; - - while(++first != last) - { - if(*first < *currentMin) - currentMin = first; - } - return currentMin; - } - return first; - } - - - /// min_element - /// - /// min_element finds the smallest element in the range [first, last). - /// It returns the first iterator i in [first, last) such that no other - /// iterator in [first, last) points to a value smaller than *i. - /// The return value is last if and only if [first, last) is an empty range. - /// - /// Returns: The first iterator i in the range [first, last) such that - /// for any iterator j in the range [first, last) the following corresponding - /// conditions hold: compare(*j, *i) == false. - /// - /// Complexity: Exactly 'max((last - first) - 1, 0)' applications of the - /// corresponding comparisons. - /// - template - ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare compare) - { - if(first != last) - { - ForwardIterator currentMin = first; - - while(++first != last) - { - if(compare(*first, *currentMin)) - currentMin = first; - } - return currentMin; - } - return first; - } - - - /// max_element - /// - /// max_element finds the largest element in the range [first, last). - /// It returns the first iterator i in [first, last) such that no other - /// iterator in [first, last) points to a value greater than *i. - /// The return value is last if and only if [first, last) is an empty range. - /// - /// Returns: The first iterator i in the range [first, last) such that - /// for any iterator j in the range [first, last) the following corresponding - /// condition holds: !(*i < *j). - /// - /// Complexity: Exactly 'max((last - first) - 1, 0)' applications of the - /// corresponding comparisons. - /// - template - ForwardIterator max_element(ForwardIterator first, ForwardIterator last) - { - if(first != last) - { - ForwardIterator currentMax = first; - - while(++first != last) - { - if(*currentMax < *first) - currentMax = first; - } - return currentMax; - } - return first; - } - - - /// max_element - /// - /// max_element finds the largest element in the range [first, last). - /// It returns the first iterator i in [first, last) such that no other - /// iterator in [first, last) points to a value greater than *i. - /// The return value is last if and only if [first, last) is an empty range. - /// - /// Returns: The first iterator i in the range [first, last) such that - /// for any iterator j in the range [first, last) the following corresponding - /// condition holds: compare(*i, *j) == false. - /// - /// Complexity: Exactly 'max((last - first) - 1, 0)' applications of the - /// corresponding comparisons. - /// - template - ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare compare) - { - if(first != last) - { - ForwardIterator currentMax = first; - - while(++first != last) - { - if(compare(*currentMax, *first)) - currentMax = first; - } - return currentMax; - } - return first; - } - - - /// median - /// - /// median finds which element of three (a, b, d) is in-between the other two. - /// If two or more elements are equal, the first (e.g. a before b) is chosen. - /// - /// Complexity: Either two or three comparisons will be required, depending - /// on the values. - /// - template - inline const T& median(const T& a, const T& b, const T& c) - { - if(a < b) - { - if(b < c) - return b; - else if(a < c) - return c; - else - return a; - } - else if(a < c) - return a; - else if(b < c) - return c; - return b; - } - - - /// median - /// - /// median finds which element of three (a, b, d) is in-between the other two. - /// If two or more elements are equal, the first (e.g. a before b) is chosen. - /// - /// Complexity: Either two or three comparisons will be required, depending - /// on the values. - /// - template - inline const T& median(const T& a, const T& b, const T& c, Compare compare) - { - if(compare(a, b)) - { - if(compare(b, c)) - return b; - else if(compare(a, c)) - return c; - else - return a; - } - else if(compare(a, c)) - return a; - else if(compare(b, c)) - return c; - return b; - } - - - - /// swap - /// - /// Assigns the contents of a to b and the contents of b to a. - /// A temporary instance of type T is created and destroyed - /// in the process. - /// - /// This function is used by numerous other algorithms, and as - /// such it may in some cases be feasible and useful for the user - /// to implement an override version of this function which is - /// more efficient in some way. - /// - template - inline void swap(T& a, T& b) - { - T temp(a); - a = b; - b = temp; - } - - - - // iter_swap helper functions - // - template - struct iter_swap_impl - { - template - static void iter_swap(ForwardIterator1 a, ForwardIterator2 b) - { - typedef typename eastl::iterator_traits::value_type value_type_a; - - value_type_a temp(*a); - *a = *b; - *b = temp; - } - }; - - template <> - struct iter_swap_impl - { - template - static void iter_swap(ForwardIterator1 a, ForwardIterator2 b) - { - eastl::swap(*a, *b); - } - }; - - /// iter_swap - /// - /// Equivalent to swap(*a, *b), though the user can provide an override to - /// iter_swap that is independent of an override which may exist for swap. - /// - /// We provide a version of iter_swap which uses swap when the swapped types - /// are equal but a manual implementation otherwise. We do this because the - /// C++ standard defect report says that iter_swap(a, b) must be implemented - /// as swap(*a, *b) when possible. - /// - template - inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) - { - typedef typename eastl::iterator_traits::value_type value_type_a; - typedef typename eastl::iterator_traits::value_type value_type_b; - typedef typename eastl::iterator_traits::reference reference_a; - typedef typename eastl::iterator_traits::reference reference_b; - - iter_swap_impl::value, is_same::value, is_same::value >::value >::iter_swap(a, b); - } - - - - /// swap_ranges - /// - /// Swaps each of the elements in the range [first1, last1) with the - /// corresponding element in the range [first2, first2 + (last1 - first1)). - /// - /// Effects: For each nonnegative integer n < (last1 - first1), - /// performs: swap(*(first1 + n), *(first2 + n)). - /// - /// Requires: The two ranges [first1, last1) and [first2, first2 + (last1 - first1)) - /// shall not overlap. - /// - /// Returns: first2 + (last1 - first1). That is, returns the end of the second range. - /// - /// Complexity: Exactly 'last1 - first1' swaps. - /// - template - inline ForwardIterator2 - swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) - { - for(; first1 != last1; ++first1, ++first2) - iter_swap(first1, first2); - return first2; - } - - - - /// adjacent_find - /// - /// Returns: The first iterator i such that both i and i + 1 are in the range - /// [first, last) for which the following corresponding conditions hold: *i == *(i + 1). - /// Returns last if no such iterator is found. - /// - /// Complexity: Exactly 'find(first, last, value) - first' applications of the corresponding predicate. - /// - template - inline ForwardIterator - adjacent_find(ForwardIterator first, ForwardIterator last) - { - if(first != last) - { - ForwardIterator i = first; - - for(++i; i != last; ++i) - { - if(*first == *i) - return first; - first = i; - } - } - return last; - } - - - - /// adjacent_find - /// - /// Returns: The first iterator i such that both i and i + 1 are in the range - /// [first, last) for which the following corresponding conditions hold: predicate(*i, *(i + 1)) != false. - /// Returns last if no such iterator is found. - /// - /// Complexity: Exactly 'find(first, last, value) - first' applications of the corresponding predicate. - /// - template - inline ForwardIterator - adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate predicate) - { - if(first != last) - { - ForwardIterator i = first; - - for(++i; i != last; ++i) - { - if(predicate(*first, *i)) - return first; - first = i; - } - } - return last; - } - - - - - // copy - // - // We implement copy via some helper functions whose purpose is to - // try to use memcpy when possible. We need to use type_traits and - // iterator categories to do this. - // - template - struct copy_impl - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - for(; first != last; ++result, ++first) - *result = *first; - return result; - } - }; - - template <> - struct copy_impl // If we have a trivally copyable random access array, use memcpy - { - template - static T* do_copy(const T* first, const T* last, T* result) - { - // We cannot use memcpy because memcpy requires the entire source and dest ranges to be - // non-overlapping, whereas the copy algorithm requires only that 'result' not be within - // the range from first to last. - return (T*)memmove(result, first, (size_t)((uintptr_t)last - (uintptr_t)first)) + (last - first); - } - }; - - // copy_chooser - // Calls one of the above copy_impl functions. - template - inline OutputIterator - copy_chooser(InputIterator first, InputIterator last, OutputIterator result) - { - typedef typename eastl::iterator_traits::iterator_category IC; - typedef typename eastl::iterator_traits::value_type value_type_input; - typedef typename eastl::iterator_traits::value_type value_type_output; - - const bool bHasTrivialCopy = type_and::value, - is_pointer::value, - is_pointer::value, - is_same::value>::value; - - return eastl::copy_impl::do_copy(first, last, result); - } - - // copy_generic_iterator - // Converts a copy call via a generic_iterator to a copy call via the iterator type the - // generic_iterator holds. We do this because generic_iterator's purpose is to hold - // iterators that are simply pointers, and if we want the functions above to be fast, - // we need them to see the pointers and not an iterator that wraps the pointers as - // does generic_iterator. We are forced into using a templated struct with a templated - // do_copy member function because C++ doesn't allow specializations for standalone functions. - template - struct copy_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return eastl::copy_chooser(first, last, result); - } - }; - - template <> - struct copy_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return eastl::copy_chooser(first.base(), last.base(), result); // first.base(), last.base() will resolve to a pointer (e.g. T*). - } - }; - - template <> - struct copy_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return OutputIterator(eastl::copy_chooser(first, last, result.base())); // Have to convert to OutputIterator because result.base() is a T* - } - }; - - template <> - struct copy_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return OutputIterator(eastl::copy_chooser(first.base(), last.base(), result.base())); // Have to convert to OutputIterator because result.base() is a T* - } - }; - - /// copy - /// - /// Effects: Copies elements in the range [first, last) into the range [result, result + (last - first)) - /// starting from first and proceeding to last. For each nonnegative integer n < (last - first), - /// performs *(result + n) = *(first + n). - /// - /// Returns: result + (last - first). That is, returns the end of the result. Note that this - /// is different from how memcpy works, as memcpy returns the beginning of the result. - /// - /// Requires: result shall not be in the range [first, last). - /// - /// Complexity: Exactly 'last - first' assignments. - /// - /// Note: This function is like memcpy in that the result must not be with the - /// range of (first, last), as would cause memory to be overwritten incorrectly. - /// - template - inline OutputIterator - copy(InputIterator first, InputIterator last, OutputIterator result) - { - //#ifdef __GNUC__ // GCC has template depth problems and this shortcut may need to be enabled. - // return eastl::copy_chooser(first, last, result); - //#else - const bool bInputIsGenericIterator = is_generic_iterator::value; - const bool bOutputIsGenericIterator = is_generic_iterator::value; - return eastl::copy_generic_iterator::do_copy(first, last, result); - //#endif - } - - - - - // copy_backward - // - // We implement copy_backward via some helper functions whose purpose is - // to try to use memcpy when possible. We need to use type_traits and - // iterator categories to do this. - // - template - struct copy_backward_impl - { - template - static BidirectionalIterator2 do_copy(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) - { - while(last != first) - *--result = *--last; - return result; - } - }; - - template <> - struct copy_backward_impl // If we have a trivally copyable random access array, use memcpy - { - template - static T* do_copy(const T* first, const T* last, T* result) - { - return (T*)memmove(result - (last - first), first, (size_t)((uintptr_t)last - (uintptr_t)first)); - } - }; - - // copy_backward_chooser - // Calls one of the above copy_backward_impl functions. - template - inline OutputIterator - copy_backward_chooser(InputIterator first, InputIterator last, OutputIterator result) - { - typedef typename eastl::iterator_traits::iterator_category IC; - typedef typename eastl::iterator_traits::value_type value_type_input; - typedef typename eastl::iterator_traits::value_type value_type_output; - - const bool bHasTrivialCopy = type_and::value, - is_pointer::value, - is_pointer::value, - is_same::value>::value; - - return eastl::copy_backward_impl::do_copy(first, last, result); - } - - // copy_backward_generic_iterator - // Converts a copy call via a generic_iterator to a copy call via the iterator type the - // generic_iterator holds. We do this because generic_iterator's purpose is to hold - // iterators that are simply pointers, and if we want the functions above to be fast, - // we need them to see the pointers and not an iterator that wraps the pointers as - // does generic_iterator. We are forced into using a templated struct with a templated - // do_copy member function because C++ doesn't allow specializations for standalone functions. - template - struct copy_backward_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return eastl::copy_backward_chooser(first, last, result); - } - }; - - template <> - struct copy_backward_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return eastl::copy_backward_chooser(first.base(), last.base(), result); // first.base(), last.base() will resolve to a pointer (e.g. T*). - } - }; - - template <> - struct copy_backward_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return OutputIterator(eastl::copy_backward_chooser(first, last, result.base())); // Have to convert to OutputIterator because result.base() is a T* - } - }; - - template <> - struct copy_backward_generic_iterator - { - template - static OutputIterator do_copy(InputIterator first, InputIterator last, OutputIterator result) - { - return OutputIterator(eastl::copy_backward_chooser(first.base(), last.base(), result.base())); // Have to convert to OutputIterator because result.base() is a T* - } - }; - - /// copy_backward - /// - /// copies memory in the range of [first, last) to the range *ending* with result. - /// - /// Effects: Copies elements in the range [first, last) into the range - /// [result - (last - first), result) starting from last 1 and proceeding to first. - /// For each positive integer n <= (last - first), performs *(result n) = *(last - n). - /// - /// Requires: result shall not be in the range [first, last). - /// - /// Returns: result - (last - first). That is, returns the beginning of the result range. - /// - /// Complexity: Exactly 'last - first' assignments. - /// - template - inline BidirectionalIterator2 - copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) - { - const bool bInputIsGenericIterator = is_generic_iterator::value; - const bool bOutputIsGenericIterator = is_generic_iterator::value; - - return eastl::copy_backward_generic_iterator::do_copy(first, last, result); - } - - - - /// count - /// - /// Counts the number of items in the range of [first, last) which equal the input value. - /// - /// Effects: Returns the number of iterators i in the range [first, last) for which the - /// following corresponding conditions hold: *i == value. - /// - /// Complexity: At most 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of count is count_if and not another variation of count. - /// This is because both versions would have three parameters and there could be ambiguity. - /// - template - inline typename eastl::iterator_traits::difference_type - count(InputIterator first, InputIterator last, const T& value) - { - typename eastl::iterator_traits::difference_type result = 0; - - for(; first != last; ++first) - { - if(*first == value) - ++result; - } - return result; - } - - - /// count_if - /// - /// Counts the number of items in the range of [first, last) which match - /// the input value as defined by the input predicate function. - /// - /// Effects: Returns the number of iterators i in the range [first, last) for which the - /// following corresponding conditions hold: predicate(*i) != false. - /// - /// Complexity: At most 'last - first' applications of the corresponding predicate. - /// - /// Note: The non-predicate version of count_if is count and not another variation of count_if. - /// This is because both versions would have three parameters and there could be ambiguity. - /// - template - inline typename eastl::iterator_traits::difference_type - count_if(InputIterator first, InputIterator last, Predicate predicate) - { - typename eastl::iterator_traits::difference_type result = 0; - - for(; first != last; ++first) - { - if(predicate(*first)) - ++result; - } - return result; - } - - - - // fill - // - // We implement some fill helper functions in order to allow us to optimize it - // where possible. - // - template - struct fill_imp - { - template - static void do_fill(ForwardIterator first, ForwardIterator last, const T& value) - { - // The C++ standard doesn't specify whether we need to create a temporary - // or not, but all std STL implementations are written like what we have here. - for(; first != last; ++first) - *first = value; - } - }; - - template <> - struct fill_imp - { - template - static void do_fill(ForwardIterator first, ForwardIterator last, const T& value) - { - // We create a temp and fill from that because value might alias to the - // destination range and so the compiler would be forced into generating - // less efficient code. - for(const T temp(value); first != last; ++first) - *first = temp; - } - }; - - /// fill - /// - /// fill is like memset in that it assigns a single value repeatedly to a - /// destination range. It allows for any type of iterator (not just an array) - /// and the source value can be any type, not just a byte. - /// Note that the source value (which is a reference) can come from within - /// the destination range. - /// - /// Effects: Assigns value through all the iterators in the range [first, last). - /// - /// Complexity: Exactly 'last - first' assignments. - /// - /// Note: The C++ standard doesn't specify anything about the value parameter - /// coming from within the first-last range. All std STL implementations act - /// as if the standard specifies that value must not come from within this range. - /// - template - inline void fill(ForwardIterator first, ForwardIterator last, const T& value) - { - eastl::fill_imp< is_scalar::value >::do_fill(first, last, value); - - // Possibly better implementation, as it will deal with small PODs as well as scalars: - // bEasyCopy is true if the type has a trivial constructor (e.g. is a POD) and if - // it is small. Thus any built-in type or any small user-defined struct will qualify. - //const bool bEasyCopy = eastl::type_and::value, - // eastl::integral_constant::value; - //eastl::fill_imp::do_fill(first, last, value); - - } - - inline void fill(char* first, char* last, const char& c) // It's debateable whether we should use 'char& c' or 'char c' here. - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - inline void fill(char* first, char* last, const int c) // This is used for cases like 'fill(first, last, 0)'. - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - inline void fill(unsigned char* first, unsigned char* last, const unsigned char& c) - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - inline void fill(unsigned char* first, unsigned char* last, const int c) - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - inline void fill(signed char* first, signed char* last, const signed char& c) - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - inline void fill(signed char* first, signed char* last, const int c) - { - memset(first, (unsigned char)c, (size_t)(last - first)); - } - - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__SNC__) || defined(__ICL) || defined(__PPU__) || defined(__SPU__) // SN = SN compiler, ICL = Intel compiler, PPU == PS3 processor, SPU = PS3 cell processor - inline void fill(bool* first, bool* last, const bool& b) - { - memset(first, (char)b, (size_t)(last - first)); - } - #endif - - - - - // fill_n - // - // We implement some fill helper functions in order to allow us to optimize it - // where possible. - // - template - struct fill_n_imp - { - template - static OutputIterator do_fill(OutputIterator first, Size n, const T& value) - { - for(; n-- > 0; ++first) - *first = value; - return first; - } - }; - - template <> - struct fill_n_imp - { - template - static OutputIterator do_fill(OutputIterator first, Size n, const T& value) - { - // We create a temp and fill from that because value might alias to - // the destination range and so the compiler would be forced into - // generating less efficient code. - for(const T temp = value; n-- > 0; ++first) - *first = temp; - return first; - } - }; - - /// fill_n - /// - /// The fill_n function is very much like memset in that a copies a source value - /// n times into a destination range. The source value may come from within - /// the destination range. - /// - /// Effects: Assigns value through all the iterators in the range [first, first + n). - /// - /// Complexity: Exactly n assignments. - /// - template - OutputIterator fill_n(OutputIterator first, Size n, const T& value) - { - #ifdef _MSC_VER // VC++ up to and including VC8 blow up when you pass a 64 bit scalar to the do_fill function. - return eastl::fill_n_imp< is_scalar::value && (sizeof(T) <= sizeof(uint32_t)) >::do_fill(first, n, value); - #else - return eastl::fill_n_imp< is_scalar::value >::do_fill(first, n, value); - #endif - } - - template - inline char* fill_n(char* first, Size n, const char& c) - { - return (char*)memset(first, (char)c, (size_t)n) + n; - } - - template - inline unsigned char* fill_n(unsigned char* first, Size n, const unsigned char& c) - { - return (unsigned char*)memset(first, (unsigned char)c, (size_t)n) + n; - } - - template - inline signed char* fill_n(signed char* first, Size n, const signed char& c) - { - return (signed char*)memset(first, (signed char)c, n) + (size_t)n; - } - - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__SNC__) || defined(__ICL) || defined(__PPU__) || defined(__SPU__) // SN = SN compiler, ICL = Intel compiler, PU == PS3 processor, SPU = PS3 cell processor - template - inline bool* fill_n(bool* first, Size n, const bool& b) - { - return (bool*)memset(first, (char)b, n) + (size_t)n; - } - #endif - - - - /// find - /// - /// finds the value within the unsorted range of [first, last). - /// - /// Returns: The first iterator i in the range [first, last) for which - /// the following corresponding conditions hold: *i == value. - /// Returns last if no such iterator is found. - /// - /// Complexity: At most 'last - first' applications of the corresponding predicate. - /// This is a linear search and not a binary one. - /// - /// Note: The predicate version of find is find_if and not another variation of find. - /// This is because both versions would have three parameters and there could be ambiguity. - /// - template - inline InputIterator - find(InputIterator first, InputIterator last, const T& value) - { - while((first != last) && !(*first == value)) // Note that we always express value comparisons in terms of < or ==. - ++first; - return first; - } - - - - /// find_if - /// - /// finds the value within the unsorted range of [first, last). - /// - /// Returns: The first iterator i in the range [first, last) for which - /// the following corresponding conditions hold: pred(*i) != false. - /// Returns last if no such iterator is found. - /// If the sequence of elements to search for (i.e. first2 - last2) is empty, - /// the find always fails and last1 will be returned. - /// - /// Complexity: At most 'last - first' applications of the corresponding predicate. - /// - /// Note: The non-predicate version of find_if is find and not another variation of find_if. - /// This is because both versions would have three parameters and there could be ambiguity. - /// - template - inline InputIterator - find_if(InputIterator first, InputIterator last, Predicate predicate) - { - while((first != last) && !predicate(*first)) - ++first; - return first; - } - - - - /// find_first_of - /// - /// find_first_of is similar to find in that it performs linear search through - /// a range of ForwardIterators. The difference is that while find searches - /// for one particular value, find_first_of searches for any of several values. - /// Specifically, find_first_of searches for the first occurrance in the - /// range [first1, last1) of any of the elements in [first2, last2). - /// This function is thus similar to the strpbrk standard C string function. - /// If the sequence of elements to search for (i.e. first2-last2) is empty, - /// the find always fails and last1 will be returned. - /// - /// Effects: Finds an element that matches one of a set of values. - /// - /// Returns: The first iterator i in the range [first1, last1) such that for some - /// integer j in the range [first2, last2) the following conditions hold: *i == *j. - /// Returns last1 if no such iterator is found. - /// - /// Complexity: At most '(last1 - first1) * (last2 - first2)' applications of the - /// corresponding predicate. - /// - template - ForwardIterator1 - find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - for(; first1 != last1; ++first1) - { - for(ForwardIterator2 i = first2; i != last2; ++i) - { - if(*first1 == *i) - return first1; - } - } - return last1; - } - - - /// find_first_of - /// - /// find_first_of is similar to find in that it performs linear search through - /// a range of ForwardIterators. The difference is that while find searches - /// for one particular value, find_first_of searches for any of several values. - /// Specifically, find_first_of searches for the first occurrance in the - /// range [first1, last1) of any of the elements in [first2, last2). - /// This function is thus similar to the strpbrk standard C string function. - /// - /// Effects: Finds an element that matches one of a set of values. - /// - /// Returns: The first iterator i in the range [first1, last1) such that for some - /// integer j in the range [first2, last2) the following conditions hold: pred(*i, *j) != false. - /// Returns last1 if no such iterator is found. - /// - /// Complexity: At most '(last1 - first1) * (last2 - first2)' applications of the - /// corresponding predicate. - /// - template - ForwardIterator1 - find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - for(; first1 != last1; ++first1) - { - for(ForwardIterator2 i = first2; i != last2; ++i) - { - if(predicate(*first1, *i)) - return first1; - } - } - return last1; - } - - - /// find_first_not_of - /// - /// Searches through first range for the first element that does not belong the second input range. - /// This is very much like the C++ string find_first_not_of function. - /// - /// Returns: The first iterator i in the range [first1, last1) such that for some - /// integer j in the range [first2, last2) the following conditions hold: !(*i == *j). - /// Returns last1 if no such iterator is found. - /// - /// Complexity: At most '(last1 - first1) * (last2 - first2)' applications of the - /// corresponding predicate. - /// - template - ForwardIterator1 - find_first_not_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - for(; first1 != last1; ++first1) - { - if(eastl::find(first2, last2, *first1) == last2) - break; - } - - return first1; - } - - - - /// find_first_not_of - /// - /// Searches through first range for the first element that does not belong the second input range. - /// This is very much like the C++ string find_first_not_of function. - /// - /// Returns: The first iterator i in the range [first1, last1) such that for some - /// integer j in the range [first2, last2) the following conditions hold: pred(*i, *j) == false. - /// Returns last1 if no such iterator is found. - /// - /// Complexity: At most '(last1 - first1) * (last2 - first2)' applications of the - /// corresponding predicate. - /// - template - inline ForwardIterator1 - find_first_not_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - typedef typename eastl::iterator_traits::value_type value_type; - - for(; first1 != last1; ++first1) - { - if(eastl::find_if(first2, last2, eastl::bind1st(predicate, *first1)) == last2) - break; - } - - return first1; - } - - - template - inline BidirectionalIterator1 - find_last_of(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - if((first1 != last1) && (first2 != last2)) - { - BidirectionalIterator1 it1(last1); - - while((--it1 != first1) && (eastl::find(first2, last2, *it1) == last2)) - ; // Do nothing - - if((it1 != first1) || (eastl::find(first2, last2, *it1) != last2)) - return it1; - } - - return last1; - } - - - template - BidirectionalIterator1 - find_last_of(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - typedef typename eastl::iterator_traits::value_type value_type; - - if((first1 != last1) && (first2 != last2)) - { - BidirectionalIterator1 it1(last1); - - while((--it1 != first1) && (eastl::find_if(first2, last2, eastl::bind1st(predicate, *it1)) == last2)) - ; // Do nothing - - if((it1 != first1) || (eastl::find_if(first2, last2, eastl::bind1st(predicate, *it1)) != last2)) - return it1; - } - - return last1; - } - - - template - inline BidirectionalIterator1 - find_last_not_of(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - if((first1 != last1) && (first2 != last2)) - { - BidirectionalIterator1 it1(last1); - - while((--it1 != first1) && (eastl::find(first2, last2, *it1) != last2)) - ; // Do nothing - - if((it1 != first1) || (eastl::find( first2, last2, *it1) == last2)) - return it1; - } - - return last1; - } - - - template - inline BidirectionalIterator1 - find_last_not_of(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - typedef typename eastl::iterator_traits::value_type value_type; - - if((first1 != last1) && (first2 != last2)) - { - BidirectionalIterator1 it1(last1); - - while((--it1 != first1) && (eastl::find_if(first2, last2, eastl::bind1st(predicate, *it1)) != last2)) - ; // Do nothing - - if((it1 != first1) || (eastl::find_if(first2, last2, eastl::bind1st(predicate, *it1))) != last2) - return it1; - } - - return last1; - } - - - - - /// for_each - /// - /// Calls the Function function for each value in the range [first, last). - /// Function takes a single parameter: the current value. - /// - /// Effects: Applies function to the result of dereferencing every iterator in - /// the range [first, last), starting from first and proceeding to last 1. - /// - /// Returns: function. - /// - /// Complexity: Applies function exactly 'last - first' times. - /// - /// Note: If function returns a result, the result is ignored. - /// - template - inline Function - for_each(InputIterator first, InputIterator last, Function function) - { - for(; first != last; ++first) - function(*first); - return function; - } - - - /// generate - /// - /// Iterates the range of [first, last) and assigns to each element the - /// result of the function generator. Generator is a function which takes - /// no arguments. - /// - /// Complexity: Exactly 'last - first' invocations of generator and assignments. - /// - template - inline void - generate(ForwardIterator first, ForwardIterator last, Generator generator) - { - for(; first != last; ++first) // We cannot call generate_n(first, last-first, generator) - *first = generator(); // because the 'last-first' might not be supported by the - } // given iterator. - - - /// generate_n - /// - /// Iterates an interator n times and assigns the result of generator - /// to each succeeding element. Generator is a function which takes - /// no arguments. - /// - /// Complexity: Exactly n invocations of generator and assignments. - /// - template - inline OutputIterator - generate_n(OutputIterator first, Size n, Generator generator) - { - for(; n > 0; --n, ++first) - *first = generator(); - return first; - } - - - /// transform - /// - /// Iterates the input range of [first, last) and the output iterator result - /// and assigns the result of unaryOperation(input) to result. - /// - /// Effects: Assigns through every iterator i in the range [result, result + (last1 - first1)) - /// a new corresponding value equal to unaryOperation(*(first1 + (i - result)). - /// - /// Requires: op shall not have any side effects. - /// - /// Returns: result + (last1 - first1). That is, returns the end of the output range. - /// - /// Complexity: Exactly 'last1 - first1' applications of unaryOperation. - /// - /// Note: result may be equal to first. - /// - template - inline OutputIterator - transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation unaryOperation) - { - for(; first != last; ++first, ++result) - *result = unaryOperation(*first); - return result; - } - - - /// transform - /// - /// Iterates the input range of [first, last) and the output iterator result - /// and assigns the result of binaryOperation(input1, input2) to result. - /// - /// Effects: Assigns through every iterator i in the range [result, result + (last1 - first1)) - /// a new corresponding value equal to binaryOperation(*(first1 + (i - result), *(first2 + (i - result))). - /// - /// Requires: binaryOperation shall not have any side effects. - /// - /// Returns: result + (last1 - first1). That is, returns the end of the output range. - /// - /// Complexity: Exactly 'last1 - first1' applications of binaryOperation. - /// - /// Note: result may be equal to first1 or first2. - /// - template - inline OutputIterator - transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation binaryOperation) - { - for(; first1 != last1; ++first1, ++first2, ++result) - *result = binaryOperation(*first1, *first2); - return result; - } - - - /// equal - /// - /// Returns: true if for every iterator i in the range [first1, last1) the - /// following corresponding conditions hold: predicate(*i, *(first2 + (i - first1))) != false. - /// Otherwise, returns false. - /// - /// Complexity: At most last1 first1 applications of the corresponding predicate. - /// - /// To consider: Make specializations of this for scalar types and random access - /// iterators that uses memcmp or some trick memory comparison function. - /// We should verify that such a thing results in an improvement. - /// - template - inline bool - equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) - { - for(; first1 != last1; ++first1, ++first2) - { - if(!(*first1 == *first2)) // Note that we always express value comparisons in terms of < or ==. - return false; - } - return true; - } - - /// equal - /// - /// Returns: true if for every iterator i in the range [first1, last1) the - /// following corresponding conditions hold: pred(*i, *(first2 + (i first1))) != false. - /// Otherwise, returns false. - /// - /// Complexity: At most last1 first1 applications of the corresponding predicate. - /// - template - inline bool - equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate predicate) - { - for(; first1 != last1; ++first1, ++first2) - { - if(!predicate(*first1, *first2)) - return false; - } - return true; - } - - - - /// identical - /// - /// Returns true if the two input ranges are equivalent. - /// There is a subtle difference between this algorithm and - /// the 'equal' algorithm. The equal algorithm assumes the - /// two ranges are of equal length. This algorithm efficiently - /// compares two ranges for both length equality and for - /// element equality. There is no other standard algorithm - /// that can do this. - /// - /// Returns: true if the sequence of elements defined by the range - /// [first1, last1) is of the same length as the sequence of - /// elements defined by the range of [first2, last2) and if - /// the elements in these ranges are equal as per the - /// equal algorithm. - /// - /// Complexity: At most 'min((last1 - first1), (last2 - first2))' applications - /// of the corresponding comparison. - /// - template - bool identical(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2) - { - while((first1 != last1) && (first2 != last2) && (*first1 == *first2)) - { - ++first1; - ++first2; - } - return (first1 == last1) && (first2 == last2); - } - - - /// identical - /// - template - bool identical(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, BinaryPredicate predicate) - { - while((first1 != last1) && (first2 != last2) && predicate(*first1, *first2)) - { - ++first1; - ++first2; - } - return (first1 == last1) && (first2 == last2); - } - - - /// lexicographical_compare - /// - /// Returns: true if the sequence of elements defined by the range - /// [first1, last1) is lexicographically less than the sequence of - /// elements defined by the range [first2, last2). Returns false otherwise. - /// - /// Complexity: At most 'min((last1 - first1), (last2 - first2))' applications - /// of the corresponding comparison. - /// - /// Note: If two sequences have the same number of elements and their - /// corresponding elements are equivalent, then neither sequence is - /// lexicographically less than the other. If one sequence is a prefix - /// of the other, then the shorter sequence is lexicographically less - /// than the longer sequence. Otherwise, the lexicographical comparison - /// of the sequences yields the same result as the comparison of the first - /// corresponding pair of elements that are not equivalent. - /// - template - inline bool - lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2) - { - for(; (first1 != last1) && (first2 != last2); ++first1, ++first2) - { - if(*first1 < *first2) - return true; - if(*first2 < *first1) - return false; - } - return (first1 == last1) && (first2 != last2); - } - - inline bool // Specialization for const char*. - lexicographical_compare(const char* first1, const char* last1, const char* first2, const char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - inline bool // Specialization for char*. - lexicographical_compare(char* first1, char* last1, char* first2, char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - inline bool // Specialization for const unsigned char*. - lexicographical_compare(const unsigned char* first1, const unsigned char* last1, const unsigned char* first2, const unsigned char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - inline bool // Specialization for unsigned char*. - lexicographical_compare(unsigned char* first1, unsigned char* last1, unsigned char* first2, unsigned char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - inline bool // Specialization for const signed char*. - lexicographical_compare(const signed char* first1, const signed char* last1, const signed char* first2, const signed char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - inline bool // Specialization for signed char*. - lexicographical_compare(signed char* first1, signed char* last1, signed char* first2, signed char* last2) - { - const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - return result ? (result < 0) : (n1 < n2); - } - - #if defined(_MSC_VER) // If using the VC++ compiler (and thus bool is known to be a single byte)... - //Not sure if this is a good idea. - //inline bool // Specialization for const bool*. - //lexicographical_compare(const bool* first1, const bool* last1, const bool* first2, const bool* last2) - //{ - // const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - // const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - // return result ? (result < 0) : (n1 < n2); - //} - // - //inline bool // Specialization for bool*. - //lexicographical_compare(bool* first1, bool* last1, bool* first2, bool* last2) - //{ - // const ptrdiff_t n1(last1 - first1), n2(last2 - first2); - // const int result = memcmp(first1, first2, (size_t)eastl::min_alt(n1, n2)); - // return result ? (result < 0) : (n1 < n2); - //} - #endif - - - - /// lexicographical_compare - /// - /// Returns: true if the sequence of elements defined by the range - /// [first1, last1) is lexicographically less than the sequence of - /// elements defined by the range [first2, last2). Returns false otherwise. - /// - /// Complexity: At most 'min((last1 -first1), (last2 - first2))' applications - /// of the corresponding comparison. - /// - /// Note: If two sequences have the same number of elements and their - /// corresponding elements are equivalent, then neither sequence is - /// lexicographically less than the other. If one sequence is a prefix - /// of the other, then the shorter sequence is lexicographically less - /// than the longer sequence. Otherwise, the lexicographical comparison - /// of the sequences yields the same result as the comparison of the first - /// corresponding pair of elements that are not equivalent. - /// - /// Note: False is always returned if range 1 is exhausted before range 2. - /// The result of this is that you can't do a successful reverse compare - /// (e.g. use greater<> as the comparison instead of less<>) unless the - /// two sequences are of identical length. What you want to do is reverse - /// the order of the arguments in order to get the desired effect. - /// - template - inline bool - lexicographical_compare(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, Compare compare) - { - for(; (first1 != last1) && (first2 != last2); ++first1, ++first2) - { - if(compare(*first1, *first2)) - return true; - if(compare(*first2, *first1)) - return false; - } - return (first1 == last1) && (first2 != last2); - } - - - - /// lower_bound - /// - /// Finds the position of the first element in a sorted range that has a value - /// greater than or equivalent to a specified value. - /// - /// Effects: Finds the first position into which value can be inserted without - /// violating the ordering. - /// - /// Returns: The furthermost iterator i in the range [first, last) such that - /// for any iterator j in the range [first, i) the following corresponding - /// condition holds: *j < value. - /// - /// Complexity: At most 'log(last - first) + 1' comparisons. - /// - /// Optimizations: We have no need to specialize this implementation for random - /// access iterators (e.g. contiguous array), as the code below will already - /// take advantage of them. - /// - template - ForwardIterator - lower_bound(ForwardIterator first, ForwardIterator last, const T& value) - { - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType d = eastl::distance(first, last); // This will be efficient for a random access iterator such as an array. - - while(d > 0) - { - ForwardIterator i = first; - DifferenceType d2 = d >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, d2); // This will be efficient for a random access iterator such as an array. - - if(*i < value) - { - // Disabled because std::lower_bound doesn't specify (23.3.3.3, p3) this can be done: EASTL_VALIDATE_COMPARE(!(value < *i)); // Validate that the compare function is sane. - first = ++i; - d -= d2 + 1; - } - else - d = d2; - } - return first; - } - - - /// lower_bound - /// - /// Finds the position of the first element in a sorted range that has a value - /// greater than or equivalent to a specified value. The input Compare function - /// takes two arguments and returns true if the first argument is less than - /// the second argument. - /// - /// Effects: Finds the first position into which value can be inserted without - /// violating the ordering. - /// - /// Returns: The furthermost iterator i in the range [first, last) such that - /// for any iterator j in the range [first, i) the following corresponding - /// condition holds: compare(*j, value) != false. - /// - /// Complexity: At most 'log(last - first) + 1' comparisons. - /// - /// Optimizations: We have no need to specialize this implementation for random - /// access iterators (e.g. contiguous array), as the code below will already - /// take advantage of them. - /// - template - ForwardIterator - lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare compare) - { - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType d = eastl::distance(first, last); // This will be efficient for a random access iterator such as an array. - - while(d > 0) - { - ForwardIterator i = first; - DifferenceType d2 = d >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, d2); // This will be efficient for a random access iterator such as an array. - - if(compare(*i, value)) - { - // Disabled because std::lower_bound doesn't specify (23.3.3.1, p3) this can be done: EASTL_VALIDATE_COMPARE(!compare(value, *i)); // Validate that the compare function is sane. - first = ++i; - d -= d2 + 1; - } - else - d = d2; - } - return first; - } - - - - /// upper_bound - /// - /// Finds the position of the first element in a sorted range that has a - /// value that is greater than a specified value. - /// - /// Effects: Finds the furthermost position into which value can be inserted - /// without violating the ordering. - /// - /// Returns: The furthermost iterator i in the range [first, last) such that - /// for any iterator j in the range [first, i) the following corresponding - /// condition holds: !(value < *j). - /// - /// Complexity: At most 'log(last - first) + 1' comparisons. - /// - template - ForwardIterator - upper_bound(ForwardIterator first, ForwardIterator last, const T& value) - { - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType len = eastl::distance(first, last); - - while(len > 0) - { - ForwardIterator i = first; - DifferenceType len2 = len >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, len2); - - if(!(value < *i)) // Note that we always express value comparisons in terms of < or ==. - { - first = ++i; - len -= len2 + 1; - } - else - { - // Disabled because std::upper_bound doesn't specify (23.3.3.2, p3) this can be done: EASTL_VALIDATE_COMPARE(!(*i < value)); // Validate that the compare function is sane. - len = len2; - } - } - return first; - } - - - /// upper_bound - /// - /// Finds the position of the first element in a sorted range that has a - /// value that is greater than a specified value. The input Compare function - /// takes two arguments and returns true if the first argument is less than - /// the second argument. - /// - /// Effects: Finds the furthermost position into which value can be inserted - /// without violating the ordering. - /// - /// Returns: The furthermost iterator i in the range [first, last) such that - /// for any iterator j in the range [first, i) the following corresponding - /// condition holds: compare(value, *j) == false. - /// - /// Complexity: At most 'log(last - first) + 1' comparisons. - /// - template - ForwardIterator - upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare compare) - { - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType len = eastl::distance(first, last); - - while(len > 0) - { - ForwardIterator i = first; - DifferenceType len2 = len >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, len2); - - if(!compare(value, *i)) - { - first = ++i; - len -= len2 + 1; - } - else - { - // Disabled because std::upper_bound doesn't specify (23.3.3.2, p3) this can be done: EASTL_VALIDATE_COMPARE(!compare(*i, value)); // Validate that the compare function is sane. - len = len2; - } - } - return first; - } - - - /// equal_range - /// - /// Effects: Finds the largest subrange [i, j) such that the value can be inserted - /// at any iterator k in it without violating the ordering. k satisfies the - /// corresponding conditions: !(*k < value) && !(value < *k). - /// - /// Complexity: At most '2 * log(last - first) + 1' comparisons. - /// - template - pair - equal_range(ForwardIterator first, ForwardIterator last, const T& value) - { - typedef pair ResultType; - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType d = eastl::distance(first, last); - - while(d > 0) - { - ForwardIterator i(first); - DifferenceType d2 = d >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, d2); - - if(*i < value) - { - EASTL_VALIDATE_COMPARE(!(value < *i)); // Validate that the compare function is sane. - first = ++i; - d -= d2 + 1; - } - else if(value < *i) - { - EASTL_VALIDATE_COMPARE(!(*i < value)); // Validate that the compare function is sane. - d = d2; - last = i; - } - else - { - ForwardIterator j(i); - - return ResultType(eastl::lower_bound(first, i, value), - eastl::upper_bound(++j, last, value)); - } - } - return ResultType(first, first); - } - - - /// equal_range - /// - /// Effects: Finds the largest subrange [i, j) such that the value can be inserted - /// at any iterator k in it without violating the ordering. k satisfies the - /// corresponding conditions: comp(*k, value) == false && comp(value, *k) == false. - /// - /// Complexity: At most '2 * log(last - first) + 1' comparisons. - /// - template - pair - equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare compare) - { - typedef pair ResultType; - typedef typename eastl::iterator_traits::difference_type DifferenceType; - - DifferenceType d = eastl::distance(first, last); - - while(d > 0) - { - ForwardIterator i(first); - DifferenceType d2 = d >> 1; // We use '>>1' here instead of '/2' because MSVC++ for some reason generates significantly worse code for '/2'. Go figure. - - eastl::advance(i, d2); - - if(compare(*i, value)) - { - EASTL_VALIDATE_COMPARE(!compare(value, *i)); // Validate that the compare function is sane. - first = ++i; - d -= d2 + 1; - } - else if(compare(value, *i)) - { - EASTL_VALIDATE_COMPARE(!compare(*i, value)); // Validate that the compare function is sane. - d = d2; - last = i; - } - else - { - ForwardIterator j(i); - - return ResultType(eastl::lower_bound(first, i, value, compare), - eastl::upper_bound(++j, last, value, compare)); - } - } - return ResultType(first, first); - } - - - /// replace - /// - /// Effects: Substitutes elements referred by the iterator i in the range [first, last) - /// with new_value, when the following corresponding conditions hold: *i == old_value. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of replace is replace_if and not another variation of replace. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - template - inline void - replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value) - { - for(; first != last; ++first) - { - if(*first == old_value) - *first = new_value; - } - } - - - /// replace_if - /// - /// Effects: Substitutes elements referred by the iterator i in the range [first, last) - /// with new_value, when the following corresponding conditions hold: predicate(*i) != false. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of replace_if is replace and not another variation of replace_if. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - template - inline void - replace_if(ForwardIterator first, ForwardIterator last, Predicate predicate, const T& new_value) - { - for(; first != last; ++first) - { - if(predicate(*first)) - *first = new_value; - } - } - - - /// remove_copy - /// - /// Effects: Copies all the elements referred to by the iterator i in the range - /// [first, last) for which the following corresponding condition does not hold: - /// *i == value. - /// - /// Requires: The ranges [first, last) and [result, result + (last - first)) shall not overlap. - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - template - inline OutputIterator - remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value) - { - for(; first != last; ++first) - { - if(!(*first == value)) // Note that we always express value comparisons in terms of < or ==. - { - *result = *first; - ++result; - } - } - return result; - } - - - /// remove_copy_if - /// - /// Effects: Copies all the elements referred to by the iterator i in the range - /// [first, last) for which the following corresponding condition does not hold: - /// predicate(*i) != false. - /// - /// Requires: The ranges [first, last) and [result, result + (last - first)) shall not overlap. - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - template - inline OutputIterator - remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate predicate) - { - for(; first != last; ++first) - { - if(!predicate(*first)) - { - *result = *first; - ++result; - } - } - return result; - } - - - /// remove - /// - /// Effects: Eliminates all the elements referred to by iterator i in the - /// range [first, last) for which the following corresponding condition - /// holds: *i == value. - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of remove is remove_if and not another variation of remove. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - /// Note: Since this function moves the element to the back of the heap and - /// doesn't actually remove it from the given container, the user must call - /// the container erase function if the user wants to erase the element - /// from the container. - /// - /// Example usage: - /// vector intArray; - /// ... - /// intArray.erase(remove(intArray.begin(), intArray.end(), 4), intArray.end()); // Erase all elements of value 4. - /// - template - inline ForwardIterator - remove(ForwardIterator first, ForwardIterator last, const T& value) - { - first = eastl::find(first, last, value); - if(first != last) - { - ForwardIterator i(first); - return eastl::remove_copy(++i, last, first, value); - } - return first; - } - - - /// remove_if - /// - /// Effects: Eliminates all the elements referred to by iterator i in the - /// range [first, last) for which the following corresponding condition - /// holds: predicate(*i) != false. - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of remove_if is remove and not another variation of remove_if. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - /// Note: Since this function moves the element to the back of the heap and - /// doesn't actually remove it from the given container, the user must call - /// the container erase function if the user wants to erase the element - /// from the container. - /// - /// Example usage: - /// vector intArray; - /// ... - /// intArray.erase(remove(intArray.begin(), intArray.end(), bind2nd(less(), (int)3)), intArray.end()); // Erase all elements less than 3. - /// - template - inline ForwardIterator - remove_if(ForwardIterator first, ForwardIterator last, Predicate predicate) - { - first = eastl::find_if(first, last, predicate); - if(first != last) - { - ForwardIterator i(first); - return eastl::remove_copy_if(++i, last, first, predicate); - } - return first; - } - - - /// replace_copy - /// - /// Effects: Assigns to every iterator i in the range [result, result + (last - first)) - /// either new_value or *(first + (i - result)) depending on whether the following - /// corresponding conditions hold: *(first + (i - result)) == old_value. - /// - /// Requires: The ranges [first, last) and [result, result + (last - first)) shall not overlap. - /// - /// Returns: result + (last - first). - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of replace_copy is replace_copy_if and not another variation of replace_copy. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - template - inline OutputIterator - replace_copy(InputIterator first, InputIterator last, OutputIterator result, const T& old_value, const T& new_value) - { - for(; first != last; ++first, ++result) - *result = (*first == old_value) ? new_value : *first; - return result; - } - - - /// replace_copy_if - /// - /// Effects: Assigns to every iterator i in the range [result, result + (last - first)) - /// either new_value or *(first + (i - result)) depending on whether the following - /// corresponding conditions hold: predicate(*(first + (i - result))) != false. - /// - /// Requires: The ranges [first, last) and [result, result+(lastfirst)) shall not overlap. - /// - /// Returns: result + (last - first). - /// - /// Complexity: Exactly 'last - first' applications of the corresponding predicate. - /// - /// Note: The predicate version of replace_copy_if is replace_copy and not another variation of replace_copy_if. - /// This is because both versions would have the same parameter count and there could be ambiguity. - /// - template - inline OutputIterator - replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate predicate, const T& new_value) - { - for(; first != last; ++first, ++result) - *result = predicate(*first) ? new_value : *first; - return result; - } - - - - - // reverse - // - // We provide helper functions which allow reverse to be implemented more - // efficiently for some types of iterators and types. - // - template - inline void reverse_impl(BidirectionalIterator first, BidirectionalIterator last, EASTL_ITC_NS::bidirectional_iterator_tag) - { - for(; (first != last) && (first != --last); ++first) // We are not allowed to use operator <, <=, >, >= with a - eastl::iter_swap(first, last); // generic (bidirectional or otherwise) iterator. - } - - template - inline void reverse_impl(RandomAccessIterator first, RandomAccessIterator last, EASTL_ITC_NS::random_access_iterator_tag) - { - for(; first < --last; ++first) // With a random access iterator, we can use operator < to more efficiently implement - eastl::iter_swap(first, last); // this algorithm. A generic iterator doesn't necessarily have an operator < defined. - } - - /// reverse - /// - /// Reverses the values within the range [first, last). - /// - /// Effects: For each nonnegative integer i <= (last - first) / 2, - /// applies swap to all pairs of iterators first + i, (last i) - 1. - /// - /// Complexity: Exactly '(last - first) / 2' swaps. - /// - template - inline void reverse(BidirectionalIterator first, BidirectionalIterator last) - { - typedef typename eastl::iterator_traits::iterator_category IC; - eastl::reverse_impl(first, last, IC()); - } - - - - /// reverse_copy - /// - /// Copies the range [first, last) in reverse order to the result. - /// - /// Effects: Copies the range [first, last) to the range - /// [result, result + (last - first)) such that for any nonnegative - /// integer i < (last - first) the following assignment takes place: - /// *(result + (last - first) - i) = *(first + i) - /// - /// Requires: The ranges [first, last) and [result, result + (last - first)) - /// shall not overlap. - /// - /// Returns: result + (last - first). That is, returns the end of the output range. - /// - /// Complexity: Exactly 'last - first' assignments. - /// - template - inline OutputIterator - reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result) - { - for(; first != last; ++result) - *result = *--last; - return result; - } - - - - /// search - /// - /// Search finds a subsequence within the range [first1, last1) that is identical to [first2, last2) - /// when compared element-by-element. It returns an iterator pointing to the beginning of that - /// subsequence, or else last1 if no such subsequence exists. As such, it is very much like - /// the C strstr function, with the primary difference being that strstr uses 0-terminated strings - /// whereas search uses an end iterator to specify the end of a string. - /// - /// Returns: The first iterator i in the range [first1, last1 - (last2 - first2)) such that for - /// any nonnegative integer n less than 'last2 - first2' the following corresponding condition holds: - /// *(i + n) == *(first2 + n). Returns last1 if no such iterator is found. - /// - /// Complexity: At most (last1 first1) * (last2 first2) applications of the corresponding predicate. - /// - template - ForwardIterator1 - search(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - if(first2 != last2) // If there is anything to search for... - { - // We need to make a special case for a pattern of one element, - // as the logic below prevents one element patterns from working. - ForwardIterator2 temp2(first2); - ++temp2; - - if(temp2 != last2) // If what we are searching for has a length > 1... - { - ForwardIterator1 cur1(first1); - ForwardIterator2 p2; - - while(first1 != last1) - { - // The following loop is the equivalent of eastl::find(first1, last1, *first2) - while((first1 != last1) && !(*first1 == *first2)) - ++first1; - - if(first1 != last1) - { - p2 = temp2; - cur1 = first1; - - if(++cur1 != last1) - { - while(*cur1 == *p2) - { - if(++p2 == last2) - return first1; - - if(++cur1 == last1) - return last1; - } - - ++first1; - continue; - } - } - return last1; - } - - // Fall through to the end. - } - else - return eastl::find(first1, last1, *first2); - } - - return first1; - - - #if 0 - /* Another implementation which is a little more simpler but executes a little slower on average. - typedef typename eastl::iterator_traits::difference_type difference_type_1; - typedef typename eastl::iterator_traits::difference_type difference_type_2; - - const difference_type_2 d2 = eastl::distance(first2, last2); - - for(difference_type_1 d1 = eastl::distance(first1, last1); d1 >= d2; ++first1, --d1) - { - ForwardIterator1 temp1 = first1; - - for(ForwardIterator2 temp2 = first2; ; ++temp1, ++temp2) - { - if(temp2 == last2) - return first1; - if(!(*temp1 == *temp2)) - break; - } - } - - return last1; - */ - #endif - } - - - /// search - /// - /// Search finds a subsequence within the range [first1, last1) that is identical to [first2, last2) - /// when compared element-by-element. It returns an iterator pointing to the beginning of that - /// subsequence, or else last1 if no such subsequence exists. As such, it is very much like - /// the C strstr function, with the only difference being that strstr uses 0-terminated strings - /// whereas search uses an end iterator to specify the end of a string. - /// - /// Returns: The first iterator i in the range [first1, last1 - (last2 - first2)) such that for - /// any nonnegative integer n less than 'last2 - first2' the following corresponding condition holds: - /// predicate(*(i + n), *(first2 + n)) != false. Returns last1 if no such iterator is found. - /// - /// Complexity: At most (last1 first1) * (last2 first2) applications of the corresponding predicate. - /// - template - ForwardIterator1 - search(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - typedef typename eastl::iterator_traits::difference_type difference_type_1; - typedef typename eastl::iterator_traits::difference_type difference_type_2; - - difference_type_2 d2 = eastl::distance(first2, last2); - - if(d2 != 0) - { - ForwardIterator1 i(first1); - eastl::advance(i, d2); - - for(difference_type_1 d1 = eastl::distance(first1, last1); d1 >= d2; --d1) - { - if(eastl::equal(first1, i, first2, predicate)) - return first1; - if(d1 > d2) // To do: Find a way to make the algorithm more elegant. - { - ++first1; - ++i; - } - } - return last1; - } - return first1; // Just like with strstr, we return first1 if the match string is empty. - } - - - - // search_n helper functions - // - template - ForwardIterator // Generic implementation. - search_n_impl(ForwardIterator first, ForwardIterator last, Size count, const T& value, EASTL_ITC_NS::forward_iterator_tag) - { - if(count <= 0) - return first; - - Size d1 = (Size)eastl::distance(first, last); // Should d1 be of type Size, ptrdiff_t, or iterator_traits::difference_type? - // The problem with using iterator_traits::difference_type is that - if(count > d1) // ForwardIterator may not be a true iterator but instead something like a pointer. - return last; - - for(; d1 >= count; ++first, --d1) - { - ForwardIterator i(first); - - for(Size n = 0; n < count; ++n, ++i, --d1) - { - if(!(*i == value)) // Note that we always express value comparisons in terms of < or ==. - goto not_found; - } - return first; - - not_found: - first = i; - } - return last; - } - - template inline - RandomAccessIterator // Random access iterator implementation. Much faster than generic implementation. - search_n_impl(RandomAccessIterator first, RandomAccessIterator last, Size count, const T& value, EASTL_ITC_NS::random_access_iterator_tag) - { - if(count <= 0) - return first; - else if(count == 1) - return find(first, last, value); - else if(last > first) - { - RandomAccessIterator lookAhead; - RandomAccessIterator backTrack; - - Size skipOffset = (count - 1); - Size tailSize = (Size)(last - first); - Size remainder; - Size prevRemainder; - - for(lookAhead = first + skipOffset; tailSize >= count; lookAhead += count) - { - tailSize -= count; - - if(*lookAhead == value) - { - remainder = skipOffset; - - for(backTrack = lookAhead - 1; *backTrack == value; --backTrack) - { - if(--remainder == 0) - return (lookAhead - skipOffset); // success - } - - if(remainder <= tailSize) - { - prevRemainder = remainder; - - while(*(++lookAhead) == value) - { - if(--remainder == 0) - return (backTrack + 1); // success - } - tailSize -= (prevRemainder - remainder); - } - else - return last; // failure - } - - // lookAhead here is always pointing to the element of the last mismatch. - } - } - - return last; // failure - } - - - /// search_n - /// - /// Returns: The first iterator i in the range [first, last count) such that - /// for any nonnegative integer n less than count the following corresponding - /// conditions hold: *(i + n) == value, pred(*(i + n),value) != false. - /// Returns last if no such iterator is found. - /// - /// Complexity: At most '(last1 - first1) * count' applications of the corresponding predicate. - /// - template - ForwardIterator - search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value) - { - typedef typename eastl::iterator_traits::iterator_category IC; - return eastl::search_n_impl(first, last, count, value, IC()); - } - - - /// binary_search - /// - /// Returns: true if there is an iterator i in the range [first last) that - /// satisfies the corresponding conditions: !(*i < value) && !(value < *i). - /// - /// Complexity: At most 'log(last - first) + 2' comparisons. - /// - /// Note: The reason binary_search returns bool instead of an iterator is - /// that search_n, lower_bound, or equal_range already return an iterator. - /// However, there are arguments that binary_search should return an iterator. - /// Note that we provide binary_search_i (STL extension) to return an iterator. - /// - /// To use search_n to find an item, do this: - /// iterator i = search_n(begin, end, 1, value); - /// To use lower_bound to find an item, do this: - /// iterator i = lower_bound(begin, end, value); - /// if((i != last) && !(value < *i)) - /// - /// It turns out that the above lower_bound method is as fast as binary_search - /// would be if it returned an iterator. - /// - template - inline bool - binary_search(ForwardIterator first, ForwardIterator last, const T& value) - { - // To do: This can be made slightly faster by not using lower_bound. - ForwardIterator i(eastl::lower_bound(first, last, value)); - return ((i != last) && !(value < *i)); // Note that we always express value comparisons in terms of < or ==. - } - - - /// binary_search - /// - /// Returns: true if there is an iterator i in the range [first last) that - /// satisfies the corresponding conditions: compare(*i, value) == false && - /// compare(value, *i) == false. - /// - /// Complexity: At most 'log(last - first) + 2' comparisons. - /// - /// Note: See comments above regarding the bool return value of binary_search. - /// - template - inline bool - binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare compare) - { - // To do: This can be made slightly faster by not using lower_bound. - ForwardIterator i(eastl::lower_bound(first, last, value, compare)); - return ((i != last) && !compare(value, *i)); - } - - - /// binary_search_i - /// - /// Returns: iterator if there is an iterator i in the range [first last) that - /// satisfies the corresponding conditions: !(*i < value) && !(value < *i). - /// Returns last if the value is not found. - /// - /// Complexity: At most 'log(last - first) + 2' comparisons. - /// - template - inline ForwardIterator - binary_search_i(ForwardIterator first, ForwardIterator last, const T& value) - { - // To do: This can be made slightly faster by not using lower_bound. - ForwardIterator i(eastl::lower_bound(first, last, value)); - if((i != last) && !(value < *i)) // Note that we always express value comparisons in terms of < or ==. - return i; - return last; - } - - - /// binary_search_i - /// - /// Returns: iterator if there is an iterator i in the range [first last) that - /// satisfies the corresponding conditions: !(*i < value) && !(value < *i). - /// Returns last if the value is not found. - /// - /// Complexity: At most 'log(last - first) + 2' comparisons. - /// - template - inline ForwardIterator - binary_search_i(ForwardIterator first, ForwardIterator last, const T& value, Compare compare) - { - // To do: This can be made slightly faster by not using lower_bound. - ForwardIterator i(eastl::lower_bound(first, last, value, compare)); - if((i != last) && !compare(value, *i)) - return i; - return last; - } - - - /// unique - /// - /// Given a sorted range, this function removes duplicated items. - /// Note that if you have a container then you will probably want - /// to call erase on the container with the return value if your - /// goal is to remove the duplicated items from the container. - /// - /// Effects: Eliminates all but the first element from every consecutive - /// group of equal elements referred to by the iterator i in the range - /// [first, last) for which the following corresponding condition holds - /// *i == *(i - 1). - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: If the range (last - first) is not empty, exactly (last - first) - /// applications of the corresponding predicate, otherwise no applications of the predicate. - /// - /// Example usage: - /// vector intArray; - /// ... - /// intArray.erase(unique(intArray.begin(), intArray.end()), intArray.end()); - /// - template - ForwardIterator unique(ForwardIterator first, ForwardIterator last) - { - first = eastl::adjacent_find(first, last); - - if(first != last) // We expect that there are duplicated items, else the user wouldn't be calling this function. - { - ForwardIterator dest(first); - - for(++first; first != last; ++first) - { - if(!(*dest == *first)) // Note that we always express value comparisons in terms of < or ==. - *++dest = *first; - } - return ++dest; - } - return last; - } - - - /// unique - /// - /// Given a sorted range, this function removes duplicated items. - /// Note that if you have a container then you will probably want - /// to call erase on the container with the return value if your - /// goal is to remove the duplicated items from the container. - /// - /// Effects: Eliminates all but the first element from every consecutive - /// group of equal elements referred to by the iterator i in the range - /// [first, last) for which the following corresponding condition holds: - /// predicate(*i, *(i - 1)) != false. - /// - /// Returns: The end of the resulting range. - /// - /// Complexity: If the range (last - first) is not empty, exactly (last - first) - /// applications of the corresponding predicate, otherwise no applications of the predicate. - /// - template - ForwardIterator unique(ForwardIterator first, ForwardIterator last, BinaryPredicate predicate) - { - first = eastl::adjacent_find(first, last, predicate); - - if(first != last) // We expect that there are duplicated items, else the user wouldn't be calling this function. - { - ForwardIterator dest(first); - - for(++first; first != last; ++first) - { - if(!predicate(*dest, *first)) - *++dest = *first; - } - return ++dest; - } - return last; - } - - - - // find_end - // - // We provide two versions here, one for a bidirectional iterators and one for - // regular forward iterators. Given that we are searching backward, it's a bit - // more efficient if we can use backwards iteration to implement our search, - // though this requires an iterator that can be reversed. - // - template - ForwardIterator1 - find_end_impl(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - EASTL_ITC_NS::forward_iterator_tag, EASTL_ITC_NS::forward_iterator_tag) - { - if(first2 != last2) // We have to do this check because the search algorithm below will return first1 (and not last1) if the first2/last2 range is empty. - { - for(ForwardIterator1 result(last1); ; ) - { - const ForwardIterator1 resultNext(eastl::search(first1, last1, first2, last2)); - - if(resultNext != last1) // If another sequence was found... - { - first1 = result = resultNext; - ++first1; - } - else - return result; - } - } - return last1; - } - - template - BidirectionalIterator1 - find_end_impl(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - BidirectionalIterator2 first2, BidirectionalIterator2 last2, - EASTL_ITC_NS::bidirectional_iterator_tag, EASTL_ITC_NS::bidirectional_iterator_tag) - { - typedef eastl::reverse_iterator reverse_iterator1; - typedef eastl::reverse_iterator reverse_iterator2; - - reverse_iterator1 rresult(eastl::search(reverse_iterator1(last1), reverse_iterator1(first1), - reverse_iterator2(last2), reverse_iterator2(first2))); - if(rresult.base() != first1) // If we found something... - { - BidirectionalIterator1 result(rresult.base()); - - eastl::advance(result, -eastl::distance(first2, last2)); // We have an opportunity to optimize this, as the - return result; // search function already calculates this distance. - } - return last1; - } - - /// find_end - /// - /// Finds the last occurrence of the second sequence in the first sequence. - /// As such, this function is much like the C string function strrstr and it - /// is also the same as a reversed version of 'search'. It is called find_end - /// instead of the possibly more consistent search_end simply because the C++ - /// standard algorithms have such naming. - /// - /// Returns an iterator between first1 and last1 if the sequence is found. - /// returns last1 (the end of the first seqence) if the sequence is not found. - /// - template - inline ForwardIterator1 - find_end(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - typedef typename eastl::iterator_traits::iterator_category IC1; - typedef typename eastl::iterator_traits::iterator_category IC2; - - return eastl::find_end_impl(first1, last1, first2, last2, IC1(), IC2()); - } - - - - - // To consider: Fold the predicate and non-predicate versions of - // this algorithm into a single function. - template - ForwardIterator1 - find_end_impl(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate, - EASTL_ITC_NS::forward_iterator_tag, EASTL_ITC_NS::forward_iterator_tag) - { - if(first2 != last2) // We have to do this check because the search algorithm below will return first1 (and not last1) if the first2/last2 range is empty. - { - for(ForwardIterator1 result = last1; ; ) - { - const ForwardIterator1 resultNext(eastl::search(first1, last1, first2, last2, predicate)); - - if(resultNext != last1) // If another sequence was found... - { - first1 = result = resultNext; - ++first1; - } - else - return result; - } - } - return last1; - } - - template - BidirectionalIterator1 - find_end_impl(BidirectionalIterator1 first1, BidirectionalIterator1 last1, - BidirectionalIterator2 first2, BidirectionalIterator2 last2, - BinaryPredicate predicate, - EASTL_ITC_NS::bidirectional_iterator_tag, EASTL_ITC_NS::bidirectional_iterator_tag) - { - typedef eastl::reverse_iterator reverse_iterator1; - typedef eastl::reverse_iterator reverse_iterator2; - - reverse_iterator1 rresult(eastl::search - (reverse_iterator1(last1), reverse_iterator1(first1), - reverse_iterator2(last2), reverse_iterator2(first2), - predicate)); - if(rresult.base() != first1) // If we found something... - { - BidirectionalIterator1 result(rresult.base()); - eastl::advance(result, -eastl::distance(first2, last2)); - return result; - } - return last1; - } - - - /// find_end - /// - /// Effects: Finds a subsequence of equal values in a sequence. - /// - /// Returns: The last iterator i in the range [first1, last1 - (last2 - first2)) - /// such that for any nonnegative integer n < (last2 - first2), the following - /// corresponding conditions hold: pred(*(i+n),*(first2+n)) != false. Returns - /// last1 if no such iterator is found. - /// - /// Complexity: At most (last2 - first2) * (last1 - first1 - (last2 - first2) + 1) - /// applications of the corresponding predicate. - /// - template - inline ForwardIterator1 - find_end(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate predicate) - { - typedef typename eastl::iterator_traits::iterator_category IC1; - typedef typename eastl::iterator_traits::iterator_category IC2; - - return eastl::find_end_impl - (first1, last1, first2, last2, predicate, IC1(), IC2()); - } - - - - /// set_difference - /// - /// set_difference iterates over both input ranges and copies elements present - /// in the first range but not the second to the output range. - /// - /// Effects: Copies the elements of the range [first1, last1) which are not - /// present in the range [first2, last2) to the range beginning at result. - /// The elements in the constructed range are sorted. - /// - /// Requires: The input ranges must be sorted. - /// Requires: The output range shall not overlap with either of the original ranges. - /// - /// Returns: The end of the output range. - /// - /// Complexity: At most (2 * ((last1 - first1) + (last2 - first2)) - 1) comparisons. - /// - template - OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - OutputIterator result) - { - while((first1 != last1) && (first2 != last2)) - { - if(*first1 < *first2) - { - *result = *first1; - ++first1; - ++result; - } - else if(*first2 < *first1) - ++first2; - else - { - ++first1; - ++first2; - } - } - - return eastl::copy(first1, last1, result); - } - - - template - OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - OutputIterator result, Compare compare) - { - while((first1 != last1) && (first2 != last2)) - { - if(compare(*first1, *first2)) - { - EASTL_VALIDATE_COMPARE(!compare(*first2, *first1)); // Validate that the compare function is sane. - *result = *first1; - ++first1; - ++result; - } - else if(compare(*first2, *first1)) - { - EASTL_VALIDATE_COMPARE(!compare(*first1, *first2)); // Validate that the compare function is sane. - ++first2; - } - else - { - ++first1; - ++first2; - } - } - - return eastl::copy(first1, last1, result); - } - -} // namespace eastl - - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_rdestl.h deleted file mode 100644 index d446481c635f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/algorithm_rdestl.h +++ /dev/null @@ -1,273 +0,0 @@ -#ifndef RDESTL_ALGORITHM_H -#define RDESTL_ALGORITHM_H - -#include -#include -#include -#include - -namespace rde -{ - -//----------------------------------------------------------------------------- -template RDE_FORCEINLINE -void copy_construct(T* mem, const T& orig) -{ - //new (mem) T(orig); - internal::copy_construct(mem, orig, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template RDE_FORCEINLINE -void construct(T* mem) -{ - internal::construct(mem, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template RDE_FORCEINLINE -void destruct(T* mem) -{ - internal::destruct(mem, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template -void copy_n(const T* first, size_t n, T* result) -{ - internal::copy_n(first, n, result, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template -void copy(const T* first, const T* last, T* result) -{ - internal::copy(first, last, result, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template -void copy_construct_n(T* first, size_t n, T* result) -{ - internal::copy_construct_n(first, n, result, int_to_type::value>()); -} -//----------------------------------------------------------------------------- -template -void move_n(const T* from, size_t n, T* result) -{ - RDE_ASSERT(from != result || n == 0); - // Overlap? - if (result > from && result < from + n) - { - internal::move_n(from, n, result, int_to_type::value>()); - } - else - { - internal::copy_n(from, n, result, int_to_type::value>()); - } -} - -//----------------------------------------------------------------------------- -template -void move(const T* first, const T* last, T* result) -{ - RDE_ASSERT(first != result || first == last); - if (result > first && result < last) - { - internal::move(first, last, result, int_to_type::value>()); - } - else - { - internal::copy(first, last, result, int_to_type::value>()); - } -} - -//----------------------------------------------------------------------------- -template -void construct_n(T* first, size_t n) -{ - internal::construct_n(first, n, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template -void destruct_n(T* first, size_t n) -{ - internal::destruct_n(first, n, int_to_type::value>()); -} - -//----------------------------------------------------------------------------- -template RDE_FORCEINLINE -void fill_n(T* first, size_t n, const T& val) -{ - //for (size_t i = 0; i < n; ++i) - // first[i] = val; - // Loop unrolling with Duff's Device. - T* last = first + n; - switch (n & 0x7) - { - case 0: - while (first != last) - { - *first = val; ++first; - case 7: *first = val; ++first; - case 6: *first = val; ++first; - case 5: *first = val; ++first; - case 4: *first = val; ++first; - case 3: *first = val; ++first; - case 2: *first = val; ++first; - case 1: *first = val; ++first; - } - } -} - -//----------------------------------------------------------------------------- -template inline -void distance(TIter first, TIter last, TDist& dist) -{ - internal::distance(first, last, dist, typename iterator_traits::iterator_category()); -} - -//----------------------------------------------------------------------------- -template inline -void advance(TIter& iter, TDist off) -{ - internal::advance(iter, off, typename iterator_traits::iterator_category()); -} - -//----------------------------------------------------------------------------- -template inline -TIter lower_bound(TIter first, TIter last, const T& val, const TPred& pred) -{ - internal::test_ordering(first, last, pred); - int dist(0); - distance(first, last, dist); - while (dist > 0) - { - const int halfDist = dist >> 1; - TIter mid = first; - advance(mid, halfDist); - if (internal::debug_pred(pred, *mid, val)) - first = ++mid, dist -= halfDist + 1; - else - dist = halfDist; - } - return first; -} - -//----------------------------------------------------------------------------- -template inline -TIter upper_bound(TIter first, TIter last, const T& val, const TPred& pred) -{ - internal::test_ordering(first, last, pred); - int dist(0); - distance(first, last, dist); - while (dist > 0) - { - const int halfDist = dist >> 1; - TIter mid = first; - advance(mid, halfDist); - if (!internal::debug_pred(pred, val, *mid)) - first = ++mid, dist -= halfDist + 1; - else - dist = halfDist; - } - return first; -} - -//----------------------------------------------------------------------------- -template -TIter find(TIter first, TIter last, const T& val) -{ - while (first != last) - { - if ((*first) == val) - return first; - ++first; - } - return last; -} - -//----------------------------------------------------------------------------- -template -TIter find_if(TIter first, TIter last, const T& val, const TPred& pred) -{ - while (first != last) - { - if (pred(*first, val)) - return first; - ++first; - } - return last; -} - -//----------------------------------------------------------------------------- -template -void accumulate(TIter first, TIter last, T& result) -{ - while (first != last) - { - result += *first; - ++first; - } -} - -//----------------------------------------------------------------------------- -template -T abs(const T& t) -{ - return t >= T(0) ? t : -t; -} -// No branches, Hacker's Delight way. -RDE_FORCEINLINE int abs(int x) -{ - const int y = x >> 31; - return (x ^ y) - y; -} -RDE_FORCEINLINE short abs(short x) -{ - const short y = x >> 15; - return (x ^ y) - y; -} - -//----------------------------------------------------------------------------- -template inline -T max(const T& x, const T& y) -{ - return x > y ? x : y; -} - -//----------------------------------------------------------------------------- -template inline -T min(const T& x, const T& y) -{ - return x < y ? x : y; -} -// @TODO: determine if it REALLY is quicker than version with branches. -/*RDE_FORCEINLINE float min(float x, float y) -{ - float result; - __asm - { - fld [x] - fld [y] - fcomi st(0), st(1) - fcmovnb st(0), st(1) - fstp [result] - fcomp - } - return result; -}*/ - -//----------------------------------------------------------------------------- -template -void swap(TAssignable& a, TAssignable& b) -{ - TAssignable tmp(a); - a = b; - b = tmp; -} - -} // namespace rde -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_ALGORITHM_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.cpp deleted file mode 100644 index 0737316b6c27..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/allocator.cpp -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - -#include -#include - - -/////////////////////////////////////////////////////////////////////////////// -// ReadMe -// -// This file implements the default application allocator. -// You can replace this allocator.cpp file with a different one, -// you can define EASTL_USER_DEFINED_ALLOCATOR below to ignore this file, -// or you can modify the EASTL config.h file to redefine how allocators work. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_USER_DEFINED_ALLOCATOR // If the user hasn't declared that he has defined an allocator implementation elsewhere... - - namespace eastl - { - - /// gDefaultAllocator - /// Default global allocator instance. - EASTL_API allocator gDefaultAllocator; - EASTL_API allocator* gpDefaultAllocator = &gDefaultAllocator; - - EASTL_API allocator* GetDefaultAllocator() - { - return gpDefaultAllocator; - } - - EASTL_API allocator* SetDefaultAllocator(allocator* pAllocator) - { - allocator* const pPrevAllocator = gpDefaultAllocator; - gpDefaultAllocator = pAllocator; - return pPrevAllocator; - } - - } // namespace eastl - - -#endif // EASTL_USER_DEFINED_ALLOCATOR - - - - - - - - - - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.h deleted file mode 100644 index 6618886dabd1..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_eastl.h +++ /dev/null @@ -1,326 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/allocator.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_ALLOCATOR_H -#define EASTL_ALLOCATOR_H - - -#include -#include - - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4189) // local variable is initialized but not referenced -#endif - - -namespace eastl -{ - - /// EASTL_ALLOCATOR_DEFAULT_NAME - /// - /// Defines a default allocator name in the absence of a user-provided name. - /// - #ifndef EASTL_ALLOCATOR_DEFAULT_NAME - #define EASTL_ALLOCATOR_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX // Unless the user overrides something, this is "EASTL". - #endif - - - /// alloc_flags - /// - /// Defines allocation flags. - /// - enum alloc_flags - { - MEM_TEMP = 0, // Low memory, not necessarily actually temporary. - MEM_PERM = 1 // High memory, for things that won't be unloaded. - }; - - - /// allocator - /// - /// In this allocator class, note that it is not templated on any type and - /// instead it simply allocates blocks of memory much like the C malloc and - /// free functions. It can be thought of as similar to C++ std::allocator. - /// The flags parameter has meaning that is specific to the allocation - /// - class EASTL_API allocator - { - public: - EASTL_ALLOCATOR_EXPLICIT allocator(const char* pName = EASTL_NAME_VAL(EASTL_ALLOCATOR_DEFAULT_NAME)); - allocator(const allocator& x); - allocator(const allocator& x, const char* pName); - - allocator& operator=(const allocator& x); - - void* allocate(size_t n, int flags = 0); - void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0); - void deallocate(void* p, size_t n); - - const char* get_name() const; - void set_name(const char* pName); - - protected: - #if EASTL_NAME_ENABLED - const char* mpName; // Debug name, used to track memory. - #endif - }; - - bool operator==(const allocator& a, const allocator& b); - bool operator!=(const allocator& a, const allocator& b); - - EASTL_API allocator* GetDefaultAllocator(); - EASTL_API allocator* SetDefaultAllocator(allocator* pAllocator); - - - - /// get_default_allocator - /// - /// This templated function allows the user to implement a default allocator - /// retrieval function that any part of EASTL can use. EASTL containers take - /// an Allocator parameter which identifies an Allocator class to use. But - /// different kinds of allocators have different mechanisms for retrieving - /// a default allocator instance, and some don't even intrinsically support - /// such functionality. The user can override this get_default_allocator - /// function in order to provide the glue between EASTL and whatever their - /// system's default allocator happens to be. - /// - /// Example usage: - /// MyAllocatorType* gpSystemAllocator; - /// - /// MyAllocatorType* get_default_allocator(const MyAllocatorType*) - /// { return gpSystemAllocator; } - /// - template - inline Allocator* get_default_allocator(const Allocator*) - { - return NULL; // By default we return NULL; the user must make specialization of this function in order to provide their own implementation. - } - - inline EASTLAllocatorType* get_default_allocator(const EASTLAllocatorType*) - { - return EASTLAllocatorDefault(); // For the built-in allocator EASTLAllocatorType, we happen to already have a function for returning the default allocator instance, so we provide it. - } - - - /// default_allocfreemethod - /// - /// Implements a default allocfreemethod which uses the default global allocator. - /// This version supports only default alignment. - /// - inline void* default_allocfreemethod(size_t n, void* pBuffer, void* /*pContext*/) - { - EASTLAllocatorType* const pAllocator = EASTLAllocatorDefault(); - - if(pBuffer) // If freeing... - { - EASTLFree(*pAllocator, pBuffer, n); - return NULL; // The return value is meaningless for the free. - } - else // allocating - return EASTLAlloc(*pAllocator, n); - } - - - /// allocate_memory - /// - /// This is a memory allocation dispatching function. - /// To do: Make aligned and unaligned specializations. - /// Note that to do this we will need to use a class with a static - /// function instead of a standalone function like below. - /// - template - void* allocate_memory(Allocator& a, size_t n, size_t alignment, size_t alignmentOffset) - { - if(alignment <= 8) - return EASTLAlloc(a, n); - return EASTLAllocAligned(a, n, alignment, alignmentOffset); - } - -} // namespace eastl - - - - - -#ifndef EASTL_USER_DEFINED_ALLOCATOR // If the user hasn't declared that he has defined a different allocator implementation elsewhere... - - #ifdef _MSC_VER - #pragma warning(push, 0) - #include - #pragma warning(pop) - #else - #include - #endif - - #if !EASTL_DLL // If building a regular library and not building EASTL as a DLL... - // It is expected that the application define the following - // versions of operator new for the application. Either that or the - // user needs to override the implementation of the allocator class. - void* operator new[](size_t size, const char* pName, int flags, unsigned debugFlags, const char* file, int line); - void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* pName, int flags, unsigned debugFlags, const char* file, int line); - #endif - - namespace eastl - { - inline allocator::allocator(const char* EASTL_NAME(pName)) - { - #if EASTL_NAME_ENABLED - mpName = pName ? pName : EASTL_ALLOCATOR_DEFAULT_NAME; - #endif - } - - - inline allocator::allocator(const allocator& EASTL_NAME(alloc)) - { - #if EASTL_NAME_ENABLED - mpName = alloc.mpName; - #endif - } - - - inline allocator::allocator(const allocator&, const char* EASTL_NAME(pName)) - { - #if EASTL_NAME_ENABLED - mpName = pName ? pName : EASTL_ALLOCATOR_DEFAULT_NAME; - #endif - } - - - inline allocator& allocator::operator=(const allocator& EASTL_NAME(alloc)) - { - #if EASTL_NAME_ENABLED - mpName = alloc.mpName; - #endif - return *this; - } - - - inline const char* allocator::get_name() const - { - #if EASTL_NAME_ENABLED - return mpName; - #else - return EASTL_ALLOCATOR_DEFAULT_NAME; - #endif - } - - - inline void allocator::set_name(const char* EASTL_NAME(pName)) - { - #if EASTL_NAME_ENABLED - mpName = pName; - #endif - } - - - inline void* allocator::allocate(size_t n, int flags) - { - #if EASTL_NAME_ENABLED - #define pName mpName - #else - #define pName EASTL_ALLOCATOR_DEFAULT_NAME - #endif - - #if EASTL_DLL - // We currently have no support for implementing flags when - // using the C runtime library operator new function. The user - // can use SetDefaultAllocator to override the default allocator. - (void)flags; - return ::new char[n]; - #elif (EASTL_DEBUGPARAMS_LEVEL <= 0) - return ::new((char*)0, flags, 0, (char*)0, 0) char[n]; - #elif (EASTL_DEBUGPARAMS_LEVEL == 1) - return ::new( pName, flags, 0, (char*)0, 0) char[n]; - #else - return ::new( pName, flags, 0, __FILE__, __LINE__) char[n]; - #endif - } - - - inline void* allocator::allocate(size_t n, size_t alignment, size_t offset, int flags) - { - #if EASTL_DLL - // We have a problem here. We cannot support alignment, as we don't have access - // to a memory allocator that can provide aligned memory. The C++ standard doesn't - // recognize such a thing. The user will need to call SetDefaultAllocator to - // provide an alloator which supports alignment. - EASTL_ASSERT(alignment <= 8); // 8 (sizeof(double)) is the standard alignment returned by operator new. - (void)alignment; (void)offset; (void)flags; - return new char[n]; - #elif (EASTL_DEBUGPARAMS_LEVEL <= 0) - return ::new(alignment, offset, (char*)0, flags, 0, (char*)0, 0) char[n]; - #elif (EASTL_DEBUGPARAMS_LEVEL == 1) - return ::new(alignment, offset, pName, flags, 0, (char*)0, 0) char[n]; - #else - return ::new(alignment, offset, pName, flags, 0, __FILE__, __LINE__) char[n]; - #endif - - #undef pName // See above for the definition of this. - } - - - inline void allocator::deallocate(void* p, size_t) - { - delete[] (char*)p; - } - - - inline bool operator==(const allocator&, const allocator&) - { - return true; // All allocators are considered equal, as they merely use global new/delete. - } - - - inline bool operator!=(const allocator&, const allocator&) - { - return false; // All allocators are considered equal, as they merely use global new/delete. - } - - - } // namespace eastl - - -#endif // EASTL_USER_DEFINED_ALLOCATOR - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_rdestl.h deleted file mode 100644 index 81d87d977539..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/allocator_rdestl.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef RDESTL_ALLOCATOR_H -#define RDESTL_ALLOCATOR_H - -namespace rde -{ - -// CONCEPT! -class allocator -{ -public: - explicit allocator(const char* name = "DEFAULT"): m_name(name) {} - // Copy ctor generated by compiler. - // allocator(const allocator&) - ~allocator() {} - - // Generated by compiler. - //allocator& operator=(const allocator&) - - void* allocate(unsigned int bytes, int flags = 0); - // Not supported for standard allocator for the time being. - void* allocate_aligned(unsigned int bytes, unsigned int alignment, int flags = 0); - void deallocate(void* ptr, unsigned int bytes); - - const char* get_name() const; - -private: - const char* m_name; -}; - -// True if lhs can free memory allocated by rhs and vice-versa. -inline bool operator==(const allocator& /*lhs*/, const allocator& /*rhs*/) -{ - return true; -} -inline bool operator!=(const allocator& lhs, const allocator& rhs) -{ - return !(lhs == rhs); -} - -inline void* allocator::allocate(unsigned int bytes, int) -{ - return operator new(bytes); -} - -inline void allocator::deallocate(void* ptr, unsigned int) -{ - operator delete(ptr); -} - -} // namespace rde - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_ALLOCATOR_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/assert_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/assert_eastl.cpp deleted file mode 100644 index 9442ac8c98f8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/assert_eastl.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/assert.cpp -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - - -#include -#include -#include - -#if defined(EA_PLATFORM_MICROSOFT) - #pragma warning(push, 0) - #if defined _MSC_VER - #include - #endif - #if defined(EA_PLATFORM_WINDOWS) - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - #include - #elif defined(EA_PLATFORM_XENON) - #include - #endif - #pragma warning(pop) -#else - #include -#endif - - - - -namespace eastl -{ - - /// gpAssertionFailureFunction - /// - /// Global assertion failure function pointer. Set by SetAssertionFailureFunction. - /// - EASTL_API EASTL_AssertionFailureFunction gpAssertionFailureFunction = AssertionFailureFunctionDefault; - EASTL_API void* gpAssertionFailureFunctionContext = NULL; - - - - /// SetAssertionFailureFunction - /// - /// Sets the function called when an assertion fails. If this function is not called - /// by the user, a default function will be used. The user may supply a context parameter - /// which will be passed back to the user in the function call. This is typically used - /// to store a C++ 'this' pointer, though other things are possible. - /// - /// There is no thread safety here, so the user needs to externally make sure that - /// this function is not called in a thread-unsafe way. The easiest way to do this is - /// to just call this function once from the main thread on application startup. - /// - EASTL_API void SetAssertionFailureFunction(EASTL_AssertionFailureFunction pAssertionFailureFunction, void* pContext) - { - gpAssertionFailureFunction = pAssertionFailureFunction; - gpAssertionFailureFunctionContext = pContext; - } - - - - /// AssertionFailureFunctionDefault - /// - EASTL_API void AssertionFailureFunctionDefault(const char* pExpression, void* /*pContext*/) - { -#if defined(EA_DEBUG) || defined(_DEBUG) - // We cannot use puts() because it appends a newline. - // We cannot use printf(pExpression) because pExpression might have formatting statements. - #if defined(EA_PLATFORM_MICROSOFT) - OutputDebugStringA(pExpression); - (void)pExpression; - #else - printf("%s", pExpression); // Write the message to stdout, which happens to be the trace view for many console debug machines. - #endif -#endif - EASTL_DEBUG_BREAK(); - } - - - /// AssertionFailure - /// - EASTL_API void AssertionFailure(const char* pExpression) - { - if(gpAssertionFailureFunction) - gpAssertionFailureFunction(pExpression, gpAssertionFailureFunctionContext); - } - - -} // namespace eastl diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/config_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/config_eastl.h deleted file mode 100644 index c29194419213..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/config_eastl.h +++ /dev/null @@ -1,1191 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/config.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_CONFIG_H -#define EASTL_INTERNAL_CONFIG_H - - -/////////////////////////////////////////////////////////////////////////////// -// ReadMe -// -// This is the EASTL configuration file. All configurable parameters of EASTL -// are controlled through this file. However, all the settings here can be -// manually overridden by the user. There are three ways for a user to override -// the settings in this file: -// -// - Simply edit this file. -// - Define EASTL_USER_CONFIG_HEADER. -// - Predefine individual defines (e.g. EASTL_ASSERT). -// -/////////////////////////////////////////////////////////////////////////////// - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_USER_CONFIG_HEADER -// -// This allows the user to define a header file to be #included before the -// EASTL config.h contents are compiled. A primary use of this is to override -// the contents of this config.h file. Note that all the settings below in -// this file are user-overridable. -// -// Example usage: -// #define EASTL_USER_CONFIG_HEADER "MyConfigOverrides.h" -// #include -// -/////////////////////////////////////////////////////////////////////////////// - -#ifdef EASTL_USER_CONFIG_HEADER - #include EASTL_USER_CONFIG_HEADER -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_EABASE_DISABLED -// -// The user can disable EABase usage and manually supply the configuration -// via defining EASTL_EABASE_DISABLED and defining the appropriate entities -// globally or via the above EASTL_USER_CONFIG_HEADER. -// -// Example usage: -// #define EASTL_EABASE_DISABLED -// #include -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_EABASE_DISABLED - #include -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// VC++ bug fix. -/////////////////////////////////////////////////////////////////////////////// - -#ifdef _MSC_VER - // VC8 has a bug whereby it generates a warning when malloc.h is #included - // by its headers instead of by yours. There is no practical solution but - // to pre-empt the #include of malloc.h with our own inclusion of it. - // The only other alternative is to disable the warning globally, which is - // something we try to avoid as much as possible. - #pragma warning(push, 0) - #include - #pragma warning(pop) -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_VERSION -// -// We more or less follow the conventional EA packaging approach to versioning -// here. A primary distinction here is that minor versions are defined as two -// digit entities (e.g. .03") instead of minimal digit entities ".3"). The logic -// here is that the value is a counter and not a floating point fraction. -// Note that the major version doesn't have leading zeros. -// -// Example version strings: -// "0.91.00" // Major version 0, minor version 91, patch version 0. -// "1.00.00" // Major version 1, minor and patch version 0. -// "3.10.02" // Major version 3, minor version 10, patch version 02. -// "12.03.01" // Major version 12, minor version 03, patch version -// -// Example usage: -// printf("EASTL version: %s", EASTL_VERSION); -// printf("EASTL version: %d.%d.%d", EASTL_VERSION_N / 10000 % 100, EASTL_VERSION_N / 100 % 100, EASTL_VERSION_N % 100); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_VERSION - #define EASTL_VERSION "1.11.03" - #define EASTL_VERSION_N 11103 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EA_PLATFORM_MICROSOFT -// -// Defined as 1 or undefined. -// Implements support for the definition of EA_PLATFORM_MICROSOFT for the case -// of using EABase versions prior to the addition of its EA_PLATFORM_MICROSOFT support. -// -#if (EABASE_VERSION_N < 20022) && !defined(EA_PLATFORM_MICROSOFT) - #if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XENON) - #define EA_PLATFORM_MICROSOFT 1 - #endif -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// EA_COMPILER_NO_STANDARD_CPP_LIBRARY -// -// Defined as 1 or undefined. -// Implements support for the definition of EA_COMPILER_NO_STANDARD_CPP_LIBRARY for the case -// of using EABase versions prior to the addition of its EA_COMPILER_NO_STANDARD_CPP_LIBRARY support. -// -#if (EABASE_VERSION_N < 20022) && !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY) - #if defined(EA_PLATFORM_ANDROID) - #define EA_COMPILER_NO_STANDARD_CPP_LIBRARY 1 - #endif -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// EA_COMPILER_NO_RTTI -// -// Defined as 1 or undefined. -// Implements support for the definition of EA_COMPILER_NO_RTTI for the case -// of using EABase versions prior to the addition of its EA_COMPILER_NO_RTTI support. -// -#if (EABASE_VERSION_N < 20022) && !defined(EA_COMPILER_NO_RTTI) - #if defined(__SNC__) && !defined(__RTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(__GXX_ABI_VERSION) && !defined(__GXX_RTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(_MSC_VER) && !defined(_CPPRTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(__MWERKS__) - #if !__option(RTTI) - #define EA_COMPILER_NO_RTTI - #endif - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL namespace -// -// We define this so that users that #include this config file can reference -// these namespaces without seeing any other files that happen to use them. -/////////////////////////////////////////////////////////////////////////////// - -/// EA Standard Template Library -namespace eastl -{ - // Intentionally empty. -} - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_DEBUG -// -// Defined as an integer >= 0. Default is 1 for debug builds and 0 for -// release builds. This define is also a master switch for the default value -// of some other settings. -// -// Example usage: -// #if EASTL_DEBUG -// ... -// #endif -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_DEBUG - #if defined(EA_DEBUG) || defined(_DEBUG) - #define EASTL_DEBUG 1 - #else - #define EASTL_DEBUG 0 - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_DEBUGPARAMS_LEVEL -// -// EASTL_DEBUGPARAMS_LEVEL controls what debug information is passed through to -// the allocator by default. -// This value may be defined by the user ... if not it will default to 1 for -// EA_DEBUG builds, otherwise 0. -// -// 0 - no debug information is passed through to allocator calls. -// 1 - 'name' is passed through to allocator calls. -// 2 - 'name', __FILE__, and __LINE__ are passed through to allocator calls. -// -// This parameter mirrors the equivalent parameter in the CoreAllocator package. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_DEBUGPARAMS_LEVEL - #if EASTL_DEBUG - #define EASTL_DEBUGPARAMS_LEVEL 2 - #else - #define EASTL_DEBUGPARAMS_LEVEL 0 - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_DLL -// -// Defined as 0 or 1. The default is dependent on the definition of EA_DLL. -// If EA_DLL is defined, then EASTL_DLL is 1, else EASTL_DLL is 0. -// EA_DLL is a define that controls DLL builds within the EAConfig build system. -// EASTL_DLL controls whether EASTL is built and used as a DLL. -// Normally you wouldn't do such a thing, but there are use cases for such -// a thing, particularly in the case of embedding C++ into C# applications. -// -#ifndef EASTL_DLL - #if defined(EA_DLL) - #define EASTL_DLL 1 - #else - #define EASTL_DLL 0 - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_API -// -// This is used to label functions as DLL exports under Microsoft platforms. -// If EA_DLL is defined, then the user is building EASTL as a DLL and EASTL's -// non-templated functions will be exported. EASTL template functions are not -// labelled as EASTL_API (and are thus not exported in a DLL build). This is -// because it's not possible (or at least unsafe) to implement inline templated -// functions in a DLL. -// -// Example usage of EASTL_API: -// EASTL_API int someVariable = 10; // Export someVariable in a DLL build. -// -// struct EASTL_API SomeClass{ // Export SomeClass and its member functions in a DLL build. -// }; -// -// EASTL_API void SomeFunction(); // Export SomeFunction in a DLL build. -// -// -#if defined(EA_DLL) && !defined(EASTL_DLL) - #define EASTL_DLL 1 -#endif - -#ifndef EASTL_API // If the build file hasn't already defined this to be dllexport... - #if EASTL_DLL && defined(_MSC_VER) - #define EASTL_API __declspec(dllimport) - #define EASTL_TEMPLATE_API // Not sure if there is anything we can do here. - #else - #define EASTL_API - #define EASTL_TEMPLATE_API - #endif -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_NAME_ENABLED / EASTL_NAME / EASTL_NAME_VAL -// -// Used to wrap debug string names. In a release build, the definition -// goes away. These are present to avoid release build compiler warnings -// and to make code simpler. -// -// Example usage of EASTL_NAME: -// // pName will defined away in a release build and thus prevent compiler warnings. -// void allocator::set_name(const char* EASTL_NAME(pName)) -// { -// #if EASTL_NAME_ENABLED -// mpName = pName; -// #endif -// } -// -// Example usage of EASTL_NAME_VAL: -// // "xxx" is defined to NULL in a release build. -// vector::vector(const allocator_type& allocator = allocator_type(EASTL_NAME_VAL("xxx"))); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_NAME_ENABLED - #define EASTL_NAME_ENABLED EASTL_DEBUG -#endif - -#ifndef EASTL_NAME - #if EASTL_NAME_ENABLED - #define EASTL_NAME(x) x - #define EASTL_NAME_VAL(x) x - #else - #define EASTL_NAME(x) - #define EASTL_NAME_VAL(x) ((const char*)NULL) - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_DEFAULT_NAME_PREFIX -// -// Defined as a string literal. Defaults to "EASTL". -// This define is used as the default name for EASTL where such a thing is -// referenced in EASTL. For example, if the user doesn't specify an allocator -// name for their deque, it is named "EASTL deque". However, you can override -// this to say "SuperBaseball deque" by changing EASTL_DEFAULT_NAME_PREFIX. -// -// Example usage (which is simply taken from how deque.h uses this define): -// #ifndef EASTL_DEQUE_DEFAULT_NAME -// #define EASTL_DEQUE_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " deque" -// #endif -// -#ifndef EASTL_DEFAULT_NAME_PREFIX - #define EASTL_DEFAULT_NAME_PREFIX "EASTL" -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ASSERT_ENABLED -// -// Defined as 0 or non-zero. Default is same as EASTL_DEBUG. -// If EASTL_ASSERT_ENABLED is non-zero, then asserts will be executed via -// the assertion mechanism. -// -// Example usage: -// #if EASTL_ASSERT_ENABLED -// EASTL_ASSERT(v.size() > 17); -// #endif -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ASSERT_ENABLED - #define EASTL_ASSERT_ENABLED EASTL_DEBUG -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_EMPTY_REFERENCE_ASSERT_ENABLED -// -// Defined as 0 or non-zero. Default is same as EASTL_ASSERT_ENABLED. -// This is like EASTL_ASSERT_ENABLED, except it is for empty container -// references. Sometime people like to be able to take a reference to -// the front of the container, but not use it if the container is empty. -// In practice it's often easier and more efficient to do this than to write -// extra code to check if the container is empty. -// -// Example usage: -// template -// inline typename vector::reference -// vector::front() -// { -// #if EASTL_ASSERT_ENABLED -// EASTL_ASSERT(mpEnd > mpBegin); -// #endif -// -// return *mpBegin; -// } -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_EMPTY_REFERENCE_ASSERT_ENABLED - #define EASTL_EMPTY_REFERENCE_ASSERT_ENABLED EASTL_ASSERT_ENABLED -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// SetAssertionFailureFunction -// -// Allows the user to set a custom assertion failure mechanism. -// -// Example usage: -// void Assert(const char* pExpression, void* pContext); -// SetAssertionFailureFunction(Assert, this); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ASSERTION_FAILURE_DEFINED - #define EASTL_ASSERTION_FAILURE_DEFINED - - namespace eastl - { - typedef void (*EASTL_AssertionFailureFunction)(const char* pExpression, void* pContext); - EASTL_API void SetAssertionFailureFunction(EASTL_AssertionFailureFunction pFunction, void* pContext); - - // These are the internal default functions that implement asserts. - EASTL_API void AssertionFailure(const char* pExpression); - EASTL_API void AssertionFailureFunctionDefault(const char* pExpression, void* pContext); - } -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ASSERT -// -// Assertion macro. Can be overridden by user with a different value. -// -// Example usage: -// EASTL_ASSERT(intVector.size() < 100); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ASSERT - #if EASTL_ASSERT_ENABLED - #define EASTL_ASSERT(expression) (void)((expression) || (eastl::AssertionFailure(#expression), 0)) - #else - #define EASTL_ASSERT(expression) - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_FAIL_MSG -// -// Failure macro. Can be overridden by user with a different value. -// -// Example usage: -// EASTL_FAIL("detected error condition!"); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_FAIL_MSG - #if EASTL_ASSERT_ENABLED - #define EASTL_FAIL_MSG(message) (eastl::AssertionFailure(message)) - #else - #define EASTL_FAIL_MSG(message) - #endif -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_CT_ASSERT / EASTL_CT_ASSERT_NAMED -// -// EASTL_CT_ASSERT is a macro for compile time assertion checks, useful for -// validating *constant* expressions. The advantage over using EASTL_ASSERT -// is that errors are caught at compile time instead of runtime. -// -// Example usage: -// EASTL_CT_ASSERT(sizeof(uint32_t == 4)); -// -/////////////////////////////////////////////////////////////////////////////// - -#if defined(EASTL_DEBUG) && !defined(EASTL_CT_ASSERT) - template struct EASTL_CT_ASSERTION_FAILURE; - template <> struct EASTL_CT_ASSERTION_FAILURE{ enum { value = 1 }; }; // We create a specialization for true, but not for false. - template struct EASTL_CT_ASSERTION_TEST{}; - - #define EASTL_PREPROCESSOR_JOIN(a, b) EASTL_PREPROCESSOR_JOIN1(a, b) - #define EASTL_PREPROCESSOR_JOIN1(a, b) EASTL_PREPROCESSOR_JOIN2(a, b) - #define EASTL_PREPROCESSOR_JOIN2(a, b) a##b - - #if defined(_MSC_VER) - #define EASTL_CT_ASSERT(expression) typedef EASTL_CT_ASSERTION_TEST< sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >)> EASTL_CT_ASSERT_FAILURE - #elif defined(__ICL) || defined(__ICC) - #define EASTL_CT_ASSERT(expression) typedef char EASTL_PREPROCESSOR_JOIN(EASTL_CT_ASSERT_FAILURE_, __LINE__) [EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >::value] - #elif defined(__MWERKS__) - #define EASTL_CT_ASSERT(expression) enum { EASTL_PREPROCESSOR_JOIN(EASTL_CT_ASSERT_FAILURE_, __LINE__) = sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >) } - #else // GCC, etc. - #define EASTL_CT_ASSERT(expression) typedef EASTL_CT_ASSERTION_TEST< sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >)> EASTL_PREPROCESSOR_JOIN1(EASTL_CT_ASSERT_FAILURE_, __LINE__) - #endif -#else - #define EASTL_CT_ASSERT(expression) -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_DEBUG_BREAK -// -// This function causes an app to immediately stop under the debugger. -// It is implemented as a macro in order to allow stopping at the site -// of the call. -// -// -// Example usage: -// EASTL_DEBUG_BREAK(); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_DEBUG_BREAK - #if defined(_MSC_VER) && (_MSC_VER >= 1300) - #define EASTL_DEBUG_BREAK() __debugbreak() // This is a compiler intrinsic which will map to appropriate inlined asm for the platform. - #elif defined(EA_PROCESSOR_MIPS) // - #define EASTL_DEBUG_BREAK() asm("break") - #elif defined(__SNC__) - #define EASTL_DEBUG_BREAK() *(int*)(0) = 0 - #elif defined(EA_PLATFORM_PS3) - #define EASTL_DEBUG_BREAK() asm volatile("tw 31,1,1") - #elif defined(EA_PROCESSOR_POWERPC) // Generic PowerPC. - #define EASTL_DEBUG_BREAK() asm(".long 0") // This triggers an exception by executing opcode 0x00000000. - #elif (defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64)) && defined(EA_ASM_STYLE_INTEL) - #define EASTL_DEBUG_BREAK() { __asm int 3 } - #elif (defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64)) && (defined(EA_ASM_STYLE_ATT) || defined(__GNUC__)) - #define EASTL_DEBUG_BREAK() asm("int3") - #else - void EASTL_DEBUG_BREAK(); // User must define this externally. - #endif -#else - void EASTL_DEBUG_BREAK(); // User must define this externally. -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ALLOCATOR_COPY_ENABLED -// -// Defined as 0 or 1. Default is 0 (disabled) until some future date. -// If enabled (1) then container operator= copies the allocator from the -// source container. It ideally should be set to enabled but for backwards -// compatibility with older versions of EASTL it is currently set to 0. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ALLOCATOR_COPY_ENABLED - #define EASTL_ALLOCATOR_COPY_ENABLED 0 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_FIXED_SIZE_TRACKING_ENABLED -// -// Defined as an integer >= 0. Default is same as EASTL_DEBUG. -// If EASTL_FIXED_SIZE_TRACKING_ENABLED is enabled, then fixed -// containers in debug builds track the max count of objects -// that have been in the container. This allows for the tuning -// of fixed container sizes to their minimum required size. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_FIXED_SIZE_TRACKING_ENABLED - #define EASTL_FIXED_SIZE_TRACKING_ENABLED EASTL_DEBUG -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_RTTI_ENABLED -// -// Defined as 0 or 1. Default is 1 if RTTI is supported by the compiler. -// This define exists so that we can use some dynamic_cast operations in the -// code without warning. dynamic_cast is only used if the specifically refers -// to it; EASTL won't do dynamic_cast behind your back. -// -// Example usage: -// #if EASTL_RTTI_ENABLED -// pChildClass = dynamic_cast(pParentClass); -// #endif -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_RTTI_ENABLED - #if defined(EA_COMPILER_NO_RTTI) - #define EASTL_RTTI_ENABLED 0 - #else - #define EASTL_RTTI_ENABLED 1 - #endif -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_EXCEPTIONS_ENABLED -// -// Defined as 0 or 1. Default is to follow what the compiler settings are. -// The user can predefine EASTL_EXCEPTIONS_ENABLED to 0 or 1; however, if the -// compiler is set to disable exceptions then EASTL_EXCEPTIONS_ENABLED is -// forced to a value of 0 regardless of the user predefine. -// -/////////////////////////////////////////////////////////////////////////////// - -#if !defined(EASTL_EXCEPTIONS_ENABLED) || ((EASTL_EXCEPTIONS_ENABLED == 1) && defined(EA_COMPILER_NO_EXCEPTIONS)) - #define EASTL_EXCEPTIONS_ENABLED 0 -#endif - - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_STRING_OPT_XXXX -// -// Enables some options / optimizations options that cause the string class -// to behave slightly different from the C++ standard basic_string. These are -// options whereby you can improve performance by avoiding operations that -// in practice may never occur for you. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_STRING_OPT_CHAR_INIT - // Defined as 0 or 1. Default is 1. - // Defines if newly created characters are initialized to 0 or left - // as random values. - // The C++ string standard is to initialize chars to 0. - #define EASTL_STRING_OPT_CHAR_INIT 1 -#endif - -#ifndef EASTL_STRING_OPT_EXPLICIT_CTORS - // Defined as 0 or 1. Default is 0. - // Defines if we should implement explicity in constructors where the C++ - // standard string does not. The advantage of enabling explicit constructors - // is that you can do this: string s = "hello"; in addition to string s("hello"); - // The disadvantage of enabling explicity constructors is that there can be - // silent conversions done which impede performance if the user isn't paying - // attention. - // C++ standard string ctors are not explicit. - #define EASTL_STRING_OPT_EXPLICIT_CTORS 0 -#endif - -#ifndef EASTL_STRING_OPT_LENGTH_ERRORS - // Defined as 0 or 1. Default is equal to EASTL_EXCEPTIONS_ENABLED. - // Defines if we check for string values going beyond kMaxSize - // (a very large value) and throw exections if so. - // C++ standard strings are expected to do such checks. - #define EASTL_STRING_OPT_LENGTH_ERRORS EASTL_EXCEPTIONS_ENABLED -#endif - -#ifndef EASTL_STRING_OPT_RANGE_ERRORS - // Defined as 0 or 1. Default is equal to EASTL_EXCEPTIONS_ENABLED. - // Defines if we check for out-of-bounds references to string - // positions and throw exceptions if so. Well-behaved code shouldn't - // refence out-of-bounds positions and so shouldn't need these checks. - // C++ standard strings are expected to do such range checks. - #define EASTL_STRING_OPT_RANGE_ERRORS EASTL_EXCEPTIONS_ENABLED -#endif - -#ifndef EASTL_STRING_OPT_ARGUMENT_ERRORS - // Defined as 0 or 1. Default is 0. - // Defines if we check for NULL ptr arguments passed to string - // functions by the user and throw exceptions if so. Well-behaved code - // shouldn't pass bad arguments and so shouldn't need these checks. - // Also, some users believe that strings should check for NULL pointers - // in all their arguments and do no-ops if so. This is very debatable. - // C++ standard strings are not required to check for such argument errors. - #define EASTL_STRING_OPT_ARGUMENT_ERRORS 0 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ABSTRACT_STRING_ENABLED -// -// Defined as 0 or 1. Default is 0 until abstract string is fully tested. -// Defines whether the proposed replacement for the string module is enabled. -// See bonus/abstract_string.h for more information. -// -#ifndef EASTL_ABSTRACT_STRING_ENABLED - #define EASTL_ABSTRACT_STRING_ENABLED 0 -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_BITSET_SIZE_T -// -// Defined as 0 or 1. Default is 1. -// Controls whether bitset uses size_t or eastl_size_t. -// -#ifndef EASTL_BITSET_SIZE_T - #define EASTL_BITSET_SIZE_T 1 -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_LIST_SIZE_CACHE -// -// Defined as 0 or 1. Default is 0. -// If defined as 1, the list and slist containers (and possibly any additional -// containers as well) keep a member mSize (or similar) variable which allows -// the size() member function to execute in constant time (a.k.a. O(1)). -// There are debates on both sides as to whether it is better to have this -// cached value or not, as having it entails some cost (memory and code). -// To consider: Make list size caching an optional template parameter. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_LIST_SIZE_CACHE - #define EASTL_LIST_SIZE_CACHE 0 -#endif - -#ifndef EASTL_SLIST_SIZE_CACHE - #define EASTL_SLIST_SIZE_CACHE 0 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_MAX_STACK_USAGE -// -// Defined as an integer greater than zero. Default is 4000. -// There are some places in EASTL where temporary objects are put on the -// stack. A common example of this is in the implementation of container -// swap functions whereby a temporary copy of the container is made. -// There is a problem, however, if the size of the item created on the stack -// is very large. This can happen with fixed-size containers, for example. -// The EASTL_MAX_STACK_USAGE define specifies the maximum amount of memory -// (in bytes) that the given platform/compiler will safely allow on the stack. -// Platforms such as Windows will generally allow larger values than embedded -// systems or console machines, but it is usually a good idea to stick with -// a max usage value that is portable across all platforms, lest the user be -// surprised when something breaks as it is ported to another platform. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_MAX_STACK_USAGE - #define EASTL_MAX_STACK_USAGE 4000 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_VA_COPY_ENABLED -// -// Defined as 0 or 1. Default is 1 for compilers that need it, 0 for others. -// Some compilers on some platforms implement va_list whereby its contents -// are destroyed upon usage, even if passed by value to another function. -// With these compilers you can use va_copy to restore the a va_list. -// Known compiler/platforms that destroy va_list contents upon usage include: -// CodeWarrior on PowerPC -// GCC on x86-64 -// However, va_copy is part of the C99 standard and not part of earlier C and -// C++ standards. So not all compilers support it. VC++ doesn't support va_copy, -// but it turns out that VC++ doesn't need it on the platforms it supports. -// For example usage, see the EASTL string.h file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_VA_COPY_ENABLED - #if defined(__MWERKS__) || (defined(__GNUC__) && (__GNUC__ >= 3) && (!defined(__i386__) || defined(__x86_64__)) && !defined(__ppc__) && !defined(__PPC__) && !defined(__PPC64__)) - #define EASTL_VA_COPY_ENABLED 1 - #else - #define EASTL_VA_COPY_ENABLED 0 - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_LIST_PROXY_ENABLED -// -#if !defined(EASTL_LIST_PROXY_ENABLED) - // GCC with -fstrict-aliasing has bugs (or undocumented functionality in their - // __may_alias__ implementation. The compiler gets confused about function signatures. - // VC8 (1400) doesn't need the proxy because it has built-in smart debugging capabilities. - #if defined(EASTL_DEBUG) && (!defined(__GNUC__) || defined(__SNC__)) && (!defined(_MSC_VER) || (_MSC_VER < 1400)) - #define EASTL_LIST_PROXY_ENABLED 1 - #define EASTL_LIST_PROXY_MAY_ALIAS EASTL_MAY_ALIAS - #else - #define EASTL_LIST_PROXY_ENABLED 0 - #define EASTL_LIST_PROXY_MAY_ALIAS - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_STD_ITERATOR_CATEGORY_ENABLED -// -// Defined as 0 or 1. Default is 1. -// If defined as non-zero, EASTL iterator categories (iterator.h's input_iterator_tag, -// forward_iterator_tag, etc.) are defined to be those from std C++ in the std -// namespace. The reason for wanting to enable such a feature is that it allows -// EASTL containers and algorithms to work with std STL containes and algorithms. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_STD_ITERATOR_CATEGORY_ENABLED - #define EASTL_STD_ITERATOR_CATEGORY_ENABLED 1 -#endif - -#if EASTL_STD_ITERATOR_CATEGORY_ENABLED - #define EASTL_ITC_NS std -#else - #define EASTL_ITC_NS eastl -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_VALIDATION_ENABLED -// -// Defined as an integer >= 0. Default is to be equal to EASTL_DEBUG. -// If nonzero, then a certain amount of automatic runtime validation is done. -// Runtime validation is not considered the same thing as asserting that user -// input values are valid. Validation refers to internal consistency checking -// of the validity of containers and their iterators. Validation checking is -// something that often involves significantly more than basic assertion -// checking, and it may sometimes be desirable to disable it. -// This macro would generally be used internally by EASTL. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_VALIDATION_ENABLED - #define EASTL_VALIDATION_ENABLED EASTL_DEBUG -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_VALIDATE_COMPARE -// -// Defined as EASTL_ASSERT or defined away. Default is EASTL_ASSERT if EASTL_VALIDATION_ENABLED is enabled. -// This is used to validate user-supplied comparison functions, particularly for sorting purposes. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_VALIDATE_COMPARE_ENABLED - #define EASTL_VALIDATE_COMPARE_ENABLED EASTL_VALIDATION_ENABLED -#endif - -#if EASTL_VALIDATE_COMPARE_ENABLED - #define EASTL_VALIDATE_COMPARE EASTL_ASSERT -#else - #define EASTL_VALIDATE_COMPARE(expression) -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_VALIDATE_INTRUSIVE_LIST -// -// Defined as an integral value >= 0. Controls the amount of automatic validation -// done by intrusive_list. A value of 0 means no automatic validation is done. -// As of this writing, EASTL_VALIDATE_INTRUSIVE_LIST defaults to 0, as it makes -// the intrusive_list_node become a non-POD, which may be an issue for some code. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_VALIDATE_INTRUSIVE_LIST - #define EASTL_VALIDATE_INTRUSIVE_LIST 0 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_FORCE_INLINE -// -// Defined as a "force inline" expression or defined away. -// You generally don't need to use forced inlining with the Microsoft and -// Metrowerks compilers, but you may need it with the GCC compiler (any version). -// -// Example usage: -// template -// EASTL_FORCE_INLINE typename vector::size_type -// vector::size() const -// { return mpEnd - mpBegin; } -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_FORCE_INLINE - #define EASTL_FORCE_INLINE EA_FORCE_INLINE -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_MAY_ALIAS -// -// Defined as a macro that wraps the GCC may_alias attribute. This attribute -// has no significance for VC++ because VC++ doesn't support the concept of -// strict aliasing. Users should avoid writing code that breaks strict -// aliasing rules; EASTL_MAY_ALIAS is for cases with no alternative. -// -// Example usage: -// uint32_t value EASTL_MAY_ALIAS; -// -// Example usage: -// typedef uint32_t EASTL_MAY_ALIAS value_type; -// value_type value; -// -#if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303) - #define EASTL_MAY_ALIAS __attribute__((__may_alias__)) -#else - #define EASTL_MAY_ALIAS -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_LIKELY / EASTL_UNLIKELY -// -// Defined as a macro which gives a hint to the compiler for branch -// prediction. GCC gives you the ability to manually give a hint to -// the compiler about the result of a comparison, though it's often -// best to compile shipping code with profiling feedback under both -// GCC (-fprofile-arcs) and VC++ (/LTCG:PGO, etc.). However, there -// are times when you feel very sure that a boolean expression will -// usually evaluate to either true or false and can help the compiler -// by using an explicity directive... -// -// Example usage: -// if(EASTL_LIKELY(a == 0)) // Tell the compiler that a will usually equal 0. -// { ... } -// -// Example usage: -// if(EASTL_UNLIKELY(a == 0)) // Tell the compiler that a will usually not equal 0. -// { ... } -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_LIKELY - #if defined(__GNUC__) && (__GNUC__ >= 3) - #define EASTL_LIKELY(x) __builtin_expect(!!(x), true) - #define EASTL_UNLIKELY(x) __builtin_expect(!!(x), false) - #else - #define EASTL_LIKELY(x) (x) - #define EASTL_UNLIKELY(x) (x) - #endif -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_MINMAX_ENABLED -// -// Defined as 0 or 1; default is 1. -// Specifies whether the min and max algorithms are available. -// It may be useful to disable the min and max algorithems because sometimes -// #defines for min and max exist which would collide with EASTL min and max. -// Note that there are already alternative versions of min and max in EASTL -// with the min_alt and max_alt functions. You can use these without colliding -// with min/max macros that may exist. -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef EASTL_MINMAX_ENABLED - #define EASTL_MINMAX_ENABLED 1 -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_NOMINMAX -// -// Defined as 0 or 1; default is 1. -// MSVC++ has #defines for min/max which collide with the min/max algorithm -// declarations. If EASTL_NOMINMAX is defined as 1, then we undefine min and -// max if they are #defined by an external library. This allows our min and -// max definitions in algorithm.h to work as expected. An alternative to -// the enabling of EASTL_NOMINMAX is to #define NOMINMAX in your project -// settings if you are compiling for Windows. -// Note that this does not control the availability of the EASTL min and max -// algorithms; the EASTL_MINMAX_ENABLED configuration parameter does that. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_NOMINMAX - #define EASTL_NOMINMAX 1 -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ALIGN_OF -// -// Determines the alignment of a type. -// -// Example usage: -// size_t alignment = EASTL_ALIGN_OF(int); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ALIGN_OF - #if defined(__MWERKS__) - #define EASTL_ALIGN_OF(type) ((size_t)__alignof__(type)) - #elif !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x doesn't do __alignof correctly all the time. - #define EASTL_ALIGN_OF __alignof - #else - #define EASTL_ALIGN_OF(type) ((size_t)offsetof(struct{ char c; type m; }, m)) - #endif -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// eastl_size_t -// -// Defined as an unsigned integer type, usually either size_t or uint32_t. -// Defaults to uint32_t instead of size_t because the latter wastes memory -// and is sometimes slower on 64 bit machines. -// -// Example usage: -// eastl_size_t n = intVector.size(); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_SIZE_T - #if(EA_PLATFORM_WORD_SIZE == 4) // If (sizeof(size_t) == 4) and we can thus use size_t as-is... - #include - #define EASTL_SIZE_T size_t - #define EASTL_SSIZE_T intptr_t - #else - #define EASTL_SIZE_T uint32_t - #define EASTL_SSIZE_T int32_t - #endif -#endif - -typedef EASTL_SIZE_T eastl_size_t; // Same concept as std::size_t. -typedef EASTL_SSIZE_T eastl_ssize_t; // Signed version of eastl_size_t. Concept is similar to Posix's ssize_t. - - - - - - -/////////////////////////////////////////////////////////////////////////////// -// AddRef / Release -// -// AddRef and Release are used for "intrusive" reference counting. By the term -// "intrusive", we mean that the reference count is maintained by the object -// and not by the user of the object. Given that an object implements referencing -// counting, the user of the object needs to be able to increment and decrement -// that reference count. We do that via the venerable AddRef and Release functions -// which the object must supply. These defines here allow us to specify the name -// of the functions. They could just as well be defined to addref and delref or -// IncRef and DecRef. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTLAddRef - #define EASTLAddRef AddRef -#endif - -#ifndef EASTLRelease - #define EASTLRelease Release -#endif - - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_ALLOCATOR_EXPLICIT_ENABLED -// -// Defined as 0 or 1. Default is 0 for now but ideally would be changed to -// 1 some day. It's 0 because setting it to 1 breaks some existing code. -// This option enables the allocator ctor to be explicit, which avoids -// some undesirable silent conversions, especially with the string class. -// -// Example usage: -// class allocator -// { -// public: -// EASTL_ALLOCATOR_EXPLICIT allocator(const char* pName); -// }; -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EASTL_ALLOCATOR_EXPLICIT_ENABLED - #define EASTL_ALLOCATOR_EXPLICIT_ENABLED 0 -#endif - -#if EASTL_ALLOCATOR_EXPLICIT_ENABLED - #define EASTL_ALLOCATOR_EXPLICIT explicit -#else - #define EASTL_ALLOCATOR_EXPLICIT -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL allocator -// -// The EASTL allocator system allows you to redefine how memory is allocated -// via some defines that are set up here. In the container code, memory is -// allocated via macros which expand to whatever the user has them set to -// expand to. Given that there are multiple allocator systems available, -// this system allows you to configure it to use whatever system you want, -// provided your system meets the requirements of this library. -// The requirements are: -// -// - Must be constructable via a const char* (name) parameter. -// Some uses of allocators won't require this, however. -// - Allocate a block of memory of size n and debug name string. -// - Allocate a block of memory of size n, debug name string, -// alignment a, and offset o. -// - Free memory allocated via either of the allocation functions above. -// - Provide a default allocator instance which can be used if the user -// doesn't provide a specific one. -// -/////////////////////////////////////////////////////////////////////////////// - -// namespace eastl -// { -// class allocator -// { -// allocator(const char* pName = NULL); -// -// void* allocate(size_t n, int flags = 0); -// void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0); -// void deallocate(void* p, size_t n); -// -// const char* get_name() const; -// void set_name(const char* pName); -// }; -// -// allocator* GetDefaultAllocator(); // This is used for anonymous allocations. -// } - -#ifndef EASTLAlloc // To consider: Instead of calling through pAllocator, just go directly to operator new, since that's what allocator does. - #define EASTLAlloc(allocator, n) (allocator).allocate(n); -#endif - -#ifndef EASTLAllocFlags // To consider: Instead of calling through pAllocator, just go directly to operator new, since that's what allocator does. - #define EASTLAllocFlags(allocator, n, flags) (allocator).allocate(n, flags); -#endif - -#ifndef EASTLAllocAligned - #define EASTLAllocAligned(allocator, n, alignment, offset) (allocator).allocate((n), (alignment), (offset)) -#endif - -#ifndef EASTLFree - #define EASTLFree(allocator, p, size) (allocator).deallocate((p), (size)) -#endif - -#ifndef EASTLAllocatorType - #define EASTLAllocatorType eastl::allocator -#endif - -#ifndef EASTLAllocatorDefault - // EASTLAllocatorDefault returns the default allocator instance. This is not a global - // allocator which implements all container allocations but is the allocator that is - // used when EASTL needs to allocate memory internally. There are very few cases where - // EASTL allocates memory internally, and in each of these it is for a sensible reason - // that is documented to behave as such. - #define EASTLAllocatorDefault eastl::GetDefaultAllocator -#endif - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eabase_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eabase_eastl.h deleted file mode 100644 index f107dacd9ced..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eabase_eastl.h +++ /dev/null @@ -1,862 +0,0 @@ -/* -Copyright (C) 2009 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/*----------------------------------------------------------------------------- - * eabase.h - * - * Copyright (c) 2002 - 2005 Electronic Arts Inc. All rights reserved. - * Maintained by Paul Pedriana, Maxis - *---------------------------------------------------------------------------*/ - - -#ifndef INCLUDED_eabase_H -#define INCLUDED_eabase_H - - -// Identify the compiler and declare the EA_COMPILER_xxxx defines -#ifndef INCLUDED_eacompiler_H - #include -#endif - -// Identify traits which this compiler supports, or does not support -#ifndef INCLUDED_eacompilertraits_H - #include -#endif - -// Identify the platform and declare the EA_xxxx defines -#ifndef INCLUDED_eaplatform_H - #include -#endif - - - -/////////////////////////////////////////////////////////////////////////////// -// EABASE_VERSION -// -// We more or less follow the conventional EA packaging approach to versioning -// here. A primary distinction here is that minor versions are defined as two -// digit entities (e.g. .03") instead of minimal digit entities ".3"). The logic -// here is that the value is a counter and not a floating point fraction. -// Note that the major version doesn't have leading zeros. -// -// Example version strings: -// "0.91.00" // Major version 0, minor version 91, patch version 0. -// "1.00.00" // Major version 1, minor and patch version 0. -// "3.10.02" // Major version 3, minor version 10, patch version 02. -// "12.03.01" // Major version 12, minor version 03, patch version -// -// Example usage: -// printf("EABASE version: %s", EABASE_VERSION); -// printf("EABASE version: %d.%d.%d", EABASE_VERSION_N / 10000 % 100, EABASE_VERSION_N / 100 % 100, EABASE_VERSION_N % 100); -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef EABASE_VERSION - #define EABASE_VERSION "2.00.22" - #define EABASE_VERSION_N 20022 -#endif - - - -// ------------------------------------------------------------------------ -// The C++ standard defines size_t as a built-in type. Some compilers are -// not standards-compliant in this respect, so we need an additional include. -// The case is similar with wchar_t under C++. - -#if defined(EA_COMPILER_GNUC) || defined(EA_COMPILER_MSVC) || defined(EA_WCHAR_T_NON_NATIVE) - #include -#endif - - -// ------------------------------------------------------------------------ -// Ensure this header file is only processed once (with certain compilers) -// GCC doesn't need such a pragma because it has special recognition for -// include guards (such as that above) and effectively implements the same -// thing without having to resort to non-portable pragmas. It is possible -// that the decision to use pragma once here is ill-advised, perhaps because -// some compilers masquerade as MSVC but don't implement all features. -#if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_METROWERKS) - #pragma once -#endif - - -// ------------------------------------------------------------------------ -// By default, GCC on certain platforms defines NULL as ((void*)0), which is the -// C definition. This causes all sort of problems for C++ code, so it is -// worked around by undefining NULL. - -#if defined(NULL) - #undef NULL -#endif - - -// ------------------------------------------------------------------------ -// Define the NULL pointer. This is normally defined in , but we -// don't want to force a global dependency on that header, so the definition -// is duplicated here. - -#if defined(__cplusplus) - #define NULL 0 -#else - #define NULL ((void*)0) -#endif - - -// ------------------------------------------------------------------------ -// C98/99 Standard typedefs. From the ANSI ISO/IEC 9899 standards document -// Most recent versions of the gcc-compiler come with these defined in -// inttypes.h or stddef.h. Determining if they are predefined can be -// tricky, so we expect some problems on non-standard compilers - -// ------------------------------------------------------------------------ -// We need to test this after we potentially include stddef.h, otherwise we -// would have put this into the compilertraits header. -#if !defined(EA_COMPILER_HAS_INTTYPES) && (!defined(_MSC_VER) || (_MSC_VER > 1500)) && (defined(EA_COMPILER_IS_C99) || defined(INT8_MIN) || defined(EA_COMPILER_HAS_C99_TYPES) || defined(_SN_STDINT_H)) - #define EA_COMPILER_HAS_INTTYPES -#endif - - -#ifdef EA_COMPILER_HAS_INTTYPES // If the compiler supports inttypes... - // ------------------------------------------------------------------------ - // Include the stdint header to define and derive the required types. - // Additionally include inttypes.h as many compilers, including variations - // of GCC define things in inttypes.h that the C99 standard says goes - // in stdint.h. - // - // The C99 standard specifies that inttypes.h only define printf/scanf - // format macros if __STDC_FORMAT_MACROS is defined before #including - // inttypes.h. For consistency, we do that here. - #ifndef __STDC_FORMAT_MACROS - #define __STDC_FORMAT_MACROS - #endif - #if !defined(__psp__) // The GCC compiler defines standard int types (e.g. uint32_t) but not PRId8, etc. - #include // PRId8, SCNd8, etc. - #endif - #include // int32_t, INT64_C, UINT8_MAX, etc. - #include // float_t, double_t, etc. - #include // FLT_EVAL_METHOD. - - #if !defined(FLT_EVAL_METHOD) && (defined(__FLT_EVAL_METHOD__) || defined(_FEVAL)) // GCC 3.x defines __FLT_EVAL_METHOD__ instead of the C99 standard FLT_EVAL_METHOD. - #ifdef __FLT_EVAL_METHOD__ - #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ - #else - #define FLT_EVAL_METHOD _FEVAL - #endif - #endif - - // MinGW GCC (up to at least v4.3.0-20080502) mistakenly neglects to define float_t and double_t. - // This appears to be an acknowledged bug as of March 2008 and is scheduled to be fixed. - // Similarly, Android uses a mix of custom standard library headers which don't define float_t and double_t. - #if defined(__MINGW32__) || defined(EA_PLATFORM_ANDROID) - #if defined(__FLT_EVAL_METHOD__) - #if(__FLT_EVAL_METHOD__== 0) - typedef float float_t; - typedef double double_t; - #elif(__FLT_EVAL_METHOD__ == 1) - typedef double float_t; - typedef double double_t; - #elif(__FLT_EVAL_METHOD__ == 2) - typedef long double float_t; - typedef long double double_t; - #endif - #else - typedef float float_t; - typedef double double_t; - #endif - #endif - - // Airplay's pretty broken for these types (at least as of 4.1) - #if defined __S3E__ - - typedef float float_t; - typedef double double_t; - - #undef INT32_C - #undef UINT32_C - #undef INT64_C - #undef UINT64_C - #define INT32_C(x) x##L - #define UINT32_C(x) x##UL - #define INT64_C(x) x##LL - #define UINT64_C(x) x##ULL - - #define EA_PRI_64_LENGTH_SPECIFIER "ll" - #define EA_SCN_64_LENGTH_SPECIFIER "ll" - - #define SCNd16 "hd" - #define SCNi16 "hi" - #define SCNo16 "ho" - #define SCNu16 "hu" - #define SCNx16 "hx" - - #define SCNd32 "d" // This works for both 32 bit and 64 bit systems, as we assume LP64 conventions. - #define SCNi32 "i" - #define SCNo32 "o" - #define SCNu32 "u" - #define SCNx32 "x" - - #define SCNd64 EA_SCN_64_LENGTH_SPECIFIER "d" - #define SCNi64 EA_SCN_64_LENGTH_SPECIFIER "i" - #define SCNo64 EA_SCN_64_LENGTH_SPECIFIER "o" - #define SCNu64 EA_SCN_64_LENGTH_SPECIFIER "u" - #define SCNx64 EA_SCN_64_LENGTH_SPECIFIER "x" - - #define PRIdPTR PRId32 // Usage of pointer values will generate warnings with - #define PRIiPTR PRIi32 // some compilers because they are defined in terms of - #define PRIoPTR PRIo32 // integers. However, you can't simply use "p" because - #define PRIuPTR PRIu32 // 'p' is interpreted in a specific and often different - #define PRIxPTR PRIx32 // way by the library. - #define PRIXPTR PRIX32 - - #define PRId8 "hhd" - #define PRIi8 "hhi" - #define PRIo8 "hho" - #define PRIu8 "hhu" - #define PRIx8 "hhx" - #define PRIX8 "hhX" - - #define PRId16 "hd" - #define PRIi16 "hi" - #define PRIo16 "ho" - #define PRIu16 "hu" - #define PRIx16 "hx" - #define PRIX16 "hX" - - #define PRId32 "d" // This works for both 32 bit and 64 bit systems, as we assume LP64 conventions. - #define PRIi32 "i" - #define PRIo32 "o" - #define PRIu32 "u" - #define PRIx32 "x" - #define PRIX32 "X" - - #define PRId64 EA_PRI_64_LENGTH_SPECIFIER "d" - #define PRIi64 EA_PRI_64_LENGTH_SPECIFIER "i" - #define PRIo64 EA_PRI_64_LENGTH_SPECIFIER "o" - #define PRIu64 EA_PRI_64_LENGTH_SPECIFIER "u" - #define PRIx64 EA_PRI_64_LENGTH_SPECIFIER "x" - #define PRIX64 EA_PRI_64_LENGTH_SPECIFIER "X" - #endif - - // The CodeSourcery definitions of PRIxPTR and SCNxPTR are broken for 32 bit systems. - #if defined(__SIZEOF_SIZE_T__) && (__SIZEOF_SIZE_T__ == 4) && (defined(__have_long64) || defined(__have_longlong64) || defined(__S3E__)) - #undef PRIdPTR - #define PRIdPTR "d" - #undef PRIiPTR - #define PRIiPTR "i" - #undef PRIoPTR - #define PRIoPTR "o" - #undef PRIuPTR - #define PRIuPTR "u" - #undef PRIxPTR - #define PRIxPTR "x" - #undef PRIXPTR - #define PRIXPTR "X" - - #undef SCNdPTR - #define SCNdPTR "d" - #undef SCNiPTR - #define SCNiPTR "i" - #undef SCNoPTR - #define SCNoPTR "o" - #undef SCNuPTR - #define SCNuPTR "u" - #undef SCNxPTR - #define SCNxPTR "x" - #endif -#else // else we must implement types ourselves. - - #if !defined(__S3E__) - #if !defined(__BIT_TYPES_DEFINED__) && !defined(__int8_t_defined) - typedef signed char int8_t; //< 8 bit signed integer - #endif - #if !defined( __int8_t_defined ) - typedef signed short int16_t; //< 16 bit signed integer - typedef signed int int32_t; //< 32 bit signed integer. This works for both 32 bit and 64 bit platforms, as we assume the LP64 is followed. - #define __int8_t_defined - #endif - typedef unsigned char uint8_t; //< 8 bit unsigned integer - typedef unsigned short uint16_t; //< 16 bit unsigned integer - #if !defined( __uint32_t_defined ) - typedef unsigned int uint32_t; //< 32 bit unsigned integer. This works for both 32 bit and 64 bit platforms, as we assume the LP64 is followed. - #define __uint32_t_defined - #endif - #endif - - // According to the C98/99 standard, FLT_EVAL_METHOD defines control the - // width used for floating point _t types. - #if defined(__MWERKS__) && ((defined(_MSL_C99) && (_MSL_C99 == 1)) || (__MWERKS__ < 0x4000)) - // Metrowerks defines FLT_EVAL_METHOD and - // float_t/double_t under this condition. - #elif defined(FLT_EVAL_METHOD) - #if (FLT_EVAL_METHOD == 0) - typedef float float_t; - typedef double double_t; - #elif (FLT_EVAL_METHOD == 1) - typedef double float_t; - typedef double double_t; - #elif (FLT_EVAL_METHOD == 2) - typedef long double float_t; - typedef long double double_t; - #endif - #else - #define FLT_EVAL_METHOD 0 - typedef float float_t; - typedef double double_t; - #endif - - #if defined(EA_PLATFORM_LINUX) || defined(EA_PLATFORM_PS3) || defined(EA_PLATFORM_PS3_SPU) - typedef signed long long int64_t; - typedef unsigned long long uint64_t; - - #elif defined(EA_PLATFORM_SUN) || defined(EA_PLATFORM_SGI) - #if (EA_PLATFORM_PTR_SIZE == 4) - typedef signed long long int64_t; - typedef unsigned long long uint64_t; - #else - typedef signed long int64_t; - typedef unsigned long uint64_t; - #endif - - #elif defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOX) || defined(EA_PLATFORM_XENON) || defined(EA_PLATFORM_MAC) - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) || defined(EA_COMPILER_INTEL) - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; - #else // GCC, Metrowerks, etc. - typedef long long int64_t; - typedef unsigned long long uint64_t; - #endif - #elif defined(EA_PLATFORM_AIRPLAY) - #else - typedef signed long long int64_t; - typedef unsigned long long uint64_t; - #endif - - - // ------------------------------------------------------------------------ - // macros for declaring constants in a portable way. - // - // e.g. int64_t x = INT64_C(1234567812345678); - // e.g. int64_t x = INT64_C(0x1111111122222222); - // e.g. uint64_t x = UINT64_C(0x1111111122222222); - - #ifndef INT8_C_DEFINED // If the user hasn't already defined these... - #define INT8_C_DEFINED - - // VC++ 7.0 and earlier don't handle the LL suffix. - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) - #ifndef INT8_C - #define INT8_C(x) int8_t(x) // x##i8 doesn't work satisfactorilly because -128i8 generates an out of range warning. - #endif - #ifndef UINT8_C - #define UINT8_C(x) uint8_t(x) - #endif - #ifndef INT16_C - #define INT16_C(x) int16_t(x) // x##i16 doesn't work satisfactorilly because -32768i8 generates an out of range warning. - #endif - #ifndef UINT16_C - #define UINT16_C(x) uint16_t(x) - #endif - #ifndef INT32_C - #define INT32_C(x) x##i32 - #endif - #ifndef UINT32_C - #define UINT32_C(x) x##ui32 - #endif - #ifndef INT64_C - #define INT64_C(x) x##i64 - #endif - #ifndef UINT64_C - #define UINT64_C(x) x##ui64 - #endif - - #elif !defined(__STDC_CONSTANT_MACROS) // __STDC_CONSTANT_MACROS is defined by GCC 3 and later when INT8_C(), etc. are defined. - #define INT8_C(x) int8_t(x) // For the majority of compilers and platforms, long is 32 bits and long long is 64 bits. - #define UINT8_C(x) uint8_t(x) - #define INT16_C(x) int16_t(x) - #define UINT16_C(x) uint16_t(x) // Possibly we should make this be uint16_t(x##u). Let's see how compilers react before changing this. - #if defined(EA_PLATFORM_PS3) // PS3 defines long as 64 bit, so we cannot use any size suffix. - #define INT32_C(x) int32_t(x) - #define UINT32_C(x) uint32_t(x) - #else // Else we are working on a platform whereby sizeof(long) == sizeof(int32_t). - #define INT32_C(x) x##L - #define UINT32_C(x) x##UL - #endif - #define INT64_C(x) x##LL // The way to deal with this is to compare ULONG_MAX to 0xffffffff and if not equal, then remove the L. - #define UINT64_C(x) x##ULL // We need to follow a similar approach for LL. - #endif - #endif - - // ------------------------------------------------------------------------ - // type sizes - #ifndef INT8_MAX_DEFINED // If the user hasn't already defined these... - #define INT8_MAX_DEFINED - - // The value must be 2^(n-1)-1 - #ifndef INT8_MAX - #define INT8_MAX 127 - #endif - #ifndef INT16_MAX - #define INT16_MAX 32767 - #endif - #ifndef INT32_MAX - #define INT32_MAX 2147483647 - #endif - #ifndef INT64_MAX - #define INT64_MAX INT64_C(9223372036854775807) - #endif - - // The value must be either -2^(n-1) or 1-2(n-1). - #ifndef INT8_MIN - #define INT8_MIN -128 - #endif - #ifndef INT16_MIN - #define INT16_MIN -32768 - #endif - #ifndef INT32_MIN - #define INT32_MIN (-INT32_MAX - 1) // -2147483648 - #endif - #ifndef INT64_MIN - #define INT64_MIN (-INT64_MAX - 1) // -9223372036854775808 - #endif - - // The value must be 2^n-1 - #ifndef UINT8_MAX - #define UINT8_MAX 0xffU // 255 - #endif - #ifndef UINT16_MAX - #define UINT16_MAX 0xffffU // 65535 - #endif - #ifndef UINT32_MAX - #define UINT32_MAX UINT32_C(0xffffffff) // 4294967295 - #endif - #ifndef UINT64_MAX - #define UINT64_MAX UINT64_C(0xffffffffffffffff) // 18446744073709551615 - #endif - #endif - - // ------------------------------------------------------------------------ - // sized printf and scanf format specifiers - // See the C99 standard, section 7.8.1 -- Macros for format specifiers. - // - // The C99 standard specifies that inttypes.h only define printf/scanf - // format macros if __STDC_FORMAT_MACROS is defined before #including - // inttypes.h. For consistency, we define both __STDC_FORMAT_MACROS and - // the printf format specifiers here. We also skip the "least/most" - // variations of these specifiers, as we've decided to do so with - // basic types. - // - // For 64 bit systems, we assume the LP64 standard is followed - // (as opposed to ILP64, etc.) For 32 bit systems, we assume the - // ILP32 standard is followed. See: - // http://www.opengroup.org/public/tech/aspen/lp64_wp.htm - // for information about this. Thus, on both 32 and 64 bit platforms, - // %l refers to 32 bit data while %ll refers to 64 bit data. - - #ifndef __STDC_FORMAT_MACROS - #define __STDC_FORMAT_MACROS - #endif - - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) // VC++ 7.1+ understands long long as a data type but doesn't accept %ll as a printf specifier. - #define EA_PRI_64_LENGTH_SPECIFIER "I64" - #define EA_SCN_64_LENGTH_SPECIFIER "I64" - #else - #define EA_PRI_64_LENGTH_SPECIFIER "ll" - #define EA_SCN_64_LENGTH_SPECIFIER "ll" - #endif // It turns out that some platforms use %q to represent a 64 bit value, but these are not relevant to us at this time. - - // Printf format specifiers - #if defined(EA_COMPILER_IS_C99) || defined(EA_COMPILER_GNUC) || defined(EA_COMPILER_METROWERKS) // || defined(EA_COMPILER_INTEL) ? - #define PRId8 "hhd" - #define PRIi8 "hhi" - #define PRIo8 "hho" - #define PRIu8 "hhu" - #define PRIx8 "hhx" - #define PRIX8 "hhX" - #else // VC++, Borland, etc. which have no way to specify 8 bit values other than %c. - #define PRId8 "c" // This may not work properly but it at least will not crash. Try using 16 bit versions instead. - #define PRIi8 "c" // " - #define PRIo8 "o" // " - #define PRIu8 "u" // " - #define PRIx8 "x" // " - #define PRIX8 "X" // " - #endif - - #define PRId16 "hd" - #define PRIi16 "hi" - #define PRIo16 "ho" - #define PRIu16 "hu" - #define PRIx16 "hx" - #define PRIX16 "hX" - - #define PRId32 "d" // This works for both 32 bit and 64 bit systems, as we assume LP64 conventions. - #define PRIi32 "i" - #define PRIo32 "o" - #define PRIu32 "u" - #define PRIx32 "x" - #define PRIX32 "X" - - #define PRId64 EA_PRI_64_LENGTH_SPECIFIER "d" - #define PRIi64 EA_PRI_64_LENGTH_SPECIFIER "i" - #define PRIo64 EA_PRI_64_LENGTH_SPECIFIER "o" - #define PRIu64 EA_PRI_64_LENGTH_SPECIFIER "u" - #define PRIx64 EA_PRI_64_LENGTH_SPECIFIER "x" - #define PRIX64 EA_PRI_64_LENGTH_SPECIFIER "X" - - #if (EA_PLATFORM_PTR_SIZE == 4) - #define PRIdPTR PRId32 // Usage of pointer values will generate warnings with - #define PRIiPTR PRIi32 // some compilers because they are defined in terms of - #define PRIoPTR PRIo32 // integers. However, you can't simply use "p" because - #define PRIuPTR PRIu32 // 'p' is interpreted in a specific and often different - #define PRIxPTR PRIx32 // way by the library. - #define PRIXPTR PRIX32 - #elif (EA_PLATFORM_PTR_SIZE == 8) - #define PRIdPTR PRId64 - #define PRIiPTR PRIi64 - #define PRIoPTR PRIo64 - #define PRIuPTR PRIu64 - #define PRIxPTR PRIx64 - #define PRIXPTR PRIX64 - #endif - - // Scanf format specifiers - #if defined(EA_COMPILER_IS_C99) || defined(EA_COMPILER_GNUC) || defined(EA_COMPILER_METROWERKS) // || defined(EA_COMPILER_INTEL) ? - #define SCNd8 "hhd" - #define SCNi8 "hhi" - #define SCNo8 "hho" - #define SCNu8 "hhu" - #define SCNx8 "hhx" - #else // VC++, Borland, etc. which have no way to specify 8 bit values other than %c. - #define SCNd8 "c" // This will not work properly but it at least will not crash. Try using 16 bit versions instead. - #define SCNi8 "c" // " - #define SCNo8 "c" // " - #define SCNu8 "c" // " - #define SCNx8 "c" // " - #endif - - #define SCNd16 "hd" - #define SCNi16 "hi" - #define SCNo16 "ho" - #define SCNu16 "hu" - #define SCNx16 "hx" - - #define SCNd32 "d" // This works for both 32 bit and 64 bit systems, as we assume LP64 conventions. - #define SCNi32 "i" - #define SCNo32 "o" - #define SCNu32 "u" - #define SCNx32 "x" - - #define SCNd64 EA_SCN_64_LENGTH_SPECIFIER "d" - #define SCNi64 EA_SCN_64_LENGTH_SPECIFIER "i" - #define SCNo64 EA_SCN_64_LENGTH_SPECIFIER "o" - #define SCNu64 EA_SCN_64_LENGTH_SPECIFIER "u" - #define SCNx64 EA_SCN_64_LENGTH_SPECIFIER "x" - - #if (EA_PLATFORM_PTR_SIZE == 4) - #define SCNdPTR SCNd32 // Usage of pointer values will generate warnings with - #define SCNiPTR SCNi32 // some compilers because they are defined in terms of - #define SCNoPTR SCNo32 // integers. However, you can't simply use "p" because - #define SCNuPTR SCNu32 // 'p' is interpreted in a specific and often different - #define SCNxPTR SCNx32 // way by the library. - #elif (EA_PLATFORM_PTR_SIZE == 8) - #define SCNdPTR SCNd64 - #define SCNiPTR SCNi64 - #define SCNoPTR SCNo64 - #define SCNuPTR SCNu64 - #define SCNxPTR SCNx64 - #endif - -#endif - - -// ------------------------------------------------------------------------ -// bool8_t -// The definition of a bool8_t is controversial with some, as it doesn't -// act just like built-in bool. For example, you can assign -100 to it. -// -#ifndef BOOL8_T_DEFINED // If the user hasn't already defined this... - #define BOOL8_T_DEFINED - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_METROWERKS) || (defined(EA_COMPILER_INTEL) && defined(EA_PLATFORM_WINDOWS)) || defined(EA_COMPILER_BORLAND) - #if defined(__cplusplus) - typedef bool bool8_t; - #else - typedef int8_t bool8_t; - #endif - #else // EA_COMPILER_GNUC generally uses 4 bytes per bool. - typedef int8_t bool8_t; - #endif -#endif - - -// ------------------------------------------------------------------------ -// intptr_t / uintptr_t -// Integer type guaranteed to be big enough to hold -// a native pointer ( intptr_t is defined in STDDEF.H ) -// -#if !defined(_INTPTR_T_DEFINED) && !defined(_intptr_t_defined) && !defined(EA_COMPILER_HAS_C99_TYPES) - #if (EA_PLATFORM_PTR_SIZE == 4) - typedef int32_t intptr_t; - #elif (EA_PLATFORM_PTR_SIZE == 8) - typedef int64_t intptr_t; - #endif - - #define _intptr_t_defined - #define _INTPTR_T_DEFINED -#endif - -#if !defined(_UINTPTR_T_DEFINED) && !defined(_uintptr_t_defined) && !defined(EA_COMPILER_HAS_C99_TYPES) - #if (EA_PLATFORM_PTR_SIZE == 4) - typedef uint32_t uintptr_t; - #elif (EA_PLATFORM_PTR_SIZE == 8) - typedef uint64_t uintptr_t; - #endif - - #define _uintptr_t_defined - #define _UINTPTR_T_DEFINED -#endif - -#if !defined(EA_COMPILER_HAS_INTTYPES) - #ifndef INTMAX_T_DEFINED - #define INTMAX_T_DEFINED - - // At this time, all supported compilers have int64_t as the max - // integer type. Some compilers support a 128 bit inteter type, - // but in those cases it is not a true int128_t but rather a - // crippled data type. - typedef int64_t intmax_t; - typedef uint64_t uintmax_t; - #endif -#endif - - -// ------------------------------------------------------------------------ -// ssize_t -// signed equivalent to size_t. -// This is defined by GCC but not by other compilers. -// -#if !defined(__GNUC__) - // As of this writing, all non-GCC compilers significant to us implement - // uintptr_t the same as size_t. However, this isn't guaranteed to be - // so for all compilers, as size_t may be based on int, long, or long long. - #if defined(_MSC_VER) && (EA_PLATFORM_PTR_SIZE == 8) - typedef __int64 ssize_t; - #elif !defined(__S3E__) - typedef long ssize_t; - #endif -#elif defined(EA_PLATFORM_UNIX) || defined(EA_PLATFORM_MINGW) || defined(__APPLE__) || defined(_BSD_SIZE_T_) // _BSD_SIZE_T_ indicates that Unix-like headers are present, even though it may not be a true Unix platform. - #include -#endif - - -// ------------------------------------------------------------------------ -// Character types - -#if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) - #if defined(EA_WCHAR_T_NON_NATIVE) - // In this case, wchar_t is not defined unless we include - // wchar.h or if the compiler makes it built-in. - #ifdef EA_COMPILER_MSVC - #pragma warning(push, 3) - #endif - #include - #ifdef EA_COMPILER_MSVC - #pragma warning(pop) - #endif - #endif -#endif - - -// ------------------------------------------------------------------------ -// char8_t -- Guaranteed to be equal to the compiler's char data type. -// Some compilers implement char8_t as unsigned, though char -// is usually set to be signed. -// -// char16_t -- This is set to be an unsigned 16 bit value. If the compiler -// has wchar_t as an unsigned 16 bit value, then char16_t is -// set to be the same thing as wchar_t in order to allow the -// user to use char16_t with standard wchar_t functions. -// -// char32_t -- This is set to be an unsigned 32 bit value. If the compiler -// has wchar_t as an unsigned 32 bit value, then char32_t is -// set to be the same thing as wchar_t in order to allow the -// user to use char32_t with standard wchar_t functions. -// -// VS2010 unilaterally defines char16_t and char32_t in its yvals.h header -// unless _HAS_CHAR16_T_LANGUAGE_SUPPORT or _CHAR16T are defined. -// However, VS2010 does not support the C++0x u"" and U"" string literals, -// which makes its definition of char16_t and char32_t somewhat useless. -// Until VC++ supports string literals, the buildystems should define -// _CHAR16T and let EABase define char16_t and EA_CHAR16. -// -// GCC defines char16_t and char32_t in the C compiler in -std=gnu99 mode, -// as __CHAR16_TYPE__ and __CHAR32_TYPE__, and for the C++ compiler -// in -std=c++0x and -std=gnu++0x modes, as char16_t and char32_t too. - -#if !defined(EA_CHAR16_NATIVE) - #if defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT // VS2010+ - #define EA_CHAR16_NATIVE 1 - #elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 404) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__STDC_VERSION__)) // g++ (C++ compiler) 4.4+ with -std=c++0x or gcc (C compiler) 4.4+ with -std=gnu99 - #define EA_CHAR16_NATIVE 1 - #else - #define EA_CHAR16_NATIVE 0 - #endif -#endif - -#if !defined(EA_CHAR32_NATIVE) - #if defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT // VS2010+ - #define EA_CHAR32_NATIVE 1 - #elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 404) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__STDC_VERSION__)) // g++ (C++ compiler) 4.4+ with -std=c++0x or gcc (C compiler) 4.4+ with -std=gnu99 - #define EA_CHAR32_NATIVE 1 - #else - #define EA_CHAR32_NATIVE 0 - #endif -#endif - - -#ifndef CHAR8_T_DEFINED // If the user hasn't already defined these... - #define CHAR8_T_DEFINED - - #if EA_CHAR16_NATIVE - typedef char char8_t; - - // In C++, char16_t and char32_t are already defined by the compiler. - // In MS C, char16_t and char32_t are already defined by the compiler/standard library. - // In GCC C, __CHAR16_TYPE__ and __CHAR32_TYPE__ are defined instead, and we must define char16_t and char32_t from these. - #if defined(__GNUC__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(__CHAR16_TYPE__) // If using GCC and compiling in C... - typedef __CHAR16_TYPE__ char16_t; - typedef __CHAR32_TYPE__ char32_t; - #endif - #elif (EA_WCHAR_SIZE == 2) - typedef char char8_t; - typedef wchar_t char16_t; - typedef uint32_t char32_t; - #else - typedef char char8_t; - typedef uint16_t char16_t; - typedef wchar_t char32_t; - #endif -#endif - - -// EA_CHAR16 / EA_CHAR32 -// -// Supports usage of portable string constants. -// -// Example usage: -// const char16_t* str = EA_CHAR16("Hello world"); -// const char32_t* str = EA_CHAR32("Hello world"); -// const char16_t c = EA_CHAR16('\x3001'); -// const char32_t c = EA_CHAR32('\x3001'); -// -#ifndef EA_CHAR16 - #if EA_CHAR16_NATIVE && !defined(_MSC_VER) // Microsoft doesn't support char16_t string literals. - #define EA_CHAR16(s) u ## s - #elif (EA_WCHAR_SIZE == 2) - #define EA_CHAR16(s) L ## s - #else - //#define EA_CHAR16(s) // Impossible to implement. - #endif -#endif - -#ifndef EA_CHAR32 - #if EA_CHAR32_NATIVE && !defined(_MSC_VER) // Microsoft doesn't support char32_t string literals. - #define EA_CHAR32(s) U ## s - #elif (EA_WCHAR_SIZE == 2) - //#define EA_CHAR32(s) // Impossible to implement. - #else - #define EA_CHAR32(s) L ## s - #endif -#endif - - -// ------------------------------------------------------------------------ -// EAArrayCount -// -// Returns the count of items in a built-in C array. This is a common technique -// which is often used to help properly calculate the number of items in an -// array at runtime in order to prevent overruns, etc. -// -// Example usage: -// int array[75]; -// size_t arrayCount = EAArrayCount(array); // arrayCount is 75. -// -#ifndef EAArrayCount - #define EAArrayCount(x) (sizeof(x) / sizeof(x[0])) -#endif - - -// ------------------------------------------------------------------------ -// static_assert -// -// C++0x static_assert (a.k.a. compile-time assert). -// -// Specification: -// void static_assert(bool const_expression, const char* description); -// -// Example usage: -// static_assert(sizeof(int) == 4, "int must be 32 bits"); -// -#if !defined(EABASE_STATIC_ASSERT_ENABLED) - #if defined(EA_DEBUG) || defined(_DEBUG) - #define EABASE_STATIC_ASSERT_ENABLED 1 - #else - #define EABASE_STATIC_ASSERT_ENABLED 0 - #endif -#endif - -#ifndef EA_PREPROCESSOR_JOIN - #define EA_PREPROCESSOR_JOIN(a, b) EA_PREPROCESSOR_JOIN1(a, b) - #define EA_PREPROCESSOR_JOIN1(a, b) EA_PREPROCESSOR_JOIN2(a, b) - #define EA_PREPROCESSOR_JOIN2(a, b) a##b -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1600) - // static_assert is defined by the compiler for both C and C++. -#elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) - // static_assert is defined by the compiler. -#else - #if EABASE_STATIC_ASSERT_ENABLED - #if defined(__COUNTER__) // If this VC++ extension is available... - #define static_assert(expression, description) enum { EA_PREPROCESSOR_JOIN(static_assert_, __COUNTER__) = 1 / ((!!(expression)) ? 1 : 0) } - #else - #define static_assert(expression, description) enum { EA_PREPROCESSOR_JOIN(static_assert_, __LINE__) = 1 / ((!!(expression)) ? 1 : 0) } - #endif - #else - #if defined(EA_COMPILER_METROWERKS) - #if defined(__cplusplus) - #define static_assert(expression, description) struct EA_PREPROCESSOR_JOIN(EACTAssertUnused_, __LINE__){ } - #else - #define static_assert(expression, description) enum { EA_PREPROCESSOR_JOIN(static_assert_, __LINE__) = 1 / ((!!(expression)) ? 1 : 0) } - #endif - #else - #define static_assert(expression, description) - #endif - #endif -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompiler_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompiler_eastl.h deleted file mode 100644 index e339f0c48e66..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompiler_eastl.h +++ /dev/null @@ -1,476 +0,0 @@ -/* -Copyright (C) 2009 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/*----------------------------------------------------------------------------- - * config/eacompiler.h - * - * Copyright (c) 2002 - 2005 Electronic Arts Inc. All rights reserved. - * Maintained by Paul Pedriana, Maxis - * - *----------------------------------------------------------------------------- - * Currently supported defines include: - * EA_COMPILER_GNUC - * EA_COMPILER_ARM - * EA_COMPILER_EDG - * EA_COMPILER_SN - * EA_COMPILER_MSVC - * EA_COMPILER_METROWERKS - * EA_COMPILER_INTEL - * EA_COMPILER_BORLANDC - * EA_COMPILER_IBM - * - * EA_COMPILER_VERSION = - * EA_COMPILER_NAME = - * EA_COMPILER_STRING = - * - * EA_COMPILER_NO_STATIC_CONSTANTS - * EA_COMPILER_NO_TEMPLATE_SPECIALIZATION - * EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION - * EA_COMPILER_NO_MEMBER_TEMPLATES - * EA_COMPILER_NO_MEMBER_TEMPLATE_SPECIALIZATION - * EA_COMPILER_NO_TEMPLATE_TEMPLATES - * EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS - * EA_COMPILER_NO_VOID_RETURNS - * EA_COMPILER_NO_COVARIANT_RETURN_TYPE - * EA_COMPILER_NO_DEDUCED_TYPENAME - * EA_COMPILER_NO_ARGUMENT_DEPENDENT_LOOKUP - * EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE - * EA_COMPILER_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS - * EA_COMPILER_NO_RTTI - * EA_COMPILER_NO_EXCEPTIONS - * EA_COMPILER_NO_UNWIND - * EA_COMPILER_NO_STANDARD_CPP_LIBRARY - * EA_COMPILER_NO_STATIC_VARIABLE_INIT - * EA_COMPILER_NO_STATIC_FUNCTION_INIT - * - *----------------------------------------------------------------------------- - * - * Documentation - * EA_COMPILER_NO_STATIC_CONSTANTS - * Code such as this is legal, but some compilers fail to compile it: - * struct A{ static const a = 1; }; - * - * EA_COMPILER_NO_TEMPLATE_SPECIALIZATION - * Some compilers fail to allow template specialization, such as with this: - * template void DoSomething(U u); - * void DoSomething(int x); - * - * EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION - * Some compilers fail to allow partial template specialization, such as with this: - * template class vector{ }; // Primary templated class. - * template class vector{ }; // Partially specialized version. - * - * EA_COMPILER_NO_MEMBER_TEMPLATES - * Some compilers fail to allow member template functions such as this: - * struct A{ template void DoSomething(U u); }; - * - * EA_COMPILER_NO_MEMBER_TEMPLATE_SPECIALIZATION - * Some compilers fail to allow member template specialization, such as with this: - * struct A{ - * template void DoSomething(U u); - * void DoSomething(int x); - * }; - * - * EA_COMPILER_NO_TEMPLATE_TEMPLATES - * Code such as this is legal: - * template class U> - * U SomeFunction(const U x) { return x.DoSomething(); } - * - * EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS - * Some compilers fail to compile templated friends, as with this: - * struct A{ template friend class SomeFriend; }; - * This is described in the C++ Standard at 14.5.3. - * - * EA_COMPILER_NO_VOID_RETURNS - * This is legal C++: - * void DoNothing1(){ }; - * void DoNothing2(){ return DoNothing1(); } - * - * EA_COMPILER_NO_COVARIANT_RETURN_TYPE - * See the C++ standard sec 10.3,p5. - * - * EA_COMPILER_NO_DEDUCED_TYPENAME - * Some compilers don't support the use of 'typename' for - * dependent types in deduced contexts, as with this: - * template void Function(T, typename T::type); - * - * EA_COMPILER_NO_ARGUMENT_DEPENDENT_LOOKUP - * Also known as Koenig lookup. Basically, if you have a function - * that is a namespace and you call that function without prefixing - * it with the namespace the compiler should look at any arguments - * you pass to that function call and search their namespace *first* - * to see if the given function exists there. - * - * EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE - * is in namespace std. Some std libraries fail to - * put the contents of in namespace std. The following - * code should normally be legal: - * void Function(){ std::terminate(); } - * - * EA_COMPILER_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS - * Some compilers fail to execute DoSomething() properly, though they - * succeed in compiling it, as with this: - * template - * bool DoSomething(int j){ return i == j; }; - * DoSomething<1>(2); - * - * EA_COMPILER_NO_EXCEPTIONS - * The compiler is configured to disallow the use of try/throw/catch - * syntax (often to improve performance). Use of such syntax in this - * case will cause a compilation error. - * - * EA_COMPILER_NO_UNWIND - * The compiler is configured to allow the use of try/throw/catch - * syntax and behaviour but disables the generation of stack unwinding - * code for responding to exceptions (often to improve performance). - * - *---------------------------------------------------------------------------*/ - -#ifndef INCLUDED_eacompiler_H -#define INCLUDED_eacompiler_H - - #ifndef INCLUDED_eaplatform_H - #include - #endif - - // Note: This is used to generate the EA_COMPILER_STRING macros - #ifndef INTERNAL_STRINGIZE - #define INTERNAL_STRINGIZE(x) INTERNAL_PRIMITIVE_STRINGIZE(x) - #endif - #ifndef INTERNAL_PRIMITIVE_STRINGIZE - #define INTERNAL_PRIMITIVE_STRINGIZE(x) #x - #endif - - - // EDG (EDG compiler front-end, used by other compilers such as SN) - #if defined(__EDG_VERSION__) - #define EA_COMPILER_EDG - #endif - - - // SN - #if defined(__SNC__) // SN Systems compiler - // Note that there are two versions of the SN compiler, one that is - // GNUC-based and a newer one which is based on an EDG (Edison Design - // Group) front-end with a back-end code generator made by SN. - // The EDG-based SN compiler uses "GCC compatibility mode" and thus - // defines __GNUC__ but isn't really GNUC. Also, as of this writing - // it appears that the SN compiler may arrive with MSVC-compatibility - // mode in addition as well. Thus, we define EA_COMPILER_SN - // separately from other EA_COMPILER defines it is possible that both - // may be defined at the same time. Note that while the newer EDG-based - // SN compiler may emulate other compilers, it doesn't act exactly - // the same. - #define EA_COMPILER_SN - #endif - - - // Airplay SDK (third party mobile middleware compiler) - #if defined(__S3E__) - #define EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE - #endif - - - // SNC (SN Systems) - #if defined(__SNC__) - #define EA_COMPILER_NAME "SNC" - - #ifdef __GNUC__ // If SN is using GCC-compatibility mode (which it usually is)... - #define EA_COMPILER_GNUC - #define EA_COMPILER_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) // We intentionally report the GCC version here. SN - #define EA_COMPILER_STRING EA_COMPILER_NAME " compiler, GCC version " INTERNAL_STRINGIZE( __GNUC__ ) "." INTERNAL_STRINGIZE( __GNUC_MINOR__ ) ", SNC version " INTERNAL_STRINGIZE( __SN_VER__ ) ", EDG version " INTERNAL_STRINGIZE( __EDG_VERSION__ ) - #else - #define EA_COMPILER_VERSION __SN_VER__ - #define EA_COMPILER_STRING EA_COMPILER_NAME " compiler, version " INTERNAL_STRINGIZE( EA_COMPILER_VERSION ) ", EDG version " INTERNAL_STRINGIZE( __EDG_VERSION__ ) - #endif - - // GCC (a.k.a. GNUC) - #elif defined(__GNUC__) // GCC compilers exist for many platforms. - #define EA_COMPILER_GNUC - #define EA_COMPILER_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) - #define EA_COMPILER_NAME "GCC" - #define EA_COMPILER_STRING EA_COMPILER_NAME " compiler, version " INTERNAL_STRINGIZE( __GNUC__ ) "." INTERNAL_STRINGIZE( __GNUC_MINOR__ ) - - #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) // If GCC < 2.95... - #define EA_COMPILER_NO_MEMBER_TEMPLATES - #endif - #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 97) // If GCC <= 2.97... - #define EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS - #endif - #if (__GNUC__ == 3) && ((__GNUC_MINOR__ == 1) || (__GNUC_MINOR__ == 2)) // If GCC 3.1 or 3.2 (but not pre 3.1 or post 3.2)... - #define EA_COMPILER_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS - #endif - - // Borland C++ - #elif defined(__BORLANDC__) - #define EA_COMPILER_BORLANDC - #define EA_COMPILER_VERSION __BORLANDC__ - #define EA_COMPILER_NAME "Borland C" - //#define EA_COMPILER_STRING (defined below) - - #if (__BORLANDC__ <= 0x0550) // If Borland C++ Builder 4 and 5... - #define EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS - #endif - #if (__BORLANDC__ >= 0x561) && (__BORLANDC__ < 0x600) - #define EA_COMPILER_NO_MEMBER_FUNCTION_SPECIALIZATION - #endif - - - // Intel C++ (via EDG front-end) - #elif defined(__ICL) || defined(__ICC) - #define EA_COMPILER_INTEL - #if defined(__ICL) - #define EA_COMPILER_VERSION __ICL - #elif defined(__ICC) - #define EA_COMPILER_VERSION __ICC - #endif - #define EA_COMPILER_NAME "Intel C++" - //#define EA_COMPILER_STRING (defined below) - - // Intel is based ont the EDG (Edison Design Group) front end and - // all recent versions are very compliant to the C++ standard. - - - // Metrowerks - #elif defined(__MWERKS__) || defined(__CWCC__) // Metrowerks compilers exist for many platforms. - #define EA_COMPILER_METROWERKS - #ifdef __MWERKS__ - #define EA_COMPILER_VERSION __MWERKS__ - #else - #define EA_COMPILER_VERSION __CWCC__ - #endif - #define EA_COMPILER_NAME "Metrowerks" - //#define EA_COMPILER_STRING (defined below) - - #if (__MWERKS__ <= 0x2407) // If less than v7.x... - #define EA_COMPILER_NO_MEMBER_FUNCTION_SPECIALIZATION - #endif - #if (__MWERKS__ <= 0x3003) // If less than v8.x... - #define EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS - #endif - - - // Microsoft VC++ - #elif defined(_MSC_VER) && !(defined(__S3E__) && defined(__arm__)) // S3E is a mobile SDK which mistakenly masquerades as VC++ on ARM. - #define EA_COMPILER_MSVC - #define EA_COMPILER_VERSION _MSC_VER - #define EA_COMPILER_NAME "Microsoft Visual C++" - //#define EA_COMPILER_STRING (defined below) - - #if (_MSC_VER <= 1200) // If VC6.x and earlier... - #if (_MSC_VER < 1200) - #define EA_COMPILER_MSVCOLD - #else - #define EA_COMPILER_MSVC6 - #endif - - #if (_MSC_VER < 1200) // If VC5.x or earlier... - #define EA_COMPILER_NO_TEMPLATE_SPECIALIZATION - #endif - #define EA_COMPILER_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS // The compiler compiles this OK, but executes it wrong. Fixed in VC7.0 - #define EA_COMPILER_NO_VOID_RETURNS // The compiler fails to compile such cases. Fixed in VC7.0 - #define EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE // The compiler fails to compile such cases. Fixed in VC7.0 - #define EA_COMPILER_NO_DEDUCED_TYPENAME // The compiler fails to compile such cases. Fixed in VC7.0 - #define EA_COMPILER_NO_STATIC_CONSTANTS // The compiler fails to compile such cases. Fixed in VC7.0 - #define EA_COMPILER_NO_COVARIANT_RETURN_TYPE // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_ARGUMENT_DEPENDENT_LOOKUP // The compiler compiles this OK, but executes it wrong. Fixed in VC7.1 - #define EA_COMPILER_NO_TEMPLATE_TEMPLATES // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS // The compiler fails to compile such cases. Fixed in VC7.1 - //#define EA_COMPILER_NO_MEMBER_TEMPLATES // VC6.x supports member templates properly 95% of the time. So do we flag the remaining 5%? - //#define EA_COMPILER_NO_MEMBER_TEMPLATE_SPECIALIZATION // VC6.x supports member templates properly 95% of the time. So do we flag the remaining 5%? - - #elif (_MSC_VER <= 1300) // If VC7.0 and earlier... - #define EA_COMPILER_MSVC7 - - #define EA_COMPILER_NO_COVARIANT_RETURN_TYPE // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_ARGUMENT_DEPENDENT_LOOKUP // The compiler compiles this OK, but executes it wrong. Fixed in VC7.1 - #define EA_COMPILER_NO_TEMPLATE_TEMPLATES // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS // The compiler fails to compile such cases. Fixed in VC7.1 - #define EA_COMPILER_NO_MEMBER_FUNCTION_SPECIALIZATION // This is the case only for VC7.0 and not VC6 or VC7.1+. Fixed in VC7.1 - //#define EA_COMPILER_NO_MEMBER_TEMPLATES // VC7.0 supports member templates properly 95% of the time. So do we flag the remaining 5%? - - #elif (_MSC_VER < 1400) // If VC7.1 ... - // The VC7.1 and later compiler is fairly close to the C++ standard - // and thus has no compiler limitations that we are concerned about. - #define EA_COMPILER_MSVC7_2003 - #define EA_COMPILER_MSVC7_1 - - #else // _MSC_VER of 1400 means VC8 (VS2005), 1500 means VC9 (VS2008) - #define EA_COMPILER_MSVC8_2005 - #define EA_COMPILER_MSVC8_0 - - #endif - - - // IBM - #elif defined(__xlC__) - #define EA_COMPILER_IBM - #define EA_COMPILER_NAME "IBM XL C" - #define EA_COMPILER_VERSION __xlC__ - #define EA_COMPILER_STRING "IBM XL C compiler, version " INTERNAL_STRINGIZE( __xlC__ ) - - - // ARM compiler - #if defined(__ARMCC_VERSION) - // Note that this refers to the ARM compiler (armcc or armcpp), but there - // are other compilers that target ARM processors, such as GCC and Microsoft VC++. - // If you want to detect compiling for the ARM processor, check for EA_PROCESSOR_ARM - // being defined. - #define EA_COMPILER_ARM - #define EA_COMPILER_VERSION __ARMCC_VERSION - #define EA_COMPILER_NAME __CC_ARM - //#define EA_COMPILER_STRING (defined below) - - #endif - - - // Unknown - #else // Else the compiler is unknown - - #define EA_COMPILER_VERSION 0 - #define EA_COMPILER_NAME "Unknown" - - #endif - - #ifndef EA_COMPILER_STRING - #define EA_COMPILER_STRING EA_COMPILER_NAME " compiler, version " INTERNAL_STRINGIZE(EA_COMPILER_VERSION) - #endif - - - // Deprecated definitions - // For backwards compatibility, should be supported for at least the life of EABase v2.0.x. - #ifndef EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION - #define EA_COMPILER_PARTIAL_TEMPLATE_SPECIALIZATION - #endif - #ifndef EA_COMPILER_NO_TEMPLATE_SPECIALIZATION - #define EA_COMPILER_TEMPLATE_SPECIALIZATION - #endif - #ifndef EA_COMPILER_NO_MEMBER_TEMPLATES - #define EA_COMPILER_MEMBER_TEMPLATES - #endif - #ifndef EA_COMPILER_NO_MEMBER_TEMPLATE_SPECIALIZATION - #define EA_COMPILER_MEMBER_TEMPLATE_SPECIALIZATION - #endif - - - - // EA_COMPILER_NO_RTTI - // - // If EA_COMPILER_NO_RTTI is defined, then RTTI (run-time type information) - // is not available (possibly due to being disabled by the user). - // - #if defined(__SNC__) && !defined(__RTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(__GXX_ABI_VERSION) && !defined(__GXX_RTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(_MSC_VER) && !defined(_CPPRTTI) - #define EA_COMPILER_NO_RTTI - #elif defined(__MWERKS__) - #if !__option(RTTI) - #define EA_COMPILER_NO_RTTI - #endif - #endif - - - - // EA_COMPILER_NO_EXCEPTIONS / EA_COMPILER_NO_UNWIND - // - // If EA_COMPILER_NO_EXCEPTIONS is defined, then the compiler is - // configured to not recognize C++ exception-handling statements - // such as try/catch/throw. Thus, when EA_COMPILER_NO_EXCEPTIONS is - // defined, code that attempts to use exception handling statements - // will usually cause a compilation error. If is often desirable - // for projects to disable exception handling because exception - // handling causes extra code and/or data generation which might - // not be needed, especially if it is known that exceptions won't - // be happening. When writing code that is to be portable between - // systems of which some enable exception handling while others - // don't, check for EA_COMPILER_NO_EXCEPTIONS being defined. - // - #if defined(EA_COMPILER_GNUC) && defined(_NO_EX) // GCC on some platforms (e.g. PS3) defines _NO_EX when exceptions are disabled. - #define EA_COMPILER_NO_EXCEPTIONS - - #elif (defined(EA_COMPILER_GNUC) || defined(EA_COMPILER_INTEL) || defined(EA_COMPILER_SN)) && !defined(__EXCEPTIONS) // GCC and most EDG-based compilers define __EXCEPTIONS when exception handling is enabled. - #define EA_COMPILER_NO_EXCEPTIONS - - #elif defined(EA_COMPILER_METROWERKS) - #if !__option(exceptions) - #define EA_COMPILER_NO_EXCEPTIONS - #endif - - // Borland and Micrsoft use the _CPUUNWIND define to denote that - // exception stack unwinding code generation is disabled. The result - // is that you can call try/catch/throw and that exceptions will be - // caught handled, but that no automatic object destruction will - // happen between a throw and the resulting catch. We thus don't - // want to define EA_COMPILER_NO_EXCEPTIONS, but perhaps users might - // be interesting in knowing that unwinding is disabled. - #elif (defined(EA_COMPILER_BORLAND) || defined(EA_COMPILER_MSVC)) && !defined(_CPPUNWIND) - #define EA_COMPILER_NO_UNWIND - - #endif // EA_COMPILER_NO_EXCEPTIONS / EA_COMPILER_NO_UNWIND - - - - // EA_COMPILER_NO_STANDARD_CPP_LIBRARY - // - // If defined, then the compiler doesn't provide a Standard C++ library. - // - #if defined(EA_PLATFORM_ANDROID) - #define EA_COMPILER_NO_STANDARD_CPP_LIBRARY - #endif - - - // EA_COMPILER_NO_STATIC_VARIABLE_INIT - // - // If defined, it means that global or static C++ variables will be - // constructed. Not all compiler/platorm combinations support this. - // User code that needs to be portable must avoid having C++ variables - // that construct before main. - // - //#if defined(EA_PLATFORM_MOBILE) - // #define EA_COMPILER_NO_STATIC_VARIABLE_INIT - //#endif - - - - // EA_COMPILER_NO_STATIC_FUNCTION_INIT - // - // If defined, it means that functions marked as startup functions - // (e.g. __attribute__((constructor)) in GCC) are supported. It may - // be that some compiler/platform combinations don't support this. - // - //#if defined(XXX) // So far, all compiler/platforms we use support this. - // #define EA_COMPILER_NO_STATIC_VARIABLE_INIT - //#endif - - - -#endif // INCLUDED_eacompiler_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompilertraits_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompilertraits_eastl.h deleted file mode 100644 index 47274bddb5ab..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eacompilertraits_eastl.h +++ /dev/null @@ -1,935 +0,0 @@ -/* -Copyright (C) 2009 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/*----------------------------------------------------------------------------- - * config/eacompilertraits.h - * - * Copyright (c) 2002 - 2005 Electronic Arts Inc. All rights reserved. - * Maintained by Paul Pedriana, Maxis - * - *----------------------------------------------------------------------------- - * Currently supported defines include: - * EA_COMPILER_IS_ANSIC - * EA_COMPILER_IS_C99 - * EA_COMPILER_HAS_C99_TYPES - * EA_COMPILER_IS_CPLUSPLUS - * EA_COMPILER_MANAGED_CPP - * - * EA_ALIGN_OF() - * EA_ALIGN() / EA_PREFIX_ALIGN() / EA_POSTFIX_ALIGN() - * EA_ALIGNED() - * EA_PACKED() - * - * EA_LIKELY() - * EA_UNLIKELY() - * EA_INIT_PRIORITY() - * EA_MAY_ALIAS() - * EA_ASSUME() - * EA_PURE - * EA_WEAK - * - * EA_WCHAR_T_NON_NATIVE - * EA_WCHAR_SIZE = - * - * EA_RESTRICT - * EA_DEPRECATED / EA_PREFIX_DEPRECATED / EA_POSTFIX_DEPRECATED - * EA_FORCE_INLINE / EA_PREFIX_FORCE_INLINE / EA_POSTFIX_FORCE_INLINE - * EA_NO_INLINE / EA_PREFIX_NO_INLINE / EA_POSTFIX_NO_INLINE - * EA_NO_VTABLE / EA_CLASS_NO_VTABLE / EA_STRUCT_NO_VTABLE - * EA_PASCAL - * EA_PASCAL_FUNC() - * EA_SSE = [0 | 1] - * EA_IMPORT - * EA_EXPORT - * EA_PRAGMA_ONCE_SUPPORTED - * EA_OVERRIDE - * EA_SEALED - * EA_ABSTRACT - * - * Todo: - * Find a way to reliably detect wchar_t size at preprocessor time and - * implement it below for EA_WCHAR_SIZE. - * - * Todo: - * Find out how to support EA_PASCAL and EA_PASCAL_FUNC for systems in - * which it hasn't yet been found out for. - *---------------------------------------------------------------------------*/ - - -#ifndef INCLUDED_eacompilertraits_H -#define INCLUDED_eacompilertraits_H - - #ifndef INCLUDED_eaplatform_H - #include - #endif - - #ifndef INCLUDED_eacompiler_H - #include - #endif - - // Metrowerks uses #defines in its core C header files to define - // the kind of information we need below (e.g. C99 compatibility) - #if defined(__MWERKS__) - // Defining the following causes C99 compilers to enable the macros - // associated with the defines. The C99 standard specifies that you - // should define these as such. - #ifndef __STDC_LIMIT_MACROS - #define __STDC_LIMIT_MACROS - #endif - - #ifndef __STDC_CONSTANT_MACROS - #define __STDC_CONSTANT_MACROS - #endif - - #include - #endif - - #if defined(__SNC__) || defined(EA_PLATFORM_PS3) || defined(__S3E__) - #ifndef __STDC_LIMIT_MACROS - #define __STDC_LIMIT_MACROS - #endif - - #ifndef __STDC_CONSTANT_MACROS - #define __STDC_CONSTANT_MACROS - #endif - - #include - - #if !defined(EA_COMPILER_HAS_INTTYPES) - #if !defined(__S3E__) - #define EA_COMPILER_HAS_INTTYPES - #endif - #endif - #endif - - // Determine if this compiler is ANSI C compliant and if it is C99 compliant. - #if defined(__STDC__) - #define EA_COMPILER_IS_ANSIC // The compiler claims to be ANSI C - - // Is the compiler a C99 compiler or equivalent? - // From ISO/IEC 9899:1999: - // 6.10.8 Predefined macro names - // __STDC_VERSION__ The integer constant 199901L. (150) - // - // 150) This macro was not specified in ISO/IEC 9899:1990 and was - // specified as 199409L in ISO/IEC 9899/AMD1:1995. The intention - // is that this will remain an integer constant of type long int - // that is increased with each revision of this International Standard. - // - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) - #define EA_COMPILER_IS_C99 - #endif - #endif - - // Some compilers (e.g. GCC) define __USE_ISOC99 if they are not - // strictly C99 compilers (or are simply C++ compilers) but are set - // to use C99 functionality. Metrowerks defines _MSL_C99 as 1 in - // this case, but 0 otherwise. - #if (defined(__USE_ISOC99) || (defined(_MSL_C99) && (_MSL_C99 == 1))) && !defined(EA_COMPILER_IS_C99) - #define EA_COMPILER_IS_C99 - #endif - - // Metrowerks defines C99 types (e.g. intptr_t) instrinsically when in C99 mode (-lang C99 on the command line). - #if (defined(_MSL_C99) && (_MSL_C99 == 1)) - #define EA_COMPILER_HAS_C99_TYPES - #endif - - #if defined(__GNUC__) - #if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 302) // Also, GCC defines _HAS_C9X. - #define EA_COMPILER_HAS_C99_TYPES // The compiler is not necessarily a C99 compiler, but it defines C99 types. - - #ifndef __STDC_LIMIT_MACROS - #define __STDC_LIMIT_MACROS - #endif - - #ifndef __STDC_CONSTANT_MACROS - #define __STDC_CONSTANT_MACROS // This tells the GCC compiler that we want it to use its native C99 types. - #endif - #endif - #endif - - #ifdef __cplusplus - #define EA_COMPILER_IS_CPLUSPLUS - #endif - - - // ------------------------------------------------------------------------ - // EA_COMPILER_MANAGED_CPP - // Defined if this is being compiled with Managed C++ extensions - #ifdef EA_COMPILER_MSVC - #if EA_COMPILER_VERSION >= 1300 - #ifdef _MANAGED - #define EA_COMPILER_MANAGED_CPP - #endif - #endif - #endif - - - // ------------------------------------------------------------------------ - // alignment expressions - // - // Here we define - // EA_ALIGN_OF(type) // Returns size_t. - // EA_ALIGN(n) // Used as a prefix. n is byte alignment, with being a power of two. Most of the time you can use this and avoid using EA_PREFIX_ALIGN/EA_POSTFIX_ALIGN. - // EA_PREFIX_ALIGN(n) // n is byte alignment, with being a power of two. You should need this only for unusual compilers. - // EA_POSTFIX_ALIGN(n) // Valid values for n are 1, 2, 4, 8, etc. You should need this only for unusual compilers. - // EA_ALIGNED(t, v, n) // Type, variable, alignment. Used to align an instance. You should need this only for unusual compilers. - // EA_PACKED // Specifies that the given structure be packed (and not have its members aligned). - // - // Example usage: - // size_t x = EA_ALIGN_OF(int); Non-aligned equivalents. Meaning - // EA_PREFIX_ALIGN(8) int x = 5; int x = 5; Align x on 8 for compilers that require prefix attributes. Can just use EA_ALIGN instead. - // EA_ALIGN(8) int x; int x; Align x on 8 for compilers that allow prefix attributes. - // int x EA_POSTFIX_ALIGN(8); int x; Align x on 8 for compilers that require postfix attributes. - // int x EA_POSTFIX_ALIGN(8) = 5; int x = 5; Align x on 8 for compilers that require postfix attributes. - // int x EA_POSTFIX_ALIGN(8)(5); int x(5); Align x on 8 for compilers that require postfix attributes. - // struct EA_PREFIX_ALIGN(8) X { int x; } EA_POSTFIX_ALIGN(8); struct X { int x; }; Define X as a struct which is aligned on 8 when used. - // EA_ALIGNED(int, x, 8) = 5; int x = 5; Align x on 8. - // EA_ALIGNED(int, x, 16)(5); int x(5); Align x on 16. - // EA_ALIGNED(int, x[3], 16); int x[3]; Align x array on 16. - // EA_ALIGNED(int, x[3], 16) = { 1, 2, 3 }; int x[3] = { 1, 2, 3 }; Align x array on 16. - // int x[3] EA_PACKED; int x[3]; Pack the 3 ints of the x array. GCC doesn't seem to support packing of int arrays. - // struct EA_ALIGN(32) X { int x; int y; }; struct X { int x; }; Define A as a struct which is aligned on 32 when used. - // EA_ALIGN(32) struct X { int x; int y; } Z; struct X { int x; } Z; Define A as a struct, and align the instance Z on 32. - // struct X { int x EA_PACKED; int y EA_PACKED; }; struct X { int x; int y; }; Pack the x and y members of struct X. - // struct X { int x; int y; } EA_PACKED; struct X { int x; int y; }; Pack the members of struct X. - // typedef EA_ALIGNED(int, int16, 16); int16 n16; typedef int int16; int16 n16; Define int16 as an int which is aligned on 16. - // typedef EA_ALIGNED(X, X16, 16); X16 x16; typedef X X16; X16 x16; Define X16 as an X which is aligned on 16. - - // SNC (EDG) intends to be compatible with GCC but has a bug whereby it - // fails to support calling a constructor in an aligned declaration when - // using postfix alignment attributes. Prefix works for alignment, but does not align - // the size like postfix does. Prefix also fails on templates. So gcc style post fix - // is still used, but the user will need to use EA_POSTFIX_ALIGN before the constructor parameters. - // this note by Paul and Frank - #if defined(EA_COMPILER_SN) && defined(__GNUC__) // If using the SN compiler in GCC compatibility mode... - #define EA_ALIGN_OF(type) ((size_t)__alignof__(type)) - #define EA_ALIGN(n) __attribute__((aligned(n))) - #define EA_PREFIX_ALIGN(n) - #define EA_POSTFIX_ALIGN(n) __attribute__((aligned(n))) - #define EA_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((aligned(n))) - #define EA_PACKED __attribute__((packed)) - - // GCC 2.x doesn't support prefix attributes. - #elif defined(__GNUC__) && (__GNUC__ < 3) - #define EA_ALIGN_OF(type) ((size_t)__alignof__(type)) - #define EA_ALIGN(n) - #define EA_PREFIX_ALIGN(n) - #define EA_POSTFIX_ALIGN(n) __attribute__((aligned(n))) - #define EA_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((aligned(n))) - #define EA_PACKED __attribute__((packed)) - - // GCC 3.x+ and IBM C support prefix attributes. - #elif (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__xlC__) - #define EA_ALIGN_OF(type) ((size_t)__alignof__(type)) - #define EA_ALIGN(n) __attribute__((aligned(n))) - #define EA_PREFIX_ALIGN(n) - #define EA_POSTFIX_ALIGN(n) __attribute__((aligned(n))) - #define EA_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((aligned(n))) - #define EA_PACKED __attribute__((packed)) - - // Metrowerks supports prefix attributes. - // Metrowerks does not support packed alignment attributes. - #elif defined(EA_COMPILER_METROWERKS) - #define EA_ALIGN_OF(type) ((size_t)__alignof__(type)) - #define EA_ALIGN(n) __attribute__((aligned(n))) - #define EA_PREFIX_ALIGN(n) - #define EA_POSTFIX_ALIGN(n) __attribute__((aligned(n))) - #define EA_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((aligned(n))) - #define EA_PACKED - - // Microsoft supports prefix alignment via __declspec, but the alignment value must be a literal number, not just a constant expression. - // Contrary to VC7.x and earlier documentation, __declspec(align) works on stack variables. VC8+ (VS2005+) documents correctly. - // Microsoft does not support packed alignment attributes; you must use #pragma pack. - #elif defined(EA_COMPILER_INTEL) || defined(EA_PLATFORM_XBOX) || (defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1300)) - #define EA_ALIGN_OF(type) ((size_t)__alignof(type)) - #define EA_ALIGN(n) __declspec(align(n)) - #define EA_PREFIX_ALIGN(n) __declspec(align(n)) - #define EA_POSTFIX_ALIGN(n) - #define EA_ALIGNED(variable_type, variable, n) __declspec(align(n)) variable_type variable - #define EA_PACKED - - // Arm brand compiler - #elif defined(__ARMCC_VERSION) - #define EA_ALIGN_OF(type) ((size_t)__ALIGNOF__(type)) - #define EA_ALIGN(n) __align(n) - #define EA_PREFIX_ALIGN(n) __align(n) - #define EA_POSTFIX_ALIGN(n) - #define EA_ALIGNED(variable_type, variable, n) __align(n) variable_type variable - #define EA_PACKED __packed - - #else // Unusual compilers - // There is nothing we can do about some of these. This is not as bad a problem as it seems. - // If the given platform/compiler doesn't support alignment specifications, then it's somewhat - // likely that alignment doesn't matter for that platform. Otherwise they would have defined - // functionality to manipulate alignment. - #define EA_ALIGN(n) - #define EA_PREFIX_ALIGN(n) - #define EA_POSTFIX_ALIGN(n) - #define EA_ALIGNED(variable_type, variable, n) variable_type variable - #define EA_PACKED - - #ifdef __cplusplus - template struct EAAlignOf1 { enum { s = sizeof (T), value = s ^ (s & (s - 1)) }; }; - template struct EAAlignOf2; - template struct helper { template struct Val { enum { value = size_diff }; }; }; - template <> struct helper<0> { template struct Val { enum { value = EAAlignOf2::value }; }; }; - template struct EAAlignOf2 { struct Big { T x; char c; }; - enum { diff = sizeof (Big) - sizeof (T), value = helper::template Val::value }; }; - template struct EAAlignof3 { enum { x = EAAlignOf2::value, y = EAAlignOf1::value, value = x < y ? x : y }; }; - #define EA_ALIGN_OF(type) ((size_t)EAAlignof3::value) - - #else - // C implementation of EA_ALIGN_OF - // This implementation works for most cases, but doesn't directly work - // for types such as function pointer declarations. To work with those - // types you need to typedef the type and then use the typedef in EA_ALIGN_OF. - #define EA_ALIGN_OF(type) ((size_t)offsetof(struct { char c; type m; }, m)) - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_LIKELY / EA_UNLIKELY - // - // Defined as a macro which gives a hint to the compiler for branch - // prediction. GCC gives you the ability to manually give a hint to - // the compiler about the result of a comparison, though it's often - // best to compile shipping code with profiling feedback under both - // GCC (-fprofile-arcs) and VC++ (/LTCG:PGO, etc.). However, there - // are times when you feel very sure that a boolean expression will - // usually evaluate to either true or false and can help the compiler - // by using an explicity directive... - // - // Example usage: - // if(EA_LIKELY(a == 0)) // Tell the compiler that a will usually equal 0. - // { ... } - // - // Example usage: - // if(EA_UNLIKELY(a == 0)) // Tell the compiler that a will usually not equal 0. - // { ... } - // - #ifndef EA_LIKELY - #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__MWERKS__) // Metrowerks supports __builtin_expect, but with some platforms (e.g. Wii) it appears to ignore it. - #if defined(__cplusplus) - #define EA_LIKELY(x) __builtin_expect(!!(x), true) - #define EA_UNLIKELY(x) __builtin_expect(!!(x), false) - #else - #define EA_LIKELY(x) __builtin_expect(!!(x), 1) - #define EA_UNLIKELY(x) __builtin_expect(!!(x), 0) - #endif - #else - #define EA_LIKELY(x) (x) - #define EA_UNLIKELY(x) (x) - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_INIT_PRIORITY - // - // This is simply a wrapper for the GCC init_priority attribute that allows - // multiplatform code to be easier to read. This attribute doesn't apply - // to VC++ because VC++ uses file-level pragmas to control init ordering. - // - // Example usage: - // SomeClass gSomeClass EA_INIT_PRIORITY(2000); - // - #if !defined(EA_INIT_PRIORITY) - #if defined(__GNUC__) - #define EA_INIT_PRIORITY(x) __attribute__ ((init_priority (x))) - #else - #define EA_INIT_PRIORITY(x) - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_MAY_ALIAS - // - // Defined as a macro that wraps the GCC may_alias attribute. This attribute - // has no significance for VC++ because VC++ doesn't support the concept of - // strict aliasing. Users should avoid writing code that breaks strict - // aliasing rules; EA_MAY_ALIAS is for cases with no alternative. - // - // Example usage: - // void* EA_MAY_ALIAS gPtr = NULL; - // - // Example usage: - // typedef void* EA_MAY_ALIAS pvoid_may_alias; - // pvoid_may_alias gPtr = NULL; - // - #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303) - #define EA_MAY_ALIAS __attribute__((__may_alias__)) - #else - #define EA_MAY_ALIAS - #endif - - - // ------------------------------------------------------------------------ - // EA_ASSUME - // - // This acts the same as the VC++ __assume directive and is implemented - // simply as a wrapper around it to allow portable usage of it and to take - // advantage of it if and when it appears in other compilers. - // - // Example usage: - // void Function(int a) { - // switch(a) { - // case 1: - // DoSomething(1); - // break; - // case 2: - // DoSomething(-1); - // break; - // default: - // EA_ASSUME(0); // This tells the optimizer that the default cannot be reached. - // } - // } - // - #ifndef EA_ASSUME - #if defined(_MSC_VER) && (_MSC_VER >= 1300) // If VC7.0 and later (including XBox, and XBox 360)... - #define EA_ASSUME(x) __assume(x) - #else - #define EA_ASSUME(x) - #endif - #endif - - - - // ------------------------------------------------------------------------ - // EA_PURE - // - // This acts the same as the GCC __attribute__ ((pure)) directive and is - // implemented simply as a wrapper around it to allow portable usage of - // it and to take advantage of it if and when it appears in other compilers. - // - // A "pure" function is one that has no effects except its return value and - // its return value is a function of only the function's parameters or - // non-volatile global variables. Any parameter or global variable access - // must be read-only. Loop optimization and subexpression elimination can be - // applied to such functions. A common example is strlen(): Given identical - // inputs, the function's return value (its only effect) is invariant across - // multiple invocations and thus can be pulled out of a loop and called but once. - // - // Example usage: - // EA_PURE void Function(); - // - #ifndef EA_PURE - #if defined(EA_COMPILER_GNUC) - #define EA_PURE __attribute__((pure)) - #elif defined(__ARMCC_VERSION) // Arm brand compiler for ARM CPU - #define EA_PURE __pure - #else - #define EA_PURE - #endif - #endif - - - - // ------------------------------------------------------------------------ - // EA_WEAK - // EA_WEAK_SUPPORTED -- defined as 0 or 1. - // - // GCC - // The weak attribute causes the declaration to be emitted as a weak - // symbol rather than a global. This is primarily useful in defining - // library functions which can be overridden in user code, though it - // can also be used with non-function declarations. - // - // VC++ - // At link time, if multiple definitions of a COMDAT are seen, the linker - // picks one and discards the rest. If the linker option /OPT:REF - // is selected, then COMDAT elimination will occur to remove all the - // unreferenced data items in the linker output. - // - // Example usage: - // EA_WEAK void Function(); - // - #ifndef EA_WEAK - #if defined(_MSC_VER) && (_MSC_VER >= 1300) // If VC7.0 and later (including XBox)... - #define EA_WEAK __declspec(selectany) - #define EA_WEAK_SUPPORTED 1 - #elif defined(_MSC_VER) || (defined(__GNUC__) && defined(__CYGWIN__)) - #define EA_WEAK - #define EA_WEAK_SUPPORTED 0 - #elif defined(__ARMCC_VERSION) // Arm brand compiler for ARM CPU - #define EA_WEAK __weak - #define EA_WEAK_SUPPORTED 1 - #else // GCC and IBM compilers, others. - #define EA_WEAK __attribute__((weak)) - #define EA_WEAK_SUPPORTED 1 - #endif - #endif - - - - // ------------------------------------------------------------------------ - // wchar_t - // Here we define: - // EA_WCHAR_T_NON_NATIVE - // EA_WCHAR_SIZE = - // - #ifndef EA_WCHAR_T_NON_NATIVE - // Compilers that always implement wchar_t as native include: - // COMEAU, new SN, and other EDG-based compilers. - // GCC - // Borland - // SunPro - // IBM Visual Age - #if defined(EA_COMPILER_INTEL) - #if (EA_COMPILER_VERSION < 700) - #define EA_WCHAR_T_NON_NATIVE 1 - #else - #if (!defined(_WCHAR_T_DEFINED) && !defined(_WCHAR_T)) - #define EA_WCHAR_T_NON_NATIVE 1 - #endif - #endif - #elif defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) - #ifndef _NATIVE_WCHAR_T_DEFINED - #define EA_WCHAR_T_NON_NATIVE 1 - #endif - #elif defined(EA_COMPILER_METROWERKS) - #if !__option(wchar_type) - #define EA_WCHAR_T_NON_NATIVE 1 - #endif - #elif defined(__SNC__) && !defined(__cplusplus) // If compiling C under SNC... - #define EA_WCHAR_T_NON_NATIVE 1 - #endif - #endif - - #ifndef EA_WCHAR_SIZE // If the user hasn't specified that it is a given size... - #if defined(__WCHAR_MAX__) // GCC defines this for most platforms. - #if (__WCHAR_MAX__ == 2147483647) || (__WCHAR_MAX__ == 4294967295) - #define EA_WCHAR_SIZE 4 - #elif (__WCHAR_MAX__ == 32767) || (__WCHAR_MAX__ == 65535) - #define EA_WCHAR_SIZE 2 - #elif (__WCHAR_MAX__ == 127) || (__WCHAR_MAX__ == 255) - #define EA_WCHAR_SIZE 1 - #else - #define EA_WCHAR_SIZE 4 - #endif - #elif defined(WCHAR_MAX) // The SN and Arm compilers define this. - #if (WCHAR_MAX == 2147483647) || (WCHAR_MAX == 4294967295) - #define EA_WCHAR_SIZE 4 - #elif (WCHAR_MAX == 32767) || (WCHAR_MAX == 65535) - #define EA_WCHAR_SIZE 2 - #elif (WCHAR_MAX == 127) || (WCHAR_MAX == 255) - #define EA_WCHAR_SIZE 1 - #else - #define EA_WCHAR_SIZE 4 - #endif - #elif defined(_WCMAX) // The SN and Arm compilers define this. - #if (_WCMAX == 2147483647) || (_WCMAX == 4294967295) - #define EA_WCHAR_SIZE 4 - #elif (_WCMAX == 32767) || (_WCMAX == 65535) - #define EA_WCHAR_SIZE 2 - #elif (_WCMAX == 127) || (_WCMAX == 255) - #define EA_WCHAR_SIZE 1 - #else - #define EA_WCHAR_SIZE 4 - #endif - #elif defined(EA_PLATFORM_UNIX) || defined(EA_PLATFORM_PS3) || defined(EA_PLATFORM_PS3_SPU) - // It is standard on Unix to have wchar_t be int32_t or uint32_t. - // All versions of GNUC default to a 32 bit wchar_t, but has been used - // with the -fshort-wchar GCC command line option to force it to 16 bit. - // If you know that the compiler is set to use a wchar_t of other than - // the default, you need to manually define EA_WCHAR_SIZE for the build. - #define EA_WCHAR_SIZE 4 - #else - // It is standard on Windows to have wchar_t be uint16_t. - // Metrowerks and the new EDG-based SN compilers define wchar_t - // as uint16_t. Given that there is currently no known way to tell at preprocessor - // time what the size of wchar_t is, we declare it to be 2. - // If you have EA_WCHAR_SIZE != sizeof(wchar_t), then your - // code might not be broken, but it also won't work with wchar libraries - // and data from other parts of EA. Under GCC, you can force wchar_t - // to two bytes with the -fshort-wchar compiler argument. - #define EA_WCHAR_SIZE 2 - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_RESTRICT - // - // The C99 standard defines a new keyword, restrict, which allows for the - // improvement of code generation regarding memory usage. Compilers can - // generate significantly faster code when you are able to use restrict. - // - // Example usage: - // void DoSomething(char* EA_RESTRICT p1, char* EA_RESTRICT p2); - // - #ifndef EA_RESTRICT - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // If VC8 (VS2005) or later... - #define EA_RESTRICT __restrict - #elif defined(EA_COMPILER_GNUC) - #define EA_RESTRICT __restrict // GCC defines 'restrict' (as opposed to __restrict) in C99 mode only. - #elif defined(__ARMCC_VERSION) - #define EA_RESTRICT __restrict - #elif defined(__MWERKS__) - #if __option(c99) - #define EA_RESTRICT restrict - #else - #define EA_RESTRICT - #endif - #elif defined(EA_COMPILER_IS_C99) - #define EA_RESTRICT restrict - #else - // If the compiler didn't support restricted pointers, defining EA_RESTRICT - // away would result in compiling and running fine but you just wouldn't - // the same level of optimization. On the other hand, all the major compilers - // support restricted pointers. - #define EA_RESTRICT - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_DEPRECATED // Used as a prefix. - // EA_PREFIX_DEPRECATED // You should need this only for unusual compilers. - // EA_POSTFIX_DEPRECATED // You should need this only for unusual compilers. - // - // Example usage: - // EA_DEPRECATED void Function(); - // - // or for maximum portability: - // EA_PREFIX_DEPRECATED void Function() EA_POSTFIX_DEPRECATED; - // - #ifndef EA_DEPRECATED - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION > 1300) // If VC7 (VS2003) or later... - #define EA_DEPRECATED __declspec(deprecated) - #elif defined(EA_COMPILER_MSVC) - #define EA_DEPRECATED - #else - #define EA_DEPRECATED __attribute__((deprecated)) - #endif - #endif - - #ifndef EA_PREFIX_DEPRECATED - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION > 1300) // If VC7 (VS2003) or later... - #define EA_PREFIX_DEPRECATED __declspec(deprecated) - #define EA_POSTFIX_DEPRECATED - #elif defined(EA_COMPILER_MSVC) - #define EA_PREFIX_DEPRECATED - #define EA_POSTFIX_DEPRECATED - #else - #define EA_PREFIX_DEPRECATED - #define EA_POSTFIX_DEPRECATED __attribute__((deprecated)) - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_FORCE_INLINE // Used as a prefix. - // EA_PREFIX_FORCE_INLINE // You should need this only for unusual compilers. - // EA_POSTFIX_FORCE_INLINE // You should need this only for unusual compilers. - // - // Example usage: - // EA_FORCE_INLINE void Foo(); // Implementation elsewhere. - // EA_PREFIX_FORCE_INLINE void Foo() EA_POSTFIX_FORCE_INLINE; // Implementation elsewhere. - // - // Note that when the prefix version of this function is used, it replaces - // the regular C++ 'inline' statement. Thus you should not use both the - // C++ inline statement and this macro with the same function declaration. - // - // To force inline usage under GCC 3.1+, you use this: - // inline void Foo() __attribute__((always_inline)); - // or - // inline __attribute__((always_inline)) void Foo(); - // - // The CodeWarrior compiler doesn't have the concept of forcing inlining per function. - // - #ifndef EA_FORCE_INLINE - #if defined(EA_COMPILER_MSVC) - #define EA_FORCE_INLINE __forceinline - #elif defined(EA_COMPILER_GNUC) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 301) - #if defined(__cplusplus) - #define EA_FORCE_INLINE inline __attribute__((always_inline)) - #else - #define EA_FORCE_INLINE __inline__ __attribute__((always_inline)) - #endif - #else - #if defined(__cplusplus) - #define EA_FORCE_INLINE inline - #else - #define EA_FORCE_INLINE __inline - #endif - #endif - #endif - - #if defined(EA_COMPILER_SN) && defined(EA_PLATFORM_PS3) // SN's implementation of always_inline is broken and sometimes fails to link the function. - #define EA_PREFIX_FORCE_INLINE inline - #define EA_POSTFIX_FORCE_INLINE - #elif defined(EA_COMPILER_GNUC) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 301) - #define EA_PREFIX_FORCE_INLINE inline - #define EA_POSTFIX_FORCE_INLINE __attribute__((always_inline)) - #else - #define EA_PREFIX_FORCE_INLINE inline - #define EA_POSTFIX_FORCE_INLINE - #endif - - - // ------------------------------------------------------------------------ - // EA_NO_INLINE // Used as a prefix. - // EA_PREFIX_NO_INLINE // You should need this only for unusual compilers. - // EA_POSTFIX_NO_INLINE // You should need this only for unusual compilers. - // - // Example usage: - // EA_NO_INLINE void Foo(); // Implementation elsewhere. - // EA_PREFIX_NO_INLINE void Foo() EA_POSTFIX_NO_INLINE; // Implementation elsewhere. - // - // That this declaration is incompatbile with C++ 'inline' and any - // variant of EA_FORCE_INLINE. - // - // To disable inline usage under VC++ priof to VS2005, you need to use this: - // #pragma inline_depth(0) // Disable inlining. - // void Foo() { ... } - // #pragma inline_depth() // Restore to default. - // - // Since there is no easy way to disable inlining on a function-by-function - // basis in VC++ prior to VS2005, the best strategy is to write platform-specific - // #ifdefs in the code or to disable inlining for a given module and enable - // functions individually with EA_FORCE_INLINE. - // - #ifndef EA_NO_INLINE - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // If VC8 (VS2005) or later... - #define EA_NO_INLINE __declspec(noinline) - #elif defined(EA_COMPILER_MSVC) - #define EA_NO_INLINE - #else - #define EA_NO_INLINE __attribute__((noinline)) - #endif - #endif - - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // If VC8 (VS2005) or later... - #define EA_PREFIX_NO_INLINE __declspec(noinline) - #define EA_POSTFIX_NO_INLINE - #elif defined(EA_COMPILER_MSVC) - #define EA_PREFIX_NO_INLINE - #define EA_POSTFIX_NO_INLINE - #else - #define EA_PREFIX_NO_INLINE - #define EA_POSTFIX_NO_INLINE __attribute__((noinline)) - #endif - - - // ------------------------------------------------------------------------ - // EA_NO_VTABLE - // - // Example usage: - // class EA_NO_VTABLE X { - // virtual void InterfaceFunction(); - // }; - // - // EA_CLASS_NO_VTABLE(X) { - // virtual void InterfaceFunction(); - // }; - // - #ifdef EA_COMPILER_MSVC - #define EA_NO_VTABLE __declspec(novtable) - #define EA_CLASS_NO_VTABLE(x) class __declspec(novtable) x - #define EA_STRUCT_NO_VTABLE(x) struct __declspec(novtable) x - #else - #define EA_NO_VTABLE - #define EA_CLASS_NO_VTABLE(x) class x - #define EA_STRUCT_NO_VTABLE(x) struct x - #endif - - - // ------------------------------------------------------------------------ - // EA_PASCAL - // - // Also known on PC platforms as stdcall. - // This convention causes the compiler to assume that the called function - // will pop off the stack space used to pass arguments, unless it takes a - // variable number of arguments. - // - // Example usage: - // this: - // void DoNothing(int x); - // void DoNothing(int x){} - // would be written as this: - // void EA_PASCAL_FUNC(DoNothing(int x)); - // void EA_PASCAL_FUNC(DoNothing(int x)){} - // - #ifndef EA_PASCAL - #if defined(EA_COMPILER_MSVC) - #define EA_PASCAL __stdcall - #elif defined(EA_COMPILER_GNUC) && defined(EA_PROCESSOR_X86) - #define EA_PASCAL __attribute__((stdcall)) - #elif defined(EA_COMPILER_METROWERKS) && defined(EA_PLATFORM_WINDOWS) - // You need to make sure you have the Metrowerks "ANSI keywords only' - // compilation option disabled for the pascal keyword to work. - #define EA_PASCAL pascal - #else - // Some compilers simply don't support pascal calling convention. - // As a result, there isn't an issue here, since the specification of - // pascal calling convention is for the purpose of disambiguating the - // calling convention that is applied. - #define EA_PASCAL - #endif - #endif - - #ifndef EA_PASCAL_FUNC - #if defined(EA_COMPILER_MSVC) - #define EA_PASCAL_FUNC(funcname_and_paramlist) __stdcall funcname_and_paramlist - #elif defined(EA_COMPILER_GNUC) && defined(EA_PROCESSOR_X86) - #define EA_PASCAL_FUNC(funcname_and_paramlist) __attribute__((stdcall)) funcname_and_paramlist - #elif defined(EA_COMPILER_METROWERKS) && defined(EA_PLATFORM_WINDOWS) - #define EA_PASCAL_FUNC(funcname_and_paramlist) pascal funcname_and_paramlist - #else - #define EA_PASCAL_FUNC(funcname_and_paramlist) funcname_and_paramlist - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_SSE - // Visual C Processor Packs define _MSC_FULL_VER and are needed for SSE - // Intel C also has SSE support. - // EA_SSE is used to select FPU or SSE versions in hw_select.inl - #ifndef EA_SSE - #if defined(EA_COMPILER_GNUC) - #if defined(__SSE2__) - #define EA_SSE 2 - #elif defined(__SSE__) && __SSE__ - #define EA_SSE 1 - #else - #define EA_SSE 0 - #endif - #elif defined(EA_PROCESSOR_X86) && defined(_MSC_FULL_VER) && !defined(__NOSSE__) && defined(_M_IX86_FP) - #define EA_SSE _M_IX86_FP - #elif defined(EA_PROCESSOR_X86) && defined(EA_COMPILER_INTEL) && !defined(__NOSSE__) - #define EA_SSE 1 - #else - #define EA_SSE 0 - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_IMPORT - // import declaration specification - // specifies that the declared symbol is imported from another dynamic library. - #ifndef EA_IMPORT - #if defined(EA_COMPILER_MSVC) - #define EA_IMPORT __declspec(dllimport) - #else - #define EA_IMPORT - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_EXPORT - // export declaration specification - // specifies that the declared symbol is exported from the current dynamic library. - // this is not the same as the C++ export keyword. - #ifndef EA_EXPORT - #if defined(EA_COMPILER_MSVC) - #define EA_EXPORT __declspec(dllexport) - #else - #define EA_EXPORT - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_PRAGMA_ONCE_SUPPORTED - // - // This is a wrapper for the #pragma once preprocessor directive. - // It allows for some compilers (in particular VC++) to implement signifcantly - // faster include file preprocessing. #pragma once can be used to replace - // header include guards or to augment them. However, #pragma once isn't - // necessarily supported by all compilers and isn't guaranteed to be so in - // the future, so using #pragma once to replace traditional include guards - // is not strictly portable. Note that a direct #define for #pragma once is - // impossible with VC++, due to limitations, but can be done with other - // compilers/preprocessors via _Pragma("once"). - // - // Example usage (which includes traditional header guards for portability): - // #ifndef SOMEPACKAGE_SOMEHEADER_H - // #define SOMEPACKAGE_SOMEHEADER_H - // - // #if defined(EA_PRAGMA_ONCE_SUPPORTED) - // #pragma once - // #endif - // - // - // - // #endif - // - #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__) || defined(__SNC__) || defined(__ICC) || defined(__ICL) - #define EA_PRAGMA_ONCE_SUPPORTED 1 - #endif - - - // ------------------------------------------------------------------------ - // EA_OVERRIDE - // - // See http://msdn.microsoft.com/en-us/library/41w3sh1c.aspx for more information. - // - #ifndef EA_OVERRIDE - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // VS2005 (VC8) and later - #define EA_OVERRIDE override - #else - #define EA_OVERRIDE - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_SEALED - // - // See http://msdn.microsoft.com/en-us/library/49k3w2fx%28VS.71%29.aspx for more information. - // - #ifndef EA_SEALED - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // VS2005 (VC8) and later - #define EA_SEALED sealed - #else - #define EA_SEALED - #endif - #endif - - - // ------------------------------------------------------------------------ - // EA_ABSTRACT - // - // See http://msdn.microsoft.com/en-us/library/49k3w2fx%28VS.71%29.aspx for more information. - // - #ifndef EA_ABSTRACT - #if defined(EA_COMPILER_MSVC) && (EA_COMPILER_VERSION >= 1400) // VS2005 (VC8) and later - #define EA_ABSTRACT abstract - #else - #define EA_ABSTRACT - #endif - #endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eaplatform_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eaplatform_eastl.h deleted file mode 100644 index a8d008e587df..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/eaplatform_eastl.h +++ /dev/null @@ -1,541 +0,0 @@ -/* -Copyright (C) 2009 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/*----------------------------------------------------------------------------- - * config/eaplatform.h - * - * Copyright (c) 2002 - 2005 Electronic Arts Inc. All rights reserved. - * Maintained by Paul Pedriana, Maxis - * - *----------------------------------------------------------------------------- - * Currently supported platform indentification defines include: - * EA_PLATFORM_PS3 - * EA_PLATFORM_PS3_PPU - * EA_PLATFORM_PS3_SPU - * EA_PLATFORM_XENON (a.k.a. XBox2) - * EA_PLATFORM_MAC - * EA_PLATFORM_OSX - * EA_PLATFORM_LINUX - * EA_PLATFORM_WINDOWS - * EA_PLATFORM_WIN32 - * EA_PLATFORM_WIN64 - * EA_PLATFORM_HPUX - * EA_PLATFORM_SUN - * EA_PLATFORM_LRB (Larrabee) - * EA_PLATFORM_UNIX (pseudo-platform; may be defined along with another platform like EA_PLATFORM_LINUX) - * EA_PLATFORM_CYGWIN (pseudo-platform; may be defined along with another platform like EA_PLATFORM_LINUX) - * EA_PLATFORM_MINGW (pseudo-platform; may be defined along with another platform like EA_PLATFORM_WINDOWS) - * EA_PLATFORM_MICROSOFT (pseudo-platform; may be defined along with another platform like EA_PLATFORM_WINDOWS) - * - * Other definitions emanated from this file inclue: - * EA_PLATFORM_NAME = - * EA_PLATFORM_DESCRIPTION = - * EA_PROCESSOR_XXX - * EA_SYSTEM_LITTLE_ENDIAN | EA_SYSTEM_BIG_ENDIAN - * EA_ASM_STYLE_ATT | EA_ASM_STYLE_INTEL | EA_ASM_STYLE_MOTOROLA - * EA_PLATFORM_PTR_SIZE = - * EA_PLATFORM_WORD_SIZE = - * - *---------------------------------------------------------------------------*/ - - -#ifndef INCLUDED_eaplatform_H -#define INCLUDED_eaplatform_H - - -// Cygwin -// This is a pseudo-platform which will be defined along with EA_PLATFORM_LINUX when -// using the Cygwin build environment. -#if defined(__CYGWIN__) - #define EA_PLATFORM_CYGWIN - #define EA_PLATFORM_DESKTOP -#endif - -// MinGW -// This is a pseudo-platform which will be defined along with EA_PLATFORM_WINDOWS when -// using the MinGW Windows build environment. -#if defined(__MINGW32__) || defined(__MINGW64__) - #define EA_PLATFORM_MINGW - #define EA_PLATFORM_DESKTOP -#endif - -// PlayStation 3 PPU (Primary Processing Unit) -#if defined(EA_PLATFORM_PS3_PPU) || defined(EA_PLATFORM_PS3) || defined(__PU__) || defined(__PPU__) - #undef EA_PLATFORM_PS3_PPU - #define EA_PLATFORM_PS3_PPU 1 - #undef EA_PLATFORM_PS3 - #define EA_PLATFORM_PS3 1 - #define EA_PLATFORM_NAME "PS3" - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_64 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "PS3 on PowerPC" - #define EA_PLATFORM_CONSOLE - -// PlayStation 3 SPU (Synergistic Processing Unit) -#elif defined(EA_PLATFORM_PS3_SPU) || defined(__SPU__) - #undef EA_PLATFORM_PS3_SPU - #define EA_PLATFORM_PS3_SPU 1 - #define EA_PLATFORM_NAME "PS3 SPU" - #define EA_PROCESSOR_SPU - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "PS3 SPU on SPU" - #define EA_PLATFORM_CONSOLE - -// XBox -// _XBOX is defined by the VC++ project, not the compiler. There is no way -// to tell if the compiler is compiling for XBox unless _XBOX is #defined -// in the project files or otherwise. _M_IX86 is the VC++ way of detecting -// an x86 target, which would mean XBox and not Xenon (a.k.a. XBox2). -#elif defined(EA_PLATFORM_XBOX) || (defined(_XBOX) && defined(_M_IX86)) - #undef EA_PLATFORM_XBOX - #define EA_PLATFORM_XBOX 1 - #define EA_PLATFORM_NAME "XBox" - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "XBox on X86" - #if defined(_MSC_VER) || defined(__ICL) - #define EA_ASM_STYLE_INTEL - #endif - #define EA_PLATFORM_CONSOLE - -// Xenon (XBox 360) -// The Xenon compiler doesn't define anything in particular to indicate that the -// target is the Xenon platform. The Xenon SDK, however, expects that XBOX and -// _XBOX are #defined, so the project build file must make sure these are defined. -// Since the Xenon compiler in fact defines _M_PPC, we can use this information -// to infer that Xenon is the target if neither _XENON nor _XBOX2 are specifically -// defined by the project build file. -#elif defined(EA_PLATFORM_XENON) || defined(_XENON) || defined(_XBOX2) || ((defined(_XBOX) || defined(XBOX)) && defined(_M_PPC)) - #undef EA_PLATFORM_XENON - #define EA_PLATFORM_XENON 1 - #define EA_PLATFORM_NAME "Xenon" - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_64 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Xenon on PowerPC" - #if defined(_MSC_VER) || defined(__ICL) - #define EA_ASM_STYLE_INTEL - #endif - #define EA_PLATFORM_CONSOLE - #define EA_PLATFORM_MICROSOFT 1 - -// Larrabee // This part to be removed once __LRB__ is supported by the Larrabee compiler in 2009. -#elif defined(EA_PLATFORM_LRB) || defined(__LRB__) || (defined(__EDG__) && defined(__ICC) && defined(__x86_64__)) - #undef EA_PLATFORM_LRB - #define EA_PLATFORM_LRB 1 - #define EA_PLATFORM_NAME "Larrabee" - #define EA_PLATFORM_DESCRIPTION "Larrabee on LRB1" - #define EA_PROCESSOR_X86_64 - #if defined(BYTE_ORDER) && (BYTE_ORDER == 4321) - #define EA_SYSTEM_BIG_ENDIAN - #else - #define EA_SYSTEM_LITTLE_ENDIAN - #endif - #define EA_PROCESSOR_LRB - #define EA_PROCESSOR_LRB1 // Larrabee version 1 - #define EA_ASM_STYLE_ATT // Both types of asm style - #define EA_ASM_STYLE_INTEL // are supported. - #define EA_PLATFORM_DESKTOP - -// Android (Google phone OS) -#elif defined(EA_PLATFORM_ANDROID) || defined(__ANDROID__) - #undef EA_PLATFORM_ANDROID - #define EA_PLATFORM_ANDROID 1 - #define EA_PLATFORM_LINUX 1 - #define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "Android" - #define EA_ASM_STYLE_ATT - #if defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_PLATFORM_DESCRIPTION "Android on ARM" - #else - #error Unknown processor - #endif - #if !defined(EA_SYSTEM_BIG_ENDIAN) && !defined(EA_SYSTEM_LITTLE_ENDIAN) - #define EA_SYSTEM_LITTLE_ENDIAN - #endif - #define EA_PLATFORM_MOBILE - -// Palm OS for Mobile (Linux variant) -#elif defined(EA_PLATFORM_PALM) - #undef EA_PLATFORM_PALM - #define EA_PLATFORM_PALM 1 - #define EA_PLATFORM_LINUX 1 - #define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "Palm" - #define EA_POSIX_THREADS_AVAILABLE 1 - #define EA_ASM_STYLE_ATT - #if defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_PLATFORM_DESCRIPTION "Palm on ARM" - #else - #error Unknown processor - #endif - #if !defined(EA_SYSTEM_BIG_ENDIAN) && !defined(EA_SYSTEM_LITTLE_ENDIAN) - #define EA_SYSTEM_LITTLE_ENDIAN - #endif - #define EA_PLATFORM_MOBILE - -// Airplay -#elif defined(EA_PLATFORM_AIRPLAY) || defined(__S3E__) - #undef EA_PLATFORM_AIRPLAY - #define EA_PLATFORM_AIRPLAY - #define EA_PLATFORM_NAME "Airplay" - #if defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_PLATFORM_DESCRIPTION "Airplay on ARM" - #define EA_ASM_STYLE_ATT - #undef _MSC_VER - #elif defined(_M_IX86) - #define EA_PROCESSOR_X86 - #define EA_PLATFORM_DESCRIPTION "Airplay on x86" - #define EA_ASM_STYLE_INTEL - #else - #error Unknown processor - #endif - #if !defined(EA_SYSTEM_BIG_ENDIAN) && !defined(EA_SYSTEM_LITTLE_ENDIAN) - #if defined(HAVE_BIG_ENDIAN) || (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN))) - #define EA_SYSTEM_BIG_ENDIAN - #else - #define EA_SYSTEM_LITTLE_ENDIAN - #endif - #endif - #define EA_PLATFORM_MOBILE - -// Samsung Bada OS for Mobile (Linux variant) -#elif defined(EA_PLATFORM_BADA) - #undef EA_PLATFORM_BADA - #define EA_PLATFORM_BADA 1 - //#define EA_PLATFORM_LINUX 1 // The underlying OS is Linux, but the app mostly doesn't see this. - //#define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "bada" - #define EA_ASM_STYLE_ATT - #if defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_PLATFORM_DESCRIPTION "bada on ARM" - #elif defined(__i386__) - #define EA_PLATFORM_BADA_SIMULATOR - #define EA_PROCESSOR_X86 - #define EA_PLATFORM_DESCRIPTION "bada simulator on x86" - #else - #error Unknown processor - #endif - #if !defined(EA_SYSTEM_BIG_ENDIAN) && !defined(EA_SYSTEM_LITTLE_ENDIAN) - #define EA_SYSTEM_LITTLE_ENDIAN - #endif - #define EA_PLATFORM_MOBILE - -#elif defined(__APPLE__) && __APPLE__ - #include - - // Apple family of operating systems. - #define EA_PLATFORM_APPLE - - // iPhone - // TARGET_OS_IPHONE will be undefined on an unknown compiler, and will be defined on gcc. - #if defined(EA_PLATFORM_IPHONE) || defined(__IPHONE__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR) - #undef EA_PLATFORM_IPHONE - #define EA_PLATFORM_IPHONE 1 - #define EA_PLATFORM_NAME "iPhone" - #define EA_ASM_STYLE_ATT - #define EA_POSIX_THREADS_AVAILABLE 1 - #if defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "iPhone on ARM" - #elif defined(__i386__) - #define EA_PLATFORM_IPHONE_SIMULATOR - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "iPhone simulator on x86" - #else - #error Unknown processor - #endif - #define EA_PLATFORM_MOBILE - - // Macintosh OSX - // TARGET_OS_MAC is defined by the Metrowerks and older AppleC compilers. - // Howerver, TARGET_OS_MAC is defined to be 1 in all cases. - // __i386__ and __intel__ are defined by the GCC compiler. - // __dest_os is defined by the Metrowerks compiler. - // __MACH__ is defined by the Metrowerks and GCC compilers. - // powerc and __powerc are defined by the Metrowerks and GCC compilers. - #elif defined(EA_PLATFORM_OSX) || defined(__MACH__) || (defined(__MSL__) && (__dest_os == __mac_os_x)) - #undef EA_PLATFORM_OSX - #define EA_PLATFORM_OSX 1 - #define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "OSX" - #if defined(__i386__) || defined(__intel__) - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "OSX on x86" - #elif defined(__x86_64) || defined(__amd64) - #define EA_PROCESSOR_X86_64 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "OSX on x86-64" - #elif defined(__arm__) - #define EA_PROCESSOR_ARM - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "OSX on ARM" - #elif defined(__POWERPC64__) || defined(__powerpc64__) - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_64 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "OSX on PowerPC 64" - #elif defined(__POWERPC__) || defined(__powerpc__) - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_32 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "OSX on PowerPC" - #else - #error Unknown processor - #endif - #if defined(__GNUC__) - #define EA_ASM_STYLE_ATT - #else - #define EA_ASM_STYLE_MOTOROLA - #endif - #define EA_PLATFORM_DESKTOP - - #else - #error Unknown Apple Platform - #endif - -// Linux -// __linux and __linux__ are defined by the GCC and Borland compiler. -// __i386__ and __intel__ are defined by the GCC compiler. -// __i386__ is defined by the Metrowerks compiler. -// _M_IX86 is defined by the Borland compiler. -// __sparc__ is defined by the GCC compiler. -// __powerpc__ is defined by the GCC compiler. -#elif defined(EA_PLATFORM_LINUX) || (defined(__linux) || defined(__linux__)) - #undef EA_PLATFORM_LINUX - #define EA_PLATFORM_LINUX 1 - #define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "Linux" - #if defined(__i386__) || defined(__intel__) || defined(_M_IX86) - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Linux on x86" - #elif defined(__x86_64__) - #define EA_PROCESSOR_X86_64 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Linux on x86-64" - #elif defined(__powerpc64__) - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_64 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Linux on PowerPC 64" - #elif defined(__powerpc__) - #define EA_PROCESSOR_POWERPC - #define EA_PROCESSOR_POWERPC_32 - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Linux on PowerPC" - #else - #error Unknown processor - #error Unknown endianness - #endif - #if defined(__GNUC__) - #define EA_ASM_STYLE_ATT - #endif - #define EA_PLATFORM_DESKTOP - -// Win CE (Windows mobile) -#elif defined(EA_PLATFORM_WINCE) || defined(_WIN32_WCE) - #undef EA_PLATFORM_WINCE - #define EA_PLATFORM_WINCE 1 - #define EA_PLATFORM_NAME "WinCE" - #define EA_ASM_STYLE_INTEL - #define EA_SYSTEM_LITTLE_ENDIAN - #if defined(_M_ARM) // Also there is _M_ARMT - #define EA_PROCESSOR_ARM - #define EA_PLATFORM_DESCRIPTION "Windows CE on ARM" - #elif defined(_M_IX86) - #define EA_PROCESSOR_X86 - #define EA_PLATFORM_DESCRIPTION "Windows CE on X86" - #else //Possibly other Windows CE variants - #error Unknown processor - #endif - #define EA_PLATFORM_MOBILE - -// Windows -// _WIN32 is defined by the VC++, Intel and GCC compilers. -// _WIN64 is defined by the VC++, Intel and GCC compilers. -// __WIN32__ is defined by the Borland compiler. -// __INTEL__ is defined by the Metrowerks compiler. -// _M_IX86, _M_AMD64 and _M_IA64 are defined by the VC++, Intel, and Borland compilers. -// _X86_, _AMD64_, and _IA64_ are defined by the Metrowerks compiler. -// _M_ARM is defined by the VC++ compiler. -#elif (defined(EA_PLATFORM_WINDOWS) || (defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || (defined(__MWERKS__) && defined(_X86_)))) && !defined(_XBOX) - #undef EA_PLATFORM_WINDOWS - #define EA_PLATFORM_WINDOWS 1 - #define EA_PLATFORM_NAME "Windows" - #ifdef _WIN64 // VC++ defines both _WIN32 and _WIN64 when compiling for Win64. - #define EA_PLATFORM_WIN64 - #else - #define EA_PLATFORM_WIN32 - #endif - #if defined(_M_AMD64) || defined(_AMD64_) || defined(__x86_64__) - #define EA_PROCESSOR_X86_64 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Windows on X86-64" - #elif defined(_M_IX86) || defined(_X86_) - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Windows on X86" - #elif defined(_M_IA64) || defined(_IA64_) - #define EA_PROCESSOR_IA64 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Windows on IA-64" - #elif defined(_M_ARM) - #define EA_PROCESSOR_ARM - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "Windows CE on ARM" - #else //Possibly other Windows CE variants - #error Unknown processor - #error Unknown endianness - #endif - #if defined(__GNUC__) - #define EA_ASM_STYLE_ATT - #elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__ICL) - #define EA_ASM_STYLE_INTEL - #endif - #define EA_PLATFORM_DESKTOP - #define EA_PLATFORM_MICROSOFT 1 - -// Sun (Solaris) -// __SUNPRO_CC is defined by the Sun compiler. -// __sun is defined by the GCC compiler. -// __i386 is defined by the Sun and GCC compilers. -// __sparc is defined by the Sun and GCC compilers. -#elif defined(EA_PLATFORM_SUN) || (defined(__SUNPRO_CC) || defined(__sun)) - #undef EA_PLATFORM_SUN - #define EA_PLATFORM_SUN 1 - #define EA_PLATFORM_UNIX 1 - #define EA_PLATFORM_NAME "SUN" - #if defined(__i386) - #define EA_PROCESSOR_X86 - #define EA_SYSTEM_LITTLE_ENDIAN - #define EA_PLATFORM_DESCRIPTION "SUN on x86" - #elif defined(__sparc) - #define EA_PROCESSOR_SPARC - #define EA_SYSTEM_BIG_ENDIAN - #define EA_PLATFORM_DESCRIPTION "SUN on Sparc" - #else - #error Unknown processor - #error Unknown endianness - #endif - #define EA_PLATFORM_DESKTOP - -#else - #error Unknown platform - #error Unknown processor - #error Unknown endianness -#endif - - - -// EA_PLATFORM_PTR_SIZE -// Platform pointer size; same as sizeof(void*). -// This is not the same as sizeof(int), as int is usually 32 bits on -// even 64 bit platforms. -// -// _WIN64 is defined by Win64 compilers, such as VC++. -// _M_IA64 is defined by VC++ and Intel compilers for IA64 processors. -// __LP64__ is defined by HP compilers for the LP64 standard. -// _LP64 is defined by the GCC and Sun compilers for the LP64 standard. -// __ia64__ is defined by the GCC compiler for IA64 processors. -// __arch64__ is defined by the Sparc compiler for 64 bit processors. -// __mips64__ is defined by the GCC compiler for MIPS processors. -// __powerpc64__ is defined by the GCC compiler for PowerPC processors. -// __64BIT__ is defined by the AIX compiler for 64 bit processors. -// __sizeof_ptr is defined by the ARM compiler (armcc, armcpp). -// -#ifndef EA_PLATFORM_PTR_SIZE - #if defined(__WORDSIZE) // Defined by some variations of GCC. - #define EA_PLATFORM_PTR_SIZE ((__WORDSIZE) / 8) - #elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || defined(__ia64__) || defined(__arch64__) || defined(__mips64__) || defined(__64BIT__) - #define EA_PLATFORM_PTR_SIZE 8 - #elif defined(__CC_ARM) && (__sizeof_ptr == 8) - #define EA_PLATFORM_PTR_SIZE 8 - #else - #define EA_PLATFORM_PTR_SIZE 4 - #endif -#endif - - - -// EA_PLATFORM_WORD_SIZE -// This defines the size of a machine word. This will be the same as -// the size of registers on the machine but not necessarily the same -// as the size of pointers on the machine. A number of 64 bit platforms -// have 64 bit registers but 32 bit pointers. -// -#ifndef EA_PLATFORM_WORD_SIZE - #if defined(EA_PLATFORM_XENON) || defined(EA_PLATFORM_PS3) - #define EA_PLATFORM_WORD_SIZE 8 - #else - #define EA_PLATFORM_WORD_SIZE EA_PLATFORM_PTR_SIZE - #endif -#endif - - - -// Disabled until and unless deemed useful: -// -// Platform integer types -// These definitions allow us to define other things properly, such as -// sized integer types. In order to bring some order to this chaos, -// we follow a variation of the standard LP64 conventions defined at: -// http://www.opengroup.org/public/tech/aspen/lp64_wp.htm -// -// #if defined(EA_PLATFORM_LINUX) || defined(EA_PLATFORM_OSX) || defined(EA_PLATFORM_XBOX) || defined(EA_PLATFORM_XENON) -// #define EA_PLATFORM_ILP32_LL64 // int, long, ptr = 32 bits; long long = 64 bits. -// -// #elif defined(EA_PLATFORM_SUN) || defined(EA_PLATFORM_SGI) -// #if (EA_PLATFORM_WORD_SIZE == 32) -// #define ILP32_LL64 // int, long, ptr = 32 bits; long long = 64 bits. -// #else // 64 bit platform -// #define EA_PLATFORM_I32_LLLP64 // int = 32 bits; long, long long, ptr = 64 bits. -// #endif -// -// #elif defined(EA_PLATFORM_WINDOWS) -// #if (EA_PLATFORM_WORD_SIZE == 32) -// #define ILP32_LL64 // int, long, ptr = 32 bits; long long = 64 bits. -// #else // 64 bit platform -// #if defined(__MWERKS__) || defined(__GNUC__) -// #define EA_PLATFORM_I32_LLLP64 // int = 32 bits; long, long long, ptr = 64 bits. -// #else // MSVC -// #define EA_PLATFORM_IL32_LLP64 // int, long = 32 bits; long long, ptr = 64 bits. -// #endif -// #endif -// #endif - - -#endif // INCLUDED_eaplatform_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_allocator_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_allocator_eastl.h deleted file mode 100644 index 36a86c7abd9e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_allocator_eastl.h +++ /dev/null @@ -1,464 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/fixed_allocator.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file implements the following -// fixed_allocator -// fixed_allocator_with_overflow -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_FIXED_ALLOCATOR_H -#define EASTL_FIXED_ALLOCATOR_H - - -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) - #include - #pragma warning(pop) -#else - #include -#endif - - -namespace eastl -{ - - /////////////////////////////////////////////////////////////////////////// - // fixed_allocator - /////////////////////////////////////////////////////////////////////////// - - /// fixed_allocator - /// - /// Implements an allocator which allocates a single fixed size where - /// the size, alignment, and memory used for the pool is defined at - /// runtime by the user. This is different from fixed containers - /// such as fixed_list whereby the size and alignment are determined - /// at compile time and the memory is directly built into the container's - /// member data. - /// - /// If the pool's memory is exhausted or was never initialized, the - /// allocate function returns NULL. Consider the fixed_allocator_with_overflow - /// class as an alternative in order to deal with this situation. - /// - /// This class requires the user to call container.get_allocator().init() - /// after constructing the container. There currently isn't a way to - /// construct the container with the initialization parameters, though - /// with some effort such a thing could probably be made possible. - /// It's not as simple as it might first seem, due to the non-copyable - /// nature of fixed allocators. A side effect of this limitation is that - /// you cannot copy-construct a container using fixed_allocators. - /// - /// Another side-effect is that you cannot swap two containers using - /// a fixed_allocator, as a swap requires temporary memory allocated by - /// an equivalent allocator, and such a thing cannot be done implicitly. - /// A workaround for the swap limitation is that you can implement your - /// own swap whereby you provide an explicitly created temporary object. - /// - /// Note: Be careful to set the allocator's node size to the size of the - /// container node and not the size of the contained object. Note that the - /// example code below uses IntListNode. - /// - /// Example usage: - /// typedef eastl::list IntList; - /// typedef IntList::node_type IntListNode; - /// - /// IntListNode buffer[200]; - /// IntList intList; - /// intList.get_allocator().init(buffer, sizeof(buffer), sizeof(IntListNode), __alignof(IntListNode)); - /// - class EASTL_API fixed_allocator : public fixed_pool_base - { - public: - /// fixed_allocator - /// - /// Default constructor. The user usually will need to call init() after - /// constructing via this constructor. - /// - fixed_allocator(const char* /*pName*/ = EASTL_FIXED_POOL_DEFAULT_NAME) - : fixed_pool_base(NULL) - { - } - - - /// fixed_allocator - /// - /// Copy constructor. The user usually will need to call init() after - /// constructing via this constructor. By their nature, fixed-allocators - /// cannot be copied in any useful way, as by their nature the user - /// must manually initialize them. - /// - fixed_allocator(const fixed_allocator&) - : fixed_pool_base(NULL) - { - } - - - /// operator= - /// - /// By their nature, fixed-allocators cannot be copied in any - /// useful way, as by their nature the user must manually - /// initialize them. - /// - fixed_allocator& operator=(const fixed_allocator&) - { - return *this; - } - - - // init - // - // No init here, as the base class version is sufficient. - // - //void init(void* pMemory, size_t memorySize, size_t nodeSize, - // size_t alignment, size_t alignmentOffset = 0); - - - /// allocate - /// - /// Allocates a new object of the size specified upon class initialization. - /// Returns NULL if there is no more memory. - /// - void* allocate(size_t /*n*/, int /*flags*/ = 0) - { - // To consider: Verify that 'n' is what the user initialized us with. - - Link* pLink = mpHead; - - if(pLink) // If we have space... - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(++mnCurrentSize > mnPeakSize) - mnPeakSize = mnCurrentSize; - #endif - - mpHead = pLink->mpNext; - return pLink; - } - else - { - // If there's no free node in the free list, just - // allocate another from the reserved memory area - - if(mpNext != mpCapacity) - { - pLink = mpNext; - - mpNext = reinterpret_cast(reinterpret_cast(mpNext) + mnNodeSize); - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(++mnCurrentSize > mnPeakSize) - mnPeakSize = mnCurrentSize; - #endif - - return pLink; - } - - // EASTL_ASSERT(false); To consider: enable this assert. However, we intentionally disable it because this isn't necessarily an assertable error. - return NULL; - } - } - - - /// allocate - /// - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int flags = 0) - { - return allocate(n, flags); - } - - - /// deallocate - /// - /// Frees the given object which was allocated by allocate(). - /// If the given node was not allocated by allocate() then the behaviour - /// is undefined. - /// - void deallocate(void* p, size_t) - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - --mnCurrentSize; - #endif - - ((Link*)p)->mpNext = mpHead; - mpHead = ((Link*)p); - } - - - using fixed_pool_base::can_allocate; - - - const char* get_name() const - { - return EASTL_FIXED_POOL_DEFAULT_NAME; - } - - - void set_name(const char*) - { - // Nothing to do. We don't allocate memory. - } - - }; // fixed_allocator - - bool operator==(const fixed_allocator& a, const fixed_allocator& b); - bool operator!=(const fixed_allocator& a, const fixed_allocator& b); - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_allocator_with_overflow - /////////////////////////////////////////////////////////////////////////// - - /// fixed_allocator_with_overflow - /// - /// Implements an allocator which allocates a single fixed size where - /// the size, alignment, and memory used for the pool is defined at - /// runtime by the user. This is different from fixed containers - /// such as fixed_list whereby the size and alignment are determined - /// at compile time and the memory is directly built into the container's - /// member data. - /// - /// Note: Be careful to set the allocator's node size to the size of the - /// container node and not the size of the contained object. Note that the - /// example code below uses IntListNode. - /// - /// This class requires the user to call container.get_allocator().init() - /// after constructing the container. There currently isn't a way to - /// construct the container with the initialization parameters, though - /// with some effort such a thing could probably be made possible. - /// It's not as simple as it might first seem, due to the non-copyable - /// nature of fixed allocators. A side effect of this limitation is that - /// you cannot copy-construct a container using fixed_allocators. - /// - /// Another side-effect is that you cannot swap two containers using - /// a fixed_allocator, as a swap requires temporary memory allocated by - /// an equivalent allocator, and such a thing cannot be done implicitly. - /// A workaround for the swap limitation is that you can implement your - /// own swap whereby you provide an explicitly created temporary object. - /// - /// Example usage: - /// typedef eastl::list IntList; - /// typedef IntList::node_type IntListNode; - /// - /// IntListNode buffer[200]; - /// IntList intList; - /// intList.get_allocator().init(buffer, sizeof(buffer), sizeof(IntListNode), __alignof(IntListNode)); - /// - class EASTL_API fixed_allocator_with_overflow : public fixed_pool_base - { - public: - /// fixed_allocator_with_overflow - /// - /// Default constructor. The user usually will need to call init() after - /// constructing via this constructor. - /// - fixed_allocator_with_overflow(const char* pName = EASTL_FIXED_POOL_DEFAULT_NAME) - : fixed_pool_base(NULL), - mOverflowAllocator(pName) - { - } - - - /// fixed_allocator_with_overflow - /// - /// Copy constructor. The user usually will need to call init() after - /// constructing via this constructor. By their nature, fixed-allocators - /// cannot be copied in any useful way, as by their nature the user - /// must manually initialize them. - /// - fixed_allocator_with_overflow(const fixed_allocator_with_overflow&) - : fixed_pool_base(NULL) - { - } - - - /// operator= - /// - /// By their nature, fixed-allocators cannot be copied in any - /// useful way, as by their nature the user must manually - /// initialize them. - /// - fixed_allocator_with_overflow& operator=(const fixed_allocator_with_overflow& x) - { - #if EASTL_ALLOCATOR_COPY_ENABLED - mOverflowAllocator = x.mOverflowAllocator; - #else - (void)x; - #endif - - return *this; - } - - - /// init - /// - void init(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t alignmentOffset = 0) - { - fixed_pool_base::init(pMemory, memorySize, nodeSize, alignment, alignmentOffset); - - mpPoolBegin = pMemory; - mpPoolEnd = (void*)((uintptr_t)pMemory + memorySize); - mnNodeSize = (eastl_size_t)nodeSize; - } - - - /// allocate - /// - /// Allocates a new object of the size specified upon class initialization. - /// Returns NULL if there is no more memory. - /// - void* allocate(size_t /*n*/, int /*flags*/ = 0) - { - // To consider: Verify that 'n' is what the user initialized us with. - - void* p; - - if(mpHead) // If we have space... - { - p = mpHead; - mpHead = mpHead->mpNext; - } - else - p = mOverflowAllocator.allocate(mnNodeSize); - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(p && (++mnCurrentSize > mnPeakSize)) - mnPeakSize = mnCurrentSize; - #endif - - return p; - } - - - /// allocate - /// - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int flags = 0) - { - return allocate(n, flags); - } - - - /// deallocate - /// - /// Frees the given object which was allocated by allocate(). - /// If the given node was not allocated by allocate() then the behaviour - /// is undefined. - /// - void deallocate(void* p, size_t) - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - --mnCurrentSize; - #endif - - if((p >= mpPoolBegin) && (p < mpPoolEnd)) - { - ((Link*)p)->mpNext = mpHead; - mpHead = ((Link*)p); - } - else - mOverflowAllocator.deallocate(p, (size_t)mnNodeSize); - } - - - using fixed_pool_base::can_allocate; - - - const char* get_name() const - { - return mOverflowAllocator.get_name(); - } - - - void set_name(const char* pName) - { - mOverflowAllocator.set_name(pName); - } - - protected: - EASTLAllocatorType mOverflowAllocator; // To consider: Allow the user to define the type of this, presumably via a template parameter. - void* mpPoolBegin; // To consider: We have these member variables and ideally we shouldn't need them. The problem is that - void* mpPoolEnd; // the information about the pool buffer and object size is stored in the owning container - eastl_size_t mnNodeSize; // and we can't have access to it without increasing the amount of code we need and by templating - // more code. It may turn out that simply storing data here is smaller in the end. - }; // fixed_allocator_with_overflow // Granted, this class is usually used for debugging purposes, but perhaps there is an elegant solution. - - bool operator==(const fixed_allocator_with_overflow& a, const fixed_allocator_with_overflow& b); - bool operator!=(const fixed_allocator_with_overflow& a, const fixed_allocator_with_overflow& b); - - - - - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - inline bool operator==(const fixed_allocator&, const fixed_allocator&) - { - return false; - } - - inline bool operator!=(const fixed_allocator&, const fixed_allocator&) - { - return false; - } - - inline bool operator==(const fixed_allocator_with_overflow&, const fixed_allocator_with_overflow&) - { - return false; - } - - inline bool operator!=(const fixed_allocator_with_overflow&, const fixed_allocator_with_overflow&) - { - return false; - } - - -} // namespace eastl - - - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.cpp deleted file mode 100644 index 84e122a4eaac..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/fixed_pool.cpp -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - - -#include -#include - - - -namespace eastl -{ - - - void fixed_pool_base::init(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t /*alignmentOffset*/) - { - // To do: Support alignmentOffset. - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - mnCurrentSize = 0; - mnPeakSize = 0; - #endif - - if(pMemory) - { - // Assert that alignment is a power of 2 value (e.g. 1, 2, 4, 8, 16, etc.) - EASTL_ASSERT((alignment & (alignment - 1)) == 0); - - // Make sure alignment is a valid value. - if(alignment < 1) - alignment = 1; - - mpNext = (Link*)(((uintptr_t)pMemory + (alignment - 1)) & ~(alignment - 1)); - memorySize -= (uintptr_t)mpNext - (uintptr_t)pMemory; - pMemory = mpNext; - - // The node size must be at least as big as a Link, which itself is sizeof(void*). - if(nodeSize < sizeof(Link)) - nodeSize = ((sizeof(Link) + (alignment - 1))) & ~(alignment - 1); - - // If the user passed in a memory size that wasn't a multiple of the node size, - // we need to chop down the memory size so that the last node is not a whole node. - memorySize = (memorySize / nodeSize) * nodeSize; - - mpCapacity = (Link*)((uintptr_t)pMemory + memorySize); - mpHead = NULL; - mnNodeSize = nodeSize; - } - } - - -} // namespace eastl diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.h deleted file mode 100644 index 27b1361d160e..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/fixed_pool_eastl.h +++ /dev/null @@ -1,1371 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/fixed_pool.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file implements the following -// aligned_buffer -// fixed_pool_base -// fixed_pool -// fixed_pool_with_overflow -// fixed_hashtable_allocator -// fixed_vector_allocator -// fixed_swap -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_FIXED_POOL_H -#define EASTL_INTERNAL_FIXED_POOL_H - - -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) - #include - #pragma warning(pop) -#else - #include -#endif - - - -namespace eastl -{ - - /// EASTL_FIXED_POOL_DEFAULT_NAME - /// - /// Defines a default allocator name in the absence of a user-provided name. - /// - #ifndef EASTL_FIXED_POOL_DEFAULT_NAME - #define EASTL_FIXED_POOL_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " fixed_pool" // Unless the user overrides something, this is "EASTL fixed_pool". - #endif - - - - /////////////////////////////////////////////////////////////////////////// - // aligned_buffer - /////////////////////////////////////////////////////////////////////////// - - /// aligned_buffer - /// - /// This is useful for creating a buffer of the same size and alignment - /// of a given struct or class. This is useful for creating memory pools - /// that support both size and alignment requirements of stored objects - /// but without wasting space in over-allocating. - /// - /// Note that we implement this via struct specializations, as some - /// compilers such as VC++ do not support specification of alignments - /// in any way other than via an integral constant. - /// - /// Example usage: - /// struct Widget{ }; // This class has a given size and alignment. - /// - /// Declare a char buffer of equal size and alignment to Widget. - /// aligned_buffer mWidgetBuffer; - /// - /// Declare an array this time. - /// aligned_buffer mWidgetArray[15]; - /// - typedef char EASTL_MAY_ALIAS aligned_buffer_char; - - template - struct aligned_buffer { aligned_buffer_char buffer[size]; }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(2) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(2); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(4) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(4); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(8) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(8); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(16) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(16); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(32) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(32); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(64) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(64); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(128) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(128); }; - - #if !defined(EA_PLATFORM_PSP) // This compiler fails to compile alignment >= 256 and gives an error. - - template - struct aligned_buffer { EA_PREFIX_ALIGN(256) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(256); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(512) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(512); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(1024) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(1024); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(2048) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(2048); }; - - template - struct aligned_buffer { EA_PREFIX_ALIGN(4096) aligned_buffer_char buffer[size] EA_POSTFIX_ALIGN(4096); }; - - #endif // EA_PLATFORM_PSP - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_pool_base - /////////////////////////////////////////////////////////////////////////// - - /// fixed_pool_base - /// - /// This is a base class for the implementation of fixed-size pools. - /// In particular, the fixed_pool and fixed_pool_with_overflow classes - /// are based on fixed_pool_base. - /// - struct EASTL_API fixed_pool_base - { - public: - /// fixed_pool_base - /// - fixed_pool_base(void* pMemory = NULL) - : mpHead((Link*)pMemory) - , mpNext((Link*)pMemory) - , mpCapacity((Link*)pMemory) - #if EASTL_DEBUG - , mnNodeSize(0) // This is normally set in the init function. - #endif - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - mnCurrentSize = 0; - mnPeakSize = 0; - #endif - } - - - /// operator= - /// - fixed_pool_base& operator=(const fixed_pool_base&) - { - // By design we do nothing. We don't attempt to deep-copy member data. - return *this; - } - - - /// init - /// - /// Initializes a fixed_pool with a given set of parameters. - /// You cannot call this function twice else the resulting - /// behaviour will be undefined. You can only call this function - /// after constructing the fixed_pool with the default constructor. - /// - void init(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t alignmentOffset = 0); - - - /// peak_size - /// - /// Returns the maximum number of outstanding allocations there have been - /// at any one time. This represents a high water mark for the allocation count. - /// - size_t peak_size() const - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - return mnPeakSize; - #else - return 0; - #endif - } - - - /// can_allocate - /// - /// Returns true if there are any free links. - /// - bool can_allocate() const - { - return (mpHead != NULL) || (mpNext != mpCapacity); - } - - public: - /// Link - /// Implements a singly-linked list. - struct Link - { - Link* mpNext; - }; - - Link* mpHead; - Link* mpNext; - Link* mpCapacity; - size_t mnNodeSize; - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - uint32_t mnCurrentSize; /// Current number of allocated nodes. - uint32_t mnPeakSize; /// Max number of allocated nodes at any one time. - #endif - - }; // fixed_pool_base - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_pool - /////////////////////////////////////////////////////////////////////////// - - /// fixed_pool - /// - /// Implements a simple fixed pool allocator for use by fixed-size containers. - /// This is not a generic eastl allocator which can be plugged into an arbitrary - /// eastl container, as it simplifies some functions are arguments for the - /// purpose of efficiency. - /// - class EASTL_API fixed_pool : public fixed_pool_base - { - public: - /// fixed_pool - /// - /// Default constructor. User usually will want to call init() after - /// constructing via this constructor. The pMemory argument is for the - /// purposes of temporarily storing a pointer to the buffer to be used. - /// Even though init may have a pMemory argument, this arg is useful - /// for temporary storage, as per copy construction. - /// - fixed_pool(void* pMemory = NULL) - : fixed_pool_base(pMemory) - { - } - - - /// fixed_pool - /// - /// Constructs a fixed_pool with a given set of parameters. - /// - fixed_pool(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t alignmentOffset = 0) - { - init(pMemory, memorySize, nodeSize, alignment, alignmentOffset); - } - - - /// operator= - /// - fixed_pool& operator=(const fixed_pool&) - { - // By design we do nothing. We don't attempt to deep-copy member data. - return *this; - } - - - /// allocate - /// - /// Allocates a new object of the size specified upon class initialization. - /// Returns NULL if there is no more memory. - /// - void* allocate() - { - Link* pLink = mpHead; - - if(pLink) // If we have space... - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(++mnCurrentSize > mnPeakSize) - mnPeakSize = mnCurrentSize; - #endif - - mpHead = pLink->mpNext; - return pLink; - } - else - { - // If there's no free node in the free list, just - // allocate another from the reserved memory area - - if(mpNext != mpCapacity) - { - pLink = mpNext; - - mpNext = reinterpret_cast(reinterpret_cast(mpNext) + mnNodeSize); - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(++mnCurrentSize > mnPeakSize) - mnPeakSize = mnCurrentSize; - #endif - - return pLink; - } - - // EASTL_ASSERT(false); To consider: enable this assert. However, we intentionally disable it because this isn't necessarily an assertable error. - return NULL; - } - } - - - /// deallocate - /// - /// Frees the given object which was allocated by allocate(). - /// If the given node was not allocated by allocate() then the behaviour - /// is undefined. - /// - void deallocate(void* p) - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - --mnCurrentSize; - #endif - - ((Link*)p)->mpNext = mpHead; - mpHead = ((Link*)p); - } - - - using fixed_pool_base::can_allocate; - - - const char* get_name() const - { - return EASTL_FIXED_POOL_DEFAULT_NAME; - } - - - void set_name(const char*) - { - // Nothing to do. We don't allocate memory. - } - - }; // fixed_pool - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_pool_with_overflow - /////////////////////////////////////////////////////////////////////////// - - /// fixed_pool_with_overflow - /// - template - class fixed_pool_with_overflow : public fixed_pool_base - { - public: - fixed_pool_with_overflow(void* pMemory = NULL) - : fixed_pool_base(pMemory), - mOverflowAllocator(EASTL_FIXED_POOL_DEFAULT_NAME) - { - // Leave mpPoolBegin, mpPoolEnd uninitialized. - } - - - fixed_pool_with_overflow(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t alignmentOffset = 0) - : mOverflowAllocator(EASTL_FIXED_POOL_DEFAULT_NAME) - { - fixed_pool_base::init(pMemory, memorySize, nodeSize, alignment, alignmentOffset); - - mpPoolBegin = pMemory; - } - - - /// operator= - /// - fixed_pool_with_overflow& operator=(const fixed_pool_with_overflow& x) - { - #if EASTL_ALLOCATOR_COPY_ENABLED - mOverflowAllocator = x.mOverflowAllocator; - #else - (void)x; - #endif - - return *this; - } - - - void init(void* pMemory, size_t memorySize, size_t nodeSize, - size_t alignment, size_t alignmentOffset = 0) - { - fixed_pool_base::init(pMemory, memorySize, nodeSize, alignment, alignmentOffset); - - mpPoolBegin = pMemory; - } - - - void* allocate() - { - void* p = NULL; - Link* pLink = mpHead; - - if(pLink) - { - // Unlink from chain - p = pLink; - mpHead = pLink->mpNext; - } - else - { - // If there's no free node in the free list, just - // allocate another from the reserved memory area - - if(mpNext != mpCapacity) - { - p = pLink = mpNext; - mpNext = reinterpret_cast(reinterpret_cast(mpNext) + mnNodeSize); - } - else - p = mOverflowAllocator.allocate(mnNodeSize); - } - - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - if(p && (++mnCurrentSize > mnPeakSize)) - mnPeakSize = mnCurrentSize; - #endif - - return p; - } - - - void deallocate(void* p) - { - #if EASTL_FIXED_SIZE_TRACKING_ENABLED - --mnCurrentSize; - #endif - - if((p >= mpPoolBegin) && (p < mpCapacity)) - { - ((Link*)p)->mpNext = mpHead; - mpHead = ((Link*)p); - } - else - mOverflowAllocator.deallocate(p, (size_t)mnNodeSize); - } - - - using fixed_pool_base::can_allocate; - - - const char* get_name() const - { - return mOverflowAllocator.get_name(); - } - - - void set_name(const char* pName) - { - mOverflowAllocator.set_name(pName); - } - - public: - Allocator mOverflowAllocator; - void* mpPoolBegin; // Ideally we wouldn't need this member variable. he problem is that the information - // about the pool buffer and object size is stored in the owning container and we - //can't have access to it without increasing the amount of code we need and by templating more code. - //It may turn out that simply storing data here is smaller in the end. - - }; // fixed_pool_with_overflow - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_node_allocator - /////////////////////////////////////////////////////////////////////////// - - /// fixed_node_allocator - /// - /// Note: This class was previously named fixed_node_pool, but was changed because this name - /// was inconsistent with the other allocators here which ended with _allocator. - /// - /// Implements a fixed_pool with a given node count, alignment, and alignment offset. - /// fixed_node_allocator is like fixed_pool except it is templated on the node type instead - /// of being a generic allocator. All it does is pass allocations through to - /// the fixed_pool base. This functionality is separate from fixed_pool because there - /// are other uses for fixed_pool. - /// - /// We template on kNodeSize instead of node_type because the former allows for the - /// two different node_types of the same size to use the same template implementation. - /// - /// Template parameters: - /// nodeSize The size of the object to allocate. - /// nodeCount The number of objects the pool contains. - /// nodeAlignment The alignment of the objects to allocate. - /// nodeAlignmentOffset The alignment offset of the objects to allocate. - /// bEnableOverflow Whether or not we should use the overflow heap if our object pool is exhausted. - /// Allocator Overflow allocator, which is only used if bEnableOverflow == true. Defaults to the global heap. - /// - template - class fixed_node_allocator - { - public: - typedef typename type_select, fixed_pool>::type pool_type; - typedef fixed_node_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the compiler sets sizeof(T) to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset - }; - - public: - pool_type mPool; - - public: - //fixed_node_allocator(const char* pName) - //{ - // mPool.set_name(pName); - //} - - - fixed_node_allocator(void* pNodeBuffer) - : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset) - { - } - - - /// fixed_node_allocator - /// - /// Note that we are copying x.mpHead to our own fixed_pool. This at first may seem - /// broken, as fixed pools cannot take over ownership of other fixed pools' memory. - /// However, we declare that this copy ctor can only ever be safely called when - /// the user has intentionally pre-seeded the source with the destination pointer. - /// This is somewhat playing with fire, but it allows us to get around chicken-and-egg - /// problems with containers being their own allocators, without incurring any memory - /// costs or extra code costs. There's another reason for this: we very strongly want - /// to avoid full copying of instances of fixed_pool around, especially via the stack. - /// Larger pools won't even be able to fit on many machine's stacks. So this solution - /// is also a mechanism to prevent that situation from existing and being used. - /// Perhaps some day we'll find a more elegant yet costless way around this. - /// - fixed_node_allocator(const this_type& x) - : mPool(x.mPool.mpNext, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset) - { - // Problem: how do we copy mPool.mOverflowAllocator if mPool is fixed_pool_with_overflow? - // Probably we should use mPool = x.mPool, though it seems a little odd to do so after - // doing the copying above. - mPool = x.mPool; - } - - - this_type& operator=(const this_type& x) - { - mPool = x.mPool; - return *this; - } - - - void* allocate(size_t n, int /*flags*/ = 0) - { - (void)n; - EASTL_ASSERT(n == kNodeSize); - return mPool.allocate(); - } - - - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int /*flags*/ = 0) - { - (void)n; - EASTL_ASSERT(n == kNodeSize); - return mPool.allocate(); - } - - - void deallocate(void* p, size_t) - { - mPool.deallocate(p); - } - - - /// can_allocate - /// - /// Returns true if there are any free links. - /// - bool can_allocate() const - { - return mPool.can_allocate(); - } - - - /// reset - /// - /// This function unilaterally resets the fixed pool back to a newly initialized - /// state. This is useful for using in tandem with container reset functionality. - /// - void reset(void* pNodeBuffer) - { - mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset); - } - - - const char* get_name() const - { - return mPool.get_name(); - } - - - void set_name(const char* pName) - { - mPool.set_name(pName); - } - - - overflow_allocator_type& get_overflow_allocator() - { - return mPool.mOverflowAllocator; - } - - - void set_overflow_allocator(const overflow_allocator_type& allocator) - { - mPool.mOverflowAllocator = allocator; - } - - }; // fixed_node_allocator - - - // This is a near copy of the code above, with the only difference being - // the 'false' bEnableOverflow template parameter, the pool_type and this_type typedefs, - // and the get_overflow_allocator / set_overflow_allocator functions. - template - class fixed_node_allocator - { - public: - typedef fixed_pool pool_type; - typedef fixed_node_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the compiler sets - //sizeof(T) to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset - }; - - public: - pool_type mPool; - - public: - fixed_node_allocator(void* pNodeBuffer) - : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset) - { - } - - - fixed_node_allocator(const this_type& x) - : mPool(x.mPool.mpNext, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset) - { - } - - - this_type& operator=(const this_type& x) - { - mPool = x.mPool; - return *this; - } - - - void* allocate(size_t n, int /*flags*/ = 0) - { - (void)n; - EASTL_ASSERT(n == kNodeSize); - return mPool.allocate(); - } - - - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int /*flags*/ = 0) - { - (void)n; - EASTL_ASSERT(n == kNodeSize); - return mPool.allocate(); - } - - - void deallocate(void* p, size_t) - { - mPool.deallocate(p); - } - - - bool can_allocate() const - { - return mPool.can_allocate(); - } - - - void reset(void* pNodeBuffer) - { - mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset); - } - - - const char* get_name() const - { - return mPool.get_name(); - } - - - void set_name(const char* pName) - { - mPool.set_name(pName); - } - - - overflow_allocator_type& get_overflow_allocator() - { - EASTL_ASSERT(false); - return *(overflow_allocator_type*)NULL; // This is not pretty. - } - - - void set_overflow_allocator(const overflow_allocator_type& /*allocator*/) - { - // We don't have an overflow allocator. - EASTL_ASSERT(false); - } - - }; // fixed_node_allocator - - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const fixed_node_allocator& a, - const fixed_node_allocator& b) - { - return (&a == &b); // They are only equal if they are the same object. - } - - - template - inline bool operator!=(const fixed_node_allocator& a, - const fixed_node_allocator& b) - { - return (&a != &b); // They are only equal if they are the same object. - } - - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_hashtable_allocator - /////////////////////////////////////////////////////////////////////////// - - /// fixed_hashtable_allocator - /// - /// Provides a base class for fixed hashtable allocations. - /// To consider: Have this inherit from fixed_node_allocator. - /// - /// Template parameters: - /// bucketCount The fixed number of hashtable buckets to provide. - /// nodeCount The number of objects the pool contains. - /// nodeAlignment The alignment of the objects to allocate. - /// nodeAlignmentOffset The alignment offset of the objects to allocate. - /// bEnableOverflow Whether or not we should use the overflow heap if our object pool is exhausted. - /// Allocator Overflow allocator, which is only used if bEnableOverflow == true. Defaults to the global heap. - /// - template - class fixed_hashtable_allocator - { - public: - typedef typename type_select, fixed_pool>::type pool_type; - typedef fixed_hashtable_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kBucketCount = bucketCount + 1, // '+1' because the hash table needs a null terminating bucket. - kBucketsSize = bucketCount * sizeof(void*), - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the - //compiler sets sizeof(T) to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, - // Don't need to include kBucketsSize in this calculation, as fixed_hash_xxx containers have a separate buffer for buckets. - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset, - kAllocFlagBuckets = 0x00400000 // Flag to allocator which indicates that we are allocating buckets and not nodes. - }; - - protected: - pool_type mPool; - void* mpBucketBuffer; - - public: - //fixed_hashtable_allocator(const char* pName) - //{ - // mPool.set_name(pName); - //} - - fixed_hashtable_allocator(void* pNodeBuffer) - : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(NULL) - { - // EASTL_ASSERT(false); // As it stands now, this is not supposed to be called. - } - - - fixed_hashtable_allocator(void* pNodeBuffer, void* pBucketBuffer) - : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(pBucketBuffer) - { - } - - - /// fixed_hashtable_allocator - /// - /// Note that we are copying x.mpHead and mpBucketBuffer to our own fixed_pool. - /// See the discussion above in fixed_node_allocator for important information about this. - /// - fixed_hashtable_allocator(const this_type& x) - : mPool(x.mPool.mpHead, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(x.mpBucketBuffer) - { - // Problem: how do we copy mPool.mOverflowAllocator if mPool is fixed_pool_with_overflow? - // Probably we should use mPool = x.mPool, though it seems a little odd to do so after - // doing the copying above. - mPool = x.mPool; - } - - - fixed_hashtable_allocator& operator=(const fixed_hashtable_allocator& x) - { - mPool = x.mPool; - return *this; // Do nothing. Ignore the source type. - } - - - void* allocate(size_t n, int flags = 0) - { - // We expect that the caller uses kAllocFlagBuckets when it wants us to allocate buckets instead of nodes. - EASTL_CT_ASSERT(kAllocFlagBuckets == 0x00400000); // Currently we expect this to be so, because the hashtable has a copy of this enum. - if((flags & kAllocFlagBuckets) == 0) // If we are allocating nodes and (probably) not buckets... - { - EASTL_ASSERT(n == kNodeSize); (void)n; // Make unused var warning go away. - return mPool.allocate(); - } - - EASTL_ASSERT(n <= kBucketsSize); - return mpBucketBuffer; - } - - - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int flags = 0) - { - // We expect that the caller uses kAllocFlagBuckets when it wants us to allocate buckets instead of nodes. - if((flags & kAllocFlagBuckets) == 0) // If we are allocating nodes and (probably) not buckets... - { - EASTL_ASSERT(n == kNodeSize); (void)n; // Make unused var warning go away. - return mPool.allocate(); - } - - // To consider: allow for bucket allocations to overflow. - EASTL_ASSERT(n <= kBucketsSize); - return mpBucketBuffer; - } - - - void deallocate(void* p, size_t) - { - if(p != mpBucketBuffer) // If we are freeing a node and not buckets... - mPool.deallocate(p); - } - - - bool can_allocate() const - { - return mPool.can_allocate(); - } - - - void reset(void* pNodeBuffer) - { - // No need to modify mpBucketBuffer, as that is constant. - mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset); - } - - - const char* get_name() const - { - return mPool.get_name(); - } - - - void set_name(const char* pName) - { - mPool.set_name(pName); - } - - - overflow_allocator_type& get_overflow_allocator() - { - return mPool.mOverflowAllocator; - } - - - void set_overflow_allocator(const overflow_allocator_type& allocator) - { - mPool.mOverflowAllocator = allocator; - } - - }; // fixed_hashtable_allocator - - - // This is a near copy of the code above, with the only difference being - // the 'false' bEnableOverflow template parameter, the pool_type and this_type typedefs, - // and the get_overflow_allocator / set_overflow_allocator functions. - template - class fixed_hashtable_allocator - { - public: - typedef fixed_pool pool_type; - typedef fixed_hashtable_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kBucketCount = bucketCount + 1, // '+1' because the hash table needs a null terminating bucket. - kBucketsSize = bucketCount * sizeof(void*), - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the compiler - //sets sizeof(T) to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, // Don't need to include kBucketsSize - //in this calculation, as fixed_hash_xxx containers have a separate buffer for buckets. - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset, - kAllocFlagBuckets = 0x00400000 // Flag to allocator which indicates that we are allocating buckets and not nodes. - }; - - protected: - pool_type mPool; - void* mpBucketBuffer; - - public: - //fixed_hashtable_allocator(const char* pName) - //{ - // mPool.set_name(pName); - //} - - fixed_hashtable_allocator(void* pNodeBuffer) - : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(NULL) - { - // EASTL_ASSERT(false); // As it stands now, this is not supposed to be called. - } - - - fixed_hashtable_allocator(void* pNodeBuffer, void* pBucketBuffer) - : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(pBucketBuffer) - { - } - - - /// fixed_hashtable_allocator - /// - /// Note that we are copying x.mpHead and mpBucketBuffer to our own fixed_pool. - /// See the discussion above in fixed_node_allocator for important information about this. - /// - fixed_hashtable_allocator(const this_type& x) - : mPool(x.mPool.mpHead, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset), - mpBucketBuffer(x.mpBucketBuffer) - { - } - - - fixed_hashtable_allocator& operator=(const fixed_hashtable_allocator& x) - { - mPool = x.mPool; - return *this; // Do nothing. Ignore the source type. - } - - - void* allocate(size_t n, int flags = 0) - { - // We expect that the caller uses kAllocFlagBuckets when it wants us to allocate buckets instead of nodes. - EASTL_CT_ASSERT(kAllocFlagBuckets == 0x00400000); // Currently we expect this to be so, because the hashtable has a copy of this enum. - if((flags & kAllocFlagBuckets) == 0) // If we are allocating nodes and (probably) not buckets... - { - EASTL_ASSERT(n == kNodeSize); (void)n; // Make unused var warning go away. - return mPool.allocate(); - } - - EASTL_ASSERT(n <= kBucketsSize); - return mpBucketBuffer; - } - - - void* allocate(size_t n, size_t /*alignment*/, size_t /*offset*/, int flags = 0) - { - // We expect that the caller uses kAllocFlagBuckets when it wants us to allocate buckets instead of nodes. - if((flags & kAllocFlagBuckets) == 0) // If we are allocating nodes and (probably) not buckets... - { - EASTL_ASSERT(n == kNodeSize); (void)n; // Make unused var warning go away. - return mPool.allocate(); - } - - // To consider: allow for bucket allocations to overflow. - EASTL_ASSERT(n <= kBucketsSize); - return mpBucketBuffer; - } - - - void deallocate(void* p, size_t) - { - if(p != mpBucketBuffer) // If we are freeing a node and not buckets... - mPool.deallocate(p); - } - - - bool can_allocate() const - { - return mPool.can_allocate(); - } - - - void reset(void* pNodeBuffer) - { - // No need to modify mpBucketBuffer, as that is constant. - mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset); - } - - - const char* get_name() const - { - return mPool.get_name(); - } - - - void set_name(const char* pName) - { - mPool.set_name(pName); - } - - - overflow_allocator_type& get_overflow_allocator() - { - EASTL_ASSERT(false); - return *(overflow_allocator_type*)NULL; // This is not pretty. - } - - void set_overflow_allocator(const overflow_allocator_type& /*allocator*/) - { - // We don't have an overflow allocator. - EASTL_ASSERT(false); - } - - }; // fixed_hashtable_allocator - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const fixed_hashtable_allocator& a, - const fixed_hashtable_allocator& b) - { - return (&a == &b); // They are only equal if they are the same object. - } - - - template - inline bool operator!=(const fixed_hashtable_allocator& a, - const fixed_hashtable_allocator& b) - { - return (&a != &b); // They are only equal if they are the same object. - } - - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_vector_allocator - /////////////////////////////////////////////////////////////////////////// - - /// fixed_vector_allocator - /// - /// Template parameters: - /// nodeSize The size of individual objects. - /// nodeCount The number of objects the pool contains. - /// nodeAlignment The alignment of the objects to allocate. - /// nodeAlignmentOffset The alignment offset of the objects to allocate. - /// bEnableOverflow Whether or not we should use the overflow heap if our object pool is exhausted. - /// Allocator Overflow allocator, which is only used if bEnableOverflow == true. Defaults to the global heap. - /// - template - class fixed_vector_allocator - { - public: - typedef fixed_vector_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the compiler sets sizeof(T) - //to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset - }; - - public: - overflow_allocator_type mOverflowAllocator; - void* mpPoolBegin; // To consider: Find some way to make this data unnecessary, without increasing template proliferation. - - public: - //fixed_vector_allocator(const char* pName = NULL) - //{ - // mOverflowAllocator.set_name(pName); - //} - - fixed_vector_allocator(void* pNodeBuffer) - : mpPoolBegin(pNodeBuffer) - { - } - - fixed_vector_allocator& operator=(const fixed_vector_allocator& x) - { - #if EASTL_ALLOCATOR_COPY_ENABLED - mOverflowAllocator = x.mOverflowAllocator; - #else - (void)x; - #endif - - return *this; // Do nothing. Ignore the source type. - } - - void* allocate(size_t n, int flags = 0) - { - return mOverflowAllocator.allocate(n, flags); - } - - void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0) - { - return mOverflowAllocator.allocate(n, alignment, offset, flags); - } - - void deallocate(void* p, size_t n) - { - if(p != mpPoolBegin) - mOverflowAllocator.deallocate(p, n); // Can't do this to our own allocation. - } - - const char* get_name() const - { - return mOverflowAllocator.get_name(); - } - - void set_name(const char* pName) - { - mOverflowAllocator.set_name(pName); - } - - overflow_allocator_type& get_overflow_allocator() - { - return mOverflowAllocator; - } - - void set_overflow_allocator(const overflow_allocator_type& allocator) - { - mOverflowAllocator = allocator; - } - - }; // fixed_vector_allocator - - - template - class fixed_vector_allocator - { - public: - typedef fixed_vector_allocator this_type; - typedef Allocator overflow_allocator_type; - - enum - { - kNodeSize = nodeSize, - kNodeCount = nodeCount, - kNodesSize = nodeCount * nodeSize, // Note that the kBufferSize calculation assumes that the compiler sets - //sizeof(T) to be a multiple alignof(T), and so sizeof(T) is always >= alignof(T). - kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset, - kNodeAlignment = nodeAlignment, - kNodeAlignmentOffset = nodeAlignmentOffset - }; - - //fixed_vector_allocator(const char* = NULL) // This char* parameter is present so that this class can be like the other version. - //{ - //} - - fixed_vector_allocator(void* /*pNodeBuffer*/) - { - } - - void* allocate(size_t /*n*/, int /*flags*/ = 0) - { - EASTL_ASSERT(false); // A fixed_vector should not reallocate, else the user has exhausted its space. - return NULL; - } - - void* allocate(size_t /*n*/, size_t /*alignment*/, size_t /*offset*/, int /*flags*/ = 0) - { - EASTL_ASSERT(false); - return NULL; - } - - void deallocate(void* /*p*/, size_t /*n*/) - { - } - - const char* get_name() const - { - return EASTL_FIXED_POOL_DEFAULT_NAME; - } - - void set_name(const char* /*pName*/) - { - } - - overflow_allocator_type& get_overflow_allocator() - { - EASTL_ASSERT(false); - overflow_allocator_type* pNULL = NULL; - return *pNULL; // This is not pretty, but it should never execute. - } - - void set_overflow_allocator(const overflow_allocator_type& /*allocator*/) - { - // We don't have an overflow allocator. - EASTL_ASSERT(false); - } - - }; // fixed_vector_allocator - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const fixed_vector_allocator& a, - const fixed_vector_allocator& b) - { - return (&a == &b); // They are only equal if they are the same object. - } - - - template - inline bool operator!=(const fixed_vector_allocator& a, - const fixed_vector_allocator& b) - { - return (&a != &b); // They are only equal if they are the same object. - } - - - - - - /////////////////////////////////////////////////////////////////////////// - // fixed_swap - /////////////////////////////////////////////////////////////////////////// - - /// fixed_swap - /// - /// This function implements a swap suitable for fixed containers. - /// This is an issue because the size of fixed containers can be very - /// large, due to their having the container buffer within themselves. - /// Note that we are referring to sizeof(container) and not the total - /// sum of memory allocated by the container from the heap. - /// - template - void fixed_swap(Container& a, Container& b) - { - // We must do a brute-force swap, because fixed containers cannot share memory allocations. - eastl::less compare; - - if(compare(sizeof(a), EASTL_MAX_STACK_USAGE)) // Using compare instead of just '<' avoids a stubborn compiler warning. - { - // Note: The C++ language does not define what happens when you declare - // an object in too small of stack space but the object is never created. - // This may result in a stack overflow exception on some systems, depending - // on how they work and possibly depending on enabled debug functionality. - - const Container temp(a); // Can't use global swap because that could - a = b; // itself call this swap function in return. - b = temp; - } - else - { - EASTLAllocatorType allocator(*EASTLAllocatorDefault(), EASTL_TEMP_DEFAULT_NAME); - void* const pMemory = allocator.allocate(sizeof(a)); - - if(pMemory) - { - Container* const pTemp = ::new(pMemory) Container(a); - a = b; - b = *pTemp; - - pTemp->~Container(); - allocator.deallocate(pMemory, sizeof(a)); - } - } - } - - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_eastl.h deleted file mode 100644 index 3abe3eb26611..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_eastl.h +++ /dev/null @@ -1,929 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/functional.h -// Written and maintained by Paul Pedriana - 2005 -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_FUNCTIONAL_H -#define EASTL_FUNCTIONAL_H - - -#include -#include - - -namespace eastl -{ - - /////////////////////////////////////////////////////////////////////// - // Primary C++ functions - /////////////////////////////////////////////////////////////////////// - - template - struct unary_function - { - typedef Argument argument_type; - typedef Result result_type; - }; - - - template - struct binary_function - { - typedef Argument1 first_argument_type; - typedef Argument2 second_argument_type; - typedef Result result_type; - }; - - - template - struct plus : public binary_function - { - T operator()(const T& a, const T& b) const - { return a + b; } - }; - - template - struct minus : public binary_function - { - T operator()(const T& a, const T& b) const - { return a - b; } - }; - - template - struct multiplies : public binary_function - { - T operator()(const T& a, const T& b) const - { return a * b; } - }; - - template - struct divides : public binary_function - { - T operator()(const T& a, const T& b) const - { return a / b; } - }; - - template - struct modulus : public binary_function - { - T operator()(const T& a, const T& b) const - { return a % b; } - }; - - template - struct negate : public unary_function - { - T operator()(const T& a) const - { return -a; } - }; - - template - struct equal_to : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a == b; } - }; - - template - bool validate_equal_to(const T& a, const T& b, Compare compare) - { - return compare(a, b) == compare(b, a); - } - - template - struct not_equal_to : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a != b; } - }; - - template - bool validate_not_equal_to(const T& a, const T& b, Compare compare) - { - return compare(a, b) == compare(b, a); // We want the not equal comparison results to be equal. - } - - /// str_equal_to - /// - /// Compares two 0-terminated string types. - /// The T types are expected to be iterators or act like iterators. - /// - /// Example usage: - /// hash_set, str_equal_to > stringHashSet; - /// - /// Note: - /// You couldn't use str_equal_to like this: - /// bool result = equal("hi", "hi" + 2, "ho", str_equal_to()); - /// This is because equal tests an array of something, with each element by - /// the comparison function. But str_equal_to tests an array of something itself. - /// - template - struct str_equal_to : public binary_function - { - bool operator()(T a, T b) const - { - while(*a && (*a == *b)) - { - ++a; - ++b; - } - return (*a == *b); - } - }; - - template - struct greater : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a > b; } - }; - - template - bool validate_greater(const T& a, const T& b, Compare compare) - { - return !compare(a, b) || !compare(b, a); // If (a > b), then !(b > a) - } - - template - struct less : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a < b; } - }; - - template - bool validate_less(const T& a, const T& b, Compare compare) - { - return !compare(a, b) || !compare(b, a); // If (a < b), then !(b < a) - } - - template - struct greater_equal : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a >= b; } - }; - - template - bool validate_greater_equal(const T& a, const T& b, Compare compare) - { - return !compare(a, b) || !compare(b, a); // If (a >= b), then !(b >= a) - } - - template - struct less_equal : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a <= b; } - }; - - template - bool validate_less_equal(const T& a, const T& b, Compare compare) - { - return !compare(a, b) || !compare(b, a); // If (a <= b), then !(b <= a) - } - - template - struct logical_and : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a && b; } - }; - - template - struct logical_or : public binary_function - { - bool operator()(const T& a, const T& b) const - { return a || b; } - }; - - template - struct logical_not : public unary_function - { - bool operator()(const T& a) const - { return !a; } - }; - - - - /////////////////////////////////////////////////////////////////////// - // Dual type functions - /////////////////////////////////////////////////////////////////////// - - template - struct equal_to_2 : public binary_function - { - bool operator()(const T& a, const U& b) const - { return a == b; } - }; - - template - struct not_equal_to_2 : public binary_function - { - bool operator()(const T& a, const U& b) const - { return a != b; } - }; - - template - struct less_2 : public binary_function - { - bool operator()(const T& a, const U& b) const - { return a < b; } - }; - - - - - /// unary_negate - /// - template - class unary_negate : public unary_function - { - protected: - Predicate mPredicate; - public: - explicit unary_negate(const Predicate& a) - : mPredicate(a) {} - bool operator()(const typename Predicate::argument_type& a) const - { return !mPredicate(a); } - }; - - template - inline unary_negate not1(const Predicate& predicate) - { return unary_negate(predicate); } - - - - /// binary_negate - /// - template - class binary_negate : public binary_function - { - protected: - Predicate mPredicate; - public: - explicit binary_negate(const Predicate& a) - : mPredicate(a) { } - bool operator()(const typename Predicate::first_argument_type& a, const typename Predicate::second_argument_type& b) const - { return !mPredicate(a, b); } - }; - - template - inline binary_negate not2(const Predicate& predicate) - { return binary_negate(predicate); } - - - - - /////////////////////////////////////////////////////////////////////// - // bind - /////////////////////////////////////////////////////////////////////// - - /// bind1st - /// - template - class binder1st : public unary_function - { - protected: - typename Operation::first_argument_type value; - Operation op; - - public: - binder1st(const Operation& x, const typename Operation::first_argument_type& y) - : value(y), op(x) { } - - typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const - { return op(value, x); } - - typename Operation::result_type operator()(typename Operation::second_argument_type& x) const - { return op(value, x); } - }; - - - template - inline binder1st bind1st(const Operation& op, const T& x) - { - typedef typename Operation::first_argument_type value; - return binder1st(op, value(x)); - } - - - /// bind2nd - /// - template - class binder2nd : public unary_function - { - protected: - Operation op; - typename Operation::second_argument_type value; - - public: - binder2nd(const Operation& x, const typename Operation::second_argument_type& y) - : op(x), value(y) { } - - typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const - { return op(x, value); } - - typename Operation::result_type operator()(typename Operation::first_argument_type& x) const - { return op(x, value); } - }; - - - template - inline binder2nd bind2nd(const Operation& op, const T& x) - { - typedef typename Operation::second_argument_type value; - return binder2nd(op, value(x)); - } - - - - - /////////////////////////////////////////////////////////////////////// - // pointer_to_unary_function - /////////////////////////////////////////////////////////////////////// - - /// pointer_to_unary_function - /// - /// This is an adapter template which converts a pointer to a standalone - /// function to a function object. This allows standalone functions to - /// work in many cases where the system requires a function object. - /// - /// Example usage: - /// ptrdiff_t Rand(ptrdiff_t n) { return rand() % n; } // Note: The C rand function is poor and slow. - /// pointer_to_unary_function randInstance(Rand); - /// random_shuffle(pArrayBegin, pArrayEnd, randInstance); - /// - template - class pointer_to_unary_function : public unary_function - { - protected: - Result (*mpFunction)(Arg); - - public: - pointer_to_unary_function() - { } - - explicit pointer_to_unary_function(Result (*pFunction)(Arg)) - : mpFunction(pFunction) { } - - Result operator()(Arg x) const - { return mpFunction(x); } - }; - - - /// ptr_fun - /// - /// This ptr_fun is simply shorthand for usage of pointer_to_unary_function. - /// - /// Example usage (actually, you don't need to use ptr_fun here, but it works anyway): - /// int factorial(int x) { return (x > 1) ? (x * factorial(x - 1)) : x; } - /// transform(pIntArrayBegin, pIntArrayEnd, pIntArrayBegin, ptr_fun(factorial)); - /// - template - inline pointer_to_unary_function ptr_fun(Result (*pFunction)(Arg)) - { return pointer_to_unary_function(pFunction); } - - - - - - /////////////////////////////////////////////////////////////////////// - // pointer_to_binary_function - /////////////////////////////////////////////////////////////////////// - - /// pointer_to_binary_function - /// - /// This is an adapter template which converts a pointer to a standalone - /// function to a function object. This allows standalone functions to - /// work in many cases where the system requires a function object. - /// - template - class pointer_to_binary_function : public binary_function - { - protected: - Result (*mpFunction)(Arg1, Arg2); - - public: - pointer_to_binary_function() - { } - - explicit pointer_to_binary_function(Result (*pFunction)(Arg1, Arg2)) - : mpFunction(pFunction) {} - - Result operator()(Arg1 x, Arg2 y) const - { return mpFunction(x, y); } - }; - - - /// This ptr_fun is simply shorthand for usage of pointer_to_binary_function. - /// - /// Example usage (actually, you don't need to use ptr_fun here, but it works anyway): - /// int multiply(int x, int y) { return x * y; } - /// transform(pIntArray1Begin, pIntArray1End, pIntArray2Begin, pIntArray1Begin, ptr_fun(multiply)); - /// - template - inline pointer_to_binary_function ptr_fun(Result (*pFunction)(Arg1, Arg2)) - { return pointer_to_binary_function(pFunction); } - - - - - - - /////////////////////////////////////////////////////////////////////// - // mem_fun - // mem_fun1 - // - // Note that mem_fun calls member functions via *pointers* to classes - // and not instances of classes. mem_fun_ref is for calling functions - // via instances of classes or references to classes. - // - /////////////////////////////////////////////////////////////////////// - - /// mem_fun_t - /// - /// Member function with no arguments. - /// - template - class mem_fun_t : public unary_function - { - public: - typedef Result (T::*MemberFunction)(); - - EA_FORCE_INLINE explicit mem_fun_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(T* pT) const - { - return (pT->*mpMemberFunction)(); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// mem_fun1_t - /// - /// Member function with one argument. - /// - template - class mem_fun1_t : public binary_function - { - public: - typedef Result (T::*MemberFunction)(Argument); - - EA_FORCE_INLINE explicit mem_fun1_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(T* pT, Argument arg) const - { - return (pT->*mpMemberFunction)(arg); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// const_mem_fun_t - /// - /// Const member function with no arguments. - /// Note that we inherit from unary_function - /// instead of what the C++ standard specifies: unary_function. - /// The C++ standard is in error and this has been recognized by the defect group. - /// - template - class const_mem_fun_t : public unary_function - { - public: - typedef Result (T::*MemberFunction)() const; - - EA_FORCE_INLINE explicit const_mem_fun_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(const T* pT) const - { - return (pT->*mpMemberFunction)(); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// const_mem_fun1_t - /// - /// Const member function with one argument. - /// Note that we inherit from unary_function - /// instead of what the C++ standard specifies: unary_function. - /// The C++ standard is in error and this has been recognized by the defect group. - /// - template - class const_mem_fun1_t : public binary_function - { - public: - typedef Result (T::*MemberFunction)(Argument) const; - - EA_FORCE_INLINE explicit const_mem_fun1_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(const T* pT, Argument arg) const - { - return (pT->*mpMemberFunction)(arg); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// mem_fun - /// - /// This is the high level interface to the mem_fun_t family. - /// - /// Example usage: - /// struct TestClass { void print() { puts("hello"); } } - /// TestClass* pTestClassArray[3] = { ... }; - /// for_each(pTestClassArray, pTestClassArray + 3, &TestClass::print); - /// - template - EA_FORCE_INLINE mem_fun_t - mem_fun(Result (T::*MemberFunction)()) - { - return eastl::mem_fun_t(MemberFunction); - } - - template - EA_FORCE_INLINE mem_fun1_t - mem_fun(Result (T::*MemberFunction)(Argument)) - { - return eastl::mem_fun1_t(MemberFunction); - } - - template - EA_FORCE_INLINE const_mem_fun_t - mem_fun(Result (T::*MemberFunction)() const) - { - return eastl::const_mem_fun_t(MemberFunction); - } - - template - EA_FORCE_INLINE const_mem_fun1_t - mem_fun(Result (T::*MemberFunction)(Argument) const) - { - return eastl::const_mem_fun1_t(MemberFunction); - } - - - - - - /////////////////////////////////////////////////////////////////////// - // mem_fun_ref - // mem_fun1_ref - // - /////////////////////////////////////////////////////////////////////// - - /// mem_fun_ref_t - /// - template - class mem_fun_ref_t : public unary_function - { - public: - typedef Result (T::*MemberFunction)(); - - EA_FORCE_INLINE explicit mem_fun_ref_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(T& t) const - { - return (t.*mpMemberFunction)(); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// mem_fun1_ref_t - /// - template - class mem_fun1_ref_t : public binary_function - { - public: - typedef Result (T::*MemberFunction)(Argument); - - EA_FORCE_INLINE explicit mem_fun1_ref_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(T& t, Argument arg) const - { - return (t.*mpMemberFunction)(arg); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// const_mem_fun_ref_t - /// - template - class const_mem_fun_ref_t : public unary_function - { - public: - typedef Result (T::*MemberFunction)() const; - - EA_FORCE_INLINE explicit const_mem_fun_ref_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(const T& t) const - { - return (t.*mpMemberFunction)(); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// const_mem_fun1_ref_t - /// - template - class const_mem_fun1_ref_t : public binary_function - { - public: - typedef Result (T::*MemberFunction)(Argument) const; - - EA_FORCE_INLINE explicit const_mem_fun1_ref_t(MemberFunction pMemberFunction) - : mpMemberFunction(pMemberFunction) - { - // Empty - } - - EA_FORCE_INLINE Result operator()(const T& t, Argument arg) const - { - return (t.*mpMemberFunction)(arg); - } - - protected: - MemberFunction mpMemberFunction; - }; - - - /// mem_fun_ref - /// Example usage: - /// struct TestClass { void print() { puts("hello"); } } - /// TestClass testClassArray[3]; - /// for_each(testClassArray, testClassArray + 3, &TestClass::print); - /// - template - EA_FORCE_INLINE mem_fun_ref_t - mem_fun_ref(Result (T::*MemberFunction)()) - { - return eastl::mem_fun_ref_t(MemberFunction); - } - - template - EA_FORCE_INLINE mem_fun1_ref_t - mem_fun_ref(Result (T::*MemberFunction)(Argument)) - { - return eastl::mem_fun1_ref_t(MemberFunction); - } - - template - EA_FORCE_INLINE const_mem_fun_ref_t - mem_fun_ref(Result (T::*MemberFunction)() const) - { - return eastl::const_mem_fun_ref_t(MemberFunction); - } - - template - EA_FORCE_INLINE const_mem_fun1_ref_t - mem_fun_ref(Result (T::*MemberFunction)(Argument) const) - { - return eastl::const_mem_fun1_ref_t(MemberFunction); - } - - - - - /////////////////////////////////////////////////////////////////////// - // hash - /////////////////////////////////////////////////////////////////////// - - template struct hash; - - template struct hash // Note that we use the pointer as-is and don't divide by sizeof(T*). This is because the table is of a prime size and this division doesn't benefit distribution. - { size_t operator()(T* p) const { return size_t(uintptr_t(p)); } }; - - template <> struct hash - { size_t operator()(bool val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(char val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(signed char val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(unsigned char val) const { return static_cast(val); } }; - - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - template <> struct hash - { size_t operator()(wchar_t val) const { return static_cast(val); } }; - #endif - - template <> struct hash - { size_t operator()(short val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(unsigned short val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(signed int val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(unsigned int val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(signed long val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(unsigned long val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(signed long long val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(unsigned long long val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(float val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(double val) const { return static_cast(val); } }; - - template <> struct hash - { size_t operator()(long double val) const { return static_cast(val); } }; - - - /////////////////////////////////////////////////////////////////////////// - // string hashes - // - // Note that our string hashes here intentionally are slow for long strings. - // The reasoning for this is so: - // - The large majority of hashed strings are only a few bytes long. - // - The hash function is significantly more efficient if it can make this assumption. - // - The user is welcome to make a custom hash for those uncommon cases where - // long strings need to be hashed. Indeed, the user can probably make a - // special hash customized for such strings that's better than what we provide. - /////////////////////////////////////////////////////////////////////////// - - template <> struct hash - { - size_t operator()(const char8_t* p) const - { - size_t c, result = 2166136261U; // FNV1 hash. Perhaps the best string hash. - while((c = (uint8_t)*p++) != 0) // Using '!=' disables compiler warnings. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - template <> struct hash - { - size_t operator()(const char8_t* p) const - { - size_t c, result = 2166136261U; - while((c = (uint8_t)*p++) != 0) // cast to unsigned 8 bit. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - template <> struct hash - { - size_t operator()(const char16_t* p) const - { - size_t c, result = 2166136261U; - while((c = (uint16_t)*p++) != 0) // cast to unsigned 16 bit. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - template <> struct hash - { - size_t operator()(const char16_t* p) const - { - size_t c, result = 2166136261U; - while((c = (uint16_t)*p++) != 0) // cast to unsigned 16 bit. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - template <> struct hash - { - size_t operator()(const char32_t* p) const - { - size_t c, result = 2166136261U; - while((c = (uint32_t)*p++) != 0) // cast to unsigned 32 bit. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - template <> struct hash - { - size_t operator()(const char32_t* p) const - { - size_t c, result = 2166136261U; - while((c = (uint32_t)*p++) != 0) // cast to unsigned 32 bit. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - /// string_hash - /// - /// Defines a generic string hash for an arbitrary EASTL basic_string container. - /// - /// Example usage: - /// eastl::hash_set > hashSet; - /// - template - struct string_hash - { - typedef String string_type; - typedef typename String::value_type value_type; - typedef typename eastl::add_unsigned::type unsigned_value_type; - - size_t operator()(const string_type& s) const - { - const unsigned_value_type* p = (const unsigned_value_type*)s.c_str(); - size_t c, result = 2166136261U; - while((c = *p++) != 0) - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_rdestl.h deleted file mode 100644 index 8f613def074a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/functional_rdestl.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef RDESTL_FUNCTIONAL_H -#define RDESTL_FUNCTIONAL_H - -namespace rde -{ -//============================================================================= -template -struct less -{ - bool operator()(const T& lhs, const T& rhs) const - { - return lhs < rhs; - } -}; - -//============================================================================= -template -struct greater -{ - bool operator()(const T& lhs, const T& rhs) const - { - return lhs > rhs; - } -}; - -//============================================================================= -template -struct equal_to -{ - bool operator()(const T& lhs, const T& rhs) const - { - return lhs == rhs; - } -}; - -} - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_FUNCTIONAL_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/generic_iterator_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/generic_iterator_eastl.h deleted file mode 100644 index 55a8dd5a59a0..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/generic_iterator_eastl.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/generic_iterator.h -// -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Implements a generic iterator from a given iteratable type, such as a pointer. -// We cannot put this file into our own iterator.h file because we need to -// still be able to use this file when we have our iterator.h disabled. -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_GENERIC_ITERATOR_H -#define EASTL_INTERNAL_GENERIC_ITERATOR_H - - -#include -#include -#include - - -#ifdef _MSC_VER - #pragma warning(push) // VC++ generates a bogus warning that you cannot code away. - #pragma warning(disable: 4619) // There is no warning number 'number'. - #pragma warning(disable: 4217) // Member template functions cannot be used for copy-assignment or copy-construction. -#endif - - -namespace eastl -{ - - /// generic_iterator - /// - /// Converts something which can be iterated into a formal iterator. - /// While this class' primary purpose is to allow the conversion of - /// a pointer to an iterator, you can convert anything else to an - /// iterator by defining an iterator_traits<> specialization for that - /// object type. See EASTL iterator.h for this. - /// - /// Example usage: - /// typedef generic_iterator IntArrayIterator; - /// typedef generic_iterator IntArrayIteratorOther; - /// - template - class generic_iterator - { - protected: - Iterator mIterator; - - public: - typedef typename eastl::iterator_traits::iterator_category iterator_category; - typedef typename eastl::iterator_traits::value_type value_type; - typedef typename eastl::iterator_traits::difference_type difference_type; - typedef typename eastl::iterator_traits::reference reference; - typedef typename eastl::iterator_traits::pointer pointer; - typedef Iterator iterator_type; - typedef Container container_type; - typedef generic_iterator this_type; - - generic_iterator() - : mIterator(iterator_type()) { } - - explicit generic_iterator(const iterator_type& x) - : mIterator(x) { } - - this_type& operator=(const iterator_type& x) - { mIterator = x; return *this; } - - template - generic_iterator(const generic_iterator& x) - : mIterator(x.base()) { } - - reference operator*() const - { return *mIterator; } - - pointer operator->() const - { return mIterator; } - - this_type& operator++() - { ++mIterator; return *this; } - - this_type operator++(int) - { return this_type(mIterator++); } - - this_type& operator--() - { --mIterator; return *this; } - - this_type operator--(int) - { return this_type(mIterator--); } - - reference operator[](const difference_type& n) const - { return mIterator[n]; } - - this_type& operator+=(const difference_type& n) - { mIterator += n; return *this; } - - this_type operator+(const difference_type& n) const - { return this_type(mIterator + n); } - - this_type& operator-=(const difference_type& n) - { mIterator -= n; return *this; } - - this_type operator-(const difference_type& n) const - { return this_type(mIterator - n); } - - const iterator_type& base() const - { return mIterator; } - - }; // class generic_iterator - - - - - - template - inline bool operator==(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() == rhs.base(); } - - template - inline bool operator==(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() == rhs.base(); } - - template - inline bool operator!=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() != rhs.base(); } - - template - inline bool operator!=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() != rhs.base(); } - - template - inline bool operator<(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() < rhs.base(); } - - template - inline bool operator<(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() < rhs.base(); } - - template - inline bool operator>(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() > rhs.base(); } - - template - inline bool operator>(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() > rhs.base(); } - - template - inline bool operator<=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() <= rhs.base(); } - - template - inline bool operator<=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() <= rhs.base(); } - - template - inline bool operator>=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() >= rhs.base(); } - - template - inline bool operator>=(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() >= rhs.base(); } - - template - inline typename generic_iterator::difference_type - operator-(const generic_iterator& lhs, const generic_iterator& rhs) - { return lhs.base() - rhs.base(); } - - template - inline generic_iterator - operator+(typename generic_iterator::difference_type n, const generic_iterator& x) - { return generic_iterator(x.base() + n); } - - - - /// is_generic_iterator - /// - /// Tells if an iterator is one of these generic_iterators. This is useful if you want to - /// write code that uses miscellaneous iterators but wants to tell if they are generic_iterators. - /// A primary reason to do so is that you can get at the pointer within the generic_iterator. - /// - template - struct is_generic_iterator : public false_type { }; - - template - struct is_generic_iterator > : public true_type { }; - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_eastl.h deleted file mode 100644 index 66729172d152..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_eastl.h +++ /dev/null @@ -1,329 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/hash_map.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file is based on the TR1 (technical report 1) reference implementation -// of the unordered_set/unordered_map C++ classes as of about 4/2005. Most likely -// many or all C++ library vendors' implementations of this classes will be -// based off of the reference version and so will look pretty similar to this -// file as well as other vendors' versions. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_HASH_MAP_H -#define EASTL_HASH_MAP_H - - -#include -#include -#include -#include - - - -namespace eastl -{ - - /// EASTL_HASH_MAP_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_HASH_MAP_DEFAULT_NAME - #define EASTL_HASH_MAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_map" // Unless the user overrides something, this is "EASTL hash_map". - #endif - - - /// EASTL_HASH_MULTIMAP_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_HASH_MULTIMAP_DEFAULT_NAME - #define EASTL_HASH_MULTIMAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_multimap" // Unless the user overrides something, this is "EASTL hash_multimap". - #endif - - - /// EASTL_HASH_MAP_DEFAULT_ALLOCATOR - /// - #ifndef EASTL_HASH_MAP_DEFAULT_ALLOCATOR - #define EASTL_HASH_MAP_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_MAP_DEFAULT_NAME) - #endif - - /// EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR - /// - #ifndef EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR - #define EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_MULTIMAP_DEFAULT_NAME) - #endif - - - - /// hash_map - /// - /// Implements a hash_map, which is a hashed associative container. - /// Lookups are O(1) (that is, they are fast) but the container is - /// not sorted. - /// - /// set_max_load_factor - /// If you want to make a hashtable never increase its bucket usage, - /// call set_max_load_factor with a very high value such as 100000.f. - /// - /// bCacheHashCode - /// We provide the boolean bCacheHashCode template parameter in order - /// to allow the storing of the hash code of the key within the map. - /// When this option is disabled, the rehashing of the table will - /// call the hash function on the key. Setting bCacheHashCode to true - /// is useful for cases whereby the calculation of the hash value for - /// a contained object is very expensive. - /// - /// find_as - /// In order to support the ability to have a hashtable of strings but - /// be able to do efficiently lookups via char pointers (i.e. so they - /// aren't converted to string objects), we provide the find_as - /// function. This function allows you to do a find with a key of a - /// type other than the hashtable key type. - /// - /// Example find_as usage: - /// hash_map hashMap; - /// i = hashMap.find_as("hello"); // Use default hash and compare. - /// - /// Example find_as usage (namespaces omitted for brevity): - /// hash_map hashMap; - /// i = hashMap.find_as("hello", hash(), equal_to_2()); - /// - template , typename Predicate = eastl::equal_to, - typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false> - class hash_map - : public hashtable, Allocator, eastl::use_first >, Predicate, - Hash, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, true, true> - { - public: - typedef hashtable, Allocator, - eastl::use_first >, - Predicate, Hash, mod_range_hashing, default_ranged_hash, - prime_rehash_policy, bCacheHashCode, true, true> base_type; - typedef hash_map this_type; - typedef typename base_type::size_type size_type; - typedef typename base_type::key_type key_type; - typedef T mapped_type; - typedef typename base_type::value_type value_type; // Note that this is pair. - typedef typename base_type::allocator_type allocator_type; - typedef typename base_type::node_type node_type; - typedef typename base_type::insert_return_type insert_return_type; - typedef typename base_type::iterator iterator; - - #if !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x has a bug which we work around. - using base_type::insert; - #endif - - public: - /// hash_map - /// - /// Default constructor. - /// - explicit hash_map(const allocator_type& allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR) - : base_type(0, Hash(), mod_range_hashing(), default_ranged_hash(), - Predicate(), eastl::use_first >(), allocator) - { - // Empty - } - - - /// hash_map - /// - /// Constructor which creates an empty container, but start with nBucketCount buckets. - /// We default to a small nBucketCount value, though the user really should manually - /// specify an appropriate value in order to prevent memory from being reallocated. - /// - explicit hash_map(size_type nBucketCount, const Hash& hashFunction = Hash(), - const Predicate& predicate = Predicate(), const allocator_type& allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR) - : base_type(nBucketCount, hashFunction, mod_range_hashing(), default_ranged_hash(), - predicate, eastl::use_first >(), allocator) - { - // Empty - } - - - /// hash_map - /// - /// An input bucket count of <= 1 causes the bucket count to be equal to the number of - /// elements in the input range. - /// - template - hash_map(ForwardIterator first, ForwardIterator last, size_type nBucketCount = 0, const Hash& hashFunction = Hash(), - const Predicate& predicate = Predicate(), const allocator_type& allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR) - : base_type(first, last, nBucketCount, hashFunction, mod_range_hashing(), default_ranged_hash(), - predicate, eastl::use_first >(), allocator) - { - // Empty - } - - - /// insert - /// - /// This is an extension to the C++ standard. We insert a default-constructed - /// element with the given key. The reason for this is that we can avoid the - /// potentially expensive operation of creating and/or copying a mapped_type - /// object on the stack. - insert_return_type insert(const key_type& key) - { - return base_type::DoInsertKey(key, true_type()); - } - - - #if defined(__GNUC__) && (__GNUC__ < 3) // If using old GCC (GCC 2.x has a bug which we work around) - template - void insert(InputIterator first, InputIterator last) { return base_type::insert(first, last); } - insert_return_type insert(const value_type& value) { return base_type::insert(value); } - iterator insert(const_iterator it, const value_type& value) { return base_type::insert(it, value); } - #endif - - - mapped_type& operator[](const key_type& key) - { - const typename base_type::iterator it = base_type::find(key); - if(it != base_type::end()) - return (*it).second; - return (*base_type::insert(value_type(key, mapped_type())).first).second; - } - - }; // hash_map - - - - - - - /// hash_multimap - /// - /// Implements a hash_multimap, which is the same thing as a hash_map - /// except that contained elements need not be unique. See the - /// documentation for hash_set for details. - /// - template , typename Predicate = eastl::equal_to, - typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false> - class hash_multimap - : public hashtable, Allocator, eastl::use_first >, Predicate, - Hash, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, true, false> - { - public: - typedef hashtable, Allocator, - eastl::use_first >, - Predicate, Hash, mod_range_hashing, default_ranged_hash, - prime_rehash_policy, bCacheHashCode, true, false> base_type; - typedef hash_multimap this_type; - typedef typename base_type::size_type size_type; - typedef typename base_type::key_type key_type; - typedef T mapped_type; - typedef typename base_type::value_type value_type; // Note that this is pair. - typedef typename base_type::allocator_type allocator_type; - typedef typename base_type::node_type node_type; - typedef typename base_type::insert_return_type insert_return_type; - typedef typename base_type::iterator iterator; - - #if !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x has a bug which we work around. - using base_type::insert; - #endif - - public: - /// hash_multimap - /// - /// Default constructor. - /// - explicit hash_multimap(const allocator_type& allocator = EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR) - : base_type(0, Hash(), mod_range_hashing(), default_ranged_hash(), - Predicate(), eastl::use_first >(), allocator) - { - // Empty - } - - - /// hash_multimap - /// - /// Constructor which creates an empty container, but start with nBucketCount buckets. - /// We default to a small nBucketCount value, though the user really should manually - /// specify an appropriate value in order to prevent memory from being reallocated. - /// - explicit hash_multimap(size_type nBucketCount, const Hash& hashFunction = Hash(), - const Predicate& predicate = Predicate(), const allocator_type& allocator = EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR) - : base_type(nBucketCount, hashFunction, mod_range_hashing(), default_ranged_hash(), - predicate, eastl::use_first >(), allocator) - { - // Empty - } - - - /// hash_multimap - /// - /// An input bucket count of <= 1 causes the bucket count to be equal to the number of - /// elements in the input range. - /// - template - hash_multimap(ForwardIterator first, ForwardIterator last, size_type nBucketCount = 0, const Hash& hashFunction = Hash(), - const Predicate& predicate = Predicate(), const allocator_type& allocator = EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR) - : base_type(first, last, nBucketCount, hashFunction, mod_range_hashing(), default_ranged_hash(), - predicate, eastl::use_first >(), allocator) - { - // Empty - } - - - /// insert - /// - /// This is an extension to the C++ standard. We insert a default-constructed - /// element with the given key. The reason for this is that we can avoid the - /// potentially expensive operation of creating and/or copying a mapped_type - /// object on the stack. - insert_return_type insert(const key_type& key) - { - return base_type::DoInsertKey(key, false_type()); - } - - - #if defined(__GNUC__) && (__GNUC__ < 3) // If using old GCC (GCC 2.x has a bug which we work around) - template - void insert(InputIterator first, InputIterator last) { return base_type::insert(first, last); } - insert_return_type insert(const value_type& value) { return base_type::insert(value); } - iterator insert(const_iterator it, const value_type& value) { return base_type::insert(it, value); } - #endif - - - }; // hash_multimap - - - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_rdestl.h deleted file mode 100644 index 05018875e642..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_map_rdestl.h +++ /dev/null @@ -1,575 +0,0 @@ -#ifndef RDESTL_HASH_MAP_H -#define RDESTL_HASH_MAP_H - -#include -#include -#include -#include -#include - -namespace rde -{ - -// TLoadFactor4 - controls hash map load. 4 means 100% load, ie. hashmap will grow -// when number of items == capacity. Default value of 6 means it grows when -// number of items == capacity * 3/2 (6/4). Higher load == tighter maps, but bigger -// risk of collisions. -template, - int TLoadFactor4 = 6, - class TKeyEqualFunc = rde::equal_to, - class TAllocator = rde::allocator> -class hash_map -{ -public: - typedef rde::pair value_type; - -private: - struct node - { - static const hash_value_t kUnusedHash = 0xFFFFFFFF; - static const hash_value_t kDeletedHash = 0xFFFFFFFE; - - node(): hash(kUnusedHash) {} - - RDE_FORCEINLINE bool is_unused() const { return hash == kUnusedHash; } - RDE_FORCEINLINE bool is_deleted() const { return hash == kDeletedHash; } - RDE_FORCEINLINE bool is_occupied() const { return hash < kDeletedHash; } - - hash_value_t hash; - value_type data; - }; - template - class node_iterator - { - friend class hash_map; - public: - typedef forward_iterator_tag iterator_category; - - explicit node_iterator(TNodePtr node, const hash_map* map) - : m_node(node), - m_map(map) - {/**/} - template - node_iterator(const node_iterator& rhs) - : m_node(rhs.node()), - m_map(rhs.get_map()) - {/**/} - - TRef operator*() const - { - RDE_ASSERT(m_node != 0); - return m_node->data; - } - TPtr operator->() const - { - return &m_node->data; - } - RDE_FORCEINLINE TNodePtr node() const - { - return m_node; - } - - node_iterator& operator++() - { - RDE_ASSERT(m_node != 0); - ++m_node; - move_to_next_occupied_node(); - return *this; - } - node_iterator operator++(int) - { - node_iterator copy(*this); - ++(*this); - return copy; - } - - RDE_FORCEINLINE bool operator==(const node_iterator& rhs) const - { - return rhs.m_node == m_node; - } - bool operator!=(const node_iterator& rhs) const - { - return !(rhs == *this); - } - - const hash_map* get_map() const { return m_map; } - private: - void move_to_next_occupied_node() - { - // @todo: save nodeEnd in constructor? - TNodePtr nodeEnd = m_map->m_nodes + m_map->bucket_count(); - for (/**/; m_node < nodeEnd; ++m_node) - { - if (m_node->is_occupied()) - break; - } - } - TNodePtr m_node; - const hash_map* m_map; - }; - -public: - typedef TKey key_type; - typedef TValue mapped_type; - typedef TAllocator allocator_type; - typedef node_iterator iterator; - typedef node_iterator const_iterator; - typedef int size_type; - static const size_type kNodeSize = sizeof(node); - static const size_type kInitialCapacity = 64; - - hash_map() - : m_nodes(&ms_emptyNode), - m_size(0), - m_capacity(0), - m_capacityMask(0), - m_numUsed(0) - { - RDE_ASSERT((kInitialCapacity & (kInitialCapacity - 1)) == 0); // Must be power-of-two - } - explicit hash_map(const allocator_type& allocator) - : m_nodes(&ms_emptyNode), - m_size(0), - m_capacity(0), - m_capacityMask(0), - m_numUsed(0), - m_allocator(allocator) - { - /**/ - } - explicit hash_map(size_type initial_bucket_count, - const allocator_type& allocator = allocator_type()) - : m_nodes(&ms_emptyNode), - m_size(0), - m_capacity(0), - m_capacityMask(0), - m_numUsed(0), - m_allocator(allocator) - { - reserve(initial_bucket_count); - } - hash_map(size_type initial_bucket_count, - const THashFunc& hashFunc, - const allocator_type& allocator = allocator_type()) - : m_nodes(&ms_emptyNode), - m_size(0), - m_capacity(0), - m_capacityMask(0), - m_numUsed(0), - m_hashFunc(hashFunc), - m_allocator(allocator) - { - reserve(initial_bucket_count); - } - hash_map(const hash_map& rhs, const allocator_type& allocator = allocator_type()) - : m_nodes(&ms_emptyNode), - m_size(0), - m_capacity(0), - m_capacityMask(0), - m_numUsed(0), - m_allocator(allocator) - { - *this = rhs; - } - explicit hash_map(e_noinitialize) - { - /**/ - } - ~hash_map() - { - delete_nodes(); - } - - iterator begin() - { - iterator it(m_nodes, this); - it.move_to_next_occupied_node(); - return it; - } - const_iterator begin() const - { - const_iterator it(m_nodes, this); - it.move_to_next_occupied_node(); - return it; - } - iterator end() { return iterator(m_nodes + m_capacity, this); } - const_iterator end() const { return const_iterator(m_nodes + m_capacity, this); } - - // @note: Added for compatiblity sake. - // Personally, I consider it "risky". Use find/insert for more - // explicit operations. - mapped_type& operator[](const key_type& key) - { - hash_value_t hash; - node* n = find_for_insert(key, &hash); - if (n == 0 || !n->is_occupied()) - { - return insert_at(value_type(key, TValue()), n, hash).first->second; - } - return n->data.second; - } - // @note: Doesn't copy allocator. - hash_map& operator=(const hash_map& rhs) - { - RDE_ASSERT(invariant()); - if (&rhs != this) - { - clear(); - if (m_capacity < rhs.bucket_count()) - { - delete_nodes(); - m_nodes = allocate_nodes(rhs.bucket_count()); - m_capacity = rhs.bucket_count(); - m_capacityMask = m_capacity - 1; - } - rehash(m_capacity, m_nodes, rhs.m_capacity, rhs.m_nodes, false); - m_size = rhs.size(); - m_numUsed = rhs.m_numUsed; - } - RDE_ASSERT(invariant()); - return *this; - } - void swap(hash_map& rhs) - { - if (&rhs != this) - { - RDE_ASSERT(invariant()); - RDE_ASSERT(m_allocator == rhs.m_allocator); - rde::swap(m_nodes, rhs.m_nodes); - rde::swap(m_size, rhs.m_size); - rde::swap(m_capacity, rhs.m_capacity); - rde::swap(m_capacityMask, rhs.m_capacityMask); - rde::swap(m_numUsed, rhs.m_numUsed); - rde::swap(m_hashFunc, rhs.m_hashFunc); - rde::swap(m_keyEqualFunc, rhs.m_keyEqualFunc); - RDE_ASSERT(invariant()); - } - } - - rde::pair insert(const value_type& v) - { - typedef rde::pair ret_type_t; - RDE_ASSERT(invariant()); - if (m_numUsed * TLoadFactor4 >= m_capacity * 4) - grow(); - - hash_value_t hash = 0XFFFFFFFF; - - node* n = find_for_insert(v.first, &hash); - if (n->is_occupied()) - { - RDE_ASSERT(hash == n->hash && m_keyEqualFunc(v.first, n->data.first)); - return ret_type_t(iterator(n, this), false); - } - if (n->is_unused()) - ++m_numUsed; - rde::copy_construct(&n->data, v); - n->hash = hash; - ++m_size; - RDE_ASSERT(invariant()); - return ret_type_t(iterator(n, this), true); - } - - size_type erase(const key_type& key) - { - node* n = lookup(key); - if (n != (m_nodes + m_capacity) && n->is_occupied()) - { - erase_node(n); - return 1; - } - return 0; - } - void erase(iterator it) - { - RDE_ASSERT(it.get_map() == this); - if (it != end()) - { - RDE_ASSERT(!empty()); - erase_node(it.node()); - } - } - void erase(iterator from, iterator to) - { - for (/**/; from != to; ++from) - { - node* n = from.node(); - if (n->is_occupied()) - erase_node(n); - } - } - - iterator find(const key_type& key) - { - node* n = lookup(key); - return iterator(n, this); - } - const_iterator find(const key_type& key) const - { - const node* n = lookup(key); - return const_iterator(n, this); - } - - void clear() - { - node* endNode = m_nodes + m_capacity; - for (node* iter = m_nodes; iter != endNode; ++iter) - { - if( iter ) - { - if (iter->is_occupied()) - { - rde::destruct(&iter->data); - } - // We can make them unused, because we clear whole hash_map, - // so we can guarantee there'll be no holes. - iter->hash = node::kUnusedHash; - } - } - m_size = 0; - m_numUsed = 0; - } - - // More like reserve. - // resize() name chosen for compatibility sake. - void reserve(size_type min_size) - { - size_type newCapacity = (m_capacity == 0 ? kInitialCapacity : m_capacity); - while (newCapacity < min_size) - newCapacity *= 2; - if (newCapacity > m_capacity) - grow(newCapacity); - } - - size_type bucket_count() const { return m_capacity; } - size_type size() const { return m_size; } - size_type empty() const { return size() == 0; } - size_type nonempty_bucket_count() const { return m_numUsed; } - size_type used_memory() const - { - return bucket_count() * kNodeSize; - } - - const allocator_type& get_allocator() const { return m_allocator; } - void set_allocator(const allocator_type& allocator) - { - m_allocator = allocator; - } - -private: - void grow() - { - const int newCapacity = (m_capacity == 0 ? kInitialCapacity : m_capacity * 2); - grow(newCapacity); - } - void grow(int new_capacity) - { - RDE_ASSERT((new_capacity & (new_capacity - 1)) == 0); // Must be power-of-two - node* newNodes = allocate_nodes(new_capacity); - rehash(new_capacity, newNodes, m_capacity, m_nodes, true); - if (m_nodes != &ms_emptyNode) - m_allocator.deallocate(m_nodes, sizeof(node) * m_capacity); - m_capacity = new_capacity; - m_capacityMask = new_capacity - 1; - m_nodes = newNodes; - m_numUsed = m_size; - RDE_ASSERT(m_numUsed < m_capacity); - } - rde::pair insert_at(const value_type& v, node* n, - hash_value_t hash) - { - RDE_ASSERT(invariant()); - if (n == 0 || m_numUsed * TLoadFactor4 >= m_capacity * 4) - return insert(v); - - RDE_ASSERT(!n->is_occupied()); - if (n->is_unused()) - ++m_numUsed; - rde::copy_construct(&n->data, v); - n->hash = hash; - ++m_size; - RDE_ASSERT(invariant()); - return rde::pair(iterator(n, this), true); - } - node* find_for_insert(const key_type& key, hash_value_t* out_hash) - { - if (m_capacity == 0) - return 0; - - const hash_value_t hash = hash_func(key); - *out_hash = hash; - uint32 i = hash & m_capacityMask; - - node* n = m_nodes + i; - if (n->hash == hash && m_keyEqualFunc(key, n->data.first)) - return n; - - node* freeNode(0); - if (n->is_deleted()) - freeNode = n; - uint32 numProbes(0); - // Guarantees loop termination. - RDE_ASSERT(m_numUsed < m_capacity); - while (!n->is_unused()) - { - ++numProbes; - i = (i + numProbes) & m_capacityMask; - n = m_nodes + i; - if (compare_key(n, key, hash)) - return n; - if (n->is_deleted() && freeNode == 0) - freeNode = n; - } - return freeNode ? freeNode : n; - } - node* lookup(const key_type& key) const - { - const hash_value_t hash = hash_func(key); - uint32 i = hash & m_capacityMask; - node* n = m_nodes + i; - // In theory, we could try to use compare_key here, it would - // be a little bit faster for keys with cheap_compare. However, if keys are - // not totally destroyed on removal (erase_node), this could result in returning - // unused nodes. By testing hashes - we make sure it does not happen. - // This could also be solved by doing what Google does -- set_empty_key/set_deleted_key, - // but for the time being it doesn't look to me like it's worth it. - if (n->hash == hash && m_keyEqualFunc(key, n->data.first)) - return n; - - uint32 numProbes(0); - // Guarantees loop termination. - RDE_ASSERT(m_capacity == 0 || m_numUsed < m_capacity); - while (!n->is_unused()) - { - ++numProbes; - i = (i + numProbes) & m_capacityMask; - n = m_nodes + i; - - if (compare_key(n, key, hash)) - return n; - } - return m_nodes + m_capacity; - } - - static void rehash(int new_capacity, node* new_nodes, - int capacity, const node* nodes, bool destruct_original) - { - //if (nodes == &ms_emptyNode || new_nodes == &ms_emptyNode) - // return; - - const node* it = nodes; - const node* itEnd = nodes + capacity; - const uint32 mask = new_capacity - 1; - while (it != itEnd) - { - if (it->is_occupied()) - { - const hash_value_t hash = it->hash; - uint32 i = hash & mask; - - node* n = new_nodes + i; - uint32 numProbes(0); - while (!n->is_unused()) - { - ++numProbes; - i = (i + numProbes) & mask; - n = new_nodes + i; - } - rde::copy_construct(&n->data, it->data); - n->hash = hash; - if (destruct_original) - rde::destruct(&it->data); - } - ++it; - } - } - - node* allocate_nodes(int n) - { - node* buckets = static_cast(m_allocator.allocate(n * sizeof(node))); - node* iterBuckets(buckets); - node* end = iterBuckets + n; - for (/**/; iterBuckets != end; ++iterBuckets) - iterBuckets->hash = node::kUnusedHash; - - return buckets; - } - void delete_nodes() - { - node* it = m_nodes; - node* itEnd = it + m_capacity; - while (it != itEnd) - { - if (it && it->is_occupied()) - rde::destruct(&it->data); - ++it; - } - if (m_nodes != &ms_emptyNode) - m_allocator.deallocate(m_nodes, sizeof(node) * m_capacity); - - m_capacity = 0; - m_capacityMask = 0; - m_size = 0; - } - void erase_node(node* n) - { - RDE_ASSERT(!empty()); - RDE_ASSERT(n->is_occupied()); - rde::destruct(&n->data); - n->hash = node::kDeletedHash; - --m_size; - } - - RDE_FORCEINLINE hash_value_t hash_func(const key_type& key) const - { - const hash_value_t h = m_hashFunc(key) & 0xFFFFFFFD; - //RDE_ASSERT(h < node::kDeletedHash); - return h; - } - bool invariant() const - { - RDE_ASSERT((m_capacity & (m_capacity - 1)) == 0); - RDE_ASSERT(m_numUsed >= m_size); - return true; - } - - RDE_FORCEINLINE bool compare_key(const node* n, const key_type& key, hash_value_t hash, - int_to_type) const - { - return (n->hash == hash && m_keyEqualFunc(key, n->data.first)); - } - RDE_FORCEINLINE bool compare_key(const node* n, const key_type& key, hash_value_t, - int_to_type) const - { - return m_keyEqualFunc(key, n->data.first); - } - RDE_FORCEINLINE bool compare_key(const node* n, const key_type& key, hash_value_t hash) const - { - return compare_key(n, key, hash, int_to_type::value>()); - } - - node* m_nodes; - int m_size; - int m_capacity; - uint32 m_capacityMask; - int m_numUsed; - THashFunc m_hashFunc; - TKeyEqualFunc m_keyEqualFunc; - TAllocator m_allocator; - - static node ms_emptyNode; -}; - - -// Holy ... -template -typename hash_map::node hash_map::ms_emptyNode; - -} - -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_rdestl.h deleted file mode 100644 index 16b49af82191..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hash_rdestl.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef RDESTL_HASH_H -#define RDESTL_HASH_H - -namespace rde -{ - -typedef unsigned long hash_value_t; - -// Default implementations, just casts to hash_value. -template -hash_value_t extract_int_key_value(const T& t) -{ - return (hash_value_t)t; -} - -// Default implementation of hasher. -// Works for keys that can be converted to 32-bit integer -// with extract_int_key_value. -// Algorithm by Robert Jenkins. -// (see http://www.cris.com/~Ttwang/tech/inthash.htm for example). -template -struct hash -{ - hash_value_t operator()(const T& t) const - { - hash_value_t a = extract_int_key_value(t); - a = (a+0x7ed55d16) + (a<<12); - a = (a^0xc761c23c) ^ (a>>19); - a = (a+0x165667b1) + (a<<5); - a = (a+0xd3a2646c) ^ (a<<9); - a = (a+0xfd7046c5) + (a<<3); - a = (a^0xb55a4f09) ^ (a>>16); - return a; - } -}; - -} - -#endif diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.cpp deleted file mode 100644 index a24435700375..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/hashtable.cpp -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - - -#include -#include -#include // Not all compilers support and std::ceil(), which we need below. -#include - - -#ifdef _MSC_VER - #pragma warning(disable: 4267) // 'argument' : conversion from 'size_t' to 'const uint32_t', possible loss of data. This is a bogus warning resulting from a bug in VC++. -#endif - - -namespace eastl -{ - - /// gpEmptyBucketArray - /// - /// A shared representation of an empty hash table. This is present so that - /// a new empty hashtable allocates no memory. It has two entries, one for - /// the first lone empty (NULL) bucket, and one for the non-NULL trailing sentinel. - /// - EASTL_API void* gpEmptyBucketArray[2] = { NULL, (void*)uintptr_t(~0) }; - - - - /// gPrimeNumberArray - /// - /// This is an array of prime numbers. This is the same set of prime - /// numbers suggested by the C++ standard proposal. These are numbers - /// which are separated by 8% per entry. - /// - /// To consider: Allow the user to specify their own prime number array. - /// - const uint32_t gPrimeNumberArray[] = - { - 2u, 3u, 5u, 7u, 11u, 13u, 17u, 19u, 23u, 29u, 31u, - 37u, 41u, 43u, 47u, 53u, 59u, 61u, 67u, 71u, 73u, 79u, - 83u, 89u, 97u, 103u, 109u, 113u, 127u, 137u, 139u, 149u, - 157u, 167u, 179u, 193u, 199u, 211u, 227u, 241u, 257u, - 277u, 293u, 313u, 337u, 359u, 383u, 409u, 439u, 467u, - 503u, 541u, 577u, 619u, 661u, 709u, 761u, 823u, 887u, - 953u, 1031u, 1109u, 1193u, 1289u, 1381u, 1493u, 1613u, - 1741u, 1879u, 2029u, 2179u, 2357u, 2549u, 2753u, 2971u, - 3209u, 3469u, 3739u, 4027u, 4349u, 4703u, 5087u, 5503u, - 5953u, 6427u, 6949u, 7517u, 8123u, 8783u, 9497u, 10273u, - 11113u, 12011u, 12983u, 14033u, 15173u, 16411u, 17749u, - 19183u, 20753u, 22447u, 24281u, 26267u, 28411u, 30727u, - 33223u, 35933u, 38873u, 42043u, 45481u, 49201u, 53201u, - 57557u, 62233u, 67307u, 72817u, 78779u, 85229u, 92203u, - 99733u, 107897u, 116731u, 126271u, 136607u, 147793u, - 159871u, 172933u, 187091u, 202409u, 218971u, 236897u, - 256279u, 277261u, 299951u, 324503u, 351061u, 379787u, - 410857u, 444487u, 480881u, 520241u, 562841u, 608903u, - 658753u, 712697u, 771049u, 834181u, 902483u, 976369u, - 1056323u, 1142821u, 1236397u, 1337629u, 1447153u, 1565659u, - 1693859u, 1832561u, 1982627u, 2144977u, 2320627u, 2510653u, - 2716249u, 2938679u, 3179303u, 3439651u, 3721303u, 4026031u, - 4355707u, 4712381u, 5098259u, 5515729u, 5967347u, 6456007u, - 6984629u, 7556579u, 8175383u, 8844859u, 9569143u, 10352717u, - 11200489u, 12117689u, 13109983u, 14183539u, 15345007u, - 16601593u, 17961079u, 19431899u, 21023161u, 22744717u, - 24607243u, 26622317u, 28802401u, 31160981u, 33712729u, - 36473443u, 39460231u, 42691603u, 46187573u, 49969847u, - 54061849u, 58488943u, 63278561u, 68460391u, 74066549u, - 80131819u, 86693767u, 93793069u, 101473717u, 109783337u, - 118773397u, 128499677u, 139022417u, 150406843u, 162723577u, - 176048909u, 190465427u, 206062531u, 222936881u, 241193053u, - 260944219u, 282312799u, 305431229u, 330442829u, 357502601u, - 386778277u, 418451333u, 452718089u, 489790921u, 529899637u, - 573292817u, 620239453u, 671030513u, 725980837u, 785430967u, - 849749479u, 919334987u, 994618837u, 1076067617u, 1164186217u, - 1259520799u, 1362662261u, 1474249943u, 1594975441u, - 1725587117u, 1866894511u, 2019773507u, 2185171673u, - 2364114217u, 2557710269u, 2767159799u, 2993761039u, - 3238918481u, 3504151727u, 3791104843u, 4101556399u, - 4294967291u, - 4294967291u // Sentinel so we don't have to test result of lower_bound - }; - - - /// kPrimeCount - /// - /// The number of prime numbers in gPrimeNumberArray. - /// - const uint32_t kPrimeCount = (sizeof(gPrimeNumberArray) / sizeof(gPrimeNumberArray[0]) - 1); - - - /// GetPrevBucketCountOnly - /// Return a bucket count no greater than nBucketCountHint. - /// - uint32_t prime_rehash_policy::GetPrevBucketCountOnly(uint32_t nBucketCountHint) - { - const uint32_t nPrime = *(eastl::upper_bound(gPrimeNumberArray, gPrimeNumberArray + kPrimeCount, nBucketCountHint) - 1); - return nPrime; - } - - - /// GetPrevBucketCount - /// Return a bucket count no greater than nBucketCountHint. - /// This function has a side effect of updating mnNextResize. - /// - uint32_t prime_rehash_policy::GetPrevBucketCount(uint32_t nBucketCountHint) const - { - const uint32_t nPrime = *(eastl::upper_bound(gPrimeNumberArray, gPrimeNumberArray + kPrimeCount, nBucketCountHint) - 1); - - mnNextResize = (uint32_t)ceil(nPrime * mfMaxLoadFactor); - return nPrime; - } - - - /// GetNextBucketCount - /// Return a prime no smaller than nBucketCountHint. - /// This function has a side effect of updating mnNextResize. - /// - uint32_t prime_rehash_policy::GetNextBucketCount(uint32_t nBucketCountHint) const - { - const uint32_t nPrime = *eastl::lower_bound(gPrimeNumberArray, gPrimeNumberArray + kPrimeCount, nBucketCountHint); - - mnNextResize = (uint32_t)ceil(nPrime * mfMaxLoadFactor); - return nPrime; - } - - - /// GetBucketCount - /// Return the smallest prime p such that alpha p >= nElementCount, where alpha - /// is the load factor. This function has a side effect of updating mnNextResize. - /// - uint32_t prime_rehash_policy::GetBucketCount(uint32_t nElementCount) const - { - const uint32_t nMinBucketCount = (uint32_t)(nElementCount / mfMaxLoadFactor); - const uint32_t nPrime = *eastl::lower_bound(gPrimeNumberArray, gPrimeNumberArray + kPrimeCount, nMinBucketCount); - - mnNextResize = (uint32_t)ceil(nPrime * mfMaxLoadFactor); - return nPrime; - } - - - /// GetRehashRequired - /// Finds the smallest prime p such that alpha p > nElementCount + nElementAdd. - /// If p > nBucketCount, return pair(true, p); otherwise return - /// pair(false, 0). In principle this isn't very different from GetBucketCount. - /// This function has a side effect of updating mnNextResize. - /// - eastl::pair - prime_rehash_policy::GetRehashRequired(uint32_t nBucketCount, uint32_t nElementCount, uint32_t nElementAdd) const - { - if((nElementCount + nElementAdd) > mnNextResize) // It is significant that we specify > next resize and not >= next resize. - { - if(nBucketCount == 1) // We force rehashing to occur if the bucket count is < 2. - nBucketCount = 0; - - float fMinBucketCount = (nElementCount + nElementAdd) / mfMaxLoadFactor; - - if(fMinBucketCount > (float)nBucketCount) - { - fMinBucketCount = eastl::max_alt(fMinBucketCount, mfGrowthFactor * nBucketCount); - const uint32_t nPrime = *eastl::lower_bound(gPrimeNumberArray, gPrimeNumberArray + kPrimeCount, (uint32_t)fMinBucketCount); - mnNextResize = (uint32_t)ceil(nPrime * mfMaxLoadFactor); - - return eastl::pair(true, nPrime); - } - else - { - mnNextResize = (uint32_t)ceil(nBucketCount * mfMaxLoadFactor); - return eastl::pair(false, (uint32_t)0); - } - } - - return eastl::pair(false, (uint32_t)0); - } - - -} // namespace eastl diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.h deleted file mode 100644 index 4d5577d00b02..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/hashtable_eastl.h +++ /dev/null @@ -1,2251 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/hashtable.h -// -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file implements a hashtable, much like the C++ TR1 hash_set/hash_map. -// proposed classes. -// The primary distinctions between this hashtable and TR1 hash tables are: -// - hashtable is savvy to an environment that doesn't have exception handling, -// as is sometimes the case with console or embedded environments. -// - hashtable is slightly more space-efficient than a conventional std hashtable -// implementation on platforms with 64 bit size_t. This is -// because std STL uses size_t (64 bits) in data structures whereby 32 bits -// of data would be fine. -// - hashtable can contain objects with alignment requirements. TR1 hash tables -// cannot do so without a bit of tedious non-portable effort. -// - hashtable supports debug memory naming natively. -// - hashtable provides a find function that lets you specify a type that is -// different from the hash table key type. This is particularly useful for -// the storing of string objects but finding them by char pointers. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file is currently partially based on the TR1 (technical report 1) -// reference implementation of the hash_set/hash_map C++ classes -// as of about 4/2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_HASHTABLE_H -#define EASTL_INTERNAL_HASHTABLE_H - - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) - #include - #include - #pragma warning(pop) -#else - #include - #include -#endif - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4512) // 'class' : assignment operator could not be generated. - #pragma warning(disable: 4530) // C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc -#endif - - -namespace eastl -{ - - /// EASTL_HASHTABLE_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_HASHTABLE_DEFAULT_NAME - #define EASTL_HASHTABLE_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hashtable" // Unless the user overrides something, this is "EASTL hashtable". - #endif - - - /// EASTL_HASHTABLE_DEFAULT_ALLOCATOR - /// - #ifndef EASTL_HASHTABLE_DEFAULT_ALLOCATOR - #define EASTL_HASHTABLE_DEFAULT_ALLOCATOR allocator_type(EASTL_HASHTABLE_DEFAULT_NAME) - #endif - - - - /// gpEmptyBucketArray - /// - /// A shared representation of an empty hash table. This is present so that - /// a new empty hashtable allocates no memory. It has two entries, one for - /// the first lone empty (NULL) bucket, and one for the non-NULL trailing sentinel. - /// - extern EASTL_API void* gpEmptyBucketArray[2]; - - - - /// hash_node - /// - /// A hash_node stores an element in a hash table, much like a - /// linked list node stores an element in a linked list. - /// A hash_node additionally can, via template parameter, - /// store a hash code in the node to speed up hash calculations - /// and comparisons in some cases. - /// - template - struct hash_node; - - template - struct hash_node - { - Value mValue; - hash_node* mpNext; - eastl_size_t mnHashCode; // See config.h for the definition of eastl_size_t, which defaults to uint32_t. - } EASTL_MAY_ALIAS; - - template - struct hash_node - { - Value mValue; - hash_node* mpNext; - } EASTL_MAY_ALIAS; - - - - /// node_iterator_base - /// - /// Node iterators iterate nodes within a given bucket. - /// - /// We define a base class here because it is shared by both const and - /// non-const iterators. - /// - template - struct node_iterator_base - { - public: - typedef hash_node node_type; - - node_type* mpNode; - - public: - node_iterator_base(node_type* pNode) - : mpNode(pNode) { } - - void increment() - { mpNode = mpNode->mpNext; } - }; - - - - /// node_iterator - /// - /// Node iterators iterate nodes within a given bucket. - /// - /// The bConst parameter defines if the iterator is a const_iterator - /// or an iterator. - /// - template - struct node_iterator : public node_iterator_base - { - public: - typedef node_iterator_base base_type; - typedef node_iterator this_type; - typedef typename base_type::node_type node_type; - typedef Value value_type; - typedef typename type_select::type pointer; - typedef typename type_select::type reference; - typedef ptrdiff_t difference_type; - typedef EASTL_ITC_NS::forward_iterator_tag iterator_category; - - public: - explicit node_iterator(node_type* pNode = NULL) - : base_type(pNode) { } - - node_iterator(const node_iterator& x) - : base_type(x.mpNode) { } - - reference operator*() const - { return base_type::mpNode->mValue; } - - pointer operator->() const - { return &(base_type::mpNode->mValue); } - - node_iterator& operator++() - { base_type::increment(); return *this; } - - node_iterator operator++(int) - { node_iterator temp(*this); base_type::increment(); return temp; } - - }; // node_iterator - - - - /// hashtable_iterator_base - /// - /// A hashtable_iterator iterates the entire hash table and not just - /// nodes within a single bucket. Users in general will use a hash - /// table iterator much more often, as it is much like other container - /// iterators (e.g. vector::iterator). - /// - /// We define a base class here because it is shared by both const and - /// non-const iterators. - /// - template - struct hashtable_iterator_base - { - public: - typedef hash_node node_type; - - public: - // We use public here because it allows the hashtable class to access - // these without a function call, and we are very strongly avoiding - // function calls in this library, as our primary goal is performance - // over correctness and some compilers (e.g. GCC) are terrible at - // inlining and so avoiding function calls is of major importance. - node_type* mpNode; // Current node within current bucket. - node_type** mpBucket; // Current bucket. - - public: - hashtable_iterator_base(node_type* pNode, node_type** pBucket) - : mpNode(pNode), mpBucket(pBucket) { } - - void increment_bucket() - { - ++mpBucket; - while(*mpBucket == NULL) // We store an extra bucket with some non-NULL value at the end - ++mpBucket; // of the bucket array so that finding the end of the bucket - mpNode = *mpBucket; // array is quick and simple. - } - - void increment() - { - mpNode = mpNode->mpNext; - - while(mpNode == NULL) - mpNode = *++mpBucket; - } - - }; // hashtable_iterator_base - - - - - /// hashtable_iterator - /// - /// A hashtable_iterator iterates the entire hash table and not just - /// nodes within a single bucket. Users in general will use a hash - /// table iterator much more often, as it is much like other container - /// iterators (e.g. vector::iterator). - /// - /// The bConst parameter defines if the iterator is a const_iterator - /// or an iterator. - /// - template - struct hashtable_iterator : public hashtable_iterator_base - { - public: - typedef hashtable_iterator_base base_type; - typedef hashtable_iterator this_type; - typedef hashtable_iterator this_type_non_const; - typedef typename base_type::node_type node_type; - typedef Value value_type; - typedef typename type_select::type pointer; - typedef typename type_select::type reference; - typedef ptrdiff_t difference_type; - typedef EASTL_ITC_NS::forward_iterator_tag iterator_category; - - public: - hashtable_iterator(node_type* pNode = NULL, node_type** pBucket = NULL) - : base_type(pNode, pBucket) { } - - hashtable_iterator(node_type** pBucket) - : base_type(*pBucket, pBucket) { } - - hashtable_iterator(const this_type_non_const& x) - : base_type(x.mpNode, x.mpBucket) { } - - reference operator*() const - { return base_type::mpNode->mValue; } - - pointer operator->() const - { return &(base_type::mpNode->mValue); } - - hashtable_iterator& operator++() - { base_type::increment(); return *this; } - - hashtable_iterator operator++(int) - { hashtable_iterator temp(*this); base_type::increment(); return temp; } - - const node_type* get_node() const - { return base_type::mpNode; } - - }; // hashtable_iterator - - - - - /// ht_distance - /// - /// This function returns the same thing as distance() for - /// forward iterators but returns zero for input iterators. - /// The reason why is that input iterators can only be read - /// once, and calling distance() on an input iterator destroys - /// the ability to read it. This ht_distance is used only for - /// optimization and so the code will merely work better with - /// forward iterators that input iterators. - /// - template - inline typename eastl::iterator_traits::difference_type - distance_fw_impl(Iterator first, Iterator last, EASTL_ITC_NS::input_iterator_tag) - { return 0; } - - template - inline typename eastl::iterator_traits::difference_type - distance_fw_impl(Iterator first, Iterator last, EASTL_ITC_NS::forward_iterator_tag) - { return eastl::distance(first, last); } - - template - inline typename eastl::iterator_traits::difference_type - ht_distance(Iterator first, Iterator last) - { - typedef typename eastl::iterator_traits::iterator_category IC; - return distance_fw_impl(first, last, IC()); - } - - - - - /// mod_range_hashing - /// - /// Implements the algorithm for conversion of a number in the range of - /// [0, UINT32_MAX) to the range of [0, BucketCount). - /// - struct mod_range_hashing - { - // Defined as eastl_size_t instead of size_t because the latter - // wastes memory and is sometimes slower on 64 bit machines. - uint32_t operator()(uint32_t r, uint32_t n) const - { return r % n; } - }; - - - /// default_ranged_hash - /// - /// Default ranged hash function H. In principle it should be a - /// function object composed from objects of type H1 and H2 such that - /// h(k, n) = h2(h1(k), n), but that would mean making extra copies of - /// h1 and h2. So instead we'll just use a tag to tell class template - /// hashtable to do that composition. - /// - struct default_ranged_hash{ }; - - - /// prime_rehash_policy - /// - /// Default value for rehash policy. Bucket size is (usually) the - /// smallest prime that keeps the load factor small enough. - /// - struct EASTL_API prime_rehash_policy - { - public: - float mfMaxLoadFactor; - float mfGrowthFactor; - mutable uint32_t mnNextResize; - - public: - prime_rehash_policy(float fMaxLoadFactor = 1.f) - : mfMaxLoadFactor(fMaxLoadFactor), mfGrowthFactor(2.f), mnNextResize(0) { } - - float GetMaxLoadFactor() const - { return mfMaxLoadFactor; } - - /// Return a bucket count no greater than nBucketCountHint, - /// Don't update member variables while at it. - static uint32_t GetPrevBucketCountOnly(uint32_t nBucketCountHint); - - /// Return a bucket count no greater than nBucketCountHint. - /// This function has a side effect of updating mnNextResize. - uint32_t GetPrevBucketCount(uint32_t nBucketCountHint) const; - - /// Return a bucket count no smaller than nBucketCountHint. - /// This function has a side effect of updating mnNextResize. - uint32_t GetNextBucketCount(uint32_t nBucketCountHint) const; - - /// Return a bucket count appropriate for nElementCount elements. - /// This function has a side effect of updating mnNextResize. - uint32_t GetBucketCount(uint32_t nElementCount) const; - - /// nBucketCount is current bucket count, nElementCount is current element count, - /// and nElementAdd is number of elements to be inserted. Do we need - /// to increase bucket count? If so, return pair(true, n), where - /// n is the new bucket count. If not, return pair(false, 0). - eastl::pair - GetRehashRequired(uint32_t nBucketCount, uint32_t nElementCount, uint32_t nElementAdd) const; - }; - - - - - - /////////////////////////////////////////////////////////////////////// - // Base classes for hashtable. We define these base classes because - // in some cases we want to do different things depending on the - // value of a policy class. In some cases the policy class affects - // which member functions and nested typedefs are defined; we handle that - // by specializing base class templates. Several of the base class templates - // need to access other members of class template hashtable, so we use - // the "curiously recurring template pattern" (parent class is templated - // on type of child class) for them. - /////////////////////////////////////////////////////////////////////// - - - /// rehash_base - /// - /// Give hashtable the get_max_load_factor functions if the rehash - /// policy is prime_rehash_policy. - /// - template - struct rehash_base { }; - - template - struct rehash_base - { - // Returns the max load factor, which is the load factor beyond - // which we rebuild the container with a new bucket count. - float get_max_load_factor() const - { - const Hashtable* const pThis = static_cast(this); - return pThis->rehash_policy().GetMaxLoadFactor(); - } - - // If you want to make the hashtable never rehash (resize), - // set the max load factor to be a very high number (e.g. 100000.f). - void set_max_load_factor(float fMaxLoadFactor) - { - Hashtable* const pThis = static_cast(this); - pThis->rehash_policy(prime_rehash_policy(fMaxLoadFactor)); - } - }; - - - - - /// hash_code_base - /// - /// Encapsulates two policy issues that aren't quite orthogonal. - /// (1) The difference between using a ranged hash function and using - /// the combination of a hash function and a range-hashing function. - /// In the former case we don't have such things as hash codes, so - /// we have a dummy type as placeholder. - /// (2) Whether or not we cache hash codes. Caching hash codes is - /// meaningless if we have a ranged hash function. This is because - /// a ranged hash function converts an object directly to its - /// bucket index without ostensibly using a hash code. - /// We also put the key extraction and equality comparison function - /// objects here, for convenience. - /// - template - struct hash_code_base; - - - /// hash_code_base - /// - /// Specialization: ranged hash function, no caching hash codes. - /// H1 and H2 are provided but ignored. We define a dummy hash code type. - /// - template - struct hash_code_base - { - protected: - ExtractKey mExtractKey; // To do: Make this member go away entirely, as it never has any data. - Equal mEqual; // To do: Make this instance use zero space when it is zero size. - H mRangedHash; // To do: Make this instance use zero space when it is zero size - - public: - H1 hash_function() const - { return H1(); } - - Equal equal_function() const // Deprecated. Use key_eq() instead, as key_eq is what the new C++ standard - { return mEqual; } // has specified in its hashtable (unordered_*) proposal. - - const Equal& key_eq() const - { return mEqual; } - - Equal& key_eq() - { return mEqual; } - - protected: - typedef void* hash_code_t; - typedef uint32_t bucket_index_t; - - hash_code_base(const ExtractKey& extractKey, const Equal& eq, const H1&, const H2&, const H& h) - : mExtractKey(extractKey), mEqual(eq), mRangedHash(h) { } - - hash_code_t get_hash_code(const Key& key) const - { return NULL; } - - bucket_index_t bucket_index(hash_code_t, uint32_t) const - { return (bucket_index_t)0; } - - bucket_index_t bucket_index(const Key& key, hash_code_t, uint32_t nBucketCount) const - { return (bucket_index_t)mRangedHash(key, nBucketCount); } - - bucket_index_t bucket_index(const hash_node* pNode, uint32_t nBucketCount) const - { return (bucket_index_t)mRangedHash(mExtractKey(pNode->mValue), nBucketCount); } - - bool compare(const Key& key, hash_code_t, hash_node* pNode) const - { return mEqual(key, mExtractKey(pNode->mValue)); } - - void copy_code(hash_node*, const hash_node*) const - { } // Nothing to do. - - void set_code(hash_node* pDest, hash_code_t c) const - { } // Nothing to do. - - void base_swap(hash_code_base& x) - { - eastl::swap(mExtractKey, x.mExtractKey); - eastl::swap(mEqual, x.mEqual); - eastl::swap(mRangedHash, x.mRangedHash); - } - - }; // hash_code_base - - - - // No specialization for ranged hash function while caching hash codes. - // That combination is meaningless, and trying to do it is an error. - - - /// hash_code_base - /// - /// Specialization: ranged hash function, cache hash codes. - /// This combination is meaningless, so we provide only a declaration - /// and no definition. - /// - template - struct hash_code_base; - - - - /// hash_code_base - /// - /// Specialization: hash function and range-hashing function, - /// no caching of hash codes. H is provided but ignored. - /// Provides typedef and accessor required by TR1. - /// - template - struct hash_code_base - { - protected: - ExtractKey mExtractKey; - Equal mEqual; - H1 m_h1; - H2 m_h2; - - public: - typedef H1 hasher; - - H1 hash_function() const - { return m_h1; } - - Equal equal_function() const // Deprecated. Use key_eq() instead, as key_eq is what the new C++ standard - { return mEqual; } // has specified in its hashtable (unordered_*) proposal. - - const Equal& key_eq() const - { return mEqual; } - - Equal& key_eq() - { return mEqual; } - - protected: - typedef uint32_t hash_code_t; - typedef uint32_t bucket_index_t; - typedef hash_node node_type; - - hash_code_base(const ExtractKey& ex, const Equal& eq, const H1& h1, const H2& h2, const default_ranged_hash&) - : mExtractKey(ex), mEqual(eq), m_h1(h1), m_h2(h2) { } - - hash_code_t get_hash_code(const Key& key) const - { return (hash_code_t)m_h1(key); } - - bucket_index_t bucket_index(hash_code_t c, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2(c, nBucketCount); } - - bucket_index_t bucket_index(const Key&, hash_code_t c, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2(c, nBucketCount); } - - bucket_index_t bucket_index(const node_type* pNode, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2((hash_code_t)m_h1(mExtractKey(pNode->mValue)), nBucketCount); } - - bool compare(const Key& key, hash_code_t, node_type* pNode) const - { return mEqual(key, mExtractKey(pNode->mValue)); } - - void copy_code(node_type*, const node_type*) const - { } // Nothing to do. - - void set_code(node_type*, hash_code_t) const - { } // Nothing to do. - - void base_swap(hash_code_base& x) - { - eastl::swap(mExtractKey, x.mExtractKey); - eastl::swap(mEqual, x.mEqual); - eastl::swap(m_h1, x.m_h1); - eastl::swap(m_h2, x.m_h2); - } - - }; // hash_code_base - - - - /// hash_code_base - /// - /// Specialization: hash function and range-hashing function, - /// caching hash codes. H is provided but ignored. - /// Provides typedef and accessor required by TR1. - /// - template - struct hash_code_base - { - protected: - ExtractKey mExtractKey; - Equal mEqual; - H1 m_h1; - H2 m_h2; - - public: - typedef H1 hasher; - - H1 hash_function() const - { return m_h1; } - - Equal equal_function() const // Deprecated. Use key_eq() instead, as key_eq is what the new C++ standard - { return mEqual; } // has specified in its hashtable (unordered_*) proposal. - - const Equal& key_eq() const - { return mEqual; } - - Equal& key_eq() - { return mEqual; } - - protected: - typedef uint32_t hash_code_t; - typedef uint32_t bucket_index_t; - typedef hash_node node_type; - - hash_code_base(const ExtractKey& ex, const Equal& eq, const H1& h1, const H2& h2, const default_ranged_hash&) - : mExtractKey(ex), mEqual(eq), m_h1(h1), m_h2(h2) { } - - hash_code_t get_hash_code(const Key& key) const - { return (hash_code_t)m_h1(key); } - - bucket_index_t bucket_index(hash_code_t c, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2(c, nBucketCount); } - - bucket_index_t bucket_index(const Key&, hash_code_t c, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2(c, nBucketCount); } - - bucket_index_t bucket_index(const node_type* pNode, uint32_t nBucketCount) const - { return (bucket_index_t)m_h2((uint32_t)pNode->mnHashCode, nBucketCount); } - - bool compare(const Key& key, hash_code_t c, node_type* pNode) const - { return (pNode->mnHashCode == c) && mEqual(key, mExtractKey(pNode->mValue)); } - - void copy_code(node_type* pDest, const node_type* pSource) const - { pDest->mnHashCode = pSource->mnHashCode; } - - void set_code(node_type* pDest, hash_code_t c) const - { pDest->mnHashCode = c; } - - void base_swap(hash_code_base& x) - { - eastl::swap(mExtractKey, x.mExtractKey); - eastl::swap(mEqual, x.mEqual); - eastl::swap(m_h1, x.m_h1); - eastl::swap(m_h2, x.m_h2); - } - - }; // hash_code_base - - - - - - /////////////////////////////////////////////////////////////////////////// - /// hashtable - /// - /// Key and Value: arbitrary CopyConstructible types. - /// - /// ExtractKey: function object that takes a object of type Value - /// and returns a value of type Key. - /// - /// Equal: function object that takes two objects of type k and returns - /// a bool-like value that is true if the two objects are considered equal. - /// - /// H1: a hash function. A unary function object with argument type - /// Key and result type size_t. Return values should be distributed - /// over the entire range [0, numeric_limits::max()]. - /// - /// H2: a range-hashing function (in the terminology of Tavori and - /// Dreizin). This is a function which takes the output of H1 and - /// converts it to the range of [0, n]. Usually it merely takes the - /// output of H1 and mods it to n. - /// - /// H: a ranged hash function (Tavori and Dreizin). This is merely - /// a class that combines the functionality of H1 and H2 together, - /// possibly in some way that is somehow improved over H1 and H2 - /// It is a binary function whose argument types are Key and size_t - /// and whose result type is uint32_t. Given arguments k and n, the - /// return value is in the range [0, n). Default: h(k, n) = h2(h1(k), n). - /// If H is anything other than the default, H1 and H2 are ignored, - /// as H is thus overriding H1 and H2. - /// - /// RehashPolicy: Policy class with three members, all of which govern - /// the bucket count. nBucket(n) returns a bucket count no smaller - /// than n. GetBucketCount(n) returns a bucket count appropriate - /// for an element count of n. GetRehashRequired(nBucketCount, nElementCount, nElementAdd) - /// determines whether, if the current bucket count is nBucket and the - /// current element count is nElementCount, we need to increase the bucket - /// count. If so, returns pair(true, n), where n is the new - /// bucket count. If not, returns pair(false, ). - /// - /// Currently it is hard-wired that the number of buckets never - /// shrinks. Should we allow RehashPolicy to change that? - /// - /// bCacheHashCode: true if we store the value of the hash - /// function along with the value. This is a time-space tradeoff. - /// Storing it may improve lookup speed by reducing the number of - /// times we need to call the Equal function. - /// - /// bMutableIterators: true if hashtable::iterator is a mutable - /// iterator, false if iterator and const_iterator are both const - /// iterators. This is true for hash_map and hash_multimap, - /// false for hash_set and hash_multiset. - /// - /// bUniqueKeys: true if the return value of hashtable::count(k) - /// is always at most one, false if it may be an arbitrary number. - /// This is true for hash_set and hash_map and is false for - /// hash_multiset and hash_multimap. - /// - /////////////////////////////////////////////////////////////////////// - /// Note: - /// If you want to make a hashtable never increase its bucket usage, - /// call set_max_load_factor with a very high value such as 100000.f. - /// - /// find_as - /// In order to support the ability to have a hashtable of strings but - /// be able to do efficiently lookups via char pointers (i.e. so they - /// aren't converted to string objects), we provide the find_as - /// function. This function allows you to do a find with a key of a - /// type other than the hashtable key type. See the find_as function - /// for more documentation on this. - /// - /// find_by_hash - /// In the interest of supporting fast operations wherever possible, - /// we provide a find_by_hash function which finds a node using its - /// hash code. This is useful for cases where the node's hash is - /// already known, allowing us to avoid a redundant hash operation - /// in the normal find path. - /// - template - class hashtable - : public rehash_base >, - public hash_code_base - { - public: - typedef Key key_type; - typedef Value value_type; - typedef typename ExtractKey::result_type mapped_type; - typedef hash_code_base hash_code_base_type; - typedef typename hash_code_base_type::hash_code_t hash_code_t; - typedef Allocator allocator_type; - typedef Equal key_equal; - typedef ptrdiff_t difference_type; - typedef eastl_size_t size_type; // See config.h for the definition of eastl_size_t, which defaults to uint32_t. - typedef value_type& reference; - typedef const value_type& const_reference; - typedef node_iterator local_iterator; - typedef node_iterator const_local_iterator; - typedef hashtable_iterator iterator; - typedef hashtable_iterator const_iterator; - typedef eastl::reverse_iterator reverse_iterator; - typedef eastl::reverse_iterator const_reverse_iterator; - typedef hash_node node_type; - typedef typename type_select, iterator>::type insert_return_type; - typedef hashtable this_type; - typedef RehashPolicy rehash_policy_type; - typedef ExtractKey extract_key_type; - typedef H1 h1_type; - typedef H2 h2_type; - typedef H h_type; - - using hash_code_base_type::key_eq; - using hash_code_base_type::hash_function; - using hash_code_base_type::mExtractKey; - using hash_code_base_type::get_hash_code; - using hash_code_base_type::bucket_index; - using hash_code_base_type::compare; - using hash_code_base_type::set_code; - - static const bool kCacheHashCode = bCacheHashCode; - - enum - { - kKeyAlignment = EASTL_ALIGN_OF(key_type), - kKeyAlignmentOffset = 0, // To do: Make sure this really is zero for all uses of this template. - kValueAlignment = EASTL_ALIGN_OF(value_type), - kValueAlignmentOffset = 0, // To fix: This offset is zero for sets and >0 for maps. Need to fix this. - kAllocFlagBuckets = 0x00400000 // Flag to allocator which indicates that we are allocating buckets and not nodes. - }; - - protected: - node_type** mpBucketArray; - size_type mnBucketCount; - size_type mnElementCount; - RehashPolicy mRehashPolicy; // To do: Use base class optimization to make this go away. - allocator_type mAllocator; // To do: Use base class optimization to make this go away. - - public: - hashtable(size_type nBucketCount, const H1&, const H2&, const H&, const Equal&, const ExtractKey&, - const allocator_type& allocator = EASTL_HASHTABLE_DEFAULT_ALLOCATOR); - - template - hashtable(FowardIterator first, FowardIterator last, size_type nBucketCount, - const H1&, const H2&, const H&, const Equal&, const ExtractKey&, - const allocator_type& allocator = EASTL_HASHTABLE_DEFAULT_ALLOCATOR); // allocator arg removed because VC7.1 fails on the default arg. To do: Make a second version of this function without a default arg. - - hashtable(const hashtable& x); - ~hashtable(); - - allocator_type& get_allocator(); - void set_allocator(const allocator_type& allocator); - - this_type& operator=(const this_type& x); - - void swap(this_type& x); - - public: - iterator begin() - { - iterator i(mpBucketArray); - if(!i.mpNode) - i.increment_bucket(); - return i; - } - - const_iterator begin() const - { - const_iterator i(mpBucketArray); - if(!i.mpNode) - i.increment_bucket(); - return i; - } - - iterator end() - { return iterator(mpBucketArray + mnBucketCount); } - - const_iterator end() const - { return const_iterator(mpBucketArray + mnBucketCount); } - - local_iterator begin(size_type n) - { return local_iterator(mpBucketArray[n]); } - - local_iterator end(size_type) - { return local_iterator(NULL); } - - const_local_iterator begin(size_type n) const - { return const_local_iterator(mpBucketArray[n]); } - - const_local_iterator end(size_type) const - { return const_local_iterator(NULL); } - - bool empty() const - { return mnElementCount == 0; } - - size_type size() const - { return mnElementCount; } - - size_type bucket_count() const - { return mnBucketCount; } - - size_type bucket_size(size_type n) const - { return (size_type)eastl::distance(begin(n), end(n)); } - - //size_type bucket(const key_type& k) const - // { return bucket_index(k, (hash code here), (uint32_t)mnBucketCount); } - - public: - float load_factor() const - { return (float)mnElementCount / (float)mnBucketCount; } - - // Inherited from the base class. - // Returns the max load factor, which is the load factor beyond - // which we rebuild the container with a new bucket count. - // get_max_load_factor comes from rehash_base. - // float get_max_load_factor() const; - - // Inherited from the base class. - // If you want to make the hashtable never rehash (resize), - // set the max load factor to be a very high number (e.g. 100000.f). - // set_max_load_factor comes from rehash_base. - // void set_max_load_factor(float fMaxLoadFactor); - - /// Generalization of get_max_load_factor. This is an extension that's - /// not present in TR1. - const rehash_policy_type& rehash_policy() const - { return mRehashPolicy; } - - /// Generalization of set_max_load_factor. This is an extension that's - /// not present in TR1. - void rehash_policy(const rehash_policy_type& rehashPolicy); - - public: - - insert_return_type insert(const value_type& value); - iterator insert(const_iterator, const value_type& value); - - template - void insert(InputIterator first, InputIterator last); - - public: - iterator erase(iterator position); - iterator erase(iterator first, iterator last); - reverse_iterator erase(reverse_iterator position); - reverse_iterator erase(reverse_iterator first, reverse_iterator last); - size_type erase(const key_type& k); - - void clear(); - void clear(bool clearBuckets); - void reset(); - void rehash(size_type nBucketCount); - - public: - iterator find(const key_type& key); - const_iterator find(const key_type& key) const; - - /// Implements a find whereby the user supplies a comparison of a different type - /// than the hashtable value_type. A useful case of this is one whereby you have - /// a container of string objects but want to do searches via passing in char pointers. - /// The problem is that without this kind of find, you need to do the expensive operation - /// of converting the char pointer to a string so it can be used as the argument to the - /// find function. - /// - /// Example usage (namespaces omitted for brevity): - /// hash_set hashSet; - /// hashSet.find_as("hello"); // Use default hash and compare. - /// - /// Example usage (note that the predicate uses string as first type and char* as second): - /// hash_set hashSet; - /// hashSet.find_as("hello", hash(), equal_to_2()); - /// - template - iterator find_as(const U& u, UHash uhash, BinaryPredicate predicate); - - template - const_iterator find_as(const U& u, UHash uhash, BinaryPredicate predicate) const; - - template - iterator find_as(const U& u); - - template - const_iterator find_as(const U& u) const; - - /// Implements a find whereby the user supplies the node's hash code. - /// - iterator find_by_hash(hash_code_t c); - const_iterator find_by_hash(hash_code_t c) const; - - size_type count(const key_type& k) const; - - eastl::pair equal_range(const key_type& k); - eastl::pair equal_range(const key_type& k) const; - - public: - bool validate() const; - int validate_iterator(const_iterator i) const; - - protected: - node_type* DoAllocateNode(const value_type& value); - node_type* DoAllocateNodeFromKey(const key_type& key); - void DoFreeNode(node_type* pNode); - void DoFreeNodes(node_type** pBucketArray, size_type); - - node_type** DoAllocateBuckets(size_type n); - void DoFreeBuckets(node_type** pBucketArray, size_type n); - - eastl::pair DoInsertValue(const value_type& value, true_type); - iterator DoInsertValue(const value_type& value, false_type); - - eastl::pair DoInsertKey(const key_type& key, true_type); - iterator DoInsertKey(const key_type& key, false_type); - - void DoRehash(size_type nBucketCount); - node_type* DoFindNode(node_type* pNode, const key_type& k, hash_code_t c) const; - - template - node_type* DoFindNode(node_type* pNode, const U& u, BinaryPredicate predicate) const; - - node_type* DoFindNode(node_type* pNode, hash_code_t c) const; - - }; // class hashtable - - - - - - /////////////////////////////////////////////////////////////////////// - // node_iterator_base - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const node_iterator_base& a, const node_iterator_base& b) - { return a.mpNode == b.mpNode; } - - template - inline bool operator!=(const node_iterator_base& a, const node_iterator_base& b) - { return a.mpNode != b.mpNode; } - - - - - /////////////////////////////////////////////////////////////////////// - // hashtable_iterator_base - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const hashtable_iterator_base& a, const hashtable_iterator_base& b) - { return a.mpNode == b.mpNode; } - - template - inline bool operator!=(const hashtable_iterator_base& a, const hashtable_iterator_base& b) - { return a.mpNode != b.mpNode; } - - - - - /////////////////////////////////////////////////////////////////////// - // hashtable - /////////////////////////////////////////////////////////////////////// - - template - hashtable - ::hashtable(size_type nBucketCount, const H1& h1, const H2& h2, const H& h, - const Eq& eq, const EK& ek, const allocator_type& allocator) - : rehash_base(), - hash_code_base(ek, eq, h1, h2, h), - mnBucketCount(0), - mnElementCount(0), - mRehashPolicy(), - mAllocator(allocator) - { - if(nBucketCount < 2) // If we are starting in an initially empty state, with no memory allocation done. - reset(); - else // Else we are creating a potentially non-empty hashtable... - { - EASTL_ASSERT(nBucketCount < 10000000); - mnBucketCount = (size_type)mRehashPolicy.GetNextBucketCount((uint32_t)nBucketCount); - mpBucketArray = DoAllocateBuckets(mnBucketCount); // mnBucketCount will always be at least 2. - } - } - - - - template - template - hashtable::hashtable(FowardIterator first, FowardIterator last, size_type nBucketCount, - const H1& h1, const H2& h2, const H& h, - const Eq& eq, const EK& ek, const allocator_type& allocator) - : rehash_base(), - hash_code_base(ek, eq, h1, h2, h), - //mnBucketCount(0), // This gets re-assigned below. - mnElementCount(0), - mRehashPolicy(), - mAllocator(allocator) - { - if(nBucketCount < 2) - { - const size_type nElementCount = (size_type)eastl::ht_distance(first, last); - mnBucketCount = (size_type)mRehashPolicy.GetBucketCount((uint32_t)nElementCount); - } - else - { - EASTL_ASSERT(nBucketCount < 10000000); - mnBucketCount = nBucketCount; - } - - mpBucketArray = DoAllocateBuckets(mnBucketCount); // mnBucketCount will always be at least 2. - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - for(; first != last; ++first) - insert(*first); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - clear(); - DoFreeBuckets(mpBucketArray, mnBucketCount); - throw; - } - #endif - } - - - - template - hashtable::hashtable(const this_type& x) - : rehash_base(x), - hash_code_base(x), - mnBucketCount(x.mnBucketCount), - mnElementCount(x.mnElementCount), - mRehashPolicy(x.mRehashPolicy), - mAllocator(x.mAllocator) - { - if(mnElementCount) // If there is anything to copy... - { - mpBucketArray = DoAllocateBuckets(mnBucketCount); // mnBucketCount will be at least 2. - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - for(size_type i = 0; i < x.mnBucketCount; ++i) - { - node_type* pNodeSource = x.mpBucketArray[i]; - node_type** ppNodeDest = mpBucketArray + i; - - while(pNodeSource) - { - *ppNodeDest = DoAllocateNode(pNodeSource->mValue); - copy_code(*ppNodeDest, pNodeSource); - ppNodeDest = &(*ppNodeDest)->mpNext; - pNodeSource = pNodeSource->mpNext; - } - } - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - clear(); - DoFreeBuckets(mpBucketArray, mnBucketCount); - throw; - } - #endif - } - else - { - // In this case, instead of allocate memory and copy nothing from x, - // we reset ourselves to a zero allocation state. - reset(); - } - } - - - - template - inline typename hashtable::allocator_type& - hashtable::get_allocator() - { - return mAllocator; - } - - - - template - inline void hashtable::set_allocator(const allocator_type& allocator) - { - mAllocator = allocator; - } - - - - template - inline typename hashtable::this_type& - hashtable::operator=(const this_type& x) - { - if(this != &x) - { - clear(); - - #if EASTL_ALLOCATOR_COPY_ENABLED - mAllocator = x.mAllocator; - #endif - - insert(x.begin(), x.end()); - } - return *this; - } - - - - template - inline hashtable::~hashtable() - { - clear(); - DoFreeBuckets(mpBucketArray, mnBucketCount); - } - - - - template - typename hashtable::node_type* - hashtable::DoAllocateNode(const value_type& value) - { - node_type* const pNode = (node_type*)allocate_memory(mAllocator, sizeof(node_type), kValueAlignment, kValueAlignmentOffset); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - ::new(&pNode->mValue) value_type(value); - pNode->mpNext = NULL; - return pNode; - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - EASTLFree(mAllocator, pNode, sizeof(node_type)); - throw; - } - #endif - } - - - - template - typename hashtable::node_type* - hashtable::DoAllocateNodeFromKey(const key_type& key) - { - node_type* const pNode = (node_type*)allocate_memory(mAllocator, sizeof(node_type), kValueAlignment, kValueAlignmentOffset); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - ::new(&pNode->mValue) value_type(key); - pNode->mpNext = NULL; - return pNode; - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - EASTLFree(mAllocator, pNode, sizeof(node_type)); - throw; - } - #endif - } - - - - template - inline void hashtable::DoFreeNode(node_type* pNode) - { - pNode->~node_type(); - EASTLFree(mAllocator, pNode, sizeof(node_type)); - } - - - - template - void hashtable::DoFreeNodes(node_type** pNodeArray, size_type n) - { - for(size_type i = 0; i < n; ++i) - { - node_type* pNode = pNodeArray[i]; - while(pNode) - { - node_type* const pTempNode = pNode; - pNode = pNode->mpNext; - DoFreeNode(pTempNode); - } - pNodeArray[i] = NULL; - } - } - - - - template - typename hashtable::node_type** - hashtable::DoAllocateBuckets(size_type n) - { - // We allocate one extra bucket to hold a sentinel, an arbitrary - // non-null pointer. Iterator increment relies on this. - EASTL_ASSERT(n > 1); // We reserve an mnBucketCount of 1 for the shared gpEmptyBucketArray. - EASTL_CT_ASSERT(kAllocFlagBuckets == 0x00400000); // Currently we expect this to be so, because the allocator has a copy of this enum. - node_type** const pBucketArray = (node_type**)EASTLAllocFlags(mAllocator, (n + 1) * sizeof(node_type*), kAllocFlagBuckets); - //eastl::fill(pBucketArray, pBucketArray + n, (node_type*)NULL); - memset(pBucketArray, 0, n * sizeof(node_type*)); - pBucketArray[n] = reinterpret_cast((uintptr_t)~0); - return pBucketArray; - } - - - - template - inline void hashtable::DoFreeBuckets(node_type** pBucketArray, size_type n) - { - // If n <= 1, then pBucketArray is from the shared gpEmptyBucketArray. We don't test - // for pBucketArray == &gpEmptyBucketArray because one library have a different gpEmptyBucketArray - // than another but pass a hashtable to another. So we go by the size. - if(n > 1) - EASTLFree(mAllocator, pBucketArray, (n + 1) * sizeof(node_type*)); // '+1' because DoAllocateBuckets allocates nBucketCount + 1 buckets in order to have a NULL sentinel at the end. - } - - - - template - void hashtable::swap(this_type& x) - { - if(mAllocator == x.mAllocator) // If allocators are equivalent... - { - // We leave mAllocator as-is. - hash_code_base::base_swap(x); // hash_code_base has multiple implementations, so we let them handle the swap. - eastl::swap(mRehashPolicy, x.mRehashPolicy); - eastl::swap(mpBucketArray, x.mpBucketArray); - eastl::swap(mnBucketCount, x.mnBucketCount); - eastl::swap(mnElementCount, x.mnElementCount); - } - else - { - const this_type temp(*this); // Can't call eastl::swap because that would - *this = x; // itself call this member swap function. - x = temp; - } - } - - - template - inline void hashtable::rehash_policy(const rehash_policy_type& rehashPolicy) - { - mRehashPolicy = rehashPolicy; - - const size_type nBuckets = rehashPolicy.GetBucketCount((uint32_t)mnElementCount); - - if(nBuckets > mnBucketCount) - DoRehash(nBuckets); - } - - - - template - inline typename hashtable::iterator - hashtable::find(const key_type& k) - { - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - - node_type* const pNode = DoFindNode(mpBucketArray[n], k, c); - return pNode ? iterator(pNode, mpBucketArray + n) : iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - - template - inline typename hashtable::const_iterator - hashtable::find(const key_type& k) const - { - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - - node_type* const pNode = DoFindNode(mpBucketArray[n], k, c); - return pNode ? const_iterator(pNode, mpBucketArray + n) : const_iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - - template - template - inline typename hashtable::iterator - hashtable::find_as(const U& other, UHash uhash, BinaryPredicate predicate) - { - const hash_code_t c = (hash_code_t)uhash(other); - const size_type n = (size_type)(c % mnBucketCount); // This assumes we are using the mod range policy. - - node_type* const pNode = DoFindNode(mpBucketArray[n], other, predicate); - return pNode ? iterator(pNode, mpBucketArray + n) : iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - - template - template - inline typename hashtable::const_iterator - hashtable::find_as(const U& other, UHash uhash, BinaryPredicate predicate) const - { - const hash_code_t c = (hash_code_t)uhash(other); - const size_type n = (size_type)(c % mnBucketCount); // This assumes we are using the mod range policy. - - node_type* const pNode = DoFindNode(mpBucketArray[n], other, predicate); - return pNode ? const_iterator(pNode, mpBucketArray + n) : const_iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - /// hashtable_find - /// - /// Helper function that defaults to using hash and equal_to_2. - /// This makes it so that by default you don't need to provide these. - /// Note that the default hash functions may not be what you want, though. - /// - /// Example usage. Instead of this: - /// hash_set hashSet; - /// hashSet.find("hello", hash(), equal_to_2()); - /// - /// You can use this: - /// hash_set hashSet; - /// hashtable_find(hashSet, "hello"); - /// - template - inline typename H::iterator hashtable_find(H& hashTable, U u) - { return hashTable.find_as(u, eastl::hash(), eastl::equal_to_2()); } - - template - inline typename H::const_iterator hashtable_find(const H& hashTable, U u) - { return hashTable.find_as(u, eastl::hash(), eastl::equal_to_2()); } - - - - template - template - inline typename hashtable::iterator - hashtable::find_as(const U& other) - { return eastl::hashtable_find(*this, other); } - // VC++ doesn't appear to like the following, though it seems correct to me. - // So we implement the workaround above until we can straighten this out. - //{ return find_as(other, eastl::hash(), eastl::equal_to_2()); } - - - template - template - inline typename hashtable::const_iterator - hashtable::find_as(const U& other) const - { return eastl::hashtable_find(*this, other); } - // VC++ doesn't appear to like the following, though it seems correct to me. - // So we implement the workaround above until we can straighten this out. - //{ return find_as(other, eastl::hash(), eastl::equal_to_2()); } - - - template - inline typename hashtable::iterator - hashtable::find_by_hash(hash_code_t c) - { - const size_type n = (size_type)bucket_index(c, (uint32_t)mnBucketCount); - - node_type* const pNode = DoFindNode(mpBucketArray[n], c); - return pNode ? iterator(pNode, mpBucketArray + n) : iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - template - inline typename hashtable::const_iterator - hashtable::find_by_hash(hash_code_t c) const - { - const size_type n = (size_type)bucket_index(c, (uint32_t)mnBucketCount); - - node_type* const pNode = DoFindNode(mpBucketArray[n], c); - return pNode ? const_iterator(pNode, mpBucketArray + n) : const_iterator(mpBucketArray + mnBucketCount); // iterator(mpBucketArray + mnBucketCount) == end() - } - - - template - typename hashtable::size_type - hashtable::count(const key_type& k) const - { - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - size_type result = 0; - - // To do: Make a specialization for bU (unique keys) == true and take - // advantage of the fact that the count will always be zero or one in that case. - for(node_type* pNode = mpBucketArray[n]; pNode; pNode = pNode->mpNext) - { - if(compare(k, c, pNode)) - ++result; - } - return result; - } - - - - template - eastl::pair::iterator, - typename hashtable::iterator> - hashtable::equal_range(const key_type& k) - { - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - - node_type** head = mpBucketArray + n; - node_type* pNode = DoFindNode(*head, k, c); - - if(pNode) - { - node_type* p1 = pNode->mpNext; - - for(; p1; p1 = p1->mpNext) - { - if(!compare(k, c, p1)) - break; - } - - iterator first(pNode, head); - iterator last(p1, head); - - if(!p1) - last.increment_bucket(); - - return eastl::pair(first, last); - } - - return eastl::pair(iterator(mpBucketArray + mnBucketCount), // iterator(mpBucketArray + mnBucketCount) == end() - iterator(mpBucketArray + mnBucketCount)); - } - - - - - template - eastl::pair::const_iterator, - typename hashtable::const_iterator> - hashtable::equal_range(const key_type& k) const - { - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - node_type** head = mpBucketArray + n; - node_type* pNode = DoFindNode(*head, k, c); - - if(pNode) - { - node_type* p1 = pNode->mpNext; - - for(; p1; p1 = p1->mpNext) - { - if(!compare(k, c, p1)) - break; - } - - const_iterator first(pNode, head); - const_iterator last(p1, head); - - if(!p1) - last.increment_bucket(); - - return eastl::pair(first, last); - } - - return eastl::pair(const_iterator(mpBucketArray + mnBucketCount), // iterator(mpBucketArray + mnBucketCount) == end() - const_iterator(mpBucketArray + mnBucketCount)); - } - - - - template - inline typename hashtable::node_type* - hashtable::DoFindNode(node_type* pNode, const key_type& k, hash_code_t c) const - { - for(; pNode; pNode = pNode->mpNext) - { - if(compare(k, c, pNode)) - return pNode; - } - return NULL; - } - - - - template - template - inline typename hashtable::node_type* - hashtable::DoFindNode(node_type* pNode, const U& other, BinaryPredicate predicate) const - { - for(; pNode; pNode = pNode->mpNext) - { - if(predicate(mExtractKey(pNode->mValue), other)) // Intentionally compare with key as first arg and other as second arg. - return pNode; - } - return NULL; - } - - - - template - inline typename hashtable::node_type* - hashtable::DoFindNode(node_type* pNode, hash_code_t c) const - { - for(; pNode; pNode = pNode->mpNext) - { - if(pNode->mnHashCode == c) - return pNode; - } - return NULL; - } - - - - template - eastl::pair::iterator, bool> - hashtable::DoInsertValue(const value_type& value, true_type) // true_type means bUniqueKeys is true. - { - const key_type& k = mExtractKey(value); - const hash_code_t c = get_hash_code(k); - size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - node_type* const pNode = DoFindNode(mpBucketArray[n], k, c); - - if(pNode == NULL) - { - const eastl::pair bRehash = mRehashPolicy.GetRehashRequired((uint32_t)mnBucketCount, (uint32_t)mnElementCount, (uint32_t)1); - - // Allocate the new node before doing the rehash so that we don't - // do a rehash if the allocation throws. - node_type* const pNodeNew = DoAllocateNode(value); - set_code(pNodeNew, c); // This is a no-op for most hashtables. - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - if(bRehash.first) - { - n = (size_type)bucket_index(k, c, (uint32_t)bRehash.second); - DoRehash(bRehash.second); - } - - EASTL_ASSERT((void**)mpBucketArray != &gpEmptyBucketArray[0]); - pNodeNew->mpNext = mpBucketArray[n]; - mpBucketArray[n] = pNodeNew; - ++mnElementCount; - - return eastl::pair(iterator(pNodeNew, mpBucketArray + n), true); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - DoFreeNode(pNodeNew); - throw; - } - #endif - } - - return eastl::pair(iterator(pNode, mpBucketArray + n), false); - } - - - - template - typename hashtable::iterator - hashtable::DoInsertValue(const value_type& value, false_type) // false_type means bUniqueKeys is false. - { - const eastl::pair bRehash = mRehashPolicy.GetRehashRequired((uint32_t)mnBucketCount, (uint32_t)mnElementCount, (uint32_t)1); - - if(bRehash.first) - DoRehash(bRehash.second); - - const key_type& k = mExtractKey(value); - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - - node_type* const pNodeNew = DoAllocateNode(value); - set_code(pNodeNew, c); // This is a no-op for most hashtables. - - // To consider: Possibly make this insertion not make equal elements contiguous. - // As it stands now, we insert equal values contiguously in the hashtable. - // The benefit is that equal_range can work in a sensible manner and that - // erase(value) can more quickly find equal values. The downside is that - // this insertion operation taking some extra time. How important is it to - // us that equal_range span all equal items? - node_type* const pNodePrev = DoFindNode(mpBucketArray[n], k, c); - - if(pNodePrev == NULL) - { - EASTL_ASSERT((void**)mpBucketArray != &gpEmptyBucketArray[0]); - pNodeNew->mpNext = mpBucketArray[n]; - mpBucketArray[n] = pNodeNew; - } - else - { - pNodeNew->mpNext = pNodePrev->mpNext; - pNodePrev->mpNext = pNodeNew; - } - - ++mnElementCount; - - return iterator(pNodeNew, mpBucketArray + n); - } - - - - template - eastl::pair::iterator, bool> - hashtable::DoInsertKey(const key_type& key, true_type) // true_type means bUniqueKeys is true. - { - const hash_code_t c = get_hash_code(key); - size_type n = (size_type)bucket_index(key, c, (uint32_t)mnBucketCount); - node_type* const pNode = DoFindNode(mpBucketArray[n], key, c); - - if(pNode == NULL) - { - const eastl::pair bRehash = mRehashPolicy.GetRehashRequired((uint32_t)mnBucketCount, (uint32_t)mnElementCount, (uint32_t)1); - - // Allocate the new node before doing the rehash so that we don't - // do a rehash if the allocation throws. - node_type* const pNodeNew = DoAllocateNodeFromKey(key); - set_code(pNodeNew, c); // This is a no-op for most hashtables. - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - if(bRehash.first) - { - n = (size_type)bucket_index(key, c, (uint32_t)bRehash.second); - DoRehash(bRehash.second); - } - - EASTL_ASSERT((void**)mpBucketArray != &gpEmptyBucketArray[0]); - pNodeNew->mpNext = mpBucketArray[n]; - mpBucketArray[n] = pNodeNew; - ++mnElementCount; - - return eastl::pair(iterator(pNodeNew, mpBucketArray + n), true); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - DoFreeNode(pNodeNew); - throw; - } - #endif - } - - return eastl::pair(iterator(pNode, mpBucketArray + n), false); - } - - - - template - typename hashtable::iterator - hashtable::DoInsertKey(const key_type& key, false_type) // false_type means bUniqueKeys is false. - { - const eastl::pair bRehash = mRehashPolicy.GetRehashRequired((uint32_t)mnBucketCount, (uint32_t)mnElementCount, (uint32_t)1); - - if(bRehash.first) - DoRehash(bRehash.second); - - const hash_code_t c = get_hash_code(key); - const size_type n = (size_type)bucket_index(key, c, (uint32_t)mnBucketCount); - - node_type* const pNodeNew = DoAllocateNodeFromKey(key); - set_code(pNodeNew, c); // This is a no-op for most hashtables. - - // To consider: Possibly make this insertion not make equal elements contiguous. - // As it stands now, we insert equal values contiguously in the hashtable. - // The benefit is that equal_range can work in a sensible manner and that - // erase(value) can more quickly find equal values. The downside is that - // this insertion operation taking some extra time. How important is it to - // us that equal_range span all equal items? - node_type* const pNodePrev = DoFindNode(mpBucketArray[n], key, c); - - if(pNodePrev == NULL) - { - EASTL_ASSERT((void**)mpBucketArray != &gpEmptyBucketArray[0]); - pNodeNew->mpNext = mpBucketArray[n]; - mpBucketArray[n] = pNodeNew; - } - else - { - pNodeNew->mpNext = pNodePrev->mpNext; - pNodePrev->mpNext = pNodeNew; - } - - ++mnElementCount; - - return iterator(pNodeNew, mpBucketArray + n); - } - - - - template - typename hashtable::insert_return_type - hashtable::insert(const value_type& value) - { - return DoInsertValue(value, integral_constant()); - } - - - - template - typename hashtable::iterator - hashtable::insert(const_iterator, const value_type& value) - { - // We ignore the first argument (hint iterator). It's not likely to be useful for hashtable containers. - - #ifdef __MWERKS__ // The Metrowerks compiler has a bug. - insert_return_type result = insert(value); - return result.first; // Note by Paul Pedriana while perusing this code: This code will fail to compile when bU is false (i.e. for multiset, multimap). - - #elif defined(__GNUC__) && (__GNUC__ < 3) // If using old GCC (GCC 2.x has a bug which we work around) - EASTL_ASSERT(empty()); // This function cannot return the correct return value on GCC 2.x. Unless, that is, the container is empty. - DoInsertValue(value, integral_constant()); - return begin(); // This is the wrong answer. - #else - insert_return_type result = DoInsertValue(value, integral_constant()); - return result.first; // Note by Paul Pedriana while perusing this code: This code will fail to compile when bU is false (i.e. for multiset, multimap). - #endif - } - - - - template - template - void - hashtable::insert(InputIterator first, InputIterator last) - { - const uint32_t nElementAdd = (uint32_t)eastl::ht_distance(first, last); - const eastl::pair bRehash = mRehashPolicy.GetRehashRequired((uint32_t)mnBucketCount, (uint32_t)mnElementCount, nElementAdd); - - if(bRehash.first) - DoRehash(bRehash.second); - - for(; first != last; ++first) - { - #ifdef __MWERKS__ // The Metrowerks compiler has a bug. - insert(*first); - #else - DoInsertValue(*first, integral_constant()); - #endif - } - } - - - - template - typename hashtable::iterator - hashtable::erase(iterator i) - { - iterator iNext(i); - ++iNext; - - node_type* pNode = i.mpNode; - node_type* pNodeCurrent = *i.mpBucket; - - if(pNodeCurrent == pNode) - *i.mpBucket = pNodeCurrent->mpNext; - else - { - // We have a singly-linked list, so we have no choice but to - // walk down it till we find the node before the node at 'i'. - node_type* pNodeNext = pNodeCurrent->mpNext; - - while(pNodeNext != pNode) - { - pNodeCurrent = pNodeNext; - pNodeNext = pNodeCurrent->mpNext; - } - - pNodeCurrent->mpNext = pNodeNext->mpNext; - } - - DoFreeNode(pNode); - --mnElementCount; - - return iNext; - } - - - - template - inline typename hashtable::iterator - hashtable::erase(iterator first, iterator last) - { - while(first != last) - first = erase(first); - return first; - } - - - - template - typename hashtable::reverse_iterator - hashtable::erase(reverse_iterator position) - { - return reverse_iterator(erase((++position).base())); - } - - - - template - inline typename hashtable::reverse_iterator - hashtable::erase(reverse_iterator first, reverse_iterator last) - { - // Version which erases in order from first to last. - // difference_type i(first.base() - last.base()); - // while(i--) - // first = erase(first); - // return first; - - // Version which erases in order from last to first, but is slightly more efficient: - return reverse_iterator(erase((++last).base(), (++first).base())); - } - - - - template - typename hashtable::size_type - hashtable::erase(const key_type& k) - { - // To do: Reimplement this function to do a single loop and not try to be - // smart about element contiguity. The mechanism here is only a benefit if the - // buckets are heavily overloaded; otherwise this mechanism may be slightly slower. - - const hash_code_t c = get_hash_code(k); - const size_type n = (size_type)bucket_index(k, c, (uint32_t)mnBucketCount); - const size_type nElementCountSaved = mnElementCount; - - node_type** pBucketArray = mpBucketArray + n; - - while(*pBucketArray && !compare(k, c, *pBucketArray)) - pBucketArray = &(*pBucketArray)->mpNext; - - while(*pBucketArray && compare(k, c, *pBucketArray)) - { - node_type* const pNode = *pBucketArray; - *pBucketArray = pNode->mpNext; - DoFreeNode(pNode); - --mnElementCount; - } - - return nElementCountSaved - mnElementCount; - } - - - - template - inline void hashtable::clear() - { - DoFreeNodes(mpBucketArray, mnBucketCount); - mnElementCount = 0; - } - - - - template - inline void hashtable::clear(bool clearBuckets) - { - DoFreeNodes(mpBucketArray, mnBucketCount); - if(clearBuckets) - { - DoFreeBuckets(mpBucketArray, mnBucketCount); - reset(); - } - mnElementCount = 0; - } - - - - template - inline void hashtable::reset() - { - // The reset function is a special extension function which unilaterally - // resets the container to an empty state without freeing the memory of - // the contained objects. This is useful for very quickly tearing down a - // container built into scratch memory. - mnBucketCount = 1; - - #ifdef _MSC_VER - mpBucketArray = (node_type**)&gpEmptyBucketArray[0]; - #else - void* p = &gpEmptyBucketArray[0]; - memcpy(&mpBucketArray, &p, sizeof(mpBucketArray)); // Other compilers implement strict aliasing and casting is thus unsafe. - #endif - - mnElementCount = 0; - mRehashPolicy.mnNextResize = 0; - } - - - - template - inline void hashtable::rehash(size_type nBucketCount) - { - // Note that we unilaterally use the passed in bucket count; we do not attempt migrate it - // up to the next prime number. We leave it at the user's discretion to do such a thing. - DoRehash(nBucketCount); - } - - - - template - void hashtable::DoRehash(size_type nNewBucketCount) - { - node_type** const pBucketArray = DoAllocateBuckets(nNewBucketCount); // nNewBucketCount should always be >= 2. - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - node_type* pNode; - - for(size_type i = 0; i < mnBucketCount; ++i) - { - while((pNode = mpBucketArray[i]) != NULL) // Using '!=' disables compiler warnings. - { - const size_type nNewBucketIndex = (size_type)bucket_index(pNode, (uint32_t)nNewBucketCount); - - mpBucketArray[i] = pNode->mpNext; - pNode->mpNext = pBucketArray[nNewBucketIndex]; - pBucketArray[nNewBucketIndex] = pNode; - } - } - - DoFreeBuckets(mpBucketArray, mnBucketCount); - mnBucketCount = nNewBucketCount; - mpBucketArray = pBucketArray; - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - // A failure here means that a hash function threw an exception. - // We can't restore the previous state without calling the hash - // function again, so the only sensible recovery is to delete everything. - DoFreeNodes(pBucketArray, nNewBucketCount); - DoFreeBuckets(pBucketArray, nNewBucketCount); - DoFreeNodes(mpBucketArray, mnBucketCount); - mnElementCount = 0; - throw; - } - #endif - } - - - template - inline bool hashtable::validate() const - { - // Verify our empty bucket array is unmodified. - if(gpEmptyBucketArray[0] != NULL) - return false; - - if(gpEmptyBucketArray[1] != (void*)uintptr_t(~0)) - return false; - - // Verify that we have at least one bucket. Calculations can - // trigger division by zero exceptions otherwise. - if(mnBucketCount == 0) - return false; - - // Verify that gpEmptyBucketArray is used correctly. - // gpEmptyBucketArray is only used when initially empty. - if((void**)mpBucketArray == &gpEmptyBucketArray[0]) - { - if(mnElementCount) // gpEmptyBucketArray is used only for empty hash tables. - return false; - - if(mnBucketCount != 1) // gpEmptyBucketArray is used exactly an only for mnBucketCount == 1. - return false; - } - else - { - if(mnBucketCount < 2) // Small bucket counts *must* use gpEmptyBucketArray. - return false; - } - - // Verify that the element count matches mnElementCount. - size_type nElementCount = 0; - - for(const_iterator temp = begin(), tempEnd = end(); temp != tempEnd; ++temp) - ++nElementCount; - - if(nElementCount != mnElementCount) - return false; - - // To do: Verify that individual elements are in the expected buckets. - - return true; - } - - - template - int hashtable::validate_iterator(const_iterator i) const - { - // To do: Come up with a more efficient mechanism of doing this. - - for(const_iterator temp = begin(), tempEnd = end(); temp != tempEnd; ++temp) - { - if(temp == i) - return (isf_valid | isf_current | isf_can_dereference); - } - - if(i == end()) - return (isf_valid | isf_current); - - return isf_none; - } - - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const hashtable& a, - const hashtable& b) - { - return (a.size() == b.size()) && eastl::equal(a.begin(), a.end(), b.begin()); - } - - - // Comparing hash tables for less-ness is an odd thing to do. We provide it for - // completeness, though the user is advised to be wary of how they use this. - template - inline bool operator<(const hashtable& a, - const hashtable& b) - { - // This requires hash table elements to support operator<. Since the hash table - // doesn't compare elements via less (it does so via equals), we must use the - // globally defined operator less for the elements. - return eastl::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); - } - - - template - inline bool operator!=(const hashtable& a, - const hashtable& b) - { - return !(a == b); - } - - - template - inline bool operator>(const hashtable& a, - const hashtable& b) - { - return b < a; - } - - - template - inline bool operator<=(const hashtable& a, - const hashtable& b) - { - return !(b < a); - } - - - template - inline bool operator>=(const hashtable& a, - const hashtable& b) - { - return !(a < b); - } - - - template - inline void swap(const hashtable& a, - const hashtable& b) - { - a.swap(b); - } - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/int_to_type_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/int_to_type_rdestl.h deleted file mode 100644 index ee4203c0d87a..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/int_to_type_rdestl.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef RDESTL_INT_TO_TYPE_H -#define RDESTL_INT_TO_TYPE_H - -namespace rde -{ - -/** - * Sample usage: - * void fun(int_to_type) { ... } - * void fun(int_to_type) { ... } - * template void bar() - * { - * fun(int_to_type::is_exact>()) - * } - */ -template -struct int_to_type -{ - enum - { - value = TVal - }; -}; - -} // namespaces - -#endif // #ifndef RDESTL_INT_TO_TYPE_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_eastl.h deleted file mode 100644 index b82c44f59c84..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_eastl.h +++ /dev/null @@ -1,616 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/iterator.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_ITERATOR_H -#define EASTL_ITERATOR_H - - -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif - -#include - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -// If the user has specified that we use std iterator -// categories instead of EASTL iterator categories, -// then #include . -#if EASTL_STD_ITERATOR_CATEGORY_ENABLED - #ifdef _MSC_VER - #pragma warning(push, 0) - #endif - #include - #ifdef _MSC_VER - #pragma warning(pop) - #endif -#endif - - -#ifdef _MSC_VER - #pragma warning(push) // VC++ generates a bogus warning that you cannot code away. - #pragma warning(disable: 4619) // There is no warning number 'number'. - #pragma warning(disable: 4217) // Member template functions cannot be used for copy-assignment or copy-construction. -#elif defined(__SNC__) - #pragma control %push diag - #pragma diag_suppress=187 // Pointless comparison of unsigned integer with zero -#endif - - -namespace eastl -{ - /// iterator_status_flag - /// - /// Defines the validity status of an iterator. This is primarily used for - /// iterator validation in debug builds. These are implemented as OR-able - /// flags (as opposed to mutually exclusive values) in order to deal with - /// the nature of iterator status. In particular, an iterator may be valid - /// but not dereferencable, as in the case with an iterator to container end(). - /// An iterator may be valid but also dereferencable, as in the case with an - /// iterator to container begin(). - /// - enum iterator_status_flag - { - isf_none = 0x00, /// This is called none and not called invalid because it is not strictly the opposite of invalid. - isf_valid = 0x01, /// The iterator is valid, which means it is in the range of [begin, end]. - isf_current = 0x02, /// The iterator is valid and points to the same element it did when created. For example, if an iterator points to vector::begin() but an element is inserted at the front, the iterator is valid but not current. Modification of elements in place do not make iterators non-current. - isf_can_dereference = 0x04 /// The iterator is dereferencable, which means it is in the range of [begin, end). It may or may not be current. - }; - - - - // The following declarations are taken directly from the C++ standard document. - // input_iterator_tag, etc. - // iterator - // iterator_traits - // reverse_iterator - - // Iterator categories - // Every iterator is defined as belonging to one of the iterator categories that - // we define here. These categories come directly from the C++ standard. - #if !EASTL_STD_ITERATOR_CATEGORY_ENABLED // If we are to use our own iterator category definitions... - struct input_iterator_tag { }; - struct output_iterator_tag { }; - struct forward_iterator_tag : public input_iterator_tag { }; - struct bidirectional_iterator_tag : public forward_iterator_tag { }; - struct random_access_iterator_tag : public bidirectional_iterator_tag { }; - struct contiguous_iterator_tag : public random_access_iterator_tag { }; // Extension to the C++ standard. Contiguous ranges are more than random access, they are physically contiguous. - #endif - - - // struct iterator - template - struct iterator - { - typedef Category iterator_category; - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; - }; - - - // struct iterator_traits - template - struct iterator_traits - { - typedef typename Iterator::iterator_category iterator_category; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - }; - - template - struct iterator_traits - { - typedef EASTL_ITC_NS::random_access_iterator_tag iterator_category; // To consider: Change this to contiguous_iterator_tag for the case that - typedef T value_type; // EASTL_ITC_NS is "eastl" instead of "std". - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; - }; - - template - struct iterator_traits - { - typedef EASTL_ITC_NS::random_access_iterator_tag iterator_category; - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef const T* pointer; - typedef const T& reference; - }; - - - - - - /// reverse_iterator - /// - /// From the C++ standard: - /// Bidirectional and random access iterators have corresponding reverse - /// iterator adaptors that iterate through the data structure in the - /// opposite direction. They have the same signatures as the corresponding - /// iterators. The fundamental relation between a reverse iterator and its - /// corresponding iterator i is established by the identity: - /// &*(reverse_iterator(i)) == &*(i - 1). - /// This mapping is dictated by the fact that while there is always a pointer - /// past the end of an array, there might not be a valid pointer before the - /// beginning of an array. - /// - template - class reverse_iterator : public iterator::iterator_category, - typename eastl::iterator_traits::value_type, - typename eastl::iterator_traits::difference_type, - typename eastl::iterator_traits::pointer, - typename eastl::iterator_traits::reference> - { - public: - typedef Iterator iterator_type; - typedef typename eastl::iterator_traits::pointer pointer; - typedef typename eastl::iterator_traits::reference reference; - typedef typename eastl::iterator_traits::difference_type difference_type; - - protected: - Iterator mIterator; - - public: - reverse_iterator() // It's important that we construct mIterator, because if Iterator - : mIterator() { } // is a pointer, there's a difference between doing it and not. - - explicit reverse_iterator(iterator_type i) - : mIterator(i) { } - - reverse_iterator(const reverse_iterator& ri) - : mIterator(ri.mIterator) { } - - template - reverse_iterator(const reverse_iterator& ri) - : mIterator(ri.base()) { } - - // This operator= isn't in the standard, but the the C++ - // library working group has tentatively approved it, as it - // allows const and non-const reverse_iterators to interoperate. - template - reverse_iterator& operator=(const reverse_iterator& ri) - { mIterator = ri.base(); return *this; } - - iterator_type base() const - { return mIterator; } - - reference operator*() const - { - iterator_type i(mIterator); - return *--i; - } - - pointer operator->() const - { return &(operator*()); } - - reverse_iterator& operator++() - { --mIterator; return *this; } - - reverse_iterator operator++(int) - { - reverse_iterator ri(*this); - --mIterator; - return ri; - } - - reverse_iterator& operator--() - { ++mIterator; return *this; } - - reverse_iterator operator--(int) - { - reverse_iterator ri(*this); - ++mIterator; - return ri; - } - - reverse_iterator operator+(difference_type n) const - { return reverse_iterator(mIterator - n); } - - reverse_iterator& operator+=(difference_type n) - { mIterator -= n; return *this; } - - reverse_iterator operator-(difference_type n) const - { return reverse_iterator(mIterator + n); } - - reverse_iterator& operator-=(difference_type n) - { mIterator += n; return *this; } - - reference operator[](difference_type n) const - { return mIterator[-n - 1]; } - }; - - - // The C++ library working group has tentatively approved the usage of two - // template parameters (Iterator1 and Iterator2) in order to allow reverse_iterators - // and const_reverse iterators to be comparable. This is a similar issue to the - // C++ defect report #179 regarding comparison of container iterators and const_iterators. - template - inline bool - operator==(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() == b.base(); } - - - template - inline bool - operator<(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() > b.base(); } - - - template - inline bool - operator!=(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() != b.base(); } - - - template - inline bool - operator>(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() < b.base(); } - - - template - inline bool - operator<=(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() >= b.base(); } - - - template - inline bool - operator>=(const reverse_iterator& a, const reverse_iterator& b) - { return a.base() <= b.base(); } - - - template - inline typename reverse_iterator::difference_type - operator-(const reverse_iterator& a, const reverse_iterator& b) - { return b.base() - a.base(); } - - - template - inline reverse_iterator - operator+(typename reverse_iterator::difference_type n, const reverse_iterator& a) - { return reverse_iterator(a.base() - n); } - - - - - - - - /// back_insert_iterator - /// - /// A back_insert_iterator is simply a class that acts like an iterator but when you - /// assign a value to it, it calls push_back on the container with the value. - /// - template - class back_insert_iterator : public iterator - { - public: - typedef Container container_type; - typedef typename Container::const_reference const_reference; - - protected: - Container& container; - - public: - explicit back_insert_iterator(Container& x) - : container(x) { } - - back_insert_iterator& operator=(const_reference value) - { container.push_back(value); return *this; } - - back_insert_iterator& operator*() - { return *this; } - - back_insert_iterator& operator++() - { return *this; } // This is by design. - - back_insert_iterator operator++(int) - { return *this; } // This is by design. - }; - - - /// back_inserter - /// - /// Creates an instance of a back_insert_iterator. - /// - template - inline back_insert_iterator - back_inserter(Container& x) - { return back_insert_iterator(x); } - - - - - /// front_insert_iterator - /// - /// A front_insert_iterator is simply a class that acts like an iterator but when you - /// assign a value to it, it calls push_front on the container with the value. - /// - template - class front_insert_iterator : public iterator - { - public: - typedef Container container_type; - typedef typename Container::const_reference const_reference; - - protected: - Container& container; - - public: - explicit front_insert_iterator(Container& x) - : container(x) { } - - front_insert_iterator& operator=(const_reference value) - { container.push_front(value); return *this; } - - front_insert_iterator& operator*() - { return *this; } - - front_insert_iterator& operator++() - { return *this; } // This is by design. - - front_insert_iterator operator++(int) - { return *this; } // This is by design. - }; - - - /// front_inserter - /// - /// Creates an instance of a front_insert_iterator. - /// - template - inline front_insert_iterator - front_inserter(Container& x) - { return front_insert_iterator(x); } - - - - - /// insert_iterator - /// - /// An insert_iterator is like an iterator except that when you assign a value to it, - /// the insert_iterator inserts the value into the container and increments the iterator. - /// - /// insert_iterator is an iterator adaptor that functions as an OutputIterator: - /// assignment through an insert_iterator inserts an object into a container. - /// Specifically, if ii is an insert_iterator, then ii keeps track of a container c and - /// an insertion point p; the expression *ii = x performs the insertion c.insert(p, x). - /// - /// If you assign through an insert_iterator several times, then you will be inserting - /// several elements into the underlying container. In the case of a sequence, they will - /// appear at a particular location in the underlying sequence, in the order in which - /// they were inserted: one of the arguments to insert_iterator's constructor is an - /// iterator p, and the new range will be inserted immediately before p. - /// - template - class insert_iterator : public iterator - { - public: - typedef Container container_type; - typedef typename Container::iterator iterator_type; - typedef typename Container::const_reference const_reference; - - protected: - Container& container; - iterator_type it; - - public: - // This assignment operator is defined more to stop compiler warnings (e.g. VC++ C4512) - // than to be useful. However, it does an insert_iterator to be assigned to another - // insert iterator provided that they point to the same container. - insert_iterator& operator=(const insert_iterator& x) - { - EASTL_ASSERT(&x.container == &container); - it = x.it; - return *this; - } - - insert_iterator(Container& x, iterator_type itNew) - : container(x), it(itNew) {} - - insert_iterator& operator=(const_reference value) - { - it = container.insert(it, value); - ++it; - return *this; - } - - insert_iterator& operator*() - { return *this; } - - insert_iterator& operator++() - { return *this; } // This is by design. - - insert_iterator& operator++(int) - { return *this; } // This is by design. - - }; // insert_iterator - - - /// inserter - /// - /// Creates an instance of an insert_iterator. - /// - template - inline eastl::insert_iterator - inserter(Container& x, Iterator i) - { - typedef typename Container::iterator iterator; - return eastl::insert_iterator(x, iterator(i)); - } - - - - - ////////////////////////////////////////////////////////////////////////////////// - /// distance - /// - /// Implements the distance() function. There are two versions, one for - /// random access iterators (e.g. with vector) and one for regular input - /// iterators (e.g. with list). The former is more efficient. - /// - template - inline typename eastl::iterator_traits::difference_type - distance_impl(InputIterator first, InputIterator last, EASTL_ITC_NS::input_iterator_tag) - { - typename eastl::iterator_traits::difference_type n = 0; - - while(first != last) - { - ++first; - ++n; - } - return n; - } - - template - inline typename eastl::iterator_traits::difference_type - distance_impl(RandomAccessIterator first, RandomAccessIterator last, EASTL_ITC_NS::random_access_iterator_tag) - { - return last - first; - } - - // Special version defined so that std C++ iterators can be recognized by - // this function. Unfortunately, this function treats all foreign iterators - // as InputIterators and thus can seriously hamper performance in the case - // of large ranges of bidirectional_iterator_tag iterators. - //template - //inline typename eastl::iterator_traits::difference_type - //distance_impl(InputIterator first, InputIterator last, ...) - //{ - // typename eastl::iterator_traits::difference_type n = 0; - // - // while(first != last) - // { - // ++first; - // ++n; - // } - // return n; - //} - - template - inline typename eastl::iterator_traits::difference_type - distance(InputIterator first, InputIterator last) - { - typedef typename eastl::iterator_traits::iterator_category IC; - - return eastl::distance_impl(first, last, IC()); - } - - - - - ////////////////////////////////////////////////////////////////////////////////// - /// advance - /// - /// Implements the advance() function. There are three versions, one for - /// random access iterators (e.g. with vector), one for bidirectional - /// iterators (list) and one for regular input iterators (e.g. with slist). - /// - template - inline void - advance_impl(InputIterator& i, Distance n, EASTL_ITC_NS::input_iterator_tag) - { - while(n--) - ++i; - } - - template - inline void - advance_impl(BidirectionalIterator& i, Distance n, EASTL_ITC_NS::bidirectional_iterator_tag) - { - if(n > 0) - { - while(n--) - ++i; - } - else - { - while(n++) - --i; - } - } - - template - inline void - advance_impl(RandomAccessIterator& i, Distance n, EASTL_ITC_NS::random_access_iterator_tag) - { - i += n; - } - - // Special version defined so that std C++ iterators can be recognized by - // this function. Unfortunately, this function treats all foreign iterators - // as InputIterators and thus can seriously hamper performance in the case - // of large ranges of bidirectional_iterator_tag iterators. - //template - //inline void - //advance_impl(InputIterator& i, Distance n, ...) - //{ - // while(n--) - // ++i; - //} - - template - inline void - advance(InputIterator& i, Distance n) - { - typedef typename eastl::iterator_traits::iterator_category IC; - - eastl::advance_impl(i, n, IC()); - } - - -} // namespace eastl - - -#if defined(_MSC_VER) - #pragma warning(pop) -#elif defined(__SNC__) - #pragma control %pop diag -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_rdestl.h deleted file mode 100644 index d1bf5ce193b8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/iterator_rdestl.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef RDESTL_ITERATOR_H -#define RDESTL_ITERATOR_H - -#include - -namespace rde -{ - -//----------------------------------------------------------------------------- -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag: public input_iterator_tag {}; -struct bidirectional_iterator_tag: public forward_iterator_tag {}; -struct random_access_iterator_tag: public bidirectional_iterator_tag {}; - -//----------------------------------------------------------------------------- -template -struct iterator_traits -{ - typedef typename IterT::iterator_category iterator_category; -}; - -template -struct iterator_traits -{ - typedef random_access_iterator_tag iterator_category; -}; - -//----------------------------------------------------------------------------- -namespace internal -{ - template RDE_FORCEINLINE - void distance(TIter first, TIter last, TDist& dist, rde::random_access_iterator_tag) - { - dist = TDist(last - first); - } - template RDE_FORCEINLINE - void distance(TIter first, TIter last, TDist& dist, rde::input_iterator_tag) - { - dist = 0; - while (first != last) - { - ++dist; - ++first; - } - } - - template RDE_FORCEINLINE - void advance(TIter& iter, TDist d, rde::random_access_iterator_tag) - { - iter += d; - } - template RDE_FORCEINLINE - void advance(TIter& iter, TDist d, rde::bidirectional_iterator_tag) - { - if (d >= 0) - { - while (d--) - ++iter; - } - else - { - while (d++) - --iter; - } - } - template RDE_FORCEINLINE - void advance(TIter& iter, TDist d, rde::input_iterator_tag) - { - RDE_ASSERT(d >= 0); - while (d--) - ++iter; - } -} // namespace internal -} // namespace rde - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_ITERATOR_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/memory_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/memory_eastl.h deleted file mode 100644 index 6a5160a42c18..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/memory_eastl.h +++ /dev/null @@ -1,687 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/memory.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -// The uninitialized_move function was written by Ryan Ingram. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// This file implements the following functions from the C++ standard that -// are found in the header: -// -// Temporary memory: -// get_temporary_buffer -// return_temporary_buffer -// -// Uninitialized operations: -// These are the same as the copy, fill, and fill_n algorithms, except that -// they *construct* the destination with the source values rather than assign -// the destination with the source values. -// -// uninitialized_copy -// uninitialized_fill -// uninitialized_fill_n -// uninitialized_move - Extention to standard functionality. -// uninitialized_copy_ptr - Extention to standard functionality. -// uninitialized_fill_ptr - Extention to standard functionality. -// uninitialized_fill_n_ptr - Extention to standard functionality. -// uninitialized_copy_fill - Extention to standard functionality. -// uninitialized_fill_copy - Extention to standard functionality. -// uninitialized_copy_copy - Extention to standard functionality. -// -// In-place destructor helpers: -// destruct(T*) -// destruct(first, last) -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_MEMORY_H -#define EASTL_MEMORY_H - - -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4530) // C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc -#endif - - -namespace eastl -{ - - /// EASTL_TEMP_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_TEMP_DEFAULT_NAME - #define EASTL_TEMP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " temp" // Unless the user overrides something, this is "EASTL temp". - #endif - - - /// get_temporary_buffer - /// - /// From the C++ standard, section 20.4.3: - /// 1 Effects: Obtains a pointer to storage sufficient to store up to n adjacent T objects. - /// 2 Returns: A pair containing the buffer's address and capacity (in the units of sizeof(T)), - /// or a pair of 0 values if no storage can be obtained. - /// - /// Note: The return value is space to hold T elements, but no T elements are constructed. - /// - /// Our implementation here differs slightly in that we have alignment, alignmentOffset, and pName arguments. - /// Note that you can use the EASTL_NAME_VAL macro to make names go away in release builds. - /// - /// Example usage: - /// pair pr = get_temporary_buffer(100, 0, 0, EASTL_NAME_VAL("Temp int array")); - /// memset(pr.first, 0, 100 * sizeof(int)); - /// return_temporary_buffer(pr.first); - /// - template - pair get_temporary_buffer(ptrdiff_t n, size_t alignment = 0, size_t alignmentOffset = 0, const char* pName = EASTL_TEMP_DEFAULT_NAME) - { - EASTLAllocatorType allocator(*EASTLAllocatorDefault(), pName); - return eastl::pair(static_cast(EASTLAllocAligned(allocator, n * sizeof(T), alignment, alignmentOffset)), n); - } - - - /// return_temporary_buffer - /// - /// From the C++ standard, section 20.4.3: - /// 3 Effects: Deallocates the buffer to which p points. - /// 4 Requires: The buffer shall have been previously allocated by get_temporary_buffer. - /// - /// Note: This function merely frees space and does not destruct any T elements. - /// - /// Example usage: - /// pair pr = get_temporary_buffer(300); - /// memset(pr.first, 0, 300 * sizeof(int)); - /// return_temporary_buffer(pr.first, pr.second); - /// - template - void return_temporary_buffer(T* p, ptrdiff_t n = 0) - { - EASTLAllocatorType& allocator(*EASTLAllocatorDefault()); - EASTLFree(allocator, p, n * sizeof(T)); - } - - - - /// uninitialized_move - /// - /// uninitialized_move takes a constructed sequence of objects and an - /// uninitialized destination buffer. In the case of any exception thrown - /// while moving the objects, any newly constructed objects are guaranteed - /// to be destructed and the input left fully constructed. - /// - /// In the case where you need to do multiple moves atomically, split the - /// calls into uninitialized_move_start/abort/commit. - /// - /// uninitialized_move_start can possibly throw an exception. If it does, - /// you don't need to do anything. However, if it returns without throwing - /// an exception you need to guarantee that either uninitialize_move_abort - /// or uninitialized_move_commit is called. - /// - /// Both uninitialize_move_abort and uninitialize_move_commit are - /// guaranteed to not throw C++ exceptions. - - template - struct uninitialized_move_impl - { - template - static ForwardIteratorDest do_move_start(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) - { - typedef typename eastl::iterator_traits::value_type value_type; - - #if EASTL_EXCEPTIONS_ENABLED - ForwardIteratorDest origDest(dest); - try - { - for(; first != last; ++first, ++dest) - ::new(&*dest) value_type(*first); - } - catch(...) - { - for(; origDest < dest; ++origDest) - origDest->~value_type(); - throw; - } - #else - for(; first != last; ++first, ++dest) - ::new(&*dest) value_type(*first); - #endif - - return dest; - } - - template - static ForwardIteratorDest do_move_commit(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) //throw() - { - typedef typename eastl::iterator_traits::value_type value_type; - for(; first != last; ++first, ++dest) - first->~value_type(); - - return dest; - } - - template - static ForwardIteratorDest do_move_abort(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) //throw() - { - typedef typename eastl::iterator_traits::value_type value_type; - for(; first != last; ++first, ++dest) - dest->~value_type(); - return dest; - } - }; - - template <> - struct uninitialized_move_impl - { - template - static T* do_move_start(T* first, T* last, T* dest) - { - return (T*)memcpy(dest, first, (size_t)((uintptr_t)last - (uintptr_t)first)) + (last - first); - } - - template - static T* do_move_commit(T* first, T* last, T* dest) - { - return dest + (last - first); - } - - template - static T* do_move_abort(T* first, T* last, T* dest) - { - return dest + (last - first); - } - }; - - - /// uninitialized_move_start, uninitialized_move_commit, uninitialized_move_abort - /// - /// After calling uninitialized_move_start, if it doesn't throw an exception, - /// both the source and destination iterators point to undefined data. If it - /// does throw an exception, the destination remains uninitialized and the source - /// is as it was before. - /// - /// In order to make the iterators valid again you need to call either uninitialized_move_abort - /// or uninitialized_move_commit. The abort call makes the original source - /// iterator valid again, and commit makes the destination valid. Both abort - /// and commit are guaranteed to not throw C++ exceptions. - /// - /// Example usage: - /// iterator dest2 = uninitialized_move_start(first, last, dest); - /// try { - /// // some code here that might throw an exception - /// } - /// catch(...) - /// { - /// uninitialized_move_abort(first, last, dest); - /// throw; - /// } - /// uninitialized_move_commit(first, last, dest); - /// - template - inline ForwardIteratorDest uninitialized_move_start(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) - { - typedef typename eastl::iterator_traits::iterator_category IC; - typedef typename eastl::iterator_traits::value_type value_type_input; - typedef typename eastl::iterator_traits::value_type value_type_output; - - const bool bHasTrivialMove = type_and::value, - is_pointer::value, - is_pointer::value, - is_same::value>::value; - - return eastl::uninitialized_move_impl::do_move_start(first, last, dest); - } - - template - inline ForwardIteratorDest uninitialized_move_commit(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) - { - typedef typename eastl::iterator_traits::iterator_category IC; - typedef typename eastl::iterator_traits::value_type value_type_input; - typedef typename eastl::iterator_traits::value_type value_type_output; - - const bool bHasTrivialMove = type_and::value, - is_pointer::value, - is_pointer::value, - is_same::value>::value; - - return eastl::uninitialized_move_impl::do_move_commit(first, last, dest); - } - - template - inline ForwardIteratorDest uninitialized_move_abort(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) - { - typedef typename eastl::iterator_traits::iterator_category IC; - typedef typename eastl::iterator_traits::value_type value_type_input; - typedef typename eastl::iterator_traits::value_type value_type_output; - - const bool bHasTrivialMove = type_and::value, - is_pointer::value, - is_pointer::value, - is_same::value>::value; - - return eastl::uninitialized_move_impl::do_move_abort(first, last, dest); - } - - /// uninitialized_move - /// - /// uninitialized_move takes a constructed sequence of objects and an - /// uninitialized destination buffer. In the case of any exception thrown - /// while moving the objects, any newly constructed objects are guaranteed - /// to be destructed and the input left as it was before. - /// - template - inline ForwardIteratorDest uninitialized_move(ForwardIterator first, ForwardIterator last, ForwardIteratorDest dest) - { - ForwardIteratorDest result = uninitialized_move_start(first, last, dest); - uninitialized_move_commit(first, last, dest); - - return result; - } - - - - - - // uninitialized_copy - // - template - inline ForwardIterator uninitialized_copy_impl(InputIterator first, InputIterator last, ForwardIterator dest, true_type) - { - return eastl::copy(first, last, dest); // The copy() in turn will use memcpy for POD types. - } - - template - inline ForwardIterator uninitialized_copy_impl(InputIterator first, InputIterator last, ForwardIterator dest, false_type) - { - typedef typename eastl::iterator_traits::value_type value_type; - ForwardIterator currentDest(dest); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - for(; first != last; ++first, ++currentDest) - ::new(&*currentDest) value_type(*first); - } - catch(...) - { - for(; dest < currentDest; ++dest) - dest->~value_type(); - throw; - } - #else - for(; first != last; ++first, ++currentDest) - ::new(&*currentDest) value_type(*first); - #endif - - return currentDest; - } - - /// uninitialized_copy - /// - /// Copies a source range to a destination, copy-constructing the destination with - /// the source values (and not *assigning* the destination with the source values). - /// Returns the end of the destination range (i.e. dest + (last - first)). - /// - /// Declaration: - /// template - /// ForwardIterator uninitialized_copy(InputIterator sourceFirst, InputIterator sourceLast, ForwardIterator destination); - /// - /// Example usage: - /// SomeClass* pArray = malloc(10 * sizeof(SomeClass)); - /// uninitialized_copy(pSourceDataBegin, pSourceDataBegin + 10, pArray); - /// - template - inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result) - { - typedef typename eastl::iterator_traits::value_type value_type; - - // Note: has_trivial_assign isn't actually the right thing to use here, as it - // refers to assignment as opposed to construction. Bug Paul Pedriana if this - // is becoming a problem. In the meantime, this code assumes that if has_trivial_assign - // is present for a type, then has_trivial_copy is as well. - return uninitialized_copy_impl(first, last, result, has_trivial_assign()); - } - - /// uninitialized_copy_ptr - /// - /// This is a specialization of uninitialized_copy for iterators that are pointers. - /// It exists so that we can declare a value_type for the iterator, which you - /// can't do with a pointer by itself. - /// - template - inline Result uninitialized_copy_ptr(First first, Last last, Result result) - { - typedef typename eastl::iterator_traits >::value_type value_type; - const generic_iterator i(uninitialized_copy_impl(generic_iterator(first), - generic_iterator(last), - generic_iterator(result), - has_trivial_assign())); - return i.base(); - } - - - - - // uninitialized_fill - // - template - inline void uninitialized_fill_impl(ForwardIterator first, ForwardIterator last, const T& value, true_type) - { - eastl::fill(first, last, value); - } - - template - void uninitialized_fill_impl(ForwardIterator first, ForwardIterator last, const T& value, false_type) - { - typedef typename eastl::iterator_traits::value_type value_type; - ForwardIterator currentDest(first); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - for(; currentDest != last; ++currentDest) - ::new(&*currentDest) value_type(value); - } - catch(...) - { - for(; first < currentDest; ++first) - first->~value_type(); - throw; - } - #else - for(; currentDest != last; ++currentDest) - ::new(&*currentDest) value_type(value); - #endif - } - - /// uninitialized_fill - /// - /// Copy-constructs the elements in the destination range with the given input value. - /// Returns void. It wouldn't be useful to return the end of the destination range, - /// as that is the same as the 'last' input parameter. - /// - /// Declaration: - /// template - /// void uninitialized_fill(ForwardIterator destinationFirst, ForwardIterator destinationLast, const T& value); - /// - template - inline void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& value) - { - typedef typename eastl::iterator_traits::value_type value_type; - uninitialized_fill_impl(first, last, value, has_trivial_assign()); - } - - /// uninitialized_fill_ptr - /// - /// This is a specialization of uninitialized_fill for iterators that are pointers. - /// It exists so that we can declare a value_type for the iterator, which you - /// can't do with a pointer by itself. - /// - template - inline void uninitialized_fill_ptr(T* first, T* last, const T& value) - { - typedef typename eastl::iterator_traits >::value_type value_type; - uninitialized_fill_impl(generic_iterator(first), generic_iterator(last), value, has_trivial_assign()); - } - - - - - // uninitialized_fill_n - // - template - inline void uninitialized_fill_n_impl(ForwardIterator first, Count n, const T& value, true_type) - { - eastl::fill_n(first, n, value); - } - - template - void uninitialized_fill_n_impl(ForwardIterator first, Count n, const T& value, false_type) - { - typedef typename eastl::iterator_traits::value_type value_type; - ForwardIterator currentDest(first); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - for(; n > 0; --n, ++currentDest) - ::new(&*currentDest) value_type(value); - } - catch(...) - { - for(; first < currentDest; ++first) - first->~value_type(); - throw; - } - #else - for(; n > 0; --n, ++currentDest) - ::new(&*currentDest) value_type(value); - #endif - } - - /// uninitialized_fill_n - /// - /// Copy-constructs the range of [first, first + n) with the given input value. - /// Returns void as per the C++ standard, though returning the end input iterator - /// value may be of use. - /// - /// Declaration: - /// template - /// void uninitialized_fill_n(ForwardIterator destination, Count n, const T& value); - /// - template - inline void uninitialized_fill_n(ForwardIterator first, Count n, const T& value) - { - typedef typename eastl::iterator_traits::value_type value_type; - uninitialized_fill_n_impl(first, n, value, has_trivial_assign()); - } - - /// uninitialized_fill_n_ptr - /// - /// This is a specialization of uninitialized_fill_n for iterators that are pointers. - /// It exists so that we can declare a value_type for the iterator, which you - /// can't do with a pointer by itself. - /// - template - inline void uninitialized_fill_n_ptr(T* first, Count n, const T& value) - { - typedef typename eastl::iterator_traits >::value_type value_type; - uninitialized_fill_n_impl(generic_iterator(first), n, value, has_trivial_assign()); - } - - - - - /// uninitialized_copy_fill - /// - /// Copies [first1, last1) into [first2, first2 + (last1 - first1)) then - /// fills [first2 + (last1 - first1), last2) with value. - /// - template - inline void uninitialized_copy_fill(InputIterator first1, InputIterator last1, - ForwardIterator first2, ForwardIterator last2, const T& value) - { - const ForwardIterator mid(eastl::uninitialized_copy(first1, last1, first2)); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - eastl::uninitialized_fill(mid, last2, value); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - for(; first2 < mid; ++first2) - first2->~value_type(); - throw; - } - #endif - } - - - - - - /// uninitialized_fill_copy - /// - /// Fills [result, mid) with value then copies [first, last) into [mid, mid + (last - first)). - /// - template - inline ForwardIterator - uninitialized_fill_copy(ForwardIterator result, ForwardIterator mid, const T& value, InputIterator first, InputIterator last) - { - eastl::uninitialized_fill(result, mid, value); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - return eastl::uninitialized_copy(first, last, mid); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - for(; result < mid; ++result) - result->~value_type(); - throw; - } - #endif - } - - - - /// uninitialized_copy_copy - /// - /// Copies [first1, last1) into [result, result + (last1 - first1)) then - /// copies [first2, last2) into [result, result + (last1 - first1) + (last2 - first2)). - /// - template - inline ForwardIterator - uninitialized_copy_copy(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - ForwardIterator result) - { - const ForwardIterator mid(eastl::uninitialized_copy(first1, last1, result)); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - return eastl::uninitialized_copy(first2, last2, mid); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - for(; result < mid; ++result) - result->~value_type(); - throw; - } - #endif - } - - - - /// destruct - /// - /// Calls the destructor of a given object. - /// - /// Note that we don't have a specialized version of this for objects - /// with trivial destructors, such as integers. This is because the - /// compiler can already see in our version here that the destructor - /// is a no-op. - /// - template - inline void destruct(T* p) - { - p->~T(); - } - - - - // destruct(first, last) - // - template - inline void destruct_impl(ForwardIterator /*first*/, ForwardIterator /*last*/, true_type) // true means the type has a trivial destructor. - { - // Empty. The type has a trivial destructor. - } - - template - inline void destruct_impl(ForwardIterator first, ForwardIterator last, false_type) // false means the type has a significant destructor. - { - typedef typename eastl::iterator_traits::value_type value_type; - - for(; first != last; ++first) - (*first).~value_type(); - } - - /// destruct - /// - /// Calls the destructor on a range of objects. - /// - /// We have a specialization for objects with trivial destructors, such as - /// PODs. In this specialization the destruction of the range is a no-op. - /// - template - inline void destruct(ForwardIterator first, ForwardIterator last) - { - typedef typename eastl::iterator_traits::value_type value_type; - destruct_impl(first, last, eastl::has_trivial_destructor()); - } - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/pair_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/pair_rdestl.h deleted file mode 100644 index 6e162ccf79ed..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/pair_rdestl.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef RDESTL_PAIR_H -#define RDESTL_PAIR_H - -#include - -namespace rde -{ -//============================================================================= -template -struct pair -{ - typedef T1 first_type; - typedef T2 second_type; - - pair() {/**/} - pair(const T1& a, const T2& b): first(a), second(b) {/**/} - explicit pair(const T1& a): first(a) {/**/} - - pair(const pair& rhs) : first(rhs.first), second(rhs.second) {/**/} - - pair& operator=(const pair& rhs) - { - first = rhs.first; - second = rhs.second; - return *this; - } - - T1 first; - T2 second; -}; - -//============================================================================= -// Pair is POD if every element is POD/fundamental -template struct is_pod > -{ - enum { value = (is_pod::value || is_fundamental::value) && - (is_pod::value || is_fundamental::value) }; -}; - -//----------------------------------------------------------------------------- -template -pair make_pair(const T1& a, const T2& b) -{ - return pair(a, b); -} - -} - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_PAIR_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/rdestl_common.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/rdestl_common.h deleted file mode 100644 index b130e6c5b638..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/rdestl_common.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef RDESTL_COMMON_H -#define RDESTL_COMMON_H - -#ifndef RDESTL_STANDALONE -# define RDESTL_STANDALONE 1 -#endif - -#if RDESTL_STANDALONE -# ifdef _MSC_VER -# include -# include -# define RDE_FORCEINLINE __forceinline -# else -# include -# include -# include -# define RDE_FORCEINLINE inline -# endif - -# ifdef _DEBUG -# undef RDE_DEBUG -# define RDE_DEBUG 1 -# endif - -# define RDE_ASSERT assert - - namespace rde - { - // # Meh. MSVC doesnt seem to have - // @todo Fixes to make this portable. - typedef unsigned char uint8; - typedef unsigned short uint16; - typedef signed long int32; - typedef unsigned long uint32; - #ifdef _MSC_VER - typedef unsigned __int64 uint64; - #else - typedef unsigned long long uint64; - #endif - namespace Sys - { - RDE_FORCEINLINE void MemCpy(void* to, const void* from, size_t bytes) - { - memcpy(to, from, bytes); - } - RDE_FORCEINLINE void MemMove(void* to, const void* from, size_t bytes) - { - memmove(to, from, bytes); - } - RDE_FORCEINLINE void MemSet(void* buf, unsigned char value, size_t bytes) - { - memset(buf, value, bytes); - } - } // sys - } -#else -# include "core/RdeAssert.h" -# include "core/System.h" -#endif - -namespace rde -{ -enum e_noinitialize -{ - noinitialize -}; -} - -#endif // #ifndef RDESTL_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.cpp deleted file mode 100644 index cb4cdaff27c9..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/red_black_tree.cpp -// -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// The tree insert and erase functions below are based on the original -// HP STL tree functions. Use of these functions was been approved by -// EA legal on November 4, 2005 and the approval documentation is available -// from the EASTL maintainer or from the EA legal deparatment on request. -// -// Copyright (c) 1994 -// Hewlett-Packard Company -// -// Permission to use, copy, modify, distribute and sell this software -// and its documentation for any purpose is hereby granted without fee, -// provided that the above copyright notice appear in all copies and -// that both that copyright notice and this permission notice appear -// in supporting documentation. Hewlett-Packard Company makes no -// representations about the suitability of this software for any -// purpose. It is provided "as is" without express or implied warranty. -/////////////////////////////////////////////////////////////////////////////// - - - - -#include -#include -#include - - - -namespace eastl -{ - // Forward declarations - rbtree_node_base* RBTreeRotateLeft(rbtree_node_base* pNode, rbtree_node_base* pNodeRoot); - rbtree_node_base* RBTreeRotateRight(rbtree_node_base* pNode, rbtree_node_base* pNodeRoot); - - - - /// RBTreeIncrement - /// Returns the next item in a sorted red-black tree. - /// - EASTL_API rbtree_node_base* RBTreeIncrement(const rbtree_node_base* pNode) - { - if(pNode->mpNodeRight) - { - pNode = pNode->mpNodeRight; - - while(pNode->mpNodeLeft) - pNode = pNode->mpNodeLeft; - } - else - { - rbtree_node_base* pNodeTemp = pNode->mpNodeParent; - - while(pNode == pNodeTemp->mpNodeRight) - { - pNode = pNodeTemp; - pNodeTemp = pNodeTemp->mpNodeParent; - } - - if(pNode->mpNodeRight != pNodeTemp) - pNode = pNodeTemp; - } - - return const_cast(pNode); - } - - - - /// RBTreeIncrement - /// Returns the previous item in a sorted red-black tree. - /// - EASTL_API rbtree_node_base* RBTreeDecrement(const rbtree_node_base* pNode) - { - if((pNode->mpNodeParent->mpNodeParent == pNode) && (pNode->mColor == kRBTreeColorRed)) - return pNode->mpNodeRight; - else if(pNode->mpNodeLeft) - { - rbtree_node_base* pNodeTemp = pNode->mpNodeLeft; - - while(pNodeTemp->mpNodeRight) - pNodeTemp = pNodeTemp->mpNodeRight; - - return pNodeTemp; - } - - rbtree_node_base* pNodeTemp = pNode->mpNodeParent; - - while(pNode == pNodeTemp->mpNodeLeft) - { - pNode = pNodeTemp; - pNodeTemp = pNodeTemp->mpNodeParent; - } - - return const_cast(pNodeTemp); - } - - - - /// RBTreeGetBlackCount - /// Counts the number of black nodes in an red-black tree, from pNode down to the given bottom node. - /// We don't count red nodes because red-black trees don't really care about - /// red node counts; it is black node counts that are significant in the - /// maintenance of a balanced tree. - /// - EASTL_API size_t RBTreeGetBlackCount(const rbtree_node_base* pNodeTop, const rbtree_node_base* pNodeBottom) - { - size_t nCount = 0; - - for(; pNodeBottom; pNodeBottom = pNodeBottom->mpNodeParent) - { - if(pNodeBottom->mColor == kRBTreeColorBlack) - ++nCount; - - if(pNodeBottom == pNodeTop) - break; - } - - return nCount; - } - - - /// RBTreeRotateLeft - /// Does a left rotation about the given node. - /// If you want to understand tree rotation, any book on algorithms will - /// discussion the topic in good detail. - rbtree_node_base* RBTreeRotateLeft(rbtree_node_base* pNode, rbtree_node_base* pNodeRoot) - { - rbtree_node_base* const pNodeTemp = pNode->mpNodeRight; - - pNode->mpNodeRight = pNodeTemp->mpNodeLeft; - - if(pNodeTemp->mpNodeLeft) - pNodeTemp->mpNodeLeft->mpNodeParent = pNode; - pNodeTemp->mpNodeParent = pNode->mpNodeParent; - - if(pNode == pNodeRoot) - pNodeRoot = pNodeTemp; - else if(pNode == pNode->mpNodeParent->mpNodeLeft) - pNode->mpNodeParent->mpNodeLeft = pNodeTemp; - else - pNode->mpNodeParent->mpNodeRight = pNodeTemp; - - pNodeTemp->mpNodeLeft = pNode; - pNode->mpNodeParent = pNodeTemp; - - return pNodeRoot; - } - - - - /// RBTreeRotateRight - /// Does a right rotation about the given node. - /// If you want to understand tree rotation, any book on algorithms will - /// discussion the topic in good detail. - rbtree_node_base* RBTreeRotateRight(rbtree_node_base* pNode, rbtree_node_base* pNodeRoot) - { - rbtree_node_base* const pNodeTemp = pNode->mpNodeLeft; - - pNode->mpNodeLeft = pNodeTemp->mpNodeRight; - - if(pNodeTemp->mpNodeRight) - pNodeTemp->mpNodeRight->mpNodeParent = pNode; - pNodeTemp->mpNodeParent = pNode->mpNodeParent; - - if(pNode == pNodeRoot) - pNodeRoot = pNodeTemp; - else if(pNode == pNode->mpNodeParent->mpNodeRight) - pNode->mpNodeParent->mpNodeRight = pNodeTemp; - else - pNode->mpNodeParent->mpNodeLeft = pNodeTemp; - - pNodeTemp->mpNodeRight = pNode; - pNode->mpNodeParent = pNodeTemp; - - return pNodeRoot; - } - - - - - /// RBTreeInsert - /// Insert a node into the tree and rebalance the tree as a result of the - /// disturbance the node introduced. - /// - EASTL_API void RBTreeInsert(rbtree_node_base* pNode, - rbtree_node_base* pNodeParent, - rbtree_node_base* pNodeAnchor, - RBTreeSide insertionSide) - { - rbtree_node_base*& pNodeRootRef = pNodeAnchor->mpNodeParent; - - // Initialize fields in new node to insert. - pNode->mpNodeParent = pNodeParent; - pNode->mpNodeRight = NULL; - pNode->mpNodeLeft = NULL; - pNode->mColor = kRBTreeColorRed; - - // Insert the node. - if(insertionSide == kRBTreeSideLeft) - { - pNodeParent->mpNodeLeft = pNode; // Also makes (leftmost = pNode) when (pNodeParent == pNodeAnchor) - - if(pNodeParent == pNodeAnchor) - { - pNodeAnchor->mpNodeParent = pNode; - pNodeAnchor->mpNodeRight = pNode; - } - else if(pNodeParent == pNodeAnchor->mpNodeLeft) - pNodeAnchor->mpNodeLeft = pNode; // Maintain leftmost pointing to min node - } - else - { - pNodeParent->mpNodeRight = pNode; - - if(pNodeParent == pNodeAnchor->mpNodeRight) - pNodeAnchor->mpNodeRight = pNode; // Maintain rightmost pointing to max node - } - - // Rebalance the tree. - while((pNode != pNodeRootRef) && (pNode->mpNodeParent->mColor == kRBTreeColorRed)) - { - rbtree_node_base* const pNodeParentParent = pNode->mpNodeParent->mpNodeParent; - - if(pNode->mpNodeParent == pNodeParentParent->mpNodeLeft) - { - rbtree_node_base* const pNodeTemp = pNodeParentParent->mpNodeRight; - - if(pNodeTemp && (pNodeTemp->mColor == kRBTreeColorRed)) - { - pNode->mpNodeParent->mColor = kRBTreeColorBlack; - pNodeTemp->mColor = kRBTreeColorBlack; - pNodeParentParent->mColor = kRBTreeColorRed; - pNode = pNodeParentParent; - } - else - { - if(pNode == pNode->mpNodeParent->mpNodeRight) - { - pNode = pNode->mpNodeParent; - pNodeRootRef = RBTreeRotateLeft(pNode, pNodeRootRef); - } - - pNode->mpNodeParent->mColor = kRBTreeColorBlack; - pNodeParentParent->mColor = kRBTreeColorRed; - pNodeRootRef = RBTreeRotateRight(pNodeParentParent, pNodeRootRef); - } - } - else - { - rbtree_node_base* const pNodeTemp = pNodeParentParent->mpNodeLeft; - - if(pNodeTemp && (pNodeTemp->mColor == kRBTreeColorRed)) - { - pNode->mpNodeParent->mColor = kRBTreeColorBlack; - pNodeTemp->mColor = kRBTreeColorBlack; - pNodeParentParent->mColor = kRBTreeColorRed; - pNode = pNodeParentParent; - } - else - { - if(pNode == pNode->mpNodeParent->mpNodeLeft) - { - pNode = pNode->mpNodeParent; - pNodeRootRef = RBTreeRotateRight(pNode, pNodeRootRef); - } - - pNode->mpNodeParent->mColor = kRBTreeColorBlack; - pNodeParentParent->mColor = kRBTreeColorRed; - pNodeRootRef = RBTreeRotateLeft(pNodeParentParent, pNodeRootRef); - } - } - } - - pNodeRootRef->mColor = kRBTreeColorBlack; - - } // RBTreeInsert - - - - - /// RBTreeErase - /// Erase a node from the tree. - /// - EASTL_API void RBTreeErase(rbtree_node_base* pNode, rbtree_node_base* pNodeAnchor) - { - rbtree_node_base*& pNodeRootRef = pNodeAnchor->mpNodeParent; - rbtree_node_base*& pNodeLeftmostRef = pNodeAnchor->mpNodeLeft; - rbtree_node_base*& pNodeRightmostRef = pNodeAnchor->mpNodeRight; - rbtree_node_base* pNodeSuccessor = pNode; - rbtree_node_base* pNodeChild = NULL; - rbtree_node_base* pNodeChildParent = NULL; - - if(pNodeSuccessor->mpNodeLeft == NULL) // pNode has at most one non-NULL child. - pNodeChild = pNodeSuccessor->mpNodeRight; // pNodeChild might be null. - else if(pNodeSuccessor->mpNodeRight == NULL) // pNode has exactly one non-NULL child. - pNodeChild = pNodeSuccessor->mpNodeLeft; // pNodeChild is not null. - else - { - // pNode has two non-null children. Set pNodeSuccessor to pNode's successor. pNodeChild might be NULL. - pNodeSuccessor = pNodeSuccessor->mpNodeRight; - - while(pNodeSuccessor->mpNodeLeft) - pNodeSuccessor = pNodeSuccessor->mpNodeLeft; - - pNodeChild = pNodeSuccessor->mpNodeRight; - } - - // Here we remove pNode from the tree and fix up the node pointers appropriately around it. - if(pNodeSuccessor == pNode) // If pNode was a leaf node (had both NULL children)... - { - pNodeChildParent = pNodeSuccessor->mpNodeParent; // Assign pNodeReplacement's parent. - - if(pNodeChild) - pNodeChild->mpNodeParent = pNodeSuccessor->mpNodeParent; - - if(pNode == pNodeRootRef) // If the node being deleted is the root node... - pNodeRootRef = pNodeChild; // Set the new root node to be the pNodeReplacement. - else - { - if(pNode == pNode->mpNodeParent->mpNodeLeft) // If pNode is a left node... - pNode->mpNodeParent->mpNodeLeft = pNodeChild; // Make pNode's replacement node be on the same side. - else - pNode->mpNodeParent->mpNodeRight = pNodeChild; - // Now pNode is disconnected from the bottom of the tree (recall that in this pathway pNode was determined to be a leaf). - } - - if(pNode == pNodeLeftmostRef) // If pNode is the tree begin() node... - { - // Because pNode is the tree begin(), pNode->mpNodeLeft must be NULL. - // Here we assign the new begin() (first node). - if(pNode->mpNodeRight) - pNodeLeftmostRef = RBTreeGetMinChild(pNodeChild); - else - pNodeLeftmostRef = pNode->mpNodeParent; // This makes (pNodeLeftmostRef == end()) if (pNode == root node) - } - - if(pNode == pNodeRightmostRef) // If pNode is the tree last (rbegin()) node... - { - // Because pNode is the tree rbegin(), pNode->mpNodeRight must be NULL. - // Here we assign the new rbegin() (last node) - if(pNode->mpNodeLeft) - pNodeRightmostRef = RBTreeGetMaxChild(pNodeChild); - else // pNodeChild == pNode->mpNodeLeft - pNodeRightmostRef = pNode->mpNodeParent; // makes pNodeRightmostRef == &mAnchor if pNode == pNodeRootRef - } - } - else // else (pNodeSuccessor != pNode) - { - // Relink pNodeSuccessor in place of pNode. pNodeSuccessor is pNode's successor. - // We specifically set pNodeSuccessor to be on the right child side of pNode, so fix up the left child side. - pNode->mpNodeLeft->mpNodeParent = pNodeSuccessor; - pNodeSuccessor->mpNodeLeft = pNode->mpNodeLeft; - - if(pNodeSuccessor == pNode->mpNodeRight) // If pNode's successor was at the bottom of the tree... (yes that's effectively what this statement means) - pNodeChildParent = pNodeSuccessor; // Assign pNodeReplacement's parent. - else - { - pNodeChildParent = pNodeSuccessor->mpNodeParent; - - if(pNodeChild) - pNodeChild->mpNodeParent = pNodeChildParent; - - pNodeChildParent->mpNodeLeft = pNodeChild; - - pNodeSuccessor->mpNodeRight = pNode->mpNodeRight; - pNode->mpNodeRight->mpNodeParent = pNodeSuccessor; - } - - if(pNode == pNodeRootRef) - pNodeRootRef = pNodeSuccessor; - else if(pNode == pNode->mpNodeParent->mpNodeLeft) - pNode->mpNodeParent->mpNodeLeft = pNodeSuccessor; - else - pNode->mpNodeParent->mpNodeRight = pNodeSuccessor; - - // Now pNode is disconnected from the tree. - - pNodeSuccessor->mpNodeParent = pNode->mpNodeParent; - eastl::swap(pNodeSuccessor->mColor, pNode->mColor); - } - - // Here we do tree balancing as per the conventional red-black tree algorithm. - if(pNode->mColor == kRBTreeColorBlack) - { - while((pNodeChild != pNodeRootRef) && ((pNodeChild == NULL) || (pNodeChild->mColor == kRBTreeColorBlack))) - { - if(pNodeChild == pNodeChildParent->mpNodeLeft) - { - rbtree_node_base* pNodeTemp = pNodeChildParent->mpNodeRight; - - if(pNodeTemp->mColor == kRBTreeColorRed) - { - pNodeTemp->mColor = kRBTreeColorBlack; - pNodeChildParent->mColor = kRBTreeColorRed; - pNodeRootRef = RBTreeRotateLeft(pNodeChildParent, pNodeRootRef); - pNodeTemp = pNodeChildParent->mpNodeRight; - } - - if(((pNodeTemp->mpNodeLeft == NULL) || (pNodeTemp->mpNodeLeft->mColor == kRBTreeColorBlack)) && - ((pNodeTemp->mpNodeRight == NULL) || (pNodeTemp->mpNodeRight->mColor == kRBTreeColorBlack))) - { - pNodeTemp->mColor = kRBTreeColorRed; - pNodeChild = pNodeChildParent; - pNodeChildParent = pNodeChildParent->mpNodeParent; - } - else - { - if((pNodeTemp->mpNodeRight == NULL) || (pNodeTemp->mpNodeRight->mColor == kRBTreeColorBlack)) - { - pNodeTemp->mpNodeLeft->mColor = kRBTreeColorBlack; - pNodeTemp->mColor = kRBTreeColorRed; - pNodeRootRef = RBTreeRotateRight(pNodeTemp, pNodeRootRef); - pNodeTemp = pNodeChildParent->mpNodeRight; - } - - pNodeTemp->mColor = pNodeChildParent->mColor; - pNodeChildParent->mColor = kRBTreeColorBlack; - - if(pNodeTemp->mpNodeRight) - pNodeTemp->mpNodeRight->mColor = kRBTreeColorBlack; - - pNodeRootRef = RBTreeRotateLeft(pNodeChildParent, pNodeRootRef); - break; - } - } - else - { - // The following is the same as above, with mpNodeRight <-> mpNodeLeft. - rbtree_node_base* pNodeTemp = pNodeChildParent->mpNodeLeft; - - if(pNodeTemp->mColor == kRBTreeColorRed) - { - pNodeTemp->mColor = kRBTreeColorBlack; - pNodeChildParent->mColor = kRBTreeColorRed; - - pNodeRootRef = RBTreeRotateRight(pNodeChildParent, pNodeRootRef); - pNodeTemp = pNodeChildParent->mpNodeLeft; - } - - if(((pNodeTemp->mpNodeRight == NULL) || (pNodeTemp->mpNodeRight->mColor == kRBTreeColorBlack)) && - ((pNodeTemp->mpNodeLeft == NULL) || (pNodeTemp->mpNodeLeft->mColor == kRBTreeColorBlack))) - { - pNodeTemp->mColor = kRBTreeColorRed; - pNodeChild = pNodeChildParent; - pNodeChildParent = pNodeChildParent->mpNodeParent; - } - else - { - if((pNodeTemp->mpNodeLeft == NULL) || (pNodeTemp->mpNodeLeft->mColor == kRBTreeColorBlack)) - { - pNodeTemp->mpNodeRight->mColor = kRBTreeColorBlack; - pNodeTemp->mColor = kRBTreeColorRed; - - pNodeRootRef = RBTreeRotateLeft(pNodeTemp, pNodeRootRef); - pNodeTemp = pNodeChildParent->mpNodeLeft; - } - - pNodeTemp->mColor = pNodeChildParent->mColor; - pNodeChildParent->mColor = kRBTreeColorBlack; - - if(pNodeTemp->mpNodeLeft) - pNodeTemp->mpNodeLeft->mColor = kRBTreeColorBlack; - - pNodeRootRef = RBTreeRotateRight(pNodeChildParent, pNodeRootRef); - break; - } - } - } - - if(pNodeChild) - pNodeChild->mColor = kRBTreeColorBlack; - } - - } // RBTreeErase - - - -} // namespace eastl diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.h deleted file mode 100644 index 85b0f68fbb73..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/red_black_tree_eastl.h +++ /dev/null @@ -1,1904 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/red_black_tree.h -// Written by Paul Pedriana 2005. -////////////////////////////////////////////////////////////////////////////// - - - -#ifndef EASTL_RED_BLACK_TREE_H -#define EASTL_RED_BLACK_TREE_H - - - -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) - #include - #include - #pragma warning(pop) -#else - #include - #include -#endif - - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4512) // 'class' : assignment operator could not be generated - #pragma warning(disable: 4530) // C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc -#endif - - -namespace eastl -{ - - /// EASTL_RBTREE_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_RBTREE_DEFAULT_NAME - #define EASTL_RBTREE_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " rbtree" // Unless the user overrides something, this is "EASTL rbtree". - #endif - - - /// EASTL_RBTREE_DEFAULT_ALLOCATOR - /// - #ifndef EASTL_RBTREE_DEFAULT_ALLOCATOR - #define EASTL_RBTREE_DEFAULT_ALLOCATOR allocator_type(EASTL_RBTREE_DEFAULT_NAME) - #endif - - - - /// RBTreeColor - /// - enum RBTreeColor - { - kRBTreeColorRed, - kRBTreeColorBlack - }; - - - - /// RBTreeColor - /// - enum RBTreeSide - { - kRBTreeSideLeft, - kRBTreeSideRight - }; - - - - /// rbtree_node_base - /// - /// We define a rbtree_node_base separately from rbtree_node (below), because it - /// allows us to have non-templated operations, and it makes it so that the - /// rbtree anchor node doesn't carry a T with it, which would waste space and - /// possibly lead to surprising the user due to extra Ts existing that the user - /// didn't explicitly create. The downside to all of this is that it makes debug - /// viewing of an rbtree harder, given that the node pointers are of type - /// rbtree_node_base and not rbtree_node. - /// - struct rbtree_node_base - { - typedef rbtree_node_base this_type; - - public: - this_type* mpNodeRight; // Declared first because it is used most often. - this_type* mpNodeLeft; - this_type* mpNodeParent; - char mColor; // We only need one bit here, would be nice if we could stuff that bit somewhere else. - }; - - - /// rbtree_node - /// - template - struct rbtree_node : public rbtree_node_base - { - Value mValue; // For set and multiset, this is the user's value, for map and multimap, this is a pair of key/value. - }; - - - - - // rbtree_node_base functions - // - // These are the fundamental functions that we use to maintain the - // tree. The bulk of the work of the tree maintenance is done in - // these functions. - // - EASTL_API rbtree_node_base* RBTreeIncrement (const rbtree_node_base* pNode); - EASTL_API rbtree_node_base* RBTreeDecrement (const rbtree_node_base* pNode); - EASTL_API rbtree_node_base* RBTreeGetMinChild (const rbtree_node_base* pNode); - EASTL_API rbtree_node_base* RBTreeGetMaxChild (const rbtree_node_base* pNode); - EASTL_API size_t RBTreeGetBlackCount(const rbtree_node_base* pNodeTop, - const rbtree_node_base* pNodeBottom); - EASTL_API void RBTreeInsert ( rbtree_node_base* pNode, - rbtree_node_base* pNodeParent, - rbtree_node_base* pNodeAnchor, - RBTreeSide insertionSide); - EASTL_API void RBTreeErase ( rbtree_node_base* pNode, - rbtree_node_base* pNodeAnchor); - - - - - - - - /// rbtree_iterator - /// - template - struct rbtree_iterator - { - typedef rbtree_iterator this_type; - typedef rbtree_iterator iterator; - typedef rbtree_iterator const_iterator; - typedef eastl_size_t size_type; // See config.h for the definition of eastl_size_t, which defaults to uint32_t. - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef rbtree_node_base base_node_type; - typedef rbtree_node node_type; - typedef Pointer pointer; - typedef Reference reference; - typedef EASTL_ITC_NS::bidirectional_iterator_tag iterator_category; - - public: - node_type* mpNode; - - public: - rbtree_iterator(); - explicit rbtree_iterator(const node_type* pNode); - rbtree_iterator(const iterator& x); - - reference operator*() const; - pointer operator->() const; - - rbtree_iterator& operator++(); - rbtree_iterator operator++(int); - - rbtree_iterator& operator--(); - rbtree_iterator operator--(int); - - }; // rbtree_iterator - - - - - - /////////////////////////////////////////////////////////////////////////////// - // rb_base - // - // This class allows us to use a generic rbtree as the basis of map, multimap, - // set, and multiset transparently. The vital template parameters for this are - // the ExtractKey and the bUniqueKeys parameters. - // - // If the rbtree has a value type of the form pair (i.e. it is a map or - // multimap and not a set or multiset) and a key extraction policy that returns - // the first part of the pair, the rbtree gets a mapped_type typedef. - // If it satisfies those criteria and also has unique keys, then it also gets an - // operator[] (which only map and set have and multimap and multiset don't have). - // - /////////////////////////////////////////////////////////////////////////////// - - - - /// rb_base - /// This specialization is used for 'set'. In this case, Key and Value - /// will be the same as each other and ExtractKey will be eastl::use_self. - /// - template - struct rb_base - { - typedef ExtractKey extract_key; - - public: - Compare mCompare; // To do: Make sure that empty Compare classes go away via empty base optimizations. - - public: - rb_base() : mCompare() {} - rb_base(const Compare& compare) : mCompare(compare) {} - }; - - - /// rb_base - /// This class is used for 'multiset'. - /// In this case, Key and Value will be the same as each - /// other and ExtractKey will be eastl::use_self. - /// - template - struct rb_base - { - typedef ExtractKey extract_key; - - public: - Compare mCompare; // To do: Make sure that empty Compare classes go away via empty base optimizations. - - public: - rb_base() : mCompare() {} - rb_base(const Compare& compare) : mCompare(compare) {} - }; - - - /// rb_base - /// This specialization is used for 'map'. - /// - template - struct rb_base, true, RBTree> - { - typedef eastl::use_first extract_key; - - public: - Compare mCompare; // To do: Make sure that empty Compare classes go away via empty base optimizations. - - public: - rb_base() : mCompare() {} - rb_base(const Compare& compare) : mCompare(compare) {} - }; - - - /// rb_base - /// This specialization is used for 'multimap'. - /// - template - struct rb_base, false, RBTree> - { - typedef eastl::use_first extract_key; - - public: - Compare mCompare; // To do: Make sure that empty Compare classes go away via empty base optimizations. - - public: - rb_base() : mCompare() {} - rb_base(const Compare& compare) : mCompare(compare) {} - }; - - - - - - /// rbtree - /// - /// rbtree is the red-black tree basis for the map, multimap, set, and multiset - /// containers. Just about all the work of those containers is done here, and - /// they are merely a shell which sets template policies that govern the code - /// generation for this rbtree. - /// - /// This rbtree implementation is pretty much the same as all other modern - /// rbtree implementations, as the topic is well known and researched. We may - /// choose to implement a "relaxed balancing" option at some point in the - /// future if it is deemed worthwhile. Most rbtree implementations don't do this. - /// - /// The primary rbtree member variable is mAnchor, which is a node_type and - /// acts as the end node. However, like any other node, it has mpNodeLeft, - /// mpNodeRight, and mpNodeParent members. We do the conventional trick of - /// assigning begin() (left-most rbtree node) to mpNodeLeft, assigning - /// 'end() - 1' (a.k.a. rbegin()) to mpNodeRight, and assigning the tree root - /// node to mpNodeParent. - /// - /// Compare (functor): This is a comparison class which defaults to 'less'. - /// It is a common STL thing which takes two arguments and returns true if - /// the first is less than the second. - /// - /// ExtractKey (functor): This is a class which gets the key from a stored - /// node. With map and set, the node is a pair, whereas with set and multiset - /// the node is just the value. ExtractKey will be either eastl::use_first (map and multimap) - /// or eastl::use_self (set and multiset). - /// - /// bMutableIterators (bool): true if rbtree::iterator is a mutable - /// iterator, false if iterator and const_iterator are both const iterators. - /// It will be true for map and multimap and false for set and multiset. - /// - /// bUniqueKeys (bool): true if the keys are to be unique, and false if there - /// can be multiple instances of a given key. It will be true for set and map - /// and false for multiset and multimap. - /// - /// To consider: Add an option for relaxed tree balancing. This could result - /// in performance improvements but would require a more complicated implementation. - /// - /////////////////////////////////////////////////////////////////////// - /// find_as - /// In order to support the ability to have a tree of strings but - /// be able to do efficiently lookups via char pointers (i.e. so they - /// aren't converted to string objects), we provide the find_as - /// function. This function allows you to do a find with a key of a - /// type other than the tree's key type. See the find_as function - /// for more documentation on this. - /// - template - class rbtree - : public rb_base > - { - public: - typedef ptrdiff_t difference_type; - typedef eastl_size_t size_type; // See config.h for the definition of eastl_size_t, which defaults to uint32_t. - typedef Key key_type; - typedef Value value_type; - typedef rbtree_node node_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename type_select, - rbtree_iterator >::type iterator; - typedef rbtree_iterator const_iterator; - typedef eastl::reverse_iterator reverse_iterator; - typedef eastl::reverse_iterator const_reverse_iterator; - - typedef Allocator allocator_type; - typedef Compare key_compare; - typedef typename type_select, iterator>::type insert_return_type; // map/set::insert return a pair, multimap/multiset::iterator return an iterator. - typedef rbtree this_type; - typedef rb_base base_type; - typedef integral_constant has_unique_keys_type; - typedef typename base_type::extract_key extract_key; - - using base_type::mCompare; - - enum - { - kKeyAlignment = EASTL_ALIGN_OF(key_type), - kKeyAlignmentOffset = 0, // To do: Make sure this really is zero for all uses of this template. - kValueAlignment = EASTL_ALIGN_OF(value_type), - kValueAlignmentOffset = 0 // To fix: This offset is zero for sets and >0 for maps. Need to fix this. - }; - - public: - rbtree_node_base mAnchor; /// This node acts as end() and its mpLeft points to begin(), and mpRight points to rbegin() (the last node on the right). - size_type mnSize; /// Stores the count of nodes in the tree (not counting the anchor node). - allocator_type mAllocator; // To do: Use base class optimization to make this go away. - - public: - // ctor/dtor - rbtree(); - rbtree(const allocator_type& allocator); - rbtree(const Compare& compare, const allocator_type& allocator = EASTL_RBTREE_DEFAULT_ALLOCATOR); - rbtree(const this_type& x); - - template - rbtree(InputIterator first, InputIterator last, const Compare& compare, const allocator_type& allocator = EASTL_RBTREE_DEFAULT_ALLOCATOR); - - ~rbtree(); - - public: - // properties - allocator_type& get_allocator(); - void set_allocator(const allocator_type& allocator); - - const key_compare& key_comp() const { return mCompare; } - key_compare& key_comp() { return mCompare; } - - this_type& operator=(const this_type& x); - - void swap(this_type& x); - - public: - // iterators - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - public: - bool empty() const; - size_type size() const; - - /// map::insert and set::insert return a pair, while multimap::insert and - /// multiset::insert return an iterator. - insert_return_type insert(const value_type& value); - - // C++ standard: inserts value if and only if there is no element with - // key equivalent to the key of t in containers with unique keys; always - // inserts value in containers with equivalent keys. Always returns the - // iterator pointing to the element with key equivalent to the key of value. - // iterator position is a hint pointing to where the insert should start - // to search. However, there is a potential defect/improvement report on this behaviour: - // LWG issue #233 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1780.html) - // We follow the same approach as SGI STL/STLPort and use the position as - // a forced insertion position for the value when possible. - iterator insert(iterator position, const value_type& value); - - template - void insert(InputIterator first, InputIterator last); - - iterator erase(iterator position); - iterator erase(iterator first, iterator last); - - reverse_iterator erase(reverse_iterator position); - reverse_iterator erase(reverse_iterator first, reverse_iterator last); - - // For some reason, multiple STL versions make a specialization - // for erasing an array of key_types. I'm pretty sure we don't - // need this, but just to be safe we will follow suit. - // The implementation is trivial. Returns void because the values - // could well be randomly distributed throughout the tree and thus - // a return value would be nearly meaningless. - void erase(const key_type* first, const key_type* last); - - void clear(); - void reset(); - - iterator find(const key_type& key); - const_iterator find(const key_type& key) const; - - /// Implements a find whereby the user supplies a comparison of a different type - /// than the tree's value_type. A useful case of this is one whereby you have - /// a container of string objects but want to do searches via passing in char pointers. - /// The problem is that without this kind of find, you need to do the expensive operation - /// of converting the char pointer to a string so it can be used as the argument to the - /// find function. - /// - /// Example usage (note that the compare uses string as first type and char* as second): - /// set strings; - /// strings.find_as("hello", less_2()); - /// - template - iterator find_as(const U& u, Compare2 compare2); - - template - const_iterator find_as(const U& u, Compare2 compare2) const; - - iterator lower_bound(const key_type& key); - const_iterator lower_bound(const key_type& key) const; - - iterator upper_bound(const key_type& key); - const_iterator upper_bound(const key_type& key) const; - - bool validate() const; - int validate_iterator(const_iterator i) const; - - protected: - node_type* DoAllocateNode(); - void DoFreeNode(node_type* pNode); - - node_type* DoCreateNodeFromKey(const key_type& key); - node_type* DoCreateNode(const value_type& value); - node_type* DoCreateNode(const node_type* pNodeSource, node_type* pNodeParent); - - node_type* DoCopySubtree(const node_type* pNodeSource, node_type* pNodeDest); - void DoNukeSubtree(node_type* pNode); - - // Intentionally return a pair and not an iterator for DoInsertValue(..., true_type) - // This is because the C++ standard for map and set is to return a pair and not just an iterator. - eastl::pair DoInsertValue(const value_type& value, true_type); // true_type means keys are unique. - iterator DoInsertValue(const value_type& value, false_type); // false_type means keys are not unique. - - eastl::pair DoInsertKey(const key_type& key, true_type); - iterator DoInsertKey(const key_type& key, false_type); - - iterator DoInsertValue(iterator position, const value_type& value, true_type); - iterator DoInsertValue(iterator position, const value_type& value, false_type); - - iterator DoInsertKey(iterator position, const key_type& key, true_type); - iterator DoInsertKey(iterator position, const key_type& key, false_type); - - iterator DoInsertValueImpl(node_type* pNodeParent, const value_type& value, bool bForceToLeft); - iterator DoInsertKeyImpl(node_type* pNodeParent, const key_type& key, bool bForceToLeft); - - }; // rbtree - - - - - - /////////////////////////////////////////////////////////////////////// - // rbtree_node_base functions - /////////////////////////////////////////////////////////////////////// - - EASTL_API inline rbtree_node_base* RBTreeGetMinChild(const rbtree_node_base* pNodeBase) - { - while(pNodeBase->mpNodeLeft) - pNodeBase = pNodeBase->mpNodeLeft; - return const_cast(pNodeBase); - } - - EASTL_API inline rbtree_node_base* RBTreeGetMaxChild(const rbtree_node_base* pNodeBase) - { - while(pNodeBase->mpNodeRight) - pNodeBase = pNodeBase->mpNodeRight; - return const_cast(pNodeBase); - } - - // The rest of the functions are non-trivial and are found in - // the corresponding .cpp file to this file. - - - - /////////////////////////////////////////////////////////////////////// - // rbtree_iterator functions - /////////////////////////////////////////////////////////////////////// - - template - rbtree_iterator::rbtree_iterator() - : mpNode(NULL) { } - - - template - rbtree_iterator::rbtree_iterator(const node_type* pNode) - : mpNode(static_cast(const_cast(pNode))) { } - - - template - rbtree_iterator::rbtree_iterator(const iterator& x) - : mpNode(x.mpNode) { } - - - template - typename rbtree_iterator::reference - rbtree_iterator::operator*() const - { return mpNode->mValue; } - - - template - typename rbtree_iterator::pointer - rbtree_iterator::operator->() const - { return &mpNode->mValue; } - - - template - typename rbtree_iterator::this_type& - rbtree_iterator::operator++() - { - mpNode = static_cast(RBTreeIncrement(mpNode)); - return *this; - } - - - template - typename rbtree_iterator::this_type - rbtree_iterator::operator++(int) - { - this_type temp(*this); - mpNode = static_cast(RBTreeIncrement(mpNode)); - return temp; - } - - - template - typename rbtree_iterator::this_type& - rbtree_iterator::operator--() - { - mpNode = static_cast(RBTreeDecrement(mpNode)); - return *this; - } - - - template - typename rbtree_iterator::this_type - rbtree_iterator::operator--(int) - { - this_type temp(*this); - mpNode = static_cast(RBTreeDecrement(mpNode)); - return temp; - } - - - // The C++ defect report #179 requires that we support comparisons between const and non-const iterators. - // Thus we provide additional template paremeters here to support this. The defect report does not - // require us to support comparisons between reverse_iterators and const_reverse_iterators. - template - inline bool operator==(const rbtree_iterator& a, - const rbtree_iterator& b) - { - return a.mpNode == b.mpNode; - } - - - template - inline bool operator!=(const rbtree_iterator& a, - const rbtree_iterator& b) - { - return a.mpNode != b.mpNode; - } - - - // We provide a version of operator!= for the case where the iterators are of the - // same type. This helps prevent ambiguity errors in the presence of rel_ops. - template - inline bool operator!=(const rbtree_iterator& a, - const rbtree_iterator& b) - { - return a.mpNode != b.mpNode; - } - - - - - /////////////////////////////////////////////////////////////////////// - // rbtree functions - /////////////////////////////////////////////////////////////////////// - - template - inline rbtree::rbtree() - : mAnchor(), - mnSize(0), - mAllocator(EASTL_RBTREE_DEFAULT_NAME) - { - reset(); - } - - - template - inline rbtree::rbtree(const allocator_type& allocator) - : mAnchor(), - mnSize(0), - mAllocator(allocator) - { - reset(); - } - - - template - inline rbtree::rbtree(const C& compare, const allocator_type& allocator) - : base_type(compare), - mAnchor(), - mnSize(0), - mAllocator(allocator) - { - reset(); - } - - - template - inline rbtree::rbtree(const this_type& x) - : base_type(x.mCompare), - mAnchor(), - mnSize(0), - mAllocator(x.mAllocator) - { - reset(); - - if(x.mAnchor.mpNodeParent) // mAnchor.mpNodeParent is the rb_tree root node. - { - mAnchor.mpNodeParent = DoCopySubtree((const node_type*)x.mAnchor.mpNodeParent, (node_type*)&mAnchor); - mAnchor.mpNodeRight = RBTreeGetMaxChild(mAnchor.mpNodeParent); - mAnchor.mpNodeLeft = RBTreeGetMinChild(mAnchor.mpNodeParent); - mnSize = x.mnSize; - } - } - - - template - template - inline rbtree::rbtree(InputIterator first, InputIterator last, const C& compare, const allocator_type& allocator) - : base_type(compare), - mAnchor(), - mnSize(0), - mAllocator(allocator) - { - reset(); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - for(; first != last; ++first) - insert(*first); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - clear(); - throw; - } - #endif - } - - - template - inline rbtree::~rbtree() - { - // Erase the entire tree. DoNukeSubtree is not a - // conventional erase function, as it does no rebalancing. - DoNukeSubtree((node_type*)mAnchor.mpNodeParent); - } - - - template - inline typename rbtree::allocator_type& - rbtree::get_allocator() - { - return mAllocator; - } - - - template - inline void rbtree::set_allocator(const allocator_type& allocator) - { - mAllocator = allocator; - } - - - template - inline typename rbtree::size_type - rbtree::size() const - { return mnSize; } - - - template - inline bool rbtree::empty() const - { return (mnSize == 0); } - - - template - inline typename rbtree::iterator - rbtree::begin() - { return iterator(static_cast(mAnchor.mpNodeLeft)); } - - - template - inline typename rbtree::const_iterator - rbtree::begin() const - { return const_iterator(static_cast(const_cast(mAnchor.mpNodeLeft))); } - - - template - inline typename rbtree::iterator - rbtree::end() - { return iterator(static_cast(&mAnchor)); } - - - template - inline typename rbtree::const_iterator - rbtree::end() const - { return const_iterator(static_cast(const_cast(&mAnchor))); } - - - template - inline typename rbtree::reverse_iterator - rbtree::rbegin() - { return reverse_iterator(end()); } - - - template - inline typename rbtree::const_reverse_iterator - rbtree::rbegin() const - { return const_reverse_iterator(end()); } - - - template - inline typename rbtree::reverse_iterator - rbtree::rend() - { return reverse_iterator(begin()); } - - - template - inline typename rbtree::const_reverse_iterator - rbtree::rend() const - { return const_reverse_iterator(begin()); } - - - template - inline typename rbtree::this_type& - rbtree::operator=(const this_type& x) - { - if(this != &x) - { - clear(); - - #if EASTL_ALLOCATOR_COPY_ENABLED - mAllocator = x.mAllocator; - #endif - - base_type::mCompare = x.mCompare; - - if(x.mAnchor.mpNodeParent) // mAnchor.mpNodeParent is the rb_tree root node. - { - mAnchor.mpNodeParent = DoCopySubtree((const node_type*)x.mAnchor.mpNodeParent, (node_type*)&mAnchor); - mAnchor.mpNodeRight = RBTreeGetMaxChild(mAnchor.mpNodeParent); - mAnchor.mpNodeLeft = RBTreeGetMinChild(mAnchor.mpNodeParent); - mnSize = x.mnSize; - } - } - return *this; - } - - - template - void rbtree::swap(this_type& x) - { - if(mAllocator == x.mAllocator) // If allocators are equivalent... - { - // Most of our members can be exchaged by a basic swap: - // We leave mAllocator as-is. - eastl::swap(mnSize, x.mnSize); - eastl::swap(base_type::mCompare, x.mCompare); - - // However, because our anchor node is a part of our class instance and not - // dynamically allocated, we can't do a swap of it but must do a more elaborate - // procedure. This is the downside to having the mAnchor be like this, but - // otherwise we consider it a good idea to avoid allocating memory for a - // nominal container instance. - - // We optimize for the expected most common case: both pointers being non-null. - if(mAnchor.mpNodeParent && x.mAnchor.mpNodeParent) // If both pointers are non-null... - { - eastl::swap(mAnchor.mpNodeRight, x.mAnchor.mpNodeRight); - eastl::swap(mAnchor.mpNodeLeft, x.mAnchor.mpNodeLeft); - eastl::swap(mAnchor.mpNodeParent, x.mAnchor.mpNodeParent); - - // We need to fix up the anchors to point to themselves (we can't just swap them). - mAnchor.mpNodeParent->mpNodeParent = &mAnchor; - x.mAnchor.mpNodeParent->mpNodeParent = &x.mAnchor; - } - else if(mAnchor.mpNodeParent) - { - x.mAnchor.mpNodeRight = mAnchor.mpNodeRight; - x.mAnchor.mpNodeLeft = mAnchor.mpNodeLeft; - x.mAnchor.mpNodeParent = mAnchor.mpNodeParent; - x.mAnchor.mpNodeParent->mpNodeParent = &x.mAnchor; - - // We need to fix up our anchor to point it itself (we can't have it swap with x). - mAnchor.mpNodeRight = &mAnchor; - mAnchor.mpNodeLeft = &mAnchor; - mAnchor.mpNodeParent = NULL; - } - else if(x.mAnchor.mpNodeParent) - { - mAnchor.mpNodeRight = x.mAnchor.mpNodeRight; - mAnchor.mpNodeLeft = x.mAnchor.mpNodeLeft; - mAnchor.mpNodeParent = x.mAnchor.mpNodeParent; - mAnchor.mpNodeParent->mpNodeParent = &mAnchor; - - // We need to fix up x's anchor to point it itself (we can't have it swap with us). - x.mAnchor.mpNodeRight = &x.mAnchor; - x.mAnchor.mpNodeLeft = &x.mAnchor; - x.mAnchor.mpNodeParent = NULL; - } // Else both are NULL and there is nothing to do. - } - else - { - const this_type temp(*this); // Can't call eastl::swap because that would - *this = x; // itself call this member swap function. - x = temp; - } - } - - - template - inline typename rbtree::insert_return_type // map/set::insert return a pair, multimap/multiset::iterator return an iterator. - rbtree::insert(const value_type& value) - { return DoInsertValue(value, has_unique_keys_type()); } - - - template - typename rbtree::iterator - rbtree::insert(iterator position, const value_type& value) - { return DoInsertValue(position, value, has_unique_keys_type()); } - - - template - eastl::pair::iterator, bool> - rbtree::DoInsertValue(const value_type& value, true_type) // true_type means keys are unique. - { - // This is the pathway for insertion of unique keys (map and set, but not multimap and multiset). - // Note that we return a pair and not an iterator. This is because the C++ standard for map - // and set is to return a pair and not just an iterator. - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pLowerBound = (node_type*)&mAnchor; // Set it to the container end for now. - node_type* pParent; // This will be where we insert the new node. - - bool bValueLessThanNode = true; // If the tree is empty, this will result in an insertion at the front. - - // Find insertion position of the value. This will either be a position which - // already contains the value, a position which is greater than the value or - // end(), which we treat like a position which is greater than the value. - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - bValueLessThanNode = mCompare(extractKey(value), extractKey(pCurrent->mValue)); - pLowerBound = pCurrent; - - if(bValueLessThanNode) - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(pCurrent->mValue), extractKey(value))); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - - pParent = pLowerBound; // pLowerBound is actually upper bound right now (i.e. it is > value instead of <=), but we will make it the lower bound below. - - if(bValueLessThanNode) // If we ended up on the left side of the last parent node... - { - if(EASTL_LIKELY(pLowerBound != (node_type*)mAnchor.mpNodeLeft)) // If the tree was empty or if we otherwise need to insert at the very front of the tree... - { - // At this point, pLowerBound points to a node which is > than value. - // Move it back by one, so that it points to a node which is <= value. - pLowerBound = (node_type*)RBTreeDecrement(pLowerBound); - } - else - { - const iterator itResult(DoInsertValueImpl(pLowerBound, value, false)); - return pair(itResult, true); - } - } - - // Since here we require values to be unique, we will do nothing if the value already exists. - if(mCompare(extractKey(pLowerBound->mValue), extractKey(value))) // If the node is < the value (i.e. if value is >= the node)... - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(value), extractKey(pLowerBound->mValue))); // Validate that the compare function is sane. - const iterator itResult(DoInsertValueImpl(pParent, value, false)); - return pair(itResult, true); - } - - // The item already exists (as found by the compare directly above), so return false. - return pair(iterator(pLowerBound), false); - } - - - template - typename rbtree::iterator - rbtree::DoInsertValue(const value_type& value, false_type) // false_type means keys are not unique. - { - // This is the pathway for insertion of non-unique keys (multimap and multiset, but not map and set). - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - extract_key extractKey; - - while(pCurrent) - { - pRangeEnd = pCurrent; - - if(mCompare(extractKey(value), extractKey(pCurrent->mValue))) - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(pCurrent->mValue), extractKey(value))); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - - return DoInsertValueImpl(pRangeEnd, value, false); - } - - - template - eastl::pair::iterator, bool> - rbtree::DoInsertKey(const key_type& key, true_type) // true_type means keys are unique. - { - // This code is essentially a slightly modified copy of the the rbtree::insert - // function whereby this version takes a key and not a full value_type. - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pLowerBound = (node_type*)&mAnchor; // Set it to the container end for now. - node_type* pParent; // This will be where we insert the new node. - - bool bValueLessThanNode = true; // If the tree is empty, this will result in an insertion at the front. - - // Find insertion position of the value. This will either be a position which - // already contains the value, a position which is greater than the value or - // end(), which we treat like a position which is greater than the value. - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - bValueLessThanNode = mCompare(key, extractKey(pCurrent->mValue)); - pLowerBound = pCurrent; - - if(bValueLessThanNode) - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(pCurrent->mValue), key)); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - - pParent = pLowerBound; // pLowerBound is actually upper bound right now (i.e. it is > value instead of <=), but we will make it the lower bound below. - - if(bValueLessThanNode) // If we ended up on the left side of the last parent node... - { - if(EASTL_LIKELY(pLowerBound != (node_type*)mAnchor.mpNodeLeft)) // If the tree was empty or if we otherwise need to insert at the very front of the tree... - { - // At this point, pLowerBound points to a node which is > than value. - // Move it back by one, so that it points to a node which is <= value. - pLowerBound = (node_type*)RBTreeDecrement(pLowerBound); - } - else - { - const iterator itResult(DoInsertKeyImpl(pLowerBound, key, false)); - return pair(itResult, true); - } - } - - // Since here we require values to be unique, we will do nothing if the value already exists. - if(mCompare(extractKey(pLowerBound->mValue), key)) // If the node is < the value (i.e. if value is >= the node)... - { - EASTL_VALIDATE_COMPARE(!mCompare(key, extractKey(pLowerBound->mValue))); // Validate that the compare function is sane. - const iterator itResult(DoInsertKeyImpl(pParent, key, false)); - return pair(itResult, true); - } - - // The item already exists (as found by the compare directly above), so return false. - return pair(iterator(pLowerBound), false); - } - - - template - typename rbtree::iterator - rbtree::DoInsertKey(const key_type& key, false_type) // false_type means keys are not unique. - { - // This is the pathway for insertion of non-unique keys (multimap and multiset, but not map and set). - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - extract_key extractKey; - - while(pCurrent) - { - pRangeEnd = pCurrent; - - if(mCompare(key, extractKey(pCurrent->mValue))) - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(pCurrent->mValue), key)); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - - return DoInsertKeyImpl(pRangeEnd, key, false); - } - - - template - typename rbtree::iterator - rbtree::DoInsertValue(iterator position, const value_type& value, true_type) // true_type means keys are unique. - { - // This is the pathway for insertion of unique keys (map and set, but not multimap and multiset). - // - // We follow the same approach as SGI STL/STLPort and use the position as - // a forced insertion position for the value when possible. - extract_key extractKey; - - if((position.mpNode != mAnchor.mpNodeRight) && (position.mpNode != &mAnchor)) // If the user specified a specific insertion position... - { - iterator itNext(position); - ++itNext; - - // To consider: Change this so that 'position' specifies the position after - // where the insertion goes and not the position before where the insertion goes. - // Doing so would make this more in line with user expectations and with LWG #233. - const bool bPositionLessThanValue = mCompare(extractKey(position.mpNode->mValue), extractKey(value)); - - if(bPositionLessThanValue) // If (value > *position)... - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(value), extractKey(position.mpNode->mValue))); // Validate that the compare function is sane. - - const bool bValueLessThanNext = mCompare(extractKey(value), extractKey(itNext.mpNode->mValue)); - - if(bValueLessThanNext) // if (value < *itNext)... - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(itNext.mpNode->mValue), extractKey(value))); // Validate that the compare function is sane. - - if(position.mpNode->mpNodeRight) - return DoInsertValueImpl(itNext.mpNode, value, true); - return DoInsertValueImpl(position.mpNode, value, false); - } - } - - return DoInsertValue(value, has_unique_keys_type()).first; - } - - if(mnSize && mCompare(extractKey(((node_type*)mAnchor.mpNodeRight)->mValue), extractKey(value))) - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(value), extractKey(((node_type*)mAnchor.mpNodeRight)->mValue))); // Validate that the compare function is sane. - return DoInsertValueImpl((node_type*)mAnchor.mpNodeRight, value, false); - } - - return DoInsertValue(value, has_unique_keys_type()).first; - } - - - template - typename rbtree::iterator - rbtree::DoInsertValue(iterator position, const value_type& value, false_type) // false_type means keys are not unique. - { - // This is the pathway for insertion of non-unique keys (multimap and multiset, but not map and set). - // - // We follow the same approach as SGI STL/STLPort and use the position as - // a forced insertion position for the value when possible. - extract_key extractKey; - - if((position.mpNode != mAnchor.mpNodeRight) && (position.mpNode != &mAnchor)) // If the user specified a specific insertion position... - { - iterator itNext(position); - ++itNext; - - // To consider: Change this so that 'position' specifies the position after - // where the insertion goes and not the position before where the insertion goes. - // Doing so would make this more in line with user expectations and with LWG #233. - - if(!mCompare(extractKey(value), extractKey(position.mpNode->mValue)) && // If value >= *position && - !mCompare(extractKey(itNext.mpNode->mValue), extractKey(value))) // if value <= *itNext... - { - if(position.mpNode->mpNodeRight) // If there are any nodes to the right... [this expression will always be true as long as we aren't at the end()] - return DoInsertValueImpl(itNext.mpNode, value, true); // Specifically insert in front of (to the left of) itNext (and thus after 'position'). - return DoInsertValueImpl(position.mpNode, value, false); - } - - return DoInsertValue(value, has_unique_keys_type()); // If the above specified hint was not useful, then we do a regular insertion. - } - - // This pathway shouldn't be commonly executed, as the user shouldn't be calling - // this hinted version of insert if the user isn't providing a useful hint. - - if(mnSize && !mCompare(extractKey(value), extractKey(((node_type*)mAnchor.mpNodeRight)->mValue))) // If we are non-empty and the value is >= the last node... - return DoInsertValueImpl((node_type*)mAnchor.mpNodeRight, value, false); // Insert after the last node (doesn't matter if we force left or not). - - return DoInsertValue(value, has_unique_keys_type()); // We are empty or we are inserting at the end. - } - - - template - typename rbtree::iterator - rbtree::DoInsertKey(iterator position, const key_type& key, true_type) // true_type means keys are unique. - { - // This is the pathway for insertion of unique keys (map and set, but not multimap and multiset). - // - // We follow the same approach as SGI STL/STLPort and use the position as - // a forced insertion position for the value when possible. - extract_key extractKey; - - if((position.mpNode != mAnchor.mpNodeRight) && (position.mpNode != &mAnchor)) // If the user specified a specific insertion position... - { - iterator itNext(position); - ++itNext; - - // To consider: Change this so that 'position' specifies the position after - // where the insertion goes and not the position before where the insertion goes. - // Doing so would make this more in line with user expectations and with LWG #233. - const bool bPositionLessThanValue = mCompare(extractKey(position.mpNode->mValue), key); - - if(bPositionLessThanValue) // If (value > *position)... - { - EASTL_VALIDATE_COMPARE(!mCompare(key, extractKey(position.mpNode->mValue))); // Validate that the compare function is sane. - - const bool bValueLessThanNext = mCompare(key, extractKey(itNext.mpNode->mValue)); - - if(bValueLessThanNext) // If value < *itNext... - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(itNext.mpNode->mValue), key)); // Validate that the compare function is sane. - - if(position.mpNode->mpNodeRight) - return DoInsertKeyImpl(itNext.mpNode, key, true); - return DoInsertKeyImpl(position.mpNode, key, false); - } - } - - return DoInsertKey(key, has_unique_keys_type()).first; - } - - if(mnSize && mCompare(extractKey(((node_type*)mAnchor.mpNodeRight)->mValue), key)) - { - EASTL_VALIDATE_COMPARE(!mCompare(key, extractKey(((node_type*)mAnchor.mpNodeRight)->mValue))); // Validate that the compare function is sane. - return DoInsertKeyImpl((node_type*)mAnchor.mpNodeRight, key, false); - } - - return DoInsertKey(key, has_unique_keys_type()).first; - } - - - template - typename rbtree::iterator - rbtree::DoInsertKey(iterator position, const key_type& key, false_type) // false_type means keys are not unique. - { - // This is the pathway for insertion of non-unique keys (multimap and multiset, but not map and set). - // - // We follow the same approach as SGI STL/STLPort and use the position as - // a forced insertion position for the value when possible. - extract_key extractKey; - - if((position.mpNode != mAnchor.mpNodeRight) && (position.mpNode != &mAnchor)) // If the user specified a specific insertion position... - { - iterator itNext(position); - ++itNext; - - // To consider: Change this so that 'position' specifies the position after - // where the insertion goes and not the position before where the insertion goes. - // Doing so would make this more in line with user expectations and with LWG #233. - if(!mCompare(key, extractKey(position.mpNode->mValue)) && // If value >= *position && - !mCompare(extractKey(itNext.mpNode->mValue), key)) // if value <= *itNext... - { - if(position.mpNode->mpNodeRight) // If there are any nodes to the right... [this expression will always be true as long as we aren't at the end()] - return DoInsertKeyImpl(itNext.mpNode, key, true); // Specifically insert in front of (to the left of) itNext (and thus after 'position'). - return DoInsertKeyImpl(position.mpNode, key, false); - } - - return DoInsertKey(key, has_unique_keys_type()); // If the above specified hint was not useful, then we do a regular insertion. - } - - // This pathway shouldn't be commonly executed, as the user shouldn't be calling - // this hinted version of insert if the user isn't providing a useful hint. - if(mnSize && !mCompare(key, extractKey(((node_type*)mAnchor.mpNodeRight)->mValue))) // If we are non-empty and the value is >= the last node... - return DoInsertKeyImpl((node_type*)mAnchor.mpNodeRight, key, false); // Insert after the last node (doesn't matter if we force left or not). - - return DoInsertKey(key, has_unique_keys_type()); // We are empty or we are inserting at the end. - } - - - template - typename rbtree::iterator - rbtree::DoInsertValueImpl(node_type* pNodeParent, const value_type& value, bool bForceToLeft) - { - RBTreeSide side; - extract_key extractKey; - - // The reason we may want to have bForceToLeft == true is that pNodeParent->mValue and value may be equal. - // In that case it doesn't matter what side we insert on, except that the C++ LWG #233 improvement report - // suggests that we should use the insert hint position to force an ordering. So that's what we do. - if(bForceToLeft || (pNodeParent == &mAnchor) || mCompare(extractKey(value), extractKey(pNodeParent->mValue))) - side = kRBTreeSideLeft; - else - side = kRBTreeSideRight; - - node_type* const pNodeNew = DoCreateNode(value); // Note that pNodeNew->mpLeft, mpRight, mpParent, will be uninitialized. - RBTreeInsert(pNodeNew, pNodeParent, &mAnchor, side); - mnSize++; - - return iterator(pNodeNew); - } - - - template - typename rbtree::iterator - rbtree::DoInsertKeyImpl(node_type* pNodeParent, const key_type& key, bool bForceToLeft) - { - RBTreeSide side; - extract_key extractKey; - - // The reason we may want to have bForceToLeft == true is that pNodeParent->mValue and value may be equal. - // In that case it doesn't matter what side we insert on, except that the C++ LWG #233 improvement report - // suggests that we should use the insert hint position to force an ordering. So that's what we do. - if(bForceToLeft || (pNodeParent == &mAnchor) || mCompare(key, extractKey(pNodeParent->mValue))) - side = kRBTreeSideLeft; - else - side = kRBTreeSideRight; - - node_type* const pNodeNew = DoCreateNodeFromKey(key); // Note that pNodeNew->mpLeft, mpRight, mpParent, will be uninitialized. - RBTreeInsert(pNodeNew, pNodeParent, &mAnchor, side); - mnSize++; - - return iterator(pNodeNew); - } - - - template - template - void rbtree::insert(InputIterator first, InputIterator last) - { - for( ; first != last; ++first) - DoInsertValue(*first, has_unique_keys_type()); // Or maybe we should call 'insert(end(), *first)' instead. If the first-last range was sorted then this might make some sense. - } - - - template - inline void rbtree::clear() - { - // Erase the entire tree. DoNukeSubtree is not a - // conventional erase function, as it does no rebalancing. - DoNukeSubtree((node_type*)mAnchor.mpNodeParent); - reset(); - } - - - template - inline void rbtree::reset() - { - // The reset function is a special extension function which unilaterally - // resets the container to an empty state without freeing the memory of - // the contained objects. This is useful for very quickly tearing down a - // container built into scratch memory. - mAnchor.mpNodeRight = &mAnchor; - mAnchor.mpNodeLeft = &mAnchor; - mAnchor.mpNodeParent = NULL; - mAnchor.mColor = kRBTreeColorRed; - mnSize = 0; - } - - - template - inline typename rbtree::iterator - rbtree::erase(iterator position) - { - const iterator iErase(position); - --mnSize; // Interleave this between the two references to itNext. We expect no exceptions to occur during the code below. - ++position; - RBTreeErase(iErase.mpNode, &mAnchor); - DoFreeNode(iErase.mpNode); - return position; - } - - - template - typename rbtree::iterator - rbtree::erase(iterator first, iterator last) - { - // We expect that if the user means to clear the container, they will call clear. - if(EASTL_LIKELY((first.mpNode != mAnchor.mpNodeLeft) || (last.mpNode != &mAnchor))) // If (first != begin or last != end) ... - { - // Basic implementation: - while(first != last) - first = erase(first); - return first; - - // Inlined implementation: - //size_type n = 0; - //while(first != last) - //{ - // const iterator itErase(first); - // ++n; - // ++first; - // RBTreeErase(itErase.mpNode, &mAnchor); - // DoFreeNode(itErase.mpNode); - //} - //mnSize -= n; - //return first; - } - - clear(); - return iterator((node_type*)&mAnchor); // Same as: return end(); - } - - - template - inline typename rbtree::reverse_iterator - rbtree::erase(reverse_iterator position) - { - return reverse_iterator(erase((++position).base())); - } - - - template - typename rbtree::reverse_iterator - rbtree::erase(reverse_iterator first, reverse_iterator last) - { - // Version which erases in order from first to last. - // difference_type i(first.base() - last.base()); - // while(i--) - // first = erase(first); - // return first; - - // Version which erases in order from last to first, but is slightly more efficient: - return reverse_iterator(erase((++last).base(), (++first).base())); - } - - - template - inline void rbtree::erase(const key_type* first, const key_type* last) - { - // We have no choice but to run a loop like this, as the first/last range could - // have values that are discontiguously located in the tree. And some may not - // even be in the tree. - while(first != last) - erase(*first++); - } - - - template - typename rbtree::iterator - rbtree::find(const key_type& key) - { - // To consider: Implement this instead via calling lower_bound and - // inspecting the result. The following is an implementation of this: - // const iterator it(lower_bound(key)); - // return ((it.mpNode == &mAnchor) || mCompare(key, extractKey(it.mpNode->mValue))) ? iterator(&mAnchor) : it; - // We don't currently implement the above because in practice people tend to call - // find a lot with trees, but very uncommonly call lower_bound. - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - if(EASTL_LIKELY(!mCompare(extractKey(pCurrent->mValue), key))) // If pCurrent is >= key... - { - pRangeEnd = pCurrent; - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - { - EASTL_VALIDATE_COMPARE(!mCompare(key, extractKey(pCurrent->mValue))); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - } - - if(EASTL_LIKELY((pRangeEnd != &mAnchor) && !mCompare(key, extractKey(pRangeEnd->mValue)))) - return iterator(pRangeEnd); - return iterator((node_type*)&mAnchor); - } - - - template - inline typename rbtree::const_iterator - rbtree::find(const key_type& key) const - { - typedef rbtree rbtree_type; - return const_iterator(const_cast(this)->find(key)); - } - - - template - template - typename rbtree::iterator - rbtree::find_as(const U& u, Compare2 compare2) - { - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - if(EASTL_LIKELY(!compare2(extractKey(pCurrent->mValue), u))) // If pCurrent is >= u... - { - pRangeEnd = pCurrent; - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - { - EASTL_VALIDATE_COMPARE(!compare2(u, extractKey(pCurrent->mValue))); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - } - - if(EASTL_LIKELY((pRangeEnd != &mAnchor) && !compare2(u, extractKey(pRangeEnd->mValue)))) - return iterator(pRangeEnd); - return iterator((node_type*)&mAnchor); - } - - - template - template - inline typename rbtree::const_iterator - rbtree::find_as(const U& u, Compare2 compare2) const - { - typedef rbtree rbtree_type; - return const_iterator(const_cast(this)->find_as(u, compare2)); - } - - - template - typename rbtree::iterator - rbtree::lower_bound(const key_type& key) - { - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - if(EASTL_LIKELY(!mCompare(extractKey(pCurrent->mValue), key))) // If pCurrent is >= key... - { - pRangeEnd = pCurrent; - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - { - EASTL_VALIDATE_COMPARE(!mCompare(key, extractKey(pCurrent->mValue))); // Validate that the compare function is sane. - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - } - - return iterator(pRangeEnd); - } - - - template - inline typename rbtree::const_iterator - rbtree::lower_bound(const key_type& key) const - { - typedef rbtree rbtree_type; - return const_iterator(const_cast(this)->lower_bound(key)); - } - - - template - typename rbtree::iterator - rbtree::upper_bound(const key_type& key) - { - extract_key extractKey; - - node_type* pCurrent = (node_type*)mAnchor.mpNodeParent; // Start with the root node. - node_type* pRangeEnd = (node_type*)&mAnchor; // Set it to the container end for now. - - while(EASTL_LIKELY(pCurrent)) // Do a walk down the tree. - { - if(EASTL_LIKELY(mCompare(key, extractKey(pCurrent->mValue)))) // If key is < pCurrent... - { - EASTL_VALIDATE_COMPARE(!mCompare(extractKey(pCurrent->mValue), key)); // Validate that the compare function is sane. - pRangeEnd = pCurrent; - pCurrent = (node_type*)pCurrent->mpNodeLeft; - } - else - pCurrent = (node_type*)pCurrent->mpNodeRight; - } - - return iterator(pRangeEnd); - } - - - template - inline typename rbtree::const_iterator - rbtree::upper_bound(const key_type& key) const - { - typedef rbtree rbtree_type; - return const_iterator(const_cast(this)->upper_bound(key)); - } - - - // To do: Move this validate function entirely to a template-less implementation. - template - bool rbtree::validate() const - { - // Red-black trees have the following canonical properties which we validate here: - // 1 Every node is either red or black. - // 2 Every leaf (NULL) is black by defintion. Any number of black nodes may appear in a sequence. - // 3 If a node is red, then both its children are black. Thus, on any path from - // the root to a leaf, red nodes must not be adjacent. - // 4 Every simple path from a node to a descendant leaf contains the same number of black nodes. - // 5 The mnSize member of the tree must equal the number of nodes in the tree. - // 6 The tree is sorted as per a conventional binary tree. - // 7 The comparison function is sane; it obeys strict weak ordering. If mCompare(a,b) is true, then mCompare(b,a) must be false. Both cannot be true. - - extract_key extractKey; - - if(mnSize) - { - // Verify basic integrity. - //if(!mAnchor.mpNodeParent || (mAnchor.mpNodeLeft == mAnchor.mpNodeRight)) - // return false; // Fix this for case of empty tree. - - if(mAnchor.mpNodeLeft != RBTreeGetMinChild(mAnchor.mpNodeParent)) - return false; - - if(mAnchor.mpNodeRight != RBTreeGetMaxChild(mAnchor.mpNodeParent)) - return false; - - const size_t nBlackCount = RBTreeGetBlackCount(mAnchor.mpNodeParent, mAnchor.mpNodeLeft); - size_type nIteratedSize = 0; - - for(const_iterator it = begin(); it != end(); ++it, ++nIteratedSize) - { - const node_type* const pNode = (const node_type*)it.mpNode; - const node_type* const pNodeRight = (const node_type*)pNode->mpNodeRight; - const node_type* const pNodeLeft = (const node_type*)pNode->mpNodeLeft; - - // Verify #7 above. - if(pNodeRight && mCompare(extractKey(pNodeRight->mValue), extractKey(pNode->mValue)) && mCompare(extractKey(pNode->mValue), extractKey(pNodeRight->mValue))) // Validate that the compare function is sane. - return false; - - // Verify #7 above. - if(pNodeLeft && mCompare(extractKey(pNodeLeft->mValue), extractKey(pNode->mValue)) && mCompare(extractKey(pNode->mValue), extractKey(pNodeLeft->mValue))) // Validate that the compare function is sane. - return false; - - // Verify item #1 above. - if((pNode->mColor != kRBTreeColorRed) && (pNode->mColor != kRBTreeColorBlack)) - return false; - - // Verify item #3 above. - if(pNode->mColor == kRBTreeColorRed) - { - if((pNodeRight && (pNodeRight->mColor == kRBTreeColorRed)) || - (pNodeLeft && (pNodeLeft->mColor == kRBTreeColorRed))) - return false; - } - - // Verify item #6 above. - if(pNodeRight && mCompare(extractKey(pNodeRight->mValue), extractKey(pNode->mValue))) - return false; - - if(pNodeLeft && mCompare(extractKey(pNode->mValue), extractKey(pNodeLeft->mValue))) - return false; - - if(!pNodeRight && !pNodeLeft) // If we are at a bottom node of the tree... - { - // Verify item #4 above. - if(RBTreeGetBlackCount(mAnchor.mpNodeParent, pNode) != nBlackCount) - return false; - } - } - - // Verify item #5 above. - if(nIteratedSize != mnSize) - return false; - - return true; - } - else - { - if((mAnchor.mpNodeLeft != &mAnchor) || (mAnchor.mpNodeRight != &mAnchor)) - return false; - } - - return true; - } - - - template - inline int rbtree::validate_iterator(const_iterator i) const - { - // To do: Come up with a more efficient mechanism of doing this. - - for(const_iterator temp = begin(), tempEnd = end(); temp != tempEnd; ++temp) - { - if(temp == i) - return (isf_valid | isf_current | isf_can_dereference); - } - - if(i == end()) - return (isf_valid | isf_current); - - return isf_none; - } - - - template - inline typename rbtree::node_type* - rbtree::DoAllocateNode() - { - return (node_type*)allocate_memory(mAllocator, sizeof(node_type), kValueAlignment, kValueAlignmentOffset); - } - - - template - inline void rbtree::DoFreeNode(node_type* pNode) - { - pNode->~node_type(); - EASTLFree(mAllocator, pNode, sizeof(node_type)); - } - - - template - typename rbtree::node_type* - rbtree::DoCreateNodeFromKey(const key_type& key) - { - // Note that this function intentionally leaves the node pointers uninitialized. - // The caller would otherwise just turn right around and modify them, so there's - // no point in us initializing them to anything (except in a debug build). - node_type* const pNode = DoAllocateNode(); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - ::new(&pNode->mValue) value_type(key); - - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - DoFreeNode(pNode); - throw; - } - #endif - - #if EASTL_DEBUG - pNode->mpNodeRight = NULL; - pNode->mpNodeLeft = NULL; - pNode->mpNodeParent = NULL; - pNode->mColor = kRBTreeColorBlack; - #endif - - return pNode; - } - - - template - typename rbtree::node_type* - rbtree::DoCreateNode(const value_type& value) - { - // Note that this function intentionally leaves the node pointers uninitialized. - // The caller would otherwise just turn right around and modify them, so there's - // no point in us initializing them to anything (except in a debug build). - node_type* const pNode = DoAllocateNode(); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - ::new(&pNode->mValue) value_type(value); - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - DoFreeNode(pNode); - throw; - } - #endif - - #if EASTL_DEBUG - pNode->mpNodeRight = NULL; - pNode->mpNodeLeft = NULL; - pNode->mpNodeParent = NULL; - pNode->mColor = kRBTreeColorBlack; - #endif - - return pNode; - } - - - template - typename rbtree::node_type* - rbtree::DoCreateNode(const node_type* pNodeSource, node_type* pNodeParent) - { - node_type* const pNode = DoCreateNode(pNodeSource->mValue); - - pNode->mpNodeRight = NULL; - pNode->mpNodeLeft = NULL; - pNode->mpNodeParent = pNodeParent; - pNode->mColor = pNodeSource->mColor; - - return pNode; - } - - - template - typename rbtree::node_type* - rbtree::DoCopySubtree(const node_type* pNodeSource, node_type* pNodeDest) - { - node_type* const pNewNodeRoot = DoCreateNode(pNodeSource, pNodeDest); - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - // Copy the right side of the tree recursively. - if(pNodeSource->mpNodeRight) - pNewNodeRoot->mpNodeRight = DoCopySubtree((const node_type*)pNodeSource->mpNodeRight, pNewNodeRoot); - - node_type* pNewNodeLeft; - - for(pNodeSource = (node_type*)pNodeSource->mpNodeLeft, pNodeDest = pNewNodeRoot; - pNodeSource; - pNodeSource = (node_type*)pNodeSource->mpNodeLeft, pNodeDest = pNewNodeLeft) - { - pNewNodeLeft = DoCreateNode(pNodeSource, pNodeDest); - - pNodeDest->mpNodeLeft = pNewNodeLeft; - - // Copy the right side of the tree recursively. - if(pNodeSource->mpNodeRight) - pNewNodeLeft->mpNodeRight = DoCopySubtree((const node_type*)pNodeSource->mpNodeRight, pNewNodeLeft); - } - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - DoNukeSubtree(pNewNodeRoot); - throw; - } - #endif - - return pNewNodeRoot; - } - - - template - void rbtree::DoNukeSubtree(node_type* pNode) - { - while(pNode) // Recursively traverse the tree and destroy items as we go. - { - DoNukeSubtree((node_type*)pNode->mpNodeRight); - - node_type* const pNodeLeft = (node_type*)pNode->mpNodeLeft; - DoFreeNode(pNode); - pNode = pNodeLeft; - } - } - - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const rbtree& a, const rbtree& b) - { - return (a.size() == b.size()) && eastl::equal(a.begin(), a.end(), b.begin()); - } - - - // Note that in operator< we do comparisons based on the tree value_type with operator<() of the - // value_type instead of the tree's Compare function. For set/multiset, the value_type is T, while - // for map/multimap the value_type is a pair. operator< for pair can be seen by looking - // utility.h, but it basically is uses the operator< for pair.first and pair.second. The C++ standard - // appears to require this behaviour, whether intentionally or not. If anything, a good reason to do - // this is for consistency. A map and a vector that contain the same items should compare the same. - template - inline bool operator<(const rbtree& a, const rbtree& b) - { - return eastl::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); - } - - - template - inline bool operator!=(const rbtree& a, const rbtree& b) - { - return !(a == b); - } - - - template - inline bool operator>(const rbtree& a, const rbtree& b) - { - return b < a; - } - - - template - inline bool operator<=(const rbtree& a, const rbtree& b) - { - return !(b < a); - } - - - template - inline bool operator>=(const rbtree& a, const rbtree& b) - { - return !(a < b); - } - - - template - inline void swap(rbtree& a, rbtree& b) - { - a.swap(b); - } - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.cpp b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.cpp deleted file mode 100644 index a68c8700cc74..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/string.cpp -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - - -#include -#include -#include - - -namespace eastl -{ - - /// gEmptyString - /// - /// gEmptyString is used for empty strings. This allows us to avoid allocating - /// memory for empty strings without having to add null pointer checks. - /// The downside of this technique is that all empty strings share this same - /// value and if any code makes an error and writes to this value with non-zero, - /// then all existing empty strings will be wrecked and not just the one that - /// was incorrectly overwritten. - EASTL_API EmptyString gEmptyString = { 0 }; - - -} // namespace eastl diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.h deleted file mode 100644 index 05a09d416088..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/string_eastl.h +++ /dev/null @@ -1,3470 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/string.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Implements a basic_string class, much like the C++ std::basic_string. -// The primary distinctions between basic_string and std::basic_string are: -// - basic_string has a few extension functions that allow for increased performance. -// - basic_string has a few extension functions that make use easier, -// such as a member sprintf function and member tolower/toupper functions. -// - basic_string supports debug memory naming natively. -// - basic_string is easier to read, debug, and visualize. -// - basic_string internally manually expands basic functions such as begin(), -// size(), etc. in order to improve debug performance and optimizer success. -// - basic_string is savvy to an environment that doesn't have exception handling, -// as is sometimes the case with console or embedded environments. -// - basic_string has less deeply nested function calls and allows the user to -// enable forced inlining in debug builds in order to reduce bloat. -// - basic_string doesn't use char traits. As a result, EASTL assumes that -// strings will hold characters and not exotic things like widgets. At the -// very least, basic_string assumes that the value_type is a POD. -// - basic_string::size_type is defined as eastl_size_t instead of size_t in -// order to save memory and run faster on 64 bit systems. -// - basic_string data is guaranteed to be contiguous. -// - basic_string data is guaranteed to be 0-terminated, and the c_str() function -// is guaranteed to return the same pointer as the data() which is guaranteed -// to be the same value as &string[0]. -// - basic_string has a set_capacity() function which frees excess capacity. -// The only way to do this with std::basic_string is via the cryptic non-obvious -// trick of using: basic_string(x).swap(x); -// - basic_string has a force_size() function, which unilaterally moves the string -// end position (mpEnd) to the given location. Useful for when the user writes -// into the string via some extenal means such as C strcpy or sprintf. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Copy on Write (cow) -// -// This string implementation does not do copy on write (cow). This is by design, -// as cow penalizes 95% of string uses for the benefit of only 5% of the uses -// (these percentages are qualitative, not quantitative). The primary benefit of -// cow is that it allows for the sharing of string data between two string objects. -// Thus if you say this: -// string a("hello"); -// string b(a); -// the "hello" will be shared between a and b. If you then say this: -// a = "world"; -// then a will release its reference to "hello" and leave b with the only reference -// to it. Normally this functionality is accomplished via reference counting and -// with atomic operations or mutexes. -// -// The C++ standard does not say anything about basic_string and cow. However, -// for a basic_string implementation to be standards-conforming, a number of -// issues arise which dictate some things about how one would have to implement -// a cow string. The discussion of these issues will not be rehashed here, as you -// can read the references below for better detail than can be provided in the -// space we have here. However, we can say that the C++ standard is sensible and -// that anything we try to do here to allow for an efficient cow implementation -// would result in a generally unacceptable string interface. -// -// The disadvantages of cow strings are: -// - A reference count needs to exist with the string, which increases string memory usage. -// - With thread safety, atomic operations and mutex locks are expensive, especially -// on weaker memory systems such as console gaming platforms. -// - All non-const string accessor functions need to do a sharing check the the -// first such check needs to detach the string. Similarly, all string assignments -// need to do a sharing check as well. If you access the string before doing an -// assignment, the assignment doesn't result in a shared string, because the string -// has already been detached. -// - String sharing doesn't happen the large majority of the time. In some cases, -// the total sum of the reference count memory can exceed any memory savings -// gained by the strings that share representations. -// -// The addition of a string_cow class is under consideration for this library. -// There are conceivably some systems which have string usage patterns which would -// benefit from cow sharing. Such functionality is best saved for a separate string -// implementation so that the other string uses aren't penalized. -// -// References: -// This is a good starting HTML reference on the topic: -// http://www.gotw.ca/publications/optimizations.htm -// Here is a Usenet discussion on the topic: -// http://groups-beta.google.com/group/comp.lang.c++.moderated/browse_thread/thread/3dc6af5198d0bf7/886c8642cb06e03d -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_STRING_H -#define EASTL_STRING_H - - -#include -#if EASTL_ABSTRACT_STRING_ENABLED - #include -#else // 'else' encompasses the entire rest of this file. -#include -#include -#include - -#ifdef _MSC_VER - #pragma warning(push, 0) -#endif -#include // size_t, ptrdiff_t, etc. -#include // vararg functionality. -#include // malloc, free. -#include // snprintf, etc. -#include // toupper, etc. -#include // toupper, etc. -#ifdef __MWERKS__ - #include <../Include/string.h> // Force the compiler to use the std lib header. -#else - #include // strlen, etc. -#endif -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#if EASTL_EXCEPTIONS_ENABLED - #ifdef _MSC_VER - #pragma warning(push, 0) - #endif - #include // std::out_of_range, std::length_error. - #ifdef _MSC_VER - #pragma warning(pop) - #endif -#endif - -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4530) // C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc - #pragma warning(disable: 4267) // 'argument' : conversion from 'size_t' to 'const uint32_t', possible loss of data. This is a bogus warning resulting from a bug in VC++. - #pragma warning(disable: 4480) // nonstandard extension used: specifying underlying type for enum -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_STRING_EXPLICIT -// -// See EASTL_STRING_OPT_EXPLICIT_CTORS for documentation. -// -#if EASTL_STRING_OPT_EXPLICIT_CTORS - #define EASTL_STRING_EXPLICIT explicit -#else - #define EASTL_STRING_EXPLICIT -#endif -/////////////////////////////////////////////////////////////////////////////// - - - -/////////////////////////////////////////////////////////////////////////////// -// EASTL_STRING_INITIAL_CAPACITY -// -// As of this writing, this must be > 0. Note that an initially empty string -// has a capacity of zero (it allocates no memory). -// -const eastl_size_t EASTL_STRING_INITIAL_CAPACITY = 8; -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Vsnprintf8 / Vsnprintf16 -// -// The user is expected to supply these functions. Note that these functions -// are expected to accept parameters as per the C99 standard. These functions -// can deal with C99 standard return values or Microsoft non-standard return -// values but act more efficiently if implemented via the C99 style. - -extern int Vsnprintf8 (char8_t* pDestination, size_t n, const char8_t* pFormat, va_list arguments); -extern int Vsnprintf16(char16_t* pDestination, size_t n, const char16_t* pFormat, va_list arguments); -extern int Vsnprintf32(char32_t* pDestination, size_t n, const char32_t* pFormat, va_list arguments); - -namespace eastl -{ - inline int Vsnprintf(char8_t* pDestination, size_t n, const char8_t* pFormat, va_list arguments) - { return Vsnprintf8(pDestination, n, pFormat, arguments); } - - inline int Vsnprintf(char16_t* pDestination, size_t n, const char16_t* pFormat, va_list arguments) - { return Vsnprintf16(pDestination, n, pFormat, arguments); } - - inline int Vsnprintf(char32_t* pDestination, size_t n, const char32_t* pFormat, va_list arguments) - { return Vsnprintf32(pDestination, n, pFormat, arguments); } -} -/////////////////////////////////////////////////////////////////////////////// - - - -namespace eastl -{ - - /// EASTL_BASIC_STRING_DEFAULT_NAME - /// - /// Defines a default container name in the absence of a user-provided name. - /// - #ifndef EASTL_BASIC_STRING_DEFAULT_NAME - #define EASTL_BASIC_STRING_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " basic_string" // Unless the user overrides something, this is "EASTL basic_string". - #endif - - - /// EASTL_BASIC_STRING_DEFAULT_ALLOCATOR - /// - #ifndef EASTL_BASIC_STRING_DEFAULT_ALLOCATOR - #define EASTL_BASIC_STRING_DEFAULT_ALLOCATOR allocator_type(EASTL_BASIC_STRING_DEFAULT_NAME) - #endif - - - - /// gEmptyString - /// - /// Declares a shared terminating 0 representation for scalar strings that are empty. - /// - union EmptyString - { - uint32_t mUint32; - char mEmpty8[1]; - unsigned char mEmptyU8[1]; - signed char mEmptyS8[1]; - char16_t mEmpty16[1]; - char32_t mEmpty32[1]; - }; - extern EASTL_API EmptyString gEmptyString; - - inline const signed char* GetEmptyString(signed char) { return gEmptyString.mEmptyS8; } - inline const unsigned char* GetEmptyString(unsigned char) { return gEmptyString.mEmptyU8; } - inline const char* GetEmptyString(char) { return gEmptyString.mEmpty8; } - inline const char16_t* GetEmptyString(char16_t) { return gEmptyString.mEmpty16; } - inline const char32_t* GetEmptyString(char32_t) { return gEmptyString.mEmpty32; } - - - /////////////////////////////////////////////////////////////////////////////// - /// basic_string - /// - /// Implements a templated string class, somewhat like C++ std::basic_string. - /// - /// Notes: - /// As of this writing, an insert of a string into itself necessarily - /// triggers a reallocation, even if there is enough capacity in self - /// to handle the increase in size. This is due to the slightly tricky - /// nature of the operation of modifying one's self with one's self, - /// and thus the source and destination are being modified during the - /// operation. It might be useful to rectify this to the extent possible. - /// - template - class basic_string - { - public: - typedef basic_string this_type; - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T* iterator; // Maintainer note: We want to leave iterator defined as T* -- at least in release builds -- as this gives some algorithms an advantage that optimizers cannot get around. - typedef const T* const_iterator; - typedef eastl::reverse_iterator reverse_iterator; - typedef eastl::reverse_iterator const_reverse_iterator; - typedef eastl_size_t size_type; // See config.h for the definition of eastl_size_t, which defaults to uint32_t. - typedef ptrdiff_t difference_type; - typedef Allocator allocator_type; - - #if defined(_MSC_VER) && (_MSC_VER >= 1400) // _MSC_VER of 1400 means VC8 (VS2005), 1500 means VC9 (VS2008) - enum : size_type { // Use Microsoft enum language extension, allowing for smaller debug symbols than using a static const. Users have been affected by this. - npos = (size_type)-1, - kMaxSize = (size_type)-2 - }; - #else - static const size_type npos = (size_type)-1; /// 'npos' means non-valid position or simply non-position. - static const size_type kMaxSize = (size_type)-2; /// -1 is reserved for 'npos'. It also happens to be slightly beneficial that kMaxSize is a value less than -1, as it helps us deal with potential integer wraparound issues. - #endif - - enum - { - kAlignment = EASTL_ALIGN_OF(T), - kAlignmentOffset = 0 - }; - - public: - // CtorDoNotInitialize exists so that we can create a constructor that allocates but doesn't - // initialize and also doesn't collide with any other constructor declaration. - struct CtorDoNotInitialize{}; - - // CtorSprintf exists so that we can create a constructor that accepts printf-style - // arguments but also doesn't collide with any other constructor declaration. - struct CtorSprintf{}; - - protected: - value_type* mpBegin; // Begin of string. - value_type* mpEnd; // End of string. *mpEnd is always '0', as we 0-terminate our string. mpEnd is always < mpCapacity. - value_type* mpCapacity; // End of allocated space, including the space needed to store the trailing '0' char. mpCapacity is always at least mpEnd + 1. - allocator_type mAllocator; // To do: Use base class optimization to make this go away. - - public: - // Constructor, destructor - basic_string(); - explicit basic_string(const allocator_type& allocator); - basic_string(const this_type& x, size_type position, size_type n = npos); - basic_string(const value_type* p, size_type n, const allocator_type& allocator = EASTL_BASIC_STRING_DEFAULT_ALLOCATOR); - EASTL_STRING_EXPLICIT basic_string(const value_type* p, const allocator_type& allocator = EASTL_BASIC_STRING_DEFAULT_ALLOCATOR); - basic_string(size_type n, value_type c, const allocator_type& allocator = EASTL_BASIC_STRING_DEFAULT_ALLOCATOR); - basic_string(const this_type& x); - basic_string(const value_type* pBegin, const value_type* pEnd, const allocator_type& allocator = EASTL_BASIC_STRING_DEFAULT_ALLOCATOR); - basic_string(CtorDoNotInitialize, size_type n, const allocator_type& allocator = EASTL_BASIC_STRING_DEFAULT_ALLOCATOR); - basic_string(CtorSprintf, const value_type* pFormat, ...); - - ~basic_string(); - - // Allocator - const allocator_type& get_allocator() const; - allocator_type& get_allocator(); - void set_allocator(const allocator_type& allocator); - - // Operator = - this_type& operator=(const this_type& x); - this_type& operator=(const value_type* p); - this_type& operator=(value_type c); - - void swap(this_type& x); - - // Assignment operations - basic_string& assign(const basic_string& x); - basic_string& assign(const basic_string& x, size_type position, size_type n); - basic_string& assign(const value_type* p, size_type n); - basic_string& assign(const value_type* p); - basic_string& assign(size_type n, value_type c); - basic_string& assign(const value_type* pBegin, const value_type* pEnd); - - // Iterators. - iterator begin(); // Expanded in source code as: mpBegin - const_iterator begin() const; // Expanded in source code as: mpBegin - iterator end(); // Expanded in source code as: mpEnd - const_iterator end() const; // Expanded in source code as: mpEnd - - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - // Size-related functionality - bool empty() const; // Expanded in source code as: (mpBegin == mpEnd) or (mpBegin != mpEnd) - size_type size() const; // Expanded in source code as: (size_type)(mpEnd - mpBegin) - size_type length() const; // Expanded in source code as: (size_type)(mpEnd - mpBegin) - size_type max_size() const; // Expanded in source code as: kMaxSize - size_type capacity() const; // Expanded in source code as: (size_type)((mpCapacity - mpBegin) - 1) - void resize(size_type n, value_type c); - void resize(size_type n); - void reserve(size_type = 0); - void set_capacity(size_type n = npos); // Revises the capacity to the user-specified value. Resizes the container to match the capacity if the requested capacity n is less than the current size. If n == npos then the capacity is reallocated (if necessary) such that capacity == size. - void force_size(size_type n); // Unilaterally moves the string end position (mpEnd) to the given location. Useful for when the user writes into the string via some extenal means such as C strcpy or sprintf. This allows for more efficient use than using resize to achieve this. - - // Raw access - const value_type* data() const; - const value_type* c_str() const; - - // Element access - reference operator[](size_type n); - const_reference operator[](size_type n) const; - reference at(size_type n); - const_reference at(size_type n) const; - reference front(); - const_reference front() const; - reference back(); - const_reference back() const; - - // Append operations - basic_string& operator+=(const basic_string& x); - basic_string& operator+=(const value_type* p); - basic_string& operator+=(value_type c); - - basic_string& append(const basic_string& x); - basic_string& append(const basic_string& x, size_type position, size_type n); - basic_string& append(const value_type* p, size_type n); - basic_string& append(const value_type* p); - basic_string& append(size_type n, value_type c); - basic_string& append(const value_type* pBegin, const value_type* pEnd); - - basic_string& append_sprintf_va_list(const value_type* pFormat, va_list arguments); - basic_string& append_sprintf(const value_type* pFormat, ...); - - void push_back(value_type c); - void pop_back(); - - // Insertion operations - basic_string& insert(size_type position, const basic_string& x); - basic_string& insert(size_type position, const basic_string& x, size_type beg, size_type n); - basic_string& insert(size_type position, const value_type* p, size_type n); - basic_string& insert(size_type position, const value_type* p); - basic_string& insert(size_type position, size_type n, value_type c); - iterator insert(iterator p, value_type c); - void insert(iterator p, size_type n, value_type c); - void insert(iterator p, const value_type* pBegin, const value_type* pEnd); - - // Erase operations - basic_string& erase(size_type position = 0, size_type n = npos); - iterator erase(iterator p); - iterator erase(iterator pBegin, iterator pEnd); - reverse_iterator erase(reverse_iterator position); - reverse_iterator erase(reverse_iterator first, reverse_iterator last); - void clear(); - void reset(); // This is a unilateral reset to an initially empty state. No destructors are called, no deallocation occurs. - - //Replacement operations - basic_string& replace(size_type position, size_type n, const basic_string& x); - basic_string& replace(size_type pos1, size_type n1, const basic_string& x, size_type pos2, size_type n2); - basic_string& replace(size_type position, size_type n1, const value_type* p, size_type n2); - basic_string& replace(size_type position, size_type n1, const value_type* p); - basic_string& replace(size_type position, size_type n1, size_type n2, value_type c); - basic_string& replace(iterator first, iterator last, const basic_string& x); - basic_string& replace(iterator first, iterator last, const value_type* p, size_type n); - basic_string& replace(iterator first, iterator last, const value_type* p); - basic_string& replace(iterator first, iterator last, size_type n, value_type c); - basic_string& replace(iterator first, iterator last, const value_type* pBegin, const value_type* pEnd); - size_type copy(value_type* p, size_type n, size_type position = 0) const; - - // Find operations - size_type find(const basic_string& x, size_type position = 0) const; - size_type find(const value_type* p, size_type position = 0) const; - size_type find(const value_type* p, size_type position, size_type n) const; - size_type find(value_type c, size_type position = 0) const; - - // Reverse find operations - size_type rfind(const basic_string& x, size_type position = npos) const; - size_type rfind(const value_type* p, size_type position = npos) const; - size_type rfind(const value_type* p, size_type position, size_type n) const; - size_type rfind(value_type c, size_type position = npos) const; - - // Find first-of operations - size_type find_first_of(const basic_string& x, size_type position = 0) const; - size_type find_first_of(const value_type* p, size_type position = 0) const; - size_type find_first_of(const value_type* p, size_type position, size_type n) const; - size_type find_first_of(value_type c, size_type position = 0) const; - - // Find last-of operations - size_type find_last_of(const basic_string& x, size_type position = npos) const; - size_type find_last_of(const value_type* p, size_type position = npos) const; - size_type find_last_of(const value_type* p, size_type position, size_type n) const; - size_type find_last_of(value_type c, size_type position = npos) const; - - // Find first not-of operations - size_type find_first_not_of(const basic_string& x, size_type position = 0) const; - size_type find_first_not_of(const value_type* p, size_type position = 0) const; - size_type find_first_not_of(const value_type* p, size_type position, size_type n) const; - size_type find_first_not_of(value_type c, size_type position = 0) const; - - // Find last not-of operations - size_type find_last_not_of(const basic_string& x, size_type position = npos) const; - size_type find_last_not_of(const value_type* p, size_type position = npos) const; - size_type find_last_not_of(const value_type* p, size_type position, size_type n) const; - size_type find_last_not_of(value_type c, size_type position = npos) const; - - // Substring functionality - basic_string substr(size_type position = 0, size_type n = npos) const; - - // Comparison operations - int compare(const basic_string& x) const; - int compare(size_type pos1, size_type n1, const basic_string& x) const; - int compare(size_type pos1, size_type n1, const basic_string& x, size_type pos2, size_type n2) const; - int compare(const value_type* p) const; - int compare(size_type pos1, size_type n1, const value_type* p) const; - int compare(size_type pos1, size_type n1, const value_type* p, size_type n2) const; - static int compare(const value_type* pBegin1, const value_type* pEnd1, const value_type* pBegin2, const value_type* pEnd2); - - // Case-insensitive comparison functions. Not part of C++ basic_string. Only ASCII-level locale functionality is supported. Thus this is not suitable for localization purposes. - int comparei(const basic_string& x) const; - int comparei(const value_type* p) const; - static int comparei(const value_type* pBegin1, const value_type* pEnd1, const value_type* pBegin2, const value_type* pEnd2); - - // Misc functionality, not part of C++ basic_string. - void make_lower(); - void make_upper(); - void ltrim(); - void rtrim(); - void trim(); - basic_string left(size_type n) const; - basic_string right(size_type n) const; - basic_string& sprintf_va_list(const value_type* pFormat, va_list arguments); - basic_string& sprintf(const value_type* pFormat, ...); - - bool validate() const; - int validate_iterator(const_iterator i) const; - - protected: - // Helper functions for initialization/insertion operations. - value_type* DoAllocate(size_type n); - void DoFree(value_type* p, size_type n); - size_type GetNewCapacity(size_type currentCapacity); - - void AllocateSelf(); - void AllocateSelf(size_type n); - void DeallocateSelf(); - iterator InsertInternal(iterator p, value_type c); - void RangeInitialize(const value_type* pBegin, const value_type* pEnd); - void RangeInitialize(const value_type* pBegin); - void SizeInitialize(size_type n, value_type c); - void ThrowLengthException() const; - void ThrowRangeException() const; - void ThrowInvalidArgumentException() const; - - // Replacements for STL template functions. - static const value_type* CharTypeStringFindEnd(const value_type* pBegin, const value_type* pEnd, value_type c); - static const value_type* CharTypeStringRFind(const value_type* pRBegin, const value_type* pREnd, const value_type c); - static const value_type* CharTypeStringSearch(const value_type* p1Begin, const value_type* p1End, const value_type* p2Begin, const value_type* p2End); - static const value_type* CharTypeStringRSearch(const value_type* p1Begin, const value_type* p1End, const value_type* p2Begin, const value_type* p2End); - static const value_type* CharTypeStringFindFirstOf(const value_type* p1Begin, const value_type* p1End, const value_type* p2Begin, const value_type* p2End); - static const value_type* CharTypeStringRFindFirstOf(const value_type* p1RBegin, const value_type* p1REnd, const value_type* p2Begin, const value_type* p2End); - static const value_type* CharTypeStringFindFirstNotOf(const value_type* p1Begin, const value_type* p1End, const value_type* p2Begin, const value_type* p2End); - static const value_type* CharTypeStringRFindFirstNotOf(const value_type* p1RBegin, const value_type* p1REnd, const value_type* p2Begin, const value_type* p2End); - - }; // basic_string - - - - - /////////////////////////////////////////////////////////////////////////////// - // 'char traits' functionality - // - inline char8_t CharToLower(char8_t c) - { return (char8_t)tolower((uint8_t)c); } - - inline char16_t CharToLower(char16_t c) - { if((unsigned)c <= 0xff) return (char16_t)tolower((uint8_t)c); return c; } - - inline char32_t CharToLower(char32_t c) - { if((unsigned)c <= 0xff) return (char32_t)tolower((uint8_t)c); return c; } - - - - inline char8_t CharToUpper(char8_t c) - { return (char8_t)toupper((uint8_t)c); } - - inline char16_t CharToUpper(char16_t c) - { if((unsigned)c <= 0xff) return (char16_t)toupper((uint8_t)c); return c; } - - inline char32_t CharToUpper(char32_t c) - { if((unsigned)c <= 0xff) return (char32_t)toupper((uint8_t)c); return c; } - - - - template - int Compare(const T* p1, const T* p2, size_t n) - { - for(; n > 0; ++p1, ++p2, --n) - { - if(*p1 != *p2) - return (*p1 < *p2) ? -1 : 1; - } - return 0; - } - - inline int Compare(const char8_t* p1, const char8_t* p2, size_t n) - { - return memcmp(p1, p2, n); - } - - template - inline int CompareI(const T* p1, const T* p2, size_t n) - { - for(; n > 0; ++p1, ++p2, --n) - { - const T c1 = CharToLower(*p1); - const T c2 = CharToLower(*p2); - - if(c1 != c2) - return (c1 < c2) ? -1 : 1; - } - return 0; - } - - - inline const char8_t* Find(const char8_t* p, char8_t c, size_t n) - { - return (const char8_t*)memchr(p, c, n); - } - - inline const char16_t* Find(const char16_t* p, char16_t c, size_t n) - { - for(; n > 0; --n, ++p) - { - if(*p == c) - return p; - } - - return NULL; - } - - inline const char32_t* Find(const char32_t* p, char32_t c, size_t n) - { - for(; n > 0; --n, ++p) - { - if(*p == c) - return p; - } - - return NULL; - } - - - inline size_t CharStrlen(const char8_t* p) - { - #ifdef _MSC_VER // VC++ can implement an instrinsic here. - return strlen(p); - #else - const char8_t* pCurrent = p; - while(*pCurrent) - ++pCurrent; - return (size_t)(pCurrent - p); - #endif - } - - inline size_t CharStrlen(const char16_t* p) - { - const char16_t* pCurrent = p; - while(*pCurrent) - ++pCurrent; - return (size_t)(pCurrent - p); - } - - inline size_t CharStrlen(const char32_t* p) - { - const char32_t* pCurrent = p; - while(*pCurrent) - ++pCurrent; - return (size_t)(pCurrent - p); - } - - - template - inline T* CharStringUninitializedCopy(const T* pSource, const T* pSourceEnd, T* pDestination) - { - memmove(pDestination, pSource, (size_t)(pSourceEnd - pSource) * sizeof(T)); - return pDestination + (pSourceEnd - pSource); - } - - - - - inline char8_t* CharStringUninitializedFillN(char8_t* pDestination, size_t n, const char8_t c) - { - if(n) // Some compilers (e.g. GCC 4.3+) generate a warning (which can't be disabled) if you call memset with a size of 0. - memset(pDestination, (uint8_t)c, (size_t)n); - return pDestination + n; - } - - inline char16_t* CharStringUninitializedFillN(char16_t* pDestination, size_t n, const char16_t c) - { - char16_t* pDest16 = pDestination; - const char16_t* const pEnd = pDestination + n; - while(pDest16 < pEnd) - *pDest16++ = c; - return pDestination + n; - } - - inline char32_t* CharStringUninitializedFillN(char32_t* pDestination, size_t n, const char32_t c) - { - char32_t* pDest32 = pDestination; - const char32_t* const pEnd = pDestination + n; - while(pDest32 < pEnd) - *pDest32++ = c; - return pDestination + n; - } - - - - inline char8_t* CharTypeAssignN(char8_t* pDestination, size_t n, char8_t c) - { - if(n) // Some compilers (e.g. GCC 4.3+) generate a warning (which can't be disabled) if you call memset with a size of 0. - return (char8_t*)memset(pDestination, c, (size_t)n); - return pDestination; - } - - inline char16_t* CharTypeAssignN(char16_t* pDestination, size_t n, char16_t c) - { - char16_t* pDest16 = pDestination; - const char16_t* const pEnd = pDestination + n; - while(pDest16 < pEnd) - *pDest16++ = c; - return pDestination; - } - - inline char32_t* CharTypeAssignN(char32_t* pDestination, size_t n, char32_t c) - { - char32_t* pDest32 = pDestination; - const char32_t* const pEnd = pDestination + n; - while(pDest32 < pEnd) - *pDest32++ = c; - return pDestination; - } - - - - /////////////////////////////////////////////////////////////////////////////// - // basic_string - /////////////////////////////////////////////////////////////////////////////// - - template - inline basic_string::basic_string() - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(EASTL_BASIC_STRING_DEFAULT_NAME) - { - AllocateSelf(); - } - - - template - inline basic_string::basic_string(const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - AllocateSelf(); - } - - - template - inline basic_string::basic_string(const this_type& x) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(x.mAllocator) - { - RangeInitialize(x.mpBegin, x.mpEnd); - } - - - template - basic_string::basic_string(const this_type& x, size_type position, size_type n) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(x.mAllocator) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(x.mpEnd - x.mpBegin))) - { - ThrowRangeException(); - AllocateSelf(); - } - else - RangeInitialize(x.mpBegin + position, x.mpBegin + position + eastl::min_alt(n, (size_type)(x.mpEnd - x.mpBegin) - position)); - #else - RangeInitialize(x.mpBegin + position, x.mpBegin + position + eastl::min_alt(n, (size_type)(x.mpEnd - x.mpBegin) - position)); - #endif - } - - - template - inline basic_string::basic_string(const value_type* p, size_type n, const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - RangeInitialize(p, p + n); - } - - - template - inline basic_string::basic_string(const value_type* p, const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - RangeInitialize(p); - } - - - template - inline basic_string::basic_string(size_type n, value_type c, const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - SizeInitialize(n, c); - } - - - template - inline basic_string::basic_string(const value_type* pBegin, const value_type* pEnd, const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - RangeInitialize(pBegin, pEnd); - } - - - // CtorDoNotInitialize exists so that we can create a version that allocates but doesn't - // initialize but also doesn't collide with any other constructor declaration. - template - basic_string::basic_string(CtorDoNotInitialize /*unused*/, size_type n, const allocator_type& allocator) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator(allocator) - { - // Note that we do not call SizeInitialize here. - AllocateSelf(n + 1); // '+1' so that we have room for the terminating 0. - *mpEnd = 0; - } - - - // CtorSprintf exists so that we can create a version that does a variable argument - // sprintf but also doesn't collide with any other constructor declaration. - template - basic_string::basic_string(CtorSprintf /*unused*/, const value_type* pFormat, ...) - : mpBegin(NULL), - mpEnd(NULL), - mpCapacity(NULL), - mAllocator() - { - const size_type n = (size_type)CharStrlen(pFormat) + 1; // We'll need at least this much. '+1' so that we have room for the terminating 0. - AllocateSelf(n); - - va_list arguments; - va_start(arguments, pFormat); - append_sprintf_va_list(pFormat, arguments); - va_end(arguments); - } - - - template - inline basic_string::~basic_string() - { - DeallocateSelf(); - } - - - template - inline const typename basic_string::allocator_type& - basic_string::get_allocator() const - { - return mAllocator; - } - - - template - inline typename basic_string::allocator_type& - basic_string::get_allocator() - { - return mAllocator; - } - - - template - inline void basic_string::set_allocator(const allocator_type& allocator) - { - mAllocator = allocator; - } - - - template - inline const typename basic_string::value_type* - basic_string::data() const - { - return mpBegin; - } - - - template - inline const typename basic_string::value_type* - basic_string::c_str() const - { - return mpBegin; - } - - - template - inline typename basic_string::iterator - basic_string::begin() - { - return mpBegin; - } - - - template - inline typename basic_string::iterator - basic_string::end() - { - return mpEnd; - } - - - template - inline typename basic_string::const_iterator - basic_string::begin() const - { - return mpBegin; - } - - - template - inline typename basic_string::const_iterator - basic_string::end() const - { - return mpEnd; - } - - - template - inline typename basic_string::reverse_iterator - basic_string::rbegin() - { - return reverse_iterator(mpEnd); - } - - - template - inline typename basic_string::reverse_iterator - basic_string::rend() - { - return reverse_iterator(mpBegin); - } - - - template - inline typename basic_string::const_reverse_iterator - basic_string::rbegin() const - { - return const_reverse_iterator(mpEnd); - } - - - template - inline typename basic_string::const_reverse_iterator - basic_string::rend() const - { - return const_reverse_iterator(mpBegin); - } - - - template - inline bool basic_string::empty() const - { - return (mpBegin == mpEnd); - } - - - template - inline typename basic_string::size_type - basic_string::size() const - { - return (size_type)(mpEnd - mpBegin); - } - - - template - inline typename basic_string::size_type - basic_string::length() const - { - return (size_type)(mpEnd - mpBegin); - } - - - template - inline typename basic_string::size_type - basic_string::max_size() const - { - return kMaxSize; - } - - - template - inline typename basic_string::size_type - basic_string::capacity() const - { - return (size_type)((mpCapacity - mpBegin) - 1); // '-1' because we pretend that we didn't allocate memory for the terminating 0. - } - - - template - inline typename basic_string::const_reference - basic_string::operator[](size_type n) const - { - #if EASTL_ASSERT_ENABLED // We allow the user to reference the trailing 0 char without asserting. Perhaps we shouldn't. - if(EASTL_UNLIKELY(n > (static_cast(mpEnd - mpBegin)))) - EASTL_FAIL_MSG("basic_string::operator[] -- out of range"); - #endif - - return mpBegin[n]; // Sometimes done as *(mpBegin + n) - } - - - template - inline typename basic_string::reference - basic_string::operator[](size_type n) - { - #if EASTL_ASSERT_ENABLED // We allow the user to reference the trailing 0 char without asserting. Perhaps we shouldn't. - if(EASTL_UNLIKELY(n > (static_cast(mpEnd - mpBegin)))) - EASTL_FAIL_MSG("basic_string::operator[] -- out of range"); - #endif - - return mpBegin[n]; // Sometimes done as *(mpBegin + n) - } - - - template - inline typename basic_string::this_type& basic_string::operator=(const basic_string& x) - { - if(&x != this) - { - #if EASTL_ALLOCATOR_COPY_ENABLED - mAllocator = x.mAllocator; - #endif - - assign(x.mpBegin, x.mpEnd); - } - return *this; - } - - - template - inline typename basic_string::this_type& basic_string::operator=(const value_type* p) - { - return assign(p, p + CharStrlen(p)); - } - - - template - inline typename basic_string::this_type& basic_string::operator=(value_type c) - { - return assign((size_type)1, c); - } - - - template - void basic_string::resize(size_type n, value_type c) - { - const size_type s = (size_type)(mpEnd - mpBegin); - - if(n < s) - erase(mpBegin + n, mpEnd); - else if(n > s) - append(n - s, c); - } - - - template - void basic_string::resize(size_type n) - { - // C++ basic_string specifies that resize(n) is equivalent to resize(n, value_type()). - // For built-in types, value_type() is the same as zero (value_type(0)). - // We can improve the efficiency (especially for long strings) of this - // string class by resizing without assigning to anything. - - const size_type s = (size_type)(mpEnd - mpBegin); - - if(n < s) - erase(mpBegin + n, mpEnd); - else if(n > s) - { - #if EASTL_STRING_OPT_CHAR_INIT - append(n - s, value_type()); - #else - append(n - s); - #endif - } - } - - - template - void basic_string::reserve(size_type n) - { - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY(n > kMaxSize)) - ThrowLengthException(); - #endif - - // The C++ standard for basic_string doesn't specify if we should or shouldn't - // downsize the container. The standard is overly vague in its description of reserve: - // The member function reserve() is a directive that informs a - // basic_string object of a planned change in size, so that it - // can manage the storage allocation accordingly. - // We will act like the vector container and preserve the contents of - // the container and only reallocate if increasing the size. The user - // can use the set_capacity function to reduce the capacity. - - n = eastl::max_alt(n, (size_type)(mpEnd - mpBegin)); // Calculate the new capacity, which needs to be >= container size. - - if(n >= (size_type)(mpCapacity - mpBegin)) // If there is something to do... // We use >= because mpCapacity accounts for the trailing zero. - set_capacity(n); - } - - - template - inline void basic_string::set_capacity(size_type n) - { - if(n == npos) // If the user wants to set the capacity to equal the current size... // '-1' because we pretend that we didn't allocate memory for the terminating 0. - n = (size_type)(mpEnd - mpBegin); - else if(n < (size_type)(mpEnd - mpBegin)) - mpEnd = mpBegin + n; - - if(n != (size_type)((mpCapacity - mpBegin) - 1)) // If there is any capacity change... - { - if(n) - { - pointer pNewBegin = DoAllocate(n + 1); // We need the + 1 to accomodate the trailing 0. - pointer pNewEnd = pNewBegin; - - pNewEnd = CharStringUninitializedCopy(mpBegin, mpEnd, pNewBegin); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + (n + 1); - } - else - { - DeallocateSelf(); - AllocateSelf(); - } - } - } - - - template - inline void basic_string::force_size(size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(n >= (size_type)(mpCapacity - mpBegin))) - ThrowRangeException(); - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(n >= (size_type)(mpCapacity - mpBegin))) - EASTL_FAIL_MSG("basic_string::force_size -- out of range"); - #endif - - mpEnd = mpBegin + n; - } - - - template - inline void basic_string::clear() - { - if(mpBegin != mpEnd) - { - *mpBegin = value_type(0); - mpEnd = mpBegin; - } - } - - - template - inline void basic_string::reset() - { - // The reset function is a special extension function which unilaterally - // resets the container to an empty state without freeing the memory of - // the contained objects. This is useful for very quickly tearing down a - // container built into scratch memory. - AllocateSelf(); - } - - - template - inline typename basic_string::const_reference - basic_string::at(size_type n) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(n >= (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #elif EASTL_ASSERT_ENABLED // We assert if the user references the trailing 0 char. - if(EASTL_UNLIKELY(n >= (size_type)(mpEnd - mpBegin))) - EASTL_FAIL_MSG("basic_string::at -- out of range"); - #endif - - return mpBegin[n]; - } - - - template - inline typename basic_string::reference - basic_string::at(size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(n >= (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #elif EASTL_ASSERT_ENABLED // We assert if the user references the trailing 0 char. - if(EASTL_UNLIKELY(n >= (size_type)(mpEnd - mpBegin))) - EASTL_FAIL_MSG("basic_string::at -- out of range"); - #endif - - return mpBegin[n]; - } - - - template - inline typename basic_string::reference - basic_string::front() - { - #if EASTL_EMPTY_REFERENCE_ASSERT_ENABLED - // We allow the user to reference the trailing 0 char without asserting. - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(mpEnd <= mpBegin)) // We assert if the user references the trailing 0 char. - EASTL_FAIL_MSG("basic_string::front -- empty string"); - #endif - - return *mpBegin; - } - - - template - inline typename basic_string::const_reference - basic_string::front() const - { - #if EASTL_EMPTY_REFERENCE_ASSERT_ENABLED - // We allow the user to reference the trailing 0 char without asserting. - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(mpEnd <= mpBegin)) // We assert if the user references the trailing 0 char. - EASTL_FAIL_MSG("basic_string::front -- empty string"); - #endif - - return *mpBegin; - } - - - template - inline typename basic_string::reference - basic_string::back() - { - #if EASTL_EMPTY_REFERENCE_ASSERT_ENABLED - // We allow the user to reference the trailing 0 char without asserting. - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(mpEnd <= mpBegin)) // We assert if the user references the trailing 0 char. - EASTL_FAIL_MSG("basic_string::back -- empty string"); - #endif - - return *(mpEnd - 1); - } - - - template - inline typename basic_string::const_reference - basic_string::back() const - { - #if EASTL_EMPTY_REFERENCE_ASSERT_ENABLED - // We allow the user to reference the trailing 0 char without asserting. - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(mpEnd <= mpBegin)) // We assert if the user references the trailing 0 char. - EASTL_FAIL_MSG("basic_string::back -- empty string"); - #endif - - return *(mpEnd - 1); - } - - - template - inline basic_string& basic_string::operator+=(const basic_string& x) - { - return append(x); - } - - - template - inline basic_string& basic_string::operator+=(const value_type* p) - { - return append(p); - } - - - template - inline basic_string& basic_string::operator+=(value_type c) - { - push_back(c); - return *this; - } - - - template - inline basic_string& basic_string::append(const basic_string& x) - { - return append(x.mpBegin, x.mpEnd); - } - - - template - inline basic_string& basic_string::append(const basic_string& x, size_type position, size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(x.mpEnd - x.mpBegin))) - ThrowRangeException(); - #endif - - return append(x.mpBegin + position, x.mpBegin + position + eastl::min_alt(n, (size_type)(x.mpEnd - x.mpBegin) - position)); - } - - - template - inline basic_string& basic_string::append(const value_type* p, size_type n) - { - return append(p, p + n); - } - - - template - inline basic_string& basic_string::append(const value_type* p) - { - return append(p, p + CharStrlen(p)); - } - - - template - basic_string& basic_string::append(size_type n, value_type c) - { - const size_type s = (size_type)(mpEnd - mpBegin); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((n > kMaxSize) || (s > (kMaxSize - n)))) - ThrowLengthException(); - #endif - - const size_type nCapacity = (size_type)((mpCapacity - mpBegin) - 1); - - if((s + n) > nCapacity) - reserve(eastl::max_alt((size_type)GetNewCapacity(nCapacity), (size_type)(s + n))); - - if(n > 0) - { - CharStringUninitializedFillN(mpEnd + 1, n - 1, c); - *mpEnd = c; - mpEnd += n; - *mpEnd = 0; - } - - return *this; - } - - - template - basic_string& basic_string::append(const value_type* pBegin, const value_type* pEnd) - { - if(pBegin != pEnd) - { - const size_type nOldSize = (size_type)(mpEnd - mpBegin); - const size_type n = (size_type)(pEnd - pBegin); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY(((size_t)n > kMaxSize) || (nOldSize > (kMaxSize - n)))) - ThrowLengthException(); - #endif - - const size_type nCapacity = (size_type)((mpCapacity - mpBegin) - 1); - - if((nOldSize + n) > nCapacity) - { - const size_type nLength = eastl::max_alt((size_type)GetNewCapacity(nCapacity), (size_type)(nOldSize + n)) + 1; // + 1 to accomodate the trailing 0. - - pointer pNewBegin = DoAllocate(nLength); - pointer pNewEnd = pNewBegin; - - pNewEnd = CharStringUninitializedCopy(mpBegin, mpEnd, pNewBegin); - pNewEnd = CharStringUninitializedCopy(pBegin, pEnd, pNewEnd); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + nLength; - } - else - { - const value_type* pTemp = pBegin; - ++pTemp; - CharStringUninitializedCopy(pTemp, pEnd, mpEnd + 1); - mpEnd[n] = 0; - *mpEnd = *pBegin; - mpEnd += n; - } - } - - return *this; - } - - - template - basic_string& basic_string::append_sprintf_va_list(const value_type* pFormat, va_list arguments) - { - // From unofficial C89 extension documentation: - // The vsnprintf returns the number of characters written into the array, - // not counting the terminating null character, or a negative value - // if count or more characters are requested to be generated. - // An error can occur while converting a value for output. - - // From the C99 standard: - // The vsnprintf function returns the number of characters that would have - // been written had n been sufficiently large, not counting the terminating - // null character, or a negative value if an encoding error occurred. - // Thus, the null-terminated output has been completely written if and only - // if the returned value is nonnegative and less than n. - size_type nInitialSize = (size_type)(mpEnd - mpBegin); - int nReturnValue; - - #if EASTL_VA_COPY_ENABLED - va_list argumentsSaved; - va_copy(argumentsSaved, arguments); - #endif - - if(mpBegin == GetEmptyString(value_type())) // We need to do this because non-standard vsnprintf implementations will otherwise overwrite gEmptyString with a non-zero char. - nReturnValue = eastl::Vsnprintf(mpEnd, 0, pFormat, arguments); - else - nReturnValue = eastl::Vsnprintf(mpEnd, (size_t)(mpCapacity - mpEnd), pFormat, arguments); - - if(nReturnValue >= (int)(mpCapacity - mpEnd)) // If there wasn't enough capacity... - { - // In this case we definitely have C99 Vsnprintf behaviour. - #if EASTL_VA_COPY_ENABLED - va_copy(arguments, argumentsSaved); - #endif - resize(nInitialSize + nReturnValue); - nReturnValue = eastl::Vsnprintf(mpBegin + nInitialSize, (size_t)(nReturnValue + 1), pFormat, arguments); // '+1' because vsnprintf wants to know the size of the buffer including the terminating zero. - } - else if(nReturnValue < 0) // If vsnprintf is non-C99-standard (e.g. it is VC++ _vsnprintf)... - { - // In this case we either have C89 extension behaviour or C99 behaviour. - size_type n = eastl::max_alt((size_type)(EASTL_STRING_INITIAL_CAPACITY - 1), (size_type)(size() * 2)); // '-1' because the resize call below will add one for NULL terminator and we want to keep allocations on fixed block sizes. - - for(; (nReturnValue < 0) && (n < 1000000); n *= 2) - { - #if EASTL_VA_COPY_ENABLED - va_copy(arguments, argumentsSaved); - #endif - resize(n); - - const size_t nCapacity = (size_t)((n + 1) - nInitialSize); - nReturnValue = eastl::Vsnprintf(mpBegin + nInitialSize, nCapacity, pFormat, arguments); // '+1' because vsnprintf wants to know the size of the buffer including the terminating zero. - - if(nReturnValue == (int)(unsigned)nCapacity) - { - resize(++n); - nReturnValue = eastl::Vsnprintf(mpBegin + nInitialSize, nCapacity + 1, pFormat, arguments); - } - } - } - - if(nReturnValue >= 0) - mpEnd = mpBegin + nInitialSize + nReturnValue; // We are guaranteed from the above logic that mpEnd <= mpCapacity. - - return *this; - } - - template - basic_string& basic_string::append_sprintf(const value_type* pFormat, ...) - { - va_list arguments; - va_start(arguments, pFormat); - append_sprintf_va_list(pFormat, arguments); - va_end(arguments); - - return *this; - } - - - template - inline void basic_string::push_back(value_type c) - { - if((mpEnd + 1) == mpCapacity) // If we are out of space... (note that we test for + 1 because we have a trailing 0) - reserve(eastl::max_alt(GetNewCapacity((size_type)((mpCapacity - mpBegin) - 1)), (size_type)(mpEnd - mpBegin) + 1)); - *mpEnd++ = c; - *mpEnd = 0; - } - - - template - inline void basic_string::pop_back() - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(mpEnd <= mpBegin)) - EASTL_FAIL_MSG("basic_string::pop_back -- empty string"); - #endif - - mpEnd[-1] = value_type(0); - --mpEnd; - } - - - template - inline basic_string& basic_string::assign(const basic_string& x) - { - return assign(x.mpBegin, x.mpEnd); - } - - - template - inline basic_string& basic_string::assign(const basic_string& x, size_type position, size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(x.mpEnd - x.mpBegin))) - ThrowRangeException(); - #endif - - return assign(x.mpBegin + position, x.mpBegin + position + eastl::min_alt(n, (size_type)(x.mpEnd - x.mpBegin) - position)); - } - - - template - inline basic_string& basic_string::assign(const value_type* p, size_type n) - { - return assign(p, p + n); - } - - - template - inline basic_string& basic_string::assign(const value_type* p) - { - return assign(p, p + CharStrlen(p)); - } - - - template - basic_string& basic_string::assign(size_type n, value_type c) - { - if(n <= (size_type)(mpEnd - mpBegin)) - { - CharTypeAssignN(mpBegin, n, c); - erase(mpBegin + n, mpEnd); - } - else - { - CharTypeAssignN(mpBegin, (size_type)(mpEnd - mpBegin), c); - append(n - (size_type)(mpEnd - mpBegin), c); - } - return *this; - } - - - template - basic_string& basic_string::assign(const value_type* pBegin, const value_type* pEnd) - { - const ptrdiff_t n = pEnd - pBegin; - if(static_cast(n) <= (size_type)(mpEnd - mpBegin)) - { - memmove(mpBegin, pBegin, (size_t)n * sizeof(value_type)); - erase(mpBegin + n, mpEnd); - } - else - { - memmove(mpBegin, pBegin, (size_t)(mpEnd - mpBegin) * sizeof(value_type)); - append(pBegin + (size_type)(mpEnd - mpBegin), pEnd); - } - return *this; - } - - - template - basic_string& basic_string::insert(size_type position, const basic_string& x) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((size_type)(mpEnd - mpBegin) > (kMaxSize - (size_type)(x.mpEnd - x.mpBegin)))) - ThrowLengthException(); - #endif - - insert(mpBegin + position, x.mpBegin, x.mpEnd); - return *this; - } - - - template - basic_string& basic_string::insert(size_type position, const basic_string& x, size_type beg, size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY((position > (size_type)(mpEnd - mpBegin)) || (beg > (size_type)(x.mpEnd - x.mpBegin)))) - ThrowRangeException(); - #endif - - size_type nLength = eastl::min_alt(n, (size_type)(x.mpEnd - x.mpBegin) - beg); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((size_type)(mpEnd - mpBegin) > (kMaxSize - nLength))) - ThrowLengthException(); - #endif - - insert(mpBegin + position, x.mpBegin + beg, x.mpBegin + beg + nLength); - return *this; - } - - - template - basic_string& basic_string::insert(size_type position, const value_type* p, size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((size_type)(mpEnd - mpBegin) > (kMaxSize - n))) - ThrowLengthException(); - #endif - - insert(mpBegin + position, p, p + n); - return *this; - } - - - template - basic_string& basic_string::insert(size_type position, const value_type* p) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - size_type nLength = (size_type)CharStrlen(p); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((size_type)(mpEnd - mpBegin) > (kMaxSize - nLength))) - ThrowLengthException(); - #endif - - insert(mpBegin + position, p, p + nLength); - return *this; - } - - - template - basic_string& basic_string::insert(size_type position, size_type n, value_type c) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((size_type)(mpEnd - mpBegin) > (kMaxSize - n))) - ThrowLengthException(); - #endif - - insert(mpBegin + position, n, c); - return *this; - } - - - template - inline typename basic_string::iterator - basic_string::insert(iterator p, value_type c) - { - if(p == mpEnd) - { - push_back(c); - return mpEnd - 1; - } - return InsertInternal(p, c); - } - - - template - void basic_string::insert(iterator p, size_type n, value_type c) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((p < mpBegin) || (p > mpEnd))) - EASTL_FAIL_MSG("basic_string::insert -- invalid position"); - #endif - - if(n) // If there is anything to insert... - { - if(size_type(mpCapacity - mpEnd) >= (n + 1)) // If we have enough capacity... - { - const size_type nElementsAfter = (size_type)(mpEnd - p); - iterator pOldEnd = mpEnd; - - if(nElementsAfter >= n) // If there's enough space for the new chars between the insert position and the end... - { - CharStringUninitializedCopy((mpEnd - n) + 1, mpEnd + 1, mpEnd + 1); - mpEnd += n; - memmove(p + n, p, (size_t)((nElementsAfter - n) + 1) * sizeof(value_type)); - CharTypeAssignN(p, n, c); - } - else - { - CharStringUninitializedFillN(mpEnd + 1, n - nElementsAfter - 1, c); - mpEnd += n - nElementsAfter; - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - CharStringUninitializedCopy(p, pOldEnd + 1, mpEnd); - mpEnd += nElementsAfter; - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - mpEnd = pOldEnd; - throw; - } - #endif - - CharTypeAssignN(p, nElementsAfter + 1, c); - } - } - else - { - const size_type nOldSize = (size_type)(mpEnd - mpBegin); - const size_type nOldCap = (size_type)((mpCapacity - mpBegin) - 1); - const size_type nLength = eastl::max_alt((size_type)GetNewCapacity(nOldCap), (size_type)(nOldSize + n)) + 1; // + 1 to accomodate the trailing 0. - - iterator pNewBegin = DoAllocate(nLength); - iterator pNewEnd = pNewBegin; - - pNewEnd = CharStringUninitializedCopy(mpBegin, p, pNewBegin); - pNewEnd = CharStringUninitializedFillN(pNewEnd, n, c); - pNewEnd = CharStringUninitializedCopy(p, mpEnd, pNewEnd); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + nLength; - } - } - } - - - template - void basic_string::insert(iterator p, const value_type* pBegin, const value_type* pEnd) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((p < mpBegin) || (p > mpEnd))) - EASTL_FAIL_MSG("basic_string::insert -- invalid position"); - #endif - - const size_type n = (size_type)(pEnd - pBegin); - - if(n) - { - const bool bCapacityIsSufficient = ((mpCapacity - mpEnd) >= (difference_type)(n + 1)); - const bool bSourceIsFromSelf = ((pEnd >= mpBegin) && (pBegin <= mpEnd)); - - // If bSourceIsFromSelf is true, then we reallocate. This is because we are - // inserting ourself into ourself and thus both the source and destination - // be modified, making it rather tricky to attempt to do in place. The simplest - // resolution is to reallocate. To consider: there may be a way to implement this - // whereby we don't need to reallocate or can often avoid reallocating. - if(bCapacityIsSufficient && !bSourceIsFromSelf) - { - const ptrdiff_t nElementsAfter = (mpEnd - p); - iterator pOldEnd = mpEnd; - - if(nElementsAfter >= (ptrdiff_t)n) // If the newly inserted characters entirely fit within the size of the original string... - { - memmove(mpEnd + 1, mpEnd - n + 1, (size_t)n * sizeof(value_type)); - mpEnd += n; - memmove(p + n, p, (size_t)((nElementsAfter - n) + 1) * sizeof(value_type)); - memmove(p, pBegin, (size_t)(pEnd - pBegin) * sizeof(value_type)); - } - else - { - const value_type* const pMid = pBegin + (nElementsAfter + 1); - - memmove(mpEnd + 1, pMid, (size_t)(pEnd - pMid) * sizeof(value_type)); - mpEnd += n - nElementsAfter; - - #if EASTL_EXCEPTIONS_ENABLED - try - { - #endif - memmove(mpEnd, p, (size_t)(pOldEnd - p + 1) * sizeof(value_type)); - mpEnd += nElementsAfter; - #if EASTL_EXCEPTIONS_ENABLED - } - catch(...) - { - mpEnd = pOldEnd; - throw; - } - #endif - - memmove(p, pBegin, (size_t)(pMid - pBegin) * sizeof(value_type)); - } - } - else // Else we need to reallocate to implement this. - { - const size_type nOldSize = (size_type)(mpEnd - mpBegin); - const size_type nOldCap = (size_type)((mpCapacity - mpBegin) - 1); - size_type nLength; - - if(bCapacityIsSufficient) // If bCapacityIsSufficient is true, then bSourceIsFromSelf must be false. - nLength = nOldSize + n + 1; // + 1 to accomodate the trailing 0. - else - nLength = eastl::max_alt((size_type)GetNewCapacity(nOldCap), (size_type)(nOldSize + n)) + 1; // + 1 to accomodate the trailing 0. - - pointer pNewBegin = DoAllocate(nLength); - pointer pNewEnd = pNewBegin; - - pNewEnd = CharStringUninitializedCopy(mpBegin, p, pNewBegin); - pNewEnd = CharStringUninitializedCopy(pBegin, pEnd, pNewEnd); - pNewEnd = CharStringUninitializedCopy(p, mpEnd, pNewEnd); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + nLength; - } - } - } - - - template - inline basic_string& basic_string::erase(size_type position, size_type n) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - EASTL_FAIL_MSG("basic_string::erase -- invalid position"); - #endif - - erase(mpBegin + position, mpBegin + position + eastl::min_alt(n, (size_type)(mpEnd - mpBegin) - position)); - return *this; - } - - - template - inline typename basic_string::iterator - basic_string::erase(iterator p) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((p < mpBegin) || (p >= mpEnd))) - EASTL_FAIL_MSG("basic_string::erase -- invalid position"); - #endif - - memmove(p, p + 1, (size_t)(mpEnd - p) * sizeof(value_type)); - --mpEnd; - return p; - } - - - template - typename basic_string::iterator - basic_string::erase(iterator pBegin, iterator pEnd) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((pBegin < mpBegin) || (pBegin > mpEnd) || (pEnd < mpBegin) || (pEnd > mpEnd) || (pEnd < pBegin))) - EASTL_FAIL_MSG("basic_string::erase -- invalid position"); - #endif - - if(pBegin != pEnd) - { - memmove(pBegin, pEnd, (size_t)((mpEnd - pEnd) + 1) * sizeof(value_type)); - const iterator pNewEnd = (mpEnd - (pEnd - pBegin)); - mpEnd = pNewEnd; - } - return pBegin; - } - - - template - inline typename basic_string::reverse_iterator - basic_string::erase(reverse_iterator position) - { - return reverse_iterator(erase((++position).base())); - } - - - template - typename basic_string::reverse_iterator - basic_string::erase(reverse_iterator first, reverse_iterator last) - { - return reverse_iterator(erase((++last).base(), (++first).base())); - } - - - template - basic_string& basic_string::replace(size_type position, size_type n, const basic_string& x) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - const size_type nLength = eastl::min_alt(n, (size_type)(mpEnd - mpBegin) - position); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY(((size_type)(mpEnd - mpBegin) - nLength) >= (kMaxSize - (size_type)(x.mpEnd - x.mpBegin)))) - ThrowLengthException(); - #endif - - return replace(mpBegin + position, mpBegin + position + nLength, x.mpBegin, x.mpEnd); - } - - - template - basic_string& basic_string::replace(size_type pos1, size_type n1, const basic_string& x, size_type pos2, size_type n2) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY((pos1 > (size_type)(mpEnd - mpBegin)) || (pos2 > (size_type)(x.mpEnd - x.mpBegin)))) - ThrowRangeException(); - #endif - - const size_type nLength1 = eastl::min_alt(n1, (size_type)( mpEnd - mpBegin) - pos1); - const size_type nLength2 = eastl::min_alt(n2, (size_type)(x.mpEnd - x.mpBegin) - pos2); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY(((size_type)(mpEnd - mpBegin) - nLength1) >= (kMaxSize - nLength2))) - ThrowLengthException(); - #endif - - return replace(mpBegin + pos1, mpBegin + pos1 + nLength1, x.mpBegin + pos2, x.mpBegin + pos2 + nLength2); - } - - - template - basic_string& basic_string::replace(size_type position, size_type n1, const value_type* p, size_type n2) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - const size_type nLength = eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - position); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((n2 > kMaxSize) || (((size_type)(mpEnd - mpBegin) - nLength) >= (kMaxSize - n2)))) - ThrowLengthException(); - #endif - - return replace(mpBegin + position, mpBegin + position + nLength, p, p + n2); - } - - - template - basic_string& basic_string::replace(size_type position, size_type n1, const value_type* p) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - const size_type nLength = eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - position); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - const size_type n2 = (size_type)CharStrlen(p); - if(EASTL_UNLIKELY((n2 > kMaxSize) || (((size_type)(mpEnd - mpBegin) - nLength) >= (kMaxSize - n2)))) - ThrowLengthException(); - #endif - - return replace(mpBegin + position, mpBegin + position + nLength, p, p + CharStrlen(p)); - } - - - template - basic_string& basic_string::replace(size_type position, size_type n1, size_type n2, value_type c) - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - const size_type nLength = eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - position); - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY((n2 > kMaxSize) || ((size_type)(mpEnd - mpBegin) - nLength) >= (kMaxSize - n2))) - ThrowLengthException(); - #endif - - return replace(mpBegin + position, mpBegin + position + nLength, n2, c); - } - - - template - inline basic_string& basic_string::replace(iterator pBegin, iterator pEnd, const basic_string& x) - { - return replace(pBegin, pEnd, x.mpBegin, x.mpEnd); - } - - - template - inline basic_string& basic_string::replace(iterator pBegin, iterator pEnd, const value_type* p, size_type n) - { - return replace(pBegin, pEnd, p, p + n); - } - - - template - inline basic_string& basic_string::replace(iterator pBegin, iterator pEnd, const value_type* p) - { - return replace(pBegin, pEnd, p, p + CharStrlen(p)); - } - - - template - basic_string& basic_string::replace(iterator pBegin, iterator pEnd, size_type n, value_type c) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((pBegin < mpBegin) || (pBegin > mpEnd) || (pEnd < mpBegin) || (pEnd > mpEnd) || (pEnd < pBegin))) - EASTL_FAIL_MSG("basic_string::replace -- invalid position"); - #endif - - const size_type nLength = static_cast(pEnd - pBegin); - - if(nLength >= n) - { - CharTypeAssignN(pBegin, n, c); - erase(pBegin + n, pEnd); - } - else - { - CharTypeAssignN(pBegin, nLength, c); - insert(pEnd, n - nLength, c); - } - return *this; - } - - - template - basic_string& basic_string::replace(iterator pBegin1, iterator pEnd1, const value_type* pBegin2, const value_type* pEnd2) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY((pBegin1 < mpBegin) || (pBegin1 > mpEnd) || (pEnd1 < mpBegin) || (pEnd1 > mpEnd) || (pEnd1 < pBegin1))) - EASTL_FAIL_MSG("basic_string::replace -- invalid position"); - #endif - - const size_type nLength1 = (size_type)(pEnd1 - pBegin1); - const size_type nLength2 = (size_type)(pEnd2 - pBegin2); - - if(nLength1 >= nLength2) // If we have a non-expanding operation... - { - if((pBegin2 > pEnd1) || (pEnd2 <= pBegin1)) // If we have a non-overlapping operation... - memcpy(pBegin1, pBegin2, (size_t)(pEnd2 - pBegin2) * sizeof(value_type)); - else - memmove(pBegin1, pBegin2, (size_t)(pEnd2 - pBegin2) * sizeof(value_type)); - erase(pBegin1 + nLength2, pEnd1); - } - else // Else we are expanding. - { - if((pBegin2 > pEnd1) || (pEnd2 <= pBegin1)) // If we have a non-overlapping operation... - { - const value_type* const pMid2 = pBegin2 + nLength1; - - if((pEnd2 <= pBegin1) || (pBegin2 > pEnd1)) - memcpy(pBegin1, pBegin2, (size_t)(pMid2 - pBegin2) * sizeof(value_type)); - else - memmove(pBegin1, pBegin2, (size_t)(pMid2 - pBegin2) * sizeof(value_type)); - insert(pEnd1, pMid2, pEnd2); - } - else // else we have an overlapping operation. - { - // I can't think of any easy way of doing this without allocating temporary memory. - const size_type nOldSize = (size_type)(mpEnd - mpBegin); - const size_type nOldCap = (size_type)((mpCapacity - mpBegin) - 1); - const size_type nNewCapacity = eastl::max_alt((size_type)GetNewCapacity(nOldCap), (size_type)(nOldSize + (nLength2 - nLength1))) + 1; // + 1 to accomodate the trailing 0. - - pointer pNewBegin = DoAllocate(nNewCapacity); - pointer pNewEnd = pNewBegin; - - pNewEnd = CharStringUninitializedCopy(mpBegin, pBegin1, pNewBegin); - pNewEnd = CharStringUninitializedCopy(pBegin2, pEnd2, pNewEnd); - pNewEnd = CharStringUninitializedCopy(pEnd1, mpEnd, pNewEnd); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + nNewCapacity; - } - } - return *this; - } - - - template - typename basic_string::size_type - basic_string::copy(value_type* p, size_type n, size_type position) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - // It is not clear from the C++ standard if 'p' destination pointer is allowed to - // refer to memory from within the string itself. We assume so and use memmove - // instead of memcpy until we find otherwise. - const size_type nLength = eastl::min_alt(n, (size_type)(mpEnd - mpBegin) - position); - memmove(p, mpBegin + position, (size_t)nLength * sizeof(value_type)); - return nLength; - } - - - template - void basic_string::swap(basic_string& x) - { - if(mAllocator == x.mAllocator) // If allocators are equivalent... - { - // We leave mAllocator as-is. - eastl::swap(mpBegin, x.mpBegin); - eastl::swap(mpEnd, x.mpEnd); - eastl::swap(mpCapacity, x.mpCapacity); - } - else // else swap the contents. - { - const this_type temp(*this); // Can't call eastl::swap because that would - *this = x; // itself call this member swap function. - x = temp; - } - } - - - template - inline typename basic_string::size_type - basic_string::find(const basic_string& x, size_type position) const - { - return find(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::find(const value_type* p, size_type position) const - { - return find(p, position, (size_type)CharStrlen(p)); - } - - - #if defined(EA_PLATFORM_XENON) // If XBox 360... - - template - typename basic_string::size_type - basic_string::find(const value_type* p, size_type position, size_type n) const - { - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(n || (position > nLength)) - { - if(position < nLength) - { - size_type nRemain = nLength - position; - - if(n <= nRemain) - { - nRemain -= (n - 1); - - for(const value_type* p1, *p2 = mpBegin + position; - (p1 = Find(p2, *p, nRemain)) != 0; - nRemain -= (p1 - p2) + 1, p2 = (p1 + 1)) - { - if(Compare(p1, p, n) == 0) - return (size_type)(p1 - mpBegin); - } - } - } - - return npos; - } - - return position; - } - #else - template - typename basic_string::size_type - basic_string::find(const value_type* p, size_type position, size_type n) const - { - // It is not clear what the requirements are for position, but since the C++ standard - // appears to be silent it is assumed for now that position can be any value. - //#if EASTL_ASSERT_ENABLED - // if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - // EASTL_FAIL_MSG("basic_string::find -- invalid position"); - //#endif - - if(EASTL_LIKELY((position + n) <= (size_type)(mpEnd - mpBegin))) // If the range is valid... - { - const value_type* const pTemp = eastl::search(mpBegin + position, mpEnd, p, p + n); - - if((pTemp != mpEnd) || (n == 0)) - return (size_type)(pTemp - mpBegin); - } - return npos; - } - #endif - - - template - typename basic_string::size_type - basic_string::find(value_type c, size_type position) const - { - // It is not clear what the requirements are for position, but since the C++ standard - // appears to be silent it is assumed for now that position can be any value. - //#if EASTL_ASSERT_ENABLED - // if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - // EASTL_FAIL_MSG("basic_string::find -- invalid position"); - //#endif - - if(EASTL_LIKELY(position < (size_type)(mpEnd - mpBegin))) // If the position is valid... - { - const const_iterator pResult = eastl::find(mpBegin + position, mpEnd, c); - - if(pResult != mpEnd) - return (size_type)(pResult - mpBegin); - } - return npos; - } - - - template - inline typename basic_string::size_type - basic_string::rfind(const basic_string& x, size_type position) const - { - return rfind(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::rfind(const value_type* p, size_type position) const - { - return rfind(p, position, (size_type)CharStrlen(p)); - } - - - template - typename basic_string::size_type - basic_string::rfind(const value_type* p, size_type position, size_type n) const - { - // Disabled because it's not clear what values are valid for position. - // It is documented that npos is a valid value, though. We return npos and - // don't crash if postion is any invalid value. - //#if EASTL_ASSERT_ENABLED - // if(EASTL_UNLIKELY((position != npos) && (position > (size_type)(mpEnd - mpBegin)))) - // EASTL_FAIL_MSG("basic_string::rfind -- invalid position"); - //#endif - - // Note that a search for a zero length string starting at position = end() returns end() and not npos. - // Note by Paul Pedriana: I am not sure how this should behave in the case of n == 0 and position > size. - // The standard seems to suggest that rfind doesn't act exactly the same as find in that input position - // can be > size and the return value can still be other than npos. Thus, if n == 0 then you can - // never return npos, unlike the case with find. - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(EASTL_LIKELY(n <= nLength)) - { - if(EASTL_LIKELY(n)) - { - const const_iterator pEnd = mpBegin + eastl::min_alt(nLength - n, position) + n; - const const_iterator pResult = CharTypeStringRSearch(mpBegin, pEnd, p, p + n); - - if(pResult != pEnd) - return (size_type)(pResult - mpBegin); - } - else - return eastl::min_alt(nLength, position); - } - return npos; - } - - - template - typename basic_string::size_type - basic_string::rfind(value_type c, size_type position) const - { - // If n is zero or position is >= size, we return npos. - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(EASTL_LIKELY(nLength)) - { - const value_type* const pEnd = mpBegin + eastl::min_alt(nLength - 1, position) + 1; - const value_type* const pResult = CharTypeStringRFind(pEnd, mpBegin, c); - - if(pResult != mpBegin) - return (size_type)((pResult - 1) - mpBegin); - } - return npos; - } - - - template - inline typename basic_string::size_type - basic_string::find_first_of(const basic_string& x, size_type position) const - { - return find_first_of(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::find_first_of(const value_type* p, size_type position) const - { - return find_first_of(p, position, (size_type)CharStrlen(p)); - } - - - #if defined(EA_PLATFORM_XENON) // If XBox 360... - - template - typename basic_string::size_type - basic_string::find_first_of(const value_type* p, size_type position, size_type n) const - { - // If position is >= size, we return npos. - if(n && (position < (size_type)(mpEnd - mpBegin))) - { - for(const value_type* p1 = (mpBegin + position); p1 < mpEnd; ++p1) - { - if(Find(p, *p1, n) != 0) - return (size_type)(p1 - mpBegin); - } - } - return npos; - } - #else - template - typename basic_string::size_type - basic_string::find_first_of(const value_type* p, size_type position, size_type n) const - { - // If position is >= size, we return npos. - if(EASTL_LIKELY((position < (size_type)(mpEnd - mpBegin)))) - { - const value_type* const pBegin = mpBegin + position; - const const_iterator pResult = CharTypeStringFindFirstOf(pBegin, mpEnd, p, p + n); - - if(pResult != mpEnd) - return (size_type)(pResult - mpBegin); - } - return npos; - } - #endif - - - template - inline typename basic_string::size_type - basic_string::find_first_of(value_type c, size_type position) const - { - return find(c, position); - } - - - template - inline typename basic_string::size_type - basic_string::find_last_of(const basic_string& x, size_type position) const - { - return find_last_of(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::find_last_of(const value_type* p, size_type position) const - { - return find_last_of(p, position, (size_type)CharStrlen(p)); - } - - - #if defined(EA_PLATFORM_XENON) // If XBox 360... - - template - typename basic_string::size_type - basic_string::find_last_of(const value_type* p, size_type position, size_type n) const - { - // If n is zero or position is >= size, we return npos. - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(n && nLength) - { - const value_type* p1; - - if(position < nLength) - p1 = mpBegin + position; - else - p1 = mpEnd - 1; - - for(;;) - { - if(Find(p, *p1, n)) - return (size_type)(p1 - mpBegin); - - if(p1-- == mpBegin) - break; - } - } - - return npos; - } - #else - template - typename basic_string::size_type - basic_string::find_last_of(const value_type* p, size_type position, size_type n) const - { - // If n is zero or position is >= size, we return npos. - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(EASTL_LIKELY(nLength)) - { - const value_type* const pEnd = mpBegin + eastl::min_alt(nLength - 1, position) + 1; - const value_type* const pResult = CharTypeStringRFindFirstOf(pEnd, mpBegin, p, p + n); - - if(pResult != mpBegin) - return (size_type)((pResult - 1) - mpBegin); - } - return npos; - } - #endif - - - template - inline typename basic_string::size_type - basic_string::find_last_of(value_type c, size_type position) const - { - return rfind(c, position); - } - - - template - inline typename basic_string::size_type - basic_string::find_first_not_of(const basic_string& x, size_type position) const - { - return find_first_not_of(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::find_first_not_of(const value_type* p, size_type position) const - { - return find_first_not_of(p, position, (size_type)CharStrlen(p)); - } - - - template - typename basic_string::size_type - basic_string::find_first_not_of(const value_type* p, size_type position, size_type n) const - { - if(EASTL_LIKELY(position <= (size_type)(mpEnd - mpBegin))) - { - const const_iterator pResult = CharTypeStringFindFirstNotOf(mpBegin + position, mpEnd, p, p + n); - - if(pResult != mpEnd) - return (size_type)(pResult - mpBegin); - } - return npos; - } - - - template - typename basic_string::size_type - basic_string::find_first_not_of(value_type c, size_type position) const - { - if(EASTL_LIKELY(position <= (size_type)(mpEnd - mpBegin))) - { - // Todo: Possibly make a specialized version of CharTypeStringFindFirstNotOf(pBegin, pEnd, c). - const const_iterator pResult = CharTypeStringFindFirstNotOf(mpBegin + position, mpEnd, &c, &c + 1); - - if(pResult != mpEnd) - return (size_type)(pResult - mpBegin); - } - return npos; - } - - - template - inline typename basic_string::size_type - basic_string::find_last_not_of(const basic_string& x, size_type position) const - { - return find_last_not_of(x.mpBegin, position, (size_type)(x.mpEnd - x.mpBegin)); - } - - - template - inline typename basic_string::size_type - basic_string::find_last_not_of(const value_type* p, size_type position) const - { - return find_last_not_of(p, position, (size_type)CharStrlen(p)); - } - - - template - typename basic_string::size_type - basic_string::find_last_not_of(const value_type* p, size_type position, size_type n) const - { - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(EASTL_LIKELY(nLength)) - { - const value_type* const pEnd = mpBegin + eastl::min_alt(nLength - 1, position) + 1; - const value_type* const pResult = CharTypeStringRFindFirstNotOf(pEnd, mpBegin, p, p + n); - - if(pResult != mpBegin) - return (size_type)((pResult - 1) - mpBegin); - } - return npos; - } - - - template - typename basic_string::size_type - basic_string::find_last_not_of(value_type c, size_type position) const - { - const size_type nLength = (size_type)(mpEnd - mpBegin); - - if(EASTL_LIKELY(nLength)) - { - // Todo: Possibly make a specialized version of CharTypeStringRFindFirstNotOf(pBegin, pEnd, c). - const value_type* const pEnd = mpBegin + eastl::min_alt(nLength - 1, position) + 1; - const value_type* const pResult = CharTypeStringRFindFirstNotOf(pEnd, mpBegin, &c, &c + 1); - - if(pResult != mpBegin) - return (size_type)((pResult - 1) - mpBegin); - } - return npos; - } - - - template - inline basic_string basic_string::substr(size_type position, size_type n) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #elif EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(position > (size_type)(mpEnd - mpBegin))) - EASTL_FAIL_MSG("basic_string::substr -- invalid position"); - #endif - - return basic_string(mpBegin + position, mpBegin + position + eastl::min_alt(n, (size_type)(mpEnd - mpBegin) - position), mAllocator); - } - - - template - inline int basic_string::compare(const basic_string& x) const - { - return compare(mpBegin, mpEnd, x.mpBegin, x.mpEnd); - } - - - template - inline int basic_string::compare(size_type pos1, size_type n1, const basic_string& x) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(pos1 > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - return compare(mpBegin + pos1, - mpBegin + pos1 + eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - pos1), - x.mpBegin, - x.mpEnd); - } - - - template - inline int basic_string::compare(size_type pos1, size_type n1, const basic_string& x, size_type pos2, size_type n2) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY((pos1 > (size_type)(mpEnd - mpBegin)) || (pos2 > (size_type)(x.mpEnd - x.mpBegin)))) - ThrowRangeException(); - #endif - - return compare(mpBegin + pos1, - mpBegin + pos1 + eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - pos1), - x.mpBegin + pos2, - x.mpBegin + pos2 + eastl::min_alt(n2, (size_type)(mpEnd - mpBegin) - pos2)); - } - - - template - inline int basic_string::compare(const value_type* p) const - { - return compare(mpBegin, mpEnd, p, p + CharStrlen(p)); - } - - - template - inline int basic_string::compare(size_type pos1, size_type n1, const value_type* p) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(pos1 > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - return compare(mpBegin + pos1, - mpBegin + pos1 + eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - pos1), - p, - p + CharStrlen(p)); - } - - - template - inline int basic_string::compare(size_type pos1, size_type n1, const value_type* p, size_type n2) const - { - #if EASTL_STRING_OPT_RANGE_ERRORS - if(EASTL_UNLIKELY(pos1 > (size_type)(mpEnd - mpBegin))) - ThrowRangeException(); - #endif - - return compare(mpBegin + pos1, - mpBegin + pos1 + eastl::min_alt(n1, (size_type)(mpEnd - mpBegin) - pos1), - p, - p + n2); - } - - - // make_lower - // This is a very simple ASCII-only case conversion function - // Anything more complicated should use a more powerful separate library. - template - inline void basic_string::make_lower() - { - for(pointer p = mpBegin; p < mpEnd; ++p) - *p = (value_type)CharToLower(*p); - } - - - // make_upper - // This is a very simple ASCII-only case conversion function - // Anything more complicated should use a more powerful separate library. - template - inline void basic_string::make_upper() - { - for(pointer p = mpBegin; p < mpEnd; ++p) - *p = (value_type)CharToUpper(*p); - } - - - template - inline void basic_string::ltrim() - { - const value_type array[] = { ' ', '\t', 0 }; // This is a pretty simplistic view of whitespace. - erase(0, find_first_not_of(array)); - } - - - template - inline void basic_string::rtrim() - { - const value_type array[] = { ' ', '\t', 0 }; // This is a pretty simplistic view of whitespace. - erase(find_last_not_of(array) + 1); - } - - - template - inline void basic_string::trim() - { - ltrim(); - rtrim(); - } - - - template - inline basic_string basic_string::left(size_type n) const - { - const size_type nLength = length(); - if(n < nLength) - return substr(0, n); - return *this; - } - - - template - inline basic_string basic_string::right(size_type n) const - { - const size_type nLength = length(); - if(n < nLength) - return substr(nLength - n, n); - return *this; - } - - - template - inline basic_string& basic_string::sprintf(const value_type* pFormat, ...) - { - va_list arguments; - va_start(arguments, pFormat); - mpEnd = mpBegin; // Fast truncate to zero length. - append_sprintf_va_list(pFormat, arguments); - va_end(arguments); - - return *this; - } - - - template - basic_string& basic_string::sprintf_va_list(const value_type* pFormat, va_list arguments) - { - mpEnd = mpBegin; // Fast truncate to zero length. - - return append_sprintf_va_list(pFormat, arguments); - } - - - template - int basic_string::compare(const value_type* pBegin1, const value_type* pEnd1, - const value_type* pBegin2, const value_type* pEnd2) - { - const ptrdiff_t n1 = pEnd1 - pBegin1; - const ptrdiff_t n2 = pEnd2 - pBegin2; - const ptrdiff_t nMin = eastl::min_alt(n1, n2); - const int cmp = Compare(pBegin1, pBegin2, (size_t)nMin); - - return (cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0))); - } - - - template - int basic_string::comparei(const value_type* pBegin1, const value_type* pEnd1, - const value_type* pBegin2, const value_type* pEnd2) - { - const ptrdiff_t n1 = pEnd1 - pBegin1; - const ptrdiff_t n2 = pEnd2 - pBegin2; - const ptrdiff_t nMin = eastl::min_alt(n1, n2); - const int cmp = CompareI(pBegin1, pBegin2, (size_t)nMin); - - return (cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0))); - } - - - template - inline int basic_string::comparei(const basic_string& x) const - { - return comparei(mpBegin, mpEnd, x.mpBegin, x.mpEnd); - } - - - template - inline int basic_string::comparei(const value_type* p) const - { - return comparei(mpBegin, mpEnd, p, p + CharStrlen(p)); - } - - - template - typename basic_string::iterator - basic_string::InsertInternal(iterator p, value_type c) - { - iterator pNewPosition = p; - - if((mpEnd + 1) < mpCapacity) - { - *(mpEnd + 1) = 0; - memmove(p + 1, p, (size_t)(mpEnd - p) * sizeof(value_type)); - *p = c; - ++mpEnd; - } - else - { - const size_type nOldSize = (size_type)(mpEnd - mpBegin); - const size_type nOldCap = (size_type)((mpCapacity - mpBegin) - 1); - const size_type nLength = eastl::max_alt((size_type)GetNewCapacity(nOldCap), (size_type)(nOldSize + 1)) + 1; // The second + 1 is to accomodate the trailing 0. - - iterator pNewBegin = DoAllocate(nLength); - iterator pNewEnd = pNewBegin; - - pNewPosition = CharStringUninitializedCopy(mpBegin, p, pNewBegin); - *pNewPosition = c; - - pNewEnd = pNewPosition + 1; - pNewEnd = CharStringUninitializedCopy(p, mpEnd, pNewEnd); - *pNewEnd = 0; - - DeallocateSelf(); - mpBegin = pNewBegin; - mpEnd = pNewEnd; - mpCapacity = pNewBegin + nLength; - } - return pNewPosition; - } - - - template - void basic_string::SizeInitialize(size_type n, value_type c) - { - AllocateSelf((size_type)(n + 1)); // '+1' so that we have room for the terminating 0. - - mpEnd = CharStringUninitializedFillN(mpBegin, n, c); - *mpEnd = 0; - } - - - template - void basic_string::RangeInitialize(const value_type* pBegin, const value_type* pEnd) - { - const size_type n = (size_type)(pEnd - pBegin); - - #if EASTL_STRING_OPT_ARGUMENT_ERRORS - if(EASTL_UNLIKELY(!pBegin && (n != 0))) - ThrowInvalidArgumentException(); - #endif - - AllocateSelf((size_type)(n + 1)); // '+1' so that we have room for the terminating 0. - - mpEnd = CharStringUninitializedCopy(pBegin, pEnd, mpBegin); - *mpEnd = 0; - } - - - template - inline void basic_string::RangeInitialize(const value_type* pBegin) - { - #if EASTL_STRING_OPT_ARGUMENT_ERRORS - if(EASTL_UNLIKELY(!pBegin)) - ThrowInvalidArgumentException(); - #endif - - RangeInitialize(pBegin, pBegin + CharStrlen(pBegin)); - } - - - template - inline typename basic_string::value_type* - basic_string::DoAllocate(size_type n) - { - EASTL_ASSERT(n > 1); // We want n > 1 because n == 1 is reserved for empty capacity and usage of gEmptyString. - return (value_type*)EASTLAlloc(mAllocator, n * sizeof(value_type)); - } - - - template - inline void basic_string::DoFree(value_type* p, size_type n) - { - if(p) - EASTLFree(mAllocator, p, n * sizeof(value_type)); - } - - - template - inline typename basic_string::size_type - basic_string::GetNewCapacity(size_type currentCapacity) // This needs to return a value of at least currentCapacity and at least 1. - { - return (currentCapacity > EASTL_STRING_INITIAL_CAPACITY) ? (2 * currentCapacity) : EASTL_STRING_INITIAL_CAPACITY; - } - - - template - inline void basic_string::AllocateSelf() - { - EASTL_ASSERT(gEmptyString.mUint32 == 0); - mpBegin = const_cast(GetEmptyString(value_type())); // In const_cast-int this, we promise not to modify it. - mpEnd = mpBegin; - mpCapacity = mpBegin + 1; // When we are using gEmptyString, mpCapacity is always mpEnd + 1. This is an important distinguising characteristic. - } - - - template - void basic_string::AllocateSelf(size_type n) - { - #if EASTL_ASSERT_ENABLED - if(EASTL_UNLIKELY(n >= 0x40000000)) - EASTL_FAIL_MSG("basic_string::AllocateSelf -- improbably large request."); - #endif - - #if EASTL_STRING_OPT_LENGTH_ERRORS - if(EASTL_UNLIKELY(n > kMaxSize)) - ThrowLengthException(); - #endif - - if(n > 1) - { - mpBegin = DoAllocate(n); - mpEnd = mpBegin; - mpCapacity = mpBegin + n; - } - else - AllocateSelf(); - } - - - template - inline void basic_string::DeallocateSelf() - { - // Note that we compare mpCapacity to mpEnd instead of comparing - // mpBegin to &gEmptyString. This is important because we may have - // a case whereby one library passes a string to another library to - // deallocate and the two libraries have idependent versions of gEmptyString. - if((mpCapacity - mpBegin) > 1) // If we are not using gEmptyString as our memory... - DoFree(mpBegin, (size_type)(mpCapacity - mpBegin)); - } - - - template - inline void basic_string::ThrowLengthException() const - { - #if EASTL_EXCEPTIONS_ENABLED - throw std::length_error("basic_string -- length_error"); - #elif EASTL_ASSERT_ENABLED - EASTL_FAIL_MSG("basic_string -- length_error"); - #endif - } - - - template - inline void basic_string::ThrowRangeException() const - { - #if EASTL_EXCEPTIONS_ENABLED - throw std::out_of_range("basic_string -- out of range"); - #elif EASTL_ASSERT_ENABLED - EASTL_FAIL_MSG("basic_string -- out of range"); - #endif - } - - - template - inline void basic_string::ThrowInvalidArgumentException() const - { - #if EASTL_EXCEPTIONS_ENABLED - throw std::invalid_argument("basic_string -- invalid argument"); - #elif EASTL_ASSERT_ENABLED - EASTL_FAIL_MSG("basic_string -- invalid argument"); - #endif - } - - - // CharTypeStringFindEnd - // Specialized char version of STL find() from back function. - // Not the same as RFind because search range is specified as forward iterators. - template - const typename basic_string::value_type* - basic_string::CharTypeStringFindEnd(const value_type* pBegin, const value_type* pEnd, value_type c) - { - const value_type* pTemp = pEnd; - while(--pTemp >= pBegin) - { - if(*pTemp == c) - return pTemp; - } - - return pEnd; - } - - - // CharTypeStringRFind - // Specialized value_type version of STL find() function in reverse. - template - const typename basic_string::value_type* - basic_string::CharTypeStringRFind(const value_type* pRBegin, const value_type* pREnd, const value_type c) - { - while(pRBegin > pREnd) - { - if(*(pRBegin - 1) == c) - return pRBegin; - --pRBegin; - } - return pREnd; - } - - - // CharTypeStringSearch - // Specialized value_type version of STL search() function. - // Purpose: find p2 within p1. Return p1End if not found or if either string is zero length. - template - const typename basic_string::value_type* - basic_string::CharTypeStringSearch(const value_type* p1Begin, const value_type* p1End, - const value_type* p2Begin, const value_type* p2End) - { - // Test for zero length strings, in which case we have a match or a failure, - // but the return value is the same either way. - if((p1Begin == p1End) || (p2Begin == p2End)) - return p1Begin; - - // Test for a pattern of length 1. - if((p2Begin + 1) == p2End) - return eastl::find(p1Begin, p1End, *p2Begin); - - // General case. - const value_type* pTemp; - const value_type* pTemp1 = (p2Begin + 1); - const value_type* pCurrent = p1Begin; - - while(p1Begin != p1End) - { - p1Begin = eastl::find(p1Begin, p1End, *p2Begin); - if(p1Begin == p1End) - return p1End; - - pTemp = pTemp1; - pCurrent = p1Begin; - if(++pCurrent == p1End) - return p1End; - - while(*pCurrent == *pTemp) - { - if(++pTemp == p2End) - return p1Begin; - if(++pCurrent == p1End) - return p1End; - } - - ++p1Begin; - } - - return p1Begin; - } - - - // CharTypeStringRSearch - // Specialized value_type version of STL find_end() function (which really is a reverse search function). - // Purpose: find last instance of p2 within p1. Return p1End if not found or if either string is zero length. - template - const typename basic_string::value_type* - basic_string::CharTypeStringRSearch(const value_type* p1Begin, const value_type* p1End, - const value_type* p2Begin, const value_type* p2End) - { - // Test for zero length strings, in which case we have a match or a failure, - // but the return value is the same either way. - if((p1Begin == p1End) || (p2Begin == p2End)) - return p1Begin; - - // Test for a pattern of length 1. - if((p2Begin + 1) == p2End) - return CharTypeStringFindEnd(p1Begin, p1End, *p2Begin); - - // Test for search string length being longer than string length. - if((p2End - p2Begin) > (p1End - p1Begin)) - return p1End; - - // General case. - const value_type* pSearchEnd = (p1End - (p2End - p2Begin) + 1); - const value_type* pCurrent1; - const value_type* pCurrent2; - - while(pSearchEnd != p1Begin) - { - // Search for the last occurrence of *p2Begin. - pCurrent1 = CharTypeStringFindEnd(p1Begin, pSearchEnd, *p2Begin); - if(pCurrent1 == pSearchEnd) // If the first char of p2 wasn't found, - return p1End; // then we immediately have failure. - - // In this case, *pTemp == *p2Begin. So compare the rest. - pCurrent2 = p2Begin; - while(*pCurrent1++ == *pCurrent2++) - { - if(pCurrent2 == p2End) - return (pCurrent1 - (p2End - p2Begin)); - } - - // A smarter algorithm might know to subtract more than just one, - // but in most cases it won't make much difference anyway. - --pSearchEnd; - } - - return p1End; - } - - - // CharTypeStringFindFirstOf - // Specialized value_type version of STL find_first_of() function. - // This function is much like the C runtime strtok function, except the strings aren't null-terminated. - template - const typename basic_string::value_type* - basic_string::CharTypeStringFindFirstOf(const value_type* p1Begin, const value_type* p1End, - const value_type* p2Begin, const value_type* p2End) - { - for( ; p1Begin != p1End; ++p1Begin) - { - for(const value_type* pTemp = p2Begin; pTemp != p2End; ++pTemp) - { - if(*p1Begin == *pTemp) - return p1Begin; - } - } - return p1End; - } - - - // CharTypeStringRFindFirstOf - // Specialized value_type version of STL find_first_of() function in reverse. - // This function is much like the C runtime strtok function, except the strings aren't null-terminated. - template - const typename basic_string::value_type* - basic_string::CharTypeStringRFindFirstOf(const value_type* p1RBegin, const value_type* p1REnd, - const value_type* p2Begin, const value_type* p2End) - { - for( ; p1RBegin != p1REnd; --p1RBegin) - { - for(const value_type* pTemp = p2Begin; pTemp != p2End; ++pTemp) - { - if(*(p1RBegin - 1) == *pTemp) - return p1RBegin; - } - } - return p1REnd; - } - - - - // CharTypeStringFindFirstNotOf - // Specialized value_type version of STL find_first_not_of() function. - template - const typename basic_string::value_type* - basic_string::CharTypeStringFindFirstNotOf(const value_type* p1Begin, const value_type* p1End, - const value_type* p2Begin, const value_type* p2End) - { - for( ; p1Begin != p1End; ++p1Begin) - { - const value_type* pTemp; - for(pTemp = p2Begin; pTemp != p2End; ++pTemp) - { - if(*p1Begin == *pTemp) - break; - } - if(pTemp == p2End) - return p1Begin; - } - return p1End; - } - - - // CharTypeStringRFindFirstNotOf - // Specialized value_type version of STL find_first_not_of() function in reverse. - template - const typename basic_string::value_type* - basic_string::CharTypeStringRFindFirstNotOf(const value_type* p1RBegin, const value_type* p1REnd, - const value_type* p2Begin, const value_type* p2End) - { - for( ; p1RBegin != p1REnd; --p1RBegin) - { - const value_type* pTemp; - for(pTemp = p2Begin; pTemp != p2End; ++pTemp) - { - if(*(p1RBegin-1) == *pTemp) - break; - } - if(pTemp == p2End) - return p1RBegin; - } - return p1REnd; - } - - - - - // iterator operators - template - inline bool operator==(const typename basic_string::reverse_iterator& r1, - const typename basic_string::reverse_iterator& r2) - { - return r1.mpCurrent == r2.mpCurrent; - } - - - template - inline bool operator!=(const typename basic_string::reverse_iterator& r1, - const typename basic_string::reverse_iterator& r2) - { - return r1.mpCurrent != r2.mpCurrent; - } - - - // Operator + - template - basic_string operator+(const basic_string& a, const basic_string& b) - { - typedef typename basic_string::CtorDoNotInitialize CtorDoNotInitialize; - CtorDoNotInitialize cDNI; // GCC 2.x forces us to declare a named temporary like this. - basic_string result(cDNI, a.size() + b.size(), const_cast&>(a).get_allocator()); // Note that we choose to assign a's allocator. - result.append(a); - result.append(b); - return result; - } - - - template - basic_string operator+(const typename basic_string::value_type* p, const basic_string& b) - { - typedef typename basic_string::CtorDoNotInitialize CtorDoNotInitialize; - CtorDoNotInitialize cDNI; // GCC 2.x forces us to declare a named temporary like this. - const typename basic_string::size_type n = (typename basic_string::size_type)CharStrlen(p); - basic_string result(cDNI, n + b.size(), const_cast&>(b).get_allocator()); - result.append(p, p + n); - result.append(b); - return result; - } - - - template - basic_string operator+(typename basic_string::value_type c, const basic_string& b) - { - typedef typename basic_string::CtorDoNotInitialize CtorDoNotInitialize; - CtorDoNotInitialize cDNI; // GCC 2.x forces us to declare a named temporary like this. - basic_string result(cDNI, 1 + b.size(), const_cast&>(b).get_allocator()); - result.push_back(c); - result.append(b); - return result; - } - - - template - basic_string operator+(const basic_string& a, const typename basic_string::value_type* p) - { - typedef typename basic_string::CtorDoNotInitialize CtorDoNotInitialize; - CtorDoNotInitialize cDNI; // GCC 2.x forces us to declare a named temporary like this. - const typename basic_string::size_type n = (typename basic_string::size_type)CharStrlen(p); - basic_string result(cDNI, a.size() + n, const_cast&>(a).get_allocator()); - result.append(a); - result.append(p, p + n); - return result; - } - - - template - basic_string operator+(const basic_string& a, const typename basic_string::value_type c) - { - typedef typename basic_string::CtorDoNotInitialize CtorDoNotInitialize; - CtorDoNotInitialize cDNI; // GCC 2.x forces us to declare a named temporary like this. - basic_string result(cDNI, a.size() + 1, const_cast&>(a).get_allocator()); - result.append(a); - result.push_back(c); - return result; - } - - - template - inline bool basic_string::validate() const - { - if((mpBegin == NULL) || (mpEnd == NULL)) - return false; - if(mpEnd < mpBegin) - return false; - if(mpCapacity < mpEnd) - return false; - return true; - } - - - template - inline int basic_string::validate_iterator(const_iterator i) const - { - if(i >= mpBegin) - { - if(i < mpEnd) - return (isf_valid | isf_current | isf_can_dereference); - - if(i <= mpEnd) - return (isf_valid | isf_current); - } - - return isf_none; - } - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - // Operator== and operator!= - template - inline bool operator==(const basic_string& a, const basic_string& b) - { - return ((a.size() == b.size()) && (memcmp(a.data(), b.data(), (size_t)a.size() * sizeof(typename basic_string::value_type)) == 0)); - } - - - template - inline bool operator==(const typename basic_string::value_type* p, const basic_string& b) - { - typedef typename basic_string::size_type size_type; - const size_type n = (size_type)CharStrlen(p); - return ((n == b.size()) && (memcmp(p, b.data(), (size_t)n * sizeof(*p)) == 0)); - } - - - template - inline bool operator==(const basic_string& a, const typename basic_string::value_type* p) - { - typedef typename basic_string::size_type size_type; - const size_type n = (size_type)CharStrlen(p); - return ((a.size() == n) && (memcmp(a.data(), p, (size_t)n * sizeof(*p)) == 0)); - } - - - template - inline bool operator!=(const basic_string& a, const basic_string& b) - { - return !(a == b); - } - - - template - inline bool operator!=(const typename basic_string::value_type* p, const basic_string& b) - { - return !(p == b); - } - - - template - inline bool operator!=(const basic_string& a, const typename basic_string::value_type* p) - { - return !(a == p); - } - - - // Operator< (and also >, <=, and >=). - template - inline bool operator<(const basic_string& a, const basic_string& b) - { - return basic_string::compare(a.begin(), a.end(), b.begin(), b.end()) < 0; } - - - template - inline bool operator<(const typename basic_string::value_type* p, const basic_string& b) - { - typedef typename basic_string::size_type size_type; - const size_type n = (size_type)CharStrlen(p); - return basic_string::compare(p, p + n, b.begin(), b.end()) < 0; - } - - - template - inline bool operator<(const basic_string& a, const typename basic_string::value_type* p) - { - typedef typename basic_string::size_type size_type; - const size_type n = (size_type)CharStrlen(p); - return basic_string::compare(a.begin(), a.end(), p, p + n) < 0; - } - - - template - inline bool operator>(const basic_string& a, const basic_string& b) - { - return b < a; - } - - - template - inline bool operator>(const typename basic_string::value_type* p, const basic_string& b) - { - return b < p; - } - - - template - inline bool operator>(const basic_string& a, const typename basic_string::value_type* p) - { - return p < a; - } - - - template - inline bool operator<=(const basic_string& a, const basic_string& b) - { - return !(b < a); - } - - - template - inline bool operator<=(const typename basic_string::value_type* p, const basic_string& b) - { - return !(b < p); - } - - - template - inline bool operator<=(const basic_string& a, const typename basic_string::value_type* p) - { - return !(p < a); - } - - - template - inline bool operator>=(const basic_string& a, const basic_string& b) - { - return !(a < b); - } - - - template - inline bool operator>=(const typename basic_string::value_type* p, const basic_string& b) - { - return !(p < b); - } - - - template - inline bool operator>=(const basic_string& a, const typename basic_string::value_type* p) - { - return !(a < p); - } - - - template - inline void swap(basic_string& a, basic_string& b) - { - a.swap(b); - } - - - /// string / wstring - typedef basic_string string; - typedef basic_string wstring; - - /// string8 / string16 / string32 - typedef basic_string string8; - typedef basic_string string16; - typedef basic_string string32; - - - - /// hash - /// - /// We provide EASTL hash function objects for use in hash table containers. - /// - /// Example usage: - /// #include - /// hash_set stringHashSet; - /// - template struct hash; - - template <> - struct hash - { - size_t operator()(const string& x) const - { - const unsigned char* p = (const unsigned char*)x.c_str(); // To consider: limit p to at most 256 chars. - unsigned int c, result = 2166136261U; // We implement an FNV-like string hash. - while((c = *p++) != 0) // Using '!=' disables compiler warnings. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - /// hash - /// - template <> - struct hash - { - size_t operator()(const wstring& x) const - { - const wchar_t* p = (const wchar_t*)x.c_str(); // To consider: limit p to at most 256 chars. - unsigned int c, result = 2166136261U; // We implement an FNV-like string hash. - while((c = *p++) != 0) // Using '!=' disables compiler warnings. - result = (result * 16777619) ^ c; - return (size_t)result; - } - }; - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif // EASTL_ABSTRACT_STRING_ENABLED - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_compound_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_compound_eastl.h deleted file mode 100644 index ebd95d609fea..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_compound_eastl.h +++ /dev/null @@ -1,469 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/type_compound.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_TYPE_COMPOUND_H -#define EASTL_INTERNAL_TYPE_COMPOUND_H - - -namespace eastl -{ - - // The following properties or relations are defined here. If the given - // item is missing then it simply hasn't been implemented, at least not yet. - // is_array - // is_pointer - // is_reference - // is_member_object_pointer - // is_member_function_pointer - // is_member_pointer - // is_enum - // is_union - // is_class - // is_polymorphic - // is_function - // is_object - // is_scalar - // is_compound - // is_same - // is_convertible - - /////////////////////////////////////////////////////////////////////// - // is_array - // - // is_array::value == true if and only if T is an array type. - // As of this writing, the SNC compiler (EDG-based) doesn't compile - // the code below and says that returning an array is illegal. - // - /////////////////////////////////////////////////////////////////////// - template - T (*is_array_tester1(empty))(empty); - char is_array_tester1(...); // May need to use __cdecl under VC++. - - template - no_type is_array_tester2(T(*)(empty)); - yes_type is_array_tester2(...); // May need to use __cdecl under VC++. - - template - struct is_array_helper { - static empty emptyInstance; - }; - - template - struct is_array : public integral_constant::emptyInstance))) == 1 - >{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_reference - // - // is_reference::value == true if and only if T is a reference type. - // This category includes reference to function types. - // - /////////////////////////////////////////////////////////////////////// - template struct is_reference : public false_type{}; - template struct is_reference : public true_type{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_member_function_pointer - // - // is_member_function_pointer::value == true if and only if T is a - // pointer to member function type. - // - /////////////////////////////////////////////////////////////////////// - // We detect member functions with 0 to N arguments. We can extend this - // for additional arguments if necessary. - // To do: Make volatile and const volatile versions of these in addition to non-const and const. - /////////////////////////////////////////////////////////////////////// - template struct is_mem_fun_pointer_value : public false_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - template struct is_mem_fun_pointer_value : public true_type{}; - - template - struct is_member_function_pointer : public integral_constant::value>{}; - - - /////////////////////////////////////////////////////////////////////// - // is_member_pointer - // - // is_member_pointer::value == true if and only if: - // is_member_object_pointer::value == true, or - // is_member_function_pointer::value == true - // - /////////////////////////////////////////////////////////////////////// - template - struct is_member_pointer : public integral_constant::value>{}; - - template struct is_member_pointer : public true_type{}; - - - - - /////////////////////////////////////////////////////////////////////// - // is_pointer - // - // is_pointer::value == true if and only if T is a pointer type. - // This category includes function pointer types, but not pointer to - // member types. - // - /////////////////////////////////////////////////////////////////////// - template struct is_pointer_helper : public false_type{}; - - template struct is_pointer_helper : public true_type{}; - template struct is_pointer_helper : public true_type{}; - template struct is_pointer_helper : public true_type{}; - template struct is_pointer_helper : public true_type{}; - - template - struct is_pointer_value : public type_and::value, type_not::value>::value> {}; - - template - struct is_pointer : public integral_constant::value>{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_same - // - // Given two (possibly identical) types T and U, is_same::value == true - // if and only if T and U are the same type. - // - /////////////////////////////////////////////////////////////////////// - template - struct is_same : public false_type { }; - - template - struct is_same : public true_type { }; - - - /////////////////////////////////////////////////////////////////////// - // is_convertible - // - // Given two (possible identical) types From and To, is_convertible::value == true - // if and only if an lvalue of type From can be implicitly converted to type To, - // or is_void::value == true - // - // is_convertible may only be applied to complete types. - // Type To may not be an abstract type. - // If the conversion is ambiguous, the program is ill-formed. - // If either or both of From and To are class types, and the conversion would invoke - // non-public member functions of either From or To (such as a private constructor of To, - // or a private conversion operator of From), the program is ill-formed. - // - // Note that without compiler help, both is_convertible and is_base - // can produce compiler errors if the conversion is ambiguous. - // Example: - // struct A {}; - // struct B : A {}; - // struct C : A {}; - // struct D : B, C {}; - // is_convertible::value; // Generates compiler error. - /////////////////////////////////////////////////////////////////////// - #if !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x doesn't like the code below. - template - struct is_convertible_helper { - static yes_type Test(To); // May need to use __cdecl under VC++. - static no_type Test(...); // May need to use __cdecl under VC++. - static From from; - typedef integral_constant result; - }; - - // void is not convertible to non-void - template - struct is_convertible_helper { typedef false_type result; }; - - // Anything is convertible to void - template - struct is_convertible_helper { typedef true_type result; }; - - template - struct is_convertible : public is_convertible_helper::value, is_void::value>::result {}; - - #else - template - struct is_convertible : public false_type{}; - #endif - - - /////////////////////////////////////////////////////////////////////// - // is_union - // - // is_union::value == true if and only if T is a union type. - // - // There is no way to tell if a type is a union without compiler help. - // As of this writing, only Metrowerks v8+ supports such functionality - // via 'msl::is_union::value'. The user can force something to be - // evaluated as a union via EASTL_DECLARE_UNION. - /////////////////////////////////////////////////////////////////////// - template struct is_union : public false_type{}; - - #define EASTL_DECLARE_UNION(T) namespace eastl{ template <> struct is_union : public true_type{}; template <> struct is_union : public true_type{}; } - - - - - /////////////////////////////////////////////////////////////////////// - // is_class - // - // is_class::value == true if and only if T is a class or struct - // type (and not a union type). - // - // Without specific compiler help, it is not possible to - // distinguish between unions and classes. As a result, is_class - // will erroneously evaluate to true for union types. - /////////////////////////////////////////////////////////////////////// - #if defined(__MWERKS__) - // To do: Switch this to use msl_utility type traits. - template - struct is_class : public false_type{}; - #elif !defined(__GNUC__) || (((__GNUC__ * 100) + __GNUC_MINOR__) >= 304) // Not GCC or GCC 3.4+ - template static yes_type is_class_helper(void (U::*)()); - template static no_type is_class_helper(...); - - template - struct is_class : public integral_constant(0)) == sizeof(yes_type) && !is_union::value - >{}; - #else - // GCC 2.x version, due to GCC being broken. - template - struct is_class : public false_type{}; - #endif - - - - /////////////////////////////////////////////////////////////////////// - // is_enum - // - // is_enum::value == true if and only if T is an enumeration type. - // - /////////////////////////////////////////////////////////////////////// - struct int_convertible{ int_convertible(int); }; - - template - struct is_enum_helper { template struct nest : public is_convertible{}; }; - - template <> - struct is_enum_helper { template struct nest : public false_type {}; }; - - template - struct is_enum_helper2 - { - typedef type_or::value, is_reference::value, is_class::value> selector; - typedef is_enum_helper helper_t; - typedef typename add_reference::type ref_t; - typedef typename helper_t::template nest result; - }; - - template - struct is_enum : public integral_constant::result::value>{}; - - template <> struct is_enum : public false_type {}; - template <> struct is_enum : public false_type {}; - template <> struct is_enum : public false_type {}; - template <> struct is_enum : public false_type {}; - - #define EASTL_DECLARE_ENUM(T) namespace eastl{ template <> struct is_enum : public true_type{}; template <> struct is_enum : public true_type{}; } - - - /////////////////////////////////////////////////////////////////////// - // is_polymorphic - // - // is_polymorphic::value == true if and only if T is a class or struct - // that declares or inherits a virtual function. is_polymorphic may only - // be applied to complete types. - // - /////////////////////////////////////////////////////////////////////// - template - struct is_polymorphic_imp1 - { - typedef typename remove_cv::type t; - - struct helper_1 : public t - { - helper_1(); - ~helper_1() throw(); - char pad[64]; - }; - - struct helper_2 : public t - { - helper_2(); - virtual ~helper_2() throw(); - #ifndef _MSC_VER - virtual void foo(); - #endif - char pad[64]; - }; - - static const bool value = (sizeof(helper_1) == sizeof(helper_2)); - }; - - template - struct is_polymorphic_imp2{ static const bool value = false; }; - - template - struct is_polymorphic_selector{ template struct rebind{ typedef is_polymorphic_imp2 type; }; }; - - template <> - struct is_polymorphic_selector{ template struct rebind{ typedef is_polymorphic_imp1 type; }; }; - - template - struct is_polymorphic_value{ - typedef is_polymorphic_selector::value> selector; - typedef typename selector::template rebind binder; - typedef typename binder::type imp_type; - static const bool value = imp_type::value; - }; - - template - struct is_polymorphic : public integral_constant::value>{}; - - - - - /////////////////////////////////////////////////////////////////////// - // is_function - // - // is_function::value == true if and only if T is a function type. - // - /////////////////////////////////////////////////////////////////////// - template struct is_function_ptr_helper : public false_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - template struct is_function_ptr_helper : public true_type{}; - - template - struct is_function_chooser{ template struct result_ : public false_type{}; }; - - template <> - struct is_function_chooser{ template struct result_ : public is_function_ptr_helper{}; }; - - template - struct is_function_value : public is_function_chooser::value>::template result_{}; - - template - struct is_function : public integral_constant::value>{}; - - - - - /////////////////////////////////////////////////////////////////////// - // is_object - // - // is_object::value == true if and only if: - // is_reference::value == false, and - // is_function::value == false, and - // is_void::value == false - // - // The C++ standard, section 3.9p9, states: "An object type is a - // (possibly cv-qualified) type that is not a function type, not a - // reference type, and not incomplete (except for an incompletely - // defined object type). - /////////////////////////////////////////////////////////////////////// - - template - struct is_object : public integral_constant::value && !is_void::value && !is_function::value - >{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_scalar - // - // is_scalar::value == true if and only if: - // is_arithmetic::value == true, or - // is_enum::value == true, or - // is_pointer::value == true, or - // is_member_pointer::value - // - /////////////////////////////////////////////////////////////////////// - template - struct is_scalar : public integral_constant::value || is_enum::value>{}; - - template struct is_scalar : public true_type {}; - template struct is_scalar : public true_type {}; - template struct is_scalar : public true_type {}; - template struct is_scalar : public true_type {}; - - - - /////////////////////////////////////////////////////////////////////// - // is_compound - // - // Compound means anything but fundamental. See C++ standard, section 3.9.2. - // - // is_compound::value == true if and only if: - // is_fundamental::value == false - // - // Thus, is_compound::value == true if and only if: - // is_floating_point::value == false, and - // is_integral::value == false, and - // is_void::value == false - // - /////////////////////////////////////////////////////////////////////// - template - struct is_compound : public integral_constant::value>{}; - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_fundamental_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_fundamental_eastl.h deleted file mode 100644 index a7cea0f63c9f..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_fundamental_eastl.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/type_fundamental.h -// -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_TYPE_FUNDAMENTAL_H -#define EASTL_INTERNAL_TYPE_FUNDAMENTAL_H - - -namespace eastl -{ - - // The following properties or relations are defined here. If the given - // item is missing then it simply hasn't been implemented, at least not yet. - - - /////////////////////////////////////////////////////////////////////// - // is_void - // - // is_void::value == true if and only if T is one of the following types: - // [const][volatile] void - // - /////////////////////////////////////////////////////////////////////// - template struct is_void : public false_type{}; - - template <> struct is_void : public true_type{}; - template <> struct is_void : public true_type{}; - template <> struct is_void : public true_type{}; - template <> struct is_void : public true_type{}; - - - /////////////////////////////////////////////////////////////////////// - // is_integral - // - // is_integral::value == true if and only if T is one of the following types: - // [const] [volatile] bool - // [const] [volatile] char - // [const] [volatile] signed char - // [const] [volatile] unsigned char - // [const] [volatile] wchar_t - // [const] [volatile] short - // [const] [volatile] int - // [const] [volatile] long - // [const] [volatile] long long - // [const] [volatile] unsigned short - // [const] [volatile] unsigned int - // [const] [volatile] unsigned long - // [const] [volatile] unsigned long long - // - /////////////////////////////////////////////////////////////////////// - template struct is_integral : public false_type{}; - - // To do: Need to define volatile and const volatile versions of these. - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - template <> struct is_integral : public true_type{}; - template <> struct is_integral : public true_type{}; - #endif - - /////////////////////////////////////////////////////////////////////// - // is_floating_point - // - // is_floating_point::value == true if and only if T is one of the following types: - // [const] [volatile] float - // [const] [volatile] double - // [const] [volatile] long double - // - /////////////////////////////////////////////////////////////////////// - template struct is_floating_point : public false_type{}; - - // To do: Need to define volatile and const volatile versions of these. - template <> struct is_floating_point : public true_type{}; - template <> struct is_floating_point : public true_type{}; - template <> struct is_floating_point : public true_type{}; - template <> struct is_floating_point : public true_type{}; - template <> struct is_floating_point : public true_type{}; - template <> struct is_floating_point : public true_type{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_arithmetic - // - // is_arithmetic::value == true if and only if: - // is_floating_point::value == true, or - // is_integral::value == true - // - /////////////////////////////////////////////////////////////////////// - template - struct is_arithmetic : public integral_constant::value || is_floating_point::value - >{}; - - - /////////////////////////////////////////////////////////////////////// - // is_fundamental - // - // is_fundamental::value == true if and only if: - // is_floating_point::value == true, or - // is_integral::value == true, or - // is_void::value == true - /////////////////////////////////////////////////////////////////////// - template - struct is_fundamental : public integral_constant::value || is_integral::value || is_floating_point::value - >{}; - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_pod_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_pod_eastl.h deleted file mode 100644 index addfab56fe9c..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_pod_eastl.h +++ /dev/null @@ -1,284 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/type_pod.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_TYPE_POD_H -#define EASTL_INTERNAL_TYPE_POD_H - - -#include - - -namespace eastl -{ - - - // The following properties or relations are defined here. If the given - // item is missing then it simply hasn't been implemented, at least not yet. - // is_empty - // is_pod - // has_trivial_constructor - // has_trivial_copy - // has_trivial_assign - // has_trivial_destructor - // has_trivial_relocate -- EA extension to the C++ standard proposal. - // has_nothrow_constructor - // has_nothrow_copy - // has_nothrow_assign - // has_virtual_destructor - - - - - /////////////////////////////////////////////////////////////////////// - // is_empty - // - // is_empty::value == true if and only if T is an empty class or struct. - // is_empty may only be applied to complete types. - // - // is_empty cannot be used with union types until is_union can be made to work. - /////////////////////////////////////////////////////////////////////// - template - struct is_empty_helper_t1 : public T { char m[64]; }; - struct is_empty_helper_t2 { char m[64]; }; - - // The inheritance in empty_helper_t1 will not work with non-class types - template - struct is_empty_helper : public false_type{}; - - template - struct is_empty_helper : public integral_constant) == sizeof(is_empty_helper_t2) - >{}; - - template - struct is_empty_helper2 - { - typedef typename remove_cv::type _T; - typedef is_empty_helper<_T, is_class<_T>::value> type; - }; - - template - struct is_empty : public is_empty_helper2::type {}; - - - /////////////////////////////////////////////////////////////////////// - // is_pod - // - // is_pod::value == true if and only if, for a given type T: - // - is_scalar::value == true, or - // - T is a class or struct that has no user-defined copy - // assignment operator or destructor, and T has no non-static - // data members M for which is_pod::value == false, and no - // members of reference type, or - // - T is a class or struct that has no user-defined copy assignment - // operator or destructor, and T has no non-static data members M for - // which is_pod::value == false, and no members of reference type, or - // - T is the type of an array of objects E for which is_pod::value == true - // - // is_pod may only be applied to complete types. - // - // Without some help from the compiler or user, is_pod will not report - // that a struct or class is a POD, but will correctly report that - // built-in types such as int are PODs. The user can help the compiler - // by using the EASTL_DECLARE_POD macro on a class. - /////////////////////////////////////////////////////////////////////// - template // There's not much we can do here without some compiler extension. - struct is_pod : public integral_constant::value || is_scalar::value>{}; - - template - struct is_pod : public is_pod{}; - - template - struct is_POD : public is_pod{}; - - #define EASTL_DECLARE_POD(T) namespace eastl{ template <> struct is_pod : public true_type{}; template <> struct is_pod : public true_type{}; } - - - - - /////////////////////////////////////////////////////////////////////// - // has_trivial_constructor - // - // has_trivial_constructor::value == true if and only if T is a class - // or struct that has a trivial constructor. A constructor is trivial if - // - it is implicitly defined by the compiler, and - // - is_polymorphic::value == false, and - // - T has no virtual base classes, and - // - for every direct base class of T, has_trivial_constructor::value == true, - // where B is the type of the base class, and - // - for every nonstatic data member of T that has class type or array - // of class type, has_trivial_constructor::value == true, - // where M is the type of the data member - // - // has_trivial_constructor may only be applied to complete types. - // - // Without from the compiler or user, has_trivial_constructor will not - // report that a class or struct has a trivial constructor. - // The user can use EASTL_DECLARE_TRIVIAL_CONSTRUCTOR to help the compiler. - // - // A default constructor for a class X is a constructor of class X that - // can be called without an argument. - /////////////////////////////////////////////////////////////////////// - - // With current compilers, this is all we can do. - template - struct has_trivial_constructor : public is_pod {}; - - #define EASTL_DECLARE_TRIVIAL_CONSTRUCTOR(T) namespace eastl{ template <> struct has_trivial_constructor : public true_type{}; template <> struct has_trivial_constructor : public true_type{}; } - - - - - /////////////////////////////////////////////////////////////////////// - // has_trivial_copy - // - // has_trivial_copy::value == true if and only if T is a class or - // struct that has a trivial copy constructor. A copy constructor is - // trivial if - // - it is implicitly defined by the compiler, and - // - is_polymorphic::value == false, and - // - T has no virtual base classes, and - // - for every direct base class of T, has_trivial_copy::value == true, - // where B is the type of the base class, and - // - for every nonstatic data member of T that has class type or array - // of class type, has_trivial_copy::value == true, where M is the - // type of the data member - // - // has_trivial_copy may only be applied to complete types. - // - // Another way of looking at this is: - // A copy constructor for class X is trivial if it is implicitly - // declared and if all the following are true: - // - Class X has no virtual functions (10.3) and no virtual base classes (10.1). - // - Each direct base class of X has a trivial copy constructor. - // - For all the nonstatic data members of X that are of class type - // (or array thereof), each such class type has a trivial copy constructor; - // otherwise the copy constructor is nontrivial. - // - // Without from the compiler or user, has_trivial_copy will not report - // that a class or struct has a trivial copy constructor. The user can - // use EASTL_DECLARE_TRIVIAL_COPY to help the compiler. - /////////////////////////////////////////////////////////////////////// - - template - struct has_trivial_copy : public integral_constant::value && !is_volatile::value>{}; - - #define EASTL_DECLARE_TRIVIAL_COPY(T) namespace eastl{ template <> struct has_trivial_copy : public true_type{}; template <> struct has_trivial_copy : public true_type{}; } - - - /////////////////////////////////////////////////////////////////////// - // has_trivial_assign - // - // has_trivial_assign::value == true if and only if T is a class or - // struct that has a trivial copy assignment operator. A copy assignment - // operator is trivial if: - // - it is implicitly defined by the compiler, and - // - is_polymorphic::value == false, and - // - T has no virtual base classes, and - // - for every direct base class of T, has_trivial_assign::value == true, - // where B is the type of the base class, and - // - for every nonstatic data member of T that has class type or array - // of class type, has_trivial_assign::value == true, where M is - // the type of the data member. - // - // has_trivial_assign may only be applied to complete types. - // - // Without from the compiler or user, has_trivial_assign will not - // report that a class or struct has trivial assignment. The user - // can use EASTL_DECLARE_TRIVIAL_ASSIGN to help the compiler. - /////////////////////////////////////////////////////////////////////// - - template - struct has_trivial_assign : public integral_constant::value && !is_const::value && !is_volatile::value - >{}; - - #define EASTL_DECLARE_TRIVIAL_ASSIGN(T) namespace eastl{ template <> struct has_trivial_assign : public true_type{}; template <> struct has_trivial_assign : public true_type{}; } - - - - - /////////////////////////////////////////////////////////////////////// - // has_trivial_destructor - // - // has_trivial_destructor::value == true if and only if T is a class - // or struct that has a trivial destructor. A destructor is trivial if - // - it is implicitly defined by the compiler, and - // - for every direct base class of T, has_trivial_destructor::value == true, - // where B is the type of the base class, and - // - for every nonstatic data member of T that has class type or - // array of class type, has_trivial_destructor::value == true, - // where M is the type of the data member - // - // has_trivial_destructor may only be applied to complete types. - // - // Without from the compiler or user, has_trivial_destructor will not - // report that a class or struct has a trivial destructor. - // The user can use EASTL_DECLARE_TRIVIAL_DESTRUCTOR to help the compiler. - /////////////////////////////////////////////////////////////////////// - - // With current compilers, this is all we can do. - template - struct has_trivial_destructor : public is_pod{}; - - #define EASTL_DECLARE_TRIVIAL_DESTRUCTOR(T) namespace eastl{ template <> struct has_trivial_destructor : public true_type{}; template <> struct has_trivial_destructor : public true_type{}; } - - - /////////////////////////////////////////////////////////////////////// - // has_trivial_relocate - // - // This is an EA extension to the type traits standard. - // - // A trivially relocatable object is one that can be safely memmove'd - // to uninitialized memory. construction, assignment, and destruction - // properties are not addressed by this trait. A type that has the - // is_fundamental trait would always have the has_trivial_relocate trait. - // A type that has the has_trivial_constructor, has_trivial_copy or - // has_trivial_assign traits would usally have the has_trivial_relocate - // trait, but this is not strictly guaranteed. - // - // The user can use EASTL_DECLARE_TRIVIAL_RELOCATE to help the compiler. - /////////////////////////////////////////////////////////////////////// - - // With current compilers, this is all we can do. - template - struct has_trivial_relocate : public integral_constant::value && !is_volatile::value>{}; - - #define EASTL_DECLARE_TRIVIAL_RELOCATE(T) namespace eastl{ template <> struct has_trivial_relocate : public true_type{}; template <> struct has_trivial_relocate : public true_type{}; } - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_properties_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_properties_eastl.h deleted file mode 100644 index 41843439eb13..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_properties_eastl.h +++ /dev/null @@ -1,263 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/type_properties.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_TYPE_PROPERTIES_H -#define EASTL_INTERNAL_TYPE_PROPERTIES_H - - -#include - - -namespace eastl -{ - - // The following properties or relations are defined here. If the given - // item is missing then it simply hasn't been implemented, at least not yet. - - /////////////////////////////////////////////////////////////////////// - // is_const - // - // is_const::value == true if and only if T has const-qualification. - // - /////////////////////////////////////////////////////////////////////// - template struct is_const_value : public false_type{}; - template struct is_const_value : public true_type{}; - template struct is_const_value : public true_type{}; - - template struct is_const : public is_const_value{}; - template struct is_const : public false_type{}; // Note here that T is const, not the reference to T. So is_const is false. See section 8.3.2p1 of the C++ standard. - - - - /////////////////////////////////////////////////////////////////////// - // is_volatile - // - // is_volatile::value == true if and only if T has volatile-qualification. - // - /////////////////////////////////////////////////////////////////////// - - template struct is_volatile_value : public false_type{}; - template struct is_volatile_value : public true_type{}; - template struct is_volatile_value : public true_type{}; - - template struct is_volatile : public is_volatile_value{}; - template struct is_volatile : public false_type{}; // Note here that T is volatile, not the reference to T. So is_const is false. See section 8.3.2p1 of the C++ standard. - - - - /////////////////////////////////////////////////////////////////////// - // is_abstract - // - // is_abstract::value == true if and only if T is a class or struct - // that has at least one pure virtual function. is_abstract may only - // be applied to complete types. - // - /////////////////////////////////////////////////////////////////////// - - // Not implemented yet. - - - - /////////////////////////////////////////////////////////////////////// - // is_signed - // - // is_signed::value == true if and only if T is one of the following types: - // [const] [volatile] char (maybe) - // [const] [volatile] signed char - // [const] [volatile] short - // [const] [volatile] int - // [const] [volatile] long - // [const] [volatile] long long - // - // Used to determine if a integral type is signed or unsigned. - // Given that there are some user-made classes which emulate integral - // types, we provide the EASTL_DECLARE_SIGNED macro to allow you to - // set a given class to be identified as a signed type. - /////////////////////////////////////////////////////////////////////// - template struct is_signed : public false_type{}; - - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - - #if (CHAR_MAX == SCHAR_MAX) - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - #endif - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - #if defined(__WCHAR_MAX__) && ((__WCHAR_MAX__ == 2147483647) || (__WCHAR_MAX__ == 32767)) // GCC defines __WCHAR_MAX__ for most platforms. - template <> struct is_signed : public true_type{}; - template <> struct is_signed : public true_type{}; - #endif - #endif - - #define EASTL_DECLARE_SIGNED(T) namespace eastl{ template <> struct is_signed : public true_type{}; template <> struct is_signed : public true_type{}; } - - - - /////////////////////////////////////////////////////////////////////// - // is_unsigned - // - // is_unsigned::value == true if and only if T is one of the following types: - // [const] [volatile] char (maybe) - // [const] [volatile] unsigned char - // [const] [volatile] unsigned short - // [const] [volatile] unsigned int - // [const] [volatile] unsigned long - // [const] [volatile] unsigned long long - // - // Used to determine if a integral type is signed or unsigned. - // Given that there are some user-made classes which emulate integral - // types, we provide the EASTL_DECLARE_UNSIGNED macro to allow you to - // set a given class to be identified as an unsigned type. - /////////////////////////////////////////////////////////////////////// - template struct is_unsigned : public false_type{}; - - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - - #if (CHAR_MAX == UCHAR_MAX) - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - #endif - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - #if defined(_MSC_VER) || (defined(__WCHAR_MAX__) && ((__WCHAR_MAX__ == 4294967295U) || (__WCHAR_MAX__ == 65535))) // GCC defines __WCHAR_MAX__ for most platforms. - template <> struct is_unsigned : public true_type{}; - template <> struct is_unsigned : public true_type{}; - #endif - #endif - - #define EASTL_DECLARE_UNSIGNED(T) namespace eastl{ template <> struct is_unsigned : public true_type{}; template <> struct is_unsigned : public true_type{}; } - - - - /////////////////////////////////////////////////////////////////////// - // alignment_of - // - // alignment_of::value is an integral value representing, in bytes, - // the memory alignment of objects of type T. - // - // alignment_of may only be applied to complete types. - // - /////////////////////////////////////////////////////////////////////// - template - struct alignment_of_value{ static const size_t value = EASTL_ALIGN_OF(T); }; - - template - struct alignment_of : public integral_constant::value>{}; - - - - /////////////////////////////////////////////////////////////////////// - // is_aligned - // - // Defined as true if the type has alignment requirements greater - // than default alignment, which is taken to be 8. This allows for - // doing specialized object allocation and placement for such types. - /////////////////////////////////////////////////////////////////////// - template - struct is_aligned_value{ static const bool value = (EASTL_ALIGN_OF(T) > 8); }; - - template - struct is_aligned : public integral_constant::value>{}; - - - - /////////////////////////////////////////////////////////////////////// - // rank - // - // rank::value is an integral value representing the number of - // dimensions possessed by an array type. For example, given a - // multi-dimensional array type T[M][N], std::tr1::rank::value == 2. - // For a given non-array type T, std::tr1::rank::value == 0. - // - /////////////////////////////////////////////////////////////////////// - - // Not implemented yet. - - - - /////////////////////////////////////////////////////////////////////// - // extent - // - // extent::value is an integral type representing the number of - // elements in the Ith dimension of array type T. - // - // For a given array type T[N], std::tr1::extent::value == N. - // For a given multi-dimensional array type T[M][N], std::tr1::extent::value == N. - // For a given multi-dimensional array type T[M][N], std::tr1::extent::value == M. - // For a given array type T and a given dimension I where I >= rank::value, std::tr1::extent::value == 0. - // For a given array type of unknown extent T[], std::tr1::extent::value == 0. - // For a given non-array type T and an arbitrary dimension I, std::tr1::extent::value == 0. - // - /////////////////////////////////////////////////////////////////////// - - // Not implemented yet. - - - - /////////////////////////////////////////////////////////////////////// - // is_base_of - // - // Given two (possibly identical) types Base and Derived, is_base_of::value == true - // if and only if Base is a direct or indirect base class of Derived, - // or Base and Derived are the same type. - // - // is_base_of may only be applied to complete types. - // - /////////////////////////////////////////////////////////////////////// - - // Not implemented yet. - - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_eastl.h deleted file mode 100644 index ce5951499cae..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_eastl.h +++ /dev/null @@ -1,337 +0,0 @@ -/* -Copyright (C) 2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/type_traits.h -// -// Copyright (c) 2005, Electronic Arts. All rights reserved. -// Written and maintained by Paul Pedriana. -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Specification -// -// This file implements C++ type traits as proposed by the emerging C++ update -// as of May, 2005. This update is known as "Proposed Draft Technical Report -// on C++ Library Extensions" and is document number n1745. It can be found -// on the Internet as n1745.pdf and as of this writing it is updated every -// couple months to reflect current thinking. -////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Description -// -// EASTL includes a fairly serious type traits library that is on par with the -// one found in Boost but offers some additional performance-enhancing help as well. -// The type_traits library provides information about class types, as opposed to -// class instances. For example, the is_integral type trait tells if a type is -// one of int, short, long, char, uint64_t, etc. -// -// There are three primary uses of type traits: -// * Allowing for optimized operations on some data types. -// * Allowing for different logic pathways based on data types. -// * Allowing for compile-type assertions about data type expectations. -// -// Most of the type traits are automatically detected and implemented by the compiler. -// However, EASTL allows for the user to explicitly give the compiler hints about -// type traits that the compiler cannot know, via the EASTL_DECLARE declarations. -// If the user has a class that is relocatable (i.e. can safely use memcpy to copy values), -// the user can use the EASTL_DECLARE_TRIVIAL_RELOCATE declaration to tell the compiler -// that the class can be copied via memcpy. This will automatically significantly speed -// up some containers and algorithms that use that class. -// -// Here is an example of using type traits to tell if a value is a floating point -// value or not: -// -// template -// DoSomething(T t) { -// assert(is_floating_point::value); -// } -// -// Here is an example of declaring a class as relocatable and using it in a vector. -// -// EASTL_DECLARE_TRIVIAL_RELOCATE(Widget); // Usually you put this at the Widget class declaration. -// vector wVector; -// wVector.erase(wVector.begin()); // This operation will be optimized via using memcpy. -// -// The following is a full list of the currently recognized type traits. Most of these -// are implemented as of this writing, but if there is one that is missing, feel free -// to contact the maintainer of this library and request that it be completed. -// -// Trait Description -// ------------------------------------------------------------------------------ -// is_void T is void or a cv-qualified (const/void-qualified) void. -// is_integral T is an integral type. -// is_floating_point T is a floating point type. -// is_arithmetic T is an arithmetic type (integral or floating point). -// is_fundamental T is a fundamental type (void, integral, or floating point). -// is_const T is const-qualified. -// is_volatile T is volatile-qualified. -// is_abstract T is an abstract class. -// is_signed T is a signed integral type. -// is_unsigned T is an unsigned integral type. -// is_array T is an array type. The templated array container is not an array type. -// is_pointer T is a pointer type. Includes function pointers, but not pointers to (data or function) members. -// is_reference T is a reference type. Includes references to functions. -// is_member_object_pointer T is a pointer to data member. -// is_member_function_pointer T is a pointer to member function. -// is_member_pointer T is a pointer to a member or member function. -// is_enum T is an enumeration type. -// is_union T is a union type. -// is_class T is a class type but not a union type. -// is_polymorphic T is a polymorphic class. -// is_function T is a function type. -// is_object T is an object type. -// is_scalar T is a scalar type (arithmetic, enum, pointer, member_pointer) -// is_compound T is a compound type (anything but fundamental). -// is_same T and U name the same type. -// is_convertible An imaginary lvalue of type From is implicitly convertible to type To. Special conversions involving string-literals -// and null-pointer constants are not considered. No function-parameter adjustments are made to type To when determining -// whether From is convertible to To; this implies that if type To is a function type or an array type, then the condition is false. -// is_base_of Base is a base class of Derived or Base and Derived name the same type. -// is_empty T is an empty class. -// is_pod T is a POD type. -// *is_aligned Defined as true if the type has alignment requirements greater than default alignment, which is taken to be 8. -// has_trivial_constructor The default constructor for T is trivial. -// has_trivial_copy The copy constructor for T is trivial. -// has_trivial_assign The assignment operator for T is trivial. -// has_trivial_destructor The destructor for T is trivial. -// *has_trivial_relocate T can be moved to a new location via bitwise copy. -// has_nothrow_constructor The default constructor for T has an empty exception specification or can otherwise be deduced never to throw an exception. -// has_nothrow_copy The copy constructor for T has an empty exception specification or can otherwise be deduced never to throw an exception. -// has_nothrow_assign The assignment operator for T has an empty exception specification or can otherwise be deduced never to throw an exception. -// has_virtual_destructor T has a virtual destructor. -// alignment_of An integer value representing the number of bytes of the alignment of objects of type T; an object of type T may be allocated -// at an address that is a multiple of its alignment. -// rank An integer value representing the rank of objects of type T. The term 'rank' here is used to describe the number of dimensions of an array type. -// extent An integer value representing the extent (dimension) of the I'th bound of objects of type T. If the type T is not an array -// type, has rank of less than I, or if I == 0 and T is of type 'array of unknown bound of U,' then value shall evaluate to zero; -// otherwise value shall evaluate to the number of elements in the I'th array bound of T. The term 'extent' here is used to describe -// the number of elements in an array type. -// remove_const The member typedef type shall be the same as T except that any top level const-qualifier has been removed. -// remove_const::type evaluates to volatile int, whereas remove_const is const int*. -// -// * is_aligned is not found in Boost nor the C++ standard update proposal. -// -// * has_trivial_relocate is not found in Boost nor the C++ standard update proposal. -// However, it is very useful in allowing for the generation of optimized object -// moving operations. It is similar to the is_pod type trait, but goes further and -// allows non-pod classes to be categorized as relocatable. Such categorization is -// something that no compiler can do, as only the user can know if it is such. -// Thus EASTL_DECLARE_TRIVIAL_RELOCATE is provided to allow the user to give -// the compiler a hint. -// -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Requirements -// -// As of this writing (5/2005), type_traits here requires a well-conforming -// C++ compiler with respect to template metaprogramming. To use this library -// you need to have at least one of the following: -// MSVC++ 7.1 (includes Win32, XBox 360, Win64, and WinCE platforms) -// GCC 3.2 (includes Playstation 3, and Linux platforms) -// Metrowerks 8.0 (incluees Playstation 3, Windows, and other platforms) -// SN Systems (not the GCC 2.95-based compilers) -// EDG (includes any compiler with EDG as a back-end, such as the Intel compiler) -// Comeau (this is a C++ to C generator) -// -// It may be useful to list the compilers/platforms the current version of -// type_traits doesn't support: -// Borland C++ (it simply has too many bugs with respect to templates). -// GCC 2.96 With a little effort, type_traits can probably be made to work with this compiler. -////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Implementation -// -// The implementation here is almost entirely based on template metaprogramming. -// This is whereby you use the compiler's template functionality to define types -// and values and make compilation decisions based on template declarations. -// Many of the algorithms here are similar to those found in books such as -// "Modern C++ Design" and C++ libraries such as Boost. The implementations here -// are simpler and more straightforward than those found in some libraries, due -// largely to our assumption that the compiler is good at donig template programming. -/////////////////////////////////////////////////////////////////////////////// - - - -#ifndef EASTL_TYPE_TRAITS_H -#define EASTL_TYPE_TRAITS_H - - - -#include -#include // Is needed for size_t usage by some traits. - - - -namespace eastl -{ - - /////////////////////////////////////////////////////////////////////// - // integral_constant - // - // This is the base class for various type traits, as defined by the proposed - // C++ standard. This is essentially a utility base class for defining properties - // as both class constants (value) and as types (type). - // - template - struct integral_constant - { - static const T value = v; - typedef T value_type; - typedef integral_constant type; - }; - - - /////////////////////////////////////////////////////////////////////// - // true_type / false_type - // - // These are commonly used types in the implementation of type_traits. - // Other integral constant types can be defined, such as those based on int. - // - typedef integral_constant true_type; - typedef integral_constant false_type; - - - - /////////////////////////////////////////////////////////////////////// - // yes_type / no_type - // - // These are used as a utility to differentiate between two things. - // - typedef char yes_type; // sizeof(yes_type) == 1 - struct no_type { char padding[8]; }; // sizeof(no_type) != 1 - - - - /////////////////////////////////////////////////////////////////////// - // type_select - // - // This is used to declare a type from one of two type options. - // The result is based on the condition type. This has certain uses - // in template metaprogramming. - // - // Example usage: - // typedef ChosenType = type_select::value, ChoiceAType, ChoiceBType>::type; - // - template - struct type_select { typedef ConditionIsTrueType type; }; - - template - struct type_select { typedef ConditionIsFalseType type; }; - - - - /////////////////////////////////////////////////////////////////////// - // type_or - // - // This is a utility class for creating composite type traits. - // - template - struct type_or; - - template - struct type_or { static const bool value = true; }; - - template <> - struct type_or { static const bool value = false; }; - - - - /////////////////////////////////////////////////////////////////////// - // type_and - // - // This is a utility class for creating composite type traits. - // - template - struct type_and; - - template - struct type_and{ static const bool value = false; }; - - template <> - struct type_and{ static const bool value = true; }; - - - - /////////////////////////////////////////////////////////////////////// - // type_equal - // - // This is a utility class for creating composite type traits. - // - template - struct type_equal{ static const bool value = (b1 == b2); }; - - - - /////////////////////////////////////////////////////////////////////// - // type_not_equal - // - // This is a utility class for creating composite type traits. - // - template - struct type_not_equal{ static const bool value = (b1 != b2); }; - - - - /////////////////////////////////////////////////////////////////////// - // type_not - // - // This is a utility class for creating composite type traits. - // - template - struct type_not{ static const bool value = true; }; - - template <> - struct type_not{ static const bool value = false; }; - - - - /////////////////////////////////////////////////////////////////////// - // empty - // - template - struct empty{ }; - - -} // namespace eastl - - -// The following files implement the type traits themselves. - #include - #include - #include - #include - #include - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_rdestl.h deleted file mode 100644 index 9252b341d1f7..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_traits_rdestl.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef RDESTL_TYPETRAITS_H -#define RDESTL_TYPETRAITS_H - -namespace rde -{ - -template struct is_integral -{ - enum { value = false }; -}; - -template struct is_floating_point -{ - enum { value = false }; -}; - -#define RDE_INTEGRAL(TYPE) template<> struct is_integral { enum { value = true }; } - -RDE_INTEGRAL(char); -RDE_INTEGRAL(bool); -RDE_INTEGRAL(short); -RDE_INTEGRAL(int); -RDE_INTEGRAL(long); -RDE_INTEGRAL(wchar_t); - -template<> struct is_floating_point { enum { value = true }; }; -template<> struct is_floating_point { enum { value = true }; }; - -template struct is_pointer -{ - enum { value = false }; -}; -template struct is_pointer -{ - enum { value = true }; -}; - -template struct is_pod -{ - enum { value = false }; -}; - -template struct is_fundamental -{ - enum - { - value = is_integral::value || is_floating_point::value - }; -}; - -template struct has_trivial_constructor -{ - enum - { - value = is_fundamental::value || is_pointer::value || is_pod::value - }; -}; - -template struct has_trivial_copy -{ - enum - { - value = is_fundamental::value || is_pointer::value || is_pod::value - }; -}; - -template struct has_trivial_assign -{ - enum - { - value = is_fundamental::value || is_pointer::value || is_pod::value - }; -}; - -template struct has_trivial_destructor -{ - enum - { - value = is_fundamental::value || is_pointer::value || is_pod::value - }; -}; - -template struct has_cheap_compare -{ - enum - { - value = has_trivial_copy::value && sizeof(T) <= 4 - }; -}; - -} // namespace rde - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_TYPETRAITS_H - - diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_transformations_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_transformations_eastl.h deleted file mode 100644 index 3100f1cded65..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/type_transformations_eastl.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/internal/type_transformations.h -// Written and maintained by Paul Pedriana - 2005 -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef EASTL_INTERNAL_TYPE_TRANFORMATIONS_H -#define EASTL_INTERNAL_TYPE_TRANFORMATIONS_H - - -namespace eastl -{ - - - // The following transformations are defined here. If the given item - // is missing then it simply hasn't been implemented, at least not yet. - // add_unsigned - // add_signed - // remove_const - // remove_volatile - // remove_cv - // add_const - // add_volatile - // add_cv - // remove_reference - // add_reference - // remove_extent - // remove_all_extents - // remove_pointer - // add_pointer - // aligned_storage - - - /////////////////////////////////////////////////////////////////////// - // add_signed - // - // Adds signed-ness to the given type. - // Modifies only integral values; has no effect on others. - // add_signed::type is int - // add_signed::type is int - // - /////////////////////////////////////////////////////////////////////// - - template - struct add_signed - { typedef T type; }; - - template<> - struct add_signed - { typedef signed char type; }; - - #if (defined(CHAR_MAX) && defined(UCHAR_MAX) && (CHAR_MAX == UCHAR_MAX)) // If char is unsigned (which is usually not the case)... - template<> - struct add_signed - { typedef signed char type; }; - #endif - - template<> - struct add_signed - { typedef short type; }; - - template<> - struct add_signed - { typedef int type; }; - - template<> - struct add_signed - { typedef long type; }; - - template<> - struct add_signed - { typedef long long type; }; - - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - #if (defined(__WCHAR_MAX__) && (__WCHAR_MAX__ == 4294967295U)) // If wchar_t is a 32 bit unsigned value... - template<> - struct add_signed - { typedef int32_t type; }; - #elif (defined(__WCHAR_MAX__) && (__WCHAR_MAX__ == 65535)) // If wchar_t is a 16 bit unsigned value... - template<> - struct add_signed - { typedef int16_t type; }; - #endif - #endif - - - - /////////////////////////////////////////////////////////////////////// - // add_unsigned - // - // Adds unsigned-ness to the given type. - // Modifies only integral values; has no effect on others. - // add_unsigned::type is unsigned int - // add_unsigned::type is unsigned int - // - /////////////////////////////////////////////////////////////////////// - - template - struct add_unsigned - { typedef T type; }; - - template<> - struct add_unsigned - { typedef unsigned char type; }; - - #if (defined(CHAR_MAX) && defined(SCHAR_MAX) && (CHAR_MAX == SCHAR_MAX)) // If char is signed (which is usually so)... - template<> - struct add_unsigned - { typedef unsigned char type; }; - #endif - - template<> - struct add_unsigned - { typedef unsigned short type; }; - - template<> - struct add_unsigned - { typedef unsigned int type; }; - - template<> - struct add_unsigned - { typedef unsigned long type; }; - - template<> - struct add_unsigned - { typedef unsigned long long type; }; - - #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type... - #if (defined(__WCHAR_MAX__) && (__WCHAR_MAX__ == 2147483647)) // If wchar_t is a 32 bit signed value... - template<> - struct add_unsigned - { typedef uint32_t type; }; - #elif (defined(__WCHAR_MAX__) && (__WCHAR_MAX__ == 32767)) // If wchar_t is a 16 bit signed value... - template<> - struct add_unsigned - { typedef uint16_t type; }; - #endif - #endif - - /////////////////////////////////////////////////////////////////////// - // remove_cv - // - // Remove const and volatile from a type. - // - // The remove_cv transformation trait removes top-level const and/or volatile - // qualification (if any) from the type to which it is applied. For a given type T, - // remove_cv::type is equivalent to T. For example, - // remove_cv::type is equivalent to char*, while remove_cv::type - // is equivalent to const char*. In the latter case, the const qualifier modifies - // char, not *, and is therefore not at the top level. - // - /////////////////////////////////////////////////////////////////////// - template struct remove_cv_imp{}; - template struct remove_cv_imp { typedef T unqualified_type; }; - template struct remove_cv_imp { typedef T unqualified_type; }; - template struct remove_cv_imp { typedef T unqualified_type; }; - template struct remove_cv_imp { typedef T unqualified_type; }; - - template struct remove_cv{ typedef typename remove_cv_imp::unqualified_type type; }; - template struct remove_cv{ typedef T& type; }; // References are automatically not const nor volatile. See section 8.3.2p1 of the C++ standard. - - template struct remove_cv { typedef T type[N]; }; - template struct remove_cv { typedef T type[N]; }; - template struct remove_cv{ typedef T type[N]; }; - - - - /////////////////////////////////////////////////////////////////////// - // add_reference - // - // Add reference to a type. - // - // The add_reference transformation trait adds a level of indirection - // by reference to the type to which it is applied. For a given type T, - // add_reference::type is equivalent to T& if is_reference::value == false, - // and T otherwise. - // - /////////////////////////////////////////////////////////////////////// - template - struct add_reference_impl{ typedef T& type; }; - - template - struct add_reference_impl{ typedef T& type; }; - - template <> - struct add_reference_impl{ typedef void type; }; - - template - struct add_reference { typedef typename add_reference_impl::type type; }; - - -} // namespace eastl - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_eastl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_eastl.h deleted file mode 100644 index df22d4859d65..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_eastl.h +++ /dev/null @@ -1,297 +0,0 @@ -/* -Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/////////////////////////////////////////////////////////////////////////////// -// EASTL/utility.h -// Written and maintained by Paul Pedriana - 2005. -/////////////////////////////////////////////////////////////////////////////// - - - -#ifndef EASTL_UTILITY_H -#define EASTL_UTILITY_H - - -#include - - -#ifdef _MSC_VER - #pragma warning(push) // VC++ generates a bogus warning that you cannot code away. - #pragma warning(disable: 4619) // There is no warning number 'number'. - #pragma warning(disable: 4217) // Member template functions cannot be used for copy-assignment or copy-construction. - #pragma warning(disable: 4512) // 'class' : assignment operator could not be generated. // This disabling would best be put elsewhere. -#endif - - -namespace eastl -{ - - /////////////////////////////////////////////////////////////////////// - /// rel_ops - /// - /// rel_ops allow the automatic generation of operators !=, >, <=, >= from - /// just operators == and <. These are intentionally in the rel_ops namespace - /// so that they don't conflict with other similar operators. To use these - /// operators, add "using namespace std::rel_ops;" to an appropriate place in - /// your code, usually right in the function that you need them to work. - /// In fact, you will very likely have collision problems if you put such - /// using statements anywhere other than in the .cpp file like so and may - /// also have collisions when you do, as the using statement will affect all - /// code in the module. You need to be careful about use of rel_ops. - /// - namespace rel_ops - { - template - inline bool operator!=(const T& x, const T& y) - { return !(x == y); } - - template - inline bool operator>(const T& x, const T& y) - { return (y < x); } - - template - inline bool operator<=(const T& x, const T& y) - { return !(y < x); } - - template - inline bool operator>=(const T& x, const T& y) - { return !(x < y); } - } - - - - /////////////////////////////////////////////////////////////////////// - /// pair - /// - /// Implements a simple pair, just like the C++ std::pair. - /// - template - struct pair - { - typedef T1 first_type; - typedef T2 second_type; - - T1 first; - T2 second; - - pair(); - pair(const T1& x); - pair(const T1& x, const T2& y); - - template - pair(const pair& p); - - // pair(const pair& p); // Not necessary, as default version is OK. - // pair& operator=(const pair& p); // Not necessary, as default version is OK. - }; - - - - - /// use_self - /// - /// operator()(x) simply returns x. Used in sets, as opposed to maps. - /// This is a template policy implementation; it is an alternative to - /// the use_first template implementation. - /// - /// The existance of use_self may seem odd, given that it does nothing, - /// but these kinds of things are useful, virtually required, for optimal - /// generic programming. - /// - template - struct use_self // : public unary_function // Perhaps we want to make it a subclass of unary_function. - { - typedef T result_type; - - const T& operator()(const T& x) const - { return x; } - }; - - /// use_first - /// - /// operator()(x) simply returns x.first. Used in maps, as opposed to sets. - /// This is a template policy implementation; it is an alternative to - /// the use_self template implementation. This is the same thing as the - /// SGI SGL select1st utility. - /// - template - struct use_first // : public unary_function // Perhaps we want to make it a subclass of unary_function. - { - typedef typename Pair::first_type result_type; - - const result_type& operator()(const Pair& x) const - { return x.first; } - }; - - /// use_second - /// - /// operator()(x) simply returns x.second. - /// This is the same thing as the SGI SGL select2nd utility - /// - template - struct use_second // : public unary_function // Perhaps we want to make it a subclass of unary_function. - { - typedef typename Pair::second_type result_type; - - const result_type& operator()(const Pair& x) const - { return x.second; } - }; - - - - - - /////////////////////////////////////////////////////////////////////// - // pair - /////////////////////////////////////////////////////////////////////// - - template - inline pair::pair() - : first(), second() - { - // Empty - } - - - template - inline pair::pair(const T1& x) - : first(x), second() - { - // Empty - } - - - template - inline pair::pair(const T1& x, const T2& y) - : first(x), second(y) - { - // Empty - } - - - template - template - inline pair::pair(const pair& p) - : first(p.first), second(p.second) - { - // Empty - } - - - - - /////////////////////////////////////////////////////////////////////// - // global operators - /////////////////////////////////////////////////////////////////////// - - template - inline bool operator==(const pair& a, const pair& b) - { - return ((a.first == b.first) && (a.second == b.second)); - } - - - template - inline bool operator<(const pair& a, const pair& b) - { - // Note that we use only operator < in this expression. Otherwise we could - // use the simpler: return (a.m1 == b.m1) ? (a.m2 < b.m2) : (a.m1 < b.m1); - // The user can write a specialization for this operator to get around this - // in cases where the highest performance is required. - return ((a.first < b.first) || (!(b.first < a.first) && (a.second < b.second))); - } - - - template - inline bool operator!=(const pair& a, const pair& b) - { - return !(a == b); - } - - - template - inline bool operator>(const pair& a, const pair& b) - { - return b < a; - } - - - template - inline bool operator>=(const pair& a, const pair& b) - { - return !(a < b); - } - - - template - inline bool operator<=(const pair& a, const pair& b) - { - return !(b < a); - } - - - - - /////////////////////////////////////////////////////////////////////// - /// make_pair / make_pair_ref - /// - /// make_pair is the same as std::make_pair specified by the C++ standard. - /// If you look at the C++ standard, you'll see that it specifies T& instead of T. - /// However, it has been determined that the C++ standard is incorrect and has - /// flagged it as a defect (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#181). - /// In case you feel that you want a more efficient version that uses references, - /// we provide the make_pair_ref function below. - /// - /// Note: You don't need to use make_pair in order to make a pair. The following - /// code is equivalent, and the latter avoids one more level of inlining: - /// return make_pair(charPtr, charPtr); - /// return pair(charPtr, charPtr); - /// - template - inline pair make_pair(T1 a, T2 b) - { - return pair(a, b); - } - - - template - inline pair make_pair_ref(const T1& a, const T2& b) - { - return pair(a, b); - } - - -} // namespace eastl - - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - - -#endif // Header include guard diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_rdestl.h b/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_rdestl.h deleted file mode 100644 index 2310989d5ef8..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/unused-maps/utility_rdestl.h +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef RDESTL_UTILITY_H -#define RDESTL_UTILITY_H - -#include -#include - -namespace rde -{ -namespace internal -{ - template - void copy_n(const T* first, size_t n, T* result, int_to_type) - { - const T* last = first + n; - //while (first != last) - // *result++ = *first++; - switch (n & 0x3) - { - case 0: - while (first != last) - { - *result++ = *first++; - case 3: *result++ = *first++; - case 2: *result++ = *first++; - case 1: *result++ = *first++; - } - } - } - template - void copy_n(const T* first, size_t n, T* result, int_to_type) - { - RDE_ASSERT(result >= first + n || result < first); - Sys::MemCpy(result, first, n * sizeof(T)); - } - - template - void copy(const T* first, const T* last, T* result, int_to_type) - { - while (first != last) - *result++ = *first++; - } - template - void copy(const T* first, const T* last, T* result, int_to_type) - { - const size_t n = reinterpret_cast(last) - reinterpret_cast(first); - Sys::MemCpy(result, first, n); - } - - template RDE_FORCEINLINE - void move_n(const T* from, size_t n, T* result, int_to_type) - { - for (int i = int(n) - 1; i >= 0; --i) - result[i] = from[i]; - } - template RDE_FORCEINLINE - void move_n(const T* first, size_t n, T* result, int_to_type) - { - Sys::MemMove(result, first, n * sizeof(T)); - } - - template RDE_FORCEINLINE - void move(const T* first, const T* last, T* result, int_to_type) - { - while (--last >= first) - *result++ = *last; - } - template RDE_FORCEINLINE - void move(const T* first, const T* last, T* result, int_to_type) - { - // Meh, MSVC does pretty stupid things here. - //memmove(result, first, (last - first) * sizeof(T)); - const size_t n = reinterpret_cast(last) - reinterpret_cast(first); - //const size_t n = (last - first) * sizeof(T); - Sys::MemMove(result, first, n); - } - - - template - void copy_construct_n(const T* first, size_t n, T* result, int_to_type) - { - for (size_t i = 0; i < n; ++i) - new (result + i) T(first[i]); - } - template - void copy_construct_n(const T* first, size_t n, T* result, int_to_type) - { - RDE_ASSERT(result >= first + n || result < first); - Sys::MemCpy(result, first, n * sizeof(T)); - } - - template - void destruct_n(T* first, size_t n, int_to_type) - { - // For unknown reason MSVC cant see reference to first here... - sizeof(first); - for (size_t i = 0; i < n; ++i) - (first + i)->~T(); - } - template RDE_FORCEINLINE - void destruct_n(T*, size_t, int_to_type) - { - // Nothing to do, no destructor needed. - } - - template - void destruct(T* mem, int_to_type) - { - //////CB17/05/11sizeof(mem); - mem->~T(); - } - template RDE_FORCEINLINE - void destruct(T*, int_to_type) - { - // Nothing to do, no destructor needed. - } - - template - void construct(T* mem, int_to_type) - { - new (mem) T(); - } - template RDE_FORCEINLINE - void construct(T*, int_to_type) - { - // Nothing to do - } - - template RDE_FORCEINLINE - void copy_construct(T* mem, const T& orig, int_to_type) - { - new (mem) T(orig); - } - template RDE_FORCEINLINE - void copy_construct(T* mem, const T& orig, int_to_type) - { - mem[0] = orig; - } - - template - void construct_n(T* to, size_t count, int_to_type) - { - sizeof(to); - for (size_t i = 0; i < count; ++i) - new (to + i) T(); - } - template inline - void construct_n(T*, int, int_to_type) - { - // trivial ctor, nothing to do. - } - - // Tests if all elements in range are ordered according to pred. - template - void test_ordering(TIter first, TIter last, const TPred& pred) - { -#if RDE_DEBUG - if (first != last) - { - TIter next = first; - if (++next != last) - { - RDE_ASSERT(pred(*first, *next)); - first = next; - } - } -#else - sizeof(first); sizeof(last); sizeof(pred); -#endif - } - - template inline - bool debug_pred(const TPred& pred, const T1& a, const T2& b) - { -#if RDE_DEBUG - if (pred(a, b)) - { - RDE_ASSERT(!pred(b, a)); - return true; - } - else - { - return false; - } -#else - return pred(a, b); -#endif - } -} // namespace internal - -} // namespace rde - -//----------------------------------------------------------------------------- -#endif // #ifndef RDESTL_UTILITY_H diff --git a/packages/stk/stk_classic/stk_util/stk_util/util/vectorization.hpp b/packages/stk/stk_classic/stk_util/stk_util/util/vectorization.hpp deleted file mode 100644 index 9858ef725c75..000000000000 --- a/packages/stk/stk_classic/stk_util/stk_util/util/vectorization.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef STK_UTIL_UTIL_VECTORIZATION_H -#define STK_UTIL_UTIL_VECTORIZATION_H - -#if defined(__INTEL_COMPILER) -#define RESTRICT_ALIAS restrict -#elif defined(__GNUC__) -#define RESTRICT_ALIAS __restrict__ -#else -#define RESTRICT_ALIAS -#endif - -#endif diff --git a/packages/stk/stk_classic/stk_util/unit_tests/CMakeLists.txt b/packages/stk/stk_classic/stk_util/unit_tests/CMakeLists.txt deleted file mode 100644 index 30ba8e93d56a..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - - -ASSERT_DEFINED(PACKAGE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR) - -if ( TPL_ENABLE_MPI ) - ADD_SUBDIRECTORY(parallel) -ENDIF() - -TRIBITS_CONFIGURE_FILE(${PACKAGE_NAME}_config.h) - -FILE(GLOB SOURCES diag/*.cpp environment/*.cpp util/*.cpp) - -APPEND_SET( SOURCES - UnitTestBoost.cpp - UnitTestMain.cpp -) - -if ( TPL_ENABLE_MPI ) - APPEND_SET( SOURCES - UnitTestParallel.cpp - ) -ENDIF() - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - util_UnitTest - SOURCES ${SOURCES} - DEPLIBS stkclassic_util_parallel stkclassic_util_diag - COMM serial mpi - NUM_MPI_PROCS 1 - STANDARD_PASS_OUTPUT - ) - - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestBoost.cpp b/packages/stk/stk_classic/stk_util/unit_tests/UnitTestBoost.cpp deleted file mode 100644 index adb98b376c26..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestBoost.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -//boost tr1 headers... -//On the sun, couldn't get '#include ' to work, so we're using the boost -//form instead... -#include -#include -#include -#include - -#include - -#include - -namespace boost { - -template <> -struct hash -{ - std::size_t operator()(const ci_string &s) const { - std::size_t seed = 0; - - for(ci_string::const_iterator first = s.begin(); first != s.end(); ++first) { - boost::hash hasher; - seed ^= hasher(std::tolower(*first)) + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - - return seed; - } -}; - -} // namespace boost - -STKUNIT_UNIT_TEST(UnitTestBoost, testUnit) -{ - { - double* d = new double; - boost::shared_ptr dptr(d); - - STKUNIT_ASSERT_EQUAL( dptr.get(), d); - - double* d2 = new double[1]; - boost::shared_array dptr2(d2); - - STKUNIT_ASSERT_EQUAL( dptr2.get(), d2); - } - - // Had to comment this out because boost/tr1/array.hpp is incompatible with - // stk_utest_macros.hpp - /* - boost::array my_array; - - my_array[0] = 5.0; - - STKUNIT_ASSERT_EQUAL( my_array[0], 5.0 ); - STKUNIT_ASSERT_EQUAL( my_array.size(), (boost::array::size_type)5 ); - */ - - boost::unordered_set int_set; - - int_set.insert(5); - - STKUNIT_ASSERT_EQUAL( int_set.size(), (boost::unordered_set::size_type)1 ); - - boost::unordered_set ci_string_set; - - ci_string_set.insert("Test"); - std::pair::iterator, bool> res = ci_string_set.insert("test"); - - STKUNIT_ASSERT_EQUAL( ci_string_set.size(), (boost::unordered_set::size_type)1 ); - STKUNIT_ASSERT_EQUAL( res.second, false ); - - ci_string s("This is a test"); - - STKUNIT_ASSERT( s == "this is a test" ); - - std::cout << s << std::endl; - -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestMain.cpp b/packages/stk/stk_classic/stk_util/unit_tests/UnitTestMain.cpp deleted file mode 100644 index 882fefdf2eba..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestMain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestParallel.cpp b/packages/stk/stk_classic/stk_util/unit_tests/UnitTestParallel.cpp deleted file mode 100644 index 7408b94231a4..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestParallel.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include -#include - -STKUNIT_UNIT_TEST(UnitTestParallel, testUnit) -{ - int mpi_rank = stk_classic::parallel_machine_rank(MPI_COMM_WORLD); - int mpi_size = stk_classic::parallel_machine_size(MPI_COMM_WORLD); - - std::string s; - std::ostringstream strout; - - std::cout << "all_write_string " << std::flush; - -// for (size_t i = 0; i < 250000; ++i) { - for (size_t i = 0; i < 100; ++i) { - if (mpi_rank == 0 && i%1000 == 0) - std::cout << "." << std::flush; - - stk_classic::all_write_string(MPI_COMM_WORLD, strout, s); - } - - STKUNIT_ASSERT_LT(mpi_rank, mpi_size); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestRange.cpp b/packages/stk/stk_classic/stk_util/unit_tests/UnitTestRange.cpp deleted file mode 100644 index 39d61ca2a0b6..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/UnitTestRange.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include - -STKUNIT_UNIT_TEST( UnitTestRange, range ) -{ - typedef std::vector IntVector; - typedef boost::sub_range IntRange; - - IntVector array(10,0); - - IntRange a_range = std::make_pair(array.begin(),array.end()); - IntRange b_range(std::make_pair(array.begin(),array.end())); - IntRange c_range(array.begin(),array.end() ); - IntRange d_range(array); - - STKUNIT_EXPECT_EQ( a_range, b_range ); - STKUNIT_EXPECT_EQ( a_range, c_range ); - STKUNIT_EXPECT_EQ( a_range, d_range ); - - stk_foreach( int & i, a_range) - { - STKUNIT_EXPECT_EQ( i, 0 ); - i = 1; - } - - stk_foreach( int i, c_range) - { - STKUNIT_EXPECT_EQ( i, 1 ); - } - - STKUNIT_EXPECT_TRUE( a_range == array); - -} - - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/UnitTest_iterator_wrapper.cpp b/packages/stk/stk_classic/stk_util/unit_tests/UnitTest_iterator_wrapper.cpp deleted file mode 100644 index 226daa0ab791..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/UnitTest_iterator_wrapper.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -#include - -STKUNIT_UNIT_TEST( random_access_iterator_wrapper, basic ) -{ - typedef stk_util::random_access_iterator_wrapper iterator; - typedef stk_util::random_access_iterator_wrapper const_iterator; - - int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - - { - iterator i(a); - const_iterator end(a+10); - for (int tmp=1; i!=end; ++i, ++tmp) { - STKUNIT_EXPECT_EQ(*i,tmp); - } - } - - { - iterator i(a); - for (int n=0; n<10; ++n) { - STKUNIT_EXPECT_EQ(i[n],a[n]); - } - } - - - -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestTimer.cpp b/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestTimer.cpp deleted file mode 100644 index aa88e63ed0b6..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestTimer.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -enum { - TIMER_DOMAIN = 0x00001000, ///< Enable domain timers - TIMER_REGION = 0x00002000, ///< Enable region timers - TIMER_PROCEDURE = 0x00004000, ///< Enable procedure timers - TIMER_MECHANICS = 0x00008000, ///< Enable mechanics timers - TIMER_ALGORITHM = 0x00010000, ///< Enable algorithm timers - TIMER_SOLVER = 0x00020000, ///< Enable solver timers - TIMER_CONTACT = 0x00040000, ///< Enable contact timers - TIMER_MATERIAL = 0x00080000, ///< Enable material timers - TIMER_SEARCH = 0x00100000, ///< Enable search timers - TIMER_TRANSFER = 0x00200000, ///< Enable transfer timers - TIMER_ADAPTIVITY = 0x00400000 ///< Enable adaptivity -}; - -enum { - TIMER_UNUSED_1 = 0x00001000, ///< Enable unused 1 - TIMER_PROFILE_1 = 0x00002000, ///< Enable profile 1 timers - TIMER_PROFILE_2 = 0x00004000, ///< Enable profile 2 timers - TIMER_PROFILE_3 = 0x00008000, ///< Enable profile 3 timers - TIMER_PROFILE_4 = 0x00010000, ///< Enable profile 4 timers - TIMER_APP_1 = 0x00020000, ///< Enable application defined 1 - TIMER_APP_2 = 0x00040000, ///< Enable application defined 2 - TIMER_APP_3 = 0x00080000 ///< Enable application defined 3 -}; - -namespace { - -double -quick_work() -{ - double x = 1.0; - - for (int i = 0; i < 10000; ++i) - x += std::sin((double) i); - - return x; -} - - -double -work() -{ - double x = 1.0; - - for (int i = 0; i < 100000; ++i) -// for (int i = 0; i < 100; ++i) - x += std::sin((double) i); - - return x; -} - - -stk_classic::diag::TimerSet & -unitTestTimerSet() -{ - static stk_classic::diag::TimerSet s_unitTestTimerSet(TIMER_REGION); - - return s_unitTestTimerSet; -} - - -stk_classic::diag::TimerSet & -unitTestSecondTimerSet() -{ - static stk_classic::diag::TimerSet s_unitTestSecondTimerSet(TIMER_APP_3); - - return s_unitTestSecondTimerSet; -} - - -stk_classic::diag::Timer &unitTestTimer() { - const std::string name("Unit test timer"); - static stk_classic::diag::Timer s_unitTestTimer (stk_classic::diag::createRootTimer(name, unitTestTimerSet())); - - return s_unitTestTimer; -} - - -struct RootObject -{ - RootObject() - : m_timer("Root object", TIMER_REGION, unitTestTimer()) - {} - - stk_classic::diag::Timer m_timer; -}; - - -struct Object -{ - Object(const std::string &name, RootObject &root_object) - : m_id(0), - m_name(name), - m_timer(name, root_object.m_timer) - {} - - Object(int id, const Object &parent) - : m_id(id), - m_name(id_name(id)), - m_timer(m_name, parent.m_timer) - {} - - static std::string id_name(int id) { - std::ostringstream s; - s << "Object id " << id << " run"; - return s.str(); - } - - void run() { - stk_classic::diag::TimeBlock _time(m_timer); - m_x += work(); - } - - int m_id; - std::string m_name; - stk_classic::diag::Timer m_timer; - double m_x; -}; - -} // namespace - -STKUNIT_UNIT_TEST(UnitTestTimer, UnitTest) -{ - stk_classic::diag::TimeBlock root_time_block(unitTestTimer()); - - std::ostringstream strout; - - // Create subtimer and test lap time - { - static stk_classic::diag::Timer lap_timer("One second Wall time twice", unitTestTimer()); - - stk_classic::diag::TimeBlock _time(lap_timer); - double x = quick_work(); - x = x; - std::ostringstream oss; - oss << x << std::endl; - - ::sleep(1); - - lap_timer.lap(); - - stk_classic::diag::MetricTraits::Type lap_time = lap_timer.getMetric().getLap(); - - STKUNIT_ASSERT(lap_time >= 1.0); - - ::sleep(1); - - lap_timer.stop(); - - lap_time = lap_timer.getMetric().getLap(); - - STKUNIT_ASSERT(lap_time >= 2.0); - } - - // - { - static stk_classic::diag::Timer run_timer("Run 100 times twice", unitTestTimer()); - - for (int i = 0; i < 100; ++i) { - stk_classic::diag::TimeBlock _time(run_timer); - work(); - } - - stk_classic::diag::MetricTraits::Type lap_count = run_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT(lap_count == 100); - } - - // Create second timer set - { - static stk_classic::diag::Timer second_timer("Second timer set", unitTestTimer(), unitTestSecondTimerSet()); - static stk_classic::diag::Timer second_timer_on_default("On default", second_timer); - static stk_classic::diag::Timer second_timer_on("On", TIMER_APP_3, second_timer); - static stk_classic::diag::Timer second_timer_off("Off", TIMER_APP_1, second_timer); - - stk_classic::diag::TimeBlock _time(second_timer); - stk_classic::diag::TimeBlock _time1(second_timer_on_default); - stk_classic::diag::TimeBlock _time2(second_timer_on); - stk_classic::diag::TimeBlock _time3(second_timer_off); - - ::sleep(1); - } - - // Grab previous subtimer and run 100 laps - { - static stk_classic::diag::Timer run_timer("Run 100 times twice", unitTestTimer()); - - for (int i = 0; i < 100; ++i) { - stk_classic::diag::TimeBlock _time(run_timer); - work(); - } - - stk_classic::diag::MetricTraits::Type lap_count = run_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT(lap_count == 200); - } - - // Create root object - RootObject root_object; - - { - stk_classic::diag::MetricTraits::Type lap_count = root_object.m_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT(lap_count == 0); - } - - // Create object - { - Object time_object("One object", root_object); - - for (int i = 0; i < 100; ++i) { - time_object.run(); - } - - stk_classic::diag::MetricTraits::Type lap_count = time_object.m_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT(lap_count == 100); - } - - // Create object tree - { - std::vector object_vector; - object_vector.push_back(Object("Object Tree", root_object)); - - int id = 0; - for (size_t i = 0; i < 2; ++i) { - size_t ix = object_vector.size(); - object_vector.push_back(Object(id++, object_vector[0])); - for (size_t j = 0; j < 2; ++j) { - size_t jx = object_vector.size(); - object_vector.push_back(Object(id++, object_vector[ix])); - for (int k = 0; k < 2; ++k) { - object_vector.push_back(Object(id++, object_vector[jx])); - } - } - } - - stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - stk_classic::diag::MetricTraits::Type lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits::Type(0)); - - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits::Type(object_vector.size())); - - for (size_t i = 1; i < 100; ++i) - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false); - - lap_count = 0; - for (size_t j = 0; j < object_vector.size(); ++j) - lap_count += object_vector[j].m_timer.getMetric().getAccumulatedLap(false); - - STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits::Type(100*object_vector.size())); - - stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, true); - - for (size_t i = 1; i < 100; ++i) - for (size_t j = 0; j < object_vector.size(); ++j) - object_vector[j].run(); - - stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, true); - - std::cout << strout.str() << std::endl; - -// dw().m(LOG_TIMER) << strout.str() << stk_classic::diag::dendl; - } -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestWriter.cpp b/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestWriter.cpp deleted file mode 100644 index 66e3d25c6ce6..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/diag/UnitTestWriter.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -using namespace stk_classic::diag; - -enum LogMask { - LOG_ALWAYS = stk_classic::LOG_ALWAYS, - LOG_TRACE = stk_classic::LOG_TRACE, - LOG_TRACE_STATS = stk_classic::LOG_TRACE_STATS, - LOG_TRACE_SUB_CALLS = stk_classic::LOG_TRACE_SUB_CALLS, - LOG_MEMBERS = stk_classic::LOG_MEMBERS, - - LOG_TEST1 = 0x0000010, - LOG_TEST2 = 0x0000020 -}; - - -std::ostringstream & -oss() -{ - static std::ostringstream s_oss; - - return s_oss; -} - - -std::ostream & -dwout() -{ - static stk_classic::indent_streambuf s_dwoutStreambuf(oss().rdbuf()); - static std::ostream s_dwout(&s_dwoutStreambuf); - - return s_dwout; -} - - -// Diagnostic writer -stk_classic::diag::Writer & -dw() -{ - static stk_classic::diag::Writer s_diagWriter(dwout().rdbuf(), 0); - - return s_diagWriter; -} - -STKUNIT_UNIT_TEST(UnitTestWriter, UnitTest) -{ - dw() << "This is a test" << dendl << dflush; - - STKUNIT_ASSERT_EQUAL((std::string("This is a test\n") == oss().str()), true); - - oss().str(""); - dw() << "Level 0" << push << dendl - << "This is a test" << dendl - << pop << dendl; - - STKUNIT_ASSERT_EQUAL((std::string("Level 0 {\n This is a test\n}\n") == oss().str()), true); - - oss().str(""); - { - stk_classic::diag::WriterThrowSafe throw_safe__(dw()); - - dw() << "Level 0" << push << dendl - << "Level 1" << push << dendl - << "Level 2" << push << dendl - << "Level 3" << push << dendl - << "This is a test" << dendl - << pop << dendl; - } - dw() << dendl; - STKUNIT_ASSERT_EQUAL((std::string("Level 0 {\n Level 1 {\n Level 2 {\n Level 3 {\n This is a test\n }\n }\n }\n}\n") == oss().str()), true); - - oss().str(""); - { - int x1 = 7; - unsigned x2 = 7; - short x3 = 7; - unsigned short x4 = 7; - long x5 = 7; - unsigned long x6 = 7; - long long x7 = 7; - unsigned long long x8 = 7; - char x9 = '\x7'; - signed char x10 = '\x7'; - unsigned char x11 = '\x7'; - - dw() << x1 << dendl; - dw() << x2 << dendl; - dw() << x3 << dendl; - dw() << x4 << dendl; - dw() << x5 << dendl; - dw() << x6 << dendl; - dw() << x7 << dendl; - dw() << x8 << dendl; - dw() << x9 << dendl; - dw() << x10 << dendl; - dw() << x11 << dendl; - dw() << 7.0 << dendl; - dw() << 7.0f << dendl; - dw() << 7.0l << dendl; - dw() << "This is a test" << dendl; - dw() << std::string("This is a test") << dendl; - } - STKUNIT_ASSERT_EQUAL((std::string("7\n7\n7\n7\n7\n7\n7\n7\n7\n7\n7\n7\n7\n7\nThis is a test\nThis is a test\n") == oss().str()), true); - - oss().str(""); - dw() << std::hex << 16 << dendl; - dw() << std::oct << 16 << dendl; - dw() << std::dec << 16 << dendl; - dw() << std::fixed << 3.14159265 << dendl; - dw() << std::scientific << 3.14159265 << dendl; - dw() << stk_classic::diag::hex << 16 << dendl; - dw() << stk_classic::diag::oct << 16 << dendl; - dw() << stk_classic::diag::dec << 16 << dendl; - dw() << stk_classic::diag::fixed << 3.14159265 << dendl; - dw() << stk_classic::diag::scientific << 3.14159265 << dendl; - dw() << stk_classic::diag::setw(5) << 3.14159265 << dendl; - dw() << stk_classic::diag::setprecision(5) << 3.14159265 << dendl; - dw() << stk_classic::diag::setiosflags(std::ios::fixed) << 3.14159265 << dendl; - dw() << stk_classic::diag::resetiosflags(std::ios::fixed) << 3.14159265 << dendl; - dw() << stk_classic::diag::setfill('#') << stk_classic::diag::setw(10) << "x" << dendl; - STKUNIT_ASSERT_EQUAL((std::string("10\n20\n16\n3.141593\n3.141593e+00\n10\n20\n16\n3.141593\n3.141593e+00\n3.141593e+00\n3.14159e+00\n3.1416\n3.14159e+00\n#########x\n") == oss().str()), true); - - oss().str(""); - { - std::vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - - std::vector vl; - for (int i = 0; i < 20; ++i) - vl.push_back(i); - - std::vector vp; - vp.push_back(new int(1)); - vp.push_back(new int(2)); - vp.push_back(new int(3)); - vp.push_back(0); - - std::list l; - l.push_back(1); - l.push_back(2); - l.push_back(3); - - std::list lp; - lp.push_back(new int(1)); - lp.push_back(new int(2)); - lp.push_back(new int(3)); - - std::map m; - m[1] = 2; - m[2] = 3; - m[3] = 4; - - std::map mp; - mp[1] = new int(2); - mp[2] = new int(3); - mp[3] = new int(4); - - std::multimap mm; - mm.insert(std::multimap::value_type(1, 2)); - mm.insert(std::multimap::value_type(1, 3)); - mm.insert(std::multimap::value_type(2, 4)); - - std::multimap mmp; - mmp.insert(std::multimap::value_type(1, new int(2))); - mmp.insert(std::multimap::value_type(1, new int(3))); - mmp.insert(std::multimap::value_type(2, new int(4))); - - std::set s; - s.insert(2); - s.insert(3); - s.insert(4); - - std::set sp; - sp.insert(new int(2)); - sp.insert(new int(3)); - sp.insert(new int(4)); - - std::multiset ms; - ms.insert(2); - ms.insert(2); - ms.insert(4); - - std::multiset msp; - msp.insert(new int(2)); - msp.insert(new int(3)); - msp.insert(new int(4)); - - std::bitset<8> b; - b[1] = 1; - b[3] = 1; - - dw() << typeid(int) << dendl; - dw() << std::pair(5, 7) << dendl; - dw() << v << dendl; - dw() << vl << dendl; - dw() << vp << dendl; - dw() << l << dendl; - dw() << lp << dendl; - dw() << m << dendl; - dw() << mp << dendl; - dw() << mm << dendl; - dw() << mmp << dendl; - dw() << s << dendl; - dw() << sp << dendl; - dw() << ms << dendl; - dw() << msp << dendl; - dw() << b << dendl; - - for(std::vector::iterator it=vp.begin(); it!=vp.end(); ++it) - delete *it; - - for ( std::multimap::iterator curmmp = mmp.begin() ; curmmp != mmp.end() ; curmmp++ ) - delete curmmp->second; - for ( std::map::iterator curmp = mp.begin() ; curmp != mp.end() ; curmp++ ) - delete curmp->second; - for ( std::list::iterator curp = lp.begin() ; curp != lp.end() ; curp++ ) - delete *curp; - for ( std::set::iterator cursp = sp.begin() ; cursp != sp.end() ; cursp++ ) - delete *cursp; - for ( std::multiset::iterator curmsp = msp.begin() ; curmsp != msp.end() ; curmsp++ ) - delete *curmsp; - - } -// STKUNIT_ASSERT_EQUAL(std::string("int\n(5:7)\nstd::vector >, size 3 {\n 1 2 3 \n}\nstd::vector >, size 3 {\n [0] (pointer 0x53b040), 1\n [1] (pointer 0x53b770), 2\n [2] (pointer 0x53b750), 3\n}\nstd::list >, size 3 {\n [0] 1\n [1] 2\n [2] 3\n}\nstd::list >, size 3 {\n [0] (pointer 0x53b820), 1\n [1] (pointer 0x53b8a0), 2\n [2] (pointer 0x53b8e0), 3\n}\nstd::map, std::allocator > >, size 3 {\n [1] 2\n [2] 3\n [3] 4\n}\nstd::map, std::allocator > >, size 3 {\n [1] 0x53b9f0\n [2] 0x53ba50\n [3] 0x53bab0\n}\nstd::multimap, std::allocator > >, size 3 {\n [1] 2\n [1] 3\n [2] 4\n}\nstd::multimap, std::allocator > >, size 3 {\n [1] 0x53bb60\n [1] 0x53bbc0\n [2] 0x53bc20\n}\nstd::set, std::allocator >, size 3 {\n 2\n 3\n 4\n}\nstd::set, std::allocator >, size 3 {\n 0x53bd10\n 0x53bd60\n 0x53bdb0\n}\nstd::multiset, std::allocator >, size 3 {\n 2\n 2\n 4\n}\nstd::multiset, std::allocator >, size 3 {\n 0x53be90\n 0x53bee0\n 0x53bf30\n}\n00001010\n"), oss().str()); - - oss().str(""); - { - std::auto_ptr a0(new int(1)); - std::auto_ptr a1; - dw() << a0 << dendl; - dw() << a1 << dendl; - a1 = a0; - dw() << a0 << dendl; - dw() << a1 << dendl; - } -// STKUNIT_ASSERT_EQUAL(std::string("std::auto_ptr, 0x53b8c0, 1\n std::auto_ptr, \n std::auto_ptr, \n std::auto_ptr, 0x53b8c0, 1\n"), oss().str()); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestCPUTime.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestCPUTime.cpp deleted file mode 100644 index c7746bed3ce1..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestCPUTime.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestCPUTime, testUnit) -{ - std::ostringstream oss; - - double cpu_now = stk_classic::cpu_time(); - - double x = 0.0; - for (int i = 0; i < 10000; ++i) - x += 1.0; - - // This makes sure that the loop isn't optimized away (hopefully) - if (x > 100000.0) - oss << x << std::endl; - - double cpu_delta = stk_classic::cpu_time() - cpu_now; - - STKUNIT_ASSERT(cpu_delta >= 0.0 && cpu_delta <= 1.0); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestDemangle.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestDemangle.cpp deleted file mode 100644 index b9a9390f034f..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestDemangle.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010, 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -bool -utest_demangle() -{ - return true; -} - -STKUNIT_UNIT_TEST(UnitTestDemangle, UnitTest) -{ -#if defined(__PGI) - { - std::string linux_name("ThisIsJunk"); - std::string demangled_name = stk_classic::demangle(linux_name.c_str()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - std::string linux_name("bool ()"); - std::string demangled_name = stk_classic::demangle(typeid(utest_demangle).name()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - typedef std::vector DoubleVector; - - DoubleVector double_vector; - - std::string linux_name("std::vector>"); - std::string demangled_name = stk_classic::demangle(typeid(double_vector).name()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - -#elif defined(__sun) - { - std::string linux_name("ThisIsJunk"); - std::string demangled_name = stk_classic::demangle(linux_name.c_str()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - std::string linux_name("bool()"); - std::string demangled_name = stk_classic::demangle(typeid(utest_demangle).name()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - typedef std::vector DoubleVector; - - DoubleVector double_vector; - - std::string linux_name("std::vector>"); - std::string demangled_name = stk_classic::demangle(typeid(double_vector).name()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - -#elif defined(__xlC__) - { - std::string linux_name("ThisIsJunk"); - std::string demangled_name = stk_classic::demangle(linux_name.c_str()); -// STKUNIT_ASSERT_EQUAL((linux_name == demangled_name), true); - } - - { - std::string linux_name("bool ()()"); - std::string demangled_name = stk_classic::demangle(typeid(utest_demangle).name()); -// STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - typedef std::vector DoubleVector; - - DoubleVector double_vector; - - std::string linux_name("std::vector >"); - std::string demangled_name = stk_classic::demangle(typeid(double_vector).name()); -// STKUNIT_ASSERT_EQUAL((linux_name == demangled_name), true); - } -#elif defined(__linux__) - { - std::string linux_name("ThisIsJunk"); - std::string demangled_name = stk_classic::demangle(linux_name.c_str()); - STKUNIT_ASSERT_EQUAL((linux_name == demangled_name), true); - } - - { -// std::string linux_name("bool ()()"); - std::string linux_name("bool ()"); - std::string demangled_name = stk_classic::demangle(typeid(utest_demangle).name()); - STKUNIT_ASSERT_EQUAL(linux_name, demangled_name); - } - - { - typedef std::vector DoubleVector; - - DoubleVector double_vector; - -#ifdef _GLIBCXX_DEBUG - std::string linux_name("__gnu_debug_def::vector >"); -#else - std::string linux_name("std::vector >"); -#endif - std::string demangled_name = stk_classic::demangle(typeid(double_vector).name()); - STKUNIT_ASSERT_EQUAL((linux_name == demangled_name), true); - } -#endif -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestLogControl.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestLogControl.cpp deleted file mode 100644 index 98f3c23e409e..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestLogControl.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include -#include -#include - -#include - -namespace { - -std::ostringstream os; - -} // namespace - -STKUNIT_UNIT_TEST(UnitTestLogControl, UnitTest) -{ - stk_classic::RuleMap rule_map; - - rule_map.addLogControlRule("system", stk_classic::LogControlRuleInterval(2)); -// rule_map.addLogControlRule("transient", stk_classic::LogControlRuleInterval(3)); - rule_map.addLogControlRule("nonlinear", stk_classic::LogControlRuleInterval(5)); - - int work_count = 0; - - stk_classic::LogControl log_control_i(os, *rule_map.getLogControlRule("system")); - for (int i = 0; i < 10; ++i) { - log_control_i.next(); - - os << "Running system " << i << std::endl; - - stk_classic::LogControl log_control_j(os, stk_classic::LogControlRuleInterval(3)); - for (int j = 0; j < 10; ++j) { - log_control_j.next(); - - os << " Running transient " << j << std::endl; - - stk_classic::LogControl log_control_k(os, *rule_map.getLogControlRule("nonlinear")); - for (int k = 0; k < 10; ++k) { - log_control_k.next(); - - os << " Running nonlinear " << k << std::endl; - - os << " Work count " << work_count << std::endl; - - ++work_count; - } - } - } - - std::string result = - "Running system 0\n" - " Running transient 0\n" - " Running nonlinear 0\n" - " Work count 0\n" - " Running nonlinear 5\n" - " Work count 5\n" - " Running nonlinear 9\n" - " Work count 9\n" - " Running transient 3\n" - " Running nonlinear 0\n" - " Work count 30\n" - " Running nonlinear 5\n" - " Work count 35\n" - " Running nonlinear 9\n" - " Work count 39\n" - " Running transient 6\n" - " Running nonlinear 0\n" - " Work count 60\n" - " Running nonlinear 5\n" - " Work count 65\n" - " Running nonlinear 9\n" - " Work count 69\n" - " Running transient 9\n" - " Running nonlinear 0\n" - " Work count 90\n" - " Running nonlinear 5\n" - " Work count 95\n" - " Running nonlinear 9\n" - " Work count 99\n" - "Running system 2\n" - " Running transient 0\n" - " Running nonlinear 0\n" - " Work count 200\n" - " Running nonlinear 5\n" - " Work count 205\n" - " Running nonlinear 9\n" - " Work count 209\n" - " Running transient 3\n" - " Running nonlinear 0\n" - " Work count 230\n" - " Running nonlinear 5\n" - " Work count 235\n" - " Running nonlinear 9\n" - " Work count 239\n" - " Running transient 6\n" - " Running nonlinear 0\n" - " Work count 260\n" - " Running nonlinear 5\n" - " Work count 265\n" - " Running nonlinear 9\n" - " Work count 269\n" - " Running transient 9\n" - " Running nonlinear 0\n" - " Work count 290\n" - " Running nonlinear 5\n" - " Work count 295\n" - " Running nonlinear 9\n" - " Work count 299\n" - "Running system 4\n" - " Running transient 0\n" - " Running nonlinear 0\n" - " Work count 400\n" - " Running nonlinear 5\n" - " Work count 405\n" - " Running nonlinear 9\n" - " Work count 409\n" - " Running transient 3\n" - " Running nonlinear 0\n" - " Work count 430\n" - " Running nonlinear 5\n" - " Work count 435\n" - " Running nonlinear 9\n" - " Work count 439\n" - " Running transient 6\n" - " Running nonlinear 0\n" - " Work count 460\n" - " Running nonlinear 5\n" - " Work count 465\n" - " Running nonlinear 9\n" - " Work count 469\n" - " Running transient 9\n" - " Running nonlinear 0\n" - " Work count 490\n" - " Running nonlinear 5\n" - " Work count 495\n" - " Running nonlinear 9\n" - " Work count 499\n" - "Running system 6\n" - " Running transient 0\n" - " Running nonlinear 0\n" - " Work count 600\n" - " Running nonlinear 5\n" - " Work count 605\n" - " Running nonlinear 9\n" - " Work count 609\n" - " Running transient 3\n" - " Running nonlinear 0\n" - " Work count 630\n" - " Running nonlinear 5\n" - " Work count 635\n" - " Running nonlinear 9\n" - " Work count 639\n" - " Running transient 6\n" - " Running nonlinear 0\n" - " Work count 660\n" - " Running nonlinear 5\n" - " Work count 665\n" - " Running nonlinear 9\n" - " Work count 669\n" - " Running transient 9\n" - " Running nonlinear 0\n" - " Work count 690\n" - " Running nonlinear 5\n" - " Work count 695\n" - " Running nonlinear 9\n" - " Work count 699\n" - "Running system 8\n" - " Running transient 0\n" - " Running nonlinear 0\n" - " Work count 800\n" - " Running nonlinear 5\n" - " Work count 805\n" - " Running nonlinear 9\n" - " Work count 809\n" - " Running transient 3\n" - " Running nonlinear 0\n" - " Work count 830\n" - " Running nonlinear 5\n" - " Work count 835\n" - " Running nonlinear 9\n" - " Work count 839\n" - " Running transient 6\n" - " Running nonlinear 0\n" - " Work count 860\n" - " Running nonlinear 5\n" - " Work count 865\n" - " Running nonlinear 9\n" - " Work count 869\n" - " Running transient 9\n" - " Running nonlinear 0\n" - " Work count 890\n" - " Running nonlinear 5\n" - " Work count 895\n" - " Running nonlinear 9\n" - " Work count 899\n"; - - STKUNIT_ASSERT_EQUAL((result == os.str()), true); -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestOutputLog.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestOutputLog.cpp deleted file mode 100644 index eb5924b60d08..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestOutputLog.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestOutputLog, UnitTest) -{ - // UseCaseEnvironment registers a bunch of things automatically, some of - // which conflict with this test. We unregister the conflicting streams - // here. - if (stk_classic::get_log_ostream("cout") != NULL) { - stk_classic::unregister_log_ostream(*stk_classic::get_log_ostream("cout")); - } - if (stk_classic::get_log_ostream("cerr") != NULL) { - stk_classic::unregister_log_ostream(*stk_classic::get_log_ostream("cerr")); - } - if (stk_classic::get_ostream_ostream("out") != NULL) { - stk_classic::unregister_ostream(*stk_classic::get_ostream_ostream("out")); - } - if (stk_classic::get_ostream_ostream("pout") != NULL) { - stk_classic::unregister_ostream(*stk_classic::get_ostream_ostream("pout")); - } - - // Make cout and cerr available as log stream targets. - stk_classic::register_log_ostream(std::cout, "cout"); - stk_classic::register_log_ostream(std::cerr, "cerr"); - - // Test registration, binding, rebinding and unregistration - { - std::ostringstream log1; - std::ostringstream log2; - - std::ostream out(std::cout.rdbuf()); - - stk_classic::register_ostream(out, "out"); - - STKUNIT_ASSERT(stk_classic::is_registered_ostream("out")); - - stk_classic::register_log_ostream(log1, "log1"); - stk_classic::register_log_ostream(log2, "log2"); - - stk_classic::bind_output_streams("out>log1"); - - out << "stk_classic::bind_output_streams(\"out>log1\");" << std::endl; - - stk_classic::bind_output_streams("out>+log2"); - out << "stk_classic::bind_output_streams(\"out>+log2\");" << std::endl; - - stk_classic::bind_output_streams("out>-log1"); - out << "stk_classic::bind_output_streams(\"out>-log1\");" << std::endl; - - stk_classic::bind_output_streams("out>-log2"); - out << "stk_classic::bind_output_streams(\"out>-log2\");" << std::endl; - - std::ostringstream log1_result; - log1_result << "stk_classic::bind_output_streams(\"out>log1\");" << std::endl - << "stk_classic::bind_output_streams(\"out>+log2\");" << std::endl; - - std::ostringstream log2_result; - log2_result << "stk_classic::bind_output_streams(\"out>+log2\");" << std::endl - << "stk_classic::bind_output_streams(\"out>-log1\");" << std::endl; - - STKUNIT_ASSERT_EQUAL((log1_result.str() == log1.str()), true); - STKUNIT_ASSERT_EQUAL((log2_result.str() == log2.str()), true); - - stk_classic::unregister_log_ostream(log1); - stk_classic::unregister_log_ostream(log2); - stk_classic::unregister_ostream(out); - - STKUNIT_ASSERT_EQUAL(out.rdbuf(), std::cout.rdbuf()); - } - - // Test logging to a file - { - std::ostream out(std::cout.rdbuf()); - - stk_classic::register_ostream(out, "out"); - - stk_classic::bind_output_streams("log=\"logfile\" out>log"); - - STKUNIT_ASSERT_EQUAL((std::string("logfile") == stk_classic::get_log_path("log")), true); - - out << "This is a test" << std::endl; - - stk_classic::bind_output_streams("log=\"\""); - - stk_classic::unregister_ostream(out); - - std::ostringstream log_result; - log_result << "This is a test"; - - std::ifstream log_stream("logfile"); - std::string log_string; - getline(log_stream, log_string); - STKUNIT_ASSERT_EQUAL((log_result.str() == log_string), true); - } - - // Test results of unregistration of an output stream bound as a log stream - { - std::ostringstream default_log; - std::ostream out(default_log.rdbuf()); - std::ostream pout(std::cout.rdbuf()); - - stk_classic::register_ostream(out, "out"); - stk_classic::register_ostream(pout, "pout"); - - // Constructing the log streams after the registered output stream is not exception safe. - std::ostringstream log; - stk_classic::register_log_ostream(log, "log"); - - // As a result, this try catch block must be represent to ensure the that unregistration - // happens correctly. - try { - stk_classic::bind_output_streams("out>pout pout>log"); - - out << "This is to out" << std::endl; - pout << "This is to pout" << std::endl; - - std::ostringstream log_result; - log_result << "This is to out" << std::endl - << "This is to pout" << std::endl; - - STKUNIT_ASSERT_EQUAL((log_result.str() == log.str()), true); - - throw std::exception(); - } - catch (...) { - } - - stk_classic::unregister_log_ostream(log); - stk_classic::unregister_ostream(pout); - stk_classic::unregister_ostream(out); - - out << "This is to out" << std::endl; - - std::ostringstream log_result; - log_result << "This is to out" << std::endl; - STKUNIT_ASSERT_EQUAL((log_result.str() == default_log.str()), true); - } - - // Test exception of registration with existing name - { - std::ostringstream log1; - std::ostringstream log2; - - std::ostream out(std::cout.rdbuf()); - std::ostream pout(std::cout.rdbuf()); - - stk_classic::register_ostream(out, "out"); - STKUNIT_ASSERT_THROW(stk_classic::register_ostream(pout, "out"), std::runtime_error); - - STKUNIT_ASSERT_EQUAL(&out, stk_classic::get_ostream_ostream("out")); - - stk_classic::register_log_ostream(log1, "log"); - - STKUNIT_ASSERT_THROW(stk_classic::bind_output_streams("badout>log"), std::runtime_error); - - STKUNIT_ASSERT_THROW(stk_classic::bind_output_streams("out>badlog"), std::runtime_error); - - stk_classic::unregister_log_ostream(log1); - stk_classic::unregister_ostream(out); - } -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestReportHandler.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestReportHandler.cpp deleted file mode 100644 index 563d21f0cbc8..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestReportHandler.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -namespace { - -std::ostringstream & -test_ostringstream() -{ - static std::ostringstream s_testStringStream; - - return s_testStringStream; -} - - -std::ostream & -test_stream() -{ - return test_ostringstream(); -} - - -void -test_report_handler( - const char * message, - int type) -{ - test_stream() << "Message type " << type << ": " << message << std::endl; -} - -} // namespace - -STKUNIT_UNIT_TEST(UnitTestReportHandler, UnitTest) -{ - // Set and restore report handler. - stk_classic::report("This is a test", 0); - - stk_classic::REH original_reh = stk_classic::set_report_handler(test_report_handler); - - stk_classic::report("This is a test", 0); - - stk_classic::set_report_handler(original_reh); - - STKUNIT_ASSERT_THROW(stk_classic::set_report_handler(0), std::runtime_error); - - STKUNIT_ASSERT_EQUAL((std::string("Message type 0: This is a test\n") == test_ostringstream().str()), true); - STKUNIT_ASSERT_EQUAL((std::string("Test.cpp") == stk_classic::source_relative_path("/src/Test.cpp")), true); - STKUNIT_ASSERT_EQUAL((std::string("Test.hpp") == stk_classic::source_relative_path("/include/Test.hpp")), true); - STKUNIT_ASSERT_EQUAL((std::string("Apps_Test.cpp") == stk_classic::source_relative_path("/Apps_Test.cpp")), true); - STKUNIT_ASSERT_EQUAL((std::string("stk_Test.cpp") == stk_classic::source_relative_path("/stk_Test.cpp")), true); - STKUNIT_ASSERT_EQUAL((std::string("/smile/Test.cpp") == stk_classic::source_relative_path("/smile/Test.cpp")), true); -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestThrowMacros.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestThrowMacros.cpp deleted file mode 100644 index 2ab2250898e6..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestThrowMacros.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include -#include - -#include - -namespace { - -bool test_assert_handler_called = false; -bool test_error_handler_called = false; -bool test_invarg_handler_called = false; - -void -test_assert_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - test_assert_handler_called = true; -} - -void -test_error_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - test_error_handler_called = true; -} - -void -test_invarg_handler(const char* expr, - const std::string& location, - std::ostringstream& message) -{ - test_invarg_handler_called = true; -} - -void force_throw_require_trigger(bool msg = true) -{ - if (msg) { - ThrowRequireMsg(false, "Will always fail, this is for testing"); - } - else { - ThrowRequire(false); - } -} - -void force_throw_error_trigger(bool msg = true) -{ - if (msg) { - ThrowErrorMsgIf(true, "Will always fail, this is for testing"); - } - else { - ThrowErrorIf(true); - } -} - -void force_throw_invarg_trigger(bool msg = true) -{ - if (msg) { - ThrowInvalidArgMsgIf(true, "Will always fail, this is for testing"); - } - else { - ThrowInvalidArgIf(true); - } -} - -void check_interaction_with_if(bool msg = true) -{ - if (msg) { - if (true) - ThrowRequireMsg(false, "Will always fail, this is for testing"); - } - else { - if (true) - ThrowRequire(false); - } -} - -void force_throw_assert() -{ - ThrowAssert(false); -} - -void test_no_expr_error() -{ - ThrowErrorMsg("message"); -} - -} // namespace - -STKUNIT_UNIT_TEST(UnitTestingOfThrowMacros, testUnit) -{ - // Setting assert handler to NULL should cause exception - STKUNIT_ASSERT_THROW(stk_classic::set_assert_handler(0), std::runtime_error); - - // Check that Throw*Msg works - STKUNIT_ASSERT_THROW(force_throw_require_trigger(), std::logic_error); - STKUNIT_ASSERT_THROW(force_throw_error_trigger(), std::runtime_error); - STKUNIT_ASSERT_THROW(force_throw_invarg_trigger(), std::invalid_argument); - - // Check that Throw* works - STKUNIT_ASSERT_THROW(force_throw_require_trigger(false), std::logic_error); - STKUNIT_ASSERT_THROW(force_throw_error_trigger(false), std::runtime_error); - STKUNIT_ASSERT_THROW(force_throw_invarg_trigger(false), std::invalid_argument); - - // Check that macro interacts appropriately with if statements - STKUNIT_ASSERT_THROW(check_interaction_with_if(), std::logic_error); - STKUNIT_ASSERT_THROW(check_interaction_with_if(false), std::logic_error); - - // Check that usage of ThrowRequireMsg/ThrowAssertMsg does not change program - // semantics. Code blocks that are not contained within braces seem to be - // the most likely to be problematic. - - bool expected_execution_path = false; - if (false) - ThrowRequireMsg(false, "test"); - else - expected_execution_path = true; - STKUNIT_ASSERT(expected_execution_path); - - expected_execution_path = false; - if (false) - ThrowAssertMsg(false, "test"); - else - expected_execution_path = true; - STKUNIT_ASSERT(expected_execution_path); - - expected_execution_path = false; - if (false) - ThrowErrorMsg("test"); - else - expected_execution_path = true; - STKUNIT_ASSERT(expected_execution_path); - - // These next four statements are to check compilation success - - if (false) - ThrowRequireMsg(false, "test"); - - if (false) - ThrowAssertMsg(false, "test"); - - if (false) - ThrowRequire(false); - - if (false) - ThrowAssert(false); - - // Check that do-while still works, again, we are mostly checking compilation - // success here. - - do ThrowRequireMsg(true, "test"); - while (false); - - do ThrowAssertMsg(true, "test"); - while (false); - - // Check that message with put-tos compiles - - int temp = 0; - ThrowRequireMsg(true, "test: " << temp << " blah"); - ThrowAssertMsg(true, "test: " << temp << " blah"); - - // Check that assert behaves as expected (throws in debug, not in opt) -#ifdef NDEBUG - force_throw_assert(); -#else - STKUNIT_ASSERT_THROW(force_throw_assert(), std::logic_error); -#endif - - // Check that ThrowErrorMsg works - - STKUNIT_ASSERT_THROW(test_no_expr_error(), std::runtime_error); - - // Check that setting handler for asserts works. - - stk_classic::ErrorHandler orig = stk_classic::set_assert_handler(test_assert_handler); - - ThrowRequireMsg(false, "test"); - - STKUNIT_ASSERT(test_assert_handler_called); - - stk_classic::set_assert_handler(orig); - - STKUNIT_ASSERT_THROW(force_throw_require_trigger(), std::logic_error); - - // Check that setting handler for errors works. - - orig = stk_classic::set_error_handler(test_error_handler); - - ThrowErrorMsgIf(true, "test"); - - STKUNIT_ASSERT(test_error_handler_called); - - stk_classic::set_error_handler(orig); - - STKUNIT_ASSERT_THROW(force_throw_error_trigger(), std::runtime_error); - - // Check that setting handler for invalid args works. - - orig = stk_classic::set_invalid_arg_handler(test_invarg_handler); - - ThrowInvalidArgMsgIf(true, "test"); - - STKUNIT_ASSERT(test_invarg_handler_called); - - stk_classic::set_invalid_arg_handler(orig); - - STKUNIT_ASSERT_THROW(force_throw_invarg_trigger(), std::invalid_argument); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestWallTime.cpp b/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestWallTime.cpp deleted file mode 100644 index 317f742f2a03..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/environment/UnitTestWallTime.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestWallTime, UnitTest) -{ - double wall_now = stk_classic::wall_time(); - - ::sleep(1); - - double wall_delta = stk_classic::wall_time() - wall_now; - - STKUNIT_ASSERT(wall_delta >= 1.0 && wall_delta <= 2.0); - - double wall_delta2 = stk_classic::wall_dtime(wall_now); - - STKUNIT_ASSERT(wall_delta2 >= 1.0 && wall_delta2 <= 2.0); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/parallel/CMakeLists.txt b/packages/stk/stk_classic/stk_util/unit_tests/parallel/CMakeLists.txt deleted file mode 100644 index 7f227f2c424b..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/parallel/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - - -ASSERT_DEFINED(PACKAGE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR) - -FILE(GLOB SOURCES *.cpp) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - util_parallel_UnitTest - SOURCES ${SOURCES} - COMM serial mpi - NUM_MPI_PROCS 1-6 - STANDARD_PASS_OUTPUT - ) diff --git a/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestDistributedIndex.cpp b/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestDistributedIndex.cpp deleted file mode 100644 index 8febc6ebbf65..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestDistributedIndex.cpp +++ /dev/null @@ -1,618 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include - -#include -#include - -#include - -class UnitTestSTKParallelDistributedIndex { - public: - static void test_ctor(); - static void test_ctor_bad(); - static void test_update(); - static void test_update_bad(); - static void test_generate(); - static void test_generate_bad(); - static void test_generate_big(); - static void test_update_generate(); -}; - -namespace { - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexConstructor , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_ctor(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexConstructorBad , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_ctor_bad(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexUpdate , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_update(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexUpdateBad , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_update_bad(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexGenerate , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_generate(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexGenerateBad , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_generate_bad(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexUpdateGenerate , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_update_generate(); } - -STKUNIT_UNIT_TEST( UnitTestDistributedIndexGenerateBig , testUnit ) -{ UnitTestSTKParallelDistributedIndex::test_generate_big(); } - -// Generate spans: -// [ 1..10000] -// [20001..30000] -// [40001..50000] -// [60001..70000] -// [80001..90000] -// etc. -void generate_test_spans_10x10000( - std::vector< stk_classic::parallel::DistributedIndex::KeySpan > & partition_spans ) -{ - enum { test_spans_count = 10 }; - enum { test_spans_size = 10000 }; - - partition_spans.resize( test_spans_count ); - - for ( unsigned i = 0 ; i < test_spans_count ; ++i ) { - partition_spans[i].first = 1 + test_spans_size * i * 2 ; - partition_spans[i].second = test_spans_size * ( i * 2 + 1 ); - } -} - -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_ctor() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int mpi_rank = stk_classic::parallel_machine_rank(comm); - int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - STKUNIT_EXPECT_EQ( di.m_comm_rank , mpi_rank ); - STKUNIT_EXPECT_EQ( di.m_comm_size , mpi_size ); - STKUNIT_EXPECT_TRUE( di.m_key_usage.empty() ); - STKUNIT_ASSERT_EQ( di.m_key_span.size() , partition_spans.size() ); - for ( size_t i = 0 ; i < di.m_key_span.size() ; ++i ) { - STKUNIT_EXPECT_EQ( di.m_key_span[i].first , partition_spans[i].first ); - STKUNIT_EXPECT_EQ( di.m_key_span[i].second , partition_spans[i].second ); - } - - // All queries will be empty: - - std::vector keys_to_query ; - std::vector sharing_of_local_keys ; - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_TRUE( sharing_of_local_keys.empty() ); - - di.query( keys_to_query , sharing_of_local_keys ); - - STKUNIT_EXPECT_TRUE( sharing_of_local_keys.empty() ); - - keys_to_query.push_back( 10 ); - - di.query( keys_to_query , sharing_of_local_keys ); - - STKUNIT_EXPECT_TRUE( sharing_of_local_keys.empty() ); -} - -void UnitTestSTKParallelDistributedIndex::test_ctor_bad() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - { - // Throw for overlapping span - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - // Corrupt this span to trigger an error - partition_spans[5].first = partition_spans[4].second ; - - STKUNIT_ASSERT_THROW( PDIndex di( comm , partition_spans ) , std::runtime_error ); - } - - { - // Throw for one bad span - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - // Corrupt this span to trigger an error - std::swap( partition_spans[5].first , partition_spans[5].second ); - - STKUNIT_ASSERT_THROW( PDIndex( comm , partition_spans ) , std::runtime_error ); - } -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_update() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int mpi_rank = stk_classic::parallel_machine_rank(comm); - int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector keys_to_add ; - std::vector keys_to_remove ; - std::vector sharing_of_local_keys ; - - //------------------------------ - // Update nothing: - - di.update_keys( keys_to_add , keys_to_remove ); - - STKUNIT_EXPECT_TRUE( di.m_key_usage.empty() ); - - //------------------------------ - // Update one key on all processes and - // one key unique to each process. - - keys_to_add.push_back( partition_spans[0].first + 1 ); - keys_to_add.push_back( partition_spans[1].first + 2 + mpi_rank ); - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - // First key shared by all processes - // Second key shared just by this process - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(mpi_size + 1) ); - - di.query( keys_to_add , sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(mpi_size + 1) ); - - //------------------------------ - // Repeat the update, should result in no changes. - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - // First key shared by all processes - // Second key shared just by this process - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(mpi_size + 1) ); - - //------------------------------ - - keys_to_remove.clear(); - keys_to_add.clear(); - - keys_to_remove.push_back( partition_spans[0].second ); - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(mpi_size + 1) ); - - //------------------------------ - // Remove shared key - - keys_to_remove.clear(); - keys_to_add.clear(); - - keys_to_remove.push_back( partition_spans[0].first + 1 ); - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(1) ); - - //------------------------------ - // Add two shared-by-all - - keys_to_remove.clear(); - keys_to_add.clear(); - - keys_to_add.push_back( partition_spans[0].first + 1 ); - keys_to_add.push_back( partition_spans[0].first + 2 ); - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(2*mpi_size + 1) ); - - di.query( keys_to_add , sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , size_t(2*mpi_size) ); - - //------------------------------ - - keys_to_remove.clear(); - keys_to_add.clear(); - - // Shared by even rank processes: - if ( 0 == mpi_rank % 2 ) { - keys_to_add.push_back( partition_spans[2].first ); - } - - di.update_keys( keys_to_add , keys_to_remove ); - - di.query( sharing_of_local_keys ); - - { - size_t expected = 2 * mpi_size + 1 ; - if ( 0 == mpi_rank % 2 ) { expected += ( mpi_size + 1 ) / 2 ; } - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , expected ); - } - -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_update_bad() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int mpi_rank = stk_classic::parallel_machine_rank(comm); - int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector keys_to_add ; - std::vector keys_to_remove ; - std::vector sharing_of_local_keys ; - - //------------------------------ - // Invalid key on every process - - keys_to_add.push_back( partition_spans[0].second + 1 + mpi_rank ); - - STKUNIT_ASSERT_THROW( di.update_keys( keys_to_add , keys_to_remove ) , std::runtime_error ); - - //------------------------------ - - keys_to_add.clear(); - if ( mpi_size == mpi_rank + 1 ) { - keys_to_add.push_back( partition_spans[0].second + 1 ); - } - - STKUNIT_ASSERT_THROW( di.update_keys( keys_to_add , keys_to_remove ) , std::runtime_error ); -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_generate() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int mpi_rank = stk_classic::parallel_machine_rank(comm); - // int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector requests( partition_spans.size() , size_t(0) ); - std::vector< std::vector > generated_keys ; - std::vector sharing_of_local_keys ; - - di.generate_new_keys( requests , generated_keys ); - - STKUNIT_EXPECT_TRUE( di.m_key_usage.empty() ); - - STKUNIT_ASSERT_EQ( generated_keys.size() , partition_spans.size() ); - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - STKUNIT_EXPECT_TRUE( generated_keys[i].empty() ); - } - - //---------------------------------------- - - size_t total = 0 ; - for ( size_t i = 0 ; i < requests.size() ; ++i ) { - requests[i] = i + mpi_rank ; - total += requests[i] ; - } - - di.generate_new_keys( requests , generated_keys ); - - STKUNIT_ASSERT_EQ( generated_keys.size() , partition_spans.size() ); - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - STKUNIT_EXPECT_EQ( generated_keys[i].size() , requests[i] ); - for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { - STKUNIT_EXPECT_TRUE( partition_spans[i].first <= generated_keys[i][j] ); - STKUNIT_EXPECT_TRUE( generated_keys[i][j] <= partition_spans[i].second ); - if ( 0 < j ) { - STKUNIT_EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); - } - } - } - - //---------------------------------------- - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , total ); - - // Confirm global uniqueness - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - di.query( generated_keys[i] , sharing_of_local_keys ); - STKUNIT_EXPECT_EQ( generated_keys[i].size() , sharing_of_local_keys.size() ); - for ( size_t j = 0 ; j < sharing_of_local_keys.size() ; ++j ) { - STKUNIT_EXPECT_EQ( sharing_of_local_keys[j].second , mpi_rank ); - } - } - - //---------------------------------------- - // Double the number of keys - - di.generate_new_keys( requests , generated_keys ); - - STKUNIT_ASSERT_EQ( generated_keys.size() , partition_spans.size() ); - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - STKUNIT_EXPECT_EQ( generated_keys[i].size() , requests[i] ); - for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { - STKUNIT_EXPECT_TRUE( partition_spans[i].first <= generated_keys[i][j] ); - STKUNIT_EXPECT_TRUE( generated_keys[i][j] <= partition_spans[i].second ); - if ( 0 < j ) { - STKUNIT_EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); - } - } - } - - di.query( sharing_of_local_keys ); - - STKUNIT_EXPECT_EQ( sharing_of_local_keys.size() , total * 2 ); -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_update_generate() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int p_rank = stk_classic::parallel_machine_rank(comm); - int p_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector requests( partition_spans.size() , size_t(0) ); - std::vector< std::vector > generated_keys ; - std::vector sharing_of_local_keys ; - - std::vector keys_to_add ; - std::vector keys_to_remove ; - - //------------------------------ - // Add ( 5 * j ) odd keys per process - // starting at the beginning of the partition. - - const size_t old_size_multiplier = 5 ; - - for ( size_t j = 0 ; j < partition_spans.size() ; ++j ) { - PDIndex::KeyType key_first = partition_spans[j].first ; - if ( 0 == key_first % 2 ) { ++key_first ; } // Make it odd - key_first += old_size_multiplier * p_rank ; - - const size_t n = old_size_multiplier * j ; - for ( size_t i = 0 ; i < n ; ++i ) { - PDIndex::KeyType key = key_first + 2 * i ; - keys_to_add.push_back( key ); - } - } - - di.update_keys( keys_to_add , keys_to_remove ); - - //------------------------------ - // Request 20 new keys per process per span - // The maximum new key will be larger than some spans - // and within the gaps of other spans. - - const size_t gen_count = 20 ; - for ( size_t i = 0 ; i < requests.size() ; ++i ) { - if ( i % 2 ) { - requests[i] = gen_count ; - } - else { - requests[i] = 0 ; - } - } - - di.generate_new_keys( requests , generated_keys ); - - for ( size_t i = 0 ; i < requests.size() ; ++i ) { - STKUNIT_EXPECT_EQ( requests[i] , generated_keys[i].size() ); - - const size_t old_count = p_size * old_size_multiplier * i ; - const size_t tot_request = p_size * requests[i] ; - - PDIndex::KeyType max_gen_key = partition_spans[i].first ; - - if ( 0 == tot_request ) { - STKUNIT_EXPECT_TRUE( generated_keys[i].size() == 0 ); - } - else if ( tot_request < old_count ) { - // Will only fill in gaps between odd keys - max_gen_key += 2 * old_count ; - - STKUNIT_EXPECT_TRUE( max_gen_key > generated_keys[i][ requests[i] - 1 ] ); - } - else { - // Will fill in gaps contiguously after the old max key - max_gen_key += old_count + tot_request - 1 ; - - STKUNIT_EXPECT_TRUE( max_gen_key >= generated_keys[i][ requests[i] - 1 ] ); - } - - // Sorted - for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { - if ( 0 < j ) { - STKUNIT_EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); - } - } - } -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_generate_bad() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - int mpi_rank = stk_classic::parallel_machine_rank(comm); - int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector requests( partition_spans.size() , size_t(0) ); - std::vector< std::vector > generated_keys ; - //------------------------------ - - for ( size_t i = 0 ; i < requests.size() ; ++i ) { - requests[i] = 10 ; - } - - if( mpi_rank == mpi_size -1 ) { - requests.clear(); - } - - STKUNIT_ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); - - if( mpi_rank == mpi_size -1 ) { - requests.push_back(2*(partition_spans[0].second - partition_spans[0].first)); - } - - STKUNIT_ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); - - for ( size_t i = 0 ; i < requests.size() ; ++i ) { - requests[i] = partition_spans[i].second - partition_spans[i].first ; - } - - STKUNIT_ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); - -} - -//---------------------------------------------------------------------- - -void UnitTestSTKParallelDistributedIndex::test_generate_big() -{ - typedef stk_classic::parallel::DistributedIndex PDIndex ; - - stk_classic::ParallelMachine comm = MPI_COMM_WORLD ; - - const int mpi_rank = stk_classic::parallel_machine_rank(comm); - const int mpi_size = stk_classic::parallel_machine_size(comm); - - std::vector< PDIndex::KeySpan > partition_spans ; - - generate_test_spans_10x10000( partition_spans ); - - PDIndex di( comm , partition_spans ); - - std::vector requests( partition_spans.size() , size_t(0) ); - - std::vector< std::vector > generated_keys ; - - //---------------------------------------- - - if ( mpi_rank == mpi_size - 1 ) { - requests[5] = 5000 ; // Half - } - else { - requests[5] = 0 ; - } - - di.generate_new_keys( requests , generated_keys ); - - STKUNIT_ASSERT_EQ( generated_keys.size() , partition_spans.size() ); - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - STKUNIT_EXPECT_EQ( generated_keys[i].size() , requests[i] ); - } - - //---------------------------------------- - - if ( mpi_rank == mpi_size - 1 ) { - requests[5] = 4999 ; // Almost half again - } - else { - requests[5] = 0 ; - } - - di.generate_new_keys( requests , generated_keys ); - - STKUNIT_ASSERT_EQ( generated_keys.size() , partition_spans.size() ); - - for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { - STKUNIT_EXPECT_EQ( generated_keys[i].size() , requests[i] ); - } - - //---------------------------------------- - // This should request generation of one too many keys. - - if ( mpi_rank == 0 ) { - requests[5] = 2 ; // Exceed the total - } - else { - requests[5] = 0 ; - } - - STKUNIT_ASSERT_THROW( di.generate_new_keys( requests , generated_keys ) , std::runtime_error ); - -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestParallelMain.cpp b/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestParallelMain.cpp deleted file mode 100644 index 2f1d7f9af9e5..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/parallel/UnitTestParallelMain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - - -#include -#include -#include -#include - -#include - -#include - -STKUNIT_MAIN(argc,argv) diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestCSet.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestCSet.cpp deleted file mode 100644 index c8f5cf72b7ca..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestCSet.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -namespace stk_classic { -namespace cset_unit { - -class A { -public: - virtual int id() const = 0 ; - virtual ~A(){} -}; - -class B { -public: - virtual int id() const = 0 ; - virtual ~B(){} -}; - -class U : public A { -public: - int id() const - { - return (int)ID; - } - ~U() {} - enum {ID = 0}; -}; - -class V : public B { -public: - int id() const - { - return (int)ID; - } - ~V() {} - enum {ID = 1}; -}; - -class W : public B { -public: - int id() const - { - return (int)ID; - } - ~W() {} - enum {ID = 2}; -}; - -class X : public A , public B { -public: - int id() const - { - return (int)ID; - } - ~X() {} - enum {ID = 3}; -}; - -class Y : public A , public B { -public: - int id() const - { - return (int)ID; - } - ~Y() {} - enum {ID = 4}; -}; - -class Z { -public: - int id() const - { - return (int)ID; - } - ~Z() {} - enum {ID = 5}; -}; - -}//namespace cset_unit -}//namespace stk_classic - -using namespace stk_classic; -using namespace stk_classic::cset_unit; - -STKUNIT_UNIT_TEST( UnitTestCSet, UnitTest) -{ -//This unit-test imported from its previous home in the bottom of -//the CSet implementation file. - const A * sa ; - const B * sb ; - bool flag ; - - U u; - V v; - W w; - X x; - Y y; - - { - CSet cs ; - - sa = cs.insert_no_delete(&u); - STKUNIT_ASSERT(sa->id() == (int)U::ID); - - sb = cs.insert_no_delete(&v); - STKUNIT_ASSERT(sb->id() == (int)V::ID); - - // Should not replace: - sb = cs.insert_no_delete(&w); - STKUNIT_ASSERT(sb->id() == (int)V::ID); - - flag = cs.remove( &u ); - STKUNIT_ASSERT(flag); - - flag = cs.remove( &v ); - STKUNIT_ASSERT(flag); - - sa = cs.insert_no_delete(&x); - sb = cs.insert_no_delete(&x); - STKUNIT_ASSERT(sa->id() == (int)X::ID); - STKUNIT_ASSERT(sb->id() == (int)X::ID); - - sa = cs.insert_no_delete(&y); - sb = cs.insert_no_delete(&y); - STKUNIT_ASSERT(sa->id() == (int)X::ID); - STKUNIT_ASSERT(sb->id() == (int)X::ID); - } -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestFormatTime.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestFormatTime.cpp deleted file mode 100644 index 282516bac2b5..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestFormatTime.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include - -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestFormatTime, UnitTest) -{ - double time = 41.399684906; - - STKUNIT_ASSERT_EQUAL((std::string("41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS)), true); - STKUNIT_ASSERT_EQUAL((std::string("41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS)), true); - STKUNIT_ASSERT_EQUAL((std::string("41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("41.3997") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_NONE)), true); - - time = 441.399684906; - - STKUNIT_ASSERT_EQUAL((std::string("7:21") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS)), true); - STKUNIT_ASSERT_EQUAL((std::string("7:21.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("441") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS)), true); - STKUNIT_ASSERT_EQUAL((std::string("441.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("441.4") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_NONE)), true); - - time = 5441.399684906; - - STKUNIT_ASSERT_EQUAL((std::string("1:30:41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS)), true); - STKUNIT_ASSERT_EQUAL((std::string("1:30:41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("5441") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS)), true); - STKUNIT_ASSERT_EQUAL((std::string("5441.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("5441.4") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_NONE)), true); - - time = 1251305441.399684906; - - STKUNIT_ASSERT_EQUAL((std::string("347584:50:41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS)), true); - STKUNIT_ASSERT_EQUAL((std::string("347584:50:41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("1251305441") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS)), true); - STKUNIT_ASSERT_EQUAL((std::string("1251305441.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("1.25131e+09") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_NONE)), true); - - time = -41.399684906; - - STKUNIT_ASSERT_EQUAL((std::string("-41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS)), true); - STKUNIT_ASSERT_EQUAL((std::string("-41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_HMS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("-41") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS)), true); - STKUNIT_ASSERT_EQUAL((std::string("-41.400") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_SECONDS | stk_classic::TIMEFORMAT_MILLIS)), true); - STKUNIT_ASSERT_EQUAL((std::string("-41.3997") == stk_classic::formatTime(time, stk_classic::TIMEFORMAT_NONE)), true); -} - - - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIdentifier.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIdentifier.cpp deleted file mode 100644 index a66e62835cce..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIdentifier.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -STKUNIT_UNIT_TEST( UnitTestIdentifier, UnitTest) -{ - { - stk_classic::IdentifierA id1("identifier1"); - - STKUNIT_ASSERT(id1 == "identifier1"); - STKUNIT_ASSERT(id1 == "IDENTIFIER1"); - STKUNIT_ASSERT(id1 == std::string("identifier1")); - STKUNIT_ASSERT(std::string("identifier1") == id1); - STKUNIT_ASSERT(id1 < "idf"); - STKUNIT_ASSERT(id1 < "IDF"); - STKUNIT_ASSERT(id1 < std::string("idf")); - STKUNIT_ASSERT(id1 <= "idf"); - STKUNIT_ASSERT(id1 <= "IDF"); - STKUNIT_ASSERT(id1 <= std::string("idf")); - STKUNIT_ASSERT(id1 > "idd"); - STKUNIT_ASSERT(id1 > "IDD"); - STKUNIT_ASSERT(id1 > std::string("idd")); - STKUNIT_ASSERT(id1 >= "idd"); - STKUNIT_ASSERT(id1 >= "IDD"); - STKUNIT_ASSERT(id1 >= std::string("idd")); - - STKUNIT_ASSERT(id1 <= "identifier1"); - STKUNIT_ASSERT(id1 <= "IDENTIFIER1"); - STKUNIT_ASSERT(id1 <= std::string("identifier1")); - STKUNIT_ASSERT(id1 >= "identifier1"); - STKUNIT_ASSERT(id1 >= "IDENTIFIER1"); - STKUNIT_ASSERT(id1 >= std::string("identifier1")); - - stk_classic::IdentifierA id2(id1); - - STKUNIT_ASSERT(id1 == id2); - - std::cout << id1 << std::endl; - - stk_classic::IdentifierA id3 = id1 + "test1"; - STKUNIT_ASSERT(id3 == "identifier1test1"); - - id3 += "test2"; - STKUNIT_ASSERT(id3 == "identifier1test1test2"); - - id3 = "identifier3"; - STKUNIT_ASSERT(id3 == "identifier3"); - - typedef std::map IdIntMap; - - IdIntMap id_int_map; - - id_int_map[stk_classic::IdentifierA("identifier1")] = 1; - id_int_map[stk_classic::IdentifierA("IDENTIFIER1")] = 2; - - STKUNIT_ASSERT(id_int_map[stk_classic::IdentifierA("identifier1")] == 2); - } - - - { - stk_classic::IdentifierB id1("identifier1"); - - - STKUNIT_ASSERT(id1 == "identifier1"); - STKUNIT_ASSERT(id1 == "IDENTIFIER1"); - STKUNIT_ASSERT(id1 == std::string("identifier1")); - STKUNIT_ASSERT(std::string("identifier1") == id1); - STKUNIT_ASSERT(id1 < "idf"); - STKUNIT_ASSERT(id1 < "IDF"); - STKUNIT_ASSERT(id1 < std::string("idf")); - STKUNIT_ASSERT(id1 <= "idf"); - STKUNIT_ASSERT(id1 <= "IDF"); - STKUNIT_ASSERT(id1 <= std::string("idf")); - STKUNIT_ASSERT(id1 > "idd"); - STKUNIT_ASSERT(id1 > "IDD"); - STKUNIT_ASSERT(id1 > std::string("idd")); - STKUNIT_ASSERT(id1 >= "idd"); - STKUNIT_ASSERT(id1 >= "IDD"); - STKUNIT_ASSERT(id1 >= std::string("idd")); - - STKUNIT_ASSERT(id1 <= "identifier1"); - STKUNIT_ASSERT(id1 <= "IDENTIFIER1"); - STKUNIT_ASSERT(id1 <= std::string("identifier1")); - STKUNIT_ASSERT(id1 >= "identifier1"); - STKUNIT_ASSERT(id1 >= "IDENTIFIER1"); - STKUNIT_ASSERT(id1 >= std::string("identifier1")); - - stk_classic::IdentifierB id2(id1); - - STKUNIT_ASSERT(id1 == id2); - - std::cout << id1 << std::endl; - - stk_classic::IdentifierB id3 = id1 + "test1"; - STKUNIT_ASSERT(id3 == "identifier1test1"); - - id3 += "test2"; - STKUNIT_ASSERT(id3 == "identifier1test1test2"); - - id3 = "identifier3"; - STKUNIT_ASSERT(id3 == "identifier3"); - - typedef std::map IdIntMap; - - IdIntMap id_int_map; - - id_int_map[stk_classic::IdentifierB("identifier1")] = 1; - id_int_map[stk_classic::IdentifierB("IDENTIFIER1")] = 2; - - STKUNIT_ASSERT(id_int_map[stk_classic::IdentifierB("identifier1")] == 2); - } -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIndentStreambuf.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIndentStreambuf.cpp deleted file mode 100644 index b55bc3023f6c..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestIndentStreambuf.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -using stk_classic::push; -using stk_classic::pop; - -namespace { - -void plain(std::ostream &os) -{ - os << "This is an ostream test" << std::endl; - os << "This is an ostream test" << stk_classic::PUSH << std::endl; - os << "This is an ostream test" << stk_classic::POP << std::endl; - os << "This is an ostream test" << std::endl; -} - -void deep(std::ostream &log_stream, int depth) -{ - if (depth < 100) { - log_stream << "now " << depth << " deep" << stk_classic::PUSH << std::endl; - deep(log_stream, depth + 1); - log_stream << stk_classic::POP << std::endl; - } -} - -} // namespace - -STKUNIT_UNIT_TEST(UnitTestIndentStreambuf, UnitTest) -{ - { - std::string result = - "--- indent_streambuf ---\n" - "indented 0 {\n" - " indented 1\n" - " indented 2 {\n" - " indented 2\n" - "no indentation\n" - " indented 1\n" - " }\n" - " This is an ostream test\n" - " This is an ostream test {\n" - " This is an ostream test\n" - " }\n" - " This is an ostream test\n" - " indented 1\n" - "}\n" - "indented 0\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf()); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << std::endl; - log_stream << "--- indent_streambuf ---" << std::endl; - - log_stream << "indented 0" << stk_classic::PUSH << std::endl; - log_stream << "indented 1" << std::endl; - log_stream << stk_classic::PUSH << "indented 2" << std::endl; - log_stream << "indented 2" << std::endl; - log_stream << stk_classic::LEFT << "no indentation" << std::endl; - log_stream << "\017indented 1" << std::endl; - - plain(log_stream); - - log_stream << "indented 1\017" << std::endl; - log_stream << "indented 0" << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "--- No braces, no blank lines ---\n" - "indented 0\n" - " indented 1\n" - " indented 2\n" - " indented 2\n" - " indented 1\n" - " This is an ostream test\n" - " This is an ostream test\n" - " This is an ostream test\n" - " This is an ostream test\n" - " indented 1\n" - "indented 0\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf(), 2, stk_classic::indent_streambuf::NO_BRACES | stk_classic::indent_streambuf::NO_BLANK_LINES); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "--- No braces, no blank lines ---" << std::endl; - - log_stream << "indented 0" << stk_classic::PUSH << std::endl; - log_stream << "indented 1" << std::endl; - log_stream << stk_classic::PUSH << "indented 2" << std::endl; - log_stream << "indented 2" << std::endl; - log_stream << "\017indented 1" << std::endl; - - plain(log_stream); - - log_stream << "indented 1\017" << std::endl; - log_stream << "indented 0" << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "--- push, pop manipulators ---\n" - "indented 0 {\n" - " indented 1 {\n" - " }\n" - "}\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf()); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "--- push, pop manipulators ---" << std::endl; - - log_stream << "indented 0" << push << std::endl; - log_stream << "indented 1" << push << std::endl; - log_stream << pop << std::endl; - log_stream << pop << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "--- double push, double pop, push pop, pop push ---\n" - "push push {\n" - " {\n" - " pop push\n" - " }\n" - " {\n" - " pop pop\n" - " }\n" - "}\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf()); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "--- double push, double pop, push pop, pop push ---" << std::endl; - - log_stream << "push push" << push << push << std::endl; - log_stream << "pop push" << pop << push << std::endl; - log_stream << "pop pop" << pop << pop << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "--- No braces, blank lines ---\n" - "indented 0\n" - "\n" - " indented 1\n" - "\n" - " indented 2\n" - "\n" - " indented 2\n" - "\n" - " indented 1\n" - "\n" - " This is an ostream test\n" - " This is an ostream test\n" - " This is an ostream test\n" - " This is an ostream test\n" - " indented 1\n" - "\n" - "indented 0\n" - "\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf(), 2, stk_classic::indent_streambuf::BLANK_LINES); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "--- No braces, blank lines ---" << std::endl; - - log_stream << "indented 0" << stk_classic::PUSH << std::endl << std::endl; - log_stream << "indented 1" << std::endl << std::endl; - log_stream << stk_classic::PUSH << "indented 2" << std::endl << std::endl; - log_stream << "indented 2" << std::endl << std::endl; - log_stream << "\017indented 1" << std::endl << std::endl; - - plain(log_stream); - - log_stream << "indented 1\017" << std::endl << std::endl; - log_stream << "indented 0" << std::endl << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "--- Braces, blank lines ---\n" - "indented 0 {\n" - "\n" - " indented 1\n" - "\n" - " indented 2 {\n" - "\n" - " indented 2\n" - "\n" - " indented 1\n" - " }\n" - "\n" - " This is an ostream test\n" - " This is an ostream test {\n" - " This is an ostream test\n" - " }\n" - " This is an ostream test\n" - " indented 1\n" - "}\n" - "\n" - "indented 0\n" - "\n"; - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf(), 2, stk_classic::indent_streambuf::BRACES | stk_classic::indent_streambuf::BLANK_LINES); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "--- Braces, blank lines ---" << std::endl; - - log_stream << "indented 0" << stk_classic::PUSH << std::endl << std::endl; - log_stream << "indented 1" << std::endl << std::endl; - log_stream << stk_classic::PUSH << "indented 2" << std::endl << std::endl; - log_stream << "indented 2" << std::endl << std::endl; - log_stream << "\017indented 1" << std::endl << std::endl; - - plain(log_stream); - - log_stream << "indented 1\017" << std::endl << std::endl; - log_stream << "indented 0" << std::endl << std::endl; - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } - - { - std::string result = - "Depth test\n" - "now 0 deep {\n" - " now 1 deep {\n" - " now 2 deep {\n" - " now 3 deep {\n" - " now 4 deep {\n" - " now 5 deep {\n" - " now 6 deep {\n" - " now 7 deep {\n" - " now 8 deep {\n" - " now 9 deep {\n" - " now 10 deep {\n" - " now 11 deep {\n" - " now 12 deep {\n" - " now 13 deep {\n" - " now 14 deep {\n" - " now 15 deep {\n" - " now 16 deep {\n" - " now 17 deep {\n" - " now 18 deep {\n" - " now 19 deep {\n" - " now 20 deep {\n" - " now 21 deep {\n" - " now 22 deep {\n" - " now 23 deep {\n" - " now 24 deep {\n" - " now 25 deep {\n" - " now 26 deep {\n" - " now 27 deep {\n" - " now 28 deep {\n" - " now 29 deep {\n" - " now 30 deep {\n" - " now 31 deep {\n" - " now 32 deep {\n" - " now 33 deep {\n" - " now 34 deep {\n" - " now 35 deep {\n" - " now 36 deep {\n" - " now 37 deep {\n" - " now 38 deep {\n" - " now 39 deep {\n" - " now 40 deep {\n" - " now 41 deep {\n" - " now 42 deep {\n" - " now 43 deep {\n" - " now 44 deep {\n" - " now 45 deep {\n" - " now 46 deep {\n" - " now 47 deep {\n" - " now 48 deep {\n" - " now 49 deep {\n" - " now 50 deep {\n" - " now 51 deep {\n" - " now 52 deep {\n" - " now 53 deep {\n" - " now 54 deep {\n" - " now 55 deep {\n" - " now 56 deep {\n" - " now 57 deep {\n" - " now 58 deep {\n" - " now 59 deep {\n" - " now 60 deep {\n" - " now 61 deep {\n" - " now 62 deep {\n" - " now 63 deep {\n" - " now 64 deep {\n" - " now 65 deep {\n" - " now 66 deep {\n" - " now 67 deep {\n" - " now 68 deep {\n" - " now 69 deep {\n" - " now 70 deep {\n" - " now 71 deep {\n" - " now 72 deep {\n" - " now 73 deep {\n" - " now 74 deep {\n" - " now 75 deep {\n" - " now 76 deep {\n" - " now 77 deep {\n" - " now 78 deep {\n" - " now 79 deep {\n" - " now 80 deep {\n" - " now 81 deep {\n" - " now 82 deep {\n" - " now 83 deep {\n" - " now 84 deep {\n" - " now 85 deep {\n" - " now 86 deep {\n" - " now 87 deep {\n" - " now 88 deep {\n" - " now 89 deep {\n" - " now 90 deep {\n" - " now 91 deep {\n" - " now 92 deep {\n" - " now 93 deep {\n" - " now 94 deep {\n" - " now 95 deep {\n" - " now 96 deep {\n" - " now 97 deep {\n" - " now 98 deep {\n" - " now 99 deep {\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - "}\n"; - - - std::ostringstream dest; - stk_classic::indent_streambuf dest_indent_streambuf(dest.rdbuf()); - std::ostream log_stream(&dest_indent_streambuf); - - log_stream << "Depth test" << std::endl; - deep(log_stream, 0); - - STKUNIT_ASSERT_EQUAL((result == dest.str()), true); - } -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestMallocUsed.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestMallocUsed.cpp deleted file mode 100644 index 264cc9bb4366..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestMallocUsed.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2011 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include - -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_8) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 8; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_16) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 16; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_32) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 32; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_1024) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 1024; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_100x1024) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 1024; - - for (size_t i = 0; i != 100; ++i) { - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; - } -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_1M) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 1024*1024; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_1_100M) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 100*1024*1024; - - size_t start = malloc_used(); - - size_t used = 0; - - char *x = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - free(x); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_100_32) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 32; - - size_t start = malloc_used(); - - char *x[100]; - size_t used = 0; - - for (size_t i = 0; i < 100; ++i) - x[i] = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - for (size_t i = 0; i < 100; ++i) - free(x[i]); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate*100, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_100_1024) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 1024; - - size_t start = malloc_used(); - - char *x[100]; - size_t used = 0; - - for (size_t i = 0; i < 100; ++i) - x[i] = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - for (size_t i = 0; i < 100; ++i) - free(x[i]); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate*100, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -STKUNIT_UNIT_TEST(UnitTestMallocUsed, Malloc_100_1M) -{ -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - static const size_t bytes_to_allocate = 1024*1024; - - size_t start = malloc_used(); - - char *x[100]; - size_t used = 0; - - for (size_t i = 0; i < 100; ++i) - x[i] = (char *) malloc(bytes_to_allocate); - - used += malloc_used(); - - for (size_t i = 0; i < 100; ++i) - free(x[i]); - - size_t end = malloc_used(); - - STKUNIT_EXPECT_LE(bytes_to_allocate*100, used - start); - STKUNIT_EXPECT_LE(start, end); - std::cout << "start " << start << ", end " << end << ", used " << used - start << std::endl; -#endif -} - -#define MAXP 4000 -#define SUBP 200 -#define NPASS 25 -#define NLOOP 12 - -int lrand() -{ - static unsigned long long next = 0; - next = next * 0x5deece66dLL + 11; - return (int)((next >> 16) & 0x7fffffff); -} - -int rsize() -{ - int rv = 8 << (lrand() % 24); - rv = lrand() & (rv-1); - return rv; -} - -STKUNIT_UNIT_TEST(UnitTestMalloc, Performance) -{ - void *pointers[MAXP]; - int size[MAXP]; - - int i, r, loop, pass, subpass; - double start_time, end_time; - ptrdiff_t start_mem, end_mem; -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - ptrdiff_t start_footprint, end_footprint; -#endif - double elapsed; - size_t absmax=0, curmax=0; - int realloc_mask = -1; - size_t allocations = 0; - size_t allocations_size = 0; - size_t frees = 0; - - memset(pointers, 0, MAXP*sizeof(pointers[0])); - - start_time = stk_classic::cpu_time(); -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - free(malloc(1)); - - start_mem = malloc_used(); - start_footprint = malloc_footprint(); -#else - start_mem = (ptrdiff_t) sbrk(0); -#endif - -#if defined SIERRA_PTMALLOC3_ALLOCATOR - std::cout << "Modified ptmalloc3 allocator: "; -#elif defined SIERRA_PTMALLOC2_ALLOCATOR - std::cout << "Modified ptmalloc2 allocator: "; -#else - std::cout << "Default allocator: "; -#endif - -#ifndef NDEBUG - std::cout << "(debug)" << std::endl; -#endif - - std::cout << std::endl; - -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - std::cout << "Start used " << start_mem << std::endl; - std::cout << "Start footprint " << start_footprint << std::endl; -#endif - - std::cout << std::endl - << std::setw(14) << "elapsed" << " " - -#if defined SIERRA_PTMALLOC3_ALLOCATOR || defined SIERRA_PTMALLOC2_ALLOCATOR - << std::setw(14) << "footprint" << " " - << std::setw(14) << "max_footprint" << " " -#endif - << std::setw(14) << "used " << " " - << std::setw(14) << "curmax" << " " << std::endl; - - for (loop=0; loop -#include - -#include - -#include - -struct S1 -{ - S1() - : m_string(), - m_int(0) - {} - - S1(const std::string &s, int i) - : m_string(s), - m_int(i) - {} - - std::string m_string; - int m_int; -}; - -struct S2 -{ - S2() - : m_string(), - m_int(0) - {} - - S2(const std::string &s, int i) - : m_string(s), - m_int(i) - {} - - std::string m_string; - int m_int; -}; - -// Define Marshal for S1 type in S1's namespace -stk_classic::Marshal &operator<<(stk_classic::Marshal &mout, const S1 &s) { - return mout << s.m_string << s.m_int; -} - -stk_classic::Marshal &operator>>(stk_classic::Marshal &min, S1 &s) { - return min >> s.m_string >> s.m_int; -} - - -// Define Marshal for S2 type in stk's namespace -namespace stk_classic { - -template<> -stk_classic::Marshal &operator<<(stk_classic::Marshal &mout, const S2 &s) { - return mout << s.m_string << s.m_int; -} - -template<> -stk_classic::Marshal &operator>>(stk_classic::Marshal &min, S2 &s) { - return min >> s.m_string >> s.m_int; -} - -} // namespace stk_classic - - -template -void -test(const T &t_in) -{ - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_ALL); - mout << t_in; - - stk_classic::Marshal min(mout.str()); - T t_out; - min >> t_out; - - STKUNIT_ASSERT_EQUAL(t_in, t_out); -} - -STKUNIT_UNIT_TEST(UnitTestMarshal, UnitTest) -{ - // Marshal/Unmarshal POD - { - test('a'); - test('a'); - test('a'); - test(1); - test(2); - test(3); - test(4); - test(5); - test(6); - test(7); - test(8); - test(9.0); - test(10.0); - } - - // Marshal/Unmarshal more than one POD in a single message - { - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_ALL); - std::string s_out("this is a test"); - int i_out = 7; - - mout << s_out << i_out; - - stk_classic::Marshal min(mout.str()); - std::string s_in; - int i_in; - - min >> s_in >> i_in; - - STKUNIT_ASSERT_EQUAL(min.size(), mout.size()); - STKUNIT_ASSERT(mout); - STKUNIT_ASSERT(min); - STKUNIT_ASSERT_EQUAL((s_in == s_out), true); - STKUNIT_ASSERT_EQUAL(i_in, i_out); - } - - // Marshal/Unmarshal locally defined class/struct - { - stk_classic::Marshal mout; - S1 s_out("this is a test", 5); - mout << s_out; - - stk_classic::Marshal min(mout.str()); - S1 s_in; - - min >> s_in; - - STKUNIT_ASSERT_EQUAL((s_in.m_string == s_out.m_string), true); - STKUNIT_ASSERT_EQUAL(s_in.m_int, s_out.m_int); - } - - // Marshal/Unmarshal std::vector of S2's (uses the stk namespace operator>> and operator<<) - { - stk_classic::Marshal mout; - S2 s_out("this is a test", 5); - std::vector v_out; - v_out.push_back(s_out); - - mout << v_out; - - stk_classic::Marshal min(mout.str()); - std::vector v_in; - - min >> v_in; - - STKUNIT_ASSERT_EQUAL((v_in[0].m_string == v_out[0].m_string), true); - } - - // Marshal/Unmarshal error from type mismatch - { - - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_ALL); - std::string s_out("this is a test"); - int i_out = 7; - - mout << s_out << i_out; - - stk_classic::Marshal min(mout.str()); - std::string s_in; - double x_in; - - STKUNIT_ASSERT_THROW(min >> s_in >> x_in, std::runtime_error); - } - - // Marshal error for STL container mismatch - { - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_ALL); - S1 s_out("this is a test", 5); - std::vector v_out; - v_out.push_back(s_out); - - mout << v_out; - - stk_classic::Marshal min(mout.str()); - std::list v_in; - - STKUNIT_ASSERT_THROW(min >> v_in, std::runtime_error); - } - - // Marshal error for STL container mismatch - { - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_ALL); - S1 s_out("this is a test", 5); - std::list v_out; - v_out.push_back(s_out); - - mout << v_out; - - stk_classic::Marshal min(mout.str()); - std::vector v_in; - - STKUNIT_ASSERT_THROW(min >> v_in, std::runtime_error); - } - - // Marshal without error for STL container mismatch - { - stk_classic::Marshal mout(stk_classic::Marshal::TYPE_CHECK_NONE); - S1 s_out("this is a test", 5); - std::vector v_out; - v_out.push_back(s_out); - - mout << v_out; - - stk_classic::Marshal min(mout.str()); - std::list v_in; - - STKUNIT_ASSERT_NO_THROW(min >> v_in); - } -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestPrintTable.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestPrintTable.cpp deleted file mode 100644 index e4e0addb56ab..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestPrintTable.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -#include - -STKUNIT_UNIT_TEST( UnitTestPrintTable, UnitTest) -{ - std::ostringstream oss; - - { - oss.str(""); - oss << std::endl; - - stk_classic::PrintTable table; - table.setAutoEndCol(false); - - table.setTitle("Test"); - - table << "x" << stk_classic::end_col - << "y" << stk_classic::end_col << stk_classic::end_header - << "2" << stk_classic::end_row - << "" << stk_classic::end_col - << "3" << stk_classic::end_row - << "" << stk_classic::end_col - << "" << stk_classic::end_col - << "4" << stk_classic::end_row; - oss << table; - } - STKUNIT_ASSERT_EQUAL((std::string("\n Test\nx y\n- - -\n2\n 3\n 4\n\n") == oss.str()), true); - - { - oss.str(""); - oss << std::endl; - - stk_classic::PrintTable table; - - table.setTitle("A multiplication table, auto end column"); - - table << "x" << "|"; - for (int i = 0; i < 10; ++i) - table << i << "|"; - table << stk_classic::end_row; - for (int i = 0; i < 10; ++i) { - table << i << "|"; - for (int j = 0; j < 10; ++j) - table << i*j << "|"; - table << stk_classic::end_row; - } - - oss << table; - } - STKUNIT_ASSERT_EQUAL((std::string("\n A multiplication table, auto end column\nx | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n2 | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 |\n3 | 0 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 |\n4 | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 |\n5 | 0 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 |\n6 | 0 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 |\n7 | 0 | 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 |\n8 | 0 | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 |\n9 | 0 | 9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 | 81 |\n\n") == oss.str()), true); - - { - oss.str(""); - oss << std::endl; - - stk_classic::PrintTable table; - - table.setTitle("A multiplication table, auto end column"); - - table.setAutoEndCol(true); - table.setCommaSeparatedValues(false); - - table << "x" << "|"; - for (int i = 0; i < 10; ++i) - table << i << "|"; - table << stk_classic::end_row; - for (int i = 0; i < 10; ++i) { - table << i << "|"; - for (int j = 0; j < 10; ++j) - table << i*j << "|"; - table << stk_classic::end_row; - } - - oss << table; - } - STKUNIT_ASSERT_EQUAL((std::string("\n A multiplication table, auto end column\nx | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n2 | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 |\n3 | 0 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 |\n4 | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 |\n5 | 0 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 |\n6 | 0 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 |\n7 | 0 | 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 |\n8 | 0 | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 |\n9 | 0 | 9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 | 81 |\n\n") == oss.str()), true); - - { - oss.str(""); - oss << std::endl; - - stk_classic::PrintTable table; - - table.setTitle("A multiplication table (in hex), no auto end column"); - - table.setAutoEndCol(false); - table.setCommentPrefix("# "); - - table << "x" << stk_classic::end_col << "|" << stk_classic::end_col; - for (int i = 0; i < 10; ++i) - table << i << stk_classic::end_col << "|" << stk_classic::end_col; - table << stk_classic::end_header; - for (int i = 0; i < 10; ++i) { - table << i << stk_classic::end_col << "|" << stk_classic::end_col; - for (int j = 0; j < 10; ++j) - table << std::hex << i*j << stk_classic::end_col << "|" << stk_classic::end_col; - table << stk_classic::end_row; - } - - oss << table; - } - STKUNIT_ASSERT_EQUAL((std::string("\n# A multiplication table (in hex), no auto end column\n# x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n# - - - - - - -- - -- - -- - -- - -- - -- - -- - -- -\n 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n 2 | 0 | 2 | 4 | 6 | 8 | a | c | e | 10 | 12 |\n 3 | 0 | 3 | 6 | 9 | c | f | 12 | 15 | 18 | 1b |\n 4 | 0 | 4 | 8 | c | 10 | 14 | 18 | 1c | 20 | 24 |\n 5 | 0 | 5 | a | f | 14 | 19 | 1e | 23 | 28 | 2d |\n 6 | 0 | 6 | c | 12 | 18 | 1e | 24 | 2a | 30 | 36 |\n 7 | 0 | 7 | e | 15 | 1c | 23 | 2a | 31 | 38 | 3f |\n 8 | 0 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 |\n 9 | 0 | 9 | 12 | 1b | 24 | 2d | 36 | 3f | 48 | 51 |\n \n") == oss.str()), true); - - { - oss.str(""); - oss << std::endl; - - stk_classic::PrintTable table; - - table.setTitle("A multiplication table, comma separated values"); - - table.setAutoEndCol(true); - table.setCommaSeparatedValues(true); - - table << "x"; - for (int i = 0; i < 10; ++i) - table << i; - table << stk_classic::end_header; - - for (int i = 0; i < 10; ++i) { - table << i; - for (int j = 0; j < 10; ++j) - table << i*j; - table << stk_classic::end_row; - } - - oss << table; - } - STKUNIT_ASSERT_EQUAL((std::string("\nA multiplication table, comma separated values\nx,0,1,2,3,4,5,6,7,8,9\n0,0,0,0,0,0,0,0,0,0,0\n1,0,1,2,3,4,5,6,7,8,9\n2,0,2,4,6,8,10,12,14,16,18\n3,0,3,6,9,12,15,18,21,24,27\n4,0,4,8,12,16,20,24,28,32,36\n5,0,5,10,15,20,25,30,35,40,45\n6,0,6,12,18,24,30,36,42,48,54\n7,0,7,14,21,28,35,42,49,56,63\n8,0,8,16,24,32,40,48,56,64,72\n9,0,9,18,27,36,45,54,63,72,81\n\n") == oss.str()), true); -} diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestTeeStreambuf.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestTeeStreambuf.cpp deleted file mode 100644 index 4b0f150805ed..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTestTeeStreambuf.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Copyright 2010 Sandia Corporation. */ -/* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ -/* license for use of this work by or on behalf of the U.S. Government. */ -/* Export of this program may require a license from the */ -/* United States Government. */ -/*------------------------------------------------------------------------*/ - -#include -#include -#include - -#include - -STKUNIT_UNIT_TEST(UnitTestTeeStreambuf, UnitTest) -{ - stk_classic::tee_streambuf out_tee_streambuf; - - std::ostream my_out(&out_tee_streambuf); - - std::ostringstream dest1; - std::ostringstream dest2; - - out_tee_streambuf.add(&dest1); - out_tee_streambuf.add(&dest2); - - std::string message1("This is a test"); - std::string message2("This is a test"); - - std::string message3 = message1 + message2; - - my_out << message1; - - STKUNIT_ASSERT_EQUAL((dest1.str() == message1), true); - STKUNIT_ASSERT_EQUAL((dest2.str() == message1), true); - - out_tee_streambuf.remove(&dest2); - - my_out << message2; - - STKUNIT_ASSERT_EQUAL((dest1.str() == message3), true); - STKUNIT_ASSERT_EQUAL((dest2.str() == message1), true); - - out_tee_streambuf.remove(&dest1); - - my_out << message2; - - STKUNIT_ASSERT_EQUAL((dest1.str() == message3), true); - STKUNIT_ASSERT_EQUAL((dest2.str() == message1), true); -} - diff --git a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_filter_iterator.cpp b/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_filter_iterator.cpp deleted file mode 100644 index 4b56d0eaf5d0..000000000000 --- a/packages/stk/stk_classic/stk_util/unit_tests/util/UnitTest_filter_iterator.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include - -#include - -#include -#include - -namespace vector_vector_int { - -struct vec_filter { - vec_filter(size_t sz=0) : m_sz(sz) {} - - bool operator()(const std::vector& vec) const { return vec.size() > m_sz; } - - private: - size_t m_sz; -}; - -typedef std::vector< std::vector > nested_type; - -} - -STKUNIT_UNIT_TEST ( filter_iterator, vector_vector_int) -{ - using namespace vector_vector_int; - - const int OUTER = 10; - - nested_type a(OUTER); - - { - int count = 0; - for (int i=0; i >::iterator> itr(vec_filter(4),a.begin(),a.end()); - boost::filter_iterator >::iterator> itr_end(a.end(), a.end()); - - for(; itr!=itr_end; ++itr) - { - std::vector& v = *itr; - for(std::vector::iterator vit=v.begin(),vend=v.end(); vit!=vend; ++vit) { - std::cout<<*vit<<" "; - } - std::cout< - -#include -#include - -#include -#include -#include - -namespace vector_vector_int { - - typedef std::vector< std::vector > nested_type; - - typedef stk_classic::util::nested_iterator< std::vector >, - std::vector, - stk_classic::util::details::identity > - > nested_iterator; - - typedef stk_classic::util::nested_iterator< const std::vector >, - std::vector, - stk_classic::util::details::identity > - > const_nested_iterator; -} - -STKUNIT_UNIT_TEST ( nested_iterator, vector_vector_int) -{ - using namespace vector_vector_int; - - const int OUTER = 10; - const int INNER = 10; - - nested_type a(OUTER); - - { - int count = 0; - for (int i=0; i > nested_type; - - typedef stk_classic::util::nested_iterator< std::list >, - std::vector, - stk_classic::util::details::identity > - > nested_iterator; -} - -STKUNIT_UNIT_TEST ( nested_iterator, list_vector_int) -{ - using namespace list_vector_int; - - const int OUTER = 10; - const int INNER = 10; - - nested_type a(OUTER); - - { - int count = 0; - for (int i=0; i tmp; - a.push_back(tmp); - for (int j=0; j - -#include -#include - -#include -#include -#include - -namespace vector_vector_int { - -typedef std::vector< std::vector > nested_type; -typedef std::vector< std::pair > nested_pair_type; - -typedef stk_classic::util::nested_range< nested_type > range; -typedef stk_classic::util::nested_range< nested_pair_type > pair_range; - - -} - -STKUNIT_UNIT_TEST ( nested_range, basic) -{ - using namespace vector_vector_int; - - const int OUTER = 10; - const int INNER = 10; - - nested_type a(OUTER); - nested_pair_type ap(OUTER); - - { - int count = 0; - for (int i=0; i result_type; -// typedef std::vector* value_type; -// -// result_type& operator()(value_type& r) const { return *r; } -// const result_type& operator()(const value_type& r) const { return *r; } -//}; -// -//typedef std::vector< std::vector* > nested_ptr_type; -// -//typedef stk_classic::util::nested_range< nested_ptr_type, std::vector, to_inner_range > ptr_range; -// -//} -// -//STKUNIT_UNIT_TEST ( nested_range, nested_ptr) -//{ -// using namespace vector_vector_int; -// -// const int OUTER = 10; -// const int INNER = 10; -// -// nested_ptr_type a(OUTER); -// -// { -// int count = 0; -// for (int i=0; i(INNER); -// for (int j=0; j* vecptr,a) { -// std::vector& vec = *vecptr; -// BOOST_FOREACH(int i,vec) { -// std::cout< Date: Wed, 19 Sep 2018 11:52:59 -0600 Subject: [PATCH 2/2] remove stk_classic references from cmake and examples. --- .../TrilinosPackageDependencies.xml | 14 - packages/stk/cmake/Dependencies.cmake | 1 - .../examples/scaling/example_Poisson_stk.cpp | 189 --- .../scaling/example_Poisson_stkclassic.cpp | 1403 ----------------- 4 files changed, 1607 deletions(-) delete mode 100644 packages/trilinoscouplings/examples/scaling/example_Poisson_stkclassic.cpp diff --git a/cmake/dependencies/TrilinosPackageDependencies.xml b/cmake/dependencies/TrilinosPackageDependencies.xml index d00b2b531bab..b74c14770dce 100644 --- a/cmake/dependencies/TrilinosPackageDependencies.xml +++ b/cmake/dependencies/TrilinosPackageDependencies.xml @@ -1427,20 +1427,6 @@ - - - - - - - - - - - - - - diff --git a/packages/stk/cmake/Dependencies.cmake b/packages/stk/cmake/Dependencies.cmake index 31f4bba72d6d..47926cc1d0ae 100644 --- a/packages/stk/cmake/Dependencies.cmake +++ b/packages/stk/cmake/Dependencies.cmake @@ -1,5 +1,4 @@ SET(SUBPACKAGES_DIRS_CLASSIFICATIONS_OPTREQS - Classic stk_classic EX OPTIONAL Util stk_util PT OPTIONAL Simd stk_simd PT OPTIONAL Topology stk_topology PT OPTIONAL diff --git a/packages/trilinoscouplings/examples/scaling/example_Poisson_stk.cpp b/packages/trilinoscouplings/examples/scaling/example_Poisson_stk.cpp index 3994336b86de..f3a9aaba4021 100644 --- a/packages/trilinoscouplings/examples/scaling/example_Poisson_stk.cpp +++ b/packages/trilinoscouplings/examples/scaling/example_Poisson_stk.cpp @@ -990,195 +990,6 @@ int main(int argc, char *argv[]) { rhsVector, femCoefficients, TotalErrorResidual, TotalErrorExactSol); - -#ifdef OLD_STK_CLASSIC_STUFF - -/**********************************************************************************/ -/**************************** CALCULATE ERROR *************************************/ -/**********************************************************************************/ - - if (MyPID == 0) {Time.ResetStartTime();} - - double L2err = 0.0; - double L2errTot = 0.0; - double H1err = 0.0; - double H1errTot = 0.0; - double Linferr = 0.0; - double LinferrTot = 0.0; - - // Import solution onto current processor - // FIXME - int numNodesGlobal = globalMapG.NumGlobalElements(); - Epetra_Map solnMap(numNodesGlobal, numNodesGlobal, 0, Comm); - Epetra_Import solnImporter(solnMap, globalMapG); - Epetra_Vector uCoeff(solnMap); - uCoeff.Import(femCoefficients, solnImporter, Insert); - - // Define desired workset size - desiredWorksetSize = numElems; - int numWorksetsErr = numElems/desiredWorksetSize; - - // When numElems is not divisible by desiredWorksetSize, increase workset count by 1 - if(numWorksetsErr*desiredWorksetSize < numElems) numWorksetsErr += 1; - - // Get cubature points and weights for error calc (may be different from previous) - Intrepid::DefaultCubatureFactory cubFactoryErr; - int cubDegErr = 3; - RCP > cellCubatureErr = cubFactoryErr.create(cellType, cubDegErr); - int cubDimErr = cellCubatureErr->getDimension(); - int numCubPointsErr = cellCubatureErr->getNumPoints(); - IntrepidFieldContainer cubPointsErr(numCubPointsErr, cubDimErr); - IntrepidFieldContainer cubWeightsErr(numCubPointsErr); - cellCubatureErr->getCubature(cubPointsErr, cubWeightsErr); - - // Evaluate basis values and gradients at cubature points - IntrepidFieldContainer uhGVals(numFieldsG, numCubPointsErr); - IntrepidFieldContainer uhGrads(numFieldsG, numCubPointsErr, spaceDim); - HGradBasis->getValues(uhGVals, cubPointsErr, Intrepid::OPERATOR_VALUE); - HGradBasis->getValues(uhGrads, cubPointsErr, Intrepid::OPERATOR_GRAD); - - // Loop over worksets - for(int workset = 0; workset < numWorksetsErr; workset++){ - - // compute cell numbers where the workset starts and ends - int worksetSize = 0; - int worksetBegin = (workset + 0)*desiredWorksetSize; - int worksetEnd = (workset + 1)*desiredWorksetSize; - - // when numElems is not divisible by desiredWorksetSize, the last workset ends at numElems - worksetEnd = (worksetEnd <= numElems) ? worksetEnd : numElems; - - // now we know the actual workset size and can allocate the array for the cell nodes - worksetSize = worksetEnd - worksetBegin; - IntrepidFieldContainer cellWorksetEr(worksetSize, numNodesPerElem, spaceDim); - IntrepidFieldContainer worksetApproxSolnCoef(worksetSize, numNodesPerElem); - - // loop over cells to fill arrays with coordinates and calculation solution coefficient - int cellCounter = 0; - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // Get element entity from id of cell - stk_classic::mesh::Entity * worksetElem = bulkData.get_entity(elementRank,cell+1); - - // get nodes attached to this element - const stk_classic::mesh::PairIterRelation worksetNodes = worksetElem->relations(nodeRank); - - // loop over nodes and get coordinates to fill workset array - for (size_t i = 0; i < worksetNodes.size(); i++) { - double * coord = stk_classic::mesh::field_data(*coords, *worksetNodes[i].entity()); - cellWorksetEr(cellCounter, i, 0) = coord[0]; - cellWorksetEr(cellCounter, i, 1) = coord[1]; - cellWorksetEr(cellCounter, i, 2) = coord[2]; - int rowIndex = worksetNodes[i].entity()->identifier() - 1; - worksetApproxSolnCoef(cellCounter, i) = uCoeff.Values()[rowIndex]; - } - - cellCounter++; - - } // end cell loop - - // Containers for Jacobian - IntrepidFieldContainer worksetJacobianE(worksetSize, numCubPointsErr, spaceDim, spaceDim); - IntrepidFieldContainer worksetJacobInvE(worksetSize, numCubPointsErr, spaceDim, spaceDim); - IntrepidFieldContainer worksetJacobDetE(worksetSize, numCubPointsErr); - IntrepidFieldContainer worksetCubWeightsE(worksetSize, numCubPointsErr); - - // Containers for basis values and gradients in physical space - IntrepidFieldContainer uhGValsTrans(worksetSize,numFieldsG, numCubPointsErr); - IntrepidFieldContainer uhGradsTrans(worksetSize, numFieldsG, numCubPointsErr, spaceDim); - - // compute cell Jacobians, their inverses and their determinants - IntrepidCTools::setJacobian(worksetJacobianE, cubPointsErr, cellWorksetEr, cellType); - IntrepidCTools::setJacobianInv(worksetJacobInvE, worksetJacobianE ); - IntrepidCTools::setJacobianDet(worksetJacobDetE, worksetJacobianE ); - - // map cubature points to physical frame - IntrepidFieldContainer worksetCubPoints(worksetSize, numCubPointsErr, cubDimErr); - IntrepidCTools::mapToPhysicalFrame(worksetCubPoints, cubPointsErr, cellWorksetEr, cellType); - - // evaluate exact solution and gradient at cubature points - IntrepidFieldContainer worksetExactSoln(worksetSize, numCubPointsErr); - IntrepidFieldContainer worksetExactSolnGrad(worksetSize, numCubPointsErr, spaceDim); - evaluateExactSolution(worksetExactSoln, worksetCubPoints); - evaluateExactSolutionGrad(worksetExactSolnGrad, worksetCubPoints); - - // transform basis values to physical coordinates - IntrepidFSTools::HGRADtransformVALUE(uhGValsTrans, uhGVals); - IntrepidFSTools::HGRADtransformGRAD(uhGradsTrans, worksetJacobInvE, uhGrads); - - // compute weighted measure - IntrepidFSTools::computeCellMeasure(worksetCubWeightsE, worksetJacobDetE, cubWeightsErr); - - // evaluate the approximate solution and gradient at cubature points - IntrepidFieldContainer worksetApproxSoln(worksetSize, numCubPointsErr); - IntrepidFieldContainer worksetApproxSolnGrad(worksetSize, numCubPointsErr, spaceDim); - IntrepidFSTools::evaluate(worksetApproxSoln, worksetApproxSolnCoef, uhGValsTrans); - IntrepidFSTools::evaluate(worksetApproxSolnGrad, worksetApproxSolnCoef, uhGradsTrans); - - // get difference between approximate and exact solutions - IntrepidFieldContainer worksetDeltaSoln(worksetSize, numCubPointsErr); - IntrepidFieldContainer worksetDeltaSolnGrad(worksetSize, numCubPointsErr, spaceDim); - IntrepidRSTools::subtract(worksetDeltaSoln, worksetApproxSoln, worksetExactSoln); - IntrepidRSTools::subtract(worksetDeltaSolnGrad, worksetApproxSolnGrad, worksetExactSolnGrad); - - // take absolute values - IntrepidRSTools::absval(worksetDeltaSoln); - IntrepidRSTools::absval(worksetDeltaSolnGrad); - - // apply cubature weights to differences in values and grads for use in integration - IntrepidFieldContainer worksetDeltaSolnWeighted(worksetSize, numCubPointsErr); - IntrepidFieldContainer worksetDeltaSolnGradWeighted(worksetSize, numCubPointsErr, spaceDim); - IntrepidFSTools::scalarMultiplyDataData(worksetDeltaSolnWeighted, - worksetCubWeightsE, worksetDeltaSoln); - IntrepidFSTools::scalarMultiplyDataData(worksetDeltaSolnGradWeighted, - worksetCubWeightsE, worksetDeltaSolnGrad); - - // integrate to get errors on each element - IntrepidFieldContainer worksetL2err(worksetSize); - IntrepidFieldContainer worksetH1err(worksetSize); - IntrepidFSTools::integrate(worksetL2err, worksetDeltaSoln, - worksetDeltaSolnWeighted, Intrepid::COMP_BLAS); - IntrepidFSTools::integrate(worksetH1err, worksetDeltaSolnGrad, - worksetDeltaSolnGradWeighted, Intrepid::COMP_BLAS); - - // loop over cells to get errors for total workset - cellCounter = 0; - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // loop over cubature points - for(int nPt = 0; nPt < numCubPointsErr; nPt++){ - - Linferr = std::max(Linferr, worksetDeltaSoln(cellCounter,nPt)); - - } - - L2err += worksetL2err(cellCounter); - H1err += worksetH1err(cellCounter); - - cellCounter++; - - } // end cell loop - - } // end loop over worksets - - - // sum over all processors - Comm.SumAll(&L2err,&L2errTot,1); - Comm.SumAll(&H1err,&H1errTot,1); - Comm.MaxAll(&Linferr,&LinferrTot,1); - - if (MyPID == 0) { - std::cout << "\n" << "L2 Error: " << sqrt(L2errTot) <<"\n"; - std::cout << "H1 Error: " << sqrt(H1errTot) <<"\n"; - std::cout << "LInf Error: " << LinferrTot <<"\n\n"; - } - - - if(MyPID==0) {std::cout << "Calculate error " - << Time.ElapsedTime() << " s \n"; Time.ResetStartTime();} - -#endif //OLD_STK_CLASSIC_STUFF - return 0; } diff --git a/packages/trilinoscouplings/examples/scaling/example_Poisson_stkclassic.cpp b/packages/trilinoscouplings/examples/scaling/example_Poisson_stkclassic.cpp deleted file mode 100644 index 6896ff41c2a4..000000000000 --- a/packages/trilinoscouplings/examples/scaling/example_Poisson_stkclassic.cpp +++ /dev/null @@ -1,1403 +0,0 @@ -// @HEADER -// ************************************************************************ -// -// Intrepid Package -// Copyright (2007) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -// USA -// Questions? Contact Pavel Bochev (pbboche@sandia.gov), -// Denis Ridzal (dridzal@sandia.gov), -// Kara Peterson (kjpeter@sandia.gov). -// -// ************************************************************************ -// @HEADER - -/** \file example_Poisson_stk.cpp - \brief Example solution of a Poisson equation on a hexahedral or - tetrahedral mesh using nodal (Hgrad) elements. - - This example requires a hexahedral or tetrahedral mesh in Exodus - format with a nodeset containing boundary nodes. STK is used to - read the mesh and populate a mesh database, Intrepid is used to - build the stiffness matrix and right-hand side, and ML is used - to solve the resulting linear system. - - \verbatim - - Poisson system: - - div A grad u = f in Omega - u = g on Gamma - - where - A is a symmetric, positive definite material tensor - f is a given source term - - - Corresponding discrete linear system for nodal coefficients(x): - - Kx = b - - K - HGrad stiffness matrix - b - right hand side vector - - \endverbatim - - \author Created by P. Bochev, D. Ridzal, K. Peterson C. Siefert. - - \remark Usage: - \code ./example_Poisson_stk \endcode - - \remark Example requires a hexahedral or tetrahedral mesh in Exodus format -*/ -/********************************************************************************/ -/********************************************************************************/ -/********************************************************************************/ - -#define DUMP_DATA - -/**************************************************************/ -/* Includes */ -/**************************************************************/ - -// Intrepid includes -#include "Intrepid_FunctionSpaceTools.hpp" -#include "Intrepid_CellTools.hpp" -#include "Intrepid_ArrayTools.hpp" -#include "Intrepid_Basis.hpp" -#include "Intrepid_HGRAD_HEX_C1_FEM.hpp" -#include "Intrepid_HGRAD_TET_C1_FEM.hpp" -#include "Intrepid_RealSpaceTools.hpp" -#include "Intrepid_DefaultCubatureFactory.hpp" -#include "Intrepid_Utils.hpp" - -// Epetra includes -#include "Epetra_Time.h" -#include "Epetra_Map.h" -#ifdef HAVE_MPI -#include "Epetra_MpiComm.h" -#else -#include "Epetra_SerialComm.h" -#endif -#include "Epetra_FECrsMatrix.h" -#include "Epetra_FEVector.h" -#include "Epetra_Import.h" - -// Teuchos includes -#include "Teuchos_oblackholestream.hpp" -#include "Teuchos_RCP.hpp" -#include "Teuchos_BLAS.hpp" -#include "Teuchos_GlobalMPISession.hpp" -#include "Teuchos_XMLParameterListHelpers.hpp" - -// Shards includes -#include "Shards_CellTopology.hpp" - -// EpetraExt includes -#include "EpetraExt_RowMatrixOut.h" -#include "EpetraExt_MultiVectorOut.h" - -// AztecOO includes -#include "AztecOO.h" - -// ML includes -#include "ml_MultiLevelPreconditioner.h" -#include "ml_epetra_utils.h" - -#ifdef HAVE_INTREPID_KOKKOSCORE -#include "Sacado.hpp" -#else -// Sacado includes -#include "Sacado_No_Kokkos.hpp" -#endif - -// STK includes -#include "Ionit_Initializer.h" -#include "stk_io/IossBridge.hpp" -#include "stk_io/MeshReadWriteUtils.hpp" -#include "stk_util/parallel/Parallel.hpp" -#include "stk_mesh/base/FieldData.hpp" -#include "stk_mesh/base/MetaData.hpp" -#include "stk_mesh/base/BulkData.hpp" -#include "stk_mesh/base/Comm.hpp" -#include "stk_mesh/base/Selector.hpp" -#include "stk_mesh/base/GetEntities.hpp" -#include "stk_mesh/base/GetBuckets.hpp" -#include "stk_mesh/fem/CreateAdjacentEntities.hpp" - -/*********************************************************/ -/* Typedefs */ -/*********************************************************/ -typedef Sacado::Fad::SFad Fad3; //# ind. vars fixed at 3 -typedef shards::CellTopology ShardsCellTopology; -typedef Intrepid::FunctionSpaceTools IntrepidFSTools; -typedef Intrepid::RealSpaceTools IntrepidRSTools; -typedef Intrepid::CellTools IntrepidCTools; - - -/**********************************************************************************/ -/******** FUNCTION DECLARATIONS FOR EXACT SOLUTION AND SOURCE TERMS ***************/ -/**********************************************************************************/ - -/** \brief User-defined exact solution. - - \param x [in] x-coordinate of the evaluation point - \param y [in] y-coordinate of the evaluation point - \param z [in] z-coordinate of the evaluation point - - \return Value of the exact solution at (x,y,z) - */ -template -const Scalar exactSolution(const Scalar& x, const Scalar& y, const Scalar& z); - -/** \brief User-defined material tensor. - - \param material [out] 3 x 3 material tensor evaluated at (x,y,z) - \param x [in] x-coordinate of the evaluation point - \param y [in] y-coordinate of the evaluation point - \param z [in] z-coordinate of the evaluation point - - \warning Symmetric and positive definite tensor is required for every (x,y,z). -*/ -template -void materialTensor(Scalar material[][3], const Scalar& x, const Scalar& y, const Scalar& z); - -/** \brief Computes gradient of the exact solution. Requires user-defined exact solution. - - \param gradExact [out] gradient of the exact solution evaluated at (x,y,z) - \param x [in] x-coordinate of the evaluation point - \param y [in] y-coordinate of the evaluation point - \param z [in] z-coordinate of the evaluation point - */ -template -void exactSolutionGrad(Scalar gradExact[3], const Scalar& x, const Scalar& y, const Scalar& z); - - -/** \brief Computes source term: f = -div(A.grad u). Requires user-defined exact solution - and material tensor. - - \param x [in] x-coordinate of the evaluation point - \param y [in] y-coordinate of the evaluation point - \param z [in] z-coordinate of the evaluation point - - \return Source term corresponding to the user-defined exact solution evaluated at (x,y,z) - */ -template -const Scalar sourceTerm(Scalar& x, Scalar& y, Scalar& z); - - -/** \brief Computation of the material tensor at array of points in physical space. - - \param worksetMaterialValues [out] Rank-2, 3 or 4 array with dimensions (C,P), (C,P,D) or (C,P,D,D) - with the values of the material tensor - \param evaluationPoints [in] Rank-3 (C,P,D) array with the evaluation points in physical frame -*/ -template -void evaluateMaterialTensor(ArrayOut & worksetMaterialValues, - const ArrayIn & evaluationPoints); - - -/** \brief Computation of the source term at array of points in physical space. - - \param sourceTermValues [out] Rank-2 (C,P) array with the values of the source term - \param evaluationPoints [in] Rank-3 (C,P,D) array with the evaluation points in physical frame -*/ -template -void evaluateSourceTerm(ArrayOut & sourceTermValues, - const ArrayIn & evaluationPoints); - -/** \brief Computation of the exact solution at array of points in physical space. - - \param exactSolutionValues [out] Rank-2 (C,P) array with the values of the exact solution - \param evaluationPoints [in] Rank-3 (C,P,D) array with the evaluation points in physical frame -*/ -template -void evaluateExactSolution(ArrayOut & exactSolutionValues, - const ArrayIn & evaluationPoints); - - -/** \brief Computation of the gradient of the exact solution at array of points in physical space. - - \param exactSolutionGradValues [out] Rank-3 (C,P,D) array with the values of the gradient of the exact solution - \param evaluationPoints [in] Rank-3 (C,P,D) array with the evaluation points in physical frame -*/ -template -void evaluateExactSolutionGrad(ArrayOut & exactSolutionGradValues, - const ArrayIn & evaluationPoints); - - -/**********************************************************************************/ -/**************** FUNCTION DECLARATION FOR ML PRECONDITIONER *********************/ -/**********************************************************************************/ -int TestMultiLevelPreconditioner(char ProblemType[], - Teuchos::ParameterList & MLList, - Epetra_CrsMatrix & A, - const Epetra_MultiVector & xexact, - Epetra_MultiVector & b, - Epetra_MultiVector & uh, - double & TotalErrorResidual, - double & TotalErrorExactSol); - - -/**********************************************************************************/ -/************* FUNCTION DECLARATIONS FOR SIMPLE BASIS FACTORY *********************/ -/**********************************************************************************/ - -/** \brief Simple factory that chooses basis function based on cell topology. - - \param cellTopology [in] Shards cell topology - \param order [in] basis function order, currently unused - \param basis [out] pointer to Intrepid basis - - \return Intrepid basis - */ - -void getBasis(Teuchos::RCP > > &basis, - const shards::CellTopology & cellTopology, - int order); - -/**********************************************************************************/ -/**********************************************************************************/ -/**********************************************************************************/ - - - -/**********************************************************************************/ -/******************************** MAIN ********************************************/ -/**********************************************************************************/ - -int main(int argc, char *argv[]) { - - int numProcs=1; - int rank=0; - -#ifdef HAVE_MPI - Teuchos::GlobalMPISession mpiSession(&argc, &argv,0); - rank=mpiSession.getRank(); - numProcs=mpiSession.getNProc(); - Epetra_MpiComm Comm(MPI_COMM_WORLD); -#else - Epetra_SerialComm Comm; -#endif - - int MyPID = Comm.MyPID(); - Epetra_Time Time(Comm); - - //Check number of arguments - if ( (argc == 1) | (argc > 3)) { - if (MyPID == 0) { - std::cout <<"\n>>> ERROR: Invalid number of arguments.\n\n"; - std::cout <<"Usage:\n\n"; - std::cout <<" ./Poisson \n\n"; - std::cout <<" meshfile.exo - Exodus hexhedral or tetrahedral mesh \n"; - std::cout <<" file with nodeset defined for boundary. \n\n"; - std::cout <<" solver.xml (optional) - xml file with ML solver options\n\n"; - } - exit(1); - } - - if (MyPID == 0){ - std::cout \ - << "===============================================================================\n" \ - << "| |\n" \ - << "| Example: Solve Poisson Equation |\n" \ - << "| |\n" \ - << "| Questions? Contact Pavel Bochev (pbboche@sandia.gov), |\n" \ - << "| Denis Ridzal (dridzal@sandia.gov), |\n" \ - << "| Kara Peterson (kjpeter@sandia.gov). |\n" \ - << "| |\n" \ - << "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \ - << "| STK's website: http://trilinos.sandia.gov/packages/stk |\n" \ - << "| ML's website: http://trilinos.sandia.gov/packages/ml |\n" \ - << "| Trilinos website: http://trilinos.sandia.gov |\n" \ - << "| |\n" \ - << "===============================================================================\n"; - } - - -#ifdef HAVE_MPI - if (numProcs > 1) { - if (MyPID == 0) { - std::cout <<"\n>>> ERROR: Example will only run on a single processor. \n\n"; - } - exit(1); - } -#endif - -/**********************************************************************************/ -/********************************** GET XML INPUTS ********************************/ -/**********************************************************************************/ - - // get xml file from command line if provided, otherwise use default - std::string xmlSolverInFileName; - if(argc>=3) xmlSolverInFileName=std::string(argv[2]); - - // Read xml file into parameter list - Teuchos::ParameterList inputSolverList; - - if(xmlSolverInFileName.length()) { - - if (MyPID == 0) - std::cout << "\nReading parameter list from the XML file \""< nodes; - stk_classic::mesh::get_entities(bulkData, nodeRank, nodes); - int numNodes = nodes.size(); - - // get elems - std::vector elems; - stk_classic::mesh::get_entities(bulkData, elementRank, elems); - int numElems = elems.size(); - - if (MyPID == 0) { - std::cout << " Number of Elements: " << numElems << " \n"; - std::cout << " Number of Nodes: " << numNodes << " \n\n"; - } - - // get coordinates field - stk_classic::mesh::Field *coords = - femMetaData.get_field >("coordinates"); - - // get buckets containing entities of node rank - const std::vector & nodeBuckets = bulkData.buckets( nodeRank ); - std::vector bcNodes; - - // loop over all mesh parts - const stk_classic::mesh::PartVector & all_parts = femMetaData.get_parts(); - for (stk_classic::mesh::PartVector::const_iterator i = all_parts.begin(); - i != all_parts.end(); ++i) { - - stk_classic::mesh::Part & part = **i ; - - // if part only contains nodes, then it is a node set - // ! this assumes that the only node set defined is the set - // ! of boundary nodes - if (part.primary_entity_rank() == nodeRank) { - stk_classic::mesh::Selector bcNodeSelector(part); - stk_classic::mesh::get_selected_entities(bcNodeSelector, nodeBuckets, bcNodes); - } - - } // end loop over mesh parts - - // if no boundary node set was found give a warning - if (bcNodes.size() == 0) { - if (MyPID == 0) { - std::cout << "\n Warning! - No boundary node set found. \n"; - std::cout << " Boundary conditions will not be applied correctly. \n\n"; - } - } - - if(MyPID==0) {std::cout << "Read mesh " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - -/**********************************************************************************/ -/********************************SET CELL TOPOLOGY ********************************/ -/**********************************************************************************/ - - // Here the topology is defined from the mesh. Note that it is assumed - // that there is a part labeled "block_1" and that the cell topology is - // homogeneous over the entire mesh (i.e. there is not another block - // containing elements with a different topology). - - // get the part labeled block_1 - stk_classic::mesh::Part* const part = femMetaData.get_part("block_1"); - - // get the topology of this part - // (stk_classic::mesh::fem::CellTopology is shards::CellTopology) - stk_classic::mesh::fem::CellTopology cellType = femMetaData.get_cell_topology( *part ); - - // Get dimensions - int numNodesPerElem = cellType.getNodeCount(); - - if(MyPID==0) {std::cout << "Get cell topology " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - -/**********************************************************************************/ -/********************************* GET CUBATURE ***********************************/ -/**********************************************************************************/ - - // Define cubature of the specified degree for the cellType - Intrepid::DefaultCubatureFactory cubFactory; - int cubDegree = 2; - Teuchos::RCP > cellCubature = cubFactory.create(cellType, cubDegree); - - int cubDim = cellCubature -> getDimension(); - int numCubPoints = cellCubature -> getNumPoints(); - - // Get numerical integration points and weights - Intrepid::FieldContainer cubPoints (numCubPoints, cubDim); - Intrepid::FieldContainer cubWeights(numCubPoints); - - cellCubature -> getCubature(cubPoints, cubWeights); - - if(MyPID==0) {std::cout << "Getting cubature " - << Time.ElapsedTime() << " sec \n" ; Time.ResetStartTime();} - -/**********************************************************************************/ -/*********************************** GET BASIS ************************************/ -/**********************************************************************************/ - - // Select basis from the cell topology - int order = 1; - Teuchos::RCP > > HGradBasis; - getBasis(HGradBasis, cellType, order); - - - int numFieldsG = HGradBasis->getCardinality(); - Intrepid::FieldContainer basisValues(numFieldsG, numCubPoints); - Intrepid::FieldContainer basisGrads(numFieldsG, numCubPoints, spaceDim); - - // Evaluate basis values and gradients at cubature points - HGradBasis->getValues(basisValues, cubPoints, Intrepid::OPERATOR_VALUE); - HGradBasis->getValues(basisGrads, cubPoints, Intrepid::OPERATOR_GRAD); - - if(MyPID==0) {std::cout << "Getting basis " - << Time.ElapsedTime() << " sec \n" ; Time.ResetStartTime();} - - -/**********************************************************************************/ -/********************* BUILD MAPS FOR GLOBAL SOLUTION *****************************/ -/**********************************************************************************/ - - // For now assume local nodes = global nodes (and assume DOFs = nodes) - - // For parallel need a map like this: - // Epetra_Map globalMapG(-1,ownedNodes,ownedGIDs,0,Comm); - - Epetra_Map globalMapG(numNodes, 0, Comm); - Epetra_FECrsMatrix StiffMatrix(Copy, globalMapG, numFieldsG); - Epetra_FEVector rhsVector(globalMapG); - - if(MyPID==0) {std::cout << "Build global maps " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - -#ifdef DUMP_DATA -/**********************************************************************************/ -/**** PUT COORDINATES AND NODAL VALUES IN ARRAYS FOR OUTPUT (FOR PLOTTING ONLY) ***/ -/**********************************************************************************/ - - // Put coordinates in multivector for output - Epetra_MultiVector nCoord(globalMapG,3); - - // Put element to node mapping in multivector for output - Epetra_Map globalMapElem(numElems, 0, Comm); - Epetra_MultiVector elem2node(globalMapElem,numNodesPerElem); - - // Loop over elements - for (size_t j = 0; j < elems.size(); j++) { - - // get nodes attached to this element - const stk_classic::mesh::PairIterRelation elem_nodes = elems[j]->relations(nodeRank); - - // loop over nodes and fill element to node map - // local ids - // element id : elems[j]->identifier()-1 - // node id: elem_nodes[i].entity()->identifier()-1 - for (size_t i = 0; i < elem_nodes.size(); i++) { - elem2node[i][elems[j]->identifier()-1] = elem_nodes[i].entity()->identifier() - 1; - double * coord = stk_classic::mesh::field_data(*coords, *elem_nodes[i].entity()); - nCoord[0][elem_nodes[i].entity()->identifier()-1] = coord[0]; - nCoord[1][elem_nodes[i].entity()->identifier()-1] = coord[1]; - nCoord[2][elem_nodes[i].entity()->identifier()-1] = coord[2]; - } - - } // end loop over elements - - // output multivectors - EpetraExt::MultiVectorToMatrixMarketFile("elem2node.dat",elem2node,0,0,false); - EpetraExt::MultiVectorToMatrixMarketFile("coords.dat",nCoord,0,0,false); - - if(MyPID==0) {Time.ResetStartTime();} - -#endif - -/**********************************************************************************/ -/************************** DIRICHLET BC SETUP ************************************/ -/**********************************************************************************/ - - // Vector for use in applying BCs - Epetra_MultiVector v(globalMapG,true); - v.PutScalar(0.0); - - int * bcNodeVec = new int [bcNodes.size()]; - // Loop over boundary nodes - for (unsigned i = 0; i < bcNodes.size(); i++) { - - int bcNodeId = bcNodes[i]->identifier() - 1; - bcNodeVec[i] = bcNodeId; - - // get coordinates for this node - stk_classic::mesh::Entity * bcnode = bulkData.get_entity(nodeRank,bcNodes[i]->identifier()); - double * coord = stk_classic::mesh::field_data(*coords, *bcnode); - - // look up exact value of function on boundary - double x = coord[0]; - double y = coord[1]; - double z = coord[2]; - v[0][bcNodeId]=exactSolution(x, y, z); - - } // end loop over boundary nodes - - if(MyPID==0) {std::cout << "Get Dirichlet boundary values " - << Time.ElapsedTime() << " sec \n\n"; Time.ResetStartTime();} - - -/**********************************************************************************/ -/******************** DEFINE WORKSETS AND LOOP OVER THEM **************************/ -/**********************************************************************************/ - - // Define desired workset size and count how many worksets there are on this processor's mesh block - int desiredWorksetSize = numElems; // change to desired workset size! - //int desiredWorksetSize = 100; // change to desired workset size! - int numWorksets = numElems/desiredWorksetSize; - - // When numElems is not divisible by desiredWorksetSize, increase workset count by 1 - if(numWorksets*desiredWorksetSize < numElems) numWorksets += 1; - - if (MyPID == 0) { - std::cout << "\tDesired workset size: " << desiredWorksetSize <<"\n"; - std::cout << "\tNumber of worksets (per processor): " << numWorksets <<"\n\n"; - Time.ResetStartTime(); - } - - for(int workset = 0; workset < numWorksets; workset++){ - - // compute cell numbers where the workset starts and ends - int worksetSize = 0; - int worksetBegin = (workset + 0)*desiredWorksetSize; - int worksetEnd = (workset + 1)*desiredWorksetSize; - - // when numElems is not divisible by desiredWorksetSize, the last workset ends at numElems - worksetEnd = (worksetEnd <= numElems) ? worksetEnd : numElems; - - // allocate the array for the cell nodes - worksetSize = worksetEnd - worksetBegin; - Intrepid::FieldContainer cellWorkset(worksetSize, numNodesPerElem, spaceDim); - - // copy coordinates into cell workset - int cellCounter = 0; - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // Get element entity from id of cell - stk_classic::mesh::Entity * worksetElem = bulkData.get_entity(elementRank,cell+1); - - // get nodes attached to this element - const stk_classic::mesh::PairIterRelation worksetNodes = worksetElem->relations(nodeRank); - - // loop over nodes and get coordinates to fill workset array - for (size_t i = 0; i < worksetNodes.size(); i++) { - double * coord = stk_classic::mesh::field_data(*coords, *worksetNodes[i].entity()); - cellWorkset(cellCounter, i, 0) = coord[0]; - cellWorkset(cellCounter, i, 1) = coord[1]; - cellWorkset(cellCounter, i, 2) = coord[2]; - } - - cellCounter++; - - } // end cell loop - - /**********************************************************************************/ - /* Allocate arrays */ - /**********************************************************************************/ - - // Containers for Jacobians, integration measure & cubature points in workset cells - Intrepid::FieldContainer worksetJacobian (worksetSize, numCubPoints, spaceDim, spaceDim); - Intrepid::FieldContainer worksetJacobInv (worksetSize, numCubPoints, spaceDim, spaceDim); - Intrepid::FieldContainer worksetJacobDet (worksetSize, numCubPoints); - Intrepid::FieldContainer worksetCubWeights(worksetSize, numCubPoints); - Intrepid::FieldContainer worksetCubPoints (worksetSize, numCubPoints, cubDim); - - // Containers for basis values transformed to workset cells and them multiplied by cubature weights - Intrepid::FieldContainer worksetBasisValues (worksetSize, numFieldsG, numCubPoints); - Intrepid::FieldContainer worksetBasisValuesWeighted(worksetSize, numFieldsG, numCubPoints); - Intrepid::FieldContainer worksetBasisGrads (worksetSize, numFieldsG, numCubPoints, spaceDim); - Intrepid::FieldContainer worksetBasisGradsWeighted (worksetSize, numFieldsG, numCubPoints, spaceDim); - - // Containers for diffusive & advective fluxes & non-conservative adv. term and reactive terms - Intrepid::FieldContainer worksetDiffusiveFlux(worksetSize, numFieldsG, numCubPoints, spaceDim); - - // Containers for material values and source term. Require user-defined functions - Intrepid::FieldContainer worksetMaterialVals (worksetSize, numCubPoints, spaceDim, spaceDim); - Intrepid::FieldContainer worksetSourceTerm (worksetSize, numCubPoints); - - // Containers for workset contributions to the discretization matrix and the right hand side - Intrepid::FieldContainer worksetStiffMatrix (worksetSize, numFieldsG, numFieldsG); - Intrepid::FieldContainer worksetRHS (worksetSize, numFieldsG); - - if(MyPID==0) {std::cout << "Allocate arrays " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - - - /**********************************************************************************/ - /* Calculate Jacobians */ - /**********************************************************************************/ - - IntrepidCTools::setJacobian(worksetJacobian, cubPoints, cellWorkset, cellType); - IntrepidCTools::setJacobianInv(worksetJacobInv, worksetJacobian ); - IntrepidCTools::setJacobianDet(worksetJacobDet, worksetJacobian ); - - if(MyPID==0) {std::cout << "Calculate Jacobians " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - - /**********************************************************************************/ - /* Cubature Points to Physical Frame and Compute Data */ - /**********************************************************************************/ - - // map cubature points to physical frame - IntrepidCTools::mapToPhysicalFrame (worksetCubPoints, cubPoints, cellWorkset, cellType); - - // get A at cubature points - evaluateMaterialTensor (worksetMaterialVals, worksetCubPoints); - - // get source term at cubature points - evaluateSourceTerm (worksetSourceTerm, worksetCubPoints); - - if(MyPID==0) {std::cout << "Map to physical frame and get source term " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - - /**********************************************************************************/ - /* Compute Stiffness Matrix */ - /**********************************************************************************/ - - // Transform basis gradients to physical frame: DF^{-T}(grad u) - IntrepidFSTools::HGRADtransformGRAD(worksetBasisGrads, - worksetJacobInv, basisGrads); - - // Compute integration measure for workset cells: Det(DF)*w = J*w - IntrepidFSTools::computeCellMeasure(worksetCubWeights, - worksetJacobDet, cubWeights); - - - // Multiply transformed (workset) gradients with weighted measure: DF^{-T}(grad u)*J*w - IntrepidFSTools::multiplyMeasure(worksetBasisGradsWeighted, - worksetCubWeights, worksetBasisGrads); - - - // Compute material tensor applied to basis grads: A*(DF^{-T}(grad u) - IntrepidFSTools::tensorMultiplyDataField(worksetDiffusiveFlux, - worksetMaterialVals, - worksetBasisGrads); - - // Integrate to compute contribution to global stiffness matrix: (DF^{-T}(grad u)*J*w)*(A*DF^{-T}(grad u)) - IntrepidFSTools::integrate(worksetStiffMatrix, - worksetBasisGradsWeighted, - worksetDiffusiveFlux, Intrepid::COMP_BLAS); - - if(MyPID==0) {std::cout << "Compute stiffness matrix " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - /**********************************************************************************/ - /* Compute RHS */ - /**********************************************************************************/ - - // Transform basis values to physical frame: clones basis values (u) - IntrepidFSTools::HGRADtransformVALUE(worksetBasisValues, - basisValues); - - // Multiply transformed (workset) values with weighted measure: (u)*J*w - IntrepidFSTools::multiplyMeasure(worksetBasisValuesWeighted, - worksetCubWeights, worksetBasisValues); - - // Integrate worksetSourceTerm against weighted basis function set: f.(u)*J*w - IntrepidFSTools::integrate(worksetRHS, - worksetSourceTerm, - worksetBasisValuesWeighted, Intrepid::COMP_BLAS); - - if(MyPID==0) {std::cout << "Compute right-hand side " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - - /**********************************************************************************/ - /* Assemble into Global Matrix */ - /**********************************************************************************/ - - //"WORKSET CELL" loop: local cell ordinal is relative to numElems - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // Compute cell ordinal relative to the current workset - int worksetCellOrdinal = cell - worksetBegin; - - // Get element entity from id of cell - stk_classic::mesh::Entity * worksetElem = bulkData.get_entity(elementRank,cell+1); - - // get nodes attached to this element - const stk_classic::mesh::PairIterRelation worksetNodes = worksetElem->relations(nodeRank); - - // "CELL EQUATION" loop for the workset cell: cellRow is relative to the cell DoF numbering - for (int cellRow = 0; cellRow < numFieldsG; cellRow++){ - - int globalRow = worksetNodes[cellRow].entity()->identifier() - 1; - double sourceTermContribution = worksetRHS(worksetCellOrdinal, cellRow); - rhsVector.SumIntoGlobalValues(1, &globalRow, &sourceTermContribution); - - // "CELL VARIABLE" loop for the workset cell: cellCol is relative to the cell DoF numbering - for (int cellCol = 0; cellCol < numFieldsG; cellCol++){ - - int globalCol = worksetNodes[cellCol].entity()->identifier() - 1; - double operatorMatrixContribution = worksetStiffMatrix(worksetCellOrdinal, cellRow, cellCol); - StiffMatrix.InsertGlobalValues(1, &globalRow, 1, &globalCol, &operatorMatrixContribution); - - }// end cell col loop - - }// end cell row loop - - }// end workset cell loop - - } // end workset loop - - StiffMatrix.GlobalAssemble(); - StiffMatrix.FillComplete(); - rhsVector.GlobalAssemble(); - - if(MyPID==0) {std::cout << "Global assembly " - << Time.ElapsedTime() << " sec \n"; Time.ResetStartTime();} - -/**********************************************************************************/ -/************************ ADJUST MATRIX AND RHS FOR BCs ***************************/ -/**********************************************************************************/ - - // Apply stiffness matrix to v - Epetra_MultiVector rhsDir(globalMapG,true); - StiffMatrix.Apply(v,rhsDir); - - // Update right-hand side - rhsVector.Update(-1.0,rhsDir,1.0); - - // Loop over boundary nodes and replace rhs values with boundary values - for (size_t i = 0; i < bcNodes.size(); i++) { - - int bcNodeId = bcNodes[i]->identifier() - 1; - rhsVector[0][bcNodeId]=v[0][bcNodeId]; - - } // end loop over boundary nodes - - // Zero out rows and columns of stiffness matrix corresponding to Dirichlet edges - // and add one to diagonal. - ML_Epetra::Apply_OAZToMatrix(bcNodeVec, bcNodes.size(), StiffMatrix); - - delete [] bcNodeVec; - - if(MyPID==0) {std::cout << "Adjust global matrix and rhs due to BCs " << Time.ElapsedTime() - << " sec \n"; Time.ResetStartTime();} - -#ifdef DUMP_DATA - // Dump matrices to disk - EpetraExt::RowMatrixToMatlabFile("stiff_matrix.dat",StiffMatrix); - EpetraExt::MultiVectorToMatrixMarketFile("rhs_vector.dat",rhsVector,0,0,false); -#endif - -/**********************************************************************************/ -/*********************************** SOLVE ****************************************/ -/**********************************************************************************/ - - // Run the solver - Teuchos::ParameterList MLList = inputSolverList; - ML_Epetra::SetDefaults("SA", MLList, 0, 0, false); - Epetra_FEVector exactNodalVals(globalMapG); - Epetra_FEVector femCoefficients(globalMapG); - double TotalErrorResidual = 0.0; - double TotalErrorExactSol = 0.0; - - // Get exact solution at nodes - for (unsigned inode = 0; inode < nodes.size(); inode++) { - - int nodeId = nodes[inode]->identifier() - 1; - - // get coordinates for this node - stk_classic::mesh::Entity * currentNode = bulkData.get_entity(nodeRank,nodes[inode]->identifier()); - double * coord = stk_classic::mesh::field_data(*coords, *currentNode); - - // look up exact value of function - double x = coord[0]; - double y = coord[1]; - double z = coord[2]; - exactNodalVals[0][nodeId]=exactSolution(x, y, z); - - } // end loop over nodes - - exactNodalVals.GlobalAssemble(); - - char probType[10] = "laplace"; - - TestMultiLevelPreconditioner(probType, MLList, - StiffMatrix, exactNodalVals, - rhsVector, femCoefficients, - TotalErrorResidual, TotalErrorExactSol); - - -/**********************************************************************************/ -/**************************** CALCULATE ERROR *************************************/ -/**********************************************************************************/ - - if (MyPID == 0) {Time.ResetStartTime();} - - double L2err = 0.0; - double L2errTot = 0.0; - double H1err = 0.0; - double H1errTot = 0.0; - double Linferr = 0.0; - double LinferrTot = 0.0; - -#ifdef HAVE_MPI - // Import solution onto current processor - // FIXME - int numNodesGlobal = globalMapG.NumGlobalElements(); - Epetra_Map solnMap(numNodesGlobal, numNodesGlobal, 0, Comm); - Epetra_Import solnImporter(solnMap, globalMapG); - Epetra_Vector uCoeff(solnMap); - uCoeff.Import(femCoefficients, solnImporter, Insert); -#endif - - // Define desired workset size - desiredWorksetSize = numElems; - int numWorksetsErr = numElems/desiredWorksetSize; - - // When numElems is not divisible by desiredWorksetSize, increase workset count by 1 - if(numWorksetsErr*desiredWorksetSize < numElems) numWorksetsErr += 1; - - // Get cubature points and weights for error calc (may be different from previous) - Intrepid::DefaultCubatureFactory cubFactoryErr; - int cubDegErr = 3; - Teuchos::RCP > cellCubatureErr = cubFactoryErr.create(cellType, cubDegErr); - int cubDimErr = cellCubatureErr->getDimension(); - int numCubPointsErr = cellCubatureErr->getNumPoints(); - Intrepid::FieldContainer cubPointsErr(numCubPointsErr, cubDimErr); - Intrepid::FieldContainer cubWeightsErr(numCubPointsErr); - cellCubatureErr->getCubature(cubPointsErr, cubWeightsErr); - - // Evaluate basis values and gradients at cubature points - Intrepid::FieldContainer uhGVals(numFieldsG, numCubPointsErr); - Intrepid::FieldContainer uhGrads(numFieldsG, numCubPointsErr, spaceDim); - HGradBasis->getValues(uhGVals, cubPointsErr, Intrepid::OPERATOR_VALUE); - HGradBasis->getValues(uhGrads, cubPointsErr, Intrepid::OPERATOR_GRAD); - - // Loop over worksets - for(int workset = 0; workset < numWorksetsErr; workset++){ - - // compute cell numbers where the workset starts and ends - int worksetSize = 0; - int worksetBegin = (workset + 0)*desiredWorksetSize; - int worksetEnd = (workset + 1)*desiredWorksetSize; - - // when numElems is not divisible by desiredWorksetSize, the last workset ends at numElems - worksetEnd = (worksetEnd <= numElems) ? worksetEnd : numElems; - - // now we know the actual workset size and can allocate the array for the cell nodes - worksetSize = worksetEnd - worksetBegin; - Intrepid::FieldContainer cellWorksetEr(worksetSize, numNodesPerElem, spaceDim); - Intrepid::FieldContainer worksetApproxSolnCoef(worksetSize, numNodesPerElem); - - // loop over cells to fill arrays with coordinates and calculation solution coefficient - int cellCounter = 0; - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // Get element entity from id of cell - stk_classic::mesh::Entity * worksetElem = bulkData.get_entity(elementRank,cell+1); - - // get nodes attached to this element - const stk_classic::mesh::PairIterRelation worksetNodes = worksetElem->relations(nodeRank); - - // loop over nodes and get coordinates to fill workset array - for (size_t i = 0; i < worksetNodes.size(); i++) { - double * coord = stk_classic::mesh::field_data(*coords, *worksetNodes[i].entity()); - cellWorksetEr(cellCounter, i, 0) = coord[0]; - cellWorksetEr(cellCounter, i, 1) = coord[1]; - cellWorksetEr(cellCounter, i, 2) = coord[2]; - int rowIndex = worksetNodes[i].entity()->identifier() - 1; -#ifdef HAVE_MPI - worksetApproxSolnCoef(cellCounter, i) = uCoeff.Values()[rowIndex]; -#else - worksetApproxSolnCoef(cellCounter, i) = femCoefficients.Values()[rowIndex]; -#endif - } - - cellCounter++; - - } // end cell loop - - // Containers for Jacobian - Intrepid::FieldContainer worksetJacobianE(worksetSize, numCubPointsErr, spaceDim, spaceDim); - Intrepid::FieldContainer worksetJacobInvE(worksetSize, numCubPointsErr, spaceDim, spaceDim); - Intrepid::FieldContainer worksetJacobDetE(worksetSize, numCubPointsErr); - Intrepid::FieldContainer worksetCubWeightsE(worksetSize, numCubPointsErr); - - // Containers for basis values and gradients in physical space - Intrepid::FieldContainer uhGValsTrans(worksetSize,numFieldsG, numCubPointsErr); - Intrepid::FieldContainer uhGradsTrans(worksetSize, numFieldsG, numCubPointsErr, spaceDim); - - // compute cell Jacobians, their inverses and their determinants - IntrepidCTools::setJacobian(worksetJacobianE, cubPointsErr, cellWorksetEr, cellType); - IntrepidCTools::setJacobianInv(worksetJacobInvE, worksetJacobianE ); - IntrepidCTools::setJacobianDet(worksetJacobDetE, worksetJacobianE ); - - // map cubature points to physical frame - Intrepid::FieldContainer worksetCubPoints(worksetSize, numCubPointsErr, cubDimErr); - IntrepidCTools::mapToPhysicalFrame(worksetCubPoints, cubPointsErr, cellWorksetEr, cellType); - - // evaluate exact solution and gradient at cubature points - Intrepid::FieldContainer worksetExactSoln(worksetSize, numCubPointsErr); - Intrepid::FieldContainer worksetExactSolnGrad(worksetSize, numCubPointsErr, spaceDim); - evaluateExactSolution(worksetExactSoln, worksetCubPoints); - evaluateExactSolutionGrad(worksetExactSolnGrad, worksetCubPoints); - - // transform basis values to physical coordinates - IntrepidFSTools::HGRADtransformVALUE(uhGValsTrans, uhGVals); - IntrepidFSTools::HGRADtransformGRAD(uhGradsTrans, worksetJacobInvE, uhGrads); - - // compute weighted measure - IntrepidFSTools::computeCellMeasure(worksetCubWeightsE, worksetJacobDetE, cubWeightsErr); - - // evaluate the approximate solution and gradient at cubature points - Intrepid::FieldContainer worksetApproxSoln(worksetSize, numCubPointsErr); - Intrepid::FieldContainer worksetApproxSolnGrad(worksetSize, numCubPointsErr, spaceDim); - IntrepidFSTools::evaluate(worksetApproxSoln, worksetApproxSolnCoef, uhGValsTrans); - IntrepidFSTools::evaluate(worksetApproxSolnGrad, worksetApproxSolnCoef, uhGradsTrans); - - // get difference between approximate and exact solutions - Intrepid::FieldContainer worksetDeltaSoln(worksetSize, numCubPointsErr); - Intrepid::FieldContainer worksetDeltaSolnGrad(worksetSize, numCubPointsErr, spaceDim); - IntrepidRSTools::subtract(worksetDeltaSoln, worksetApproxSoln, worksetExactSoln); - IntrepidRSTools::subtract(worksetDeltaSolnGrad, worksetApproxSolnGrad, worksetExactSolnGrad); - - // take absolute values - IntrepidRSTools::absval(worksetDeltaSoln); - IntrepidRSTools::absval(worksetDeltaSolnGrad); - - // apply cubature weights to differences in values and grads for use in integration - Intrepid::FieldContainer worksetDeltaSolnWeighted(worksetSize, numCubPointsErr); - Intrepid::FieldContainer worksetDeltaSolnGradWeighted(worksetSize, numCubPointsErr, spaceDim); - IntrepidFSTools::scalarMultiplyDataData(worksetDeltaSolnWeighted, - worksetCubWeightsE, worksetDeltaSoln); - IntrepidFSTools::scalarMultiplyDataData(worksetDeltaSolnGradWeighted, - worksetCubWeightsE, worksetDeltaSolnGrad); - - // integrate to get errors on each element - Intrepid::FieldContainer worksetL2err(worksetSize); - Intrepid::FieldContainer worksetH1err(worksetSize); - IntrepidFSTools::integrate(worksetL2err, worksetDeltaSoln, - worksetDeltaSolnWeighted, Intrepid::COMP_BLAS); - IntrepidFSTools::integrate(worksetH1err, worksetDeltaSolnGrad, - worksetDeltaSolnGradWeighted, Intrepid::COMP_BLAS); - - // loop over cells to get errors for total workset - cellCounter = 0; - for(int cell = worksetBegin; cell < worksetEnd; cell++){ - - // loop over cubature points - for(int nPt = 0; nPt < numCubPointsErr; nPt++){ - - Linferr = std::max(Linferr, worksetDeltaSoln(cellCounter,nPt)); - - } - - L2err += worksetL2err(cellCounter); - H1err += worksetH1err(cellCounter); - - cellCounter++; - - } // end cell loop - - } // end loop over worksets - - -#ifdef HAVE_MPI - // sum over all processors - Comm.SumAll(&L2err,&L2errTot,1); - Comm.SumAll(&H1err,&H1errTot,1); - Comm.MaxAll(&Linferr,&LinferrTot,1); -#else - L2errTot = L2err; - H1errTot = H1err; - LinferrTot = Linferr; -#endif - - if (MyPID == 0) { - std::cout << "\n" << "L2 Error: " << sqrt(L2errTot) <<"\n"; - std::cout << "H1 Error: " << sqrt(H1errTot) <<"\n"; - std::cout << "LInf Error: " << LinferrTot <<"\n\n"; - } - - - if(MyPID==0) {std::cout << "Calculate error " - << Time.ElapsedTime() << " s \n"; Time.ResetStartTime();} - - - return 0; - -} -/**********************************************************************************/ -/********************************* END MAIN ***************************************/ -/**********************************************************************************/ - -/**********************************************************************************/ -/************ USER DEFINED FUNCTIONS FOR EXACT SOLUTION ***************************/ -/**********************************************************************************/ - -template -const Scalar exactSolution(const Scalar& x, const Scalar& y, const Scalar& z) { - - // Patch test - tet: function is in the FE space and should be recovered - return 1. + x + y + z ; - - // Patch test - hex: tri-linear function is in the FE space and should be recovered - // return 1. + x + y + z + x*y + x*z + y*z + x*y*z; - - // Analytic solution with homogeneous Dirichlet boundary data for [0 1]x[0 1]x[0 1] - // return sin(M_PI*x)*sin(M_PI*y)*sin(M_PI*z)*exp(x+y+z); - - // Analytic solution with inhomogeneous Dirichlet boundary data - // return exp(x + y + z)/(1. + x*y + y*z + x*y*z); -} - - -template -void materialTensor(Scalar material[][3], const Scalar& x, const Scalar& y, const Scalar& z) { - - material[0][0] = 1.; - material[0][1] = 0.; - material[0][2] = 0.; - // - material[1][0] = 0.; - material[1][1] = 1.; - material[1][2] = 0.; - // - material[2][0] = 0.; - material[2][1] = 0.; - material[2][2] = 1.; -} - -/**********************************************************************************/ -/************** AUXILIARY FUNCTIONS FROM EXACT SOLUTION ***************************/ -/**********************************************************************************/ - -/************ Grad of Exact Solution ****************/ -template -void exactSolutionGrad(Scalar gradExact[3], const Scalar& x, const Scalar& y, const Scalar& z) { - - // To enable derivatives of the gradient (i.e., 2nd derivatives of the exact solution) need 2 levels of fad types - Sacado::Fad::SFad fad_x = x; - Sacado::Fad::SFad fad_y = y; - Sacado::Fad::SFad fad_z = z; - Sacado::Fad::SFad u; - - // Indicate the independent variables - fad_x.diff(0,3); - fad_y.diff(1,3); - fad_z.diff(2,3); - - u = exactSolution(fad_x, fad_y, fad_z); - - gradExact[0] = u.dx(0); - gradExact[1] = u.dx(1); - gradExact[2] = u.dx(2); -} - -/************ Source Term (RHS) ****************/ -template -const Scalar sourceTerm(Scalar& x, Scalar& y, Scalar& z){ - - Scalar u; - Scalar grad_u[3]; - Scalar flux[3]; - Scalar material[3][3]; - Scalar f = 0.; - - // Indicate the independent variables - x.diff(0,3); - y.diff(1,3); - z.diff(2,3); - - // Get exact solution and its gradient - u = exactSolution(x, y, z); - exactSolutionGrad(grad_u, x, y, z); - - // Get material tensor - materialTensor(material, x, y, z); - - // Compute total flux = (A.grad u) - for(int i = 0; i < 3; i++){ - - // Add diffusive flux - for(int j = 0; j < 3; j++){ - flux[i] += material[i][j]*grad_u[j]; - } - } - - // Compute source term (right hand side): f = -div(A.grad u) - f = -(flux[0].dx(0) + flux[1].dx(1) + flux[2].dx(2)); - - return f; -} - -/**********************************************************************************/ -/*************************** EVALUATION METHODS ***********************************/ -/**********************************************************************************/ - -/************ Material Tensor ****************/ -template -void evaluateMaterialTensor(ArrayOut & matTensorValues, - const ArrayIn & evaluationPoints){ - - int numWorksetCells = evaluationPoints.dimension(0); - int numPoints = evaluationPoints.dimension(1); - int spaceDim = evaluationPoints.dimension(2); - - double material[3][3]; - - for(int cell = 0; cell < numWorksetCells; cell++){ - for(int pt = 0; pt < numPoints; pt++){ - - double x = evaluationPoints(cell, pt, 0); - double y = evaluationPoints(cell, pt, 1); - double z = evaluationPoints(cell, pt, 2); - - materialTensor(material, x, y, z); - - for(int row = 0; row < spaceDim; row++){ - for(int col = 0; col < spaceDim; col++){ - matTensorValues(cell, pt, row, col) = material[row][col]; - } - } - } - } -} - -/************ Source Term (RHS) ****************/ -template -void evaluateSourceTerm(ArrayOut & sourceTermValues, - const ArrayIn & evaluationPoints){ - - int numWorksetCells = evaluationPoints.dimension(0); - int numPoints = evaluationPoints.dimension(1); - - for(int cell = 0; cell < numWorksetCells; cell++){ - for(int pt = 0; pt < numPoints; pt++){ - - Sacado::Fad::SFad x = evaluationPoints(cell, pt, 0); - Sacado::Fad::SFad y = evaluationPoints(cell, pt, 1); - Sacado::Fad::SFad z = evaluationPoints(cell, pt, 2); - - sourceTermValues(cell, pt) = sourceTerm >(x, y, z).val(); - } - } -} - -/************ Exact Solution ****************/ -template -void evaluateExactSolution(ArrayOut & exactSolutionValues, - const ArrayIn & evaluationPoints){ - - int numWorksetCells = evaluationPoints.dimension(0); - int numPoints = evaluationPoints.dimension(1); - - for(int cell = 0; cell < numWorksetCells; cell++){ - for(int pt = 0; pt < numPoints; pt++){ - - double x = evaluationPoints(cell, pt, 0); - double y = evaluationPoints(cell, pt, 1); - double z = evaluationPoints(cell, pt, 2); - - exactSolutionValues(cell, pt) = exactSolution(x, y, z); - } - } -} - - -/************ Grad of Exact Solution ****************/ -template -void evaluateExactSolutionGrad(ArrayOut & exactSolutionGradValues, - const ArrayIn & evaluationPoints){ - - int numWorksetCells = evaluationPoints.dimension(0); - int numPoints = evaluationPoints.dimension(1); - int spaceDim = evaluationPoints.dimension(2); - - double gradient[3]; - - for(int cell = 0; cell < numWorksetCells; cell++){ - for(int pt = 0; pt < numPoints; pt++){ - - double x = evaluationPoints(cell, pt, 0); - double y = evaluationPoints(cell, pt, 1); - double z = evaluationPoints(cell, pt, 2); - - exactSolutionGrad(gradient, x, y, z); - - for(int row = 0; row < spaceDim; row++){ - exactSolutionGradValues(cell, pt, row) = gradient[row]; - } - } - } -} - -/**********************************************************************************/ -/******************************* TEST ML ******************************************/ -/**********************************************************************************/ - -// Test ML -int TestMultiLevelPreconditioner(char ProblemType[], - Teuchos::ParameterList & MLList, - Epetra_CrsMatrix & A, - const Epetra_MultiVector & xexact, - Epetra_MultiVector & b, - Epetra_MultiVector & uh, - double & TotalErrorResidual, - double & TotalErrorExactSol) -{ - Epetra_MultiVector x(xexact); - x.PutScalar(0.0); - - Epetra_LinearProblem Problem(&A,&x,&b); - Epetra_MultiVector* lhs = Problem.GetLHS(); - Epetra_MultiVector* rhs = Problem.GetRHS(); - - Epetra_Time Time(A.Comm()); - - // =================== // - // call ML and AztecOO // - // =================== // - - AztecOO solver(Problem); - ML_Epetra::MultiLevelPreconditioner *MLPrec = new ML_Epetra::MultiLevelPreconditioner(A, MLList, true); - - // tell AztecOO to use this preconditioner, then solve - solver.SetPrecOperator(MLPrec); - solver.SetAztecOption(AZ_solver, AZ_cg); - solver.SetAztecOption(AZ_output, 1); - - solver.Iterate(200, 1e-10); - - delete MLPrec; - - uh = *lhs; - - // ==================================================== // - // compute difference between exact solution and ML one // - // ==================================================== // - double d = 0.0, d_tot = 0.0; - for( int i=0 ; iMap().NumMyElements() ; ++i ) - d += ((*lhs)[0][i] - xexact[0][i]) * ((*lhs)[0][i] - xexact[0][i]); - - A.Comm().SumAll(&d,&d_tot,1); - - // ================== // - // compute ||Ax - b|| // - // ================== // - double Norm; - Epetra_Vector Ax(rhs->Map()); - A.Multiply(false, *lhs, Ax); - Ax.Update(1.0, *rhs, -1.0); - Ax.Norm2(&Norm); - - std::string msg = ProblemType; - - if (A.Comm().MyPID() == 0) { - std::cout << msg << std::endl << "......Using " << A.Comm().NumProc() << " processes" << std::endl; - std::cout << msg << "......||A x - b||_2 = " << Norm << std::endl; - std::cout << msg << "......||x_exact - x||_2 = " << sqrt(d_tot) << std::endl; - std::cout << msg << "......Total Time = " << Time.ElapsedTime() << std::endl << std::endl; - } - - TotalErrorExactSol += sqrt(d_tot); - TotalErrorResidual += Norm; - - return( solver.NumIters() ); - -} - -/**********************************************************************************/ -/**************************** SIMPLE BASIS FACTORY ********************************/ -/**********************************************************************************/ - - -void getBasis(Teuchos::RCP > > &basis, - const shards::CellTopology & cellTopology, - int order) { - - - // select basis based on cell topology only for now, and assume first order basis - switch (cellTopology.getKey()) { - - case shards::Tetrahedron<4>::key: - basis = Teuchos::rcp(new Intrepid::Basis_HGRAD_TET_C1_FEM > ); - break; - - case shards::Hexahedron<8>::key: - basis = Teuchos::rcp(new Intrepid::Basis_HGRAD_HEX_C1_FEM > ); - break; - - default: - TEUCHOS_TEST_FOR_EXCEPTION( ( (cellTopology.getKey() != shards::Tetrahedron<4>::key) && - (cellTopology.getKey() != shards::Hexahedron<8>::key) ), - std::invalid_argument, - "Unknown cell topology for basis selction. Please use Hexahedron_8 or Tetrahedron_4."); - - } - -} - - - - -